@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,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: 'top-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
|
+
(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,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FontConfig } from '../../types';
|
|
3
|
+
type FontPopoverProps = {
|
|
4
|
+
fonts?: FontConfig[];
|
|
5
|
+
value?: {
|
|
6
|
+
font: FontConfig;
|
|
7
|
+
weight: number;
|
|
8
|
+
};
|
|
9
|
+
onChange?: (font: FontConfig, weight: number) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const FontPopover: import("react").MemoExoticComponent<(props: FontPopoverProps) => import("react/jsx-runtime").JSX.Element>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Flex, Typography } from 'antd';
|
|
3
|
+
import { SearchPopover, VirtualizedMenu } from '@antscorp/antsomi-ui/es/components/molecules';
|
|
4
|
+
import { DEFAULT_FONT_CONFIGS, FONT_WEIGHT_MAP } from '../../constants';
|
|
5
|
+
import { memo, useMemo, useState } from 'react';
|
|
6
|
+
import { PopoverTrigger } from './styled';
|
|
7
|
+
import { calInlineListSize } from '@antscorp/antsomi-ui/es/components/molecules/VirtualizedMenu/utils';
|
|
8
|
+
import { useTextEditorStore } from '../../provider';
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import { TextEditorPopover } from '../Popover';
|
|
11
|
+
import { ChevronRightIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
12
|
+
const FontItem = (props) => {
|
|
13
|
+
const { fontConfig, active, onSelectFont, onOpenChange } = props;
|
|
14
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
15
|
+
const numOfWeight = fontConfig.fontWeight.length;
|
|
16
|
+
const isActive = active.font.fontFamily.name === fontConfig.fontFamily.name;
|
|
17
|
+
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 })] }));
|
|
18
|
+
const handleOpenChange = (newOpen) => {
|
|
19
|
+
setIsOpen(newOpen);
|
|
20
|
+
onOpenChange?.(newOpen);
|
|
21
|
+
};
|
|
22
|
+
if (numOfWeight < 2) {
|
|
23
|
+
return fontNameContent;
|
|
24
|
+
}
|
|
25
|
+
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', {
|
|
26
|
+
active: active.weight === weight,
|
|
27
|
+
}), style: {
|
|
28
|
+
fontFamily: fontConfig.fontFamily.name,
|
|
29
|
+
fontWeight: weight,
|
|
30
|
+
}, onClick: () => onSelectFont?.(weight), children: FONT_WEIGHT_MAP[weight] }, weight))) }), children: fontNameContent }));
|
|
31
|
+
};
|
|
32
|
+
export const FontPopover = memo((props) => {
|
|
33
|
+
const { fonts = [], value: fontValue = {
|
|
34
|
+
font: DEFAULT_FONT_CONFIGS[0],
|
|
35
|
+
weight: 400,
|
|
36
|
+
}, onChange, } = props;
|
|
37
|
+
const [search, setSearch] = useState('');
|
|
38
|
+
const [open, setOpen] = useState(false);
|
|
39
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
40
|
+
const filteredFonts = useMemo(() => fonts
|
|
41
|
+
.filter(font => font.fontFamily.name.toLowerCase().includes(search.toLowerCase()))
|
|
42
|
+
.sort((a, b) => a.fontFamily.name.localeCompare(b.fontFamily.name)), [fonts, search]);
|
|
43
|
+
const handleClose = () => {
|
|
44
|
+
setOpen(false);
|
|
45
|
+
setSearch('');
|
|
46
|
+
};
|
|
47
|
+
const handleOpenChange = (newOpen) => {
|
|
48
|
+
setOpen(newOpen);
|
|
49
|
+
if (newOpen === false) {
|
|
50
|
+
handleClose();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const handleChangeFont = (font, weight = 400) => {
|
|
54
|
+
onChange?.(font, weight);
|
|
55
|
+
handleClose();
|
|
56
|
+
};
|
|
57
|
+
const itemSize = 30;
|
|
58
|
+
const itemSpacing = 4;
|
|
59
|
+
const activeFontName = fontValue.font.fontFamily.name;
|
|
60
|
+
return (_jsx(SearchPopover, { open: open, placement: "bottomLeft", onOpenChange: handleOpenChange, getPopupContainer: () => bubbleMenuContainer || document.body, inputSearchProps: {
|
|
61
|
+
value: search,
|
|
62
|
+
onAfterChange: setSearch,
|
|
63
|
+
}, overlayClassName: "font-popover-overlay", content: _jsx("div", { className: "list-font-root", style: {
|
|
64
|
+
height: calInlineListSize(Math.min(filteredFonts.length, 6), itemSize, itemSpacing),
|
|
65
|
+
}, children: _jsx(VirtualizedMenu, { itemSize: itemSize, inlinePadding: 0, itemSpacing: itemSpacing, items: filteredFonts.map(fontConfig => ({
|
|
66
|
+
key: fontConfig.fontFamily.name,
|
|
67
|
+
label: (_jsx(FontItem, { fontConfig: fontConfig, active: { font: fontValue.font, weight: fontValue.weight }, onSelectFont: weight => handleChangeFont(fontConfig, weight) })),
|
|
68
|
+
})) }) }), children: _jsx(PopoverTrigger, { className: "font-popover-trigger", children: _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: activeFontName }) }) }));
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PopoverTrigger: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,22 @@
|
|
|
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: 90px;
|
|
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
|
+
`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type PopoverProps } from 'antd';
|
|
3
|
+
export interface TextEditorPopoverProps extends PopoverProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare const TextEditorPopover: ({ children, ...restProps }: TextEditorPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Popover } from 'antd';
|
|
3
|
+
import { useTextEditorStore } from '../../provider';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
export const TextEditorPopover = ({ children, ...restProps }) => {
|
|
6
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
7
|
+
const getPopupContainer = useCallback(() => bubbleMenuContainer || document.body, [bubbleMenuContainer]);
|
|
8
|
+
return (_jsx(Popover, { trigger: ['click'], ...restProps, getPopupContainer: getPopupContainer, children: children }));
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Popover';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Popover';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Select } from 'antd';
|
|
3
|
+
import { useTextEditorStore } from '../../provider';
|
|
4
|
+
export const TextEditorSelect = (props) => {
|
|
5
|
+
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
6
|
+
return _jsx(Select, { ...props, getPopupContainer: () => bubbleMenuContainer || document.body });
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Select';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Select';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ArrowDropDownIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
3
|
+
import { StyledDropdownButton } from './styled';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { Tooltip } from 'antd';
|
|
7
|
+
export const SplitButtonDropdown = (props) => {
|
|
8
|
+
const { children, disabled, value, className = '', tooltipProps, options = [], onClickOption, onClick, } = props;
|
|
9
|
+
const selectedOpt = value ? options.filter(opt => opt.value === value) : [];
|
|
10
|
+
const isSelected = selectedOpt.length > 0;
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const handleOpenChange = (visible) => {
|
|
13
|
+
if (disabled)
|
|
14
|
+
return;
|
|
15
|
+
setIsOpen(visible);
|
|
16
|
+
};
|
|
17
|
+
return (_jsx(StyledDropdownButton, { disabled: disabled, trigger: ['click'], className: clsx(className, {
|
|
18
|
+
'is-active': isSelected,
|
|
19
|
+
'is-open': isOpen,
|
|
20
|
+
}), open: isOpen, onOpenChange: handleOpenChange, placement: "bottomLeft", menu: {
|
|
21
|
+
style: {
|
|
22
|
+
maxHeight: 240,
|
|
23
|
+
overflow: 'auto',
|
|
24
|
+
},
|
|
25
|
+
items: options.map(opt => ({
|
|
26
|
+
key: opt.value,
|
|
27
|
+
label: opt.label,
|
|
28
|
+
disabled: opt.disabled,
|
|
29
|
+
})),
|
|
30
|
+
selectedKeys: selectedOpt.map(opt => opt.value),
|
|
31
|
+
onClick: e => {
|
|
32
|
+
const { key } = e;
|
|
33
|
+
onClickOption?.(key);
|
|
34
|
+
},
|
|
35
|
+
}, onClick: e => {
|
|
36
|
+
onClick?.(e, isSelected);
|
|
37
|
+
}, icon: _jsx(ArrowDropDownIcon, { size: 16 }), type: "text", buttonsRender: buttons => {
|
|
38
|
+
const [fistButton, ...restButton] = buttons;
|
|
39
|
+
return [
|
|
40
|
+
_jsx(Tooltip, { placement: "top", mouseEnterDelay: 0.4, ...tooltipProps, open: disabled ? false : undefined, children: fistButton }),
|
|
41
|
+
...restButton,
|
|
42
|
+
];
|
|
43
|
+
}, children: children }));
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SplitButtonDropdown } from './SplitButtonDropdown';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SplitButtonDropdown } from './SplitButtonDropdown';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Dropdown } from 'antd';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const StyledDropdownButton = styled(Dropdown.Button) `
|
|
4
|
+
&.antsomi-dropdown-button {
|
|
5
|
+
width: fit-content;
|
|
6
|
+
|
|
7
|
+
.antsomi-btn {
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.antsomi-btn-compact-item:not(.antsomi-btn-compact-last-item).antsomi-btn-compact-first-item {
|
|
12
|
+
width: 36px;
|
|
13
|
+
height: 36px;
|
|
14
|
+
border-start-end-radius: 0;
|
|
15
|
+
border-end-end-radius: 0;
|
|
16
|
+
|
|
17
|
+
&:hover:not(:disabled, .is-active) {
|
|
18
|
+
background-color: #ebebeb;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.antsomi-btn-compact-item:not(.antsomi-btn-compact-first-item).antsomi-btn-compact-last-item {
|
|
23
|
+
width: 16px;
|
|
24
|
+
height: 36px;
|
|
25
|
+
border-start-start-radius: 0;
|
|
26
|
+
border-end-start-radius: 0;
|
|
27
|
+
|
|
28
|
+
&:hover:not(:disabled),
|
|
29
|
+
&.antsomi-dropdown-open:not(:disabled) {
|
|
30
|
+
background-color: #ebebeb;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.is-active {
|
|
35
|
+
.antsomi-btn-compact-item:not(.antsomi-btn-compact-last-item).antsomi-btn-compact-first-item {
|
|
36
|
+
:not(:disabled) {
|
|
37
|
+
background-color: #e0ebf7;
|
|
38
|
+
|
|
39
|
+
&:hover {
|
|
40
|
+
background-color: #e0ebf7;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.is-open {
|
|
47
|
+
.antsomi-btn-icon svg {
|
|
48
|
+
transform: rotate(180deg);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type SplitButtonDropdownProps = {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
value?: string;
|
|
6
|
+
options?: {
|
|
7
|
+
value: string;
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
className?: string;
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
onClickOption?: (key: string) => void;
|
|
15
|
+
onClick?: (e: React.MouseEvent<HTMLElement>, isSelected: boolean) => void;
|
|
16
|
+
tooltipProps?: {
|
|
17
|
+
title?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
declare const textAlignOptions: readonly [{
|
|
4
|
+
readonly label: string;
|
|
5
|
+
readonly value: string;
|
|
6
|
+
readonly shortcut: string;
|
|
7
|
+
readonly icon: import("react").ForwardRefExoticComponent<import("../../../../icons/types").IconProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
8
|
+
}, {
|
|
9
|
+
readonly label: string;
|
|
10
|
+
readonly value: string;
|
|
11
|
+
readonly shortcut: string;
|
|
12
|
+
readonly icon: import("react").ForwardRefExoticComponent<import("../../../../icons/types").IconProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
13
|
+
}, {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly value: string;
|
|
16
|
+
readonly shortcut: string;
|
|
17
|
+
readonly icon: import("react").ForwardRefExoticComponent<import("../../../../icons/types").IconProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
18
|
+
}, {
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly shortcut: string;
|
|
22
|
+
readonly icon: import("react").ForwardRefExoticComponent<import("../../../../icons/types").IconProps & import("react").RefAttributes<SVGSVGElement>>;
|
|
23
|
+
}];
|
|
24
|
+
type AlignType = (typeof textAlignOptions)[number]['value'];
|
|
25
|
+
interface TextAlignSelectProps {
|
|
26
|
+
editor?: Editor;
|
|
27
|
+
onChange?: (value: AlignType) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare const TextAlignSelect: (props: TextAlignSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { formatHotkey } from '@antscorp/antsomi-ui/es/utils';
|
|
3
|
+
import { Flex } from 'antd';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../constants';
|
|
6
|
+
import { TextEditorPopover } from '../Popover';
|
|
7
|
+
import { TextEditorButton } from '../Button';
|
|
8
|
+
import { ALignRightIcon, AlignCenterIcon, AlignJustifyIcon, AlignLeftIcon, ArrowDropDownIcon, } from '@antscorp/antsomi-ui/es/components/icons';
|
|
9
|
+
import styled from 'styled-components';
|
|
10
|
+
import { useEditorState } from '@tiptap/react';
|
|
11
|
+
const { TEXT_ALIGN } = TEXT_EDITOR_CONSTANTS;
|
|
12
|
+
const textAlignOptions = [
|
|
13
|
+
{
|
|
14
|
+
label: TEXT_ALIGN.OPTIONS.LEFT.LABEL,
|
|
15
|
+
value: TEXT_ALIGN.OPTIONS.LEFT.VALUE,
|
|
16
|
+
shortcut: formatHotkey('Shift+L'),
|
|
17
|
+
icon: AlignLeftIcon,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: TEXT_ALIGN.OPTIONS.CENTER.LABEL,
|
|
21
|
+
value: TEXT_ALIGN.OPTIONS.CENTER.VALUE,
|
|
22
|
+
shortcut: formatHotkey('Shift+E'),
|
|
23
|
+
icon: AlignCenterIcon,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: TEXT_ALIGN.OPTIONS.RIGHT.LABEL,
|
|
27
|
+
value: TEXT_ALIGN.OPTIONS.RIGHT.VALUE,
|
|
28
|
+
shortcut: formatHotkey('Shift+R'),
|
|
29
|
+
icon: ALignRightIcon,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: TEXT_ALIGN.OPTIONS.JUSTIFY.LABEL,
|
|
33
|
+
value: TEXT_ALIGN.OPTIONS.JUSTIFY.VALUE,
|
|
34
|
+
shortcut: formatHotkey('Shift+J'),
|
|
35
|
+
icon: AlignJustifyIcon,
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
const StyledTriggerButton = styled(TextEditorButton) `
|
|
39
|
+
&.antsomi-btn.antsomi-btn-text {
|
|
40
|
+
width: 40px;
|
|
41
|
+
gap: 0;
|
|
42
|
+
|
|
43
|
+
&.is-active {
|
|
44
|
+
background-color: unset;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
export const TextAlignSelect = (props) => {
|
|
49
|
+
const { editor, onChange } = props;
|
|
50
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
51
|
+
const { currentAlignment } = useEditorState({
|
|
52
|
+
editor: editor,
|
|
53
|
+
selector: ({ editor: editorInstance }) => {
|
|
54
|
+
const alignment = ['left', 'center', 'right', 'justify'].find(alignment => editorInstance?.isActive({ textAlign: alignment }));
|
|
55
|
+
return {
|
|
56
|
+
currentAlignment: alignment || 'left',
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
const selectedOption = useMemo(() => textAlignOptions.find(option => option.value === currentAlignment), [currentAlignment]);
|
|
61
|
+
const handleClickOption = (align) => {
|
|
62
|
+
setIsOpen(false);
|
|
63
|
+
onChange?.(align);
|
|
64
|
+
};
|
|
65
|
+
let AlignIconComponent = textAlignOptions[0].icon;
|
|
66
|
+
if (selectedOption) {
|
|
67
|
+
AlignIconComponent = selectedOption.icon;
|
|
68
|
+
}
|
|
69
|
+
return (_jsx(TextEditorPopover, { destroyTooltipOnHide: true, open: isOpen, arrow: false, overlayInnerStyle: { padding: 8 }, content: _jsx(Flex, { gap: 8, children: textAlignOptions.map(option => (_jsx(TextEditorButton, { icon: _jsx(option.icon, { size: 16 }, option.value), onClick: () => handleClickOption(option.value), isActive: currentAlignment === option.value, tooltipProps: {
|
|
70
|
+
title: `${TEXT_ALIGN.TOOLTIP} ${option.label.toLowerCase()} (${option.shortcut})`,
|
|
71
|
+
} }, option.value))) }), trigger: ['click'], placement: "bottomLeft", onOpenChange: setOpen => setIsOpen(setOpen), children: _jsx(StyledTriggerButton, { icon: _jsx(AlignIconComponent, { size: 18 }), isActive: !!currentAlignment, tooltipProps: { title: TEXT_ALIGN.TITLE }, children: _jsx(ArrowDropDownIcon, { style: {
|
|
72
|
+
flexShrink: 0,
|
|
73
|
+
...(isOpen && {
|
|
74
|
+
transform: 'rotate(180deg)',
|
|
75
|
+
}),
|
|
76
|
+
}, size: 16 }) }) }));
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextAlignSelect } from './TextAlignSelect';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextAlignSelect } from './TextAlignSelect';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/core';
|
|
3
|
+
import { Config, TextStyle } from '../../types';
|
|
4
|
+
export type ToolbarProps = {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
config?: Config;
|
|
7
|
+
defaultTextStyle?: TextStyle;
|
|
8
|
+
smartTagHandler?: {
|
|
9
|
+
onUpsert?: (event: React.MouseEvent) => void;
|
|
10
|
+
};
|
|
11
|
+
linkHanlder?: {
|
|
12
|
+
onUpsert?: () => void;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const Toolbar: (props: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Divider, Flex, Typography } from 'antd';
|
|
3
|
+
import { BoldAction } from './actions/BoldAction';
|
|
4
|
+
import { BulletListAction } from './actions/BulletListAction';
|
|
5
|
+
import { ClearFormattingAction } from './actions/ClearFormattingAction';
|
|
6
|
+
import { FontFamilyAction } from './actions/FontFamilyAction';
|
|
7
|
+
import { FontSizeAction } from './actions/FontSizeAction';
|
|
8
|
+
import { TextBackColorAction } from './actions/TextBackgroundColorAction';
|
|
9
|
+
import { IndentAction } from './actions/IndentAction';
|
|
10
|
+
import { ItalicAction } from './actions/ItalicAction';
|
|
11
|
+
import { LinkAction } from './actions/LinkAction';
|
|
12
|
+
import { OrderedListAction } from './actions/OrderedListAction';
|
|
13
|
+
import { OutdentAction } from './actions/OutdentAction';
|
|
14
|
+
import { SmartTagAction } from './actions/SmartTagAction';
|
|
15
|
+
import { StrikeAction } from './actions/StrikeAction';
|
|
16
|
+
import { SubscriptAction } from './actions/SubscriptAction';
|
|
17
|
+
import { SuperscriptAction } from './actions/SuperscriptAction';
|
|
18
|
+
import { TextAlignAction } from './actions/TextAlignAction';
|
|
19
|
+
import { TextColorAction } from './actions/TextColorAction';
|
|
20
|
+
import { TextTransformAction } from './actions/TextTransformAction';
|
|
21
|
+
import { UnderlineAction } from './actions/UnderlineAction';
|
|
22
|
+
import { SpacingAction } from './actions/SpacingAction';
|
|
23
|
+
import { getLinkMark, isShowLinkMenu } from '../../utils';
|
|
24
|
+
import { ToolbarWrapper } from '../../styled';
|
|
25
|
+
import { UnsetLinkAction } from './actions/UnsetLink';
|
|
26
|
+
import { EmoijiAction } from './actions';
|
|
27
|
+
import { LetterSpacingAction } from './actions/LetterSpacing';
|
|
28
|
+
import { HistoryAction } from './actions/HistoryAction';
|
|
29
|
+
import { CopyDuplicateIcon, EditIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
30
|
+
import { TextEditorButton } from '../Button';
|
|
31
|
+
export const Toolbar = (props) => {
|
|
32
|
+
const { editor, smartTagHandler, linkHanlder, config, defaultTextStyle } = props;
|
|
33
|
+
if (isShowLinkMenu(editor.state)) {
|
|
34
|
+
const { attrs } = getLinkMark({ state: editor.state }) || {};
|
|
35
|
+
const href = String(attrs?.href);
|
|
36
|
+
return (_jsxs(ToolbarWrapper, { wrap: "wrap", gap: 8, align: "center", children: [_jsx(Typography.Link, { style: { maxWidth: 150 }, ellipsis: true, href: href, children: href }), _jsx(TextEditorButton, { icon: _jsx(CopyDuplicateIcon, { size: 18 }), tooltipProps: { title: 'Copy' }, onClick: () => {
|
|
37
|
+
navigator.clipboard.writeText(href);
|
|
38
|
+
} }), _jsx(TextEditorButton, { icon: _jsx(EditIcon, { size: 18 }), tooltipProps: { title: 'Edit' }, onClick: () => linkHanlder?.onUpsert?.() }), _jsx(UnsetLinkAction, { editor: editor })] }));
|
|
39
|
+
}
|
|
40
|
+
return (_jsxs(ToolbarWrapper, { vertical: true, gap: 8, children: [_jsxs(Flex, { gap: 4, justify: "flex-start", align: "center", children: [_jsx(FontFamilyAction, { editor: editor, fonts: config?.FontFamily?.fonts }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(FontSizeAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(BoldAction, { editor: editor }), _jsx(ItalicAction, { editor: editor }), _jsx(UnderlineAction, { editor: editor }), _jsx(LinkAction, { editor: editor, onClick: linkHanlder?.onUpsert }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(StrikeAction, { editor: editor }), _jsx(SuperscriptAction, { editor: editor }), _jsx(SubscriptAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(TextTransformAction, { editor: editor }), _jsx(TextColorAction, { editor: editor }), _jsx(TextBackColorAction, { editor: editor }), _jsx(EmoijiAction, { editor: editor }), _jsx(SmartTagAction, { editor: editor, onClick: smartTagHandler?.onUpsert })] }), _jsxs(Flex, { gap: 4, justify: "flex-start", align: "center", children: [_jsx(BulletListAction, { editor: editor, useCustomBullet: config?.UnorderedList?.useCustomBullet }), _jsx(OrderedListAction, { editor: editor }), _jsx(TextAlignAction, { editor: editor }), _jsx(SpacingAction, { editor: editor, defaultValue: defaultTextStyle?.lineHeight }), _jsx(LetterSpacingAction, { editor: editor }), _jsx(IndentAction, { editor: editor }), _jsx(OutdentAction, { editor: editor }), _jsx(Divider, { type: "vertical", className: "toolbar-separator" }), _jsx(HistoryAction, { editor: editor }), _jsx(ClearFormattingAction, { editor: editor })] })] }));
|
|
41
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { TEXT_EDITOR_CONSTANTS } from '../../../constants';
|
|
3
|
+
import { TextEditorButton } from '../../Button';
|
|
4
|
+
import { useEditorState } from '@tiptap/react';
|
|
5
|
+
const { TOOLTIPS } = TEXT_EDITOR_CONSTANTS;
|
|
6
|
+
const BoldIcon = ({ size }) => (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: _jsx("path", { d: "M5 22V2H12.9687C14.5312 2 15.9736 2.47619 17.2957 3.42857C18.6178 4.38095 19.2788 5.70238 19.2788 7.39286C19.2788 8.60714 19.0024 9.54167 18.4495 10.1964C17.8966 10.8512 17.3798 11.3214 16.899 11.6071C17.5 11.869 18.1671 12.3571 18.9002 13.0714C19.6334 13.7857 20 14.8571 20 16.2857C20 18.4048 19.2187 19.8869 17.6562 20.7321C16.0937 21.5774 14.6274 22 13.2572 22H5ZM9.36298 18H13.113C14.2668 18 14.97 17.7083 15.2224 17.125C15.4748 16.5417 15.601 16.119 15.601 15.8571C15.601 15.5952 15.4748 15.1726 15.2224 14.5893C14.97 14.006 14.2308 13.7143 13.0048 13.7143H9.36298V18ZM9.36298 9.85714H12.7163C13.5096 9.85714 14.0865 9.65476 14.4471 9.25C14.8077 8.84524 14.988 8.39286 14.988 7.89286C14.988 7.32143 14.7837 6.85714 14.375 6.5C13.9663 6.14286 13.4375 5.96429 12.7885 5.96429H9.36298V9.85714Z", fill: "currentColor" }) }));
|
|
7
|
+
export const BoldAction = ({ editor }) => {
|
|
8
|
+
const { isBold, disabled } = useEditorState({
|
|
9
|
+
editor,
|
|
10
|
+
selector: ({ editor: editorInstance }) => ({
|
|
11
|
+
isBold: editorInstance.isActive('bold'),
|
|
12
|
+
disabled: !editorInstance.can().chain().focus().toggleBold().run(),
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
return (_jsx(TextEditorButton, { disabled: disabled, onClick: () => editor.chain().focus().toggleBold().run(), isActive: isBold, icon: _jsx(BoldIcon, { size: 18 }), tooltipProps: {
|
|
16
|
+
title: `${TOOLTIPS.BOLD.TITLE} (${TOOLTIPS.BOLD.SHORTCUT})`,
|
|
17
|
+
} }));
|
|
18
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/core';
|
|
2
|
+
export interface BulletListActionProps {
|
|
3
|
+
editor: Editor;
|
|
4
|
+
useCustomBullet?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const BulletListAction: ({ editor, useCustomBullet }: BulletListActionProps) => import("react/jsx-runtime").JSX.Element;
|