@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
package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/types.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { CheckboxState } from '@frontify/fondue';
|
|
4
|
+
|
|
5
|
+
export type InsertModalDispatchType = { type: string; payload?: Partial<InsertModalStateProps> };
|
|
6
|
+
|
|
7
|
+
export type InsertModalStateProps = {
|
|
8
|
+
url: string;
|
|
9
|
+
text: string;
|
|
10
|
+
newTab: CheckboxState;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type InitiallyExpandedItems = {
|
|
14
|
+
documentId: number | undefined;
|
|
15
|
+
pageId: number | undefined;
|
|
16
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ELEMENT_LINK,
|
|
5
|
+
FloatingLinkProps,
|
|
6
|
+
HTMLPropsAs,
|
|
7
|
+
LinkPlugin,
|
|
8
|
+
floatingLinkActions,
|
|
9
|
+
getPluginOptions,
|
|
10
|
+
getSelectionBoundingClientRect,
|
|
11
|
+
triggerFloatingLinkInsert,
|
|
12
|
+
useComposedRef,
|
|
13
|
+
useEditorRef,
|
|
14
|
+
useFloatingLinkEscape,
|
|
15
|
+
useFloatingLinkSelectors,
|
|
16
|
+
useHotkeys,
|
|
17
|
+
useVirtualFloatingLink,
|
|
18
|
+
} from '@udecode/plate';
|
|
19
|
+
import { useEffect } from 'react';
|
|
20
|
+
import { useFocused } from 'slate-react';
|
|
21
|
+
|
|
22
|
+
export const useFloatingLinkInsert = ({ floatingOptions, ...props }: FloatingLinkProps): HTMLPropsAs<'div'> => {
|
|
23
|
+
const editor = useEditorRef();
|
|
24
|
+
const focused = useFocused();
|
|
25
|
+
const mode = useFloatingLinkSelectors().mode();
|
|
26
|
+
const open = useFloatingLinkSelectors().isOpen(editor.id);
|
|
27
|
+
|
|
28
|
+
const { triggerFloatingLinkHotkeys } = getPluginOptions<LinkPlugin>(editor, ELEMENT_LINK);
|
|
29
|
+
|
|
30
|
+
useHotkeys(
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
+
triggerFloatingLinkHotkeys!,
|
|
33
|
+
(e) => {
|
|
34
|
+
if (triggerFloatingLinkInsert(editor, { focused })) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
enableOnContentEditable: true,
|
|
40
|
+
},
|
|
41
|
+
[focused]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const { update, style, floating } = useVirtualFloatingLink({
|
|
45
|
+
editorId: editor.id,
|
|
46
|
+
open: open && mode === 'insert',
|
|
47
|
+
getBoundingClientRect: getSelectionBoundingClientRect,
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
49
|
+
whileElementsMounted: () => {},
|
|
50
|
+
...floatingOptions,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// wait for update before focusing input
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (open) {
|
|
56
|
+
update();
|
|
57
|
+
floatingLinkActions.updated(true);
|
|
58
|
+
} else {
|
|
59
|
+
floatingLinkActions.updated(false);
|
|
60
|
+
}
|
|
61
|
+
}, [open, update]);
|
|
62
|
+
|
|
63
|
+
useFloatingLinkEscape();
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
style: {
|
|
67
|
+
...style,
|
|
68
|
+
zIndex: 1000,
|
|
69
|
+
},
|
|
70
|
+
...props,
|
|
71
|
+
ref: useComposedRef<HTMLElement | null>(props.ref, floating),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { AppBridgeBlock } from '@frontify/app-bridge';
|
|
4
|
+
import { CheckboxState } from '@frontify/fondue';
|
|
5
|
+
import {
|
|
6
|
+
ELEMENT_LINK,
|
|
7
|
+
floatingLinkActions,
|
|
8
|
+
floatingLinkSelectors,
|
|
9
|
+
getPluginOptions,
|
|
10
|
+
submitFloatingLink,
|
|
11
|
+
useEditorRef,
|
|
12
|
+
useHotkeys,
|
|
13
|
+
} from '@udecode/plate';
|
|
14
|
+
import { Dispatch, Reducer, useEffect, useReducer } from 'react';
|
|
15
|
+
import { getLegacyUrl, getUrl } from '../../utils';
|
|
16
|
+
import { InsertModalDispatchType, InsertModalStateProps } from './types';
|
|
17
|
+
import { addHttps } from '../../../../../../helpers';
|
|
18
|
+
import { isValidUrlOrEmpty } from '../../utils/url';
|
|
19
|
+
|
|
20
|
+
const initialState: InsertModalStateProps = {
|
|
21
|
+
url: '',
|
|
22
|
+
text: '',
|
|
23
|
+
newTab: CheckboxState.Unchecked,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const InsertModalState = (): [InsertModalStateProps, Dispatch<InsertModalDispatchType>] => {
|
|
27
|
+
const [state, dispatch] = useReducer<Reducer<InsertModalStateProps, InsertModalDispatchType>>((state, action) => {
|
|
28
|
+
const { type, payload } = action;
|
|
29
|
+
|
|
30
|
+
switch (type) {
|
|
31
|
+
case 'NEW_TAB':
|
|
32
|
+
return {
|
|
33
|
+
...state,
|
|
34
|
+
newTab: CheckboxState.Checked,
|
|
35
|
+
};
|
|
36
|
+
case 'SAME_TAB':
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
newTab: CheckboxState.Unchecked,
|
|
40
|
+
};
|
|
41
|
+
case 'URL':
|
|
42
|
+
case 'TEXT':
|
|
43
|
+
case 'INIT':
|
|
44
|
+
return {
|
|
45
|
+
...state,
|
|
46
|
+
...payload,
|
|
47
|
+
};
|
|
48
|
+
default:
|
|
49
|
+
return state;
|
|
50
|
+
}
|
|
51
|
+
}, initialState);
|
|
52
|
+
|
|
53
|
+
return [state, dispatch];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const useInsertModal = () => {
|
|
57
|
+
const editor = useEditorRef();
|
|
58
|
+
const [state, dispatch] = InsertModalState();
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const legacyUrl = getLegacyUrl(editor);
|
|
62
|
+
const url = getUrl(editor);
|
|
63
|
+
|
|
64
|
+
dispatch({
|
|
65
|
+
type: 'INIT',
|
|
66
|
+
payload: {
|
|
67
|
+
text: floatingLinkSelectors.text(),
|
|
68
|
+
newTab: floatingLinkSelectors.newTab() ? CheckboxState.Checked : CheckboxState.Unchecked,
|
|
69
|
+
url: legacyUrl && url === '' ? legacyUrl : floatingLinkSelectors.url(),
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}, [dispatch, editor]);
|
|
73
|
+
|
|
74
|
+
const onTextChange = (value: string) => {
|
|
75
|
+
dispatch({
|
|
76
|
+
type: 'TEXT',
|
|
77
|
+
payload: { text: value },
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const onUrlChange = (value: string) => {
|
|
82
|
+
dispatch({
|
|
83
|
+
type: 'URL',
|
|
84
|
+
payload: { url: value },
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const onToggleTab = (checked: boolean) => {
|
|
89
|
+
checked ? dispatch({ type: 'NEW_TAB' }) : dispatch({ type: 'SAME_TAB' });
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const onCancel = () => {
|
|
93
|
+
floatingLinkActions.hide();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const onSave = (event: React.MouseEvent<HTMLButtonElement, MouseEvent> | KeyboardEvent | undefined) => {
|
|
97
|
+
if (!isValidUrlOrEmpty(state.url) || !hasValues) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const urlToSave = addHttps(state.url);
|
|
102
|
+
|
|
103
|
+
floatingLinkActions.text(state.text);
|
|
104
|
+
floatingLinkActions.url(urlToSave);
|
|
105
|
+
floatingLinkActions.newTab(state.newTab === CheckboxState.Checked);
|
|
106
|
+
|
|
107
|
+
if (submitFloatingLink(editor)) {
|
|
108
|
+
event?.preventDefault();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const hasValues = state.url !== '' && state.text !== '';
|
|
113
|
+
|
|
114
|
+
const { appBridge } = getPluginOptions<{ appBridge: AppBridgeBlock }>(editor, ELEMENT_LINK);
|
|
115
|
+
|
|
116
|
+
useHotkeys(
|
|
117
|
+
'enter',
|
|
118
|
+
onSave,
|
|
119
|
+
{
|
|
120
|
+
enableOnFormTags: ['INPUT'],
|
|
121
|
+
},
|
|
122
|
+
[]
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
state,
|
|
127
|
+
onTextChange,
|
|
128
|
+
onUrlChange,
|
|
129
|
+
onToggleTab,
|
|
130
|
+
onCancel,
|
|
131
|
+
onSave,
|
|
132
|
+
hasValues,
|
|
133
|
+
isValidUrlOrEmpty,
|
|
134
|
+
appBridge,
|
|
135
|
+
};
|
|
136
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
IconLink,
|
|
5
|
+
IconSize,
|
|
6
|
+
PluginButtonProps,
|
|
7
|
+
getButtonClassNames,
|
|
8
|
+
getHotkeyByPlatform,
|
|
9
|
+
getTooltip,
|
|
10
|
+
} from '@frontify/fondue';
|
|
11
|
+
import { LinkToolbarButton, isRangeInSameBlock, useEventPlateId, usePlateEditorState } from '@udecode/plate';
|
|
12
|
+
|
|
13
|
+
export const LinkButton = ({ id, editorId }: PluginButtonProps) => {
|
|
14
|
+
const editor = usePlateEditorState(useEventPlateId(editorId));
|
|
15
|
+
const isEnabled = !!isRangeInSameBlock(editor, {
|
|
16
|
+
at: editor.selection,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div data-plugin-id={id}>
|
|
21
|
+
<LinkToolbarButton
|
|
22
|
+
tooltip={getTooltip(
|
|
23
|
+
isEnabled
|
|
24
|
+
? `Link\n${getHotkeyByPlatform('Ctrl+K')}`
|
|
25
|
+
: 'Links can only be set for a single text block.'
|
|
26
|
+
)}
|
|
27
|
+
icon={
|
|
28
|
+
<span className="tw-p-2 tw-h-8 tw-justify-center tw-items-center tw-flex">
|
|
29
|
+
<IconLink size={IconSize.Size16} />
|
|
30
|
+
</span>
|
|
31
|
+
}
|
|
32
|
+
classNames={getButtonClassNames(isEnabled)}
|
|
33
|
+
styles={{ root: { width: '24px', height: '24px' } }}
|
|
34
|
+
actionHandler="onMouseDown"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
};
|
package/src/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { HTMLPropsAs, LinkRootProps, useElementProps } from '@udecode/plate';
|
|
4
|
+
import { MouseEvent } from 'react';
|
|
5
|
+
import { TLinkElement } from '../types';
|
|
6
|
+
import { BlockStyles } from '../../styles';
|
|
7
|
+
import { LINK_PLUGIN } from '../id';
|
|
8
|
+
|
|
9
|
+
const useLink = (props: LinkRootProps): HTMLPropsAs<'a'> => {
|
|
10
|
+
const _props = useElementProps<TLinkElement, 'a'>({
|
|
11
|
+
...props,
|
|
12
|
+
elementToAttributes: (element) => ({
|
|
13
|
+
href: element.url || element.chosenLink?.searchResult?.link || '',
|
|
14
|
+
target: element.target || '_blank',
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
..._props,
|
|
20
|
+
// quick fix: hovering <a> with href loses the editor focus
|
|
21
|
+
onMouseOver: (event: MouseEvent) => {
|
|
22
|
+
event.stopPropagation();
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const LinkMarkupElementNode = (props: LinkRootProps) => {
|
|
28
|
+
const htmlProps = useLink(props);
|
|
29
|
+
const { attributes, children } = props;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<a {...attributes} href={htmlProps.href} target={htmlProps.target} style={BlockStyles[LINK_PLUGIN]}>
|
|
33
|
+
{children}
|
|
34
|
+
</a>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { MarkupElement } from '@frontify/fondue';
|
|
4
|
+
import { ELEMENT_LINK } from '@udecode/plate';
|
|
5
|
+
import { LinkMarkupElementNode } from './LinkMarkupElementNode';
|
|
6
|
+
|
|
7
|
+
export class LinkMarkupElement extends MarkupElement {
|
|
8
|
+
constructor(id = ELEMENT_LINK, node = LinkMarkupElementNode) {
|
|
9
|
+
super(id, node);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { AppBridgeBlock } from '@frontify/app-bridge';
|
|
4
|
+
import { Plugin, PluginProps } from '@frontify/fondue';
|
|
5
|
+
import { createLinkPlugin as createPlateLinkPlugin, createPluginFactory } from '@udecode/plate';
|
|
6
|
+
import { CustomFloatingLink } from './FloatingLink/CustomFloatingLink';
|
|
7
|
+
import { LINK_PLUGIN } from './id';
|
|
8
|
+
import { LinkButton } from './LinkButton';
|
|
9
|
+
import { LinkMarkupElement } from './LinkMarkupElement';
|
|
10
|
+
import { isValidUrl } from './utils/url';
|
|
11
|
+
import { CSSProperties } from 'react';
|
|
12
|
+
import { BlockStyles } from '../styles';
|
|
13
|
+
|
|
14
|
+
export const createLinkPlugin = (appBridge: AppBridgeBlock) =>
|
|
15
|
+
createPluginFactory({
|
|
16
|
+
...createPlateLinkPlugin(),
|
|
17
|
+
renderAfterEditable: CustomFloatingLink,
|
|
18
|
+
options: {
|
|
19
|
+
isUrl: isValidUrl,
|
|
20
|
+
rangeBeforeOptions: {
|
|
21
|
+
matchString: ' ',
|
|
22
|
+
skipInvalid: true,
|
|
23
|
+
afterMatch: true,
|
|
24
|
+
},
|
|
25
|
+
triggerFloatingLinkHotkeys: 'command+k, ctrl+k',
|
|
26
|
+
appBridge,
|
|
27
|
+
},
|
|
28
|
+
})();
|
|
29
|
+
|
|
30
|
+
export type LinkPluginProps = PluginProps & { appBridge: AppBridgeBlock };
|
|
31
|
+
|
|
32
|
+
export class LinkPlugin extends Plugin {
|
|
33
|
+
private appBridge: AppBridgeBlock;
|
|
34
|
+
public styles: CSSProperties = {};
|
|
35
|
+
constructor(props?: LinkPluginProps, styles = BlockStyles[LINK_PLUGIN]) {
|
|
36
|
+
super(LINK_PLUGIN, {
|
|
37
|
+
button: LinkButton,
|
|
38
|
+
markupElement: new LinkMarkupElement(),
|
|
39
|
+
...props,
|
|
40
|
+
});
|
|
41
|
+
this.styles = styles;
|
|
42
|
+
this.appBridge = props?.appBridge as AppBridgeBlock;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
plugins() {
|
|
46
|
+
return [createLinkPlugin(this.appBridge)];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { TLinkElement as TPlateLinkElement } from '@udecode/plate';
|
|
4
|
+
|
|
5
|
+
export type TLinkElement = TPlateLinkElement & {
|
|
6
|
+
chosenLink?: {
|
|
7
|
+
searchResult?: {
|
|
8
|
+
link?: string;
|
|
9
|
+
};
|
|
10
|
+
openInNewTab?: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { ELEMENT_LINK, PlateEditor, getAboveNode } from '@udecode/plate';
|
|
4
|
+
import { TLinkElement } from '../types';
|
|
5
|
+
|
|
6
|
+
const getLinkNode = (editor: PlateEditor, cb: (link: TLinkElement) => string): string => {
|
|
7
|
+
const linkNode = getAboveNode<TLinkElement>(editor, { match: { type: ELEMENT_LINK } });
|
|
8
|
+
|
|
9
|
+
if (!Array.isArray(linkNode)) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return cb(linkNode[0]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getLegacyUrl = (editor: PlateEditor) => {
|
|
17
|
+
return getLinkNode(editor, (link) => link.chosenLink?.searchResult?.link || '');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const getUrl = (editor: PlateEditor) => {
|
|
21
|
+
return getLinkNode(editor, (link) => link.url || '');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getUrlFromLinkOrLegacyLink = (link: TLinkElement): string => {
|
|
25
|
+
return link.url || link.chosenLink?.searchResult?.link || '';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const getUrlFromEditor = (editor: PlateEditor) => {
|
|
29
|
+
return getLinkNode(editor, getUrlFromLinkOrLegacyLink);
|
|
30
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { relativeUrlRegex } from './relativeUrlRegex';
|
|
5
|
+
|
|
6
|
+
describe('Regex values', () => {
|
|
7
|
+
it('should only match internal documents starting with /r/ or /document/', () => {
|
|
8
|
+
const testData = [
|
|
9
|
+
{
|
|
10
|
+
input: '/document/123',
|
|
11
|
+
shouldMatch: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
input: '/r/123',
|
|
15
|
+
shouldMatch: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
input: '/wrong/123',
|
|
19
|
+
shouldMatch: false,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
input: '/r/',
|
|
23
|
+
shouldMatch: false,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
input: '/document/',
|
|
27
|
+
shouldMatch: false,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
for (const data of testData) {
|
|
31
|
+
const isMatching = relativeUrlRegex.test(data.input);
|
|
32
|
+
expect(isMatching).toBe(data.shouldMatch);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
import { isValidUrl } from './url';
|
|
5
|
+
|
|
6
|
+
describe('LinkPlugin URL utils', () => {
|
|
7
|
+
it('should validate isValidUrl', () => {
|
|
8
|
+
const testData = [
|
|
9
|
+
{
|
|
10
|
+
input: 'https://frontify.com',
|
|
11
|
+
shouldBeValid: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
input: 'http://frontify.com',
|
|
15
|
+
shouldBeValid: true,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
input: 'http://frontify.com/any/path',
|
|
19
|
+
shouldBeValid: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
input: 'https://product.frontify.com/any/path/with#3/',
|
|
23
|
+
shouldBeValid: true,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
input: 'mailto:hello@frontify.com',
|
|
27
|
+
shouldBeValid: true,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
input: 'tel:+123456789',
|
|
31
|
+
shouldBeValid: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
input: 'tel:',
|
|
35
|
+
shouldBeValid: false,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
input: 'anyword:',
|
|
39
|
+
shouldBeValid: false,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
input: '/r/123',
|
|
43
|
+
shouldBeValid: true,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
input: '/document/123',
|
|
47
|
+
shouldBeValid: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
input: '/wrongpage/123',
|
|
51
|
+
shouldBeValid: false,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
input: '+123456789',
|
|
55
|
+
shouldBeValid: false,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
input: 'hello@frontify.com',
|
|
59
|
+
shouldBeValid: false,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
input: 'frontify.com',
|
|
63
|
+
shouldBeValid: false,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
input: 'frontify',
|
|
67
|
+
shouldBeValid: false,
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
for (const data of testData) {
|
|
71
|
+
const isValid = isValidUrl(data.input);
|
|
72
|
+
expect(isValid).toBe(data.shouldBeValid);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { addHttps } from '../../../../../helpers';
|
|
4
|
+
import { relativeUrlRegex } from './relativeUrlRegex';
|
|
5
|
+
|
|
6
|
+
export const isValidUrl = (url: string) => {
|
|
7
|
+
if (relativeUrlRegex.test(url)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const parsedUrl = new URL(url);
|
|
12
|
+
const validProtocols = ['http:', 'https:', 'mailto:', 'tel:'];
|
|
13
|
+
return validProtocols.includes(parsedUrl.protocol) && parsedUrl.pathname !== '';
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const isValidUrlOrEmpty = (url: string) => {
|
|
20
|
+
return isValidUrl(addHttps(url)) || url === '';
|
|
21
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { createPluginFactory } from '@udecode/plate';
|
|
4
|
+
import { CSSProperties } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
MarkupElement,
|
|
7
|
+
Plugin,
|
|
8
|
+
PluginProps,
|
|
9
|
+
TextStyleRenderElementProps,
|
|
10
|
+
alignmentClassnames,
|
|
11
|
+
getColumnBreakClasses,
|
|
12
|
+
merge,
|
|
13
|
+
} from '@frontify/fondue';
|
|
14
|
+
import { BlockStyles, TextStyles } from '../styles';
|
|
15
|
+
|
|
16
|
+
const ID = 'textstyle-custom1-plugin';
|
|
17
|
+
|
|
18
|
+
export class Custom1Plugin extends Plugin {
|
|
19
|
+
public styles: CSSProperties = {};
|
|
20
|
+
constructor({ styles = BlockStyles.custom1, ...props }: PluginProps = {}) {
|
|
21
|
+
super(TextStyles.custom1, {
|
|
22
|
+
label: 'Custom 1',
|
|
23
|
+
markupElement: new Custom1MarkupElement(),
|
|
24
|
+
...props,
|
|
25
|
+
});
|
|
26
|
+
this.styles = styles;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
plugins() {
|
|
30
|
+
return [createCustom1Plugin(this.styles)];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class Custom1MarkupElement extends MarkupElement {
|
|
35
|
+
constructor(id = ID, node = Custom1MarkupElementNode) {
|
|
36
|
+
super(id, node);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Custom1MarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {
|
|
41
|
+
const align = element.align as string;
|
|
42
|
+
return (
|
|
43
|
+
<p
|
|
44
|
+
{...attributes}
|
|
45
|
+
className={merge([align && alignmentClassnames[align], getColumnBreakClasses(element), 'a-custom1'])}
|
|
46
|
+
>
|
|
47
|
+
<span style={styles}>{children}</span>
|
|
48
|
+
</p>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const createCustom1Plugin = (styles: CSSProperties) =>
|
|
53
|
+
createPluginFactory({
|
|
54
|
+
key: TextStyles.custom1,
|
|
55
|
+
isElement: true,
|
|
56
|
+
deserializeHtml: {
|
|
57
|
+
rules: [{ validClassName: TextStyles.custom1 }],
|
|
58
|
+
},
|
|
59
|
+
})({
|
|
60
|
+
component: (props: TextStyleRenderElementProps) => <Custom1MarkupElementNode {...props} styles={styles} />,
|
|
61
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { createPluginFactory } from '@udecode/plate';
|
|
4
|
+
import { CSSProperties } from 'react';
|
|
5
|
+
import {
|
|
6
|
+
MarkupElement,
|
|
7
|
+
Plugin,
|
|
8
|
+
PluginProps,
|
|
9
|
+
TextStyleRenderElementProps,
|
|
10
|
+
alignmentClassnames,
|
|
11
|
+
getColumnBreakClasses,
|
|
12
|
+
merge,
|
|
13
|
+
} from '@frontify/fondue';
|
|
14
|
+
import { BlockStyles, TextStyles } from '../styles';
|
|
15
|
+
|
|
16
|
+
const ID = 'textstyle-custom2-plugin';
|
|
17
|
+
|
|
18
|
+
export class Custom2Plugin extends Plugin {
|
|
19
|
+
public styles: CSSProperties = {};
|
|
20
|
+
constructor({ styles = BlockStyles.custom2, ...props }: PluginProps = {}) {
|
|
21
|
+
super(TextStyles.custom2, {
|
|
22
|
+
label: 'Custom 2',
|
|
23
|
+
markupElement: new Custom2MarkupElement(),
|
|
24
|
+
...props,
|
|
25
|
+
});
|
|
26
|
+
this.styles = styles;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
plugins() {
|
|
30
|
+
return [createCustom2Plugin(this.styles)];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
class Custom2MarkupElement extends MarkupElement {
|
|
35
|
+
constructor(id = ID, node = Custom2MarkupElementNode) {
|
|
36
|
+
super(id, node);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Custom2MarkupElementNode = ({ element, attributes, children, styles }: TextStyleRenderElementProps) => {
|
|
41
|
+
const align = element.align as string;
|
|
42
|
+
return (
|
|
43
|
+
<p
|
|
44
|
+
{...attributes}
|
|
45
|
+
className={merge([align && alignmentClassnames[align], getColumnBreakClasses(element), 'a-custom2'])}
|
|
46
|
+
>
|
|
47
|
+
<span style={styles}>{children}</span>
|
|
48
|
+
</p>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const createCustom2Plugin = (styles: CSSProperties) =>
|
|
53
|
+
createPluginFactory({
|
|
54
|
+
key: TextStyles.custom2,
|
|
55
|
+
isElement: true,
|
|
56
|
+
deserializeHtml: {
|
|
57
|
+
rules: [{ validClassName: TextStyles.custom2 }],
|
|
58
|
+
},
|
|
59
|
+
})({
|
|
60
|
+
component: (props: TextStyleRenderElementProps) => <Custom2MarkupElementNode {...props} styles={styles} />,
|
|
61
|
+
});
|