@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,169 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
3
|
+
// Helper functions (simplified implementations)
|
|
4
|
+
async function compressString(str) {
|
|
5
|
+
// Implement compression logic
|
|
6
|
+
return str;
|
|
7
|
+
}
|
|
8
|
+
async function decompressString(str) {
|
|
9
|
+
// Implement decompression logic
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
async function encryptString(str, _key) {
|
|
13
|
+
// Implement encryption logic
|
|
14
|
+
return str;
|
|
15
|
+
}
|
|
16
|
+
async function decryptString(str, _key) {
|
|
17
|
+
// Implement decryption logic
|
|
18
|
+
return str;
|
|
19
|
+
}
|
|
20
|
+
async function saveToIndexedDB(_key, _data) {
|
|
21
|
+
// Implement IndexedDB save
|
|
22
|
+
}
|
|
23
|
+
async function loadFromIndexedDB(_key) {
|
|
24
|
+
// Implement IndexedDB load
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
function migrateData(data, _targetVersion) {
|
|
28
|
+
// Implement data migration logic
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
export function usePersistence(editor, config) {
|
|
32
|
+
const { key, storage = 'localStorage', autoSaveDelay = 2000, version = 1, compress = false, encryptionKey, } = config;
|
|
33
|
+
const lastSavedContent = useRef('');
|
|
34
|
+
// Storage operations
|
|
35
|
+
const saveToStorage = useCallback(async (data) => {
|
|
36
|
+
try {
|
|
37
|
+
let serializedData = JSON.stringify(data);
|
|
38
|
+
// Apply compression if enabled
|
|
39
|
+
if (compress && 'CompressionStream' in window) {
|
|
40
|
+
// Use browser compression API if available
|
|
41
|
+
serializedData = await compressString(serializedData);
|
|
42
|
+
}
|
|
43
|
+
// Apply encryption if key provided
|
|
44
|
+
if (encryptionKey) {
|
|
45
|
+
serializedData = await encryptString(serializedData, encryptionKey);
|
|
46
|
+
}
|
|
47
|
+
switch (storage) {
|
|
48
|
+
case 'localStorage':
|
|
49
|
+
localStorage.setItem(key, serializedData);
|
|
50
|
+
break;
|
|
51
|
+
case 'sessionStorage':
|
|
52
|
+
sessionStorage.setItem(key, serializedData);
|
|
53
|
+
break;
|
|
54
|
+
case 'indexedDB':
|
|
55
|
+
await saveToIndexedDB(key, serializedData);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.error('Failed to save to storage:', error);
|
|
64
|
+
}
|
|
65
|
+
}, [key, storage, compress, encryptionKey]);
|
|
66
|
+
const loadFromStorage = useCallback(async () => {
|
|
67
|
+
try {
|
|
68
|
+
let serializedData = null;
|
|
69
|
+
switch (storage) {
|
|
70
|
+
case 'localStorage':
|
|
71
|
+
serializedData = localStorage.getItem(key);
|
|
72
|
+
break;
|
|
73
|
+
case 'sessionStorage':
|
|
74
|
+
serializedData = sessionStorage.getItem(key);
|
|
75
|
+
break;
|
|
76
|
+
case 'indexedDB':
|
|
77
|
+
serializedData = await loadFromIndexedDB(key);
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (!serializedData)
|
|
83
|
+
return null;
|
|
84
|
+
// Apply decryption if key provided
|
|
85
|
+
if (encryptionKey) {
|
|
86
|
+
serializedData = await decryptString(serializedData, encryptionKey);
|
|
87
|
+
}
|
|
88
|
+
// Apply decompression if enabled
|
|
89
|
+
if (compress && 'DecompressionStream' in window) {
|
|
90
|
+
serializedData = await decompressString(serializedData);
|
|
91
|
+
}
|
|
92
|
+
const data = JSON.parse(serializedData);
|
|
93
|
+
// Handle version migration
|
|
94
|
+
if (data.metadata.version !== version) {
|
|
95
|
+
return migrateData(data, version);
|
|
96
|
+
}
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// eslint-disable-next-line no-console
|
|
101
|
+
console.error('Failed to load from storage:', error);
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}, [key, storage, compress, encryptionKey, version]);
|
|
105
|
+
// Auto-save debounced function
|
|
106
|
+
const debouncedSave = useDebouncedCallback(async () => {
|
|
107
|
+
if (!editor)
|
|
108
|
+
return;
|
|
109
|
+
const currentContent = editor.getHTML();
|
|
110
|
+
// Only save if content changed
|
|
111
|
+
if (currentContent === lastSavedContent.current)
|
|
112
|
+
return;
|
|
113
|
+
const { selection, storedMarks } = editor.state;
|
|
114
|
+
const marks = storedMarks || selection.$from.marks();
|
|
115
|
+
const data = {
|
|
116
|
+
content: currentContent,
|
|
117
|
+
marks: marks.map(mark => ({
|
|
118
|
+
type: mark.type.name,
|
|
119
|
+
attrs: mark.attrs,
|
|
120
|
+
})),
|
|
121
|
+
metadata: {
|
|
122
|
+
timestamp: Date.now(),
|
|
123
|
+
version,
|
|
124
|
+
wordCount: editor.state.doc.textContent.split(/\s+/).length,
|
|
125
|
+
characterCount: editor.state.doc.textContent.length,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
await saveToStorage(data);
|
|
129
|
+
lastSavedContent.current = currentContent;
|
|
130
|
+
}, autoSaveDelay);
|
|
131
|
+
// Manual save
|
|
132
|
+
const save = useCallback(async () => {
|
|
133
|
+
debouncedSave.flush();
|
|
134
|
+
}, [debouncedSave]);
|
|
135
|
+
// Load data
|
|
136
|
+
const load = useCallback(async () => {
|
|
137
|
+
if (!editor)
|
|
138
|
+
return false;
|
|
139
|
+
const data = await loadFromStorage();
|
|
140
|
+
if (!data)
|
|
141
|
+
return false;
|
|
142
|
+
// Set content
|
|
143
|
+
editor.commands.setContent(data.content);
|
|
144
|
+
// Restore marks if available
|
|
145
|
+
if (data.marks.length > 0) {
|
|
146
|
+
data.marks.forEach(({ type, attrs }) => {
|
|
147
|
+
editor.commands.setMark(type, attrs);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
lastSavedContent.current = data.content;
|
|
151
|
+
return true;
|
|
152
|
+
}, [editor, loadFromStorage]);
|
|
153
|
+
// Auto-save setup
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!editor)
|
|
156
|
+
return;
|
|
157
|
+
editor.on('update', debouncedSave);
|
|
158
|
+
return () => {
|
|
159
|
+
editor.off('update', debouncedSave);
|
|
160
|
+
debouncedSave.flush(); // Save any pending changes
|
|
161
|
+
};
|
|
162
|
+
}, [editor, debouncedSave]);
|
|
163
|
+
return {
|
|
164
|
+
save,
|
|
165
|
+
load,
|
|
166
|
+
saveToStorage,
|
|
167
|
+
loadFromStorage,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
export function useStyleMemory(editor) {
|
|
3
|
+
// Store current marks manually
|
|
4
|
+
const storeCurrentMarks = useCallback(() => {
|
|
5
|
+
editor?.commands.storeCurrentMarks();
|
|
6
|
+
}, [editor]);
|
|
7
|
+
// Clear stored marks
|
|
8
|
+
const clearStoredMarks = useCallback(() => {
|
|
9
|
+
editor?.commands.clearStoredMarks();
|
|
10
|
+
}, [editor]);
|
|
11
|
+
// Apply stored marks
|
|
12
|
+
const applyStoredMarks = useCallback(() => {
|
|
13
|
+
editor?.commands.applyStoredMarks();
|
|
14
|
+
}, [editor]);
|
|
15
|
+
// Auto-store marks when selection changes
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (!editor)
|
|
18
|
+
return;
|
|
19
|
+
const handleSelectionUpdate = () => {
|
|
20
|
+
const { selection, doc } = editor.state;
|
|
21
|
+
// Only store if editor has content and selection has marks
|
|
22
|
+
if (doc.content.size > 4 && !selection.empty) {
|
|
23
|
+
const { $from } = selection;
|
|
24
|
+
const marks = editor.state.storedMarks || $from.marks();
|
|
25
|
+
if (marks.length > 0) {
|
|
26
|
+
storeCurrentMarks();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
editor.on('selectionUpdate', handleSelectionUpdate);
|
|
31
|
+
editor.on('update', handleSelectionUpdate);
|
|
32
|
+
return () => {
|
|
33
|
+
editor.off('selectionUpdate', handleSelectionUpdate);
|
|
34
|
+
editor.off('update', handleSelectionUpdate);
|
|
35
|
+
};
|
|
36
|
+
}, [editor, storeCurrentMarks]);
|
|
37
|
+
return {
|
|
38
|
+
storeCurrentMarks,
|
|
39
|
+
clearStoredMarks,
|
|
40
|
+
applyStoredMarks,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export interface StylePreset {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
marks: Array<{
|
|
7
|
+
type: string;
|
|
8
|
+
attrs: Record<string, any>;
|
|
9
|
+
}>;
|
|
10
|
+
textStyle: {
|
|
11
|
+
fontSize?: string;
|
|
12
|
+
fontFamily?: string;
|
|
13
|
+
color?: string;
|
|
14
|
+
backgroundColor?: string;
|
|
15
|
+
fontWeight?: string | number;
|
|
16
|
+
};
|
|
17
|
+
createdAt: number;
|
|
18
|
+
usageCount: number;
|
|
19
|
+
}
|
|
20
|
+
export interface UseStylePresetsOptions {
|
|
21
|
+
/** Storage key for presets */
|
|
22
|
+
storageKey?: string;
|
|
23
|
+
/** Maximum number of presets */
|
|
24
|
+
maxPresets?: number;
|
|
25
|
+
/** Default presets */
|
|
26
|
+
defaultPresets?: Omit<StylePreset, 'id' | 'createdAt' | 'usageCount'>[];
|
|
27
|
+
}
|
|
28
|
+
export declare function useStylePresets(editor: Editor | null, options?: UseStylePresetsOptions): {
|
|
29
|
+
presets: StylePreset[];
|
|
30
|
+
createPreset: (name: string, description?: string) => StylePreset | undefined;
|
|
31
|
+
applyPreset: (presetId: string) => void;
|
|
32
|
+
deletePreset: (presetId: string) => void;
|
|
33
|
+
getPopularPresets: (limit?: number) => StylePreset[];
|
|
34
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Use case**: Template systems, corporate branding, user productivity
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { useBroadcastedLocalStorage } from '@antscorp/antsomi-ui/es/hooks/useBroadcastedLocalStorage';
|
|
4
|
+
export function useStylePresets(editor, options = {}) {
|
|
5
|
+
const { storageKey = 'text-editor-style-presets', maxPresets = 20, defaultPresets = [], } = options;
|
|
6
|
+
const { value: presets, setValue: setPresets } = useBroadcastedLocalStorage(storageKey, defaultPresets.map((preset, index) => ({
|
|
7
|
+
...preset,
|
|
8
|
+
id: `default-${index}`,
|
|
9
|
+
createdAt: Date.now(),
|
|
10
|
+
usageCount: 0,
|
|
11
|
+
})));
|
|
12
|
+
// Create preset from current style
|
|
13
|
+
const createPreset = useCallback((name, description) => {
|
|
14
|
+
if (!editor)
|
|
15
|
+
return;
|
|
16
|
+
const { selection, storedMarks } = editor.state;
|
|
17
|
+
const { $from } = selection;
|
|
18
|
+
const marks = (storedMarks || $from.marks()).map(mark => ({
|
|
19
|
+
type: mark.type.name,
|
|
20
|
+
attrs: mark.attrs,
|
|
21
|
+
}));
|
|
22
|
+
const textStyle = editor.getAttributes('textStyle');
|
|
23
|
+
const preset = {
|
|
24
|
+
id: `preset-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
25
|
+
name,
|
|
26
|
+
description,
|
|
27
|
+
marks,
|
|
28
|
+
textStyle,
|
|
29
|
+
createdAt: Date.now(),
|
|
30
|
+
usageCount: 0,
|
|
31
|
+
};
|
|
32
|
+
setPresets(prev => {
|
|
33
|
+
const updated = [preset, ...prev];
|
|
34
|
+
return updated.slice(0, maxPresets);
|
|
35
|
+
});
|
|
36
|
+
return preset;
|
|
37
|
+
}, [editor, maxPresets, setPresets]);
|
|
38
|
+
// Apply preset
|
|
39
|
+
const applyPreset = useCallback((presetId) => {
|
|
40
|
+
if (!editor)
|
|
41
|
+
return;
|
|
42
|
+
const preset = presets.find(p => p.id === presetId);
|
|
43
|
+
if (!preset)
|
|
44
|
+
return;
|
|
45
|
+
// Clear current formatting
|
|
46
|
+
editor.chain().focus().unsetAllMarks().run();
|
|
47
|
+
// Apply text style attributes
|
|
48
|
+
if (preset.textStyle.fontSize) {
|
|
49
|
+
editor.chain().setFontSize(preset.textStyle.fontSize).run();
|
|
50
|
+
}
|
|
51
|
+
if (preset.textStyle.fontFamily) {
|
|
52
|
+
editor.chain().setFontFamily(preset.textStyle.fontFamily).run();
|
|
53
|
+
}
|
|
54
|
+
if (preset.textStyle.color) {
|
|
55
|
+
editor.chain().setColor(preset.textStyle.color).run();
|
|
56
|
+
}
|
|
57
|
+
if (preset.textStyle.backgroundColor) {
|
|
58
|
+
editor.chain().setBackgroundColor(preset.textStyle.backgroundColor).run();
|
|
59
|
+
}
|
|
60
|
+
if (preset.textStyle.fontWeight) {
|
|
61
|
+
editor.chain().setFontWeight(preset.textStyle.fontWeight).run();
|
|
62
|
+
}
|
|
63
|
+
// Apply marks
|
|
64
|
+
preset.marks.forEach(({ type, attrs }) => {
|
|
65
|
+
editor.chain().setMark(type, attrs).run();
|
|
66
|
+
});
|
|
67
|
+
// Update usage count
|
|
68
|
+
setPresets(prev => prev.map(p => (p.id === presetId ? { ...p, usageCount: p.usageCount + 1 } : p)));
|
|
69
|
+
}, [editor, presets, setPresets]);
|
|
70
|
+
// Delete preset
|
|
71
|
+
const deletePreset = useCallback((presetId) => {
|
|
72
|
+
setPresets(prev => prev.filter(p => p.id !== presetId));
|
|
73
|
+
}, [setPresets]);
|
|
74
|
+
// Get popular presets
|
|
75
|
+
const getPopularPresets = useCallback((limit = 5) => [...presets].sort((a, b) => b.usageCount - a.usageCount).slice(0, limit), [presets]);
|
|
76
|
+
return {
|
|
77
|
+
presets,
|
|
78
|
+
createPreset,
|
|
79
|
+
applyPreset,
|
|
80
|
+
deletePreset,
|
|
81
|
+
getPopularPresets,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { JSONContent } from '@tiptap/core';
|
|
3
|
+
export type { TextEditorProps, TextEditorRef } from './types';
|
|
4
|
+
export type { JSONContent as TextEditorJSONContent };
|
|
5
|
+
export { TextEditorProvider, type TextEditorProviderProps, type TextEditorProviderRefHandler, } from './provider';
|
|
6
|
+
export declare const TextEditor: import("react").NamedExoticComponent<Omit<import("./types").TextEditorProps & import("react").RefAttributes<import("./types").TextEditorRef>, "ref"> & {
|
|
7
|
+
ref?: ((instance: import("./types").TextEditorRef | null) => void) | import("react").RefObject<import("./types").TextEditorRef> | null | undefined;
|
|
8
|
+
}> & {
|
|
9
|
+
readonly type: import("react").ForwardRefExoticComponent<import("./types").TextEditorProps & import("react").RefAttributes<import("./types").TextEditorRef>>;
|
|
10
|
+
} & {
|
|
11
|
+
Utils: {
|
|
12
|
+
htmlMinifyForEmail: (htmlEditorContent: string) => string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
.antsomi-text-editor-bubble-menu {
|
|
2
|
+
visibility: hidden;
|
|
3
|
+
position: absolute;
|
|
4
|
+
pointer-events: auto;
|
|
5
|
+
z-index: 999;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.antsomi-text-editor-emoji-popover {
|
|
9
|
+
position: absolute;
|
|
10
|
+
width: 180px;
|
|
11
|
+
z-index: 1000;
|
|
12
|
+
|
|
13
|
+
.antsomi-text-editor-emoji-list {
|
|
14
|
+
.antsomi-virtualize-menu-menu-inline {
|
|
15
|
+
background-color: white;
|
|
16
|
+
box-shadow: var(--antsomi-box-shadow-secondary);
|
|
17
|
+
border-radius: 10px;
|
|
18
|
+
|
|
19
|
+
.antsomi-virtualize-menu-item-label {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 10px;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.font-popover-overlay {
|
|
29
|
+
padding: 0;
|
|
30
|
+
|
|
31
|
+
.font-popover-item {
|
|
32
|
+
width: 100%;
|
|
33
|
+
height: 100%;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
padding-left: 10px;
|
|
36
|
+
padding-right: 8px;
|
|
37
|
+
|
|
38
|
+
&:hover,
|
|
39
|
+
&.active {
|
|
40
|
+
background-color: #f2f9ff;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.font-weight-popover {
|
|
46
|
+
&.antsomi-popover {
|
|
47
|
+
.antsomi-popover-inner {
|
|
48
|
+
padding: 10px 0px;
|
|
49
|
+
|
|
50
|
+
.font-weight-item {
|
|
51
|
+
padding: 4px 10px;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
|
|
54
|
+
&:hover,
|
|
55
|
+
&.active {
|
|
56
|
+
background-color: #f2f9ff;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StoreApi } from 'zustand';
|
|
3
|
+
import type { TextEditorStore } from './store';
|
|
4
|
+
export type TextEditorStoreApi = StoreApi<TextEditorStore>;
|
|
5
|
+
export declare const TextEditorStoreContext: import("react").Context<TextEditorStoreApi | null>;
|
|
6
|
+
export interface TextEditorProviderRefHandler {
|
|
7
|
+
updateColors?: (colors: string[]) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface TextEditorProviderProps {
|
|
10
|
+
ref?: React.RefObject<TextEditorProviderRefHandler>;
|
|
11
|
+
children: React.ReactNode | ((props: TextEditorStoreApi) => React.ReactNode);
|
|
12
|
+
onChangeColors?: (colors: string[]) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const TextEditorProvider: React.FC<React.PropsWithChildren<TextEditorProviderProps>>;
|
|
15
|
+
export declare const useTextEditorStore: <T>(selector: (state: TextEditorStore) => T) => T;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { createContext, useContext, useEffect, useImperativeHandle, useRef } from 'react';
|
|
4
|
+
import { useStore } from 'zustand';
|
|
5
|
+
// Store
|
|
6
|
+
import { createTextEditorStore } from './store';
|
|
7
|
+
export const TextEditorStoreContext = createContext(null);
|
|
8
|
+
export const TextEditorProvider = ({ ref, children, onChangeColors, }) => {
|
|
9
|
+
const storeRef = useRef();
|
|
10
|
+
if (!storeRef.current) {
|
|
11
|
+
storeRef.current = createTextEditorStore();
|
|
12
|
+
}
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
storeRef.current?.setState({
|
|
15
|
+
setColors: colors => {
|
|
16
|
+
storeRef.current?.getInitialState().setColors(colors);
|
|
17
|
+
onChangeColors?.(colors);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}, [onChangeColors]);
|
|
21
|
+
useImperativeHandle(ref, () => ({
|
|
22
|
+
updateColors: colors => {
|
|
23
|
+
storeRef.current?.getState().setColors(colors);
|
|
24
|
+
},
|
|
25
|
+
}));
|
|
26
|
+
return (_jsx(TextEditorStoreContext.Provider, { value: storeRef.current, children: typeof children === 'function' ? children(storeRef.current) : children }));
|
|
27
|
+
};
|
|
28
|
+
export const useTextEditorStore = (selector) => {
|
|
29
|
+
const store = useContext(TextEditorStoreContext);
|
|
30
|
+
if (!store)
|
|
31
|
+
throw new Error('Missing TextEditorStoreContext.Provider in the tree');
|
|
32
|
+
return useStore(store, selector);
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type TextEditorState = {
|
|
2
|
+
bubbleMenuContainer: HTMLDivElement | null;
|
|
3
|
+
isShowBubbleMenu: boolean;
|
|
4
|
+
colors?: string[];
|
|
5
|
+
};
|
|
6
|
+
export type TextEditorActions = {
|
|
7
|
+
setBubbleMenuContainer: (container: HTMLDivElement | null) => void;
|
|
8
|
+
setIsShowBubbleMenu: (isShow: boolean) => void;
|
|
9
|
+
setColors: (newColorSet: string[]) => void;
|
|
10
|
+
};
|
|
11
|
+
export type TextEditorStore = TextEditorState & TextEditorActions;
|
|
12
|
+
export declare const defaultTextEditorState: TextEditorState;
|
|
13
|
+
export declare const createTextEditorStore: (initState?: Partial<TextEditorState>) => import("zustand").StoreApi<TextEditorStore>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import isEqual from 'react-fast-compare';
|
|
3
|
+
import { createStore } from 'zustand';
|
|
4
|
+
export const defaultTextEditorState = {
|
|
5
|
+
bubbleMenuContainer: null,
|
|
6
|
+
isShowBubbleMenu: false,
|
|
7
|
+
};
|
|
8
|
+
export const createTextEditorStore = (initState = {}) => createStore()((set, get) => ({
|
|
9
|
+
...defaultTextEditorState,
|
|
10
|
+
...initState,
|
|
11
|
+
setBubbleMenuContainer: container => set(() => ({ bubbleMenuContainer: container })),
|
|
12
|
+
setIsShowBubbleMenu: isShow => set(() => ({ isShowBubbleMenu: isShow })),
|
|
13
|
+
setColors: newColors => {
|
|
14
|
+
const currentColors = get().colors;
|
|
15
|
+
if (isEqual(currentColors, newColors)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
set(() => ({ colors: newColors }));
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TextStyle } from './types';
|
|
3
|
+
export declare const StyledBubbleMenu: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<Pick<Partial<Omit<Pick<Partial<import("./extensions/BubbleMenu").BubbleMenuPluginProps>, "pluginKey"> & Omit<import("./extensions/BubbleMenu").BubbleMenuPluginProps, "pluginKey">, "element">>, "editor"> & Omit<Omit<Pick<Partial<import("./extensions/BubbleMenu").BubbleMenuPluginProps>, "pluginKey"> & Omit<import("./extensions/BubbleMenu").BubbleMenuPluginProps, "pluginKey">, "element">, "editor"> & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
|
|
4
|
+
export declare const StyledEditorContent: import("styled-components").StyledComponent<import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<import("@tiptap/react").EditorContentProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>>, any, {
|
|
5
|
+
$textStyle: TextStyle;
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const ColorBox: import("styled-components").StyledComponent<"div", any, {
|
|
8
|
+
$color?: string | undefined;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const ToolbarWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { EditorContent } from '@tiptap/react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import { BubbleMenu } from './ui/BubbleMenu';
|
|
4
|
+
import { SMART_TAG_HIGHLIGHT_BG } from './constants';
|
|
5
|
+
import { Flex } from 'antd';
|
|
6
|
+
import tinycolor from 'tinycolor2';
|
|
7
|
+
export const StyledBubbleMenu = styled(BubbleMenu) `
|
|
8
|
+
background-color: white;
|
|
9
|
+
border-radius: 5px;
|
|
10
|
+
padding: 8px;
|
|
11
|
+
box-shadow: var(--antsomi-box-shadow-secondary);
|
|
12
|
+
`;
|
|
13
|
+
const dynContentStyles = css `
|
|
14
|
+
background-color: ${SMART_TAG_HIGHLIGHT_BG};
|
|
15
|
+
background-color: color-mix(
|
|
16
|
+
in lab,
|
|
17
|
+
var(--text-style-bg-color, transparent),
|
|
18
|
+
${SMART_TAG_HIGHLIGHT_BG}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
background-color: ${SMART_TAG_HIGHLIGHT_BG};
|
|
23
|
+
background-color: color-mix(
|
|
24
|
+
in lab,
|
|
25
|
+
var(--text-style-bg-color, transparent),
|
|
26
|
+
${SMART_TAG_HIGHLIGHT_BG} 80%
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
export const StyledEditorContent = styled(EditorContent) `
|
|
31
|
+
.tiptap {
|
|
32
|
+
outline: none;
|
|
33
|
+
|
|
34
|
+
p {
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
|
|
38
|
+
line-height: ${p => p.$textStyle.lineHeight};
|
|
39
|
+
font-family: ${p => p.$textStyle.fontFamily};
|
|
40
|
+
font-size: ${p => p.$textStyle.fontSize};
|
|
41
|
+
color: ${p => p.$textStyle.color};
|
|
42
|
+
letter-spacing: ${p => p.$textStyle.letterSpacing};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:not([contenteditable='false']) {
|
|
46
|
+
p {
|
|
47
|
+
cursor: text;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.selection {
|
|
51
|
+
background-color: #d7cac9;
|
|
52
|
+
background-color: color-mix(in lab, var(--text-style-bg-color, transparent), #d7cac9);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.smart-tag {
|
|
56
|
+
cursor: pointer;
|
|
57
|
+
|
|
58
|
+
&.highlight {
|
|
59
|
+
${dynContentStyles}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.link {
|
|
64
|
+
&.highlight > span {
|
|
65
|
+
${dynContentStyles}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
export const ColorBox = styled.div `
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
width: 20px;
|
|
74
|
+
height: 20px;
|
|
75
|
+
border-radius: 50%;
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
padding: 2px;
|
|
80
|
+
transition: box-shadow 0.3s ease-in-out;
|
|
81
|
+
border: 1px solid #d9d9d9;
|
|
82
|
+
background-color: ${p => p.$color};
|
|
83
|
+
|
|
84
|
+
&:hover {
|
|
85
|
+
box-shadow: 0 0 5px ${p => tinycolor(p.$color).setAlpha(0.45).toRgbString()};
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
export const ToolbarWrapper = styled(Flex) `
|
|
90
|
+
.antsomi-divider.toolbar-separator {
|
|
91
|
+
height: 28px;
|
|
92
|
+
margin: 2px;
|
|
93
|
+
}
|
|
94
|
+
`;
|