mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
Editor: add Insert As Relative Image Link option
This commit is contained in:
parent
a7ba7e9d58
commit
61713915b5
@ -1900,6 +1900,9 @@ bool VMdEditor::processUrlFromMimeData(const QMimeData *p_source)
|
|||||||
if (isImage) {
|
if (isImage) {
|
||||||
dialog.addSelection(tr("Insert As Image"), 0);
|
dialog.addSelection(tr("Insert As Image"), 0);
|
||||||
dialog.addSelection(tr("Insert As Image Link"), 1);
|
dialog.addSelection(tr("Insert As Image Link"), 1);
|
||||||
|
if (isLocalFile) {
|
||||||
|
dialog.addSelection(tr("Insert As Relative Image Link"), 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.addSelection(tr("Insert As Link"), 2);
|
dialog.addSelection(tr("Insert As Link"), 2);
|
||||||
@ -1931,11 +1934,25 @@ bool VMdEditor::processUrlFromMimeData(const QMimeData *p_source)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 7:
|
||||||
|
// Insert As Relative Image Link.
|
||||||
|
relativeLink = true;
|
||||||
|
V_FALLTHROUGH;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
// Insert As Image Link.
|
// Insert As Image Link.
|
||||||
insertImageLink("", url.isLocalFile() ? url.toString(QUrl::EncodeSpaces)
|
QString ut;
|
||||||
: url.toString());
|
if (relativeLink) {
|
||||||
|
QDir dir(m_file->fetchBasePath());
|
||||||
|
ut = dir.relativeFilePath(url.toLocalFile());
|
||||||
|
ut = QUrl(ut).toString(QUrl::EncodeSpaces);
|
||||||
|
} else {
|
||||||
|
ut = url.isLocalFile() ? url.toString(QUrl::EncodeSpaces)
|
||||||
|
: url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
insertImageLink("", ut);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user