diff options
author | Kuuuube <61125188+Kuuuube@users.noreply.github.com> | 2024-05-21 13:11:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 17:11:37 +0000 |
commit | 654bb75e4104f0b49cb94a7296ffd8a9a6eb3fc7 (patch) | |
tree | 38aa4fab25a12c91ca27cd14349a137096e1425d /ext | |
parent | 6998ebeee2f68158428ee58de2e77fcf658e53ab (diff) |
Browser agnostic search page clipboard checking (#965)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/js/display/search-display-controller.js | 9 |
1 files changed, 4 insertions, 5 deletions
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'>} */ |