From 6e3c6bca4d523d150a915f2e6524d8058b1a17cd Mon Sep 17 00:00:00 2001 From: Autumn60 Date: Mon, 1 Jul 2024 16:01:37 +0900 Subject: [PATCH] fix #5 issue Signed-off-by: Autumn60 --- conflu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conflu.js b/conflu.js index 5008da4..95a0435 100644 --- a/conflu.js +++ b/conflu.js @@ -1,4 +1,4 @@ -let previousCursorPosition = 0; +let previousCursorPosition = -1; const keydownHandler = (event) => { const activeField = document.activeElement; // role="textbox"の場合は、カーソル位置を取得 @@ -7,7 +7,7 @@ const keydownHandler = (event) => { const cursorPosition = selection.anchorOffset; // 入力カーソル位置が 1 以外から 1 に変わった場合 - if ((previousCursorPosition !== 1 && previousCursorPosition !== 0) && cursorPosition === 1 && (event.key === "Process" || event.key == "Shift")) { + if (previousCursorPosition !== cursorPosition && cursorPosition === 1 && (event.key === "Process" || event.key == "Shift")) { activeField.focus(); document.execCommand('insertText', false, ' '); }