An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle: attr
Vanessa67c0fda4dd51
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex da16bb834e..d538e4b99a 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -149,7 +149,7 @@ export const openFileWechatNotify = (protyle: IProtyle) => {});};-const genAttr = (attrs: IObject, focusName = "bookmark") => {+export const openFileAttr = (attrs: IObject, focusName = "bookmark") => {let customHTML = "";let notifyHTML = "";let hasAV = false;@@ -263,7 +263,7 @@ const genAttr = (attrs: IObject, focusName = "bookmark") => {} else if (type === "remove") {fetchPost("/api/attr/setBlockAttrs", {id: attrs.id,- attrs: {["custom-"+target.previousElementSibling.textContent]: ""}+ attrs: {["custom-" + target.previousElementSibling.textContent]: ""}});target.parentElement.parentElement.remove();event.stopPropagation();@@ -285,7 +285,7 @@ const genAttr = (attrs: IObject, focusName = "bookmark") => {click() {const bookmarkInputElement = target.parentElement.parentElement.querySelector("input");bookmarkInputElement.value = item;- bookmarkInputElement.dispatchEvent(new CustomEvent("change"));+ bookmarkInputElement.dispatchEvent(new CustomEvent("change"));}}).element);});@@ -350,147 +350,13 @@ const genAttr = (attrs: IObject, focusName = "bookmark") => {});};-export const openFileAttr = (attrs: IObject, id: string, focusName = "bookmark") => {- genAttr(attrs, focusName,- // (dialog) => {- // let nodeAttrHTML = "";- // let errorTip = "";- // const attrsResult: IObject = {};- // dialog.element.querySelectorAll(".b3-text-field").forEach((item: HTMLInputElement) => {- // let name = item.getAttribute("data-name");- // if (!name) {- // if (item.tagName === "INPUT") {- // return;- // }- // name = "custom-" + (item.parentElement.querySelector(".b3-text-field") as HTMLInputElement).value;- // }- // if (item.value.trim()) {- // if (!isValidAttrName(name)) {- // errorTip += name.replace(/^custom-/, "") + ", ";- // return;- // }- // attrsResult[name] = item.value;- // const escapeHTML = Lute.EscapeHTMLStr(item.value);- // if (name === "bookmark") {- // nodeAttrHTML += `<div class="protyle-attr--bookmark">${escapeHTML}</div>`;- // } else if (name === "name") {- // nodeAttrHTML += `<div class="protyle-attr--name"><svg><use xlink:href="#iconN"></use></svg>${escapeHTML}</div>`;- // } else if (name === "alias") {- // nodeAttrHTML += `<div class="protyle-attr--alias"><svg><use xlink:href="#iconA"></use></svg>${escapeHTML}</div>`;- // } else if (name === "memo") {- // nodeAttrHTML += `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;- // }- // }- // });- // if (errorTip) {- // showMessage(errorTip.substr(0, errorTip.length - 2) + " " + window.siyuan.languages.invalid);- // }- // /// #if !MOBILE- // getAllModels().editor.forEach(item => {- // if (item.editor.protyle.block.rootID === id) {- // const refElement = item.editor.protyle.title.element.querySelector(".protyle-attr--refcount");- // if (refElement) {- // nodeAttrHTML += refElement.outerHTML;- // }- // item.editor.protyle.title.element.querySelector(".protyle-attr").innerHTML = nodeAttrHTML;- // item.editor.protyle.wysiwyg.renderCustom(attrsResult);- // }- // // https://github.com/siyuan-note/siyuan/issues/6398- // item.editor.protyle.wysiwyg.element.querySelectorAll(`[data-type~="block-ref"][data-id="${id}"][data-subtype="d"]`).forEach(item => {- // fetchPost("/api/block/getRefText", {id: id}, (response) => {- // item.innerHTML = response.data;- // });- // });- // });- // /// #endif- // fetchPost("/api/attr/resetBlockAttrs", {id, attrs: attrsResult}, () => {- // /// #if !MOBILE- // if (attrsResult.bookmark !== attrs.bookmark) {- // const bookmark = getDockByType("bookmark").data.bookmark;- // if (bookmark instanceof Bookmark) {- // bookmark.update();- // }- // }- // /// #endif- // });- // dialog.destroy();- // }- );-};--export const openAttr = (nodeElement: Element, protyle: IProtyle, focusName = "bookmark") => {+export const openAttr = (nodeElement: Element, focusName = "bookmark") => {if (nodeElement.getAttribute("data-type") === "NodeThematicBreak") {return;}const id = nodeElement.getAttribute("data-node-id");fetchPost("/api/attr/getBlockAttrs", {id}, (response) => {- genAttr(response.data, focusName,- // (dialog, removeAttrs) => {- // let nodeAttrHTML = "";- // const oldHTML = nodeElement.outerHTML;- // let errorTip = "";- // dialog.element.querySelectorAll(".b3-text-field").forEach((item: HTMLInputElement) => {- // let name = item.getAttribute("data-name");- // if (!name) {- // if (item.tagName === "INPUT") {- // return;- // }- // name = "custom-" + (item.parentElement.querySelector(".b3-text-field") as HTMLInputElement).value;- // }- // if (item.value.trim()) {- // if (!isValidAttrName(name)) {- // errorTip += name.replace(/^custom-/, "") + ", ";- // return;- // }- // if (removeAttrs.includes(name)) {- // removeAttrs.find((rmAttr, index) => {- // if (rmAttr === name) {- // removeAttrs.splice(index, 1);- // return true;- // }- // });- // }- // const escapeHTML = Lute.EscapeHTMLStr(item.value);- // nodeElement.setAttribute(name, escapeHTML);- // if (name === "bookmark") {- // /// #if !MOBILE- // if (escapeHTML !== response.data.bookmark) {- // const bookmark = getDockByType("bookmark").data.bookmark;- // if (bookmark instanceof Bookmark) {- // setTimeout(() => {- // bookmark.update();- // }, 219);- // }- // }- // /// #endif- // nodeAttrHTML += `<div class="protyle-attr--bookmark">${escapeHTML}</div>`;- // } else if (name === "name") {- // nodeAttrHTML += `<div class="protyle-attr--name"><svg><use xlink:href="#iconN"></use></svg>${escapeHTML}</div>`;- // } else if (name === "alias") {- // nodeAttrHTML += `<div class="protyle-attr--alias"><svg><use xlink:href="#iconA"></use></svg>${escapeHTML}</div>`;- // } else if (name === "memo") {- // nodeAttrHTML += `<div class="protyle-attr--memo b3-tooltips b3-tooltips__sw" aria-label="${escapeHTML}"><svg><use xlink:href="#iconM"></use></svg></div>`;- // }- // } else {- // nodeElement.removeAttribute(name);- // }- // });- // removeAttrs.forEach(item => {- // nodeElement.removeAttribute(item);- // });- // if (errorTip) {- // showMessage(errorTip.substr(0, errorTip.length - 2) + " " + window.siyuan.languages.invalid);- // }- // const refElement = nodeElement.lastElementChild.querySelector(".protyle-attr--refcount");- // if (refElement) {- // nodeAttrHTML += refElement.outerHTML;- // }- // nodeElement.lastElementChild.innerHTML = nodeAttrHTML + Constants.ZWSP;- // nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));- // updateTransaction(protyle, id, nodeElement.outerHTML, oldHTML);- // dialog.destroy();- // }- );+ openFileAttr(response.data, focusName);});};diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex a5412bd36b..b70d570825 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -365,7 +365,7 @@ export const initFileMenu = (app: App, notebookId: string, pathString: string, lfetchPost("/api/block/getDocInfo", {id}, (response) => {- openFileAttr(response.data.ial, id);+ openFileAttr(response.data.ial);});}}).element);diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.tsindex f369f6e96f..be22e5f07e 100644--- a/app/src/protyle/breadcrumb/index.ts+++ b/app/src/protyle/breadcrumb/index.ts@@ -85,7 +85,7 @@ export class Breadcrumb {fetchPost("/api/block/getDocInfo", {id: protyle.block.rootID}, (response) => {- openFileAttr(response.data.ial, protyle.block.rootID);+ openFileAttr(response.data.ial);});} else {const targetRect = target.getBoundingClientRect();diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 039d52db6d..a86f5922ba 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -215,7 +215,7 @@ export class Gutter {}foldElement.classList.remove("protyle-wysiwyg--hl");} else if (window.siyuan.shiftIsPressed && !protyle.disabled) {- openAttr(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`), protyle);+ openAttr(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`));} else {this.renderMenu(protyle, buttonElement);// https://ld246.com/article/1648433751993@@ -1496,7 +1496,7 @@ export class Gutter {label: window.siyuan.languages.attr,accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"),click() {- openAttr(nodeElement, protyle);+ openAttr(nodeElement);}}).element);}diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 3931f76868..700f72f927 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -140,7 +140,7 @@ export class Title {fetchPost("/api/block/getDocInfo", {id: protyle.block.rootID}, (response) => {- openFileAttr(response.data.ial, protyle.block.rootID);+ openFileAttr(response.data.ial);});event.preventDefault();event.stopPropagation();@@ -179,7 +179,7 @@ export class Title {fetchPost("/api/block/getDocInfo", {id: protyle.block.rootID}, (response) => {- openFileAttr(response.data.ial, protyle.block.rootID);+ openFileAttr(response.data.ial);});} else {const iconRect = iconElement.getBoundingClientRect();diff --git a/app/src/protyle/header/openTitleMenu.ts b/app/src/protyle/header/openTitleMenu.tsindex d906c59ceb..d2d6c7d37b 100644--- a/app/src/protyle/header/openTitleMenu.ts+++ b/app/src/protyle/header/openTitleMenu.ts@@ -55,7 +55,7 @@ export const openTitleMenu = (protyle: IProtyle, position: {label: window.siyuan.languages.attr,accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"),click() {- openFileAttr(response.data.ial, protyle.block.rootID);+ openFileAttr(response.data.ial);}}).element);}diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex 24e7945c4d..ecef77e2d5 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -291,7 +291,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellElbind(element) {element.querySelector("input").addEventListener("keydown", (event: KeyboardEvent) => {if (event.isComposing) {- return+ return;}if (event.key === "Enter") {menu.close();diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.tsindex 224ef8540b..4bb62cbd0f 100644--- a/app/src/protyle/render/av/filter.ts+++ b/app/src/protyle/render/av/filter.ts@@ -374,7 +374,7 @@ export const getFiltersHTML = (data: IAVTable) => {if (index !== filter.value.mSelect.length - 1) {selectContent += ", ";}- })+ });if ("Contains" === filter.operator) {filterValue = `: ${selectContent}`;} else if (filter.operator === "Does not contains") {diff --git a/app/src/protyle/wysiwyg/commonClick.ts b/app/src/protyle/wysiwyg/commonClick.tsindex 8110455e04..a6851cfa00 100644--- a/app/src/protyle/wysiwyg/commonClick.ts+++ b/app/src/protyle/wysiwyg/commonClick.ts@@ -17,9 +17,9 @@ export const commonClick = (event: MouseEvent & {/// #endif} else {if (data) {- openFileAttr(data, protyle.block.rootID, "bookmark");+ openFileAttr(data, "bookmark");} else {- openAttr(attrBookmarkElement.parentElement.parentElement, protyle, "bookmark");+ openAttr(attrBookmarkElement.parentElement.parentElement, "bookmark");}}event.stopPropagation();@@ -34,9 +34,9 @@ export const commonClick = (event: MouseEvent & {/// #endif} else {if (data) {- openFileAttr(data, protyle.block.rootID, "name");+ openFileAttr(data, "name");} else {- openAttr(attrNameElement.parentElement.parentElement, protyle, "name");+ openAttr(attrNameElement.parentElement.parentElement, "name");}}event.stopPropagation();@@ -51,9 +51,9 @@ export const commonClick = (event: MouseEvent & {/// #endif} else {if (data) {- openFileAttr(data, protyle.block.rootID, "alias");+ openFileAttr(data, "alias");} else {- openAttr(attrAliasElement.parentElement.parentElement, protyle, "alias");+ openAttr(attrAliasElement.parentElement.parentElement, "alias");}}event.stopPropagation();@@ -68,9 +68,9 @@ export const commonClick = (event: MouseEvent & {/// #endif} else {if (data) {- openFileAttr(data, protyle.block.rootID, "memo");+ openFileAttr(data, "memo");} else {- openAttr(attrMemoElement.parentElement.parentElement, protyle, "memo");+ openAttr(attrMemoElement.parentElement.parentElement, "memo");}}event.stopPropagation();diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 4dd7fc68ee..e574a1c6d1 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -1929,7 +1929,7 @@ export class WYSIWYG {}hideElements(["gutter"], protyle);} else if (event.shiftKey) {- openAttr(actionElement.parentElement, protyle);+ openAttr(actionElement.parentElement);} else if (ctrlIsPressed) {zoomOut({protyle, id: actionElement.parentElement.getAttribute("data-node-id")});} else {diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 3ec5b881de..10d072325c 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -1042,7 +1042,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {} else {actionElement = topElement;}- openAttr(actionElement, protyle);+ openAttr(actionElement);} else {const oldHTML = topElement.outerHTML;const name = Lute.EscapeHTMLStr(selectText);