at谁列表

This commit is contained in:
谢思 2021-10-15 11:36:51 +08:00
parent 4a6012bfa9
commit 4add266047
2 changed files with 17 additions and 29 deletions

View File

@ -15,7 +15,7 @@
background: #FFFFFF;
box-shadow: 0px 4px 8px 2px rgba(212, 212, 212, 0.5);
border-radius: 4px;
top: 100px;
top: 60px;
left: 100px;
overflow-y: scroll;
cursor: pointer;

View File

@ -79,7 +79,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
const resizeBarEl = useRef();
const [editorInstance, setEditorInstance] = useState();
const [atWhoVisible, setAtWhoVisible] = useState(false);
// const [atWho, setAtWho] = useState(undefined);
const containerId = `mdEditor_${mdID}`;
const editorBodyId = `mdEditors_${mdID}`;
const tipId = `e_tips_mdEditor_${mdID}`;
@ -109,19 +108,17 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
function selectAtWho(username){
setAtWhoVisible(false);
const a = editorInstance.cm;
const b = editorInstance.cm.on;
console.log('cm.getValue()', editorInstance.cm)
console.log('onchange', editorInstance.cm.doc.getCursor());
editorInstance.setValue(initValue.toString()+username);
// editorInstance.cm.on('change',(cm)=>{
// onchange(cm.getValue()+username);
// })
// setAtWho(username);
// console.log('editorInstance1',editorInstance);
// console.log('editorInstance2',editorInstance);
const cm = editorInstance.cm;
//获取鼠标所在行的行数和ch
const cursor = cm.doc.getCursor();
const line = cursor.line;//行
const ch = cursor.ch;//列
//替换最后的内容
cm.replaceRange(username+" ",{line,ch},{line,ch});
}
console.log('window.event',window.event);
const atWhoList = (
<div className="at_who_list">
{users && users.map((item,key)=>{
@ -236,31 +233,22 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
if (!noStorage) {
tid = md_elocalStorage(editorInstance, `MDEditor__${containerId}`, containerId)
}
editorInstance.cm.on('change', (cm) => {
if(forMember){
//当光标或选中内容时触发绑定@事件
editorInstance.cm.on("cursorActivity", () => {
if (forMember) {
document.onkeydown = (e) => {
console.log('onkeydown', e)
if (e.key === "@") {
// 输入@键后在对应的位置显示可选的项目成员
// const endOffset = window.getSelection();
setAtWhoVisible(true);
// const addValue = atWho? cm.getValue()+atWho:cm.getValue();
// onChange(addValue);
}else{
} else {
setAtWhoVisible(false);
}
};
}
console.log('change---')
});
editorInstance.cm.on("change", (cm) => {
onChange && onChange(cm.getValue());
// atWho && onChange(addValue+atWho) && setAtWho(undefined);
// if(atWho){
// onChange(cm.getValue()+atWho);
// setAtWho(undefined);
// }else{
// onChange(cm.getValue());
// }
})
});
if (onChange) {
}
ro = onLayout()