UNPKG

@sklinet/strapi-plugin-tinymce

Version:

Strapi custom field with a customized build of TinyMCE richtext editor.

167 lines (165 loc) 5.32 kB
"use strict"; const react = require("react"); const jsxRuntime = require("react/jsx-runtime"); const styled = require("styled-components"); const designSystem = require("@strapi/design-system"); const icons = require("@strapi/icons"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const styled__default = /* @__PURE__ */ _interopDefault(styled); const __variableDynamicImportRuntimeHelper = (glob, path, segs) => { const v = glob[path]; if (v) { return typeof v === "function" ? v() : Promise.resolve(v); } return new Promise((_, reject) => { (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)( reject.bind( null, new Error( "Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "") ) ) ); }); }; const name$1 = "@sklinet/strapi-plugin-tinymce"; const strapi = { name: "tinymce" }; const pluginPkg = { name: name$1, strapi }; const PLUGIN_ID = pluginPkg.name.replace(/^(@sklinet\/strapi-)plugin-/i, ""); const getTranslation = (id) => `${PLUGIN_ID}.${id}`; const Initializer = ({ setPlugin }) => { const ref = react.useRef(setPlugin); react.useEffect(() => { ref.current(PLUGIN_ID); }, []); return null; }; const prefixPluginTranslations = (trad, pluginId) => { if (!pluginId) { throw new TypeError("pluginId can't be empty"); } return Object.keys(trad).reduce((acc, current) => { acc[`${pluginId}.${current}`] = trad[current]; return acc; }, {}); }; const pluginPermissions = { settings: [{ action: "plugin::tinymce.settings.read", subject: null }] }; const IconBox = styled__default.default(designSystem.Flex)` background-color: #f0f0ff; /* primary100 */ border: 1px solid #d9d8ff; /* primary200 */ svg > path { fill: #4945ff; /* primary600 */ } `; const PluginIcon = () => { return /* @__PURE__ */ jsxRuntime.jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Paragraph, {}) }); }; const name = pluginPkg.strapi.name; const index = { register(app) { app.customFields.register({ name: "tinymce", pluginId: PLUGIN_ID, type: "richtext", icon: PluginIcon, intlLabel: { id: getTranslation("settings.title"), defaultMessage: "TinyMCE" }, intlDescription: { id: getTranslation("settings.description"), defaultMessage: "TinyMCE rich text editor" }, isResizable: false, default: 12, options: { advanced: [ { type: "checkbox", name: "required", intlLabel: { id: getTranslation("settings.required-field"), defaultMessage: "Required field" }, description: "You won't be able to create an entry if this field is empty" }, { type: "checkbox", name: "options.disableMediaLibrary", intlLabel: { id: getTranslation("settings.disable-media-library"), defaultMessage: "Disable Media Library" }, description: "Disable Media Library integration and prevent uploading images through the editor" } ] }, components: { Input: async () => Promise.resolve().then(() => require( /* webpackChunkName: "video-field-input-component" */ "./Wysiwyg-BkVXULqb.js" )) } }); app.createSettingSection( { id: PLUGIN_ID, intlLabel: { id: `${PLUGIN_ID}.plugin.name`, defaultMessage: "TinyMCE" } }, [ { intlLabel: { id: getTranslation("settings.page-title"), defaultMessage: "Configuration" }, id: "settings", to: `/settings/${PLUGIN_ID}`, Component: async () => { return Promise.resolve().then(() => require("./Settings-B9wGTsjO.js")); }, permissions: pluginPermissions["settings"] } ] ); app.registerPlugin({ id: PLUGIN_ID, initializer: Initializer, isReady: false, name }); }, bootstrap(app) { }, async registerTrads(app) { const { locales } = app; const importedTranslations = await Promise.all( locales.map((locale) => { return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-BxnAP70z.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-BXIb0N2E.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CoWQ3RL4.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => { return { data: prefixPluginTranslations(data, PLUGIN_ID), locale }; }).catch(() => { return { data: {}, locale }; }); }) ); return importedTranslations; } }; exports.PLUGIN_ID = PLUGIN_ID; exports.getTranslation = getTranslation; exports.index = index;