From 45371fb4d5495d1ae4add94daeb9d73c988c8683 Mon Sep 17 00:00:00 2001 From: "SENOO, Ken" Date: Fri, 18 Nov 2022 16:35:53 +0900 Subject: [PATCH] Remove extra space in CJK post With CJK language and IME turned on, typing text in the post field and pressing enter caused an extra space to be inserted. So I deleted the code. --- js/qvitter.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/js/qvitter.js b/js/qvitter.js index e1b7d9c..1136915 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -3385,13 +3385,7 @@ $('body').on('keyup', 'div.queet-box-syntax', function(e) { var cursorPosArray = getSelectionInElement(queetBox[0]); var cursorPos = cursorPosArray[0]; - // add space before linebreaks (to separate mentions in beginning of new lines when .text():ing later) - if(e.keyCode == '13') { - e.preventDefault(); - var range = createRangeFromCharacterIndices(queetBox[0], cursorPos, cursorPos); - range.insertNode(document.createTextNode(" \n")); - } - else if(e.keyCode != '40' && e.keyCode != '38' && e.keyCode != '13' && e.keyCode != '9') { + if(e.keyCode != '40' && e.keyCode != '38' && e.keyCode != '13' && e.keyCode != '9') { var contents = queetBox.text().substring(0,cursorPos); var mentionPos = contents.lastIndexOf('@'); var check_contents = contents.substring(mentionPos - 1, cursorPos); @@ -3459,13 +3453,7 @@ $('body').on('keyup', 'div.queet-box-syntax', function(e) { var cursorPosArray = getSelectionInElement(queetBox[0]); var cursorPos = cursorPosArray[0]; - // add space before linebreaks (to separate mentions in beginning of new lines when .text():ing later) - if(e.keyCode == '13') { - e.preventDefault(); - var range = createRangeFromCharacterIndices(queetBox[0], cursorPos, cursorPos); - range.insertNode(document.createTextNode(" \n")); - } - else if(e.keyCode != '40' && e.keyCode != '38' && e.keyCode != '13' && e.keyCode != '9') { + if(e.keyCode != '40' && e.keyCode != '38' && e.keyCode != '13' && e.keyCode != '9') { var contents = queetBox.text().substring(0,cursorPos); var mentionPos = contents.lastIndexOf('!'); var check_contents = contents.substring(mentionPos - 1, cursorPos);