summaryrefslogtreecommitdiff
path: root/ext/js/display/search-display-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display/search-display-controller.js')
-rw-r--r--ext/js/display/search-display-controller.js21
1 files changed, 19 insertions, 2 deletions
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index e23d5d50..00f5efc6 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -103,7 +103,7 @@ export class SearchDisplayController {
this._searchBackButton.addEventListener('click', this._onSearchBackButtonClick.bind(this), false);
this._wanakanaEnableCheckbox.addEventListener('change', this._onWanakanaEnableChange.bind(this));
window.addEventListener('copy', this._onCopy.bind(this));
- this._clipboardMonitor.on('change', this._onExternalSearchUpdate.bind(this));
+ this._clipboardMonitor.on('change', this._onClipboardMonitorChange.bind(this));
this._clipboardMonitorEnableCheckbox.addEventListener('change', this._onClipboardMonitorEnableChange.bind(this));
this._display.hotkeyHandler.on('keydownNonHotkey', this._onKeyDown.bind(this));
@@ -271,9 +271,26 @@ export class SearchDisplayController {
}
/** @type {import('application').ApiHandler<'searchDisplayControllerUpdateSearchQuery'>} */
- _onExternalSearchUpdate({text, animate = true}) {
+ _onExternalSearchUpdate({text, animate}) {
+ void this._updateSearchFromClipboard(text, animate, false);
+ }
+
+ /**
+ * @param {import('clipboard-monitor').Events['change']} event
+ */
+ _onClipboardMonitorChange({text}) {
+ void this._updateSearchFromClipboard(text, true, true);
+ }
+
+ /**
+ * @param {string} text
+ * @param {boolean} animate
+ * @param {boolean} checkText
+ */
+ async _updateSearchFromClipboard(text, animate, checkText) {
const options = this._display.getOptions();
if (options === null) { return; }
+ if (checkText && !await this._display.application.api.isTextLookupWorthy(text, options.general.language)) { return; }
const {clipboard: {autoSearchContent, maximumSearchLength}} = options;
if (text.length > maximumSearchLength) {
text = text.substring(0, maximumSearchLength);