@frontify/guideline-blocks-settings 0.27.0 → 0.28.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/.eslintrc.js +1 -1
- package/CHANGELOG.md +21 -0
- package/README.md +24 -5
- package/dist/_virtual/_commonjsHelpers.es.js +7 -0
- package/dist/_virtual/_commonjsHelpers.es.js.map +1 -0
- package/dist/_virtual/index.es.js +5 -0
- package/dist/_virtual/index.es.js.map +1 -0
- package/dist/_virtual/index.es2.js +5 -0
- package/dist/_virtual/index.es2.js.map +1 -0
- package/dist/_virtual/index.es3.js +5 -0
- package/dist/_virtual/index.es3.js.map +1 -0
- package/dist/_virtual/jsx-runtime.es.js +5 -0
- package/dist/_virtual/jsx-runtime.es.js.map +1 -0
- package/dist/_virtual/react-dom.development.es.js +5 -0
- package/dist/_virtual/react-dom.development.es.js.map +1 -0
- package/dist/_virtual/react-dom.production.min.es.js +5 -0
- package/dist/_virtual/react-dom.production.min.es.js.map +1 -0
- package/dist/_virtual/react-jsx-runtime.development.es.js +5 -0
- package/dist/_virtual/react-jsx-runtime.development.es.js.map +1 -0
- package/dist/_virtual/react-jsx-runtime.production.min.es.js +5 -0
- package/dist/_virtual/react-jsx-runtime.production.min.es.js.map +1 -0
- package/dist/_virtual/react.development.es.js +5 -0
- package/dist/_virtual/react.development.es.js.map +1 -0
- package/dist/_virtual/react.production.min.es.js +5 -0
- package/dist/_virtual/react.production.min.es.js.map +1 -0
- package/dist/_virtual/scheduler.development.es.js +5 -0
- package/dist/_virtual/scheduler.development.es.js.map +1 -0
- package/dist/_virtual/scheduler.production.min.es.js +5 -0
- package/dist/_virtual/scheduler.production.min.es.js.map +1 -0
- package/dist/components/Attachments/AttachmentItem.es.js +180 -0
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -0
- package/dist/components/Attachments/Attachments.es.js +145 -0
- package/dist/components/Attachments/Attachments.es.js.map +1 -0
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js +150 -0
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js +73 -0
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar.es.js +113 -0
- package/dist/components/BlockItemWrapper/Toolbar.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/constants.es.js +6 -0
- package/dist/components/BlockItemWrapper/constants.es.js.map +1 -0
- package/dist/components/DownloadButton/DownloadButton.es.js +39 -0
- package/dist/components/DownloadButton/DownloadButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/RichTextEditor.es.js +42 -0
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -0
- package/dist/components/RichTextEditor/SerializedText.es.js +13 -0
- package/dist/components/RichTextEditor/SerializedText.es.js.map +1 -0
- package/dist/components/RichTextEditor/constants.es.js +5 -0
- package/dist/components/RichTextEditor/constants.es.js.map +1 -0
- package/dist/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.es.js +34 -0
- package/dist/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.es.js +54 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/index.es.js +12 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/index.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.es.js +17 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.es.js +30 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/CustomFloatingButton.es.js +16 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/CustomFloatingButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.es.js +37 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButton.es.js +25 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonEditButton.es.js +20 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonEditButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.es.js +26 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/InsertButtonModal.es.js +69 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/InsertButtonModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.es.js +105 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/UnlinkButton.es.js +20 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/UnlinkButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/floatingButtonStore.es.js +32 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/floatingButtonStore.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.es.js +58 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEnter.es.js +19 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEnter.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEscape.es.js +26 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEscape.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.es.js +43 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useVirtualFloatingButton.es.js +18 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useVirtualFloatingButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.es.js +62 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.es.js +13 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/submitFloatingButton.es.js +25 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/submitFloatingButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.es.js +35 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.es.js +86 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.es.js +24 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.es.js +19 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.es.js +13 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/getButtonStyle.es.js +11 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/getButtonStyle.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/getUrl.es.js +10 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/getUrl.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/styles.es.js +75 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/styles.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.es.js +18 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonEdit.es.js +17 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonEdit.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.es.js +14 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/withButton.es.js +53 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/withButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js +19 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js +37 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.es.js +53 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/FloatingLink.es.js +29 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/FloatingLink.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertLinkModal.es.js +8 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertLinkModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertModal.es.js +80 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js +40 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js +93 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkButton.es.js +25 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js +27 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/index.es.js +12 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/index.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/id.es.js +5 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/id.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/index.es.js +39 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/index.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/getUrl.es.js +18 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/getUrl.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/relativeUrlRegex.es.js +5 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/relativeUrlRegex.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/url.es.js +17 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/url.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js +45 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js +45 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js +45 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js +46 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js +39 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js +39 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js +39 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/helpers.es.js +40 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/helpers.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js +46 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js +46 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js +41 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js +48 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLink.es.js +68 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLink.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLinks.es.js +55 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLinks.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/LinkSelector.es.js +62 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/LinkSelector.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLink.es.js +61 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLink.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLinks.es.js +34 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/PageLinks.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/SectionLink.es.js +26 -0
- package/dist/components/RichTextEditor/plugins/shared/LinkSelector/SectionLink.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/styles.es.js +168 -0
- package/dist/components/RichTextEditor/plugins/styles.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/nodes/button.es.js +16 -0
- package/dist/components/RichTextEditor/serializer/nodes/button.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/nodes/checkItemNode.es.js +19 -0
- package/dist/components/RichTextEditor/serializer/nodes/checkItemNode.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/nodes/default.es.js +17 -0
- package/dist/components/RichTextEditor/serializer/nodes/default.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/nodes/link.es.js +15 -0
- package/dist/components/RichTextEditor/serializer/nodes/link.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/nodes/mentionHtmlNode.es.js +12 -0
- package/dist/components/RichTextEditor/serializer/nodes/mentionHtmlNode.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.es.js +61 -0
- package/dist/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js +25 -0
- package/dist/components/RichTextEditor/serializer/serializeToHtml.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.es.js +8 -0
- package/dist/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.es.js.map +1 -0
- package/dist/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.es.js +13 -0
- package/dist/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.es.js.map +1 -0
- package/dist/helpers/addHttps.es.js +14 -0
- package/dist/helpers/addHttps.es.js.map +1 -0
- package/dist/helpers/convertToRichTextValue.es.js +6 -0
- package/dist/helpers/convertToRichTextValue.es.js.map +1 -0
- package/dist/helpers/customCoordinatesGetterFactory.es.js +32 -0
- package/dist/helpers/customCoordinatesGetterFactory.es.js.map +1 -0
- package/dist/helpers/hasRichTextValue.es.js +15 -0
- package/dist/helpers/hasRichTextValue.es.js.map +1 -0
- package/dist/helpers/isDownloadable.es.js +6 -0
- package/dist/helpers/isDownloadable.es.js.map +1 -0
- package/dist/helpers/mapColorPalettes.es.js +16 -0
- package/dist/helpers/mapColorPalettes.es.js.map +1 -0
- package/dist/hooks/useAttachments.es.js +31 -0
- package/dist/hooks/useAttachments.es.js.map +1 -0
- package/dist/hooks/useDndSensors.es.js +20 -0
- package/dist/hooks/useDndSensors.es.js.map +1 -0
- package/dist/index.cjs.js +252 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +816 -1
- package/dist/index.es.js +172 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +252 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/settings/background.es.js +22 -0
- package/dist/settings/background.es.js.map +1 -0
- package/dist/settings/border.es.js +61 -0
- package/dist/settings/border.es.js.map +1 -0
- package/dist/settings/borderRadius.es.js +56 -0
- package/dist/settings/borderRadius.es.js.map +1 -0
- package/dist/settings/borderRadiusExtended.es.js +64 -0
- package/dist/settings/borderRadiusExtended.es.js.map +1 -0
- package/dist/settings/defaultValues.es.js +19 -0
- package/dist/settings/defaultValues.es.js.map +1 -0
- package/dist/settings/gutter.es.js +56 -0
- package/dist/settings/gutter.es.js.map +1 -0
- package/dist/settings/margin.es.js +53 -0
- package/dist/settings/margin.es.js.map +1 -0
- package/dist/settings/marginExtended.es.js +65 -0
- package/dist/settings/marginExtended.es.js.map +1 -0
- package/dist/settings/padding.es.js +53 -0
- package/dist/settings/padding.es.js.map +1 -0
- package/dist/settings/paddingExtended.es.js +65 -0
- package/dist/settings/paddingExtended.es.js.map +1 -0
- package/dist/settings/securityDownloadable.es.js +19 -0
- package/dist/settings/securityDownloadable.es.js.map +1 -0
- package/dist/settings/securityGlobalControl.es.js +33 -0
- package/dist/settings/securityGlobalControl.es.js.map +1 -0
- package/dist/settings/types.es.js +48 -0
- package/dist/settings/types.es.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/utilities/color/getReadableColor.es.js +14 -0
- package/dist/utilities/color/getReadableColor.es.js.map +1 -0
- package/dist/utilities/color/isDark.es.js +10 -0
- package/dist/utilities/color/isDark.es.js.map +1 -0
- package/dist/utilities/color/setAlpha.es.js +6 -0
- package/dist/utilities/color/setAlpha.es.js.map +1 -0
- package/dist/utilities/color/toColorObject.es.js +9 -0
- package/dist/utilities/color/toColorObject.es.js.map +1 -0
- package/dist/utilities/color/toHex8String.es.js +7 -0
- package/dist/utilities/color/toHex8String.es.js.map +1 -0
- package/dist/utilities/color/toHexString.es.js +7 -0
- package/dist/utilities/color/toHexString.es.js.map +1 -0
- package/dist/utilities/color/toRgbaString.es.js +7 -0
- package/dist/utilities/color/toRgbaString.es.js.map +1 -0
- package/dist/utilities/color/toShortRgba.es.js +11 -0
- package/dist/utilities/color/toShortRgba.es.js.map +1 -0
- package/dist/utilities/moveItemInArray.es.js +12 -0
- package/dist/utilities/moveItemInArray.es.js.map +1 -0
- package/dist/utilities/react/getBackgroundColorStyles.es.js +8 -0
- package/dist/utilities/react/getBackgroundColorStyles.es.js.map +1 -0
- package/dist/utilities/react/getBorderStyles.es.js +12 -0
- package/dist/utilities/react/getBorderStyles.es.js.map +1 -0
- package/dist/utilities/react/getRadiusStyles.es.js +8 -0
- package/dist/utilities/react/getRadiusStyles.es.js.map +1 -0
- package/dist/utilities/react/joinClassNames.es.js +5 -0
- package/dist/utilities/react/joinClassNames.es.js.map +1 -0
- package/package.json +46 -10
- package/postcss.config.js +8 -0
- package/setupTests.ts +13 -0
- package/src/components/Attachments/AttachmentItem.tsx +257 -0
- package/src/components/Attachments/Attachments.spec.ct.tsx +151 -0
- package/src/components/Attachments/Attachments.tsx +221 -0
- package/src/components/Attachments/index.ts +4 -0
- package/src/components/Attachments/types.ts +30 -0
- package/src/components/BlockInjectButton/BlockInjectButton.spec.ct.tsx +48 -0
- package/src/components/BlockInjectButton/BlockInjectButton.tsx +212 -0
- package/src/components/BlockInjectButton/index.ts +4 -0
- package/src/components/BlockInjectButton/types.ts +18 -0
- package/src/components/BlockItemWrapper/BlockItemWrapper.spec.ct.tsx +146 -0
- package/src/components/BlockItemWrapper/BlockItemWrapper.tsx +76 -0
- package/src/components/BlockItemWrapper/Toolbar.tsx +128 -0
- package/src/components/BlockItemWrapper/constants.ts +4 -0
- package/src/components/BlockItemWrapper/index.ts +5 -0
- package/src/components/BlockItemWrapper/types.ts +46 -0
- package/src/components/DownloadButton/DownloadButton.spec.ct.tsx +20 -0
- package/src/components/DownloadButton/DownloadButton.tsx +36 -0
- package/src/components/DownloadButton/index.ts +3 -0
- package/src/components/DownloadButton/types.ts +5 -0
- package/src/components/RichTextEditor/RichTextEditor.spec.ct.tsx +204 -0
- package/src/components/RichTextEditor/RichTextEditor.tsx +62 -0
- package/src/components/RichTextEditor/SerializedText.tsx +25 -0
- package/src/components/RichTextEditor/constants.ts +3 -0
- package/src/components/RichTextEditor/index.ts +6 -0
- package/src/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.tsx +53 -0
- package/src/components/RichTextEditor/pluginPresets/index.ts +3 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.tsx +74 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/index.ts +11 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.tsx +20 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.tsx +56 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/CustomFloatingButton.tsx +19 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.tsx +42 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButton.tsx +37 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonEditButton.tsx +22 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.tsx +30 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/InsertButtonModal.tsx +81 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/types.ts +13 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.ts +143 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/UnlinkButton.tsx +31 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/floatingButtonStore.ts +46 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/index.ts +12 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.ts +113 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEnter.ts +21 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEscape.ts +30 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.ts +71 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useVirtualFloatingButton.ts +22 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/index.ts +3 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.ts +116 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/index.ts +7 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/index.ts +8 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.ts +17 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/submitFloatingButton.ts +40 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.ts +68 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.ts +198 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.ts +40 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.ts +30 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/types.ts +13 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.ts +28 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/getButtonStyle.ts +14 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/getUrl.ts +18 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/index.ts +8 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/styles.ts +77 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.ts +23 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonEdit.ts +30 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.ts +45 -0
- package/src/components/RichTextEditor/plugins/ButtonPlugin/withButton.ts +106 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/CustomFloatingLink.tsx +26 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.tsx +43 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/index.ts +4 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.ts +113 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/FloatingLink.tsx +45 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertLinkModal.tsx +5 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertModal.tsx +105 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/index.ts +4 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/types.ts +16 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.ts +73 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.ts +136 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkButton.tsx +38 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx +36 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/index.ts +11 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/id.ts +3 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/index.ts +48 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/types.ts +12 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/getUrl.ts +30 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/index.ts +4 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/relativeUrlRegex.spec.ts +35 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/relativeUrlRegex.ts +3 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/url.spec.ts +75 -0
- package/src/components/RichTextEditor/plugins/LinkPlugin/utils/url.ts +21 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.tsx +61 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.tsx +61 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.tsx +62 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.tsx +61 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.tsx +58 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.tsx +58 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.tsx +59 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/helpers.tsx +44 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.tsx +61 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.tsx +61 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/index.ts +15 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.tsx +58 -0
- package/src/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.tsx +62 -0
- package/src/components/RichTextEditor/plugins/index.ts +6 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLink.tsx +80 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/DocumentLinks.tsx +97 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/LinkSelector.spec.ct.tsx +138 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/LinkSelector.tsx +80 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/PageLink.tsx +83 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/PageLinks.tsx +68 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/SectionLink.tsx +37 -0
- package/src/components/RichTextEditor/plugins/shared/LinkSelector/index.ts +3 -0
- package/src/components/RichTextEditor/plugins/styles.ts +179 -0
- package/src/components/RichTextEditor/serializer/index.ts +3 -0
- package/src/components/RichTextEditor/serializer/nodes/button.ts +25 -0
- package/src/components/RichTextEditor/serializer/nodes/checkItemNode.ts +29 -0
- package/src/components/RichTextEditor/serializer/nodes/default.ts +52 -0
- package/src/components/RichTextEditor/serializer/nodes/link.ts +25 -0
- package/src/components/RichTextEditor/serializer/nodes/mentionHtmlNode.ts +17 -0
- package/src/components/RichTextEditor/serializer/serializeNodesToHtmlRecursive.ts +134 -0
- package/src/components/RichTextEditor/serializer/serializeToHtml.ts +49 -0
- package/src/components/RichTextEditor/serializer/utlis/reactCssPropsToCss.ts +21 -0
- package/src/components/RichTextEditor/serializer/utlis/serializeLeafToHtml.ts +32 -0
- package/src/components/RichTextEditor/types.ts +23 -0
- package/src/components/index.ts +7 -0
- package/src/helpers/addHttps.spec.ts +42 -0
- package/src/helpers/addHttps.ts +15 -0
- package/src/helpers/convertToRichTextValue.spec.ts +32 -0
- package/src/helpers/convertToRichTextValue.ts +6 -0
- package/src/helpers/customCoordinatesGetterFactory.spec.ts +69 -0
- package/src/helpers/customCoordinatesGetterFactory.ts +39 -0
- package/src/helpers/hasRichTextValue.spec.ts +63 -0
- package/src/helpers/hasRichTextValue.ts +29 -0
- package/src/helpers/index.ts +8 -0
- package/src/helpers/isDownloadable.spec.ts +47 -0
- package/src/helpers/isDownloadable.ts +7 -0
- package/src/helpers/mapColorPalettes.spec.ts +146 -0
- package/src/helpers/mapColorPalettes.ts +22 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useAttachments.spec.ts +79 -0
- package/src/hooks/useAttachments.ts +46 -0
- package/src/hooks/useDndSensors.spec.ts +40 -0
- package/src/hooks/useDndSensors.ts +23 -0
- package/src/index.ts +8 -0
- package/src/settings/background.spec.ts +173 -0
- package/src/settings/background.ts +49 -0
- package/src/settings/border.spec.ts +76 -0
- package/src/settings/border.ts +90 -0
- package/src/settings/borderRadius.spec.ts +30 -0
- package/src/settings/borderRadius.ts +73 -0
- package/src/settings/borderRadiusExtended.spec.ts +52 -0
- package/src/settings/borderRadiusExtended.ts +84 -0
- package/src/settings/defaultValues.ts +21 -0
- package/src/settings/gutter.spec.ts +60 -0
- package/src/settings/gutter.ts +75 -0
- package/src/settings/index.ts +14 -0
- package/src/settings/margin.spec.ts +42 -0
- package/src/settings/margin.ts +72 -0
- package/src/settings/marginExtended.spec.ts +45 -0
- package/src/settings/marginExtended.ts +91 -0
- package/src/settings/padding.spec.ts +42 -0
- package/src/settings/padding.ts +73 -0
- package/src/settings/paddingExtended.spec.ts +45 -0
- package/src/settings/paddingExtended.ts +91 -0
- package/src/settings/security.spec.ts +87 -0
- package/src/settings/security.ts +61 -0
- package/src/settings/securityDownloadable.spec.ts +46 -0
- package/src/settings/securityDownloadable.ts +33 -0
- package/src/settings/securityGlobalControl.ts +42 -0
- package/src/settings/types.ts +128 -0
- package/src/utilities/color/getReadableColor.spec.ts +32 -0
- package/src/utilities/color/getReadableColor.ts +34 -0
- package/src/utilities/color/index.ts +10 -0
- package/src/utilities/color/isDark.spec.ts +33 -0
- package/src/utilities/color/isDark.ts +29 -0
- package/src/utilities/color/setAlpha.spec.ts +28 -0
- package/src/utilities/color/setAlpha.ts +14 -0
- package/src/utilities/color/toColorObject.spec.ts +19 -0
- package/src/utilities/color/toColorObject.ts +16 -0
- package/src/utilities/color/toHex8String.spec.ts +17 -0
- package/src/utilities/color/toHex8String.ts +14 -0
- package/src/utilities/color/toHexString.spec.ts +17 -0
- package/src/utilities/color/toHexString.ts +10 -0
- package/src/utilities/color/toRgbaString.spec.ts +12 -0
- package/src/utilities/color/toRgbaString.ts +14 -0
- package/src/utilities/color/toShortRgba.spec.ts +16 -0
- package/src/utilities/color/toShortRgba.ts +35 -0
- package/src/utilities/index.ts +5 -0
- package/src/utilities/moveItemInArray.spec.ts +17 -0
- package/src/utilities/moveItemInArray.ts +21 -0
- package/src/utilities/react/getBackgroundColorStyles.spec.ts +18 -0
- package/src/utilities/react/getBackgroundColorStyles.ts +11 -0
- package/src/utilities/react/getBorderStyles.spec.ts +39 -0
- package/src/utilities/react/getBorderStyles.ts +21 -0
- package/src/utilities/react/getRadiusStyles.spec.ts +25 -0
- package/src/utilities/react/getRadiusStyles.ts +8 -0
- package/src/utilities/react/index.ts +6 -0
- package/src/utilities/react/joinClassNames.spec.ts +18 -0
- package/src/utilities/react/joinClassNames.ts +10 -0
- package/tailwind.config.js +27 -0
- package/tsconfig.json +3 -1
- package/vite.config.ts +11 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { CSSProperties } from 'react';
|
|
4
|
+
import { LINK_PLUGIN } from './LinkPlugin/id';
|
|
5
|
+
import { BlockButtonStyles } from './ButtonPlugin';
|
|
6
|
+
|
|
7
|
+
export const enum TextStyles {
|
|
8
|
+
heading1 = 'heading1',
|
|
9
|
+
heading2 = 'heading2',
|
|
10
|
+
heading3 = 'heading3',
|
|
11
|
+
heading4 = 'heading4',
|
|
12
|
+
custom1 = 'custom1',
|
|
13
|
+
custom2 = 'custom2',
|
|
14
|
+
custom3 = 'custom3',
|
|
15
|
+
quote = 'quote',
|
|
16
|
+
imageCaption = 'imageCaption',
|
|
17
|
+
imageTitle = 'imageTitle',
|
|
18
|
+
p = 'p',
|
|
19
|
+
}
|
|
20
|
+
export const BlockStyles: Record<string, CSSProperties & { hover?: CSSProperties }> = {
|
|
21
|
+
[TextStyles.heading1]: {
|
|
22
|
+
display: 'inline-block',
|
|
23
|
+
fontSize: 'var(--f-theme-settings-heading1-font-size)',
|
|
24
|
+
lineHeight: 'var(--f-theme-settings-heading1-line-height)',
|
|
25
|
+
marginTop: 'var(--f-theme-settings-heading1-margin-top)',
|
|
26
|
+
marginBottom: 'var(--f-theme-settings-heading1-margin-bottom)',
|
|
27
|
+
textDecoration: 'var(--f-theme-settings-heading1-text-decoration)',
|
|
28
|
+
fontStyle: 'var(--f-theme-settings-heading1-font-style)',
|
|
29
|
+
textTransform: 'var(--f-theme-settings-heading1-text-transform)' as CSSProperties['textTransform'],
|
|
30
|
+
letterSpacing: 'var(--f-theme-settings-heading1-letter-spacing)',
|
|
31
|
+
fontWeight: 'var(--f-theme-settings-heading1-font-weight)',
|
|
32
|
+
fontFamily: 'var(--f-theme-settings-heading1-font-family)',
|
|
33
|
+
color: 'var(--f-theme-settings-heading1-color)',
|
|
34
|
+
},
|
|
35
|
+
[TextStyles.heading2]: {
|
|
36
|
+
fontSize: 'var(--f-theme-settings-heading2-font-size)',
|
|
37
|
+
lineHeight: 'var(--f-theme-settings-heading2-line-height)',
|
|
38
|
+
marginTop: 'var(--f-theme-settings-heading2-margin-top)',
|
|
39
|
+
marginBottom: 'var(--f-theme-settings-heading2-margin-bottom)',
|
|
40
|
+
textDecoration: 'var(--f-theme-settings-heading2-text-decoration)',
|
|
41
|
+
fontStyle: 'var(--f-theme-settings-heading2-font-style)',
|
|
42
|
+
textTransform: 'var(--f-theme-settings-heading2-text-transform)' as CSSProperties['textTransform'],
|
|
43
|
+
letterSpacing: 'var(--f-theme-settings-heading2-letter-spacing)',
|
|
44
|
+
fontWeight: 'var(--f-theme-settings-heading2-font-weight)',
|
|
45
|
+
fontFamily: 'var(--f-theme-settings-heading2-font-family)',
|
|
46
|
+
color: 'var(--f-theme-settings-heading2-color)',
|
|
47
|
+
},
|
|
48
|
+
[TextStyles.heading3]: {
|
|
49
|
+
fontSize: 'var(--f-theme-settings-heading3-font-size)',
|
|
50
|
+
lineHeight: 'var(--f-theme-settings-heading3-line-height)',
|
|
51
|
+
marginTop: 'var(--f-theme-settings-heading3-margin-top)',
|
|
52
|
+
marginBottom: 'var(--f-theme-settings-heading3-margin-bottom)',
|
|
53
|
+
textDecoration: 'var(--f-theme-settings-heading3-text-decoration)',
|
|
54
|
+
fontStyle: 'var(--f-theme-settings-heading3-font-style)',
|
|
55
|
+
textTransform: 'var(--f-theme-settings-heading3-text-transform)' as CSSProperties['textTransform'],
|
|
56
|
+
letterSpacing: 'var(--f-theme-settings-heading3-letter-spacing)',
|
|
57
|
+
fontWeight: 'var(--f-theme-settings-heading3-font-weight)',
|
|
58
|
+
fontFamily: 'var(--f-theme-settings-heading3-font-family)',
|
|
59
|
+
color: 'var(--f-theme-settings-heading3-color)',
|
|
60
|
+
},
|
|
61
|
+
[TextStyles.heading4]: {
|
|
62
|
+
fontSize: 'var(--f-theme-settings-heading4-font-size)',
|
|
63
|
+
lineHeight: 'var(--f-theme-settings-heading4-line-height)',
|
|
64
|
+
marginTop: 'var(--f-theme-settings-heading4-margin-top)',
|
|
65
|
+
marginBottom: 'var(--f-theme-settings-heading4-margin-bottom)',
|
|
66
|
+
textDecoration: 'var(--f-theme-settings-heading4-text-decoration)',
|
|
67
|
+
fontStyle: 'var(--f-theme-settings-heading4-font-style)',
|
|
68
|
+
textTransform: 'var(--f-theme-settings-heading4-text-transform)' as CSSProperties['textTransform'],
|
|
69
|
+
letterSpacing: 'var(--f-theme-settings-heading4-letter-spacing)',
|
|
70
|
+
fontWeight: 'var(--f-theme-settings-heading4-font-weight)',
|
|
71
|
+
fontFamily: 'var(--f-theme-settings-heading4-font-family)',
|
|
72
|
+
color: 'var(--f-theme-settings-heading4-color)',
|
|
73
|
+
},
|
|
74
|
+
[TextStyles.custom1]: {
|
|
75
|
+
fontSize: 'var(--f-theme-settings-custom1-font-size)',
|
|
76
|
+
lineHeight: 'var(--f-theme-settings-custom1-line-height)',
|
|
77
|
+
marginTop: 'var(--f-theme-settings-custom1-margin-top)',
|
|
78
|
+
marginBottom: 'var(--f-theme-settings-custom1-margin-bottom)',
|
|
79
|
+
textDecoration: 'var(--f-theme-settings-custom1-text-decoration)',
|
|
80
|
+
fontStyle: 'var(--f-theme-settings-custom1-font-style)',
|
|
81
|
+
textTransform: 'var(--f-theme-settings-custom1-text-transform)' as CSSProperties['textTransform'],
|
|
82
|
+
letterSpacing: 'var(--f-theme-settings-custom1-letter-spacing)',
|
|
83
|
+
fontWeight: 'var(--f-theme-settings-custom1-font-weight)',
|
|
84
|
+
fontFamily: 'var(--f-theme-settings-custom1-font-family)',
|
|
85
|
+
color: 'var(--f-theme-settings-custom1-color)',
|
|
86
|
+
},
|
|
87
|
+
[TextStyles.custom2]: {
|
|
88
|
+
fontSize: 'var(--f-theme-settings-custom2-font-size)',
|
|
89
|
+
lineHeight: 'var(--f-theme-settings-custom2-line-height)',
|
|
90
|
+
marginTop: 'var(--f-theme-settings-custom2-margin-top)',
|
|
91
|
+
marginBottom: 'var(--f-theme-settings-custom2-margin-bottom)',
|
|
92
|
+
textDecoration: 'var(--f-theme-settings-custom2-text-decoration)',
|
|
93
|
+
fontStyle: 'var(--f-theme-settings-custom2-font-style)',
|
|
94
|
+
textTransform: 'var(--f-theme-settings-custom2-text-transform)' as CSSProperties['textTransform'],
|
|
95
|
+
letterSpacing: 'var(--f-theme-settings-custom2-letter-spacing)',
|
|
96
|
+
fontWeight: 'var(--f-theme-settings-custom2-font-weight)',
|
|
97
|
+
fontFamily: 'var(--f-theme-settings-custom2-font-family)',
|
|
98
|
+
color: 'var(--f-theme-settings-custom2-color)',
|
|
99
|
+
},
|
|
100
|
+
[TextStyles.custom3]: {
|
|
101
|
+
fontSize: 'var(--f-theme-settings-custom3-font-size)',
|
|
102
|
+
lineHeight: 'var(--f-theme-settings-custom3-line-height)',
|
|
103
|
+
marginTop: 'var(--f-theme-settings-custom3-margin-top)',
|
|
104
|
+
marginBottom: 'var(--f-theme-settings-custom3-margin-bottom)',
|
|
105
|
+
textDecoration: 'var(--f-theme-settings-custom3-text-decoration)',
|
|
106
|
+
fontStyle: 'var(--f-theme-settings-custom3-font-style)',
|
|
107
|
+
textTransform: 'var(--f-theme-settings-custom3-text-transform)' as CSSProperties['textTransform'],
|
|
108
|
+
letterSpacing: 'var(--f-theme-settings-custom3-letter-spacing)',
|
|
109
|
+
fontWeight: 'var(--f-theme-settings-custom3-font-weight)',
|
|
110
|
+
fontFamily: 'var(--f-theme-settings-custom3-font-family)',
|
|
111
|
+
color: 'var(--f-theme-settings-custom3-color)',
|
|
112
|
+
},
|
|
113
|
+
[TextStyles.p]: {
|
|
114
|
+
fontSize: 'var(--f-theme-settings-body-font-size)',
|
|
115
|
+
lineHeight: 'var(--f-theme-settings-body-line-height)',
|
|
116
|
+
marginTop: 'var(--f-theme-settings-body-margin-top)',
|
|
117
|
+
marginBottom: 'var(--f-theme-settings-body-margin-bottom)',
|
|
118
|
+
textDecoration: 'var(--f-theme-settings-body-text-decoration)',
|
|
119
|
+
fontStyle: 'var(--f-theme-settings-body-font-style)',
|
|
120
|
+
textTransform: 'var(--f-theme-settings-body-text-transform)' as CSSProperties['textTransform'],
|
|
121
|
+
letterSpacing: 'var(--f-theme-settings-body-letter-spacing)',
|
|
122
|
+
fontWeight: 'var(--f-theme-settings-body-font-weight)',
|
|
123
|
+
fontFamily: 'var(--f-theme-settings-body-font-family)',
|
|
124
|
+
color: 'var(--f-theme-settings-body-color)',
|
|
125
|
+
},
|
|
126
|
+
[TextStyles.quote]: {
|
|
127
|
+
fontSize: 'var(--f-theme-settings-quote-font-size)',
|
|
128
|
+
lineHeight: 'var(--f-theme-settings-quote-line-height)',
|
|
129
|
+
marginTop: 'var(--f-theme-settings-quote-margin-top)',
|
|
130
|
+
marginBottom: 'var(--f-theme-settings-quote-margin-bottom)',
|
|
131
|
+
textDecoration: 'var(--f-theme-settings-quote-text-decoration)',
|
|
132
|
+
fontStyle: 'var(--f-theme-settings-quote-font-style)',
|
|
133
|
+
textTransform: 'var(--f-theme-settings-quote-text-transform)' as CSSProperties['textTransform'],
|
|
134
|
+
letterSpacing: 'var(--f-theme-settings-quote-letter-spacing)',
|
|
135
|
+
fontWeight: 'var(--f-theme-settings-quote-font-weight)',
|
|
136
|
+
fontFamily: 'var(--f-theme-settings-quote-font-family)',
|
|
137
|
+
color: 'var(--f-theme-settings-quote-color)',
|
|
138
|
+
},
|
|
139
|
+
[TextStyles.imageCaption]: {
|
|
140
|
+
fontSize: 'var(--f-theme-settings-image-caption-font-size)',
|
|
141
|
+
lineHeight: 'var(--f-theme-settings-image-caption-line-height)',
|
|
142
|
+
marginTop: 'var(--f-theme-settings-image-caption-margin-top)',
|
|
143
|
+
marginBottom: 'var(--f-theme-settings-image-caption-margin-bottom)',
|
|
144
|
+
textDecoration: 'var(--f-theme-settings-image-caption-text-decoration)',
|
|
145
|
+
fontStyle: 'var(--f-theme-settings-image-caption-font-style)',
|
|
146
|
+
textTransform: 'var(--f-theme-settings-image-caption-text-transform)' as CSSProperties['textTransform'],
|
|
147
|
+
letterSpacing: 'var(--f-theme-settings-image-caption-letter-spacing)',
|
|
148
|
+
fontWeight: 'var(--f-theme-settings-image-caption-font-weight)',
|
|
149
|
+
fontFamily: 'var(--f-theme-settings-image-caption-font-family)',
|
|
150
|
+
color: 'var(--f-theme-settings-image-caption-color)',
|
|
151
|
+
},
|
|
152
|
+
[TextStyles.imageTitle]: {
|
|
153
|
+
fontSize: 'var(--f-theme-settings-image-title-font-size)',
|
|
154
|
+
lineHeight: 'var(--f-theme-settings-image-title-line-height)',
|
|
155
|
+
marginTop: 'var(--f-theme-settings-image-title-margin-top)',
|
|
156
|
+
marginBottom: 'var(--f-theme-settings-image-title-margin-bottom)',
|
|
157
|
+
textDecoration: 'var(--f-theme-settings-image-title-text-decoration)',
|
|
158
|
+
fontStyle: 'var(--f-theme-settings-image-title-font-style)',
|
|
159
|
+
textTransform: 'var(--f-theme-settings-image-title-text-transform)' as CSSProperties['textTransform'],
|
|
160
|
+
letterSpacing: 'var(--f-theme-settings-image-title-letter-spacing)',
|
|
161
|
+
fontWeight: 'var(--f-theme-settings-image-title-font-weight)',
|
|
162
|
+
fontFamily: 'var(--f-theme-settings-image-title-font-family)',
|
|
163
|
+
color: 'var(--f-theme-settings-image-title-color)',
|
|
164
|
+
},
|
|
165
|
+
[LINK_PLUGIN]: {
|
|
166
|
+
fontSize: 'var(--f-theme-settings-link-font-size)',
|
|
167
|
+
lineHeight: 'var(--f-theme-settings-link-line-height)',
|
|
168
|
+
marginTop: 'var(--f-theme-settings-link-margin-top)',
|
|
169
|
+
marginBottom: 'var(--f-theme-settings-link-margin-bottom)',
|
|
170
|
+
textDecoration: 'var(--f-theme-settings-link-text-decoration)',
|
|
171
|
+
fontStyle: 'var(--f-theme-settings-link-font-style)',
|
|
172
|
+
textTransform: 'var(--f-theme-settings-link-text-transform)' as CSSProperties['textTransform'],
|
|
173
|
+
letterSpacing: 'var(--f-theme-settings-link-letter-spacing)',
|
|
174
|
+
fontWeight: 'var(--f-theme-settings-link-font-weight)',
|
|
175
|
+
fontFamily: 'var(--f-theme-settings-link-font-family)',
|
|
176
|
+
color: 'var(--f-theme-settings-link-color)',
|
|
177
|
+
},
|
|
178
|
+
...BlockButtonStyles,
|
|
179
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { TElement } from '@udecode/plate';
|
|
4
|
+
import { reactCssPropsToCss } from '../utlis/reactCssPropsToCss';
|
|
5
|
+
import { CSSProperties } from 'react';
|
|
6
|
+
import { BUTTON_PLUGIN } from '../../plugins';
|
|
7
|
+
|
|
8
|
+
export type ButtonStylesType = Record<string, Record<string, CSSProperties & { hover?: CSSProperties }>>;
|
|
9
|
+
|
|
10
|
+
export const buttonNode = (node: TElement, children: string, defaultClassNames: string, styles: ButtonStylesType) => {
|
|
11
|
+
const buttonStyles = styles[BUTTON_PLUGIN];
|
|
12
|
+
const buttonTypeString = (node.buttonStyle as string) ?? 'primary';
|
|
13
|
+
const buttonType = `button${buttonTypeString.charAt(0).toUpperCase()}${buttonTypeString.slice(1)}`;
|
|
14
|
+
const buttonStyle = buttonStyles[buttonType];
|
|
15
|
+
|
|
16
|
+
const defaultStyles = reactCssPropsToCss(buttonStyle);
|
|
17
|
+
|
|
18
|
+
return `<a href="${node.url}"
|
|
19
|
+
target="${node.target ?? '_blank'}"
|
|
20
|
+
style="${defaultStyles}"
|
|
21
|
+
class="${defaultClassNames}"
|
|
22
|
+
onmouseenter="this.setAttribute('style', '${defaultStyles} ${reactCssPropsToCss(buttonStyle?.hover)}');"
|
|
23
|
+
onmouseleave="this.setAttribute('style', '${reactCssPropsToCss(buttonStyle)}');"
|
|
24
|
+
>${children}</a>`;
|
|
25
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { merge } from '@frontify/fondue';
|
|
4
|
+
import { TElement } from '@udecode/plate';
|
|
5
|
+
import { CSSProperties } from 'react';
|
|
6
|
+
import { reactCssPropsToCss } from '../utlis/reactCssPropsToCss';
|
|
7
|
+
|
|
8
|
+
export const checkItemNode = (
|
|
9
|
+
node: TElement,
|
|
10
|
+
children: string,
|
|
11
|
+
defaultClassNames: string,
|
|
12
|
+
styles: Record<string, CSSProperties & { hover?: CSSProperties }>
|
|
13
|
+
) => {
|
|
14
|
+
return `<div disabled class="tw-flex tw-flex-row tw-pb-2 first-of-type:tw-ml-0 ${defaultClassNames}" style="margin-left:${
|
|
15
|
+
((node.indent as number) ?? 0) * 24
|
|
16
|
+
}px;">
|
|
17
|
+
<div class="tw-flex tw-items-center tw-justify-center tw-select-none tw-mr-1.5">
|
|
18
|
+
<input
|
|
19
|
+
class="tw-w-4 tw-h-4 tw-m-0"
|
|
20
|
+
type="checkbox"
|
|
21
|
+
${node.checked ? 'checked' : ''}
|
|
22
|
+
onclick="return false;" />
|
|
23
|
+
</div>
|
|
24
|
+
<span class="${merge([
|
|
25
|
+
'tw-flex-1 tw-focus:outline-none',
|
|
26
|
+
node.checked ? '!tw-line-through' : '',
|
|
27
|
+
])}" style="${reactCssPropsToCss(styles[node.children[0].textStyle as string])}">${children}</span>
|
|
28
|
+
</div>`;
|
|
29
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { TElement } from '@udecode/plate';
|
|
4
|
+
import { CSSProperties } from 'react';
|
|
5
|
+
import { TextStyles } from '../../plugins';
|
|
6
|
+
import { reactCssPropsToCss } from '../utlis/reactCssPropsToCss';
|
|
7
|
+
import { merge } from '@frontify/fondue';
|
|
8
|
+
|
|
9
|
+
export const defaultNode = (node: TElement, children: string, styles: CSSProperties, defaultClassNames: string) => {
|
|
10
|
+
const defaultStyles = reactCssPropsToCss(styles);
|
|
11
|
+
|
|
12
|
+
if (node.type === TextStyles.heading1) {
|
|
13
|
+
return `<h1 class="${merge([defaultClassNames, 'a-h1'])}">${getStyledChild(children, defaultStyles)}</h1>`;
|
|
14
|
+
}
|
|
15
|
+
if (node.type === TextStyles.heading2) {
|
|
16
|
+
return `<h2 class="${defaultClassNames}">${getStyledChild(children, defaultStyles)}</h2>`;
|
|
17
|
+
}
|
|
18
|
+
if (node.type === TextStyles.heading3) {
|
|
19
|
+
return `<h3 class="${defaultClassNames}">${getStyledChild(children, defaultStyles)}</h3>`;
|
|
20
|
+
}
|
|
21
|
+
if (node.type === TextStyles.heading4) {
|
|
22
|
+
return `<h4 class="${defaultClassNames}">${getStyledChild(children, defaultStyles)}</h4>`;
|
|
23
|
+
}
|
|
24
|
+
if (node.type === TextStyles.custom1) {
|
|
25
|
+
return `<p class="${merge([defaultClassNames, 'a-custom1'])}">${getStyledChild(children, defaultStyles)}</p>`;
|
|
26
|
+
}
|
|
27
|
+
if (node.type === TextStyles.custom2) {
|
|
28
|
+
return `<p class="${merge([defaultClassNames, 'a-custom2'])}">${getStyledChild(children, defaultStyles)}</p>`;
|
|
29
|
+
}
|
|
30
|
+
if (node.type === TextStyles.custom3) {
|
|
31
|
+
return `<p class="${merge([defaultClassNames, 'a-custom3'])}">${getStyledChild(children, defaultStyles)}</p>`;
|
|
32
|
+
}
|
|
33
|
+
if (node.type === TextStyles.quote) {
|
|
34
|
+
return `<p class="${merge([defaultClassNames, 'a-quote'])}">${getStyledChild(children, defaultStyles)}</p>`;
|
|
35
|
+
}
|
|
36
|
+
if (node.type === TextStyles.imageTitle) {
|
|
37
|
+
return `<p class="${merge([defaultClassNames, 'a-image-title'])}">${getStyledChild(
|
|
38
|
+
children,
|
|
39
|
+
defaultStyles
|
|
40
|
+
)}</p>`;
|
|
41
|
+
}
|
|
42
|
+
if (node.type === TextStyles.imageCaption) {
|
|
43
|
+
return `<p class="${merge([defaultClassNames, 'a-image-caption'])}">${getStyledChild(
|
|
44
|
+
children,
|
|
45
|
+
defaultStyles
|
|
46
|
+
)}</p>`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return `<p class="${defaultClassNames}">${getStyledChild(children, defaultStyles)}</p>`;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getStyledChild = (children: string, styles: string) => `<span style="${styles}">${children}</span>`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { TElement } from '@udecode/plate';
|
|
4
|
+
import { LINK_PLUGIN } from '../../plugins/LinkPlugin/id';
|
|
5
|
+
import { TLinkElement } from '../../plugins/LinkPlugin/types';
|
|
6
|
+
import { reactCssPropsToCss } from '../utlis/reactCssPropsToCss';
|
|
7
|
+
import escapeHtml from 'escape-html';
|
|
8
|
+
import { CSSProperties } from 'react';
|
|
9
|
+
|
|
10
|
+
export const linkNode = (
|
|
11
|
+
node: TElement,
|
|
12
|
+
children: string,
|
|
13
|
+
defaultClassNames: string,
|
|
14
|
+
styles: Record<string, CSSProperties & { hover?: CSSProperties }>
|
|
15
|
+
) => {
|
|
16
|
+
if (node.chosenLink) {
|
|
17
|
+
const { chosenLink } = node as TLinkElement;
|
|
18
|
+
return `<a class="${defaultClassNames}" style="${reactCssPropsToCss(styles[LINK_PLUGIN])}" target=${
|
|
19
|
+
chosenLink?.openInNewTab ? '_blank' : '_self'
|
|
20
|
+
} href="${escapeHtml(chosenLink?.searchResult?.link)}">${children}</a>`;
|
|
21
|
+
}
|
|
22
|
+
return `<a class="${defaultClassNames}" style="${reactCssPropsToCss(styles[LINK_PLUGIN])}" target="${
|
|
23
|
+
node?.target ?? '_blank'
|
|
24
|
+
}" href="${escapeHtml(node.url as string)}">${children}</a>`;
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import { TElement, TMentionElement } from '@udecode/plate';
|
|
5
|
+
import { MappedMentionableItems, MentionMarkupElementNode } from '@frontify/fondue';
|
|
6
|
+
|
|
7
|
+
type MentionHtmlNodeProps = { mentionable?: MappedMentionableItems };
|
|
8
|
+
|
|
9
|
+
export const mentionHtmlNode = (node: TElement, { mentionable }: MentionHtmlNodeProps = {}) => {
|
|
10
|
+
if (!mentionable) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const div = document.createElement('div');
|
|
15
|
+
ReactDOM.render(MentionMarkupElementNode(mentionable)({ element: node as TMentionElement }), div);
|
|
16
|
+
return div.innerHTML;
|
|
17
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ELEMENT_CHECK_ITEM,
|
|
5
|
+
LI_CLASSNAMES,
|
|
6
|
+
MappedMentionableItems,
|
|
7
|
+
OL_STYLES,
|
|
8
|
+
UL_CLASSES,
|
|
9
|
+
alignmentClassnames,
|
|
10
|
+
getLiStyles,
|
|
11
|
+
getLicElementClassNames,
|
|
12
|
+
getOrderedListClasses,
|
|
13
|
+
merge,
|
|
14
|
+
} from '@frontify/fondue';
|
|
15
|
+
import {
|
|
16
|
+
ELEMENT_LI,
|
|
17
|
+
ELEMENT_LIC,
|
|
18
|
+
ELEMENT_LINK,
|
|
19
|
+
ELEMENT_MENTION,
|
|
20
|
+
ELEMENT_OL,
|
|
21
|
+
ELEMENT_UL,
|
|
22
|
+
TDescendant,
|
|
23
|
+
TElement,
|
|
24
|
+
isText,
|
|
25
|
+
} from '@udecode/plate';
|
|
26
|
+
import { serializeLeafToHtml } from './utlis/serializeLeafToHtml';
|
|
27
|
+
import { reactCssPropsToCss } from './utlis/reactCssPropsToCss';
|
|
28
|
+
import { CSSProperties } from 'react';
|
|
29
|
+
import { ButtonStylesType, buttonNode } from './nodes/button';
|
|
30
|
+
import { linkNode } from './nodes/link';
|
|
31
|
+
import { defaultNode } from './nodes/default';
|
|
32
|
+
import { checkItemNode } from './nodes/checkItemNode';
|
|
33
|
+
import { mentionHtmlNode } from './nodes/mentionHtmlNode';
|
|
34
|
+
import { ELEMENT_BUTTON } from '../plugins';
|
|
35
|
+
|
|
36
|
+
const countNodesOfType = (nodes: TDescendant[], type: string): number => {
|
|
37
|
+
return nodes.reduce((acc, node) => {
|
|
38
|
+
if (node.type === type) {
|
|
39
|
+
acc++;
|
|
40
|
+
}
|
|
41
|
+
if (node.children) {
|
|
42
|
+
return acc + countNodesOfType(node.children as TDescendant[], type);
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
}, 0);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
type NestingCount = {
|
|
49
|
+
[type: string]: number;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type SerializeNodeToHtmlRecursiveOptions = {
|
|
53
|
+
mappedMentionable?: MappedMentionableItems;
|
|
54
|
+
nestingCount?: NestingCount;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const serializeNodeToHtmlRecursive = (
|
|
58
|
+
node: TDescendant,
|
|
59
|
+
styles: Record<string, CSSProperties & { hover?: CSSProperties }> | ButtonStylesType,
|
|
60
|
+
{ mappedMentionable, nestingCount = {} }: SerializeNodeToHtmlRecursiveOptions
|
|
61
|
+
): string => {
|
|
62
|
+
if (isText(node)) {
|
|
63
|
+
return serializeLeafToHtml(node);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const rootNestingCount = nestingCount[node.type] || countNodesOfType([node], node.type);
|
|
67
|
+
let children = '';
|
|
68
|
+
for (const element of node.children) {
|
|
69
|
+
children += serializeNodeToHtmlRecursive(element, styles, {
|
|
70
|
+
nestingCount: {
|
|
71
|
+
...nestingCount,
|
|
72
|
+
[element.type as string]: rootNestingCount,
|
|
73
|
+
},
|
|
74
|
+
mappedMentionable,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const htmlMapper = MapNodeTypesToHtml[node.type];
|
|
79
|
+
if (typeof htmlMapper !== 'undefined') {
|
|
80
|
+
return htmlMapper({
|
|
81
|
+
classNames: getClassNames(node.breakAfterColumn as string | undefined, node.align as string | undefined),
|
|
82
|
+
children,
|
|
83
|
+
rootNestingCount,
|
|
84
|
+
node,
|
|
85
|
+
mappedMentionable,
|
|
86
|
+
styles,
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
return defaultNode(
|
|
90
|
+
node,
|
|
91
|
+
children,
|
|
92
|
+
styles[node.type],
|
|
93
|
+
getClassNames(node.breakAfterColumn as string | undefined, node.align as string | undefined)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type Arguments = {
|
|
99
|
+
classNames: string;
|
|
100
|
+
children: string;
|
|
101
|
+
rootNestingCount: number;
|
|
102
|
+
node: TElement;
|
|
103
|
+
mappedMentionable?: MappedMentionableItems;
|
|
104
|
+
styles: Record<string, CSSProperties & { hover?: CSSProperties }> | ButtonStylesType;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const MapNodeTypesToHtml: { [key: string]: ({ ...args }: Arguments) => string } = {
|
|
108
|
+
[ELEMENT_UL]: (args) => `<ul class="${UL_CLASSES} ${args.classNames}">${args.children}</ul>`,
|
|
109
|
+
[ELEMENT_OL]: ({ classNames, children, node, rootNestingCount }) => {
|
|
110
|
+
const nestingLevel = Math.max(rootNestingCount - countNodesOfType([node], ELEMENT_OL), 0);
|
|
111
|
+
return `<ol class="${getOrderedListClasses(nestingLevel)} ${classNames}" style="${reactCssPropsToCss(
|
|
112
|
+
OL_STYLES
|
|
113
|
+
)}">${children}</ol>`;
|
|
114
|
+
},
|
|
115
|
+
[ELEMENT_LI]: ({ classNames, children, node, styles }) =>
|
|
116
|
+
`<li class="${classNames} ${LI_CLASSNAMES}" style="${reactCssPropsToCss(
|
|
117
|
+
getLiStyles(node, styles)
|
|
118
|
+
)}">${children}</li>`,
|
|
119
|
+
[ELEMENT_LIC]: ({ classNames, children, node }) =>
|
|
120
|
+
`<p class="${classNames} ${getLicElementClassNames(node)}"><span>${children}</span></p>`,
|
|
121
|
+
[ELEMENT_LINK]: ({ node, children, classNames, styles }) => linkNode(node, children, classNames, styles),
|
|
122
|
+
[ELEMENT_BUTTON]: ({ node, children, classNames, styles }) =>
|
|
123
|
+
buttonNode(node, children, classNames, styles as ButtonStylesType),
|
|
124
|
+
[ELEMENT_CHECK_ITEM]: ({ node, children, classNames, styles }) => checkItemNode(node, children, classNames, styles),
|
|
125
|
+
[ELEMENT_MENTION]: ({ node, mappedMentionable }) => mentionHtmlNode(node, { mentionable: mappedMentionable }),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const getClassNames = (breakAfterColumn?: string, align?: string) => {
|
|
129
|
+
const breakWordsClass = 'tw-break-words';
|
|
130
|
+
const columnBreakClasses =
|
|
131
|
+
breakAfterColumn === 'active' ? 'tw-break-after-column tw-break-inside-avoid-column' : '';
|
|
132
|
+
const alignClass = align ? alignmentClassnames[align] : '';
|
|
133
|
+
return merge([alignClass, breakWordsClass, columnBreakClasses]);
|
|
134
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { TDescendant } from '@udecode/plate';
|
|
4
|
+
import { PluginComposer, SerializeNodesToHtmlOptions, mapMentionable, parseRawValue } from '@frontify/fondue';
|
|
5
|
+
import { BlockStyles } from '../plugins';
|
|
6
|
+
import { serializeNodeToHtmlRecursive } from './serializeNodesToHtmlRecursive';
|
|
7
|
+
|
|
8
|
+
export const serializeRawToHtmlAsync = async (
|
|
9
|
+
raw: string,
|
|
10
|
+
columns: SerializeNodesToHtmlOptions['columns'] = 1,
|
|
11
|
+
columnGap: SerializeNodesToHtmlOptions['columnGap'] = 'normal',
|
|
12
|
+
plugins: PluginComposer = new PluginComposer()
|
|
13
|
+
): Promise<string> => {
|
|
14
|
+
const nodes = parseRawValue({ raw, plugins });
|
|
15
|
+
const styles = plugins.getStyles;
|
|
16
|
+
return Promise.resolve(serializeNodesToHtml(nodes, { columns, columnGap, styles }));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const serializeNodesToHtml = (
|
|
20
|
+
nodes: TDescendant[],
|
|
21
|
+
{ mentionable, columns = 1, columnGap = 'normal', styles = BlockStyles }: SerializeNodesToHtmlOptions = {}
|
|
22
|
+
): string => {
|
|
23
|
+
const mappedMentionable = mentionable ? mapMentionable(mentionable) : new Map();
|
|
24
|
+
|
|
25
|
+
let html = '';
|
|
26
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
27
|
+
const node = nodes[i];
|
|
28
|
+
if (isEmptyNode(node)) {
|
|
29
|
+
html += '<br />';
|
|
30
|
+
} else {
|
|
31
|
+
html += serializeNodeToHtmlRecursive(node, styles, {
|
|
32
|
+
mappedMentionable,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (columns > 1) {
|
|
38
|
+
return `<div style="columns:${columns}; column-gap:${columnGap};">${html}</div>`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return html;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const isEmptyNode = (node: TDescendant): boolean => {
|
|
45
|
+
if (!Array.isArray(node?.children)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return node?.children?.every((child) => child.text === '');
|
|
49
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { CSSProperties } from 'react';
|
|
4
|
+
|
|
5
|
+
export const reactCssPropsToCss = (props?: CSSProperties): string => {
|
|
6
|
+
if (!props) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return Object.keys(props)
|
|
11
|
+
.reduce<string>((acc, key) => {
|
|
12
|
+
const value = props[key as keyof CSSProperties];
|
|
13
|
+
return value ? `${acc}${convertCamelCaseToKebabCase(key)}: ${value}; ` : acc;
|
|
14
|
+
}, '')
|
|
15
|
+
.trim()
|
|
16
|
+
.replaceAll('"', "'");
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const convertCamelCaseToKebabCase = (str: string): string => {
|
|
20
|
+
return str.replaceAll(/([A-Z])/g, '-$1').toLowerCase();
|
|
21
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { BOLD_CLASSES, CODE_CLASSES, ITALIC_CLASSES, STRIKETHROUGH_CLASSES, UNDERLINE_CLASSES } from '@frontify/fondue';
|
|
4
|
+
import { TText } from '@udecode/plate';
|
|
5
|
+
import escapeHtml from 'escape-html';
|
|
6
|
+
|
|
7
|
+
export const serializeLeafToHtml = (node: TText): string => {
|
|
8
|
+
let string = escapeHtml(node.text);
|
|
9
|
+
string = string.replaceAll('\n', '<br />');
|
|
10
|
+
const { bold, italic, underline, strikethrough, code, subscript, superscript } = node;
|
|
11
|
+
if (bold) {
|
|
12
|
+
string = `<span class="${BOLD_CLASSES}">${string}</span>`;
|
|
13
|
+
}
|
|
14
|
+
if (italic) {
|
|
15
|
+
string = `<span class="${ITALIC_CLASSES}">${string}</span>`;
|
|
16
|
+
}
|
|
17
|
+
if (underline) {
|
|
18
|
+
string = `<span class="${UNDERLINE_CLASSES}">${string}</span>`;
|
|
19
|
+
}
|
|
20
|
+
if (strikethrough) {
|
|
21
|
+
string = `<span class="${STRIKETHROUGH_CLASSES}">${string}</span>`;
|
|
22
|
+
}
|
|
23
|
+
if (code) {
|
|
24
|
+
string = `<span class="${CODE_CLASSES}">${string}</span>`;
|
|
25
|
+
}
|
|
26
|
+
if (subscript) {
|
|
27
|
+
string = `<sub>${string}</sub>`;
|
|
28
|
+
} else if (superscript) {
|
|
29
|
+
string = `<sup>${string}</sup>`;
|
|
30
|
+
}
|
|
31
|
+
return string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { PluginComposer } from '@frontify/fondue';
|
|
4
|
+
|
|
5
|
+
export type RichTextEditorProps = {
|
|
6
|
+
id?: string;
|
|
7
|
+
isEditing: boolean;
|
|
8
|
+
value?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
columns?: number;
|
|
11
|
+
gap?: string;
|
|
12
|
+
plugins?: PluginComposer;
|
|
13
|
+
showSerializedText?: boolean;
|
|
14
|
+
onTextChange?: (value: string) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type SerializedTextProps = {
|
|
18
|
+
value?: string;
|
|
19
|
+
show?: boolean;
|
|
20
|
+
columns?: number;
|
|
21
|
+
gap?: string;
|
|
22
|
+
plugins?: PluginComposer;
|
|
23
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { addHttps } from './addHttps';
|
|
5
|
+
|
|
6
|
+
describe('String converted to Richtext value', () => {
|
|
7
|
+
it('should return rich text value with correct textStyle', () => {
|
|
8
|
+
const url = 'https://www.frontify.com';
|
|
9
|
+
const result = addHttps(url);
|
|
10
|
+
expect(result).toBe(url);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should not add https:// for mailto', () => {
|
|
14
|
+
const url = 'mailto:info@frontify.com';
|
|
15
|
+
const result = addHttps(url);
|
|
16
|
+
expect(result).toBe(url);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should not add https:// for tel', () => {
|
|
20
|
+
const url = 'tel:+41 44 552 02 22';
|
|
21
|
+
const result = addHttps(url);
|
|
22
|
+
expect(result).toBe(url);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should add https://', () => {
|
|
26
|
+
const url = 'frontify.com';
|
|
27
|
+
const result = addHttps(url);
|
|
28
|
+
expect(result).toBe('https://frontify.com');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should not add https:// for relative url', () => {
|
|
32
|
+
const url = '/document/123';
|
|
33
|
+
const result = addHttps(url);
|
|
34
|
+
expect(result).toBe(url);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should not add https:// for http://', () => {
|
|
38
|
+
const url = 'http://localhost:3000/document/123';
|
|
39
|
+
const result = addHttps(url);
|
|
40
|
+
expect(result).toBe(url);
|
|
41
|
+
});
|
|
42
|
+
});
|