mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
635f8b3bf5
commit
85a76a59a5
1 changed files with 14 additions and 4 deletions
|
|
@ -16,7 +16,7 @@ import {getContenteditableElement, hasNextSibling, hasPreviousSibling} from "../
|
||||||
import {transaction, updateTransaction} from "../wysiwyg/transaction";
|
import {transaction, updateTransaction} from "../wysiwyg/transaction";
|
||||||
import {insertHTML} from "../util/insertHTML";
|
import {insertHTML} from "../util/insertHTML";
|
||||||
import {highlightRender} from "../render/highlightRender";
|
import {highlightRender} from "../render/highlightRender";
|
||||||
import {assetMenu, imgMenu} from "../../menus/protyle";
|
import {assetMenu, imgMenu, setFold} from "../../menus/protyle";
|
||||||
import {hideElements} from "../ui/hideElements";
|
import {hideElements} from "../ui/hideElements";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {getDisplayName, pathPosix} from "../../util/pathName";
|
import {getDisplayName, pathPosix} from "../../util/pathName";
|
||||||
|
|
@ -805,6 +805,14 @@ ${genHintItemHTML(item)}
|
||||||
if (value === "<div>") {
|
if (value === "<div>") {
|
||||||
newHTML = `<div data-node-id="${Lute.NewNodeID()}" data-type="NodeHTMLBlock" class="render-node" data-subtype="block">${genIconHTML()}<div><protyle-html data-content=""></protyle-html><span style="position: absolute">${Constants.ZWSP}</span></div><div class="protyle-attr" contenteditable="false"></div></div>`;
|
newHTML = `<div data-node-id="${Lute.NewNodeID()}" data-type="NodeHTMLBlock" class="render-node" data-subtype="block">${genIconHTML()}<div><protyle-html data-content=""></protyle-html><span style="position: absolute">${Constants.ZWSP}</span></div><div class="protyle-attr" contenteditable="false"></div></div>`;
|
||||||
}
|
}
|
||||||
|
const doOperations: IOperation[] = [];
|
||||||
|
const undoOperations: IOperation[] = [];
|
||||||
|
if (nodeElement.getAttribute("data-type") === "NodeHeading" &&
|
||||||
|
nodeElement.getAttribute("fold") === "1") {
|
||||||
|
const foldData = setFold(protyle, nodeElement, true, false, false, true);
|
||||||
|
doOperations.push(...foldData.doOperations);
|
||||||
|
undoOperations.push(...foldData.undoOperations);
|
||||||
|
}
|
||||||
nodeElement.insertAdjacentHTML("afterend", newHTML);
|
nodeElement.insertAdjacentHTML("afterend", newHTML);
|
||||||
const oldHTML = nodeElement.outerHTML;
|
const oldHTML = nodeElement.outerHTML;
|
||||||
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
|
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
|
||||||
|
|
@ -815,7 +823,7 @@ ${genHintItemHTML(item)}
|
||||||
item.style.minWidth = "60px";
|
item.style.minWidth = "60px";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
transaction(protyle, [{
|
doOperations.push({
|
||||||
data: oldHTML,
|
data: oldHTML,
|
||||||
id,
|
id,
|
||||||
action: "update"
|
action: "update"
|
||||||
|
|
@ -824,14 +832,16 @@ ${genHintItemHTML(item)}
|
||||||
id: newId,
|
id: newId,
|
||||||
previousID: id,
|
previousID: id,
|
||||||
action: "insert"
|
action: "insert"
|
||||||
}], [{
|
});
|
||||||
|
undoOperations.push({
|
||||||
id: newId,
|
id: newId,
|
||||||
action: "delete"
|
action: "delete"
|
||||||
}, {
|
}, {
|
||||||
data: html,
|
data: html,
|
||||||
id,
|
id,
|
||||||
action: "update"
|
action: "update"
|
||||||
}]);
|
});
|
||||||
|
transaction(protyle, doOperations, undoOperations);
|
||||||
}
|
}
|
||||||
if (value === "<div>" || value === "$$" || (value.indexOf("```") > -1 && (value.length > 3 || nodeElement.classList.contains("render-node")))) {
|
if (value === "<div>" || value === "$$" || (value.indexOf("```") > -1 && (value.length > 3 || nodeElement.classList.contains("render-node")))) {
|
||||||
protyle.toolbar.showRender(protyle, nodeElement);
|
protyle.toolbar.showRender(protyle, nodeElement);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue