mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 23:00:20 +08:00
2ff5feb1bd
* fix: theme editor edit error * chore: less bundle * fix: themeEditor * fix: lint * fix: themeEditor * fix: last fix * chore: update --------- Co-authored-by: 洋 <hetongyang@bytedance.com> Co-authored-by: lijianan <574980606@qq.com>
27 lines
727 B
TypeScript
27 lines
727 B
TypeScript
import React, { useEffect, useRef } from 'react';
|
|
import type { JSONEditorPropsOptional } from 'vanilla-jsoneditor';
|
|
import { JSONEditor, Mode } from 'vanilla-jsoneditor';
|
|
|
|
const Editor: React.FC<JSONEditorPropsOptional> = (props) => {
|
|
const editorRef = useRef<JSONEditor>(null);
|
|
const container = useRef<HTMLDivElement>(null);
|
|
|
|
useEffect(() => {
|
|
editorRef.current = new JSONEditor({
|
|
target: container.current,
|
|
props: { mode: Mode.text },
|
|
});
|
|
return () => {
|
|
editorRef.current?.destroy();
|
|
};
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
editorRef.current?.updateProps(props);
|
|
}, [props.content]);
|
|
|
|
return <div ref={container} className="vanilla-jsoneditor-react" />;
|
|
};
|
|
|
|
export default Editor;
|