@antscorp/antsomi-ui 2.0.90 → 2.0.91-text-editor-beta.1
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 +4 -2
- 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/AntsomiAIIcon.d.ts +3 -0
- package/es/components/icons/AntsomiAIIcon.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/EmotionFeedbackIcon.d.ts +6 -0
- package/es/components/icons/EmotionFeedbackIcon.js +8 -0
- package/es/components/icons/FeedbackRatingIcon.d.ts +3 -0
- package/es/components/icons/FeedbackRatingIcon.js +7 -0
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +17 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +14 -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/NoteNewIcon.d.ts +3 -0
- package/es/components/icons/NoteNewIcon.js +7 -0
- package/es/components/icons/SearchNotFoundIcon.d.ts +3 -0
- package/es/components/icons/SearchNotFoundIcon.js +7 -0
- package/es/components/icons/SummarizeIcon.d.ts +3 -0
- package/es/components/icons/SummarizeIcon.js +7 -0
- package/es/components/icons/index.d.ts +14 -0
- package/es/components/icons/index.js +14 -0
- package/es/components/index.scss +2 -0
- package/es/components/molecules/ColorSetting/index.js +2 -11
- package/es/components/molecules/ColorSetting/styled.d.ts +1 -1
- package/es/components/molecules/ColorSetting/styled.js +9 -1
- 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 +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
- package/es/components/molecules/EmojiPopover/styled.d.ts +2 -2
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +127 -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 +20 -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 +36 -0
- package/es/components/molecules/FontSizeInput/styles.scss +15 -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/ItemNotFound/ItemNotFound.d.ts +6 -0
- package/es/components/molecules/ItemNotFound/ItemNotFound.js +9 -0
- package/es/components/molecules/ItemNotFound/index.d.ts +1 -0
- package/es/components/molecules/ItemNotFound/index.js +1 -0
- package/es/components/molecules/ItemNotFound/styled.d.ts +4 -0
- package/es/components/molecules/ItemNotFound/styled.js +29 -0
- package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +23 -7
- package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.d.ts +1 -0
- package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.js +7 -2
- package/es/components/molecules/MatchAnySelect/types.d.ts +2 -1
- package/es/components/molecules/MatchAnySelect/utils.d.ts +1 -0
- package/es/components/molecules/MatchAnySelect/utils.js +2 -0
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +6 -3
- package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +2550 -938
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +1 -11
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +53 -25
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +8 -5
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +289 -46
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +1 -0
- package/es/components/molecules/VirtualizedMenu/styled.d.ts +2 -2
- package/es/components/molecules/VirtualizedMenu/styled.js +23 -4
- package/es/components/molecules/VirtualizedMenu/types.d.ts +27 -10
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +8 -5
- package/es/components/molecules/VirtualizedMenu/utils.js +13 -18
- package/es/components/molecules/index.d.ts +2 -0
- package/es/components/molecules/index.js +2 -0
- package/es/components/molecules/index.scss +1 -0
- package/es/components/organism/ActivityTimeline/ActivityTimeline.js +15 -9
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -0
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -0
- package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.d.ts +3 -4
- package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.js +4 -3
- package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.d.ts +4 -6
- package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.js +4 -4
- package/es/components/organism/ActivityTimeline/components/TimeLineTitle/TimelineTitle.js +1 -1
- package/es/components/organism/ActivityTimeline/types.d.ts +2 -1
- package/es/components/organism/ActivityTimeline/utils.d.ts +1 -1
- package/es/components/organism/ActivityTimeline/utils.js +1 -1
- package/es/components/organism/TextEditor/TextEditor.d.ts +3 -0
- package/es/components/organism/TextEditor/TextEditor.js +257 -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 +38 -0
- package/es/components/organism/TextEditor/constants.d.ts +175 -0
- package/es/components/organism/TextEditor/constants.js +321 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +46 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +130 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +247 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +31 -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/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 +32 -0
- package/es/components/organism/TextEditor/extensions/FontSize.js +47 -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/Highlight.d.ts +1 -0
- package/es/components/organism/TextEditor/extensions/Highlight.js +14 -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 +36 -0
- package/es/components/organism/TextEditor/extensions/Link.d.ts +16 -0
- package/es/components/organism/TextEditor/extensions/Link.js +48 -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 +39 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.js +167 -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 +31 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.js +37 -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 +7 -0
- package/es/components/organism/TextEditor/hooks/index.js +7 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.js +22 -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/useLinkHandler.d.ts +11 -0
- package/es/components/organism/TextEditor/hooks/useLinkHandler.js +125 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +68 -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 +14 -0
- package/es/components/organism/TextEditor/index.js +6 -0
- package/es/components/organism/TextEditor/index.scss +61 -0
- package/es/components/organism/TextEditor/provider.d.ts +15 -0
- package/es/components/organism/TextEditor/provider.js +33 -0
- package/es/components/organism/TextEditor/store.d.ts +13 -0
- package/es/components/organism/TextEditor/store.js +20 -0
- package/es/components/organism/TextEditor/styled.d.ts +10 -0
- package/es/components/organism/TextEditor/styled.js +94 -0
- package/es/components/organism/TextEditor/types.d.ts +96 -0
- package/es/components/organism/TextEditor/types.js +3 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +85 -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/BubbleToolbar/BubbleToolbar.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +1 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Button/Button.js +31 -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/FontPopover.d.ts +12 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +69 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +22 -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 +52 -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 +77 -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/Toolbar.d.ts +15 -0
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +41 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +84 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +27 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +31 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +28 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +47 -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/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/SpacingAction.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +45 -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 +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +1 -0
- package/es/components/organism/TextEditor/utils/documentState.d.ts +57 -0
- package/es/components/organism/TextEditor/utils/documentState.js +100 -0
- package/es/components/organism/TextEditor/utils/font.d.ts +73 -0
- package/es/components/organism/TextEditor/utils/font.js +160 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +63 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +319 -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 +100 -0
- package/es/components/organism/TextEditor/utils/link.js +149 -0
- package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
- package/es/components/organism/TextEditor/utils/menu.js +317 -0
- package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
- package/es/components/organism/TextEditor/utils/selection.js +57 -0
- package/es/components/organism/TextEditor/utils/shared.d.ts +1 -0
- package/es/components/organism/TextEditor/utils/shared.js +9 -0
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
- package/es/components/organism/TextEditor/utils/smartTag.js +89 -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/TicketEditor/index.js +24 -16
- 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/hooks/index.d.ts +3 -0
- package/es/hooks/index.js +3 -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/useIsMounted.d.ts +1 -0
- package/es/hooks/useIsMounted.js +11 -0
- package/es/locales/en/translation.json +2 -1
- package/es/locales/i18n.d.ts +3 -1
- package/es/locales/vi/translation.json +2 -1
- package/es/utils/common.d.ts +6 -9
- package/es/utils/common.js +44 -23
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/tree.d.ts +225 -0
- package/es/utils/tree.js +469 -0
- package/es/utils/web.d.ts +15 -0
- package/es/utils/web.js +39 -0
- package/package.json +24 -4
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { JSONContent, Editor } from '@tiptap/core';
|
|
3
|
+
import { LinkAttrs } from './extensions/Link';
|
|
4
|
+
import { SmartTagAttrs } from './extensions/SmartTag';
|
|
5
|
+
import { ORDERED_LIST_STYLE_TYPE, UNORDERED_LIST_STYLE_TYPE } from './constants';
|
|
6
|
+
export type HandleSmartTagRef = {
|
|
7
|
+
setSmartTag: (attrs: SmartTagAttrs) => void;
|
|
8
|
+
deleteSmartTag: (id: string) => void;
|
|
9
|
+
updateSmartTagAttrs: (id: string, updatedAttrs: Omit<SmartTagAttrs, 'id'>) => void;
|
|
10
|
+
};
|
|
11
|
+
export type HandleLinkRef = {
|
|
12
|
+
setLink: (attrs: LinkAttrs) => void;
|
|
13
|
+
deleteLink: (id: string) => void;
|
|
14
|
+
updateLinkAttrs: (id: string, updatedAttrs: Omit<LinkAttrs, 'id'>) => void;
|
|
15
|
+
};
|
|
16
|
+
export type TextEditorRef = HandleSmartTagRef & HandleLinkRef & {
|
|
17
|
+
blur: (perserveSelection?: boolean) => void;
|
|
18
|
+
style?: CSSStyleDeclaration;
|
|
19
|
+
readonly editor: Editor | null;
|
|
20
|
+
};
|
|
21
|
+
export type SmartTagHandler = Partial<{
|
|
22
|
+
edit: (id: string, event: React.MouseEvent) => void;
|
|
23
|
+
setNew: (args: {
|
|
24
|
+
selectionText: string;
|
|
25
|
+
}) => void;
|
|
26
|
+
}>;
|
|
27
|
+
export type LinkHandler = Partial<{
|
|
28
|
+
setNew: (args: {
|
|
29
|
+
selectionText: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
edit: (args: {
|
|
32
|
+
id: string;
|
|
33
|
+
selectionText: string;
|
|
34
|
+
}) => void;
|
|
35
|
+
}>;
|
|
36
|
+
export type FontConfig = {
|
|
37
|
+
fontFamily: {
|
|
38
|
+
name: string;
|
|
39
|
+
fallback?: string[];
|
|
40
|
+
};
|
|
41
|
+
fontWeight: number[];
|
|
42
|
+
};
|
|
43
|
+
export type Config = Partial<{
|
|
44
|
+
SmartTag: Partial<{
|
|
45
|
+
highlight: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
Link: Partial<{
|
|
48
|
+
highlightDynamic: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
FontFamily: {
|
|
51
|
+
fonts: FontConfig[];
|
|
52
|
+
};
|
|
53
|
+
UnorderedList: {
|
|
54
|
+
useCustomBullet?: boolean;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export type TextStyle = {
|
|
58
|
+
fontFamily: string;
|
|
59
|
+
fontSize: string;
|
|
60
|
+
color: string;
|
|
61
|
+
backgroundColor: string;
|
|
62
|
+
lineHeight: string;
|
|
63
|
+
fontWeight: string;
|
|
64
|
+
letterSpacing: string;
|
|
65
|
+
};
|
|
66
|
+
export type TextEditorProps = {
|
|
67
|
+
id?: string;
|
|
68
|
+
className?: string;
|
|
69
|
+
style?: React.CSSProperties;
|
|
70
|
+
initialContent?: string;
|
|
71
|
+
config?: Config;
|
|
72
|
+
smartTagHandler?: SmartTagHandler;
|
|
73
|
+
linkHandler?: LinkHandler;
|
|
74
|
+
editable?: boolean;
|
|
75
|
+
bubbleMenuProps?: {
|
|
76
|
+
container?: HTMLElement | null;
|
|
77
|
+
};
|
|
78
|
+
defaultTextStyle?: Partial<TextStyle>;
|
|
79
|
+
dataAttributes?: Record<`data-${string}`, unknown>;
|
|
80
|
+
onUpdateDebounced?: number;
|
|
81
|
+
onFocus?: (event: FocusEvent) => void;
|
|
82
|
+
onUpdate?: (args: {
|
|
83
|
+
html: string;
|
|
84
|
+
text: string;
|
|
85
|
+
json: JSONContent;
|
|
86
|
+
}) => void;
|
|
87
|
+
onCreate?: (args: {
|
|
88
|
+
html: string;
|
|
89
|
+
text: string;
|
|
90
|
+
json: JSONContent;
|
|
91
|
+
}) => void;
|
|
92
|
+
};
|
|
93
|
+
export type OrderedListStyleType = (typeof ORDERED_LIST_STYLE_TYPE)[keyof typeof ORDERED_LIST_STYLE_TYPE];
|
|
94
|
+
export type UnorderedListStyleType = (typeof UNORDERED_LIST_STYLE_TYPE)[keyof typeof UNORDERED_LIST_STYLE_TYPE];
|
|
95
|
+
export declare const isOrderedListStyleType: (value: unknown) => value is OrderedListStyleType;
|
|
96
|
+
export declare const isUnorderedListStyleType: (value: unknown) => value is UnorderedListStyleType;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ORDERED_LIST_STYLE_TYPE, UNORDERED_LIST_STYLE_TYPE } from './constants';
|
|
2
|
+
export const isOrderedListStyleType = (value) => typeof value === 'string' && Object.values(ORDERED_LIST_STYLE_TYPE).some(v => v === value);
|
|
3
|
+
export const isUnorderedListStyleType = (value) => typeof value === 'string' && Object.values(UNORDERED_LIST_STYLE_TYPE).some(v => v === value);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BubbleMenuPluginProps } from '../../extensions/BubbleMenu';
|
|
3
|
+
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
4
|
+
export type BubbleMenuProps = Optional<Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'>, 'editor'> & React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
+
export declare const BubbleMenu: React.ForwardRefExoticComponent<Pick<Partial<Omit<Optional<BubbleMenuPluginProps, "pluginKey">, "element">>, "editor"> & Omit<Omit<Optional<BubbleMenuPluginProps, "pluginKey">, "element">, "editor"> & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import { useCurrentEditor } from '@tiptap/react';
|
|
4
|
+
import { forwardRef, useRef } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import { BubbleMenuPlugin } from '../../extensions/BubbleMenu';
|
|
7
|
+
import { useDeepCompareEffect, useIsMounted } from '@antscorp/antsomi-ui/es/hooks';
|
|
8
|
+
import { useTextEditorStore } from '../../provider';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { ANTSOMI_COMPONENT_PREFIX_CLS } from '@antscorp/antsomi-ui/es/constants';
|
|
11
|
+
export const BubbleMenu = forwardRef(({ pluginKey = 'bubbleMenu', editor, updateDelay, resizeDelay, shouldShow = null, options, children, container, className, ...restProps }, ref) => {
|
|
12
|
+
const menuEl = useRef(document.createElement('div'));
|
|
13
|
+
const isMounted = useIsMounted();
|
|
14
|
+
const setIsShowBubbleMenu = useTextEditorStore(state => state.setIsShowBubbleMenu);
|
|
15
|
+
console.log({ setIsShowBubbleMenu });
|
|
16
|
+
if (typeof ref === 'function') {
|
|
17
|
+
ref(menuEl.current);
|
|
18
|
+
}
|
|
19
|
+
else if (ref) {
|
|
20
|
+
ref.current = menuEl.current;
|
|
21
|
+
}
|
|
22
|
+
const { editor: currentEditor } = useCurrentEditor();
|
|
23
|
+
useDeepCompareEffect(() => {
|
|
24
|
+
const bubbleMenuElement = menuEl.current;
|
|
25
|
+
bubbleMenuElement.className = clsx(className, `${ANTSOMI_COMPONENT_PREFIX_CLS}-text-editor-bubble-menu`);
|
|
26
|
+
if (editor?.isDestroyed || currentEditor?.isDestroyed) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const attachToEditor = editor || currentEditor;
|
|
30
|
+
if (!attachToEditor) {
|
|
31
|
+
console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const plugin = BubbleMenuPlugin({
|
|
35
|
+
updateDelay,
|
|
36
|
+
resizeDelay,
|
|
37
|
+
editor: attachToEditor,
|
|
38
|
+
element: bubbleMenuElement,
|
|
39
|
+
container,
|
|
40
|
+
pluginKey,
|
|
41
|
+
shouldShow,
|
|
42
|
+
onShow: () => {
|
|
43
|
+
if (isMounted()) {
|
|
44
|
+
setIsShowBubbleMenu(true);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onHide: () => {
|
|
48
|
+
if (isMounted()) {
|
|
49
|
+
setIsShowBubbleMenu(false);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
options: {
|
|
53
|
+
...options,
|
|
54
|
+
strategy: options?.strategy || 'absolute',
|
|
55
|
+
placement: options?.placement || 'top-start',
|
|
56
|
+
offset: options?.offset || {
|
|
57
|
+
alignmentAxis: -20,
|
|
58
|
+
mainAxis: 10,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
attachToEditor.registerPlugin(plugin);
|
|
63
|
+
return () => {
|
|
64
|
+
attachToEditor.unregisterPlugin(pluginKey);
|
|
65
|
+
window.requestAnimationFrame(() => {
|
|
66
|
+
if (bubbleMenuElement.parentNode) {
|
|
67
|
+
bubbleMenuElement.parentNode.removeChild(bubbleMenuElement);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
}, [
|
|
72
|
+
editor,
|
|
73
|
+
container,
|
|
74
|
+
updateDelay,
|
|
75
|
+
resizeDelay,
|
|
76
|
+
pluginKey,
|
|
77
|
+
options,
|
|
78
|
+
className,
|
|
79
|
+
currentEditor,
|
|
80
|
+
isMounted,
|
|
81
|
+
shouldShow,
|
|
82
|
+
setIsShowBubbleMenu,
|
|
83
|
+
]);
|
|
84
|
+
return createPortal(_jsx("div", { ...restProps, children: children }), menuEl.current);
|
|
85
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BubbleMenu, type BubbleMenuProps } from './BubbleMenu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BubbleMenu } from './BubbleMenu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BubbleToolbar: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const BubbleToolbar = () => { };
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Tooltip } from 'antd';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
const StyledButton = styled(Button) `
|
|
6
|
+
&.antsomi-btn.antsomi-btn-text {
|
|
7
|
+
height: 36px;
|
|
8
|
+
width: 36px;
|
|
9
|
+
padding: 0;
|
|
10
|
+
flex-shrink: 0;
|
|
11
|
+
border-radius: 4px;
|
|
12
|
+
|
|
13
|
+
&.is-active {
|
|
14
|
+
background-color: #e0ebf7;
|
|
15
|
+
|
|
16
|
+
&:hover {
|
|
17
|
+
background-color: #e0ebf7;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:hover:not(:disabled, .is-active) {
|
|
22
|
+
background-color: #ebebeb;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
export const TextEditorButton = (props) => {
|
|
27
|
+
const { children, isActive, tooltipProps, className, disabled, ...restProps } = props;
|
|
28
|
+
return (_jsx(Tooltip, { mouseEnterDelay: 0.4, placement: "top", ...tooltipProps, open: disabled ? false : tooltipProps?.open, children: _jsx(StyledButton, { ...restProps, disabled: disabled, type: "text", className: clsx(className, {
|
|
29
|
+
'is-active': isActive,
|
|
30
|
+
}), children: children }) }));
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextEditorButton } from './Button';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from 'antd';
|
|
3
|
+
export type TextEditorButtonProps = {
|
|
4
|
+
isActive?: boolean;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
tooltipProps?: {
|
|
7
|
+
title?: string;
|
|
8
|
+
open?: boolean;
|
|
9
|
+
};
|
|
10
|
+
} & Pick<ButtonProps, 'icon' | 'onClick' | 'className' | 'disabled' | 'className'>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PopoverProps } from 'antd/lib';
|
|
3
|
+
export interface ColorPickerProps {
|
|
4
|
+
value?: string;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
popoverProps?: Omit<PopoverProps, 'content'> & {
|
|
8
|
+
content?: ((args: {
|
|
9
|
+
colorGrid: React.ReactNode;
|
|
10
|
+
usedColors: React.ReactNode;
|
|
11
|
+
customColorPicker: React.ReactNode;
|
|
12
|
+
}) => React.ReactNode) | React.ReactNode;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface ColorPickerRef {
|
|
16
|
+
setOpen: (open: boolean) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface UsedColorsProps {
|
|
19
|
+
value?: string;
|
|
20
|
+
onChange?: (value: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export interface GridColorProps {
|
|
23
|
+
value?: string;
|
|
24
|
+
colorGrid?: string[][];
|
|
25
|
+
onChange?: (value: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface UseUsedColorsParams {
|
|
28
|
+
numberOfColors?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface BoxColorProps {
|
|
31
|
+
color?: string;
|
|
32
|
+
isActive?: boolean;
|
|
33
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
34
|
+
}
|
|
35
|
+
export interface CustomColorPickerProps {
|
|
36
|
+
currentColor: string;
|
|
37
|
+
onApply?: (value: string) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<ColorPickerRef>>;
|
|
@@ -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?.(color);
|
|
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 { 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: 36px;
|
|
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] : [], 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
|
+
});
|