mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-09 08:44:20 +01:00
This commit is contained in:
parent
cd1e638cca
commit
92768541bb
1 changed files with 26 additions and 12 deletions
|
|
@ -304,24 +304,38 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, focus: b
|
|||
return;
|
||||
}
|
||||
if (operation.action === "updateAttrs") { // 调用接口才推送
|
||||
let nodeAttrHTML = "";
|
||||
const data = operation.data as any;
|
||||
const attrsResult: IObject = {};
|
||||
Object.keys(data.new).forEach(key => {
|
||||
attrsResult[key] = data.new[key];
|
||||
const escapeHTML = data.new[key];
|
||||
if (key === "bookmark") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--bookmark">${escapeHTML}</div>`;
|
||||
} else if (key === "name") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--name"><svg><use xlink:href="#iconN"></use></svg>${escapeHTML}</div>`;
|
||||
} else if (key === "alias") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--alias"><svg><use xlink:href="#iconA"></use></svg>${escapeHTML}</div>`;
|
||||
} else if (key === "memo") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;
|
||||
}
|
||||
});
|
||||
if (protyle.block.rootID === operation.id) {
|
||||
// 文档
|
||||
const refElement = protyle.title.element.querySelector(".protyle-attr--refcount");
|
||||
if (refElement) {
|
||||
nodeAttrHTML += refElement.outerHTML;
|
||||
}
|
||||
protyle.title.element.querySelector(".protyle-attr").innerHTML = nodeAttrHTML;
|
||||
protyle.wysiwyg.renderCustom(attrsResult);
|
||||
return;
|
||||
}
|
||||
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${operation.id}"]`).forEach(item => {
|
||||
const data = operation.data as any;
|
||||
Object.keys(data.old).forEach(key => {
|
||||
item.removeAttribute(key);
|
||||
});
|
||||
let nodeAttrHTML = "";
|
||||
Object.keys(data.new).forEach(key => {
|
||||
item.setAttribute(key, data.new[key]);
|
||||
const escapeHTML = data.new[key];
|
||||
if (key === "bookmark") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--bookmark">${escapeHTML}</div>`;
|
||||
} else if (key === "name") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--name"><svg><use xlink:href="#iconN"></use></svg>${escapeHTML}</div>`;
|
||||
} else if (key === "alias") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--alias"><svg><use xlink:href="#iconA"></use></svg>${escapeHTML}</div>`;
|
||||
} else if (key === "memo") {
|
||||
nodeAttrHTML += `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;
|
||||
}
|
||||
});
|
||||
const refElement = item.lastElementChild.querySelector(".protyle-attr--refcount");
|
||||
if (refElement) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue