From 889240311b4072021f3742345bc87118c5b3a3e1 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 31 Dec 2020 14:21:50 -0500 Subject: Improve tag scanning behaviour (#1189) * Update include/exclude selectors for Display._definitionTextScanner * Fix missing condition --- ext/mixed/display-templates.html | 4 ++-- ext/mixed/js/display.js | 8 +++----- ext/mixed/js/text-scanner.js | 6 ++++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'ext') diff --git a/ext/mixed/display-templates.html b/ext/mixed/display-templates.html index 4c202448..95432ad2 100644 --- a/ext/mixed/display-templates.html +++ b/ext/mixed/display-templates.html @@ -39,8 +39,8 @@ - - + + diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index c0d84dce..3817559d 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -845,6 +845,7 @@ class Display extends EventDispatcher { _showTagNotification(content) { if (this._tagNotification === null) { const node = this._displayGenerator.createEmptyFooterNotification(); + node.classList.add('click-scannable'); this._tagNotification = new DisplayNotification(this._tagNotificationContainer, node); } @@ -1792,8 +1793,8 @@ class Display extends EventDispatcher { searchOnClick: true, searchOnClickOnly: true }); - const excludeSelectors = ['.scan-disable', '.scan-disable *']; - this._definitionTextScanner.excludeSelector = excludeSelectors.join(','); + this._definitionTextScanner.includeSelector = '.click-scannable,.click-scannable *'; + this._definitionTextScanner.excludeSelector = '.scan-disable,.scan-disable *'; this._definitionTextScanner.prepare(); this._definitionTextScanner.on('searched', this._onDefinitionTextScannerSearched.bind(this)); } @@ -1825,9 +1826,6 @@ class Display extends EventDispatcher { preventMiddleMouse: false }); - const includeSelector = '.term-glossary-item,.term-glossary-item *,.tag,.tag *'; - this._definitionTextScanner.includeSelector = includeSelector; - this._definitionTextScanner.setEnabled(true); } diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index f0903370..daea6a6c 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -198,8 +198,10 @@ class TextScanner extends EventDispatcher { clonedTextSource.setEndOffset(length, layoutAwareScan); - if (this._excludeSelector !== null) { - this._constrainTextSource(clonedTextSource, this._includeSelector, this._excludeSelector, layoutAwareScan); + const includeSelector = this._includeSelector; + const excludeSelector = this._excludeSelector; + if (includeSelector !== null || excludeSelector !== null) { + this._constrainTextSource(clonedTextSource, includeSelector, excludeSelector, layoutAwareScan); } return clonedTextSource.text(); -- cgit v1.2.3