summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/js/display/search-display-controller.js9
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'>} */