mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
This commit is contained in:
parent
c5d9b83224
commit
8af49fcc16
2 changed files with 7 additions and 7 deletions
|
|
@ -930,7 +930,7 @@ export const openMenuPanel = (options: {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
} else if (type === "goSearchAV") {
|
} else if (type === "goSearchAV") {
|
||||||
openSearchAV(avID, target);
|
openSearchAV(avID, target, undefined, false);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import {updateAttrViewCellAnimation} from "./action";
|
||||||
import {focusBlock} from "../../util/selection";
|
import {focusBlock} from "../../util/selection";
|
||||||
import {setPosition} from "../../../util/setPosition";
|
import {setPosition} from "../../../util/setPosition";
|
||||||
|
|
||||||
const genSearchList = (element: Element, keyword: string, avId: string, cb?: () => void) => {
|
const genSearchList = (element: Element, keyword: string, avId: string, excludes = true, cb?: () => void) => {
|
||||||
fetchPost("/api/av/searchAttributeView", {keyword, excludes: [avId]}, (response) => {
|
fetchPost("/api/av/searchAttributeView", {keyword, excludes: excludes ? [avId] : undefined}, (response) => {
|
||||||
let html = "";
|
let html = "";
|
||||||
response.data.results.forEach((item: {
|
response.data.results.forEach((item: {
|
||||||
avID: string
|
avID: string
|
||||||
|
|
@ -45,7 +45,7 @@ const setDatabase = (avId: string, element: HTMLElement, item: HTMLElement) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const openSearchAV = (avId: string, target: HTMLElement, cb?: (element: HTMLElement) => void) => {
|
export const openSearchAV = (avId: string, target: HTMLElement, cb?: (element: HTMLElement) => void, excludes = true) => {
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
menu.addItem({
|
menu.addItem({
|
||||||
|
|
@ -86,10 +86,10 @@ export const openSearchAV = (avId: string, target: HTMLElement, cb?: (element: H
|
||||||
if (event.isComposing) {
|
if (event.isComposing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
genSearchList(listElement, inputElement.value, avId);
|
genSearchList(listElement, inputElement.value, avId, excludes);
|
||||||
});
|
});
|
||||||
inputElement.addEventListener("compositionend", () => {
|
inputElement.addEventListener("compositionend", () => {
|
||||||
genSearchList(listElement, inputElement.value, avId);
|
genSearchList(listElement, inputElement.value, avId, excludes);
|
||||||
});
|
});
|
||||||
element.lastElementChild.addEventListener("click", (event) => {
|
element.lastElementChild.addEventListener("click", (event) => {
|
||||||
const listItemElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
const listItemElement = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
|
||||||
|
|
@ -103,7 +103,7 @@ export const openSearchAV = (avId: string, target: HTMLElement, cb?: (element: H
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
genSearchList(listElement, "", avId, () => {
|
genSearchList(listElement, "", avId, excludes, () => {
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
menu.open({
|
menu.open({
|
||||||
x: rect.left,
|
x: rect.left,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue