fo-editor-react
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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>;
};

Readme

Keywords

none

Package Sidebar

Install

npm i fo-editor-react

Weekly Downloads

1

Version

0.0.7

License

ISC

Unpacked Size

9.17 kB

Total Files

9

Last publish

Collaborators

  • fo.editor