mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-11-30 03:08:31 +08:00
fix: default value for rich text
This commit is contained in:
parent
a6b6f840e3
commit
e109e2a37e
@ -25,12 +25,12 @@ const DEFAULT_VALUE = [
|
||||
];
|
||||
|
||||
export const RichText = (props: any) => {
|
||||
const { value = DEFAULT_VALUE, placeholder = '', className, readOnly, autop = true, ellipsis, onChange } = props;
|
||||
const { value, placeholder = '', className, readOnly, autop = true, ellipsis, onChange } = props;
|
||||
const renderElement = useCallback((props) => <Element {...props} />, []);
|
||||
const renderLeaf = useCallback((props) => <Leaf {...props} />, []);
|
||||
const editor = useMemo(() => withHistory(withReact(createEditor() as ReactEditor)), []);
|
||||
const slateValue = useMemo(() => {
|
||||
editor.children = JSON.parse(JSON.stringify(value || []));
|
||||
editor.children = JSON.parse(JSON.stringify(value || DEFAULT_VALUE));
|
||||
Editor.normalize(editor, { force: true });
|
||||
return editor.children;
|
||||
}, [editor, value]);
|
||||
|
Loading…
Reference in New Issue
Block a user