kedao 是一个基于 braft-editor 修改而来的前端编辑器,底层基于 draft-js。
在 Braft-Editor 的基础之上,kedao 做了一些改进工作,如:
npm i kedao
import React, { useState } from "react";
import Editor, {
EditorState,
convertRawToEditorState,
convertEditorStateToRaw,
} from "kedao";
import { useLocalStorage } from "react-use";
function App() {
const [value, setValue] = useLocalStorage(
"kedao-state",
convertEditorStateToRaw(EditorState.createEmpty())
);
const [editorState, setEditorState] = useState(
convertRawToEditorState(value)
);
const handleChange = (newEditorState: EditorState) => {
setEditorState(newEditorState);
setValue(convertEditorStateToRaw(newEditorState));
};
return (
<div className="App">
<Editor value={editorState} onChange={handleChange} />
</div>
);
}
export default App;
更多示例参见 examples
欢迎任何方式的贡献,issue、文档、翻译等。
更多文档见组件官网:https://kedao.vercel.app