This commit is contained in:
parent
a19ec991b0
commit
286e87259b
1 changed files with 13 additions and 10 deletions
|
@ -1047,16 +1047,19 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (!selectText.trim()) {
|
||||
selectAll(protyle, nodeElement, range);
|
||||
}
|
||||
const newName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML)) || "Untitled";
|
||||
const id = Lute.NewNodeID();
|
||||
fetchPost("/api/filetree/createDoc", {
|
||||
const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML)) || "Untitled";
|
||||
fetchPost("/api/filetree/getHPathByPath", {
|
||||
notebook: protyle.notebookId,
|
||||
path: pathPosix().join(getDisplayName(protyle.path, false, true), id + ".sy"),
|
||||
title: newName,
|
||||
md: ""
|
||||
}, () => {
|
||||
insertHTML(`<span data-type="block-ref" data-id="${id}" data-subtype="d">${escapeHtml(newName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}</span>`, protyle);
|
||||
hideElements(["toolbar"], protyle)
|
||||
path: protyle.path,
|
||||
}, (response) => {
|
||||
fetchPost("/api/filetree/createDocWithMd", {
|
||||
notebook: protyle.notebookId,
|
||||
path: pathPosix().join(response.data, newFileName),
|
||||
markdown: ""
|
||||
}, response => {
|
||||
insertHTML(`<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${escapeHtml(newFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}</span>`, protyle);
|
||||
hideElements(["toolbar"], protyle)
|
||||
});
|
||||
});
|
||||
}
|
||||
event.preventDefault();
|
||||
|
@ -1071,8 +1074,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (!selectText.trim()) {
|
||||
selectAll(protyle, nodeElement, range);
|
||||
}
|
||||
const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML));
|
||||
getSavePath(protyle.path, protyle.notebookId, (pathString) => {
|
||||
const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML)) || "Untitled";
|
||||
fetchPost("/api/filetree/createDocWithMd", {
|
||||
notebook: protyle.notebookId,
|
||||
path: pathPosix().join(pathString, newFileName),
|
||||
|
|
Loading…
Add table
Reference in a new issue