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: https://github.com/siyuan-note/siyuan/issues/10577
Vanessaa90402845b0e
diff --git a/app/src/boot/globalEvent/touch.ts b/app/src/boot/globalEvent/touch.tsindex 836b69b376..4ad9995922 100644--- a/app/src/boot/globalEvent/touch.ts+++ b/app/src/boot/globalEvent/touch.ts@@ -1,7 +1,7 @@import {isIPad} from "../../protyle/util/compatibility";import {hasClosestByAttribute, hasClosestByClassName, hasTopClosestByTag} from "../../protyle/util/hasClosest";import {initFileMenu, initNavigationMenu} from "../../menus/navigation";-import {fileAnnotationRefMenu, linkMenu, refMenu, tagMenu} from "../../menus/protyle";+import {fileAnnotationRefMenu, inlineMathMenu, linkMenu, refMenu, tagMenu} from "../../menus/protyle";import {App} from "../../index";import {Protyle} from "../../protyle";import {getCurrentEditor} from "../../mobile/editor";@@ -123,6 +123,11 @@ export const globalTouchEnd = (event: TouchEvent, yDiff: number, time: number, alinkMenu(editor.protyle, target);return true;}+ const inlineMathElement = hasClosestByAttribute(target, "data-type", "inline-math");+ if (inlineMathElement) {+ inlineMathMenu(editor.protyle, inlineMathElement);+ return true;+ }}}return false;diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex b5f6f16000..10881da2a9 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -1547,6 +1547,55 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {window.siyuan.menus.menu.element.querySelector("input").select();};+export const inlineMathMenu = (protyle: IProtyle, element: Element) => {+ window.siyuan.menus.menu.remove();+ const nodeElement = hasClosestBlock(element);+ if (!nodeElement) {+ return;+ }+ const id = nodeElement.getAttribute("data-node-id");+ const html = nodeElement.outerHTML;+ window.siyuan.menus.menu.append(new MenuItem({+ label: window.siyuan.languages.copy,+ icon: "iconCopy",+ click() {+ writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));+ }+ }).element);+ if (!protyle.disabled) {+ window.siyuan.menus.menu.append(new MenuItem({+ icon: "iconCut",+ label: window.siyuan.languages.cut,+ click() {+ writeText(protyle.lute.BlockDOM2StdMd(element.outerHTML));++ element.insertAdjacentHTML("afterend", "<wbr>");+ element.remove();+ nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));+ updateTransaction(protyle, id, nodeElement.outerHTML, html);+ focusByWbr(nodeElement, protyle.toolbar.range);+ }+ }).element);+ window.siyuan.menus.menu.append(new MenuItem({+ icon: "iconTrashcan",+ label: window.siyuan.languages.remove,+ click() {+ element.insertAdjacentHTML("afterend", "<wbr>");+ element.remove();+ nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));+ updateTransaction(protyle, id, nodeElement.outerHTML, html);+ focusByWbr(nodeElement, protyle.toolbar.range);+ }+ }).element);+ }+ const rect = element.getBoundingClientRect();+ window.siyuan.menus.menu.popup({+ x: rect.left,+ y: rect.top + 26,+ h: 26+ });+}+const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement: HTMLElement, protyle: IProtyle, id: string, nodeElement: HTMLElement, html: string) => {return {iconHTML: "",diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 41864e4cf1..1b8ca56468 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -23,7 +23,7 @@ import {contentMenu,enterBack,fileAnnotationRefMenu,- imgMenu,+ imgMenu, inlineMathMenu,linkMenu,refMenu,setFold,@@ -1674,6 +1674,11 @@ export class WYSIWYG {return false;}}+ const inlineMathElement = hasClosestByAttribute(target, "data-type", "inline-math");+ if (inlineMathElement) {+ inlineMathMenu(protyle, inlineMathElement);+ return false;+ }if (target.tagName === "IMG" && hasClosestByClassName(target, "img")) {imgMenu(protyle, protyle.toolbar.range, target.parentElement.parentElement, {clientX: x + 4,diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex aba28d2e1f..0d19d50af9 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -54,7 +54,7 @@ import {getStartEndElement,upSelect} from "./commonHotkey";-import {fileAnnotationRefMenu, linkMenu, refMenu, setFold, tagMenu} from "../../menus/protyle";+import {fileAnnotationRefMenu, inlineMathMenu, linkMenu, refMenu, setFold, tagMenu} from "../../menus/protyle";import {openAttr} from "../../menus/commonMenuItem";import {Constants} from "../../constants";import {fetchPost} from "../../util/fetch";@@ -594,14 +594,14 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {previousSibling.nodeType !== 3 &&previousSibling.getAttribute("data-type")?.indexOf("inline-math") > -1) {- protyle.toolbar.showRender(protyle, previousSibling);+ inlineMathMenu(protyle, previousSibling);return;} else if (!previousSibling &&range.startContainer.parentElement.previousSibling &&range.startContainer.parentElement.previousSibling.isSameNode(range.startContainer.parentElement.previousElementSibling) &&range.startContainer.parentElement.previousElementSibling.getAttribute("data-type")?.indexOf("inline-math") > -1) {- protyle.toolbar.showRender(protyle, range.startContainer.parentElement.previousElementSibling);+ inlineMathMenu(protyle, range.startContainer.parentElement.previousElementSibling);return;}}