From 3498390974be49da9d3e3e3dbc0daa624d4984e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Thu, 21 Oct 2021 14:12:15 +0800 Subject: [PATCH] at --- src/modules/tpm/challengesnew/tpm-md-editor.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/tpm/challengesnew/tpm-md-editor.js b/src/modules/tpm/challengesnew/tpm-md-editor.js index 5579f33b..2aaa879e 100644 --- a/src/modules/tpm/challengesnew/tpm-md-editor.js +++ b/src/modules/tpm/challengesnew/tpm-md-editor.js @@ -117,6 +117,9 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla const ch = cursor.ch;//列 //替换最后的内容 cm.replaceRange(username+" ",{line,ch},{line,ch}); + //鼠标聚焦到此行的最后 + editorInstance.focus(); + editorInstance.setCursor({line,ch:ch+username.length+1}); //将此user的login存储到atWhoLoginList集合中 const list = new Set(atWhoLoginList.current); users.map((item)=>{ @@ -148,6 +151,15 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla document.addEventListener('click',()=>{setAtWhoVisible(false)}); }) + useEffect(()=>{ + //当atWhoVisible为true的时候,失焦,监听上下和enter键 + if(atWhoVisible && editorInstance && editorInstance.cm){ + console.log('弹框啦'); + //焦点转移到非monaco-editer编辑器上 + editorInstance.cm.addEventListener('blur',()=>{}) + } + },[atWhoVisible]) + useEffect(() => { if (editorInstance) { return @@ -352,7 +364,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla }) } } - }); ro = onLayout() return () => { @@ -368,7 +379,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla useEffect(() => { if (editorInstance && initValue !== undefined) { - const val = editorInstance.getValue(); if (initValue !== null && initValue !== editorInstance.getValue()) { editorInstance.setValue(initValue.toString()) } @@ -419,7 +429,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
{atWhoVisible && atWhoList} - {/* {atWhoList} */} {showResizeBar ? : null}