mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-07-03 14:09:06 +02:00
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user