@frontify/guideline-blocks-settings 0.33.4 → 0.34.0
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 +86 -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 +41 -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 +24 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/ButtonToolbarButton.es.js +26 -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 +28 -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 +48 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.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 +104 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/InsertButtonModal/useInsertModal.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 +57 -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 +41 -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 +67 -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 +52 -0
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/withButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/CustomFloatingLink.es.js +32 -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 +35 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.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/useInsertModal.es.js +79 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/InsertLinkModal/useInsertModal.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkButton.es.js +22 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkButton.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js +12 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/index.es.js +11 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkMarkupElement/index.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkToolbarButton.es.js +25 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/LinkToolbarButton.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/LinkPlugin/utils/getUrl.es.js +13 -0
- package/dist/components/RichTextEditor/plugins/LinkPlugin/utils/getUrl.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js +50 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom1Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js +50 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom2Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js +50 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/custom3Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading1Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading2Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading3Plugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/heading4Plugin.es.js +51 -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 +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageCaptionPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js +51 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/imageTitlePlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js +45 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/paragraphPlugin.es.js.map +1 -0
- package/dist/components/RichTextEditor/plugins/TextStylePlugins/quotePlugin.es.js +53 -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 +1190 -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 +9 -6
- package/.eslintrc.cjs +0 -27
- package/.prettierrc +0 -7
- package/CHANGELOG.md +0 -787
- 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
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import type { Document, DocumentPage, DocumentSection } from '@frontify/app-bridge';
|
|
4
|
-
import { ReactElement, useEffect, useState } from 'react';
|
|
5
|
-
import { DocumentLink } from './DocumentLink';
|
|
6
|
-
import { LoadingIndicator } from './LoadingIndicator';
|
|
7
|
-
import { InitiallyExpandedItems } from '../';
|
|
8
|
-
|
|
9
|
-
type DocumentLinksProps = {
|
|
10
|
-
selectedUrl: string;
|
|
11
|
-
onSelectUrl: (url: string) => void;
|
|
12
|
-
getAllDocuments: () => Promise<Document[]>;
|
|
13
|
-
getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;
|
|
14
|
-
getDocumentPagesByDocumentId: (documentId: number) => Promise<DocumentPage[]>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const DocumentLinks = ({
|
|
18
|
-
selectedUrl,
|
|
19
|
-
onSelectUrl,
|
|
20
|
-
getAllDocuments,
|
|
21
|
-
getDocumentPagesByDocumentId,
|
|
22
|
-
getDocumentSectionsByDocumentPageId,
|
|
23
|
-
}: DocumentLinksProps): ReactElement => {
|
|
24
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
25
|
-
const [documents, setDocuments] = useState<Document[]>([]);
|
|
26
|
-
const [itemsToExpandInitially, setItemsToExpandInitially] = useState<InitiallyExpandedItems>({
|
|
27
|
-
documentId: undefined,
|
|
28
|
-
pageId: undefined,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const documentArray = [...documents.values()];
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (selectedUrl && documentArray.length > 0) {
|
|
35
|
-
findLocationOfSelectedUrl().then((items) => {
|
|
36
|
-
setItemsToExpandInitially(items);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
}, [documentArray.length]);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
getAllDocuments()
|
|
44
|
-
.then((_documents) => {
|
|
45
|
-
setDocuments(_documents);
|
|
46
|
-
})
|
|
47
|
-
.finally(() => {
|
|
48
|
-
setIsLoading(false);
|
|
49
|
-
});
|
|
50
|
-
}, []);
|
|
51
|
-
|
|
52
|
-
const findLocationOfSelectedUrl = async () => {
|
|
53
|
-
const itemsToExpand: InitiallyExpandedItems = {
|
|
54
|
-
documentId: undefined,
|
|
55
|
-
pageId: undefined,
|
|
56
|
-
};
|
|
57
|
-
const selectedUrlIsDocument = documentArray.find((document) => document.permanentLink === selectedUrl);
|
|
58
|
-
if (selectedUrlIsDocument) {
|
|
59
|
-
return itemsToExpand;
|
|
60
|
-
}
|
|
61
|
-
for (const document of documentArray) {
|
|
62
|
-
const pages = await getDocumentPagesByDocumentId(document.id);
|
|
63
|
-
const pagesArray = [...pages.values()];
|
|
64
|
-
const selectedUrlIsPage = !!pagesArray.find((page) => page.permanentLink === selectedUrl);
|
|
65
|
-
if (selectedUrlIsPage) {
|
|
66
|
-
itemsToExpand.documentId = document.id;
|
|
67
|
-
return itemsToExpand;
|
|
68
|
-
}
|
|
69
|
-
for (const page of pagesArray) {
|
|
70
|
-
const sections = await getDocumentSectionsByDocumentPageId(page.id);
|
|
71
|
-
const sectionsArray = [...sections.values()];
|
|
72
|
-
const selectedUrlIsSection = !!sectionsArray.find((section) => section.permanentLink === selectedUrl);
|
|
73
|
-
if (selectedUrlIsSection) {
|
|
74
|
-
itemsToExpand.documentId = document.id;
|
|
75
|
-
itemsToExpand.pageId = page.id;
|
|
76
|
-
return itemsToExpand;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return itemsToExpand;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
return isLoading ? (
|
|
84
|
-
<LoadingIndicator />
|
|
85
|
-
) : (
|
|
86
|
-
<>
|
|
87
|
-
{documentArray.map((document) => {
|
|
88
|
-
return (
|
|
89
|
-
<DocumentLink
|
|
90
|
-
key={document.id}
|
|
91
|
-
document={document}
|
|
92
|
-
selectedUrl={selectedUrl}
|
|
93
|
-
onSelectUrl={onSelectUrl}
|
|
94
|
-
itemsToExpandInitially={itemsToExpandInitially}
|
|
95
|
-
getDocumentSectionsByDocumentPageId={getDocumentSectionsByDocumentPageId}
|
|
96
|
-
getDocumentPagesByDocumentId={getDocumentPagesByDocumentId}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
})}
|
|
100
|
-
</>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
DocumentApiDummy,
|
|
5
|
-
DocumentPageApiDummy,
|
|
6
|
-
DocumentSectionApiDummy,
|
|
7
|
-
getAppBridgeBlockStub,
|
|
8
|
-
} from '@frontify/app-bridge';
|
|
9
|
-
import { mount } from 'cypress/react18';
|
|
10
|
-
import { LinkSelector } from './LinkSelector';
|
|
11
|
-
import type { SinonStub } from 'sinon';
|
|
12
|
-
|
|
13
|
-
const LinkSelectorSelector = '[data-test-id="internal-link-selector"]';
|
|
14
|
-
const LinkSelectorButtonSelector = '[data-test-id="internal-link-selector"] > button';
|
|
15
|
-
const LinkSelectorModalSelector = '[data-test-id="modal-body"]';
|
|
16
|
-
const DocumentLinkSelector = '[data-test-id="internal-link-selector-document-link"]';
|
|
17
|
-
const DocumentTreeItemToggleSelector = '[data-test-id="tree-item-toggle"]';
|
|
18
|
-
const PageLinkSelector = '[data-test-id="internal-link-selector-page-link"]';
|
|
19
|
-
const SectionLinkSelector = '[data-test-id="internal-link-selector-section-link"]';
|
|
20
|
-
|
|
21
|
-
const apiDocuments = [
|
|
22
|
-
{ ...DocumentApiDummy.with(1), permanentLink: '/1' },
|
|
23
|
-
{ ...DocumentApiDummy.with(2), permanentLink: '/2' },
|
|
24
|
-
];
|
|
25
|
-
const apiPages = [
|
|
26
|
-
{ ...DocumentPageApiDummy.with(1), permanentLink: '/3' },
|
|
27
|
-
{ ...DocumentPageApiDummy.with(2), permanentLink: '/4' },
|
|
28
|
-
{ ...DocumentPageApiDummy.with(3), permanentLink: '/5' },
|
|
29
|
-
];
|
|
30
|
-
const apiSections = [
|
|
31
|
-
{ ...DocumentSectionApiDummy.with(1), permanentLink: '/6' },
|
|
32
|
-
{ ...DocumentSectionApiDummy.with(2), permanentLink: '/7' },
|
|
33
|
-
{ ...DocumentSectionApiDummy.with(3), permanentLink: '/8' },
|
|
34
|
-
{ ...DocumentSectionApiDummy.with(4), permanentLink: '/9' },
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
describe('Link Selector', () => {
|
|
38
|
-
it('renders the link selector button', () => {
|
|
39
|
-
const appBridge = getAppBridgeBlockStub();
|
|
40
|
-
mount(
|
|
41
|
-
<LinkSelector
|
|
42
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
43
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
44
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
45
|
-
url=""
|
|
46
|
-
onUrlChange={cy.stub()}
|
|
47
|
-
/>,
|
|
48
|
-
);
|
|
49
|
-
cy.get(LinkSelectorSelector).should('exist');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('opens the modal on button click', () => {
|
|
53
|
-
const appBridge = getAppBridgeBlockStub({
|
|
54
|
-
blockId: 1,
|
|
55
|
-
});
|
|
56
|
-
const apiDocuments = [DocumentApiDummy.with(1)];
|
|
57
|
-
(appBridge.getDocumentGroups as SinonStub) = cy.stub().returns([]);
|
|
58
|
-
(appBridge.getAllDocuments as SinonStub) = cy.stub().returns(Promise.resolve(apiDocuments));
|
|
59
|
-
|
|
60
|
-
mount(
|
|
61
|
-
<LinkSelector
|
|
62
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
63
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
64
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
65
|
-
url=""
|
|
66
|
-
onUrlChange={cy.stub()}
|
|
67
|
-
/>,
|
|
68
|
-
);
|
|
69
|
-
cy.get(LinkSelectorButtonSelector).click();
|
|
70
|
-
cy.get(LinkSelectorModalSelector).should('exist');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('renders two documents initially', () => {
|
|
74
|
-
const appBridge = getAppBridgeBlockStub({
|
|
75
|
-
blockId: 1,
|
|
76
|
-
});
|
|
77
|
-
(appBridge.getDocumentGroups as SinonStub) = cy.stub().returns([]);
|
|
78
|
-
(appBridge.getAllDocuments as SinonStub) = cy.stub().returns(Promise.resolve(apiDocuments));
|
|
79
|
-
|
|
80
|
-
mount(
|
|
81
|
-
<LinkSelector
|
|
82
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
83
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
84
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
85
|
-
url=""
|
|
86
|
-
onUrlChange={cy.stub()}
|
|
87
|
-
/>,
|
|
88
|
-
);
|
|
89
|
-
cy.get(LinkSelectorButtonSelector).click();
|
|
90
|
-
cy.get(DocumentLinkSelector).should('have.length', 2);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('renders three pages on document expand', () => {
|
|
94
|
-
const appBridge = getAppBridgeBlockStub({
|
|
95
|
-
blockId: 1,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
(appBridge.getDocumentGroups as SinonStub) = cy.stub().returns([]);
|
|
99
|
-
(appBridge.getAllDocuments as SinonStub) = cy.stub().returns(Promise.resolve(apiDocuments));
|
|
100
|
-
(appBridge.getDocumentPagesByDocumentId as SinonStub) = cy.stub().returns(Promise.resolve(apiPages));
|
|
101
|
-
(appBridge.getDocumentSectionsByDocumentPageId as SinonStub) = cy.stub().returns(Promise.resolve(apiSections));
|
|
102
|
-
|
|
103
|
-
mount(
|
|
104
|
-
<LinkSelector
|
|
105
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
106
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
107
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
108
|
-
url=""
|
|
109
|
-
onUrlChange={cy.stub()}
|
|
110
|
-
/>,
|
|
111
|
-
);
|
|
112
|
-
cy.get(LinkSelectorButtonSelector).click();
|
|
113
|
-
cy.get(DocumentLinkSelector).eq(0).find(DocumentTreeItemToggleSelector).click();
|
|
114
|
-
cy.get(PageLinkSelector).should('have.length', 3);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('renders four sections on page expand', () => {
|
|
118
|
-
const appBridge = getAppBridgeBlockStub({
|
|
119
|
-
blockId: 1,
|
|
120
|
-
});
|
|
121
|
-
(appBridge.getDocumentGroups as SinonStub) = cy.stub().returns([]);
|
|
122
|
-
(appBridge.getAllDocuments as SinonStub) = cy.stub().returns(Promise.resolve(apiDocuments));
|
|
123
|
-
(appBridge.getDocumentPagesByDocumentId as SinonStub) = cy.stub().returns(Promise.resolve(apiPages));
|
|
124
|
-
(appBridge.getDocumentSectionsByDocumentPageId as SinonStub) = cy.stub().returns(Promise.resolve(apiSections));
|
|
125
|
-
|
|
126
|
-
mount(
|
|
127
|
-
<LinkSelector
|
|
128
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
129
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
130
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
131
|
-
url=""
|
|
132
|
-
onUrlChange={cy.stub()}
|
|
133
|
-
/>,
|
|
134
|
-
);
|
|
135
|
-
cy.get(LinkSelectorButtonSelector).click();
|
|
136
|
-
cy.get(DocumentLinkSelector).eq(0).find(DocumentTreeItemToggleSelector).click();
|
|
137
|
-
cy.get(PageLinkSelector).eq(0).find('button').click();
|
|
138
|
-
cy.get(SectionLinkSelector).should('have.length', 4);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('renders the selected section immediately if it is preselected', () => {
|
|
142
|
-
const appBridge = getAppBridgeBlockStub({
|
|
143
|
-
blockId: 1,
|
|
144
|
-
});
|
|
145
|
-
(appBridge.getDocumentGroups as SinonStub) = cy.stub().returns([]);
|
|
146
|
-
(appBridge.getAllDocuments as SinonStub) = cy.stub().returns(Promise.resolve(apiDocuments));
|
|
147
|
-
(appBridge.getDocumentPagesByDocumentId as SinonStub) = cy.stub().returns(Promise.resolve(apiPages));
|
|
148
|
-
(appBridge.getDocumentSectionsByDocumentPageId as SinonStub) = cy.stub().returns(Promise.resolve(apiSections));
|
|
149
|
-
|
|
150
|
-
mount(
|
|
151
|
-
<LinkSelector
|
|
152
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
153
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
154
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
155
|
-
url="/7"
|
|
156
|
-
onUrlChange={cy.stub().as('urlChange')}
|
|
157
|
-
/>,
|
|
158
|
-
);
|
|
159
|
-
cy.get(LinkSelectorButtonSelector).click();
|
|
160
|
-
cy.get(SectionLinkSelector).should('have.length', 4);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('renders the all section and they are shown on focus and stores if you press enter', () => {
|
|
164
|
-
const appBridge = getAppBridgeBlockStub({
|
|
165
|
-
blockId: 1,
|
|
166
|
-
});
|
|
167
|
-
(appBridge.getDocumentGroups as SinonStub) = cy.stub().returns([]);
|
|
168
|
-
(appBridge.getAllDocuments as SinonStub) = cy.stub().returns(Promise.resolve(apiDocuments));
|
|
169
|
-
(appBridge.getDocumentPagesByDocumentId as SinonStub) = cy.stub().returns(Promise.resolve(apiPages));
|
|
170
|
-
(appBridge.getDocumentSectionsByDocumentPageId as SinonStub) = cy.stub().returns(Promise.resolve(apiSections));
|
|
171
|
-
|
|
172
|
-
mount(
|
|
173
|
-
<LinkSelector
|
|
174
|
-
getAllDocuments={appBridge.getAllDocuments}
|
|
175
|
-
getDocumentPagesByDocumentId={appBridge.getDocumentPagesByDocumentId}
|
|
176
|
-
getDocumentSectionsByDocumentPageId={appBridge.getDocumentSectionsByDocumentPageId}
|
|
177
|
-
url=""
|
|
178
|
-
onUrlChange={cy.stub().as('urlChange')}
|
|
179
|
-
/>,
|
|
180
|
-
);
|
|
181
|
-
cy.get(LinkSelectorButtonSelector).click();
|
|
182
|
-
cy.get(DocumentLinkSelector).should('have.length', 2);
|
|
183
|
-
cy.realPress('Tab');
|
|
184
|
-
cy.realPress('Tab');
|
|
185
|
-
cy.realPress('Enter');
|
|
186
|
-
cy.get(PageLinkSelector).should('have.length', 3);
|
|
187
|
-
cy.realPress('Tab');
|
|
188
|
-
cy.realPress('Tab');
|
|
189
|
-
cy.realPress('Enter');
|
|
190
|
-
cy.get(SectionLinkSelector).should('have.length', 4);
|
|
191
|
-
cy.realPress('Tab');
|
|
192
|
-
cy.realPress('Space');
|
|
193
|
-
cy.realPress('Enter');
|
|
194
|
-
cy.get('@urlChange').should('be.calledWith', '/6');
|
|
195
|
-
});
|
|
196
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import type { Document, DocumentPage, DocumentSection } from '@frontify/app-bridge';
|
|
4
|
-
import { Button, ButtonEmphasis, ButtonSize, ButtonStyle, ButtonType, IconLink, Modal } from '@frontify/fondue';
|
|
5
|
-
import { useOverlayTriggerState } from '@react-stately/overlays';
|
|
6
|
-
import { KeyboardEvent, ReactElement, useEffect, useState } from 'react';
|
|
7
|
-
import { DocumentLinks } from './DocumentLinks';
|
|
8
|
-
|
|
9
|
-
type LinkSelectorProps = {
|
|
10
|
-
url: string;
|
|
11
|
-
onUrlChange?: (value: string) => void;
|
|
12
|
-
buttonSize?: ButtonSize;
|
|
13
|
-
getAllDocuments: () => Promise<Document[]>;
|
|
14
|
-
getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;
|
|
15
|
-
getDocumentPagesByDocumentId: (documentId: number) => Promise<DocumentPage[]>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const LinkSelector = ({
|
|
19
|
-
url,
|
|
20
|
-
onUrlChange,
|
|
21
|
-
buttonSize = ButtonSize.Medium,
|
|
22
|
-
getAllDocuments,
|
|
23
|
-
getDocumentPagesByDocumentId,
|
|
24
|
-
getDocumentSectionsByDocumentPageId,
|
|
25
|
-
}: LinkSelectorProps): ReactElement => {
|
|
26
|
-
const { open: openLinkTree, isOpen: isLinkTreeOpen, close: closeLinkTree } = useOverlayTriggerState({});
|
|
27
|
-
const [selectedUrl, setSelectedUrl] = useState<string>(url);
|
|
28
|
-
|
|
29
|
-
const onSelectUrl = (url: string) => {
|
|
30
|
-
setSelectedUrl(url);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const onPressEnter = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
34
|
-
if (event.key === 'Enter') {
|
|
35
|
-
saveLink();
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (url && !selectedUrl) {
|
|
41
|
-
setSelectedUrl(url);
|
|
42
|
-
}
|
|
43
|
-
}, [url, selectedUrl]);
|
|
44
|
-
|
|
45
|
-
const saveLink = () => {
|
|
46
|
-
onUrlChange?.(selectedUrl);
|
|
47
|
-
closeLinkTree();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div data-test-id="internal-link-selector" onKeyDown={onPressEnter}>
|
|
52
|
-
<Button
|
|
53
|
-
icon={<IconLink />}
|
|
54
|
-
size={buttonSize}
|
|
55
|
-
type={ButtonType.Button}
|
|
56
|
-
style={ButtonStyle.Default}
|
|
57
|
-
emphasis={ButtonEmphasis.Default}
|
|
58
|
-
onClick={() => openLinkTree()}
|
|
59
|
-
>
|
|
60
|
-
Internal link
|
|
61
|
-
</Button>
|
|
62
|
-
<Modal zIndex={1001} onClose={() => closeLinkTree()} isOpen={isLinkTreeOpen} isDismissable>
|
|
63
|
-
<Modal.Header title="Select internal link" />
|
|
64
|
-
<Modal.Body>
|
|
65
|
-
<DocumentLinks
|
|
66
|
-
selectedUrl={selectedUrl}
|
|
67
|
-
onSelectUrl={onSelectUrl}
|
|
68
|
-
getAllDocuments={getAllDocuments}
|
|
69
|
-
getDocumentPagesByDocumentId={getDocumentPagesByDocumentId}
|
|
70
|
-
getDocumentSectionsByDocumentPageId={getDocumentSectionsByDocumentPageId}
|
|
71
|
-
/>
|
|
72
|
-
</Modal.Body>
|
|
73
|
-
<Modal.Footer
|
|
74
|
-
buttons={[
|
|
75
|
-
{
|
|
76
|
-
children: 'Cancel',
|
|
77
|
-
onClick: () => closeLinkTree(),
|
|
78
|
-
style: ButtonStyle.Default,
|
|
79
|
-
emphasis: ButtonEmphasis.Default,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
children: 'Choose',
|
|
83
|
-
onClick: (event) => {
|
|
84
|
-
event?.preventDefault();
|
|
85
|
-
saveLink();
|
|
86
|
-
},
|
|
87
|
-
style: ButtonStyle.Default,
|
|
88
|
-
emphasis: ButtonEmphasis.Strong,
|
|
89
|
-
disabled: !selectedUrl,
|
|
90
|
-
},
|
|
91
|
-
]}
|
|
92
|
-
/>
|
|
93
|
-
</Modal>
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { LoadingCircle, LoadingCircleSize } from '@frontify/fondue';
|
|
4
|
-
|
|
5
|
-
export const LoadingIndicator = () => {
|
|
6
|
-
return (
|
|
7
|
-
<div className="tw-flex tw-justify-center tw-h-10 tw-items-center">
|
|
8
|
-
<LoadingCircle size={LoadingCircleSize.Small} />
|
|
9
|
-
</div>
|
|
10
|
-
);
|
|
11
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { type DocumentSection } from '@frontify/app-bridge';
|
|
4
|
-
import { merge } from '@frontify/fondue';
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
import { InitiallyExpandedItems } from '../';
|
|
7
|
-
import { SectionLink } from './SectionLink';
|
|
8
|
-
|
|
9
|
-
type PageLinkProps = {
|
|
10
|
-
page: {
|
|
11
|
-
id: number;
|
|
12
|
-
title: string;
|
|
13
|
-
permanentLink: string;
|
|
14
|
-
};
|
|
15
|
-
selectedUrl: string;
|
|
16
|
-
onSelectUrl: (url: string) => void;
|
|
17
|
-
itemsToExpandInitially: InitiallyExpandedItems;
|
|
18
|
-
getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const PageLink = ({
|
|
22
|
-
page,
|
|
23
|
-
selectedUrl,
|
|
24
|
-
onSelectUrl,
|
|
25
|
-
itemsToExpandInitially,
|
|
26
|
-
getDocumentSectionsByDocumentPageId,
|
|
27
|
-
}: PageLinkProps) => {
|
|
28
|
-
const [isExpanded, setIsExpanded] = useState(page.id === itemsToExpandInitially.documentId);
|
|
29
|
-
const [documentSections, setDocumentSections] = useState<DocumentSection[]>([]);
|
|
30
|
-
const isActive = page.permanentLink === selectedUrl;
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const fetchDocumentSections = async () => {
|
|
34
|
-
const sections = await getDocumentSectionsByDocumentPageId(page.id);
|
|
35
|
-
setDocumentSections(sections);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
fetchDocumentSections();
|
|
39
|
-
}, [page.id, getDocumentSectionsByDocumentPageId]);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (page.id === itemsToExpandInitially.pageId) {
|
|
43
|
-
setIsExpanded(true);
|
|
44
|
-
}
|
|
45
|
-
}, [itemsToExpandInitially, page.id]);
|
|
46
|
-
|
|
47
|
-
const sectionsArray = [...documentSections.values()];
|
|
48
|
-
const hasSections = sectionsArray.length > 0;
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<>
|
|
52
|
-
<button
|
|
53
|
-
data-test-id="internal-link-selector-page-link"
|
|
54
|
-
className={merge([
|
|
55
|
-
'tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full',
|
|
56
|
-
hasSections ? 'tw-pl-7' : 'tw-pl-12',
|
|
57
|
-
isActive
|
|
58
|
-
? 'tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover'
|
|
59
|
-
: 'hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover',
|
|
60
|
-
])}
|
|
61
|
-
onClick={() => onSelectUrl(page.permanentLink)}
|
|
62
|
-
>
|
|
63
|
-
<div key={page.id} className="tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6">
|
|
64
|
-
{hasSections && (
|
|
65
|
-
<button
|
|
66
|
-
data-test-id="tree-item-toggle"
|
|
67
|
-
className="tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer"
|
|
68
|
-
onClick={() => setIsExpanded(!isExpanded)}
|
|
69
|
-
>
|
|
70
|
-
<div
|
|
71
|
-
className={merge([
|
|
72
|
-
'tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong',
|
|
73
|
-
isExpanded ? 'tw-rotate-90' : '',
|
|
74
|
-
])}
|
|
75
|
-
></div>
|
|
76
|
-
</button>
|
|
77
|
-
)}
|
|
78
|
-
<span className="tw-text-s">{page.title}</span>
|
|
79
|
-
<span className="tw-flex-auto tw-font-sans tw-text-xs tw-text-right">Page</span>
|
|
80
|
-
</div>
|
|
81
|
-
</button>
|
|
82
|
-
{isExpanded &&
|
|
83
|
-
sectionsArray.length > 0 &&
|
|
84
|
-
sectionsArray.map((section) => {
|
|
85
|
-
return (
|
|
86
|
-
<SectionLink
|
|
87
|
-
key={section.id}
|
|
88
|
-
section={section}
|
|
89
|
-
selectedUrl={selectedUrl}
|
|
90
|
-
onSelectUrl={onSelectUrl}
|
|
91
|
-
/>
|
|
92
|
-
);
|
|
93
|
-
})}
|
|
94
|
-
</>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import type { DocumentPage, DocumentSection } from '@frontify/app-bridge';
|
|
4
|
-
import { ReactElement, useEffect, useState } from 'react';
|
|
5
|
-
import { InitiallyExpandedItems } from '../';
|
|
6
|
-
import { PageLink } from './PageLink';
|
|
7
|
-
import { LoadingIndicator } from './LoadingIndicator';
|
|
8
|
-
|
|
9
|
-
type PageLinksProps = {
|
|
10
|
-
documentId: number;
|
|
11
|
-
selectedUrl: string;
|
|
12
|
-
onSelectUrl: (url: string) => void;
|
|
13
|
-
itemsToExpandInitially: InitiallyExpandedItems;
|
|
14
|
-
getDocumentSectionsByDocumentPageId: (documentPageId: number) => Promise<DocumentSection[]>;
|
|
15
|
-
getDocumentPagesByDocumentId: (documentId: number) => Promise<DocumentPage[]>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const PageLinks = ({
|
|
19
|
-
documentId,
|
|
20
|
-
selectedUrl,
|
|
21
|
-
onSelectUrl,
|
|
22
|
-
itemsToExpandInitially,
|
|
23
|
-
getDocumentSectionsByDocumentPageId,
|
|
24
|
-
getDocumentPagesByDocumentId,
|
|
25
|
-
}: PageLinksProps): ReactElement => {
|
|
26
|
-
const [pages, setPages] = useState<DocumentPage[]>([]);
|
|
27
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
28
|
-
const pagesArray = [...pages.values()];
|
|
29
|
-
const hasPages = !isLoading && pagesArray.length > 0;
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
getDocumentPagesByDocumentId(documentId)
|
|
33
|
-
.then((_pages) => {
|
|
34
|
-
const pagesWithCategories = _pages
|
|
35
|
-
.filter((page) => !!page.category)
|
|
36
|
-
.sort((a, b) =>
|
|
37
|
-
a.category.sort === b.category.sort ? a.sort - b.sort : a.category.sort - b.category.sort,
|
|
38
|
-
);
|
|
39
|
-
const pagesWithoutCategories = _pages.filter((page) => !page.category).sort((a, b) => a.sort - b.sort);
|
|
40
|
-
setPages([...pagesWithCategories, ...pagesWithoutCategories]);
|
|
41
|
-
})
|
|
42
|
-
.finally(() => {
|
|
43
|
-
setIsLoading(false);
|
|
44
|
-
});
|
|
45
|
-
}, []);
|
|
46
|
-
|
|
47
|
-
if (isLoading) {
|
|
48
|
-
return <LoadingIndicator />;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return hasPages ? (
|
|
52
|
-
<>
|
|
53
|
-
{pagesArray.map((page) => {
|
|
54
|
-
return (
|
|
55
|
-
<PageLink
|
|
56
|
-
key={page.id}
|
|
57
|
-
page={page}
|
|
58
|
-
selectedUrl={selectedUrl}
|
|
59
|
-
onSelectUrl={onSelectUrl}
|
|
60
|
-
itemsToExpandInitially={itemsToExpandInitially}
|
|
61
|
-
getDocumentSectionsByDocumentPageId={getDocumentSectionsByDocumentPageId}
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
})}
|
|
65
|
-
</>
|
|
66
|
-
) : (
|
|
67
|
-
<div className="tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak">
|
|
68
|
-
This document does not contain any pages.
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { IconDocumentText16, merge } from '@frontify/fondue';
|
|
4
|
-
|
|
5
|
-
type SectionLinkProps = {
|
|
6
|
-
section: {
|
|
7
|
-
id: number;
|
|
8
|
-
title: string;
|
|
9
|
-
permanentLink: string;
|
|
10
|
-
};
|
|
11
|
-
selectedUrl: string;
|
|
12
|
-
onSelectUrl: (url: string) => void;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const SectionLink = ({ section, selectedUrl, onSelectUrl }: SectionLinkProps) => {
|
|
16
|
-
const isActive = section.permanentLink === selectedUrl;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<button
|
|
20
|
-
data-test-id="internal-link-selector-section-link"
|
|
21
|
-
className={merge([
|
|
22
|
-
'tw-py-2 tw-px-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full',
|
|
23
|
-
isActive
|
|
24
|
-
? 'tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover'
|
|
25
|
-
: 'hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover',
|
|
26
|
-
])}
|
|
27
|
-
onClick={() => onSelectUrl(section.permanentLink)}
|
|
28
|
-
>
|
|
29
|
-
<div className="tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6">
|
|
30
|
-
<IconDocumentText16 />
|
|
31
|
-
<span className="tw-text-s">{section.title}</span>
|
|
32
|
-
<span className="tw-flex-auto tw-font-sans tw-text-xs tw-text-right">Section</span>
|
|
33
|
-
</div>
|
|
34
|
-
</button>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* (c) Copyright Frontify Ltd., all rights reserved. */
|
|
2
|
-
|
|
3
|
-
import { ELEMENT_LINK, PlateEditor, getAboveNode } from '@udecode/plate';
|
|
4
|
-
import { TLinkElement } from '../../RichTextEditor/plugins/LinkPlugin/types';
|
|
5
|
-
|
|
6
|
-
const getLinkNode = (editor: PlateEditor, cb: (link: TLinkElement) => string): string => {
|
|
7
|
-
const linkNode = getAboveNode<TLinkElement>(editor, { match: { type: ELEMENT_LINK } });
|
|
8
|
-
|
|
9
|
-
if (!Array.isArray(linkNode)) {
|
|
10
|
-
return '';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return cb(linkNode[0]);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const getLegacyUrl = (editor: PlateEditor) => {
|
|
17
|
-
return getLinkNode(editor, (link) => link.chosenLink?.searchResult?.link || '');
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const getUrl = (editor: PlateEditor) => {
|
|
21
|
-
return getLinkNode(editor, (link) => link.url || '');
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const getUrlFromLinkOrLegacyLink = (link: TLinkElement): string => {
|
|
25
|
-
return link.url || link.chosenLink?.searchResult?.link || '';
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const getLinkFromEditor = (editor: PlateEditor) => {
|
|
29
|
-
return getLinkNode(editor, getUrlFromLinkOrLegacyLink);
|
|
30
|
-
};
|