@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,48 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { withAppBridgeBlockStubs } from '@frontify/app-bridge';
|
|
4
|
+
import { mount } from 'cypress/react18';
|
|
5
|
+
import { BlockInjectButton } from './BlockInjectButton';
|
|
6
|
+
import { IconAdobeCreativeCloud } from '@frontify/fondue';
|
|
7
|
+
|
|
8
|
+
const BlockInjectButtonSelector = '[data-test-id="block-inject-button"]';
|
|
9
|
+
const ActionMenuItemSelector = '[data-test-id="menu-item"]';
|
|
10
|
+
|
|
11
|
+
describe('Block Inject Button', () => {
|
|
12
|
+
it('renders a simple block inject button', () => {
|
|
13
|
+
const [BlockInjectButtonWithStubs] = withAppBridgeBlockStubs(BlockInjectButton, {});
|
|
14
|
+
|
|
15
|
+
mount(
|
|
16
|
+
<BlockInjectButtonWithStubs
|
|
17
|
+
label="label"
|
|
18
|
+
icon={<IconAdobeCreativeCloud />}
|
|
19
|
+
secondaryLabel="second label"
|
|
20
|
+
withMenu={false}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
cy.get(BlockInjectButtonSelector)
|
|
24
|
+
.should('exist')
|
|
25
|
+
.should('have.class', 'first:tw-rounded-tl last:tw-rounded-br', 'first:tw-rounded-bl last:tw-rounded-tr');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders a block inject button with Menu upload and asset', () => {
|
|
29
|
+
const [BlockInjectButtonWithStubs] = withAppBridgeBlockStubs(BlockInjectButton, {});
|
|
30
|
+
|
|
31
|
+
mount(
|
|
32
|
+
<BlockInjectButtonWithStubs
|
|
33
|
+
label="label"
|
|
34
|
+
secondaryLabel="second label"
|
|
35
|
+
onAssetChooseClick={cy.stub().as('onClickOpenAssetChooser')}
|
|
36
|
+
onUploadClick={cy.stub().as('onClickonUploadClick')}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
cy.get(BlockInjectButtonSelector).click();
|
|
40
|
+
cy.get(ActionMenuItemSelector).should('have.length', 2);
|
|
41
|
+
cy.get(ActionMenuItemSelector).eq(0).should('have.text', 'Upload asset').click();
|
|
42
|
+
cy.get('@onClickonUploadClick').should('have.been.calledOnce');
|
|
43
|
+
|
|
44
|
+
cy.get(BlockInjectButtonSelector).click();
|
|
45
|
+
cy.get(ActionMenuItemSelector).eq(1).should('have.text', 'Browse asset').click();
|
|
46
|
+
cy.get('@onClickOpenAssetChooser').should('have.been.calledOnce');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ActionMenu,
|
|
5
|
+
Flyout,
|
|
6
|
+
IconArrowCircleUp20,
|
|
7
|
+
IconExclamationMarkTriangle,
|
|
8
|
+
IconImageStack20,
|
|
9
|
+
LoadingCircle,
|
|
10
|
+
MenuItemContentSize,
|
|
11
|
+
} from '@frontify/fondue';
|
|
12
|
+
import { DragEventHandler, MouseEventHandler, useRef, useState } from 'react';
|
|
13
|
+
import { joinClassNames } from '../../utilities/react/joinClassNames';
|
|
14
|
+
import { BlockInjectButtonProps } from './types';
|
|
15
|
+
import { FileExtension, FileExtensionSets } from '@frontify/app-bridge';
|
|
16
|
+
|
|
17
|
+
export const BlockInjectButton = ({
|
|
18
|
+
onDrop,
|
|
19
|
+
label,
|
|
20
|
+
icon,
|
|
21
|
+
secondaryLabel,
|
|
22
|
+
isLoading,
|
|
23
|
+
fillParentContainer,
|
|
24
|
+
onAssetChooseClick,
|
|
25
|
+
onUploadClick,
|
|
26
|
+
withMenu = true,
|
|
27
|
+
onClick,
|
|
28
|
+
validFileType,
|
|
29
|
+
verticalLayout,
|
|
30
|
+
}: BlockInjectButtonProps) => {
|
|
31
|
+
const [isDraggingOver, setIsDraggingOver] = useState(false);
|
|
32
|
+
const [menuPosition, setMenuPosition] = useState<[number, number] | undefined>();
|
|
33
|
+
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
34
|
+
const [errorMsg, setErrorMsg] = useState<string | undefined>(undefined);
|
|
35
|
+
|
|
36
|
+
const handleDrop: DragEventHandler<HTMLButtonElement> = (event) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
setIsDraggingOver(false);
|
|
39
|
+
if (!isValidAsset(event.dataTransfer.files)) {
|
|
40
|
+
setErrorMsg('Invalid');
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
setErrorMsg(undefined);
|
|
43
|
+
}, 1000);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
onDrop?.(event.dataTransfer.files);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const isValidAsset = (files: FileList) => {
|
|
50
|
+
if (!validFileType) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
for (let i = 0; i < files.length; i++) {
|
|
54
|
+
const droppedFileExtension = (files[i].name.split('.').pop() ?? '') as FileExtension;
|
|
55
|
+
if (!FileExtensionSets[validFileType].includes(droppedFileExtension)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const openMenu: MouseEventHandler<HTMLButtonElement> = (event) => {
|
|
63
|
+
if (!buttonRef.current || isLoading) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const { left, top } = buttonRef.current.getBoundingClientRect();
|
|
67
|
+
const XInsideComponent = event.clientX - left;
|
|
68
|
+
const YInsideComponent = event.clientY - top;
|
|
69
|
+
setMenuPosition([XInsideComponent, YInsideComponent]);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<button
|
|
74
|
+
ref={buttonRef}
|
|
75
|
+
data-test-id="block-inject-button"
|
|
76
|
+
className={joinClassNames([
|
|
77
|
+
'tw-font-body tw-relative tw-text-sm tw-leading-4 tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br',
|
|
78
|
+
verticalLayout
|
|
79
|
+
? '[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl'
|
|
80
|
+
: '[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr',
|
|
81
|
+
fillParentContainer ? 'tw-h-full' : 'tw-h-[72px]',
|
|
82
|
+
isDraggingOver && !isLoading ? 'tw-border-dashed' : 'tw-border-solid',
|
|
83
|
+
menuPosition && 'tw-bg-blank-state-pressed-inverse',
|
|
84
|
+
isDraggingOver && 'tw-bg-blank-state-weak-inverse',
|
|
85
|
+
errorMsg ? '!tw-border-red-50 !tw-cursor-not-allowed' : ' tw-border-blank-state-line',
|
|
86
|
+
isLoading || menuPosition || isDraggingOver || errorMsg
|
|
87
|
+
? ''
|
|
88
|
+
: 'tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover',
|
|
89
|
+
(isDraggingOver || !!menuPosition) && !errorMsg
|
|
90
|
+
? '[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover'
|
|
91
|
+
: 'tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded',
|
|
92
|
+
])}
|
|
93
|
+
onDragEnter={
|
|
94
|
+
onDrop
|
|
95
|
+
? (event) => {
|
|
96
|
+
setIsDraggingOver(true);
|
|
97
|
+
// is now only used for images, can be adapted if needed
|
|
98
|
+
if (validFileType === 'Images') {
|
|
99
|
+
for (const item of Array.from(event.dataTransfer.items)) {
|
|
100
|
+
if (!item?.type?.startsWith('image/')) {
|
|
101
|
+
setErrorMsg('Invalid');
|
|
102
|
+
} else {
|
|
103
|
+
setErrorMsg(undefined);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
: undefined
|
|
109
|
+
}
|
|
110
|
+
onDragLeave={
|
|
111
|
+
onDrop
|
|
112
|
+
? () => {
|
|
113
|
+
setIsDraggingOver(false);
|
|
114
|
+
setErrorMsg(undefined);
|
|
115
|
+
}
|
|
116
|
+
: undefined
|
|
117
|
+
}
|
|
118
|
+
onDrop={onDrop ? handleDrop : undefined}
|
|
119
|
+
onClick={(event) => {
|
|
120
|
+
withMenu && openMenu(event);
|
|
121
|
+
onClick?.();
|
|
122
|
+
}}
|
|
123
|
+
>
|
|
124
|
+
{isLoading ? (
|
|
125
|
+
<LoadingCircle />
|
|
126
|
+
) : // eslint-disable-next-line unicorn/no-nested-ternary
|
|
127
|
+
errorMsg ? (
|
|
128
|
+
<div className=" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium">
|
|
129
|
+
<IconExclamationMarkTriangle />
|
|
130
|
+
{errorMsg}
|
|
131
|
+
</div>
|
|
132
|
+
) : (
|
|
133
|
+
<>
|
|
134
|
+
{icon && <div>{icon}</div>}
|
|
135
|
+
{(label || secondaryLabel) && (
|
|
136
|
+
<div className="tw-flex tw-flex-col tw-items-start">
|
|
137
|
+
{label && <div className="tw-font-medium">{label}</div>}
|
|
138
|
+
{secondaryLabel && <div className="tw-font-normal">{secondaryLabel}</div>}
|
|
139
|
+
</div>
|
|
140
|
+
)}
|
|
141
|
+
</>
|
|
142
|
+
)}
|
|
143
|
+
{menuPosition && (
|
|
144
|
+
<div
|
|
145
|
+
className="tw-absolute tw-left-0 tw-top-full tw-z-20"
|
|
146
|
+
style={{
|
|
147
|
+
left: menuPosition[0],
|
|
148
|
+
top: menuPosition[1],
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<Flyout
|
|
152
|
+
onOpenChange={(isOpen) => !isOpen && setMenuPosition(undefined)}
|
|
153
|
+
isOpen={true}
|
|
154
|
+
fitContent
|
|
155
|
+
hug={false}
|
|
156
|
+
legacyFooter={false}
|
|
157
|
+
trigger={<div />}
|
|
158
|
+
>
|
|
159
|
+
<ActionMenu
|
|
160
|
+
menuBlocks={[
|
|
161
|
+
{
|
|
162
|
+
id: 'menu',
|
|
163
|
+
menuItems: [
|
|
164
|
+
...(onUploadClick
|
|
165
|
+
? [
|
|
166
|
+
{
|
|
167
|
+
id: 'upload',
|
|
168
|
+
size: MenuItemContentSize.XSmall,
|
|
169
|
+
title: 'Upload asset',
|
|
170
|
+
onClick: () => {
|
|
171
|
+
onUploadClick();
|
|
172
|
+
setMenuPosition(undefined);
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
initialValue: true,
|
|
176
|
+
decorator: (
|
|
177
|
+
<div className="tw-mr-2">
|
|
178
|
+
<IconArrowCircleUp20 />
|
|
179
|
+
</div>
|
|
180
|
+
),
|
|
181
|
+
},
|
|
182
|
+
]
|
|
183
|
+
: []),
|
|
184
|
+
...(onAssetChooseClick
|
|
185
|
+
? [
|
|
186
|
+
{
|
|
187
|
+
id: 'asset',
|
|
188
|
+
size: MenuItemContentSize.XSmall,
|
|
189
|
+
title: 'Browse asset',
|
|
190
|
+
onClick: () => {
|
|
191
|
+
onAssetChooseClick();
|
|
192
|
+
setMenuPosition(undefined);
|
|
193
|
+
},
|
|
194
|
+
initialValue: true,
|
|
195
|
+
decorator: (
|
|
196
|
+
<div className="tw-mr-2">
|
|
197
|
+
<IconImageStack20 />
|
|
198
|
+
</div>
|
|
199
|
+
),
|
|
200
|
+
},
|
|
201
|
+
]
|
|
202
|
+
: []),
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
]}
|
|
206
|
+
/>
|
|
207
|
+
</Flyout>
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
</button>
|
|
211
|
+
);
|
|
212
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type { FileType } from '@frontify/app-bridge';
|
|
4
|
+
|
|
5
|
+
export type BlockInjectButtonProps = {
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
validFileType?: keyof typeof FileType;
|
|
9
|
+
secondaryLabel?: string;
|
|
10
|
+
icon?: JSX.Element;
|
|
11
|
+
onDrop?: (files: FileList) => void;
|
|
12
|
+
fillParentContainer?: boolean;
|
|
13
|
+
onUploadClick?: () => void;
|
|
14
|
+
onAssetChooseClick?: () => void;
|
|
15
|
+
withMenu?: boolean;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
verticalLayout?: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { IconMagnifier16 } from '@frontify/fondue';
|
|
4
|
+
import { mount } from 'cypress/react18';
|
|
5
|
+
import { BlockItemWrapper } from './BlockItemWrapper';
|
|
6
|
+
|
|
7
|
+
const BlockItemWrapperSelector = '[data-test-id="block-item-wrapper"]';
|
|
8
|
+
const ToolbarSelector = '[data-test-id="block-item-wrapper-toolbar"]';
|
|
9
|
+
const FlyoutSelector = '[data-test-id="block-item-wrapper-toolbar-flyout"]';
|
|
10
|
+
const MenuItemSelector = '[data-test-id="menu-item"]';
|
|
11
|
+
const ToolbarButtonSelector = '[data-test-id="block-item-wrapper-toolbar-btn"]';
|
|
12
|
+
const ChildSelector = '[data-test-id="block-item-wrapper-child"]';
|
|
13
|
+
|
|
14
|
+
describe('Block Item Wrapper', () => {
|
|
15
|
+
it('should render the wrapper and the children', () => {
|
|
16
|
+
mount(
|
|
17
|
+
<BlockItemWrapper toolbarFlyoutItems={[]} toolbarItems={[]}>
|
|
18
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
19
|
+
</BlockItemWrapper>
|
|
20
|
+
);
|
|
21
|
+
cy.get(BlockItemWrapperSelector).should('exist');
|
|
22
|
+
cy.get(ChildSelector).should('exist');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should render the outline class', () => {
|
|
26
|
+
mount(
|
|
27
|
+
<BlockItemWrapper toolbarFlyoutItems={[]} toolbarItems={[]}>
|
|
28
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
29
|
+
</BlockItemWrapper>
|
|
30
|
+
);
|
|
31
|
+
cy.get(BlockItemWrapperSelector).should('have.class', 'hover:tw-outline');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should not render the outline class if the hide prop is set', () => {
|
|
35
|
+
mount(
|
|
36
|
+
<BlockItemWrapper toolbarFlyoutItems={[]} toolbarItems={[]} shouldHideWrapper>
|
|
37
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
38
|
+
</BlockItemWrapper>
|
|
39
|
+
);
|
|
40
|
+
cy.get(BlockItemWrapperSelector).should('not.exist');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should render the right amount of toolbar items', () => {
|
|
44
|
+
mount(
|
|
45
|
+
<BlockItemWrapper
|
|
46
|
+
toolbarFlyoutItems={[]}
|
|
47
|
+
toolbarItems={[
|
|
48
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
49
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
50
|
+
]}
|
|
51
|
+
>
|
|
52
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
53
|
+
</BlockItemWrapper>
|
|
54
|
+
);
|
|
55
|
+
cy.get(ToolbarButtonSelector).should('have.length', 2);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should render the flyout button with the right amount of menu items', () => {
|
|
59
|
+
mount(
|
|
60
|
+
<BlockItemWrapper
|
|
61
|
+
toolbarFlyoutItems={[
|
|
62
|
+
[
|
|
63
|
+
{
|
|
64
|
+
icon: <IconMagnifier16 />,
|
|
65
|
+
onClick: cy.stub(),
|
|
66
|
+
title: 'Test title',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
icon: <IconMagnifier16 />,
|
|
72
|
+
onClick: cy.stub(),
|
|
73
|
+
title: 'Test title',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
icon: <IconMagnifier16 />,
|
|
77
|
+
onClick: cy.stub(),
|
|
78
|
+
title: 'Test title',
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
]}
|
|
82
|
+
toolbarItems={[
|
|
83
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
84
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
85
|
+
]}
|
|
86
|
+
>
|
|
87
|
+
<div data-test-id="block-item-wrapper-child" className="tw-mt-8 tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
88
|
+
</BlockItemWrapper>
|
|
89
|
+
);
|
|
90
|
+
cy.get(ToolbarButtonSelector).eq(0).focus();
|
|
91
|
+
cy.get(FlyoutSelector).should('exist');
|
|
92
|
+
cy.get(FlyoutSelector).click({ force: true });
|
|
93
|
+
cy.get(MenuItemSelector).should('have.length', 3);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should render the outline if a toolbar button is focused', () => {
|
|
97
|
+
mount(
|
|
98
|
+
<BlockItemWrapper
|
|
99
|
+
toolbarFlyoutItems={[]}
|
|
100
|
+
toolbarItems={[
|
|
101
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
102
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
103
|
+
]}
|
|
104
|
+
>
|
|
105
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
106
|
+
</BlockItemWrapper>
|
|
107
|
+
);
|
|
108
|
+
cy.get(ToolbarButtonSelector).eq(0).focus();
|
|
109
|
+
cy.get(BlockItemWrapperSelector).should('have.css', 'outline-style', 'solid');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should render the toolbar if a button is focused', () => {
|
|
113
|
+
mount(
|
|
114
|
+
<BlockItemWrapper
|
|
115
|
+
toolbarFlyoutItems={[]}
|
|
116
|
+
shouldHideComponent={false}
|
|
117
|
+
toolbarItems={[
|
|
118
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
119
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
120
|
+
]}
|
|
121
|
+
>
|
|
122
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
123
|
+
</BlockItemWrapper>
|
|
124
|
+
);
|
|
125
|
+
cy.get(ToolbarButtonSelector).eq(0).focus();
|
|
126
|
+
cy.get(ToolbarSelector).should('be.visible');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should render the outline and the toolbar if enabled', () => {
|
|
130
|
+
mount(
|
|
131
|
+
<BlockItemWrapper
|
|
132
|
+
toolbarFlyoutItems={[]}
|
|
133
|
+
toolbarItems={[
|
|
134
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
135
|
+
{ icon: <IconMagnifier16 />, onClick: cy.stub(), tooltip: 'Test tooltip' },
|
|
136
|
+
]}
|
|
137
|
+
shouldBeShown
|
|
138
|
+
>
|
|
139
|
+
<div data-test-id="block-item-wrapper-child" className="tw-w-8 tw-h-8 tw-bg-red-50" />
|
|
140
|
+
</BlockItemWrapper>
|
|
141
|
+
);
|
|
142
|
+
cy.get(ChildSelector).should('exist');
|
|
143
|
+
cy.get(BlockItemWrapperSelector).should('have.css', 'outline-style', 'solid');
|
|
144
|
+
cy.get(ToolbarSelector).should('be.visible');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { PropsWithChildren, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { joinClassNames } from '../../utilities';
|
|
5
|
+
import { Toolbar } from './Toolbar';
|
|
6
|
+
import { BlockItemWrapperProps, ToolbarItem } from './types';
|
|
7
|
+
|
|
8
|
+
export const BlockItemWrapper = ({
|
|
9
|
+
children,
|
|
10
|
+
toolbarFlyoutItems,
|
|
11
|
+
toolbarItems,
|
|
12
|
+
shouldHideWrapper,
|
|
13
|
+
shouldHideComponent = false,
|
|
14
|
+
isDragging,
|
|
15
|
+
shouldFillContainer,
|
|
16
|
+
outlineOffset = 2,
|
|
17
|
+
shouldBeShown = false,
|
|
18
|
+
}: PropsWithChildren<BlockItemWrapperProps>) => {
|
|
19
|
+
const [isFlyoutOpen, setIsFlyoutOpen] = useState(shouldBeShown);
|
|
20
|
+
const [isFlyoutDisabled, setIsFlyoutDisabled] = useState(false);
|
|
21
|
+
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!isFlyoutOpen) {
|
|
25
|
+
// This prevents automatic refocusing of the trigger element
|
|
26
|
+
setIsFlyoutDisabled(true);
|
|
27
|
+
}
|
|
28
|
+
}, [isFlyoutOpen]);
|
|
29
|
+
|
|
30
|
+
if (shouldHideWrapper) {
|
|
31
|
+
return children;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const items = toolbarItems?.filter((item): item is ToolbarItem => item !== undefined);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div
|
|
38
|
+
ref={wrapperRef}
|
|
39
|
+
onFocus={() => setIsFlyoutDisabled(false)}
|
|
40
|
+
onPointerEnter={() => setIsFlyoutDisabled(false)}
|
|
41
|
+
data-test-id="block-item-wrapper"
|
|
42
|
+
style={{
|
|
43
|
+
outlineOffset,
|
|
44
|
+
}}
|
|
45
|
+
className={joinClassNames([
|
|
46
|
+
'tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse',
|
|
47
|
+
shouldFillContainer && 'tw-flex-1 tw-h-full tw-w-full',
|
|
48
|
+
'hover:tw-outline focus-within:tw-outline',
|
|
49
|
+
(isFlyoutOpen || shouldBeShown) && 'tw-outline',
|
|
50
|
+
shouldHideComponent && 'tw-opacity-0',
|
|
51
|
+
])}
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
style={{
|
|
55
|
+
right: -1 - outlineOffset,
|
|
56
|
+
bottom: `calc(100% - ${2 + outlineOffset}px)`,
|
|
57
|
+
}}
|
|
58
|
+
className={joinClassNames([
|
|
59
|
+
'tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-10',
|
|
60
|
+
'group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100',
|
|
61
|
+
(isFlyoutOpen || shouldBeShown) && 'tw-opacity-100',
|
|
62
|
+
])}
|
|
63
|
+
>
|
|
64
|
+
<Toolbar
|
|
65
|
+
isFlyoutOpen={isFlyoutOpen}
|
|
66
|
+
isFlyoutDisabled={isFlyoutDisabled}
|
|
67
|
+
setIsFlyoutOpen={setIsFlyoutOpen}
|
|
68
|
+
flyoutItems={toolbarFlyoutItems}
|
|
69
|
+
items={items}
|
|
70
|
+
isDragging={isDragging}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
{children}
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ActionMenu,
|
|
5
|
+
Flyout,
|
|
6
|
+
IconDotsHorizontal16,
|
|
7
|
+
MenuItemContentSize,
|
|
8
|
+
Tooltip,
|
|
9
|
+
TooltipPosition,
|
|
10
|
+
} from '@frontify/fondue';
|
|
11
|
+
import { ToolbarProps } from './types';
|
|
12
|
+
import { joinClassNames } from '../../utilities';
|
|
13
|
+
import { DEFAULT_DRAGGING_TOOLTIP, DEFAULT_DRAG_TOOLTIP } from './constants';
|
|
14
|
+
|
|
15
|
+
export const Toolbar = ({
|
|
16
|
+
items,
|
|
17
|
+
flyoutItems,
|
|
18
|
+
isFlyoutOpen,
|
|
19
|
+
setIsFlyoutOpen,
|
|
20
|
+
isDragging,
|
|
21
|
+
isFlyoutDisabled,
|
|
22
|
+
}: ToolbarProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<div data-test-id="block-item-wrapper-toolbar" className="tw-flex tw-justify-end">
|
|
25
|
+
<div className="tw-bg-white tw-text-box-selected-inverse tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-[2px] tw-px-[1px] tw-spacing tw-items-center tw-h-7 tw-self-start tw-border tw-border-box-selected-inverse tw-rounded">
|
|
26
|
+
{items.map((item, i) =>
|
|
27
|
+
'draggableProps' in item ? (
|
|
28
|
+
<Tooltip
|
|
29
|
+
key={i}
|
|
30
|
+
withArrow
|
|
31
|
+
hoverDelay={0}
|
|
32
|
+
enterDelay={300}
|
|
33
|
+
open={isDragging}
|
|
34
|
+
position={TooltipPosition.Top}
|
|
35
|
+
content={
|
|
36
|
+
<div>
|
|
37
|
+
{isDragging ? DEFAULT_DRAGGING_TOOLTIP : item.tooltip ?? DEFAULT_DRAG_TOOLTIP}
|
|
38
|
+
</div>
|
|
39
|
+
}
|
|
40
|
+
triggerElement={
|
|
41
|
+
<button
|
|
42
|
+
ref={item.setActivatorNodeRef}
|
|
43
|
+
data-test-id="block-item-wrapper-toolbar-btn"
|
|
44
|
+
{...item.draggableProps}
|
|
45
|
+
className={joinClassNames([
|
|
46
|
+
'tw-bg-base tw-inline-flex tw-items-center tw-justify-center tw-w-6 tw-h-6 tw-rounded-sm',
|
|
47
|
+
isDragging
|
|
48
|
+
? 'tw-cursor-grabbing tw-bg-box-selected-pressed'
|
|
49
|
+
: 'tw-cursor-grab hover:tw-bg-box-selected-hover',
|
|
50
|
+
])}
|
|
51
|
+
>
|
|
52
|
+
{item.icon}
|
|
53
|
+
</button>
|
|
54
|
+
}
|
|
55
|
+
/>
|
|
56
|
+
) : (
|
|
57
|
+
<Tooltip
|
|
58
|
+
key={i}
|
|
59
|
+
withArrow
|
|
60
|
+
enterDelay={300}
|
|
61
|
+
hoverDelay={0}
|
|
62
|
+
disabled={isDragging}
|
|
63
|
+
position={TooltipPosition.Top}
|
|
64
|
+
content={<div>{item.tooltip ?? ''}</div>}
|
|
65
|
+
triggerElement={
|
|
66
|
+
<button
|
|
67
|
+
data-test-id="block-item-wrapper-toolbar-btn"
|
|
68
|
+
onClick={item.onClick}
|
|
69
|
+
className="tw-bg-base hover:tw-bg-box-selected-hover active:tw-bg-box-selected-pressed tw-cursor-pointer tw-inline-flex tw-items-center tw-justify-center tw-w-6 tw-h-6 tw-rounded-sm"
|
|
70
|
+
>
|
|
71
|
+
{item.icon}
|
|
72
|
+
</button>
|
|
73
|
+
}
|
|
74
|
+
/>
|
|
75
|
+
)
|
|
76
|
+
)}
|
|
77
|
+
{flyoutItems.length > 0 && (
|
|
78
|
+
<div className="tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6">
|
|
79
|
+
<Flyout
|
|
80
|
+
isOpen={isFlyoutOpen && !isDragging}
|
|
81
|
+
isTriggerDisabled={isFlyoutDisabled}
|
|
82
|
+
legacyFooter={false}
|
|
83
|
+
fitContent
|
|
84
|
+
hug={false}
|
|
85
|
+
onOpenChange={setIsFlyoutOpen}
|
|
86
|
+
trigger={
|
|
87
|
+
<Tooltip
|
|
88
|
+
withArrow
|
|
89
|
+
hoverDelay={0}
|
|
90
|
+
enterDelay={300}
|
|
91
|
+
disabled={isDragging}
|
|
92
|
+
position={TooltipPosition.Top}
|
|
93
|
+
content={<div>Options</div>}
|
|
94
|
+
triggerElement={
|
|
95
|
+
<div
|
|
96
|
+
data-test-id="block-item-wrapper-toolbar-flyout"
|
|
97
|
+
className="tw-bg-base hover:tw-bg-box-selected-hover active:tw-bg-box-selected-pressed tw-cursor-pointer tw-inline-flex tw-items-center tw-justify-center tw-w-6 tw-h-6 tw-rounded-sm"
|
|
98
|
+
>
|
|
99
|
+
<IconDotsHorizontal16 />
|
|
100
|
+
</div>
|
|
101
|
+
}
|
|
102
|
+
/>
|
|
103
|
+
}
|
|
104
|
+
>
|
|
105
|
+
<ActionMenu
|
|
106
|
+
menuBlocks={flyoutItems.map((block, blockIndex) => ({
|
|
107
|
+
id: blockIndex.toString(),
|
|
108
|
+
menuItems: block.map((item, itemIndex) => ({
|
|
109
|
+
id: blockIndex.toString() + itemIndex.toString(),
|
|
110
|
+
size: MenuItemContentSize.XSmall,
|
|
111
|
+
title: item.title,
|
|
112
|
+
style: item.style,
|
|
113
|
+
onClick: () => {
|
|
114
|
+
setIsFlyoutOpen(false);
|
|
115
|
+
item.onClick();
|
|
116
|
+
},
|
|
117
|
+
initialValue: true,
|
|
118
|
+
decorator: <div className="tw-mr-2">{item.icon}</div>,
|
|
119
|
+
})),
|
|
120
|
+
}))}
|
|
121
|
+
/>
|
|
122
|
+
</Flyout>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
};
|