diff --git a/resources/compiled_coffeescript.zip b/resources/compiled_coffeescript.zip index 65c3b78952..bd1e285820 100644 Binary files a/resources/compiled_coffeescript.zip and b/resources/compiled_coffeescript.zip differ diff --git a/src/calibre/ebooks/oeb/polish/preview.coffee b/src/calibre/ebooks/oeb/polish/preview.coffee index 8792ae891a..3dafdedd71 100644 --- a/src/calibre/ebooks/oeb/polish/preview.coffee +++ b/src/calibre/ebooks/oeb/polish/preview.coffee @@ -174,7 +174,7 @@ get_style_properties = (style, all_properties, node_style, is_ancestor) -> process_rules = (node, cssRules, address, sheet, sheet_index, matching_selectors, all_properties, node_style, is_ancestor, ans) -> for rule, rule_index in cssRules - rule_address = address + [rule_index] + rule_address = address.concat([rule_index]) if rule.type == CSSRule.MEDIA_RULE process_rules(node, rule.cssRules, rule_address, sheet, sheet_index, matching_selectors, all_properties, node_style, is_ancestor, ans) continue diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 3e352fb0e0..78885afd9f 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -118,6 +118,7 @@ class Boss(QObject): self.gui.spell_check.refresh_requested.connect(self.commit_all_editors_to_container) self.gui.spell_check.word_replaced.connect(self.word_replaced) self.gui.spell_check.word_ignored.connect(self.word_ignored) + self.gui.live_css.goto_declaration.connect(self.goto_style_declaration) def preferences(self): p = Preferences(self.gui) @@ -1037,6 +1038,11 @@ class Boss(QObject): if name is not None and getattr(ed, 'syntax', None) == 'html': self.gui.live_css.sync_to_editor(name) + def goto_style_declaration(self, data): + name = data['name'] + editor = self.edit_file(name, syntax=data['syntax']) + self.gui.live_css.navigate_to_declaration(data, editor) + def init_editor(self, name, editor, data=None, use_template=False): editor.undo_redo_state_changed.connect(self.editor_undo_redo_state_changed) editor.data_changed.connect(self.editor_data_changed) diff --git a/src/calibre/gui2/tweak_book/live_css.py b/src/calibre/gui2/tweak_book/live_css.py index 08eadd045c..f72d98d4e1 100644 --- a/src/calibre/gui2/tweak_book/live_css.py +++ b/src/calibre/gui2/tweak_book/live_css.py @@ -112,6 +112,8 @@ class Cell(object): # {{{ class Declaration(QWidget): + hyperlink_activated = pyqtSignal(object) + def __init__(self, html_name, data, is_first=False, parent=None): QWidget.__init__(self, parent) self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) @@ -197,6 +199,27 @@ class Declaration(QWidget): self.setCursor(cursor) return QWidget.mouseMoveEvent(self, ev) + def mousePressEvent(self, ev): + if hasattr(self, 'hyperlink_rect'): + pos = ev.pos() + if self.hyperlink_rect.contains(pos): + self.emit_hyperlink_activated() + return QWidget.mouseMoveEvent(self, ev) + + def emit_hyperlink_activated(self): + dt = self.data['type'] + data = {'type':dt, 'name':self.html_name, 'syntax':'html'} + if dt == 'inline': # style attribute + data['sourceline_address'] = self.data['href'] + elif dt == 'elem': #