Update clipboard options organization (#1318)
* Update options organization * Update general.enableClipboardPopups to clipboard.enableBackgroundMonitor * Update general.enableClipboardMonitor to clipboard.enableSearchPageMonitor * Update general.maximumClipboardSearchLength to clipboard.maximumSearchLength * Update general.autoSearchClipboardContent to clipboard.autoSearchContent
This commit is contained in:
parent
d11cd7b28f
commit
8d292363d4
@ -71,14 +71,14 @@
|
||||
"parsing",
|
||||
"anki",
|
||||
"sentenceParsing",
|
||||
"inputs"
|
||||
"inputs",
|
||||
"clipboard"
|
||||
],
|
||||
"properties": {
|
||||
"general": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"enable",
|
||||
"enableClipboardPopups",
|
||||
"resultOutputMode",
|
||||
"debugInfo",
|
||||
"maxResults",
|
||||
@ -104,7 +104,6 @@
|
||||
"customPopupCss",
|
||||
"customPopupOuterCss",
|
||||
"enableWanakana",
|
||||
"enableClipboardMonitor",
|
||||
"showPitchAccentDownstepNotation",
|
||||
"showPitchAccentPositionNotation",
|
||||
"showPitchAccentGraph",
|
||||
@ -112,21 +111,15 @@
|
||||
"useSecurePopupFrameUrl",
|
||||
"usePopupShadowDom",
|
||||
"usePopupWindow",
|
||||
"maximumClipboardSearchLength",
|
||||
"popupCurrentIndicatorMode",
|
||||
"popupActionBarVisibility",
|
||||
"popupActionBarLocation",
|
||||
"autoSearchClipboardContent"
|
||||
"popupActionBarLocation"
|
||||
],
|
||||
"properties": {
|
||||
"enable": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"enableClipboardPopups": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"resultOutputMode": {
|
||||
"type": "string",
|
||||
"enum": ["group", "merge", "split"],
|
||||
@ -236,10 +229,6 @@
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"enableClipboardMonitor": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"showPitchAccentDownstepNotation": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
@ -268,11 +257,6 @@
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"maximumClipboardSearchLength": {
|
||||
"type": "integer",
|
||||
"default": 1000,
|
||||
"minimum": 0
|
||||
},
|
||||
"popupCurrentIndicatorMode": {
|
||||
"type": "string",
|
||||
"enum": ["none", "asterisk", "triangle", "bar-left", "bar-right", "dot-left", "dot-right"],
|
||||
@ -287,10 +271,6 @@
|
||||
"type": "string",
|
||||
"enum": ["left", "right", "top", "bottom"],
|
||||
"default": "top"
|
||||
},
|
||||
"autoSearchClipboardContent": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1053,6 +1033,34 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"clipboard": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"enableBackgroundMonitor",
|
||||
"enableSearchPageMonitor",
|
||||
"autoSearchContent",
|
||||
"maximumSearchLength"
|
||||
],
|
||||
"properties": {
|
||||
"enableBackgroundMonitor": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"enableSearchPageMonitor": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"autoSearchContent": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"maximumSearchLength": {
|
||||
"type": "integer",
|
||||
"default": 1000,
|
||||
"minimum": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,9 +233,9 @@ class Backend {
|
||||
// Event handlers
|
||||
|
||||
async _onClipboardTextChange({text}) {
|
||||
const {general: {maximumClipboardSearchLength}} = this._getProfileOptions({current: true});
|
||||
if (text.length > maximumClipboardSearchLength) {
|
||||
text = text.substring(0, maximumClipboardSearchLength);
|
||||
const {clipboard: {maximumSearchLength}} = this._getProfileOptions({current: true});
|
||||
if (text.length > maximumSearchLength) {
|
||||
text = text.substring(0, maximumSearchLength);
|
||||
}
|
||||
try {
|
||||
const {tab, created} = await this._getOrCreateSearchPopup();
|
||||
@ -912,7 +912,7 @@ class Backend {
|
||||
this._mecab.stopListener();
|
||||
}
|
||||
|
||||
if (options.general.enableClipboardPopups) {
|
||||
if (options.clipboard.enableBackgroundMonitor) {
|
||||
this._clipboardMonitor.start();
|
||||
} else {
|
||||
this._clipboardMonitor.stop();
|
||||
|
@ -669,8 +669,10 @@ class OptionsUtil {
|
||||
// Updated handlebars templates to include "stroke-count" definition.
|
||||
// Updated global.useSettingsV2 to be true (opt-out).
|
||||
// Added audio.customSourceType.
|
||||
// Added general.autoSearchClipboardContent.
|
||||
// Forced general.enableClipboardMonitor to false due to a bug which caused its value to not be read.
|
||||
// Moved general.enableClipboardPopups => clipboard.enableBackgroundMonitor.
|
||||
// Moved general.enableClipboardMonitor => clipboard.enableSearchPageMonitor. Forced value to false due to a bug which caused its value to not be read.
|
||||
// Moved general.maximumClipboardSearchLength => clipboard.maximumSearchLength.
|
||||
// Added clipboard.autoSearchContent.
|
||||
await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v8.handlebars');
|
||||
options.global.useSettingsV2 = true;
|
||||
for (const profile of options.profiles) {
|
||||
@ -730,8 +732,15 @@ class OptionsUtil {
|
||||
windowState: 'normal'
|
||||
};
|
||||
profile.options.audio.customSourceType = 'audio';
|
||||
profile.options.general.autoSearchClipboardContent = true;
|
||||
profile.options.general.enableClipboardMonitor = false;
|
||||
profile.options.clipboard = {
|
||||
enableBackgroundMonitor: profile.options.general.enableClipboardPopups,
|
||||
enableSearchPageMonitor: false,
|
||||
autoSearchContent: true,
|
||||
maximumSearchLength: profile.options.general.maximumClipboardSearchLength
|
||||
};
|
||||
delete profile.options.general.enableClipboardPopups;
|
||||
delete profile.options.general.enableClipboardMonitor;
|
||||
delete profile.options.general.maximumClipboardSearchLength;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class DisplaySearch extends Display {
|
||||
}
|
||||
|
||||
_onDisplayOptionsUpdated({options}) {
|
||||
this._clipboardMonitorEnabled = options.general.enableClipboardMonitor;
|
||||
this._clipboardMonitorEnabled = options.clipboard.enableSearchPageMonitor;
|
||||
this._updateClipboardMonitorEnabled();
|
||||
}
|
||||
|
||||
@ -182,13 +182,13 @@ class DisplaySearch extends Display {
|
||||
}
|
||||
|
||||
_onExternalSearchUpdate({text, animate=true}) {
|
||||
const {general: {maximumClipboardSearchLength, autoSearchClipboardContent}} = this.getOptions();
|
||||
if (text.length > maximumClipboardSearchLength) {
|
||||
text = text.substring(0, maximumClipboardSearchLength);
|
||||
const {clipboard: {autoSearchContent, maximumSearchLength}} = this.getOptions();
|
||||
if (text.length > maximumSearchLength) {
|
||||
text = text.substring(0, maximumSearchLength);
|
||||
}
|
||||
this._queryInput.value = text;
|
||||
this._updateSearchHeight(true);
|
||||
this._search(animate, false, autoSearchClipboardContent);
|
||||
this._search(animate, false, autoSearchContent);
|
||||
}
|
||||
|
||||
_onWanakanaEnableChange(e) {
|
||||
@ -303,7 +303,7 @@ class DisplaySearch extends Display {
|
||||
|
||||
await api.modifySettings([{
|
||||
action: 'set',
|
||||
path: 'general.enableClipboardMonitor',
|
||||
path: 'clipboard.enableSearchPageMonitor',
|
||||
value,
|
||||
scope: 'profile',
|
||||
optionsContext: this.getOptionsContext()
|
||||
|
@ -18,11 +18,11 @@
|
||||
class ClipboardPopupsController {
|
||||
constructor(settingsController) {
|
||||
this._settingsController = settingsController;
|
||||
this._checkbox = document.querySelector('#enable-clipboard-popups');
|
||||
this._checkbox = document.querySelector('#clipboard-enable-background-monitor');
|
||||
}
|
||||
|
||||
async prepare() {
|
||||
this._checkbox.addEventListener('change', this._onEnableClipboardPopupsChanged.bind(this), false);
|
||||
this._checkbox.addEventListener('change', this._onEnableBackgroundMonitorChanged.bind(this), false);
|
||||
this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this));
|
||||
|
||||
const options = await this._settingsController.getOptions();
|
||||
@ -32,10 +32,10 @@ class ClipboardPopupsController {
|
||||
// Private
|
||||
|
||||
_onOptionsChanged({options}) {
|
||||
this._checkbox.checked = options.general.enableClipboardPopups;
|
||||
this._checkbox.checked = options.clipboard.enableBackgroundMonitor;
|
||||
}
|
||||
|
||||
async _onEnableClipboardPopupsChanged(e) {
|
||||
async _onEnableBackgroundMonitorChanged(e) {
|
||||
const checkbox = e.currentTarget;
|
||||
let value = checkbox.checked;
|
||||
|
||||
@ -46,6 +46,6 @@ class ClipboardPopupsController {
|
||||
checkbox.checked = value;
|
||||
}
|
||||
|
||||
await this._settingsController.setProfileSetting('general.enableClipboardPopups', value);
|
||||
await this._settingsController.setProfileSetting('clipboard.enableBackgroundMonitor', value);
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@
|
||||
</div>
|
||||
|
||||
<div class="checkbox options-advanced ignore-form-changes" data-hide-for-browser="firefox-mobile">
|
||||
<label><input type="checkbox" id="enable-clipboard-popups"> Enable native popups when copying Japanese text</label>
|
||||
<label><input type="checkbox" id="clipboard-enable-background-monitor"> Enable native popups when copying Japanese text</label>
|
||||
</div>
|
||||
|
||||
<div class="checkbox options-advanced">
|
||||
|
@ -960,7 +960,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-item-right">
|
||||
<label class="toggle"><input type="checkbox" id="enable-clipboard-popups"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
|
||||
<label class="toggle"><input type="checkbox" id="clipboard-enable-background-monitor"><span class="toggle-body"><span class="toggle-track"></span><span class="toggle-knob"></span></span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-item-children more" hidden>
|
||||
@ -988,7 +988,7 @@
|
||||
<div class="settings-item-description">Limit the number of text characters used when searching clipboard content.</div>
|
||||
</div>
|
||||
<div class="settings-item-right">
|
||||
<input type="number" min="0" step="1" data-setting="general.maximumClipboardSearchLength">
|
||||
<input type="number" min="0" step="1" data-setting="clipboard.maximumSearchLength">
|
||||
</div>
|
||||
</div></div>
|
||||
<div class="settings-item"><div class="settings-item-inner settings-item-inner-wrappable">
|
||||
@ -997,7 +997,7 @@
|
||||
<div class="settings-item-description">Change how the search page reacts to new text in the clipboard.</div>
|
||||
</div>
|
||||
<div class="settings-item-right">
|
||||
<select data-setting="general.autoSearchClipboardContent"
|
||||
<select data-setting="clipboard.autoSearchContent"
|
||||
data-transform='[
|
||||
{
|
||||
"step": "pre",
|
||||
|
@ -259,7 +259,6 @@ function createProfileOptionsUpdatedTestData1() {
|
||||
return {
|
||||
general: {
|
||||
enable: true,
|
||||
enableClipboardPopups: false,
|
||||
resultOutputMode: 'group',
|
||||
debugInfo: false,
|
||||
maxResults: 32,
|
||||
@ -285,7 +284,6 @@ function createProfileOptionsUpdatedTestData1() {
|
||||
customPopupCss: '',
|
||||
customPopupOuterCss: '',
|
||||
enableWanakana: true,
|
||||
enableClipboardMonitor: false,
|
||||
showPitchAccentDownstepNotation: true,
|
||||
showPitchAccentPositionNotation: true,
|
||||
showPitchAccentGraph: false,
|
||||
@ -293,11 +291,9 @@ function createProfileOptionsUpdatedTestData1() {
|
||||
useSecurePopupFrameUrl: true,
|
||||
usePopupShadowDom: true,
|
||||
usePopupWindow: false,
|
||||
maximumClipboardSearchLength: 1000,
|
||||
popupCurrentIndicatorMode: 'triangle',
|
||||
popupActionBarVisibility: 'auto',
|
||||
popupActionBarLocation: 'top',
|
||||
autoSearchClipboardContent: true
|
||||
popupActionBarLocation: 'top'
|
||||
},
|
||||
audio: {
|
||||
enabled: true,
|
||||
@ -469,6 +465,12 @@ function createProfileOptionsUpdatedTestData1() {
|
||||
useTop: false,
|
||||
windowType: 'popup',
|
||||
windowState: 'normal'
|
||||
},
|
||||
clipboard: {
|
||||
enableBackgroundMonitor: false,
|
||||
enableSearchPageMonitor: false,
|
||||
autoSearchContent: true,
|
||||
maximumSearchLength: 1000
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user