@kookaat/strapi-plugin-tinymce 2.0.0 → 2.0.2

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.
Files changed (72) hide show
  1. package/README.md +52 -84
  2. package/dist/_chunks/Settings-DDGJdgMB.js +2606 -0
  3. package/dist/_chunks/Settings-DDGJdgMB.js.map +1 -0
  4. package/dist/_chunks/Settings-omg6NZQb.mjs +2606 -0
  5. package/dist/_chunks/Settings-omg6NZQb.mjs.map +1 -0
  6. package/dist/_chunks/Wysiwyg-B5f8_FHm.js +130 -0
  7. package/dist/_chunks/Wysiwyg-B5f8_FHm.js.map +1 -0
  8. package/dist/_chunks/Wysiwyg-BJxwboVA.mjs +130 -0
  9. package/dist/_chunks/Wysiwyg-BJxwboVA.mjs.map +1 -0
  10. package/dist/_chunks/cs-4ldo0hfI.js +15 -0
  11. package/dist/_chunks/cs-4ldo0hfI.js.map +1 -0
  12. package/dist/_chunks/cs-D-gwbfRH.mjs +15 -0
  13. package/dist/_chunks/cs-D-gwbfRH.mjs.map +1 -0
  14. package/dist/_chunks/en-BILT6xrd.mjs +15 -0
  15. package/dist/_chunks/en-BILT6xrd.mjs.map +1 -0
  16. package/dist/_chunks/en-usAdfkfH.js +15 -0
  17. package/dist/_chunks/en-usAdfkfH.js.map +1 -0
  18. package/dist/_chunks/index-BKKEJ9ZG.js +243 -0
  19. package/dist/_chunks/index-BKKEJ9ZG.js.map +1 -0
  20. package/dist/_chunks/index-C2RU5wAS.mjs +242 -0
  21. package/dist/_chunks/index-C2RU5wAS.mjs.map +1 -0
  22. package/dist/_chunks/sk-BcD0BjAU.js +15 -0
  23. package/dist/_chunks/sk-BcD0BjAU.js.map +1 -0
  24. package/dist/_chunks/sk-D3I3bI3P.mjs +15 -0
  25. package/dist/_chunks/sk-D3I3bI3P.mjs.map +1 -0
  26. package/dist/admin/index.js +4 -0
  27. package/dist/admin/index.js.map +1 -0
  28. package/dist/admin/index.mjs +5 -0
  29. package/dist/admin/index.mjs.map +1 -0
  30. package/dist/server/index.js +293 -0
  31. package/dist/server/index.js.map +1 -0
  32. package/dist/server/index.mjs +294 -0
  33. package/dist/server/index.mjs.map +1 -0
  34. package/package.json +65 -20
  35. package/.github/stale.yml +0 -17
  36. package/admin/src/api/settings.js +0 -14
  37. package/admin/src/components/Editor/index.js +0 -60
  38. package/admin/src/components/Initializer/index.js +0 -26
  39. package/admin/src/components/MediaLib/index.js +0 -43
  40. package/admin/src/components/PluginIcon/index.js +0 -12
  41. package/admin/src/components/Wysiwyg/index.js +0 -122
  42. package/admin/src/index.js +0 -78
  43. package/admin/src/pages/App/index.js +0 -25
  44. package/admin/src/pages/HomePage/index.js +0 -7
  45. package/admin/src/pages/Settings/index.js +0 -134
  46. package/admin/src/permissions.js +0 -11
  47. package/admin/src/pluginId.js +0 -5
  48. package/admin/src/translations/cs.json +0 -10
  49. package/admin/src/translations/en.json +0 -10
  50. package/admin/src/translations/sk.json +0 -10
  51. package/admin/src/utils/axiosInstance.js +0 -40
  52. package/admin/src/utils/get-trad.js +0 -5
  53. package/admin/src/utils/index.js +0 -2
  54. package/server/bootstrap.js +0 -19
  55. package/server/config/index.js +0 -6
  56. package/server/content-types/index.js +0 -3
  57. package/server/controllers/config.js +0 -12
  58. package/server/controllers/index.js +0 -9
  59. package/server/controllers/settings.js +0 -30
  60. package/server/destroy.js +0 -5
  61. package/server/index.js +0 -25
  62. package/server/middlewares/index.js +0 -3
  63. package/server/policies/index.js +0 -3
  64. package/server/register.js +0 -5
  65. package/server/routes/config.js +0 -13
  66. package/server/routes/index.js +0 -7
  67. package/server/routes/settings.js +0 -23
  68. package/server/services/config.js +0 -9
  69. package/server/services/index.js +0 -9
  70. package/server/services/settings.js +0 -36
  71. package/strapi-admin.js +0 -3
  72. package/strapi-server.js +0 -3
@@ -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;
@@ -1,78 +0,0 @@
1
- import pluginPkg from "../../package.json";
2
- import pluginId from "./pluginId";
3
- import Initializer from "./components/Initializer";
4
- import Wysiwyg from "./components/Wysiwyg";
5
- import { getTrad } from "./utils";
6
- import pluginPermissions from "./permissions";
7
-
8
- const prefixPluginTranslations = (trad, pluginId) => {
9
- if (!pluginId) {
10
- throw new TypeError("pluginId can't be empty");
11
- }
12
- return Object.keys(trad).reduce((acc, current) => {
13
- acc[`${pluginId}.${current}`] = trad[current];
14
- return acc;
15
- }, {});
16
- };
17
-
18
- const name = pluginPkg.strapi.name;
19
-
20
- export default {
21
- register(app) {
22
- app.addFields({ type: "wysiwyg", Component: Wysiwyg });
23
- app.createSettingSection(
24
- {
25
- id: pluginId,
26
- intlLabel: {
27
- id: `${pluginId}.plugin.name`,
28
- defaultMessage: "TinyMCE",
29
- },
30
- },
31
- [
32
- {
33
- intlLabel: {
34
- id: getTrad("settings.page-title"),
35
- defaultMessage: "Configuration",
36
- },
37
- id: "settings",
38
- to: `/settings/${pluginId}`,
39
- Component: async () => {
40
- return import("./pages/Settings");
41
- },
42
- permissions: pluginPermissions["settings"],
43
- },
44
- ]
45
- );
46
- app.registerPlugin({
47
- id: pluginId,
48
- initializer: Initializer,
49
- isReady: false,
50
- name,
51
- });
52
- },
53
-
54
- bootstrap(app) {},
55
- async registerTrads({ locales }) {
56
- const importedTrads = await Promise.all(
57
- locales.map((locale) => {
58
- return import(
59
- /* webpackChunkName: "translation-[request]" */ `./translations/${locale}.json`
60
- )
61
- .then(({ default: data }) => {
62
- return {
63
- data: prefixPluginTranslations(data, pluginId),
64
- locale,
65
- };
66
- })
67
- .catch(() => {
68
- return {
69
- data: {},
70
- locale,
71
- };
72
- });
73
- })
74
- );
75
-
76
- return Promise.resolve(importedTrads);
77
- },
78
- };
@@ -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,7 +0,0 @@
1
- import React, { memo } from "react";
2
-
3
- const HomePage = () => {
4
- return <></>;
5
- };
6
-
7
- export default memo(HomePage);
@@ -1,134 +0,0 @@
1
- import React, { useEffect, useState } from "react";
2
- import { useNotification, Page } from "@strapi/strapi/admin";
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
- <Page.Loading />
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;
@@ -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
-
@@ -1,5 +0,0 @@
1
- const pluginPkg = require("../../package.json");
2
-
3
- const pluginId = pluginPkg.name.replace(/^(@kookaat\/strapi-)plugin-/i, "");
4
-
5
- module.exports = pluginId;
@@ -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;
@@ -1,5 +0,0 @@
1
- import pluginId from '../pluginId';
2
-
3
- const getTrad = id => `${pluginId}.${id}`;
4
-
5
- export default getTrad;
@@ -1,2 +0,0 @@
1
- export { default as getTrad } from "./get-trad";
2
- export { default as axiosInstance } from "./axiosInstance";
@@ -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
- };
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {
4
- default: {},
5
- validator() {},
6
- };
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {};
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- getConfig: async (ctx) => {
5
- const { configKey } = ctx.params;
6
- const config = await strapi
7
- .plugin("tinymce")
8
- .service("config")
9
- .getConfig(configKey);
10
- ctx.send(config);
11
- },
12
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- const config = require("./config");
4
- const settings = require("./settings");
5
-
6
- module.exports = {
7
- config,
8
- settings,
9
- };
@@ -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
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = ({ strapi }) => {
4
- // destroy phase
5
- };
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
- };
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {};
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = {};
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = ({ strapi }) => {
4
- // registeration phase
5
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- type: "admin",
5
- routes: [
6
- {
7
- method: "GET",
8
- path: "/config/:configKey",
9
- handler: "config.getConfig",
10
- config: { policies: [] },
11
- },
12
- ],
13
- };
@@ -1,7 +0,0 @@
1
- const config = require("./config");
2
- const settings = require("./settings");
3
-
4
- module.exports = {
5
- config,
6
- settings,
7
- };
@@ -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
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = ({ strapi }) => {
4
- return {
5
- getConfig(key = "editor") {
6
- return strapi.plugin("tinymce").config(key) ?? {};
7
- },
8
- };
9
- };