fix: #2272, rich text within blocks causing crash on reorder

This commit is contained in:
James
2023-03-08 16:07:08 -08:00
parent ef826c88ec
commit 7daddf864d
2 changed files with 15 additions and 2 deletions

View File

@@ -168,7 +168,8 @@ const RichText: React.FC<Props> = (props) => {
CreatedEditor = enablePlugins(CreatedEditor, leaves);
return CreatedEditor;
}, [elements, leaves]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [elements, leaves, path]);
// All slate changes fire the onChange event
// including selection changes
@@ -225,6 +226,16 @@ const RichText: React.FC<Props> = (props) => {
};
}, [loaded, readOnly]);
// useEffect(() => {
// // If there is a change to the initial value, we need to reset Slate history
// // and clear selection because the old selection may no longer be valid
// // as returned JSON may be modified in hooks and have a different shape
// if (editor.selection) {
// console.log('deselecting');
// ReactEditor.deselect(editor);
// }
// }, [path, editor]);
if (!loaded) {
return null;
}

View File

@@ -6,7 +6,9 @@ export const blocksFieldSeedData = [
blockName: 'First block',
blockType: 'text',
text: 'first block',
richText: [],
richText: [{
children: [{ text: '' }],
}],
},
{
blockName: 'Second block',