diff options
author | flo-mic <florianmichel@hotmail.de> | 2021-02-23 20:06:01 +0300 |
---|---|---|
committer | flo-mic <florianmichel@hotmail.de> | 2021-02-23 20:06:01 +0300 |
commit | 94bf2d2c92b4bf73243ca33e2da21e264debe9d6 (patch) | |
tree | 2c5099ab59be465d8f0018adb01fd0628fd748ae /src | |
parent | 9ecfb783ba9f18cc92900e074e988fa66a279c03 (diff) |
change to execCommand instead of api
Diffstat (limited to 'src')
-rw-r--r-- | src/js/Manager/ClipboardManager.js | 10 | ||||
-rw-r--r-- | src/vue/Components/Options/Settings.vue | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/js/Manager/ClipboardManager.js b/src/js/Manager/ClipboardManager.js index 8756f62..6fb8009 100644 --- a/src/js/Manager/ClipboardManager.js +++ b/src/js/Manager/ClipboardManager.js @@ -6,6 +6,7 @@ class ClipboardManager { /** * + * @return {Boolean} */ async requestReadPermission() { try { @@ -19,6 +20,7 @@ class ClipboardManager { /** * + * @return {Boolean} */ async getReadPermissions() { try { @@ -41,7 +43,8 @@ class ClipboardManager { } if(permissions === true || await this.getReadPermissions()) { var element = this._createDOMElement(); - var result = await navigator.clipboard.readText(); + await document.execCommand('paste'); + var result = element.value; this._removeDOMElement(element); return result; } @@ -72,7 +75,7 @@ class ClipboardManager { writeText(value) { try { var element = this._createDOMElement(value); - navigator.clipboard.writeText(element.value); + document.execCommand('copy', false, element.value); this._removeDOMElement(element); } catch (e) { ErrorManager.logError(e); @@ -88,7 +91,7 @@ class ClipboardManager { if(await SettingsService.getValue('clipboard.clear.passwords') == true) { setTimeout(async () => { var current = await this.readText(); - if(current === undefined || current === value) { + if(current === undefined || current === "" || current === value) { this.writeText(" "); } }, Number(await SettingsService.getValue('clipboard.clear.delay')) * 1000) @@ -103,7 +106,6 @@ class ClipboardManager { var element = document.createElement("INPUT"); element.setAttribute("type", type); element.setAttribute("value", value); - element.readOnly = true; document.body.appendChild(element); element.select(); return element; diff --git a/src/vue/Components/Options/Settings.vue b/src/vue/Components/Options/Settings.vue index 2ab7114..f965c80 100644 --- a/src/vue/Components/Options/Settings.vue +++ b/src/vue/Components/Options/Settings.vue @@ -59,6 +59,8 @@ import SliderField from "@vue/Components/Form/SliderField"; import SelectField from "@vue/Components/Form/SelectField"; import HelpText from "@vue/Components/Options/Setting/HelpText"; + import ClipboardManager from '@js/Manager/ClipboardManager'; + export default { components: {HelpText, SliderField, SelectField, Translate}, |