我正在进行协作编辑,并将 html-text-collab-ext 用于 html 文本区域。下面是 updateContent.tsx 文件
function updateCursorText(range: any[], uid: any, text: string) {
if (range) {
doc.submitPresence({
path: [text],
type: 'text0',
subpresence: {
user: uid,
c: 0,
s: [range]
}
});
}
}
useEffect(() => {
if (subjectRef.current) {
const subjectElem = subjectRef.current.getInputElement();
doc.subscribe(() => {
subjectElem.addEventListener('focus', () => {
console.log("focus")
updateCursorText(
[subjectElem.selectionStart, subjectElem.selectionStart],
uid,
'subject'
);
});
const textEditor = new HtmlTextCollabExt.CollaborativeTextEditor({
control: subjectElem,
onSelectionChanged: (selection: { anchor: any; target: any; }) =>
updateCursorText([selection.anchor, selection.target], uid, 'subject')
});
const selectionManager = textEditor.selectionManager();
});
我收到的错误是未捕获的类型错误:无法读取未定义的属性“CollaborativeTextEditor”