This commit is contained in:
Vanessa 2023-12-23 00:00:10 +08:00
parent f5ff8f74c2
commit 07aa1e077c
4 changed files with 14 additions and 8 deletions

View file

@ -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;
}

View file

@ -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>`;

View file

@ -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>`);
};

View file

@ -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;
}