This commit is contained in:
parent
7cfce5e1c1
commit
4f9c1cb526
2 changed files with 5 additions and 5 deletions
|
@ -161,14 +161,14 @@ export const newFileContentBySelect = (protyle: IProtyle) => {
|
|||
};
|
||||
|
||||
export const newFileBySelect = (fileName: string, protyle: IProtyle) => {
|
||||
fileName = replaceFileName(fileName);
|
||||
const newName = replaceFileName(fileName) || "Untitled";
|
||||
const id = Lute.NewNodeID();
|
||||
fetchPost("/api/filetree/createDoc", {
|
||||
notebook: protyle.notebookId,
|
||||
path: pathPosix().join(getDisplayName(protyle.path, false, true), id + ".sy"),
|
||||
title: fileName,
|
||||
title: newName,
|
||||
md: ""
|
||||
}, () => {
|
||||
insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${id}" data-subtype="d">${escapeHtml(fileName)}</span>`), protyle);
|
||||
insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${id}" data-subtype="d">${escapeHtml(newName)}</span>`), protyle);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -996,8 +996,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
return;
|
||||
}
|
||||
|
||||
if (selectText.trim() && matchHotKey(window.siyuan.config.keymap.editor.general.newNameFile.custom, event)) {
|
||||
newFileBySelect(selectText, protyle);
|
||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.newNameFile.custom, event)) {
|
||||
newFileBySelect(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML), protyle);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue