fo-editor-react
v0.2.8
Published
> TODO: description
Downloads
760
Readme
fo-editor-react
最新文档请移步官方地址
使用方式
有以下两种方式
方法一:组件形式集成
import React from 'react';
import { ReactEditor, ReactEditorProps } from 'fo-editor-react';
export const MyEditor = (props: ReactEditorProps) => {
const editorRef = React.useRef<typeof ReactEditor | null>(null);
return <ReactEditor ref={editorRef} {...props} />;
};
方法二:自定义 Hook
import React from 'react';
import { useReactEditor, ReactEditor, ReactEditorProps } from 'fo-editor-react';
export const MyEditor = (props: ReactEditorProps) => {
const divRef = React.useRef<HTMLElement | null>(null);
const foEditorRef = React.useRef<ReactEditor | null>(null);
foEditorRef.current = useReactEditor(props, divRef.current);
return <div ref={divRef}></div>;
};