Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/9950

Vanessa07aa1e077cc8
diff --git a/app/src/boot/globalEvent/searchKeydown.ts b/app/src/boot/globalEvent/searchKeydown.ts
index 13b42beab0..22a2e084b7 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 6779b6e2c1..f600ef2c28 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 = `<button class="ariaLabel" data-position="right" aria-label="${this.gutterTip}"
-data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${dataNodeId}">
+data-type="${type}" data-subtype="${nodeElement.getAttribute("data-subtype")}" data-node-id="${nodeElement.getAttribute("data-node-id")}">
<svg><use xlink:href="#${getIconByType(type, nodeElement.getAttribute("data-subtype"))}"></use></svg>
<span ${protyle.disabled ? "" : 'draggable="true"'}></span>
</button>`;
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index e551720e97..6608711305 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 ||
- `<div class="b3-list-item b3-list-item--focus" data-type="search-new">
+ element.querySelector("#searchList").innerHTML = resultHTML || (
+ config.method === 0 ? `<div class="b3-list-item b3-list-item--focus" data-type="search-new">
<svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
<span class="b3-list-item__text">
${window.siyuan.languages.newFile} <mark>${(element.querySelector("#searchInput") as HTMLInputElement).value}</mark>
@@ -1359,5 +1361,9 @@ ${getAttr(item)}
</div>
<div class="search__empty">
${window.siyuan.languages.enterNewTip}
-</div>`;
+</div>` : `<div class="b3-list-item b3-list-item--focus" data-type="search-new">
+ <span class="b3-list-item__text">
+ ${window.siyuan.languages.emptyContent}
+ </span>
+</div>`);
};
diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.ts
index 4f9a121d85..91a257dbc8 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;
}