handle paste

This commit is contained in:
cade
2026-03-21 00:45:58 +00:00
parent f75809d660
commit 6c082956a3
+14 -2
View File
@@ -352,6 +352,7 @@
this.#input.addEventListener('input', this.#onInput);
this.#suggestions.addEventListener('click', this.#onSuggestionClick);
document.addEventListener('keydown', this.#onKeydown);
document.addEventListener('paste', this.#onPaste);
this.shadowRoot.append(clone);
}
@@ -491,7 +492,7 @@
}
suggestions = suggestions.filter(
(s) => s.startsWith(oq.query) || s.includes(oq.query),
(s) => s.startsWith(oq.query) || s.includes(oq.query)
);
}
@@ -504,7 +505,7 @@
suggestions = [...suggestions, ...ddgSuggestions].slice(
0,
CONFIG.suggestionLimit,
CONFIG.suggestionLimit
);
}
@@ -513,6 +514,17 @@
this.#renderSuggestions(suggestions, oq.query);
};
#onPaste = (e) => {
if (this.#dialog.open) return;
const text = e.clipboardData?.getData('text');
if (!text) return;
e.preventDefault();
this.#dialog.show();
this.#input.focus();
this.#input.value = text;
this.#onInput();
};
#onKeydown = (e) => {
if (!this.#dialog.open) {
this.#dialog.show();