diff options
-rw-r--r-- | ext/bg/data/options-schema.json | 22 | ||||
-rw-r--r-- | ext/bg/js/options.js | 5 | ||||
-rw-r--r-- | ext/bg/settings.html | 2 | ||||
-rw-r--r-- | ext/bg/settings2.html | 66 | ||||
-rw-r--r-- | ext/fg/js/frontend.js | 2 | ||||
-rw-r--r-- | ext/mixed/css/material.css | 1 | ||||
-rw-r--r-- | ext/mixed/img/sentence-parsing.svg | 1 | ||||
-rw-r--r-- | ext/mixed/js/display.js | 4 | ||||
-rw-r--r-- | resources/icons.svg | 22 | ||||
-rw-r--r-- | test/test-options-util.js | 4 |
10 files changed, 88 insertions, 41 deletions
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 @@ <div class="form-group options-advanced"> <label for="sentence-detection-extent">Sentence detection extent <span class="label-light">(in characters)</span></label> - <input type="number" min="1" step="1" id="sentence-detection-extent" class="form-control" data-setting="anki.sentenceExt"> + <input type="number" min="0" step="1" id="sentence-detection-extent" class="form-control" data-setting="sentenceParsing.scanExtent"> </div> <div class="form-group options-advanced"> 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 @@ <a href="#!window" class="outline-item"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="window"></span></span><span class="outline-item-label">Window</span></a> <a href="#!audio" class="outline-item"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="speaker"></span></span><span class="outline-item-label">Audio</span></a> <a href="#!text-parsing" class="outline-item"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="text-parsing"></span></span><span class="outline-item-label">Text Parsing</span></a> + <a href="#!sentence-parsing" class="outline-item advanced-only"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="sentence-parsing"></span></span><span class="outline-item-label">Sentence Parsing</span></a> <a href="#!translation" class="outline-item"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="translation"></span></span><span class="outline-item-label">Translation</span></a> <a href="#!anki" class="outline-item"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="note-card"></span></span><span class="outline-item-label">Anki</span></a> <a href="#!shortcuts" class="outline-item"><span class="outline-item-left"><span class="outline-item-icon icon" data-icon="keyboard"></span></span><span class="outline-item-label">Shortcuts</span></a> @@ -1107,6 +1108,48 @@ </div></div> </div> + <!-- Text Parsing --> + <div class="advanced-only"> + <div class="heading-container"> + <div class="heading-container-icon"><span class="icon" data-icon="sentence-parsing"></span></div> + <div class="heading-container-left"><h2 id="sentence-parsing"><a href="#!sentence-parsing">Sentence Parsing</a></h2></div> + <div class="heading-container-right"><a class="more-toggle more-only heading-link-light" data-parent-distance="3">Info…</a></div> + </div> + <div class="heading-description more" hidden> + <p> + Yomichan can will scan and parse sentences which can be used as contextual information for Anki cards. + </p> + <p> + <a class="more-toggle" data-parent-distance="3">Less…</a> + </p> + </div> + </div> + <div class="settings-group advanced-only"> + <div class="settings-item"> + <div class="settings-item-inner settings-item-inner-wrappable"> + <div class="settings-item-left"> + <div class="settings-item-label"> + Sentence scanning extent + <a class="more-toggle more-only" data-parent-distance="4">(?)</a> + </div> + </div> + <div class="settings-item-right"> + <input type="number" data-setting="sentenceParsing.scanExtent" min="0" step="1"> + </div> + </div> + <div class="settings-item-children more" hidden> + <p> + This option controls the maximum scanning distance used to determine the bounds of a sentence, + in number of characters. + Sentence scanning is bidirectional and begins from both the start and end of the source term. + </p> + <p> + <a class="more-toggle" data-parent-distance="3">Less…</a> + </p> + </div> + </div> + </div> + <!-- Translation --> <div> <div class="heading-container"> @@ -1389,29 +1432,6 @@ </div> </div> </div></div> - <div class="settings-item advanced-only"> - <div class="settings-item-inner settings-item-inner-wrappable"> - <div class="settings-item-left"> - <div class="settings-item-label"> - Sentence scanning extent - <a class="more-toggle more-only" data-parent-distance="4">(?)</a> - </div> - </div> - <div class="settings-item-right"> - <input type="number" data-setting="anki.sentenceExt" min="1" step="1"> - </div> - </div> - <div class="settings-item-children more" hidden> - <p> - This option controls the maximum scanning distance used to determine the bounds of a sentence, - in number of characters. - Sentence scanning is bidirectional and begins from both the start and end of the source term. - </p> - <p> - <a class="more-toggle" data-parent-distance="3">Less…</a> - </p> - </div> - </div> <div class="settings-item settings-item-button" data-modal-action="show,anki-cards"><div class="settings-item-inner"> <div class="settings-item-left"> <div class="settings-item-label">Configure Anki card format…</div> 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 @@ +<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M2.5996 1.8008C1.5996 2.8008 1 3.75 1 5c0 .55228.44772 1 1 1s1-.44772 1-1c0-.54895-.44255-.89427-.99023-.89844.04617-.75567.59691-1.3901.89062-1.9023l-.30078-.39844zm2.5 0C4.0996 2.8008 3.5 3.75 3.5 5c0 .55228.44772 1 1 1s1-.44772 1-1c0-.54895-.44255-.89427-.99023-.89844.04617-.75567.59691-1.3901.89062-1.9023l-.30078-.39844zM6.5 5v1H15V5H6.5zM1 7v1h7V7H1zm8 0v1h3V7H9zm4 0v1h2V7h-2zM1 9v1h2V9H1zm3 0v1h3V9H4zm4 0v1h3V9H8zm5.5 0c-.8225 0-1.5.6775-1.5 1.5s.6775 1.5 1.5 1.5 1.5-.6775 1.5-1.5S14.3225 9 13.5 9zm0 1c.28206 0 .5.21794.5.5s-.21794.5-.5.5-.5-.21794-.5-.5.21794-.5.5-.5zM1 11v1h4v-1H1zm5 0v1h5v-1H6z" fill="#333"/></svg>
\ 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 @@ <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - <dc:title></dc:title> + <dc:title /> </cc:Work> </rdf:RDF> </metadata> @@ -1197,7 +1197,7 @@ inkscape:groupmode="layer" id="layer37" inkscape:label="Lock" - style="display:inline"> + style="display:none"> <path style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" d="M 8,1.5 C 6.0758869,1.4999999 4.5,3.0758869 4.5,5 V 7.5 H 4 c -0.5522619,5.52e-5 -0.9999448,0.4477381 -1,1 v 5 c 5.52e-5,0.552262 0.4477381,0.999945 1,1 h 8 c 0.552262,-5.5e-5 0.999945,-0.447738 1,-1 v -5 c -5.5e-5,-0.5522619 -0.447738,-0.9999448 -1,-1 H 11.5 V 5 C 11.5,3.0758869 9.9241131,1.5000001 8,1.5 Z M 8,3 c 1.1134529,0 2,0.8865471 2,2 V 7.5 H 6 V 5 C 6,3.886547 6.886547,3 8,3 Z" @@ -1524,4 +1524,14 @@ id="rect1062" inkscape:connector-curvature="0" /> </g> + <g + inkscape:label="Sentence Parsing" + id="g1184" + inkscape:groupmode="layer" + style="display:inline"> + <path + style="display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" + d="M 2.5996094 1.8007812 C 1.5996094 2.8007812 1 3.75 1 5 C 1 5.5522847 1.4477153 6 2 6 C 2.5522847 6 3 5.5522847 3 5 C 3 4.4510454 2.5574543 4.1057254 2.0097656 4.1015625 C 2.0559376 3.3458915 2.6066745 2.7114397 2.9003906 2.1992188 L 2.5996094 1.8007812 z M 5.0996094 1.8007812 C 4.0996094 2.8007812 3.5 3.75 3.5 5 C 3.5 5.5522847 3.9477153 6 4.5 6 C 5.0522847 6 5.5 5.5522847 5.5 5 C 5.5 4.4510454 5.0574543 4.1057254 4.5097656 4.1015625 C 4.5559376 3.3458915 5.1066745 2.7114397 5.4003906 2.1992188 L 5.0996094 1.8007812 z M 6.5 5 L 6.5 6 L 15 6 L 15 5 L 6.5 5 z M 1 7 L 1 8 L 8 8 L 8 7 L 1 7 z M 9 7 L 9 8 L 12 8 L 12 7 L 9 7 z M 13 7 L 13 8 L 15 8 L 15 7 L 13 7 z M 1 9 L 1 10 L 3 10 L 3 9 L 1 9 z M 4 9 L 4 10 L 7 10 L 7 9 L 4 9 z M 8 9 L 8 10 L 11 10 L 11 9 L 8 9 z M 13.5 9 C 12.677495 9 12 9.6774952 12 10.5 C 12 11.322505 12.677495 12 13.5 12 C 14.322505 12 15 11.322505 15 10.5 C 15 9.6774952 14.322505 9 13.5 9 z M 13.5 10 C 13.782065 10 14 10.217935 14 10.5 C 14 10.782065 13.782065 11 13.5 11 C 13.217935 11 13 10.782065 13 10.5 C 13 10.217935 13.217935 10 13.5 10 z M 1 11 L 1 12 L 5 12 L 5 11 L 1 11 z M 6 11 L 6 12 L 11 12 L 11 11 L 6 11 z " + id="path1176" /> + </g> </svg> 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 } }; } |