From 34f28d22ddc1dbdce02ae206cd072597752885ac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 27 Feb 2017 20:39:24 +0530 Subject: [PATCH] Edit book: Fix a regression that caused pasting copied text from programs that generate both HTML and plain text when copying to paste the HTML in preference to the plain text --- src/calibre/gui2/tweak_book/editor/text.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index 44f55118b0..479bed211a 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -164,6 +164,7 @@ class TextEdit(PlainTextEdit): c = self.textCursor() c.insertText(text) self.setTextCursor(c) + self.ensureCursorVisible() def add_file(name, data, mt=None): from calibre.gui2.tweak_book.boss import get_boss @@ -186,19 +187,21 @@ class TextEdit(PlainTextEdit): insert_text(''.format(href)) elif mt in OEB_DOCS: self.insert_hyperlink(href, name) + self.ensureCursorVisible() return if md.hasImage(): img = md.imageData() - if img.isValid(): + if img is not None and img.isValid(): data = image_to_data(img, fmt='PNG') name = add_file(get_name('dropped_image.png', data)) self.insert_image(get_href(name)) + self.ensureCursorVisible() return + if md.hasText(): + return insert_text(md.text()) if md.hasHtml(): insert_text(md.html()) return - if md.hasText(): - return insert_text(md.text()) @dynamic_property def is_modified(self):