Improve tag scanning behaviour (#1189)
* Update include/exclude selectors for Display._definitionTextScanner * Fix missing condition
This commit is contained in:
parent
1b4ba1fb00
commit
889240311b
@ -39,8 +39,8 @@
|
|||||||
</div></template>
|
</div></template>
|
||||||
<template id="term-definition-item-template"><li class="term-definition-item"><div class="term-definition-tag-list tag-list"></div><div class="term-definition-disambiguation-list"></div><ul class="term-glossary-list"></ul></li></template>
|
<template id="term-definition-item-template"><li class="term-definition-item"><div class="term-definition-tag-list tag-list"></div><div class="term-definition-disambiguation-list"></div><ul class="term-glossary-list"></ul></li></template>
|
||||||
<template id="term-definition-disambiguation-template"><span class="term-definition-disambiguation"></span></template>
|
<template id="term-definition-disambiguation-template"><span class="term-definition-disambiguation"></span></template>
|
||||||
<template id="term-glossary-item-template"><li class="term-glossary-item"><span class="term-glossary-separator"> </span><span class="term-glossary"></span></li></template>
|
<template id="term-glossary-item-template"><li class="term-glossary-item click-scannable"><span class="term-glossary-separator"> </span><span class="term-glossary"></span></li></template>
|
||||||
<template id="term-glossary-item-image-template"><li class="term-glossary-item" data-has-image="true"><span class="term-glossary-separator"> </span><span class="term-glossary"><a class="term-glossary-image-link" target="_blank" rel="noreferrer noopener"><span class="term-glossary-image-container"><span class="term-glossary-image-aspect-ratio-sizer"></span><img class="term-glossary-image" alt="" /><span class="term-glossary-image-container-overlay"></span></span><span class="term-glossary-image-link-text">Image</span></a> <span class="term-glossary-image-description"></span></span></li></template>
|
<template id="term-glossary-item-image-template"><li class="term-glossary-item click-scannable" data-has-image="true"><span class="term-glossary-separator"> </span><span class="term-glossary"><a class="term-glossary-image-link" target="_blank" rel="noreferrer noopener"><span class="term-glossary-image-container"><span class="term-glossary-image-aspect-ratio-sizer"></span><img class="term-glossary-image" alt="" /><span class="term-glossary-image-container-overlay"></span></span><span class="term-glossary-image-link-text">Image</span></a> <span class="term-glossary-image-description"></span></span></li></template>
|
||||||
<template id="term-reason-template"><span class="term-reason"></span><span class="term-reason-separator"> </span></template>
|
<template id="term-reason-template"><span class="term-reason"></span><span class="term-reason-separator"> </span></template>
|
||||||
|
|
||||||
<!-- Pitch accent templates -->
|
<!-- Pitch accent templates -->
|
||||||
|
@ -845,6 +845,7 @@ class Display extends EventDispatcher {
|
|||||||
_showTagNotification(content) {
|
_showTagNotification(content) {
|
||||||
if (this._tagNotification === null) {
|
if (this._tagNotification === null) {
|
||||||
const node = this._displayGenerator.createEmptyFooterNotification();
|
const node = this._displayGenerator.createEmptyFooterNotification();
|
||||||
|
node.classList.add('click-scannable');
|
||||||
this._tagNotification = new DisplayNotification(this._tagNotificationContainer, node);
|
this._tagNotification = new DisplayNotification(this._tagNotificationContainer, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1792,8 +1793,8 @@ class Display extends EventDispatcher {
|
|||||||
searchOnClick: true,
|
searchOnClick: true,
|
||||||
searchOnClickOnly: true
|
searchOnClickOnly: true
|
||||||
});
|
});
|
||||||
const excludeSelectors = ['.scan-disable', '.scan-disable *'];
|
this._definitionTextScanner.includeSelector = '.click-scannable,.click-scannable *';
|
||||||
this._definitionTextScanner.excludeSelector = excludeSelectors.join(',');
|
this._definitionTextScanner.excludeSelector = '.scan-disable,.scan-disable *';
|
||||||
this._definitionTextScanner.prepare();
|
this._definitionTextScanner.prepare();
|
||||||
this._definitionTextScanner.on('searched', this._onDefinitionTextScannerSearched.bind(this));
|
this._definitionTextScanner.on('searched', this._onDefinitionTextScannerSearched.bind(this));
|
||||||
}
|
}
|
||||||
@ -1825,9 +1826,6 @@ class Display extends EventDispatcher {
|
|||||||
preventMiddleMouse: false
|
preventMiddleMouse: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const includeSelector = '.term-glossary-item,.term-glossary-item *,.tag,.tag *';
|
|
||||||
this._definitionTextScanner.includeSelector = includeSelector;
|
|
||||||
|
|
||||||
this._definitionTextScanner.setEnabled(true);
|
this._definitionTextScanner.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +198,10 @@ class TextScanner extends EventDispatcher {
|
|||||||
|
|
||||||
clonedTextSource.setEndOffset(length, layoutAwareScan);
|
clonedTextSource.setEndOffset(length, layoutAwareScan);
|
||||||
|
|
||||||
if (this._excludeSelector !== null) {
|
const includeSelector = this._includeSelector;
|
||||||
this._constrainTextSource(clonedTextSource, this._includeSelector, this._excludeSelector, layoutAwareScan);
|
const excludeSelector = this._excludeSelector;
|
||||||
|
if (includeSelector !== null || excludeSelector !== null) {
|
||||||
|
this._constrainTextSource(clonedTextSource, includeSelector, excludeSelector, layoutAwareScan);
|
||||||
}
|
}
|
||||||
|
|
||||||
return clonedTextSource.text();
|
return clonedTextSource.text();
|
||||||
|
Loading…
Reference in New Issue
Block a user