Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force scan resolution "character" for ja, zh, yue, and ko #1542

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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