@sklinet/strapi-plugin-tinymce
Version:
Strapi custom field with a customized build of TinyMCE richtext editor.
1 lines • 8.55 kB
Source Map (JSON)
{"version":3,"file":"index-o0tTkszh.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/utils/getTranslation.ts","../../admin/src/components/Initializer.tsx","../../admin/src/utils/prefixPluginTranslations.ts","../../admin/src/permissions.ts","../../admin/src/components/PluginIcon.tsx","../../admin/src/index.ts"],"sourcesContent":["import pluginPkg from '../../package.json';\n\nexport const PLUGIN_ID = pluginPkg.name.replace(/^(@sklinet\\/strapi-)plugin-/i, '');\n","import { PLUGIN_ID } from '../pluginId';\n\nconst getTranslation = (id: string) => `${PLUGIN_ID}.${id}`;\n\nexport { getTranslation };\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","type TradOptions = Record<string, string>;\n\nexport const prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n","const pluginPermissions = {\n // This permission regards the main component (App) and is used to tell\n // If the plugin link should be displayed in the menu\n // And also if the plugin is accessible. This use case is found when a user types the url of the\n // plugin directly in the browser\n 'menu-link': [{ action: 'plugin::tinymce.menu-link', subject: null }],\n settings: [{ action: 'plugin::tinymce.settings.read', subject: null }],\n};\n\nexport default pluginPermissions;\n","import React from 'react';\nimport styled from 'styled-components';\nimport { Flex } from '@strapi/design-system';\nimport { Paragraph } from '@strapi/icons';\n\nconst IconBox = styled(Flex)`\n background-color: #f0f0ff; /* primary100 */\n border: 1px solid #d9d8ff; /* primary200 */\n\n svg > path {\n fill: #4945ff; /* primary600 */\n }\n`;\n\nconst PluginIcon = () => {\n return (\n <IconBox justifyContent=\"center\" alignItems=\"center\" width={7} height={6} hasRadius aria-hidden>\n <Paragraph />\n </IconBox>\n );\n};\n\nexport { PluginIcon };\n","import pluginPkg from '../../package.json';\nimport { getTranslation } from './utils/getTranslation';\nimport { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport { prefixPluginTranslations } from './utils/prefixPluginTranslations';\nimport pluginPermissions from './permissions';\nimport { PluginIcon } from './components/PluginIcon';\n\nconst name = pluginPkg.strapi.name;\n\nexport default {\n register(app: any) {\n app.customFields.register({\n name: 'tinymce',\n pluginId: PLUGIN_ID,\n type: 'richtext',\n icon: PluginIcon,\n intlLabel: {\n id: getTranslation('settings.title'),\n defaultMessage: 'TinyMCE',\n },\n intlDescription: {\n id: getTranslation('settings.description'),\n defaultMessage: 'TinyMCE rich text editor',\n },\n isResizable: false,\n default: 12,\n options: {\n advanced: [\n {\n type: 'checkbox',\n name: 'required',\n intlLabel: {\n id: getTranslation('settings.required-field'),\n defaultMessage: 'Required field',\n },\n description: \"You won't be able to create an entry if this field is empty\",\n },\n ],\n },\n components: {\n Input: async () => import(/* webpackChunkName: \"video-field-input-component\" */ './components/Wysiwyg'),\n },\n });\n\n app.createSettingSection(\n {\n id: PLUGIN_ID,\n intlLabel: {\n id: `${PLUGIN_ID}.plugin.name`,\n defaultMessage: 'TinyMCE',\n },\n },\n [\n {\n intlLabel: {\n id: getTranslation('settings.page-title'),\n defaultMessage: 'Configuration',\n },\n id: 'settings',\n to: `/settings/${PLUGIN_ID}`,\n Component: async () => {\n return import('./pages/Settings');\n },\n permissions: pluginPermissions['settings'],\n },\n ],\n );\n\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: name,\n });\n },\n\n bootstrap(app: any) {},\n async registerTrads(app: any) {\n const { locales } = app;\n\n const importedTranslations = await Promise.all(\n (locales as string[]).map((locale) => {\n return import(/* webpackChunkName: \"translation-[request]\" */ `./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n }),\n );\n\n return importedTranslations;\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,YAAY,UAAU,KAAK,QAAQ,gCAAgC,EAAE;ACAlF,MAAM,iBAAiB,CAAC,OAAe,GAAG,SAAS,IAAI,EAAE;ACMzD,MAAM,cAAc,CAAC,EAAE,gBAAkC;AAC/C,QAAA,MAAM,OAAO,SAAS;AAE5B,YAAU,MAAM;AACZ,QAAI,QAAQ,SAAS;AAAA,EACzB,GAAG,CAAE,CAAA;AAEE,SAAA;AACX;ACda,MAAA,2BAA2B,CAAC,MAAmB,aAAkC;AAC5F,MAAI,CAAC,UAAU;AACP,UAAA,IAAI,UAAU,yBAAyB;AAAA,EAC/C;AACA,SAAO,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,KAAK,YAAY;AAChD,QAAI,GAAG,QAAQ,IAAI,OAAO,EAAE,IAAI,KAAK,OAAO;AACrC,WAAA;AAAA,EACT,GAAG,CAAiB,CAAA;AACtB;ACVA,MAAM,oBAAoB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtB,aAAa,CAAC,EAAE,QAAQ,6BAA6B,SAAS,MAAM;AAAA,EACpE,UAAU,CAAC,EAAE,QAAQ,iCAAiC,SAAS,MAAM;AACzE;ACFA,MAAM,UAAU,OAAO,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAS3B,MAAM,aAAa,MAAM;AACrB,6BACK,SAAQ,EAAA,gBAAe,UAAS,YAAW,UAAS,OAAO,GAAG,QAA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