From 654bb75e4104f0b49cb94a7296ffd8a9a6eb3fc7 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Tue, 21 May 2024 13:11:37 -0400 Subject: Browser agnostic search page clipboard checking (#965) --- ext/js/display/search-display-controller.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'ext') diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index e63b96e8..90504beb 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -66,11 +66,11 @@ export class SearchDisplayController { /** @type {boolean} */ this._clipboardMonitorEnabled = false; /** @type {import('clipboard-monitor').ClipboardReaderLike} */ - const clipboardReader = { + this.clipboardReaderLike = { getText: this._display.application.api.clipboardGet.bind(this._display.application.api) }; /** @type {ClipboardMonitor} */ - this._clipboardMonitor = new ClipboardMonitor(clipboardReader); + this._clipboardMonitor = new ClipboardMonitor(this.clipboardReaderLike); /** @type {import('application').ApiMap} */ this._apiMap = createApiMap([ ['searchDisplayControllerGetMode', this._onMessageGetMode.bind(this)], @@ -268,10 +268,9 @@ export class SearchDisplayController { } /** */ - _onCopy() { + async _onCopy() { // Ignore copy from search page - const selection = window.getSelection(); - this._clipboardMonitor.setPreviousText(selection !== null ? selection.toString().trim() : ''); + this._clipboardMonitor.setPreviousText(document.hasFocus() ? await this.clipboardReaderLike.getText(false) : ''); } /** @type {import('application').ApiHandler<'searchDisplayControllerUpdateSearchQuery'>} */ -- cgit v1.2.3