add global clipboard monitor that spawns popups
TODO: refactor the search page clipboard monitor and popup clipboard monitor to use a common ClipboardMonitor class
This commit is contained in:
parent
f29abfc511
commit
939ad42dac
@ -79,6 +79,7 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"enable",
|
"enable",
|
||||||
|
"enableClipboardPopups",
|
||||||
"resultOutputMode",
|
"resultOutputMode",
|
||||||
"debugInfo",
|
"debugInfo",
|
||||||
"maxResults",
|
"maxResults",
|
||||||
@ -111,6 +112,10 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
"enableClipboardPopups": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false
|
||||||
|
},
|
||||||
"resultOutputMode": {
|
"resultOutputMode": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["group", "merge", "split"],
|
"enum": ["group", "merge", "split"],
|
||||||
|
@ -34,6 +34,9 @@ class Backend {
|
|||||||
|
|
||||||
this.clipboardPasteTarget = document.querySelector('#clipboard-paste-target');
|
this.clipboardPasteTarget = document.querySelector('#clipboard-paste-target');
|
||||||
this.popupWindow = null;
|
this.popupWindow = null;
|
||||||
|
this.clipboardPopupTimerId = null;
|
||||||
|
this.clipboardInterval = 250;
|
||||||
|
this.clipboardPreviousText = null;
|
||||||
|
|
||||||
this.apiForwarder = new BackendApiForwarder();
|
this.apiForwarder = new BackendApiForwarder();
|
||||||
}
|
}
|
||||||
@ -122,6 +125,20 @@ class Backend {
|
|||||||
} else {
|
} else {
|
||||||
this.mecab.stopListener();
|
this.mecab.stopListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.clearInterval(this.clipboardPopupTimerId);
|
||||||
|
if (options.general.enableClipboardPopups) {
|
||||||
|
this.clipboardPopupTimerId = setInterval(() => {
|
||||||
|
this._onApiClipboardGet()
|
||||||
|
.then((result) => {
|
||||||
|
if (this.clipboardPreviousText === result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._onCommandSearch({mode: 'popup', query: result});
|
||||||
|
this.clipboardPreviousText = result;
|
||||||
|
});
|
||||||
|
}, this.clipboardInterval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOptionsSchema() {
|
async getOptionsSchema() {
|
||||||
|
@ -266,6 +266,7 @@ function profileOptionsCreateDefaults() {
|
|||||||
return {
|
return {
|
||||||
general: {
|
general: {
|
||||||
enable: true,
|
enable: true,
|
||||||
|
enableClipboardPopups: false,
|
||||||
resultOutputMode: 'group',
|
resultOutputMode: 'group',
|
||||||
debugInfo: false,
|
debugInfo: false,
|
||||||
maxResults: 32,
|
maxResults: 32,
|
||||||
|
@ -28,6 +28,7 @@ function getOptionsFullMutable() {
|
|||||||
|
|
||||||
async function formRead(options) {
|
async function formRead(options) {
|
||||||
options.general.enable = $('#enable').prop('checked');
|
options.general.enable = $('#enable').prop('checked');
|
||||||
|
options.general.enableClipboardPopups = $('#enable-clipboard-popups').prop('checked');
|
||||||
options.general.showGuide = $('#show-usage-guide').prop('checked');
|
options.general.showGuide = $('#show-usage-guide').prop('checked');
|
||||||
options.general.compactTags = $('#compact-tags').prop('checked');
|
options.general.compactTags = $('#compact-tags').prop('checked');
|
||||||
options.general.compactGlossaries = $('#compact-glossaries').prop('checked');
|
options.general.compactGlossaries = $('#compact-glossaries').prop('checked');
|
||||||
|
@ -134,6 +134,10 @@
|
|||||||
<label><input type="checkbox" id="enable"> Enable content scanning</label>
|
<label><input type="checkbox" id="enable"> Enable content scanning</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="checkbox">
|
||||||
|
<label><input type="checkbox" id="enable-clipboard-popups"> Enable native popups when copying Japanese text</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label><input type="checkbox" id="show-usage-guide"> Show usage guide on startup</label>
|
<label><input type="checkbox" id="show-usage-guide"> Show usage guide on startup</label>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user