@antscorp/antsomi-ui 2.0.110 → 2.0.112
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/es/assets/css/main.scss +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.d.ts +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.js +53 -0
- package/es/components/atoms/Eyedropper/index.d.ts +0 -0
- package/es/components/atoms/Eyedropper/index.js +1 -0
- package/es/components/atoms/Eyedropper/styled.d.ts +9 -0
- package/es/components/atoms/Eyedropper/styled.js +45 -0
- package/es/components/atoms/Eyedropper/types.d.ts +5 -0
- package/es/components/atoms/Eyedropper/types.js +1 -0
- package/es/components/icons/ALignRightIcon.d.ts +3 -0
- package/es/components/icons/ALignRightIcon.js +7 -0
- package/es/components/icons/AlignCenterIcon.d.ts +3 -0
- package/es/components/icons/AlignCenterIcon.js +7 -0
- package/es/components/icons/AlignJustifyIcon.d.ts +3 -0
- package/es/components/icons/AlignJustifyIcon.js +7 -0
- package/es/components/icons/AlignLeftIcon.d.ts +3 -0
- package/es/components/icons/AlignLeftIcon.js +7 -0
- package/es/components/icons/ArrowDropDownIcon.d.ts +3 -0
- package/es/components/icons/ArrowDropDownIcon.js +7 -0
- package/es/components/icons/ChevronRightIcon.d.ts +3 -0
- package/es/components/icons/ChevronRightIcon.js +7 -0
- package/es/components/icons/ColorizeIcon.d.ts +3 -0
- package/es/components/icons/ColorizeIcon.js +7 -0
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +9 -0
- package/es/components/icons/LinkOffIcon.d.ts +3 -0
- package/es/components/icons/LinkOffIcon.js +7 -0
- package/es/components/icons/MinusIcon.d.ts +3 -0
- package/es/components/icons/MinusIcon.js +7 -0
- package/es/components/icons/index.d.ts +9 -0
- package/es/components/icons/index.js +9 -0
- package/es/components/index.scss +1 -0
- package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
- package/es/components/molecules/EmojiCollections/types.d.ts +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +2 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +11 -0
- package/es/components/molecules/EyedropperButton/EyedropperButton.js +34 -0
- package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
- package/es/components/molecules/EyedropperButton/index.js +1 -0
- package/es/components/molecules/EyedropperButton/styled.d.ts +7 -0
- package/es/components/molecules/EyedropperButton/styled.js +23 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +134 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +8 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +14 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +21 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +19 -0
- package/es/components/molecules/FontSizeInput/constants.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/constants.js +5 -0
- package/es/components/molecules/FontSizeInput/index.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/index.js +1 -0
- package/es/components/molecules/FontSizeInput/styled.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/styled.js +39 -0
- package/es/components/molecules/FontSizeInput/types.d.ts +23 -0
- package/es/components/molecules/FontSizeInput/types.js +1 -0
- package/es/components/molecules/FontSizeInput/utils.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/utils.js +9 -0
- package/es/components/molecules/SearchPopover/SearchPopover.d.ts +2 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +3 -3
- package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
- package/es/components/molecules/SearchPopover/styled.js +1 -2
- package/es/components/molecules/SearchPopover/types.d.ts +4 -3
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +6 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +49 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
- package/es/components/molecules/VirtualizedMenu/styled.js +24 -3
- package/es/components/molecules/VirtualizedMenu/types.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.js +2 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/molecules/index.scss +1 -0
- package/es/components/organism/TextEditor/TextEditor.d.ts +10 -0
- package/es/components/organism/TextEditor/TextEditor.js +403 -0
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +47 -0
- package/es/components/organism/TextEditor/constants.d.ts +196 -0
- package/es/components/organism/TextEditor/constants.js +398 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +43 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +18 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +81 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +35 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +16 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.js +30 -0
- package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/Color.js +34 -0
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
- package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +31 -0
- package/es/components/organism/TextEditor/extensions/FontSize.js +46 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
- package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.js +101 -0
- package/es/components/organism/TextEditor/extensions/Link.d.ts +22 -0
- package/es/components/organism/TextEditor/extensions/Link.js +197 -0
- package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
- package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +33 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.js +194 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +30 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.js +36 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
- package/es/components/organism/TextEditor/hooks/index.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/index.js +6 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.js +29 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +69 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
- package/es/components/organism/TextEditor/index.d.ts +18 -0
- package/es/components/organism/TextEditor/index.js +8 -0
- package/es/components/organism/TextEditor/index.scss +65 -0
- package/es/components/organism/TextEditor/provider.d.ts +15 -0
- package/es/components/organism/TextEditor/provider.js +36 -0
- package/es/components/organism/TextEditor/store.d.ts +20 -0
- package/es/components/organism/TextEditor/store.js +40 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
- package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
- package/es/components/organism/TextEditor/stories/shared.js +57 -0
- package/es/components/organism/TextEditor/styled.d.ts +9 -0
- package/es/components/organism/TextEditor/styled.js +61 -0
- package/es/components/organism/TextEditor/types.d.ts +324 -0
- package/es/components/organism/TextEditor/types.js +6 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +3 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +114 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/Button/Button.js +35 -0
- package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.js +27 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +102 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +36 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.d.ts +35 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +58 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +75 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +85 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +93 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +20 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +32 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +41 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +8 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +51 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.js +45 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +67 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -0
- package/es/components/organism/TextEditor/utils/documentState.d.ts +73 -0
- package/es/components/organism/TextEditor/utils/documentState.js +149 -0
- package/es/components/organism/TextEditor/utils/font.d.ts +74 -0
- package/es/components/organism/TextEditor/utils/font.js +147 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +87 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +460 -0
- package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
- package/es/components/organism/TextEditor/utils/indent.js +56 -0
- package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
- package/es/components/organism/TextEditor/utils/index.js +16 -0
- package/es/components/organism/TextEditor/utils/link.d.ts +116 -0
- package/es/components/organism/TextEditor/utils/link.js +304 -0
- package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
- package/es/components/organism/TextEditor/utils/menu.js +321 -0
- package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
- package/es/components/organism/TextEditor/utils/selection.js +58 -0
- package/es/components/organism/TextEditor/utils/shared.d.ts +13 -0
- package/es/components/organism/TextEditor/utils/shared.js +52 -0
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
- package/es/components/organism/TextEditor/utils/smartTag.js +90 -0
- package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
- package/es/components/organism/TextEditor/utils/style.js +193 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/organism/index.scss +1 -0
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/web.d.ts +8 -0
- package/es/constants/web.js +57 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
- package/es/hooks/useBroadcastedLocalStorage.js +71 -0
- package/es/hooks/useElementSize.d.ts +7 -0
- package/es/hooks/useElementSize.js +56 -0
- package/es/hooks/useEyedropper/attach.d.ts +4 -0
- package/es/hooks/useEyedropper/attach.js +9 -0
- package/es/hooks/useEyedropper/eyedropper.d.ts +69 -0
- package/es/hooks/useEyedropper/eyedropper.js +205 -0
- package/es/hooks/useEyedropper/index.d.ts +2 -0
- package/es/hooks/useEyedropper/index.js +7 -0
- package/es/hooks/useEyedropper/support.d.ts +1 -0
- package/es/hooks/useEyedropper/support.js +3 -0
- package/es/hooks/useEyedropper/types.d.ts +9 -0
- package/es/hooks/useEyedropper/types.js +1 -0
- package/es/hooks/useEyedropper/useEyedropper.d.ts +8 -0
- package/es/hooks/useEyedropper/useEyedropper.js +50 -0
- package/es/hooks/useEyedropper/utils.d.ts +11 -0
- package/es/hooks/useEyedropper/utils.js +17 -0
- package/es/hooks/useIsMounted.d.ts +1 -0
- package/es/hooks/useIsMounted.js +11 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/locales/i18n.d.ts +1 -1
- package/es/types/index.d.ts +9 -0
- package/es/utils/common.d.ts +15 -9
- package/es/utils/common.js +62 -24
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/web.d.ts +80 -0
- package/es/utils/web.js +226 -0
- package/package.json +26 -17
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Flex } from 'antd';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { ToolbarWrapper } from '../../styled';
|
|
5
|
+
import { BoldAction, BulletListAction, ClearFormattingAction, EmoijiAction, FontFamilyAction, FontSizeAction, HistoryAction, IndentAction, ItalicAction, LetterSpacingAction, LinkAction, OrderedListAction, OutdentAction, SmartTagAction, LineSpacingAction, StrikeAction, SubscriptAction, SuperscriptAction, TextAlignAction, TextBackColorAction, TextColorAction, TextTransformAction, UnderlineAction, } from './actions';
|
|
6
|
+
import { ALL_TOOLBAR_ACTIONS, DEFAULT_TEXT_STYLE, DEFAULT_TOOLBAR_GROUPING } from '../../constants';
|
|
7
|
+
import { useElementSize } from '@antscorp/antsomi-ui/es/hooks';
|
|
8
|
+
export const FormattingToolbar = (props) => {
|
|
9
|
+
const { editor, smartTagHandler, linkHanlder, config, defaultTextStyle = DEFAULT_TEXT_STYLE, onChangeFont, } = props;
|
|
10
|
+
const [ref] = useElementSize();
|
|
11
|
+
// Determine visible actions based on config
|
|
12
|
+
const visibleActions = useMemo(() => {
|
|
13
|
+
const toolbarConfig = config?.Toolbar;
|
|
14
|
+
// If items is false, hide toolbar entirely
|
|
15
|
+
if (toolbarConfig?.items === false) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
// If items is an array, use it (user-specified order)
|
|
19
|
+
if (Array.isArray(toolbarConfig?.items)) {
|
|
20
|
+
return toolbarConfig.items;
|
|
21
|
+
}
|
|
22
|
+
// Default: show all actions except excluded ones
|
|
23
|
+
const excludeSet = new Set(toolbarConfig?.exclude || []);
|
|
24
|
+
return ALL_TOOLBAR_ACTIONS.filter(action => !excludeSet.has(action));
|
|
25
|
+
}, [config?.Toolbar]);
|
|
26
|
+
// Map action names to React components
|
|
27
|
+
const actionComponentMap = useMemo(() => ({
|
|
28
|
+
fontFamily: (_jsx(FontFamilyAction, { editor: editor, fonts: config?.FontFamily?.fonts, onChange: (font, weight) => onChangeFont?.({ font, weight }), fontGroupingFn: config?.FontFamily?.fontGroupingFn, groupOrder: config?.FontFamily?.groupOrder, defaultFontFamily: defaultTextStyle.fontFamily }, "fontFamily")),
|
|
29
|
+
fontSize: (_jsx(FontSizeAction, { editor: editor, defaultFontSize: defaultTextStyle.fontSize }, "fontSize")),
|
|
30
|
+
bold: _jsx(BoldAction, { editor: editor }, "bold"),
|
|
31
|
+
italic: _jsx(ItalicAction, { editor: editor }, "italic"),
|
|
32
|
+
underline: _jsx(UnderlineAction, { editor: editor }, "underline"),
|
|
33
|
+
link: _jsx(LinkAction, { editor: editor, onClick: linkHanlder?.onUpsert }, "link"),
|
|
34
|
+
strike: _jsx(StrikeAction, { editor: editor }, "strike"),
|
|
35
|
+
superscript: _jsx(SuperscriptAction, { editor: editor }, "superscript"),
|
|
36
|
+
subscript: _jsx(SubscriptAction, { editor: editor }, "subscript"),
|
|
37
|
+
textTransform: _jsx(TextTransformAction, { editor: editor }, "textTransform"),
|
|
38
|
+
textColor: _jsx(TextColorAction, { editor: editor }, "textColor"),
|
|
39
|
+
backgroundColor: _jsx(TextBackColorAction, { editor: editor }, "backgroundColor"),
|
|
40
|
+
emoji: _jsx(EmoijiAction, { editor: editor }, "emoji"),
|
|
41
|
+
smartTag: (_jsx(SmartTagAction, { editor: editor, onClick: smartTagHandler?.onUpsert }, "smartTag")),
|
|
42
|
+
bulletList: (_jsx(BulletListAction, { editor: editor, useCustomBullet: config?.UnorderedList?.useCustomBullet }, "bulletList")),
|
|
43
|
+
orderedList: _jsx(OrderedListAction, { editor: editor }, "orderedList"),
|
|
44
|
+
textAlign: _jsx(TextAlignAction, { editor: editor }, "textAlign"),
|
|
45
|
+
lineSpacing: (_jsx(LineSpacingAction, { editor: editor, defaultValue: defaultTextStyle?.lineHeight }, "lineSpacing")),
|
|
46
|
+
letterSpacing: _jsx(LetterSpacingAction, { editor: editor }, "letterSpacing"),
|
|
47
|
+
indent: _jsx(IndentAction, { editor: editor }, "indent"),
|
|
48
|
+
outdent: _jsx(OutdentAction, { editor: editor }, "outdent"),
|
|
49
|
+
history: _jsx(HistoryAction, { editor: editor }, "history"),
|
|
50
|
+
clearFormatting: _jsx(ClearFormattingAction, { editor: editor }, "clearFormatting"),
|
|
51
|
+
}), [
|
|
52
|
+
editor,
|
|
53
|
+
config?.FontFamily,
|
|
54
|
+
config?.UnorderedList,
|
|
55
|
+
defaultTextStyle,
|
|
56
|
+
linkHanlder,
|
|
57
|
+
smartTagHandler,
|
|
58
|
+
onChangeFont,
|
|
59
|
+
]);
|
|
60
|
+
// Group actions into rows
|
|
61
|
+
const actionGroups = useMemo(() => {
|
|
62
|
+
if (visibleActions.length === 0) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
// Use default grouping to determine which row each action belongs to
|
|
66
|
+
const row1Actions = DEFAULT_TOOLBAR_GROUPING[0];
|
|
67
|
+
const row2Actions = DEFAULT_TOOLBAR_GROUPING[1];
|
|
68
|
+
const row1 = [];
|
|
69
|
+
const row2 = [];
|
|
70
|
+
visibleActions.forEach(action => {
|
|
71
|
+
if (row1Actions.includes(action)) {
|
|
72
|
+
row1.push(action);
|
|
73
|
+
}
|
|
74
|
+
else if (row2Actions.includes(action)) {
|
|
75
|
+
row2.push(action);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return [row1, row2].filter(row => row.length > 0);
|
|
79
|
+
}, [visibleActions]);
|
|
80
|
+
// If no visible actions, don't render toolbar
|
|
81
|
+
if (visibleActions.length === 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return (_jsx(ToolbarWrapper, { ref: ref, vertical: true, gap: 20, children: actionGroups.map((group, groupIdx) => (_jsx(Flex, { gap: 15, justify: "flex-start", align: "center", children: group.map(actionName => actionComponentMap[actionName]) }, groupIdx))) }));
|
|
85
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { TextEditorComponentsRender } from '../../types';
|
|
3
|
+
export type LinkPreviewToolbarProps = {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
linkHanlder?: {
|
|
6
|
+
onUpsert?: () => void;
|
|
7
|
+
};
|
|
8
|
+
render?: Partial<Pick<TextEditorComponentsRender, 'renderLinkToolbar'>>;
|
|
9
|
+
};
|
|
10
|
+
export declare const LinkPreviewToolbar: (props: LinkPreviewToolbarProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CopyDuplicateIcon, EditIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
3
|
+
import { useEditorState } from '@tiptap/react';
|
|
4
|
+
import { Typography } from 'antd';
|
|
5
|
+
import { ToolbarWrapper } from '../../styled';
|
|
6
|
+
import { isShowLinkToolbar } from '../../utils';
|
|
7
|
+
import { TextEditorButton } from '../Button';
|
|
8
|
+
import { UnsetLinkAction } from './actions';
|
|
9
|
+
import { CUSTOM_LINK_EXTENSION_NAME } from '../../constants';
|
|
10
|
+
export const LinkPreviewToolbar = (props) => {
|
|
11
|
+
const { editor, linkHanlder, render } = props;
|
|
12
|
+
const { showLinkMenu, linkAttrs } = useEditorState({
|
|
13
|
+
editor,
|
|
14
|
+
selector: ctx => ({
|
|
15
|
+
showLinkMenu: isShowLinkToolbar(ctx.editor.state),
|
|
16
|
+
linkAttrs: editor.getAttributes(CUSTOM_LINK_EXTENSION_NAME),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
if (!showLinkMenu) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const href = String(linkAttrs?.href);
|
|
23
|
+
const goToLinkEl = (_jsx(Typography.Link, { style: { maxWidth: 150 }, ellipsis: true, href: href, children: href }));
|
|
24
|
+
const copyLinkEl = (_jsx(TextEditorButton, { icon: _jsx(CopyDuplicateIcon, { size: 18 }), tooltipProps: { title: 'Copy' }, onClick: () => {
|
|
25
|
+
navigator.clipboard.writeText(href);
|
|
26
|
+
} }));
|
|
27
|
+
const editLinkEl = (_jsx(TextEditorButton, { icon: _jsx(EditIcon, { size: 18 }), tooltipProps: { title: 'Edit' }, onClick: () => linkHanlder?.onUpsert?.() }));
|
|
28
|
+
const unsetLinkEl = _jsx(UnsetLinkAction, { editor: editor });
|
|
29
|
+
let linkTools = (_jsxs(_Fragment, { children: [goToLinkEl, copyLinkEl, editLinkEl, unsetLinkEl] }));
|
|
30
|
+
if (render?.renderLinkToolbar && linkAttrs) {
|
|
31
|
+
linkTools = render.renderLinkToolbar(linkAttrs, linkTools, {
|
|
32
|
+
copy: copyLinkEl,
|
|
33
|
+
edit: editLinkEl,
|
|
34
|
+
gotoLink: goToLinkEl,
|
|
35
|
+
unlink: unsetLinkEl,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return (_jsx(ToolbarWrapper, { wrap: "wrap", gap: 8, align: "center", children: linkTools }));
|
|
39
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
export interface BoldActionProps {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
}
|
|
6
|
+
export declare const BoldAction: import("react").MemoExoticComponent<({ editor }: BoldActionProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
3
|
+
import { TextEditorButton } from '../../Button';
|
|
4
|
+
import { useEditorState } from '@tiptap/react';
|
|
5
|
+
import { memo } from 'react';
|
|
6
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
7
|
+
const BoldIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M5 22V2H12.9687C14.5312 2 15.9736 2.47619 17.2957 3.42857C18.6178 4.38095 19.2788 5.70238 19.2788 7.39286C19.2788 8.60714 19.0024 9.54167 18.4495 10.1964C17.8966 10.8512 17.3798 11.3214 16.899 11.6071C17.5 11.869 18.1671 12.3571 18.9002 13.0714C19.6334 13.7857 20 14.8571 20 16.2857C20 18.4048 19.2187 19.8869 17.6562 20.7321C16.0937 21.5774 14.6274 22 13.2572 22H5ZM9.36298 18H13.113C14.2668 18 14.97 17.7083 15.2224 17.125C15.4748 16.5417 15.601 16.119 15.601 15.8571C15.601 15.5952 15.4748 15.1726 15.2224 14.5893C14.97 14.006 14.2308 13.7143 13.0048 13.7143H9.36298V18ZM9.36298 9.85714H12.7163C13.5096 9.85714 14.0865 9.65476 14.4471 9.25C14.8077 8.84524 14.988 8.39286 14.988 7.89286C14.988 7.32143 14.7837 6.85714 14.375 6.5C13.9663 6.14286 13.4375 5.96429 12.7885 5.96429H9.36298V9.85714Z", fill: "currentColor" }) }));
|
|
8
|
+
export const BoldAction = memo(({ editor }) => {
|
|
9
|
+
const { disabled, isBold } = useEditorState({
|
|
10
|
+
editor,
|
|
11
|
+
selector: ({ editor: editorInstance }) => ({
|
|
12
|
+
isBold: editorInstance.isActive('bold'),
|
|
13
|
+
disabled: !editorInstance.can().chain().focus().toggleBold().run(),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
return (_jsx(TextEditorButton, { disabled: disabled, onClick: () => editor.chain().focus().toggleBold().run(), isActive: isBold, icon: _jsx(BoldIcon, { size: 18 }), tooltipProps: {
|
|
17
|
+
title: `${TOOLTIPS.BOLD.TITLE} (${TOOLTIPS.BOLD.SHORTCUT})`,
|
|
18
|
+
} }));
|
|
19
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
export interface BulletListActionProps {
|
|
3
|
+
editor: Editor;
|
|
4
|
+
useCustomBullet?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const BulletListAction: ({ editor, useCustomBullet }: BulletListActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TEXT_EDITOR_CONSTANTS, UNORDERED_LIST_STYLE_TYPE } from '../../../constants';
|
|
3
|
+
import { isUnorderedListStyleType } from '../../../types';
|
|
4
|
+
import { CustomUnorderedList } from '../../../extensions/UnorderedList';
|
|
5
|
+
import { SplitButtonDropdown } from '../../SplitButtonDropdown';
|
|
6
|
+
import { useEditorState } from '@tiptap/react';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
9
|
+
const UnorderListIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M3.57895 11C2.73684 11 2 11.7 2 12.5C2 13.3 2.73684 14 3.57895 14C4.42105 14 5.15789 13.3 5.15789 12.5C5.15789 11.7 4.42105 11 3.57895 11ZM3.57895 6C2.73684 6 2 6.7 2 7.5C2 8.3 2.73684 9 3.57895 9C4.42105 9 5.15789 8.3 5.15789 7.5C5.15789 6.7 4.42105 6 3.57895 6ZM3.57895 16C2.73684 16 2 16.7 2 17.5C2 18.3 2.73684 19 3.57895 19C4.42105 19 5.15789 18.3 5.15789 17.5C5.15789 16.7 4.42105 16 3.57895 16ZM7.26316 6.5V8.5H22V6.5H7.26316ZM7.26316 18.5H22V16.5H7.26316V18.5ZM7.26316 13.5H22V11.5H7.26316V13.5Z", fill: "currentColor" }) }));
|
|
10
|
+
const CUSTOM_BULLET_OPTIONS = [
|
|
11
|
+
{
|
|
12
|
+
label: '+',
|
|
13
|
+
value: `${UNORDERED_LIST_STYLE_TYPE.custom}_+`,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
label: '→',
|
|
17
|
+
value: `${UNORDERED_LIST_STYLE_TYPE.custom}_→`,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: '➤',
|
|
21
|
+
value: `${UNORDERED_LIST_STYLE_TYPE.custom}_➤`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: '★',
|
|
25
|
+
value: `${UNORDERED_LIST_STYLE_TYPE.custom}_★`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: '☆',
|
|
29
|
+
value: `${UNORDERED_LIST_STYLE_TYPE.custom}_☆`,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
const OPTIONS = [
|
|
33
|
+
{
|
|
34
|
+
label: '•',
|
|
35
|
+
value: UNORDERED_LIST_STYLE_TYPE.disc,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: '○',
|
|
39
|
+
value: UNORDERED_LIST_STYLE_TYPE.circle,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: '■',
|
|
43
|
+
value: UNORDERED_LIST_STYLE_TYPE.square,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
export const BulletListAction = ({ editor, useCustomBullet = false }) => {
|
|
47
|
+
const { value, disabled, isSelected } = useEditorState({
|
|
48
|
+
editor,
|
|
49
|
+
selector: ({ editor: editorInstance }) => {
|
|
50
|
+
let value = editorInstance.getAttributes(CustomUnorderedList.name).listStyleType;
|
|
51
|
+
const disabled = !editorInstance.can().chain().focus().toggleCustomUnorderedList().run();
|
|
52
|
+
const isSelected = editorInstance.isActive(CustomUnorderedList.name);
|
|
53
|
+
if (isUnorderedListStyleType(value) && value === UNORDERED_LIST_STYLE_TYPE.custom) {
|
|
54
|
+
const bulletChar = editorInstance.getAttributes(CustomUnorderedList.name).customBulletChar;
|
|
55
|
+
value = `${UNORDERED_LIST_STYLE_TYPE.custom}_${bulletChar}`;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
value,
|
|
59
|
+
disabled,
|
|
60
|
+
isSelected,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const options = useMemo(() => (useCustomBullet ? [...OPTIONS, ...CUSTOM_BULLET_OPTIONS] : OPTIONS), [useCustomBullet]);
|
|
65
|
+
return (_jsx(SplitButtonDropdown, { disabled: disabled, value: value, options: options, onClickOption: v => {
|
|
66
|
+
const [listStyleType, customBulletChar] = v.split('_');
|
|
67
|
+
if (!isUnorderedListStyleType(listStyleType))
|
|
68
|
+
return;
|
|
69
|
+
if (isSelected) {
|
|
70
|
+
editor
|
|
71
|
+
.chain()
|
|
72
|
+
.focus()
|
|
73
|
+
.setUnorderedListStyle({
|
|
74
|
+
listStyleType,
|
|
75
|
+
customBulletChar,
|
|
76
|
+
})
|
|
77
|
+
.run();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
editor
|
|
81
|
+
.chain()
|
|
82
|
+
.focus()
|
|
83
|
+
.toggleCustomUnorderedList({
|
|
84
|
+
listStyleType,
|
|
85
|
+
customBulletChar,
|
|
86
|
+
})
|
|
87
|
+
.run();
|
|
88
|
+
}, onClick: () => {
|
|
89
|
+
editor.chain().focus().toggleCustomUnorderedList().run();
|
|
90
|
+
}, tooltipProps: {
|
|
91
|
+
title: `${TOOLTIPS.BULLET_LIST.TITLE} (${TOOLTIPS.BULLET_LIST.SHORTCUT})`,
|
|
92
|
+
}, children: _jsx(UnorderListIcon, { size: 18 }) }));
|
|
93
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TextEditorButton } from '../../Button';
|
|
3
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
4
|
+
import { useEditorState } from '@tiptap/react';
|
|
5
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
6
|
+
const RemoveFormattingIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M3.41111 3L2 4.42875L9.74445 12.27L7 18.75H10.3333L12.0778 14.6325L18.3667 21L19.7778 19.5712L3.72222 3.30375L3.41111 3ZM6.44444 3V3.2025L9.57778 6.375H12.2444L11.4444 8.265L13.7778 10.6275L15.5667 6.375H22V3H6.44444Z", fill: "currentColor" }) }));
|
|
7
|
+
export const ClearFormattingAction = ({ editor }) => {
|
|
8
|
+
const { disabled } = useEditorState({
|
|
9
|
+
editor,
|
|
10
|
+
selector: ({ editor: editorInstance }) => ({
|
|
11
|
+
disabled: !editorInstance.can().chain().focus().run(),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
const clearFormatting = () => {
|
|
15
|
+
editor?.chain().focus().clearFormatting().run();
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(TextEditorButton, { onClick: clearFormatting, disabled: disabled, icon: _jsx(RemoveFormattingIcon, { size: 18 }), tooltipProps: {
|
|
18
|
+
title: `${TOOLTIPS.CLEAR_FORMATTING.TITLE} (${TOOLTIPS.CLEAR_FORMATTING.SHORTCUT})`,
|
|
19
|
+
} }));
|
|
20
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { EmojiSmileIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
4
|
+
import { EMOJI_COLLECTIONS } from '@antscorp/antsomi-ui/es/components/molecules/TagifyInput';
|
|
5
|
+
import { EmojiPopover } from '@antscorp/antsomi-ui/es/components/molecules/EmojiPopover';
|
|
6
|
+
import { TextEditorButton } from '../../Button';
|
|
7
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
8
|
+
import { useTextEditorStore } from '../../../provider';
|
|
9
|
+
import { useEditorState } from '@tiptap/react';
|
|
10
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
11
|
+
export const EmoijiAction = ({ editor }) => {
|
|
12
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
13
|
+
const { disabled } = useEditorState({
|
|
14
|
+
editor: editor,
|
|
15
|
+
selector: ({ editor: editorInstance }) => ({
|
|
16
|
+
disabled: !editorInstance.can().chain().focus().run(),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
const getPopupContainer = useCallback(() => bubbleMenuContainer || document.body, [bubbleMenuContainer]);
|
|
20
|
+
return (_jsx(EmojiPopover, { isForceHide: true, collections: [
|
|
21
|
+
{
|
|
22
|
+
key: EMOJI_COLLECTIONS.COMMON,
|
|
23
|
+
label: _jsx(EmojiSmileIcon, {}),
|
|
24
|
+
},
|
|
25
|
+
], onEmojiClick: emoji => {
|
|
26
|
+
if (typeof emoji !== 'string')
|
|
27
|
+
return;
|
|
28
|
+
editor?.chain().insertEmoji(emoji);
|
|
29
|
+
}, getPopupContainer: getPopupContainer, destroyTooltipOnHide: true, children: _jsx(TextEditorButton, { disabled: disabled, tooltipProps: {
|
|
30
|
+
title: TOOLTIPS.EMOJI.TITLE,
|
|
31
|
+
}, icon: _jsx(EmojiSmileIcon, { size: 18 }) }) }));
|
|
32
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import { FontConfig, FontGroupingFunction, GroupOrderFunction } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props for FontFamilyAction component
|
|
5
|
+
*/
|
|
6
|
+
export interface FontFamilyActionProps {
|
|
7
|
+
/** TipTap editor instance */
|
|
8
|
+
editor: Editor;
|
|
9
|
+
/** Array of available font configurations */
|
|
10
|
+
fonts?: FontConfig[];
|
|
11
|
+
/** Function to group fonts or false to disable grouping */
|
|
12
|
+
fontGroupingFn?: FontGroupingFunction | false;
|
|
13
|
+
/** Array of group keys or function to define display order. Groups not in this array will appear after ordered groups */
|
|
14
|
+
groupOrder?: string[] | GroupOrderFunction;
|
|
15
|
+
/** Callback when font selection changes */
|
|
16
|
+
onChange?: (font: FontConfig, weight: number) => void;
|
|
17
|
+
defaultFontFamily?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const FontFamilyAction: (props: FontFamilyActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_FONT_CONFIGS } from '../../../constants';
|
|
3
|
+
import { FontPopover } from '../../FontPopover/FontPopover';
|
|
4
|
+
import { getPrimaryFontFamily } from '@antscorp/antsomi-ui/es/utils';
|
|
5
|
+
import { useEditorState } from '@tiptap/react';
|
|
6
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
7
|
+
export const FontFamilyAction = (props) => {
|
|
8
|
+
const { editor, fonts = DEFAULT_FONT_CONFIGS, onChange, fontGroupingFn, groupOrder, defaultFontFamily, } = props;
|
|
9
|
+
const onChangeRef = useRef();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
onChangeRef.current = onChange;
|
|
12
|
+
}, [onChange]);
|
|
13
|
+
const { fontValue, fontWeight } = useEditorState({
|
|
14
|
+
editor,
|
|
15
|
+
selector: ({ editor: editorInstance }) => {
|
|
16
|
+
const { fontWeight, fontFamily } = editorInstance.getAttributes('textStyle') || {};
|
|
17
|
+
return {
|
|
18
|
+
fontValue: getPrimaryFontFamily(fontFamily || defaultFontFamily),
|
|
19
|
+
fontWeight: Number(fontWeight),
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const activeFont = fonts.find(font => font.fontFamily.name === fontValue);
|
|
24
|
+
const handleChangeFont = useCallback((font, weight) => {
|
|
25
|
+
const done = editor
|
|
26
|
+
.chain()
|
|
27
|
+
.focus()
|
|
28
|
+
.setFontFamily([font.fontFamily.name, ...(font.fontFamily.fallback || [])].join(', '))
|
|
29
|
+
.setFontWeight(weight)
|
|
30
|
+
.run();
|
|
31
|
+
if (done) {
|
|
32
|
+
onChangeRef.current?.(font, weight);
|
|
33
|
+
}
|
|
34
|
+
}, [editor]);
|
|
35
|
+
return (_jsx(FontPopover, { fonts: fonts, value: activeFont
|
|
36
|
+
? {
|
|
37
|
+
font: activeFont,
|
|
38
|
+
weight: fontWeight,
|
|
39
|
+
}
|
|
40
|
+
: undefined, onChange: handleChangeFont, fontGrouping: fontGroupingFn, groupOrder: groupOrder }));
|
|
41
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
export interface FontSizeActionProps {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
throttled?: number;
|
|
6
|
+
defaultFontSize?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const FontSizeAction: import("react").MemoExoticComponent<({ editor, throttled, defaultFontSize, }: FontSizeActionProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTextEditorStore } from '../../../provider';
|
|
3
|
+
import { FontSizeInput, } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { useThrottledCallback } from 'use-debounce';
|
|
7
|
+
import { useEditorState } from '@tiptap/react';
|
|
8
|
+
import { toString } from 'lodash';
|
|
9
|
+
import { DEFAULT_TEXT_STYLE } from '../../../constants';
|
|
10
|
+
const StyledFontSizeInput = styled(FontSizeInput) `
|
|
11
|
+
&.antsomi-input-number {
|
|
12
|
+
width: 36px;
|
|
13
|
+
|
|
14
|
+
input.antsomi-input-number-input {
|
|
15
|
+
text-align: center;
|
|
16
|
+
height: 30px;
|
|
17
|
+
padding-inline: 0;
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
export const FontSizeAction = memo(({ editor, throttled = 100, defaultFontSize = DEFAULT_TEXT_STYLE.fontSize, }) => {
|
|
23
|
+
const inputRef = useRef(null);
|
|
24
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
25
|
+
const { numberFontSize } = useEditorState({
|
|
26
|
+
editor,
|
|
27
|
+
selector: ({ editor: editorInstance }) => {
|
|
28
|
+
const { fontSize } = editorInstance.getAttributes('textStyle');
|
|
29
|
+
return { numberFontSize: +toString(fontSize || defaultFontSize).replace('px', '') };
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const [currentFontSize, setCurrentFontSize] = useState(numberFontSize);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (numberFontSize) {
|
|
35
|
+
setCurrentFontSize(numberFontSize);
|
|
36
|
+
}
|
|
37
|
+
}, [numberFontSize]);
|
|
38
|
+
const updateEditorFontSize = useThrottledCallback((v) => {
|
|
39
|
+
if (v === numberFontSize)
|
|
40
|
+
return;
|
|
41
|
+
editor.chain().focus().setFontSize(`${v}px`).run();
|
|
42
|
+
}, throttled);
|
|
43
|
+
const handleFontSizeChange = useCallback((value) => {
|
|
44
|
+
setCurrentFontSize(+value);
|
|
45
|
+
updateEditorFontSize(+value);
|
|
46
|
+
}, [updateEditorFontSize]);
|
|
47
|
+
const dropdownProps = useMemo(() => ({
|
|
48
|
+
getPopupContainer: () => bubbleMenuContainer,
|
|
49
|
+
}), [bubbleMenuContainer]);
|
|
50
|
+
return (_jsx(StyledFontSizeInput, { ref: inputRef, placeholder: "Font Size", value: currentFontSize, onChange: handleFontSizeChange, dropdownProps: dropdownProps }));
|
|
51
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TextEditorButton } from '../../Button';
|
|
3
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
4
|
+
import { useEditorState } from '@tiptap/react';
|
|
5
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
6
|
+
const UndoIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M10.1768 9.02857C8.29834 9.37143 6.64088 10.0571 5.09392 11.3143L2 8V16H9.73481L6.75138 12.9143C10.8398 9.94286 16.4751 10.8571 19.4586 15.0857C19.6796 15.4286 19.9006 15.6571 20.011 16L22 14.9714C19.5691 10.6286 14.9282 8.22857 10.1768 9.02857Z", fill: "currentColor" }) }));
|
|
7
|
+
const RedoIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M13.8232 9.02857C15.7017 9.37143 17.3591 10.0571 18.9061 11.3143L22 8V16H14.2652L17.2486 12.9143C13.1602 9.94286 7.52486 10.8571 4.54144 15.0857C4.32044 15.4286 4.09945 15.6571 3.98895 16L2 14.9714C4.43094 10.6286 9.07182 8.22857 13.8232 9.02857Z", fill: "currentColor" }) }));
|
|
8
|
+
export const HistoryAction = ({ editor }) => {
|
|
9
|
+
const { disabledUndo, disabledRedo } = useEditorState({
|
|
10
|
+
editor,
|
|
11
|
+
selector: ({ editor: editorInstance }) => ({
|
|
12
|
+
disabledUndo: !editorInstance.can().chain().focus().undo().run(),
|
|
13
|
+
disabledRedo: !editorInstance.can().chain().focus().redo().run(),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
return (_jsxs(_Fragment, { children: [_jsx(TextEditorButton, { disabled: disabledUndo, onClick: () => editor.chain().focus().undo().run(), icon: _jsx(UndoIcon, { size: 18 }), tooltipProps: {
|
|
17
|
+
title: `${TOOLTIPS.UNDO.TITLE} (${TOOLTIPS.UNDO.SHORTCUT})`,
|
|
18
|
+
} }), _jsx(TextEditorButton, { disabled: disabledRedo, onClick: () => editor.chain().focus().redo().run(), icon: _jsx(RedoIcon, { size: 18 }), tooltipProps: {
|
|
19
|
+
title: `${TOOLTIPS.REDO.TITLE} (${TOOLTIPS.REDO.SHORTCUT})`,
|
|
20
|
+
} })] }));
|
|
21
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TextEditorButton } from '../../Button';
|
|
3
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
4
|
+
import { useEditorState } from '@tiptap/react';
|
|
5
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
6
|
+
const IndentIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M2 22H22V19.7778H2V22ZM2 7.55556V16.4444L6.44444 12L2 7.55556ZM10.8889 17.5556H22V15.3333H10.8889V17.5556ZM2 2V4.22222H22V2H2ZM10.8889 8.66667H22V6.44444H10.8889V8.66667ZM10.8889 13.1111H22V10.8889H10.8889V13.1111Z", fill: "currentColor" }) }));
|
|
7
|
+
export const IndentAction = ({ editor }) => {
|
|
8
|
+
const { disabled } = useEditorState({
|
|
9
|
+
editor,
|
|
10
|
+
selector: ({ editor: editorInstance }) => ({
|
|
11
|
+
disabled: !editorInstance.can().chain().focus().indent().run(),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
return (_jsx(TextEditorButton, { disabled: disabled, icon: _jsx(IndentIcon, { size: 18 }), onClick: () => editor.chain().focus().indent().run(), tooltipProps: {
|
|
15
|
+
title: `${TOOLTIPS.INDENT.TITLE} (${TOOLTIPS.INDENT.SHORTCUT})`,
|
|
16
|
+
} }));
|
|
17
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
3
|
+
import { TextEditorButton } from '../../Button';
|
|
4
|
+
import { useEditorState } from '@tiptap/react';
|
|
5
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
6
|
+
const ItalicIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M3 22V18.4286H8.84615L13.2308 5.57143H7.38462V2H22V5.57143H16.8846L12.5 18.4286H17.6154V22H3Z", fill: "currentColor" }) }));
|
|
7
|
+
export const ItalicAction = ({ editor }) => {
|
|
8
|
+
const { isItalic, disabled } = useEditorState({
|
|
9
|
+
editor,
|
|
10
|
+
selector: ({ editor: editorInstance }) => ({
|
|
11
|
+
isItalic: editorInstance.isActive('italic'),
|
|
12
|
+
disabled: !editorInstance.can().chain().focus().toggleItalic().run(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
return (_jsx(TextEditorButton, { onClick: () => editor.chain().focus().toggleItalic().run(), disabled: disabled, isActive: isItalic, icon: _jsx(ItalicIcon, { size: 18 }), tooltipProps: {
|
|
16
|
+
title: `${TOOLTIPS.ITALIC.TITLE} (${TOOLTIPS.ITALIC.SHORTCUT})`,
|
|
17
|
+
} }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SplitButtonDropdown } from '../../SplitButtonDropdown';
|
|
3
|
+
import { range } from 'lodash';
|
|
4
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
5
|
+
import { useEditorState } from '@tiptap/react';
|
|
6
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
7
|
+
const LetterSpacingIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M14.4 10.1053H18.5L16.5 4.42105L14.4 10.1053ZM15.6 2H17.3L22 14.6316H20.1L19.1 11.8947H13.7L12.7 14.6316H10.8L15.6 2ZM11.2 2H13.1L8.4 14.6316H6.7L2 2H3.9L7.5 12.2105M19 22V19.8947H5V22L2 18.8421L5 15.6842V17.7895H19V15.6842L22 18.8421L19 22Z", fill: "currentColor" }) }));
|
|
8
|
+
const LETTER_SPACING_VALUES = range(-10, 11);
|
|
9
|
+
export const LetterSpacingAction = ({ editor }) => {
|
|
10
|
+
const { letterSpacing } = useEditorState({
|
|
11
|
+
editor,
|
|
12
|
+
selector: ({ editor: editorInstance }) => ({
|
|
13
|
+
letterSpacing: editorInstance.getAttributes('textStyle').letterSpacing,
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
return (_jsx(SplitButtonDropdown, { tooltipProps: {
|
|
17
|
+
title: TOOLTIPS.LETTER_SPACING.TITLE,
|
|
18
|
+
}, value: letterSpacing, options: LETTER_SPACING_VALUES.map(value => ({
|
|
19
|
+
value: `${value}px`,
|
|
20
|
+
label: `${value} px`,
|
|
21
|
+
})), onClickOption: v => {
|
|
22
|
+
editor.chain().focus().setLetterSpacing(v).run();
|
|
23
|
+
}, onClick: (_, isSelected) => {
|
|
24
|
+
if (isSelected) {
|
|
25
|
+
editor.chain().focus().unsetLetterSpacing().run();
|
|
26
|
+
}
|
|
27
|
+
}, children: _jsx(LetterSpacingIcon, { size: 18 }) }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
interface SpacingActionProps {
|
|
3
|
+
editor: Editor;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const LineSpacingIcon: (props: React.SVGProps<SVGSVGElement> & {
|
|
7
|
+
size?: number;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const LineSpacingAction: (props: SpacingActionProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DEFAULT_TEXT_STYLE, TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
3
|
+
import { DropdownButton } from '../../DropdownButton';
|
|
4
|
+
import { range, round } from 'lodash';
|
|
5
|
+
import { Tooltip } from 'antd';
|
|
6
|
+
import { useEditorState } from '@tiptap/react';
|
|
7
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
8
|
+
export const LineSpacingIcon = (props) => {
|
|
9
|
+
const { size = 24, ...restProps } = props;
|
|
10
|
+
return (_jsx("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...restProps, children: _jsx("path", { d: "M21 10H13M21 6H13M21 14H13M21 18H13M6 20L6 4M6 20L3 17M6 20L9 17M6 4L3 7M6 4L9 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
11
|
+
};
|
|
12
|
+
const OPTIONS = [
|
|
13
|
+
{ value: '1', label: 'Single' },
|
|
14
|
+
{ value: '2', label: 'Double' },
|
|
15
|
+
...range(1.1, 3.1, 0.1).map(spacing => {
|
|
16
|
+
const roundValue = round(spacing, 1);
|
|
17
|
+
return {
|
|
18
|
+
value: `${roundValue}`,
|
|
19
|
+
label: `${roundValue}`,
|
|
20
|
+
};
|
|
21
|
+
}),
|
|
22
|
+
];
|
|
23
|
+
export const LineSpacingAction = (props) => {
|
|
24
|
+
const { editor, defaultValue = DEFAULT_TEXT_STYLE.lineHeight } = props;
|
|
25
|
+
const { selectedLineHeight } = useEditorState({
|
|
26
|
+
editor,
|
|
27
|
+
selector: ({ editor: editorInstance }) => ({
|
|
28
|
+
selectedLineHeight: OPTIONS.find(opt => {
|
|
29
|
+
const { value } = opt;
|
|
30
|
+
return +editorInstance.getAttributes('textStyle').lineHeight === +value;
|
|
31
|
+
}),
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
return (_jsx(DropdownButton, { value: selectedLineHeight?.value, options: [
|
|
35
|
+
{
|
|
36
|
+
label: (_jsx(Tooltip, { mouseEnterDelay: 0.4, title: defaultValue, arrow: false, children: "Default" })),
|
|
37
|
+
value: defaultValue,
|
|
38
|
+
},
|
|
39
|
+
...OPTIONS,
|
|
40
|
+
], onClickOption: value => {
|
|
41
|
+
editor.chain().focus().setLineHeight(value).run();
|
|
42
|
+
}, tooltipProps: {
|
|
43
|
+
title: TOOLTIPS.LINE_SPACING.TITLE,
|
|
44
|
+
}, children: _jsx(LineSpacingIcon, { size: 18 }) }));
|
|
45
|
+
};
|