mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Allow removing the currently highlighted tag (while keeping its contents) by pressing Ctrl+>. You can also add a tool to do it via Preferences->Toolbars
This commit is contained in:
parent
81f1d44454
commit
668e208611
@ -350,6 +350,20 @@ class Smarts(NullSmarts):
|
|||||||
editor.setTextCursor(c)
|
editor.setTextCursor(c)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def remove_tag(self, editor):
|
||||||
|
editor.highlighter.join()
|
||||||
|
|
||||||
|
def erase_tag(tag):
|
||||||
|
c = editor.textCursor()
|
||||||
|
c.setPosition(tag.start_block.position() + tag.start_offset)
|
||||||
|
c.setPosition(tag.end_block.position() + tag.end_offset + 1, c.KeepAnchor)
|
||||||
|
c.removeSelectedText()
|
||||||
|
|
||||||
|
if self.last_matched_closing_tag:
|
||||||
|
erase_tag(self.last_matched_closing_tag)
|
||||||
|
if self.last_matched_tag:
|
||||||
|
erase_tag(self.last_matched_tag)
|
||||||
|
|
||||||
def rename_block_tag(self, editor, new_name):
|
def rename_block_tag(self, editor, new_name):
|
||||||
editor.highlighter.join()
|
editor.highlighter.join()
|
||||||
c = editor.textCursor()
|
c = editor.textCursor()
|
||||||
|
@ -877,6 +877,10 @@ version="1.1" width="100%%" height="100%%" viewBox="0 0 {w} {h}" preserveAspectR
|
|||||||
if hasattr(self.smarts, 'insert_tag'):
|
if hasattr(self.smarts, 'insert_tag'):
|
||||||
self.smarts.insert_tag(self, tag)
|
self.smarts.insert_tag(self, tag)
|
||||||
|
|
||||||
|
def remove_tag(self):
|
||||||
|
if hasattr(self.smarts, 'remove_tag'):
|
||||||
|
self.smarts.remove_tag(self)
|
||||||
|
|
||||||
def keyPressEvent(self, ev):
|
def keyPressEvent(self, ev):
|
||||||
if ev.key() == Qt.Key_X and ev.modifiers() == Qt.AltModifier:
|
if ev.key() == Qt.Key_X and ev.modifiers() == Qt.AltModifier:
|
||||||
if self.replace_possible_unicode_sequence():
|
if self.replace_possible_unicode_sequence():
|
||||||
|
@ -112,6 +112,9 @@ def register_text_editor_actions(_reg, palette):
|
|||||||
ac = reg('code.png', _('Insert &tag'), ('insert_tag',), 'insert-tag', ('Ctrl+<'), _('Insert tag'), syntaxes=('html', 'xml'))
|
ac = reg('code.png', _('Insert &tag'), ('insert_tag',), 'insert-tag', ('Ctrl+<'), _('Insert tag'), syntaxes=('html', 'xml'))
|
||||||
ac.setToolTip(_('<h3>Insert tag</h3>Insert a tag, if some text is selected the tag will be inserted around the selected text'))
|
ac.setToolTip(_('<h3>Insert tag</h3>Insert a tag, if some text is selected the tag will be inserted around the selected text'))
|
||||||
|
|
||||||
|
ac = reg('trash.png', _('Remove &tag'), ('remove_tag',), 'remove-tag', ('Ctrl+>'), _('Remove tag'), syntaxes=('html', 'xml'))
|
||||||
|
ac.setToolTip(_('<h3>Remove tag</h3>Remove the currently highlighted tag'))
|
||||||
|
|
||||||
editor_toolbar_actions['html']['fix-html-current'] = actions['fix-html-current']
|
editor_toolbar_actions['html']['fix-html-current'] = actions['fix-html-current']
|
||||||
for s in ('xml', 'html', 'css'):
|
for s in ('xml', 'html', 'css'):
|
||||||
editor_toolbar_actions[s]['pretty-current'] = actions['pretty-current']
|
editor_toolbar_actions[s]['pretty-current'] = actions['pretty-current']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user