From 2883e24c8dd4d52845e0a0b439e0809caf661a43 Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Thu, 1 Sep 2022 17:51:13 +0800 Subject: [PATCH 1/2] Add down key check has tribute container --- web_src/js/features/comp/EasyMDE.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web_src/js/features/comp/EasyMDE.js b/web_src/js/features/comp/EasyMDE.js index f1b4b0efc398d..e1283da194239 100644 --- a/web_src/js/features/comp/EasyMDE.js +++ b/web_src/js/features/comp/EasyMDE.js @@ -92,6 +92,12 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) { } cm.execCommand('delCharBefore'); }, + Down: (cm) => { + const tributeContainer = document.querySelector('.tribute-container'); + if (!tributeContainer || tributeContainer.style.display === 'none') { + return cm.execCommand('goLineDown'); + } + }, }); attachTribute(inputField, {mentions: true, emoji: true}); attachEasyMDEToElements(easyMDE); From 64e16f471bfee55569bd25c7d50f3019840101db Mon Sep 17 00:00:00 2001 From: Tyrone Yeh Date: Fri, 2 Sep 2022 13:40:30 +0800 Subject: [PATCH 2/2] Add UP key --- web_src/js/features/comp/EasyMDE.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web_src/js/features/comp/EasyMDE.js b/web_src/js/features/comp/EasyMDE.js index e1283da194239..b1f5961a04b47 100644 --- a/web_src/js/features/comp/EasyMDE.js +++ b/web_src/js/features/comp/EasyMDE.js @@ -92,6 +92,12 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) { } cm.execCommand('delCharBefore'); }, + Up: (cm) => { + const tributeContainer = document.querySelector('.tribute-container'); + if (!tributeContainer || tributeContainer.style.display === 'none') { + return cm.execCommand('goLineUp'); + } + }, Down: (cm) => { const tributeContainer = document.querySelector('.tribute-container'); if (!tributeContainer || tributeContainer.style.display === 'none') {