Add undo ability
This commit is contained in:
parent
02e93b06d6
commit
4d15fa52b8
3 changed files with 14 additions and 1 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -10350,6 +10350,11 @@
|
|||
"resolved": "https://registry.npmjs.org/editorjs-inline-tool/-/editorjs-inline-tool-0.4.0.tgz",
|
||||
"integrity": "sha512-Ppb4e8IFPjWuNcoNM4tg9bDSo7FgMYAlqP4UhuV5W2JoJBubV5pUcpLrFrSyGTt1HJVEpbrib134zf4wxO+7VA=="
|
||||
},
|
||||
"editorjs-undo": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/editorjs-undo/-/editorjs-undo-0.1.4.tgz",
|
||||
"integrity": "sha512-YW+5x8tqMXQ+iQD+1OrroqUT1O/erDrysZLJ+8yB+zjls55rwUw9P7hdQCJ0DFm+WDSaRuEXb2p3dQ6VdrkYCg=="
|
||||
},
|
||||
"ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
"draftail": "^1.2.1",
|
||||
"draftjs-to-html": "^0.9.1",
|
||||
"editorjs-inline-tool": "^0.4.0",
|
||||
"editorjs-undo": "^0.1.4",
|
||||
"fast-array-diff": "^0.2.0",
|
||||
"fuzzaldrin": "^2.1.0",
|
||||
"graphql": "^14.4.2",
|
||||
|
|
|
@ -3,6 +3,7 @@ import FormControl from "@material-ui/core/FormControl";
|
|||
import FormHelperText from "@material-ui/core/FormHelperText";
|
||||
import InputLabel from "@material-ui/core/InputLabel";
|
||||
import classNames from "classnames";
|
||||
import Undo from "editorjs-undo";
|
||||
import React from "react";
|
||||
|
||||
import { RichTextEditorContentProps, tools } from "./RichTextEditorContent";
|
||||
|
@ -43,7 +44,13 @@ const RichTextEditor: React.FC<RichTextEditorProps> = ({
|
|||
const savedData = await api.saver.save();
|
||||
onChange(savedData);
|
||||
},
|
||||
onReady,
|
||||
onReady: () => {
|
||||
const undo = new Undo({ editor });
|
||||
undo.initialize(data);
|
||||
if (onReady) {
|
||||
onReady();
|
||||
}
|
||||
},
|
||||
readOnly: disabled,
|
||||
tools
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue