Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:recycle: http://localhost:6806/stage/build/mobile/

Vanessa922e86bc8bb3
diff --git a/app/src/protyle/breadcrumb/action.ts b/app/src/protyle/breadcrumb/action.ts
index 16dd4e3dbc..c38ba19c21 100644
--- a/app/src/protyle/breadcrumb/action.ts
+++ b/app/src/protyle/breadcrumb/action.ts
@@ -1,5 +1,6 @@
+/// #if !MOBILE
import {getAllModels} from "../../layout/getAll";
-import {isMobile} from "../../util/functions";
+/// #endif
import {setPadding} from "../ui/initUI";
export const fullscreen = (element: Element, btnElement?: Element) => {
@@ -22,18 +23,19 @@ export const fullscreen = (element: Element, btnElement?: Element) => {
} else {
btnElement.querySelector("use").setAttribute("xlink:href", "#iconContract");
}
- } else if (!isMobile()) {
- window.siyuan.editorIsFullscreen = !isFullscreen;
- getAllModels().editor.forEach(item => {
- if (window.siyuan.editorIsFullscreen) {
- if (!element.isSameNode(item.element) && item.element.classList.contains("fullscreen")) {
- item.element.classList.remove("fullscreen");
- setPadding(item.editor.protyle);
- }
- } else if (item.element.classList.contains("fullscreen")) {
+ }
+ /// #if !MOBILE
+ window.siyuan.editorIsFullscreen = !isFullscreen;
+ getAllModels().editor.forEach(item => {
+ if (window.siyuan.editorIsFullscreen) {
+ if (!element.isSameNode(item.element) && item.element.classList.contains("fullscreen")) {
item.element.classList.remove("fullscreen");
setPadding(item.editor.protyle);
}
- });
- }
+ } else if (item.element.classList.contains("fullscreen")) {
+ item.element.classList.remove("fullscreen");
+ setPadding(item.editor.protyle);
+ }
+ });
+ /// #endif
};
diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts
index 080d6a5bcd..5f355aecd1 100644
--- a/app/src/protyle/breadcrumb/index.ts
+++ b/app/src/protyle/breadcrumb/index.ts
@@ -14,12 +14,14 @@ import {isMobile} from "../../util/functions";
import {zoomOut} from "../../menus/protyle";
import {getEditorRange} from "../util/selection";
import {setPadding} from "../ui/initUI";
-import {onGet} from "../util/onGet";
+/// #if !MOBILE
+import {openFileById} from "../../editor/util";
+import {getAllModels} from "../../layout/getAll";
+/// #endif
/// #if !BROWSER
import {getCurrentWindow} from "@electron/remote";
/// #endif
-import {openFileById} from "../../editor/util";
-import {getAllModels} from "../../layout/getAll";
+import {onGet} from "../util/onGet";
export class Breadcrumb {
public element: HTMLElement;
@@ -44,9 +46,9 @@ export class Breadcrumb {
const id = target.getAttribute("data-node-id");
if (id) {
if (protyle.options.render.breadcrumbDocName && window.siyuan.ctrlIsPressed) {
- if (!isMobile()) {
- openFileById({id, action: [Constants.CB_GET_FOCUS]});
- }
+ /// #if !MOBILE
+ openFileById({id, action: [Constants.CB_GET_FOCUS]});
+ /// #endif
} else {
zoomOut(protyle, id);
}
@@ -218,27 +220,27 @@ export class Breadcrumb {
fetchPost("/api/format/autoSpace", {
id: protyle.block.rootID
}, () => {
- if (isMobile()) {
- fetchPost("/api/filetree/getDoc", {
- id: protyle.block.id,
- mode: 0,
- size: Constants.SIZE_GET,
- }, getResponse => {
- onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
- });
- } else {
- getAllModels().editor.forEach(item => {
- if (item.editor.protyle.block.rootID === protyle.block.rootID) {
- fetchPost("/api/filetree/getDoc", {
- id: item.editor.protyle.block.rootID,
- mode: 0,
- size: Constants.SIZE_GET,
- }, getResponse => {
- onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
- });
- }
- });
- }
+ /// #if MOBILE
+ fetchPost("/api/filetree/getDoc", {
+ id: protyle.block.id,
+ mode: 0,
+ size: Constants.SIZE_GET,
+ }, getResponse => {
+ onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
+ });
+ /// #else
+ getAllModels().editor.forEach(item => {
+ if (item.editor.protyle.block.rootID === protyle.block.rootID) {
+ fetchPost("/api/filetree/getDoc", {
+ id: item.editor.protyle.block.rootID,
+ mode: 0,
+ size: Constants.SIZE_GET,
+ }, getResponse => {
+ onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
+ });
+ }
+ });
+ /// #endif
});
}
}).element);
@@ -248,27 +250,27 @@ export class Breadcrumb {
fetchPost("/api/format/netImg2LocalAssets", {
id: protyle.block.rootID
}, () => {
- if (isMobile()) {
- fetchPost("/api/filetree/getDoc", {
- id: protyle.block.id,
- mode: 0,
- size: Constants.SIZE_GET,
- }, getResponse => {
- onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
- });
- } else {
- getAllModels().editor.forEach(item => {
- if (item.editor.protyle.block.rootID === protyle.block.rootID) {
- fetchPost("/api/filetree/getDoc", {
- id: item.editor.protyle.block.rootID,
- mode: 0,
- size: Constants.SIZE_GET,
- }, getResponse => {
- onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
- });
- }
- });
- }
+ /// #if MOBILE
+ fetchPost("/api/filetree/getDoc", {
+ id: protyle.block.id,
+ mode: 0,
+ size: Constants.SIZE_GET,
+ }, getResponse => {
+ onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]);
+ });
+ /// #else
+ getAllModels().editor.forEach(item => {
+ if (item.editor.protyle.block.rootID === protyle.block.rootID) {
+ fetchPost("/api/filetree/getDoc", {
+ id: item.editor.protyle.block.rootID,
+ mode: 0,
+ size: Constants.SIZE_GET,
+ }, getResponse => {
+ onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]);
+ });
+ }
+ });
+ /// #endif
});
}
}).element);
diff --git a/app/src/protyle/header/Background.ts b/app/src/protyle/header/Background.ts
index d8247ce1ed..0c05979401 100644
--- a/app/src/protyle/header/Background.ts
+++ b/app/src/protyle/header/Background.ts
@@ -6,7 +6,9 @@ import {fetchPost} from "../../util/fetch";
import {getRandomEmoji, openEmojiPanel, unicode2Emoji, updateFileTreeEmoji, updateOutlineEmoji} from "../../emoji";
import {upDownHint} from "../../util/upDownHint";
import {setPosition} from "../../util/setPosition";
+/// #if !MOBILE
import {openGlobalSearch} from "../../search/util";
+/// #endif
import {getEventName} from "../util/compatibility";
import {Dialog} from "../../dialog";
@@ -278,9 +280,9 @@ export class Background {
event.stopPropagation();
break;
} else if (type === "open-search") {
- if (!isMobile()) {
- openGlobalSearch(`#${target.textContent}#`, !window.siyuan.ctrlIsPressed);
- }
+ /// #if !MOBILE
+ openGlobalSearch(`#${target.textContent}#`, !window.siyuan.ctrlIsPressed);
+ /// #endif
event.preventDefault();
event.stopPropagation();
break;
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index 3f0f523b5c..e047c612b7 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -16,16 +16,16 @@ import {Constants} from "../../constants";
import {hasClosestByClassName} from "../util/hasClosest";
import {matchHotKey} from "../util/hotKey";
import {updateHotkeyTip, writeText} from "../util/compatibility";
-import {setPanelFocus} from "../../layout/util";
import {escapeHtml} from "../../util/escape";
-import {updatePanelByEditor} from "../../editor/util";
import * as dayjs from "dayjs";
+import {setPanelFocus} from "../../layout/util";
+import {updatePanelByEditor} from "../../editor/util";
+import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";
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";
import {deleteFile} from "../../editor/deleteFile";
export class Title {
diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts
index f5e27b1fbe..8b9e60fca1 100644
--- a/app/src/protyle/index.ts
+++ b/app/src/protyle/index.ts
@@ -16,7 +16,9 @@ import {Gutter} from "./gutter";
import {Breadcrumb} from "./breadcrumb";
import {onTransaction} from "./wysiwyg/transaction";
import {fetchPost} from "../util/fetch";
+/// #if !MOBILE
import {Title} from "./header/Title";
+/// #endif
import {Background} from "./header/Background";
import {getDisplayName} from "../util/pathName";
import {onGet} from "./util/onGet";
@@ -49,9 +51,11 @@ class Protyle {
this.protyle.hint = new Hint(this.protyle);
this.protyle.breadcrumb = new Breadcrumb(this.protyle);
+ /// #if !MOBILE
if (mergedOptions.render.title) {
this.protyle.title = new Title(this.protyle);
}
+ /// #endif
if (mergedOptions.render.background) {
this.protyle.background = new Background(this.protyle);
}
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index c7eb6eb1a5..6f5bbb768d 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -10,14 +10,16 @@ import {hideElements} from "../ui/hideElements";
import {mathRender} from "../markdown/mathRender";
import {fetchPost, fetchSyncPost} from "../../util/fetch";
import {onGet} from "./onGet";
+/// #if !MOBILE
import {getInstanceById} from "../../layout/util";
-import {Editor} from "../../editor";
import {Tab} from "../../layout/Tab";
-import {blockRender} from "../markdown/blockRender";
import {getAllModels} from "../../layout/getAll";
+import {updatePanelByEditor} from "../../editor/util";
+/// #endif
+import {Editor} from "../../editor";
+import {blockRender} from "../markdown/blockRender";
import {processRender} from "./processCode";
import {highlightRender} from "../markdown/highlightRender";
-import {updatePanelByEditor} from "../../editor/util";
const dragSb = (protyle: IProtyle, sourceElements: Element[], targetElement: Element, isBottom: boolean, direct: "col" | "row") => {
const isSameDoc = protyle.element.contains(sourceElements[0]);
@@ -211,6 +213,7 @@ const dragSb = (protyle: IProtyle, sourceElements: Element[], targetElement: Ele
doOperations.push(sbData.doOperations[0], sbData.doOperations[1]);
undoOperations.splice(0, 0, sbData.undoOperations[0], sbData.undoOperations[1]);
} else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.innerHTML === "") {
+ /// #if !MOBILE
// 拖拽后,根文档原内容为空,且不为悬浮窗
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (protyleElement && !protyleElement.classList.contains("block__edit")) {
@@ -229,6 +232,7 @@ const dragSb = (protyle: IProtyle, sourceElements: Element[], targetElement: Ele
});
}
}
+ /// #endif
}
if (isSameDoc) {
transaction(protyle, doOperations, undoOperations);
@@ -487,6 +491,7 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
doOperations.push(sbData.doOperations[0], sbData.doOperations[1]);
undoOperations.splice(0, 0, sbData.undoOperations[0], sbData.undoOperations[1]);
} else if (oldSourceParentElement && oldSourceParentElement.classList.contains("protyle-wysiwyg") && oldSourceParentElement.childElementCount === 0) {
+ /// #if !MOBILE
// 拖拽后,根文档原内容为空,且不为悬浮窗
const protyleElement = hasClosestByClassName(oldSourceParentElement, "protyle", true);
if (protyleElement && !protyleElement.classList.contains("block__edit")) {
@@ -505,6 +510,7 @@ const dragSame = (protyle: IProtyle, sourceElements: Element[], targetElement: E
});
}
}
+ /// #endif
}
if (isSameDoc) {
transaction(protyle, doOperations, undoOperations);
@@ -636,6 +642,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
dragSame(protyle, sourceElements, targetElement, targetClass.includes("dragover__bottom"));
}
}
+ /// #if !MOBILE
if (isBacklink) {
setTimeout(() => {
// 等待 drag transaction
@@ -644,6 +651,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
});
}, 200);
}
+ /// #endif
} else if (window.siyuan.dragElement && window.siyuan.dragElement.getAttribute("data-type") === "navigation-file" && targetElement) {
// 文件树拖拽
fetchPost("/api/filetree/doc2Heading", {
@@ -661,8 +669,10 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
size: Constants.SIZE_GET,
}, getResponse => {
onGet(getResponse, protyle);
+ /// #if !MOBILE
// 文档标题互转后,需更新大纲
updatePanelByEditor(protyle, false, false, true);
+ /// #endif
// 文档标题互转后,编辑区会跳转到开头 https://github.com/siyuan-note/siyuan/issues/2939
setTimeout(() => {
protyle.contentElement.scrollTop = scrollTop;
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index b4b6d186cf..b0238ff65f 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -19,7 +19,6 @@ import {getSearch, isMobile} from "../../util/functions";
import {isLocalPath, pathPosix} from "../../util/pathName";
import {genEmptyElement} from "../../block/util";
import {previewImage} from "../preview/image";
-import {openGlobalSearch} from "../../search/util";
import {contentMenu, imgMenu, linkMenu, refMenu, setFold, zoomOut} from "../../menus/protyle";
import * as dayjs from "dayjs";
import {dropEvent} from "../util/editorCommonEvent";
@@ -49,6 +48,7 @@ import {blockRender} from "../markdown/blockRender";
import {getAllModels} from "../../layout/getAll";
import {pushBack} from "../../util/backForward";
import {openAsset, openBy, openFileById} from "../../editor/util";
+import {openGlobalSearch} from "../../search/util";
/// #endif
import {BlockPanel} from "../../block/Panel";
import {isCtrl} from "../util/compatibility";
@@ -1483,12 +1483,14 @@ export class WYSIWYG {
return;
}
+ /// #if !MOBILE
const tagElement = hasClosestByAttribute(event.target, "data-type", "tag");
if (tagElement && !window.siyuan.altIsPressed && protyle.model) {
openGlobalSearch(`#${tagElement.textContent}#`, !window.siyuan.ctrlIsPressed);
hideElements(["dialog"]);
return;
}
+ /// #endif
const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed");
if (embedItemElement) {
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index aef4a3e12e..94dc66d51c 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -38,6 +38,10 @@ import {isLocalPath} from "../../util/pathName";
import {clipboard} from "electron";
import {getCurrentWindow} from "@electron/remote";
/// #endif
+/// #if !MOBILE
+import {openBy, openFileById} from "../../editor/util";
+import {commonHotkey} from "./commonHotkey";
+/// #endif
import {linkMenu, refMenu, setFold, zoomOut} from "../../menus/protyle";
import {setPosition} from "../../util/setPosition";
import {removeEmbed} from "./removeEmbed";
@@ -48,11 +52,9 @@ import {bindMenuKeydown} from "../../menus/Menu";
import {fetchPost} from "../../util/fetch";
import {onGet} from "../util/onGet";
import {scrollCenter} from "../../util/highlightById";
-import {openBy, openFileById} from "../../editor/util";
import {BlockPanel} from "../../block/Panel";
import * as dayjs from "dayjs";
import {highlightRender} from "../markdown/highlightRender";
-import {commonHotkey} from "./commonHotkey";
import {countBlockWord} from "../../layout/status";
export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
@@ -813,11 +815,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
event.preventDefault();
return true;
}
-
+ /// #if !MOBILE
if (commonHotkey(protyle, event)) {
return true;
}
-
+ /// #endif
if (matchHotKey(window.siyuan.config.keymap.editor.general.copyBlockRef.custom, event)) {
const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select");
let actionElement;
@@ -1404,6 +1406,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
}
+ /// #if !MOBILE
const refElement = hasClosestByAttribute(range.startContainer, "data-type", "block-ref");
if (refElement) {
const id = refElement.getAttribute("data-id");
@@ -1448,8 +1451,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return true;
}
}
+ /// #endif
- /// #if !BROWSER
+ /// #if !BROWSER && !MOBILE
if (matchHotKey(window.siyuan.config.keymap.editor.general.pasteAsPlainText.custom, event)) {
writeText(clipboard.readText());
setTimeout(() => {