/
index.tsx
54 lines (50 loc) · 1.3 KB
/
index.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
/**
* Note: This is used for the e2e tests
*/
import React, { Component } from "react";
import { LetterpadEditor } from "../../src/editor";
import { Editor } from "slate";
import Gallery from "./Gallery";
class Demo extends Component {
onButtonClick = (
_: MouseEvent,
type: string,
callbacks: { [key: string]: any }
) => {
return false;
// the below is a demo to fetch images from giphy based on a search term.
// remove the above return to check it
if (type == "img") {
if (callbacks.showPlaceholder) {
callbacks.showPlaceholder(Gallery);
return true;
}
}
};
onBeforeRender = (props: { type: string; props: { editor: Editor } }) => {
// if (props.type == "strong") {
// console.log("foo");
// }
(window as any).__letterpadEditor = props.props.editor;
};
render() {
return (
<LetterpadEditor
theme="dark"
onButtonClick={this.onButtonClick}
onBeforeRender={this.onBeforeRender}
spellCheck={false}
onChange={html => {
console.log(html);
}}
getCharCount={count => {
// count is available.
if (count) {
// typescript - this is only to allow the unused variable
}
}}
/>
);
}
}
export default Demo;