Vanessa
2026-04-11 22:39:24 +08:00
parent 55f5353350
commit a47491b9fa
2 changed files with 11 additions and 5 deletions
+1 -1
View File
@@ -190,7 +190,7 @@ export const setDefRefCount = (data: {
// 不能对比 rootId,否则嵌入块中的锚文本无法更新
editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${data.blockID}"]`).forEach(item => {
// 不能直接查询,否则列表中会获取到第一个列表项的 attr https://github.com/siyuan-note/siyuan/issues/12738
const countElement = item.lastElementChild.querySelector(".protyle-attr--refcount");
const countElement = item.lastElementChild?.querySelector(".protyle-attr--refcount");
if (countElement) {
if (data.refCount === 0) {
countElement.remove();
+10 -4
View File
@@ -382,9 +382,9 @@ const updateBlock = (updateElements: Element[], protyle: IProtyle, operation: IO
// 用于推送和撤销
export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo: boolean) => {
if (protyle.wysiwyg.element.firstElementChild?.classList.contains("protyle-password")) {
return;
}
if (protyle.wysiwyg.element.firstElementChild?.classList.contains("protyle-password")) {
return;
}
const updateElements: Element[] = [];
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`)).forEach(item => {
if (!isInEmbedBlock(item)) {
@@ -688,11 +688,17 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
if (updateElements.length === 0) {
const tempEl = document.createElement("div");
tempEl.setAttribute("data-node-id", operation.id);
tempEl.setAttribute("data-protyle-id", protyle.element.getAttribute("data-id"));
updateElements.push(tempEl);
fetchPost("/api/block/getBlockDOM", {
id: operation.id,
}, (response) => {
document.querySelector(`.protyle-wysiwyg [data-node-id="${operation.id}"]`).outerHTML = response.data.dom;
document.querySelectorAll(`.protyle-wysiwyg [data-node-id="${response.data.id}"]`).forEach(item => {
if (item.getAttribute("data-protyle-id")) {
item.outerHTML = response.data.dom;
item.removeAttribute("data-protyle-id");
}
});
});
}
let range;