diff --git a/app/src/editor/deleteFile.ts b/app/src/editor/deleteFile.ts
new file mode 100644
index 000000000..de1be7ee4
--- /dev/null
+++ b/app/src/editor/deleteFile.ts
@@ -0,0 +1,27 @@
+import {fetchPost} from "../util/fetch";
+import {getDisplayName} from "../util/pathName";
+import {confirmDialog} from "../dialog/confirmDialog";
+
+export const deleteFile = (notebookId: string, pathString: string, name: string) => {
+ if (window.siyuan.config.fileTree.removeDocWithoutConfirm) {
+ fetchPost("/api/filetree/removeDoc", {
+ notebook: notebookId,
+ path: pathString
+ });
+ return;
+ }
+ fetchPost("/api/block/getDocInfo", {
+ id: getDisplayName(pathString, true, true)
+ }, (response) => {
+ let tip = `${window.siyuan.languages.confirmDelete} ${name}?`;
+ if (response.data.subFileCount > 0) {
+ tip = `${window.siyuan.languages.confirmDelete} ${name} ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
+ }
+ confirmDialog(window.siyuan.languages.delete, tip, () => {
+ fetchPost("/api/filetree/removeDoc", {
+ notebook: notebookId,
+ path: pathString
+ });
+ });
+ });
+};
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index 62e1e7ca9..c7efc1a91 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -457,27 +457,3 @@ export const openBy = (url: string, type: "folder" | "app") => {
}
/// #endif
};
-
-export const deleteFile = (notebookId: string, pathString: string, name: string) => {
- if (window.siyuan.config.fileTree.removeDocWithoutConfirm) {
- fetchPost("/api/filetree/removeDoc", {
- notebook: notebookId,
- path: pathString
- });
- return;
- }
- fetchPost("/api/block/getDocInfo", {
- id: getDisplayName(pathString, true, true)
- }, (response) => {
- let tip = `${window.siyuan.languages.confirmDelete} ${name}?`;
- if (response.data.subFileCount > 0) {
- tip = `${window.siyuan.languages.confirmDelete} ${name} ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
- }
- confirmDialog(window.siyuan.languages.delete, tip, () => {
- fetchPost("/api/filetree/removeDoc", {
- notebook: notebookId,
- path: pathString
- });
- });
- });
-};
diff --git a/app/src/emoji/index.ts b/app/src/emoji/index.ts
index ea5dc6e8f..cdd41b4d9 100644
--- a/app/src/emoji/index.ts
+++ b/app/src/emoji/index.ts
@@ -3,9 +3,11 @@ import {setPosition} from "../util/setPosition";
import {fetchPost} from "../util/fetch";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
import {Constants} from "../constants";
-import {getDockByType} from "../layout/util";
import {Files} from "../layout/dock/Files";
+/// #if !MOBILE
+import {getDockByType} from "../layout/util";
import {getAllModels} from "../layout/getAll";
+/// #endif
import {getEventName} from "../protyle/util/compatibility";
import {setNoteBook} from "../util/pathName";
@@ -392,26 +394,25 @@ ${unicode2Emoji(emoji.unicode)}`;
};
export const updateOutlineEmoji = (unicode: string) => {
- if (isMobile()) {
- return;
- }
+ /// #if !MOBILE
getAllModels().outline.forEach(model => {
model.headerElement.nextElementSibling.firstElementChild.innerHTML = unicode2Emoji(unicode || Constants.SIYUAN_IMAGE_FILE);
});
+ /// #endif
};
export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFile") => {
let emojiElement;
- if (isMobile()) {
- emojiElement = document.querySelector(`#sidebar [data-type="sidebar-file"] [data-node-id="${id}"] .b3-list-item__icon`);
+ /// #if MOBILE
+ emojiElement = document.querySelector(`#sidebar [data-type="sidebar-file"] [data-node-id="${id}"] .b3-list-item__icon`);
+ /// #else
+ const files = getDockByType("file").data.file as Files;
+ if (icon === "iconFile") {
+ emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`);
} else {
- const files = getDockByType("file").data.file as Files;
- if (icon === "iconFile") {
- emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`);
- } else {
- emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`) || files.element.querySelector(`[data-url="${id}"] .b3-list-item__icon`) || files.closeElement.querySelector(`[data-url="${id}"] .b3-list-item__icon`);
- }
+ emojiElement = files.element.querySelector(`[data-node-id="${id}"] .b3-list-item__icon`) || files.element.querySelector(`[data-url="${id}"] .b3-list-item__icon`) || files.closeElement.querySelector(`[data-url="${id}"] .b3-list-item__icon`);
}
+ /// #endif
if (emojiElement) {
emojiElement.innerHTML = unicode2Emoji(unicode || (icon === "iconFile" ? (emojiElement.previousElementSibling.classList.contains("fn__hidden") ? Constants.SIYUAN_IMAGE_FILE : Constants.SIYUAN_IMAGE_FOLDER) : Constants.SIYUAN_IMAGE_NOTE));
}
@@ -421,19 +422,19 @@ export const updateFileTreeEmoji = (unicode: string, id: string, icon = "iconFil
};
const updateFileEmoji = (unicode: string, id: string) => {
- if (isMobile()) {
- 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, id);
- }
- } else {
- getAllModels().editor.find(item => {
- if (item.editor.protyle.block.rootID === id) {
- item.editor.protyle.background.ial.icon = unicode;
- item.editor.protyle.background.render(item.editor.protyle.background.ial, id);
- item.parent.setDocIcon(unicode);
- return true;
- }
- });
+ /// #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, id);
}
+ /// #else
+ getAllModels().editor.find(item => {
+ if (item.editor.protyle.block.rootID === id) {
+ item.editor.protyle.background.ial.icon = unicode;
+ item.editor.protyle.background.render(item.editor.protyle.background.ial, id);
+ item.parent.setDocIcon(unicode);
+ return true;
+ }
+ });
+ /// #endif
};
diff --git a/app/src/layout/status.ts b/app/src/layout/status.ts
index c15bb7d52..a2448be78 100644
--- a/app/src/layout/status.ts
+++ b/app/src/layout/status.ts
@@ -1,3 +1,4 @@
+/// #if !MOBILE
import {getAllDocks} from "./getAll";
import {updateHotkeyTip} from "../protyle/util/compatibility";
import {exportLayout, getDockByType, resizeTabs} from "./util";
@@ -7,9 +8,10 @@ import {mountHelp} from "../util/mount";
/// #if !BROWSER
import {getCurrentWindow} from "@electron/remote";
/// #endif
-import {isMobile} from "../util/functions";
+/// #endif
export const initStatus = () => {
+ /// #if !MOBILE
const allDocks = getAllDocks();
let menuHTML = "";
allDocks.forEach(item => {
@@ -124,10 +126,12 @@ export const initStatus = () => {
if (window.siyuan.config.appearance.hideStatusBar) {
document.getElementById("status").classList.add("fn__none");
}
+ /// #endif
};
export const countSelectWord = (range: Range) => {
- if (isMobile() || document.getElementById("status").classList.contains("fn__none")) {
+ /// #if !MOBILE
+ if (document.getElementById("status").classList.contains("fn__none")) {
return;
}
const selectText = range.toString();
@@ -142,10 +146,12 @@ export const countSelectWord = (range: Range) => {
} else {
document.querySelector("#status .status__counter").innerHTML = "";
}
+ /// #endif
};
export const countBlockWord = (ids: string[]) => {
- if (isMobile() || document.getElementById("status").classList.contains("fn__none")) {
+ /// #if !MOBILE
+ if (document.getElementById("status").classList.contains("fn__none")) {
return;
}
if (ids.length > 0) {
@@ -159,5 +165,6 @@ export const countBlockWord = (ids: string[]) => {
} else {
document.querySelector("#status .status__counter").innerHTML = "";
}
+ /// #endif
};
diff --git a/app/src/menus/commonMenuItem.ts b/app/src/menus/commonMenuItem.ts
index 5db2449bf..6ee978e62 100644
--- a/app/src/menus/commonMenuItem.ts
+++ b/app/src/menus/commonMenuItem.ts
@@ -13,16 +13,19 @@ import {writeText} from "../protyle/util/compatibility";
import {fetchPost} from "../util/fetch";
import {hideMessage, showMessage} from "../dialog/message";
import {Dialog} from "../dialog";
-import {getAllModels} from "../layout/getAll";
import {focusBlock, focusByRange, getEditorRange} from "../protyle/util/selection";
import {setPosition} from "../util/setPosition";
import {updateTransaction} from "../protyle/wysiwyg/transaction";
+/// #if !MOBILE
+import {getAllModels} from "../layout/getAll";
import {Bookmark} from "../layout/dock/Bookmark";
+import {openAsset, openBy} from "../editor/util";
+/// #endif
import {rename} from "../editor/rename";
-import {deleteFile, openAsset, openBy} from "../editor/util";
import {matchHotKey} from "../protyle/util/hotKey";
import * as dayjs from "dayjs";
import {Constants} from "../constants";
+import {deleteFile} from "../editor/deleteFile";
const bindAttrInput = (inputElement: HTMLInputElement, confirmElement: Element) => {
inputElement.addEventListener("keydown", (event) => {
@@ -315,18 +318,17 @@ export const openFileAttr = (attrs: IObject, id: string, focusName = "bookmark")
if (errorTip) {
showMessage(errorTip.substr(0, errorTip.length - 2) + " " + window.siyuan.languages.invalid);
}
- if (!isMobile()) {
- getAllModels().editor.forEach(item => {
- if (item.editor.protyle.block.rootID === id) {
- const refElement = item.editor.protyle.title.element.querySelector(".protyle-attr--refcount");
- if (refElement) {
- nodeAttrHTML += refElement.outerHTML;
- }
- item.editor.protyle.title.element.querySelector(".protyle-attr").innerHTML = nodeAttrHTML;
- item.editor.protyle.wysiwyg.renderCustom(attrsResult);
+ /// #if !MOBILE
+ getAllModels().editor.forEach(item => {
+ if (item.editor.protyle.block.rootID === id) {
+ const refElement = item.editor.protyle.title.element.querySelector(".protyle-attr--refcount");
+ if (refElement) {
+ nodeAttrHTML += refElement.outerHTML;
}
- });
- }
+ item.editor.protyle.title.element.querySelector(".protyle-attr").innerHTML = nodeAttrHTML;
+ item.editor.protyle.wysiwyg.renderCustom(attrsResult);
+ }
+ });
fetchPost("/api/attr/resetBlockAttrs", {id, attrs: attrsResult}, () => {
if (attrsResult.bookmark !== attrs.bookmark) {
const bookmark = getDockByType("bookmark").data.bookmark;
@@ -335,6 +337,7 @@ export const openFileAttr = (attrs: IObject, id: string, focusName = "bookmark")
}
}
});
+ /// #endif
dialog.destroy();
});
dialog.element.querySelectorAll(".b3-text-field").forEach((item: HTMLInputElement) => {
@@ -508,7 +511,8 @@ export const openAttr = (nodeElement: Element, protyle: IProtyle, focusName = "b
const escapeHTML = Lute.EscapeHTMLStr(item.value);
nodeElement.setAttribute(name, escapeHTML);
if (name === "bookmark") {
- if (escapeHTML !== response.data.bookmark && !isMobile()) {
+ /// #if !MOBILE
+ if (escapeHTML !== response.data.bookmark) {
const bookmark = getDockByType("bookmark").data.bookmark;
if (bookmark instanceof Bookmark) {
setTimeout(() => {
@@ -516,6 +520,7 @@ export const openAttr = (nodeElement: Element, protyle: IProtyle, focusName = "b
}, 219);
}
}
+ /// #endif
nodeAttrHTML += `
${escapeHTML}
`;
} else if (name === "name") {
nodeAttrHTML += `${escapeHTML}
`;
@@ -715,6 +720,7 @@ export const openMenu = (src: string, onlyMenu = false) => {
(!src.endsWith(".pdf") ||
(src.endsWith(".pdf") && !src.startsWith("file://")))
) {
+ /// #if !MOBILE
submenu.push({
label: window.siyuan.languages.insertRight,
accelerator: "Click",
@@ -722,6 +728,7 @@ export const openMenu = (src: string, onlyMenu = false) => {
openAsset(src.trim(), parseInt(getSearch("page", src)), "right");
}
});
+ /// #endif
/// #if !BROWSER
submenu.push({
label: window.siyuan.languages.useDefault,
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index e240eff4b..6381f2732 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -19,11 +19,10 @@ import {fetchPost} from "../util/fetch";
import {onGetnotebookconf} from "./onGetnotebookconf";
/// #if !MOBILE
import {openSearch} from "../search/spread";
+import {openFileById} from "../editor/util";
/// #endif
import {confirmDialog} from "../dialog/confirmDialog";
-import {isMobile} from "../util/functions";
import {Constants} from "../constants";
-import {openFileById} from "../editor/util";
export const initNavigationMenu = (liElement: HTMLElement) => {
const notebookId = liElement.parentElement.getAttribute("data-url");
@@ -180,6 +179,7 @@ export const initFileMenu = (notebookId: string, pathString: string, id: string,
/// #endif
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
}
+ /// #if !MOBILE
const openSubmenus: IMenu[] = [{
icon: "iconRight",
label: window.siyuan.languages.insertRight,
@@ -227,12 +227,11 @@ export const initFileMenu = (notebookId: string, pathString: string, id: string,
});
}
/// #endif
- if (!isMobile()) {
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.openBy,
- submenu: openSubmenus,
- }).element);
- }
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.openBy,
+ submenu: openSubmenus,
+ }).element);
+ /// #endif
if (!window.siyuan.config.readonly) {
genImportMenu(notebookId, pathString);
}
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index cf34afb0b..4e9f5ce49 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -26,13 +26,14 @@ import {clipboard} from "electron";
import {onGet} from "../protyle/util/onGet";
import {getAllModels} from "../layout/getAll";
import {pasteText} from "../protyle/util/paste";
+/// #if !MOBILE
import {openFileById, updateBacklinkGraph} from "../editor/util";
+/// #endif
import {isMobile} from "../util/functions";
import {removeFoldHeading} from "../protyle/util/heading";
import {lineNumberRender} from "../protyle/markdown/highlightRender";
import * as dayjs from "dayjs";
import {blockRender} from "../protyle/markdown/blockRender";
-import {isLocalPath} from "../util/pathName";
export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
const nodeElement = hasClosestBlock(element);
@@ -78,55 +79,55 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
window.siyuan.menus.menu.append(new MenuItem({
type: "separator"
}).element);
- if (!isMobile()) {
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.openBy,
- accelerator: "⌘Click",
- click() {
- fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
- openFileById({
- id: refBlockId,
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL],
- keepCursor: true,
- zoomIn: foldResponse.data
- });
+ /// #if !MOBILE
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.openBy,
+ accelerator: "⌘Click",
+ click() {
+ fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
+ openFileById({
+ id: refBlockId,
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL],
+ keepCursor: true,
+ zoomIn: foldResponse.data
});
- }
- }).element);
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.insertRight,
- icon: "iconRight",
- accelerator: "⌥Click",
- click() {
- fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
- openFileById({
- id: refBlockId,
- position: "right",
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
- zoomIn: foldResponse.data
- });
+ });
+ }
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.insertRight,
+ icon: "iconRight",
+ accelerator: "⌥Click",
+ click() {
+ fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
+ openFileById({
+ id: refBlockId,
+ position: "right",
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
+ zoomIn: foldResponse.data
});
- }
- }).element);
- window.siyuan.menus.menu.append(new MenuItem({
- label: window.siyuan.languages.insertBottom,
- icon: "iconDown",
- accelerator: "⇧Click",
- click() {
- fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
- openFileById({
- id: refBlockId,
- position: "bottom",
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
- zoomIn: foldResponse.data
- });
+ });
+ }
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ label: window.siyuan.languages.insertBottom,
+ icon: "iconDown",
+ accelerator: "⇧Click",
+ click() {
+ fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
+ openFileById({
+ id: refBlockId,
+ position: "bottom",
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
+ zoomIn: foldResponse.data
});
- }
- }).element);
- }
+ });
+ }
+ }).element);
+ /// #endif
let submenu: IMenu[] = [];
if (element.getAttribute("data-subtype") === "s") {
submenu.push({
@@ -381,9 +382,11 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB
return;
}
}
+ /// #if !MOBILE
if (protyle.model) {
updateBacklinkGraph(getAllModels(), protyle);
}
+ /// #endif
});
};
diff --git a/app/src/mobile/util/MobileFiles.ts b/app/src/mobile/util/MobileFiles.ts
index bdf9c3484..ed9fa75c7 100644
--- a/app/src/mobile/util/MobileFiles.ts
+++ b/app/src/mobile/util/MobileFiles.ts
@@ -3,7 +3,6 @@ import {escapeHtml} from "../../util/escape";
import {Model} from "../../layout/Model";
import {Constants} from "../../constants";
import {getDisplayName, pathPosix, setNoteBook} from "../../util/pathName";
-import {newFile} from "../../util/newFile";
import {initFileMenu, initNavigationMenu} from "../../menus/navigation";
import {showMessage} from "../../dialog/message";
import {fetchPost} from "../../util/fetch";
@@ -14,6 +13,7 @@ import {newNotebook} from "../../util/mount";
import {setEmpty} from "./setEmpty";
import {confirmDialog} from "../../dialog/confirmDialog";
import {MenuItem} from "../../menus/Menu";
+import {newFile} from "../../util/newFile";
export class MobileFiles extends Model {
public element: HTMLElement;
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index dd7265602..3f0f523b5 100644
--- a/app/src/protyle/header/Title.ts
+++ b/app/src/protyle/header/Title.ts
@@ -18,7 +18,7 @@ import {matchHotKey} from "../util/hotKey";
import {updateHotkeyTip, writeText} from "../util/compatibility";
import {setPanelFocus} from "../../layout/util";
import {escapeHtml} from "../../util/escape";
-import {deleteFile, updatePanelByEditor} from "../../editor/util";
+import {updatePanelByEditor} from "../../editor/util";
import * as dayjs from "dayjs";
import {setTitle} from "../../dialog/processSystem";
import {getNoContainerElement} from "../wysiwyg/getBlock";
@@ -26,6 +26,7 @@ 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 {
public element: HTMLElement;
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 3b047d6ae..d787e8431 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -47,7 +47,9 @@ import {setPosition} from "../../util/setPosition";
import {openAttr} from "../../menus/commonMenuItem";
import {blockRender} from "../markdown/blockRender";
import {pushBack} from "../../util/backForward";
+/// #if !MOBILE
import {openAsset, openBy, openFileById} from "../../editor/util";
+/// #endif
import {BlockPanel} from "../../block/Panel";
import {isCtrl} from "../util/compatibility";
import {MenuItem} from "../../menus/Menu";
@@ -1342,42 +1344,42 @@ export class WYSIWYG {
}
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
- if (isMobile()) {
- openMobileFileById(refBlockId, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]);
+ /// #if MOBILE
+ openMobileFileById(refBlockId, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]);
+ /// #else
+ if (window.siyuan.shiftIsPressed) {
+ openFileById({
+ id: refBlockId,
+ position: "bottom",
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
+ zoomIn: foldResponse.data
+ });
+ } else if (window.siyuan.altIsPressed) {
+ openFileById({
+ id: refBlockId,
+ position: "right",
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
+ zoomIn: foldResponse.data
+ });
+ } else if (window.siyuan.ctrlIsPressed) {
+ openFileById({
+ id: refBlockId,
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL],
+ keepCursor: true,
+ zoomIn: foldResponse.data
+ });
} else {
- if (window.siyuan.shiftIsPressed) {
- openFileById({
- id: refBlockId,
- position: "bottom",
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
- zoomIn: foldResponse.data
- });
- } else if (window.siyuan.altIsPressed) {
- openFileById({
- id: refBlockId,
- position: "right",
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
- zoomIn: foldResponse.data
- });
- } else if (window.siyuan.ctrlIsPressed) {
- openFileById({
- id: refBlockId,
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL],
- keepCursor: true,
- zoomIn: foldResponse.data
- });
- } else {
- openFileById({
- id: refBlockId,
- hasContext: !foldResponse.data,
- action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
- zoomIn: foldResponse.data
- });
- }
+ openFileById({
+ id: refBlockId,
+ hasContext: !foldResponse.data,
+ action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS],
+ zoomIn: foldResponse.data
+ });
}
+ /// #endif
});
if (protyle.model) {
// 打开双链需记录到后退中 https://github.com/siyuan-note/insider/issues/801
@@ -1400,14 +1402,13 @@ export class WYSIWYG {
event.preventDefault();
const fileIds = fileElement.getAttribute("data-id").split("/");
const linkAddress = `assets/${fileIds[1]}`;
- if (isMobile()) {
- if (typeof window.JSAndroid === "undefined") {
- window.open(linkAddress);
- } else {
- window.JSAndroid.openExternal(linkAddress);
- }
- return;
+ /// #if MOBILE
+ if (typeof window.JSAndroid === "undefined") {
+ window.open(linkAddress);
+ } else {
+ window.JSAndroid.openExternal(linkAddress);
}
+ /// #else
if (window.siyuan.ctrlIsPressed) {
openBy(linkAddress, "folder");
} else if (window.siyuan.shiftIsPressed) {
@@ -1415,6 +1416,7 @@ export class WYSIWYG {
} else {
openAsset(linkAddress, fileIds[2], "right");
}
+ /// #endif
return;
}
@@ -1422,16 +1424,15 @@ export class WYSIWYG {
event.stopPropagation();
event.preventDefault();
const linkAddress = aElement.getAttribute("data-href");
- if (isMobile()) {
- if (window.siyuan.config.system.container === "ios") {
- window.location.href = linkAddress;
- } else if (window.siyuan.config.system.container === "android" && window.JSAndroid) {
- window.JSAndroid.openExternal(linkAddress);
- } else {
- window.open(linkAddress);
- }
- return;
+ /// #if MOBILE
+ if (window.siyuan.config.system.container === "ios") {
+ window.location.href = linkAddress;
+ } else if (window.siyuan.config.system.container === "android" && window.JSAndroid) {
+ window.JSAndroid.openExternal(linkAddress);
+ } else {
+ window.open(linkAddress);
}
+ /// #else
if (isLocalPath(linkAddress)) {
const linkPathname = linkAddress.split("?page")[0];
if (Constants.SIYUAN_ASSETS_EXTS.includes(pathPosix().extname(linkPathname)) &&
@@ -1474,6 +1475,7 @@ export class WYSIWYG {
}
/// #endif
}
+ /// #endif
return;
}
@@ -1487,9 +1489,10 @@ export class WYSIWYG {
const embedItemElement = hasClosestByClassName(event.target, "protyle-wysiwyg__embed");
if (embedItemElement) {
const embedId = embedItemElement.getAttribute("data-id");
- if (isMobile()) {
- openMobileFileById(embedId, false, [Constants.CB_GET_ALL]);
- } else if (window.siyuan.shiftIsPressed) {
+ /// #if MOBILE
+ openMobileFileById(embedId, false, [Constants.CB_GET_ALL]);
+ /// #else
+ if (window.siyuan.shiftIsPressed) {
openFileById({
id: embedId,
position: "bottom",
@@ -1519,6 +1522,7 @@ export class WYSIWYG {
nodeIds: [embedId],
}));
}
+ /// #endif
event.stopPropagation();
return;
}
diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts
index 49f6e1cde..9343b7a73 100644
--- a/app/src/util/globalShortcut.ts
+++ b/app/src/util/globalShortcut.ts
@@ -24,7 +24,7 @@ import {goBack, goForward} from "./backForward";
import {onGet} from "../protyle/util/onGet";
import {getDisplayName, getNotebookName, movePathTo} from "./pathName";
import {confirmDialog} from "../dialog/confirmDialog";
-import {deleteFile, openFileById} from "../editor/util";
+import {openFileById} from "../editor/util";
import {getAllDocks, getAllModels, getAllTabs} from "../layout/getAll";
import {openGlobalSearch} from "../search/util";
import {getColIndex} from "../protyle/util/table";
@@ -36,6 +36,7 @@ import {openHistory} from "./history";
import {needSubscribe} from "./needSubscribe";
import {Dialog} from "../dialog";
import {unicode2Emoji} from "../emoji";
+import {deleteFile} from "../editor/deleteFile";
const getRightBlock = (element: HTMLElement, x: number, y: number) => {
let index = 1;
diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.ts
index d90113214..d75f15280 100644
--- a/app/src/util/newFile.ts
+++ b/app/src/util/newFile.ts
@@ -2,18 +2,20 @@ import {showMessage} from "../dialog/message";
import {getAllModels} from "../layout/getAll";
import {hasTopClosestByTag} from "../protyle/util/hasClosest";
import {getDockByType} from "../layout/util";
+/// #if !MOBILE
import {Files} from "../layout/dock/Files";
+import {openFileById} from "../editor/util";
+/// #endif
import {fetchPost} from "./fetch";
import {getDisplayName, getOpenNotebookCount, pathPosix} from "./pathName";
-import {openFileById} from "../editor/util";
import {Constants} from "../constants";
-import {isMobile} from "./functions";
export const newFile = (notebookId?: string, currentPath?: string, open?: boolean) => {
if (getOpenNotebookCount() === 0) {
showMessage(window.siyuan.languages.newFileTip);
return;
}
+ /// #if !MOBILE
if (!notebookId) {
getAllModels().editor.find((item) => {
const currentElement = item.parent.headElement;
@@ -39,15 +41,16 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea
}
}
}
- if (!notebookId) {
- window.siyuan.notebooks.find(item => {
- if (!item.closed) {
- notebookId = item.id;
- currentPath = "/";
- return true;
- }
- });
- }
+ }
+ /// #endif
+ if (!notebookId) {
+ window.siyuan.notebooks.find(item => {
+ if (!item.closed) {
+ notebookId = item.id;
+ currentPath = "/";
+ return true;
+ }
+ });
}
fetchPost("/api/filetree/getDocNameTemplate", {notebook: notebookId}, (data) => {
const id = Lute.NewNodeID();
@@ -57,9 +60,11 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea
title: data.data.name || "Untitled",
md: "",
}, () => {
- if (open && !isMobile()) {
+ /// #if !MOBILE
+ if (open) {
openFileById({id, hasContext: true, action: [Constants.CB_GET_HL]});
}
+ /// #endif
});
});
};