@antscorp/antsomi-ui 2.0.110 → 2.0.111
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 +388 -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 +178 -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 +28 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.js +103 -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 +311 -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 +18 -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,131 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable react/no-array-index-key */
|
|
3
|
+
import { ColorPicker as AntdColorPicker, Button, Col, Flex, Row, Typography } from 'antd';
|
|
4
|
+
import tinycolor from 'tinycolor2';
|
|
5
|
+
import { chunk } from 'lodash';
|
|
6
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../constants';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
import { forwardRef, useEffect, useState, useImperativeHandle } from 'react';
|
|
9
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
10
|
+
import { useTextEditorStore } from '../../provider';
|
|
11
|
+
import { ColorBox } from '../../styled';
|
|
12
|
+
import { TextEditorPopover } from '../Popover';
|
|
13
|
+
import { useColorSet } from '../../hooks';
|
|
14
|
+
import { CheckSlimIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
15
|
+
const { COLOR_GIRD } = TEXT_EDITOR_CONSTANTS;
|
|
16
|
+
const useUsedColors = (params) => {
|
|
17
|
+
const { numberOfColors = 10 } = params || {};
|
|
18
|
+
const { colors: usedColors, setColors: updateColor } = useColorSet();
|
|
19
|
+
const addColor = (color) => {
|
|
20
|
+
const updatedColors = [...usedColors];
|
|
21
|
+
if (!usedColors.includes(color)) {
|
|
22
|
+
updatedColors.push(color);
|
|
23
|
+
if (usedColors.length >= numberOfColors) {
|
|
24
|
+
updatedColors.shift();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
updateColor(updatedColors);
|
|
28
|
+
};
|
|
29
|
+
return { usedColors, addColor };
|
|
30
|
+
};
|
|
31
|
+
const CustomColorPicker = (props) => {
|
|
32
|
+
const { onApply, currentColor } = props;
|
|
33
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
34
|
+
const [color, setColor] = useState(currentColor || tinycolor('red').toHex());
|
|
35
|
+
const { addColor: addUsedColor } = useUsedColors();
|
|
36
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (tinycolor(currentColor).isValid()) {
|
|
39
|
+
setColor(currentColor);
|
|
40
|
+
}
|
|
41
|
+
}, [currentColor]);
|
|
42
|
+
const handleChangeColor = useDebouncedCallback((newColor) => {
|
|
43
|
+
setColor(newColor);
|
|
44
|
+
}, 50);
|
|
45
|
+
const handleClose = () => {
|
|
46
|
+
if (tinycolor(currentColor).isValid()) {
|
|
47
|
+
setColor(currentColor);
|
|
48
|
+
}
|
|
49
|
+
setIsOpen(false);
|
|
50
|
+
};
|
|
51
|
+
const handleOpenChange = (visible) => {
|
|
52
|
+
if (visible)
|
|
53
|
+
return setIsOpen(true);
|
|
54
|
+
handleClose();
|
|
55
|
+
};
|
|
56
|
+
const handleApply = () => {
|
|
57
|
+
addUsedColor(color);
|
|
58
|
+
onApply?.(color);
|
|
59
|
+
handleClose();
|
|
60
|
+
};
|
|
61
|
+
return (_jsx(AntdColorPicker, { getPopupContainer: () => bubbleMenuContainer || document.body, open: isOpen, value: color, placement: "bottomRight", panelRender: panel => (_jsxs(_Fragment, { children: [panel, _jsxs(Flex, { justify: "end", gap: 8, style: { marginTop: 10 }, children: [_jsx(Button, { type: "text", onClick: handleClose, children: "Cancel" }), _jsx(Button, { type: "primary", onClick: handleApply, children: "Apply" })] })] })), onChange: newColor => {
|
|
62
|
+
handleChangeColor(newColor.toRgbString());
|
|
63
|
+
}, onOpenChange: handleOpenChange, children: _jsx(Button, { children: "Customize" }) }));
|
|
64
|
+
};
|
|
65
|
+
const ColorSwatch = (props) => {
|
|
66
|
+
const { color, isActive, onClick } = props;
|
|
67
|
+
const handleClick = (e) => {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
onClick?.(e);
|
|
70
|
+
};
|
|
71
|
+
return (_jsx(ColorBox, { "$color": color, className: clsx({
|
|
72
|
+
'is-active': isActive,
|
|
73
|
+
}), onClick: handleClick, children: isActive ? _jsx(CheckSlimIcon, { color: tinycolor(color).isDark() ? 'white' : 'black' }) : null }));
|
|
74
|
+
};
|
|
75
|
+
const UsedColors = (props) => {
|
|
76
|
+
const { onChange, value } = props;
|
|
77
|
+
const { usedColors, addColor: addUsedColor } = useUsedColors();
|
|
78
|
+
const rowColorSize = COLOR_GIRD[0].length;
|
|
79
|
+
const handleClick = (color) => {
|
|
80
|
+
addUsedColor(color);
|
|
81
|
+
onChange?.(color);
|
|
82
|
+
};
|
|
83
|
+
if (usedColors.length === 0) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return (_jsxs(Flex, { vertical: true, gap: 2, children: [_jsx(Typography.Text, { children: "Recently used" }), chunk(usedColors, rowColorSize).map((row, rowIndex) => (_jsx(Row, { gutter: [2, 2], children: row.map((color, colIndex) => (_jsx(Col, { span: 24 / rowColorSize, children: _jsx(ColorSwatch, { color: color, isActive: color === value, onClick: () => handleClick(color) }) }, `${rowIndex}-${colIndex}`))) }, rowIndex)))] }));
|
|
87
|
+
};
|
|
88
|
+
const GridColor = (props) => {
|
|
89
|
+
const { onChange, value, colorGrid = COLOR_GIRD } = props;
|
|
90
|
+
const rowColorSize = colorGrid[0].length;
|
|
91
|
+
const { addColor: addUsedColor } = useUsedColors();
|
|
92
|
+
const handleClick = (color) => {
|
|
93
|
+
addUsedColor(color);
|
|
94
|
+
onChange?.(color);
|
|
95
|
+
};
|
|
96
|
+
return (_jsx(Flex, { vertical: true, gap: 2, children: colorGrid.map((row, rowIndex) => (_jsx(Row, { gutter: [2, 2], wrap: false, children: row.map((color, colIndex) => (_jsx(Col, { span: 24 / rowColorSize, children: _jsx(ColorSwatch, { color: color, isActive: tinycolor.equals(color, value), onClick: () => handleClick(color) }) }, `${rowIndex}-${colIndex}`))) }, rowIndex))) }));
|
|
97
|
+
};
|
|
98
|
+
export const ColorPicker = forwardRef((props, ref) => {
|
|
99
|
+
const { value = '', onChange, children, popoverProps } = props;
|
|
100
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (popoverProps?.open !== undefined) {
|
|
103
|
+
setIsOpen(popoverProps.open);
|
|
104
|
+
}
|
|
105
|
+
}, [popoverProps?.open]);
|
|
106
|
+
const handleChangeOpen = (open) => {
|
|
107
|
+
setIsOpen(open);
|
|
108
|
+
if (popoverProps?.onOpenChange) {
|
|
109
|
+
popoverProps.onOpenChange(open);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const handleOnChange = (color) => {
|
|
113
|
+
onChange?.(tinycolor(color).toRgbString());
|
|
114
|
+
handleChangeOpen(false);
|
|
115
|
+
};
|
|
116
|
+
useImperativeHandle(ref, () => ({
|
|
117
|
+
setOpen: handleChangeOpen,
|
|
118
|
+
}));
|
|
119
|
+
const colorGrid = _jsx(GridColor, { onChange: handleOnChange, value: value });
|
|
120
|
+
const usedColors = _jsx(UsedColors, { onChange: handleOnChange, value: value });
|
|
121
|
+
const customColorPicker = _jsx(CustomColorPicker, { currentColor: value, onApply: handleOnChange });
|
|
122
|
+
let content = (_jsxs(Flex, { vertical: true, gap: 8, children: [colorGrid, usedColors, customColorPicker] }));
|
|
123
|
+
if (typeof popoverProps?.content === 'function') {
|
|
124
|
+
content = popoverProps.content({
|
|
125
|
+
colorGrid,
|
|
126
|
+
usedColors,
|
|
127
|
+
customColorPicker,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return (_jsx(TextEditorPopover, { placement: "bottomLeft", ...popoverProps, open: isOpen, content: content, onOpenChange: handleChangeOpen, children: children }));
|
|
131
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker } from './ColorPicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ColorPicker } from './ColorPicker';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type TextEditorButtonProps } from '../Button';
|
|
3
|
+
type DropdownButtonProps = {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
value?: string;
|
|
6
|
+
options?: {
|
|
7
|
+
value: string;
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
tooltipProps?: TextEditorButtonProps['tooltipProps'];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
onClickOption?: (key: string) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const DropdownButton: (props: DropdownButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Dropdown } from 'antd';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { TextEditorButton } from '../Button';
|
|
5
|
+
import { ArrowDropDownIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import clsx from 'clsx';
|
|
8
|
+
const StyledTriggerButton = styled(TextEditorButton) `
|
|
9
|
+
&.antsomi-dropdown-trigger.antsomi-btn {
|
|
10
|
+
gap: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
width: 40px;
|
|
13
|
+
height: 24px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.is-open {
|
|
17
|
+
svg.icon-dropdown {
|
|
18
|
+
transform: rotate(180deg);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
export const DropdownButton = (props) => {
|
|
23
|
+
const { className, children, disabled, tooltipProps, options = [], value, onClickOption } = props;
|
|
24
|
+
const selectedOpt = value ? options.filter(opt => opt.value === value) : [];
|
|
25
|
+
const isSelected = selectedOpt.length > 0;
|
|
26
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
+
const handleOpenChange = (visible) => {
|
|
28
|
+
if (disabled)
|
|
29
|
+
return;
|
|
30
|
+
setIsOpen(visible);
|
|
31
|
+
};
|
|
32
|
+
return (_jsx(Dropdown, { trigger: ['click'], className: clsx(className, {
|
|
33
|
+
'is-active': isSelected,
|
|
34
|
+
'is-open': isOpen,
|
|
35
|
+
}), disabled: disabled, placement: "bottomLeft", menu: {
|
|
36
|
+
style: {
|
|
37
|
+
maxHeight: 240,
|
|
38
|
+
overflow: 'auto',
|
|
39
|
+
},
|
|
40
|
+
items: options.map(opt => ({
|
|
41
|
+
key: opt.value,
|
|
42
|
+
label: opt.label,
|
|
43
|
+
disabled: opt.disabled,
|
|
44
|
+
})),
|
|
45
|
+
selectedKeys: selectedOpt.map(opt => opt.value),
|
|
46
|
+
onClick: e => {
|
|
47
|
+
const { key } = e;
|
|
48
|
+
onClickOption?.(key);
|
|
49
|
+
},
|
|
50
|
+
}, open: isOpen, onOpenChange: handleOpenChange, children: _jsxs(StyledTriggerButton, { tooltipProps: tooltipProps, isActive: isSelected, disabled: disabled, children: [children, _jsx(ArrowDropDownIcon, { className: "icon-dropdown", size: 16 })] }) }));
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropdownButton } from './DropdownButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DropdownButton } from './DropdownButton';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { EmojiNodeAttrs, SuggestionItem } from '../../extensions/Emoji';
|
|
3
|
+
import { SuggestionProps } from '@tiptap/suggestion';
|
|
4
|
+
export declare const ITEM_SIZE = 28;
|
|
5
|
+
export type EmojiListRef = {
|
|
6
|
+
onKeyDown: (args: {
|
|
7
|
+
event: KeyboardEvent;
|
|
8
|
+
}) => boolean;
|
|
9
|
+
};
|
|
10
|
+
export type EmojiListProps = SuggestionProps<SuggestionItem, EmojiNodeAttrs>;
|
|
11
|
+
export declare const EmojiList: import("react").ForwardRefExoticComponent<EmojiListProps & import("react").RefAttributes<EmojiListRef>>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from 'antd';
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
4
|
+
import { COMPONENT_CLS } from '../../constants';
|
|
5
|
+
import { VirtualizedMenu } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
6
|
+
import clsx from 'clsx';
|
|
7
|
+
export const ITEM_SIZE = 28;
|
|
8
|
+
export const EmojiList = forwardRef((props, ref) => {
|
|
9
|
+
const { items = [] } = props;
|
|
10
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
11
|
+
const selectItem = (index) => {
|
|
12
|
+
const item = items[index];
|
|
13
|
+
if (item) {
|
|
14
|
+
props.command({ name: item.name });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const upHandler = () => {
|
|
18
|
+
setSelectedIndex((selectedIndex + props.items.length - 1) % props.items.length);
|
|
19
|
+
};
|
|
20
|
+
const downHandler = () => {
|
|
21
|
+
setSelectedIndex((selectedIndex + 1) % props.items.length);
|
|
22
|
+
};
|
|
23
|
+
const enterHandler = () => {
|
|
24
|
+
selectItem(selectedIndex);
|
|
25
|
+
};
|
|
26
|
+
useEffect(() => setSelectedIndex(0), [props.items]);
|
|
27
|
+
useImperativeHandle(ref, () => ({
|
|
28
|
+
onKeyDown: ({ event }) => {
|
|
29
|
+
if (event.key === 'ArrowUp') {
|
|
30
|
+
upHandler();
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (event.key === 'ArrowDown') {
|
|
34
|
+
downHandler();
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
if (event.key === 'Enter') {
|
|
38
|
+
enterHandler();
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
if (items.length <= 0) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (_jsx(VirtualizedMenu, { className: `${COMPONENT_CLS}-emoji-list`, itemSize: ITEM_SIZE, selected: items.at(selectedIndex) ? [items[selectedIndex].slug] : [], focusedKey: items[selectedIndex]?.slug, onClick: item => {
|
|
48
|
+
const idx = items.findIndex(i => i.slug === item.item.key);
|
|
49
|
+
if (idx !== -1) {
|
|
50
|
+
selectItem(idx);
|
|
51
|
+
}
|
|
52
|
+
}, items: items.map(i => ({
|
|
53
|
+
key: i.slug,
|
|
54
|
+
className: clsx(`${COMPONENT_CLS}-emoji-item`),
|
|
55
|
+
label: (_jsxs(_Fragment, { children: [_jsx("span", { style: {
|
|
56
|
+
lineHeight: 1,
|
|
57
|
+
fontSize: ITEM_SIZE - 8,
|
|
58
|
+
}, children: i.emoji }), _jsxs(Typography.Text, { ellipsis: {
|
|
59
|
+
tooltip: {
|
|
60
|
+
title: i.slug,
|
|
61
|
+
mouseEnterDelay: 0.3,
|
|
62
|
+
placement: 'right',
|
|
63
|
+
},
|
|
64
|
+
}, children: [":", i.slug] }, i.slug)] })),
|
|
65
|
+
})) }));
|
|
66
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { posToDOMRect, ReactRenderer } from '@tiptap/react';
|
|
2
|
+
import { LIST_EMOJI } from '../../extensions/Emoji';
|
|
3
|
+
import { EmojiList, ITEM_SIZE } from './EmojiList';
|
|
4
|
+
import { computePosition, flip, shift } from '@floating-ui/dom';
|
|
5
|
+
import { COMPONENT_CLS } from '../../constants';
|
|
6
|
+
import { calInlineListSize } from '@antscorp/antsomi-ui/es/components/molecules/VirtualizedMenu/utils';
|
|
7
|
+
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
8
|
+
const updatePosition = (editor, element, itemLength) => {
|
|
9
|
+
const virtualElement = {
|
|
10
|
+
getBoundingClientRect: () => posToDOMRect(editor.view, editor.state.selection.from, editor.state.selection.to),
|
|
11
|
+
};
|
|
12
|
+
computePosition(virtualElement, element, {
|
|
13
|
+
placement: 'bottom-start',
|
|
14
|
+
strategy: 'absolute',
|
|
15
|
+
middleware: [shift(), flip()],
|
|
16
|
+
}).then(({ x, y, strategy }) => {
|
|
17
|
+
element.style.height = `${calInlineListSize(Math.min(itemLength, 6), ITEM_SIZE)}px`;
|
|
18
|
+
element.style.position = strategy;
|
|
19
|
+
element.style.left = `${x}px`;
|
|
20
|
+
element.style.top = `${y}px`;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export const suggestion = ({ container }) => ({
|
|
24
|
+
items: ({ query }) => LIST_EMOJI.filter(i => searchStringQuery(i.slug, query)),
|
|
25
|
+
render() {
|
|
26
|
+
let renderer;
|
|
27
|
+
const safeGetRenndererEl = () => {
|
|
28
|
+
if (renderer.element instanceof HTMLElement) {
|
|
29
|
+
return renderer.element;
|
|
30
|
+
}
|
|
31
|
+
throw Error('ReactRenderer element should be HTMLElement');
|
|
32
|
+
};
|
|
33
|
+
const destroy = () => {
|
|
34
|
+
renderer.destroy();
|
|
35
|
+
safeGetRenndererEl().remove();
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
onStart: props => {
|
|
39
|
+
renderer = new ReactRenderer(EmojiList, {
|
|
40
|
+
props,
|
|
41
|
+
editor: props.editor,
|
|
42
|
+
});
|
|
43
|
+
if (!props.clientRect) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const rendererEl = safeGetRenndererEl();
|
|
47
|
+
rendererEl.classList.add(`${COMPONENT_CLS}-emoji-popover`);
|
|
48
|
+
((typeof container === 'function' ? container() : container) || document.body).appendChild(rendererEl);
|
|
49
|
+
updatePosition(props.editor, rendererEl, props.items.length);
|
|
50
|
+
},
|
|
51
|
+
onUpdate(props) {
|
|
52
|
+
renderer.updateProps(props);
|
|
53
|
+
const rendererEl = safeGetRenndererEl();
|
|
54
|
+
if (!props.clientRect) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
updatePosition(props.editor, rendererEl, props.items.length);
|
|
58
|
+
},
|
|
59
|
+
onKeyDown(props) {
|
|
60
|
+
if (props.event.key === 'Escape') {
|
|
61
|
+
destroy();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
return renderer.ref?.onKeyDown(props) || false;
|
|
65
|
+
},
|
|
66
|
+
onExit() {
|
|
67
|
+
destroy();
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FONT_WEIGHT_MAP } from '../../constants';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { Flex, Typography } from 'antd';
|
|
5
|
+
import { TextEditorPopover } from '../Popover';
|
|
6
|
+
import { ChevronRightIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
export const FontItem = (props) => {
|
|
9
|
+
const { fontConfig, active, onSelectFont, onOpenChange } = props;
|
|
10
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
+
const numOfWeight = fontConfig.fontWeight.length;
|
|
12
|
+
const isActive = active?.font.fontFamily.name === fontConfig.fontFamily.name;
|
|
13
|
+
const fontNameContent = (_jsxs(Flex, { className: clsx('font-popover-item', { active: isOpen || isActive }), style: { fontFamily: fontConfig.fontFamily.name }, onClick: () => onSelectFont?.(400), align: "center", justify: "space-between", children: [fontConfig.fontFamily.name, numOfWeight > 1 && _jsx(ChevronRightIcon, { size: 14 })] }));
|
|
14
|
+
const handleOpenChange = (newOpen) => {
|
|
15
|
+
setIsOpen(newOpen);
|
|
16
|
+
onOpenChange?.(newOpen);
|
|
17
|
+
};
|
|
18
|
+
if (numOfWeight < 2) {
|
|
19
|
+
return fontNameContent;
|
|
20
|
+
}
|
|
21
|
+
return (_jsx(TextEditorPopover, { open: isOpen, onOpenChange: handleOpenChange, placement: "rightTop", trigger: ['hover'], arrow: false, overlayClassName: "font-weight-popover", destroyTooltipOnHide: true, content: _jsx(Flex, { vertical: true, gap: 4, children: fontConfig.fontWeight.map(weight => (_jsx(Typography.Text, { className: clsx('font-weight-item', {
|
|
22
|
+
active: active?.weight === weight,
|
|
23
|
+
}), style: {
|
|
24
|
+
fontFamily: fontConfig.fontFamily.name,
|
|
25
|
+
fontWeight: weight,
|
|
26
|
+
}, onClick: () => onSelectFont?.(weight), children: FONT_WEIGHT_MAP[weight] }, weight))) }), children: fontNameContent }));
|
|
27
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FontConfig, FontGroupingFunction, GroupOrderFunction } from '../../types';
|
|
3
|
+
import { FontPopoverProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Converts font configurations to menu items with optional grouping
|
|
6
|
+
* @param fonts Array of font configurations
|
|
7
|
+
* @param renderLabel Function to render font label
|
|
8
|
+
* @param fontGroupingFn Optional function to group fonts, or false to disable grouping
|
|
9
|
+
* @param groupOrder Optional array of group keys or function to define display order
|
|
10
|
+
* @returns Array of menu items for font selection
|
|
11
|
+
*/
|
|
12
|
+
export declare const createFontMenuItems: (fonts: FontConfig[], renderLabel: (font: FontConfig) => React.ReactNode, fontGroupingFn?: FontGroupingFunction | false, groupOrder?: string[] | GroupOrderFunction) => {
|
|
13
|
+
key: string;
|
|
14
|
+
label: React.ReactNode;
|
|
15
|
+
}[];
|
|
16
|
+
export declare const FontPopover: import("react").MemoExoticComponent<(props: FontPopoverProps) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Typography } from 'antd';
|
|
4
|
+
import { SearchPopover, VirtualizedMenu } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
5
|
+
import { FontGroupTitle, PopoverTrigger } from './styled';
|
|
6
|
+
import { calInlineListSize } from '@antscorp/antsomi-ui/es/components/molecules/VirtualizedMenu/utils';
|
|
7
|
+
import { useTextEditorStore } from '../../provider';
|
|
8
|
+
import { groupFonts, sortFontsByName } from '../../utils';
|
|
9
|
+
import { searchStringQuery } from '@antscorp/antsomi-ui/es/utils';
|
|
10
|
+
import { FontItem } from './FontItem';
|
|
11
|
+
import { useDebounce } from 'use-debounce';
|
|
12
|
+
/**
|
|
13
|
+
* Converts font configurations to menu items with optional grouping
|
|
14
|
+
* @param fonts Array of font configurations
|
|
15
|
+
* @param renderLabel Function to render font label
|
|
16
|
+
* @param fontGroupingFn Optional function to group fonts, or false to disable grouping
|
|
17
|
+
* @param groupOrder Optional array of group keys or function to define display order
|
|
18
|
+
* @returns Array of menu items for font selection
|
|
19
|
+
*/
|
|
20
|
+
export const createFontMenuItems = (fonts, renderLabel, fontGroupingFn, groupOrder) => {
|
|
21
|
+
const items = [];
|
|
22
|
+
const mapFontToMenuItem = (font) => ({
|
|
23
|
+
key: font.fontFamily.name,
|
|
24
|
+
label: renderLabel(font),
|
|
25
|
+
});
|
|
26
|
+
const appendFontGroup = (groupKey, groupLabel, groupFonts) => {
|
|
27
|
+
if (groupFonts.length <= 0)
|
|
28
|
+
return;
|
|
29
|
+
items.push({
|
|
30
|
+
key: groupKey,
|
|
31
|
+
displayOnly: true,
|
|
32
|
+
label: _jsx(FontGroupTitle, { className: "font-popover-item", children: groupLabel }),
|
|
33
|
+
}, ...groupFonts.map(mapFontToMenuItem));
|
|
34
|
+
};
|
|
35
|
+
if (fontGroupingFn !== false) {
|
|
36
|
+
const groupedFonts = groupFonts(fonts, {
|
|
37
|
+
fontGroupingFn,
|
|
38
|
+
groupOrder,
|
|
39
|
+
});
|
|
40
|
+
// Use Map.forEach to maintain insertion order
|
|
41
|
+
groupedFonts.forEach(({ label, fonts: groupFonts }, key) => {
|
|
42
|
+
appendFontGroup(key, label, groupFonts);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
items.push(...fonts.map(mapFontToMenuItem));
|
|
47
|
+
}
|
|
48
|
+
return items;
|
|
49
|
+
};
|
|
50
|
+
export const FontPopover = memo((props) => {
|
|
51
|
+
const { fonts = [], value: fontValue, onChange, fontGrouping, groupOrder } = props;
|
|
52
|
+
const itemSize = 30;
|
|
53
|
+
const itemSpacing = 4;
|
|
54
|
+
const activeFontName = fontValue?.font.fontFamily.name;
|
|
55
|
+
const inputSearchRef = useRef(null);
|
|
56
|
+
const [search, setSearch] = useState('');
|
|
57
|
+
const [open, setOpen] = useState(false);
|
|
58
|
+
const [fontItemsSize, setFontItemSize] = useDebounce(0, 200);
|
|
59
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
60
|
+
const filteredFonts = useMemo(() => {
|
|
61
|
+
let results = fonts.filter(font => searchStringQuery(font.fontFamily.name, search));
|
|
62
|
+
results = sortFontsByName(results);
|
|
63
|
+
return results;
|
|
64
|
+
}, [fonts, search]);
|
|
65
|
+
const handleClose = useCallback(() => {
|
|
66
|
+
setOpen(false);
|
|
67
|
+
setSearch('');
|
|
68
|
+
}, []);
|
|
69
|
+
const handleChangeFont = useCallback((font, weight = 400) => {
|
|
70
|
+
onChange?.(font, weight);
|
|
71
|
+
handleClose();
|
|
72
|
+
}, [onChange, handleClose]);
|
|
73
|
+
const handleOpenChange = (newOpen) => {
|
|
74
|
+
setOpen(newOpen);
|
|
75
|
+
if (newOpen === false) {
|
|
76
|
+
handleClose();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const items = useMemo(() => {
|
|
80
|
+
const renderLabel = (fontConfig) => (_jsx(FontItem, { fontConfig: fontConfig, active: fontValue ? { font: fontValue.font, weight: fontValue.weight } : undefined, onSelectFont: weight => handleChangeFont(fontConfig, weight) }));
|
|
81
|
+
return createFontMenuItems(filteredFonts, renderLabel, fontGrouping, groupOrder);
|
|
82
|
+
}, [filteredFonts, fontGrouping, groupOrder, fontValue, handleChangeFont]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
const listSize = calInlineListSize(Math.min(items.length, 6), itemSize, itemSpacing);
|
|
85
|
+
setFontItemSize(listSize);
|
|
86
|
+
}, [items.length, setFontItemSize]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (open) {
|
|
89
|
+
// Use setTimeout to ensure the popover content is fully mounted in the DOM
|
|
90
|
+
const timeoutId = setTimeout(() => {
|
|
91
|
+
inputSearchRef.current?.focus();
|
|
92
|
+
}, 0);
|
|
93
|
+
return () => clearTimeout(timeoutId);
|
|
94
|
+
}
|
|
95
|
+
}, [open]);
|
|
96
|
+
return (_jsx(SearchPopover, { open: open, placement: "bottomLeft", onOpenChange: handleOpenChange, getPopupContainer: () => bubbleMenuContainer || document.body, inputSearchProps: {
|
|
97
|
+
value: search,
|
|
98
|
+
onAfterChange: setSearch,
|
|
99
|
+
}, inputSearchRef: inputSearchRef, overlayClassName: "font-popover-overlay", content: _jsx("div", { className: "list-font-root", style: {
|
|
100
|
+
height: `${fontItemsSize}px`,
|
|
101
|
+
}, children: _jsx(VirtualizedMenu, { itemSize: itemSize, inlinePadding: 0, itemSpacing: itemSpacing, selectable: false, items: items }) }), children: _jsx(PopoverTrigger, { className: "font-popover-trigger", children: _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: activeFontName }) }) }));
|
|
102
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const PopoverTrigger = styled.div `
|
|
4
|
+
&.font-popover-trigger {
|
|
5
|
+
width: 100px;
|
|
6
|
+
height: 30px;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
padding: 0 7px;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
white-space: nowrap;
|
|
13
|
+
text-overflow: ellipsis;
|
|
14
|
+
font-size: ${THEME.token?.fontSize || 12}px;
|
|
15
|
+
border-bottom: 1px solid ${THEME.token?.blue1};
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
background-color: ${THEME.token?.blue};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
23
|
+
export const FontGroupTitle = styled.div `
|
|
24
|
+
color: ${THEME.token?.bw8};
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
font-size: 11px;
|
|
28
|
+
|
|
29
|
+
&.font-popover-item {
|
|
30
|
+
cursor: default;
|
|
31
|
+
|
|
32
|
+
&:hover {
|
|
33
|
+
background-color: white;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FontConfig, FontGroupingFunction, GroupOrderFunction } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Props for FontPopover component
|
|
4
|
+
*/
|
|
5
|
+
export type FontPopoverProps = {
|
|
6
|
+
/** Array of available font configurations */
|
|
7
|
+
fonts?: FontConfig[];
|
|
8
|
+
/** Currently selected font and weight */
|
|
9
|
+
value?: {
|
|
10
|
+
font: FontConfig;
|
|
11
|
+
weight: number;
|
|
12
|
+
};
|
|
13
|
+
/** Callback when font selection changes */
|
|
14
|
+
onChange?: (font: FontConfig, weight: number) => void;
|
|
15
|
+
/** Function to group fonts or false to disable grouping */
|
|
16
|
+
fontGrouping?: FontGroupingFunction | false;
|
|
17
|
+
/** Array of group keys or function to define display order. Groups not in this array will appear after ordered groups */
|
|
18
|
+
groupOrder?: string[] | GroupOrderFunction;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Props for FontItem component
|
|
22
|
+
*/
|
|
23
|
+
export type FontItemProps = {
|
|
24
|
+
/** Font configuration to display */
|
|
25
|
+
fontConfig: FontConfig;
|
|
26
|
+
/** Currently active font and weight */
|
|
27
|
+
active?: {
|
|
28
|
+
font: FontConfig;
|
|
29
|
+
weight: number;
|
|
30
|
+
};
|
|
31
|
+
/** Callback when font weight is selected */
|
|
32
|
+
onSelectFont?: (fontweight: number) => void;
|
|
33
|
+
/** Callback when popover open state changes */
|
|
34
|
+
onOpenChange?: (open: boolean) => void;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { LinkFormData } from '../../types';
|
|
4
|
+
export type LinkInsertFormProps = {
|
|
5
|
+
/** TipTap editor instance */
|
|
6
|
+
editor: Editor;
|
|
7
|
+
/** Form mode: insert or edit */
|
|
8
|
+
mode: 'insert' | 'edit';
|
|
9
|
+
/** Initial form data */
|
|
10
|
+
initialData: LinkFormData;
|
|
11
|
+
/** Callback when form is submitted */
|
|
12
|
+
onSubmit: () => void;
|
|
13
|
+
/** Callback when form is cancelled */
|
|
14
|
+
onCancel: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const LinkInsertForm: React.FC<LinkInsertFormProps>;
|