@quadrats/react 1.1.6 → 1.1.8
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/CHANGELOG.md +610 -0
- package/_internal/package.json +1 -4
- package/_internal/src/renderer/composeRenderElementsBase.ts +19 -0
- package/_internal/src/renderer/composeRenderLeafsBase.ts +17 -0
- package/_internal/src/renderer/createRenderElementBase.ts +14 -0
- package/_internal/src/renderer/createRenderElementsBase.ts +15 -0
- package/_internal/src/renderer/createRenderMarkBase.ts +19 -0
- package/_internal/src/renderer/typings.ts +30 -0
- package/_internal/tsconfig.build.json +5 -0
- package/accordion/jsx-serializer/package.json +6 -3
- package/accordion/jsx-serializer/src/createJsxSerializeAccordion.ts +79 -0
- package/accordion/jsx-serializer/src/defaultRenderAccordionElements.tsx +21 -0
- package/accordion/jsx-serializer/src/typings.ts +16 -0
- package/accordion/jsx-serializer/tsconfig.build.json +5 -0
- package/accordion/package.json +8 -3
- package/accordion/src/components/Accordion.tsx +53 -0
- package/accordion/src/components/AccordionContent.tsx +38 -0
- package/accordion/src/components/AccordionTitle.tsx +33 -0
- package/accordion/src/contexts/AccordionContext.ts +4 -0
- package/accordion/src/createReactAccordion.ts +194 -0
- package/accordion/src/defaultRenderAccordionElements.tsx +11 -0
- package/accordion/src/hooks/useAccordion.ts +6 -0
- package/accordion/src/typings.ts +41 -0
- package/accordion/toolbar/package.json +6 -3
- package/accordion/toolbar/src/AccordionToolbarIcon.tsx +17 -0
- package/accordion/toolbar/src/index.ts +3 -0
- package/accordion/toolbar/src/useAccordionTool.ts +10 -0
- package/accordion/toolbar/tsconfig.build.json +5 -0
- package/accordion/tsconfig.build.json +5 -0
- package/align/package.json +5 -3
- package/align/src/constants.ts +8 -0
- package/align/src/createReactAlign.ts +27 -0
- package/align/src/typings.ts +20 -0
- package/align/toolbar/package.json +7 -3
- package/align/toolbar/src/AlignToolbarIcon.tsx +19 -0
- package/align/toolbar/src/index.ts +3 -0
- package/align/toolbar/src/useAlignTool.ts +18 -0
- package/align/toolbar/tsconfig.build.json +5 -0
- package/align/tsconfig.build.json +5 -0
- package/blockquote/jsx-serializer/package.json +6 -3
- package/blockquote/jsx-serializer/src/createJsxSerializeBlockquote.ts +14 -0
- package/blockquote/jsx-serializer/src/typings.ts +4 -0
- package/blockquote/jsx-serializer/tsconfig.build.json +5 -0
- package/blockquote/package.json +9 -3
- package/blockquote/src/ReactBlockquote.spec.tsx +42 -0
- package/blockquote/src/constants.ts +6 -0
- package/blockquote/src/createReactBlockquote.ts +105 -0
- package/blockquote/src/defaultRenderBlockquoteElement.tsx +15 -0
- package/blockquote/src/typings.ts +22 -0
- package/blockquote/toolbar/package.json +6 -3
- package/blockquote/toolbar/src/BlockquoteToolbarIcon.tsx +17 -0
- package/blockquote/toolbar/src/useBlockquoteTool.ts +11 -0
- package/blockquote/toolbar/tsconfig.build.json +5 -0
- package/blockquote/tsconfig.build.json +5 -0
- package/bold/jsx-serializer/package.json +6 -3
- package/bold/jsx-serializer/src/createJsxSerializeBold.ts +8 -0
- package/bold/jsx-serializer/tsconfig.build.json +5 -0
- package/bold/package.json +5 -3
- package/bold/src/constants.ts +6 -0
- package/bold/src/createReactBold.ts +11 -0
- package/bold/src/defaultRenderBold.tsx +12 -0
- package/bold/src/typings.ts +6 -0
- package/bold/tsconfig.build.json +5 -0
- package/card/jsx-serializer/package.json +6 -3
- package/card/jsx-serializer/src/createJsxSerializeCard.ts +65 -0
- package/card/jsx-serializer/src/defaultRenderCardElements.tsx +9 -0
- package/card/jsx-serializer/src/typings.ts +20 -0
- package/card/jsx-serializer/tsconfig.build.json +5 -0
- package/card/package.json +11 -3
- package/card/src/components/Card.tsx +139 -0
- package/card/src/components/CardContents.tsx +35 -0
- package/card/src/components/CardImage.tsx +30 -0
- package/card/src/components/CardPlaceholder.tsx +40 -0
- package/card/src/createReactCard.ts +101 -0
- package/card/src/defaultRenderCardElements.tsx +16 -0
- package/card/src/typings.ts +46 -0
- package/card/toolbar/package.json +6 -3
- package/card/toolbar/src/CardToolbarIcon.tsx +17 -0
- package/card/toolbar/src/useCardTool.tsx +43 -0
- package/card/toolbar/tsconfig.build.json +5 -0
- package/card/tsconfig.build.json +5 -0
- package/carousel/jsx-serializer/package.json +6 -3
- package/carousel/jsx-serializer/src/createJsxSerializeCarousel.ts +71 -0
- package/carousel/jsx-serializer/src/defaultRenderCarouselElements.tsx +9 -0
- package/carousel/jsx-serializer/src/typings.ts +20 -0
- package/carousel/jsx-serializer/tsconfig.build.json +5 -0
- package/carousel/package.json +10 -3
- package/carousel/src/components/Carousel.tsx +102 -0
- package/carousel/src/components/CarouselCaption.tsx +27 -0
- package/carousel/src/components/CarouselImages.tsx +97 -0
- package/carousel/src/components/CarouselPlaceholder.tsx +26 -0
- package/carousel/src/contexts/CarouselContext.ts +4 -0
- package/carousel/src/createReactCarousel.ts +104 -0
- package/carousel/src/defaultRenderCarouselElements.tsx +16 -0
- package/carousel/src/hooks/useCarousel.ts +6 -0
- package/carousel/src/typings.ts +55 -0
- package/carousel/toolbar/package.json +6 -3
- package/carousel/toolbar/src/CarouselToolbarIcon.tsx +17 -0
- package/carousel/toolbar/src/useCarouselTool.tsx +34 -0
- package/carousel/toolbar/tsconfig.build.json +5 -0
- package/carousel/tsconfig.build.json +5 -0
- package/components/package.json +21 -3
- package/components/src/BaseField/index.tsx +35 -0
- package/components/src/Button/index.tsx +48 -0
- package/components/src/Hint/index.tsx +61 -0
- package/components/src/Icon/index.tsx +45 -0
- package/components/src/ImageUploader/index.tsx +306 -0
- package/components/src/Input/index.tsx +72 -0
- package/components/src/Message/index.tsx +138 -0
- package/components/src/Modal/index.tsx +161 -0
- package/components/src/Notifier/NotifierManager.tsx +50 -0
- package/components/src/Notifier/createNotifier.tsx +100 -0
- package/components/src/Notifier/typings.ts +33 -0
- package/components/src/Portal/index.tsx +15 -0
- package/components/src/Progress/index.tsx +49 -0
- package/components/src/SegmentedControl/index.tsx +37 -0
- package/components/src/Textarea/index.tsx +74 -0
- package/components/src/Toggle/index.tsx +34 -0
- package/components/src/Tooltip/calculatePosition.ts +84 -0
- package/components/src/Tooltip/index.tsx +187 -0
- package/components/src/Tooltip/typings.ts +40 -0
- package/components/src/Transition/SlideFade.tsx +159 -0
- package/components/src/Transition/Transition.tsx +176 -0
- package/components/src/Transition/getTransitionStyleProps.ts +48 -0
- package/components/src/Transition/useSetNodeTransition.ts +46 -0
- package/components/src/index.ts +17 -0
- package/components/tsconfig.build.json +5 -0
- package/configs/package.json +1 -4
- package/configs/src/ConfigsProvider.tsx +39 -0
- package/configs/src/locale.ts +8 -0
- package/configs/src/theme.ts +50 -0
- package/configs/tsconfig.build.json +5 -0
- package/divider/jsx-serializer/package.json +6 -3
- package/divider/jsx-serializer/src/createJsxSerializeDivider.ts +12 -0
- package/divider/jsx-serializer/src/defaultRenderDividerElement.tsx +3 -0
- package/divider/jsx-serializer/src/typings.ts +4 -0
- package/divider/jsx-serializer/tsconfig.build.json +5 -0
- package/divider/package.json +8 -3
- package/divider/src/createReactDivider.ts +16 -0
- package/divider/src/defaultRenderDividerElement.tsx +8 -0
- package/divider/src/typings.ts +13 -0
- package/divider/toolbar/package.json +6 -3
- package/divider/toolbar/src/DividerToolbarIcon.tsx +17 -0
- package/divider/toolbar/src/index.ts +3 -0
- package/divider/toolbar/src/useDividerTool.ts +10 -0
- package/divider/toolbar/tsconfig.build.json +5 -0
- package/divider/tsconfig.build.json +5 -0
- package/embed/jsx-serializer/facebook/package.json +6 -3
- package/embed/jsx-serializer/facebook/tsconfig.build.json +5 -0
- package/embed/jsx-serializer/instagram/package.json +6 -3
- package/embed/jsx-serializer/instagram/tsconfig.build.json +5 -0
- package/embed/jsx-serializer/package.json +6 -3
- package/embed/jsx-serializer/src/createJsxSerializeEmbed.ts +20 -0
- package/embed/jsx-serializer/src/typings.ts +7 -0
- package/embed/jsx-serializer/tsconfig.build.json +5 -0
- package/embed/jsx-serializer/twitter/package.json +6 -3
- package/embed/jsx-serializer/twitter/tsconfig.build.json +5 -0
- package/embed/jsx-serializer/vimeo/package.json +6 -3
- package/embed/jsx-serializer/vimeo/tsconfig.build.json +5 -0
- package/embed/jsx-serializer/youtube/package.json +6 -3
- package/embed/jsx-serializer/youtube/tsconfig.build.json +5 -0
- package/embed/package.json +8 -3
- package/embed/renderers/base/package.json +6 -3
- package/embed/renderers/base/src/components/BaseEmbedElement.tsx +107 -0
- package/embed/renderers/base/src/index.ts +5 -0
- package/embed/renderers/base/tsconfig.build.json +5 -0
- package/embed/renderers/facebook/package.json +6 -3
- package/embed/renderers/facebook/src/components/Facebook.tsx +56 -0
- package/embed/renderers/facebook/src/defaultRenderFacebookEmbedElement.tsx +81 -0
- package/embed/renderers/facebook/tsconfig.build.json +5 -0
- package/embed/renderers/instagram/package.json +6 -3
- package/embed/renderers/instagram/src/components/Instagram.tsx +86 -0
- package/embed/renderers/instagram/src/defaultRenderInstagramEmbedElement.tsx +74 -0
- package/embed/renderers/instagram/src/hooks/useLoadInstagramEmbedApi.ts +39 -0
- package/embed/renderers/instagram/tsconfig.build.json +5 -0
- package/embed/renderers/podcast-apple/package.json +6 -3
- package/embed/renderers/podcast-apple/src/components/PodcastApple.tsx +37 -0
- package/embed/renderers/podcast-apple/src/defaultRenderPodcastAppleEmbedElement.tsx +69 -0
- package/embed/renderers/podcast-apple/tsconfig.build.json +5 -0
- package/embed/renderers/spotify/package.json +6 -3
- package/embed/renderers/spotify/src/components/Spotify.tsx +51 -0
- package/embed/renderers/spotify/src/defaultRenderSpotifyEmbedElement.tsx +63 -0
- package/embed/renderers/spotify/tsconfig.build.json +5 -0
- package/embed/renderers/twitter/package.json +6 -3
- package/embed/renderers/twitter/src/components/Twitter.tsx +47 -0
- package/embed/renderers/twitter/src/defaultRenderTwitterEmbedElement.tsx +78 -0
- package/embed/renderers/twitter/src/hooks/useLoadTwitterEmbedApi.ts +55 -0
- package/embed/renderers/twitter/tsconfig.build.json +5 -0
- package/embed/renderers/vimeo/package.json +6 -3
- package/embed/renderers/vimeo/src/defaultRenderVimeoEmbedElement.tsx +52 -0
- package/embed/renderers/vimeo/tsconfig.build.json +5 -0
- package/embed/renderers/youtube/package.json +6 -3
- package/embed/renderers/youtube/src/defaultRenderYoutubeEmbedElement.tsx +52 -0
- package/embed/renderers/youtube/tsconfig.build.json +5 -0
- package/embed/src/components/VideoIframe.tsx +41 -0
- package/embed/src/createReactEmbed.ts +23 -0
- package/embed/src/createRenderEmbedElementBase.ts +30 -0
- package/embed/src/hooks/useVideoIframeSize.ts +28 -0
- package/embed/src/typings.ts +26 -0
- package/embed/toolbar/package.json +6 -3
- package/embed/toolbar/src/EmbedToolbarIcon.tsx +25 -0
- package/embed/toolbar/src/index.ts +3 -0
- package/embed/toolbar/src/useEmbedTool.tsx +106 -0
- package/embed/toolbar/tsconfig.build.json +5 -0
- package/embed/tsconfig.build.json +5 -0
- package/file-uploader/package.json +9 -3
- package/file-uploader/src/components/FileUploader.tsx +18 -0
- package/file-uploader/src/createReactFileUploader.ts +28 -0
- package/file-uploader/src/defaultRenderFileUploaderElement.tsx +5 -0
- package/file-uploader/src/hooks/useFileUploader.ts +14 -0
- package/file-uploader/src/typings.ts +19 -0
- package/file-uploader/toolbar/package.json +6 -3
- package/file-uploader/toolbar/src/FileUploaderToolbarIcon.tsx +19 -0
- package/file-uploader/toolbar/src/index.ts +3 -0
- package/file-uploader/toolbar/src/useFileUploaderTool.ts +14 -0
- package/file-uploader/toolbar/tsconfig.build.json +5 -0
- package/file-uploader/tsconfig.build.json +5 -0
- package/footnote/jsx-serializer/package.json +6 -3
- package/footnote/jsx-serializer/src/createJsxSerializeFootnote.ts +13 -0
- package/footnote/jsx-serializer/src/defaultRenderFootnoteElement.tsx +18 -0
- package/footnote/jsx-serializer/src/typings.ts +4 -0
- package/footnote/jsx-serializer/tsconfig.build.json +5 -0
- package/footnote/package.json +5 -3
- package/footnote/src/createReactFootnote.ts +22 -0
- package/footnote/src/defaultRenderFootnoteElement.tsx +36 -0
- package/footnote/src/typings.ts +14 -0
- package/footnote/src/useFootnotes.ts +28 -0
- package/footnote/src/useFootnotesFromNodes.ts +33 -0
- package/footnote/toolbar/package.json +6 -3
- package/footnote/toolbar/src/FootnoteToolbarIcon.tsx +18 -0
- package/footnote/toolbar/src/index.ts +3 -0
- package/footnote/toolbar/src/useFootnoteTool.ts +22 -0
- package/footnote/toolbar/tsconfig.build.json +5 -0
- package/footnote/tsconfig.build.json +5 -0
- package/heading/jsx-serializer/package.json +6 -3
- package/heading/jsx-serializer/src/createJsxSerializeHeading.ts +13 -0
- package/heading/jsx-serializer/src/typings.ts +4 -0
- package/heading/jsx-serializer/tsconfig.build.json +5 -0
- package/heading/package.json +9 -3
- package/heading/src/constants.ts +9 -0
- package/heading/src/createReactHeading.ts +56 -0
- package/heading/src/defaultRenderHeadingElement.tsx +36 -0
- package/heading/src/typings.ts +21 -0
- package/heading/toolbar/package.json +6 -3
- package/heading/toolbar/src/HeadingToolbarIcon.tsx +22 -0
- package/heading/toolbar/src/index.ts +3 -0
- package/heading/toolbar/src/useToggleHeadingTool.ts +15 -0
- package/heading/toolbar/tsconfig.build.json +5 -0
- package/heading/tsconfig.build.json +5 -0
- package/highlight/jsx-serializer/package.json +6 -3
- package/highlight/jsx-serializer/src/createJsxSerializeHighlight.ts +8 -0
- package/highlight/jsx-serializer/tsconfig.build.json +5 -0
- package/highlight/package.json +5 -3
- package/highlight/src/constants.ts +6 -0
- package/highlight/src/createReactHighlight.ts +11 -0
- package/highlight/src/defaultRenderHighlight.tsx +12 -0
- package/highlight/src/typings.ts +6 -0
- package/highlight/tsconfig.build.json +5 -0
- package/image/jsx-serializer/package.json +6 -3
- package/image/jsx-serializer/src/createJsxSerializeImage.ts +85 -0
- package/image/jsx-serializer/src/defaultRenderImageElements.tsx +21 -0
- package/image/jsx-serializer/src/typings.ts +34 -0
- package/image/jsx-serializer/tsconfig.build.json +5 -0
- package/image/package.json +10 -3
- package/image/src/components/Image.tsx +107 -0
- package/image/src/components/ImageCaption.tsx +35 -0
- package/image/src/components/ImageFigure.tsx +26 -0
- package/image/src/components/ImagePlaceholder.tsx +16 -0
- package/image/src/createReactImage.ts +191 -0
- package/image/src/defaultRenderImageElements.tsx +11 -0
- package/image/src/hooks/useImageResizer.ts +135 -0
- package/image/src/typings.ts +50 -0
- package/image/tsconfig.build.json +5 -0
- package/input-block/package.json +8 -3
- package/input-block/src/components/InputBlock.tsx +70 -0
- package/input-block/src/createReactInputBlock.ts +34 -0
- package/input-block/src/defaultRenderInputBlockElement.tsx +5 -0
- package/input-block/src/hooks/useInputBlock.ts +61 -0
- package/input-block/src/typings.ts +19 -0
- package/input-block/tsconfig.build.json +5 -0
- package/italic/jsx-serializer/package.json +6 -3
- package/italic/jsx-serializer/src/createJsxSerializeItalic.ts +8 -0
- package/italic/jsx-serializer/tsconfig.build.json +5 -0
- package/italic/package.json +5 -3
- package/italic/src/constants.ts +6 -0
- package/italic/src/createReactItalic.ts +11 -0
- package/italic/src/defaultRenderItalic.tsx +12 -0
- package/italic/src/typings.ts +6 -0
- package/italic/tsconfig.build.json +5 -0
- package/jsx-serializer/package.json +5 -3
- package/jsx-serializer/src/createJsxSerializeElement.ts +8 -0
- package/jsx-serializer/src/createJsxSerializeElements.ts +8 -0
- package/jsx-serializer/src/createJsxSerializeMark.ts +6 -0
- package/jsx-serializer/src/createJsxSerializer.tsx +84 -0
- package/jsx-serializer/src/typings.ts +20 -0
- package/jsx-serializer/tsconfig.build.json +5 -0
- package/line-break/jsx-serializer/package.json +6 -3
- package/line-break/jsx-serializer/src/createJsxSerializeLineBreak.ts +13 -0
- package/line-break/jsx-serializer/src/defaultRenderLineBreakElement.tsx +7 -0
- package/line-break/jsx-serializer/src/typings.ts +4 -0
- package/line-break/jsx-serializer/tsconfig.build.json +5 -0
- package/line-break/package.json +8 -3
- package/line-break/src/commonBreak.ts +32 -0
- package/line-break/src/createOnKeyDownBreak.ts +88 -0
- package/line-break/src/createReactLineBreak.ts +20 -0
- package/line-break/src/defaultRenderLineBreakElement.tsx +8 -0
- package/line-break/src/renderLineBreakElementWithSymbol.tsx +8 -0
- package/line-break/src/typings.ts +38 -0
- package/line-break/tsconfig.build.json +5 -0
- package/link/jsx-serializer/package.json +6 -3
- package/link/jsx-serializer/src/createJsxSerializeLink.ts +11 -0
- package/link/jsx-serializer/src/defaultRenderLinkElement.tsx +8 -0
- package/link/jsx-serializer/src/typings.ts +4 -0
- package/link/jsx-serializer/tsconfig.build.json +5 -0
- package/link/package.json +5 -3
- package/link/src/createReactLink.ts +49 -0
- package/link/src/defaultRenderLinkElement.tsx +27 -0
- package/link/src/typings.ts +14 -0
- package/link/toolbar/package.json +6 -3
- package/link/toolbar/src/LinkToolbarIcon.tsx +18 -0
- package/link/toolbar/src/UnlinkToolbarIcon.tsx +17 -0
- package/link/toolbar/src/index.ts +5 -0
- package/link/toolbar/src/useLinkTool.ts +31 -0
- package/link/toolbar/src/useUnlinkTool.ts +10 -0
- package/link/toolbar/tsconfig.build.json +5 -0
- package/link/tsconfig.build.json +5 -0
- package/list/jsx-serializer/package.json +6 -3
- package/list/jsx-serializer/src/createJsxSerializeList.ts +21 -0
- package/list/jsx-serializer/src/typings.ts +4 -0
- package/list/jsx-serializer/tsconfig.build.json +5 -0
- package/list/package.json +8 -3
- package/list/src/createReactList.ts +52 -0
- package/list/src/defaultRenderListElements.tsx +12 -0
- package/list/src/typings.ts +14 -0
- package/list/toolbar/package.json +6 -3
- package/list/toolbar/src/ListToolbarIcon.tsx +19 -0
- package/list/toolbar/src/index.ts +3 -0
- package/list/toolbar/src/useListTool.ts +12 -0
- package/list/toolbar/tsconfig.build.json +5 -0
- package/list/tsconfig.build.json +5 -0
- package/package.json +19 -6
- package/paragraph/jsx-serializer/package.json +6 -3
- package/paragraph/jsx-serializer/src/createJsxSerializeParagraph.ts +14 -0
- package/paragraph/jsx-serializer/src/typings.ts +4 -0
- package/paragraph/jsx-serializer/tsconfig.build.json +5 -0
- package/paragraph/package.json +8 -3
- package/paragraph/src/createReactParagraph.ts +9 -0
- package/paragraph/src/createRenderParagraphElement.ts +17 -0
- package/paragraph/src/defaultRenderParagraphElement.tsx +21 -0
- package/paragraph/src/renderParagraphElementWithSymbol.tsx +21 -0
- package/paragraph/toolbar/package.json +6 -3
- package/paragraph/toolbar/src/ParagraphToolbarIcon.tsx +17 -0
- package/paragraph/toolbar/src/useToggleParagraphTool.ts +11 -0
- package/paragraph/toolbar/tsconfig.build.json +5 -0
- package/paragraph/tsconfig.build.json +5 -0
- package/read-more/jsx-serializer/package.json +6 -3
- package/read-more/jsx-serializer/src/createJsxSerializeReadMore.ts +11 -0
- package/read-more/jsx-serializer/src/typings.ts +4 -0
- package/read-more/jsx-serializer/tsconfig.build.json +5 -0
- package/read-more/package.json +8 -3
- package/read-more/src/components/ReadMore.tsx +24 -0
- package/read-more/src/createReactReadMore.ts +16 -0
- package/read-more/src/defaultRenderReadMoreElement.tsx +5 -0
- package/read-more/src/typings.ts +12 -0
- package/read-more/toolbar/package.json +6 -3
- package/read-more/toolbar/src/ReadMoreToolbarIcon.tsx +17 -0
- package/read-more/toolbar/src/index.ts +3 -0
- package/read-more/toolbar/src/useReadMoreTool.ts +10 -0
- package/read-more/toolbar/tsconfig.build.json +5 -0
- package/read-more/tsconfig.build.json +5 -0
- package/src/core/components/DefaultElement.tsx +6 -0
- package/src/core/components/DefaultLeaf.tsx +6 -0
- package/src/core/components/Editable.tsx +129 -0
- package/src/core/components/Quadrats.tsx +40 -0
- package/src/core/composeHandlers.ts +58 -0
- package/src/core/composeRenderElements.tsx +13 -0
- package/src/core/composeRenderLeafs.tsx +11 -0
- package/src/core/constants.ts +1 -0
- package/src/core/contexts/composition/CompositionProvider.tsx +15 -0
- package/src/core/contexts/composition/composition.ts +16 -0
- package/src/core/contexts/message/MessageProvider.tsx +46 -0
- package/src/core/contexts/message/message.ts +14 -0
- package/src/core/contexts/modal/CardModal/CardModal.tsx +256 -0
- package/src/core/contexts/modal/CarouselModal/CarouselItem.tsx +97 -0
- package/src/core/contexts/modal/CarouselModal/CarouselModal.tsx +280 -0
- package/src/core/contexts/modal/CarouselModal/FilesDropZone.tsx +118 -0
- package/src/core/contexts/modal/ConfirmModal/ConfirmModal.tsx +72 -0
- package/src/core/contexts/modal/EmbedModal/EmbedModal.tsx +57 -0
- package/src/core/contexts/modal/ModalProvider.tsx +114 -0
- package/src/core/contexts/modal/modal.ts +36 -0
- package/src/core/createReactEditor.ts +7 -0
- package/src/core/createRenderElement.ts +6 -0
- package/src/core/createRenderElements.ts +6 -0
- package/src/core/createRenderMark.ts +6 -0
- package/src/core/index.ts +53 -0
- package/src/core/typings/descendant.ts +3 -0
- package/src/core/typings/handler.ts +32 -0
- package/src/core/typings/renderer.ts +33 -0
- package/src/core/typings/with.ts +5 -0
- package/strikethrough/jsx-serializer/package.json +6 -3
- package/strikethrough/jsx-serializer/src/createJsxSerializeStrikethrough.ts +8 -0
- package/strikethrough/jsx-serializer/tsconfig.build.json +5 -0
- package/strikethrough/package.json +5 -3
- package/strikethrough/src/constants.ts +6 -0
- package/strikethrough/src/createReactStrikethrough.ts +11 -0
- package/strikethrough/src/defaultRenderStrikethrough.tsx +12 -0
- package/strikethrough/src/typings.ts +6 -0
- package/strikethrough/tsconfig.build.json +5 -0
- package/table/jsx-serializer/package.json +6 -3
- package/table/jsx-serializer/src/components/Table.tsx +6 -0
- package/table/jsx-serializer/src/components/TableBody.tsx +6 -0
- package/table/jsx-serializer/src/components/TableCell.tsx +51 -0
- package/table/jsx-serializer/src/components/TableHeader.tsx +16 -0
- package/table/jsx-serializer/src/components/TableMain.tsx +36 -0
- package/table/jsx-serializer/src/components/TableRow.tsx +6 -0
- package/table/jsx-serializer/src/components/TableTitle.tsx +6 -0
- package/table/jsx-serializer/src/contexts/TableHeaderContext.ts +3 -0
- package/table/jsx-serializer/src/contexts/TableScrollContext.ts +6 -0
- package/table/jsx-serializer/src/createJsxSerializeTable.tsx +163 -0
- package/table/jsx-serializer/src/defaultRenderTableElements.tsx +19 -0
- package/table/jsx-serializer/src/typings.ts +36 -0
- package/table/jsx-serializer/tsconfig.build.json +5 -0
- package/table/package.json +12 -3
- package/table/src/components/ColumnDragButton.tsx +72 -0
- package/table/src/components/RowDragButton.tsx +69 -0
- package/table/src/components/Table.tsx +351 -0
- package/table/src/components/TableBody.tsx +15 -0
- package/table/src/components/TableCell.tsx +415 -0
- package/table/src/components/TableDragLayer.tsx +127 -0
- package/table/src/components/TableHeader.tsx +26 -0
- package/table/src/components/TableMain.tsx +322 -0
- package/table/src/components/TableRow.tsx +11 -0
- package/table/src/components/TableTitle.tsx +28 -0
- package/table/src/contexts/TableActionsContext.ts +23 -0
- package/table/src/contexts/TableDragContext.tsx +58 -0
- package/table/src/contexts/TableHeaderContext.ts +6 -0
- package/table/src/contexts/TableMetadataContext.ts +21 -0
- package/table/src/contexts/TableScrollContext.ts +8 -0
- package/table/src/contexts/TableStateContext.ts +9 -0
- package/table/src/createReactTable.ts +371 -0
- package/table/src/defaultRenderTableElements.tsx +19 -0
- package/table/src/hooks/useColumnResize.ts +242 -0
- package/table/src/hooks/useTableActions.ts +1394 -0
- package/table/src/hooks/useTableActionsContext.ts +12 -0
- package/table/src/hooks/useTableCell.ts +223 -0
- package/table/src/hooks/useTableCellToolbarActions.tsx +694 -0
- package/table/src/hooks/useTableMetadata.ts +12 -0
- package/table/src/hooks/useTableStateContext.ts +12 -0
- package/table/src/hooks/useTableStates.ts +14 -0
- package/table/src/typings.ts +107 -0
- package/table/src/utils/helper.ts +1106 -0
- package/table/toolbar/package.json +6 -3
- package/table/toolbar/src/TableToolbarIcon.tsx +17 -0
- package/table/toolbar/src/useTableTool.ts +14 -0
- package/table/toolbar/tsconfig.build.json +5 -0
- package/table/tsconfig.build.json +5 -0
- package/toggle-mark/jsx-serializer/package.json +6 -3
- package/toggle-mark/jsx-serializer/src/createJsxSerializeToggleMarkCreator.ts +12 -0
- package/toggle-mark/jsx-serializer/src/index.ts +6 -0
- package/toggle-mark/jsx-serializer/src/typings.ts +3 -0
- package/toggle-mark/jsx-serializer/tsconfig.build.json +5 -0
- package/toggle-mark/package.json +5 -3
- package/toggle-mark/src/createReactToggleMarkCreator.ts +33 -0
- package/toggle-mark/src/index.ts +6 -0
- package/toggle-mark/src/typings.ts +24 -0
- package/toggle-mark/toolbar/package.json +6 -3
- package/toggle-mark/toolbar/src/ToggleMarkToolbarIcon.tsx +17 -0
- package/toggle-mark/toolbar/src/useToggleMarkTool.ts +11 -0
- package/toggle-mark/toolbar/tsconfig.build.json +5 -0
- package/toggle-mark/tsconfig.build.json +5 -0
- package/toolbar/package.json +9 -3
- package/toolbar/src/components/InlineToolbar.tsx +81 -0
- package/toolbar/src/components/Toolbar.tsx +243 -0
- package/toolbar/src/components/ToolbarGroupIcon.tsx +131 -0
- package/toolbar/src/components/ToolbarIcon.tsx +84 -0
- package/toolbar/src/components/ToolbarInput.tsx +66 -0
- package/toolbar/src/components/toolbarIconName.ts +125 -0
- package/toolbar/src/constants.tsx +6 -0
- package/toolbar/src/contexts/StartToolInputContext.ts +4 -0
- package/toolbar/src/contexts/toolbar.ts +14 -0
- package/toolbar/src/contexts/toolbarMenu.ts +15 -0
- package/toolbar/src/hooks/useAutoGroupIcons.tsx +98 -0
- package/toolbar/src/hooks/useStartToolInput.ts +6 -0
- package/toolbar/src/index.ts +7 -0
- package/toolbar/src/typings.ts +8 -0
- package/toolbar/tsconfig.build.json +5 -0
- package/tsconfig.build.json +8 -0
- package/underline/jsx-serializer/package.json +6 -3
- package/underline/jsx-serializer/src/createJsxSerializeUnderline.ts +8 -0
- package/underline/jsx-serializer/tsconfig.build.json +5 -0
- package/underline/package.json +5 -3
- package/underline/src/constants.ts +6 -0
- package/underline/src/createReactUnderline.ts +11 -0
- package/underline/src/defaultRenderUnderline.tsx +12 -0
- package/underline/src/typings.ts +6 -0
- package/underline/tsconfig.build.json +5 -0
- package/utils/package.json +1 -4
- package/utils/src/composeRefs.ts +34 -0
- package/utils/src/removePreviousElement.ts +62 -0
- package/utils/src/upload.ts +83 -0
- package/utils/src/useClickAway.ts +34 -0
- package/utils/src/useDocumentEvents.ts +35 -0
- package/utils/src/useIsomorphicLayoutEffect.ts +8 -0
- package/utils/src/usePreviousValue.ts +11 -0
- package/utils/tsconfig.build.json +5 -0
- package/LICENSE +0 -21
- package/_internal/index.cjs.js +0 -59
- package/_internal/index.js +0 -5
- package/_internal/renderer/composeRenderElementsBase.d.ts +0 -3
- package/_internal/renderer/composeRenderElementsBase.js +0 -13
- package/_internal/renderer/composeRenderLeafsBase.d.ts +0 -3
- package/_internal/renderer/composeRenderLeafsBase.js +0 -11
- package/_internal/renderer/createRenderElementBase.d.ts +0 -3
- package/_internal/renderer/createRenderElementBase.js +0 -9
- package/_internal/renderer/createRenderElementsBase.d.ts +0 -3
- package/_internal/renderer/createRenderElementsBase.js +0 -11
- package/_internal/renderer/createRenderMarkBase.d.ts +0 -3
- package/_internal/renderer/createRenderMarkBase.js +0 -13
- package/_internal/renderer/typings.d.ts +0 -19
- package/accordion/accordion.css +0 -1
- package/accordion/components/Accordion.d.ts +0 -9
- package/accordion/components/Accordion.js +0 -22
- package/accordion/components/AccordionContent.d.ts +0 -8
- package/accordion/components/AccordionContent.js +0 -24
- package/accordion/components/AccordionTitle.d.ts +0 -8
- package/accordion/components/AccordionTitle.js +0 -20
- package/accordion/contexts/AccordionContext.d.ts +0 -2
- package/accordion/contexts/AccordionContext.js +0 -5
- package/accordion/createReactAccordion.d.ts +0 -4
- package/accordion/createReactAccordion.js +0 -144
- package/accordion/defaultRenderAccordionElements.d.ts +0 -2
- package/accordion/defaultRenderAccordionElements.js +0 -12
- package/accordion/hooks/useAccordion.d.ts +0 -1
- package/accordion/hooks/useAccordion.js +0 -8
- package/accordion/index.cjs.js +0 -212
- package/accordion/index.js +0 -10
- package/accordion/jsx-serializer/createJsxSerializeAccordion.d.ts +0 -5
- package/accordion/jsx-serializer/createJsxSerializeAccordion.js +0 -48
- package/accordion/jsx-serializer/defaultRenderAccordionElements.d.ts +0 -2
- package/accordion/jsx-serializer/defaultRenderAccordionElements.js +0 -16
- package/accordion/jsx-serializer/index.cjs.js +0 -64
- package/accordion/jsx-serializer/index.js +0 -2
- package/accordion/jsx-serializer/typings.d.ts +0 -4
- package/accordion/toolbar/AccordionToolbarIcon.d.ts +0 -8
- package/accordion/toolbar/AccordionToolbarIcon.js +0 -12
- package/accordion/toolbar/index.cjs.js +0 -22
- package/accordion/toolbar/index.d.ts +0 -2
- package/accordion/toolbar/index.js +0 -2
- package/accordion/toolbar/useAccordionTool.d.ts +0 -4
- package/accordion/toolbar/useAccordionTool.js +0 -10
- package/accordion/typings.d.ts +0 -25
- package/align/constants.d.ts +0 -8
- package/align/constants.js +0 -10
- package/align/createReactAlign.d.ts +0 -2
- package/align/createReactAlign.js +0 -26
- package/align/index.cjs.js +0 -39
- package/align/index.js +0 -2
- package/align/toolbar/AlignToolbarIcon.d.ts +0 -10
- package/align/toolbar/AlignToolbarIcon.js +0 -12
- package/align/toolbar/index.cjs.js +0 -30
- package/align/toolbar/index.d.ts +0 -2
- package/align/toolbar/index.js +0 -2
- package/align/toolbar/useAlignTool.d.ts +0 -6
- package/align/toolbar/useAlignTool.js +0 -18
- package/align/typings.d.ts +0 -17
- package/blockquote/blockquote.css +0 -1
- package/blockquote/constants.d.ts +0 -6
- package/blockquote/constants.js +0 -8
- package/blockquote/createReactBlockquote.d.ts +0 -5
- package/blockquote/createReactBlockquote.js +0 -69
- package/blockquote/defaultRenderBlockquoteElement.d.ts +0 -6
- package/blockquote/defaultRenderBlockquoteElement.js +0 -7
- package/blockquote/index.cjs.js +0 -83
- package/blockquote/index.js +0 -3
- package/blockquote/jsx-serializer/createJsxSerializeBlockquote.d.ts +0 -4
- package/blockquote/jsx-serializer/createJsxSerializeBlockquote.js +0 -10
- package/blockquote/jsx-serializer/index.cjs.js +0 -13
- package/blockquote/jsx-serializer/index.js +0 -2
- package/blockquote/jsx-serializer/typings.d.ts +0 -3
- package/blockquote/toolbar/BlockquoteToolbarIcon.d.ts +0 -8
- package/blockquote/toolbar/BlockquoteToolbarIcon.js +0 -12
- package/blockquote/toolbar/index.cjs.js +0 -23
- package/blockquote/toolbar/index.js +0 -2
- package/blockquote/toolbar/useBlockquoteTool.d.ts +0 -5
- package/blockquote/toolbar/useBlockquoteTool.js +0 -11
- package/blockquote/typings.d.ts +0 -16
- package/bold/constants.d.ts +0 -6
- package/bold/constants.js +0 -8
- package/bold/createReactBold.d.ts +0 -1
- package/bold/createReactBold.js +0 -11
- package/bold/defaultRenderBold.d.ts +0 -3
- package/bold/defaultRenderBold.js +0 -7
- package/bold/index.cjs.js +0 -24
- package/bold/index.js +0 -3
- package/bold/jsx-serializer/createJsxSerializeBold.d.ts +0 -1
- package/bold/jsx-serializer/createJsxSerializeBold.js +0 -10
- package/bold/jsx-serializer/index.cjs.js +0 -13
- package/bold/jsx-serializer/index.js +0 -2
- package/bold/typings.d.ts +0 -5
- package/card/card.css +0 -1
- package/card/components/Card.d.ts +0 -15
- package/card/components/Card.js +0 -109
- package/card/components/CardContents.d.ts +0 -9
- package/card/components/CardContents.js +0 -18
- package/card/components/CardImage.d.ts +0 -9
- package/card/components/CardImage.js +0 -13
- package/card/components/CardPlaceholder.d.ts +0 -4
- package/card/components/CardPlaceholder.js +0 -21
- package/card/createReactCard.d.ts +0 -4
- package/card/createReactCard.js +0 -82
- package/card/defaultRenderCardElements.d.ts +0 -3
- package/card/defaultRenderCardElements.js +0 -14
- package/card/index.cjs.js +0 -242
- package/card/index.js +0 -6
- package/card/jsx-serializer/createJsxSerializeCard.d.ts +0 -5
- package/card/jsx-serializer/createJsxSerializeCard.js +0 -48
- package/card/jsx-serializer/defaultRenderCardElements.d.ts +0 -2
- package/card/jsx-serializer/defaultRenderCardElements.js +0 -10
- package/card/jsx-serializer/index.cjs.js +0 -58
- package/card/jsx-serializer/index.js +0 -2
- package/card/jsx-serializer/typings.d.ts +0 -9
- package/card/toolbar/CardToolbarIcon.d.ts +0 -8
- package/card/toolbar/CardToolbarIcon.js +0 -12
- package/card/toolbar/index.cjs.js +0 -52
- package/card/toolbar/index.js +0 -2
- package/card/toolbar/useCardTool.d.ts +0 -4
- package/card/toolbar/useCardTool.js +0 -41
- package/card/typings.d.ts +0 -24
- package/carousel/carousel.css +0 -1
- package/carousel/components/Carousel.d.ts +0 -15
- package/carousel/components/Carousel.js +0 -66
- package/carousel/components/CarouselCaption.d.ts +0 -9
- package/carousel/components/CarouselCaption.js +0 -12
- package/carousel/components/CarouselImages.d.ts +0 -9
- package/carousel/components/CarouselImages.js +0 -52
- package/carousel/components/CarouselPlaceholder.d.ts +0 -4
- package/carousel/components/CarouselPlaceholder.js +0 -17
- package/carousel/contexts/CarouselContext.d.ts +0 -2
- package/carousel/contexts/CarouselContext.js +0 -5
- package/carousel/createReactCarousel.d.ts +0 -4
- package/carousel/createReactCarousel.js +0 -82
- package/carousel/defaultRenderCarouselElements.d.ts +0 -3
- package/carousel/defaultRenderCarouselElements.js +0 -14
- package/carousel/hooks/useCarousel.d.ts +0 -1
- package/carousel/hooks/useCarousel.js +0 -8
- package/carousel/index.cjs.js +0 -236
- package/carousel/index.js +0 -8
- package/carousel/jsx-serializer/createJsxSerializeCarousel.d.ts +0 -5
- package/carousel/jsx-serializer/createJsxSerializeCarousel.js +0 -48
- package/carousel/jsx-serializer/defaultRenderCarouselElements.d.ts +0 -2
- package/carousel/jsx-serializer/defaultRenderCarouselElements.js +0 -10
- package/carousel/jsx-serializer/index.cjs.js +0 -58
- package/carousel/jsx-serializer/index.js +0 -2
- package/carousel/jsx-serializer/typings.d.ts +0 -9
- package/carousel/toolbar/CarouselToolbarIcon.d.ts +0 -8
- package/carousel/toolbar/CarouselToolbarIcon.js +0 -12
- package/carousel/toolbar/index.cjs.js +0 -43
- package/carousel/toolbar/index.js +0 -2
- package/carousel/toolbar/useCarouselTool.d.ts +0 -4
- package/carousel/toolbar/useCarouselTool.js +0 -32
- package/carousel/typings.d.ts +0 -27
- package/components/BaseField/index.d.ts +0 -11
- package/components/BaseField/index.js +0 -17
- package/components/Button/index.d.ts +0 -14
- package/components/Button/index.js +0 -12
- package/components/Hint/index.d.ts +0 -15
- package/components/Hint/index.js +0 -30
- package/components/Icon/index.d.ts +0 -15
- package/components/Icon/index.js +0 -21
- package/components/ImageUploader/index.d.ts +0 -25
- package/components/ImageUploader/index.js +0 -174
- package/components/Input/index.d.ts +0 -14
- package/components/Input/index.js +0 -24
- package/components/Message/index.d.ts +0 -18
- package/components/Message/index.js +0 -72
- package/components/Modal/index.d.ts +0 -28
- package/components/Modal/index.js +0 -61
- package/components/Notifier/NotifierManager.d.ts +0 -17
- package/components/Notifier/NotifierManager.js +0 -24
- package/components/Notifier/createNotifier.d.ts +0 -21
- package/components/Notifier/createNotifier.js +0 -60
- package/components/Notifier/typings.d.ts +0 -28
- package/components/Portal/index.d.ts +0 -7
- package/components/Portal/index.js +0 -8
- package/components/Progress/index.d.ts +0 -7
- package/components/Progress/index.js +0 -20
- package/components/SegmentedControl/index.d.ts +0 -13
- package/components/SegmentedControl/index.js +0 -14
- package/components/Textarea/index.d.ts +0 -15
- package/components/Textarea/index.js +0 -24
- package/components/Toggle/index.d.ts +0 -8
- package/components/Toggle/index.js +0 -15
- package/components/Tooltip/calculatePosition.d.ts +0 -5
- package/components/Tooltip/calculatePosition.js +0 -69
- package/components/Tooltip/index.d.ts +0 -10
- package/components/Tooltip/index.js +0 -124
- package/components/Tooltip/typings.d.ts +0 -29
- package/components/Transition/SlideFade.d.ts +0 -20
- package/components/Transition/SlideFade.js +0 -91
- package/components/Transition/Transition.d.ts +0 -98
- package/components/Transition/Transition.js +0 -27
- package/components/Transition/getTransitionStyleProps.d.ts +0 -16
- package/components/Transition/getTransitionStyleProps.js +0 -25
- package/components/Transition/useSetNodeTransition.d.ts +0 -7
- package/components/Transition/useSetNodeTransition.js +0 -35
- package/components/baseField.css +0 -1
- package/components/button.css +0 -1
- package/components/components.css +0 -1
- package/components/hint.css +0 -1
- package/components/imageUploader.css +0 -1
- package/components/index.cjs.js +0 -867
- package/components/index.d.ts +0 -16
- package/components/index.js +0 -15
- package/components/input.css +0 -1
- package/components/message.css +0 -1
- package/components/modal.css +0 -1
- package/components/progress.css +0 -1
- package/components/segmentedControl.css +0 -1
- package/components/textarea.css +0 -1
- package/components/toggle.css +0 -1
- package/components/tooltip.css +0 -1
- package/configs/ConfigsProvider.d.ts +0 -18
- package/configs/ConfigsProvider.js +0 -15
- package/configs/index.cjs.js +0 -58
- package/configs/index.js +0 -3
- package/configs/locale.d.ts +0 -3
- package/configs/locale.js +0 -9
- package/configs/theme.d.ts +0 -18
- package/configs/theme.js +0 -34
- package/core/components/DefaultElement.d.ts +0 -4
- package/core/components/DefaultElement.js +0 -5
- package/core/components/DefaultLeaf.d.ts +0 -4
- package/core/components/DefaultLeaf.js +0 -5
- package/core/components/Editable.d.ts +0 -9
- package/core/components/Editable.js +0 -71
- package/core/components/Quadrats.d.ts +0 -16
- package/core/components/Quadrats.js +0 -21
- package/core/composeHandlers.d.ts +0 -8
- package/core/composeHandlers.js +0 -33
- package/core/composeRenderElements.d.ts +0 -6
- package/core/composeRenderElements.js +0 -12
- package/core/composeRenderLeafs.d.ts +0 -6
- package/core/composeRenderLeafs.js +0 -12
- package/core/constants.d.ts +0 -1
- package/core/constants.js +0 -3
- package/core/contexts/composition/CompositionProvider.d.ts +0 -8
- package/core/contexts/composition/CompositionProvider.js +0 -8
- package/core/contexts/composition/composition.d.ts +0 -7
- package/core/contexts/composition/composition.js +0 -11
- package/core/contexts/message/MessageProvider.d.ts +0 -5
- package/core/contexts/message/MessageProvider.js +0 -35
- package/core/contexts/message/message.d.ts +0 -10
- package/core/contexts/message/message.js +0 -10
- package/core/contexts/modal/CardModal/CardModal.d.ts +0 -28
- package/core/contexts/modal/CardModal/CardModal.js +0 -111
- package/core/contexts/modal/CarouselModal/CarouselItem.d.ts +0 -15
- package/core/contexts/modal/CarouselModal/CarouselItem.js +0 -46
- package/core/contexts/modal/CarouselModal/CarouselModal.d.ts +0 -11
- package/core/contexts/modal/CarouselModal/CarouselModal.js +0 -169
- package/core/contexts/modal/CarouselModal/FilesDropZone.d.ts +0 -13
- package/core/contexts/modal/CarouselModal/FilesDropZone.js +0 -64
- package/core/contexts/modal/ConfirmModal/ConfirmModal.d.ts +0 -14
- package/core/contexts/modal/ConfirmModal/ConfirmModal.js +0 -24
- package/core/contexts/modal/EmbedModal/EmbedModal.d.ts +0 -11
- package/core/contexts/modal/EmbedModal/EmbedModal.js +0 -27
- package/core/contexts/modal/ModalProvider.d.ts +0 -8
- package/core/contexts/modal/ModalProvider.js +0 -66
- package/core/contexts/modal/modal.d.ts +0 -24
- package/core/contexts/modal/modal.js +0 -15
- package/core/createReactEditor.d.ts +0 -2
- package/core/createReactEditor.js +0 -8
- package/core/createRenderElement.d.ts +0 -2
- package/core/createRenderElement.js +0 -7
- package/core/createRenderElements.d.ts +0 -2
- package/core/createRenderElements.js +0 -7
- package/core/createRenderMark.d.ts +0 -2
- package/core/createRenderMark.js +0 -7
- package/core/index.d.ts +0 -37
- package/core/typings/descendant.d.ts +0 -2
- package/core/typings/handler.d.ts +0 -15
- package/core/typings/renderer.d.ts +0 -15
- package/core/typings/with.d.ts +0 -4
- package/divider/createReactDivider.d.ts +0 -4
- package/divider/createReactDivider.js +0 -11
- package/divider/defaultRenderDividerElement.d.ts +0 -3
- package/divider/defaultRenderDividerElement.js +0 -6
- package/divider/divider.css +0 -1
- package/divider/index.cjs.js +0 -17
- package/divider/index.js +0 -2
- package/divider/jsx-serializer/createJsxSerializeDivider.d.ts +0 -4
- package/divider/jsx-serializer/createJsxSerializeDivider.js +0 -10
- package/divider/jsx-serializer/defaultRenderDividerElement.d.ts +0 -2
- package/divider/jsx-serializer/defaultRenderDividerElement.js +0 -6
- package/divider/jsx-serializer/index.cjs.js +0 -16
- package/divider/jsx-serializer/index.js +0 -2
- package/divider/jsx-serializer/typings.d.ts +0 -3
- package/divider/toolbar/DividerToolbarIcon.d.ts +0 -8
- package/divider/toolbar/DividerToolbarIcon.js +0 -12
- package/divider/toolbar/index.cjs.js +0 -22
- package/divider/toolbar/index.d.ts +0 -2
- package/divider/toolbar/index.js +0 -2
- package/divider/toolbar/useDividerTool.d.ts +0 -4
- package/divider/toolbar/useDividerTool.js +0 -10
- package/divider/typings.d.ts +0 -10
- package/editable.css +0 -1
- package/embed/components/VideoIframe.d.ts +0 -12
- package/embed/components/VideoIframe.js +0 -16
- package/embed/createReactEmbed.d.ts +0 -4
- package/embed/createReactEmbed.js +0 -17
- package/embed/createRenderEmbedElementBase.d.ts +0 -10
- package/embed/createRenderEmbedElementBase.js +0 -16
- package/embed/embed.css +0 -1
- package/embed/hooks/useVideoIframeSize.d.ts +0 -7
- package/embed/hooks/useVideoIframeSize.js +0 -24
- package/embed/index.cjs.js +0 -68
- package/embed/index.js +0 -4
- package/embed/jsx-serializer/createJsxSerializeEmbed.d.ts +0 -9
- package/embed/jsx-serializer/createJsxSerializeEmbed.js +0 -13
- package/embed/jsx-serializer/facebook/index.cjs.js +0 -16
- package/embed/jsx-serializer/facebook/index.js +0 -1
- package/embed/jsx-serializer/index.cjs.js +0 -15
- package/embed/jsx-serializer/index.js +0 -1
- package/embed/jsx-serializer/instagram/index.cjs.js +0 -16
- package/embed/jsx-serializer/instagram/index.js +0 -1
- package/embed/jsx-serializer/twitter/index.cjs.js +0 -16
- package/embed/jsx-serializer/twitter/index.js +0 -1
- package/embed/jsx-serializer/typings.d.ts +0 -5
- package/embed/jsx-serializer/vimeo/index.cjs.js +0 -16
- package/embed/jsx-serializer/vimeo/index.js +0 -1
- package/embed/jsx-serializer/youtube/index.cjs.js +0 -7
- package/embed/jsx-serializer/youtube/index.js +0 -1
- package/embed/renderers/base/components/BaseEmbedElement.d.ts +0 -21
- package/embed/renderers/base/components/BaseEmbedElement.js +0 -70
- package/embed/renderers/base/index.cjs.js +0 -73
- package/embed/renderers/base/index.d.ts +0 -1
- package/embed/renderers/base/index.js +0 -1
- package/embed/renderers/facebook/components/Facebook.d.ts +0 -12
- package/embed/renderers/facebook/components/Facebook.js +0 -23
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.d.ts +0 -5
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.js +0 -46
- package/embed/renderers/facebook/index.cjs.js +0 -70
- package/embed/renderers/facebook/index.js +0 -2
- package/embed/renderers/instagram/components/Instagram.d.ts +0 -12
- package/embed/renderers/instagram/components/Instagram.js +0 -53
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.d.ts +0 -5
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.js +0 -46
- package/embed/renderers/instagram/hooks/useLoadInstagramEmbedApi.d.ts +0 -1
- package/embed/renderers/instagram/hooks/useLoadInstagramEmbedApi.js +0 -27
- package/embed/renderers/instagram/index.cjs.js +0 -124
- package/embed/renderers/instagram/index.js +0 -3
- package/embed/renderers/podcast-apple/components/PodcastApple.d.ts +0 -11
- package/embed/renderers/podcast-apple/components/PodcastApple.js +0 -13
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.d.ts +0 -5
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.js +0 -39
- package/embed/renderers/podcast-apple/index.cjs.js +0 -53
- package/embed/renderers/podcast-apple/index.js +0 -2
- package/embed/renderers/spotify/components/Spotify.d.ts +0 -12
- package/embed/renderers/spotify/components/Spotify.js +0 -18
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.d.ts +0 -5
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.js +0 -36
- package/embed/renderers/spotify/index.cjs.js +0 -55
- package/embed/renderers/spotify/index.js +0 -2
- package/embed/renderers/twitter/components/Twitter.d.ts +0 -12
- package/embed/renderers/twitter/components/Twitter.js +0 -24
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.d.ts +0 -5
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.js +0 -46
- package/embed/renderers/twitter/hooks/useLoadTwitterEmbedApi.d.ts +0 -2
- package/embed/renderers/twitter/hooks/useLoadTwitterEmbedApi.js +0 -33
- package/embed/renderers/twitter/index.cjs.js +0 -101
- package/embed/renderers/twitter/index.js +0 -3
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.d.ts +0 -6
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.js +0 -30
- package/embed/renderers/vimeo/index.cjs.js +0 -34
- package/embed/renderers/vimeo/index.js +0 -1
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.d.ts +0 -6
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.js +0 -30
- package/embed/renderers/youtube/index.cjs.js +0 -34
- package/embed/renderers/youtube/index.js +0 -1
- package/embed/toolbar/EmbedToolbarIcon.d.ts +0 -12
- package/embed/toolbar/EmbedToolbarIcon.js +0 -12
- package/embed/toolbar/index.cjs.js +0 -98
- package/embed/toolbar/index.d.ts +0 -2
- package/embed/toolbar/index.js +0 -2
- package/embed/toolbar/useEmbedTool.d.ts +0 -4
- package/embed/toolbar/useEmbedTool.js +0 -87
- package/embed/typings.d.ts +0 -15
- package/file-uploader/components/FileUploader.d.ts +0 -4
- package/file-uploader/components/FileUploader.js +0 -13
- package/file-uploader/createReactFileUploader.d.ts +0 -5
- package/file-uploader/createReactFileUploader.js +0 -17
- package/file-uploader/defaultRenderFileUploaderElement.d.ts +0 -2
- package/file-uploader/defaultRenderFileUploaderElement.js +0 -6
- package/file-uploader/file-uploader.css +0 -1
- package/file-uploader/hooks/useFileUploader.d.ts +0 -4
- package/file-uploader/hooks/useFileUploader.js +0 -13
- package/file-uploader/index.cjs.js +0 -42
- package/file-uploader/index.js +0 -4
- package/file-uploader/toolbar/FileUploaderToolbarIcon.d.ts +0 -10
- package/file-uploader/toolbar/FileUploaderToolbarIcon.js +0 -12
- package/file-uploader/toolbar/index.cjs.js +0 -25
- package/file-uploader/toolbar/index.d.ts +0 -2
- package/file-uploader/toolbar/index.js +0 -2
- package/file-uploader/toolbar/useFileUploaderTool.d.ts +0 -5
- package/file-uploader/toolbar/useFileUploaderTool.js +0 -13
- package/file-uploader/typings.d.ts +0 -14
- package/footnote/createReactFootnote.d.ts +0 -4
- package/footnote/createReactFootnote.js +0 -13
- package/footnote/defaultRenderFootnoteElement.d.ts +0 -9
- package/footnote/defaultRenderFootnoteElement.js +0 -15
- package/footnote/index.cjs.js +0 -71
- package/footnote/index.js +0 -4
- package/footnote/jsx-serializer/createJsxSerializeFootnote.d.ts +0 -4
- package/footnote/jsx-serializer/createJsxSerializeFootnote.js +0 -11
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.d.ts +0 -5
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.js +0 -12
- package/footnote/jsx-serializer/index.cjs.js +0 -23
- package/footnote/jsx-serializer/index.js +0 -2
- package/footnote/jsx-serializer/typings.d.ts +0 -3
- package/footnote/toolbar/FootnoteToolbarIcon.d.ts +0 -10
- package/footnote/toolbar/FootnoteToolbarIcon.js +0 -12
- package/footnote/toolbar/index.cjs.js +0 -30
- package/footnote/toolbar/index.d.ts +0 -2
- package/footnote/toolbar/index.js +0 -2
- package/footnote/toolbar/useFootnoteTool.d.ts +0 -7
- package/footnote/toolbar/useFootnoteTool.js +0 -19
- package/footnote/typings.d.ts +0 -9
- package/footnote/useFootnotes.d.ts +0 -4
- package/footnote/useFootnotes.js +0 -21
- package/footnote/useFootnotesFromNodes.d.ts +0 -4
- package/footnote/useFootnotesFromNodes.js +0 -27
- package/heading/constants.d.ts +0 -9
- package/heading/constants.js +0 -11
- package/heading/createReactHeading.d.ts +0 -4
- package/heading/createReactHeading.js +0 -47
- package/heading/defaultRenderHeadingElement.d.ts +0 -16
- package/heading/defaultRenderHeadingElement.js +0 -20
- package/heading/heading.css +0 -1
- package/heading/index.cjs.js +0 -77
- package/heading/index.js +0 -3
- package/heading/jsx-serializer/createJsxSerializeHeading.d.ts +0 -4
- package/heading/jsx-serializer/createJsxSerializeHeading.js +0 -10
- package/heading/jsx-serializer/index.cjs.js +0 -13
- package/heading/jsx-serializer/index.js +0 -2
- package/heading/jsx-serializer/typings.d.ts +0 -3
- package/heading/toolbar/HeadingToolbarIcon.d.ts +0 -10
- package/heading/toolbar/HeadingToolbarIcon.js +0 -12
- package/heading/toolbar/index.cjs.js +0 -23
- package/heading/toolbar/index.d.ts +0 -2
- package/heading/toolbar/index.js +0 -2
- package/heading/toolbar/useToggleHeadingTool.d.ts +0 -6
- package/heading/toolbar/useToggleHeadingTool.js +0 -11
- package/heading/typings.d.ts +0 -15
- package/highlight/constants.d.ts +0 -6
- package/highlight/constants.js +0 -8
- package/highlight/createReactHighlight.d.ts +0 -1
- package/highlight/createReactHighlight.js +0 -11
- package/highlight/defaultRenderHighlight.d.ts +0 -3
- package/highlight/defaultRenderHighlight.js +0 -7
- package/highlight/index.cjs.js +0 -24
- package/highlight/index.js +0 -3
- package/highlight/jsx-serializer/createJsxSerializeHighlight.d.ts +0 -1
- package/highlight/jsx-serializer/createJsxSerializeHighlight.js +0 -10
- package/highlight/jsx-serializer/index.cjs.js +0 -13
- package/highlight/jsx-serializer/index.js +0 -2
- package/highlight/typings.d.ts +0 -5
- package/image/components/Image.d.ts +0 -4
- package/image/components/Image.js +0 -68
- package/image/components/ImageCaption.d.ts +0 -4
- package/image/components/ImageCaption.js +0 -23
- package/image/components/ImageFigure.d.ts +0 -4
- package/image/components/ImageFigure.js +0 -15
- package/image/components/ImagePlaceholder.d.ts +0 -4
- package/image/components/ImagePlaceholder.js +0 -11
- package/image/createReactImage.d.ts +0 -8
- package/image/createReactImage.js +0 -121
- package/image/defaultRenderImageElements.d.ts +0 -2
- package/image/defaultRenderImageElements.js +0 -12
- package/image/hooks/useImageResizer.d.ts +0 -7
- package/image/hooks/useImageResizer.js +0 -95
- package/image/image.css +0 -1
- package/image/index.cjs.js +0 -324
- package/image/index.js +0 -7
- package/image/jsx-serializer/createJsxSerializeImage.d.ts +0 -7
- package/image/jsx-serializer/createJsxSerializeImage.js +0 -42
- package/image/jsx-serializer/defaultRenderImageElements.d.ts +0 -2
- package/image/jsx-serializer/defaultRenderImageElements.js +0 -10
- package/image/jsx-serializer/index.cjs.js +0 -52
- package/image/jsx-serializer/index.js +0 -2
- package/image/jsx-serializer/typings.d.ts +0 -18
- package/image/typings.d.ts +0 -22
- package/index.cjs.js +0 -709
- package/index.js +0 -21
- package/input-block/components/InputBlock.d.ts +0 -4
- package/input-block/components/InputBlock.js +0 -35
- package/input-block/createReactInputBlock.d.ts +0 -4
- package/input-block/createReactInputBlock.js +0 -17
- package/input-block/defaultRenderInputBlockElement.d.ts +0 -2
- package/input-block/defaultRenderInputBlockElement.js +0 -6
- package/input-block/hooks/useInputBlock.d.ts +0 -10
- package/input-block/hooks/useInputBlock.js +0 -57
- package/input-block/index.cjs.js +0 -108
- package/input-block/index.js +0 -4
- package/input-block/input-block.css +0 -1
- package/input-block/typings.d.ts +0 -12
- package/italic/constants.d.ts +0 -6
- package/italic/constants.js +0 -8
- package/italic/createReactItalic.d.ts +0 -1
- package/italic/createReactItalic.js +0 -11
- package/italic/defaultRenderItalic.d.ts +0 -3
- package/italic/defaultRenderItalic.js +0 -7
- package/italic/index.cjs.js +0 -24
- package/italic/index.js +0 -3
- package/italic/jsx-serializer/createJsxSerializeItalic.d.ts +0 -1
- package/italic/jsx-serializer/createJsxSerializeItalic.js +0 -10
- package/italic/jsx-serializer/index.cjs.js +0 -13
- package/italic/jsx-serializer/index.js +0 -2
- package/italic/typings.d.ts +0 -5
- package/jsx-serializer/createJsxSerializeElement.d.ts +0 -2
- package/jsx-serializer/createJsxSerializeElement.js +0 -7
- package/jsx-serializer/createJsxSerializeElements.d.ts +0 -2
- package/jsx-serializer/createJsxSerializeElements.js +0 -7
- package/jsx-serializer/createJsxSerializeMark.d.ts +0 -2
- package/jsx-serializer/createJsxSerializeMark.js +0 -7
- package/jsx-serializer/createJsxSerializer.d.ts +0 -18
- package/jsx-serializer/createJsxSerializer.js +0 -49
- package/jsx-serializer/index.cjs.js +0 -66
- package/jsx-serializer/index.js +0 -4
- package/jsx-serializer/typings.d.ts +0 -8
- package/line-break/commonBreak.d.ts +0 -14
- package/line-break/commonBreak.js +0 -31
- package/line-break/createOnKeyDownBreak.d.ts +0 -11
- package/line-break/createOnKeyDownBreak.js +0 -48
- package/line-break/createReactLineBreak.d.ts +0 -4
- package/line-break/createReactLineBreak.js +0 -14
- package/line-break/defaultRenderLineBreakElement.d.ts +0 -3
- package/line-break/defaultRenderLineBreakElement.js +0 -5
- package/line-break/index.cjs.js +0 -102
- package/line-break/index.js +0 -4
- package/line-break/jsx-serializer/createJsxSerializeLineBreak.d.ts +0 -4
- package/line-break/jsx-serializer/createJsxSerializeLineBreak.js +0 -11
- package/line-break/jsx-serializer/defaultRenderLineBreakElement.d.ts +0 -2
- package/line-break/jsx-serializer/defaultRenderLineBreakElement.js +0 -6
- package/line-break/jsx-serializer/index.cjs.js +0 -17
- package/line-break/jsx-serializer/index.js +0 -2
- package/line-break/jsx-serializer/typings.d.ts +0 -3
- package/line-break/line-break.css +0 -1
- package/line-break/renderLineBreakElementWithSymbol.d.ts +0 -3
- package/line-break/renderLineBreakElementWithSymbol.js +0 -5
- package/line-break/typings.d.ts +0 -32
- package/link/createReactLink.d.ts +0 -11
- package/link/createReactLink.js +0 -29
- package/link/defaultRenderLinkElement.d.ts +0 -9
- package/link/defaultRenderLinkElement.js +0 -13
- package/link/index.cjs.js +0 -42
- package/link/index.js +0 -2
- package/link/jsx-serializer/createJsxSerializeLink.d.ts +0 -4
- package/link/jsx-serializer/createJsxSerializeLink.js +0 -10
- package/link/jsx-serializer/defaultRenderLinkElement.d.ts +0 -3
- package/link/jsx-serializer/defaultRenderLinkElement.js +0 -5
- package/link/jsx-serializer/index.cjs.js +0 -15
- package/link/jsx-serializer/index.js +0 -2
- package/link/jsx-serializer/typings.d.ts +0 -3
- package/link/toolbar/LinkToolbarIcon.d.ts +0 -10
- package/link/toolbar/LinkToolbarIcon.js +0 -12
- package/link/toolbar/UnlinkToolbarIcon.d.ts +0 -8
- package/link/toolbar/UnlinkToolbarIcon.js +0 -12
- package/link/toolbar/index.cjs.js +0 -51
- package/link/toolbar/index.d.ts +0 -4
- package/link/toolbar/index.js +0 -4
- package/link/toolbar/useLinkTool.d.ts +0 -7
- package/link/toolbar/useLinkTool.js +0 -25
- package/link/toolbar/useUnlinkTool.d.ts +0 -4
- package/link/toolbar/useUnlinkTool.js +0 -10
- package/link/typings.d.ts +0 -9
- package/list/createReactList.d.ts +0 -4
- package/list/createReactList.js +0 -35
- package/list/defaultRenderListElements.d.ts +0 -7
- package/list/defaultRenderListElements.js +0 -9
- package/list/index.cjs.js +0 -44
- package/list/index.js +0 -2
- package/list/jsx-serializer/createJsxSerializeList.d.ts +0 -7
- package/list/jsx-serializer/createJsxSerializeList.js +0 -15
- package/list/jsx-serializer/index.cjs.js +0 -18
- package/list/jsx-serializer/index.js +0 -2
- package/list/jsx-serializer/typings.d.ts +0 -3
- package/list/list.css +0 -1
- package/list/toolbar/ListToolbarIcon.d.ts +0 -10
- package/list/toolbar/ListToolbarIcon.js +0 -12
- package/list/toolbar/index.cjs.js +0 -23
- package/list/toolbar/index.d.ts +0 -2
- package/list/toolbar/index.js +0 -2
- package/list/toolbar/useListTool.d.ts +0 -6
- package/list/toolbar/useListTool.js +0 -11
- package/list/typings.d.ts +0 -9
- package/paragraph/createReactParagraph.d.ts +0 -2
- package/paragraph/createReactParagraph.js +0 -8
- package/paragraph/createRenderParagraphElement.d.ts +0 -8
- package/paragraph/createRenderParagraphElement.js +0 -10
- package/paragraph/defaultRenderParagraphElement.d.ts +0 -8
- package/paragraph/defaultRenderParagraphElement.js +0 -8
- package/paragraph/index.cjs.js +0 -31
- package/paragraph/index.js +0 -4
- package/paragraph/jsx-serializer/createJsxSerializeParagraph.d.ts +0 -4
- package/paragraph/jsx-serializer/createJsxSerializeParagraph.js +0 -10
- package/paragraph/jsx-serializer/index.cjs.js +0 -13
- package/paragraph/jsx-serializer/index.js +0 -2
- package/paragraph/jsx-serializer/typings.d.ts +0 -3
- package/paragraph/paragraph.css +0 -1
- package/paragraph/renderParagraphElementWithSymbol.d.ts +0 -8
- package/paragraph/renderParagraphElementWithSymbol.js +0 -8
- package/paragraph/toolbar/ParagraphToolbarIcon.d.ts +0 -8
- package/paragraph/toolbar/ParagraphToolbarIcon.js +0 -12
- package/paragraph/toolbar/index.cjs.js +0 -23
- package/paragraph/toolbar/index.js +0 -2
- package/paragraph/toolbar/useToggleParagraphTool.d.ts +0 -5
- package/paragraph/toolbar/useToggleParagraphTool.js +0 -11
- package/read-more/components/ReadMore.d.ts +0 -8
- package/read-more/components/ReadMore.js +0 -14
- package/read-more/createReactReadMore.d.ts +0 -4
- package/read-more/createReactReadMore.js +0 -11
- package/read-more/defaultRenderReadMoreElement.d.ts +0 -3
- package/read-more/defaultRenderReadMoreElement.js +0 -6
- package/read-more/index.cjs.js +0 -27
- package/read-more/index.js +0 -3
- package/read-more/jsx-serializer/createJsxSerializeReadMore.d.ts +0 -4
- package/read-more/jsx-serializer/createJsxSerializeReadMore.js +0 -10
- package/read-more/jsx-serializer/index.cjs.js +0 -13
- package/read-more/jsx-serializer/index.js +0 -2
- package/read-more/jsx-serializer/typings.d.ts +0 -3
- package/read-more/read-more.css +0 -1
- package/read-more/toolbar/ReadMoreToolbarIcon.d.ts +0 -8
- package/read-more/toolbar/ReadMoreToolbarIcon.js +0 -12
- package/read-more/toolbar/index.cjs.js +0 -22
- package/read-more/toolbar/index.d.ts +0 -2
- package/read-more/toolbar/index.js +0 -2
- package/read-more/toolbar/useReadMoreTool.d.ts +0 -4
- package/read-more/toolbar/useReadMoreTool.js +0 -10
- package/read-more/typings.d.ts +0 -9
- package/strikethrough/constants.d.ts +0 -6
- package/strikethrough/constants.js +0 -8
- package/strikethrough/createReactStrikethrough.d.ts +0 -1
- package/strikethrough/createReactStrikethrough.js +0 -11
- package/strikethrough/defaultRenderStrikethrough.d.ts +0 -3
- package/strikethrough/defaultRenderStrikethrough.js +0 -7
- package/strikethrough/index.cjs.js +0 -24
- package/strikethrough/index.js +0 -3
- package/strikethrough/jsx-serializer/createJsxSerializeStrikethrough.d.ts +0 -1
- package/strikethrough/jsx-serializer/createJsxSerializeStrikethrough.js +0 -10
- package/strikethrough/jsx-serializer/index.cjs.js +0 -13
- package/strikethrough/jsx-serializer/index.js +0 -2
- package/strikethrough/typings.d.ts +0 -5
- package/table/components/ColumnDragButton.d.ts +0 -10
- package/table/components/ColumnDragButton.js +0 -41
- package/table/components/RowDragButton.d.ts +0 -10
- package/table/components/RowDragButton.js +0 -42
- package/table/components/Table.d.ts +0 -9
- package/table/components/Table.js +0 -236
- package/table/components/TableBody.d.ts +0 -5
- package/table/components/TableBody.js +0 -8
- package/table/components/TableCell.d.ts +0 -5
- package/table/components/TableCell.js +0 -297
- package/table/components/TableDragLayer.d.ts +0 -6
- package/table/components/TableDragLayer.js +0 -89
- package/table/components/TableHeader.d.ts +0 -5
- package/table/components/TableHeader.js +0 -13
- package/table/components/TableMain.d.ts +0 -5
- package/table/components/TableMain.js +0 -233
- package/table/components/TableRow.d.ts +0 -5
- package/table/components/TableRow.js +0 -8
- package/table/components/TableTitle.d.ts +0 -5
- package/table/components/TableTitle.js +0 -18
- package/table/contexts/TableActionsContext.d.ts +0 -3
- package/table/contexts/TableActionsContext.js +0 -5
- package/table/contexts/TableDragContext.d.ts +0 -26
- package/table/contexts/TableDragContext.js +0 -26
- package/table/contexts/TableHeaderContext.d.ts +0 -2
- package/table/contexts/TableHeaderContext.js +0 -7
- package/table/contexts/TableMetadataContext.d.ts +0 -3
- package/table/contexts/TableMetadataContext.js +0 -5
- package/table/contexts/TableScrollContext.d.ts +0 -2
- package/table/contexts/TableScrollContext.js +0 -9
- package/table/contexts/TableStateContext.d.ts +0 -3
- package/table/contexts/TableStateContext.js +0 -5
- package/table/createReactTable.d.ts +0 -4
- package/table/createReactTable.js +0 -297
- package/table/defaultRenderTableElements.d.ts +0 -2
- package/table/defaultRenderTableElements.js +0 -20
- package/table/hooks/useColumnResize.d.ts +0 -12
- package/table/hooks/useColumnResize.js +0 -168
- package/table/hooks/useTableActions.d.ts +0 -27
- package/table/hooks/useTableActions.js +0 -1092
- package/table/hooks/useTableActionsContext.d.ts +0 -1
- package/table/hooks/useTableActionsContext.js +0 -12
- package/table/hooks/useTableCell.d.ts +0 -16
- package/table/hooks/useTableCell.js +0 -166
- package/table/hooks/useTableCellToolbarActions.d.ts +0 -34
- package/table/hooks/useTableCellToolbarActions.js +0 -540
- package/table/hooks/useTableMetadata.d.ts +0 -1
- package/table/hooks/useTableMetadata.js +0 -12
- package/table/hooks/useTableStateContext.d.ts +0 -1
- package/table/hooks/useTableStateContext.js +0 -12
- package/table/hooks/useTableStates.d.ts +0 -18
- package/table/hooks/useTableStates.js +0 -14
- package/table/index.cjs.js +0 -4016
- package/table/index.js +0 -27
- package/table/jsx-serializer/components/Table.d.ts +0 -3
- package/table/jsx-serializer/components/Table.js +0 -7
- package/table/jsx-serializer/components/TableBody.d.ts +0 -3
- package/table/jsx-serializer/components/TableBody.js +0 -7
- package/table/jsx-serializer/components/TableCell.d.ts +0 -5
- package/table/jsx-serializer/components/TableCell.js +0 -33
- package/table/jsx-serializer/components/TableHeader.d.ts +0 -3
- package/table/jsx-serializer/components/TableHeader.js +0 -10
- package/table/jsx-serializer/components/TableMain.d.ts +0 -6
- package/table/jsx-serializer/components/TableMain.js +0 -18
- package/table/jsx-serializer/components/TableRow.d.ts +0 -3
- package/table/jsx-serializer/components/TableRow.js +0 -7
- package/table/jsx-serializer/components/TableTitle.d.ts +0 -3
- package/table/jsx-serializer/components/TableTitle.js +0 -7
- package/table/jsx-serializer/contexts/TableHeaderContext.d.ts +0 -1
- package/table/jsx-serializer/contexts/TableHeaderContext.js +0 -5
- package/table/jsx-serializer/contexts/TableScrollContext.d.ts +0 -2
- package/table/jsx-serializer/contexts/TableScrollContext.js +0 -7
- package/table/jsx-serializer/createJsxSerializeTable.d.ts +0 -5
- package/table/jsx-serializer/createJsxSerializeTable.js +0 -113
- package/table/jsx-serializer/defaultRenderTableElements.d.ts +0 -2
- package/table/jsx-serializer/defaultRenderTableElements.js +0 -20
- package/table/jsx-serializer/index.cjs.js +0 -195
- package/table/jsx-serializer/index.js +0 -2
- package/table/jsx-serializer/typings.d.ts +0 -12
- package/table/table.css +0 -1
- package/table/toolbar/TableToolbarIcon.d.ts +0 -8
- package/table/toolbar/TableToolbarIcon.js +0 -12
- package/table/toolbar/index.cjs.js +0 -24
- package/table/toolbar/index.js +0 -2
- package/table/toolbar/useTableTool.d.ts +0 -4
- package/table/toolbar/useTableTool.js +0 -13
- package/table/typings.d.ts +0 -68
- package/table/utils/helper.d.ts +0 -186
- package/table/utils/helper.js +0 -799
- package/toggle-mark/createReactToggleMarkCreator.d.ts +0 -6
- package/toggle-mark/createReactToggleMarkCreator.js +0 -20
- package/toggle-mark/index.cjs.js +0 -22
- package/toggle-mark/index.d.ts +0 -2
- package/toggle-mark/index.js +0 -1
- package/toggle-mark/jsx-serializer/createJsxSerializeToggleMarkCreator.d.ts +0 -4
- package/toggle-mark/jsx-serializer/createJsxSerializeToggleMarkCreator.js +0 -7
- package/toggle-mark/jsx-serializer/index.cjs.js +0 -9
- package/toggle-mark/jsx-serializer/index.d.ts +0 -2
- package/toggle-mark/jsx-serializer/index.js +0 -1
- package/toggle-mark/jsx-serializer/typings.d.ts +0 -2
- package/toggle-mark/toolbar/ToggleMarkToolbarIcon.d.ts +0 -8
- package/toggle-mark/toolbar/ToggleMarkToolbarIcon.js +0 -12
- package/toggle-mark/toolbar/index.cjs.js +0 -23
- package/toggle-mark/toolbar/index.js +0 -2
- package/toggle-mark/toolbar/useToggleMarkTool.d.ts +0 -5
- package/toggle-mark/toolbar/useToggleMarkTool.js +0 -11
- package/toggle-mark/typings.d.ts +0 -12
- package/toolbar/components/InlineToolbar.d.ts +0 -19
- package/toolbar/components/InlineToolbar.js +0 -31
- package/toolbar/components/Toolbar.d.ts +0 -25
- package/toolbar/components/Toolbar.js +0 -137
- package/toolbar/components/ToolbarGroupIcon.d.ts +0 -7
- package/toolbar/components/ToolbarGroupIcon.js +0 -80
- package/toolbar/components/ToolbarIcon.d.ts +0 -9
- package/toolbar/components/ToolbarIcon.js +0 -32
- package/toolbar/components/ToolbarInput.d.ts +0 -8
- package/toolbar/components/ToolbarInput.js +0 -38
- package/toolbar/components/toolbarIconName.d.ts +0 -2
- package/toolbar/components/toolbarIconName.js +0 -86
- package/toolbar/constants.d.ts +0 -5
- package/toolbar/constants.js +0 -8
- package/toolbar/contexts/StartToolInputContext.d.ts +0 -2
- package/toolbar/contexts/StartToolInputContext.js +0 -5
- package/toolbar/contexts/toolbar.d.ts +0 -7
- package/toolbar/contexts/toolbar.js +0 -10
- package/toolbar/contexts/toolbarMenu.d.ts +0 -6
- package/toolbar/contexts/toolbarMenu.js +0 -11
- package/toolbar/hooks/useAutoGroupIcons.d.ts +0 -12
- package/toolbar/hooks/useAutoGroupIcons.js +0 -68
- package/toolbar/hooks/useStartToolInput.d.ts +0 -1
- package/toolbar/hooks/useStartToolInput.js +0 -8
- package/toolbar/index.cjs.js +0 -468
- package/toolbar/index.d.ts +0 -7
- package/toolbar/index.js +0 -6
- package/toolbar/toolbar.css +0 -1
- package/toolbar/typings.d.ts +0 -6
- package/underline/constants.d.ts +0 -6
- package/underline/constants.js +0 -8
- package/underline/createReactUnderline.d.ts +0 -1
- package/underline/createReactUnderline.js +0 -11
- package/underline/defaultRenderUnderline.d.ts +0 -3
- package/underline/defaultRenderUnderline.js +0 -7
- package/underline/index.cjs.js +0 -24
- package/underline/index.js +0 -3
- package/underline/jsx-serializer/createJsxSerializeUnderline.d.ts +0 -1
- package/underline/jsx-serializer/createJsxSerializeUnderline.js +0 -10
- package/underline/jsx-serializer/index.cjs.js +0 -13
- package/underline/jsx-serializer/index.js +0 -2
- package/underline/typings.d.ts +0 -5
- package/utils/composeRefs.d.ts +0 -19
- package/utils/composeRefs.js +0 -32
- package/utils/index.cjs.js +0 -193
- package/utils/index.js +0 -7
- package/utils/removePreviousElement.d.ts +0 -9
- package/utils/removePreviousElement.js +0 -44
- package/utils/upload.d.ts +0 -11
- package/utils/upload.js +0 -57
- package/utils/useClickAway.d.ts +0 -5
- package/utils/useClickAway.js +0 -23
- package/utils/useDocumentEvents.d.ts +0 -5
- package/utils/useDocumentEvents.js +0 -21
- package/utils/useIsomorphicLayoutEffect.d.ts +0 -2
- package/utils/useIsomorphicLayoutEffect.js +0 -9
- package/utils/usePreviousValue.d.ts +0 -1
- package/utils/usePreviousValue.js +0 -11
- /package/_internal/{index.d.ts → src/index.ts} +0 -0
- /package/accordion/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/accordion/{accordion.scss → src/accordion.scss} +0 -0
- /package/accordion/{index.d.ts → src/index.ts} +0 -0
- /package/align/{index.d.ts → src/index.ts} +0 -0
- /package/blockquote/jsx-serializer/{defaultRenderBlockquoteElement.d.ts → src/defaultRenderBlockquoteElement.ts} +0 -0
- /package/blockquote/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/blockquote/{blockquote.scss → src/blockquote.scss} +0 -0
- /package/blockquote/{index.d.ts → src/index.ts} +0 -0
- /package/blockquote/toolbar/{index.d.ts → src/index.ts} +0 -0
- /package/bold/jsx-serializer/{defaultRenderBold.d.ts → src/defaultRenderBold.ts} +0 -0
- /package/bold/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/bold/{index.d.ts → src/index.ts} +0 -0
- /package/card/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/card/{card.scss → src/card.scss} +0 -0
- /package/card/{index.d.ts → src/index.ts} +0 -0
- /package/card/toolbar/{index.d.ts → src/index.ts} +0 -0
- /package/carousel/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/carousel/{carousel.scss → src/carousel.scss} +0 -0
- /package/carousel/{index.d.ts → src/index.ts} +0 -0
- /package/carousel/toolbar/{index.d.ts → src/index.ts} +0 -0
- /package/components/{baseField.scss → src/BaseField/baseField.scss} +0 -0
- /package/components/{button.scss → src/Button/button.scss} +0 -0
- /package/components/{hint.scss → src/Hint/hint.scss} +0 -0
- /package/components/{imageUploader.scss → src/ImageUploader/imageUploader.scss} +0 -0
- /package/components/{input.scss → src/Input/input.scss} +0 -0
- /package/components/{message.scss → src/Message/message.scss} +0 -0
- /package/components/{modal.scss → src/Modal/modal.scss} +0 -0
- /package/components/{progress.scss → src/Progress/progress.scss} +0 -0
- /package/components/{segmentedControl.scss → src/SegmentedControl/segmentedControl.scss} +0 -0
- /package/components/{textarea.scss → src/Textarea/textarea.scss} +0 -0
- /package/components/{toggle.scss → src/Toggle/toggle.scss} +0 -0
- /package/components/{tooltip.scss → src/Tooltip/tooltip.scss} +0 -0
- /package/components/{components.scss → src/components.scss} +0 -0
- /package/configs/{index.d.ts → src/index.ts} +0 -0
- /package/divider/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/divider/{divider.scss → src/divider.scss} +0 -0
- /package/divider/{index.d.ts → src/index.ts} +0 -0
- /package/embed/jsx-serializer/facebook/{index.d.ts → src/index.ts} +0 -0
- /package/embed/jsx-serializer/instagram/{index.d.ts → src/index.ts} +0 -0
- /package/embed/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/embed/jsx-serializer/twitter/{index.d.ts → src/index.ts} +0 -0
- /package/embed/jsx-serializer/vimeo/{index.d.ts → src/index.ts} +0 -0
- /package/embed/jsx-serializer/youtube/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/facebook/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/instagram/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/podcast-apple/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/spotify/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/twitter/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/vimeo/{index.d.ts → src/index.ts} +0 -0
- /package/embed/renderers/youtube/{index.d.ts → src/index.ts} +0 -0
- /package/embed/{embed.scss → src/embed.scss} +0 -0
- /package/embed/{index.d.ts → src/index.ts} +0 -0
- /package/file-uploader/{file-uploader.scss → src/components/file-uploader.scss} +0 -0
- /package/file-uploader/{index.d.ts → src/index.ts} +0 -0
- /package/footnote/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/footnote/{index.d.ts → src/index.ts} +0 -0
- /package/heading/jsx-serializer/{defaultRenderHeadingElement.d.ts → src/defaultRenderHeadingElement.ts} +0 -0
- /package/heading/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/heading/{heading.scss → src/heading.scss} +0 -0
- /package/heading/{index.d.ts → src/index.ts} +0 -0
- /package/highlight/jsx-serializer/{defaultRenderHighlight.d.ts → src/defaultRenderHighlight.ts} +0 -0
- /package/highlight/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/highlight/{index.d.ts → src/index.ts} +0 -0
- /package/image/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/image/{image.scss → src/components/image.scss} +0 -0
- /package/image/{index.d.ts → src/index.ts} +0 -0
- /package/input-block/{index.d.ts → src/index.ts} +0 -0
- /package/input-block/{input-block.scss → src/input-block.scss} +0 -0
- /package/italic/jsx-serializer/{defaultRenderItalic.d.ts → src/defaultRenderItalic.ts} +0 -0
- /package/italic/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/italic/{index.d.ts → src/index.ts} +0 -0
- /package/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/line-break/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/line-break/{index.d.ts → src/index.ts} +0 -0
- /package/line-break/{line-break.scss → src/line-break.scss} +0 -0
- /package/link/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/link/{index.d.ts → src/index.ts} +0 -0
- /package/list/jsx-serializer/{defaultRenderListElements.d.ts → src/defaultRenderListElements.ts} +0 -0
- /package/list/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/list/{index.d.ts → src/index.ts} +0 -0
- /package/list/{list.scss → src/list.scss} +0 -0
- /package/paragraph/jsx-serializer/{defaultRenderParagraphElement.d.ts → src/defaultRenderParagraphElement.ts} +0 -0
- /package/paragraph/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/paragraph/{index.d.ts → src/index.ts} +0 -0
- /package/paragraph/{paragraph.scss → src/paragraph.scss} +0 -0
- /package/paragraph/toolbar/{index.d.ts → src/index.ts} +0 -0
- /package/read-more/jsx-serializer/{defaultRenderReadMoreElement.d.ts → src/defaultRenderReadMoreElement.ts} +0 -0
- /package/read-more/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/read-more/{read-more.scss → src/components/read-more.scss} +0 -0
- /package/read-more/{index.d.ts → src/index.ts} +0 -0
- /package/{editable.scss → src/core/components/editable.scss} +0 -0
- /package/{index.d.ts → src/index.ts} +0 -0
- /package/strikethrough/jsx-serializer/{defaultRenderStrikethrough.d.ts → src/defaultRenderStrikethrough.ts} +0 -0
- /package/strikethrough/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/strikethrough/{index.d.ts → src/index.ts} +0 -0
- /package/table/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/table/{index.d.ts → src/index.ts} +0 -0
- /package/table/{table.scss → src/table.scss} +0 -0
- /package/table/toolbar/{index.d.ts → src/index.ts} +0 -0
- /package/toggle-mark/toolbar/{index.d.ts → src/index.ts} +0 -0
- /package/toolbar/{toolbar.scss → src/components/toolbar.scss} +0 -0
- /package/underline/jsx-serializer/{defaultRenderUnderline.d.ts → src/defaultRenderUnderline.ts} +0 -0
- /package/underline/jsx-serializer/{index.d.ts → src/index.ts} +0 -0
- /package/underline/{index.d.ts → src/index.ts} +0 -0
- /package/utils/{index.d.ts → src/index.ts} +0 -0
|
@@ -0,0 +1,1394 @@
|
|
|
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
|
+
}
|