-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTinymce.js
60 lines (55 loc) · 1.73 KB
/
Tinymce.js
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
56
57
58
59
60
import React from 'react';
import PropTypes from 'prop-types';
import { Editor as Tinymce } from '@tinymce/tinymce-react';
import styled from 'styled-components';
const Wrapper = styled.div`
.ck-editor__main {
min-height: 200px;
> div {
min-height: 200px;
}
}
`;
const Editor = ({ onChange, name, value }) => {
return (
<>
<Wrapper>
<Tinymce
tinymceScriptSrc={strapi.backendURL + '/tinymce/js/tinymce/tinymce.min.js'}
value={value}
init={{
height: 500,
menubar: false,
convert_urls: false,
relative_urls : true,
remove_script_host : true,
toolbar_mode: 'wrap',
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetime media table paste code help wordcount',
'media codesample fullscreen',
'hr visualchars imagetools emoticons'
],
toolbar:
'undo redo | formatselect forecolor backcolor | \
bold italic underline strikethrough removeformat | \
alignleft aligncenter alignright alignjustify | \
outdent indent | numlist bullist | \
table link anchor | image media codesample charmap emoticons | \
fullscreen code'
}}
onEditorChange={(content, editor) => {
onChange({ target: { name, value: content } });
}}
/>
</Wrapper>
</>
);
};
Editor.propTypes = {
onChange: PropTypes.func.isRequired,
name: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
};
export default Editor;