@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useQuadrats } from '@quadrats/react';
|
|
2
|
+
|
|
3
|
+
function useToggleParagraphTool(controller) {
|
|
4
|
+
const editor = useQuadrats();
|
|
5
|
+
return {
|
|
6
|
+
active: controller.isSelectionInParagraph(editor),
|
|
7
|
+
onClick: () => controller.setParagraphNodes(editor),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { useToggleParagraphTool };
|
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { useLocale } from '@quadrats/react';
|
|
3
3
|
|
|
4
4
|
function ReadMore(props) {
|
|
5
|
-
const { attributes
|
|
5
|
+
const { attributes } = props;
|
|
6
6
|
const { readMore } = useLocale().editor;
|
|
7
7
|
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-read-more", contentEditable: false }),
|
|
8
|
-
React.createElement("
|
|
9
|
-
|
|
8
|
+
React.createElement("div", { className: "qdr-read-more__container" },
|
|
9
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }),
|
|
10
|
+
React.createElement("span", { className: "qdr-read-more__container__description" }, readMore),
|
|
11
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }))));
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export { ReadMore as default };
|
package/read-more/index.cjs.js
CHANGED
|
@@ -5,11 +5,13 @@ var react = require('@quadrats/react');
|
|
|
5
5
|
var readMore = require('@quadrats/common/read-more');
|
|
6
6
|
|
|
7
7
|
function ReadMore(props) {
|
|
8
|
-
const { attributes
|
|
8
|
+
const { attributes } = props;
|
|
9
9
|
const { readMore } = react.useLocale().editor;
|
|
10
10
|
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-read-more", contentEditable: false }),
|
|
11
|
-
React.createElement("
|
|
12
|
-
|
|
11
|
+
React.createElement("div", { className: "qdr-read-more__container" },
|
|
12
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }),
|
|
13
|
+
React.createElement("span", { className: "qdr-read-more__container__description" }, readMore),
|
|
14
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }))));
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const defaultRenderReadMoreElement = (props) => React.createElement(ReadMore, Object.assign({}, props));
|
package/read-more/read-more.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.qdr-read-more{position:relative;margin:
|
|
1
|
+
.qdr-read-more{position:relative;margin:var(--qdr-spacing-14) 0;width:100%;color:var(--qdr-divider);text-align:center}.qdr-read-more__container{display:flex;align-items:center;justify-content:space-between}.qdr-read-more__container__description{color:var(--qdr-text-secondary);position:relative;z-index:1;padding:0 var(--qdr-spacing-7);font-size:var(--qdr-typography-article-body2-font-size);line-height:var(--qdr-typography-article-body2-line-height);letter-spacing:var(--qdr-typography-article-body2-letter-spacing);font-weight:var(--qdr-typography-article-body2-font-weight)}.qdr-read-more__container__line{flex:1;height:2px;background-image:repeating-linear-gradient(to right, var(--qdr-border), var(--qdr-border) 10px, transparent 10px, transparent 15px)}
|
package/read-more/read-more.scss
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
.qdr-read-more {
|
|
2
2
|
position: relative;
|
|
3
|
-
margin:
|
|
3
|
+
margin: var(--qdr-spacing-14) 0;
|
|
4
4
|
width: 100%;
|
|
5
5
|
color: var(--qdr-divider);
|
|
6
6
|
text-align: center;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
&__container {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
|
|
13
|
+
&__description {
|
|
14
|
+
color: var(--qdr-text-secondary);
|
|
15
|
+
position: relative;
|
|
16
|
+
z-index: 1;
|
|
17
|
+
padding: 0 var(--qdr-spacing-7);
|
|
18
|
+
font-size: var(--qdr-typography-article-body2-font-size);
|
|
19
|
+
line-height: var(--qdr-typography-article-body2-line-height);
|
|
20
|
+
letter-spacing: var(--qdr-typography-article-body2-letter-spacing);
|
|
21
|
+
font-weight: var(--qdr-typography-article-body2-font-weight);
|
|
22
|
+
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
&__line {
|
|
25
|
+
flex: 1;
|
|
26
|
+
height: 2px;
|
|
27
|
+
background-image: repeating-linear-gradient(
|
|
28
|
+
to right,
|
|
29
|
+
var(--qdr-border),
|
|
30
|
+
var(--qdr-border) 10px,
|
|
31
|
+
transparent 10px,
|
|
32
|
+
transparent 15px
|
|
33
|
+
);
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconDefinition } from '@quadrats/icons';
|
|
3
|
+
export interface InlineToolbarProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
leftIcons: {
|
|
6
|
+
icon: IconDefinition;
|
|
7
|
+
onClick: VoidFunction;
|
|
8
|
+
active: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
rightIcons: {
|
|
12
|
+
icon: IconDefinition;
|
|
13
|
+
onClick: VoidFunction;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
}
|
|
17
|
+
declare function InlineToolbar({ className, leftIcons, rightIcons }: InlineToolbarProps): React.JSX.Element;
|
|
18
|
+
export default InlineToolbar;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { Icon } from '@quadrats/react/components';
|
|
4
|
+
|
|
5
|
+
function InlineToolbar({ className, leftIcons, rightIcons }) {
|
|
6
|
+
return (React.createElement("div", { contentEditable: false, className: clsx('qdr-inline-toolbar', className) },
|
|
7
|
+
leftIcons.length > 0 && (React.createElement("div", { className: "qdr-inline-toolbar__wrapper" }, leftIcons.map((icon) => (React.createElement(Icon, { key: icon.icon.name, className: clsx('qdr-inline-toolbar__icon', {
|
|
8
|
+
'qdr-inline-toolbar__icon--active': icon.active,
|
|
9
|
+
'qdr-inline-toolbar__icon--disabled': icon.disabled,
|
|
10
|
+
}), icon: icon.icon, width: 24, height: 24, onClick: (e) => {
|
|
11
|
+
if (!icon.disabled) {
|
|
12
|
+
e.preventDefault();
|
|
13
|
+
icon.onClick();
|
|
14
|
+
}
|
|
15
|
+
} }))))),
|
|
16
|
+
leftIcons.length > 0 && rightIcons.length > 0 && React.createElement("div", { className: "qdr-inline-toolbar__divider" }),
|
|
17
|
+
rightIcons.map((icon) => (React.createElement(Icon, { key: icon.icon.name, className: clsx('qdr-inline-toolbar__icon', {
|
|
18
|
+
'qdr-inline-toolbar__icon--disabled': icon.disabled,
|
|
19
|
+
}), icon: icon.icon, width: 24, height: 24, onClick: (e) => {
|
|
20
|
+
if (!icon.disabled) {
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
icon.onClick();
|
|
23
|
+
}
|
|
24
|
+
} })))));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { InlineToolbar as default };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import React, { useContext, useRef, useState, useCallback, useLayoutEffect } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
3
|
import { Range, getSelectionText, Transforms, isNodesTypeIn } from '@quadrats/core';
|
|
4
|
+
import { More } from '@quadrats/icons';
|
|
4
5
|
import { ThemeContext, useQuadrats, ReactEditor } from '@quadrats/react';
|
|
5
6
|
import { Portal } from '@quadrats/react/components';
|
|
7
|
+
import ToolbarGroupIcon from './ToolbarGroupIcon.js';
|
|
8
|
+
import { ToolbarContext } from '../contexts/toolbar.js';
|
|
6
9
|
import { StartToolInputContext } from '../contexts/StartToolInputContext.js';
|
|
10
|
+
import { useAutoGroupIcons } from '../hooks/useAutoGroupIcons.js';
|
|
7
11
|
import ToolbarInput from './ToolbarInput.js';
|
|
8
12
|
|
|
9
13
|
function roundNumber(value, min, max) {
|
|
@@ -75,7 +79,7 @@ function Toolbar(props) {
|
|
|
75
79
|
}
|
|
76
80
|
const el = toolbarRef.current;
|
|
77
81
|
const range = lastNativeRangeRef.current;
|
|
78
|
-
if (shouldRender && el && range) {
|
|
82
|
+
if (shouldRender && el && range && !fixed) {
|
|
79
83
|
setPosition(el, range);
|
|
80
84
|
}
|
|
81
85
|
});
|
|
@@ -89,8 +93,11 @@ function Toolbar(props) {
|
|
|
89
93
|
}, [props.containerRef]);
|
|
90
94
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
91
95
|
const tools = children(renderExpandedStatus && !fixed);
|
|
96
|
+
const { fakeTools, takeCount, shownElements, groupElements } = useAutoGroupIcons(tools, renderExpandedStatus && !fixed);
|
|
92
97
|
const toolbarBody = (React.createElement(React.Fragment, null,
|
|
93
|
-
React.createElement(StartToolInputContext.Provider, { value: startToolInput },
|
|
98
|
+
React.createElement(StartToolInputContext.Provider, { value: startToolInput }, takeCount > 0 ? (React.createElement(React.Fragment, null,
|
|
99
|
+
shownElements,
|
|
100
|
+
React.createElement(ToolbarGroupIcon, { icon: More, withArrow: false }, groupElements))) : tools),
|
|
94
101
|
toolInput && (React.createElement(ToolbarInput, { exit: () => {
|
|
95
102
|
const { currentSelection } = toolInput;
|
|
96
103
|
if (currentSelection) {
|
|
@@ -100,8 +107,13 @@ function Toolbar(props) {
|
|
|
100
107
|
setToolInput(undefined);
|
|
101
108
|
}, toolInput: toolInput }))));
|
|
102
109
|
if (fixed) {
|
|
103
|
-
return (React.createElement(
|
|
104
|
-
|
|
110
|
+
return (React.createElement(ToolbarContext.Provider, { value: {
|
|
111
|
+
fixed: true,
|
|
112
|
+
toolbarRef: toolbarRef,
|
|
113
|
+
} },
|
|
114
|
+
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', 'qdr-toolbar__wrapper--fixed', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
115
|
+
React.createElement("div", { className: "qdr-toolbar" }, toolbarBody),
|
|
116
|
+
fakeTools)));
|
|
105
117
|
}
|
|
106
118
|
if (!shouldRender || (disabledElementTypes && isNodesTypeIn(editor, disabledElementTypes, { mode: 'all' }))) {
|
|
107
119
|
return null;
|
|
@@ -113,8 +125,13 @@ function Toolbar(props) {
|
|
|
113
125
|
return null;
|
|
114
126
|
}
|
|
115
127
|
return (React.createElement(Portal, { getContainer: getPortalContainer },
|
|
116
|
-
React.createElement(
|
|
117
|
-
|
|
128
|
+
React.createElement(ToolbarContext.Provider, { value: {
|
|
129
|
+
fixed: false,
|
|
130
|
+
toolbarRef: toolbarRef,
|
|
131
|
+
} },
|
|
132
|
+
React.createElement("div", { ref: toolbarRef, className: clsx('qdr-toolbar__wrapper', 'qdr-toolbar__wrapper--float', { 'qdr-toolbar__wrapper--inputting': toolInput }, themeProps.className), style: themeProps.style },
|
|
133
|
+
React.createElement("div", { className: "qdr-toolbar qdr-toolbar--radius qdr-toolbar--shadow" }, toolbarBody),
|
|
134
|
+
fakeTools))));
|
|
118
135
|
}
|
|
119
136
|
|
|
120
137
|
export { Toolbar as default };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconProps } from '@quadrats/react/components';
|
|
3
|
+
export interface ToolbarGroupIconProps extends Omit<IconProps, 'ref' | 'onClick' | 'onMouseDown'> {
|
|
4
|
+
withArrow?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function ToolbarGroupIcon(props: ToolbarGroupIconProps): React.JSX.Element;
|
|
7
|
+
export default ToolbarGroupIcon;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React, { useRef, useState, useLayoutEffect, useCallback } from 'react';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { ArrowDown } from '@quadrats/icons';
|
|
5
|
+
import { Icon } from '@quadrats/react/components';
|
|
6
|
+
import { useClickAway } from '@quadrats/react/utils';
|
|
7
|
+
import { useToolbar } from '../contexts/toolbar.js';
|
|
8
|
+
import { ToolbarMenuContext } from '../contexts/toolbarMenu.js';
|
|
9
|
+
|
|
10
|
+
function ToolbarGroupIcon(props) {
|
|
11
|
+
const { className, children, withArrow = true } = props, rest = __rest(props, ["className", "children", "withArrow"]);
|
|
12
|
+
const wrapperRef = useRef(null);
|
|
13
|
+
const iconRef = useRef(null);
|
|
14
|
+
const menuRef = useRef(null);
|
|
15
|
+
const { toolbarRef } = useToolbar();
|
|
16
|
+
const [placement, setPlacement] = useState('bottom');
|
|
17
|
+
const [menuExpanded, setMenuExpanded] = useState(false);
|
|
18
|
+
useClickAway(() => {
|
|
19
|
+
if (!menuExpanded) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
return () => {
|
|
23
|
+
setMenuExpanded(false);
|
|
24
|
+
};
|
|
25
|
+
}, wrapperRef, [menuExpanded, wrapperRef]);
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
function handler() {
|
|
28
|
+
const icon = iconRef.current;
|
|
29
|
+
const menu = menuRef.current;
|
|
30
|
+
const toolbar = toolbarRef === null || toolbarRef === void 0 ? void 0 : toolbarRef.current;
|
|
31
|
+
if (icon && menu) {
|
|
32
|
+
const rect = icon.getBoundingClientRect();
|
|
33
|
+
const toolbarRect = toolbar === null || toolbar === void 0 ? void 0 : toolbar.getBoundingClientRect();
|
|
34
|
+
const menuWidth = menu.clientWidth;
|
|
35
|
+
const menuHeight = menu.clientHeight;
|
|
36
|
+
if (rect.left + menuWidth > window.innerWidth) {
|
|
37
|
+
if (rect.left + (menuWidth + rect.width) / 2 > window.innerWidth) {
|
|
38
|
+
menu.style.right = '0';
|
|
39
|
+
menu.style.left = 'unset';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
menu.style.right = 'unset';
|
|
43
|
+
menu.style.left = `-${(menuWidth - rect.width) / 2}px`;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
menu.style.right = 'unset';
|
|
48
|
+
menu.style.left = '0';
|
|
49
|
+
}
|
|
50
|
+
if (toolbarRect && toolbarRect.top + toolbarRect.height + menuHeight > window.innerHeight) {
|
|
51
|
+
setPlacement('top');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setPlacement('bottom');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
handler();
|
|
59
|
+
window.addEventListener('resize', handler);
|
|
60
|
+
window.addEventListener('scroll', handler);
|
|
61
|
+
return () => {
|
|
62
|
+
window.removeEventListener('resize', handler);
|
|
63
|
+
window.removeEventListener('scroll', handler);
|
|
64
|
+
};
|
|
65
|
+
}, [toolbarRef]);
|
|
66
|
+
const onClick = useCallback(() => {
|
|
67
|
+
setMenuExpanded(expanded => !expanded);
|
|
68
|
+
}, []);
|
|
69
|
+
return (React.createElement(ToolbarMenuContext.Provider, { value: {
|
|
70
|
+
isInGroup: true,
|
|
71
|
+
menuExpanded,
|
|
72
|
+
} },
|
|
73
|
+
React.createElement("div", { ref: wrapperRef, className: "qdr-toolbar__icon__wrapper" },
|
|
74
|
+
React.createElement("div", { ref: iconRef, className: clsx('qdr-toolbar__icon', { 'qdr-toolbar__icon--expanded': menuExpanded }, className), onClick: onClick },
|
|
75
|
+
React.createElement(Icon, Object.assign({}, rest)),
|
|
76
|
+
withArrow && (React.createElement(Icon, { icon: ArrowDown, className: "qdr-toolbar__icon__arrow", width: 12, height: 12 }))),
|
|
77
|
+
React.createElement("div", { ref: menuRef, className: clsx('qdr-toolbar__icon__menu', { 'qdr-toolbar__icon__menu--expanded': menuExpanded }, { 'qdr-toolbar__icon__menu--top': placement === 'top' }, { 'qdr-toolbar__icon__menu--bottom': placement === 'bottom' }) }, children))));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { ToolbarGroupIcon as default };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconProps } from '@quadrats/react/components';
|
|
3
|
-
export interface ToolbarIconProps extends Omit<IconProps, 'ref'> {
|
|
3
|
+
export interface ToolbarIconProps extends Omit<IconProps, 'ref' | 'onClick' | 'onMouseDown'> {
|
|
4
4
|
active?: boolean;
|
|
5
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
6
|
+
onMouseDown?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
5
7
|
}
|
|
6
8
|
declare function ToolbarIcon(props: ToolbarIconProps): React.JSX.Element;
|
|
7
9
|
export default ToolbarIcon;
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
+
import { Check } from '@quadrats/icons';
|
|
4
5
|
import { Icon } from '@quadrats/react/components';
|
|
6
|
+
import { useLocale } from '@quadrats/react';
|
|
7
|
+
import { getIconNameInGroup } from './toolbarIconName.js';
|
|
8
|
+
import { useToolbarMenu } from '../contexts/toolbarMenu.js';
|
|
5
9
|
|
|
6
10
|
function ToolbarIcon(props) {
|
|
7
|
-
const { active, className, onMouseDown } = props, rest = __rest(props, ["active", "className", "onMouseDown"]);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const { active, className, icon, onClick: onClickProps, onMouseDown: onMouseDownProps } = props, rest = __rest(props, ["active", "className", "icon", "onClick", "onMouseDown"]);
|
|
12
|
+
const locale = useLocale();
|
|
13
|
+
const { isInGroup } = useToolbarMenu();
|
|
14
|
+
const onClick = useCallback((event) => {
|
|
15
|
+
onClickProps === null || onClickProps === void 0 ? void 0 : onClickProps(event);
|
|
16
|
+
}, [onClickProps]);
|
|
17
|
+
const onMouseDown = useCallback((event) => {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
onMouseDownProps === null || onMouseDownProps === void 0 ? void 0 : onMouseDownProps(event);
|
|
20
|
+
}, [onMouseDownProps]);
|
|
21
|
+
if (isInGroup) {
|
|
22
|
+
return (React.createElement("div", { className: clsx('qdr-toolbar__icon', 'qdr-toolbar__icon--with-name', { 'qdr-toolbar__icon--with-name--active': active }, className), onClick: onClick, onMouseDown: onMouseDown },
|
|
23
|
+
React.createElement(Icon, Object.assign({}, rest, { icon: icon, width: 20, height: 20 })),
|
|
24
|
+
React.createElement("p", { className: "qdr-toolbar__icon__name" }, getIconNameInGroup(icon.name, locale)),
|
|
25
|
+
active && (React.createElement(Icon, { className: "qdr-toolbar__icon__check", icon: Check, width: 20, height: 20 }))));
|
|
26
|
+
}
|
|
27
|
+
return (React.createElement("div", { className: "qdr-toolbar__icon__wrapper" },
|
|
28
|
+
React.createElement("div", { className: clsx('qdr-toolbar__icon', { 'qdr-toolbar__icon--active': active }, className), onClick: onClick, onMouseDown: onMouseDown },
|
|
29
|
+
React.createElement(Icon, Object.assign({}, rest, { icon: icon })))));
|
|
12
30
|
}
|
|
13
31
|
|
|
14
32
|
export { ToolbarIcon as default };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function getIconNameInGroup(iconOriginName, locale) {
|
|
2
|
+
switch (iconOriginName) {
|
|
3
|
+
case 'accordion':
|
|
4
|
+
return locale.editor.toolbar.accordion;
|
|
5
|
+
case 'align-center':
|
|
6
|
+
return locale.editor.toolbar.alignCenter;
|
|
7
|
+
case 'align-left':
|
|
8
|
+
return locale.editor.toolbar.alignLeft;
|
|
9
|
+
case 'align-right':
|
|
10
|
+
return locale.editor.toolbar.alignRight;
|
|
11
|
+
case 'blockquote':
|
|
12
|
+
return locale.editor.toolbar.quote;
|
|
13
|
+
case 'bold':
|
|
14
|
+
return locale.editor.toolbar.bold;
|
|
15
|
+
case 'card':
|
|
16
|
+
return locale.editor.toolbar.card;
|
|
17
|
+
case 'carousel':
|
|
18
|
+
return locale.editor.toolbar.carousel;
|
|
19
|
+
case 'dance':
|
|
20
|
+
return locale.editor.toolbar.dance;
|
|
21
|
+
case 'divider':
|
|
22
|
+
return locale.editor.toolbar.divider;
|
|
23
|
+
case 'drama':
|
|
24
|
+
return locale.editor.toolbar.drama;
|
|
25
|
+
case 'erase':
|
|
26
|
+
return locale.editor.toolbar.erase;
|
|
27
|
+
case 'facebook':
|
|
28
|
+
return locale.editor.toolbar.facebook;
|
|
29
|
+
case 'fn':
|
|
30
|
+
return locale.editor.toolbar.footnote;
|
|
31
|
+
case 'heading1':
|
|
32
|
+
return locale.editor.toolbar.heading1;
|
|
33
|
+
case 'heading2':
|
|
34
|
+
return locale.editor.toolbar.heading2;
|
|
35
|
+
case 'heading3':
|
|
36
|
+
return locale.editor.toolbar.heading3;
|
|
37
|
+
case 'heading4':
|
|
38
|
+
return locale.editor.toolbar.heading4;
|
|
39
|
+
case 'heading5':
|
|
40
|
+
return locale.editor.toolbar.heading5;
|
|
41
|
+
case 'heading6':
|
|
42
|
+
return locale.editor.toolbar.heading6;
|
|
43
|
+
case 'highlight':
|
|
44
|
+
return locale.editor.toolbar.highlight;
|
|
45
|
+
case 'image':
|
|
46
|
+
return locale.editor.toolbar.image;
|
|
47
|
+
case 'instagram':
|
|
48
|
+
return locale.editor.toolbar.instagram;
|
|
49
|
+
case 'italic':
|
|
50
|
+
return locale.editor.toolbar.italic;
|
|
51
|
+
case 'link':
|
|
52
|
+
return locale.editor.toolbar.link;
|
|
53
|
+
case 'ordered list':
|
|
54
|
+
return locale.editor.toolbar.orderedList;
|
|
55
|
+
case 'paragraph':
|
|
56
|
+
return locale.editor.toolbar.paragraph;
|
|
57
|
+
case 'podcast-apple':
|
|
58
|
+
return locale.editor.toolbar.podcastApple;
|
|
59
|
+
case 'read-more':
|
|
60
|
+
return locale.editor.toolbar.readMore;
|
|
61
|
+
case 'sheet-music':
|
|
62
|
+
return locale.editor.toolbar.sheetMusic;
|
|
63
|
+
case 'spotify':
|
|
64
|
+
return locale.editor.toolbar.spotify;
|
|
65
|
+
case 'strikethrough':
|
|
66
|
+
return locale.editor.toolbar.strikethrough;
|
|
67
|
+
case 'twitter':
|
|
68
|
+
return locale.editor.toolbar.twitter;
|
|
69
|
+
case 'underline':
|
|
70
|
+
return locale.editor.toolbar.underline;
|
|
71
|
+
case 'unlink':
|
|
72
|
+
return locale.editor.toolbar.unlink;
|
|
73
|
+
case 'unordered list':
|
|
74
|
+
return locale.editor.toolbar.unorderedList;
|
|
75
|
+
case 'video':
|
|
76
|
+
return locale.editor.toolbar.video;
|
|
77
|
+
case 'vimeo':
|
|
78
|
+
return locale.editor.toolbar.vimeo;
|
|
79
|
+
case 'youtube':
|
|
80
|
+
return locale.editor.toolbar.youtube;
|
|
81
|
+
default:
|
|
82
|
+
return '';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { getIconNameInGroup };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface ToolbarContextValue {
|
|
3
|
+
fixed: boolean;
|
|
4
|
+
toolbarRef?: RefObject<HTMLDivElement | null>;
|
|
5
|
+
}
|
|
6
|
+
export declare const ToolbarContext: import("react").Context<ToolbarContextValue>;
|
|
7
|
+
export declare function useToolbar(): ToolbarContextValue;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const ToolbarMenuContext = createContext({
|
|
4
|
+
isInGroup: false,
|
|
5
|
+
menuExpanded: false,
|
|
6
|
+
});
|
|
7
|
+
function useToolbarMenu() {
|
|
8
|
+
return useContext(ToolbarMenuContext);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { ToolbarMenuContext, useToolbarMenu };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function useAutoGroupIcons(tools: JSX.Element | null | undefined, renderExpandedStatus: boolean): {
|
|
3
|
+
fakeTools: React.JSX.Element;
|
|
4
|
+
takeCount: number;
|
|
5
|
+
shownElements: {
|
|
6
|
+
id: number;
|
|
7
|
+
type: string | React.JSXElementConstructor<any>;
|
|
8
|
+
props: unknown;
|
|
9
|
+
key: string | null;
|
|
10
|
+
}[];
|
|
11
|
+
groupElements: any;
|
|
12
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useMemo, useState, useCallback, useLayoutEffect, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
function usePreviousValue(value) {
|
|
4
|
+
const ref = useRef(value);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
ref.current = value;
|
|
7
|
+
}, [value]);
|
|
8
|
+
return ref.current;
|
|
9
|
+
}
|
|
10
|
+
function useAutoGroupIcons(tools, renderExpandedStatus) {
|
|
11
|
+
const preRenderExpandedStatus = usePreviousValue(renderExpandedStatus);
|
|
12
|
+
const fakeToolbarId = useMemo(() => (renderExpandedStatus ? 'fake-expanded-tools-wrapper' : 'fake-tools-wrapper'), [renderExpandedStatus]);
|
|
13
|
+
const fakeTools = useMemo(() => (React.createElement("div", { id: fakeToolbarId, className: "qdr-toolbar", style: { position: 'absolute', top: 0, left: 0, visibility: 'hidden', pointerEvents: 'none' } }, tools)), [fakeToolbarId, tools]);
|
|
14
|
+
const [takeCount, setTakeCount] = useState(0);
|
|
15
|
+
const toolsElements = useMemo(() => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
return (_b = (_a = tools === null || tools === void 0 ? void 0 : tools.props.children) === null || _a === void 0 ? void 0 : _a.filter(c => !!c).map((c, index) => (Object.assign(Object.assign({}, c), { id: index })))) !== null && _b !== void 0 ? _b : [];
|
|
18
|
+
}, [tools]);
|
|
19
|
+
const calcGroupIcons = useCallback(() => {
|
|
20
|
+
const fakeToolsWrapper = document.getElementById(fakeToolbarId);
|
|
21
|
+
if (fakeToolsWrapper) {
|
|
22
|
+
const toolbarRect = fakeToolsWrapper.getBoundingClientRect();
|
|
23
|
+
if (toolbarRect.right - window.innerWidth > 0) {
|
|
24
|
+
const iconWrappers = fakeToolsWrapper.getElementsByClassName('qdr-toolbar__icon__wrapper');
|
|
25
|
+
const targetIndex = Array.from(iconWrappers).findIndex((wrapper) => {
|
|
26
|
+
const rect = wrapper.getBoundingClientRect();
|
|
27
|
+
return rect.right > window.innerWidth;
|
|
28
|
+
});
|
|
29
|
+
const groupIcons = Array.from(iconWrappers).slice(targetIndex - 1, iconWrappers.length);
|
|
30
|
+
setTakeCount(groupIcons.length);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
setTakeCount(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}, [fakeToolbarId]);
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
calcGroupIcons();
|
|
39
|
+
window.addEventListener('resize', calcGroupIcons);
|
|
40
|
+
return () => {
|
|
41
|
+
window.removeEventListener('resize', calcGroupIcons);
|
|
42
|
+
};
|
|
43
|
+
}, [calcGroupIcons]);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (renderExpandedStatus !== preRenderExpandedStatus) {
|
|
46
|
+
calcGroupIcons();
|
|
47
|
+
}
|
|
48
|
+
}, [renderExpandedStatus, preRenderExpandedStatus, calcGroupIcons]);
|
|
49
|
+
const takeIndex = useMemo(() => toolsElements.findIndex(el => el.id === toolsElements.filter(e => e.type !== 'span').slice(-takeCount)[0].id), [toolsElements, takeCount]);
|
|
50
|
+
const shownElements = useMemo(() => toolsElements.slice(0, takeIndex), [toolsElements, takeIndex]);
|
|
51
|
+
const groupElements = useMemo(() => toolsElements.slice(takeIndex).filter(g => g.type !== 'span').map((g) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if (((_b = (_a = g.props) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
54
|
+
return g.props.children;
|
|
55
|
+
}
|
|
56
|
+
return g;
|
|
57
|
+
}).reduce((acc, val) => {
|
|
58
|
+
return acc.concat(val);
|
|
59
|
+
}, []), [toolsElements, takeIndex]);
|
|
60
|
+
return {
|
|
61
|
+
fakeTools,
|
|
62
|
+
takeCount,
|
|
63
|
+
shownElements,
|
|
64
|
+
groupElements,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { useAutoGroupIcons };
|