Skip to content

Commit

Permalink
Force scan resolution "character" for ja, zh, yue, and ko (#1542)
Browse files Browse the repository at this point in the history
* Force scan resolution "character" for ja, zh, yue, ko

* Split out visibility modifiers

* Hide scan resolution setting for jp, zh, yue, ko

* Remove unused visibility modifiers css from search-settings

---------

Signed-off-by: Kuuuube <[email protected]>
  • Loading branch information
Kuuuube authored Nov 5, 2024
1 parent e7cfac4 commit 3ad6191
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
6 changes: 0 additions & 6 deletions ext/css/search-settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,6 @@ button.icon-button.modal-header-button>.icon-button-inner>.icon {
.settings-item-children.settings-item-children-group .settings-item-children {
padding-left: 0;
}
:root:not([data-advanced=true]) .advanced-only {
display: none;
}
:root:not([data-advanced=false]) .basic-only {
display: none;
}
.settings-item.settings-item-button,
a.settings-item.settings-item-button {
cursor: pointer;
Expand Down
12 changes: 0 additions & 12 deletions ext/css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -638,18 +638,6 @@ a.heading-link-light {
.settings-item-children.settings-item-children-group .settings-item-children {
padding-left: 0;
}
:root:not([data-debug=true]) .debug-only {
display: none;
}
:root:not([data-advanced=true]) .advanced-only {
display: none;
}
:root:not([data-advanced=false]) .basic-only {
display: none;
}
:root:not([data-language=ja]):not([data-language=zh]):not([data-language=yue]) .jpzhyue-only {
display: none;
}
.settings-item.settings-item-button,
a.settings-item.settings-item-button {
cursor: pointer;
Expand Down
15 changes: 15 additions & 0 deletions ext/css/visibility-modifiers.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
:root:not([data-debug=true]) .debug-only {
display: none;
}
:root:not([data-advanced=true]) .advanced-only {
display: none;
}
:root:not([data-advanced=false]) .basic-only {
display: none;
}
:root:not([data-language=ja]):not([data-language=zh]):not([data-language=yue]) .jpzhyue-only {
display: none;
}
:root:is([data-language=ja], [data-language=zh], [data-language=yue], [data-language=ko]) .not-jpzhyueko {
display: none;
}
5 changes: 4 additions & 1 deletion ext/js/language/text-scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {clone} from '../core/utilities.js';
import {anyNodeMatchesSelector, everyNodeMatchesSelector, getActiveModifiers, getActiveModifiersAndButtons, isPointInSelection} from '../dom/document-util.js';
import {TextSourceElement} from '../dom/text-source-element.js';

const SCAN_RESOLUTION_EXCLUDED_LANGUAGES = new Set(['ja', 'zh', 'yue', 'ko']);

/**
* @augments EventDispatcher<import('text-scanner').Events>
*/
Expand Down Expand Up @@ -487,7 +489,8 @@ export class TextScanner extends EventDispatcher {
null
);

if (this._scanResolution === 'word' && !disallowExpandStartOffset) {
if (this._scanResolution === 'word' && (!disallowExpandStartOffset ||
(this._language === null || !SCAN_RESOLUTION_EXCLUDED_LANGUAGES.has(this._language)))) {
// Move the start offset to the beginning of the word
textSource.setStartOffset(this._scanLength, this._layoutAwareScan, true);
}
Expand Down
3 changes: 2 additions & 1 deletion ext/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="icon" type="image/png" href="/images/icon128.png" sizes="128x128">
<link rel="stylesheet" type="text/css" href="/css/material.css">
<link rel="stylesheet" type="text/css" href="/css/settings.css">
<link rel="stylesheet" type="text/css" href="/css/visibility-modifiers.css">
<link rel="stylesheet" type="text/css" href="/css/display-pronunciation.css">
<script src="/js/pages/settings/settings-main.js" type="module"></script>
</head>
Expand Down Expand Up @@ -380,7 +381,7 @@ <h1>Yomitan Settings</h1>
</p>
</div>
</div>
<div class="settings-item">
<div class="settings-item not-jpzhyueko">
<div class="settings-item-inner settings-item-inner-wrappable">
<div class="settings-item-left">
<div class="settings-item-label">Scan resolution</div>
Expand Down

0 comments on commit 3ad6191

Please sign in to comment.