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/18384
Vanessa8b0166322c5d
diff --git a/app/src/layout/dock/agent/AgentChat.ts b/app/src/layout/dock/agent/AgentChat.tsindex d5a794cb1f..a525412aac 100644--- a/app/src/layout/dock/agent/AgentChat.ts+++ b/app/src/layout/dock/agent/AgentChat.ts@@ -4,7 +4,7 @@ import type {App} from "../../../index";import {AgentHttpError, fetchAgentSSE, IEditorContext, ISSEResult, IToolEffects} from "./agentSSE";import {genUUID} from "../../../util/genID";import {mountComposer} from "./AgentComposer";-import {disabledWYSIWYG} from "../../../protyle/util/onGet";+import {disabledWYSIWYG} from "../../../protyle/util/disabledWYSIWYG";import {getAllEditor} from "../../getAll";import "./frontendActions";import {listActions, lookupAction} from "./frontendActions";diff --git a/app/src/protyle/render/blockRender.ts b/app/src/protyle/render/blockRender.tsindex 342dc62be3..516383c072 100644--- a/app/src/protyle/render/blockRender.ts+++ b/app/src/protyle/render/blockRender.ts@@ -6,6 +6,7 @@ import {genBreadcrumb, improveBreadcrumbAppearance} from "../wysiwyg/renderBacklimport {avRender} from "./av/render";import {genRenderFrame} from "./util";import {isEncryptedBox} from "../../util/pathName";+import {disabledWYSIWYG} from "../util/disabledWYSIWYG";/*** 渲染嵌入块@@ -136,6 +137,10 @@ ${popover}${breadcrumbHTML}${blocksItem.block.content}processRender(item);highlightRender(item);avRender(item, protyle);+ if (protyle.disabled) {+ // 嵌入块异步渲染可能晚于只读状态设置,需同步禁用新插入的可编辑节点+ disabledWYSIWYG(item);+ }if (top) {// 前进后退定位 https://ld246.com/article/1667652729995protyle.contentElement.scrollTop = top;diff --git a/app/src/protyle/util/disabledWYSIWYG.ts b/app/src/protyle/util/disabledWYSIWYG.tsnew file mode 100644index 0000000000..b1f2f7b6b5--- /dev/null+++ b/app/src/protyle/util/disabledWYSIWYG.ts@@ -0,0 +1,24 @@+export const disabledWYSIWYG = (element: HTMLElement) => {+ element.querySelectorAll(".protyle-icons--show").forEach(item => {+ item.classList.remove("protyle-icons--show");+ });+ element.querySelectorAll(".av__gallery-fields--edit").forEach(item => {+ item.classList.remove("av__gallery-fields--edit");+ });+ element.querySelectorAll(".render-node .protyle-action__edit").forEach(item => {+ item.classList.add("fn__none");+ if (item.classList.contains("protyle-icon--first")) {+ item.nextElementSibling?.classList.add("protyle-icon--first");+ }+ });+ element.style.userSelect = "text";+ element.setAttribute("contenteditable", "false");+ // 用于区分移动端样式+ element.setAttribute("data-readonly", "true");+ element.querySelectorAll('[contenteditable="true"][spellcheck]').forEach(item => {+ item.setAttribute("contenteditable", "false");+ });+ element.querySelectorAll('.protyle-action[draggable="true"]').forEach(item => {+ item.setAttribute("draggable", "false");+ });+};diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex e8e971e24c..d9864905f0 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -27,6 +27,7 @@ import {renderHeadingNumbers} from "./headingNumber";import {updateDocumentBottomEof} from "./documentRange";+import {disabledWYSIWYG} from "./disabledWYSIWYG";export const onGet = (options: {data: IWebSocketData,@@ -413,31 +414,6 @@ export const disabledForeverProtyle = (protyle: IProtyle) => {protyle.element.setAttribute("disabled-forever", "true");};-export const disabledWYSIWYG = (element: HTMLElement) => {- element.querySelectorAll(".protyle-icons--show").forEach(item => {- item.classList.remove("protyle-icons--show");- });- element.querySelectorAll(".av__gallery-fields--edit").forEach(item => {- item.classList.remove("av__gallery-fields--edit");- });- element.querySelectorAll(".render-node .protyle-action__edit").forEach(item => {- item.classList.add("fn__none");- if (item.classList.contains("protyle-icon--first")) {- item.nextElementSibling?.classList.add("protyle-icon--first");- }- });- element.style.userSelect = "text";- element.setAttribute("contenteditable", "false");- // 用于区分移动端样式- element.setAttribute("data-readonly", "true");- element.querySelectorAll('[contenteditable="true"][spellcheck]').forEach(item => {- item.setAttribute("contenteditable", "false");- });- element.querySelectorAll('.protyle-action[draggable="true"]').forEach(item => {- item.setAttribute("draggable", "false");- });-};-/** 禁用编辑器 */export const disabledProtyle = (protyle: IProtyle) => {window.siyuan.menus.menu.remove();