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/7123
Vanessaed3f2af467ae
diff --git a/app/src/emoji/index.ts b/app/src/emoji/index.tsindex cc151e67ee..5bb289458f 100644--- a/app/src/emoji/index.ts+++ b/app/src/emoji/index.ts@@ -430,9 +430,9 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFilconst updateFileEmoji = (unicode: string, id: string) => {/// #if MOBILE- if (window.siyuan.mobileEditor.protyle.block.rootID === id) {- window.siyuan.mobileEditor.protyle.background.ial.icon = unicode;- window.siyuan.mobileEditor.protyle.background.render(window.siyuan.mobileEditor.protyle.background.ial, window.siyuan.mobileEditor.protyle.block.rootID);+ if (window.siyuan.mobile.editor.protyle.block.rootID === id) {+ window.siyuan.mobile.editor.protyle.background.ial.icon = unicode;+ window.siyuan.mobile.editor.protyle.background.render(window.siyuan.mobile.editor.protyle.background.ial, window.siyuan.mobile.editor.protyle.block.rootID);}/// #elsegetAllModels().editor.find(item => {diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.tsindex 5ef5fccc72..503f2ed0c0 100644--- a/app/src/menus/navigation.ts+++ b/app/src/menus/navigation.ts@@ -23,6 +23,8 @@ import {Constants} from "../constants";import {newFile} from "../util/newFile";import {hasClosestByTag} from "../protyle/util/hasClosest";import {deleteFiles} from "../editor/deleteFile";+import {getDockByType} from "../layout/util";+import {Files} from "../layout/dock/Files";const initMultiMenu = (selectItemElements: NodeListOf<Element>) => {const fileItemElement = Array.from(selectItemElements).find(item => {@@ -172,7 +174,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:window.siyuan.menus.menu.remove();const fileElement = hasClosestByTag(liElement, "DIV");if (!fileElement) {- return window.siyuan.menus.menu;+ return window.siyuan.menus.menu;}if (!liElement.classList.contains("b3-list-item--focus")) {fileElement.querySelectorAll(".b3-list-item--focus").forEach(item => {@@ -385,7 +387,14 @@ const genImportMenu = (notebookId: string, pathString: string) => {formData.append("file", event.target.files[0]);formData.append("notebook", notebookId);formData.append("toPath", pathString);- fetchPost("/api/import/importSY", formData);+ fetchPost("/api/import/importSY", formData, () => {+ /// #if MOBILE+ window.siyuan.mobile.files.selectItem(notebookId, pathString);+ /// #else+ (getDockByType("file").data["file"] as Files).selectItem(notebookId, pathString)+ /// #endif+ window.siyuan.menus.menu.remove();+ });});}},diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex b317ee6464..7563bf7f09 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -456,7 +456,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushBreturn;}}- if (window.siyuan.mobileEditor) {+ if (window.siyuan.mobile.editor) {window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id,action: id === protyle.block.rootID ? [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT] : [Constants.CB_GET_ALL]diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.tsindex c2e2fc642f..a22eb1e1a2 100644--- a/app/src/mobile/editor.ts+++ b/app/src/mobile/editor.ts@@ -17,13 +17,13 @@ import {setStorageVal} from "../protyle/util/compatibility";export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) => {window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id, action};setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]);- if (window.siyuan.mobileEditor) {- hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle);- if (window.siyuan.mobileEditor.protyle.contentElement.classList.contains("fn__none")) {- setEditMode(window.siyuan.mobileEditor.protyle, "wysiwyg");+ if (window.siyuan.mobile.editor) {+ hideElements(["toolbar", "hint", "util"], window.siyuan.mobile.editor.protyle);+ if (window.siyuan.mobile.editor.protyle.contentElement.classList.contains("fn__none")) {+ setEditMode(window.siyuan.mobile.editor.protyle, "wysiwyg");}let blockElement;- Array.from(window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find((item: HTMLElement) => {+ Array.from(window.siyuan.mobile.editor.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`)).find((item: HTMLElement) => {if (!hasClosestByAttribute(item.parentElement, "data-type", "NodeBlockQueryEmbed")) {blockElement = item;return true;@@ -32,7 +32,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =if (blockElement) {pushBack();focusBlock(blockElement);- scrollCenter(window.siyuan.mobileEditor.protyle, blockElement, true);+ scrollCenter(window.siyuan.mobile.editor.protyle, blockElement, true);closePanel();return;}@@ -44,20 +44,20 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) =lockFile(data.data);return;}- if (window.siyuan.mobileEditor) {+ if (window.siyuan.mobile.editor) {pushBack();- addLoading(window.siyuan.mobileEditor.protyle);+ addLoading(window.siyuan.mobile.editor.protyle);fetchPost("/api/filetree/getDoc", {id,size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks,mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0,}, getResponse => {- onGet(getResponse, window.siyuan.mobileEditor.protyle, action);- window.siyuan.mobileEditor.protyle.breadcrumb?.render(window.siyuan.mobileEditor.protyle);+ onGet(getResponse, window.siyuan.mobile.editor.protyle, action);+ window.siyuan.mobile.editor.protyle.breadcrumb?.render(window.siyuan.mobile.editor.protyle);});- window.siyuan.mobileEditor.protyle.undo.clear();+ window.siyuan.mobile.editor.protyle.undo.clear();} else {- window.siyuan.mobileEditor = new Protyle(document.getElementById("editor"), {+ window.siyuan.mobile.editor = new Protyle(document.getElementById("editor"), {blockId: id,action,render: {diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.tsindex 2055c8150f..8b113f497b 100644--- a/app/src/mobile/index.ts+++ b/app/src/mobile/index.ts@@ -29,6 +29,7 @@ class App {backStack: [],dialogs: [],blockPanels: [],+ mobile: {},menus: new Menus(),ws: new Model({id: genUUID(),diff --git a/app/src/mobile/settings/appearance.ts b/app/src/mobile/settings/appearance.tsindex ce089712bb..454558040c 100644--- a/app/src/mobile/settings/appearance.ts+++ b/app/src/mobile/settings/appearance.ts@@ -57,7 +57,7 @@ export const initAppearance = (modelElement: HTMLElement, modelMainElement: HTMLwindow.siyuan.config.editor.fontSize = parseInt(event.target.value);fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {window.siyuan.config.editor = response.data;- reloadProtyle(window.siyuan.mobileEditor.protyle);+ reloadProtyle(window.siyuan.mobile.editor.protyle);setInlineStyle();});});diff --git a/app/src/mobile/util/MobileBackFoward.ts b/app/src/mobile/util/MobileBackFoward.tsindex 1a54222cac..f7a2a67ae0 100644--- a/app/src/mobile/util/MobileBackFoward.ts+++ b/app/src/mobile/util/MobileBackFoward.ts@@ -12,13 +12,13 @@ import {setStorageVal} from "../../protyle/util/compatibility";const forwardStack: IBackStack[] = [];const focusStack = (backStack: IBackStack) => {- const protyle = window.siyuan.mobileEditor.protyle;+ const protyle = window.siyuan.mobile.editor.protyle;window.siyuan.storage[Constants.LOCAL_DOCINFO] = {id: backStack.id,action: backStack.callback,};setStorageVal(Constants.LOCAL_DOCINFO, window.siyuan.storage[Constants.LOCAL_DOCINFO]);- hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle);+ hideElements(["toolbar", "hint", "util"], window.siyuan.mobile.editor.protyle);if (protyle.contentElement.classList.contains("fn__none")) {setEditMode(protyle, "wysiwyg");}@@ -26,7 +26,7 @@ const focusStack = (backStack: IBackStack) => {const startEndId = backStack.endId.split(Constants.ZWSP);if (startEndId[0] === protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id") &&startEndId[1] === protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id")) {- window.siyuan.mobileEditor.protyle.contentElement.scrollTo({+ window.siyuan.mobile.editor.protyle.contentElement.scrollTo({top: backStack.scrollTop,behavior: "smooth"});@@ -81,12 +81,12 @@ const focusStack = (backStack: IBackStack) => {}}protyle.contentElement.scrollTop = backStack.scrollTop;- window.siyuan.mobileEditor.protyle.breadcrumb?.render(protyle);+ window.siyuan.mobile.editor.protyle.breadcrumb?.render(protyle);});};export const pushBack = () => {- const protyle = window.siyuan.mobileEditor.protyle;+ const protyle = window.siyuan.mobile.editor.protyle;window.siyuan.backStack.push({id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,endId: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id") + Constants.ZWSP + protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"),@@ -116,7 +116,7 @@ export const goBack = () => {if (window.siyuan.backStack.length < 1) {return;}- const protyle = window.siyuan.mobileEditor.protyle;+ const protyle = window.siyuan.mobile.editor.protyle;if (forwardStack.length === 0) {forwardStack.push({id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID,diff --git a/app/src/mobile/util/MobileBacklinks.ts b/app/src/mobile/util/MobileBacklinks.tsindex 66f596b8f1..d2de315938 100644--- a/app/src/mobile/util/MobileBacklinks.ts+++ b/app/src/mobile/util/MobileBacklinks.ts@@ -106,7 +106,7 @@ export class MobileBacklinks {public update() {fetchPost("/api/ref/getBacklink", {- id: window.siyuan.mobileEditor.protyle.block.id,+ id: window.siyuan.mobile.editor.protyle.block.id,beforeLen: this.beforeLen,k: "",mk: "",diff --git a/app/src/mobile/util/MobileFiles.ts b/app/src/mobile/util/MobileFiles.tsindex 7a650b77b7..41c0cac2a7 100644--- a/app/src/mobile/util/MobileFiles.ts+++ b/app/src/mobile/util/MobileFiles.ts@@ -99,8 +99,8 @@ export class MobileFiles extends Model {event.preventDefault();break;} else if (type === "focus") {- if (window.siyuan.mobileEditor) {- this.selectItem(window.siyuan.mobileEditor.protyle.notebookId, window.siyuan.mobileEditor.protyle.path);+ if (window.siyuan.mobile.editor) {+ this.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);}event.preventDefault();break;diff --git a/app/src/mobile/util/MobileOutline.ts b/app/src/mobile/util/MobileOutline.tsindex 77447daeb0..2c9dda7806 100644--- a/app/src/mobile/util/MobileOutline.ts+++ b/app/src/mobile/util/MobileOutline.ts@@ -49,7 +49,7 @@ export class MobileOutline {public update() {fetchPost("/api/outline/getDocOutline", {- id: window.siyuan.mobileEditor.protyle.block.rootID,+ id: window.siyuan.mobile.editor.protyle.block.rootID,}, response => {let currentId;let currentElement = this.element.querySelector(".b3-list-item--focus");@@ -57,7 +57,7 @@ export class MobileOutline {currentId = currentElement.getAttribute("data-node-id");}- const blockId = window.siyuan.mobileEditor.protyle.block.rootID;+ const blockId = window.siyuan.mobile.editor.protyle.block.rootID;if (this.openNodes[blockId]) {this.openNodes[blockId] = this.tree.getExpandIds();}diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.tsindex f70db127d7..f93c43a320 100644--- a/app/src/mobile/util/initFramework.ts+++ b/app/src/mobile/util/initFramework.ts@@ -73,7 +73,7 @@ export const initFramework = () => {}});});- new MobileFiles();+ window.siyuan.mobile.files = new MobileFiles();document.getElementById("toolbarFile").addEventListener("click", () => {sidebarElement.style.left = "0";document.querySelector(".scrim").classList.remove("fn__none");@@ -110,11 +110,11 @@ export const initFramework = () => {window.siyuan.config.editor.readOnly = isReadonly;fetchPost("/api/setting/setEditor", window.siyuan.config.editor, () => {if (!isReadonly) {- enableProtyle(window.siyuan.mobileEditor.protyle);+ enableProtyle(window.siyuan.mobile.editor.protyle);inputElement.readOnly = false;editIconElement.setAttribute("xlink:href", "#iconEdit");} else {- disabledProtyle(window.siyuan.mobileEditor.protyle);+ disabledProtyle(window.siyuan.mobile.editor.protyle);inputElement.readOnly = true;editIconElement.setAttribute("xlink:href", "#iconPreview");}@@ -169,7 +169,7 @@ const initEditorName = () => {hideKeyboardToolbar();});inputElement.addEventListener("blur", () => {- if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || window.siyuan.mobileEditor.protyle.disabled) {+ if (window.siyuan.config.readonly || window.siyuan.config.editor.readOnly || window.siyuan.mobile.editor.protyle.disabled) {return;}if (!validateName(inputElement.value)) {@@ -178,8 +178,8 @@ const initEditorName = () => {}fetchPost("/api/filetree/renameDoc", {- notebook: window.siyuan.mobileEditor.protyle.notebookId,- path: window.siyuan.mobileEditor.protyle.path,+ notebook: window.siyuan.mobile.editor.protyle.notebookId,+ path: window.siyuan.mobile.editor.protyle.path,title: inputElement.value,});});diff --git a/app/src/mobile/util/search.ts b/app/src/mobile/util/search.tsindex 6df65a1973..7fe9a21657 100644--- a/app/src/mobile/util/search.ts+++ b/app/src/mobile/util/search.ts@@ -75,8 +75,8 @@ export const popSearch = (modelElement: HTMLElement, modelMainElement: HTMLElemewhile (target && !target.isEqualNode(searchElement)) {if (target.classList.contains("b3-list-item")) {const id = target.getAttribute("data-id");- if (window.siyuan.mobileEditor.protyle) {- preventScroll(window.siyuan.mobileEditor.protyle);+ if (window.siyuan.mobile.editor.protyle) {+ preventScroll(window.siyuan.mobile.editor.protyle);}fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {openMobileFileById(id,foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);diff --git a/app/src/mobile/util/setEmpty.ts b/app/src/mobile/util/setEmpty.tsindex 5268155d1e..1b68ab2747 100644--- a/app/src/mobile/util/setEmpty.ts+++ b/app/src/mobile/util/setEmpty.ts@@ -20,8 +20,8 @@ export const setEmpty = () => {<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.help}</span></div>`;document.getElementById("emptyNewFile").addEventListener(getEventName(), () => {- if (window.siyuan.mobileEditor) {- newFile(window.siyuan.mobileEditor.protyle.notebookId, window.siyuan.mobileEditor.protyle.path, true);+ if (window.siyuan.mobile.editor) {+ newFile(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path, true);} else {window.siyuan.notebooks.find(item => {if (item.closed) {diff --git a/app/src/mobile/util/showKeyboardToolbar.ts b/app/src/mobile/util/showKeyboardToolbar.tsindex 50d65f9f37..345298c452 100644--- a/app/src/mobile/util/showKeyboardToolbar.ts+++ b/app/src/mobile/util/showKeyboardToolbar.ts@@ -8,8 +8,8 @@ import {focusByRange, getSelectionPosition} from "../../protyle/util/selection";export const showKeyboardToolbar = (bottom = 0) => {if (getSelection().rangeCount > 0) {const range = getSelection().getRangeAt(0);- if (!window.siyuan.mobileEditor ||- !window.siyuan.mobileEditor.protyle.wysiwyg.element.contains(range.startContainer)) {+ if (!window.siyuan.mobile.editor ||+ !window.siyuan.mobile.editor.protyle.wysiwyg.element.contains(range.startContainer)) {return;}} else {@@ -23,7 +23,7 @@ export const showKeyboardToolbar = (bottom = 0) => {toolbarElement.style.bottom = bottom + "px";setTimeout(() => {- const contentElement = window.siyuan.mobileEditor.protyle.contentElement;+ const contentElement = window.siyuan.mobile.editor.protyle.contentElement;const cursorTop = getSelectionPosition(contentElement).top - contentElement.getBoundingClientRect().top;if (cursorTop < window.innerHeight - 96) {return;@@ -46,16 +46,16 @@ export const initKeyboardToolbar = () => {toolbarElement.addEventListener("click", (event) => {const target = event.target as HTMLElement;const buttonElement = hasClosestByMatchTag(target, "BUTTON");- if (!buttonElement || !window.siyuan.mobileEditor) {+ if (!buttonElement || !window.siyuan.mobile.editor) {return;}- if (window.siyuan.mobileEditor.protyle.disabled) {+ if (window.siyuan.mobile.editor.protyle.disabled) {return;}event.preventDefault();event.stopPropagation();const type = buttonElement.getAttribute("data-type");- const protyle = window.siyuan.mobileEditor.protyle;+ const protyle = window.siyuan.mobile.editor.protyle;if (type === "undo") {protyle.undo.undo(protyle);return;diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.tsindex 54fb006b86..ec853b6abe 100644--- a/app/src/mobile/util/touch.ts+++ b/app/src/mobile/util/touch.ts@@ -6,7 +6,7 @@ let xDiff: number;let yDiff: number;export const handleTouchEnd = () => {- if (window.siyuan.mobileEditor) {+ if (window.siyuan.mobile.editor) {document.querySelectorAll(".protyle-breadcrumb__bar--hide").forEach(item => {item.classList.remove("protyle-breadcrumb__bar--hide");});diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 4b969fe696..63ef2880d3 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -52,8 +52,8 @@ interface Window {}interface IWorkspace {- path:string- closed:boolean+ path: string+ closed: boolean}interface ICard {@@ -171,7 +171,10 @@ interface ISiyuan {notebooks?: INotebook[],emojis?: IEmoji[],backStack?: IBackStack[],- mobileEditor?: import("../protyle").Protyle, // mobile+ mobile?: {+ editor?: import("../protyle").Protyle+ files?: import("../mobile/util/MobileFiles").MobileFiles+ },user?: {userId: stringuserName: string