From 55a6f93fe3a9f0fc657b9b23afa4e750d0083cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Mon, 8 Nov 2021 16:04:19 +0800 Subject: [PATCH] atwho --- src/modules/tpm/challengesnew/tpm-md-editor.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/modules/tpm/challengesnew/tpm-md-editor.js b/src/modules/tpm/challengesnew/tpm-md-editor.js index ae9f10e2..385005b6 100644 --- a/src/modules/tpm/challengesnew/tpm-md-editor.js +++ b/src/modules/tpm/challengesnew/tpm-md-editor.js @@ -126,7 +126,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla const line = cursor.line;//行 const ch = cursor.ch;//列 //替换最后的内容 - // cm.getLine(line).endsWith("@") ? cm.replaceRange(username+" ",{line,ch},{line,ch}) : cm.replaceRange("@"+username+" ",{line,ch},{line,ch}) cm.replaceRange(username+" ",{line,ch},{line,ch}); //鼠标聚焦 cm.focus(); @@ -148,10 +147,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla //markdown编辑器中输入的键盘监听事件 function mdKeyDown(e){ - const cm = editorInstance.cm; - //获取鼠标所在行的行数和ch - const line = cm.doc.getCursor().line;//行 - atWhoVisible && console.log('cmaa',cm.getLine(line)); console.log("markdown编辑器--------键盘监听事件"); // document.onkeydown = e=>{ if (e.shiftKey && e.key === "@") { @@ -308,11 +303,12 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla useEffect(()=>{ //当atWhoVisible为true的时候,失焦,监听上下和enter键 + // atWhoVisible && editorInstance.cm. if(atWhoVisible){ const cm = editorInstance.cm; //获取鼠标所在行的行数和ch const line = cm.doc.getCursor().line;//行 - // console.log('cmaa',cm.getLine(line)); + console.log('useEffect',cm.getLine(line)); // document.activeElement.id !== "blur_atWho" && document.getElementById("blur_atWho").focus(); // const atWhoDivs = document.getElementsByClassName("at_who"); // let index = 0; @@ -487,10 +483,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla }) } } - // const cm = editorInstance.cm; - //获取鼠标所在行的行数和ch - const line = cmEl.doc.getCursor().line;//行 - atWhoVisible && console.log('cmaa',cmEl.getLine(line)); }); ro = onLayout() return () => {