mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
676a714ba4
commit
030fa52c73
1 changed files with 11 additions and 10 deletions
|
|
@ -805,16 +805,13 @@ ${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 oldHTML = nodeElement.outerHTML;
|
||||||
const undoOperations: IOperation[] = [];
|
let foldData;
|
||||||
if (nodeElement.getAttribute("data-type") === "NodeHeading" &&
|
if (nodeElement.getAttribute("data-type") === "NodeHeading" &&
|
||||||
nodeElement.getAttribute("fold") === "1") {
|
nodeElement.getAttribute("fold") === "1") {
|
||||||
const foldData = setFold(protyle, nodeElement, true, false, false, true);
|
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 newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
|
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
|
||||||
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`);
|
nodeElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${newId}"]`);
|
||||||
// https://github.com/siyuan-note/siyuan/issues/6864
|
// https://github.com/siyuan-note/siyuan/issues/6864
|
||||||
|
|
@ -823,7 +820,7 @@ ${genHintItemHTML(item)}
|
||||||
item.style.minWidth = "60px";
|
item.style.minWidth = "60px";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
doOperations.push({
|
const doOperations: IOperation[] = [{
|
||||||
data: oldHTML,
|
data: oldHTML,
|
||||||
id,
|
id,
|
||||||
action: "update"
|
action: "update"
|
||||||
|
|
@ -832,15 +829,19 @@ ${genHintItemHTML(item)}
|
||||||
id: newId,
|
id: newId,
|
||||||
previousID: id,
|
previousID: id,
|
||||||
action: "insert"
|
action: "insert"
|
||||||
});
|
}];
|
||||||
undoOperations.push({
|
const undoOperations: IOperation[] = [{
|
||||||
id: newId,
|
id: newId,
|
||||||
action: "delete"
|
action: "delete"
|
||||||
}, {
|
}, {
|
||||||
data: html,
|
data: html,
|
||||||
id,
|
id,
|
||||||
action: "update"
|
action: "update"
|
||||||
});
|
}];
|
||||||
|
if (foldData) {
|
||||||
|
doOperations.push(...foldData.doOperations);
|
||||||
|
undoOperations.push(...foldData.undoOperations);
|
||||||
|
}
|
||||||
transaction(protyle, doOperations, undoOperations);
|
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")))) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue