@frontify/guideline-blocks-settings 0.33.3 → 0.33.5
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/dist/components/Attachments/AttachmentItem.es.js +174 -0
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -0
- package/dist/components/Attachments/Attachments.es.js +160 -0
- package/dist/components/Attachments/Attachments.es.js.map +1 -0
- package/dist/components/Attachments/AttachmentsButtonTrigger.es.js +29 -0
- package/dist/components/Attachments/AttachmentsButtonTrigger.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 +71 -0
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButton.es.js +33 -0
- package/dist/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButtonTrigger.es.js +26 -0
- package/dist/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButtonTrigger.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/BaseToolbarButton.es.js +28 -0
- package/dist/components/BlockItemWrapper/Toolbar/BaseToolbarButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/DragHandleToolbarButton/DragHandleToolbarButton.es.js +35 -0
- package/dist/components/BlockItemWrapper/Toolbar/DragHandleToolbarButton/DragHandleToolbarButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/FlyoutToolbarButton/FlyoutToolbarButton.es.js +44 -0
- package/dist/components/BlockItemWrapper/Toolbar/FlyoutToolbarButton/FlyoutToolbarButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/MenuToolbarButton/MenuToolbarButton.es.js +25 -0
- package/dist/components/BlockItemWrapper/Toolbar/MenuToolbarButton/MenuToolbarButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/MenuToolbarButton/ToolbarFlyoutMenu.es.js +29 -0
- package/dist/components/BlockItemWrapper/Toolbar/MenuToolbarButton/ToolbarFlyoutMenu.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/Toolbar.es.js +22 -0
- package/dist/components/BlockItemWrapper/Toolbar/Toolbar.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/ToolbarButton/ToolbarButton.es.js +12 -0
- package/dist/components/BlockItemWrapper/Toolbar/ToolbarButton/ToolbarButton.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/ToolbarButtonTooltip.es.js +20 -0
- package/dist/components/BlockItemWrapper/Toolbar/ToolbarButtonTooltip.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/ToolbarSegment.es.js +6 -0
- package/dist/components/BlockItemWrapper/Toolbar/ToolbarSegment.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/context/DragPreviewContext.es.js +11 -0
- package/dist/components/BlockItemWrapper/Toolbar/context/DragPreviewContext.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/context/MultiFlyoutContext.es.js +18 -0
- package/dist/components/BlockItemWrapper/Toolbar/context/MultiFlyoutContext.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js +26 -0
- package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js.map +1 -0
- package/dist/components/BlockItemWrapper/Toolbar/hooks/useMultiFlyoutState.es.js +18 -0
- package/dist/components/BlockItemWrapper/Toolbar/hooks/useMultiFlyoutState.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/Link/LinkInput.es.js +63 -0
- package/dist/components/Link/LinkInput.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/DocumentLink.es.js +68 -0
- package/dist/components/Link/LinkSelector/DocumentLink.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/DocumentLinks.es.js +60 -0
- package/dist/components/Link/LinkSelector/DocumentLinks.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/LinkSelector.es.js +78 -0
- package/dist/components/Link/LinkSelector/LinkSelector.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/LoadingIndicator.es.js +7 -0
- package/dist/components/Link/LinkSelector/LoadingIndicator.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/PageLink.es.js +70 -0
- package/dist/components/Link/LinkSelector/PageLink.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/PageLinks.es.js +38 -0
- package/dist/components/Link/LinkSelector/PageLinks.es.js.map +1 -0
- package/dist/components/Link/LinkSelector/SectionLink.es.js +25 -0
- package/dist/components/Link/LinkSelector/SectionLink.es.js.map +1 -0
- package/dist/components/Link/utils/getUrl.es.js +18 -0
- package/dist/components/Link/utils/getUrl.es.js.map +1 -0
- package/dist/components/Link/utils/relativeUrlRegex.es.js +5 -0
- package/dist/components/Link/utils/relativeUrlRegex.es.js.map +1 -0
- package/dist/components/Link/utils/url.es.js +17 -0
- package/dist/components/Link/utils/url.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 +20 -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 +35 -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 +43 -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 +68 -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 +81 -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 +43 -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 +66 -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 +45 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/index.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js +52 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js +52 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js +52 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js +52 -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 +52 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js +52 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js +46 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js +54 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/styles.es.js +167 -0
- package/dist/components/RichTextEditor/plugins/styles.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 +28 -0
- package/dist/helpers/mapColorPalettes.es.js.map +1 -0
- package/dist/hooks/useAttachments.es.js +53 -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 +4 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +1193 -0
- package/dist/index.es.js +217 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +4 -0
- package/dist/index.umd.js.map +1 -0
- 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/styles.css +1 -0
- package/dist/styles.css.es.js +2 -0
- package/dist/styles.css.es.js.map +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 +8 -2
- package/.eslintrc.cjs +0 -27
- package/.prettierrc +0 -7
- package/CHANGELOG.md +0 -778
- package/postcss.config.cjs +0 -8
- package/setupTests.ts +0 -23
- package/src/components/Attachments/AttachmentItem.tsx +0 -247
- package/src/components/Attachments/Attachments.spec.ct.tsx +0 -165
- package/src/components/Attachments/Attachments.tsx +0 -241
- package/src/components/Attachments/AttachmentsButtonTrigger.tsx +0 -30
- package/src/components/Attachments/index.ts +0 -4
- package/src/components/Attachments/types.ts +0 -40
- package/src/components/BlockInjectButton/BlockInjectButton.spec.ct.tsx +0 -48
- package/src/components/BlockInjectButton/BlockInjectButton.tsx +0 -212
- package/src/components/BlockInjectButton/index.ts +0 -4
- package/src/components/BlockInjectButton/types.ts +0 -18
- package/src/components/BlockItemWrapper/BlockItemWrapper.spec.ct.tsx +0 -145
- package/src/components/BlockItemWrapper/BlockItemWrapper.tsx +0 -76
- package/src/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButton.spec.tsx +0 -96
- package/src/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButton.tsx +0 -42
- package/src/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButtonTrigger.spec.tsx +0 -44
- package/src/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/AttachmentsToolbarButtonTrigger.tsx +0 -24
- package/src/components/BlockItemWrapper/Toolbar/AttachmentsToolbarButton/index.ts +0 -3
- package/src/components/BlockItemWrapper/Toolbar/BaseToolbarButton.spec.tsx +0 -40
- package/src/components/BlockItemWrapper/Toolbar/BaseToolbarButton.tsx +0 -37
- package/src/components/BlockItemWrapper/Toolbar/DragHandleToolbarButton/DragHandleToolbarButton.spec.tsx +0 -89
- package/src/components/BlockItemWrapper/Toolbar/DragHandleToolbarButton/DragHandleToolbarButton.tsx +0 -40
- package/src/components/BlockItemWrapper/Toolbar/DragHandleToolbarButton/index.ts +0 -3
- package/src/components/BlockItemWrapper/Toolbar/FlyoutToolbarButton/FlyoutToolbarButton.spec.tsx +0 -140
- package/src/components/BlockItemWrapper/Toolbar/FlyoutToolbarButton/FlyoutToolbarButton.tsx +0 -61
- package/src/components/BlockItemWrapper/Toolbar/FlyoutToolbarButton/index.ts +0 -3
- package/src/components/BlockItemWrapper/Toolbar/MenuToolbarButton/MenuToolbarButton.spec.tsx +0 -77
- package/src/components/BlockItemWrapper/Toolbar/MenuToolbarButton/MenuToolbarButton.tsx +0 -30
- package/src/components/BlockItemWrapper/Toolbar/MenuToolbarButton/ToolbarFlyoutMenu.spec.tsx +0 -63
- package/src/components/BlockItemWrapper/Toolbar/MenuToolbarButton/ToolbarFlyoutMenu.tsx +0 -40
- package/src/components/BlockItemWrapper/Toolbar/MenuToolbarButton/index.ts +0 -4
- package/src/components/BlockItemWrapper/Toolbar/Toolbar.spec.tsx +0 -259
- package/src/components/BlockItemWrapper/Toolbar/Toolbar.tsx +0 -36
- package/src/components/BlockItemWrapper/Toolbar/ToolbarButton/ToolbarButton.spec.tsx +0 -70
- package/src/components/BlockItemWrapper/Toolbar/ToolbarButton/ToolbarButton.tsx +0 -19
- package/src/components/BlockItemWrapper/Toolbar/ToolbarButton/index.ts +0 -3
- package/src/components/BlockItemWrapper/Toolbar/ToolbarButtonTooltip.tsx +0 -25
- package/src/components/BlockItemWrapper/Toolbar/ToolbarSegment.tsx +0 -9
- package/src/components/BlockItemWrapper/Toolbar/context/DragPreviewContext.tsx +0 -15
- package/src/components/BlockItemWrapper/Toolbar/context/MultiFlyoutContext.tsx +0 -25
- package/src/components/BlockItemWrapper/Toolbar/context/index.ts +0 -4
- package/src/components/BlockItemWrapper/Toolbar/helpers.ts +0 -33
- package/src/components/BlockItemWrapper/Toolbar/hooks/index.ts +0 -3
- package/src/components/BlockItemWrapper/Toolbar/hooks/useMultiFlyoutState.spec.tsx +0 -59
- package/src/components/BlockItemWrapper/Toolbar/hooks/useMultiFlyoutState.ts +0 -24
- package/src/components/BlockItemWrapper/Toolbar/index.ts +0 -10
- package/src/components/BlockItemWrapper/Toolbar/types.ts +0 -18
- package/src/components/BlockItemWrapper/constants.ts +0 -4
- package/src/components/BlockItemWrapper/index.ts +0 -6
- package/src/components/BlockItemWrapper/types.ts +0 -24
- package/src/components/DownloadButton/DownloadButton.spec.ct.tsx +0 -20
- package/src/components/DownloadButton/DownloadButton.tsx +0 -36
- package/src/components/DownloadButton/index.ts +0 -3
- package/src/components/DownloadButton/types.ts +0 -5
- package/src/components/Link/LinkInput.spec.ct.tsx +0 -142
- package/src/components/Link/LinkInput.tsx +0 -86
- package/src/components/Link/LinkSelector/DocumentLink.tsx +0 -81
- package/src/components/Link/LinkSelector/DocumentLinks.tsx +0 -102
- package/src/components/Link/LinkSelector/LinkSelector.spec.ct.tsx +0 -196
- package/src/components/Link/LinkSelector/LinkSelector.tsx +0 -96
- package/src/components/Link/LinkSelector/LoadingIndicator.tsx +0 -11
- package/src/components/Link/LinkSelector/PageLink.tsx +0 -96
- package/src/components/Link/LinkSelector/PageLinks.tsx +0 -71
- package/src/components/Link/LinkSelector/SectionLink.tsx +0 -36
- package/src/components/Link/LinkSelector/index.ts +0 -3
- package/src/components/Link/index.ts +0 -6
- package/src/components/Link/types.ts +0 -6
- package/src/components/Link/utils/getUrl.ts +0 -30
- package/src/components/Link/utils/index.ts +0 -5
- package/src/components/Link/utils/relativeUrlRegex.spec.ts +0 -32
- package/src/components/Link/utils/relativeUrlRegex.ts +0 -3
- package/src/components/Link/utils/url.spec.ts +0 -75
- package/src/components/Link/utils/url.ts +0 -21
- package/src/components/RichTextEditor/RichTextEditor.spec.ct.tsx +0 -231
- package/src/components/RichTextEditor/RichTextEditor.tsx +0 -62
- package/src/components/RichTextEditor/SerializedText.tsx +0 -29
- package/src/components/RichTextEditor/constants.ts +0 -3
- package/src/components/RichTextEditor/index.ts +0 -6
- package/src/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.tsx +0 -55
- package/src/components/RichTextEditor/pluginPresets/index.ts +0 -3
- package/src/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/ButtonMarkupElementNode.tsx +0 -74
- package/src/components/RichTextEditor/plugins/ButtonPlugin/ButtonMarkupElement/index.ts +0 -11
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.tsx +0 -20
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.tsx +0 -56
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/CustomFloatingButton.tsx +0 -19
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.tsx +0 -42
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButton.tsx +0 -37
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonEditButton.tsx +0 -22
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/FloatingButtonUrlInput.tsx +0 -30
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/InsertButtonModal.tsx +0 -81
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/types.ts +0 -13
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.ts +0 -143
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/UnlinkButton.tsx +0 -31
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/floatingButtonStore.ts +0 -46
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/index.ts +0 -12
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEdit.ts +0 -113
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEnter.ts +0 -21
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonEscape.ts +0 -30
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useFloatingButtonInsert.ts +0 -71
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/useVirtualFloatingButton.ts +0 -22
- package/src/components/RichTextEditor/plugins/ButtonPlugin/components/index.ts +0 -3
- package/src/components/RichTextEditor/plugins/ButtonPlugin/createButtonPlugin.ts +0 -118
- package/src/components/RichTextEditor/plugins/ButtonPlugin/index.ts +0 -7
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/index.ts +0 -8
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/insertButton.ts +0 -17
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/submitFloatingButton.ts +0 -40
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/unwrapButton.ts +0 -68
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButton.ts +0 -198
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/upsertButtonText.ts +0 -40
- package/src/components/RichTextEditor/plugins/ButtonPlugin/transforms/wrapButton.ts +0 -30
- package/src/components/RichTextEditor/plugins/ButtonPlugin/types.ts +0 -13
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/createButtonNode.ts +0 -28
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/getButtonStyle.ts +0 -14
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/getUrl.ts +0 -18
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/index.ts +0 -8
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/styles.ts +0 -83
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButton.ts +0 -23
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonEdit.ts +0 -30
- package/src/components/RichTextEditor/plugins/ButtonPlugin/utils/triggerFloatingButtonInsert.ts +0 -45
- package/src/components/RichTextEditor/plugins/ButtonPlugin/withButton.ts +0 -106
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/CustomFloatingLink.tsx +0 -26
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.tsx +0 -43
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/index.ts +0 -4
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/useFloatingLinkEdit.ts +0 -113
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/FloatingLink.tsx +0 -45
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertLinkModal.tsx +0 -5
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/InsertModal.tsx +0 -88
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/index.ts +0 -4
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/types.ts +0 -11
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useFloatingLinkInsert.ts +0 -73
- package/src/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.ts +0 -136
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkButton.tsx +0 -38
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.tsx +0 -36
- package/src/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/index.ts +0 -11
- package/src/components/RichTextEditor/plugins/LinkPlugin/id.ts +0 -3
- package/src/components/RichTextEditor/plugins/LinkPlugin/index.ts +0 -49
- package/src/components/RichTextEditor/plugins/LinkPlugin/types.ts +0 -12
- package/src/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.tsx +0 -63
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.tsx +0 -63
- package/src/components/RichTextEditor/plugins/TextStylePlugins/helpers.tsx +0 -44
- package/src/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.tsx +0 -62
- package/src/components/RichTextEditor/plugins/TextStylePlugins/index.ts +0 -15
- package/src/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.tsx +0 -58
- package/src/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.tsx +0 -63
- package/src/components/RichTextEditor/plugins/index.ts +0 -6
- package/src/components/RichTextEditor/plugins/styles.ts +0 -178
- package/src/components/RichTextEditor/types.ts +0 -23
- package/src/components/index.ts +0 -8
- package/src/helpers/addHttps.spec.ts +0 -42
- package/src/helpers/addHttps.ts +0 -15
- package/src/helpers/convertToRichTextValue.spec.ts +0 -32
- package/src/helpers/convertToRichTextValue.ts +0 -6
- package/src/helpers/customCoordinatesGetterFactory.spec.ts +0 -69
- package/src/helpers/customCoordinatesGetterFactory.ts +0 -39
- package/src/helpers/hasRichTextValue.spec.ts +0 -63
- package/src/helpers/hasRichTextValue.ts +0 -29
- package/src/helpers/index.ts +0 -8
- package/src/helpers/isDownloadable.spec.ts +0 -47
- package/src/helpers/isDownloadable.ts +0 -7
- package/src/helpers/mapColorPalettes.spec.ts +0 -47
- package/src/helpers/mapColorPalettes.ts +0 -65
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useAttachments.spec.tsx +0 -127
- package/src/hooks/useAttachments.tsx +0 -90
- package/src/hooks/useDndSensors.spec.ts +0 -40
- package/src/hooks/useDndSensors.ts +0 -23
- package/src/index.ts +0 -138
- package/src/settings/background.spec.ts +0 -173
- package/src/settings/background.ts +0 -52
- package/src/settings/border.spec.ts +0 -76
- package/src/settings/border.ts +0 -90
- package/src/settings/borderRadius.spec.ts +0 -30
- package/src/settings/borderRadius.ts +0 -73
- package/src/settings/borderRadiusExtended.spec.ts +0 -52
- package/src/settings/borderRadiusExtended.ts +0 -84
- package/src/settings/defaultValues.ts +0 -21
- package/src/settings/gutter.spec.ts +0 -60
- package/src/settings/gutter.ts +0 -75
- package/src/settings/index.ts +0 -14
- package/src/settings/margin.spec.ts +0 -42
- package/src/settings/margin.ts +0 -72
- package/src/settings/marginExtended.spec.ts +0 -45
- package/src/settings/marginExtended.ts +0 -91
- package/src/settings/padding.spec.ts +0 -42
- package/src/settings/padding.ts +0 -73
- package/src/settings/paddingExtended.spec.ts +0 -45
- package/src/settings/paddingExtended.ts +0 -91
- package/src/settings/security.spec.ts +0 -87
- package/src/settings/security.ts +0 -61
- package/src/settings/securityDownloadable.spec.ts +0 -46
- package/src/settings/securityDownloadable.ts +0 -33
- package/src/settings/securityGlobalControl.ts +0 -42
- package/src/settings/types.ts +0 -128
- package/src/styles.css +0 -3
- package/src/utilities/color/getReadableColor.spec.ts +0 -32
- package/src/utilities/color/getReadableColor.ts +0 -34
- package/src/utilities/color/index.ts +0 -10
- package/src/utilities/color/isDark.spec.ts +0 -33
- package/src/utilities/color/isDark.ts +0 -29
- package/src/utilities/color/setAlpha.spec.ts +0 -28
- package/src/utilities/color/setAlpha.ts +0 -14
- package/src/utilities/color/toColorObject.spec.ts +0 -19
- package/src/utilities/color/toColorObject.ts +0 -16
- package/src/utilities/color/toHex8String.spec.ts +0 -17
- package/src/utilities/color/toHex8String.ts +0 -14
- package/src/utilities/color/toHexString.spec.ts +0 -17
- package/src/utilities/color/toHexString.ts +0 -10
- package/src/utilities/color/toRgbaString.spec.ts +0 -12
- package/src/utilities/color/toRgbaString.ts +0 -14
- package/src/utilities/color/toShortRgba.spec.ts +0 -16
- package/src/utilities/color/toShortRgba.ts +0 -35
- package/src/utilities/index.ts +0 -5
- package/src/utilities/moveItemInArray.spec.ts +0 -17
- package/src/utilities/moveItemInArray.ts +0 -21
- package/src/utilities/react/getBackgroundColorStyles.spec.ts +0 -18
- package/src/utilities/react/getBackgroundColorStyles.ts +0 -10
- package/src/utilities/react/getBorderStyles.spec.ts +0 -39
- package/src/utilities/react/getBorderStyles.ts +0 -20
- package/src/utilities/react/getRadiusStyles.spec.ts +0 -25
- package/src/utilities/react/getRadiusStyles.ts +0 -8
- package/src/utilities/react/index.ts +0 -6
- package/src/utilities/react/joinClassNames.spec.ts +0 -18
- package/src/utilities/react/joinClassNames.ts +0 -10
- package/tailwind.config.ts +0 -27
- package/tsconfig.json +0 -24
- package/tsconfig.node.json +0 -12
- package/vite.config.ts +0 -71
package/postcss.config.cjs
DELETED
package/setupTests.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import * as matchers from '@testing-library/jest-dom/matchers';
|
|
4
|
-
import { cleanup, configure } from '@testing-library/react';
|
|
5
|
-
import { afterEach, beforeAll, expect, vi } from 'vitest';
|
|
6
|
-
import '@testing-library/jest-dom/vitest';
|
|
7
|
-
|
|
8
|
-
expect.extend(matchers);
|
|
9
|
-
|
|
10
|
-
vi.stubGlobal('crypto', {
|
|
11
|
-
getRandomValues: vi.fn(),
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
beforeAll(() => {
|
|
15
|
-
configure({ testIdAttribute: 'data-test-id' });
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
vi.restoreAllMocks();
|
|
20
|
-
cleanup();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
globalThis.structuredClone = (data: unknown) => JSON.parse(JSON.stringify(data));
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { MutableRefObject, forwardRef, useEffect, useState } from 'react';
|
|
4
|
-
import { Asset, useAssetUpload, useFileInput } from '@frontify/app-bridge';
|
|
5
|
-
import { useSortable } from '@dnd-kit/sortable';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
ActionMenu,
|
|
9
|
-
Button,
|
|
10
|
-
ButtonEmphasis,
|
|
11
|
-
FOCUS_STYLE,
|
|
12
|
-
Flyout,
|
|
13
|
-
FlyoutPlacement,
|
|
14
|
-
IconArrowCircleUp20,
|
|
15
|
-
IconDocument24,
|
|
16
|
-
IconGrabHandle20,
|
|
17
|
-
IconImage24,
|
|
18
|
-
IconImageStack20,
|
|
19
|
-
IconMusicNote24,
|
|
20
|
-
IconPen20,
|
|
21
|
-
IconPlayFrame24,
|
|
22
|
-
IconTrashBin20,
|
|
23
|
-
LoadingCircle,
|
|
24
|
-
LoadingCircleSize,
|
|
25
|
-
MenuItemContentSize,
|
|
26
|
-
MenuItemStyle,
|
|
27
|
-
} from '@frontify/fondue';
|
|
28
|
-
import { AttachmentItemProps, SortableAttachmentItemProps } from './types';
|
|
29
|
-
import { joinClassNames } from '../../utilities';
|
|
30
|
-
import { useFocusRing } from '@react-aria/focus';
|
|
31
|
-
|
|
32
|
-
const getDecorator = (type: string) => {
|
|
33
|
-
if (type === 'IMAGE') {
|
|
34
|
-
return <IconImage24 />;
|
|
35
|
-
} else if (type === 'VIDEO') {
|
|
36
|
-
return <IconPlayFrame24 />;
|
|
37
|
-
} else if (type === 'AUDIO') {
|
|
38
|
-
return <IconMusicNote24 />;
|
|
39
|
-
} else {
|
|
40
|
-
return <IconDocument24 />;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const AttachmentItem = forwardRef<HTMLButtonElement, AttachmentItemProps>(
|
|
45
|
-
(
|
|
46
|
-
{
|
|
47
|
-
item,
|
|
48
|
-
isEditing,
|
|
49
|
-
draggableProps,
|
|
50
|
-
transformStyle,
|
|
51
|
-
isDragging,
|
|
52
|
-
isOverlay,
|
|
53
|
-
isLoading,
|
|
54
|
-
onDelete,
|
|
55
|
-
onReplaceWithBrowse,
|
|
56
|
-
onReplaceWithUpload,
|
|
57
|
-
onDownload,
|
|
58
|
-
},
|
|
59
|
-
ref,
|
|
60
|
-
) => {
|
|
61
|
-
const [selectedAsset, setSelectedAsset] = useState<Asset | undefined>();
|
|
62
|
-
const [openFileDialog, { selectedFiles }] = useFileInput({ multiple: true, accept: 'image/*' });
|
|
63
|
-
const [uploadFile, { results: uploadResults, doneAll }] = useAssetUpload();
|
|
64
|
-
|
|
65
|
-
const { focusProps, isFocusVisible } = useFocusRing();
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (selectedFiles) {
|
|
69
|
-
uploadFile(selectedFiles[0]);
|
|
70
|
-
}
|
|
71
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
-
}, [selectedFiles]);
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (doneAll) {
|
|
76
|
-
onReplaceWithUpload(uploadResults[0]);
|
|
77
|
-
}
|
|
78
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
79
|
-
}, [doneAll, uploadResults]);
|
|
80
|
-
|
|
81
|
-
const showLoadingCircle = isLoading || (selectedFiles && !doneAll);
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<button
|
|
85
|
-
aria-label="Download attachment"
|
|
86
|
-
data-test-id="attachments-item"
|
|
87
|
-
onClick={() => onDownload?.()}
|
|
88
|
-
ref={ref}
|
|
89
|
-
style={{
|
|
90
|
-
...transformStyle,
|
|
91
|
-
opacity: isDragging && !isOverlay ? 0.3 : 1,
|
|
92
|
-
fontFamily: 'var(-f-theme-settings-body-font-family)',
|
|
93
|
-
}}
|
|
94
|
-
className={joinClassNames([
|
|
95
|
-
'tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-box-neutral-hover',
|
|
96
|
-
isDragging ? 'tw-bg-box-neutral-hover' : '',
|
|
97
|
-
])}
|
|
98
|
-
>
|
|
99
|
-
<div className="tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover">
|
|
100
|
-
{showLoadingCircle ? (
|
|
101
|
-
<LoadingCircle size={LoadingCircleSize.Small} />
|
|
102
|
-
) : (
|
|
103
|
-
getDecorator(item.objectType)
|
|
104
|
-
)}
|
|
105
|
-
</div>
|
|
106
|
-
<div className="tw-text-s tw-flex-1 tw-min-w-0">
|
|
107
|
-
<div className="tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover">
|
|
108
|
-
{item.title}
|
|
109
|
-
</div>
|
|
110
|
-
<div className="tw-text-text-weak">{`${item.fileSizeHumanReadable} - ${item.extension}`}</div>
|
|
111
|
-
</div>
|
|
112
|
-
{isEditing && (
|
|
113
|
-
<div
|
|
114
|
-
data-test-id="attachments-actionbar"
|
|
115
|
-
className={joinClassNames([
|
|
116
|
-
'tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100',
|
|
117
|
-
isOverlay || selectedAsset?.id === item.id ? 'tw-opacity-100' : 'tw-opacity-0',
|
|
118
|
-
])}
|
|
119
|
-
>
|
|
120
|
-
<button
|
|
121
|
-
{...focusProps}
|
|
122
|
-
{...draggableProps}
|
|
123
|
-
aria-label="Drag attachment"
|
|
124
|
-
className={joinClassNames([
|
|
125
|
-
' tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded tw-h-9 tw-w-9 ',
|
|
126
|
-
isDragging || isOverlay
|
|
127
|
-
? 'tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed'
|
|
128
|
-
: 'tw-cursor-grab hover:tw-bg-button-background-hover',
|
|
129
|
-
isFocusVisible && FOCUS_STYLE,
|
|
130
|
-
isFocusVisible && 'tw-z-[2]',
|
|
131
|
-
])}
|
|
132
|
-
>
|
|
133
|
-
<IconGrabHandle20 />
|
|
134
|
-
</button>
|
|
135
|
-
<div data-test-id="attachments-actionbar-flyout">
|
|
136
|
-
<Flyout
|
|
137
|
-
placement={FlyoutPlacement.Right}
|
|
138
|
-
isOpen={selectedAsset?.id === item.id}
|
|
139
|
-
fitContent
|
|
140
|
-
legacyFooter={false}
|
|
141
|
-
onOpenChange={(isOpen) => setSelectedAsset(isOpen ? item : undefined)}
|
|
142
|
-
trigger={(_, ref) => (
|
|
143
|
-
<Button
|
|
144
|
-
ref={ref as MutableRefObject<HTMLButtonElement>}
|
|
145
|
-
icon={<IconPen20 />}
|
|
146
|
-
emphasis={ButtonEmphasis.Default}
|
|
147
|
-
onClick={() => setSelectedAsset(item)}
|
|
148
|
-
/>
|
|
149
|
-
)}
|
|
150
|
-
>
|
|
151
|
-
<ActionMenu
|
|
152
|
-
menuBlocks={[
|
|
153
|
-
{
|
|
154
|
-
id: 'menu',
|
|
155
|
-
menuItems: [
|
|
156
|
-
{
|
|
157
|
-
id: 'upload',
|
|
158
|
-
size: MenuItemContentSize.XSmall,
|
|
159
|
-
title: 'Replace with upload',
|
|
160
|
-
onClick: () => {
|
|
161
|
-
openFileDialog();
|
|
162
|
-
setSelectedAsset(undefined);
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
initialValue: true,
|
|
166
|
-
decorator: (
|
|
167
|
-
<div className="tw-mr-2">
|
|
168
|
-
<IconArrowCircleUp20 />
|
|
169
|
-
</div>
|
|
170
|
-
),
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
id: 'asset',
|
|
175
|
-
size: MenuItemContentSize.XSmall,
|
|
176
|
-
title: 'Replace with asset',
|
|
177
|
-
onClick: () => {
|
|
178
|
-
onReplaceWithBrowse();
|
|
179
|
-
setSelectedAsset(undefined);
|
|
180
|
-
},
|
|
181
|
-
initialValue: true,
|
|
182
|
-
decorator: (
|
|
183
|
-
<div className="tw-mr-2">
|
|
184
|
-
<IconImageStack20 />
|
|
185
|
-
</div>
|
|
186
|
-
),
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
id: 'menu-delete',
|
|
192
|
-
menuItems: [
|
|
193
|
-
{
|
|
194
|
-
id: 'delete',
|
|
195
|
-
size: MenuItemContentSize.XSmall,
|
|
196
|
-
title: 'Delete',
|
|
197
|
-
style: MenuItemStyle.Danger,
|
|
198
|
-
onClick: () => {
|
|
199
|
-
onDelete();
|
|
200
|
-
setSelectedAsset(undefined);
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
initialValue: true,
|
|
204
|
-
decorator: (
|
|
205
|
-
<div className="tw-mr-2">
|
|
206
|
-
<IconTrashBin20 />
|
|
207
|
-
</div>
|
|
208
|
-
),
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
]}
|
|
213
|
-
/>
|
|
214
|
-
</Flyout>
|
|
215
|
-
</div>
|
|
216
|
-
</div>
|
|
217
|
-
)}
|
|
218
|
-
</button>
|
|
219
|
-
);
|
|
220
|
-
},
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
AttachmentItem.displayName = 'AttachmentItem';
|
|
224
|
-
|
|
225
|
-
export const SortableAttachmentItem = (props: SortableAttachmentItemProps) => {
|
|
226
|
-
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
227
|
-
id: props.item.id,
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
const transformStyle = {
|
|
231
|
-
transform: transform ? `translate(${transform.x}px, ${transform.y}px)` : '',
|
|
232
|
-
transition,
|
|
233
|
-
zIndex: isDragging ? 2 : 1,
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
const draggableProps = { ...attributes, ...listeners };
|
|
237
|
-
|
|
238
|
-
return (
|
|
239
|
-
<AttachmentItem
|
|
240
|
-
ref={setNodeRef}
|
|
241
|
-
isDragging={isDragging}
|
|
242
|
-
transformStyle={transformStyle}
|
|
243
|
-
draggableProps={draggableProps}
|
|
244
|
-
{...props}
|
|
245
|
-
/>
|
|
246
|
-
);
|
|
247
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { type AppBridgeBlock, AssetDummy, getAppBridgeBlockStub } from '@frontify/app-bridge';
|
|
4
|
-
import { mount } from 'cypress/react18';
|
|
5
|
-
import { Attachments as AttachmentsComponent } from './Attachments';
|
|
6
|
-
import { AttachmentsProps } from './types';
|
|
7
|
-
import { SinonStub } from 'sinon';
|
|
8
|
-
|
|
9
|
-
const FlyoutButtonSelector = '[data-test-id="attachments-button-trigger"]';
|
|
10
|
-
const AssetInputSelector = '[data-test-id="asset-input-placeholder"]';
|
|
11
|
-
const ActionBarSelector = '[data-test-id="attachments-actionbar"]';
|
|
12
|
-
const DragHandleSelector = '[data-test-id="attachments-actionbar"] > button';
|
|
13
|
-
const FlyoutTriggerSelector = '[data-test-id="attachments-actionbar-flyout"] button';
|
|
14
|
-
const AttachmentItemSelector = '[data-test-id="attachments-item"]';
|
|
15
|
-
const MenuItemSelector = '[data-test-id="menu-item"]';
|
|
16
|
-
const LoadingCircleSelector = '[data-test-id="loading-circle"]';
|
|
17
|
-
|
|
18
|
-
const Attachments = ({
|
|
19
|
-
appBridge = getAppBridgeBlockStub(),
|
|
20
|
-
onDelete = cy.stub(),
|
|
21
|
-
items,
|
|
22
|
-
onReplaceWithBrowse = cy.stub(),
|
|
23
|
-
onReplaceWithUpload = cy.stub(),
|
|
24
|
-
onSorted = cy.stub(),
|
|
25
|
-
onBrowse = cy.stub(),
|
|
26
|
-
onUpload = cy.stub(),
|
|
27
|
-
}: Partial<AttachmentsProps>) => {
|
|
28
|
-
return (
|
|
29
|
-
<AttachmentsComponent
|
|
30
|
-
appBridge={appBridge}
|
|
31
|
-
onDelete={onDelete}
|
|
32
|
-
items={items}
|
|
33
|
-
onReplaceWithBrowse={onReplaceWithBrowse}
|
|
34
|
-
onReplaceWithUpload={onReplaceWithUpload}
|
|
35
|
-
onSorted={onSorted}
|
|
36
|
-
onBrowse={onBrowse}
|
|
37
|
-
onUpload={onUpload}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const isPre302Stub = async (appBridge: AppBridgeBlock): Promise<boolean> => {
|
|
43
|
-
const context = appBridge.context();
|
|
44
|
-
return context === undefined;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const hasOpenAssetChooser = (
|
|
48
|
-
appBridge: AppBridgeBlock,
|
|
49
|
-
): appBridge is AppBridgeBlock & { openAssetChooser: SinonStub } => {
|
|
50
|
-
return 'openAssetChooser' in appBridge;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
describe('Attachments', () => {
|
|
54
|
-
it('renders attachments flyout if it is in edit mode', () => {
|
|
55
|
-
mount(<Attachments appBridge={getAppBridgeBlockStub({ editorState: true })} />);
|
|
56
|
-
cy.get(FlyoutButtonSelector).should('exist');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('renders attachments flyout if it has attachments', () => {
|
|
60
|
-
mount(<Attachments items={[AssetDummy.with(1)]} />);
|
|
61
|
-
cy.get(FlyoutButtonSelector).should('exist');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('does not render attachments flyout if there are no attachments', () => {
|
|
65
|
-
mount(<Attachments items={[]} />);
|
|
66
|
-
cy.get(FlyoutButtonSelector).should('not.exist');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('renders asset input if in edit mode', () => {
|
|
70
|
-
mount(<Attachments appBridge={getAppBridgeBlockStub({ editorState: true })} items={[AssetDummy.with(1)]} />);
|
|
71
|
-
cy.get(FlyoutButtonSelector).click();
|
|
72
|
-
cy.get(AssetInputSelector).should('exist');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('does not render asset input if in view mode', () => {
|
|
76
|
-
mount(<Attachments items={[AssetDummy.with(1)]} />);
|
|
77
|
-
cy.get(FlyoutButtonSelector).click();
|
|
78
|
-
cy.get(AssetInputSelector).should('not.exist');
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('renders asset action buttons if in edit mode', () => {
|
|
82
|
-
mount(<Attachments appBridge={getAppBridgeBlockStub({ editorState: true })} items={[AssetDummy.with(1)]} />);
|
|
83
|
-
cy.get(FlyoutButtonSelector).click();
|
|
84
|
-
cy.get(ActionBarSelector).should('exist');
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('does not render asset action buttons if in view mode', () => {
|
|
88
|
-
mount(<Attachments items={[AssetDummy.with(1)]} />);
|
|
89
|
-
cy.get(FlyoutButtonSelector).click();
|
|
90
|
-
cy.get(ActionBarSelector).should('not.exist');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('renders an attachment item for each asset', () => {
|
|
94
|
-
mount(<Attachments items={[AssetDummy.with(1), AssetDummy.with(2), AssetDummy.with(3)]} />);
|
|
95
|
-
cy.get(FlyoutButtonSelector).click();
|
|
96
|
-
cy.get(AttachmentItemSelector).should('have.length', 3);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it('renders loading circle for attachment item', async () => {
|
|
100
|
-
const appBridge = getAppBridgeBlockStub({
|
|
101
|
-
editorState: true,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
if ((await isPre302Stub(appBridge)) && hasOpenAssetChooser(appBridge)) {
|
|
105
|
-
(appBridge.openAssetChooser as SinonStub) = cy.stub().callsArgWith(0, AssetDummy.with(4));
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
cy.clock();
|
|
109
|
-
const replaceStub = () =>
|
|
110
|
-
new Promise<void>((resolve) =>
|
|
111
|
-
setTimeout(() => {
|
|
112
|
-
resolve();
|
|
113
|
-
}, 2000),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
mount(
|
|
117
|
-
<Attachments
|
|
118
|
-
onReplaceWithBrowse={replaceStub}
|
|
119
|
-
items={[AssetDummy.with(1), AssetDummy.with(2), AssetDummy.with(3)]}
|
|
120
|
-
appBridge={appBridge}
|
|
121
|
-
/>,
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
cy.get(FlyoutButtonSelector).click();
|
|
125
|
-
cy.get(AttachmentItemSelector).eq(0).focus();
|
|
126
|
-
cy.get(FlyoutTriggerSelector).eq(1).click();
|
|
127
|
-
cy.get(MenuItemSelector).eq(1).click();
|
|
128
|
-
cy.get(LoadingCircleSelector).should('exist');
|
|
129
|
-
cy.tick(2000);
|
|
130
|
-
cy.get(LoadingCircleSelector).should('not.exist');
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('renders focus ring on flyout button while tabbing and open it', () => {
|
|
134
|
-
mount(
|
|
135
|
-
<Attachments
|
|
136
|
-
appBridge={getAppBridgeBlockStub({ editorState: true })}
|
|
137
|
-
items={[AssetDummy.with(1), AssetDummy.with(2), AssetDummy.with(3)]}
|
|
138
|
-
/>,
|
|
139
|
-
);
|
|
140
|
-
cy.get(FlyoutButtonSelector).click();
|
|
141
|
-
cy.realPress('Tab');
|
|
142
|
-
cy.realPress('Tab');
|
|
143
|
-
cy.realPress('Tab');
|
|
144
|
-
cy.get(FlyoutTriggerSelector).eq(0).should('have.class', 'focus-visible:tw-ring-blue');
|
|
145
|
-
cy.get(FlyoutTriggerSelector).eq(0).type('{enter}');
|
|
146
|
-
cy.get(MenuItemSelector).should('exist');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('reorders items using only keyboard events', () => {
|
|
150
|
-
const onSortStub = cy.stub();
|
|
151
|
-
mount(
|
|
152
|
-
<Attachments
|
|
153
|
-
appBridge={getAppBridgeBlockStub({ editorState: true })}
|
|
154
|
-
items={[{ ...AssetDummy.with(1), title: 'Moved item' }, AssetDummy.with(2), AssetDummy.with(3)]}
|
|
155
|
-
onSorted={onSortStub}
|
|
156
|
-
/>,
|
|
157
|
-
);
|
|
158
|
-
cy.get(FlyoutButtonSelector).click();
|
|
159
|
-
cy.realPress('Tab');
|
|
160
|
-
cy.realPress('Tab');
|
|
161
|
-
cy.realPress('Tab');
|
|
162
|
-
cy.get(DragHandleSelector).eq(0).type(' {downarrow}{downarrow} ');
|
|
163
|
-
cy.get(AttachmentItemSelector).eq(1).should('contain.text', 'Moved item');
|
|
164
|
-
});
|
|
165
|
-
});
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { MutableRefObject, useEffect, useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
DndContext,
|
|
6
|
-
DragEndEvent,
|
|
7
|
-
DragOverlay,
|
|
8
|
-
DragStartEvent,
|
|
9
|
-
KeyboardSensor,
|
|
10
|
-
PointerSensor,
|
|
11
|
-
closestCenter,
|
|
12
|
-
useSensor,
|
|
13
|
-
useSensors,
|
|
14
|
-
} from '@dnd-kit/core';
|
|
15
|
-
import { restrictToWindowEdges } from '@dnd-kit/modifiers';
|
|
16
|
-
import { SortableContext, arrayMove, rectSortingStrategy } from '@dnd-kit/sortable';
|
|
17
|
-
import { Asset, useAssetChooser, useAssetUpload, useEditorState } from '@frontify/app-bridge';
|
|
18
|
-
import {
|
|
19
|
-
AssetInput,
|
|
20
|
-
AssetInputSize,
|
|
21
|
-
Flyout,
|
|
22
|
-
FlyoutPlacement,
|
|
23
|
-
LegacyTooltip as Tooltip,
|
|
24
|
-
TooltipPosition,
|
|
25
|
-
} from '@frontify/fondue';
|
|
26
|
-
|
|
27
|
-
import { AttachmentItem, SortableAttachmentItem } from './AttachmentItem';
|
|
28
|
-
import { type AttachmentsProps } from './types';
|
|
29
|
-
import { AttachmentsButtonTrigger } from './AttachmentsButtonTrigger';
|
|
30
|
-
|
|
31
|
-
export const Attachments = ({
|
|
32
|
-
items = [],
|
|
33
|
-
onDelete,
|
|
34
|
-
onReplaceWithBrowse,
|
|
35
|
-
onReplaceWithUpload,
|
|
36
|
-
onBrowse,
|
|
37
|
-
onUpload,
|
|
38
|
-
onSorted,
|
|
39
|
-
appBridge,
|
|
40
|
-
triggerComponent: TriggerComponent = AttachmentsButtonTrigger,
|
|
41
|
-
isOpen,
|
|
42
|
-
onOpenChange,
|
|
43
|
-
}: AttachmentsProps) => {
|
|
44
|
-
const [internalItems, setInternalItems] = useState<Asset[]>(items);
|
|
45
|
-
const [isFlyoutOpenInternal, setIsFlyoutOpenInternal] = useState(false);
|
|
46
|
-
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor));
|
|
47
|
-
const [draggedAssetId, setDraggedAssetId] = useState<number | undefined>(undefined);
|
|
48
|
-
const [isUploadLoading, setIsUploadLoading] = useState(false);
|
|
49
|
-
const [assetIdsLoading, setAssetIdsLoading] = useState<number[]>([]);
|
|
50
|
-
const [selectedFiles, setSelectedFiles] = useState<FileList | null>(null);
|
|
51
|
-
const isEditing = useEditorState(appBridge);
|
|
52
|
-
const { openAssetChooser, closeAssetChooser } = useAssetChooser(appBridge);
|
|
53
|
-
const isControllingStateExternally = isOpen !== undefined;
|
|
54
|
-
const isFlyoutOpen = isControllingStateExternally ? isOpen : isFlyoutOpenInternal;
|
|
55
|
-
|
|
56
|
-
const draggedItem = internalItems?.find((item) => item.id === draggedAssetId);
|
|
57
|
-
|
|
58
|
-
const [uploadFile, { results: uploadResults, doneAll }] = useAssetUpload({
|
|
59
|
-
onUploadProgress: () => !isUploadLoading && setIsUploadLoading(true),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const handleFlyoutOpenChange = (isOpen: boolean) => {
|
|
63
|
-
const stateSetter = isControllingStateExternally ? onOpenChange : setIsFlyoutOpenInternal;
|
|
64
|
-
|
|
65
|
-
stateSetter?.(isOpen);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
setInternalItems(items);
|
|
70
|
-
}, [items]);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
if (selectedFiles) {
|
|
74
|
-
setIsUploadLoading(true);
|
|
75
|
-
uploadFile(selectedFiles);
|
|
76
|
-
}
|
|
77
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
-
}, [selectedFiles]);
|
|
79
|
-
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
const uploadDone = async () => {
|
|
82
|
-
if (doneAll) {
|
|
83
|
-
await onUpload(uploadResults);
|
|
84
|
-
setIsUploadLoading(false);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
uploadDone();
|
|
88
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
|
-
}, [doneAll, uploadResults]);
|
|
90
|
-
|
|
91
|
-
const onOpenAssetChooser = () => {
|
|
92
|
-
handleFlyoutOpenChange(false);
|
|
93
|
-
openAssetChooser(
|
|
94
|
-
(result: Asset[]) => {
|
|
95
|
-
onBrowse(result);
|
|
96
|
-
closeAssetChooser();
|
|
97
|
-
handleFlyoutOpenChange(true);
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
multiSelection: true,
|
|
101
|
-
selectedValueIds: internalItems.map((internalItem) => internalItem.id),
|
|
102
|
-
},
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const onReplaceItemWithBrowse = (toReplace: Asset) => {
|
|
107
|
-
handleFlyoutOpenChange(false);
|
|
108
|
-
openAssetChooser(
|
|
109
|
-
async (result: Asset[]) => {
|
|
110
|
-
handleFlyoutOpenChange(true);
|
|
111
|
-
closeAssetChooser();
|
|
112
|
-
setAssetIdsLoading([...assetIdsLoading, toReplace.id]);
|
|
113
|
-
await onReplaceWithBrowse(toReplace, result[0]);
|
|
114
|
-
setAssetIdsLoading(assetIdsLoading.filter((id) => id !== toReplace.id));
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
multiSelection: false,
|
|
118
|
-
selectedValueIds: internalItems.map((internalItem) => internalItem.id),
|
|
119
|
-
},
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const onReplaceItemWithUpload = async (toReplace: Asset, uploadedAsset: Asset) => {
|
|
124
|
-
setAssetIdsLoading([...assetIdsLoading, toReplace.id]);
|
|
125
|
-
await onReplaceWithUpload(toReplace, uploadedAsset);
|
|
126
|
-
setAssetIdsLoading(assetIdsLoading.filter((id) => id !== toReplace.id));
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const handleDragStart = (event: DragStartEvent) => {
|
|
130
|
-
const { active } = event;
|
|
131
|
-
setDraggedAssetId(active.id as number);
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const handleDragEnd = (event: DragEndEvent) => {
|
|
135
|
-
const { active, over } = event;
|
|
136
|
-
if (over && active.id !== over.id && internalItems) {
|
|
137
|
-
const oldIndex = internalItems.findIndex((i) => i.id === active.id);
|
|
138
|
-
const newIndex = internalItems.findIndex((i) => i.id === over.id);
|
|
139
|
-
const sortedItems = arrayMove(internalItems, oldIndex, newIndex);
|
|
140
|
-
setInternalItems(sortedItems);
|
|
141
|
-
onSorted(sortedItems);
|
|
142
|
-
}
|
|
143
|
-
setDraggedAssetId(undefined);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
return isEditing || (internalItems?.length ?? 0) > 0 ? (
|
|
147
|
-
<Tooltip
|
|
148
|
-
withArrow
|
|
149
|
-
position={TooltipPosition.Top}
|
|
150
|
-
content="Attachments"
|
|
151
|
-
disabled={isFlyoutOpen}
|
|
152
|
-
enterDelay={500}
|
|
153
|
-
triggerElement={
|
|
154
|
-
<div data-test-id="attachments-flyout-button">
|
|
155
|
-
<Flyout
|
|
156
|
-
placement={FlyoutPlacement.BottomRight}
|
|
157
|
-
onOpenChange={(isOpen) => handleFlyoutOpenChange(!!draggedItem ? true : isOpen)}
|
|
158
|
-
isOpen={isFlyoutOpen}
|
|
159
|
-
hug={false}
|
|
160
|
-
fitContent
|
|
161
|
-
legacyFooter={false}
|
|
162
|
-
trigger={(triggerProps, triggerRef) => (
|
|
163
|
-
<TriggerComponent
|
|
164
|
-
isFlyoutOpen={isFlyoutOpen}
|
|
165
|
-
triggerProps={triggerProps}
|
|
166
|
-
triggerRef={triggerRef as MutableRefObject<HTMLButtonElement>}
|
|
167
|
-
>
|
|
168
|
-
<div>{items.length > 0 ? items.length : 'Add'}</div>
|
|
169
|
-
</TriggerComponent>
|
|
170
|
-
)}
|
|
171
|
-
>
|
|
172
|
-
<div className="tw-w-[300px]" data-test-id="attachments-flyout-content">
|
|
173
|
-
{internalItems.length > 0 && (
|
|
174
|
-
<DndContext
|
|
175
|
-
sensors={sensors}
|
|
176
|
-
collisionDetection={closestCenter}
|
|
177
|
-
onDragStart={handleDragStart}
|
|
178
|
-
onDragEnd={handleDragEnd}
|
|
179
|
-
modifiers={[restrictToWindowEdges]}
|
|
180
|
-
>
|
|
181
|
-
<SortableContext items={internalItems} strategy={rectSortingStrategy}>
|
|
182
|
-
<div className="tw-border-b tw-border-b-line">
|
|
183
|
-
{internalItems.map((item) => (
|
|
184
|
-
<SortableAttachmentItem
|
|
185
|
-
isEditing={isEditing}
|
|
186
|
-
isLoading={assetIdsLoading.includes(item.id)}
|
|
187
|
-
key={item.id}
|
|
188
|
-
item={item}
|
|
189
|
-
onDelete={() => onDelete(item)}
|
|
190
|
-
onReplaceWithBrowse={() => onReplaceItemWithBrowse(item)}
|
|
191
|
-
onReplaceWithUpload={(uploadedAsset: Asset) =>
|
|
192
|
-
onReplaceItemWithUpload(item, uploadedAsset)
|
|
193
|
-
}
|
|
194
|
-
onDownload={() =>
|
|
195
|
-
appBridge.dispatch({
|
|
196
|
-
name: 'downloadAsset',
|
|
197
|
-
payload: item,
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
/>
|
|
201
|
-
))}
|
|
202
|
-
</div>
|
|
203
|
-
</SortableContext>
|
|
204
|
-
<DragOverlay>
|
|
205
|
-
{draggedItem && (
|
|
206
|
-
<AttachmentItem
|
|
207
|
-
isOverlay={true}
|
|
208
|
-
isEditing={isEditing}
|
|
209
|
-
key={draggedAssetId}
|
|
210
|
-
item={draggedItem}
|
|
211
|
-
isDragging={true}
|
|
212
|
-
onDelete={() => onDelete(draggedItem)}
|
|
213
|
-
onReplaceWithBrowse={() => onReplaceItemWithBrowse(draggedItem)}
|
|
214
|
-
onReplaceWithUpload={(uploadedAsset: Asset) =>
|
|
215
|
-
onReplaceItemWithUpload(draggedItem, uploadedAsset)
|
|
216
|
-
}
|
|
217
|
-
/>
|
|
218
|
-
)}
|
|
219
|
-
</DragOverlay>
|
|
220
|
-
</DndContext>
|
|
221
|
-
)}
|
|
222
|
-
{isEditing && (
|
|
223
|
-
<div className="tw-px-5 tw-py-3">
|
|
224
|
-
<div className="tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4">
|
|
225
|
-
Add attachments
|
|
226
|
-
</div>
|
|
227
|
-
<AssetInput
|
|
228
|
-
isLoading={isUploadLoading}
|
|
229
|
-
size={AssetInputSize.Small}
|
|
230
|
-
onUploadClick={(fileList) => setSelectedFiles(fileList)}
|
|
231
|
-
onLibraryClick={onOpenAssetChooser}
|
|
232
|
-
/>
|
|
233
|
-
</div>
|
|
234
|
-
)}
|
|
235
|
-
</div>
|
|
236
|
-
</Flyout>
|
|
237
|
-
</div>
|
|
238
|
-
}
|
|
239
|
-
/>
|
|
240
|
-
) : null;
|
|
241
|
-
};
|