mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
prefer image if text starts with http
This commit is contained in:
parent
22658dea73
commit
53cb4790af
1 changed files with 9 additions and 3 deletions
|
@ -570,14 +570,20 @@ class FactEdit(QTextEdit):
|
|||
|
||||
def insertFromMimeData(self, source):
|
||||
if source.hasText():
|
||||
self.insertPlainText(source.text())
|
||||
elif source.hasImage():
|
||||
if not (unicode(source.text()).lower().startswith("http://") and
|
||||
source.hasImage()):
|
||||
# choose text unless this is a link with an image
|
||||
self.insertPlainText(source.text())
|
||||
return
|
||||
if source.hasImage():
|
||||
im = QImage(source.imageData())
|
||||
(fd, name) = tempfile.mkstemp(suffix=".jpg")
|
||||
im.save(name, None, 95)
|
||||
self.parent._addPicture(name, widget=self)
|
||||
elif source.hasHtml():
|
||||
return
|
||||
if source.hasHtml():
|
||||
self.insertHtml(self.simplifyHTML(unicode(source.html())))
|
||||
return
|
||||
|
||||
def simplifyHTML(self, html):
|
||||
"Remove all style information and P tags."
|
||||
|
|
Loading…
Reference in a new issue