-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
55 lines (50 loc) · 1.33 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import "./App.css";
import { DMEditor, DMEditorRefType } from "dmeditor";
import { useEffect, useRef } from "react";
import { dmeditorInit } from "./dme-config/dmeditorInit";
import defaultData from "./data/default.json";
dmeditorInit();
const App = () => {
const editorRef = useRef<DMEditorRefType>(null);
const data = defaultData;
useEffect(() => {
const editor = editorRef.current;
if (editor) {
editor.setData(data as any);
editor.setPageSettings([
{ identifier: "cover_image", name: "Cover image", type: "image" },
{ identifier: "summary", name: "Summary", type: "richtext" },
{ identifier: "meta_keyword", name: "keyword", type: "text" },
{
identifier: "meta_description",
name: "Meta description",
type: "multitext",
},
]);
editor.setPageData({
title: "New page",
theme: "red",
meta_keyword: "test key",
});
}
}, []);
return (
<div>
<DMEditor
ref={editorRef}
onSave={(data) => {
console.log(data);
window.alert("Saved");
}}
onChange={(data) => {
console.log("changed");
console.log(data.data);
}}
onCancel={() => {
window.alert("Cancel");
}}
/>
</div>
);
};
export default App;