From da1e1e5c5b4dc20cc6aa46b51c55a496d094ed5c Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 9 Jan 2021 21:25:04 -0500 Subject: [PATCH] Sentence parsing options (#1214) * Rename options.anki.sentenceExt to options.sentenceParsing.scanExtent * Create sentence parsing icon * Create new sentence parsing section --- ext/bg/data/options-schema.json | 22 ++++++---- ext/bg/js/options.js | 5 +++ ext/bg/settings.html | 2 +- ext/bg/settings2.html | 66 +++++++++++++++++++----------- ext/fg/js/frontend.js | 2 +- ext/mixed/css/material.css | 1 + ext/mixed/img/sentence-parsing.svg | 1 + ext/mixed/js/display.js | 4 +- resources/icons.svg | 22 +++++++--- test/test-options-util.js | 4 +- 10 files changed, 88 insertions(+), 41 deletions(-) create mode 100644 ext/mixed/img/sentence-parsing.svg diff --git a/ext/bg/data/options-schema.json b/ext/bg/data/options-schema.json index 12c4097d..9053ebb1 100644 --- a/ext/bg/data/options-schema.json +++ b/ext/bg/data/options-schema.json @@ -68,7 +68,8 @@ "translation", "dictionaries", "parsing", - "anki" + "anki", + "sentenceParsing" ], "properties": { "general": { @@ -732,7 +733,6 @@ "enable", "server", "tags", - "sentenceExt", "screenshot", "terms", "kanji", @@ -758,11 +758,6 @@ "yomichan" ] }, - "sentenceExt": { - "type": "integer", - "minimum": 0, - "default": 200 - }, "screenshot": { "type": "object", "required": [ @@ -847,6 +842,19 @@ "default": null } } + }, + "sentenceParsing": { + "type": "object", + "required": [ + "scanExtent" + ], + "properties": { + "scanExtent": { + "type": "integer", + "minimum": 0, + "default": 200 + } + } } } } diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index adf3cfd4..441d56ec 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -683,11 +683,16 @@ class OptionsUtil { _updateVersion8(options) { // Version 8 changes: // Added translation.textReplacements. + // Moved anki.sentenceExt to sentenceParsing.scanExtent. for (const profile of options.profiles) { profile.options.translation.textReplacements = { searchOriginal: true, groups: [] }; + profile.options.sentenceParsing = { + scanExtent: profile.options.anki.sentenceExt + }; + delete profile.options.anki.sentenceExt; } return options; } diff --git a/ext/bg/settings.html b/ext/bg/settings.html index ec048a3b..d206d697 100644 --- a/ext/bg/settings.html +++ b/ext/bg/settings.html @@ -960,7 +960,7 @@
- +
diff --git a/ext/bg/settings2.html b/ext/bg/settings2.html index b74c4ec1..e5f105f0 100644 --- a/ext/bg/settings2.html +++ b/ext/bg/settings2.html @@ -31,6 +31,7 @@ Window Audio Text Parsing + Sentence Parsing Translation Anki Shortcuts @@ -1107,6 +1108,48 @@
+ +
+ + +
+
+
+
+
+
+ Sentence scanning extent + (?) +
+
+
+ +
+
+ +
+
+
@@ -1389,29 +1432,6 @@
-
-
-
-
- Sentence scanning extent - (?) -
-
-
- -
-
- -
Configure Anki card format…
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 3a5a2a44..c14c2feb 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -326,7 +326,7 @@ class Frontend { touchInputEnabled: scanningOptions.touchInputEnabled, pointerEventsEnabled: scanningOptions.pointerEventsEnabled, scanLength: scanningOptions.length, - sentenceExtent: options.anki.sentenceExt, + sentenceExtent: options.sentenceParsing.scanExtent, layoutAwareScan: scanningOptions.layoutAwareScan, preventMiddleMouse }); diff --git a/ext/mixed/css/material.css b/ext/mixed/css/material.css index a21dc2bb..b4a80807 100644 --- a/ext/mixed/css/material.css +++ b/ext/mixed/css/material.css @@ -181,6 +181,7 @@ .icon[data-icon=expand] { --icon-image: url(/mixed/img/expand.svg); } .icon[data-icon=window] { --icon-image: url(/mixed/img/window.svg); } .icon[data-icon=cross] { --icon-image: url(/mixed/img/cross.svg); } +.icon[data-icon=sentence-parsing] { --icon-image: url(/mixed/img/sentence-parsing.svg); } .icon[data-icon=material-down-arrow] { --icon-image: url(/mixed/img/material-down-arrow.svg); --icon-size: var(--material-arrow-dimension2) var(--material-arrow-dimension1); diff --git a/ext/mixed/img/sentence-parsing.svg b/ext/mixed/img/sentence-parsing.svg new file mode 100644 index 00000000..7c883175 --- /dev/null +++ b/ext/mixed/img/sentence-parsing.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index e4433925..60842a3d 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -327,7 +327,7 @@ class Display extends EventDispatcher { touchInputEnabled: scanning.touchInputEnabled, pointerEventsEnabled: scanning.pointerEventsEnabled, scanLength: scanning.length, - sentenceExtent: options.anki.sentenceExt, + sentenceExtent: options.sentenceParsing.scanExtent, layoutAwareScan: scanning.layoutAwareScan, preventMiddleMouse: scanning.preventMiddleMouse.onSearchQuery } @@ -1832,7 +1832,7 @@ class Display extends EventDispatcher { touchInputEnabled: false, pointerEventsEnabled: false, scanLength: scanningOptions.length, - sentenceExtent: options.anki.sentenceExt, + sentenceExtent: options.sentenceParsing.scanExtent, layoutAwareScan: scanningOptions.layoutAwareScan, preventMiddleMouse: false }); diff --git a/resources/icons.svg b/resources/icons.svg index dc516d0c..59723730 100644 --- a/resources/icons.svg +++ b/resources/icons.svg @@ -27,11 +27,11 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="32" - inkscape:cx="9.1786991" - inkscape:cy="6.2962412" + inkscape:zoom="16" + inkscape:cx="-0.96137572" + inkscape:cy="5.5332057" inkscape:document-units="px" - inkscape:current-layer="layer37" + inkscape:current-layer="g1184" showgrid="true" units="px" inkscape:snap-center="true" @@ -532,7 +532,7 @@ image/svg+xml - + @@ -1197,7 +1197,7 @@ inkscape:groupmode="layer" id="layer37" inkscape:label="Lock" - style="display:inline"> + style="display:none"> + + + diff --git a/test/test-options-util.js b/test/test-options-util.js index ca5f5065..8b7254c6 100644 --- a/test/test-options-util.js +++ b/test/test-options-util.js @@ -412,13 +412,15 @@ function createProfileOptionsUpdatedTestData1() { enable: false, server: 'http://127.0.0.1:8765', tags: ['yomichan'], - sentenceExt: 200, screenshot: {format: 'png', quality: 92}, terms: {deck: '', model: '', fields: {}}, kanji: {deck: '', model: '', fields: {}}, duplicateScope: 'collection', checkForDuplicates: true, fieldTemplates: null + }, + sentenceParsing: { + scanExtent: 200 } }; }