diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.ts index 13b42beab..22a2e084b 100644 --- a/app/src/boot/globalEvent/searchKeydown.ts +++ b/app/src/boot/globalEvent/searchKeydown.ts @@ -55,7 +55,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => { const isAsset = !assetsElement.classList.contains("fn__none"); const listElement = isAsset ? assetsElement.querySelector("#searchAssetList") : element.querySelector("#searchList"); const searchInputElement = element.querySelector("#searchInput") as HTMLInputElement; - if (!isAsset && matchHotKey(window.siyuan.config.keymap.general.newFile.custom, event)) { + if (!isAsset && matchHotKey(window.siyuan.config.keymap.general.newFile.custom, event) && config.method === 0) { newFileByName(app, searchInputElement.value); return true; } @@ -82,7 +82,7 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => { return false; } if (currentList.getAttribute("data-type") === "search-new") { - if (event.key === "Enter") { + if (event.key === "Enter" && config.method === 0) { newFileByName(app, searchInputElement.value); return true; } diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts index 6779b6e2c..f600ef2c2 100644 --- a/app/src/protyle/gutter/index.ts +++ b/app/src/protyle/gutter/index.ts @@ -1953,7 +1953,7 @@ export class Gutter { } index += 1; const buttonHTML = ``; diff --git a/app/src/search/util.ts b/app/src/search/util.ts index e551720e9..660871130 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -861,7 +861,9 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo } else if (target.classList.contains("b3-list-item")) { const searchAssetInputElement = element.querySelector("#searchAssetInput") as HTMLInputElement; if (type === "search-new") { - newFileByName(app, searchInputElement.value); + if (config.method == 0) { + newFileByName(app, searchInputElement.value); + } } else if (type === "search-item") { const isAsset = target.dataset.id; let isClick = event.detail === 1; @@ -1349,8 +1351,8 @@ ${getAttr(item)} edit.protyle.element.classList.add("fn__none"); element.querySelector(".search__drag").classList.add("fn__none"); } - element.querySelector("#searchList").innerHTML = resultHTML || - `
+ element.querySelector("#searchList").innerHTML = resultHTML || ( + config.method === 0 ? `
${window.siyuan.languages.newFile} ${(element.querySelector("#searchInput") as HTMLInputElement).value} @@ -1359,5 +1361,9 @@ ${getAttr(item)}
${window.siyuan.languages.enterNewTip} -
`; +
` : `
+ + ${window.siyuan.languages.emptyContent} + +
`); }; diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts index 4f9a121d8..91a257dbc 100644 --- a/app/src/util/highlightById.ts +++ b/app/src/util/highlightById.ts @@ -63,7 +63,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal let offsetTop = 0; let parentNodeElement = nodeElement; - while (!parentNodeElement.classList.contains("protyle-wysiwyg")) { + while (parentNodeElement && !parentNodeElement.classList.contains("protyle-wysiwyg")) { offsetTop += (parentNodeElement as HTMLElement).offsetTop; parentNodeElement = parentNodeElement.parentElement; }