magic-editor-x 2.1.0 → 2.2.0
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/CHANGELOG.md +53 -0
- package/README.md +215 -89
- package/bin/magic-editor-x.mjs +190 -0
- package/dist/admin/{ConfigurationPage-CK2AbfGW.mjs → ConfigurationPage-3Dir3dAf.mjs} +3 -3
- package/dist/admin/{ConfigurationPage-CzsT_dO_.js → ConfigurationPage-YvnPnna6.js} +3 -3
- package/dist/admin/{CustomBlocksPage-CvLrsBds.js → CustomBlocksPage-BiiL2ORG.js} +4 -4
- package/dist/admin/{CustomBlocksPage-B2A8S5MV.mjs → CustomBlocksPage-CR2BaP9O.mjs} +4 -4
- package/dist/admin/{EditorField-7YCdXx-v.mjs → EditorField-B8pyAxPE.mjs} +5384 -278
- package/dist/admin/{EditorField-BdBCW15Q.js → EditorField-Diq1j8kc.js} +5378 -272
- package/dist/admin/{api-CmccMxlN.js → api-Dsq53giv.js} +1 -0
- package/dist/admin/{api-D5CAH0nh.mjs → api-RZ0Fz0BD.mjs} +1 -0
- package/dist/admin/de-62Vxb2iw.js +250 -0
- package/dist/admin/de-BVvwSYYO.mjs +250 -0
- package/dist/admin/de-BmmLBJli.mjs +41 -0
- package/dist/admin/{de-CkUYGb7U.js → de-BteRx2iA.js} +7 -1
- package/dist/admin/{de-rRIutpYJ.mjs → de-CFX5atOk.mjs} +7 -1
- package/dist/admin/de-DaJwN6nk.js +41 -0
- package/dist/admin/en-Cg2Ak5Cr.mjs +250 -0
- package/dist/admin/en-Cn78RZs-.js +41 -0
- package/dist/admin/{en-DulOcmXb.js → en-CyjAcccB.js} +7 -1
- package/dist/admin/en-D7mZWLGp.mjs +41 -0
- package/dist/admin/en-VlkaIzrM.js +250 -0
- package/dist/admin/{en-Puup8TFi.mjs → en-ea0tfA5i.mjs} +7 -1
- package/dist/admin/es-BT9oAcHf.js +250 -0
- package/dist/admin/es-BmGtLkJD.js +41 -0
- package/dist/admin/{es-BoQZC86B.js → es-C8GZFGjv.js} +7 -1
- package/dist/admin/es-C9-cXdb6.mjs +250 -0
- package/dist/admin/{es-257SSB7f.mjs → es-CEi_ycX8.mjs} +7 -1
- package/dist/admin/es-joykG5I9.mjs +41 -0
- package/dist/admin/{fr-C5rSdKU4.mjs → fr-BAMSvQbR.mjs} +7 -1
- package/dist/admin/fr-CrzxGe5e.mjs +41 -0
- package/dist/admin/fr-Ct_uPqxV.js +41 -0
- package/dist/admin/fr-D6KJqPWi.js +250 -0
- package/dist/admin/fr-DpU_qiXR.mjs +250 -0
- package/dist/admin/{fr-HxFcPpv4.js → fr-oRCJNdeJ.js} +7 -1
- package/dist/admin/index-C-lyON1B.mjs +303 -0
- package/dist/admin/index-iA0lued_.js +302 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/pt-BOrl6x-r.js +250 -0
- package/dist/admin/{pt-D6UuEtPy.mjs → pt-CQrfqsCN.mjs} +7 -1
- package/dist/admin/pt-Ga-4Hsv0.mjs +41 -0
- package/dist/admin/pt-chN2jrXl.js +41 -0
- package/dist/admin/pt-jUqOR7Xh.mjs +250 -0
- package/dist/admin/{pt-Cjn2Sc9k.js → pt-tUeJ2Ywd.js} +7 -1
- package/dist/admin/{sanitize-DP5aeU7V.js → sanitize-Cb4jvBhj.js} +42 -11
- package/dist/admin/{sanitize-jjCot5PM.mjs → sanitize-ClkX823p.mjs} +45 -14
- package/dist/admin/{useT-91ruePzq.js → useT-BWZ_-Hel.js} +1 -1
- package/dist/admin/{useT-vgY88N_H.mjs → useT-pvHmgBFj.mjs} +1 -1
- package/dist/render/index.d.mts +75 -0
- package/dist/render/index.d.ts +75 -0
- package/dist/render/index.js +1420 -0
- package/dist/render/index.mjs +1398 -0
- package/dist/server/index.js +8081 -348
- package/dist/server/index.mjs +8084 -351
- package/package.json +21 -4
- package/schema/magic-editor-x.schema.json +967 -0
- package/types/index.d.ts +211 -0
- package/types/render.d.ts +75 -0
- package/dist/admin/de-BHPyA2S-.mjs +0 -103
- package/dist/admin/de-DBR893G4.js +0 -13
- package/dist/admin/de-RMs-_SCK.js +0 -103
- package/dist/admin/de-fBFh09Wl.mjs +0 -13
- package/dist/admin/en-BluCStLw.mjs +0 -103
- package/dist/admin/en-C81faOHP.js +0 -103
- package/dist/admin/en-D9Nfccux.mjs +0 -13
- package/dist/admin/en-gueRT44P.js +0 -13
- package/dist/admin/es-B0Zy8DVg.mjs +0 -13
- package/dist/admin/es-CQRI2Prp.mjs +0 -103
- package/dist/admin/es-D1QzY0JW.js +0 -103
- package/dist/admin/es-DRGs7meF.js +0 -13
- package/dist/admin/fr-B8rdLAIL.js +0 -13
- package/dist/admin/fr-Di3R6gOX.mjs +0 -103
- package/dist/admin/fr-R3_MbzT5.js +0 -103
- package/dist/admin/fr-oiUb2bb_.mjs +0 -13
- package/dist/admin/index-0_b1iroK.mjs +0 -156
- package/dist/admin/index-6SZLli70.js +0 -155
- package/dist/admin/pt-B3Jce6uT.mjs +0 -13
- package/dist/admin/pt-BCW1u_Hp.js +0 -103
- package/dist/admin/pt-BiWuSBcH.js +0 -13
- package/dist/admin/pt-Cr9AL408.mjs +0 -103
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Feather } from "@strapi/icons";
|
|
3
|
+
const PLUGIN_ID = "magic-editor-x";
|
|
4
|
+
const PluginIcon = () => /* @__PURE__ */ jsx(Feather, { "aria-hidden": true });
|
|
5
|
+
const action = (uid) => [{ action: `plugin::magic-editor-x.${uid}`, subject: null }];
|
|
6
|
+
const PERMISSIONS = {
|
|
7
|
+
customBlocksManage: action("custom-blocks.manage"),
|
|
8
|
+
settingsRead: action("settings.read"),
|
|
9
|
+
settingsUpdate: action("settings.update")
|
|
10
|
+
};
|
|
11
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
12
|
+
const LOADERS = {
|
|
13
|
+
en: () => [
|
|
14
|
+
import("./en-D7mZWLGp.mjs"),
|
|
15
|
+
import("./en-Cg2Ak5Cr.mjs"),
|
|
16
|
+
import("./en-ea0tfA5i.mjs"),
|
|
17
|
+
import("./en-B_HltUxZ.mjs")
|
|
18
|
+
],
|
|
19
|
+
de: () => [
|
|
20
|
+
import("./de-BmmLBJli.mjs"),
|
|
21
|
+
import("./de-BVvwSYYO.mjs"),
|
|
22
|
+
import("./de-CFX5atOk.mjs"),
|
|
23
|
+
import("./de-Bt6pYIWi.mjs")
|
|
24
|
+
],
|
|
25
|
+
fr: () => [
|
|
26
|
+
import("./fr-CrzxGe5e.mjs"),
|
|
27
|
+
import("./fr-DpU_qiXR.mjs"),
|
|
28
|
+
import("./fr-BAMSvQbR.mjs"),
|
|
29
|
+
import("./fr-5djKfQ3s.mjs")
|
|
30
|
+
],
|
|
31
|
+
es: () => [
|
|
32
|
+
import("./es-joykG5I9.mjs"),
|
|
33
|
+
import("./es-C9-cXdb6.mjs"),
|
|
34
|
+
import("./es-CEi_ycX8.mjs"),
|
|
35
|
+
import("./es-CrhwOq-5.mjs")
|
|
36
|
+
],
|
|
37
|
+
pt: () => [
|
|
38
|
+
import("./pt-Ga-4Hsv0.mjs"),
|
|
39
|
+
import("./pt-jUqOR7Xh.mjs"),
|
|
40
|
+
import("./pt-CQrfqsCN.mjs"),
|
|
41
|
+
import("./pt-BdnY2Cth.mjs")
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
const PRESET_OPTIONS = [
|
|
45
|
+
{ value: "full", label: ["field.options.preset.full", "Full: every block and formatting"] },
|
|
46
|
+
{ value: "article", label: ["field.options.preset.article", "Article: long-form text without raw HTML"] },
|
|
47
|
+
{ value: "basic", label: ["field.options.preset.basic", "Basic: headings 2-3, lists, quotes, images"] },
|
|
48
|
+
{
|
|
49
|
+
value: "minimal",
|
|
50
|
+
label: ["field.options.preset.minimal", "Minimal: paragraphs, lists, bold, italic, links"]
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const LINK_OPTIONS = [
|
|
54
|
+
{ value: "all", label: ["field.options.linkTargets.all", "Entries and web addresses"] },
|
|
55
|
+
{ value: "internal", label: ["field.options.linkTargets.internal", "Only entries of this site"] },
|
|
56
|
+
{ value: "external", label: ["field.options.linkTargets.external", "Only web addresses"] },
|
|
57
|
+
{ value: "none", label: ["field.options.linkTargets.none", "No links"] }
|
|
58
|
+
];
|
|
59
|
+
const loadMessages = async (locale) => {
|
|
60
|
+
const loader = LOADERS[locale] || LOADERS[locale.split("-")[0]] || LOADERS.en;
|
|
61
|
+
const modules = await Promise.all(loader());
|
|
62
|
+
const merged = Object.assign({}, ...modules.map((module) => module.default || module));
|
|
63
|
+
return Object.fromEntries(Object.entries(merged).map(([key, value]) => [getTranslation(key), value]));
|
|
64
|
+
};
|
|
65
|
+
const index = {
|
|
66
|
+
/**
|
|
67
|
+
* Registers the plugin, the custom field and the settings links.
|
|
68
|
+
* @param {object} app - Strapi admin app.
|
|
69
|
+
*/
|
|
70
|
+
register(app) {
|
|
71
|
+
app.registerPlugin({ id: PLUGIN_ID, name: PLUGIN_ID });
|
|
72
|
+
app.customFields.register({
|
|
73
|
+
name: "richtext",
|
|
74
|
+
pluginId: PLUGIN_ID,
|
|
75
|
+
type: "json",
|
|
76
|
+
intlLabel: { id: getTranslation("field.label"), defaultMessage: "Magic Editor X" },
|
|
77
|
+
intlDescription: {
|
|
78
|
+
id: getTranslation("field.description"),
|
|
79
|
+
defaultMessage: "Block editor with media, embeds, custom blocks, history and live collaboration"
|
|
80
|
+
},
|
|
81
|
+
icon: PluginIcon,
|
|
82
|
+
components: {
|
|
83
|
+
Input: () => import("./EditorField-B8pyAxPE.mjs")
|
|
84
|
+
},
|
|
85
|
+
options: {
|
|
86
|
+
base: [
|
|
87
|
+
{
|
|
88
|
+
sectionTitle: { id: getTranslation("field.options.section"), defaultMessage: "Editor" },
|
|
89
|
+
items: [
|
|
90
|
+
{
|
|
91
|
+
intlLabel: {
|
|
92
|
+
id: getTranslation("field.options.placeholder.label"),
|
|
93
|
+
defaultMessage: "Placeholder"
|
|
94
|
+
},
|
|
95
|
+
description: {
|
|
96
|
+
id: getTranslation("field.options.placeholder.description"),
|
|
97
|
+
defaultMessage: "Text shown while the editor is empty"
|
|
98
|
+
},
|
|
99
|
+
name: "options.placeholder",
|
|
100
|
+
type: "text"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
intlLabel: { id: getTranslation("field.options.preset.label"), defaultMessage: "Preset" },
|
|
104
|
+
description: {
|
|
105
|
+
id: getTranslation("field.options.preset.description"),
|
|
106
|
+
defaultMessage: "Which blocks and formatting editors can use in this field. Enforced when saving."
|
|
107
|
+
},
|
|
108
|
+
name: "options.preset",
|
|
109
|
+
type: "select",
|
|
110
|
+
options: PRESET_OPTIONS.map(({ value, label: [id, defaultMessage] }) => ({
|
|
111
|
+
key: value,
|
|
112
|
+
value,
|
|
113
|
+
metadatas: { intlLabel: { id: getTranslation(id), defaultMessage } }
|
|
114
|
+
}))
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
intlLabel: {
|
|
118
|
+
id: getTranslation("field.options.linkTargets.label"),
|
|
119
|
+
defaultMessage: "Allowed links"
|
|
120
|
+
},
|
|
121
|
+
description: {
|
|
122
|
+
id: getTranslation("field.options.linkTargets.description"),
|
|
123
|
+
defaultMessage: "Links to entries of this site, to web addresses, both or none"
|
|
124
|
+
},
|
|
125
|
+
name: "options.linkTargets",
|
|
126
|
+
type: "select",
|
|
127
|
+
options: LINK_OPTIONS.map(({ value, label: [id, defaultMessage] }) => ({
|
|
128
|
+
key: value,
|
|
129
|
+
value,
|
|
130
|
+
metadatas: { intlLabel: { id: getTranslation(id), defaultMessage } }
|
|
131
|
+
}))
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
intlLabel: {
|
|
135
|
+
id: getTranslation("field.options.requireAlt.label"),
|
|
136
|
+
defaultMessage: "Require alternative text for images"
|
|
137
|
+
},
|
|
138
|
+
description: {
|
|
139
|
+
id: getTranslation("field.options.requireAlt.description"),
|
|
140
|
+
defaultMessage: "Images need a text description or must be marked as decorative"
|
|
141
|
+
},
|
|
142
|
+
name: "options.requireAlt",
|
|
143
|
+
type: "checkbox"
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
advanced: [
|
|
149
|
+
{
|
|
150
|
+
sectionTitle: {
|
|
151
|
+
id: getTranslation("field.options.content"),
|
|
152
|
+
defaultMessage: "Allowed content and limits"
|
|
153
|
+
},
|
|
154
|
+
items: [
|
|
155
|
+
{
|
|
156
|
+
intlLabel: {
|
|
157
|
+
id: getTranslation("field.options.allowedBlocks.label"),
|
|
158
|
+
defaultMessage: "Allowed blocks"
|
|
159
|
+
},
|
|
160
|
+
description: {
|
|
161
|
+
id: getTranslation("field.options.allowedBlocks.description"),
|
|
162
|
+
defaultMessage: "Comma-separated block names that replace the preset list, for example: paragraph, header, list, image, myCustomBlock"
|
|
163
|
+
},
|
|
164
|
+
name: "options.allowedBlocks",
|
|
165
|
+
type: "text"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
intlLabel: {
|
|
169
|
+
id: getTranslation("field.options.headingLevels.label"),
|
|
170
|
+
defaultMessage: "Heading levels"
|
|
171
|
+
},
|
|
172
|
+
description: {
|
|
173
|
+
id: getTranslation("field.options.headingLevels.description"),
|
|
174
|
+
defaultMessage: "For example 2-4 or 2,3. Empty uses the preset."
|
|
175
|
+
},
|
|
176
|
+
name: "options.headingLevels",
|
|
177
|
+
type: "text"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
intlLabel: {
|
|
181
|
+
id: getTranslation("field.options.maxBlocks.label"),
|
|
182
|
+
defaultMessage: "Maximum number of blocks"
|
|
183
|
+
},
|
|
184
|
+
description: {
|
|
185
|
+
id: getTranslation("field.options.maxBlocks.description"),
|
|
186
|
+
defaultMessage: "Empty or 0 means no limit"
|
|
187
|
+
},
|
|
188
|
+
name: "options.maxBlocks",
|
|
189
|
+
type: "number"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
intlLabel: {
|
|
193
|
+
id: getTranslation("field.options.maxCharacters.label"),
|
|
194
|
+
defaultMessage: "Maximum number of characters"
|
|
195
|
+
},
|
|
196
|
+
description: {
|
|
197
|
+
id: getTranslation("field.options.maxCharacters.description"),
|
|
198
|
+
defaultMessage: "Visible text, counted like the editor toolbar. Empty or 0 means no limit."
|
|
199
|
+
},
|
|
200
|
+
name: "options.maxCharacters",
|
|
201
|
+
type: "number"
|
|
202
|
+
}
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
sectionTitle: { id: getTranslation("field.options.features"), defaultMessage: "Features" },
|
|
207
|
+
items: [
|
|
208
|
+
{
|
|
209
|
+
intlLabel: {
|
|
210
|
+
id: getTranslation("field.options.disableAi.label"),
|
|
211
|
+
defaultMessage: "Turn off the AI assistant for this field"
|
|
212
|
+
},
|
|
213
|
+
name: "options.disableAi",
|
|
214
|
+
type: "checkbox"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
intlLabel: {
|
|
218
|
+
id: getTranslation("field.options.disableCollaboration.label"),
|
|
219
|
+
defaultMessage: "Turn off live collaboration for this field"
|
|
220
|
+
},
|
|
221
|
+
name: "options.disableCollaboration",
|
|
222
|
+
type: "checkbox"
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
intlLabel: {
|
|
226
|
+
id: getTranslation("field.options.publishGuard.label"),
|
|
227
|
+
defaultMessage: "Block publishing while quality checks report errors"
|
|
228
|
+
},
|
|
229
|
+
description: {
|
|
230
|
+
id: getTranslation("field.options.publishGuard.description"),
|
|
231
|
+
defaultMessage: "Errors are missing alternative texts (when required) and empty links"
|
|
232
|
+
},
|
|
233
|
+
name: "options.publishGuard",
|
|
234
|
+
type: "checkbox"
|
|
235
|
+
}
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
sectionTitle: { id: getTranslation("field.options.advanced"), defaultMessage: "Layout" },
|
|
240
|
+
items: [
|
|
241
|
+
{
|
|
242
|
+
intlLabel: {
|
|
243
|
+
id: getTranslation("field.options.minHeight.label"),
|
|
244
|
+
defaultMessage: "Minimum height (px)"
|
|
245
|
+
},
|
|
246
|
+
description: {
|
|
247
|
+
id: getTranslation("field.options.minHeight.description"),
|
|
248
|
+
defaultMessage: "Height of the empty editor, between 120 and 2000 pixels"
|
|
249
|
+
},
|
|
250
|
+
name: "options.minHeight",
|
|
251
|
+
type: "number"
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
app.addSettingsLink(
|
|
259
|
+
{
|
|
260
|
+
id: PLUGIN_ID,
|
|
261
|
+
intlLabel: { id: getTranslation("settings.section"), defaultMessage: "Magic Editor X" }
|
|
262
|
+
},
|
|
263
|
+
[
|
|
264
|
+
{
|
|
265
|
+
id: `${PLUGIN_ID}-configuration`,
|
|
266
|
+
intlLabel: { id: getTranslation("settings.link.configuration"), defaultMessage: "Configuration" },
|
|
267
|
+
to: `${PLUGIN_ID}/configuration`,
|
|
268
|
+
permissions: PERMISSIONS.settingsRead,
|
|
269
|
+
Component: () => import("./ConfigurationPage-3Dir3dAf.mjs")
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: `${PLUGIN_ID}-custom-blocks`,
|
|
273
|
+
intlLabel: { id: getTranslation("settings.link.customBlocks"), defaultMessage: "Custom blocks" },
|
|
274
|
+
to: `${PLUGIN_ID}/custom-blocks`,
|
|
275
|
+
permissions: PERMISSIONS.customBlocksManage,
|
|
276
|
+
Component: () => import("./CustomBlocksPage-CR2BaP9O.mjs")
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
);
|
|
280
|
+
},
|
|
281
|
+
bootstrap() {
|
|
282
|
+
},
|
|
283
|
+
/**
|
|
284
|
+
* @param {{ locales: string[] }} options - Admin locales.
|
|
285
|
+
* @returns {Promise<Array<{ data: object, locale: string }>>} Translations.
|
|
286
|
+
*/
|
|
287
|
+
async registerTrads({ locales }) {
|
|
288
|
+
return Promise.all(
|
|
289
|
+
locales.map(async (locale) => {
|
|
290
|
+
try {
|
|
291
|
+
return { data: await loadMessages(locale), locale };
|
|
292
|
+
} catch {
|
|
293
|
+
return { data: {}, locale };
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
export {
|
|
300
|
+
PERMISSIONS as P,
|
|
301
|
+
getTranslation as g,
|
|
302
|
+
index as i
|
|
303
|
+
};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const icons = require("@strapi/icons");
|
|
4
|
+
const PLUGIN_ID = "magic-editor-x";
|
|
5
|
+
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Feather, { "aria-hidden": true });
|
|
6
|
+
const action = (uid) => [{ action: `plugin::magic-editor-x.${uid}`, subject: null }];
|
|
7
|
+
const PERMISSIONS = {
|
|
8
|
+
customBlocksManage: action("custom-blocks.manage"),
|
|
9
|
+
settingsRead: action("settings.read"),
|
|
10
|
+
settingsUpdate: action("settings.update")
|
|
11
|
+
};
|
|
12
|
+
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
13
|
+
const LOADERS = {
|
|
14
|
+
en: () => [
|
|
15
|
+
Promise.resolve().then(() => require("./en-Cn78RZs-.js")),
|
|
16
|
+
Promise.resolve().then(() => require("./en-VlkaIzrM.js")),
|
|
17
|
+
Promise.resolve().then(() => require("./en-CyjAcccB.js")),
|
|
18
|
+
Promise.resolve().then(() => require("./en-BX362fTp.js"))
|
|
19
|
+
],
|
|
20
|
+
de: () => [
|
|
21
|
+
Promise.resolve().then(() => require("./de-DaJwN6nk.js")),
|
|
22
|
+
Promise.resolve().then(() => require("./de-62Vxb2iw.js")),
|
|
23
|
+
Promise.resolve().then(() => require("./de-BteRx2iA.js")),
|
|
24
|
+
Promise.resolve().then(() => require("./de-CVbi685U.js"))
|
|
25
|
+
],
|
|
26
|
+
fr: () => [
|
|
27
|
+
Promise.resolve().then(() => require("./fr-Ct_uPqxV.js")),
|
|
28
|
+
Promise.resolve().then(() => require("./fr-D6KJqPWi.js")),
|
|
29
|
+
Promise.resolve().then(() => require("./fr-oRCJNdeJ.js")),
|
|
30
|
+
Promise.resolve().then(() => require("./fr-B3SL0TBV.js"))
|
|
31
|
+
],
|
|
32
|
+
es: () => [
|
|
33
|
+
Promise.resolve().then(() => require("./es-BmGtLkJD.js")),
|
|
34
|
+
Promise.resolve().then(() => require("./es-BT9oAcHf.js")),
|
|
35
|
+
Promise.resolve().then(() => require("./es-C8GZFGjv.js")),
|
|
36
|
+
Promise.resolve().then(() => require("./es-CHHEZi44.js"))
|
|
37
|
+
],
|
|
38
|
+
pt: () => [
|
|
39
|
+
Promise.resolve().then(() => require("./pt-chN2jrXl.js")),
|
|
40
|
+
Promise.resolve().then(() => require("./pt-BOrl6x-r.js")),
|
|
41
|
+
Promise.resolve().then(() => require("./pt-tUeJ2Ywd.js")),
|
|
42
|
+
Promise.resolve().then(() => require("./pt-EVwCuBUK.js"))
|
|
43
|
+
]
|
|
44
|
+
};
|
|
45
|
+
const PRESET_OPTIONS = [
|
|
46
|
+
{ value: "full", label: ["field.options.preset.full", "Full: every block and formatting"] },
|
|
47
|
+
{ value: "article", label: ["field.options.preset.article", "Article: long-form text without raw HTML"] },
|
|
48
|
+
{ value: "basic", label: ["field.options.preset.basic", "Basic: headings 2-3, lists, quotes, images"] },
|
|
49
|
+
{
|
|
50
|
+
value: "minimal",
|
|
51
|
+
label: ["field.options.preset.minimal", "Minimal: paragraphs, lists, bold, italic, links"]
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
const LINK_OPTIONS = [
|
|
55
|
+
{ value: "all", label: ["field.options.linkTargets.all", "Entries and web addresses"] },
|
|
56
|
+
{ value: "internal", label: ["field.options.linkTargets.internal", "Only entries of this site"] },
|
|
57
|
+
{ value: "external", label: ["field.options.linkTargets.external", "Only web addresses"] },
|
|
58
|
+
{ value: "none", label: ["field.options.linkTargets.none", "No links"] }
|
|
59
|
+
];
|
|
60
|
+
const loadMessages = async (locale) => {
|
|
61
|
+
const loader = LOADERS[locale] || LOADERS[locale.split("-")[0]] || LOADERS.en;
|
|
62
|
+
const modules = await Promise.all(loader());
|
|
63
|
+
const merged = Object.assign({}, ...modules.map((module2) => module2.default || module2));
|
|
64
|
+
return Object.fromEntries(Object.entries(merged).map(([key, value]) => [getTranslation(key), value]));
|
|
65
|
+
};
|
|
66
|
+
const index = {
|
|
67
|
+
/**
|
|
68
|
+
* Registers the plugin, the custom field and the settings links.
|
|
69
|
+
* @param {object} app - Strapi admin app.
|
|
70
|
+
*/
|
|
71
|
+
register(app) {
|
|
72
|
+
app.registerPlugin({ id: PLUGIN_ID, name: PLUGIN_ID });
|
|
73
|
+
app.customFields.register({
|
|
74
|
+
name: "richtext",
|
|
75
|
+
pluginId: PLUGIN_ID,
|
|
76
|
+
type: "json",
|
|
77
|
+
intlLabel: { id: getTranslation("field.label"), defaultMessage: "Magic Editor X" },
|
|
78
|
+
intlDescription: {
|
|
79
|
+
id: getTranslation("field.description"),
|
|
80
|
+
defaultMessage: "Block editor with media, embeds, custom blocks, history and live collaboration"
|
|
81
|
+
},
|
|
82
|
+
icon: PluginIcon,
|
|
83
|
+
components: {
|
|
84
|
+
Input: () => Promise.resolve().then(() => require("./EditorField-Diq1j8kc.js"))
|
|
85
|
+
},
|
|
86
|
+
options: {
|
|
87
|
+
base: [
|
|
88
|
+
{
|
|
89
|
+
sectionTitle: { id: getTranslation("field.options.section"), defaultMessage: "Editor" },
|
|
90
|
+
items: [
|
|
91
|
+
{
|
|
92
|
+
intlLabel: {
|
|
93
|
+
id: getTranslation("field.options.placeholder.label"),
|
|
94
|
+
defaultMessage: "Placeholder"
|
|
95
|
+
},
|
|
96
|
+
description: {
|
|
97
|
+
id: getTranslation("field.options.placeholder.description"),
|
|
98
|
+
defaultMessage: "Text shown while the editor is empty"
|
|
99
|
+
},
|
|
100
|
+
name: "options.placeholder",
|
|
101
|
+
type: "text"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
intlLabel: { id: getTranslation("field.options.preset.label"), defaultMessage: "Preset" },
|
|
105
|
+
description: {
|
|
106
|
+
id: getTranslation("field.options.preset.description"),
|
|
107
|
+
defaultMessage: "Which blocks and formatting editors can use in this field. Enforced when saving."
|
|
108
|
+
},
|
|
109
|
+
name: "options.preset",
|
|
110
|
+
type: "select",
|
|
111
|
+
options: PRESET_OPTIONS.map(({ value, label: [id, defaultMessage] }) => ({
|
|
112
|
+
key: value,
|
|
113
|
+
value,
|
|
114
|
+
metadatas: { intlLabel: { id: getTranslation(id), defaultMessage } }
|
|
115
|
+
}))
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
intlLabel: {
|
|
119
|
+
id: getTranslation("field.options.linkTargets.label"),
|
|
120
|
+
defaultMessage: "Allowed links"
|
|
121
|
+
},
|
|
122
|
+
description: {
|
|
123
|
+
id: getTranslation("field.options.linkTargets.description"),
|
|
124
|
+
defaultMessage: "Links to entries of this site, to web addresses, both or none"
|
|
125
|
+
},
|
|
126
|
+
name: "options.linkTargets",
|
|
127
|
+
type: "select",
|
|
128
|
+
options: LINK_OPTIONS.map(({ value, label: [id, defaultMessage] }) => ({
|
|
129
|
+
key: value,
|
|
130
|
+
value,
|
|
131
|
+
metadatas: { intlLabel: { id: getTranslation(id), defaultMessage } }
|
|
132
|
+
}))
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
intlLabel: {
|
|
136
|
+
id: getTranslation("field.options.requireAlt.label"),
|
|
137
|
+
defaultMessage: "Require alternative text for images"
|
|
138
|
+
},
|
|
139
|
+
description: {
|
|
140
|
+
id: getTranslation("field.options.requireAlt.description"),
|
|
141
|
+
defaultMessage: "Images need a text description or must be marked as decorative"
|
|
142
|
+
},
|
|
143
|
+
name: "options.requireAlt",
|
|
144
|
+
type: "checkbox"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
advanced: [
|
|
150
|
+
{
|
|
151
|
+
sectionTitle: {
|
|
152
|
+
id: getTranslation("field.options.content"),
|
|
153
|
+
defaultMessage: "Allowed content and limits"
|
|
154
|
+
},
|
|
155
|
+
items: [
|
|
156
|
+
{
|
|
157
|
+
intlLabel: {
|
|
158
|
+
id: getTranslation("field.options.allowedBlocks.label"),
|
|
159
|
+
defaultMessage: "Allowed blocks"
|
|
160
|
+
},
|
|
161
|
+
description: {
|
|
162
|
+
id: getTranslation("field.options.allowedBlocks.description"),
|
|
163
|
+
defaultMessage: "Comma-separated block names that replace the preset list, for example: paragraph, header, list, image, myCustomBlock"
|
|
164
|
+
},
|
|
165
|
+
name: "options.allowedBlocks",
|
|
166
|
+
type: "text"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
intlLabel: {
|
|
170
|
+
id: getTranslation("field.options.headingLevels.label"),
|
|
171
|
+
defaultMessage: "Heading levels"
|
|
172
|
+
},
|
|
173
|
+
description: {
|
|
174
|
+
id: getTranslation("field.options.headingLevels.description"),
|
|
175
|
+
defaultMessage: "For example 2-4 or 2,3. Empty uses the preset."
|
|
176
|
+
},
|
|
177
|
+
name: "options.headingLevels",
|
|
178
|
+
type: "text"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
intlLabel: {
|
|
182
|
+
id: getTranslation("field.options.maxBlocks.label"),
|
|
183
|
+
defaultMessage: "Maximum number of blocks"
|
|
184
|
+
},
|
|
185
|
+
description: {
|
|
186
|
+
id: getTranslation("field.options.maxBlocks.description"),
|
|
187
|
+
defaultMessage: "Empty or 0 means no limit"
|
|
188
|
+
},
|
|
189
|
+
name: "options.maxBlocks",
|
|
190
|
+
type: "number"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
intlLabel: {
|
|
194
|
+
id: getTranslation("field.options.maxCharacters.label"),
|
|
195
|
+
defaultMessage: "Maximum number of characters"
|
|
196
|
+
},
|
|
197
|
+
description: {
|
|
198
|
+
id: getTranslation("field.options.maxCharacters.description"),
|
|
199
|
+
defaultMessage: "Visible text, counted like the editor toolbar. Empty or 0 means no limit."
|
|
200
|
+
},
|
|
201
|
+
name: "options.maxCharacters",
|
|
202
|
+
type: "number"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
sectionTitle: { id: getTranslation("field.options.features"), defaultMessage: "Features" },
|
|
208
|
+
items: [
|
|
209
|
+
{
|
|
210
|
+
intlLabel: {
|
|
211
|
+
id: getTranslation("field.options.disableAi.label"),
|
|
212
|
+
defaultMessage: "Turn off the AI assistant for this field"
|
|
213
|
+
},
|
|
214
|
+
name: "options.disableAi",
|
|
215
|
+
type: "checkbox"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
intlLabel: {
|
|
219
|
+
id: getTranslation("field.options.disableCollaboration.label"),
|
|
220
|
+
defaultMessage: "Turn off live collaboration for this field"
|
|
221
|
+
},
|
|
222
|
+
name: "options.disableCollaboration",
|
|
223
|
+
type: "checkbox"
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
intlLabel: {
|
|
227
|
+
id: getTranslation("field.options.publishGuard.label"),
|
|
228
|
+
defaultMessage: "Block publishing while quality checks report errors"
|
|
229
|
+
},
|
|
230
|
+
description: {
|
|
231
|
+
id: getTranslation("field.options.publishGuard.description"),
|
|
232
|
+
defaultMessage: "Errors are missing alternative texts (when required) and empty links"
|
|
233
|
+
},
|
|
234
|
+
name: "options.publishGuard",
|
|
235
|
+
type: "checkbox"
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
sectionTitle: { id: getTranslation("field.options.advanced"), defaultMessage: "Layout" },
|
|
241
|
+
items: [
|
|
242
|
+
{
|
|
243
|
+
intlLabel: {
|
|
244
|
+
id: getTranslation("field.options.minHeight.label"),
|
|
245
|
+
defaultMessage: "Minimum height (px)"
|
|
246
|
+
},
|
|
247
|
+
description: {
|
|
248
|
+
id: getTranslation("field.options.minHeight.description"),
|
|
249
|
+
defaultMessage: "Height of the empty editor, between 120 and 2000 pixels"
|
|
250
|
+
},
|
|
251
|
+
name: "options.minHeight",
|
|
252
|
+
type: "number"
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
app.addSettingsLink(
|
|
260
|
+
{
|
|
261
|
+
id: PLUGIN_ID,
|
|
262
|
+
intlLabel: { id: getTranslation("settings.section"), defaultMessage: "Magic Editor X" }
|
|
263
|
+
},
|
|
264
|
+
[
|
|
265
|
+
{
|
|
266
|
+
id: `${PLUGIN_ID}-configuration`,
|
|
267
|
+
intlLabel: { id: getTranslation("settings.link.configuration"), defaultMessage: "Configuration" },
|
|
268
|
+
to: `${PLUGIN_ID}/configuration`,
|
|
269
|
+
permissions: PERMISSIONS.settingsRead,
|
|
270
|
+
Component: () => Promise.resolve().then(() => require("./ConfigurationPage-YvnPnna6.js"))
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: `${PLUGIN_ID}-custom-blocks`,
|
|
274
|
+
intlLabel: { id: getTranslation("settings.link.customBlocks"), defaultMessage: "Custom blocks" },
|
|
275
|
+
to: `${PLUGIN_ID}/custom-blocks`,
|
|
276
|
+
permissions: PERMISSIONS.customBlocksManage,
|
|
277
|
+
Component: () => Promise.resolve().then(() => require("./CustomBlocksPage-BiiL2ORG.js"))
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
);
|
|
281
|
+
},
|
|
282
|
+
bootstrap() {
|
|
283
|
+
},
|
|
284
|
+
/**
|
|
285
|
+
* @param {{ locales: string[] }} options - Admin locales.
|
|
286
|
+
* @returns {Promise<Array<{ data: object, locale: string }>>} Translations.
|
|
287
|
+
*/
|
|
288
|
+
async registerTrads({ locales }) {
|
|
289
|
+
return Promise.all(
|
|
290
|
+
locales.map(async (locale) => {
|
|
291
|
+
try {
|
|
292
|
+
return { data: await loadMessages(locale), locale };
|
|
293
|
+
} catch {
|
|
294
|
+
return { data: {}, locale };
|
|
295
|
+
}
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
exports.PERMISSIONS = PERMISSIONS;
|
|
301
|
+
exports.getTranslation = getTranslation;
|
|
302
|
+
exports.index = index;
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED