This commit is contained in:
谢思 2021-11-08 16:04:19 +08:00
parent ac4488a907
commit 55a6f93fe3
1 changed files with 2 additions and 10 deletions

View File

@ -126,7 +126,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
const line = cursor.line;//行 const line = cursor.line;//行
const ch = cursor.ch;//列 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.replaceRange(username+" ",{line,ch},{line,ch});
//鼠标聚焦 //鼠标聚焦
cm.focus(); cm.focus();
@ -148,10 +147,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
//markdown编辑器中输入的键盘监听事件 //markdown编辑器中输入的键盘监听事件
function mdKeyDown(e){ function mdKeyDown(e){
const cm = editorInstance.cm;
//获取鼠标所在行的行数和ch
const line = cm.doc.getCursor().line;//行
atWhoVisible && console.log('cmaa',cm.getLine(line));
console.log("markdown编辑器--------键盘监听事件"); console.log("markdown编辑器--------键盘监听事件");
// document.onkeydown = e=>{ // document.onkeydown = e=>{
if (e.shiftKey && e.key === "@") { if (e.shiftKey && e.key === "@") {
@ -308,11 +303,12 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
useEffect(()=>{ useEffect(()=>{
//当atWhoVisible为true的时候失焦监听上下和enter键 //当atWhoVisible为true的时候失焦监听上下和enter键
// atWhoVisible && editorInstance.cm.
if(atWhoVisible){ if(atWhoVisible){
const cm = editorInstance.cm; const cm = editorInstance.cm;
//获取鼠标所在行的行数和ch //获取鼠标所在行的行数和ch
const line = cm.doc.getCursor().line;//行 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(); // document.activeElement.id !== "blur_atWho" && document.getElementById("blur_atWho").focus();
// const atWhoDivs = document.getElementsByClassName("at_who"); // const atWhoDivs = document.getElementsByClassName("at_who");
// let index = 0; // 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() ro = onLayout()
return () => { return () => {