diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index d2de82320..707ca04f0 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -16,7 +16,7 @@ import {getContenteditableElement, hasNextSibling, hasPreviousSibling} from "../
import {transaction, updateTransaction} from "../wysiwyg/transaction";
import {insertHTML} from "../util/insertHTML";
import {highlightRender} from "../render/highlightRender";
-import {assetMenu, imgMenu} from "../../menus/protyle";
+import {assetMenu, imgMenu, setFold} from "../../menus/protyle";
import {hideElements} from "../ui/hideElements";
import {fetchPost} from "../../util/fetch";
import {getDisplayName, pathPosix} from "../../util/pathName";
@@ -805,6 +805,14 @@ ${genHintItemHTML(item)}
if (value === "
") {
newHTML = `
`;
}
+ 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);
const oldHTML = nodeElement.outerHTML;
const newId = newHTML.substr(newHTML.indexOf('data-node-id="') + 14, 22);
@@ -815,7 +823,7 @@ ${genHintItemHTML(item)}
item.style.minWidth = "60px";
});
}
- transaction(protyle, [{
+ doOperations.push({
data: oldHTML,
id,
action: "update"
@@ -824,14 +832,16 @@ ${genHintItemHTML(item)}
id: newId,
previousID: id,
action: "insert"
- }], [{
+ });
+ undoOperations.push({
id: newId,
action: "delete"
}, {
data: html,
id,
action: "update"
- }]);
+ });
+ transaction(protyle, doOperations, undoOperations);
}
if (value === "
" || value === "$$" || (value.indexOf("```") > -1 && (value.length > 3 || nodeElement.classList.contains("render-node")))) {
protyle.toolbar.showRender(protyle, nodeElement);