mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-01 18:49:38 +12:00
Corrects bug in links tooltips
This commit is contained in:
parent
a6a82d1bba
commit
19f8938852
|
@ -19,6 +19,9 @@ class MDEditView(textEditView):
|
||||||
|
|
||||||
blockquoteRegex = QRegExp("^ {0,3}(>\\s*)+")
|
blockquoteRegex = QRegExp("^ {0,3}(>\\s*)+")
|
||||||
listRegex = QRegExp("^(\\s*)([+*-]|([0-9a-z])+([.\)]))(\\s+)")
|
listRegex = QRegExp("^(\\s*)([+*-]|([0-9a-z])+([.\)]))(\\s+)")
|
||||||
|
inlineLinkRegex = QRegExp("\\[([^\n]+)\\]\\(([^\n]+)\\)")
|
||||||
|
imageRegex = QRegExp("!\\[([^\n]*)\\]\\(([^\n]+)\\)")
|
||||||
|
automaticLinkRegex = QRegExp("(<([a-zA-Z]+\\:[^\n]+)>)|(<([^\n]+@[^\n]+)>)")
|
||||||
|
|
||||||
def __init__(self, parent=None, index=None, html=None, spellcheck=True,
|
def __init__(self, parent=None, index=None, html=None, spellcheck=True,
|
||||||
highlighting=False, dict="", autoResize=False):
|
highlighting=False, dict="", autoResize=False):
|
||||||
|
@ -465,9 +468,9 @@ class MDEditView(textEditView):
|
||||||
refs = []
|
refs = []
|
||||||
text = self.toPlainText()
|
text = self.toPlainText()
|
||||||
for rx in [
|
for rx in [
|
||||||
MT.imageRegex,
|
self.imageRegex,
|
||||||
MT.automaticLinkRegex,
|
self.automaticLinkRegex,
|
||||||
MT.inlineLinkRegex,
|
self.inlineLinkRegex,
|
||||||
]:
|
]:
|
||||||
pos = 0
|
pos = 0
|
||||||
while rx.indexIn(text, pos) != -1:
|
while rx.indexIn(text, pos) != -1:
|
||||||
|
@ -516,17 +519,17 @@ class MDEditView(textEditView):
|
||||||
if not qApp.overrideCursor():
|
if not qApp.overrideCursor():
|
||||||
qApp.setOverrideCursor(Qt.PointingHandCursor)
|
qApp.setOverrideCursor(Qt.PointingHandCursor)
|
||||||
|
|
||||||
if ct.regex == MT.automaticLinkRegex:
|
if ct.regex == self.automaticLinkRegex:
|
||||||
tooltip = ct.texts[2] or ct.texts[4]
|
tooltip = ct.texts[2] or ct.texts[4]
|
||||||
|
|
||||||
elif ct.regex == MT.imageRegex:
|
elif ct.regex == self.imageRegex:
|
||||||
tt = ("<p><b>" + ct.texts[1] + "</b></p>"
|
tt = ("<p><b>" + ct.texts[1] + "</b></p>"
|
||||||
+"<p><img src='data:image/png;base64,{}'></p>")
|
+"<p><img src='data:image/png;base64,{}'></p>")
|
||||||
tooltip = None
|
tooltip = None
|
||||||
pos = event.pos() + QPoint(0, ct.rect.height())
|
pos = event.pos() + QPoint(0, ct.rect.height())
|
||||||
imageTooltiper.fromUrl(ct.texts[2], pos, self)
|
imageTooltiper.fromUrl(ct.texts[2], pos, self)
|
||||||
|
|
||||||
elif ct.regex == MT.inlineLinkRegex:
|
elif ct.regex == self.inlineLinkRegex:
|
||||||
tooltip = ct.texts[1] or ct.texts[2]
|
tooltip = ct.texts[1] or ct.texts[2]
|
||||||
|
|
||||||
if tooltip:
|
if tooltip:
|
||||||
|
@ -539,11 +542,11 @@ class MDEditView(textEditView):
|
||||||
if onRect and event.modifiers() & Qt.ControlModifier:
|
if onRect and event.modifiers() & Qt.ControlModifier:
|
||||||
ct = onRect[0]
|
ct = onRect[0]
|
||||||
|
|
||||||
if ct.regex == MT.automaticLinkRegex:
|
if ct.regex == self.automaticLinkRegex:
|
||||||
url = ct.texts[2] or ct.texts[4]
|
url = ct.texts[2] or ct.texts[4]
|
||||||
elif ct.regex == MT.imageRegex:
|
elif ct.regex == self.imageRegex:
|
||||||
url = ct.texts[2]
|
url = ct.texts[2]
|
||||||
elif ct.regex == MT.inlineLinkRegex:
|
elif ct.regex == self.inlineLinkRegex:
|
||||||
url = ct.texts[2]
|
url = ct.texts[2]
|
||||||
|
|
||||||
F.openURL(url)
|
F.openURL(url)
|
||||||
|
|
Loading…
Reference in a new issue