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/12294
Vanessa57040323188a
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex de0c0f4adb..9af4c9f0ca 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -61,7 +61,7 @@ import {popSearch} from "../mobile/menu/search";import {showMessage} from "../dialog/message";import {img3115} from "../boot/compatibleVersion";import {hideTooltip} from "../dialog/tooltip";-import {clearSelect} from "../protyle/util/clearSelect";+import {clearSelect} from "../protyle/util/clear";import {scrollCenter} from "../util/highlightById";const renderAssetList = (element: Element, k: string, position: IPosition, exts: string[] = []) => {diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 6dd37ecd84..d0a79a37e6 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -62,7 +62,7 @@ import {openFileById} from "../../editor/util";import * as path from "path";/// #endifimport {checkFold} from "../../util/noRelyPCFunction";-import {clearSelect} from "../util/clearSelect";+import {clearSelect} from "../util/clear";export class Gutter {public element: HTMLElement;diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.tsindex 16c4d895e1..0e87428cce 100644--- a/app/src/protyle/render/av/action.ts+++ b/app/src/protyle/render/av/action.ts@@ -36,7 +36,7 @@ import {fetchPost, fetchSyncPost} from "../../../util/fetch";import {scrollCenter} from "../../../util/highlightById";import {escapeHtml} from "../../../util/escape";import {editGalleryItem, openGalleryItemMenu} from "./gallery/util";-import {clearSelect} from "../../util/clearSelect";+import {clearSelect} from "../../util/clear";import {removeCompressURL} from "../../../util/image";let foldTimeout: number;diff --git a/app/src/protyle/render/av/gallery/item.ts b/app/src/protyle/render/av/gallery/item.tsindex d3b962f344..1c1a099b6e 100644--- a/app/src/protyle/render/av/gallery/item.ts+++ b/app/src/protyle/render/av/gallery/item.ts@@ -2,7 +2,7 @@ import {genCellValue, getTypeByCellElement, renderCell, renderCellAttr} from "..import {fetchPost} from "../../../../util/fetch";import {setPage} from "../row";import {Constants} from "../../../../constants";-import {clearSelect} from "../../../util/clearSelect";+import {clearSelect} from "../../../util/clear";export const insertGalleryItemAnimation = (options: {blockElement: HTMLElement;diff --git a/app/src/protyle/render/av/keydown.ts b/app/src/protyle/render/av/keydown.tsindex a2d1a0f8d4..35fd364caf 100644--- a/app/src/protyle/render/av/keydown.ts+++ b/app/src/protyle/render/av/keydown.ts@@ -5,7 +5,7 @@ import {avContextmenu} from "./action";import {hasClosestByClassName} from "../../util/hasClosest";import {Constants} from "../../../constants";import {upDownHint} from "../../../util/upDownHint";-import {clearSelect} from "../../util/clearSelect";+import {clearSelect} from "../../util/clear";export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protyle: IProtyle) => {if (!nodeElement.classList.contains("av") || !window.siyuan.menus.menu.element.classList.contains("fn__none")) {diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.tsindex c795de9cd9..5702fdd4fc 100644--- a/app/src/protyle/render/av/render.ts+++ b/app/src/protyle/render/av/render.ts@@ -17,7 +17,7 @@ import {renderGallery} from "./gallery/render";import {getFieldsByData, getViewIcon} from "./view";import {openMenuPanel} from "./openMenuPanel";import {getPageSize} from "./groups";-import {clearSelect} from "../../util/clearSelect";+import {clearSelect} from "../../util/clear";import {showMessage} from "../../../dialog/message";import {renderKanban} from "./kanban/render";diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.tsindex 86291db256..c64141cb7f 100644--- a/app/src/protyle/render/av/row.ts+++ b/app/src/protyle/render/av/row.ts@@ -7,7 +7,7 @@ import {fetchPost} from "../../../util/fetch";import * as dayjs from "dayjs";import {Constants} from "../../../constants";import {insertGalleryItemAnimation} from "./gallery/item";-import {clearSelect} from "../../util/clearSelect";+import {clearSelect} from "../../util/clear";import {isCustomAttr} from "./blockAttr";export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {diff --git a/app/src/protyle/util/clearSelect.ts b/app/src/protyle/util/clear.tssimilarity index 73%rename from app/src/protyle/util/clearSelect.tsrename to app/src/protyle/util/clear.tsindex f010919cb2..a805981acd 100644--- a/app/src/protyle/util/clearSelect.ts+++ b/app/src/protyle/util/clear.ts@@ -1,4 +1,21 @@import {updateHeader} from "../render/av/row";+import {Constants} from "../../constants";++export const clearBlockElement = (element: Element) => {+ element.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");+ element.removeAttribute(Constants.CUSTOM_RIFF_DECKS);+ element.removeAttribute("refcount");+ element.querySelector(".protyle-attr--av")?.remove();+ element.querySelector(".protyle-attr--refcount")?.remove();+ element.removeAttribute("custom-avs");+ element.removeAttribute("av-names");+ debugger+ element.getAttributeNames().forEach(attr => {+ if (attr.startsWith("custom-sy-av-s-text-")) {+ element.removeAttribute(attr);+ }+ })+};export const clearSelect = (types: ("av" | "img" | "cell" | "row" | "galleryItem")[], element: Element) => {if (types.includes("cell")) {diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex a60afc39fd..30eb9fec69 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -34,7 +34,7 @@ import {webUtils} from "electron";import {addDragFill, getTypeByCellElement} from "../render/av/cell";import {processClonePHElement} from "../render/util";import {insertGalleryItemAnimation} from "../render/av/gallery/item";-import {clearSelect} from "./clearSelect";+import {clearSelect} from "./clear";import {dragoverTab} from "../render/av/view";// position: afterbegin 为拖拽成超级块; "afterend", "beforebegin" 一般拖拽diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex 1b605b4940..f39a3c98a8 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -14,6 +14,7 @@ import {hideElements} from "../ui/hideElements";import {avRender} from "../render/av/render";import {cellScrollIntoView, getCellText} from "../render/av/cell";import {getContenteditableElement} from "../wysiwyg/getBlock";+import {clearBlockElement} from "./clear";export const getTextStar = (blockElement: HTMLElement) => {const dataType = blockElement.dataset.type;@@ -407,13 +408,8 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEventempElement.querySelectorAll("[data-node-id]").forEach((e) => {const newId = Lute.NewNodeID();e.setAttribute("data-node-id", newId);- e.removeAttribute(Constants.CUSTOM_RIFF_DECKS);e.classList.remove("protyle-wysiwyg--select", "protyle-wysiwyg--hl");- e.setAttribute("updated", newId.split("-")[0]);- e.removeAttribute("refcount");- e.querySelector(".protyle-attr--av")?.remove();- e.removeAttribute("custom-avs");- e.removeAttribute("av-names");+ clearBlockElement(e);isBlock = true;});if (nodeElement.classList.contains("table")) {diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.tsindex 11c4d733bb..05438fd73b 100644--- a/app/src/protyle/wysiwyg/commonHotkey.ts+++ b/app/src/protyle/wysiwyg/commonHotkey.ts@@ -15,6 +15,7 @@ import {processClonePHElement} from "../render/util";import {copyTextByType} from "../toolbar/util";import {hasClosestByTag, hasTopClosestByClassName} from "../util/hasClosest";import {removeEmbed} from "./removeEmbed";+import {clearBlockElement} from "../util/clear";export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent, nodeElement?: HTMLElement) => {if (matchHotKey(window.siyuan.config.keymap.editor.general.netImg2LocalAsset.custom, event)) {@@ -313,25 +314,13 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)focusElement = tempElement;}tempElement.setAttribute("data-node-id", newId);- tempElement.removeAttribute(Constants.CUSTOM_RIFF_DECKS);- tempElement.classList.remove("protyle-wysiwyg--hl");tempElement.setAttribute("updated", newId.split("-")[0]);- tempElement.removeAttribute("refcount");- tempElement.lastElementChild.querySelector(".protyle-attr--refcount")?.remove();- tempElement.lastElementChild.querySelector(".protyle-attr--av")?.remove();- tempElement.removeAttribute("custom-avs");- tempElement.removeAttribute("av-names");+ clearBlockElement(tempElement);tempElement.querySelectorAll("[data-node-id]").forEach(childItem => {const subNewId = Lute.NewNodeID();childItem.setAttribute("data-node-id", subNewId);- childItem.removeAttribute(Constants.CUSTOM_RIFF_DECKS);- childItem.classList.remove("protyle-wysiwyg--hl");childItem.setAttribute("updated", subNewId.split("-")[0]);- childItem.removeAttribute("refcount");- childItem.lastElementChild.querySelector(".protyle-attr--refcount")?.remove();- childItem.lastElementChild.querySelector(".protyle-attr--av")?.remove();- childItem.removeAttribute("custom-avs");- childItem.removeAttribute("av-names");+ clearBlockElement(childItem);});if (typeof starIndex === "number") {const orderIndex = starIndex + index + 1;@@ -360,19 +349,11 @@ export const duplicateBlock = async (nodeElements: Element[], protyle: IProtyle)}childItem.querySelectorAll("[data-node-id]").forEach(subItem => {subItem.setAttribute("data-node-id", Lute.NewNodeID());- subItem.removeAttribute(Constants.CUSTOM_RIFF_DECKS);- subItem.removeAttribute("refcount");- subItem.lastElementChild.querySelector(".protyle-attr--av")?.remove();- subItem.removeAttribute("custom-avs");- subItem.removeAttribute("av-names");+ clearBlockElement(subItem);});const newChildId = Lute.NewNodeID();childItem.setAttribute("data-node-id", newChildId);- childItem.removeAttribute(Constants.CUSTOM_RIFF_DECKS);- childItem.removeAttribute("refcount");- childItem.lastElementChild.querySelector(".protyle-attr--av")?.remove();- childItem.removeAttribute("custom-avs");- childItem.removeAttribute("av-names");+ clearBlockElement(childItem);doOperations.push({context: {ignoreProcess: "true"diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex c9ca0ca175..08699beb74 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -99,7 +99,7 @@ import {img3115} from "../../boot/compatibleVersion";import {globalClickHideMenu} from "../../boot/globalEvent/click";import {hideTooltip} from "../../dialog/tooltip";import {openGalleryItemMenu} from "../render/av/gallery/util";-import {clearSelect} from "../util/clearSelect";+import {clearSelect} from "../util/clear";import {chartRender} from "../render/chartRender";export class WYSIWYG {