This commit is contained in:
谢思 2021-10-21 14:12:15 +08:00
parent 4f3e385f78
commit 3498390974
1 changed files with 12 additions and 3 deletions

View File

@ -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
<textarea style={{ display: 'none' }} id={editorBodyId} name="content"></textarea>
<div className="CodeMirror cm-s-defualt"></div>
{atWhoVisible && atWhoList}
{/* {atWhoList} */}
</div>
</div>
{showResizeBar ? <a ref={resizeBarEl} className='editor-resize'></a> : null}