+
+
+
+
+
@@ -151,6 +161,26 @@ export const openSnippets = () => {
target = target.parentElement;
}
});
+ dialog.element.querySelectorAll('[data-action="search"]').forEach((inputItem: HTMLInputElement) => {
+ inputItem.addEventListener("keydown", (event: KeyboardEvent) => {
+ if (event.key === "Enter" && !event.isComposing) {
+ fetchPost("/api/snippet/getSnippet", {
+ type: "all",
+ enabled: 2,
+ keyword: inputItem.value
+ }, (searchResponse) => {
+ dialog.element.querySelectorAll(`.fn__flex-1 > div > [data-type="${inputItem.dataset.type}"]`).forEach((snipeetPanel: Element) => {
+ snipeetPanel.classList.add("fn__none");
+ })
+ searchResponse.data.snippets.forEach((snippetItem: ISnippet) => {
+ if (snippetItem.type === inputItem.dataset.type) {
+ dialog.element.querySelector(`[data-id="${snippetItem.id}"]`).classList.remove("fn__none");
+ }
+ });
+ });
+ }
+ });
+ })
});
};