summaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js11
-rw-r--r--ext/mixed/js/text-scanner.js6
2 files changed, 9 insertions, 8 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 927c2c2c..170b9d23 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -20,14 +20,13 @@
* DOM
* DisplayGenerator
* DisplayHistory
+ * DocumentUtil
* Frontend
* MediaLoader
* PopupFactory
* QueryParser
* WindowScroll
* api
- * docRangeFromPoint
- * docSentenceExtract
* dynamicLoader
*/
@@ -74,12 +73,14 @@ class Display extends EventDispatcher {
this._defaultTitle = 'Yomichan Search';
this._defaultTitleMaxLength = 1000;
this._fullQuery = '';
+ this._documentUtil = new DocumentUtil();
this._queryParserVisible = false;
this._queryParserVisibleOverride = null;
this._queryParserContainer = document.querySelector('#query-parser-container');
this._queryParser = new QueryParser({
getOptionsContext: this.getOptionsContext.bind(this),
- setSpinnerVisible: this.setSpinnerVisible.bind(this)
+ setSpinnerVisible: this.setSpinnerVisible.bind(this),
+ documentUtil: this._documentUtil
});
this._mode = null;
@@ -588,7 +589,7 @@ class Display extends EventDispatcher {
const scannedElement = e.target;
const sentenceExtent = this._options.anki.sentenceExt;
const layoutAwareScan = this._options.scanning.layoutAwareScan;
- const sentence = docSentenceExtract(textSource, sentenceExtent, layoutAwareScan);
+ const sentence = this._documentUtil.extractSentence(textSource, sentenceExtent, layoutAwareScan);
state.focusEntry = this._entryIndexFind(scannedElement);
state.scrollX = this._windowScroll.x;
@@ -616,7 +617,7 @@ class Display extends EventDispatcher {
e.preventDefault();
const {length: scanLength, deepDomScan: deepScan, layoutAwareScan} = this._options.scanning;
- const textSource = docRangeFromPoint(e.clientX, e.clientY, deepScan);
+ const textSource = this._documentUtil.getRangeFromPoint(e.clientX, e.clientY, deepScan);
if (textSource === null) {
return false;
}
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index 61e9256d..923784b3 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -17,16 +17,16 @@
/* global
* DOM
- * docRangeFromPoint
*/
class TextScanner extends EventDispatcher {
- constructor({node, ignoreElements, ignorePoint, search}) {
+ constructor({node, ignoreElements, ignorePoint, search, documentUtil}) {
super();
this._node = node;
this._ignoreElements = ignoreElements;
this._ignorePoint = ignorePoint;
this._search = search;
+ this._documentUtil = documentUtil;
this._isPrepared = false;
this._ignoreNodes = null;
@@ -124,7 +124,7 @@ class TextScanner extends EventDispatcher {
return;
}
- const textSource = docRangeFromPoint(x, y, this._deepContentScan);
+ const textSource = this._documentUtil.getRangeFromPoint(x, y, this._deepContentScan);
try {
if (this._textSourceCurrent !== null && this._textSourceCurrent.equals(textSource)) {
return;