diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 8629ba180..2ad717f4e 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -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 += `
${escapeHTML}
`;
+ } else if (key === "name") {
+ nodeAttrHTML += `${escapeHTML}
`;
+ } else if (key === "alias") {
+ nodeAttrHTML += `${escapeHTML}
`;
+ } else if (key === "memo") {
+ nodeAttrHTML += ``;
+ }
+ });
+ 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 += `${escapeHTML}
`;
- } else if (key === "name") {
- nodeAttrHTML += `${escapeHTML}
`;
- } else if (key === "alias") {
- nodeAttrHTML += `${escapeHTML}
`;
- } else if (key === "memo") {
- nodeAttrHTML += ``;
- }
});
const refElement = item.lastElementChild.querySelector(".protyle-attr--refcount");
if (refElement) {