mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-17 01:21:14 +08:00
This commit is contained in:
parent
adc4998973
commit
a1f856676e
@ -82,6 +82,7 @@ const promiseTransaction = () => {
|
||||
if (!item.lastElementChild.classList.contains("protyle-attr")) {
|
||||
item.lastElementChild.remove();
|
||||
}
|
||||
removeUnfoldRepeatBlock(response.data[0].doOperations[0].retData, protyle);
|
||||
item.insertAdjacentHTML("afterend", response.data[0].doOperations[0].retData);
|
||||
if (doOperations[0].data === "remove") {
|
||||
// https://github.com/siyuan-note/siyuan/issues/2188
|
||||
@ -216,6 +217,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
||||
const scrollTop = protyle.contentElement.scrollTop;
|
||||
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
|
||||
if (operation.retData) { // undo 的时候没有 retData
|
||||
removeUnfoldRepeatBlock(operation.retData, protyle);
|
||||
item.insertAdjacentHTML("afterend", operation.retData);
|
||||
}
|
||||
item.removeAttribute("fold");
|
||||
@ -559,6 +561,14 @@ export const turnsIntoOneTransaction = (options: { protyle: IProtyle, selectsEle
|
||||
hideElements(["gutter"], options.protyle);
|
||||
};
|
||||
|
||||
const removeUnfoldRepeatBlock = (html:string, protyle:IProtyle) => {
|
||||
const temp = document.createElement("template")
|
||||
temp.innerHTML = html
|
||||
Array.from(temp.content.children).forEach(item => {
|
||||
protyle.wysiwyg.element.querySelector(`:scope > [data-node-id="${item.getAttribute("data-node-id")}"]`)?.remove()
|
||||
})
|
||||
}
|
||||
|
||||
export const turnsIntoTransaction = (options: {
|
||||
protyle: IProtyle,
|
||||
selectsElement?: Element[],
|
||||
|
Loading…
Reference in New Issue
Block a user