fix: text selection moving when typing in between (#384)

This commit is contained in:
Dakshesh Jain 2023-03-07 16:09:17 +05:30 committed by GitHub
parent 09eab9e6bf
commit 388d5b054a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,12 +153,11 @@ const RemirrorRichTextEditor: FC<IRemirrorRichTextEditor> = (props) => {
const updateState = useCallback( const updateState = useCallback(
(value: any) => { (value: any) => {
// Clear out old state when setting data from outside
// This prevents e.g. the user from using CTRL-Z to go back to the old state
manager.view.updateState( manager.view.updateState(
manager.createState({ manager.createState({
content: content:
!value || (typeof value === "object" && Object.keys(value).length === 0) ? "" : value, !value || (typeof value === "object" && Object.keys(value).length === 0) ? "" : value,
selection: value === "" ? "start" : manager.view.state.selection,
}) })
); );
}, },