An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:recycle:
Vanessa968f666d19c5
diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex ea2a6235b9..62e1e7ca9a 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -1,19 +1,16 @@import {Tab} from "../layout/Tab";import {Editor} from "./index";import {Wnd} from "../layout/Wnd";-import {getDockByType, getInstanceById, getWndByLayout, switchWnd} from "../layout/util";+import {getDockByType, getInstanceById, getWndByLayout} from "../layout/util";import {getAllModels} from "../layout/getAll";import {highlightById, scrollCenter} from "../util/highlightById";import {getDisplayName, pathPosix} from "../util/pathName";import {Constants} from "../constants";-import {Outline} from "../layout/dock/Outline";import {setEditMode} from "../protyle/util/setEditMode";import {Files} from "../layout/dock/Files";import {setPadding} from "../protyle/ui/initUI";import {fetchPost} from "../util/fetch";import {showMessage} from "../dialog/message";-import {Backlinks} from "../layout/dock/Backlinks";-import {Graph} from "../layout/dock/Graph";import {focusBlock, focusByRange} from "../protyle/util/selection";import {onGet} from "../protyle/util/onGet";/// #if !BROWSER@@ -32,86 +29,6 @@ import {lockFile, setTitle} from "../dialog/processSystem";import {zoomOut} from "../menus/protyle";import {confirmDialog} from "../dialog/confirmDialog";-export const openOutline = (protyle: IProtyle) => {- const outlinePanel = getAllModels().outline.find(item => {- if (item.blockId === protyle.block.rootID && item.type === "local") {- item.parent.parent.removeTab(item.parent.id);- return true;- }- });- if (outlinePanel) {- return;- }- const newWnd = protyle.model.parent.parent.split("lr");- const tab = new Tab({- icon: "iconAlignCenter",- title: protyle.title.editElement.textContent,- callback(tab: Tab) {- tab.addModel(new Outline({- type: "local",- tab,- blockId: protyle.block.rootID,- }));- }- });- newWnd.addTab(tab);- newWnd.element.classList.remove("fn__flex-1");- newWnd.element.style.width = "200px";- switchWnd(newWnd, protyle.model.parent.parent);-};--export const openBacklink = (protyle: IProtyle) => {- const backlink = getAllModels().backlinks.find(item => {- if (item.blockId === protyle.block.id && item.type === "local") {- item.parent.parent.removeTab(item.parent.id);- return true;- }- });- if (backlink) {- return;- }- const newWnd = protyle.model.parent.parent.split("lr");- const tab = new Tab({- icon: "iconLink",- title: protyle.title.editElement.textContent,- callback(tab: Tab) {- tab.addModel(new Backlinks({- type: "local",- tab,- blockId: protyle.block.id,- rootId: protyle.block.rootID,- }));- }- });- newWnd.addTab(tab);-};--export const openGraph = (protyle: IProtyle) => {- const graph = getAllModels().graph.find(item => {- if (item.blockId === protyle.block.id && item.type === "local") {- item.parent.parent.removeTab(item.parent.id);- return true;- }- });- if (graph) {- return;- }- const wnd = protyle.model.parent.parent.split("lr");- const tab = new Tab({- icon: "iconGraph",- title: protyle.title.editElement.textContent,- callback(tab: Tab) {- tab.addModel(new Graph({- type: "local",- tab,- blockId: protyle.block.id,- rootId: protyle.block.rootID,- }));- }- });- wnd.addTab(tab);-};-export const openFileById = (options: {id: string,position?: string,diff --git a/app/src/layout/dock/util.ts b/app/src/layout/dock/util.tsnew file mode 100644index 0000000000..d4646baefe--- /dev/null+++ b/app/src/layout/dock/util.ts@@ -0,0 +1,86 @@+import {getAllModels} from "../getAll";+import {Tab} from "../Tab";+import {Backlinks} from "./Backlinks";+import {Graph} from "./Graph";+import {Outline} from "./Outline";+import {switchWnd} from "../util";++export const openBacklink = (protyle: IProtyle) => {+ const backlink = getAllModels().backlinks.find(item => {+ if (item.blockId === protyle.block.id && item.type === "local") {+ item.parent.parent.removeTab(item.parent.id);+ return true;+ }+ });+ if (backlink) {+ return;+ }+ const newWnd = protyle.model.parent.parent.split("lr");+ const tab = new Tab({+ icon: "iconLink",+ title: protyle.title.editElement.textContent,+ callback(tab: Tab) {+ tab.addModel(new Backlinks({+ type: "local",+ tab,+ blockId: protyle.block.id,+ rootId: protyle.block.rootID,+ }));+ }+ });+ newWnd.addTab(tab);+};++export const openGraph = (protyle: IProtyle) => {+ const graph = getAllModels().graph.find(item => {+ if (item.blockId === protyle.block.id && item.type === "local") {+ item.parent.parent.removeTab(item.parent.id);+ return true;+ }+ });+ if (graph) {+ return;+ }+ const wnd = protyle.model.parent.parent.split("lr");+ const tab = new Tab({+ icon: "iconGraph",+ title: protyle.title.editElement.textContent,+ callback(tab: Tab) {+ tab.addModel(new Graph({+ type: "local",+ tab,+ blockId: protyle.block.id,+ rootId: protyle.block.rootID,+ }));+ }+ });+ wnd.addTab(tab);+};++export const openOutline = (protyle: IProtyle) => {+ const outlinePanel = getAllModels().outline.find(item => {+ if (item.blockId === protyle.block.rootID && item.type === "local") {+ item.parent.parent.removeTab(item.parent.id);+ return true;+ }+ });+ if (outlinePanel) {+ return;+ }+ const newWnd = protyle.model.parent.parent.split("lr");+ const tab = new Tab({+ icon: "iconAlignCenter",+ title: protyle.title.editElement.textContent,+ callback(tab: Tab) {+ tab.addModel(new Outline({+ type: "local",+ tab,+ blockId: protyle.block.rootID,+ }));+ }+ });+ newWnd.addTab(tab);+ newWnd.element.classList.remove("fn__flex-1");+ newWnd.element.style.width = "200px";+ switchWnd(newWnd, protyle.model.parent.parent);+};diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex 2d76f63e43..5db2449bf5 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -752,24 +752,31 @@ export const openMenu = (src: string, onlyMenu = false) => {});/// #endif} else {+ /// #if !BROWSERsubmenu.push({label: window.siyuan.languages.useDefault,accelerator: "Click",click: () => {- /// #if !BROWSERshell.openExternal(src).catch((e) => {- console.log("openExternal error:" + e);+ showMessage(e);});- /// #else- if (window.siyuan.config.system.container === "ios") {- window.location.href = src;- } else {- window.open(src);- }- /// #endif}});+ /// #endif}+ /// #if BROWSER+ submenu.push({+ label: window.siyuan.languages.useBrowserView,+ accelerator: "Click",+ click: () => {+ if (window.siyuan.config.system.container === "ios") {+ window.location.href = src;+ } else {+ window.open(src);+ }+ }+ });+ /// #endifif (onlyMenu) {return submenu;}diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 7021df7a32..dd72656028 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -18,13 +18,14 @@ import {matchHotKey} from "../util/hotKey";import {updateHotkeyTip, writeText} from "../util/compatibility";import {setPanelFocus} from "../../layout/util";import {escapeHtml} from "../../util/escape";-import {deleteFile, openBacklink, openGraph, openOutline, updatePanelByEditor} from "../../editor/util";+import {deleteFile, updatePanelByEditor} from "../../editor/util";import * as dayjs from "dayjs";import {setTitle} from "../../dialog/processSystem";import {getNoContainerElement} from "../wysiwyg/getBlock";import {commonHotkey} from "../wysiwyg/commonHotkey";import {setPosition} from "../../util/setPosition";import {code160to32} from "../util/code160to32";+import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";export class Title {public element: HTMLElement;diff --git a/app/src/protyle/preview/index.ts b/app/src/protyle/preview/index.tsindex 4b90c3143a..f0f1d2e9c6 100644--- a/app/src/protyle/preview/index.ts+++ b/app/src/protyle/preview/index.ts@@ -56,7 +56,7 @@ export class Preview {} else {/// #if !BROWSERshell.openExternal(linkAddress).catch((e) => {- console.log("openExternal error:" + e);+ showMessage(e);});/// #elsewindow.open(linkAddress);diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.tsindex e1c268d5bf..d4f1a59fee 100644--- a/app/src/protyle/wysiwyg/commonHotkey.ts+++ b/app/src/protyle/wysiwyg/commonHotkey.ts@@ -1,12 +1,12 @@import {matchHotKey} from "../util/hotKey";import {fetchPost} from "../../util/fetch";import {writeText} from "../util/compatibility";-import {openBacklink, openGraph, openOutline} from "../../editor/util";import {focusByOffset, getSelectionOffset} from "../util/selection";import {fullscreen} from "../breadcrumb/action";import {addLoading, setPadding} from "../ui/initUI";import {Constants} from "../../constants";import {onGet} from "../util/onGet";+import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {const target = event.target as HTMLElement;diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 3285ed9d52..3b047d6aec 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -55,6 +55,7 @@ import {fetchPost} from "../../util/fetch";import {onGet} from "../util/onGet";import {setTableAlign} from "../util/table";import {countBlockWord, countSelectWord} from "../../layout/status";+import {showMessage} from "../../dialog/message";export class WYSIWYG {public lastHTMLs: { [key: string]: string } = {};@@ -1463,7 +1464,7 @@ export class WYSIWYG {} else {/// #if !BROWSERshell.openExternal(linkAddress).catch((e) => {- console.log("openExternal error:" + e);+ showMessage(e);});/// #elseif (window.siyuan.config.system.container === "ios") {