fix: #2272, rich text within blocks causing crash on reorder
This commit is contained in:
@@ -168,7 +168,8 @@ const RichText: React.FC<Props> = (props) => {
|
|||||||
CreatedEditor = enablePlugins(CreatedEditor, leaves);
|
CreatedEditor = enablePlugins(CreatedEditor, leaves);
|
||||||
|
|
||||||
return CreatedEditor;
|
return CreatedEditor;
|
||||||
}, [elements, leaves]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [elements, leaves, path]);
|
||||||
|
|
||||||
// All slate changes fire the onChange event
|
// All slate changes fire the onChange event
|
||||||
// including selection changes
|
// including selection changes
|
||||||
@@ -225,6 +226,16 @@ const RichText: React.FC<Props> = (props) => {
|
|||||||
};
|
};
|
||||||
}, [loaded, readOnly]);
|
}, [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) {
|
if (!loaded) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ export const blocksFieldSeedData = [
|
|||||||
blockName: 'First block',
|
blockName: 'First block',
|
||||||
blockType: 'text',
|
blockType: 'text',
|
||||||
text: 'first block',
|
text: 'first block',
|
||||||
richText: [],
|
richText: [{
|
||||||
|
children: [{ text: '' }],
|
||||||
|
}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
blockName: 'Second block',
|
blockName: 'Second block',
|
||||||
|
|||||||
Reference in New Issue
Block a user