mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-17 12:38:07 +01:00
This commit is contained in:
parent
ec34dcca19
commit
0200e6eed5
12 changed files with 221 additions and 190 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue