@quadrats/react 0.7.7 → 1.0.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/accordion/accordion.css +1 -0
- package/accordion/accordion.scss +81 -0
- package/accordion/components/Accordion.d.ts +9 -0
- package/accordion/components/Accordion.js +22 -0
- package/accordion/components/AccordionContent.d.ts +8 -0
- package/accordion/components/AccordionContent.js +24 -0
- package/accordion/components/AccordionTitle.d.ts +8 -0
- package/accordion/components/AccordionTitle.js +20 -0
- package/accordion/contexts/AccordionContext.d.ts +2 -0
- package/accordion/contexts/AccordionContext.js +5 -0
- package/accordion/createReactAccordion.d.ts +4 -0
- package/accordion/createReactAccordion.js +144 -0
- package/accordion/defaultRenderAccordionElements.d.ts +2 -0
- package/accordion/defaultRenderAccordionElements.js +12 -0
- package/accordion/hooks/useAccordion.d.ts +1 -0
- package/accordion/hooks/useAccordion.js +8 -0
- package/accordion/index.cjs.js +212 -0
- package/accordion/index.d.ts +8 -0
- package/accordion/index.js +10 -0
- package/accordion/jsx-serializer/createJsxSerializeAccordion.d.ts +5 -0
- package/accordion/jsx-serializer/createJsxSerializeAccordion.js +48 -0
- package/accordion/jsx-serializer/defaultRenderAccordionElements.d.ts +2 -0
- package/accordion/jsx-serializer/defaultRenderAccordionElements.js +16 -0
- package/accordion/jsx-serializer/index.cjs.js +64 -0
- package/accordion/jsx-serializer/index.d.ts +3 -0
- package/accordion/jsx-serializer/index.js +2 -0
- package/accordion/jsx-serializer/package.json +7 -0
- package/accordion/jsx-serializer/typings.d.ts +4 -0
- package/accordion/package.json +10 -0
- package/accordion/toolbar/AccordionToolbarIcon.d.ts +8 -0
- package/accordion/toolbar/AccordionToolbarIcon.js +12 -0
- package/accordion/toolbar/index.cjs.js +22 -0
- package/accordion/toolbar/index.d.ts +2 -0
- package/accordion/toolbar/index.js +2 -0
- package/accordion/toolbar/package.json +7 -0
- package/accordion/toolbar/useAccordionTool.d.ts +4 -0
- package/accordion/toolbar/useAccordionTool.js +10 -0
- package/accordion/typings.d.ts +25 -0
- package/align/constants.d.ts +8 -0
- package/align/constants.js +10 -0
- package/align/createReactAlign.d.ts +2 -0
- package/align/createReactAlign.js +26 -0
- package/align/index.cjs.js +39 -0
- package/align/index.d.ts +3 -0
- package/align/index.js +2 -0
- package/align/package.json +7 -0
- package/align/toolbar/AlignToolbarIcon.d.ts +10 -0
- package/align/toolbar/AlignToolbarIcon.js +12 -0
- package/align/toolbar/index.cjs.js +30 -0
- package/align/toolbar/index.d.ts +2 -0
- package/align/toolbar/index.js +2 -0
- package/align/toolbar/package.json +7 -0
- package/align/toolbar/useAlignTool.d.ts +6 -0
- package/align/toolbar/useAlignTool.js +18 -0
- package/align/typings.d.ts +17 -0
- package/blockquote/blockquote.css +1 -0
- package/blockquote/blockquote.scss +23 -0
- package/blockquote/defaultRenderBlockquoteElement.js +3 -1
- package/blockquote/index.cjs.js +3 -1
- package/blockquote/package.json +4 -1
- package/card/card.css +1 -0
- package/card/card.scss +243 -0
- package/card/components/Card.d.ts +15 -0
- package/card/components/Card.js +101 -0
- package/card/components/CardContents.d.ts +9 -0
- package/card/components/CardContents.js +18 -0
- package/card/components/CardImage.d.ts +9 -0
- package/card/components/CardImage.js +13 -0
- package/card/components/CardPlaceholder.d.ts +4 -0
- package/card/components/CardPlaceholder.js +21 -0
- package/card/createReactCard.d.ts +4 -0
- package/card/createReactCard.js +82 -0
- package/card/defaultRenderCardElements.d.ts +3 -0
- package/card/defaultRenderCardElements.js +14 -0
- package/card/index.cjs.js +234 -0
- package/card/index.d.ts +7 -0
- package/card/index.js +6 -0
- package/card/jsx-serializer/createJsxSerializeCard.d.ts +5 -0
- package/card/jsx-serializer/createJsxSerializeCard.js +48 -0
- package/card/jsx-serializer/defaultRenderCardElements.d.ts +2 -0
- package/card/jsx-serializer/defaultRenderCardElements.js +10 -0
- package/card/jsx-serializer/index.cjs.js +58 -0
- package/card/jsx-serializer/index.d.ts +3 -0
- package/card/jsx-serializer/index.js +2 -0
- package/card/jsx-serializer/package.json +7 -0
- package/card/jsx-serializer/typings.d.ts +9 -0
- package/card/package.json +10 -0
- package/card/toolbar/CardToolbarIcon.d.ts +8 -0
- package/card/toolbar/CardToolbarIcon.js +12 -0
- package/card/toolbar/index.cjs.js +66 -0
- package/card/toolbar/index.d.ts +2 -0
- package/card/toolbar/index.js +2 -0
- package/card/toolbar/package.json +7 -0
- package/card/toolbar/useCardTool.d.ts +4 -0
- package/card/toolbar/useCardTool.js +55 -0
- package/card/typings.d.ts +24 -0
- package/carousel/carousel.css +1 -0
- package/carousel/carousel.scss +356 -0
- package/carousel/components/Carousel.d.ts +15 -0
- package/carousel/components/Carousel.js +62 -0
- package/carousel/components/CarouselCaption.d.ts +9 -0
- package/carousel/components/CarouselCaption.js +12 -0
- package/carousel/components/CarouselImages.d.ts +9 -0
- package/carousel/components/CarouselImages.js +52 -0
- package/carousel/components/CarouselPlaceholder.d.ts +4 -0
- package/carousel/components/CarouselPlaceholder.js +17 -0
- package/carousel/contexts/CarouselContext.d.ts +2 -0
- package/carousel/contexts/CarouselContext.js +5 -0
- package/carousel/createReactCarousel.d.ts +4 -0
- package/carousel/createReactCarousel.js +82 -0
- package/carousel/defaultRenderCarouselElements.d.ts +3 -0
- package/carousel/defaultRenderCarouselElements.js +14 -0
- package/carousel/hooks/useCarousel.d.ts +1 -0
- package/carousel/hooks/useCarousel.js +8 -0
- package/carousel/index.cjs.js +232 -0
- package/carousel/index.d.ts +9 -0
- package/carousel/index.js +8 -0
- package/carousel/jsx-serializer/createJsxSerializeCarousel.d.ts +5 -0
- package/carousel/jsx-serializer/createJsxSerializeCarousel.js +48 -0
- package/carousel/jsx-serializer/defaultRenderCarouselElements.d.ts +2 -0
- package/carousel/jsx-serializer/defaultRenderCarouselElements.js +10 -0
- package/carousel/jsx-serializer/index.cjs.js +58 -0
- package/carousel/jsx-serializer/index.d.ts +3 -0
- package/carousel/jsx-serializer/index.js +2 -0
- package/carousel/jsx-serializer/package.json +7 -0
- package/carousel/jsx-serializer/typings.d.ts +9 -0
- package/carousel/package.json +10 -0
- package/carousel/toolbar/CarouselToolbarIcon.d.ts +8 -0
- package/carousel/toolbar/CarouselToolbarIcon.js +12 -0
- package/carousel/toolbar/index.cjs.js +57 -0
- package/carousel/toolbar/index.d.ts +2 -0
- package/carousel/toolbar/index.js +2 -0
- package/carousel/toolbar/package.json +7 -0
- package/carousel/toolbar/useCarouselTool.d.ts +4 -0
- package/carousel/toolbar/useCarouselTool.js +46 -0
- package/carousel/typings.d.ts +27 -0
- package/components/BaseField/index.d.ts +11 -0
- package/components/BaseField/index.js +17 -0
- package/components/Button/index.d.ts +14 -0
- package/components/Button/index.js +12 -0
- package/components/Hint/index.d.ts +15 -0
- package/components/Hint/index.js +30 -0
- package/components/ImageUploader/index.d.ts +25 -0
- package/components/ImageUploader/index.js +174 -0
- package/components/Input/index.d.ts +14 -0
- package/components/Input/index.js +24 -0
- package/components/Message/index.d.ts +18 -0
- package/components/Message/index.js +72 -0
- package/components/Modal/index.d.ts +28 -0
- package/components/Modal/index.js +61 -0
- package/components/Notifier/NotifierManager.d.ts +17 -0
- package/components/Notifier/NotifierManager.js +24 -0
- package/components/Notifier/createNotifier.d.ts +21 -0
- package/components/Notifier/createNotifier.js +60 -0
- package/components/Notifier/typings.d.ts +28 -0
- package/components/Progress/index.d.ts +1 -1
- package/components/Progress/index.js +12 -8
- package/components/SegmentedControl/index.d.ts +13 -0
- package/components/SegmentedControl/index.js +14 -0
- package/components/Textarea/index.d.ts +15 -0
- package/components/Textarea/index.js +24 -0
- package/components/Toggle/index.d.ts +8 -0
- package/components/Toggle/index.js +15 -0
- package/components/Transition/SlideFade.d.ts +20 -0
- package/components/Transition/SlideFade.js +91 -0
- package/components/Transition/Transition.d.ts +98 -0
- package/components/Transition/Transition.js +27 -0
- package/components/Transition/getTransitionStyleProps.d.ts +16 -0
- package/components/Transition/getTransitionStyleProps.js +25 -0
- package/components/Transition/useSetNodeTransition.d.ts +7 -0
- package/components/Transition/useSetNodeTransition.js +35 -0
- package/components/baseField.css +1 -0
- package/components/baseField.scss +34 -0
- package/components/button.css +1 -0
- package/components/button.scss +254 -0
- package/components/components.css +1 -0
- package/components/components.scss +12 -0
- package/components/hint.css +1 -0
- package/components/hint.scss +59 -0
- package/components/index.cjs.js +647 -11
- package/components/index.d.ts +12 -0
- package/components/index.js +11 -0
- package/components/input.css +1 -0
- package/components/input.scss +102 -0
- package/components/message.css +1 -0
- package/components/message.scss +57 -0
- package/components/modal.css +1 -0
- package/components/modal.scss +200 -0
- package/components/progress.css +1 -1
- package/components/progress.scss +32 -20
- package/components/segmentedControl.css +1 -0
- package/components/segmentedControl.scss +63 -0
- package/components/textarea.css +1 -0
- package/components/textarea.scss +104 -0
- package/components/toggle.css +1 -0
- package/components/toggle.scss +55 -0
- package/components/tooltip.css +1 -1
- package/components/tooltip.scss +1 -1
- package/core/components/Editable.js +22 -3
- package/core/components/Quadrats.d.ts +4 -1
- package/core/components/Quadrats.js +6 -2
- package/core/constants.d.ts +1 -0
- package/core/constants.js +3 -0
- package/core/contexts/composition/CompositionProvider.d.ts +8 -0
- package/core/contexts/composition/CompositionProvider.js +8 -0
- package/core/contexts/composition/composition.d.ts +7 -0
- package/core/contexts/composition/composition.js +11 -0
- package/core/contexts/message/MessageProvider.d.ts +5 -0
- package/core/contexts/message/MessageProvider.js +35 -0
- package/core/contexts/message/message.d.ts +10 -0
- package/core/contexts/message/message.js +10 -0
- package/core/contexts/modal/CardModal/CardModal.d.ts +28 -0
- package/core/contexts/modal/CardModal/CardModal.js +103 -0
- package/core/contexts/modal/CarouselModal/CarouselItem.d.ts +15 -0
- package/core/contexts/modal/CarouselModal/CarouselItem.js +56 -0
- package/core/contexts/modal/CarouselModal/CarouselModal.d.ts +11 -0
- package/core/contexts/modal/CarouselModal/CarouselModal.js +174 -0
- package/core/contexts/modal/CarouselModal/FilesDropZone.d.ts +13 -0
- package/core/contexts/modal/CarouselModal/FilesDropZone.js +64 -0
- package/core/contexts/modal/ConfirmModal/ConfirmModal.d.ts +14 -0
- package/core/contexts/modal/ConfirmModal/ConfirmModal.js +21 -0
- package/core/contexts/modal/EmbedModal/EmbedModal.d.ts +11 -0
- package/core/contexts/modal/EmbedModal/EmbedModal.js +25 -0
- package/core/contexts/modal/ModalProvider.d.ts +8 -0
- package/core/contexts/modal/ModalProvider.js +66 -0
- package/core/contexts/modal/modal.d.ts +24 -0
- package/core/contexts/modal/modal.js +15 -0
- package/core/index.d.ts +8 -1
- package/divider/defaultRenderDividerElement.d.ts +1 -1
- package/divider/defaultRenderDividerElement.js +2 -3
- package/divider/divider.css +1 -0
- package/divider/divider.scss +9 -0
- package/divider/index.cjs.js +2 -3
- package/divider/jsx-serializer/defaultRenderDividerElement.js +2 -1
- package/divider/jsx-serializer/index.cjs.js +2 -1
- package/divider/package.json +4 -1
- package/editable.css +1 -1
- package/editable.scss +5 -6
- package/embed/components/VideoIframe.d.ts +3 -2
- package/embed/components/VideoIframe.js +2 -1
- package/embed/createReactEmbed.js +4 -1
- package/embed/createRenderEmbedElementBase.js +3 -1
- package/embed/embed.css +1 -0
- package/embed/embed.scss +234 -0
- package/embed/index.cjs.js +8 -2
- package/embed/jsx-serializer/youtube/index.cjs.js +1 -10
- package/embed/jsx-serializer/youtube/index.d.ts +1 -1
- package/embed/jsx-serializer/youtube/index.js +1 -1
- package/embed/package.json +4 -1
- package/embed/renderers/base/components/BaseEmbedElement.d.ts +21 -0
- package/embed/renderers/base/components/BaseEmbedElement.js +62 -0
- package/embed/renderers/base/index.cjs.js +65 -0
- package/embed/renderers/base/index.d.ts +1 -0
- package/embed/renderers/base/index.js +1 -0
- package/embed/renderers/base/package.json +7 -0
- package/embed/renderers/facebook/components/Facebook.d.ts +3 -2
- package/embed/renderers/facebook/components/Facebook.js +18 -11
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.d.ts +2 -0
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.js +42 -2
- package/embed/renderers/facebook/index.cjs.js +61 -12
- package/embed/renderers/facebook/index.d.ts +1 -1
- package/embed/renderers/facebook/index.js +1 -1
- package/embed/renderers/instagram/components/Instagram.d.ts +3 -2
- package/embed/renderers/instagram/components/Instagram.js +22 -11
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.d.ts +2 -0
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.js +42 -2
- package/embed/renderers/instagram/index.cjs.js +65 -12
- package/embed/renderers/instagram/index.d.ts +1 -1
- package/embed/renderers/instagram/index.js +1 -1
- package/embed/renderers/podcast-apple/components/PodcastApple.d.ts +3 -2
- package/embed/renderers/podcast-apple/components/PodcastApple.js +2 -1
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.d.ts +2 -0
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.js +35 -2
- package/embed/renderers/podcast-apple/index.cjs.js +38 -2
- package/embed/renderers/podcast-apple/index.d.ts +1 -1
- package/embed/renderers/podcast-apple/index.js +1 -1
- package/embed/renderers/spotify/components/Spotify.d.ts +3 -2
- package/embed/renderers/spotify/components/Spotify.js +3 -1
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.d.ts +2 -0
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.js +32 -2
- package/embed/renderers/spotify/index.cjs.js +36 -2
- package/embed/renderers/spotify/index.d.ts +1 -1
- package/embed/renderers/spotify/index.js +1 -1
- package/embed/renderers/twitter/components/Twitter.d.ts +3 -2
- package/embed/renderers/twitter/components/Twitter.js +14 -2
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.d.ts +2 -0
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.js +42 -2
- package/embed/renderers/twitter/index.cjs.js +57 -3
- package/embed/renderers/twitter/index.d.ts +1 -1
- package/embed/renderers/twitter/index.js +1 -1
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.d.ts +2 -0
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.js +26 -2
- package/embed/renderers/vimeo/index.cjs.js +27 -1
- package/embed/renderers/vimeo/index.d.ts +1 -1
- package/embed/renderers/vimeo/index.js +1 -1
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.d.ts +2 -0
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.js +26 -2
- package/embed/renderers/youtube/index.cjs.js +27 -1
- package/embed/renderers/youtube/index.d.ts +1 -1
- package/embed/renderers/youtube/index.js +1 -1
- package/embed/toolbar/EmbedToolbarIcon.d.ts +3 -6
- package/embed/toolbar/EmbedToolbarIcon.js +2 -2
- package/embed/toolbar/index.cjs.js +98 -13
- package/embed/toolbar/useEmbedTool.d.ts +1 -3
- package/embed/toolbar/useEmbedTool.js +96 -11
- package/embed/typings.d.ts +1 -0
- package/file-uploader/components/FileUploader.js +1 -2
- package/file-uploader/createReactFileUploader.js +4 -1
- package/file-uploader/defaultRenderFileUploaderElement.js +1 -1
- package/file-uploader/file-uploader.css +1 -1
- package/file-uploader/file-uploader.scss +0 -20
- package/file-uploader/index.cjs.js +5 -3
- package/file-uploader/toolbar/index.cjs.js +4 -1
- package/file-uploader/toolbar/useFileUploaderTool.d.ts +1 -1
- package/file-uploader/toolbar/useFileUploaderTool.js +4 -1
- package/file-uploader/typings.d.ts +6 -1
- package/footnote/defaultRenderFootnoteElement.js +1 -1
- package/footnote/index.cjs.js +1 -1
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.js +1 -1
- package/footnote/jsx-serializer/index.cjs.js +1 -1
- package/footnote/toolbar/index.cjs.js +1 -1
- package/footnote/toolbar/useFootnoteTool.js +1 -1
- package/heading/defaultRenderHeadingElement.js +2 -1
- package/heading/heading.css +1 -0
- package/heading/heading.scss +53 -0
- package/heading/index.cjs.js +2 -1
- package/heading/package.json +4 -1
- package/image/components/Image.js +51 -10
- package/image/components/ImageCaption.js +6 -4
- package/image/components/ImagePlaceholder.d.ts +4 -0
- package/image/components/ImagePlaceholder.js +11 -0
- package/image/createReactImage.js +13 -13
- package/image/image.css +1 -1
- package/image/image.scss +61 -6
- package/image/index.cjs.js +97 -45
- package/image/index.d.ts +1 -0
- package/image/index.js +1 -0
- package/image/jsx-serializer/defaultRenderImageElements.js +2 -1
- package/image/jsx-serializer/index.cjs.js +2 -1
- package/image/jsx-serializer/typings.d.ts +2 -0
- package/image/typings.d.ts +2 -0
- package/index.cjs.js +555 -6
- package/index.js +9 -3
- package/input-block/components/InputBlock.js +19 -9
- package/input-block/defaultRenderInputBlockElement.js +1 -1
- package/input-block/hooks/useInputBlock.d.ts +2 -0
- package/input-block/hooks/useInputBlock.js +16 -8
- package/input-block/index.cjs.js +35 -17
- package/input-block/input-block.css +1 -0
- package/input-block/input-block.scss +38 -0
- package/input-block/package.json +4 -1
- package/line-break/line-break.scss +0 -2
- package/list/createReactList.js +11 -1
- package/list/index.cjs.js +15 -5
- package/list/list.css +1 -0
- package/list/list.scss +43 -0
- package/list/package.json +4 -1
- package/package.json +11 -8
- package/paragraph/createReactParagraph.d.ts +2 -0
- package/paragraph/createReactParagraph.js +8 -0
- package/paragraph/createRenderParagraphElement.d.ts +1 -1
- package/paragraph/defaultRenderParagraphElement.d.ts +3 -1
- package/paragraph/defaultRenderParagraphElement.js +4 -1
- package/paragraph/index.cjs.js +15 -2
- package/paragraph/index.d.ts +1 -0
- package/paragraph/index.js +1 -0
- package/paragraph/paragraph.css +1 -1
- package/paragraph/paragraph.scss +7 -2
- package/paragraph/renderParagraphElementWithSymbol.d.ts +3 -1
- package/paragraph/renderParagraphElementWithSymbol.js +4 -1
- package/paragraph/toolbar/ParagraphToolbarIcon.d.ts +8 -0
- package/paragraph/toolbar/ParagraphToolbarIcon.js +12 -0
- package/paragraph/toolbar/index.cjs.js +23 -0
- package/paragraph/toolbar/index.d.ts +2 -0
- package/paragraph/toolbar/index.js +2 -0
- package/paragraph/toolbar/package.json +7 -0
- package/paragraph/toolbar/useToggleParagraphTool.d.ts +5 -0
- package/paragraph/toolbar/useToggleParagraphTool.js +11 -0
- package/read-more/components/ReadMore.js +5 -3
- package/read-more/index.cjs.js +5 -3
- package/read-more/read-more.css +1 -1
- package/read-more/read-more.scss +27 -20
- package/toolbar/components/InlineToolbar.d.ts +18 -0
- package/toolbar/components/InlineToolbar.js +27 -0
- package/toolbar/components/Toolbar.js +23 -6
- package/toolbar/components/ToolbarGroupIcon.d.ts +7 -0
- package/toolbar/components/ToolbarGroupIcon.js +80 -0
- package/toolbar/components/ToolbarIcon.d.ts +3 -1
- package/toolbar/components/ToolbarIcon.js +24 -6
- package/toolbar/components/toolbarIconName.d.ts +2 -0
- package/toolbar/components/toolbarIconName.js +86 -0
- package/toolbar/contexts/toolbar.d.ts +7 -0
- package/toolbar/contexts/toolbar.js +10 -0
- package/toolbar/contexts/toolbarMenu.d.ts +6 -0
- package/toolbar/contexts/toolbarMenu.js +11 -0
- package/toolbar/hooks/useAutoGroupIcons.d.ts +12 -0
- package/toolbar/hooks/useAutoGroupIcons.js +68 -0
- package/toolbar/index.cjs.js +300 -12
- package/toolbar/index.d.ts +2 -0
- package/toolbar/index.js +2 -0
- package/toolbar/toolbar.css +1 -1
- package/toolbar/toolbar.scss +191 -43
- package/utils/index.cjs.js +153 -0
- package/utils/index.d.ts +6 -0
- package/utils/index.js +6 -0
- package/utils/removePreviousElement.d.ts +9 -0
- package/utils/removePreviousElement.js +38 -0
- package/utils/upload.d.ts +11 -0
- package/utils/upload.js +57 -0
- package/utils/useClickAway.d.ts +5 -0
- package/utils/useClickAway.js +23 -0
- package/utils/useDocumentEvents.d.ts +5 -0
- package/utils/useDocumentEvents.js +21 -0
- package/utils/useIsomorphicLayoutEffect.d.ts +2 -0
- package/utils/useIsomorphicLayoutEffect.js +9 -0
- package/utils/usePreviousValue.d.ts +1 -0
- package/utils/usePreviousValue.js +11 -0
- package/core/index.js +0 -11
package/toolbar/toolbar.scss
CHANGED
|
@@ -1,58 +1,99 @@
|
|
|
1
|
-
$qdr-toolbar-popup-gap:
|
|
1
|
+
$qdr-toolbar-popup-gap: --qdr-spacing-4;
|
|
2
2
|
$qdr-toolbar-arrow-size: $qdr-toolbar-popup-gap;
|
|
3
|
-
$qdr-toolbar-height:
|
|
4
|
-
$qdr-toolbar-padding-vertical:
|
|
5
|
-
$qdr-toolbar-padding-horizontal:
|
|
6
|
-
$qdr-toolbar-input-cross-size:
|
|
3
|
+
$qdr-toolbar-height: --qdr-spacing-14;
|
|
4
|
+
$qdr-toolbar-padding-vertical: --qdr-spacing-4;
|
|
5
|
+
$qdr-toolbar-padding-horizontal: --qdr-spacing-4;
|
|
6
|
+
$qdr-toolbar-input-cross-size: --qdr-spacing-7;
|
|
7
7
|
|
|
8
8
|
.qdr-toolbar {
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
|
-
gap:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
padding: $qdr-toolbar-padding-vertical $qdr-toolbar-padding-horizontal;
|
|
11
|
+
gap: var(--qdr-spacing-4);
|
|
12
|
+
height: var(#{$qdr-toolbar-height});
|
|
13
|
+
padding: var(#{$qdr-toolbar-padding-vertical}) var(#{$qdr-toolbar-padding-horizontal});
|
|
15
14
|
background-color: var(--qdr-surface);
|
|
16
15
|
border: 1px solid var(--qdr-border);
|
|
17
16
|
box-sizing: border-box;
|
|
18
17
|
|
|
19
18
|
&--radius {
|
|
20
|
-
border-radius:
|
|
19
|
+
border-radius: var(--qdr-radius-3);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
&--shadow {
|
|
24
|
-
box-shadow:
|
|
23
|
+
box-shadow: var(--qdr-shadow-s);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__input {
|
|
27
|
+
font-size: 0.8125rem;
|
|
28
|
+
background: var(--qdr-block);
|
|
29
|
+
color: var(--qdr-text-secondary);
|
|
30
|
+
width: calc(100% - var(#{$qdr-toolbar-input-cross-size}));
|
|
31
|
+
height: 100%;
|
|
32
|
+
border: none;
|
|
33
|
+
padding: 0;
|
|
34
|
+
outline: none;
|
|
35
|
+
|
|
36
|
+
&__wrapper {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: var(#{$qdr-toolbar-padding-vertical});
|
|
41
|
+
left: var(#{$qdr-toolbar-padding-horizontal});
|
|
42
|
+
width: calc(100% - var(#{$qdr-toolbar-padding-horizontal}) * 2);
|
|
43
|
+
height: calc(100% - (var(#{$qdr-toolbar-padding-vertical}) * 2 + var(#{$qdr-toolbar-popup-gap})));
|
|
44
|
+
background: var(--qdr-block);
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&__cross {
|
|
49
|
+
fill: var(--qdr-text-secondary);
|
|
50
|
+
font-size: var(#{$qdr-toolbar-input-cross-size});
|
|
51
|
+
width: var(#{$qdr-toolbar-input-cross-size});
|
|
52
|
+
height: var(#{$qdr-toolbar-input-cross-size});
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
}
|
|
25
55
|
}
|
|
26
56
|
|
|
27
57
|
&__wrapper {
|
|
28
58
|
box-sizing: content-box;
|
|
29
|
-
height: $qdr-toolbar-height;
|
|
59
|
+
height: var(#{$qdr-toolbar-height});
|
|
30
60
|
|
|
31
61
|
&--fixed {
|
|
32
62
|
position: sticky;
|
|
33
63
|
top: 0;
|
|
34
64
|
z-index: 1;
|
|
65
|
+
|
|
66
|
+
.qdr-toolbar {
|
|
67
|
+
&__input {
|
|
68
|
+
&__wrapper {
|
|
69
|
+
height: calc(100% - (var(#{$qdr-toolbar-padding-vertical}) * 2));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
35
73
|
}
|
|
36
74
|
|
|
37
75
|
&--float {
|
|
38
76
|
position: absolute;
|
|
39
77
|
z-index: 1;
|
|
40
|
-
padding-bottom: $qdr-toolbar-popup-gap;
|
|
78
|
+
padding-bottom: var(#{$qdr-toolbar-popup-gap});
|
|
79
|
+
|
|
80
|
+
.qdr-toolbar {
|
|
81
|
+
background-color: var(--qdr-block);
|
|
82
|
+
}
|
|
41
83
|
}
|
|
42
84
|
|
|
43
85
|
&--inputting {
|
|
44
86
|
min-width: 250px;
|
|
45
|
-
max-width: 350px;
|
|
46
87
|
}
|
|
47
88
|
}
|
|
48
89
|
|
|
49
90
|
&__arrow {
|
|
50
91
|
position: absolute;
|
|
51
|
-
top: calc(100% - #{$qdr-toolbar-popup-gap});
|
|
92
|
+
top: calc(100% - var(#{$qdr-toolbar-popup-gap}));
|
|
52
93
|
left: 50%;
|
|
53
94
|
content: '';
|
|
54
|
-
width: $qdr-toolbar-arrow-size;
|
|
55
|
-
height: $qdr-toolbar-arrow-size;
|
|
95
|
+
width: var(#{$qdr-toolbar-arrow-size});
|
|
96
|
+
height: var(#{$qdr-toolbar-arrow-size});
|
|
56
97
|
background: var(--qdr-surface);
|
|
57
98
|
border: 1px solid var(--qdr-border);
|
|
58
99
|
border-top: none;
|
|
@@ -62,60 +103,167 @@ $qdr-toolbar-input-cross-size: 14px;
|
|
|
62
103
|
|
|
63
104
|
&__divider {
|
|
64
105
|
width: 1px;
|
|
65
|
-
height:
|
|
106
|
+
height: var(--qdr-spacing-8);
|
|
66
107
|
background-color: var(--qdr-divider);
|
|
67
108
|
}
|
|
68
109
|
|
|
69
110
|
&__icon {
|
|
70
111
|
position: relative;
|
|
71
|
-
color: var(--qdr-
|
|
112
|
+
color: var(--qdr-action-inactive);
|
|
72
113
|
font-size: 24px;
|
|
73
114
|
display: inline-flex;
|
|
74
115
|
justify-content: center;
|
|
75
116
|
align-items: center;
|
|
117
|
+
gap: var(--qdr-spacing-1);
|
|
76
118
|
border: 0;
|
|
77
119
|
background-color: transparent;
|
|
78
|
-
padding:
|
|
120
|
+
padding: var(--qdr-spacing-2);
|
|
79
121
|
outline: none;
|
|
80
122
|
box-shadow: none;
|
|
81
|
-
border-radius:
|
|
82
|
-
transition:
|
|
123
|
+
border-radius: var(--qdr-radius-1);
|
|
124
|
+
transition:
|
|
125
|
+
color var(--qdr-duration-short) var(--qdr-easing-standard),
|
|
126
|
+
background var(--qdr-duration-short) var(--qdr-easing-standard);
|
|
83
127
|
cursor: pointer;
|
|
84
128
|
|
|
85
129
|
&:hover,
|
|
130
|
+
&--expanded {
|
|
131
|
+
color: var(--qdr-action-active);
|
|
132
|
+
background: var(--qdr-secondary-hover-bg);
|
|
133
|
+
}
|
|
134
|
+
|
|
86
135
|
&--active {
|
|
87
136
|
color: var(--qdr-primary);
|
|
88
137
|
}
|
|
89
|
-
}
|
|
90
138
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
139
|
+
&--with-name {
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
justify-content: flex-start;
|
|
143
|
+
border-radius: 0;
|
|
144
|
+
gap: var(--qdr-spacing-4);
|
|
145
|
+
padding: 0 var(--qdr-spacing-6);
|
|
146
|
+
|
|
147
|
+
&:hover {
|
|
148
|
+
color: var(--qdr-action-inactive);
|
|
149
|
+
background: var(--qdr-primary-hover-bg);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&--active {
|
|
153
|
+
color: var(--qdr-action-inactive);
|
|
154
|
+
background: var(--qdr-primary-active-bg);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
100
157
|
|
|
101
158
|
&__wrapper {
|
|
102
159
|
display: flex;
|
|
103
160
|
align-items: center;
|
|
161
|
+
justify-content: center;
|
|
162
|
+
position: relative;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
&__arrow {
|
|
166
|
+
color: var(--qdr-action-disabled);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&__name {
|
|
170
|
+
flex: 1;
|
|
171
|
+
margin: 0;
|
|
172
|
+
font-size: var(--qdr-typography-basic-input1-font-size);
|
|
173
|
+
line-height: var(--qdr-typography-basic-input1-line-height);
|
|
174
|
+
letter-spacing: var(--qdr-typography-basic-input1-letter-spacing);
|
|
175
|
+
font-weight: var(--qdr-typography-basic-input1-font-weight);
|
|
176
|
+
color: var(--qdr-text-primary);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
&__check {
|
|
180
|
+
color: var(--qdr-primary);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&__menu {
|
|
184
|
+
opacity: 0;
|
|
104
185
|
position: absolute;
|
|
105
|
-
top: $qdr-toolbar-padding-vertical;
|
|
106
|
-
left: $qdr-toolbar-padding-horizontal;
|
|
107
|
-
width: calc(100% - #{$qdr-toolbar-padding-horizontal * 2});
|
|
108
|
-
height: calc(100% - #{$qdr-toolbar-padding-vertical * 2 + $qdr-toolbar-popup-gap});
|
|
109
186
|
background: var(--qdr-surface);
|
|
110
|
-
|
|
187
|
+
border: 1px solid var(--qdr-border);
|
|
188
|
+
padding: var(--qdr-spacing-2) 0;
|
|
189
|
+
width: 200px;
|
|
190
|
+
max-height: 240px;
|
|
191
|
+
box-shadow: var(--qdr-shadow-xl);
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
overflow-y: auto;
|
|
194
|
+
transition: opacity var(--qdr-duration-short) var(--qdr-easing-standard);
|
|
195
|
+
|
|
196
|
+
&--expanded {
|
|
197
|
+
pointer-events: auto;
|
|
198
|
+
opacity: 1;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
&--top {
|
|
202
|
+
bottom: var(--qdr-spacing-14);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&--bottom {
|
|
206
|
+
top: var(--qdr-spacing-14);
|
|
207
|
+
}
|
|
111
208
|
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
112
211
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
212
|
+
.qdr-inline-toolbar {
|
|
213
|
+
position: absolute;
|
|
214
|
+
top: var(--qdr-spacing-4);
|
|
215
|
+
right: var(--qdr-spacing-4);
|
|
216
|
+
display: flex;
|
|
217
|
+
align-items: center;
|
|
218
|
+
justify-content: flex-start;
|
|
219
|
+
gap: var(--qdr-spacing-3);
|
|
220
|
+
background-color: var(--qdr-bg);
|
|
221
|
+
padding: var(--qdr-spacing-3);
|
|
222
|
+
border: 1px solid var(--qdr-border);
|
|
223
|
+
border-radius: var(--qdr-radius-3);
|
|
224
|
+
pointer-events: none;
|
|
225
|
+
opacity: 0;
|
|
226
|
+
transition: opacity var(--qdr-duration-short) var(--qdr-easing-standard);
|
|
227
|
+
z-index: 1;
|
|
228
|
+
|
|
229
|
+
&__wrapper {
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
justify-content: flex-start;
|
|
233
|
+
gap: var(--qdr-spacing-1);
|
|
234
|
+
padding: var(--qdr-spacing-1);
|
|
235
|
+
background-color: var(--qdr-divider);
|
|
236
|
+
border-radius: var(--qdr-radius-1);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
&__divider {
|
|
240
|
+
width: 1px;
|
|
241
|
+
height: 16px;
|
|
242
|
+
background-color: var(--qdr-divider);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
&__icon {
|
|
246
|
+
color: var(--qdr-action-inactive);
|
|
247
|
+
border-radius: var(--qdr-radius-1);
|
|
248
|
+
transition:
|
|
249
|
+
color var(--qdr-duration-short) var(--qdr-easing-standard),
|
|
250
|
+
background-color var(--qdr-duration-short) var(--qdr-easing-standard);
|
|
251
|
+
cursor: pointer;
|
|
252
|
+
|
|
253
|
+
&:hover {
|
|
254
|
+
color: var(--qdr-primary-light);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
&--active {
|
|
258
|
+
color: var(--qdr-primary-light);
|
|
259
|
+
background-color: var(--qdr-block);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
&--disabled {
|
|
263
|
+
&:hover {
|
|
264
|
+
color: var(--qdr-action-inactive);
|
|
265
|
+
cursor: not-allowed;
|
|
266
|
+
}
|
|
119
267
|
}
|
|
120
268
|
}
|
|
121
269
|
}
|
package/utils/index.cjs.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var core = require('@quadrats/core');
|
|
4
|
+
var tslib = require('tslib');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
3
7
|
/**
|
|
4
8
|
* Compose all refs to single one.
|
|
5
9
|
* It's helpful if you want to use useRef in an forwardRef component.
|
|
@@ -31,4 +35,153 @@ function composeRefs(refs) {
|
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
function removePreviousElement({ event, editor, type, confirmModal, doConfirm, }) {
|
|
39
|
+
const { selection } = editor;
|
|
40
|
+
if (selection && core.Range.isCollapsed(selection)) {
|
|
41
|
+
const currentEntry = core.Editor.above(editor, {
|
|
42
|
+
match: (n) => core.Element.isElement(n),
|
|
43
|
+
});
|
|
44
|
+
if (currentEntry) {
|
|
45
|
+
const [, currentPath] = currentEntry;
|
|
46
|
+
if (core.Editor.isStart(editor, selection.anchor, currentPath)) {
|
|
47
|
+
// const previousEntry = Editor.previous(editor, {
|
|
48
|
+
// at: currentPath,
|
|
49
|
+
// match: (n) => Element.isElement(n) && (n as QuadratsElement).type === type,
|
|
50
|
+
// });
|
|
51
|
+
const prevPath = core.Path.previous(currentPath);
|
|
52
|
+
const prevNode = core.Node.get(editor, prevPath);
|
|
53
|
+
if (core.Element.isElement(prevNode) && prevNode.type === type) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
const remove = () => {
|
|
56
|
+
core.Transforms.removeNodes(editor, {
|
|
57
|
+
at: prevPath,
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
if (confirmModal) {
|
|
61
|
+
doConfirm(remove);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
remove();
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function readFileAsBase64(file) {
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
const reader = new FileReader();
|
|
76
|
+
reader.onload = () => {
|
|
77
|
+
if (typeof reader.result === 'string') {
|
|
78
|
+
resolve(reader.result);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
reader.onerror = () => reject(reader.error);
|
|
82
|
+
reader.readAsDataURL(file);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function upload(_a) {
|
|
86
|
+
return tslib.__awaiter(this, arguments, void 0, function* ({ file, getBody, getHeaders, getUrl, uploader, onProgress, }) {
|
|
87
|
+
const headers = yield (getHeaders === null || getHeaders === void 0 ? void 0 : getHeaders(file));
|
|
88
|
+
const xhr = uploader || new XMLHttpRequest();
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
let sent = false;
|
|
91
|
+
xhr.upload.onprogress = ({ loaded, total }) => onProgress((loaded * 100) / total);
|
|
92
|
+
xhr.onload = () => {
|
|
93
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
94
|
+
resolve(xhr.response);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
reject(new Error(`Upload failed with status ${xhr.status}: ${xhr.response}`));
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
xhr.open('POST', getUrl(file));
|
|
101
|
+
if (headers) {
|
|
102
|
+
for (const headerName in headers) {
|
|
103
|
+
xhr.setRequestHeader(headerName, headers[headerName]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!sent) {
|
|
107
|
+
sent = true;
|
|
108
|
+
xhr.send(getBody(file));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function mockUpload(base64, onProgress) {
|
|
114
|
+
return new Promise((resolve) => {
|
|
115
|
+
let progress = 0;
|
|
116
|
+
const interval = setInterval(() => {
|
|
117
|
+
progress += 10;
|
|
118
|
+
onProgress(progress);
|
|
119
|
+
if (progress >= 100) {
|
|
120
|
+
clearInterval(interval);
|
|
121
|
+
setTimeout(() => resolve(base64), 200);
|
|
122
|
+
}
|
|
123
|
+
}, 250);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function usePreviousValue(value) {
|
|
128
|
+
const ref = react.useRef(value);
|
|
129
|
+
react.useEffect(() => {
|
|
130
|
+
ref.current = value;
|
|
131
|
+
}, [value]);
|
|
132
|
+
return ref.current;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' &&
|
|
136
|
+
window.document &&
|
|
137
|
+
!!window.document.createElement
|
|
138
|
+
? react.useLayoutEffect
|
|
139
|
+
: react.useEffect;
|
|
140
|
+
|
|
141
|
+
function useDocumentEvents(factory, deps) {
|
|
142
|
+
useIsomorphicLayoutEffect(() => {
|
|
143
|
+
const handlers = factory();
|
|
144
|
+
if (!handlers) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const entries = Object.entries(handlers);
|
|
148
|
+
entries.forEach(([event, handler]) => {
|
|
149
|
+
document.addEventListener(event, handler);
|
|
150
|
+
});
|
|
151
|
+
return () => {
|
|
152
|
+
entries.forEach(([event, handler]) => {
|
|
153
|
+
document.removeEventListener(event, handler);
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
}, deps);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function useClickAway(factory, containerRef, deps) {
|
|
160
|
+
useDocumentEvents(() => {
|
|
161
|
+
const clickAwayHandler = factory();
|
|
162
|
+
if (!clickAwayHandler) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const handler = (event) => {
|
|
166
|
+
const target = event.target;
|
|
167
|
+
const container = containerRef.current;
|
|
168
|
+
if (!((container === null || container === void 0 ? void 0 : container.contains(target)) || !document.contains(target))) {
|
|
169
|
+
clickAwayHandler(event);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
click: handler,
|
|
174
|
+
touchend: handler,
|
|
175
|
+
};
|
|
176
|
+
}, deps);
|
|
177
|
+
}
|
|
178
|
+
|
|
34
179
|
exports.composeRefs = composeRefs;
|
|
180
|
+
exports.mockUpload = mockUpload;
|
|
181
|
+
exports.readFileAsBase64 = readFileAsBase64;
|
|
182
|
+
exports.removePreviousElement = removePreviousElement;
|
|
183
|
+
exports.upload = upload;
|
|
184
|
+
exports.useClickAway = useClickAway;
|
|
185
|
+
exports.useDocumentEvents = useDocumentEvents;
|
|
186
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
187
|
+
exports.usePreviousValue = usePreviousValue;
|
package/utils/index.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export { composeRefs } from './composeRefs';
|
|
2
|
+
export * from './removePreviousElement';
|
|
3
|
+
export * from './upload';
|
|
4
|
+
export * from './usePreviousValue';
|
|
5
|
+
export * from './useClickAway';
|
|
6
|
+
export * from './useDocumentEvents';
|
|
7
|
+
export * from './useIsomorphicLayoutEffect';
|
package/utils/index.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export { composeRefs } from './composeRefs.js';
|
|
2
|
+
export { removePreviousElement } from './removePreviousElement.js';
|
|
3
|
+
export { mockUpload, readFileAsBase64, upload } from './upload.js';
|
|
4
|
+
export { usePreviousValue } from './usePreviousValue.js';
|
|
5
|
+
export { useClickAway } from './useClickAway.js';
|
|
6
|
+
export { useDocumentEvents } from './useDocumentEvents.js';
|
|
7
|
+
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
2
|
+
import { QuadratsEditor, Editor } from '@quadrats/core';
|
|
3
|
+
export declare function removePreviousElement({ event, editor, type, confirmModal, doConfirm, }: {
|
|
4
|
+
event: KeyboardEvent<HTMLElement>;
|
|
5
|
+
editor: QuadratsEditor & Editor;
|
|
6
|
+
type: string;
|
|
7
|
+
confirmModal: boolean;
|
|
8
|
+
doConfirm: (remove: VoidFunction) => void;
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Range, Editor, Element, Path, Node, Transforms } from '@quadrats/core';
|
|
2
|
+
|
|
3
|
+
function removePreviousElement({ event, editor, type, confirmModal, doConfirm, }) {
|
|
4
|
+
const { selection } = editor;
|
|
5
|
+
if (selection && Range.isCollapsed(selection)) {
|
|
6
|
+
const currentEntry = Editor.above(editor, {
|
|
7
|
+
match: (n) => Element.isElement(n),
|
|
8
|
+
});
|
|
9
|
+
if (currentEntry) {
|
|
10
|
+
const [, currentPath] = currentEntry;
|
|
11
|
+
if (Editor.isStart(editor, selection.anchor, currentPath)) {
|
|
12
|
+
// const previousEntry = Editor.previous(editor, {
|
|
13
|
+
// at: currentPath,
|
|
14
|
+
// match: (n) => Element.isElement(n) && (n as QuadratsElement).type === type,
|
|
15
|
+
// });
|
|
16
|
+
const prevPath = Path.previous(currentPath);
|
|
17
|
+
const prevNode = Node.get(editor, prevPath);
|
|
18
|
+
if (Element.isElement(prevNode) && prevNode.type === type) {
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
const remove = () => {
|
|
21
|
+
Transforms.removeNodes(editor, {
|
|
22
|
+
at: prevPath,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
if (confirmModal) {
|
|
26
|
+
doConfirm(remove);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
remove();
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { removePreviousElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FileUploaderGetBody, FileUploaderGetHeaders, FileUploaderGetUrl, FileUploaderImplement } from '@quadrats/common/file-uploader';
|
|
2
|
+
export declare function readFileAsBase64(file: File): Promise<string>;
|
|
3
|
+
export declare function upload({ file, getBody, getHeaders, getUrl, uploader, onProgress, }: {
|
|
4
|
+
file: File;
|
|
5
|
+
getBody: FileUploaderGetBody;
|
|
6
|
+
getHeaders?: FileUploaderGetHeaders;
|
|
7
|
+
getUrl: FileUploaderGetUrl;
|
|
8
|
+
uploader?: FileUploaderImplement;
|
|
9
|
+
onProgress: (percent: number) => void;
|
|
10
|
+
}): Promise<string>;
|
|
11
|
+
export declare function mockUpload(base64: string, onProgress: (percent: number) => void): Promise<string>;
|
package/utils/upload.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
|
|
3
|
+
function readFileAsBase64(file) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const reader = new FileReader();
|
|
6
|
+
reader.onload = () => {
|
|
7
|
+
if (typeof reader.result === 'string') {
|
|
8
|
+
resolve(reader.result);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
reader.onerror = () => reject(reader.error);
|
|
12
|
+
reader.readAsDataURL(file);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function upload(_a) {
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* ({ file, getBody, getHeaders, getUrl, uploader, onProgress, }) {
|
|
17
|
+
const headers = yield (getHeaders === null || getHeaders === void 0 ? void 0 : getHeaders(file));
|
|
18
|
+
const xhr = uploader || new XMLHttpRequest();
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
let sent = false;
|
|
21
|
+
xhr.upload.onprogress = ({ loaded, total }) => onProgress((loaded * 100) / total);
|
|
22
|
+
xhr.onload = () => {
|
|
23
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
24
|
+
resolve(xhr.response);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
reject(new Error(`Upload failed with status ${xhr.status}: ${xhr.response}`));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
xhr.open('POST', getUrl(file));
|
|
31
|
+
if (headers) {
|
|
32
|
+
for (const headerName in headers) {
|
|
33
|
+
xhr.setRequestHeader(headerName, headers[headerName]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!sent) {
|
|
37
|
+
sent = true;
|
|
38
|
+
xhr.send(getBody(file));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function mockUpload(base64, onProgress) {
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
let progress = 0;
|
|
46
|
+
const interval = setInterval(() => {
|
|
47
|
+
progress += 10;
|
|
48
|
+
onProgress(progress);
|
|
49
|
+
if (progress >= 100) {
|
|
50
|
+
clearInterval(interval);
|
|
51
|
+
setTimeout(() => resolve(base64), 200);
|
|
52
|
+
}
|
|
53
|
+
}, 250);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { mockUpload, readFileAsBase64, upload };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RefObject, DependencyList } from 'react';
|
|
2
|
+
export type ClickAwayEvent = MouseEvent | TouchEvent | PointerEvent;
|
|
3
|
+
export type ClickAwayHandler = (event: ClickAwayEvent) => void;
|
|
4
|
+
export type ClickAwayHandlerFactory = () => ClickAwayHandler | undefined;
|
|
5
|
+
export declare function useClickAway(factory: ClickAwayHandlerFactory, containerRef: RefObject<HTMLElement | null>, deps?: DependencyList): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useDocumentEvents } from './useDocumentEvents.js';
|
|
2
|
+
|
|
3
|
+
function useClickAway(factory, containerRef, deps) {
|
|
4
|
+
useDocumentEvents(() => {
|
|
5
|
+
const clickAwayHandler = factory();
|
|
6
|
+
if (!clickAwayHandler) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const handler = (event) => {
|
|
10
|
+
const target = event.target;
|
|
11
|
+
const container = containerRef.current;
|
|
12
|
+
if (!((container === null || container === void 0 ? void 0 : container.contains(target)) || !document.contains(target))) {
|
|
13
|
+
clickAwayHandler(event);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
click: handler,
|
|
18
|
+
touchend: handler,
|
|
19
|
+
};
|
|
20
|
+
}, deps);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { useClickAway };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DependencyList } from 'react';
|
|
2
|
+
export type DocumentEventHandlersFactory = () => {
|
|
3
|
+
[event in keyof DocumentEventMap]?: (event: DocumentEventMap[event]) => void;
|
|
4
|
+
} | undefined;
|
|
5
|
+
export declare function useDocumentEvents(factory: DocumentEventHandlersFactory, deps?: DependencyList): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js';
|
|
2
|
+
|
|
3
|
+
function useDocumentEvents(factory, deps) {
|
|
4
|
+
useIsomorphicLayoutEffect(() => {
|
|
5
|
+
const handlers = factory();
|
|
6
|
+
if (!handlers) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const entries = Object.entries(handlers);
|
|
10
|
+
entries.forEach(([event, handler]) => {
|
|
11
|
+
document.addEventListener(event, handler);
|
|
12
|
+
});
|
|
13
|
+
return () => {
|
|
14
|
+
entries.forEach(([event, handler]) => {
|
|
15
|
+
document.removeEventListener(event, handler);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
}, deps);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { useDocumentEvents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function usePreviousValue<T>(value: T): T;
|