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: fix https://github.com/siyuan-note/siyuan/issues/10604
Vanessa60beaf291d5d
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.tsindex 214be13887..932d5cd58e 100644--- a/app/src/menus/commonMenuItem.ts+++ b/app/src/menus/commonMenuItem.ts@@ -20,6 +20,7 @@ import {Constants} from "../constants";import {exportImage} from "../protyle/export/util";import {App} from "../index";import {renderAVAttribute} from "../protyle/render/av/blockAttr";+import {openAssetNewWindow} from "../window/openNewWindow";const bindAttrInput = (inputElement: HTMLInputElement, id: string) => {inputElement.addEventListener("change", () => {@@ -679,12 +680,20 @@ export const exportMd = (id: string) => {export const openMenu = (app: App, src: string, onlyMenu: boolean, showAccelerator: boolean) => {const submenu = [];+ /// #if MOBILE+ submenu.push({+ label: window.siyuan.languages.useBrowserView,+ accelerator: showAccelerator ? "Click" : "",+ click: () => {+ openByMobile(src);+ }+ });+ /// #elseif (isLocalPath(src)) {if (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname(src)) &&(!src.endsWith(".pdf") ||(src.endsWith(".pdf") && !src.startsWith("file://")))) {- /// #if !MOBILEsubmenu.push({icon: "iconLayoutRight",label: window.siyuan.languages.insertRight,@@ -693,26 +702,31 @@ export const openMenu = (app: App, src: string, onlyMenu: boolean, showAcceleratopenAsset(app, src.trim(), parseInt(getSearch("page", src)), "right");}});- /// #endif+ submenu.push({+ label: window.siyuan.languages.openBy,+ icon: "iconOpen",+ accelerator: showAccelerator ? "⌥Click" : "",+ click() {+ openAsset(app, src.trim(), parseInt(getSearch("page", src)));+ }+ });/// #if !BROWSERsubmenu.push({- label: window.siyuan.languages.useDefault,- accelerator: showAccelerator ? "⇧Click" : "",+ label: window.siyuan.languages.openByNewWindow,+ icon: "iconOpenWindow",click() {- openBy(src, "app");+ openAssetNewWindow(src.trim());}});/// #endif} else {- /// #if !BROWSERsubmenu.push({- label: window.siyuan.languages.useDefault,+ label: window.siyuan.languages.useBrowserView,accelerator: showAccelerator ? "Click" : "",- click() {- openBy(src, "app");+ click: () => {+ openByMobile(src);}});- /// #endif}/// #if !BROWSERsubmenu.push({@@ -723,8 +737,20 @@ export const openMenu = (app: App, src: string, onlyMenu: boolean, showAcceleratopenBy(src, "folder");}});+ submenu.push({+ label: window.siyuan.languages.useDefault,+ accelerator: showAccelerator ? "⇧Click" : "",+ click() {+ openBy(src, "app");+ }+ });/// #endif- } else {+ } else if (src) {+ if (0 > src.indexOf(":")) {+ // 使用 : 判断,不使用 :// 判断 Open external application protocol invalid https://github.com/siyuan-note/siyuan/issues/10075+ // Support click to open hyperlinks like `www.foo.com` https://github.com/siyuan-note/siyuan/issues/9986+ src = `https://${src}`;+ }/// #if !BROWSERsubmenu.push({label: window.siyuan.languages.useDefault,@@ -735,16 +761,16 @@ export const openMenu = (app: App, src: string, onlyMenu: boolean, showAccelerat});}});+ /// #else+ submenu.push({+ label: window.siyuan.languages.useBrowserView,+ accelerator: showAccelerator ? "Click" : "",+ click: () => {+ openByMobile(src);+ }+ });/// #endif}- /// #if BROWSER- submenu.push({- label: window.siyuan.languages.useBrowserView,- accelerator: showAccelerator ? "Click" : "",- click: () => {- openByMobile(src);- }- });/// #endifif (onlyMenu) {return submenu;diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex f578b0e336..df7728a11d 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -2077,7 +2077,7 @@ export class WYSIWYG {return;}- if (aElement && !event.altKey) {+ if (aElement) {event.stopPropagation();event.preventDefault();let linkAddress = Lute.UnEscapeHTMLStr(aLink);@@ -2090,31 +2090,28 @@ export class WYSIWYG {(!linkPathname.endsWith(".pdf") ||(linkPathname.endsWith(".pdf") && !linkAddress.startsWith("file://")))) {- if (ctrlIsPressed) {- openBy(linkAddress, "folder");- } else if (event.shiftKey) {- openBy(linkAddress, "app");- } else {+ if (event.altKey) {+ openAsset(protyle.app, linkAddress, parseInt(getSearch("page", linkAddress)));+ } else if (!ctrlIsPressed && !event.shiftKey) {openAsset(protyle.app, linkPathname, parseInt(getSearch("page", linkAddress)), "right");}} else {- /// #if !BROWSER- if (ctrlIsPressed) {- openBy(linkAddress, "folder");- } else {- openBy(linkAddress, "app");- }- /// #elseopenByMobile(linkAddress);- /// #endif}- } else if (linkAddress) {/// #if !BROWSER+ if (ctrlIsPressed) {+ openBy(linkAddress, "folder");+ } else if (event.shiftKey) {+ openBy(linkAddress, "app");+ }+ /// #endif+ } else if (linkAddress) {if (0 > linkAddress.indexOf(":")) {// 使用 : 判断,不使用 :// 判断 Open external application protocol invalid https://github.com/siyuan-note/siyuan/issues/10075// Support click to open hyperlinks like `www.foo.com` https://github.com/siyuan-note/siyuan/issues/9986linkAddress = `https://${linkAddress}`;}+ /// #if !BROWSERshell.openExternal(linkAddress).catch((e) => {showMessage(e);});diff --git a/app/src/window/openNewWindow.ts b/app/src/window/openNewWindow.tsindex abefebea19..9cda816337 100644--- a/app/src/window/openNewWindow.ts+++ b/app/src/window/openNewWindow.ts@@ -6,6 +6,8 @@ import {Constants} from "../constants";import {Tab} from "../layout/Tab";import {fetchPost} from "../util/fetch";import {showMessage} from "../dialog/message";+import {getDisplayName, pathPosix} from "../util/pathName";+import {getSearch} from "../util/functions";interface windowOptions {position?: {@@ -62,5 +64,39 @@ export const openNewWindowById = (id: string, options: windowOptions = {}) => {});/// #endif});+};+export const openAssetNewWindow = (assetPath: string, options: windowOptions = {}) => {+ /// #if !BROWSER+ const suffix = pathPosix().extname(assetPath.split("?page")[0]);+ if (Constants.SIYUAN_ASSETS_EXTS.includes(suffix)) {+ let docIcon = "iconPDF";+ if (Constants.SIYUAN_ASSETS_IMAGE.includes(suffix)) {+ docIcon = "iconImage";+ } else if (Constants.SIYUAN_ASSETS_AUDIO.includes(suffix)) {+ docIcon = "iconRecord";+ } else if (Constants.SIYUAN_ASSETS_VIDEO.includes(suffix)) {+ docIcon = "iconVideo";+ }+ const json: any = {+ title: getDisplayName(assetPath),+ docIcon,+ pin: false,+ active: true,+ instance: "Tab",+ action: "Tab",+ children: {+ path: assetPath,+ page: parseInt(getSearch("page", assetPath)),+ instance: "Asset",+ }+ };+ ipcRenderer.send(Constants.SIYUAN_OPEN_WINDOW, {+ position: options.position,+ width: options.width,+ height: options.height,+ url: `${window.location.protocol}//${window.location.host}/stage/build/app/window.html?v=${Constants.SIYUAN_VERSION}&json=${encodeURIComponent(JSON.stringify(json))}`+ });+ }+ /// #endif};