@kookaat/strapi-plugin-tinymce 1.1.4 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -84
- package/package.json +67 -19
- package/.github/stale.yml +0 -17
- package/admin/src/api/settings.js +0 -14
- package/admin/src/components/Editor/index.js +0 -62
- package/admin/src/components/Initializer/index.js +0 -26
- package/admin/src/components/MediaLib/index.js +0 -43
- package/admin/src/components/PluginIcon/index.js +0 -12
- package/admin/src/components/Wysiwyg/index.js +0 -122
- package/admin/src/index.js +0 -69
- package/admin/src/pages/App/index.js +0 -25
- package/admin/src/pages/HomePage/index.js +0 -7
- package/admin/src/pages/Settings/index.js +0 -134
- package/admin/src/permissions.js +0 -11
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/cs.json +0 -10
- package/admin/src/translations/en.json +0 -10
- package/admin/src/translations/sk.json +0 -10
- package/admin/src/utils/axiosInstance.js +0 -40
- package/admin/src/utils/get-trad.js +0 -5
- package/admin/src/utils/index.js +0 -2
- package/server/bootstrap.js +0 -19
- package/server/config/index.js +0 -6
- package/server/content-types/index.js +0 -3
- package/server/controllers/config.js +0 -12
- package/server/controllers/index.js +0 -9
- package/server/controllers/settings.js +0 -30
- package/server/destroy.js +0 -5
- package/server/index.js +0 -25
- package/server/middlewares/index.js +0 -3
- package/server/policies/index.js +0 -3
- package/server/register.js +0 -5
- package/server/routes/config.js +0 -13
- package/server/routes/index.js +0 -7
- package/server/routes/settings.js +0 -23
- package/server/services/config.js +0 -9
- package/server/services/index.js +0 -9
- package/server/services/settings.js +0 -36
- package/strapi-admin.js +0 -3
- package/strapi-server.js +0 -3
package/README.md
CHANGED
|
@@ -33,14 +33,13 @@ module.exports = () => ({
|
|
|
33
33
|
|
|
34
34
|
## <a id="features"></a>✨ Key features
|
|
35
35
|
|
|
36
|
-
* **Anchor:** Add an anchor/bookmark button to the toolbar that inserts an anchor at the editor’s cursor insertion
|
|
37
|
-
point.
|
|
36
|
+
* **Anchor:** Add an anchor/bookmark button to the toolbar that inserts an anchor at the editor’s cursor insertion point.
|
|
38
37
|
* **Autolink:** Create hyperlinks automatically when a user inputs a valid and complete URL.
|
|
39
|
-
* **Autoresize:** Resize the editor automatically to the content inside it, and prevent the editor from expanding
|
|
40
|
-
infinitely.
|
|
38
|
+
* **Autoresize:** Resize the editor automatically to the content inside it, and prevent the editor from expanding infinitely.
|
|
41
39
|
* **Code:** Add a toolbar button that allows a user to edit the HTML code hidden by the WYSIWYG view.
|
|
42
40
|
* **Code sample:** Insert and embed syntax color highlighted code snippets into the editable area.
|
|
43
41
|
|
|
42
|
+
|
|
44
43
|
And much more ! [List of all features](https://www.tiny.cloud/tinymce/features/).
|
|
45
44
|
|
|
46
45
|
## <a id="installation"></a>🔧 Installation
|
|
@@ -48,132 +47,102 @@ And much more ! [List of all features](https://www.tiny.cloud/tinymce/features/)
|
|
|
48
47
|
Inside your Strapi app, add the package:
|
|
49
48
|
|
|
50
49
|
With `npm`:
|
|
51
|
-
|
|
52
50
|
```bash
|
|
53
51
|
npm install @kookaat/strapi-plugin-tinymce
|
|
54
52
|
```
|
|
55
|
-
|
|
56
53
|
With `yarn`:
|
|
57
|
-
|
|
58
54
|
```bash
|
|
59
55
|
yarn add @kookaat/strapi-plugin-tinymce
|
|
60
56
|
```
|
|
61
57
|
|
|
62
58
|
In `config/plugins.js` file add:
|
|
63
|
-
|
|
64
59
|
```js
|
|
65
60
|
tinymce:{
|
|
66
61
|
enabled:true
|
|
67
|
-
}
|
|
68
|
-
;
|
|
62
|
+
};
|
|
69
63
|
```
|
|
70
64
|
|
|
71
65
|
If you do not yet have this file, then create and add:
|
|
72
|
-
|
|
73
66
|
```js
|
|
74
67
|
module.exports = () => ({
|
|
75
|
-
tinymce:
|
|
76
|
-
|
|
68
|
+
tinymce:{
|
|
69
|
+
enabled:true
|
|
77
70
|
};
|
|
78
71
|
})
|
|
79
72
|
```
|
|
80
73
|
|
|
81
74
|
You will also have to update strapi::security middleware in your middlewares.js file in config folder.
|
|
82
75
|
If you didn't update this file yet, then replace "strapi::security" with following code (object)
|
|
83
|
-
|
|
84
76
|
```js
|
|
85
77
|
//middlewares.js
|
|
86
78
|
|
|
87
|
-
{
|
|
79
|
+
{
|
|
88
80
|
name: "strapi::security",
|
|
89
|
-
|
|
90
|
-
:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
[
|
|
119
|
-
"'self'",
|
|
120
|
-
"'unsafe-inline'",
|
|
121
|
-
"*.tinymce.com",
|
|
122
|
-
"*.tiny.cloud",
|
|
123
|
-
],
|
|
124
|
-
"font-src"
|
|
125
|
-
:
|
|
126
|
-
["'self'", "*.tinymce.com", "*.tiny.cloud"],
|
|
127
|
-
}
|
|
128
|
-
,
|
|
129
|
-
upgradeInsecureRequests: null,
|
|
130
|
-
}
|
|
131
|
-
,
|
|
132
|
-
}
|
|
133
|
-
,
|
|
134
|
-
}
|
|
135
|
-
,
|
|
81
|
+
config: {
|
|
82
|
+
contentSecurityPolicy: {
|
|
83
|
+
useDefaults: true,
|
|
84
|
+
directives: {
|
|
85
|
+
"script-src": ["'self'", "*.tinymce.com", "*.tiny.cloud", "https:"],
|
|
86
|
+
"connect-src": ["'self'", "*.tinymce.com", "*.tiny.cloud", "blob:", "*.strapi.io"],
|
|
87
|
+
"img-src": [
|
|
88
|
+
"'self'",
|
|
89
|
+
"*.tinymce.com",
|
|
90
|
+
"*.tiny.cloud",
|
|
91
|
+
"data:",
|
|
92
|
+
"blob:",
|
|
93
|
+
"dl.airtable.com",
|
|
94
|
+
"strapi.io",
|
|
95
|
+
"s3.amazonaws.com",
|
|
96
|
+
"cdn.jsdelivr.net",
|
|
97
|
+
],
|
|
98
|
+
"style-src": [
|
|
99
|
+
"'self'",
|
|
100
|
+
"'unsafe-inline'",
|
|
101
|
+
"*.tinymce.com",
|
|
102
|
+
"*.tiny.cloud",
|
|
103
|
+
],
|
|
104
|
+
"font-src": ["'self'", "*.tinymce.com", "*.tiny.cloud"],
|
|
105
|
+
},
|
|
106
|
+
upgradeInsecureRequests: null,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
136
110
|
```
|
|
137
111
|
|
|
138
112
|
Then run build:
|
|
139
|
-
|
|
140
113
|
```bash
|
|
141
114
|
npm run build
|
|
142
115
|
```
|
|
143
116
|
|
|
144
117
|
or
|
|
145
|
-
|
|
146
118
|
```bash
|
|
147
119
|
yarn build
|
|
148
120
|
```
|
|
149
121
|
|
|
150
|
-
**After starting your project please add API key for your TinyMCE editor in admin panel in
|
|
151
|
-
settings/tinymce/configuration**
|
|
122
|
+
**After starting your project please add API key for your TinyMCE editor in admin panel in settings/tinymce/configuration**
|
|
152
123
|
|
|
153
|
-
If TinyMCE editor doesn't appear in your richtext field, please check your console for any hints, you might have
|
|
154
|
-
incorrectly set your middlewares.
|
|
124
|
+
If TinyMCE editor doesn't appear in your richtext field, please check your console for any hints, you might have incorrectly set your middlewares.
|
|
155
125
|
|
|
156
126
|
## <a id="configuration"></a>⚙️ Configuration
|
|
157
|
-
|
|
158
|
-
TinyMCE outputFormat should be defined in `config.editor`, and init object should be defined
|
|
159
|
-
in `config.editor.editorConfig` field in `plugins.js` file.
|
|
127
|
+
TinyMCE outputFormat should be defined in `config.editor`, and init object should be defined in `config.editor.editorConfig` field in `plugins.js` file.
|
|
160
128
|
|
|
161
129
|
**⚠️ `plugins.js` not `plugin.js` ⚠️**
|
|
162
130
|
|
|
163
131
|
**`plugins.js` file should be placed in `config` folder.**
|
|
164
132
|
|
|
133
|
+
|
|
165
134
|
Learn more about configuration from [official documentation](https://www.tiny.cloud/docs/tinymce/6/).
|
|
166
135
|
|
|
167
136
|
**Default configuration:**
|
|
168
|
-
|
|
169
137
|
```js
|
|
170
138
|
// plugins.js
|
|
171
|
-
module.exports = ({env}) => ({
|
|
139
|
+
module.exports = ({ env }) => ({
|
|
172
140
|
tinymce: {
|
|
173
141
|
enabled: true,
|
|
174
142
|
config: {
|
|
175
143
|
editor: {
|
|
176
144
|
outputFormat: "html",
|
|
145
|
+
tinymceSrc: "/tinymce/tinymce.min.js", // USE WITH YOUR PUBLIC PATH TO TINYMCE LIBRARY FOR USING SELF HOSTED TINYMCE
|
|
177
146
|
editorConfig: {
|
|
178
147
|
language: "sk",
|
|
179
148
|
height: 500,
|
|
@@ -195,19 +164,19 @@ module.exports = ({env}) => ({
|
|
|
195
164
|
{
|
|
196
165
|
title: "Headings",
|
|
197
166
|
items: [
|
|
198
|
-
{title: "h1", block: "h1"},
|
|
199
|
-
{title: "h2", block: "h2"},
|
|
200
|
-
{title: "h3", block: "h3"},
|
|
201
|
-
{title: "h4", block: "h4"},
|
|
202
|
-
{title: "h5", block: "h5"},
|
|
203
|
-
{title: "h6", block: "h6"},
|
|
167
|
+
{ title: "h1", block: "h1" },
|
|
168
|
+
{ title: "h2", block: "h2" },
|
|
169
|
+
{ title: "h3", block: "h3" },
|
|
170
|
+
{ title: "h4", block: "h4" },
|
|
171
|
+
{ title: "h5", block: "h5" },
|
|
172
|
+
{ title: "h6", block: "h6" },
|
|
204
173
|
],
|
|
205
174
|
},
|
|
206
175
|
|
|
207
176
|
{
|
|
208
177
|
title: "Text",
|
|
209
178
|
items: [
|
|
210
|
-
{title: "Paragraph", block: "p"},
|
|
179
|
+
{ title: "Paragraph", block: "p" },
|
|
211
180
|
{
|
|
212
181
|
title: "Paragraph with small letters",
|
|
213
182
|
block: "small",
|
|
@@ -224,9 +193,8 @@ module.exports = ({env}) => ({
|
|
|
224
193
|
```
|
|
225
194
|
|
|
226
195
|
## <a id="requirements"></a>⚠️ Requirements
|
|
196
|
+
Strapi **v5.x.x+**
|
|
227
197
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Node **14 - 20**
|
|
198
|
+
Node **>= 20.x.x**
|
|
231
199
|
|
|
232
|
-
Tested on **
|
|
200
|
+
Tested on **v5.1.1**
|
package/package.json
CHANGED
|
@@ -1,36 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kookaat/strapi-plugin-tinymce",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"private": false,
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Strapi custom field with a customized build of TinyMCE richtext editor.",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"strapi",
|
|
8
7
|
"tinymce",
|
|
9
|
-
"tinymce
|
|
8
|
+
"tinymce 7",
|
|
10
9
|
"wysiwyg",
|
|
11
10
|
"rich text",
|
|
12
11
|
"editor"
|
|
13
12
|
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "M.Hossein Zendehpey (forked from SKLINET s.r.o.)",
|
|
16
|
+
"url": "https://github.com/mhzendehpey"
|
|
17
|
+
},
|
|
18
|
+
"type": "commonjs",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
"./strapi-admin": {
|
|
22
|
+
"types": "./dist/admin/src/index.d.ts",
|
|
23
|
+
"source": "./admin/src/index.ts",
|
|
24
|
+
"import": "./dist/admin/index.mjs",
|
|
25
|
+
"require": "./dist/admin/index.js",
|
|
26
|
+
"default": "./dist/admin/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./strapi-server": {
|
|
29
|
+
"types": "./dist/server/src/index.d.ts",
|
|
30
|
+
"source": "./server/src/index.ts",
|
|
31
|
+
"import": "./dist/server/index.mjs",
|
|
32
|
+
"require": "./dist/server/index.js",
|
|
33
|
+
"default": "./dist/server/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "strapi-plugin build",
|
|
41
|
+
"test:ts:back": "run -T tsc -p server/tsconfig.json",
|
|
42
|
+
"test:ts:front": "run -T tsc -p admin/tsconfig.json",
|
|
43
|
+
"verify": "strapi-plugin verify",
|
|
44
|
+
"watch": "strapi-plugin watch",
|
|
45
|
+
"watch:link": "strapi-plugin watch:link"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@strapi/design-system": "^2.0.0-rc.11",
|
|
49
|
+
"@strapi/icons": "^2.0.0-rc.11",
|
|
50
|
+
"@tinymce/tinymce-react": "^5.1.1",
|
|
51
|
+
"react-intl": "^6.8.4",
|
|
52
|
+
"tinymce-i18n": "^24.10.28"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@strapi/sdk-plugin": "^5.2.7",
|
|
56
|
+
"@strapi/strapi": "^5.1.1",
|
|
57
|
+
"@strapi/typescript-utils": "5.1.1",
|
|
58
|
+
"@types/react": "^18.3.10",
|
|
59
|
+
"@types/react-dom": "^18.3.0",
|
|
60
|
+
"prettier": "^3.3.3",
|
|
61
|
+
"react": "^18.3.1",
|
|
62
|
+
"react-dom": "^18.3.1",
|
|
63
|
+
"react-router-dom": "^6.26.2",
|
|
64
|
+
"styled-components": "^6.1.13",
|
|
65
|
+
"typescript": "^5.6.2"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"@strapi/sdk-plugin": "^5.2.7",
|
|
69
|
+
"@strapi/strapi": "^5.1.1",
|
|
70
|
+
"react": "^18.3.1",
|
|
71
|
+
"react-dom": "^18.3.1",
|
|
72
|
+
"react-router-dom": "^6.27.0",
|
|
73
|
+
"styled-components": "^6.1.13"
|
|
74
|
+
},
|
|
14
75
|
"strapi": {
|
|
15
76
|
"displayName": "TinyMCE",
|
|
16
77
|
"name": "tinymce",
|
|
17
|
-
"description": "
|
|
78
|
+
"description": "Strapi custom field with a customized build of TinyMCE richtext editor.",
|
|
18
79
|
"kind": "plugin"
|
|
19
80
|
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@strapi/helper-plugin": "^4.26.0",
|
|
22
|
-
"@tinymce/tinymce-react": "4.3.2"
|
|
23
|
-
},
|
|
24
|
-
"author": {
|
|
25
|
-
"name": "M.Hossein Zendehpey (forked from SKLINET s.r.o.)",
|
|
26
|
-
"url": "https://github.com/mhzendehpey"
|
|
27
|
-
},
|
|
28
81
|
"repository": {
|
|
29
82
|
"url": "git+https://github.com/mhzendehpey/strapi-plugin-tinymce"
|
|
30
|
-
}
|
|
31
|
-
"engines": {
|
|
32
|
-
"node": ">=14.19.1 <=24.x.x",
|
|
33
|
-
"npm": ">=6.0.0"
|
|
34
|
-
},
|
|
35
|
-
"license": "MIT"
|
|
83
|
+
}
|
|
36
84
|
}
|
package/.github/stale.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Number of days of inactivity before an issue becomes stale
|
|
2
|
-
daysUntilStale: 30
|
|
3
|
-
# Number of days of inactivity before a stale issue is closed
|
|
4
|
-
daysUntilClose: 7
|
|
5
|
-
# Issues with these labels will never be considered stale
|
|
6
|
-
exemptLabels:
|
|
7
|
-
- pinned
|
|
8
|
-
- security
|
|
9
|
-
# Label to use when marking an issue as stale
|
|
10
|
-
staleLabel: wontfix
|
|
11
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
|
12
|
-
markComment: >
|
|
13
|
-
This issue has been automatically marked as stale because it has not had
|
|
14
|
-
recent activity. It will be closed if no further activity occurs. Thank you
|
|
15
|
-
for your contributions.
|
|
16
|
-
# Comment to post when closing a stale issue. Set to `false` to disable
|
|
17
|
-
closeComment: false
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { axiosInstance } from "../utils";
|
|
2
|
-
|
|
3
|
-
const taskRequests = {
|
|
4
|
-
getSettings: async () => {
|
|
5
|
-
const data = await axiosInstance.get(`/tinymce/settings`);
|
|
6
|
-
return data;
|
|
7
|
-
},
|
|
8
|
-
setSettings: async (data) => {
|
|
9
|
-
return await axiosInstance.post(`/tinymce/settings`, {
|
|
10
|
-
apiKey: data,
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
export default taskRequests;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { Editor } from "@tinymce/tinymce-react";
|
|
4
|
-
import { request } from "@strapi/helper-plugin";
|
|
5
|
-
import pluginId from "../../pluginId";
|
|
6
|
-
import { prefixFileUrlWithBackendUrl } from "@strapi/helper-plugin";
|
|
7
|
-
|
|
8
|
-
const TinyEditor = ({ onChange, name, value }) => {
|
|
9
|
-
const [pluginConfig, setPluginConfig] = useState();
|
|
10
|
-
const uploadUrl = `${prefixFileUrlWithBackendUrl("/api/upload")}`;
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const getPluginConfig = async () => {
|
|
14
|
-
const editor = await request(`/${pluginId}/config/editor`, {
|
|
15
|
-
method: "GET",
|
|
16
|
-
});
|
|
17
|
-
if (editor) {
|
|
18
|
-
setPluginConfig(editor);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
getPluginConfig();
|
|
22
|
-
}, []);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
pluginConfig ?
|
|
26
|
-
<Editor
|
|
27
|
-
tinymceScriptSrc={pluginConfig?.tinymceScriptSrc}
|
|
28
|
-
value={value}
|
|
29
|
-
tagName={name}
|
|
30
|
-
onEditorChange={(editorContent) => {
|
|
31
|
-
onChange({ target: { name, value: editorContent } });
|
|
32
|
-
}}
|
|
33
|
-
outputFormat={pluginConfig?.outputFormat || "html"}
|
|
34
|
-
init={{
|
|
35
|
-
...pluginConfig?.editorConfig,
|
|
36
|
-
images_upload_handler: async (blobInfo) => {
|
|
37
|
-
const formData = new FormData();
|
|
38
|
-
formData.append("files", blobInfo.blob());
|
|
39
|
-
const response = await fetch(uploadUrl, {
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: {
|
|
42
|
-
Authorization: "Bearer ",
|
|
43
|
-
},
|
|
44
|
-
body: formData,
|
|
45
|
-
})
|
|
46
|
-
.then((response) => response.json())
|
|
47
|
-
.catch(function (err) {
|
|
48
|
-
console.log("error:", err);
|
|
49
|
-
});
|
|
50
|
-
return response?.[0]?.url || '';
|
|
51
|
-
},
|
|
52
|
-
}}
|
|
53
|
-
/>
|
|
54
|
-
: <></>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
TinyEditor.propTypes = {
|
|
58
|
-
onChange: PropTypes.func.isRequired,
|
|
59
|
-
name: PropTypes.string.isRequired,
|
|
60
|
-
value: PropTypes.string,
|
|
61
|
-
};
|
|
62
|
-
export default TinyEditor;
|
|
@@ -1,26 +0,0 @@
|
|
|
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 = ({ setPlugin }) => {
|
|
12
|
-
const ref = useRef();
|
|
13
|
-
ref.current = setPlugin;
|
|
14
|
-
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
ref.current(pluginId);
|
|
17
|
-
}, []);
|
|
18
|
-
|
|
19
|
-
return null;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
Initializer.propTypes = {
|
|
23
|
-
setPlugin: PropTypes.func.isRequired,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default Initializer;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { prefixFileUrlWithBackendUrl, useLibrary } from "@strapi/helper-plugin";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
|
|
5
|
-
const MediaLib = ({ isOpen, onChange, onToggle }) => {
|
|
6
|
-
const { components } = useLibrary();
|
|
7
|
-
const MediaLibraryDialog = components["media-library"];
|
|
8
|
-
|
|
9
|
-
const handleSelectAssets = (files) => {
|
|
10
|
-
const formattedFiles = files.map((f) => ({
|
|
11
|
-
alt: f.alternativeText || f.name,
|
|
12
|
-
url: prefixFileUrlWithBackendUrl(f.url),
|
|
13
|
-
mime: f.mime,
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
onChange(formattedFiles);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
if (!isOpen) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<MediaLibraryDialog
|
|
25
|
-
onClose={onToggle}
|
|
26
|
-
onSelectAssets={handleSelectAssets}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
MediaLib.defaultProps = {
|
|
32
|
-
isOpen: false,
|
|
33
|
-
onChange: () => {},
|
|
34
|
-
onToggle: () => {},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
MediaLib.propTypes = {
|
|
38
|
-
isOpen: PropTypes.bool,
|
|
39
|
-
onChange: PropTypes.func,
|
|
40
|
-
onToggle: PropTypes.func,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default MediaLib;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
|
-
import { Stack } from "@strapi/design-system/Stack";
|
|
4
|
-
import { Box } from "@strapi/design-system/Box";
|
|
5
|
-
import { Button } from "@strapi/design-system/Button";
|
|
6
|
-
import { Typography } from "@strapi/design-system/Typography";
|
|
7
|
-
import Landscape from "@strapi/icons/Landscape";
|
|
8
|
-
import MediaLib from "../MediaLib";
|
|
9
|
-
import Editor from "../Editor";
|
|
10
|
-
import { useIntl } from "react-intl";
|
|
11
|
-
|
|
12
|
-
const Wysiwyg = ({
|
|
13
|
-
name,
|
|
14
|
-
onChange,
|
|
15
|
-
value,
|
|
16
|
-
intlLabel,
|
|
17
|
-
disabled,
|
|
18
|
-
error,
|
|
19
|
-
description,
|
|
20
|
-
required,
|
|
21
|
-
}) => {
|
|
22
|
-
const { formatMessage } = useIntl();
|
|
23
|
-
const [mediaLibVisible, setMediaLibVisible] = useState(false);
|
|
24
|
-
|
|
25
|
-
const handleToggleMediaLib = () => setMediaLibVisible((prev) => !prev);
|
|
26
|
-
|
|
27
|
-
const handleChangeAssets = (assets) => {
|
|
28
|
-
let newValue = value ? value : "";
|
|
29
|
-
|
|
30
|
-
assets.map((asset) => {
|
|
31
|
-
if (asset.mime.includes("image")) {
|
|
32
|
-
const imgTag = `<p><img src="${asset.url}" alt="${asset.alt}"></img></p>`;
|
|
33
|
-
newValue = `${newValue}${imgTag}`;
|
|
34
|
-
}
|
|
35
|
-
if (asset.mime.includes("video")) {
|
|
36
|
-
const videoTag = `<video><source src="${asset.url}" alt="${asset.alt}"</source></video>`;
|
|
37
|
-
newValue = `${newValue}${videoTag}`;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
onChange({ target: { name, value: newValue } });
|
|
42
|
-
handleToggleMediaLib();
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<Stack size={1}>
|
|
48
|
-
<Box>
|
|
49
|
-
<Typography variant="pi" fontWeight="bold">
|
|
50
|
-
{formatMessage(intlLabel)}
|
|
51
|
-
</Typography>
|
|
52
|
-
{required && (
|
|
53
|
-
<Typography
|
|
54
|
-
variant="pi"
|
|
55
|
-
fontWeight="bold"
|
|
56
|
-
textColor="danger600"
|
|
57
|
-
>
|
|
58
|
-
*
|
|
59
|
-
</Typography>
|
|
60
|
-
)}
|
|
61
|
-
</Box>
|
|
62
|
-
<Button
|
|
63
|
-
startIcon={<Landscape />}
|
|
64
|
-
variant="secondary"
|
|
65
|
-
fullWidth
|
|
66
|
-
onClick={handleToggleMediaLib}
|
|
67
|
-
>
|
|
68
|
-
Media library
|
|
69
|
-
</Button>
|
|
70
|
-
<Editor
|
|
71
|
-
disabled={disabled}
|
|
72
|
-
name={name}
|
|
73
|
-
onChange={onChange}
|
|
74
|
-
value={value}
|
|
75
|
-
/>
|
|
76
|
-
{error && (
|
|
77
|
-
<Typography variant="pi" textColor="danger600">
|
|
78
|
-
{formatMessage({ id: error, defaultMessage: error })}
|
|
79
|
-
</Typography>
|
|
80
|
-
)}
|
|
81
|
-
{description && (
|
|
82
|
-
<Typography variant="pi">
|
|
83
|
-
{formatMessage(description)}
|
|
84
|
-
</Typography>
|
|
85
|
-
)}
|
|
86
|
-
</Stack>
|
|
87
|
-
<MediaLib
|
|
88
|
-
isOpen={mediaLibVisible}
|
|
89
|
-
onChange={handleChangeAssets}
|
|
90
|
-
onToggle={handleToggleMediaLib}
|
|
91
|
-
/>
|
|
92
|
-
</>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
Wysiwyg.defaultProps = {
|
|
97
|
-
description: "",
|
|
98
|
-
disabled: false,
|
|
99
|
-
error: undefined,
|
|
100
|
-
intlLabel: "",
|
|
101
|
-
required: false,
|
|
102
|
-
value: "",
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
Wysiwyg.propTypes = {
|
|
106
|
-
description: PropTypes.shape({
|
|
107
|
-
id: PropTypes.string,
|
|
108
|
-
defaultMessage: PropTypes.string,
|
|
109
|
-
}),
|
|
110
|
-
disabled: PropTypes.bool,
|
|
111
|
-
error: PropTypes.string,
|
|
112
|
-
intlLabel: PropTypes.shape({
|
|
113
|
-
id: PropTypes.string,
|
|
114
|
-
defaultMessage: PropTypes.string,
|
|
115
|
-
}),
|
|
116
|
-
name: PropTypes.string.isRequired,
|
|
117
|
-
onChange: PropTypes.func.isRequired,
|
|
118
|
-
required: PropTypes.bool,
|
|
119
|
-
value: PropTypes.string,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export default Wysiwyg;
|
package/admin/src/index.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { prefixPluginTranslations } from "@strapi/helper-plugin";
|
|
2
|
-
import pluginPkg from "../../package.json";
|
|
3
|
-
import pluginId from "./pluginId";
|
|
4
|
-
import Initializer from "./components/Initializer";
|
|
5
|
-
import Wysiwyg from "./components/Wysiwyg";
|
|
6
|
-
import { getTrad } from "./utils";
|
|
7
|
-
import pluginPermissions from "./permissions";
|
|
8
|
-
|
|
9
|
-
const name = pluginPkg.strapi.name;
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
register(app) {
|
|
13
|
-
app.addFields({ type: "wysiwyg", Component: Wysiwyg });
|
|
14
|
-
app.createSettingSection(
|
|
15
|
-
{
|
|
16
|
-
id: pluginId,
|
|
17
|
-
intlLabel: {
|
|
18
|
-
id: `${pluginId}.plugin.name`,
|
|
19
|
-
defaultMessage: "TinyMCE",
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
[
|
|
23
|
-
{
|
|
24
|
-
intlLabel: {
|
|
25
|
-
id: getTrad("settings.page-title"),
|
|
26
|
-
defaultMessage: "Configuration",
|
|
27
|
-
},
|
|
28
|
-
id: "settings",
|
|
29
|
-
to: `/settings/${pluginId}`,
|
|
30
|
-
Component: async () => {
|
|
31
|
-
return import("./pages/Settings");
|
|
32
|
-
},
|
|
33
|
-
permissions: pluginPermissions["settings"],
|
|
34
|
-
},
|
|
35
|
-
]
|
|
36
|
-
);
|
|
37
|
-
app.registerPlugin({
|
|
38
|
-
id: pluginId,
|
|
39
|
-
initializer: Initializer,
|
|
40
|
-
isReady: false,
|
|
41
|
-
name,
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
bootstrap(app) {},
|
|
46
|
-
async registerTrads({ locales }) {
|
|
47
|
-
const importedTrads = await Promise.all(
|
|
48
|
-
locales.map((locale) => {
|
|
49
|
-
return import(
|
|
50
|
-
/* webpackChunkName: "translation-[request]" */ `./translations/${locale}.json`
|
|
51
|
-
)
|
|
52
|
-
.then(({ default: data }) => {
|
|
53
|
-
return {
|
|
54
|
-
data: prefixPluginTranslations(data, pluginId),
|
|
55
|
-
locale,
|
|
56
|
-
};
|
|
57
|
-
})
|
|
58
|
-
.catch(() => {
|
|
59
|
-
return {
|
|
60
|
-
data: {},
|
|
61
|
-
locale,
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
})
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
return Promise.resolve(importedTrads);
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
import pluginId from '../../pluginId';
|
|
12
|
-
import HomePage from '../HomePage';
|
|
13
|
-
|
|
14
|
-
const App = () => {
|
|
15
|
-
return (
|
|
16
|
-
<div>
|
|
17
|
-
<Switch>
|
|
18
|
-
<Route path={`/plugins/${pluginId}`} component={HomePage} exact />
|
|
19
|
-
<Route component={NotFound} />
|
|
20
|
-
</Switch>
|
|
21
|
-
</div>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default App;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { useNotification, LoadingIndicatorPage } from "@strapi/helper-plugin";
|
|
3
|
-
import { Box } from "@strapi/design-system/Box";
|
|
4
|
-
import { Stack } from "@strapi/design-system/Stack";
|
|
5
|
-
import { Button } from "@strapi/design-system/Button";
|
|
6
|
-
import { Grid, GridItem } from "@strapi/design-system/Grid";
|
|
7
|
-
import { HeaderLayout } from "@strapi/design-system/Layout";
|
|
8
|
-
import { ContentLayout } from "@strapi/design-system/Layout";
|
|
9
|
-
import { Typography } from "@strapi/design-system/Typography";
|
|
10
|
-
import { useIntl } from "react-intl";
|
|
11
|
-
import { getTrad } from "../../utils";
|
|
12
|
-
import { TextInput } from "@strapi/design-system/TextInput";
|
|
13
|
-
import Check from "@strapi/icons/Check";
|
|
14
|
-
import taskRequests from "../../api/settings";
|
|
15
|
-
|
|
16
|
-
const Settings = () => {
|
|
17
|
-
const toggleNotification = useNotification();
|
|
18
|
-
const { formatMessage } = useIntl();
|
|
19
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
20
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
21
|
-
const [currentApiKey, setCurrentApiKey] = useState("");
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
setIsLoading(true);
|
|
25
|
-
const getApiKey = async () => {
|
|
26
|
-
const data = await taskRequests.getSettings();
|
|
27
|
-
if (data) {
|
|
28
|
-
setIsLoading(false);
|
|
29
|
-
return setCurrentApiKey(data.data.apiKey);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
getApiKey();
|
|
33
|
-
}, [setCurrentApiKey]);
|
|
34
|
-
|
|
35
|
-
const handleSubmit = async () => {
|
|
36
|
-
setIsSaving(true);
|
|
37
|
-
await taskRequests.setSettings(currentApiKey);
|
|
38
|
-
setIsSaving(false);
|
|
39
|
-
toggleNotification({
|
|
40
|
-
type: "success",
|
|
41
|
-
message: formatMessage({
|
|
42
|
-
id: getTrad("settings.success-message"),
|
|
43
|
-
defaultMessage: "Settings successfully updated",
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const handleChange = (e) => {
|
|
49
|
-
setCurrentApiKey(() => e.target.value);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<>
|
|
54
|
-
<HeaderLayout
|
|
55
|
-
id="title"
|
|
56
|
-
title={formatMessage({
|
|
57
|
-
id: getTrad("settings.title"),
|
|
58
|
-
defaultMessage: "TinyMCE",
|
|
59
|
-
})}
|
|
60
|
-
subtitle={formatMessage({
|
|
61
|
-
id: getTrad("settings.subtitle"),
|
|
62
|
-
defaultMessage:
|
|
63
|
-
"Manage the settings of your TinyMCE plugin",
|
|
64
|
-
})}
|
|
65
|
-
primaryAction={
|
|
66
|
-
isLoading ? (
|
|
67
|
-
<></>
|
|
68
|
-
) : (
|
|
69
|
-
<Button
|
|
70
|
-
onClick={handleSubmit}
|
|
71
|
-
startIcon={<Check />}
|
|
72
|
-
size="L"
|
|
73
|
-
disabled={isSaving}
|
|
74
|
-
loading={isSaving}
|
|
75
|
-
>
|
|
76
|
-
{formatMessage({
|
|
77
|
-
id: getTrad("settings.save-button"),
|
|
78
|
-
defaultMessage: "Save",
|
|
79
|
-
})}
|
|
80
|
-
</Button>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
></HeaderLayout>
|
|
84
|
-
{isLoading ? (
|
|
85
|
-
<LoadingIndicatorPage />
|
|
86
|
-
) : (
|
|
87
|
-
<ContentLayout>
|
|
88
|
-
<Box
|
|
89
|
-
background="neutral0"
|
|
90
|
-
hasRadius
|
|
91
|
-
shadow="filterShadow"
|
|
92
|
-
paddingTop={6}
|
|
93
|
-
paddingBottom={6}
|
|
94
|
-
paddingLeft={7}
|
|
95
|
-
paddingRight={7}
|
|
96
|
-
>
|
|
97
|
-
<Stack size={3}>
|
|
98
|
-
<Typography>
|
|
99
|
-
{formatMessage({
|
|
100
|
-
id: getTrad("settings.content-title"),
|
|
101
|
-
defaultMessage:
|
|
102
|
-
"Set your API key for TinyMCE editor.",
|
|
103
|
-
})}
|
|
104
|
-
</Typography>
|
|
105
|
-
<Grid gap={6}>
|
|
106
|
-
<GridItem col={8} s={18}>
|
|
107
|
-
<TextInput
|
|
108
|
-
id="api-key"
|
|
109
|
-
name="key"
|
|
110
|
-
onChange={handleChange}
|
|
111
|
-
label={formatMessage({
|
|
112
|
-
id: getTrad("settings.input-title"),
|
|
113
|
-
defaultMessage: "API key",
|
|
114
|
-
})}
|
|
115
|
-
value={currentApiKey}
|
|
116
|
-
placeholder={formatMessage({
|
|
117
|
-
id: getTrad(
|
|
118
|
-
"settings.input-placeholder"
|
|
119
|
-
),
|
|
120
|
-
defaultMessage:
|
|
121
|
-
"ex: ADASFNASF46564SAD",
|
|
122
|
-
})}
|
|
123
|
-
/>
|
|
124
|
-
</GridItem>
|
|
125
|
-
</Grid>
|
|
126
|
-
</Stack>
|
|
127
|
-
</Box>
|
|
128
|
-
</ContentLayout>
|
|
129
|
-
)}
|
|
130
|
-
</>
|
|
131
|
-
);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export default Settings;
|
package/admin/src/permissions.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const pluginPermissions = {
|
|
2
|
-
// This permission regards the main component (App) and is used to tell
|
|
3
|
-
// If the plugin link should be displayed in the menu
|
|
4
|
-
// And also if the plugin is accessible. This use case is found when a user types the url of the
|
|
5
|
-
// plugin directly in the browser
|
|
6
|
-
'menu-link': [{ action: 'plugin::tinymce.menu-link', subject: null }],
|
|
7
|
-
settings: [{ action: 'plugin::tinymce.settings.read', subject: null }],
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default pluginPermissions;
|
|
11
|
-
|
package/admin/src/pluginId.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"settings.title": "TinyMCE",
|
|
3
|
-
"settings.subtitle": "Úprava nastavení pluginu TinyMCE",
|
|
4
|
-
"settings.content-title": "Nastavení klíče API pro editor TinyMCE.",
|
|
5
|
-
"settings.save-button": "Uložit",
|
|
6
|
-
"settings.input-title": "API klíč",
|
|
7
|
-
"settings.input-placeholder": "např. eegrtg8464asnbvvvfasd46486asldaeerer45888areettzh",
|
|
8
|
-
"settings.success-message": "Nastavení bylo úspěšně uloženo.",
|
|
9
|
-
"settings.page-title": "Konfigurace"
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"settings.title": "TinyMCE",
|
|
3
|
-
"settings.subtitle": "Edit settings of your TinyMCE plugin",
|
|
4
|
-
"settings.content-title": "Set API key for TinyMCE editor.",
|
|
5
|
-
"settings.save-button": "Save",
|
|
6
|
-
"settings.input-title": "API key",
|
|
7
|
-
"settings.input-placeholder": "ex. eegrtg8464asnbvvvfasd46486asldaeerer45888areettzh",
|
|
8
|
-
"settings.success-message": "Settings successfully updated",
|
|
9
|
-
"settings.page-title": "Configuration"
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"settings.title": "TinyMCE",
|
|
3
|
-
"settings.subtitle": "Upravte nastavenia vášho TinyMCE pluginu",
|
|
4
|
-
"settings.content-title": "Nastavte API kľúč pre TinyMCE editor.",
|
|
5
|
-
"settings.save-button": "Uložiť",
|
|
6
|
-
"settings.input-title": "API kľúč",
|
|
7
|
-
"settings.input-placeholder": "napr. eegrtg8464asnbvvvfasd46486asldaeerer45888areettzh",
|
|
8
|
-
"settings.success-message": "Nastavenia boli úspešne uložené.",
|
|
9
|
-
"settings.page-title": "Konfigurácia"
|
|
10
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* axios with a custom config.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import axios from 'axios';
|
|
6
|
-
import { auth } from '@strapi/helper-plugin';
|
|
7
|
-
|
|
8
|
-
const instance = axios.create({
|
|
9
|
-
baseURL: process.env.STRAPI_ADMIN_BACKEND_URL,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
instance.interceptors.request.use(
|
|
13
|
-
async config => {
|
|
14
|
-
config.headers = {
|
|
15
|
-
Authorization: `Bearer ${auth.getToken()}`,
|
|
16
|
-
Accept: 'application/json',
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return config;
|
|
21
|
-
},
|
|
22
|
-
error => {
|
|
23
|
-
Promise.reject(error);
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
instance.interceptors.response.use(
|
|
28
|
-
response => response,
|
|
29
|
-
error => {
|
|
30
|
-
// whatever you want to do with the error
|
|
31
|
-
if (error.response?.status === 401) {
|
|
32
|
-
auth.clearAppStorage();
|
|
33
|
-
window.location.reload();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
export default instance;
|
package/admin/src/utils/index.js
DELETED
package/server/bootstrap.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
module.exports = async ({ strapi }) => {
|
|
4
|
-
const actions = [
|
|
5
|
-
{
|
|
6
|
-
section: "plugins",
|
|
7
|
-
displayName: "Access the plugin settings",
|
|
8
|
-
uid: "settings.read",
|
|
9
|
-
pluginName: "tinymce",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
section: "plugins",
|
|
13
|
-
displayName: "Menu link to plugin settings",
|
|
14
|
-
uid: "menu-link",
|
|
15
|
-
pluginName: "tinymce",
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
await strapi.admin.services.permission.actionProvider.registerMany(actions);
|
|
19
|
-
};
|
package/server/config/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
getSettings: async (ctx) => {
|
|
5
|
-
try {
|
|
6
|
-
ctx.body = await strapi
|
|
7
|
-
.plugin("tinymce")
|
|
8
|
-
.service("settings")
|
|
9
|
-
.getSettings();
|
|
10
|
-
} catch (err) {
|
|
11
|
-
ctx.body = err;
|
|
12
|
-
ctx.throw(500, err);
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
setSettings: async (ctx) => {
|
|
16
|
-
const { body } = ctx.request;
|
|
17
|
-
try {
|
|
18
|
-
await strapi
|
|
19
|
-
.plugin("tinymce")
|
|
20
|
-
.service("settings")
|
|
21
|
-
.setSettings(body);
|
|
22
|
-
ctx.body = await strapi
|
|
23
|
-
.plugin("tinymce")
|
|
24
|
-
.service("settings")
|
|
25
|
-
.getSettings();
|
|
26
|
-
} catch (err) {
|
|
27
|
-
ctx.throw(500, err);
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
};
|
package/server/destroy.js
DELETED
package/server/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const register = require('./register');
|
|
4
|
-
const bootstrap = require('./bootstrap');
|
|
5
|
-
const destroy = require('./destroy');
|
|
6
|
-
const config = require('./config');
|
|
7
|
-
const contentTypes = require('./content-types');
|
|
8
|
-
const controllers = require('./controllers');
|
|
9
|
-
const routes = require('./routes');
|
|
10
|
-
const middlewares = require('./middlewares');
|
|
11
|
-
const policies = require('./policies');
|
|
12
|
-
const services = require('./services');
|
|
13
|
-
|
|
14
|
-
module.exports = {
|
|
15
|
-
register,
|
|
16
|
-
bootstrap,
|
|
17
|
-
destroy,
|
|
18
|
-
config,
|
|
19
|
-
controllers,
|
|
20
|
-
routes,
|
|
21
|
-
services,
|
|
22
|
-
contentTypes,
|
|
23
|
-
policies,
|
|
24
|
-
middlewares,
|
|
25
|
-
};
|
package/server/policies/index.js
DELETED
package/server/register.js
DELETED
package/server/routes/config.js
DELETED
package/server/routes/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
type: "admin",
|
|
3
|
-
routes: [
|
|
4
|
-
{
|
|
5
|
-
method: "GET",
|
|
6
|
-
path: "/settings",
|
|
7
|
-
handler: "settings.getSettings",
|
|
8
|
-
config: {
|
|
9
|
-
policies: [],
|
|
10
|
-
auth: false,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
method: "POST",
|
|
15
|
-
path: "/settings",
|
|
16
|
-
handler: "settings.setSettings",
|
|
17
|
-
config: {
|
|
18
|
-
policies: [],
|
|
19
|
-
auth: false,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
};
|
package/server/services/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function getPluginStore() {
|
|
4
|
-
return strapi.store({
|
|
5
|
-
environment: "",
|
|
6
|
-
type: "plugin",
|
|
7
|
-
name: "tinymce",
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
async function createDefaultConfig() {
|
|
11
|
-
const pluginStore = getPluginStore();
|
|
12
|
-
const value = {
|
|
13
|
-
apiKey: "",
|
|
14
|
-
};
|
|
15
|
-
await pluginStore.set({ key: "settings", value });
|
|
16
|
-
return pluginStore.get({ key: "settings" });
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = () => {
|
|
20
|
-
return {
|
|
21
|
-
async getSettings() {
|
|
22
|
-
const pluginStore = getPluginStore();
|
|
23
|
-
let config = await pluginStore.get({ key: "settings" });
|
|
24
|
-
if (!config) {
|
|
25
|
-
config = await createDefaultConfig();
|
|
26
|
-
}
|
|
27
|
-
return config;
|
|
28
|
-
},
|
|
29
|
-
async setSettings(settings) {
|
|
30
|
-
const value = settings;
|
|
31
|
-
const pluginStore = getPluginStore();
|
|
32
|
-
await pluginStore.set({ key: "settings", value });
|
|
33
|
-
return pluginStore.get({ key: "settings" });
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
};
|
package/strapi-admin.js
DELETED
package/strapi-server.js
DELETED