Skip to content

Commit b64da3b

Browse files
authored
Merge pull request #1 from thi3rry/master
Adding Dropdown and Undo plugins.
2 parents 319ef01 + d6b0c3f commit b64da3b

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

admin/src/components/editorjs/index.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import customTools from '../../config/customTools';
77
import MediaLibAdapter from '../medialib/adapter'
88
import MediaLibComponent from '../medialib/component';
99
import {changeFunc, getToggleFunc} from '../medialib/utils';
10+
import DragDrop from 'editorjs-drag-drop';
11+
import Undo from 'editorjs-undo';
1012

1113
const Editor = ({ onChange, name, value }) => {
1214

@@ -38,18 +40,24 @@ const Editor = ({ onChange, name, value }) => {
3840
}
3941
}
4042

43+
const handleReady = (editor) => {
44+
new Undo({ editor });
45+
new DragDrop(editor);
46+
if(value && JSON.parse(value).blocks.length) {
47+
editor.blocks.render(JSON.parse(value))
48+
}
49+
if (document.querySelector('[data-tool="image"]')) {
50+
document.querySelector('[data-tool="image"]').remove()
51+
}
52+
};
53+
4154
return (
4255
<>
4356
<div style={{ border: `1px solid rgb(227, 233, 243)`, borderRadius: `2px`, marginTop: `4px` }}>
4457
<EditorJs
4558
// data={JSON.parse(value)}
4659
// enableReInitialize={true}
47-
onReady={(api) => {
48-
if(value && JSON.parse(value).blocks.length) {
49-
api.blocks.render(JSON.parse(value))
50-
}
51-
document.querySelector('[data-tool="image"]').remove()
52-
}}
60+
onReady={ handleReady }
5361
onChange={(api, newData) => {
5462
if (!newData.blocks.length) {
5563
newData = null;

admin/src/config/customTools.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import PluginId from '../pluginId'
22

3+
import Paragraph from '@editorjs/paragraph'
34
import Embed from '@editorjs/embed'
45
import Table from '@editorjs/table'
56
import List from '@editorjs/list'
@@ -13,6 +14,9 @@ import Marker from '@editorjs/marker'
1314
import CheckList from '@editorjs/checklist'
1415
import Delimiter from '@editorjs/delimiter'
1516
import InlineCode from '@editorjs/inline-code'
17+
import Underline from '@editorjs/underline';
18+
import NestedList from '@editorjs/nested-list';
19+
import AlignmentTuneTool from 'editorjs-text-alignment-blocktune';
1620

1721
const customTools = {
1822
embed: Embed,
@@ -21,7 +25,7 @@ const customTools = {
2125
inlineToolbar: true,
2226
},
2327
list: {
24-
class: List,
28+
class: NestedList,
2529
inlineToolbar: true,
2630
},
2731
warning: {
@@ -43,9 +47,16 @@ const customTools = {
4347
class: Raw,
4448
inlineToolbar: true,
4549
},
50+
underline: Underline,
4651
header: {
4752
class: Header,
4853
inlineToolbar: true,
54+
tunes: ['tuneAlignment'],
55+
},
56+
paragraph: {
57+
class: Paragraph,
58+
inlineToolbar: true,
59+
tunes: ['tuneAlignment'],
4960
},
5061
quote: {
5162
class: Quote,
@@ -65,6 +76,16 @@ const customTools = {
6576
},
6677
delimiter: Delimiter,
6778
inlineCode: InlineCode,
79+
tuneAlignment: {
80+
class: AlignmentTuneTool,
81+
config:{
82+
default: "left",
83+
blocks: {
84+
header: 'center',
85+
list: 'right'
86+
}
87+
},
88+
}
6889
}
6990

7091
export default customTools

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "strapi-plugin-react-editorjs",
33
"version": "0.0.0-development",
4+
"private": true,
45
"description": "Plugin for Strapi Headless CMS, hiding the standard WYSIWYG editor and replacing it with Editor.js",
56
"homepage": "https://market.strapi.io/plugins/strapi-plugin-react-editorjs",
67
"strapi": {
@@ -12,23 +13,28 @@
1213
"kind": "plugin"
1314
},
1415
"dependencies": {
16+
"@editorjs/editorjs": "^2.25.0",
1517
"@editorjs/checklist": "1.3.0",
1618
"@editorjs/code": "2.7.0",
1719
"@editorjs/delimiter": "1.2.0",
18-
"@editorjs/editorjs": "2.23.2",
1920
"@editorjs/embed": "2.5.0",
2021
"@editorjs/header": "2.6.2",
2122
"@editorjs/image": "2.6.2",
2223
"@editorjs/inline-code": "1.3.1",
2324
"@editorjs/link": "2.4.0",
2425
"@editorjs/list": "1.6.2",
2526
"@editorjs/marker": "1.2.2",
27+
"@editorjs/nested-list": "^1.0.2",
2628
"@editorjs/paragraph": "2.8.0",
2729
"@editorjs/quote": "2.4.0",
2830
"@editorjs/raw": "2.3.0",
2931
"@editorjs/table": "2.0.1",
32+
"@editorjs/underline": "^1.0.0",
3033
"@editorjs/warning": "1.2.0",
3134
"classnames": "^2.3.1",
35+
"editorjs-text-alignment-blocktune": "^1.0.3",
36+
"editorjs-drag-drop": "^1.1.5",
37+
"editorjs-undo": "^2.0.8",
3238
"get-file-object-from-local-path": "1.0.2",
3339
"open-graph-scraper": "4.9.2",
3440
"react-editor-js": "1.10.0"

0 commit comments

Comments
 (0)