├── README.md
└── admin
└── src
└── components
├── EditorJs
└── index.js
└── WysiwygWithErrors
└── index.js
/README.md:
--------------------------------------------------------------------------------
1 | # strapi-editorjs
2 |
3 | This is a prototype to get strapi to replace the Wysiwyg editor with EditorJs. Not sure
4 | if I'm gonna use strapi, but I'm putting the code for this out in the world anyway. Have fun!
5 |
6 | Note: Opening existing posts won't work, because EditorJs can't handle the markdown language
7 | normally used by strapi.
8 |
9 | ## Installation
10 |
11 | ### Install dependencies
12 |
13 | To install this, add the following dependencies to your strapi project:
14 |
15 | ```json
16 | {
17 | "dependencies": {
18 | "@editorjs/checklist": "^1.1.0",
19 | "@editorjs/delimiter": "^1.1.0",
20 | "@editorjs/editorjs": "^2.16.1",
21 | "@editorjs/embed": "^2.2.1",
22 | "@editorjs/header": "^2.4.0",
23 | "@editorjs/image": "^2.3.3",
24 | "@editorjs/link": "^2.1.3",
25 | "@editorjs/list": "^1.4.0",
26 | "@editorjs/marker": "^1.2.2",
27 | "@editorjs/paragraph": "^2.6.1",
28 | "@editorjs/quote": "^2.3.0",
29 | "@editorjs/table": "^1.2.1",
30 | "@natterstefan/react-editor-js": "^0.3.1"
31 | }
32 | }
33 | ```
34 |
35 | ### Clone this repo
36 |
37 | Clone this repo into your extensions folder.
38 |
39 | ### Build?
40 |
41 | Then build it I guess? Not sure on that part yet. Good luck.
42 |
43 | (I used `strapi develop --watch-admin` up until now)
44 |
--------------------------------------------------------------------------------
/admin/src/components/EditorJs/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import styled from 'styled-components';
4 | import ImageTool from '@editorjs/image';
5 | import { auth, request } from 'strapi-helper-plugin';
6 | import EditorJs from '@natterstefan/react-editor-js';
7 | import Header from '@editorjs/header';
8 | import Quote from '@editorjs/quote';
9 | import Embed from '@editorjs/embed';
10 | import Marker from '@editorjs/marker';
11 | import Delimiter from '@editorjs/delimiter';
12 | import Table from '@editorjs/table';
13 | import List from '@editorjs/list';
14 | import Checklist from '@editorjs/checklist';
15 |
16 | const Wrapper = styled.div`
17 | .editorjs__main {
18 | min-height: 200px;
19 | > div {
20 | min-height: 200px;
21 | }
22 | }
23 | `;
24 |
25 | const Editor = ({ onChange, name, value }) => {
26 | var editor = null;
27 |
28 | const onSave = async () => {
29 | try {
30 | const outputData = await editor.save();
31 | const dataString = JSON.stringify(outputData);
32 | onChange({ target: { name, value: dataString } });
33 | console.log('Saving data: ' + dataString);
34 | } catch (e) {
35 | console.log('Saving failed: ', e);
36 | }
37 | };
38 |
39 | return (
40 |