Skip to content

Commit

Permalink
Browser agnostic search page clipboard checking (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed May 21, 2024
1 parent 6998ebe commit 654bb75
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ext/js/display/search-display-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
Expand Down Expand Up @@ -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'>} */
Expand Down

0 comments on commit 654bb75

Please sign in to comment.