@quadrats/react 1.1.8 → 1.1.9
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/LICENSE +21 -0
- package/_internal/index.cjs.js +59 -0
- package/_internal/index.js +5 -0
- package/_internal/package.json +4 -1
- package/_internal/renderer/composeRenderElementsBase.d.ts +3 -0
- package/_internal/renderer/composeRenderElementsBase.js +13 -0
- package/_internal/renderer/composeRenderLeafsBase.d.ts +3 -0
- package/_internal/renderer/composeRenderLeafsBase.js +11 -0
- package/_internal/renderer/createRenderElementBase.d.ts +3 -0
- package/_internal/renderer/createRenderElementBase.js +9 -0
- package/_internal/renderer/createRenderElementsBase.d.ts +3 -0
- package/_internal/renderer/createRenderElementsBase.js +11 -0
- package/_internal/renderer/createRenderMarkBase.d.ts +3 -0
- package/_internal/renderer/createRenderMarkBase.js +13 -0
- package/_internal/renderer/typings.d.ts +19 -0
- package/accordion/accordion.css +1 -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.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.js +2 -0
- package/accordion/jsx-serializer/package.json +3 -6
- package/accordion/jsx-serializer/typings.d.ts +4 -0
- package/accordion/package.json +3 -8
- 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 +3 -6
- 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.js +2 -0
- package/align/package.json +3 -5
- 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 +3 -7
- 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/constants.d.ts +6 -0
- package/blockquote/constants.js +8 -0
- package/blockquote/createReactBlockquote.d.ts +5 -0
- package/blockquote/createReactBlockquote.js +84 -0
- package/blockquote/defaultRenderBlockquoteElement.d.ts +6 -0
- package/blockquote/defaultRenderBlockquoteElement.js +7 -0
- package/blockquote/index.cjs.js +98 -0
- package/blockquote/index.js +3 -0
- package/blockquote/jsx-serializer/createJsxSerializeBlockquote.d.ts +4 -0
- package/blockquote/jsx-serializer/createJsxSerializeBlockquote.js +10 -0
- package/blockquote/jsx-serializer/index.cjs.js +13 -0
- package/blockquote/jsx-serializer/index.js +2 -0
- package/blockquote/jsx-serializer/package.json +3 -6
- package/blockquote/jsx-serializer/typings.d.ts +3 -0
- package/blockquote/package.json +3 -9
- package/blockquote/toolbar/BlockquoteToolbarIcon.d.ts +8 -0
- package/blockquote/toolbar/BlockquoteToolbarIcon.js +12 -0
- package/blockquote/toolbar/index.cjs.js +23 -0
- package/blockquote/toolbar/index.js +2 -0
- package/blockquote/toolbar/package.json +3 -6
- package/blockquote/toolbar/useBlockquoteTool.d.ts +5 -0
- package/blockquote/toolbar/useBlockquoteTool.js +11 -0
- package/blockquote/typings.d.ts +16 -0
- package/bold/constants.d.ts +6 -0
- package/bold/constants.js +8 -0
- package/bold/createReactBold.d.ts +1 -0
- package/bold/createReactBold.js +11 -0
- package/bold/defaultRenderBold.d.ts +3 -0
- package/bold/defaultRenderBold.js +7 -0
- package/bold/index.cjs.js +24 -0
- package/bold/index.js +3 -0
- package/bold/jsx-serializer/createJsxSerializeBold.d.ts +1 -0
- package/bold/jsx-serializer/createJsxSerializeBold.js +10 -0
- package/bold/jsx-serializer/index.cjs.js +13 -0
- package/bold/jsx-serializer/index.js +2 -0
- package/bold/jsx-serializer/package.json +3 -6
- package/bold/package.json +3 -5
- package/bold/typings.d.ts +5 -0
- package/card/card.css +1 -0
- package/card/components/Card.d.ts +15 -0
- package/card/components/Card.js +109 -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 +242 -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.js +2 -0
- package/card/jsx-serializer/package.json +3 -6
- package/card/jsx-serializer/typings.d.ts +9 -0
- package/card/package.json +3 -11
- package/card/toolbar/CardToolbarIcon.d.ts +8 -0
- package/card/toolbar/CardToolbarIcon.js +12 -0
- package/card/toolbar/index.cjs.js +52 -0
- package/card/toolbar/index.js +2 -0
- package/card/toolbar/package.json +3 -6
- package/card/toolbar/useCardTool.d.ts +4 -0
- package/card/toolbar/useCardTool.js +41 -0
- package/card/typings.d.ts +24 -0
- package/carousel/carousel.css +1 -0
- package/carousel/components/Carousel.d.ts +15 -0
- package/carousel/components/Carousel.js +66 -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 +236 -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.js +2 -0
- package/carousel/jsx-serializer/package.json +3 -6
- package/carousel/jsx-serializer/typings.d.ts +9 -0
- package/carousel/package.json +3 -10
- package/carousel/toolbar/CarouselToolbarIcon.d.ts +8 -0
- package/carousel/toolbar/CarouselToolbarIcon.js +12 -0
- package/carousel/toolbar/index.cjs.js +43 -0
- package/carousel/toolbar/index.js +2 -0
- package/carousel/toolbar/package.json +3 -6
- package/carousel/toolbar/useCarouselTool.d.ts +4 -0
- package/carousel/toolbar/useCarouselTool.js +32 -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/Icon/index.d.ts +15 -0
- package/components/Icon/index.js +21 -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/Portal/index.d.ts +7 -0
- package/components/Portal/index.js +8 -0
- package/components/Progress/index.d.ts +7 -0
- package/components/Progress/index.js +20 -0
- 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/Tooltip/calculatePosition.d.ts +5 -0
- package/components/Tooltip/calculatePosition.js +69 -0
- package/components/Tooltip/index.d.ts +10 -0
- package/components/Tooltip/index.js +124 -0
- package/components/Tooltip/typings.d.ts +29 -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/button.css +1 -0
- package/components/components.css +1 -0
- package/components/hint.css +1 -0
- package/components/imageUploader.css +1 -0
- package/components/index.cjs.js +867 -0
- package/components/index.d.ts +16 -0
- package/components/index.js +15 -0
- package/components/input.css +1 -0
- package/components/message.css +1 -0
- package/components/modal.css +1 -0
- package/components/package.json +3 -21
- package/components/progress.css +1 -0
- package/components/segmentedControl.css +1 -0
- package/components/textarea.css +1 -0
- package/components/toggle.css +1 -0
- package/components/tooltip.css +1 -0
- package/configs/ConfigsProvider.d.ts +18 -0
- package/configs/ConfigsProvider.js +15 -0
- package/configs/index.cjs.js +58 -0
- package/configs/index.js +3 -0
- package/configs/locale.d.ts +3 -0
- package/configs/locale.js +9 -0
- package/configs/package.json +4 -1
- package/configs/theme.d.ts +18 -0
- package/configs/theme.js +34 -0
- package/core/components/DefaultElement.d.ts +4 -0
- package/core/components/DefaultElement.js +5 -0
- package/core/components/DefaultLeaf.d.ts +4 -0
- package/core/components/DefaultLeaf.js +5 -0
- package/core/components/Editable.d.ts +9 -0
- package/core/components/Editable.js +71 -0
- package/core/components/Quadrats.d.ts +16 -0
- package/core/components/Quadrats.js +21 -0
- package/core/composeHandlers.d.ts +8 -0
- package/core/composeHandlers.js +33 -0
- package/core/composeRenderElements.d.ts +6 -0
- package/core/composeRenderElements.js +12 -0
- package/core/composeRenderLeafs.d.ts +6 -0
- package/core/composeRenderLeafs.js +12 -0
- 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 +111 -0
- package/core/contexts/modal/CarouselModal/CarouselItem.d.ts +15 -0
- package/core/contexts/modal/CarouselModal/CarouselItem.js +46 -0
- package/core/contexts/modal/CarouselModal/CarouselModal.d.ts +11 -0
- package/core/contexts/modal/CarouselModal/CarouselModal.js +169 -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 +24 -0
- package/core/contexts/modal/EmbedModal/EmbedModal.d.ts +11 -0
- package/core/contexts/modal/EmbedModal/EmbedModal.js +27 -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/createReactEditor.d.ts +2 -0
- package/core/createReactEditor.js +8 -0
- package/core/createRenderElement.d.ts +2 -0
- package/core/createRenderElement.js +7 -0
- package/core/createRenderElements.d.ts +2 -0
- package/core/createRenderElements.js +7 -0
- package/core/createRenderMark.d.ts +2 -0
- package/core/createRenderMark.js +7 -0
- package/core/index.d.ts +37 -0
- package/core/typings/descendant.d.ts +2 -0
- package/core/typings/handler.d.ts +15 -0
- package/core/typings/renderer.d.ts +15 -0
- package/core/typings/with.d.ts +4 -0
- package/divider/createReactDivider.d.ts +4 -0
- package/divider/createReactDivider.js +11 -0
- package/divider/defaultRenderDividerElement.d.ts +3 -0
- package/divider/defaultRenderDividerElement.js +6 -0
- package/divider/divider.css +1 -0
- package/divider/index.cjs.js +17 -0
- package/divider/index.js +2 -0
- package/divider/jsx-serializer/createJsxSerializeDivider.d.ts +4 -0
- package/divider/jsx-serializer/createJsxSerializeDivider.js +10 -0
- package/divider/jsx-serializer/defaultRenderDividerElement.d.ts +2 -0
- package/divider/jsx-serializer/defaultRenderDividerElement.js +6 -0
- package/divider/jsx-serializer/index.cjs.js +16 -0
- package/divider/jsx-serializer/index.js +2 -0
- package/divider/jsx-serializer/package.json +3 -6
- package/divider/jsx-serializer/typings.d.ts +3 -0
- package/divider/package.json +3 -8
- package/divider/toolbar/DividerToolbarIcon.d.ts +8 -0
- package/divider/toolbar/DividerToolbarIcon.js +12 -0
- package/divider/toolbar/index.cjs.js +22 -0
- package/divider/toolbar/index.d.ts +2 -0
- package/divider/toolbar/index.js +2 -0
- package/divider/toolbar/package.json +3 -6
- package/divider/toolbar/useDividerTool.d.ts +4 -0
- package/divider/toolbar/useDividerTool.js +10 -0
- package/divider/typings.d.ts +10 -0
- package/editable.css +1 -0
- package/embed/components/VideoIframe.d.ts +12 -0
- package/embed/components/VideoIframe.js +16 -0
- package/embed/createReactEmbed.d.ts +4 -0
- package/embed/createReactEmbed.js +17 -0
- package/embed/createRenderEmbedElementBase.d.ts +10 -0
- package/embed/createRenderEmbedElementBase.js +16 -0
- package/embed/embed.css +1 -0
- package/embed/hooks/useVideoIframeSize.d.ts +7 -0
- package/embed/hooks/useVideoIframeSize.js +24 -0
- package/embed/index.cjs.js +68 -0
- package/embed/index.js +4 -0
- package/embed/jsx-serializer/createJsxSerializeEmbed.d.ts +9 -0
- package/embed/jsx-serializer/createJsxSerializeEmbed.js +13 -0
- package/embed/jsx-serializer/facebook/index.cjs.js +16 -0
- package/embed/jsx-serializer/facebook/index.js +1 -0
- package/embed/jsx-serializer/facebook/package.json +3 -6
- package/embed/jsx-serializer/index.cjs.js +15 -0
- package/embed/jsx-serializer/index.js +1 -0
- package/embed/jsx-serializer/instagram/index.cjs.js +16 -0
- package/embed/jsx-serializer/instagram/index.js +1 -0
- package/embed/jsx-serializer/instagram/package.json +3 -6
- package/embed/jsx-serializer/package.json +3 -6
- package/embed/jsx-serializer/twitter/index.cjs.js +16 -0
- package/embed/jsx-serializer/twitter/index.js +1 -0
- package/embed/jsx-serializer/twitter/package.json +3 -6
- package/embed/jsx-serializer/typings.d.ts +5 -0
- package/embed/jsx-serializer/vimeo/index.cjs.js +16 -0
- package/embed/jsx-serializer/vimeo/index.js +1 -0
- package/embed/jsx-serializer/vimeo/package.json +3 -6
- package/embed/jsx-serializer/youtube/index.cjs.js +7 -0
- package/embed/jsx-serializer/youtube/index.js +1 -0
- package/embed/jsx-serializer/youtube/package.json +3 -6
- package/embed/package.json +3 -8
- package/embed/renderers/base/components/BaseEmbedElement.d.ts +21 -0
- package/embed/renderers/base/components/BaseEmbedElement.js +70 -0
- package/embed/renderers/base/index.cjs.js +73 -0
- package/embed/renderers/base/index.d.ts +1 -0
- package/embed/renderers/base/index.js +1 -0
- package/embed/renderers/base/package.json +3 -6
- package/embed/renderers/facebook/components/Facebook.d.ts +12 -0
- package/embed/renderers/facebook/components/Facebook.js +23 -0
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.d.ts +5 -0
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.js +46 -0
- package/embed/renderers/facebook/index.cjs.js +70 -0
- package/embed/renderers/facebook/index.js +2 -0
- package/embed/renderers/facebook/package.json +3 -6
- package/embed/renderers/instagram/components/Instagram.d.ts +12 -0
- package/embed/renderers/instagram/components/Instagram.js +53 -0
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.d.ts +5 -0
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.js +46 -0
- package/embed/renderers/instagram/hooks/useLoadInstagramEmbedApi.d.ts +1 -0
- package/embed/renderers/instagram/hooks/useLoadInstagramEmbedApi.js +27 -0
- package/embed/renderers/instagram/index.cjs.js +124 -0
- package/embed/renderers/instagram/index.js +3 -0
- package/embed/renderers/instagram/package.json +3 -6
- package/embed/renderers/podcast-apple/components/PodcastApple.d.ts +11 -0
- package/embed/renderers/podcast-apple/components/PodcastApple.js +13 -0
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.d.ts +5 -0
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.js +39 -0
- package/embed/renderers/podcast-apple/index.cjs.js +53 -0
- package/embed/renderers/podcast-apple/index.js +2 -0
- package/embed/renderers/podcast-apple/package.json +3 -6
- package/embed/renderers/spotify/components/Spotify.d.ts +12 -0
- package/embed/renderers/spotify/components/Spotify.js +18 -0
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.d.ts +5 -0
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.js +36 -0
- package/embed/renderers/spotify/index.cjs.js +55 -0
- package/embed/renderers/spotify/index.js +2 -0
- package/embed/renderers/spotify/package.json +3 -6
- package/embed/renderers/twitter/components/Twitter.d.ts +12 -0
- package/embed/renderers/twitter/components/Twitter.js +24 -0
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.d.ts +5 -0
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.js +46 -0
- package/embed/renderers/twitter/hooks/useLoadTwitterEmbedApi.d.ts +2 -0
- package/embed/renderers/twitter/hooks/useLoadTwitterEmbedApi.js +33 -0
- package/embed/renderers/twitter/index.cjs.js +101 -0
- package/embed/renderers/twitter/index.js +3 -0
- package/embed/renderers/twitter/package.json +3 -6
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.d.ts +6 -0
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.js +30 -0
- package/embed/renderers/vimeo/index.cjs.js +34 -0
- package/embed/renderers/vimeo/index.js +1 -0
- package/embed/renderers/vimeo/package.json +3 -6
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.d.ts +6 -0
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.js +30 -0
- package/embed/renderers/youtube/index.cjs.js +34 -0
- package/embed/renderers/youtube/index.js +1 -0
- package/embed/renderers/youtube/package.json +3 -6
- package/embed/toolbar/EmbedToolbarIcon.d.ts +12 -0
- package/embed/toolbar/EmbedToolbarIcon.js +12 -0
- package/embed/toolbar/index.cjs.js +98 -0
- package/embed/toolbar/index.d.ts +2 -0
- package/embed/toolbar/index.js +2 -0
- package/embed/toolbar/package.json +3 -6
- package/embed/toolbar/useEmbedTool.d.ts +4 -0
- package/embed/toolbar/useEmbedTool.js +87 -0
- package/embed/typings.d.ts +15 -0
- package/file-uploader/components/FileUploader.d.ts +4 -0
- package/file-uploader/components/FileUploader.js +13 -0
- package/file-uploader/createReactFileUploader.d.ts +5 -0
- package/file-uploader/createReactFileUploader.js +17 -0
- package/file-uploader/defaultRenderFileUploaderElement.d.ts +2 -0
- package/file-uploader/defaultRenderFileUploaderElement.js +6 -0
- package/file-uploader/file-uploader.css +1 -0
- package/file-uploader/hooks/useFileUploader.d.ts +4 -0
- package/file-uploader/hooks/useFileUploader.js +13 -0
- package/file-uploader/index.cjs.js +42 -0
- package/file-uploader/index.js +4 -0
- package/file-uploader/package.json +3 -9
- package/file-uploader/toolbar/FileUploaderToolbarIcon.d.ts +10 -0
- package/file-uploader/toolbar/FileUploaderToolbarIcon.js +12 -0
- package/file-uploader/toolbar/index.cjs.js +25 -0
- package/file-uploader/toolbar/index.d.ts +2 -0
- package/file-uploader/toolbar/index.js +2 -0
- package/file-uploader/toolbar/package.json +3 -6
- package/file-uploader/toolbar/useFileUploaderTool.d.ts +5 -0
- package/file-uploader/toolbar/useFileUploaderTool.js +13 -0
- package/file-uploader/typings.d.ts +14 -0
- package/footnote/createReactFootnote.d.ts +4 -0
- package/footnote/createReactFootnote.js +13 -0
- package/footnote/defaultRenderFootnoteElement.d.ts +9 -0
- package/footnote/defaultRenderFootnoteElement.js +15 -0
- package/footnote/index.cjs.js +71 -0
- package/footnote/index.js +4 -0
- package/footnote/jsx-serializer/createJsxSerializeFootnote.d.ts +4 -0
- package/footnote/jsx-serializer/createJsxSerializeFootnote.js +11 -0
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.d.ts +5 -0
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.js +12 -0
- package/footnote/jsx-serializer/index.cjs.js +23 -0
- package/footnote/jsx-serializer/index.js +2 -0
- package/footnote/jsx-serializer/package.json +3 -6
- package/footnote/jsx-serializer/typings.d.ts +3 -0
- package/footnote/package.json +3 -5
- package/footnote/toolbar/FootnoteToolbarIcon.d.ts +10 -0
- package/footnote/toolbar/FootnoteToolbarIcon.js +12 -0
- package/footnote/toolbar/index.cjs.js +30 -0
- package/footnote/toolbar/index.d.ts +2 -0
- package/footnote/toolbar/index.js +2 -0
- package/footnote/toolbar/package.json +3 -6
- package/footnote/toolbar/useFootnoteTool.d.ts +7 -0
- package/footnote/toolbar/useFootnoteTool.js +19 -0
- package/footnote/typings.d.ts +9 -0
- package/footnote/useFootnotes.d.ts +4 -0
- package/footnote/useFootnotes.js +21 -0
- package/footnote/useFootnotesFromNodes.d.ts +4 -0
- package/footnote/useFootnotesFromNodes.js +27 -0
- package/heading/constants.d.ts +9 -0
- package/heading/constants.js +11 -0
- package/heading/createReactHeading.d.ts +4 -0
- package/heading/createReactHeading.js +47 -0
- package/heading/defaultRenderHeadingElement.d.ts +16 -0
- package/heading/defaultRenderHeadingElement.js +20 -0
- package/heading/heading.css +1 -0
- package/heading/index.cjs.js +77 -0
- package/heading/index.js +3 -0
- package/heading/jsx-serializer/createJsxSerializeHeading.d.ts +4 -0
- package/heading/jsx-serializer/createJsxSerializeHeading.js +10 -0
- package/heading/jsx-serializer/index.cjs.js +13 -0
- package/heading/jsx-serializer/index.js +2 -0
- package/heading/jsx-serializer/package.json +3 -6
- package/heading/jsx-serializer/typings.d.ts +3 -0
- package/heading/package.json +3 -9
- package/heading/toolbar/HeadingToolbarIcon.d.ts +10 -0
- package/heading/toolbar/HeadingToolbarIcon.js +12 -0
- package/heading/toolbar/index.cjs.js +23 -0
- package/heading/toolbar/index.d.ts +2 -0
- package/heading/toolbar/index.js +2 -0
- package/heading/toolbar/package.json +3 -6
- package/heading/toolbar/useToggleHeadingTool.d.ts +6 -0
- package/heading/toolbar/useToggleHeadingTool.js +11 -0
- package/heading/typings.d.ts +15 -0
- package/highlight/constants.d.ts +6 -0
- package/highlight/constants.js +8 -0
- package/highlight/createReactHighlight.d.ts +1 -0
- package/highlight/createReactHighlight.js +11 -0
- package/highlight/defaultRenderHighlight.d.ts +3 -0
- package/highlight/defaultRenderHighlight.js +7 -0
- package/highlight/index.cjs.js +24 -0
- package/highlight/index.js +3 -0
- package/highlight/jsx-serializer/createJsxSerializeHighlight.d.ts +1 -0
- package/highlight/jsx-serializer/createJsxSerializeHighlight.js +10 -0
- package/highlight/jsx-serializer/index.cjs.js +13 -0
- package/highlight/jsx-serializer/index.js +2 -0
- package/highlight/jsx-serializer/package.json +3 -6
- package/highlight/package.json +3 -5
- package/highlight/typings.d.ts +5 -0
- package/image/components/Image.d.ts +4 -0
- package/image/components/Image.js +68 -0
- package/image/components/ImageCaption.d.ts +4 -0
- package/image/components/ImageCaption.js +23 -0
- package/image/components/ImageFigure.d.ts +4 -0
- package/image/components/ImageFigure.js +15 -0
- package/image/components/ImagePlaceholder.d.ts +4 -0
- package/image/components/ImagePlaceholder.js +11 -0
- package/image/createReactImage.d.ts +8 -0
- package/image/createReactImage.js +132 -0
- package/image/defaultRenderImageElements.d.ts +2 -0
- package/image/defaultRenderImageElements.js +12 -0
- package/image/hooks/useImageResizer.d.ts +7 -0
- package/image/hooks/useImageResizer.js +95 -0
- package/image/image.css +1 -0
- package/image/index.cjs.js +335 -0
- package/image/index.js +7 -0
- package/image/jsx-serializer/createJsxSerializeImage.d.ts +7 -0
- package/image/jsx-serializer/createJsxSerializeImage.js +42 -0
- package/image/jsx-serializer/defaultRenderImageElements.d.ts +2 -0
- package/image/jsx-serializer/defaultRenderImageElements.js +10 -0
- package/image/jsx-serializer/index.cjs.js +52 -0
- package/image/jsx-serializer/index.js +2 -0
- package/image/jsx-serializer/package.json +3 -6
- package/image/jsx-serializer/typings.d.ts +18 -0
- package/image/package.json +3 -10
- package/image/typings.d.ts +22 -0
- package/index.cjs.js +709 -0
- package/index.js +21 -0
- package/input-block/components/InputBlock.d.ts +4 -0
- package/input-block/components/InputBlock.js +35 -0
- package/input-block/createReactInputBlock.d.ts +4 -0
- package/input-block/createReactInputBlock.js +17 -0
- package/input-block/defaultRenderInputBlockElement.d.ts +2 -0
- package/input-block/defaultRenderInputBlockElement.js +6 -0
- package/input-block/hooks/useInputBlock.d.ts +10 -0
- package/input-block/hooks/useInputBlock.js +57 -0
- package/input-block/index.cjs.js +108 -0
- package/input-block/index.js +4 -0
- package/input-block/input-block.css +1 -0
- package/input-block/package.json +3 -8
- package/input-block/typings.d.ts +12 -0
- package/italic/constants.d.ts +6 -0
- package/italic/constants.js +8 -0
- package/italic/createReactItalic.d.ts +1 -0
- package/italic/createReactItalic.js +11 -0
- package/italic/defaultRenderItalic.d.ts +3 -0
- package/italic/defaultRenderItalic.js +7 -0
- package/italic/index.cjs.js +24 -0
- package/italic/index.js +3 -0
- package/italic/jsx-serializer/createJsxSerializeItalic.d.ts +1 -0
- package/italic/jsx-serializer/createJsxSerializeItalic.js +10 -0
- package/italic/jsx-serializer/index.cjs.js +13 -0
- package/italic/jsx-serializer/index.js +2 -0
- package/italic/jsx-serializer/package.json +3 -6
- package/italic/package.json +3 -5
- package/italic/typings.d.ts +5 -0
- package/jsx-serializer/createJsxSerializeElement.d.ts +2 -0
- package/jsx-serializer/createJsxSerializeElement.js +7 -0
- package/jsx-serializer/createJsxSerializeElements.d.ts +2 -0
- package/jsx-serializer/createJsxSerializeElements.js +7 -0
- package/jsx-serializer/createJsxSerializeMark.d.ts +2 -0
- package/jsx-serializer/createJsxSerializeMark.js +7 -0
- package/jsx-serializer/createJsxSerializer.d.ts +18 -0
- package/jsx-serializer/createJsxSerializer.js +49 -0
- package/jsx-serializer/index.cjs.js +66 -0
- package/jsx-serializer/index.js +4 -0
- package/jsx-serializer/package.json +3 -5
- package/jsx-serializer/typings.d.ts +8 -0
- package/line-break/commonBreak.d.ts +14 -0
- package/line-break/commonBreak.js +31 -0
- package/line-break/createOnKeyDownBreak.d.ts +11 -0
- package/line-break/createOnKeyDownBreak.js +48 -0
- package/line-break/createReactLineBreak.d.ts +4 -0
- package/line-break/createReactLineBreak.js +14 -0
- package/line-break/defaultRenderLineBreakElement.d.ts +3 -0
- package/line-break/defaultRenderLineBreakElement.js +5 -0
- package/line-break/index.cjs.js +102 -0
- package/line-break/index.js +4 -0
- package/line-break/jsx-serializer/createJsxSerializeLineBreak.d.ts +4 -0
- package/line-break/jsx-serializer/createJsxSerializeLineBreak.js +11 -0
- package/line-break/jsx-serializer/defaultRenderLineBreakElement.d.ts +2 -0
- package/line-break/jsx-serializer/defaultRenderLineBreakElement.js +6 -0
- package/line-break/jsx-serializer/index.cjs.js +17 -0
- package/line-break/jsx-serializer/index.js +2 -0
- package/line-break/jsx-serializer/package.json +3 -6
- package/line-break/jsx-serializer/typings.d.ts +3 -0
- package/line-break/line-break.css +1 -0
- package/line-break/package.json +3 -8
- package/line-break/renderLineBreakElementWithSymbol.d.ts +3 -0
- package/line-break/renderLineBreakElementWithSymbol.js +5 -0
- package/line-break/typings.d.ts +32 -0
- package/link/createReactLink.d.ts +11 -0
- package/link/createReactLink.js +29 -0
- package/link/defaultRenderLinkElement.d.ts +9 -0
- package/link/defaultRenderLinkElement.js +13 -0
- package/link/index.cjs.js +42 -0
- package/link/index.js +2 -0
- package/link/jsx-serializer/createJsxSerializeLink.d.ts +4 -0
- package/link/jsx-serializer/createJsxSerializeLink.js +10 -0
- package/link/jsx-serializer/defaultRenderLinkElement.d.ts +3 -0
- package/link/jsx-serializer/defaultRenderLinkElement.js +5 -0
- package/link/jsx-serializer/index.cjs.js +15 -0
- package/link/jsx-serializer/index.js +2 -0
- package/link/jsx-serializer/package.json +3 -6
- package/link/jsx-serializer/typings.d.ts +3 -0
- package/link/package.json +3 -5
- package/link/toolbar/LinkToolbarIcon.d.ts +10 -0
- package/link/toolbar/LinkToolbarIcon.js +12 -0
- package/link/toolbar/UnlinkToolbarIcon.d.ts +8 -0
- package/link/toolbar/UnlinkToolbarIcon.js +12 -0
- package/link/toolbar/index.cjs.js +51 -0
- package/link/toolbar/index.d.ts +4 -0
- package/link/toolbar/index.js +4 -0
- package/link/toolbar/package.json +3 -6
- package/link/toolbar/useLinkTool.d.ts +7 -0
- package/link/toolbar/useLinkTool.js +25 -0
- package/link/toolbar/useUnlinkTool.d.ts +4 -0
- package/link/toolbar/useUnlinkTool.js +10 -0
- package/link/typings.d.ts +9 -0
- package/list/createReactList.d.ts +4 -0
- package/list/createReactList.js +35 -0
- package/list/defaultRenderListElements.d.ts +7 -0
- package/list/defaultRenderListElements.js +9 -0
- package/list/index.cjs.js +44 -0
- package/list/index.js +2 -0
- package/list/jsx-serializer/createJsxSerializeList.d.ts +7 -0
- package/list/jsx-serializer/createJsxSerializeList.js +15 -0
- package/list/jsx-serializer/index.cjs.js +18 -0
- package/list/jsx-serializer/index.js +2 -0
- package/list/jsx-serializer/package.json +3 -6
- package/list/jsx-serializer/typings.d.ts +3 -0
- package/list/list.css +1 -0
- package/list/package.json +3 -8
- package/list/toolbar/ListToolbarIcon.d.ts +10 -0
- package/list/toolbar/ListToolbarIcon.js +12 -0
- package/list/toolbar/index.cjs.js +23 -0
- package/list/toolbar/index.d.ts +2 -0
- package/list/toolbar/index.js +2 -0
- package/list/toolbar/package.json +3 -6
- package/list/toolbar/useListTool.d.ts +6 -0
- package/list/toolbar/useListTool.js +11 -0
- package/list/typings.d.ts +9 -0
- package/package.json +11 -24
- package/paragraph/createReactParagraph.d.ts +2 -0
- package/paragraph/createReactParagraph.js +8 -0
- package/paragraph/createRenderParagraphElement.d.ts +8 -0
- package/paragraph/createRenderParagraphElement.js +10 -0
- package/paragraph/defaultRenderParagraphElement.d.ts +8 -0
- package/paragraph/defaultRenderParagraphElement.js +8 -0
- package/paragraph/index.cjs.js +31 -0
- package/paragraph/index.js +4 -0
- package/paragraph/jsx-serializer/createJsxSerializeParagraph.d.ts +4 -0
- package/paragraph/jsx-serializer/createJsxSerializeParagraph.js +10 -0
- package/paragraph/jsx-serializer/index.cjs.js +13 -0
- package/paragraph/jsx-serializer/index.js +2 -0
- package/paragraph/jsx-serializer/package.json +3 -6
- package/paragraph/jsx-serializer/typings.d.ts +3 -0
- package/paragraph/package.json +3 -8
- package/paragraph/paragraph.css +1 -0
- package/paragraph/renderParagraphElementWithSymbol.d.ts +8 -0
- package/paragraph/renderParagraphElementWithSymbol.js +8 -0
- 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.js +2 -0
- package/paragraph/toolbar/package.json +3 -6
- package/paragraph/toolbar/useToggleParagraphTool.d.ts +5 -0
- package/paragraph/toolbar/useToggleParagraphTool.js +11 -0
- package/read-more/components/ReadMore.d.ts +8 -0
- package/read-more/components/ReadMore.js +14 -0
- package/read-more/createReactReadMore.d.ts +4 -0
- package/read-more/createReactReadMore.js +11 -0
- package/read-more/defaultRenderReadMoreElement.d.ts +3 -0
- package/read-more/defaultRenderReadMoreElement.js +6 -0
- package/read-more/index.cjs.js +27 -0
- package/read-more/index.js +3 -0
- package/read-more/jsx-serializer/createJsxSerializeReadMore.d.ts +4 -0
- package/read-more/jsx-serializer/createJsxSerializeReadMore.js +10 -0
- package/read-more/jsx-serializer/index.cjs.js +13 -0
- package/read-more/jsx-serializer/index.js +2 -0
- package/read-more/jsx-serializer/package.json +3 -6
- package/read-more/jsx-serializer/typings.d.ts +3 -0
- package/read-more/package.json +3 -8
- package/read-more/read-more.css +1 -0
- package/read-more/toolbar/ReadMoreToolbarIcon.d.ts +8 -0
- package/read-more/toolbar/ReadMoreToolbarIcon.js +12 -0
- package/read-more/toolbar/index.cjs.js +22 -0
- package/read-more/toolbar/index.d.ts +2 -0
- package/read-more/toolbar/index.js +2 -0
- package/read-more/toolbar/package.json +3 -6
- package/read-more/toolbar/useReadMoreTool.d.ts +4 -0
- package/read-more/toolbar/useReadMoreTool.js +10 -0
- package/read-more/typings.d.ts +9 -0
- package/strikethrough/constants.d.ts +6 -0
- package/strikethrough/constants.js +8 -0
- package/strikethrough/createReactStrikethrough.d.ts +1 -0
- package/strikethrough/createReactStrikethrough.js +11 -0
- package/strikethrough/defaultRenderStrikethrough.d.ts +3 -0
- package/strikethrough/defaultRenderStrikethrough.js +7 -0
- package/strikethrough/index.cjs.js +24 -0
- package/strikethrough/index.js +3 -0
- package/strikethrough/jsx-serializer/createJsxSerializeStrikethrough.d.ts +1 -0
- package/strikethrough/jsx-serializer/createJsxSerializeStrikethrough.js +10 -0
- package/strikethrough/jsx-serializer/index.cjs.js +13 -0
- package/strikethrough/jsx-serializer/index.js +2 -0
- package/strikethrough/jsx-serializer/package.json +3 -6
- package/strikethrough/package.json +3 -5
- package/strikethrough/typings.d.ts +5 -0
- package/table/components/ColumnDragButton.d.ts +10 -0
- package/table/components/ColumnDragButton.js +41 -0
- package/table/components/RowDragButton.d.ts +10 -0
- package/table/components/RowDragButton.js +42 -0
- package/table/components/Table.d.ts +9 -0
- package/table/components/Table.js +236 -0
- package/table/components/TableBody.d.ts +5 -0
- package/table/components/TableBody.js +8 -0
- package/table/components/TableCell.d.ts +5 -0
- package/table/components/TableCell.js +297 -0
- package/table/components/TableDragLayer.d.ts +6 -0
- package/table/components/TableDragLayer.js +89 -0
- package/table/components/TableHeader.d.ts +5 -0
- package/table/components/TableHeader.js +13 -0
- package/table/components/TableMain.d.ts +5 -0
- package/table/components/TableMain.js +233 -0
- package/table/components/TableRow.d.ts +5 -0
- package/table/components/TableRow.js +8 -0
- package/table/components/TableTitle.d.ts +5 -0
- package/table/components/TableTitle.js +18 -0
- package/table/contexts/TableActionsContext.d.ts +3 -0
- package/table/contexts/TableActionsContext.js +5 -0
- package/table/contexts/TableDragContext.d.ts +26 -0
- package/table/contexts/TableDragContext.js +26 -0
- package/table/contexts/TableHeaderContext.d.ts +2 -0
- package/table/contexts/TableHeaderContext.js +7 -0
- package/table/contexts/TableMetadataContext.d.ts +3 -0
- package/table/contexts/TableMetadataContext.js +5 -0
- package/table/contexts/TableScrollContext.d.ts +2 -0
- package/table/contexts/TableScrollContext.js +9 -0
- package/table/contexts/TableStateContext.d.ts +3 -0
- package/table/contexts/TableStateContext.js +5 -0
- package/table/createReactTable.d.ts +4 -0
- package/table/createReactTable.js +297 -0
- package/table/defaultRenderTableElements.d.ts +2 -0
- package/table/defaultRenderTableElements.js +20 -0
- package/table/hooks/useColumnResize.d.ts +12 -0
- package/table/hooks/useColumnResize.js +168 -0
- package/table/hooks/useTableActions.d.ts +27 -0
- package/table/hooks/useTableActions.js +1092 -0
- package/table/hooks/useTableActionsContext.d.ts +1 -0
- package/table/hooks/useTableActionsContext.js +12 -0
- package/table/hooks/useTableCell.d.ts +16 -0
- package/table/hooks/useTableCell.js +166 -0
- package/table/hooks/useTableCellToolbarActions.d.ts +34 -0
- package/table/hooks/useTableCellToolbarActions.js +540 -0
- package/table/hooks/useTableMetadata.d.ts +1 -0
- package/table/hooks/useTableMetadata.js +12 -0
- package/table/hooks/useTableStateContext.d.ts +1 -0
- package/table/hooks/useTableStateContext.js +12 -0
- package/table/hooks/useTableStates.d.ts +18 -0
- package/table/hooks/useTableStates.js +14 -0
- package/table/index.cjs.js +4016 -0
- package/table/index.js +27 -0
- package/table/jsx-serializer/components/Table.d.ts +3 -0
- package/table/jsx-serializer/components/Table.js +7 -0
- package/table/jsx-serializer/components/TableBody.d.ts +3 -0
- package/table/jsx-serializer/components/TableBody.js +7 -0
- package/table/jsx-serializer/components/TableCell.d.ts +5 -0
- package/table/jsx-serializer/components/TableCell.js +33 -0
- package/table/jsx-serializer/components/TableHeader.d.ts +3 -0
- package/table/jsx-serializer/components/TableHeader.js +10 -0
- package/table/jsx-serializer/components/TableMain.d.ts +6 -0
- package/table/jsx-serializer/components/TableMain.js +18 -0
- package/table/jsx-serializer/components/TableRow.d.ts +3 -0
- package/table/jsx-serializer/components/TableRow.js +7 -0
- package/table/jsx-serializer/components/TableTitle.d.ts +3 -0
- package/table/jsx-serializer/components/TableTitle.js +7 -0
- package/table/jsx-serializer/contexts/TableHeaderContext.d.ts +1 -0
- package/table/jsx-serializer/contexts/TableHeaderContext.js +5 -0
- package/table/jsx-serializer/contexts/TableScrollContext.d.ts +2 -0
- package/table/jsx-serializer/contexts/TableScrollContext.js +7 -0
- package/table/jsx-serializer/createJsxSerializeTable.d.ts +5 -0
- package/table/jsx-serializer/createJsxSerializeTable.js +113 -0
- package/table/jsx-serializer/defaultRenderTableElements.d.ts +2 -0
- package/table/jsx-serializer/defaultRenderTableElements.js +20 -0
- package/table/jsx-serializer/index.cjs.js +195 -0
- package/table/jsx-serializer/index.js +2 -0
- package/table/jsx-serializer/package.json +3 -6
- package/table/jsx-serializer/typings.d.ts +12 -0
- package/table/package.json +3 -12
- package/table/table.css +1 -0
- package/table/toolbar/TableToolbarIcon.d.ts +8 -0
- package/table/toolbar/TableToolbarIcon.js +12 -0
- package/table/toolbar/index.cjs.js +24 -0
- package/table/toolbar/index.js +2 -0
- package/table/toolbar/package.json +3 -6
- package/table/toolbar/useTableTool.d.ts +4 -0
- package/table/toolbar/useTableTool.js +13 -0
- package/table/typings.d.ts +68 -0
- package/table/utils/helper.d.ts +186 -0
- package/table/utils/helper.js +799 -0
- package/toggle-mark/createReactToggleMarkCreator.d.ts +6 -0
- package/toggle-mark/createReactToggleMarkCreator.js +20 -0
- package/toggle-mark/index.cjs.js +22 -0
- package/toggle-mark/index.d.ts +2 -0
- package/toggle-mark/index.js +1 -0
- package/toggle-mark/jsx-serializer/createJsxSerializeToggleMarkCreator.d.ts +4 -0
- package/toggle-mark/jsx-serializer/createJsxSerializeToggleMarkCreator.js +7 -0
- package/toggle-mark/jsx-serializer/index.cjs.js +9 -0
- package/toggle-mark/jsx-serializer/index.d.ts +2 -0
- package/toggle-mark/jsx-serializer/index.js +1 -0
- package/toggle-mark/jsx-serializer/package.json +3 -6
- package/toggle-mark/jsx-serializer/typings.d.ts +2 -0
- package/toggle-mark/package.json +3 -5
- package/toggle-mark/toolbar/ToggleMarkToolbarIcon.d.ts +8 -0
- package/toggle-mark/toolbar/ToggleMarkToolbarIcon.js +12 -0
- package/toggle-mark/toolbar/index.cjs.js +23 -0
- package/toggle-mark/toolbar/index.js +2 -0
- package/toggle-mark/toolbar/package.json +3 -6
- package/toggle-mark/toolbar/useToggleMarkTool.d.ts +5 -0
- package/toggle-mark/toolbar/useToggleMarkTool.js +11 -0
- package/toggle-mark/typings.d.ts +12 -0
- package/toolbar/components/InlineToolbar.d.ts +19 -0
- package/toolbar/components/InlineToolbar.js +31 -0
- package/toolbar/components/Toolbar.d.ts +25 -0
- package/toolbar/components/Toolbar.js +137 -0
- package/toolbar/components/ToolbarGroupIcon.d.ts +7 -0
- package/toolbar/components/ToolbarGroupIcon.js +80 -0
- package/toolbar/components/ToolbarIcon.d.ts +9 -0
- package/toolbar/components/ToolbarIcon.js +32 -0
- package/toolbar/components/ToolbarInput.d.ts +8 -0
- package/toolbar/components/ToolbarInput.js +38 -0
- package/toolbar/components/toolbarIconName.d.ts +2 -0
- package/toolbar/components/toolbarIconName.js +86 -0
- package/toolbar/constants.d.ts +5 -0
- package/toolbar/constants.js +8 -0
- package/toolbar/contexts/StartToolInputContext.d.ts +2 -0
- package/toolbar/contexts/StartToolInputContext.js +5 -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/hooks/useStartToolInput.d.ts +1 -0
- package/toolbar/hooks/useStartToolInput.js +8 -0
- package/toolbar/index.cjs.js +468 -0
- package/toolbar/index.d.ts +7 -0
- package/toolbar/index.js +6 -0
- package/toolbar/package.json +3 -9
- package/toolbar/toolbar.css +1 -0
- package/toolbar/typings.d.ts +6 -0
- package/underline/constants.d.ts +6 -0
- package/underline/constants.js +8 -0
- package/underline/createReactUnderline.d.ts +1 -0
- package/underline/createReactUnderline.js +11 -0
- package/underline/defaultRenderUnderline.d.ts +3 -0
- package/underline/defaultRenderUnderline.js +7 -0
- package/underline/index.cjs.js +24 -0
- package/underline/index.js +3 -0
- package/underline/jsx-serializer/createJsxSerializeUnderline.d.ts +1 -0
- package/underline/jsx-serializer/createJsxSerializeUnderline.js +10 -0
- package/underline/jsx-serializer/index.cjs.js +13 -0
- package/underline/jsx-serializer/index.js +2 -0
- package/underline/jsx-serializer/package.json +3 -6
- package/underline/package.json +3 -5
- package/underline/typings.d.ts +5 -0
- package/utils/composeRefs.d.ts +19 -0
- package/utils/composeRefs.js +32 -0
- package/utils/index.cjs.js +193 -0
- package/utils/index.js +7 -0
- package/utils/package.json +4 -1
- package/utils/removePreviousElement.d.ts +9 -0
- package/utils/removePreviousElement.js +44 -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/CHANGELOG.md +0 -610
- package/_internal/src/renderer/composeRenderElementsBase.ts +0 -19
- package/_internal/src/renderer/composeRenderLeafsBase.ts +0 -17
- package/_internal/src/renderer/createRenderElementBase.ts +0 -14
- package/_internal/src/renderer/createRenderElementsBase.ts +0 -15
- package/_internal/src/renderer/createRenderMarkBase.ts +0 -19
- package/_internal/src/renderer/typings.ts +0 -30
- package/_internal/tsconfig.build.json +0 -5
- package/accordion/jsx-serializer/src/createJsxSerializeAccordion.ts +0 -79
- package/accordion/jsx-serializer/src/defaultRenderAccordionElements.tsx +0 -21
- package/accordion/jsx-serializer/src/typings.ts +0 -16
- package/accordion/jsx-serializer/tsconfig.build.json +0 -5
- package/accordion/src/components/Accordion.tsx +0 -53
- package/accordion/src/components/AccordionContent.tsx +0 -38
- package/accordion/src/components/AccordionTitle.tsx +0 -33
- package/accordion/src/contexts/AccordionContext.ts +0 -4
- package/accordion/src/createReactAccordion.ts +0 -194
- package/accordion/src/defaultRenderAccordionElements.tsx +0 -11
- package/accordion/src/hooks/useAccordion.ts +0 -6
- package/accordion/src/typings.ts +0 -41
- package/accordion/toolbar/src/AccordionToolbarIcon.tsx +0 -17
- package/accordion/toolbar/src/index.ts +0 -3
- package/accordion/toolbar/src/useAccordionTool.ts +0 -10
- package/accordion/toolbar/tsconfig.build.json +0 -5
- package/accordion/tsconfig.build.json +0 -5
- package/align/src/constants.ts +0 -8
- package/align/src/createReactAlign.ts +0 -27
- package/align/src/typings.ts +0 -20
- package/align/toolbar/src/AlignToolbarIcon.tsx +0 -19
- package/align/toolbar/src/index.ts +0 -3
- package/align/toolbar/src/useAlignTool.ts +0 -18
- package/align/toolbar/tsconfig.build.json +0 -5
- package/align/tsconfig.build.json +0 -5
- package/blockquote/jsx-serializer/src/createJsxSerializeBlockquote.ts +0 -14
- package/blockquote/jsx-serializer/src/typings.ts +0 -4
- package/blockquote/jsx-serializer/tsconfig.build.json +0 -5
- package/blockquote/src/ReactBlockquote.spec.tsx +0 -42
- package/blockquote/src/constants.ts +0 -6
- package/blockquote/src/createReactBlockquote.ts +0 -105
- package/blockquote/src/defaultRenderBlockquoteElement.tsx +0 -15
- package/blockquote/src/typings.ts +0 -22
- package/blockquote/toolbar/src/BlockquoteToolbarIcon.tsx +0 -17
- package/blockquote/toolbar/src/useBlockquoteTool.ts +0 -11
- package/blockquote/toolbar/tsconfig.build.json +0 -5
- package/blockquote/tsconfig.build.json +0 -5
- package/bold/jsx-serializer/src/createJsxSerializeBold.ts +0 -8
- package/bold/jsx-serializer/tsconfig.build.json +0 -5
- package/bold/src/constants.ts +0 -6
- package/bold/src/createReactBold.ts +0 -11
- package/bold/src/defaultRenderBold.tsx +0 -12
- package/bold/src/typings.ts +0 -6
- package/bold/tsconfig.build.json +0 -5
- package/card/jsx-serializer/src/createJsxSerializeCard.ts +0 -65
- package/card/jsx-serializer/src/defaultRenderCardElements.tsx +0 -9
- package/card/jsx-serializer/src/typings.ts +0 -20
- package/card/jsx-serializer/tsconfig.build.json +0 -5
- package/card/src/components/Card.tsx +0 -139
- package/card/src/components/CardContents.tsx +0 -35
- package/card/src/components/CardImage.tsx +0 -30
- package/card/src/components/CardPlaceholder.tsx +0 -40
- package/card/src/createReactCard.ts +0 -101
- package/card/src/defaultRenderCardElements.tsx +0 -16
- package/card/src/typings.ts +0 -46
- package/card/toolbar/src/CardToolbarIcon.tsx +0 -17
- package/card/toolbar/src/useCardTool.tsx +0 -43
- package/card/toolbar/tsconfig.build.json +0 -5
- package/card/tsconfig.build.json +0 -5
- package/carousel/jsx-serializer/src/createJsxSerializeCarousel.ts +0 -71
- package/carousel/jsx-serializer/src/defaultRenderCarouselElements.tsx +0 -9
- package/carousel/jsx-serializer/src/typings.ts +0 -20
- package/carousel/jsx-serializer/tsconfig.build.json +0 -5
- package/carousel/src/components/Carousel.tsx +0 -102
- package/carousel/src/components/CarouselCaption.tsx +0 -27
- package/carousel/src/components/CarouselImages.tsx +0 -97
- package/carousel/src/components/CarouselPlaceholder.tsx +0 -26
- package/carousel/src/contexts/CarouselContext.ts +0 -4
- package/carousel/src/createReactCarousel.ts +0 -104
- package/carousel/src/defaultRenderCarouselElements.tsx +0 -16
- package/carousel/src/hooks/useCarousel.ts +0 -6
- package/carousel/src/typings.ts +0 -55
- package/carousel/toolbar/src/CarouselToolbarIcon.tsx +0 -17
- package/carousel/toolbar/src/useCarouselTool.tsx +0 -34
- package/carousel/toolbar/tsconfig.build.json +0 -5
- package/carousel/tsconfig.build.json +0 -5
- package/components/src/BaseField/index.tsx +0 -35
- package/components/src/Button/index.tsx +0 -48
- package/components/src/Hint/index.tsx +0 -61
- package/components/src/Icon/index.tsx +0 -45
- package/components/src/ImageUploader/index.tsx +0 -306
- package/components/src/Input/index.tsx +0 -72
- package/components/src/Message/index.tsx +0 -138
- package/components/src/Modal/index.tsx +0 -161
- package/components/src/Notifier/NotifierManager.tsx +0 -50
- package/components/src/Notifier/createNotifier.tsx +0 -100
- package/components/src/Notifier/typings.ts +0 -33
- package/components/src/Portal/index.tsx +0 -15
- package/components/src/Progress/index.tsx +0 -49
- package/components/src/SegmentedControl/index.tsx +0 -37
- package/components/src/Textarea/index.tsx +0 -74
- package/components/src/Toggle/index.tsx +0 -34
- package/components/src/Tooltip/calculatePosition.ts +0 -84
- package/components/src/Tooltip/index.tsx +0 -187
- package/components/src/Tooltip/typings.ts +0 -40
- package/components/src/Transition/SlideFade.tsx +0 -159
- package/components/src/Transition/Transition.tsx +0 -176
- package/components/src/Transition/getTransitionStyleProps.ts +0 -48
- package/components/src/Transition/useSetNodeTransition.ts +0 -46
- package/components/src/index.ts +0 -17
- package/components/tsconfig.build.json +0 -5
- package/configs/src/ConfigsProvider.tsx +0 -39
- package/configs/src/locale.ts +0 -8
- package/configs/src/theme.ts +0 -50
- package/configs/tsconfig.build.json +0 -5
- package/divider/jsx-serializer/src/createJsxSerializeDivider.ts +0 -12
- package/divider/jsx-serializer/src/defaultRenderDividerElement.tsx +0 -3
- package/divider/jsx-serializer/src/typings.ts +0 -4
- package/divider/jsx-serializer/tsconfig.build.json +0 -5
- package/divider/src/createReactDivider.ts +0 -16
- package/divider/src/defaultRenderDividerElement.tsx +0 -8
- package/divider/src/typings.ts +0 -13
- package/divider/toolbar/src/DividerToolbarIcon.tsx +0 -17
- package/divider/toolbar/src/index.ts +0 -3
- package/divider/toolbar/src/useDividerTool.ts +0 -10
- package/divider/toolbar/tsconfig.build.json +0 -5
- package/divider/tsconfig.build.json +0 -5
- package/embed/jsx-serializer/facebook/tsconfig.build.json +0 -5
- package/embed/jsx-serializer/instagram/tsconfig.build.json +0 -5
- package/embed/jsx-serializer/src/createJsxSerializeEmbed.ts +0 -20
- package/embed/jsx-serializer/src/typings.ts +0 -7
- package/embed/jsx-serializer/tsconfig.build.json +0 -5
- package/embed/jsx-serializer/twitter/tsconfig.build.json +0 -5
- package/embed/jsx-serializer/vimeo/tsconfig.build.json +0 -5
- package/embed/jsx-serializer/youtube/tsconfig.build.json +0 -5
- package/embed/renderers/base/src/components/BaseEmbedElement.tsx +0 -107
- package/embed/renderers/base/src/index.ts +0 -5
- package/embed/renderers/base/tsconfig.build.json +0 -5
- package/embed/renderers/facebook/src/components/Facebook.tsx +0 -56
- package/embed/renderers/facebook/src/defaultRenderFacebookEmbedElement.tsx +0 -81
- package/embed/renderers/facebook/tsconfig.build.json +0 -5
- package/embed/renderers/instagram/src/components/Instagram.tsx +0 -86
- package/embed/renderers/instagram/src/defaultRenderInstagramEmbedElement.tsx +0 -74
- package/embed/renderers/instagram/src/hooks/useLoadInstagramEmbedApi.ts +0 -39
- package/embed/renderers/instagram/tsconfig.build.json +0 -5
- package/embed/renderers/podcast-apple/src/components/PodcastApple.tsx +0 -37
- package/embed/renderers/podcast-apple/src/defaultRenderPodcastAppleEmbedElement.tsx +0 -69
- package/embed/renderers/podcast-apple/tsconfig.build.json +0 -5
- package/embed/renderers/spotify/src/components/Spotify.tsx +0 -51
- package/embed/renderers/spotify/src/defaultRenderSpotifyEmbedElement.tsx +0 -63
- package/embed/renderers/spotify/tsconfig.build.json +0 -5
- package/embed/renderers/twitter/src/components/Twitter.tsx +0 -47
- package/embed/renderers/twitter/src/defaultRenderTwitterEmbedElement.tsx +0 -78
- package/embed/renderers/twitter/src/hooks/useLoadTwitterEmbedApi.ts +0 -55
- package/embed/renderers/twitter/tsconfig.build.json +0 -5
- package/embed/renderers/vimeo/src/defaultRenderVimeoEmbedElement.tsx +0 -52
- package/embed/renderers/vimeo/tsconfig.build.json +0 -5
- package/embed/renderers/youtube/src/defaultRenderYoutubeEmbedElement.tsx +0 -52
- package/embed/renderers/youtube/tsconfig.build.json +0 -5
- package/embed/src/components/VideoIframe.tsx +0 -41
- package/embed/src/createReactEmbed.ts +0 -23
- package/embed/src/createRenderEmbedElementBase.ts +0 -30
- package/embed/src/hooks/useVideoIframeSize.ts +0 -28
- package/embed/src/typings.ts +0 -26
- package/embed/toolbar/src/EmbedToolbarIcon.tsx +0 -25
- package/embed/toolbar/src/index.ts +0 -3
- package/embed/toolbar/src/useEmbedTool.tsx +0 -106
- package/embed/toolbar/tsconfig.build.json +0 -5
- package/embed/tsconfig.build.json +0 -5
- package/file-uploader/src/components/FileUploader.tsx +0 -18
- package/file-uploader/src/createReactFileUploader.ts +0 -28
- package/file-uploader/src/defaultRenderFileUploaderElement.tsx +0 -5
- package/file-uploader/src/hooks/useFileUploader.ts +0 -14
- package/file-uploader/src/typings.ts +0 -19
- package/file-uploader/toolbar/src/FileUploaderToolbarIcon.tsx +0 -19
- package/file-uploader/toolbar/src/index.ts +0 -3
- package/file-uploader/toolbar/src/useFileUploaderTool.ts +0 -14
- package/file-uploader/toolbar/tsconfig.build.json +0 -5
- package/file-uploader/tsconfig.build.json +0 -5
- package/footnote/jsx-serializer/src/createJsxSerializeFootnote.ts +0 -13
- package/footnote/jsx-serializer/src/defaultRenderFootnoteElement.tsx +0 -18
- package/footnote/jsx-serializer/src/typings.ts +0 -4
- package/footnote/jsx-serializer/tsconfig.build.json +0 -5
- package/footnote/src/createReactFootnote.ts +0 -22
- package/footnote/src/defaultRenderFootnoteElement.tsx +0 -36
- package/footnote/src/typings.ts +0 -14
- package/footnote/src/useFootnotes.ts +0 -28
- package/footnote/src/useFootnotesFromNodes.ts +0 -33
- package/footnote/toolbar/src/FootnoteToolbarIcon.tsx +0 -18
- package/footnote/toolbar/src/index.ts +0 -3
- package/footnote/toolbar/src/useFootnoteTool.ts +0 -22
- package/footnote/toolbar/tsconfig.build.json +0 -5
- package/footnote/tsconfig.build.json +0 -5
- package/heading/jsx-serializer/src/createJsxSerializeHeading.ts +0 -13
- package/heading/jsx-serializer/src/typings.ts +0 -4
- package/heading/jsx-serializer/tsconfig.build.json +0 -5
- package/heading/src/constants.ts +0 -9
- package/heading/src/createReactHeading.ts +0 -56
- package/heading/src/defaultRenderHeadingElement.tsx +0 -36
- package/heading/src/typings.ts +0 -21
- package/heading/toolbar/src/HeadingToolbarIcon.tsx +0 -22
- package/heading/toolbar/src/index.ts +0 -3
- package/heading/toolbar/src/useToggleHeadingTool.ts +0 -15
- package/heading/toolbar/tsconfig.build.json +0 -5
- package/heading/tsconfig.build.json +0 -5
- package/highlight/jsx-serializer/src/createJsxSerializeHighlight.ts +0 -8
- package/highlight/jsx-serializer/tsconfig.build.json +0 -5
- package/highlight/src/constants.ts +0 -6
- package/highlight/src/createReactHighlight.ts +0 -11
- package/highlight/src/defaultRenderHighlight.tsx +0 -12
- package/highlight/src/typings.ts +0 -6
- package/highlight/tsconfig.build.json +0 -5
- package/image/jsx-serializer/src/createJsxSerializeImage.ts +0 -85
- package/image/jsx-serializer/src/defaultRenderImageElements.tsx +0 -21
- package/image/jsx-serializer/src/typings.ts +0 -34
- package/image/jsx-serializer/tsconfig.build.json +0 -5
- package/image/src/components/Image.tsx +0 -107
- package/image/src/components/ImageCaption.tsx +0 -35
- package/image/src/components/ImageFigure.tsx +0 -26
- package/image/src/components/ImagePlaceholder.tsx +0 -16
- package/image/src/createReactImage.ts +0 -191
- package/image/src/defaultRenderImageElements.tsx +0 -11
- package/image/src/hooks/useImageResizer.ts +0 -135
- package/image/src/typings.ts +0 -50
- package/image/tsconfig.build.json +0 -5
- package/input-block/src/components/InputBlock.tsx +0 -70
- package/input-block/src/createReactInputBlock.ts +0 -34
- package/input-block/src/defaultRenderInputBlockElement.tsx +0 -5
- package/input-block/src/hooks/useInputBlock.ts +0 -61
- package/input-block/src/typings.ts +0 -19
- package/input-block/tsconfig.build.json +0 -5
- package/italic/jsx-serializer/src/createJsxSerializeItalic.ts +0 -8
- package/italic/jsx-serializer/tsconfig.build.json +0 -5
- package/italic/src/constants.ts +0 -6
- package/italic/src/createReactItalic.ts +0 -11
- package/italic/src/defaultRenderItalic.tsx +0 -12
- package/italic/src/typings.ts +0 -6
- package/italic/tsconfig.build.json +0 -5
- package/jsx-serializer/src/createJsxSerializeElement.ts +0 -8
- package/jsx-serializer/src/createJsxSerializeElements.ts +0 -8
- package/jsx-serializer/src/createJsxSerializeMark.ts +0 -6
- package/jsx-serializer/src/createJsxSerializer.tsx +0 -84
- package/jsx-serializer/src/typings.ts +0 -20
- package/jsx-serializer/tsconfig.build.json +0 -5
- package/line-break/jsx-serializer/src/createJsxSerializeLineBreak.ts +0 -13
- package/line-break/jsx-serializer/src/defaultRenderLineBreakElement.tsx +0 -7
- package/line-break/jsx-serializer/src/typings.ts +0 -4
- package/line-break/jsx-serializer/tsconfig.build.json +0 -5
- package/line-break/src/commonBreak.ts +0 -32
- package/line-break/src/createOnKeyDownBreak.ts +0 -88
- package/line-break/src/createReactLineBreak.ts +0 -20
- package/line-break/src/defaultRenderLineBreakElement.tsx +0 -8
- package/line-break/src/renderLineBreakElementWithSymbol.tsx +0 -8
- package/line-break/src/typings.ts +0 -38
- package/line-break/tsconfig.build.json +0 -5
- package/link/jsx-serializer/src/createJsxSerializeLink.ts +0 -11
- package/link/jsx-serializer/src/defaultRenderLinkElement.tsx +0 -8
- package/link/jsx-serializer/src/typings.ts +0 -4
- package/link/jsx-serializer/tsconfig.build.json +0 -5
- package/link/src/createReactLink.ts +0 -49
- package/link/src/defaultRenderLinkElement.tsx +0 -27
- package/link/src/typings.ts +0 -14
- package/link/toolbar/src/LinkToolbarIcon.tsx +0 -18
- package/link/toolbar/src/UnlinkToolbarIcon.tsx +0 -17
- package/link/toolbar/src/index.ts +0 -5
- package/link/toolbar/src/useLinkTool.ts +0 -31
- package/link/toolbar/src/useUnlinkTool.ts +0 -10
- package/link/toolbar/tsconfig.build.json +0 -5
- package/link/tsconfig.build.json +0 -5
- package/list/jsx-serializer/src/createJsxSerializeList.ts +0 -21
- package/list/jsx-serializer/src/typings.ts +0 -4
- package/list/jsx-serializer/tsconfig.build.json +0 -5
- package/list/src/createReactList.ts +0 -52
- package/list/src/defaultRenderListElements.tsx +0 -12
- package/list/src/typings.ts +0 -14
- package/list/toolbar/src/ListToolbarIcon.tsx +0 -19
- package/list/toolbar/src/index.ts +0 -3
- package/list/toolbar/src/useListTool.ts +0 -12
- package/list/toolbar/tsconfig.build.json +0 -5
- package/list/tsconfig.build.json +0 -5
- package/paragraph/jsx-serializer/src/createJsxSerializeParagraph.ts +0 -14
- package/paragraph/jsx-serializer/src/typings.ts +0 -4
- package/paragraph/jsx-serializer/tsconfig.build.json +0 -5
- package/paragraph/src/createReactParagraph.ts +0 -9
- package/paragraph/src/createRenderParagraphElement.ts +0 -17
- package/paragraph/src/defaultRenderParagraphElement.tsx +0 -21
- package/paragraph/src/renderParagraphElementWithSymbol.tsx +0 -21
- package/paragraph/toolbar/src/ParagraphToolbarIcon.tsx +0 -17
- package/paragraph/toolbar/src/useToggleParagraphTool.ts +0 -11
- package/paragraph/toolbar/tsconfig.build.json +0 -5
- package/paragraph/tsconfig.build.json +0 -5
- package/read-more/jsx-serializer/src/createJsxSerializeReadMore.ts +0 -11
- package/read-more/jsx-serializer/src/typings.ts +0 -4
- package/read-more/jsx-serializer/tsconfig.build.json +0 -5
- package/read-more/src/components/ReadMore.tsx +0 -24
- package/read-more/src/createReactReadMore.ts +0 -16
- package/read-more/src/defaultRenderReadMoreElement.tsx +0 -5
- package/read-more/src/typings.ts +0 -12
- package/read-more/toolbar/src/ReadMoreToolbarIcon.tsx +0 -17
- package/read-more/toolbar/src/index.ts +0 -3
- package/read-more/toolbar/src/useReadMoreTool.ts +0 -10
- package/read-more/toolbar/tsconfig.build.json +0 -5
- package/read-more/tsconfig.build.json +0 -5
- package/src/core/components/DefaultElement.tsx +0 -6
- package/src/core/components/DefaultLeaf.tsx +0 -6
- package/src/core/components/Editable.tsx +0 -129
- package/src/core/components/Quadrats.tsx +0 -40
- package/src/core/composeHandlers.ts +0 -58
- package/src/core/composeRenderElements.tsx +0 -13
- package/src/core/composeRenderLeafs.tsx +0 -11
- package/src/core/constants.ts +0 -1
- package/src/core/contexts/composition/CompositionProvider.tsx +0 -15
- package/src/core/contexts/composition/composition.ts +0 -16
- package/src/core/contexts/message/MessageProvider.tsx +0 -46
- package/src/core/contexts/message/message.ts +0 -14
- package/src/core/contexts/modal/CardModal/CardModal.tsx +0 -256
- package/src/core/contexts/modal/CarouselModal/CarouselItem.tsx +0 -97
- package/src/core/contexts/modal/CarouselModal/CarouselModal.tsx +0 -280
- package/src/core/contexts/modal/CarouselModal/FilesDropZone.tsx +0 -118
- package/src/core/contexts/modal/ConfirmModal/ConfirmModal.tsx +0 -72
- package/src/core/contexts/modal/EmbedModal/EmbedModal.tsx +0 -57
- package/src/core/contexts/modal/ModalProvider.tsx +0 -114
- package/src/core/contexts/modal/modal.ts +0 -36
- package/src/core/createReactEditor.ts +0 -7
- package/src/core/createRenderElement.ts +0 -6
- package/src/core/createRenderElements.ts +0 -6
- package/src/core/createRenderMark.ts +0 -6
- package/src/core/index.ts +0 -53
- package/src/core/typings/descendant.ts +0 -3
- package/src/core/typings/handler.ts +0 -32
- package/src/core/typings/renderer.ts +0 -33
- package/src/core/typings/with.ts +0 -5
- package/strikethrough/jsx-serializer/src/createJsxSerializeStrikethrough.ts +0 -8
- package/strikethrough/jsx-serializer/tsconfig.build.json +0 -5
- package/strikethrough/src/constants.ts +0 -6
- package/strikethrough/src/createReactStrikethrough.ts +0 -11
- package/strikethrough/src/defaultRenderStrikethrough.tsx +0 -12
- package/strikethrough/src/typings.ts +0 -6
- package/strikethrough/tsconfig.build.json +0 -5
- package/table/jsx-serializer/src/components/Table.tsx +0 -6
- package/table/jsx-serializer/src/components/TableBody.tsx +0 -6
- package/table/jsx-serializer/src/components/TableCell.tsx +0 -51
- package/table/jsx-serializer/src/components/TableHeader.tsx +0 -16
- package/table/jsx-serializer/src/components/TableMain.tsx +0 -36
- package/table/jsx-serializer/src/components/TableRow.tsx +0 -6
- package/table/jsx-serializer/src/components/TableTitle.tsx +0 -6
- package/table/jsx-serializer/src/contexts/TableHeaderContext.ts +0 -3
- package/table/jsx-serializer/src/contexts/TableScrollContext.ts +0 -6
- package/table/jsx-serializer/src/createJsxSerializeTable.tsx +0 -163
- package/table/jsx-serializer/src/defaultRenderTableElements.tsx +0 -19
- package/table/jsx-serializer/src/typings.ts +0 -36
- package/table/jsx-serializer/tsconfig.build.json +0 -5
- package/table/src/components/ColumnDragButton.tsx +0 -72
- package/table/src/components/RowDragButton.tsx +0 -69
- package/table/src/components/Table.tsx +0 -351
- package/table/src/components/TableBody.tsx +0 -15
- package/table/src/components/TableCell.tsx +0 -415
- package/table/src/components/TableDragLayer.tsx +0 -127
- package/table/src/components/TableHeader.tsx +0 -26
- package/table/src/components/TableMain.tsx +0 -322
- package/table/src/components/TableRow.tsx +0 -11
- package/table/src/components/TableTitle.tsx +0 -28
- package/table/src/contexts/TableActionsContext.ts +0 -23
- package/table/src/contexts/TableDragContext.tsx +0 -58
- package/table/src/contexts/TableHeaderContext.ts +0 -6
- package/table/src/contexts/TableMetadataContext.ts +0 -21
- package/table/src/contexts/TableScrollContext.ts +0 -8
- package/table/src/contexts/TableStateContext.ts +0 -9
- package/table/src/createReactTable.ts +0 -371
- package/table/src/defaultRenderTableElements.tsx +0 -19
- package/table/src/hooks/useColumnResize.ts +0 -242
- package/table/src/hooks/useTableActions.ts +0 -1394
- package/table/src/hooks/useTableActionsContext.ts +0 -12
- package/table/src/hooks/useTableCell.ts +0 -223
- package/table/src/hooks/useTableCellToolbarActions.tsx +0 -694
- package/table/src/hooks/useTableMetadata.ts +0 -12
- package/table/src/hooks/useTableStateContext.ts +0 -12
- package/table/src/hooks/useTableStates.ts +0 -14
- package/table/src/typings.ts +0 -107
- package/table/src/utils/helper.ts +0 -1106
- package/table/toolbar/src/TableToolbarIcon.tsx +0 -17
- package/table/toolbar/src/useTableTool.ts +0 -14
- package/table/toolbar/tsconfig.build.json +0 -5
- package/table/tsconfig.build.json +0 -5
- package/toggle-mark/jsx-serializer/src/createJsxSerializeToggleMarkCreator.ts +0 -12
- package/toggle-mark/jsx-serializer/src/index.ts +0 -6
- package/toggle-mark/jsx-serializer/src/typings.ts +0 -3
- package/toggle-mark/jsx-serializer/tsconfig.build.json +0 -5
- package/toggle-mark/src/createReactToggleMarkCreator.ts +0 -33
- package/toggle-mark/src/index.ts +0 -6
- package/toggle-mark/src/typings.ts +0 -24
- package/toggle-mark/toolbar/src/ToggleMarkToolbarIcon.tsx +0 -17
- package/toggle-mark/toolbar/src/useToggleMarkTool.ts +0 -11
- package/toggle-mark/toolbar/tsconfig.build.json +0 -5
- package/toggle-mark/tsconfig.build.json +0 -5
- package/toolbar/src/components/InlineToolbar.tsx +0 -81
- package/toolbar/src/components/Toolbar.tsx +0 -243
- package/toolbar/src/components/ToolbarGroupIcon.tsx +0 -131
- package/toolbar/src/components/ToolbarIcon.tsx +0 -84
- package/toolbar/src/components/ToolbarInput.tsx +0 -66
- package/toolbar/src/components/toolbarIconName.ts +0 -125
- package/toolbar/src/constants.tsx +0 -6
- package/toolbar/src/contexts/StartToolInputContext.ts +0 -4
- package/toolbar/src/contexts/toolbar.ts +0 -14
- package/toolbar/src/contexts/toolbarMenu.ts +0 -15
- package/toolbar/src/hooks/useAutoGroupIcons.tsx +0 -98
- package/toolbar/src/hooks/useStartToolInput.ts +0 -6
- package/toolbar/src/index.ts +0 -7
- package/toolbar/src/typings.ts +0 -8
- package/toolbar/tsconfig.build.json +0 -5
- package/tsconfig.build.json +0 -8
- package/underline/jsx-serializer/src/createJsxSerializeUnderline.ts +0 -8
- package/underline/jsx-serializer/tsconfig.build.json +0 -5
- package/underline/src/constants.ts +0 -6
- package/underline/src/createReactUnderline.ts +0 -11
- package/underline/src/defaultRenderUnderline.tsx +0 -12
- package/underline/src/typings.ts +0 -6
- package/underline/tsconfig.build.json +0 -5
- package/utils/src/composeRefs.ts +0 -34
- package/utils/src/removePreviousElement.ts +0 -62
- package/utils/src/upload.ts +0 -83
- package/utils/src/useClickAway.ts +0 -34
- package/utils/src/useDocumentEvents.ts +0 -35
- package/utils/src/useIsomorphicLayoutEffect.ts +0 -8
- package/utils/src/usePreviousValue.ts +0 -11
- package/utils/tsconfig.build.json +0 -5
- /package/_internal/{src/index.ts → index.d.ts} +0 -0
- /package/accordion/{src/accordion.scss → accordion.scss} +0 -0
- /package/accordion/{src/index.ts → index.d.ts} +0 -0
- /package/accordion/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/align/{src/index.ts → index.d.ts} +0 -0
- /package/blockquote/{src/blockquote.scss → blockquote.scss} +0 -0
- /package/blockquote/{src/index.ts → index.d.ts} +0 -0
- /package/blockquote/jsx-serializer/{src/defaultRenderBlockquoteElement.ts → defaultRenderBlockquoteElement.d.ts} +0 -0
- /package/blockquote/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/blockquote/toolbar/{src/index.ts → index.d.ts} +0 -0
- /package/bold/{src/index.ts → index.d.ts} +0 -0
- /package/bold/jsx-serializer/{src/defaultRenderBold.ts → defaultRenderBold.d.ts} +0 -0
- /package/bold/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/card/{src/card.scss → card.scss} +0 -0
- /package/card/{src/index.ts → index.d.ts} +0 -0
- /package/card/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/card/toolbar/{src/index.ts → index.d.ts} +0 -0
- /package/carousel/{src/carousel.scss → carousel.scss} +0 -0
- /package/carousel/{src/index.ts → index.d.ts} +0 -0
- /package/carousel/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/carousel/toolbar/{src/index.ts → index.d.ts} +0 -0
- /package/components/{src/BaseField/baseField.scss → baseField.scss} +0 -0
- /package/components/{src/Button/button.scss → button.scss} +0 -0
- /package/components/{src/components.scss → components.scss} +0 -0
- /package/components/{src/Hint/hint.scss → hint.scss} +0 -0
- /package/components/{src/ImageUploader/imageUploader.scss → imageUploader.scss} +0 -0
- /package/components/{src/Input/input.scss → input.scss} +0 -0
- /package/components/{src/Message/message.scss → message.scss} +0 -0
- /package/components/{src/Modal/modal.scss → modal.scss} +0 -0
- /package/components/{src/Progress/progress.scss → progress.scss} +0 -0
- /package/components/{src/SegmentedControl/segmentedControl.scss → segmentedControl.scss} +0 -0
- /package/components/{src/Textarea/textarea.scss → textarea.scss} +0 -0
- /package/components/{src/Toggle/toggle.scss → toggle.scss} +0 -0
- /package/components/{src/Tooltip/tooltip.scss → tooltip.scss} +0 -0
- /package/configs/{src/index.ts → index.d.ts} +0 -0
- /package/divider/{src/divider.scss → divider.scss} +0 -0
- /package/divider/{src/index.ts → index.d.ts} +0 -0
- /package/divider/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/{src/core/components/editable.scss → editable.scss} +0 -0
- /package/embed/{src/embed.scss → embed.scss} +0 -0
- /package/embed/{src/index.ts → index.d.ts} +0 -0
- /package/embed/jsx-serializer/facebook/{src/index.ts → index.d.ts} +0 -0
- /package/embed/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/embed/jsx-serializer/instagram/{src/index.ts → index.d.ts} +0 -0
- /package/embed/jsx-serializer/twitter/{src/index.ts → index.d.ts} +0 -0
- /package/embed/jsx-serializer/vimeo/{src/index.ts → index.d.ts} +0 -0
- /package/embed/jsx-serializer/youtube/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/facebook/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/instagram/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/podcast-apple/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/spotify/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/twitter/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/vimeo/{src/index.ts → index.d.ts} +0 -0
- /package/embed/renderers/youtube/{src/index.ts → index.d.ts} +0 -0
- /package/file-uploader/{src/components/file-uploader.scss → file-uploader.scss} +0 -0
- /package/file-uploader/{src/index.ts → index.d.ts} +0 -0
- /package/footnote/{src/index.ts → index.d.ts} +0 -0
- /package/footnote/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/heading/{src/heading.scss → heading.scss} +0 -0
- /package/heading/{src/index.ts → index.d.ts} +0 -0
- /package/heading/jsx-serializer/{src/defaultRenderHeadingElement.ts → defaultRenderHeadingElement.d.ts} +0 -0
- /package/heading/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/highlight/{src/index.ts → index.d.ts} +0 -0
- /package/highlight/jsx-serializer/{src/defaultRenderHighlight.ts → defaultRenderHighlight.d.ts} +0 -0
- /package/highlight/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/image/{src/components/image.scss → image.scss} +0 -0
- /package/image/{src/index.ts → index.d.ts} +0 -0
- /package/image/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/input-block/{src/index.ts → index.d.ts} +0 -0
- /package/input-block/{src/input-block.scss → input-block.scss} +0 -0
- /package/italic/{src/index.ts → index.d.ts} +0 -0
- /package/italic/jsx-serializer/{src/defaultRenderItalic.ts → defaultRenderItalic.d.ts} +0 -0
- /package/italic/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/line-break/{src/index.ts → index.d.ts} +0 -0
- /package/line-break/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/line-break/{src/line-break.scss → line-break.scss} +0 -0
- /package/link/{src/index.ts → index.d.ts} +0 -0
- /package/link/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/list/{src/index.ts → index.d.ts} +0 -0
- /package/list/jsx-serializer/{src/defaultRenderListElements.ts → defaultRenderListElements.d.ts} +0 -0
- /package/list/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/list/{src/list.scss → list.scss} +0 -0
- /package/paragraph/{src/index.ts → index.d.ts} +0 -0
- /package/paragraph/jsx-serializer/{src/defaultRenderParagraphElement.ts → defaultRenderParagraphElement.d.ts} +0 -0
- /package/paragraph/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/paragraph/{src/paragraph.scss → paragraph.scss} +0 -0
- /package/paragraph/toolbar/{src/index.ts → index.d.ts} +0 -0
- /package/read-more/{src/index.ts → index.d.ts} +0 -0
- /package/read-more/jsx-serializer/{src/defaultRenderReadMoreElement.ts → defaultRenderReadMoreElement.d.ts} +0 -0
- /package/read-more/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/read-more/{src/components/read-more.scss → read-more.scss} +0 -0
- /package/strikethrough/{src/index.ts → index.d.ts} +0 -0
- /package/strikethrough/jsx-serializer/{src/defaultRenderStrikethrough.ts → defaultRenderStrikethrough.d.ts} +0 -0
- /package/strikethrough/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/table/{src/index.ts → index.d.ts} +0 -0
- /package/table/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/table/{src/table.scss → table.scss} +0 -0
- /package/table/toolbar/{src/index.ts → index.d.ts} +0 -0
- /package/toggle-mark/toolbar/{src/index.ts → index.d.ts} +0 -0
- /package/toolbar/{src/components/toolbar.scss → toolbar.scss} +0 -0
- /package/underline/{src/index.ts → index.d.ts} +0 -0
- /package/underline/jsx-serializer/{src/defaultRenderUnderline.ts → defaultRenderUnderline.d.ts} +0 -0
- /package/underline/jsx-serializer/{src/index.ts → index.d.ts} +0 -0
- /package/utils/{src/index.ts → index.d.ts} +0 -0
|
@@ -1,1394 +0,0 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
import { Element, Transforms, Editor } from '@quadrats/core';
|
|
3
|
-
import { ReactEditor } from 'slate-react';
|
|
4
|
-
import { RenderTableElementProps, TableContextType } from '../typings';
|
|
5
|
-
import {
|
|
6
|
-
TABLE_CELL_TYPE,
|
|
7
|
-
TABLE_HEADER_TYPE,
|
|
8
|
-
TABLE_DEFAULT_MAX_COLUMNS,
|
|
9
|
-
TABLE_ROW_TYPE,
|
|
10
|
-
TableElement,
|
|
11
|
-
} from '@quadrats/common/table';
|
|
12
|
-
import { useQuadrats } from '@quadrats/react';
|
|
13
|
-
import {
|
|
14
|
-
getTableStructure,
|
|
15
|
-
createTableCell,
|
|
16
|
-
getReferenceRowFromHeaderOrBody,
|
|
17
|
-
hasAnyPinnedRows,
|
|
18
|
-
hasAnyPinnedColumns,
|
|
19
|
-
getColumnWidths,
|
|
20
|
-
calculateColumnWidthsAfterAdd,
|
|
21
|
-
calculateColumnWidthsAfterDelete,
|
|
22
|
-
setColumnWidths,
|
|
23
|
-
moveOrSwapColumnWidth,
|
|
24
|
-
convertToMixedWidthMode,
|
|
25
|
-
convertToPercentageMode,
|
|
26
|
-
getPinnedColumnsInfo,
|
|
27
|
-
} from '../utils/helper';
|
|
28
|
-
|
|
29
|
-
export function useTableActions(element: RenderTableElementProps['element']) {
|
|
30
|
-
const editor = useQuadrats();
|
|
31
|
-
|
|
32
|
-
const isColumnPinned: TableContextType['isColumnPinned'] = useCallback(
|
|
33
|
-
(columnIndex) => {
|
|
34
|
-
try {
|
|
35
|
-
const tableStructure = getTableStructure(editor, element);
|
|
36
|
-
|
|
37
|
-
if (!tableStructure) return false;
|
|
38
|
-
|
|
39
|
-
const { tableMainElement } = tableStructure;
|
|
40
|
-
|
|
41
|
-
if (!tableMainElement) return false;
|
|
42
|
-
|
|
43
|
-
for (const container of tableMainElement.children) {
|
|
44
|
-
if (!Element.isElement(container)) continue;
|
|
45
|
-
|
|
46
|
-
for (const row of container.children) {
|
|
47
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
48
|
-
const cell = row.children[columnIndex];
|
|
49
|
-
|
|
50
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
51
|
-
// 如果有任何一個 cell 沒有 pinned 屬性,則整個 column 不算 pinned
|
|
52
|
-
if (!cell.pinned) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return true;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[element, editor],
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const isRowPinned: TableContextType['isRowPinned'] = useCallback(
|
|
69
|
-
(rowIndex) => {
|
|
70
|
-
try {
|
|
71
|
-
const tableStructure = getTableStructure(editor, element);
|
|
72
|
-
|
|
73
|
-
if (!tableStructure) return false;
|
|
74
|
-
|
|
75
|
-
const { tableHeaderElement, tableBodyElement } = tableStructure;
|
|
76
|
-
|
|
77
|
-
const headerRowCount =
|
|
78
|
-
tableHeaderElement && Element.isElement(tableHeaderElement) ? tableHeaderElement.children.length : 0;
|
|
79
|
-
|
|
80
|
-
let targetRow: TableElement | undefined;
|
|
81
|
-
|
|
82
|
-
if (rowIndex < headerRowCount && tableHeaderElement && Element.isElement(tableHeaderElement)) {
|
|
83
|
-
// 在 Header 中
|
|
84
|
-
const rowElement = tableHeaderElement.children[rowIndex];
|
|
85
|
-
|
|
86
|
-
if (Element.isElement(rowElement)) {
|
|
87
|
-
targetRow = rowElement as TableElement;
|
|
88
|
-
}
|
|
89
|
-
} else if (tableBodyElement && Element.isElement(tableBodyElement)) {
|
|
90
|
-
// 在 Body 中
|
|
91
|
-
const bodyRowIndex = rowIndex - headerRowCount;
|
|
92
|
-
const rowElement = tableBodyElement.children[bodyRowIndex];
|
|
93
|
-
|
|
94
|
-
if (Element.isElement(rowElement)) {
|
|
95
|
-
targetRow = rowElement as TableElement;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (!Element.isElement(targetRow) || !targetRow.type.includes(TABLE_ROW_TYPE)) {
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// 檢查所有 cell 是否都有 pinned 屬性
|
|
104
|
-
for (const cell of targetRow.children) {
|
|
105
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
106
|
-
if (!(cell as TableElement).pinned) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return true;
|
|
113
|
-
} catch (error) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
[element, editor],
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const addColumn: TableContextType['addColumn'] = useCallback(
|
|
121
|
-
(options = {}) => {
|
|
122
|
-
const { position = 'right', columnIndex } = options;
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
const tableStructure = getTableStructure(editor, element);
|
|
126
|
-
|
|
127
|
-
if (!tableStructure) return;
|
|
128
|
-
|
|
129
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath, tableBodyPath, columnCount } = tableStructure;
|
|
130
|
-
|
|
131
|
-
if (columnCount >= TABLE_DEFAULT_MAX_COLUMNS) {
|
|
132
|
-
console.warn(`Maximum columns limit (${TABLE_DEFAULT_MAX_COLUMNS}) reached`);
|
|
133
|
-
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// 計算插入位置
|
|
138
|
-
let insertIndex: number;
|
|
139
|
-
|
|
140
|
-
if (typeof columnIndex === 'number') {
|
|
141
|
-
insertIndex = position === 'left' ? Math.max(0, columnIndex) : Math.min(columnCount, columnIndex + 1);
|
|
142
|
-
} else {
|
|
143
|
-
insertIndex = columnCount;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// 使用 Editor.withoutNormalizing 來批次執行所有操作
|
|
147
|
-
Editor.withoutNormalizing(editor, () => {
|
|
148
|
-
// 在 Header 中加入 cell
|
|
149
|
-
if (tableHeaderElement && tableHeaderPath) {
|
|
150
|
-
tableHeaderElement.children.forEach((row, rowIndex) => {
|
|
151
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
152
|
-
const referenceCell = row.children[insertIndex - (position === 'left' ? 0 : 1)] as TableElement;
|
|
153
|
-
const newCell = createTableCell(referenceCell);
|
|
154
|
-
const cellPath = [...tableHeaderPath, rowIndex, insertIndex];
|
|
155
|
-
|
|
156
|
-
Transforms.insertNodes(editor, newCell, { at: cellPath });
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// 在 Body 中加入 cell
|
|
162
|
-
tableBodyElement!.children.forEach((row, rowIndex) => {
|
|
163
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
164
|
-
const referenceCell = row.children[insertIndex - (position === 'left' ? 0 : 1)] as TableElement;
|
|
165
|
-
const newCell = createTableCell(referenceCell);
|
|
166
|
-
const cellPath = [...tableBodyPath, rowIndex, insertIndex];
|
|
167
|
-
|
|
168
|
-
Transforms.insertNodes(editor, newCell, { at: cellPath });
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// 調整欄位寬度
|
|
173
|
-
const currentWidths = getColumnWidths(element);
|
|
174
|
-
|
|
175
|
-
if (currentWidths.length > 0) {
|
|
176
|
-
// 獲取當前的 pinned columns 資訊
|
|
177
|
-
const { pinnedColumnIndices } = getPinnedColumnsInfo(element);
|
|
178
|
-
const newWidths = calculateColumnWidthsAfterAdd(
|
|
179
|
-
currentWidths,
|
|
180
|
-
insertIndex,
|
|
181
|
-
pinnedColumnIndices,
|
|
182
|
-
columnIndex,
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
setColumnWidths(editor, element, newWidths);
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
} catch (error) {
|
|
189
|
-
console.warn('Failed to add column:', error);
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
[editor, element],
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
const addRow: TableContextType['addRow'] = useCallback(
|
|
196
|
-
(options = {}) => {
|
|
197
|
-
const { position = 'bottom', rowIndex } = options;
|
|
198
|
-
|
|
199
|
-
try {
|
|
200
|
-
const tableStructure = getTableStructure(editor, element);
|
|
201
|
-
|
|
202
|
-
if (!tableStructure) return;
|
|
203
|
-
|
|
204
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath, tableBodyPath, headerRowCount, columnCount } =
|
|
205
|
-
tableStructure;
|
|
206
|
-
|
|
207
|
-
// 計算插入位置和參考行
|
|
208
|
-
let insertIndex: number;
|
|
209
|
-
let referenceRowElement: Element | undefined;
|
|
210
|
-
let targetPath: number[];
|
|
211
|
-
|
|
212
|
-
if (typeof rowIndex === 'number') {
|
|
213
|
-
// 檢查是在 Header / Body 之中
|
|
214
|
-
if (tableHeaderElement && rowIndex < headerRowCount) {
|
|
215
|
-
targetPath = tableHeaderPath!;
|
|
216
|
-
|
|
217
|
-
if (position === 'top') {
|
|
218
|
-
insertIndex = Math.max(0, rowIndex);
|
|
219
|
-
referenceRowElement = getReferenceRowFromHeaderOrBody(tableHeaderElement, insertIndex);
|
|
220
|
-
} else {
|
|
221
|
-
insertIndex = Math.min(headerRowCount, rowIndex + 1);
|
|
222
|
-
referenceRowElement = getReferenceRowFromHeaderOrBody(tableHeaderElement, rowIndex);
|
|
223
|
-
}
|
|
224
|
-
} else {
|
|
225
|
-
targetPath = tableBodyPath;
|
|
226
|
-
const bodyRowIndex = rowIndex - headerRowCount;
|
|
227
|
-
|
|
228
|
-
if (position === 'top') {
|
|
229
|
-
insertIndex = Math.max(0, bodyRowIndex);
|
|
230
|
-
referenceRowElement = getReferenceRowFromHeaderOrBody(tableBodyElement!, insertIndex);
|
|
231
|
-
} else {
|
|
232
|
-
insertIndex = Math.min(tableBodyElement!.children.length, bodyRowIndex + 1);
|
|
233
|
-
referenceRowElement = getReferenceRowFromHeaderOrBody(tableBodyElement!, bodyRowIndex);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
} else {
|
|
237
|
-
// 預設:在 Body 尾端加入列
|
|
238
|
-
targetPath = tableBodyPath;
|
|
239
|
-
insertIndex = tableBodyElement!.children.length;
|
|
240
|
-
referenceRowElement = getReferenceRowFromHeaderOrBody(tableBodyElement!, insertIndex - 1);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// 創建新行
|
|
244
|
-
const newRow: TableElement = {
|
|
245
|
-
type: TABLE_ROW_TYPE,
|
|
246
|
-
children: Array.from({ length: columnCount }, (_, cellIndex) => {
|
|
247
|
-
let referenceCell: TableElement | undefined;
|
|
248
|
-
|
|
249
|
-
if (referenceRowElement && referenceRowElement.children[cellIndex]) {
|
|
250
|
-
const cell = referenceRowElement.children[cellIndex];
|
|
251
|
-
|
|
252
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
253
|
-
referenceCell = cell as TableElement;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return createTableCell(referenceCell);
|
|
258
|
-
}),
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// 插入新行
|
|
262
|
-
const newRowPath = [...targetPath, insertIndex];
|
|
263
|
-
|
|
264
|
-
Transforms.insertNodes(editor, newRow, { at: newRowPath });
|
|
265
|
-
} catch (error) {
|
|
266
|
-
console.warn('Failed to add row:', error);
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
[editor, element],
|
|
270
|
-
);
|
|
271
|
-
|
|
272
|
-
const addColumnAndRow: TableContextType['addColumnAndRow'] = useCallback(() => {
|
|
273
|
-
try {
|
|
274
|
-
const tableStructure = getTableStructure(editor, element);
|
|
275
|
-
|
|
276
|
-
if (!tableStructure) return;
|
|
277
|
-
|
|
278
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath, tableBodyPath, columnCount } = tableStructure;
|
|
279
|
-
|
|
280
|
-
if (columnCount >= TABLE_DEFAULT_MAX_COLUMNS) {
|
|
281
|
-
console.warn(`Maximum columns limit (${TABLE_DEFAULT_MAX_COLUMNS}) reached`);
|
|
282
|
-
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
Editor.withoutNormalizing(editor, () => {
|
|
287
|
-
// 在 Header 中加入新列
|
|
288
|
-
if (tableHeaderElement && tableHeaderPath) {
|
|
289
|
-
tableHeaderElement.children.forEach((row, rowIndex) => {
|
|
290
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
291
|
-
const lastCell = row.children[row.children.length - 1] as TableElement;
|
|
292
|
-
const newHeaderCell = createTableCell(lastCell);
|
|
293
|
-
|
|
294
|
-
const cellPath = [...tableHeaderPath, rowIndex, row.children.length];
|
|
295
|
-
|
|
296
|
-
Transforms.insertNodes(editor, newHeaderCell, { at: cellPath });
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// 在 Body 中加入新列
|
|
302
|
-
tableBodyElement!.children.forEach((row, rowIndex) => {
|
|
303
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
304
|
-
const lastCell = row.children[row.children.length - 1] as TableElement;
|
|
305
|
-
const newCell = createTableCell(lastCell);
|
|
306
|
-
|
|
307
|
-
const cellPath = [...tableBodyPath, rowIndex, row.children.length];
|
|
308
|
-
|
|
309
|
-
Transforms.insertNodes(editor, newCell, { at: cellPath });
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
// 加入新行
|
|
314
|
-
const newColumnCount = columnCount + 1;
|
|
315
|
-
const lastRow = getReferenceRowFromHeaderOrBody(tableBodyElement!, tableBodyElement!.children.length - 1);
|
|
316
|
-
|
|
317
|
-
const newRow: TableElement = {
|
|
318
|
-
type: TABLE_ROW_TYPE,
|
|
319
|
-
children: Array.from({ length: newColumnCount }, (_, cellIndex) => {
|
|
320
|
-
let referenceCell: TableElement | undefined;
|
|
321
|
-
|
|
322
|
-
if (cellIndex < newColumnCount - 1 && Element.isElement(lastRow) && lastRow.type.includes(TABLE_ROW_TYPE)) {
|
|
323
|
-
const cell = lastRow.children[cellIndex];
|
|
324
|
-
|
|
325
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
326
|
-
referenceCell = cell as TableElement;
|
|
327
|
-
}
|
|
328
|
-
} else {
|
|
329
|
-
if (Element.isElement(lastRow) && lastRow.type.includes(TABLE_ROW_TYPE)) {
|
|
330
|
-
const cell = lastRow.children[lastRow.children.length - 1];
|
|
331
|
-
|
|
332
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
333
|
-
referenceCell = cell as TableElement;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return createTableCell(referenceCell);
|
|
339
|
-
}),
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
const newRowPath = [...tableBodyPath, tableBodyElement!.children.length];
|
|
343
|
-
|
|
344
|
-
Transforms.insertNodes(editor, newRow, { at: newRowPath });
|
|
345
|
-
|
|
346
|
-
// 調整欄位寬度(新增欄位在最後)
|
|
347
|
-
const currentWidths = getColumnWidths(element);
|
|
348
|
-
|
|
349
|
-
if (currentWidths.length > 0) {
|
|
350
|
-
// 新欄位插入在最後(columnCount 位置)
|
|
351
|
-
const insertIndex = columnCount;
|
|
352
|
-
// 獲取當前的 pinned columns 資訊
|
|
353
|
-
const { pinnedColumnIndices } = getPinnedColumnsInfo(element);
|
|
354
|
-
const newWidths = calculateColumnWidthsAfterAdd(currentWidths, insertIndex, pinnedColumnIndices);
|
|
355
|
-
|
|
356
|
-
setColumnWidths(editor, element, newWidths);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
} catch (error) {
|
|
360
|
-
console.warn('Failed to add column and row:', error);
|
|
361
|
-
}
|
|
362
|
-
}, [editor, element]);
|
|
363
|
-
|
|
364
|
-
const deleteRow: TableContextType['deleteRow'] = useCallback(
|
|
365
|
-
(rowIndex) => {
|
|
366
|
-
try {
|
|
367
|
-
const tableStructure = getTableStructure(editor, element);
|
|
368
|
-
|
|
369
|
-
if (!tableStructure) return;
|
|
370
|
-
|
|
371
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath, tableBodyPath, headerRowCount } = tableStructure;
|
|
372
|
-
|
|
373
|
-
// 檢查是否刪除 Header 行
|
|
374
|
-
if (rowIndex < headerRowCount) {
|
|
375
|
-
if (!tableHeaderElement || !tableHeaderPath) return;
|
|
376
|
-
|
|
377
|
-
const headerRowPath = [...tableHeaderPath, rowIndex];
|
|
378
|
-
|
|
379
|
-
Transforms.removeNodes(editor, { at: headerRowPath });
|
|
380
|
-
|
|
381
|
-
// 如果是最後一個 header 行,移除整個 header 元素
|
|
382
|
-
if (headerRowCount <= 1) {
|
|
383
|
-
Transforms.removeNodes(editor, { at: tableHeaderPath });
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// 刪除 Body 行
|
|
390
|
-
const bodyRowIndex = rowIndex - headerRowCount;
|
|
391
|
-
|
|
392
|
-
if (bodyRowIndex < 0 || bodyRowIndex >= tableBodyElement!.children.length) {
|
|
393
|
-
console.warn('Invalid row index for deletion');
|
|
394
|
-
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (tableBodyElement!.children.length <= 1) {
|
|
399
|
-
console.warn('Cannot delete the last row');
|
|
400
|
-
|
|
401
|
-
return;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
const rowPath = [...tableBodyPath, bodyRowIndex];
|
|
405
|
-
|
|
406
|
-
Transforms.removeNodes(editor, { at: rowPath });
|
|
407
|
-
} catch (error) {
|
|
408
|
-
console.warn('Failed to delete row:', error);
|
|
409
|
-
}
|
|
410
|
-
},
|
|
411
|
-
[editor, element],
|
|
412
|
-
);
|
|
413
|
-
|
|
414
|
-
const deleteColumn: TableContextType['deleteColumn'] = useCallback(
|
|
415
|
-
(columnIndex) => {
|
|
416
|
-
try {
|
|
417
|
-
const tableStructure = getTableStructure(editor, element);
|
|
418
|
-
|
|
419
|
-
if (!tableStructure) return;
|
|
420
|
-
|
|
421
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath, tableBodyPath, columnCount } = tableStructure;
|
|
422
|
-
|
|
423
|
-
// 檢查是否有足夠的列(不允許刪除最後一列)
|
|
424
|
-
if (columnCount <= 1) {
|
|
425
|
-
console.warn('Cannot delete the last column');
|
|
426
|
-
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
// 檢查 columnIndex 是否有效
|
|
431
|
-
if (columnIndex < 0 || columnIndex >= columnCount) {
|
|
432
|
-
console.warn('Invalid column index for deletion');
|
|
433
|
-
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
editor.withoutNormalizing(() => {
|
|
438
|
-
// 從 Header 中刪除列
|
|
439
|
-
if (tableHeaderElement && tableHeaderPath) {
|
|
440
|
-
// 以反向順序刪除
|
|
441
|
-
for (let rowIndex = tableHeaderElement.children.length - 1; rowIndex >= 0; rowIndex--) {
|
|
442
|
-
const headerRow = tableHeaderElement.children[rowIndex];
|
|
443
|
-
|
|
444
|
-
if (Element.isElement(headerRow) && headerRow.type.includes(TABLE_ROW_TYPE)) {
|
|
445
|
-
const headerCellPath = [...tableHeaderPath, rowIndex, columnIndex];
|
|
446
|
-
|
|
447
|
-
Transforms.removeNodes(editor, { at: headerCellPath });
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// 從 Body 中刪除列
|
|
453
|
-
for (let rowIndex = tableBodyElement!.children.length - 1; rowIndex >= 0; rowIndex--) {
|
|
454
|
-
const row = tableBodyElement!.children[rowIndex];
|
|
455
|
-
|
|
456
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
457
|
-
const cellPath = [...tableBodyPath, rowIndex, columnIndex];
|
|
458
|
-
|
|
459
|
-
Transforms.removeNodes(editor, { at: cellPath });
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// 調整欄位寬度
|
|
464
|
-
const currentWidths = getColumnWidths(element);
|
|
465
|
-
|
|
466
|
-
if (currentWidths.length > 0) {
|
|
467
|
-
const newWidths = calculateColumnWidthsAfterDelete(currentWidths, columnIndex);
|
|
468
|
-
|
|
469
|
-
setColumnWidths(editor, element, newWidths);
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
} catch (error) {
|
|
473
|
-
console.warn('Failed to delete column:', error);
|
|
474
|
-
}
|
|
475
|
-
},
|
|
476
|
-
[editor, element],
|
|
477
|
-
);
|
|
478
|
-
|
|
479
|
-
const moveRowToBody: TableContextType['moveRowToBody'] = useCallback(
|
|
480
|
-
(rowIndex: number) => {
|
|
481
|
-
try {
|
|
482
|
-
const tableStructure = getTableStructure(editor, element);
|
|
483
|
-
|
|
484
|
-
if (!tableStructure) return;
|
|
485
|
-
|
|
486
|
-
const { tableHeaderElement, tableHeaderPath, tableBodyPath } = tableStructure;
|
|
487
|
-
|
|
488
|
-
if (!tableHeaderElement || !tableHeaderPath) return;
|
|
489
|
-
|
|
490
|
-
// 檢查行是否存在於 header 中
|
|
491
|
-
if (rowIndex >= tableHeaderElement.children.length) {
|
|
492
|
-
console.warn('Invalid header row index:', rowIndex);
|
|
493
|
-
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
const rowToMove = tableHeaderElement.children[rowIndex];
|
|
498
|
-
|
|
499
|
-
if (!Element.isElement(rowToMove) || !rowToMove.type.includes(TABLE_ROW_TYPE)) return;
|
|
500
|
-
|
|
501
|
-
const rowPath = [...tableHeaderPath, rowIndex];
|
|
502
|
-
|
|
503
|
-
// 移動前移除所有 cell 的 pinned 屬性
|
|
504
|
-
rowToMove.children.forEach((cell, columnIndex) => {
|
|
505
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE) && (cell as TableElement).pinned) {
|
|
506
|
-
if (cell.pinned && isColumnPinned(columnIndex)) {
|
|
507
|
-
const cellPath = [...rowPath, columnIndex];
|
|
508
|
-
|
|
509
|
-
Transforms.unsetNodes(editor, 'pinned', { at: cellPath });
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
|
|
514
|
-
// 移動行到 body 的開始位置
|
|
515
|
-
const bodyTargetPath = [...tableBodyPath, 0];
|
|
516
|
-
|
|
517
|
-
Transforms.moveNodes(editor, {
|
|
518
|
-
at: rowPath,
|
|
519
|
-
to: bodyTargetPath,
|
|
520
|
-
});
|
|
521
|
-
} catch (error) {
|
|
522
|
-
console.warn('Failed to move row to body:', error);
|
|
523
|
-
}
|
|
524
|
-
},
|
|
525
|
-
[editor, element, isColumnPinned],
|
|
526
|
-
);
|
|
527
|
-
|
|
528
|
-
const moveRowToHeader: TableContextType['moveRowToHeader'] = useCallback(
|
|
529
|
-
(rowIndex: number, customProps?: Pick<TableElement, 'pinned'>) => {
|
|
530
|
-
try {
|
|
531
|
-
const tableStructure = getTableStructure(editor, element);
|
|
532
|
-
|
|
533
|
-
if (!tableStructure) return;
|
|
534
|
-
|
|
535
|
-
const { tableHeaderElement, tableBodyElement, tableMainPath, tableHeaderPath, tableBodyPath, headerRowCount } =
|
|
536
|
-
tableStructure;
|
|
537
|
-
|
|
538
|
-
// 計算正確的 body 行索引
|
|
539
|
-
const bodyRowIndex = rowIndex - headerRowCount;
|
|
540
|
-
|
|
541
|
-
// 檢查 body 行索引是否有效
|
|
542
|
-
if (bodyRowIndex < 0 || bodyRowIndex >= tableBodyElement!.children.length) {
|
|
543
|
-
console.warn('Invalid body row index:', bodyRowIndex);
|
|
544
|
-
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// 檢查行是否存在
|
|
549
|
-
const rowToMove = tableBodyElement!.children[bodyRowIndex];
|
|
550
|
-
|
|
551
|
-
if (!Element.isElement(rowToMove) || !rowToMove.type.includes(TABLE_ROW_TYPE)) return;
|
|
552
|
-
|
|
553
|
-
// 檢查 header 中是否已有 pinned rows(一致性規則檢查)
|
|
554
|
-
const hasExistingPinnedRows = tableStructure ? hasAnyPinnedRows(tableStructure) : false;
|
|
555
|
-
|
|
556
|
-
// 如果有現有的 pinned rows 且沒有提供自定義屬性,自動設置 pinned 以保持一致性
|
|
557
|
-
const finalProps = customProps || (hasExistingPinnedRows ? { pinned: true } : undefined);
|
|
558
|
-
|
|
559
|
-
// 如果提供了 finalProps,則應用到 cells
|
|
560
|
-
const processedRow = finalProps
|
|
561
|
-
? {
|
|
562
|
-
...rowToMove,
|
|
563
|
-
children: rowToMove.children.map((cell) => {
|
|
564
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
565
|
-
return {
|
|
566
|
-
...cell,
|
|
567
|
-
...finalProps,
|
|
568
|
-
} as TableElement;
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
return cell;
|
|
572
|
-
}),
|
|
573
|
-
}
|
|
574
|
-
: rowToMove;
|
|
575
|
-
|
|
576
|
-
const rowPath = [...tableBodyPath, bodyRowIndex];
|
|
577
|
-
|
|
578
|
-
// 如果 header 不存在,先創建它
|
|
579
|
-
if (!tableHeaderElement) {
|
|
580
|
-
const newHeader = {
|
|
581
|
-
type: TABLE_HEADER_TYPE,
|
|
582
|
-
children: [processedRow],
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
const headerInsertPath = [...tableMainPath, 0];
|
|
586
|
-
|
|
587
|
-
Editor.withoutNormalizing(editor, () => {
|
|
588
|
-
Transforms.removeNodes(editor, { at: rowPath });
|
|
589
|
-
Transforms.insertNodes(editor, newHeader, { at: headerInsertPath });
|
|
590
|
-
});
|
|
591
|
-
} else {
|
|
592
|
-
// 如果這是 pinned row,找到正確的插入位置(pinned rows 在頂部)
|
|
593
|
-
let headerTargetPath: number[];
|
|
594
|
-
|
|
595
|
-
if (finalProps?.pinned) {
|
|
596
|
-
let insertIndex = 0;
|
|
597
|
-
|
|
598
|
-
for (const [index, headerRow] of tableHeaderElement.children.entries()) {
|
|
599
|
-
if (Element.isElement(headerRow)) {
|
|
600
|
-
const hasNonPinnedCell = headerRow.children.some(
|
|
601
|
-
(cell) => Element.isElement(cell) && !(cell as TableElement).pinned,
|
|
602
|
-
);
|
|
603
|
-
|
|
604
|
-
if (hasNonPinnedCell) {
|
|
605
|
-
break;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
insertIndex = index + 1;
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
headerTargetPath = [...tableHeaderPath!, insertIndex];
|
|
613
|
-
|
|
614
|
-
Editor.withoutNormalizing(editor, () => {
|
|
615
|
-
Transforms.removeNodes(editor, { at: rowPath });
|
|
616
|
-
Transforms.insertNodes(editor, processedRow, { at: headerTargetPath });
|
|
617
|
-
});
|
|
618
|
-
} else {
|
|
619
|
-
// 移動行到現有 header 的末尾
|
|
620
|
-
headerTargetPath = [...tableHeaderPath!, tableHeaderElement.children.length];
|
|
621
|
-
Transforms.moveNodes(editor, {
|
|
622
|
-
at: rowPath,
|
|
623
|
-
to: headerTargetPath,
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
} catch (error) {
|
|
628
|
-
console.warn('Failed to move row to header:', error);
|
|
629
|
-
}
|
|
630
|
-
},
|
|
631
|
-
[editor, element],
|
|
632
|
-
);
|
|
633
|
-
|
|
634
|
-
const unsetColumnAsTitle: TableContextType['unsetColumnAsTitle'] = useCallback(
|
|
635
|
-
(columnIndex: number) => {
|
|
636
|
-
try {
|
|
637
|
-
const tableStructure = getTableStructure(editor, element);
|
|
638
|
-
|
|
639
|
-
if (!tableStructure) return;
|
|
640
|
-
|
|
641
|
-
const { tableHeaderElement, tableBodyElement, tableMainElement } = tableStructure;
|
|
642
|
-
|
|
643
|
-
// 獲取 table 的實際寬度(用於轉換為混合模式)
|
|
644
|
-
let tableWidth = 0;
|
|
645
|
-
|
|
646
|
-
if (tableMainElement) {
|
|
647
|
-
const tableDOMElement = ReactEditor.toDOMNode(editor, tableMainElement);
|
|
648
|
-
|
|
649
|
-
if (tableDOMElement instanceof HTMLElement) {
|
|
650
|
-
tableWidth = tableDOMElement.getBoundingClientRect().width;
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
const processContainer = (containerElement: TableElement) => {
|
|
655
|
-
if (!Element.isElement(containerElement)) return;
|
|
656
|
-
|
|
657
|
-
const containerPath = ReactEditor.findPath(editor, containerElement);
|
|
658
|
-
const firstRow = containerElement.children[0];
|
|
659
|
-
|
|
660
|
-
// 找到 column 標題列的尾端
|
|
661
|
-
let targetColumnIndex = 0;
|
|
662
|
-
|
|
663
|
-
if (Element.isElement(firstRow) && firstRow.type.includes(TABLE_ROW_TYPE)) {
|
|
664
|
-
for (let i = 0; i < firstRow.children.length; i++) {
|
|
665
|
-
const cell = firstRow.children[i];
|
|
666
|
-
|
|
667
|
-
if (
|
|
668
|
-
Element.isElement(cell) &&
|
|
669
|
-
cell.type.includes(TABLE_CELL_TYPE) &&
|
|
670
|
-
cell.treatAsTitle &&
|
|
671
|
-
i !== columnIndex
|
|
672
|
-
) {
|
|
673
|
-
targetColumnIndex = i + 1;
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
containerElement.children.forEach((row, rowIndex) => {
|
|
679
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
680
|
-
const cell = row.children[columnIndex];
|
|
681
|
-
|
|
682
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
683
|
-
const cellPath = [...containerPath, rowIndex, columnIndex];
|
|
684
|
-
|
|
685
|
-
Transforms.unsetNodes(editor, 'treatAsTitle', { at: cellPath });
|
|
686
|
-
|
|
687
|
-
if (cell.pinned && !isRowPinned(rowIndex)) {
|
|
688
|
-
Transforms.unsetNodes(editor, 'pinned', { at: cellPath });
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
if (columnIndex < targetColumnIndex) {
|
|
695
|
-
const actualTargetIndex = targetColumnIndex - 1;
|
|
696
|
-
|
|
697
|
-
for (let rowIndex = containerElement.children.length - 1; rowIndex >= 0; rowIndex--) {
|
|
698
|
-
const row = containerElement.children[rowIndex];
|
|
699
|
-
|
|
700
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
701
|
-
const fromPath = [...containerPath, rowIndex, columnIndex];
|
|
702
|
-
const toPath = [...containerPath, rowIndex, actualTargetIndex];
|
|
703
|
-
|
|
704
|
-
Transforms.moveNodes(editor, {
|
|
705
|
-
at: fromPath,
|
|
706
|
-
to: toPath,
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// 調整 columnWidths:將 columnIndex 的寬度移動到 actualTargetIndex
|
|
712
|
-
const currentWidths = getColumnWidths(element);
|
|
713
|
-
|
|
714
|
-
if (currentWidths.length > 0) {
|
|
715
|
-
const movedWidths = moveOrSwapColumnWidth(currentWidths, columnIndex, actualTargetIndex, 'move');
|
|
716
|
-
|
|
717
|
-
// 檢查移動後是否還有 pinned columns
|
|
718
|
-
const { pinnedColumnIndices } = getPinnedColumnsInfo(element);
|
|
719
|
-
|
|
720
|
-
// 更新釘選欄位索引(移除當前欄位,並調整其他欄位的索引)
|
|
721
|
-
const updatedPinnedIndices = pinnedColumnIndices
|
|
722
|
-
.filter((idx) => idx !== columnIndex)
|
|
723
|
-
.map((idx) => {
|
|
724
|
-
if (idx > columnIndex && idx <= actualTargetIndex) return idx - 1;
|
|
725
|
-
|
|
726
|
-
return idx;
|
|
727
|
-
})
|
|
728
|
-
.sort((a, b) => a - b);
|
|
729
|
-
|
|
730
|
-
// 如果還有 pinned columns,轉換為混合模式;否則可能轉回全 percentage 模式
|
|
731
|
-
if (updatedPinnedIndices.length > 0 && tableWidth > 0) {
|
|
732
|
-
const mixedWidths = convertToMixedWidthMode(movedWidths, updatedPinnedIndices, tableWidth);
|
|
733
|
-
|
|
734
|
-
setColumnWidths(editor, element, mixedWidths);
|
|
735
|
-
} else {
|
|
736
|
-
// 沒有 pinned columns 了,使用原本的寬度
|
|
737
|
-
setColumnWidths(editor, element, movedWidths);
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
} else {
|
|
741
|
-
// 即使沒有移動位置,也需要檢查是否需要更新寬度模式
|
|
742
|
-
const currentWidths = getColumnWidths(element);
|
|
743
|
-
|
|
744
|
-
if (currentWidths.length > 0) {
|
|
745
|
-
const { pinnedColumnIndices } = getPinnedColumnsInfo(element);
|
|
746
|
-
|
|
747
|
-
// 移除當前欄位
|
|
748
|
-
const updatedPinnedIndices = pinnedColumnIndices
|
|
749
|
-
.filter((idx) => idx !== columnIndex)
|
|
750
|
-
.sort((a, b) => a - b);
|
|
751
|
-
|
|
752
|
-
// 如果還有 pinned columns,轉換為混合模式;否則可能轉回全 percentage 模式
|
|
753
|
-
if (updatedPinnedIndices.length > 0 && tableWidth > 0) {
|
|
754
|
-
const mixedWidths = convertToMixedWidthMode(currentWidths, updatedPinnedIndices, tableWidth);
|
|
755
|
-
|
|
756
|
-
setColumnWidths(editor, element, mixedWidths);
|
|
757
|
-
}
|
|
758
|
-
// 如果沒有 pinned columns,保持原樣(可能已經是全 percentage 了)
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
if (tableHeaderElement) {
|
|
764
|
-
processContainer(tableHeaderElement);
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
if (tableBodyElement) {
|
|
768
|
-
processContainer(tableBodyElement);
|
|
769
|
-
}
|
|
770
|
-
} catch (error) {
|
|
771
|
-
console.warn('Failed to unset column as title:', error);
|
|
772
|
-
}
|
|
773
|
-
},
|
|
774
|
-
[editor, element, isRowPinned],
|
|
775
|
-
);
|
|
776
|
-
|
|
777
|
-
const setColumnAsTitle: TableContextType['setColumnAsTitle'] = useCallback(
|
|
778
|
-
(columnIndex: number, customProps?: Pick<TableElement, 'pinned'>) => {
|
|
779
|
-
try {
|
|
780
|
-
const tableStructure = getTableStructure(editor, element);
|
|
781
|
-
|
|
782
|
-
if (!tableStructure) return;
|
|
783
|
-
|
|
784
|
-
const { tableHeaderElement, tableBodyElement, tableMainElement } = tableStructure;
|
|
785
|
-
|
|
786
|
-
// 檢查是否已有 pinned columns
|
|
787
|
-
const hasExistingPinnedColumns = hasAnyPinnedColumns(tableStructure);
|
|
788
|
-
|
|
789
|
-
// 如果有現有的 pinned columns 且沒有提供自定義屬性,自動設置 pinned 以保持一致性
|
|
790
|
-
const finalProps = customProps || (hasExistingPinnedColumns ? { pinned: true } : undefined);
|
|
791
|
-
|
|
792
|
-
// 獲取 table 的實際寬度(用於轉換為混合模式)
|
|
793
|
-
let tableWidth = 0;
|
|
794
|
-
|
|
795
|
-
if (tableMainElement) {
|
|
796
|
-
const tableDOMElement = ReactEditor.toDOMNode(editor, tableMainElement);
|
|
797
|
-
|
|
798
|
-
if (tableDOMElement instanceof HTMLElement) {
|
|
799
|
-
tableWidth = tableDOMElement.getBoundingClientRect().width;
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
const processContainer = (containerElement: TableElement) => {
|
|
804
|
-
if (!Element.isElement(containerElement)) return;
|
|
805
|
-
|
|
806
|
-
const containerPath = ReactEditor.findPath(editor, containerElement);
|
|
807
|
-
const firstRow = containerElement.children[0];
|
|
808
|
-
|
|
809
|
-
// 先找到 column 標題列的尾端
|
|
810
|
-
let targetColumnIndex = 0;
|
|
811
|
-
|
|
812
|
-
if (Element.isElement(firstRow) && firstRow.type.includes(TABLE_ROW_TYPE)) {
|
|
813
|
-
for (let i = 0; i < firstRow.children.length; i++) {
|
|
814
|
-
const cell = firstRow.children[i];
|
|
815
|
-
|
|
816
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE) && cell.treatAsTitle) {
|
|
817
|
-
targetColumnIndex = i + 1;
|
|
818
|
-
} else {
|
|
819
|
-
break;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
containerElement.children.forEach((row, rowIndex) => {
|
|
825
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
826
|
-
row.children.forEach((cell, childColIndex) => {
|
|
827
|
-
const cellPath = [...containerPath, rowIndex, childColIndex];
|
|
828
|
-
|
|
829
|
-
if (childColIndex === columnIndex) {
|
|
830
|
-
const nodeProps = finalProps ? { treatAsTitle: true, ...finalProps } : { treatAsTitle: true };
|
|
831
|
-
|
|
832
|
-
Transforms.setNodes(editor, nodeProps as Partial<TableElement>, { at: cellPath });
|
|
833
|
-
} else if (finalProps?.pinned) {
|
|
834
|
-
// 確保其他 title column 也有 pinned 屬性以保持一致性
|
|
835
|
-
if (Element.isElement(cell) && cell.treatAsTitle) {
|
|
836
|
-
Transforms.setNodes(editor, { pinned: true } as Partial<TableElement>, { at: cellPath });
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
// 檢查是否需要移動位置
|
|
844
|
-
const needsMove = columnIndex >= targetColumnIndex && columnIndex !== targetColumnIndex;
|
|
845
|
-
|
|
846
|
-
if (needsMove) {
|
|
847
|
-
for (let rowIndex = containerElement.children.length - 1; rowIndex >= 0; rowIndex--) {
|
|
848
|
-
const row = containerElement.children[rowIndex];
|
|
849
|
-
|
|
850
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
851
|
-
const fromPath = [...containerPath, rowIndex, columnIndex];
|
|
852
|
-
const toPath = [...containerPath, rowIndex, targetColumnIndex];
|
|
853
|
-
|
|
854
|
-
Transforms.moveNodes(editor, {
|
|
855
|
-
at: fromPath,
|
|
856
|
-
to: toPath,
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// 調整 columnWidths:將 columnIndex 的寬度移動到 targetColumnIndex
|
|
862
|
-
const currentWidths = getColumnWidths(element);
|
|
863
|
-
|
|
864
|
-
if (currentWidths.length > 0) {
|
|
865
|
-
const movedWidths = moveOrSwapColumnWidth(currentWidths, columnIndex, targetColumnIndex, 'move');
|
|
866
|
-
|
|
867
|
-
// 如果設定了 pinned,需要轉換為混合模式
|
|
868
|
-
if (finalProps?.pinned && tableWidth > 0) {
|
|
869
|
-
const { pinnedColumnIndices } = getPinnedColumnsInfo(element);
|
|
870
|
-
|
|
871
|
-
// 更新釘選欄位索引
|
|
872
|
-
const updatedPinnedIndices = pinnedColumnIndices
|
|
873
|
-
.map((idx) => {
|
|
874
|
-
if (idx === columnIndex) return targetColumnIndex;
|
|
875
|
-
if (idx >= targetColumnIndex && idx < columnIndex) return idx + 1;
|
|
876
|
-
|
|
877
|
-
return idx;
|
|
878
|
-
})
|
|
879
|
-
.concat(targetColumnIndex)
|
|
880
|
-
.filter((idx, i, arr) => arr.indexOf(idx) === i)
|
|
881
|
-
.sort((a, b) => a - b);
|
|
882
|
-
|
|
883
|
-
const mixedWidths = convertToMixedWidthMode(movedWidths, updatedPinnedIndices, tableWidth);
|
|
884
|
-
|
|
885
|
-
setColumnWidths(editor, element, mixedWidths);
|
|
886
|
-
} else {
|
|
887
|
-
setColumnWidths(editor, element, movedWidths);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
} else if (finalProps?.pinned && tableWidth > 0) {
|
|
891
|
-
// 即使沒有移動位置,如果設定了 pinned,也需要轉換為混合模式
|
|
892
|
-
const currentWidths = getColumnWidths(element);
|
|
893
|
-
|
|
894
|
-
if (currentWidths.length > 0) {
|
|
895
|
-
const { pinnedColumnIndices } = getPinnedColumnsInfo(element);
|
|
896
|
-
|
|
897
|
-
// 找出所有已經是 title 的 columns
|
|
898
|
-
const titleColumnIndices = new Set<number>();
|
|
899
|
-
const firstRow = containerElement.children[0];
|
|
900
|
-
|
|
901
|
-
if (Element.isElement(firstRow) && firstRow.type.includes(TABLE_ROW_TYPE)) {
|
|
902
|
-
(firstRow.children as TableElement[]).forEach((cell: TableElement, colIndex: number) => {
|
|
903
|
-
if (
|
|
904
|
-
Element.isElement(cell) &&
|
|
905
|
-
(cell as TableElement).type.includes(TABLE_CELL_TYPE) &&
|
|
906
|
-
(cell as TableElement).treatAsTitle
|
|
907
|
-
) {
|
|
908
|
-
titleColumnIndices.add(colIndex);
|
|
909
|
-
}
|
|
910
|
-
});
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
// 將當前 column 加入 title columns
|
|
914
|
-
titleColumnIndices.add(columnIndex);
|
|
915
|
-
|
|
916
|
-
// 合併所有 pinned columns 和 title columns
|
|
917
|
-
const allPinnedIndices = new Set([...pinnedColumnIndices, ...Array.from(titleColumnIndices)]);
|
|
918
|
-
const updatedPinnedIndices = Array.from(allPinnedIndices).sort((a, b) => a - b);
|
|
919
|
-
const mixedWidths = convertToMixedWidthMode(currentWidths, updatedPinnedIndices, tableWidth);
|
|
920
|
-
|
|
921
|
-
setColumnWidths(editor, element, mixedWidths);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
|
|
926
|
-
if (tableHeaderElement) {
|
|
927
|
-
processContainer(tableHeaderElement);
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
if (tableBodyElement) {
|
|
931
|
-
processContainer(tableBodyElement);
|
|
932
|
-
}
|
|
933
|
-
} catch (error) {
|
|
934
|
-
console.warn('Failed to set column as title:', error);
|
|
935
|
-
}
|
|
936
|
-
},
|
|
937
|
-
[editor, element],
|
|
938
|
-
);
|
|
939
|
-
|
|
940
|
-
const pinColumn: TableContextType['pinColumn'] = useCallback(
|
|
941
|
-
(columnIndex: number) => {
|
|
942
|
-
try {
|
|
943
|
-
setColumnAsTitle(columnIndex, { pinned: true });
|
|
944
|
-
} catch (error) {
|
|
945
|
-
console.warn('Failed to pin column:', error);
|
|
946
|
-
}
|
|
947
|
-
},
|
|
948
|
-
[setColumnAsTitle],
|
|
949
|
-
);
|
|
950
|
-
|
|
951
|
-
const unpinColumn: TableContextType['unpinColumn'] = useCallback(() => {
|
|
952
|
-
try {
|
|
953
|
-
const tableStructure = getTableStructure(editor, element);
|
|
954
|
-
|
|
955
|
-
if (!tableStructure) return;
|
|
956
|
-
|
|
957
|
-
const { tableHeaderElement, tableBodyElement } = tableStructure;
|
|
958
|
-
|
|
959
|
-
// 檢查 column 與 row 之間是否有交叉 pinned 狀態的關係
|
|
960
|
-
const shouldRowRemainPinned = (rowElement: TableElement, excludeColumns: Set<number>): boolean => {
|
|
961
|
-
let hasNonExcludedCells = false;
|
|
962
|
-
|
|
963
|
-
for (let colIndex = 0; colIndex < rowElement.children.length; colIndex++) {
|
|
964
|
-
const cell = rowElement.children[colIndex];
|
|
965
|
-
|
|
966
|
-
if (!Element.isElement(cell) || !cell.type.includes(TABLE_CELL_TYPE)) continue;
|
|
967
|
-
if (excludeColumns.has(colIndex)) continue;
|
|
968
|
-
|
|
969
|
-
hasNonExcludedCells = true;
|
|
970
|
-
|
|
971
|
-
if (!cell.pinned) {
|
|
972
|
-
return false;
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
return hasNonExcludedCells;
|
|
977
|
-
};
|
|
978
|
-
|
|
979
|
-
const processContainer = (containerElement: TableElement) => {
|
|
980
|
-
const containerPath = ReactEditor.findPath(editor, containerElement);
|
|
981
|
-
const treatAsTitleColumns = new Set<number>();
|
|
982
|
-
|
|
983
|
-
containerElement.children.forEach((row) => {
|
|
984
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
985
|
-
row.children.forEach((cell, colIndex) => {
|
|
986
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE) && cell.treatAsTitle) {
|
|
987
|
-
treatAsTitleColumns.add(colIndex);
|
|
988
|
-
}
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
});
|
|
992
|
-
|
|
993
|
-
containerElement.children.forEach((row, rowIndex) => {
|
|
994
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
995
|
-
const rowShouldRemainPinned = shouldRowRemainPinned(row as TableElement, treatAsTitleColumns);
|
|
996
|
-
|
|
997
|
-
row.children.forEach((cell, colIndex) => {
|
|
998
|
-
if (treatAsTitleColumns.has(colIndex) && Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
999
|
-
const cellPath = [...containerPath, rowIndex, colIndex];
|
|
1000
|
-
|
|
1001
|
-
Transforms.unsetNodes(editor, 'treatAsTitle', { at: cellPath });
|
|
1002
|
-
|
|
1003
|
-
if (!rowShouldRemainPinned) {
|
|
1004
|
-
Transforms.unsetNodes(editor, 'pinned', { at: cellPath });
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
});
|
|
1010
|
-
};
|
|
1011
|
-
|
|
1012
|
-
if (tableHeaderElement) {
|
|
1013
|
-
processContainer(tableHeaderElement);
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
if (tableBodyElement) {
|
|
1017
|
-
processContainer(tableBodyElement);
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
// 轉換回純百分比模式
|
|
1021
|
-
const currentWidths = getColumnWidths(element);
|
|
1022
|
-
const percentageWidths = convertToPercentageMode(currentWidths);
|
|
1023
|
-
|
|
1024
|
-
setColumnWidths(editor, element, percentageWidths);
|
|
1025
|
-
} catch (error) {
|
|
1026
|
-
console.warn('Failed to unpin column:', error);
|
|
1027
|
-
}
|
|
1028
|
-
}, [editor, element]);
|
|
1029
|
-
|
|
1030
|
-
const setPinnedOnRowCells = useCallback(
|
|
1031
|
-
(row: TableElement, pinned: boolean) => {
|
|
1032
|
-
try {
|
|
1033
|
-
for (const [, cell] of row.children.entries()) {
|
|
1034
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
1035
|
-
const cellPath = ReactEditor.findPath(editor, cell);
|
|
1036
|
-
|
|
1037
|
-
if (pinned) {
|
|
1038
|
-
Transforms.setNodes(editor, { pinned: true } as Partial<TableElement>, { at: cellPath });
|
|
1039
|
-
} else {
|
|
1040
|
-
Transforms.unsetNodes(editor, 'pinned', { at: cellPath });
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
} catch (error) {
|
|
1045
|
-
console.warn('Failed to set pinned on row cells:', error);
|
|
1046
|
-
}
|
|
1047
|
-
},
|
|
1048
|
-
[editor],
|
|
1049
|
-
);
|
|
1050
|
-
|
|
1051
|
-
const setPinnedOnAllHeaderRows = useCallback(
|
|
1052
|
-
(headerElement: TableElement, pinned: boolean) => {
|
|
1053
|
-
try {
|
|
1054
|
-
for (const headerRow of headerElement.children) {
|
|
1055
|
-
if (Element.isElement(headerRow) && headerRow.type.includes(TABLE_ROW_TYPE)) {
|
|
1056
|
-
setPinnedOnRowCells(headerRow as TableElement, pinned);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
} catch (error) {
|
|
1060
|
-
console.warn('Failed to set pinned on all header rows:', error);
|
|
1061
|
-
}
|
|
1062
|
-
},
|
|
1063
|
-
[setPinnedOnRowCells],
|
|
1064
|
-
);
|
|
1065
|
-
|
|
1066
|
-
const pinRow: TableContextType['pinRow'] = useCallback(
|
|
1067
|
-
(rowIndex: number) => {
|
|
1068
|
-
try {
|
|
1069
|
-
const tableStructure = getTableStructure(editor, element);
|
|
1070
|
-
|
|
1071
|
-
if (!tableStructure) return;
|
|
1072
|
-
|
|
1073
|
-
const { tableHeaderElement, headerRowCount } = tableStructure;
|
|
1074
|
-
|
|
1075
|
-
// 先將目前所有的 header rows 都設為 pinned
|
|
1076
|
-
if (tableHeaderElement) {
|
|
1077
|
-
setPinnedOnAllHeaderRows(tableHeaderElement, true);
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
// 然後將目標 row 移動到 header 中並設為 pinned
|
|
1081
|
-
if (rowIndex >= headerRowCount) {
|
|
1082
|
-
moveRowToHeader(rowIndex, { pinned: true });
|
|
1083
|
-
}
|
|
1084
|
-
} catch (error) {
|
|
1085
|
-
console.warn('Failed to pin row:', error);
|
|
1086
|
-
}
|
|
1087
|
-
},
|
|
1088
|
-
[editor, element, moveRowToHeader, setPinnedOnAllHeaderRows],
|
|
1089
|
-
);
|
|
1090
|
-
|
|
1091
|
-
const unpinRow: TableContextType['unpinRow'] = useCallback(() => {
|
|
1092
|
-
try {
|
|
1093
|
-
const tableStructure = getTableStructure(editor, element);
|
|
1094
|
-
|
|
1095
|
-
if (!tableStructure) return;
|
|
1096
|
-
|
|
1097
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath } = tableStructure;
|
|
1098
|
-
|
|
1099
|
-
if (!tableHeaderElement || !tableBodyElement) return;
|
|
1100
|
-
|
|
1101
|
-
// 檢查 column 與 row 之間是否有交叉 pinned 狀態的關係
|
|
1102
|
-
const shouldColumnRemainPinned = (columnIndex: number): boolean => {
|
|
1103
|
-
const containers = [tableHeaderElement, tableBodyElement];
|
|
1104
|
-
|
|
1105
|
-
for (const container of containers) {
|
|
1106
|
-
if (!Element.isElement(container)) continue;
|
|
1107
|
-
|
|
1108
|
-
for (const row of container.children) {
|
|
1109
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
1110
|
-
const cell = row.children[columnIndex];
|
|
1111
|
-
|
|
1112
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
1113
|
-
// 如果這個 cell 在 body 中且有 pinned 屬性,則 column 應該保持 pinned
|
|
1114
|
-
if (container.type === tableBodyElement.type && cell.pinned) {
|
|
1115
|
-
return true;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
return false;
|
|
1123
|
-
};
|
|
1124
|
-
|
|
1125
|
-
tableHeaderElement.children.forEach((row, headerRowIndex) => {
|
|
1126
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
1127
|
-
row.children.forEach((cell, colIndex) => {
|
|
1128
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
1129
|
-
const cellPath = [...tableHeaderPath!, headerRowIndex, colIndex];
|
|
1130
|
-
|
|
1131
|
-
if (!shouldColumnRemainPinned(colIndex)) {
|
|
1132
|
-
Transforms.unsetNodes(editor, 'pinned', { at: cellPath });
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
const tableBodyPath = ReactEditor.findPath(editor, tableBodyElement);
|
|
1140
|
-
|
|
1141
|
-
for (let i = tableHeaderElement.children.length - 1; i >= 0; i--) {
|
|
1142
|
-
const row = tableHeaderElement.children[i];
|
|
1143
|
-
|
|
1144
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
1145
|
-
const fromPath = [...tableHeaderPath!, i];
|
|
1146
|
-
const toPath = [...tableBodyPath, 0];
|
|
1147
|
-
|
|
1148
|
-
Transforms.moveNodes(editor, {
|
|
1149
|
-
at: fromPath,
|
|
1150
|
-
to: toPath,
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
} catch (error) {
|
|
1155
|
-
console.warn('Failed to unpin row:', error);
|
|
1156
|
-
}
|
|
1157
|
-
}, [editor, element]);
|
|
1158
|
-
|
|
1159
|
-
/**
|
|
1160
|
-
* 內部函數:移動或交換列的位置
|
|
1161
|
-
* @param mode 'swap' 為交換相鄰位置(toolbar 按鈕),'move' 為移動到任意位置(拖曳)
|
|
1162
|
-
*/
|
|
1163
|
-
const moveOrSwapRow = useCallback(
|
|
1164
|
-
(sourceRowIndex: number, targetRowIndex: number, mode: 'swap' | 'move' = 'move') => {
|
|
1165
|
-
try {
|
|
1166
|
-
const tableStructure = getTableStructure(editor, element);
|
|
1167
|
-
|
|
1168
|
-
if (!tableStructure) return;
|
|
1169
|
-
|
|
1170
|
-
const { tableHeaderElement, tableBodyElement, tableHeaderPath, tableBodyPath, headerRowCount } = tableStructure;
|
|
1171
|
-
|
|
1172
|
-
// 確定當前列和目標列所屬的容器
|
|
1173
|
-
const sourceInHeader = sourceRowIndex < headerRowCount;
|
|
1174
|
-
const targetInHeader = targetRowIndex < headerRowCount;
|
|
1175
|
-
|
|
1176
|
-
// 標題列只能與標題列互換/移動,一般列只能與一般列互換/移動
|
|
1177
|
-
if (sourceInHeader !== targetInHeader) {
|
|
1178
|
-
console.warn(`Cannot ${mode} row between header and body`);
|
|
1179
|
-
|
|
1180
|
-
return;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
// 檢查邊界
|
|
1184
|
-
if (sourceRowIndex === targetRowIndex) {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
let containerPath: number[];
|
|
1189
|
-
let sourceLocalIndex: number;
|
|
1190
|
-
let targetLocalIndex: number;
|
|
1191
|
-
|
|
1192
|
-
if (sourceInHeader) {
|
|
1193
|
-
// 在 header 中
|
|
1194
|
-
if (!tableHeaderElement || !tableHeaderPath) return;
|
|
1195
|
-
|
|
1196
|
-
containerPath = tableHeaderPath;
|
|
1197
|
-
sourceLocalIndex = sourceRowIndex;
|
|
1198
|
-
targetLocalIndex = targetRowIndex;
|
|
1199
|
-
} else {
|
|
1200
|
-
// 在 body 中
|
|
1201
|
-
if (!tableBodyElement) return;
|
|
1202
|
-
|
|
1203
|
-
containerPath = tableBodyPath;
|
|
1204
|
-
sourceLocalIndex = sourceRowIndex - headerRowCount;
|
|
1205
|
-
targetLocalIndex = targetRowIndex - headerRowCount;
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
Editor.withoutNormalizing(editor, () => {
|
|
1209
|
-
if (mode === 'swap') {
|
|
1210
|
-
// swap 邏輯:交換兩個相鄰位置
|
|
1211
|
-
if (sourceRowIndex < targetRowIndex) {
|
|
1212
|
-
// 向下移動:先將源列移到目標位置之後
|
|
1213
|
-
const sourcePath = [...containerPath, sourceLocalIndex];
|
|
1214
|
-
const afterTargetPath = [...containerPath, targetLocalIndex];
|
|
1215
|
-
|
|
1216
|
-
Transforms.moveNodes(editor, {
|
|
1217
|
-
at: sourcePath,
|
|
1218
|
-
to: afterTargetPath,
|
|
1219
|
-
});
|
|
1220
|
-
} else {
|
|
1221
|
-
// 向上移動:先將目標列移到源位置之後
|
|
1222
|
-
const targetPath = [...containerPath, targetLocalIndex];
|
|
1223
|
-
const afterSourcePath = [...containerPath, sourceLocalIndex];
|
|
1224
|
-
|
|
1225
|
-
Transforms.moveNodes(editor, {
|
|
1226
|
-
at: targetPath,
|
|
1227
|
-
to: afterSourcePath,
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
} else {
|
|
1231
|
-
// move 邏輯:直接移動到目標位置
|
|
1232
|
-
const sourcePath = [...containerPath, sourceLocalIndex];
|
|
1233
|
-
const targetPath = [...containerPath, targetLocalIndex];
|
|
1234
|
-
|
|
1235
|
-
Transforms.moveNodes(editor, {
|
|
1236
|
-
at: sourcePath,
|
|
1237
|
-
to: targetPath,
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
|
-
} catch (error) {
|
|
1242
|
-
console.warn(`Failed to ${mode} row:`, error);
|
|
1243
|
-
}
|
|
1244
|
-
},
|
|
1245
|
-
[editor, element],
|
|
1246
|
-
);
|
|
1247
|
-
|
|
1248
|
-
/**
|
|
1249
|
-
* 內部函數:移動或交換行的位置
|
|
1250
|
-
* @param mode 'swap' 為交換相鄰位置(toolbar 按鈕),'move' 為移動到任意位置(拖曳)
|
|
1251
|
-
*/
|
|
1252
|
-
const moveOrSwapColumn = useCallback(
|
|
1253
|
-
(sourceColumnIndex: number, targetColumnIndex: number, mode: 'swap' | 'move' = 'move') => {
|
|
1254
|
-
try {
|
|
1255
|
-
const tableStructure = getTableStructure(editor, element);
|
|
1256
|
-
|
|
1257
|
-
if (!tableStructure) return;
|
|
1258
|
-
|
|
1259
|
-
const { tableHeaderElement, tableBodyElement, columnCount } = tableStructure;
|
|
1260
|
-
|
|
1261
|
-
// 檢查邊界
|
|
1262
|
-
if (targetColumnIndex < 0 || targetColumnIndex >= columnCount) {
|
|
1263
|
-
console.warn('Target column index out of bounds');
|
|
1264
|
-
|
|
1265
|
-
return;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
// 檢查是否為同一行
|
|
1269
|
-
if (sourceColumnIndex === targetColumnIndex) {
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
// 檢查當前行和目標行是否都是標題行或都是一般行
|
|
1274
|
-
// 透過檢查第一個 cell 的 treatAsTitle 屬性來判斷
|
|
1275
|
-
const checkIsTitleColumn = (container: TableElement, colIndex: number): boolean => {
|
|
1276
|
-
if (!Element.isElement(container)) return false;
|
|
1277
|
-
|
|
1278
|
-
for (const row of container.children) {
|
|
1279
|
-
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
1280
|
-
const cell = row.children[colIndex];
|
|
1281
|
-
|
|
1282
|
-
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
1283
|
-
return !!cell.treatAsTitle;
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
return false;
|
|
1289
|
-
};
|
|
1290
|
-
|
|
1291
|
-
// 檢查兩個 container 中的第一列來確定是否為標題行
|
|
1292
|
-
let sourceIsTitle = false;
|
|
1293
|
-
let targetIsTitle = false;
|
|
1294
|
-
|
|
1295
|
-
if (tableHeaderElement) {
|
|
1296
|
-
sourceIsTitle = sourceIsTitle || checkIsTitleColumn(tableHeaderElement, sourceColumnIndex);
|
|
1297
|
-
targetIsTitle = targetIsTitle || checkIsTitleColumn(tableHeaderElement, targetColumnIndex);
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
if (tableBodyElement) {
|
|
1301
|
-
sourceIsTitle = sourceIsTitle || checkIsTitleColumn(tableBodyElement, sourceColumnIndex);
|
|
1302
|
-
targetIsTitle = targetIsTitle || checkIsTitleColumn(tableBodyElement, targetColumnIndex);
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
|
-
// 標題行只能與標題行互換/移動,一般行只能與一般行互換/移動
|
|
1306
|
-
if (sourceIsTitle !== targetIsTitle) {
|
|
1307
|
-
console.warn(`Cannot ${mode} column between title and normal columns`);
|
|
1308
|
-
|
|
1309
|
-
return;
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
// 根據模式選擇不同的 columnWidths 處理方式
|
|
1313
|
-
const currentWidths = getColumnWidths(element);
|
|
1314
|
-
const newWidths = moveOrSwapColumnWidth(currentWidths, sourceColumnIndex, targetColumnIndex, mode);
|
|
1315
|
-
|
|
1316
|
-
setColumnWidths(editor, element, newWidths);
|
|
1317
|
-
|
|
1318
|
-
// 對 header 和 body 中的所有列進行操作
|
|
1319
|
-
Editor.withoutNormalizing(editor, () => {
|
|
1320
|
-
const containers = [tableHeaderElement, tableBodyElement].filter(
|
|
1321
|
-
(c) => c && Element.isElement(c),
|
|
1322
|
-
) as TableElement[];
|
|
1323
|
-
|
|
1324
|
-
for (const container of containers) {
|
|
1325
|
-
// 對每一列進行操作
|
|
1326
|
-
for (let rowIndex = 0; rowIndex < container.children.length; rowIndex++) {
|
|
1327
|
-
const row = container.children[rowIndex];
|
|
1328
|
-
|
|
1329
|
-
if (!Element.isElement(row) || !row.type.includes(TABLE_ROW_TYPE)) continue;
|
|
1330
|
-
|
|
1331
|
-
const containerPath = ReactEditor.findPath(editor, container);
|
|
1332
|
-
const rowPath = [...containerPath, rowIndex];
|
|
1333
|
-
|
|
1334
|
-
if (mode === 'swap') {
|
|
1335
|
-
// swap 邏輯:交換兩個相鄰位置
|
|
1336
|
-
if (sourceColumnIndex < targetColumnIndex) {
|
|
1337
|
-
// 向右移動:將源 cell 移到目標位置之後
|
|
1338
|
-
const sourceCellPath = [...rowPath, sourceColumnIndex];
|
|
1339
|
-
const afterTargetCellPath = [...rowPath, targetColumnIndex];
|
|
1340
|
-
|
|
1341
|
-
Transforms.moveNodes(editor, {
|
|
1342
|
-
at: sourceCellPath,
|
|
1343
|
-
to: afterTargetCellPath,
|
|
1344
|
-
});
|
|
1345
|
-
} else {
|
|
1346
|
-
// 向左移動:將目標 cell 移到源位置之後
|
|
1347
|
-
const targetCellPath = [...rowPath, targetColumnIndex];
|
|
1348
|
-
const afterSourceCellPath = [...rowPath, sourceColumnIndex];
|
|
1349
|
-
|
|
1350
|
-
Transforms.moveNodes(editor, {
|
|
1351
|
-
at: targetCellPath,
|
|
1352
|
-
to: afterSourceCellPath,
|
|
1353
|
-
});
|
|
1354
|
-
}
|
|
1355
|
-
} else {
|
|
1356
|
-
// move 邏輯:直接移動到目標位置
|
|
1357
|
-
const sourceCellPath = [...rowPath, sourceColumnIndex];
|
|
1358
|
-
const targetCellPath = [...rowPath, targetColumnIndex];
|
|
1359
|
-
|
|
1360
|
-
Transforms.moveNodes(editor, {
|
|
1361
|
-
at: sourceCellPath,
|
|
1362
|
-
to: targetCellPath,
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
});
|
|
1368
|
-
} catch (error) {
|
|
1369
|
-
console.warn(`Failed to ${mode} column:`, error);
|
|
1370
|
-
}
|
|
1371
|
-
},
|
|
1372
|
-
[editor, element],
|
|
1373
|
-
);
|
|
1374
|
-
|
|
1375
|
-
return {
|
|
1376
|
-
addColumn,
|
|
1377
|
-
addRow,
|
|
1378
|
-
addColumnAndRow,
|
|
1379
|
-
deleteRow,
|
|
1380
|
-
deleteColumn,
|
|
1381
|
-
moveRowToBody,
|
|
1382
|
-
moveRowToHeader,
|
|
1383
|
-
unsetColumnAsTitle,
|
|
1384
|
-
setColumnAsTitle,
|
|
1385
|
-
pinColumn,
|
|
1386
|
-
unpinColumn,
|
|
1387
|
-
pinRow,
|
|
1388
|
-
unpinRow,
|
|
1389
|
-
isColumnPinned,
|
|
1390
|
-
isRowPinned,
|
|
1391
|
-
moveOrSwapRow,
|
|
1392
|
-
moveOrSwapColumn,
|
|
1393
|
-
};
|
|
1394
|
-
}
|