Skip to content

Commit 798b6fc

Browse files
committed
📟 Launch
0 parents  commit 798b6fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+718
-0
lines changed

.editorconfig

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = false
6+
indent_style = space
7+
indent_size = 2

.gitattributes

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
2+
3+
# Handle line endings automatically for files detected as text
4+
# and leave all files detected as binary untouched.
5+
* text=auto
6+
7+
#
8+
# The above will handle all files NOT found below
9+
#
10+
11+
#
12+
## These files are text and should be normalized (Convert crlf => lf)
13+
#
14+
15+
# source code
16+
*.php text
17+
*.css text
18+
*.sass text
19+
*.scss text
20+
*.less text
21+
*.styl text
22+
*.js text eol=lf
23+
*.coffee text
24+
*.json text
25+
*.htm text
26+
*.html text
27+
*.xml text
28+
*.svg text
29+
*.txt text
30+
*.ini text
31+
*.inc text
32+
*.pl text
33+
*.rb text
34+
*.py text
35+
*.scm text
36+
*.sql text
37+
*.sh text
38+
*.bat text
39+
40+
# templates
41+
*.ejs text
42+
*.hbt text
43+
*.jade text
44+
*.haml text
45+
*.hbs text
46+
*.dot text
47+
*.tmpl text
48+
*.phtml text
49+
50+
# git config
51+
.gitattributes text
52+
.gitignore text
53+
.gitconfig text
54+
55+
# code analysis config
56+
.jshintrc text
57+
.jscsrc text
58+
.jshintignore text
59+
.csslintrc text
60+
61+
# misc config
62+
*.yaml text
63+
*.yml text
64+
.editorconfig text
65+
66+
# build config
67+
*.npmignore text
68+
*.bowerrc text
69+
70+
# Heroku
71+
Procfile text
72+
.slugignore text
73+
74+
# Documentation
75+
*.md text
76+
LICENSE text
77+
AUTHORS text
78+
79+
80+
#
81+
## These files are binary and should be left untouched
82+
#
83+
84+
# (binary is a macro for -text -diff)
85+
*.png binary
86+
*.jpg binary
87+
*.jpeg binary
88+
*.gif binary
89+
*.ico binary
90+
*.mov binary
91+
*.mp4 binary
92+
*.mp3 binary
93+
*.flv binary
94+
*.fla binary
95+
*.swf binary
96+
*.gz binary
97+
*.zip binary
98+
*.7z binary
99+
*.ttf binary
100+
*.eot binary
101+
*.woff binary
102+
*.pyc binary
103+
*.pdf binary

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Don't check auto-generated stuff into git
2+
coverage
3+
node_modules
4+
stats.json
5+
package-lock.json
6+
7+
# Cruft
8+
.DS_Store
9+
npm-debug.log
10+
.idea

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<img src="static/strapi-plugin-editorjs.png">
2+
<h1 style="width: 100%; text-align: center">strapi-plugins-editorjs</h1>
3+
4+
### 📝 Plugin for Strapi Headless CMS, hiding the standard WYSIWYG editor on Editor.js
5+
6+
## 🍀 Supported Official Plugin
7+
8+
- [x] Paragraph (default)
9+
- [x] Embed
10+
- [x] Table
11+
- [x] List
12+
- [x] Warning
13+
- [x] Code
14+
- [o] Link
15+
- [o] Image
16+
- [x] Raw
17+
- [x] Header
18+
- [x] Quote
19+
- [x] Marker
20+
- [x] CheckList
21+
- [x] Delimiter
22+
- [x] InlineCode
23+
- [o] SimpleImage
24+
25+
## 🤟🏻 Getting Started
26+
27+
### Install via npm (or yarn)
28+
29+
```bash
30+
yarn add strapi-plugin-editorjs
31+
# or
32+
npm install strapi-plugin-editorjs
33+
```
34+
35+
## 🛠 Need Help
36+
37+
### At the moment, of all the official plugins not working:
38+
39+
1. Image
40+
2. SimpleImage
41+
42+
#### I need the help of more professional people in Strapi to properly implement these Editor.js plugins in conjunction with Strapi. If you know how you can solve this problem, please let me know, or create a pull request.
43+
44+
## ⭐️ Show your support
45+
46+
Give a star if this project helped you.

admin/src/components/Wysiwyg/index.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { isEmpty } from 'lodash';
4+
import { Label, InputDescription, InputErrors } from 'strapi-helper-plugin';
5+
import Editor from '../editorjs';
6+
7+
const Wysiwyg = ({
8+
inputDescription,
9+
errors,
10+
label,
11+
name,
12+
noErrorsDescription,
13+
onChange,
14+
value,
15+
}) => {
16+
17+
return (
18+
<div
19+
style={{
20+
marginBottom: '1.6rem',
21+
fontSize: '1.3rem',
22+
fontFamily: 'Lato',
23+
}}
24+
>
25+
<Label htmlFor={name} message={label} style={{ marginBottom: 10 }} />
26+
<Editor name={name} onChange={onChange} value={value} />
27+
<InputDescription
28+
message={inputDescription}
29+
style={!isEmpty(inputDescription) ? { marginTop: '1.4rem' } : {}}
30+
/>
31+
<InputErrors errors={(!noErrorsDescription && errors) || []} name={name} />
32+
</div>
33+
);
34+
};
35+
36+
Wysiwyg.defaultProps = {
37+
errors: [],
38+
inputDescription: null,
39+
label: '',
40+
noErrorsDescription: false,
41+
value: '',
42+
};
43+
44+
Wysiwyg.propTypes = {
45+
errors: PropTypes.array,
46+
inputDescription: PropTypes.oneOfType([
47+
PropTypes.string,
48+
PropTypes.func,
49+
PropTypes.shape({
50+
id: PropTypes.string,
51+
params: PropTypes.object,
52+
}),
53+
]),
54+
label: PropTypes.oneOfType([
55+
PropTypes.string,
56+
PropTypes.func,
57+
PropTypes.shape({
58+
id: PropTypes.string,
59+
params: PropTypes.object,
60+
}),
61+
]),
62+
name: PropTypes.string.isRequired,
63+
noErrorsDescription: PropTypes.bool,
64+
onChange: PropTypes.func.isRequired,
65+
value: PropTypes.string,
66+
};
67+
68+
export default Wysiwyg;
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import EditorJs from 'react-editor-js';
4+
5+
// Plugins for Editor.js
6+
import Embed from '@editorjs/embed'
7+
import Table from '@editorjs/table'
8+
import Paragraph from '@editorjs/paragraph'
9+
import List from '@editorjs/list'
10+
import Warning from '@editorjs/warning'
11+
import Code from '@editorjs/code'
12+
// import LinkTool from '@editorjs/link'
13+
import Image from '@editorjs/image'
14+
import Raw from '@editorjs/raw'
15+
import Header from '@editorjs/header'
16+
import Quote from '@editorjs/quote'
17+
import Marker from '@editorjs/marker'
18+
import CheckList from '@editorjs/checklist'
19+
import Delimiter from '@editorjs/delimiter'
20+
import InlineCode from '@editorjs/inline-code'
21+
import SimpleImage from '@editorjs/simple-image'
22+
23+
const editorTools = {
24+
embed: Embed,
25+
table: Table,
26+
paragraph: Paragraph,
27+
list: List,
28+
warning: Warning,
29+
code: Code,
30+
// linkTool: LinkTool,
31+
image: Image,
32+
raw: Raw,
33+
header: Header,
34+
quote: Quote,
35+
marker: Marker,
36+
checklist: CheckList,
37+
delimiter: Delimiter,
38+
inlineCode: InlineCode,
39+
simpleImage: SimpleImage
40+
}
41+
42+
const Editor = ({ onChange, name, value }) => {
43+
44+
return (
45+
<EditorJs
46+
data={value}
47+
onReady={(api) => value ? api.blocks.render(JSON.parse(value)) : ''}
48+
onChange={(api, newData) => {
49+
onChange({ target: { name, value: JSON.stringify(newData) } })}
50+
}
51+
tools={editorTools}
52+
/>
53+
);
54+
};
55+
56+
Editor.propTypes = {
57+
onChange: PropTypes.func.isRequired,
58+
name: PropTypes.string.isRequired,
59+
value: PropTypes.string,
60+
};
61+
62+
export default Editor;

admin/src/containers/App/index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
*
3+
* This component is the skeleton around the actual pages, and should only
4+
* contain code that should be seen on all pages. (e.g. navigation bar)
5+
*
6+
*/
7+
8+
import React from 'react';
9+
import { Switch, Route } from 'react-router-dom';
10+
import { NotFound } from 'strapi-helper-plugin';
11+
// Utils
12+
import pluginId from '../../pluginId';
13+
// Containers
14+
import HomePage from '../HomePage';
15+
16+
const App = () => {
17+
return (
18+
<div>
19+
<Switch>
20+
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
21+
<Route component={NotFound} />
22+
</Switch>
23+
</div>
24+
);
25+
};
26+
27+
export default App;
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
*
3+
* HomePage
4+
*
5+
*/
6+
7+
import React, { memo } from 'react';
8+
// import PropTypes from 'prop-types';
9+
import pluginId from '../../pluginId';
10+
11+
const HomePage = () => {
12+
return (
13+
<div>
14+
<h1>{pluginId}&apos;s HomePage</h1>
15+
<p>Happy coding</p>
16+
</div>
17+
);
18+
};
19+
20+
export default memo(HomePage);
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
*
3+
* Initializer
4+
*
5+
*/
6+
7+
import { useEffect, useRef } from 'react';
8+
import PropTypes from 'prop-types';
9+
import pluginId from '../../pluginId';
10+
11+
const Initializer = ({ updatePlugin }) => {
12+
const ref = useRef();
13+
ref.current = updatePlugin;
14+
15+
useEffect(() => {
16+
ref.current(pluginId, 'isReady', true);
17+
}, []);
18+
19+
return null;
20+
};
21+
22+
Initializer.propTypes = {
23+
updatePlugin: PropTypes.func.isRequired,
24+
};
25+
26+
export default Initializer;

0 commit comments

Comments
 (0)