aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2017-12-14 15:58:46 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2017-12-14 15:58:46 +0100
commit413bf160f1922eb56a3ea84eb1e13b04f2628662 (patch)
treecfe77ec858dd97d5d1f85ebecf90e7a38b90c68a /src/helpers
parentremove unecessary console logs (diff)
downloadferdium-app-413bf160f1922eb56a3ea84eb1e13b04f2628662.tar.gz
ferdium-app-413bf160f1922eb56a3ea84eb1e13b04f2628662.tar.zst
ferdium-app-413bf160f1922eb56a3ea84eb1e13b04f2628662.zip
Remove IME handlers
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/webview-ime-focus-helpers.js38
1 files changed, 0 insertions, 38 deletions
diff --git a/src/helpers/webview-ime-focus-helpers.js b/src/helpers/webview-ime-focus-helpers.js
deleted file mode 100644
index 2593a5f26..000000000
--- a/src/helpers/webview-ime-focus-helpers.js
+++ /dev/null
@@ -1,38 +0,0 @@
1module.exports.releaseDocumentFocus = () => {
2 const element = document.createElement('span');
3 document.body.appendChild(element);
4
5 const range = document.createRange();
6 range.setStart(element, 0);
7
8 const selection = window.getSelection();
9 selection.removeAllRanges();
10 selection.addRange(range);
11 selection.removeAllRanges();
12
13 document.body.removeChild(element);
14};
15
16module.exports.claimDocumentFocus = () => {
17 const { activeElement } = document;
18 const selection = window.getSelection();
19
20 let selectionStart;
21 let selectionEnd;
22 let range;
23
24 if (activeElement) ({ selectionStart, selectionEnd } = activeElement);
25 if (selection.rangeCount) range = selection.getRangeAt(0);
26
27 const restoreOriginalSelection = () => {
28 if (selectionStart >= 0 && selectionEnd >= 0) {
29 activeElement.selectionStart = selectionStart;
30 activeElement.selectionEnd = selectionEnd;
31 } else if (range) {
32 selection.addRange(range);
33 }
34 };
35
36 exports.releaseDocumentFocus();
37 window.requestAnimationFrame(restoreOriginalSelection);
38};