An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/7551
Vanessaf30e9893e8cc
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex c6d00b1347..75cfd021bc 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -37,6 +37,7 @@ import {openCardByData} from "../../card/openCard";import {makeCard, quickMakeCard} from "../../card/makeCard";import {viewCards} from "../../card/viewCards";import {getNotebookName, pathPosix} from "../../util/pathName";+import {commonClick} from "../wysiwyg/commonClick";export class Title {public element: HTMLElement;@@ -245,33 +246,7 @@ export class Title {fetchPost("/api/block/getDocInfo", {id: protyle.block.rootID}, (response) => {- const attrBookmarkElement = hasClosestByClassName(event.target, "protyle-attr--bookmark");- if (attrBookmarkElement) {- openFileAttr(response.data.ial, protyle.block.rootID, "bookmark");- event.stopPropagation();- return;- }-- const attrNameElement = hasClosestByClassName(event.target, "protyle-attr--name");- if (attrNameElement) {- openFileAttr(response.data.ial, protyle.block.rootID, "name");- event.stopPropagation();- return;- }-- const attrAliasElement = hasClosestByClassName(event.target, "protyle-attr--alias");- if (attrAliasElement) {- openFileAttr(response.data.ial, protyle.block.rootID, "alias");- event.stopPropagation();- return;- }-- const attrMemoElement = hasClosestByClassName(event.target, "protyle-attr--memo");- if (attrMemoElement) {- openFileAttr(response.data.ial, protyle.block.rootID, "memo");- event.stopPropagation();- return;- }+ commonClick(event, protyle, response.data.ial);});});}diff --git a/app/src/protyle/wysiwyg/commonClick.ts b/app/src/protyle/wysiwyg/commonClick.tsnew file mode 100644index 0000000000..dd67230221--- /dev/null+++ b/app/src/protyle/wysiwyg/commonClick.ts@@ -0,0 +1,79 @@+import {hasClosestByClassName} from "../util/hasClosest";+import {openAttr, openFileAttr} from "../../menus/commonMenuItem";+/// #if !MOBILE+import {openGlobalSearch} from "../../search/util";+/// #endif+import {isMobile} from "../../util/functions";++export const commonClick = (event: MouseEvent & {+ target: HTMLElement+}, protyle: IProtyle, data?:IObject) => {+ const isM = isMobile();+ const attrBookmarkElement = hasClosestByClassName(event.target, "protyle-attr--bookmark");+ if (attrBookmarkElement) {+ if (!isM && (event.ctrlKey || event.metaKey)) {+ /// #if !MOBILE+ openGlobalSearch(attrBookmarkElement.textContent.trim(), true);+ /// #endif+ } else {+ if (data) {+ openFileAttr(data, protyle.block.rootID, "bookmark");+ } else {+ openAttr(attrBookmarkElement.parentElement.parentElement, protyle, "bookmark");+ }+ }+ event.stopPropagation();+ return true;+ }++ const attrNameElement = hasClosestByClassName(event.target, "protyle-attr--name");+ if (attrNameElement) {+ if (!isM && (event.ctrlKey || event.metaKey)) {+ /// #if !MOBILE+ openGlobalSearch(attrNameElement.textContent.trim(), true);+ /// #endif+ } else {+ if (data ) {+ openFileAttr(data, protyle.block.rootID, "name");+ } else {+ openAttr(attrNameElement.parentElement.parentElement, protyle, "name");+ }+ }+ event.stopPropagation();+ return true;+ }++ const attrAliasElement = hasClosestByClassName(event.target, "protyle-attr--alias");+ if (attrAliasElement) {+ if (!isM && (event.ctrlKey || event.metaKey)) {+ /// #if !MOBILE+ openGlobalSearch(attrAliasElement.textContent.trim(), true);+ /// #endif+ } else {+ if (data) {+ openFileAttr(data, protyle.block.rootID, "alias");+ } else {+ openAttr(attrAliasElement.parentElement.parentElement, protyle, "alias");+ }+ }+ event.stopPropagation();+ return true;+ }++ const attrMemoElement = hasClosestByClassName(event.target, "protyle-attr--memo");+ if (attrMemoElement) {+ if (!isM && (event.ctrlKey || event.metaKey)) {+ /// #if !MOBILE+ openGlobalSearch(attrMemoElement.getAttribute("aria-label").trim(), true);+ /// #endif+ } else {+ if (data) {+ openFileAttr(data, protyle.block.rootID, "memo");+ } else {+ openAttr(attrMemoElement.parentElement.parentElement, protyle, "memo");+ }+ }+ event.stopPropagation();+ return true;+ }+}diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 822d0c822e..f75fdf0b3e 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -63,6 +63,7 @@ import {showMessage} from "../../dialog/message";import {getBacklinkHeadingMore, loadBreadcrumb} from "./renderBacklink";import {removeSearchMark} from "../toolbar/util";import {activeBlur, hideKeyboardToolbar} from "../../mobile/util/keyboardToolbar";+import {commonClick} from "./commonClick";export class WYSIWYG {public lastHTMLs: { [key: string]: string } = {};@@ -1718,28 +1719,7 @@ export class WYSIWYG {return;}- const attrBookmarkElement = hasClosestByClassName(event.target, "protyle-attr--bookmark");- if (attrBookmarkElement) {- openAttr(attrBookmarkElement.parentElement.parentElement, protyle, "bookmark");- event.stopPropagation();- return;- }- const attrNameElement = hasClosestByClassName(event.target, "protyle-attr--name");- if (attrNameElement) {- openAttr(attrNameElement.parentElement.parentElement, protyle, "name");- event.stopPropagation();- return;- }- const attrAliasElement = hasClosestByClassName(event.target, "protyle-attr--alias");- if (attrAliasElement) {- openAttr(attrAliasElement.parentElement.parentElement, protyle, "alias");- event.stopPropagation();- return;- }- const attrMemoElement = hasClosestByClassName(event.target, "protyle-attr--memo");- if (attrMemoElement) {- openAttr(attrMemoElement.parentElement.parentElement, protyle, "memo");- event.stopPropagation();+ if (commonClick(event, protyle)) {return;}