mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
When inserting a link, preserve the currently selected text, if any
This commit is contained in:
parent
5196b29005
commit
a31474804f
@ -539,6 +539,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
||||
url = unicode_type(url.toString(NO_URL_FORMATTING))
|
||||
self.focus_self()
|
||||
with self.editing_cursor() as c:
|
||||
selected_text = c.selectedText()
|
||||
if is_image:
|
||||
c.insertImage(url)
|
||||
else:
|
||||
@ -550,7 +551,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
|
||||
fmt.setForeground(QBrush(QColor('blue')))
|
||||
prev_fmt = c.charFormat()
|
||||
c.mergeCharFormat(fmt)
|
||||
c.insertText(url)
|
||||
c.insertText(selected_text or url)
|
||||
c.setCharFormat(prev_fmt)
|
||||
else:
|
||||
error_dialog(self, _('Invalid URL'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user