mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
recover mdeditor
This commit is contained in:
parent
dfb44d7edb
commit
8b8743a1e8
@ -1338,7 +1338,7 @@ var listContainsRegex = function(strs, exp) {
|
|||||||
var StylesToInline = null;
|
var StylesToInline = null;
|
||||||
|
|
||||||
var initStylesToInline = function() {
|
var initStylesToInline = function() {
|
||||||
StylesToInline = new Map();
|
StylesToInline = new Object();
|
||||||
|
|
||||||
if (VStylesToInline.length == 0) {
|
if (VStylesToInline.length == 0) {
|
||||||
return;
|
return;
|
||||||
@ -1354,7 +1354,7 @@ var initStylesToInline = function() {
|
|||||||
var tags = vals[0].split(':');
|
var tags = vals[0].split(':');
|
||||||
var pros = vals[1].split(':');
|
var pros = vals[1].split(':');
|
||||||
for (var j = 0; j < tags.length; ++j) {
|
for (var j = 0; j < tags.length; ++j) {
|
||||||
StylesToInline.set(tags[j].toLowerCase(), pros);
|
StylesToInline[tags[j].toLowerCase()] = pros;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1363,9 +1363,9 @@ var initStylesToInline = function() {
|
|||||||
// StylesToInline need to be init before.
|
// StylesToInline need to be init before.
|
||||||
var embedInlineStyles = function(ele) {
|
var embedInlineStyles = function(ele) {
|
||||||
var tagName = ele.tagName.toLowerCase();
|
var tagName = ele.tagName.toLowerCase();
|
||||||
var props = StylesToInline.get(tagName);
|
var props = StylesToInline[tagName];
|
||||||
if (!props) {
|
if (!props) {
|
||||||
props = StylesToInline.get('all');
|
props = StylesToInline['all'];
|
||||||
|
|
||||||
if (!props) {
|
if (!props) {
|
||||||
return;
|
return;
|
||||||
|
@ -358,11 +358,9 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
|||||||
pasteAct = getActionByObjectName(actions, "edit-paste");
|
pasteAct = getActionByObjectName(actions, "edit-paste");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (copyAct && copyAct->isEnabled()) {
|
if (copyAct && copyAct->isEnabled()) {
|
||||||
initCopyAsMenu(copyAct, menu.data());
|
initCopyAsMenu(copyAct, menu.data());
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if (pasteAct && pasteAct->isEnabled()) {
|
if (pasteAct && pasteAct->isEnabled()) {
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
@ -371,11 +369,9 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
|||||||
initPasteAsBlockQuoteMenu(pasteAct, menu.data());
|
initPasteAsBlockQuoteMenu(pasteAct, menu.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (mimeData->hasHtml()) {
|
if (mimeData->hasHtml()) {
|
||||||
initPasteAfterParseMenu(pasteAct, menu.data());
|
initPasteAfterParseMenu(pasteAct, menu.data());
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
QAction *pptAct = new QAction(tr("Paste As Plain Text"), menu.data());
|
QAction *pptAct = new QAction(tr("Paste As Plain Text"), menu.data());
|
||||||
VUtils::fixTextWithShortcut(pptAct, "PastePlainText");
|
VUtils::fixTextWithShortcut(pptAct, "PastePlainText");
|
||||||
@ -389,6 +385,44 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
|||||||
if (!textCursor().hasSelection()) {
|
if (!textCursor().hasSelection()) {
|
||||||
initLinkAndPreviewMenu(firstAct, menu.data(), p_event->pos());
|
initLinkAndPreviewMenu(firstAct, menu.data(), p_event->pos());
|
||||||
|
|
||||||
|
QAction *saveExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/save_exit.svg"),
|
||||||
|
tr("&Save Changes And Read"),
|
||||||
|
menu.data());
|
||||||
|
saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
|
||||||
|
connect(saveExitAct, &QAction::triggered,
|
||||||
|
this, [this]() {
|
||||||
|
emit m_object->saveAndRead();
|
||||||
|
});
|
||||||
|
|
||||||
|
QAction *discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||||
|
tr("&Discard Changes And Read"),
|
||||||
|
menu.data());
|
||||||
|
discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
|
||||||
|
connect(discardExitAct, &QAction::triggered,
|
||||||
|
this, [this]() {
|
||||||
|
emit m_object->discardAndRead();
|
||||||
|
});
|
||||||
|
|
||||||
|
VMdTab *mdtab = dynamic_cast<VMdTab *>(m_editTab);
|
||||||
|
if (mdtab) {
|
||||||
|
QAction *toggleLivePreviewAct = new QAction(tr("Live Preview For Graphs"), menu.data());
|
||||||
|
toggleLivePreviewAct->setToolTip(tr("Toggle live preview panel for graphs"));
|
||||||
|
VUtils::fixTextWithCaptainShortcut(toggleLivePreviewAct, "LivePreview");
|
||||||
|
connect(toggleLivePreviewAct, &QAction::triggered,
|
||||||
|
this, [mdtab]() {
|
||||||
|
mdtab->toggleLivePreview();
|
||||||
|
});
|
||||||
|
|
||||||
|
menu->insertAction(firstAct, toggleLivePreviewAct);
|
||||||
|
menu->insertAction(toggleLivePreviewAct, discardExitAct);
|
||||||
|
menu->insertAction(discardExitAct, saveExitAct);
|
||||||
|
menu->insertSeparator(toggleLivePreviewAct);
|
||||||
|
} else {
|
||||||
|
menu->insertAction(firstAct, discardExitAct);
|
||||||
|
menu->insertAction(discardExitAct, saveExitAct);
|
||||||
|
menu->insertSeparator(discardExitAct);
|
||||||
|
}
|
||||||
|
|
||||||
if (firstAct) {
|
if (firstAct) {
|
||||||
menu->insertSeparator(firstAct);
|
menu->insertSeparator(firstAct);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user