mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 00:20:12 +01:00
This commit is contained in:
parent
fb8125509f
commit
0e04a0a4e3
3 changed files with 90 additions and 14 deletions
|
|
@ -13,11 +13,14 @@ import * as path from "path";
|
||||||
import {MenuItem} from "./Menu";
|
import {MenuItem} from "./Menu";
|
||||||
import {getDisplayName, getNotebookName, getTopPaths, pathPosix} from "../util/pathName";
|
import {getDisplayName, getNotebookName, getTopPaths, pathPosix} from "../util/pathName";
|
||||||
import {hideMessage, showMessage} from "../dialog/message";
|
import {hideMessage, showMessage} from "../dialog/message";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost, fetchSyncPost} from "../util/fetch";
|
||||||
import {onGetnotebookconf} from "./onGetnotebookconf";
|
import {onGetnotebookconf} from "./onGetnotebookconf";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {openSearch} from "../search/spread";
|
import {openSearch} from "../search/spread";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
|
/// #else
|
||||||
|
import {closePanel} from "../mobile/util/closePanel";
|
||||||
|
import {popSearch} from "../mobile/menu/search";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {newFile} from "../util/newFile";
|
import {newFile} from "../util/newFile";
|
||||||
|
|
@ -27,9 +30,6 @@ import {getDockByType} from "../layout/util";
|
||||||
import {Files} from "../layout/dock/Files";
|
import {Files} from "../layout/dock/Files";
|
||||||
import {openNewWindowById} from "../window/openNewWindow";
|
import {openNewWindowById} from "../window/openNewWindow";
|
||||||
import {openCardByData} from "../card/openCard";
|
import {openCardByData} from "../card/openCard";
|
||||||
/// #if MOBILE
|
|
||||||
import {closePanel} from "../mobile/util/closePanel";
|
|
||||||
/// #endif
|
|
||||||
import {viewCards} from "../card/viewCards";
|
import {viewCards} from "../card/viewCards";
|
||||||
|
|
||||||
const initMultiMenu = (selectItemElements: NodeListOf<Element>) => {
|
const initMultiMenu = (selectItemElements: NodeListOf<Element>) => {
|
||||||
|
|
@ -150,25 +150,58 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
}).element);
|
}).element);
|
||||||
/// #if !MOBILE
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.search,
|
label: window.siyuan.languages.search,
|
||||||
accelerator: window.siyuan.config.keymap.general.search.custom,
|
accelerator: window.siyuan.config.keymap.general.search.custom,
|
||||||
icon: "iconSearch",
|
icon: "iconSearch",
|
||||||
click() {
|
click() {
|
||||||
|
/// #if MOBILE
|
||||||
|
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||||
|
popSearch({
|
||||||
|
removed: localData.removed,
|
||||||
|
sort: localData.sort,
|
||||||
|
group: localData.group,
|
||||||
|
hasReplace: false,
|
||||||
|
method: localData.method,
|
||||||
|
hPath: getNotebookName(notebookId),
|
||||||
|
idPath: [notebookId],
|
||||||
|
k: localData.k,
|
||||||
|
r: localData.r,
|
||||||
|
page: 1,
|
||||||
|
types: Object.assign({}, localData.types)
|
||||||
|
});
|
||||||
|
/// #else
|
||||||
openSearch(window.siyuan.config.keymap.general.search.custom, undefined, notebookId);
|
openSearch(window.siyuan.config.keymap.general.search.custom, undefined, notebookId);
|
||||||
|
/// #endif
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
if (!window.siyuan.config.readonly) {
|
if (!window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.replace,
|
label: window.siyuan.languages.replace,
|
||||||
accelerator: window.siyuan.config.keymap.general.replace.custom,
|
accelerator: window.siyuan.config.keymap.general.replace.custom,
|
||||||
|
icon: "iconReplace",
|
||||||
click() {
|
click() {
|
||||||
|
/// #if MOBILE
|
||||||
|
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||||
|
popSearch({
|
||||||
|
removed: localData.removed,
|
||||||
|
sort: localData.sort,
|
||||||
|
group: localData.group,
|
||||||
|
hasReplace: true,
|
||||||
|
method: localData.method,
|
||||||
|
hPath: getNotebookName(notebookId),
|
||||||
|
idPath: [notebookId],
|
||||||
|
k: localData.k,
|
||||||
|
r: localData.r,
|
||||||
|
page: 1,
|
||||||
|
types: Object.assign({}, localData.types)
|
||||||
|
});
|
||||||
|
/// #else
|
||||||
openSearch(window.siyuan.config.keymap.general.replace.custom, undefined, notebookId);
|
openSearch(window.siyuan.config.keymap.general.replace.custom, undefined, notebookId);
|
||||||
|
/// #endif
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
/// #endif
|
|
||||||
if (!window.siyuan.config.readonly) {
|
if (!window.siyuan.config.readonly) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
|
@ -364,23 +397,66 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
}).element);
|
}).element);
|
||||||
/// #if !MOBILE
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.search,
|
label: window.siyuan.languages.search,
|
||||||
icon: "iconSearch",
|
icon: "iconSearch",
|
||||||
accelerator: window.siyuan.config.keymap.general.search.custom,
|
accelerator: window.siyuan.config.keymap.general.search.custom,
|
||||||
click() {
|
async click() {
|
||||||
openSearch(window.siyuan.config.keymap.general.search.custom, undefined, notebookId, getDisplayName(pathString, false, true));
|
const searchPath = getDisplayName(pathString, false, true)
|
||||||
|
/// #if MOBILE
|
||||||
|
const response = await fetchSyncPost("/api/filetree/getHPathByPath", {
|
||||||
|
notebook: notebookId,
|
||||||
|
path: searchPath + ".sy"
|
||||||
|
});
|
||||||
|
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||||
|
popSearch({
|
||||||
|
removed: localData.removed,
|
||||||
|
sort: localData.sort,
|
||||||
|
group: localData.group,
|
||||||
|
hasReplace: false,
|
||||||
|
method: localData.method,
|
||||||
|
hPath: pathPosix().join(getNotebookName(notebookId), response.data),
|
||||||
|
idPath: [pathPosix().join(notebookId, searchPath)],
|
||||||
|
k: localData.k,
|
||||||
|
r: localData.r,
|
||||||
|
page: 1,
|
||||||
|
types: Object.assign({}, localData.types)
|
||||||
|
});
|
||||||
|
/// #else
|
||||||
|
openSearch(window.siyuan.config.keymap.general.search.custom, undefined, notebookId, searchPath);
|
||||||
|
/// #endif
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.replace,
|
label: window.siyuan.languages.replace,
|
||||||
accelerator: window.siyuan.config.keymap.general.replace.custom,
|
accelerator: window.siyuan.config.keymap.general.replace.custom,
|
||||||
click() {
|
icon: "iconReplace",
|
||||||
openSearch(window.siyuan.config.keymap.general.replace.custom, undefined, notebookId, getDisplayName(pathString, false, true));
|
async click() {
|
||||||
|
const searchPath = getDisplayName(pathString, false, true)
|
||||||
|
/// #if MOBILE
|
||||||
|
const response = await fetchSyncPost("/api/filetree/getHPathByPath", {
|
||||||
|
notebook: notebookId,
|
||||||
|
path: searchPath + ".sy"
|
||||||
|
});
|
||||||
|
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||||
|
popSearch({
|
||||||
|
removed: localData.removed,
|
||||||
|
sort: localData.sort,
|
||||||
|
group: localData.group,
|
||||||
|
hasReplace: true,
|
||||||
|
method: localData.method,
|
||||||
|
hPath: pathPosix().join(getNotebookName(notebookId), response.data),
|
||||||
|
idPath: [pathPosix().join(notebookId, searchPath)],
|
||||||
|
k: localData.k,
|
||||||
|
r: localData.r,
|
||||||
|
page: 1,
|
||||||
|
types: Object.assign({}, localData.types)
|
||||||
|
});
|
||||||
|
/// #else
|
||||||
|
openSearch(window.siyuan.config.keymap.general.replace.custom, undefined, notebookId, searchPath);
|
||||||
|
/// #endif
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
/// #endif
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||||
}
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
||||||
idPath,
|
idPath,
|
||||||
group: localData.group,
|
group: localData.group,
|
||||||
sort: localData.sort,
|
sort: localData.sort,
|
||||||
types: localData.types,
|
types: Object.assign({}, localData.types),
|
||||||
page: key ? 1 : localData.page
|
page: key ? 1 : localData.page
|
||||||
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
|
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
|
||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ export const openGlobalSearch = (text: string, replace: boolean) => {
|
||||||
idPath: [],
|
idPath: [],
|
||||||
group: localData.group,
|
group: localData.group,
|
||||||
sort: localData.sort,
|
sort: localData.sort,
|
||||||
types: localData.types,
|
types: Object.assign({}, localData.types),
|
||||||
removed: localData.removed,
|
removed: localData.removed,
|
||||||
page: 1
|
page: 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue