Merge pull request #642 from SuanmoSuanyangTechnology/fix/v0.2.8_zy
fix(web): editor bug
This commit is contained in:
@@ -18,8 +18,8 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
|||||||
const isUserInputRef = useRef(false);
|
const isUserInputRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 监听编辑器变化,标记是否为用户输入
|
const removeListener = editor.registerUpdateListener(({ editorState, tags }) => {
|
||||||
const removeListener = editor.registerUpdateListener(({ editorState }) => {
|
if (tags.has('programmatic')) return;
|
||||||
editorState.read(() => {
|
editorState.read(() => {
|
||||||
const root = $getRoot();
|
const root = $getRoot();
|
||||||
const textContent = root.getTextContent();
|
const textContent = root.getTextContent();
|
||||||
@@ -107,7 +107,7 @@ const InitialValuePlugin: React.FC<InitialValuePluginProps> = ({ value, options
|
|||||||
});
|
});
|
||||||
root.append(paragraph);
|
root.append(paragraph);
|
||||||
}
|
}
|
||||||
}, { discrete: true });
|
}, { discrete: true, tag: 'programmatic' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user