@antscorp/antsomi-ui 2.0.110 → 2.0.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/assets/css/main.scss +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.d.ts +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.js +53 -0
- package/es/components/atoms/Eyedropper/index.d.ts +0 -0
- package/es/components/atoms/Eyedropper/index.js +1 -0
- package/es/components/atoms/Eyedropper/styled.d.ts +9 -0
- package/es/components/atoms/Eyedropper/styled.js +45 -0
- package/es/components/atoms/Eyedropper/types.d.ts +5 -0
- package/es/components/atoms/Eyedropper/types.js +1 -0
- package/es/components/icons/ALignRightIcon.d.ts +3 -0
- package/es/components/icons/ALignRightIcon.js +7 -0
- package/es/components/icons/AlignCenterIcon.d.ts +3 -0
- package/es/components/icons/AlignCenterIcon.js +7 -0
- package/es/components/icons/AlignJustifyIcon.d.ts +3 -0
- package/es/components/icons/AlignJustifyIcon.js +7 -0
- package/es/components/icons/AlignLeftIcon.d.ts +3 -0
- package/es/components/icons/AlignLeftIcon.js +7 -0
- package/es/components/icons/ArrowDropDownIcon.d.ts +3 -0
- package/es/components/icons/ArrowDropDownIcon.js +7 -0
- package/es/components/icons/ChevronRightIcon.d.ts +3 -0
- package/es/components/icons/ChevronRightIcon.js +7 -0
- package/es/components/icons/ColorizeIcon.d.ts +3 -0
- package/es/components/icons/ColorizeIcon.js +7 -0
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +9 -0
- package/es/components/icons/LinkOffIcon.d.ts +3 -0
- package/es/components/icons/LinkOffIcon.js +7 -0
- package/es/components/icons/MinusIcon.d.ts +3 -0
- package/es/components/icons/MinusIcon.js +7 -0
- package/es/components/icons/index.d.ts +9 -0
- package/es/components/icons/index.js +9 -0
- package/es/components/index.scss +1 -0
- package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
- package/es/components/molecules/EmojiCollections/types.d.ts +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +2 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +11 -0
- package/es/components/molecules/EyedropperButton/EyedropperButton.js +34 -0
- package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
- package/es/components/molecules/EyedropperButton/index.js +1 -0
- package/es/components/molecules/EyedropperButton/styled.d.ts +7 -0
- package/es/components/molecules/EyedropperButton/styled.js +23 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +134 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +8 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +14 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +21 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +19 -0
- package/es/components/molecules/FontSizeInput/constants.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/constants.js +5 -0
- package/es/components/molecules/FontSizeInput/index.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/index.js +1 -0
- package/es/components/molecules/FontSizeInput/styled.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/styled.js +39 -0
- package/es/components/molecules/FontSizeInput/types.d.ts +23 -0
- package/es/components/molecules/FontSizeInput/types.js +1 -0
- package/es/components/molecules/FontSizeInput/utils.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/utils.js +9 -0
- package/es/components/molecules/SearchPopover/SearchPopover.d.ts +2 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +3 -3
- package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
- package/es/components/molecules/SearchPopover/styled.js +1 -2
- package/es/components/molecules/SearchPopover/types.d.ts +4 -3
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +6 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +49 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
- package/es/components/molecules/VirtualizedMenu/styled.js +24 -3
- package/es/components/molecules/VirtualizedMenu/types.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.js +2 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/molecules/index.scss +1 -0
- package/es/components/organism/TextEditor/TextEditor.d.ts +10 -0
- package/es/components/organism/TextEditor/TextEditor.js +403 -0
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +47 -0
- package/es/components/organism/TextEditor/constants.d.ts +196 -0
- package/es/components/organism/TextEditor/constants.js +398 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +43 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +18 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +81 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +35 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +16 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.js +30 -0
- package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/Color.js +34 -0
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
- package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +31 -0
- package/es/components/organism/TextEditor/extensions/FontSize.js +46 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
- package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.js +101 -0
- package/es/components/organism/TextEditor/extensions/Link.d.ts +22 -0
- package/es/components/organism/TextEditor/extensions/Link.js +197 -0
- package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
- package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +33 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.js +194 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +30 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.js +36 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
- package/es/components/organism/TextEditor/hooks/index.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/index.js +6 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.js +29 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +69 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
- package/es/components/organism/TextEditor/index.d.ts +18 -0
- package/es/components/organism/TextEditor/index.js +8 -0
- package/es/components/organism/TextEditor/index.scss +65 -0
- package/es/components/organism/TextEditor/provider.d.ts +15 -0
- package/es/components/organism/TextEditor/provider.js +36 -0
- package/es/components/organism/TextEditor/store.d.ts +20 -0
- package/es/components/organism/TextEditor/store.js +40 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
- package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
- package/es/components/organism/TextEditor/stories/shared.js +57 -0
- package/es/components/organism/TextEditor/styled.d.ts +9 -0
- package/es/components/organism/TextEditor/styled.js +61 -0
- package/es/components/organism/TextEditor/types.d.ts +324 -0
- package/es/components/organism/TextEditor/types.js +6 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +3 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +114 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/Button/Button.js +35 -0
- package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.js +27 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +102 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +36 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.d.ts +35 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +58 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +75 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +85 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +93 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +20 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +32 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +41 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +8 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +51 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.js +45 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +67 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -0
- package/es/components/organism/TextEditor/utils/documentState.d.ts +73 -0
- package/es/components/organism/TextEditor/utils/documentState.js +149 -0
- package/es/components/organism/TextEditor/utils/font.d.ts +74 -0
- package/es/components/organism/TextEditor/utils/font.js +147 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +87 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +460 -0
- package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
- package/es/components/organism/TextEditor/utils/indent.js +56 -0
- package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
- package/es/components/organism/TextEditor/utils/index.js +16 -0
- package/es/components/organism/TextEditor/utils/link.d.ts +116 -0
- package/es/components/organism/TextEditor/utils/link.js +304 -0
- package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
- package/es/components/organism/TextEditor/utils/menu.js +321 -0
- package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
- package/es/components/organism/TextEditor/utils/selection.js +58 -0
- package/es/components/organism/TextEditor/utils/shared.d.ts +13 -0
- package/es/components/organism/TextEditor/utils/shared.js +52 -0
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
- package/es/components/organism/TextEditor/utils/smartTag.js +90 -0
- package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
- package/es/components/organism/TextEditor/utils/style.js +193 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/organism/index.scss +1 -0
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/web.d.ts +8 -0
- package/es/constants/web.js +57 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
- package/es/hooks/useBroadcastedLocalStorage.js +71 -0
- package/es/hooks/useElementSize.d.ts +7 -0
- package/es/hooks/useElementSize.js +56 -0
- package/es/hooks/useEyedropper/attach.d.ts +4 -0
- package/es/hooks/useEyedropper/attach.js +9 -0
- package/es/hooks/useEyedropper/eyedropper.d.ts +69 -0
- package/es/hooks/useEyedropper/eyedropper.js +205 -0
- package/es/hooks/useEyedropper/index.d.ts +2 -0
- package/es/hooks/useEyedropper/index.js +7 -0
- package/es/hooks/useEyedropper/support.d.ts +1 -0
- package/es/hooks/useEyedropper/support.js +3 -0
- package/es/hooks/useEyedropper/types.d.ts +9 -0
- package/es/hooks/useEyedropper/types.js +1 -0
- package/es/hooks/useEyedropper/useEyedropper.d.ts +8 -0
- package/es/hooks/useEyedropper/useEyedropper.js +50 -0
- package/es/hooks/useEyedropper/utils.d.ts +11 -0
- package/es/hooks/useEyedropper/utils.js +17 -0
- package/es/hooks/useIsMounted.d.ts +1 -0
- package/es/hooks/useIsMounted.js +11 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/locales/i18n.d.ts +1 -1
- package/es/types/index.d.ts +9 -0
- package/es/utils/common.d.ts +15 -9
- package/es/utils/common.js +62 -24
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/web.d.ts +80 -0
- package/es/utils/web.js +226 -0
- package/package.json +26 -17
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { isTextSelection } from '@tiptap/core';
|
|
2
|
+
import { isNoSelection } from './selection';
|
|
3
|
+
import { isCursorInLink } from './link';
|
|
4
|
+
import { textBetween } from './documentState';
|
|
5
|
+
/**
|
|
6
|
+
* Default function to determine if bubble menu should be shown
|
|
7
|
+
* @param params Object containing editor state and view information
|
|
8
|
+
* @returns true if bubble menu should be shown
|
|
9
|
+
*/
|
|
10
|
+
export const defaultShouldShowBubbleMenu = (params) => {
|
|
11
|
+
const { element, editor, state, view } = params;
|
|
12
|
+
const shouldShow = () => {
|
|
13
|
+
const { doc, selection } = state;
|
|
14
|
+
const { empty, ranges } = selection;
|
|
15
|
+
const from = Math.min(...ranges.map(range => range.$from.pos));
|
|
16
|
+
const to = Math.max(...ranges.map(range => range.$to.pos));
|
|
17
|
+
// Check if selection is an atom node (like emoji)
|
|
18
|
+
const isAtomNode = from + 1 === to && doc.nodeAt(from)?.isAtom;
|
|
19
|
+
// Sometime check for `empty` is not enough.
|
|
20
|
+
// Doubleclick an empty paragraph returns a node size of 2.
|
|
21
|
+
// So we check also for an empty text size.
|
|
22
|
+
// BUT: if it's an atom node, we should still show the bubble menu
|
|
23
|
+
const isEmptyTextBlock = !textBetween(state, from, to).length && isTextSelection(state.selection) && !isAtomNode;
|
|
24
|
+
// When clicking on a element inside the bubble menu the editor "blur" event
|
|
25
|
+
// is called and the bubble menu item is focussed. In this case we should
|
|
26
|
+
// consider the menu as part of the editor and keep showing the menu
|
|
27
|
+
const isChildOfMenu = element.contains(document.activeElement);
|
|
28
|
+
const hasEditorFocus = view.hasFocus() || isChildOfMenu;
|
|
29
|
+
if (!hasEditorFocus || empty || isEmptyTextBlock || !editor.isEditable) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
const show = shouldShow();
|
|
35
|
+
return show;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Checks if link menu should be shown
|
|
39
|
+
* @param state EditorState
|
|
40
|
+
* @returns true if link menu should be shown
|
|
41
|
+
*/
|
|
42
|
+
export const shouldShowLinkMenu = (state) => isNoSelection(state) && isCursorInLink(state);
|
|
43
|
+
/**
|
|
44
|
+
* Calculates optimal menu position relative to selection
|
|
45
|
+
* @param view EditorView instance
|
|
46
|
+
* @param menuElement Menu element to position
|
|
47
|
+
* @returns Position coordinates
|
|
48
|
+
*/
|
|
49
|
+
export function calculateMenuPosition(view, menuElement) {
|
|
50
|
+
const { selection } = view.state;
|
|
51
|
+
const { from, to } = selection;
|
|
52
|
+
// Get DOM coordinates of selection
|
|
53
|
+
const start = view.coordsAtPos(from);
|
|
54
|
+
const end = view.coordsAtPos(to);
|
|
55
|
+
// Calculate menu dimensions
|
|
56
|
+
const menuRect = menuElement.getBoundingClientRect();
|
|
57
|
+
const viewportWidth = window.innerWidth;
|
|
58
|
+
// const viewportHeight = window.innerHeight;
|
|
59
|
+
// Calculate optimal position
|
|
60
|
+
let top = start.top - menuRect.height - 10; // 10px gap above selection
|
|
61
|
+
let left = (start.left + end.left) / 2 - menuRect.width / 2; // Center horizontally
|
|
62
|
+
// Adjust if menu would go off-screen
|
|
63
|
+
if (top < 0) {
|
|
64
|
+
top = end.bottom + 10; // Show below if no space above
|
|
65
|
+
}
|
|
66
|
+
if (left < 0) {
|
|
67
|
+
left = 10; // 10px from left edge
|
|
68
|
+
}
|
|
69
|
+
else if (left + menuRect.width > viewportWidth) {
|
|
70
|
+
left = viewportWidth - menuRect.width - 10; // 10px from right edge
|
|
71
|
+
}
|
|
72
|
+
return { top, left };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Checks if menu should be hidden based on editor state
|
|
76
|
+
* @param editor Editor instance
|
|
77
|
+
* @returns true if menu should be hidden
|
|
78
|
+
*/
|
|
79
|
+
export function shouldHideMenu(editor) {
|
|
80
|
+
if (!editor.isEditable)
|
|
81
|
+
return true;
|
|
82
|
+
if (!editor.isFocused)
|
|
83
|
+
return true;
|
|
84
|
+
const { selection } = editor.state;
|
|
85
|
+
if (selection.empty)
|
|
86
|
+
return true;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets the active menu type based on current selection
|
|
91
|
+
* @param state EditorState
|
|
92
|
+
* @returns Menu type identifier
|
|
93
|
+
*/
|
|
94
|
+
export function getActiveMenuType(state) {
|
|
95
|
+
if (shouldShowLinkMenu(state)) {
|
|
96
|
+
return 'link';
|
|
97
|
+
}
|
|
98
|
+
const { selection } = state;
|
|
99
|
+
if (selection.empty)
|
|
100
|
+
return null;
|
|
101
|
+
// Check if smart tag is selected
|
|
102
|
+
const node = state.doc.nodeAt(selection.from);
|
|
103
|
+
if (node && node.type.name === 'smartTag') {
|
|
104
|
+
return 'smartTag';
|
|
105
|
+
}
|
|
106
|
+
return 'default';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Menu visibility manager class
|
|
110
|
+
*/
|
|
111
|
+
export class MenuVisibilityManager {
|
|
112
|
+
constructor() {
|
|
113
|
+
this.visibleMenus = new Set();
|
|
114
|
+
this.callbacks = new Map();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Shows a menu with given ID
|
|
118
|
+
* @param menuId Menu identifier
|
|
119
|
+
* @param onShow Optional callback when menu is shown
|
|
120
|
+
*/
|
|
121
|
+
showMenu(menuId, onShow) {
|
|
122
|
+
this.hideAllMenus();
|
|
123
|
+
this.visibleMenus.add(menuId);
|
|
124
|
+
if (onShow) {
|
|
125
|
+
this.callbacks.set(menuId, onShow);
|
|
126
|
+
onShow();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Hides a specific menu
|
|
131
|
+
* @param menuId Menu identifier
|
|
132
|
+
*/
|
|
133
|
+
hideMenu(menuId) {
|
|
134
|
+
this.visibleMenus.delete(menuId);
|
|
135
|
+
this.callbacks.delete(menuId);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Hides all visible menus
|
|
139
|
+
*/
|
|
140
|
+
hideAllMenus() {
|
|
141
|
+
this.visibleMenus.clear();
|
|
142
|
+
this.callbacks.clear();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Checks if a menu is visible
|
|
146
|
+
* @param menuId Menu identifier
|
|
147
|
+
* @returns true if menu is visible
|
|
148
|
+
*/
|
|
149
|
+
isMenuVisible(menuId) {
|
|
150
|
+
return this.visibleMenus.has(menuId);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Gets all visible menu IDs
|
|
154
|
+
* @returns Array of visible menu IDs
|
|
155
|
+
*/
|
|
156
|
+
getVisibleMenus() {
|
|
157
|
+
return Array.from(this.visibleMenus);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Menu positioning utilities
|
|
162
|
+
*/
|
|
163
|
+
export class MenuPositioner {
|
|
164
|
+
constructor(container = document.body) {
|
|
165
|
+
this.container = container;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Positions menu relative to a DOM element
|
|
169
|
+
* @param menuElement Menu element to position
|
|
170
|
+
* @param targetElement Target element to position relative to
|
|
171
|
+
* @param placement Placement preference
|
|
172
|
+
*/
|
|
173
|
+
positionRelativeToElement(menuElement, targetElement, placement = 'top') {
|
|
174
|
+
const targetRect = targetElement.getBoundingClientRect();
|
|
175
|
+
const menuRect = menuElement.getBoundingClientRect();
|
|
176
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
177
|
+
let top = 0;
|
|
178
|
+
let left = 0;
|
|
179
|
+
switch (placement) {
|
|
180
|
+
case 'top':
|
|
181
|
+
top = targetRect.top - menuRect.height - 5;
|
|
182
|
+
left = targetRect.left + (targetRect.width - menuRect.width) / 2;
|
|
183
|
+
break;
|
|
184
|
+
case 'bottom':
|
|
185
|
+
top = targetRect.bottom + 5;
|
|
186
|
+
left = targetRect.left + (targetRect.width - menuRect.width) / 2;
|
|
187
|
+
break;
|
|
188
|
+
case 'left':
|
|
189
|
+
top = targetRect.top + (targetRect.height - menuRect.height) / 2;
|
|
190
|
+
left = targetRect.left - menuRect.width - 5;
|
|
191
|
+
break;
|
|
192
|
+
case 'right':
|
|
193
|
+
top = targetRect.top + (targetRect.height - menuRect.height) / 2;
|
|
194
|
+
left = targetRect.right + 5;
|
|
195
|
+
break;
|
|
196
|
+
default:
|
|
197
|
+
// Default to 'top' placement
|
|
198
|
+
top = targetRect.top - menuRect.height - 5;
|
|
199
|
+
left = targetRect.left + (targetRect.width - menuRect.width) / 2;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
// Adjust for container offset
|
|
203
|
+
top -= containerRect.top;
|
|
204
|
+
left -= containerRect.left;
|
|
205
|
+
// Ensure menu stays within container bounds
|
|
206
|
+
top = Math.max(0, Math.min(top, containerRect.height - menuRect.height));
|
|
207
|
+
left = Math.max(0, Math.min(left, containerRect.width - menuRect.width));
|
|
208
|
+
menuElement.style.position = 'absolute';
|
|
209
|
+
menuElement.style.top = `${top}px`;
|
|
210
|
+
menuElement.style.left = `${left}px`;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Positions menu at specific coordinates
|
|
214
|
+
* @param menuElement Menu element to position
|
|
215
|
+
* @param x X coordinate
|
|
216
|
+
* @param y Y coordinate
|
|
217
|
+
*/
|
|
218
|
+
positionAtCoordinates(menuElement, x, y) {
|
|
219
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
220
|
+
// Adjust coordinates relative to container
|
|
221
|
+
const relativeX = x - containerRect.left;
|
|
222
|
+
const relativeY = y - containerRect.top;
|
|
223
|
+
menuElement.style.position = 'absolute';
|
|
224
|
+
menuElement.style.left = `${relativeX}px`;
|
|
225
|
+
menuElement.style.top = `${relativeY}px`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Menu keyboard navigation handler
|
|
230
|
+
*/
|
|
231
|
+
export class MenuKeyboardHandler {
|
|
232
|
+
constructor(menuElement) {
|
|
233
|
+
this.focusableElements = [];
|
|
234
|
+
this.currentIndex = -1;
|
|
235
|
+
this.menuElement = menuElement;
|
|
236
|
+
this.updateFocusableElements();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Updates the list of focusable elements
|
|
240
|
+
*/
|
|
241
|
+
updateFocusableElements() {
|
|
242
|
+
const focusableSelector = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
|
|
243
|
+
this.focusableElements = Array.from(this.menuElement.querySelectorAll(focusableSelector));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Handles keyboard events for menu navigation
|
|
247
|
+
* @param event Keyboard event
|
|
248
|
+
*/
|
|
249
|
+
handleKeyDown(event) {
|
|
250
|
+
switch (event.key) {
|
|
251
|
+
case 'ArrowDown':
|
|
252
|
+
event.preventDefault();
|
|
253
|
+
this.focusNext();
|
|
254
|
+
return true;
|
|
255
|
+
case 'ArrowUp':
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
this.focusPrevious();
|
|
258
|
+
return true;
|
|
259
|
+
case 'Home':
|
|
260
|
+
event.preventDefault();
|
|
261
|
+
this.focusFirst();
|
|
262
|
+
return true;
|
|
263
|
+
case 'End':
|
|
264
|
+
event.preventDefault();
|
|
265
|
+
this.focusLast();
|
|
266
|
+
return true;
|
|
267
|
+
case 'Escape':
|
|
268
|
+
event.preventDefault();
|
|
269
|
+
this.blur();
|
|
270
|
+
return true;
|
|
271
|
+
default:
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Focuses the next focusable element
|
|
277
|
+
*/
|
|
278
|
+
focusNext() {
|
|
279
|
+
if (this.focusableElements.length === 0)
|
|
280
|
+
return;
|
|
281
|
+
this.currentIndex = (this.currentIndex + 1) % this.focusableElements.length;
|
|
282
|
+
this.focusableElements[this.currentIndex].focus();
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Focuses the previous focusable element
|
|
286
|
+
*/
|
|
287
|
+
focusPrevious() {
|
|
288
|
+
if (this.focusableElements.length === 0)
|
|
289
|
+
return;
|
|
290
|
+
this.currentIndex =
|
|
291
|
+
this.currentIndex <= 0 ? this.focusableElements.length - 1 : this.currentIndex - 1;
|
|
292
|
+
this.focusableElements[this.currentIndex].focus();
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Focuses the first focusable element
|
|
296
|
+
*/
|
|
297
|
+
focusFirst() {
|
|
298
|
+
if (this.focusableElements.length === 0)
|
|
299
|
+
return;
|
|
300
|
+
this.currentIndex = 0;
|
|
301
|
+
this.focusableElements[this.currentIndex].focus();
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Focuses the last focusable element
|
|
305
|
+
*/
|
|
306
|
+
focusLast() {
|
|
307
|
+
if (this.focusableElements.length === 0)
|
|
308
|
+
return;
|
|
309
|
+
this.currentIndex = this.focusableElements.length - 1;
|
|
310
|
+
this.focusableElements[this.currentIndex].focus();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Removes focus from menu
|
|
314
|
+
*/
|
|
315
|
+
blur() {
|
|
316
|
+
this.currentIndex = -1;
|
|
317
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
318
|
+
document.activeElement.blur();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EditorState } from '@tiptap/pm/state';
|
|
2
|
+
/**
|
|
3
|
+
* Kiểm tra xem có selection nào trong tài liệu hay không
|
|
4
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
5
|
+
* @returns true nếu không có selection, false nếu có selection
|
|
6
|
+
*/
|
|
7
|
+
export declare const isNoSelection: (state: EditorState) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the text content of the current selection
|
|
10
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
11
|
+
* @returns Selected text content
|
|
12
|
+
*/
|
|
13
|
+
export declare const getSelectionText: (state: EditorState) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if selection spans multiple nodes
|
|
16
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
17
|
+
* @returns true if selection spans multiple nodes
|
|
18
|
+
*/
|
|
19
|
+
export declare const isMultiNodeSelection: (state: EditorState) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the depth of the current selection
|
|
22
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
23
|
+
* @returns Selection depth
|
|
24
|
+
*/
|
|
25
|
+
export declare const getSelectionDepth: (state: EditorState) => number;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isNodeSelection, isTextSelection } from '@tiptap/core';
|
|
2
|
+
import { textBetween } from './documentState';
|
|
3
|
+
/**
|
|
4
|
+
* Kiểm tra xem có selection nào trong tài liệu hay không
|
|
5
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
6
|
+
* @returns true nếu không có selection, false nếu có selection
|
|
7
|
+
*/
|
|
8
|
+
export const isNoSelection = (state) => {
|
|
9
|
+
const { selection } = state;
|
|
10
|
+
if (selection.empty)
|
|
11
|
+
return true;
|
|
12
|
+
// Kiểm tra trường hợp text selection không có nội dung
|
|
13
|
+
if (isTextSelection(selection)) {
|
|
14
|
+
const { from, to } = selection;
|
|
15
|
+
if (from === to)
|
|
16
|
+
return true;
|
|
17
|
+
const selectedText = textBetween(state, from, to);
|
|
18
|
+
return selectedText.length === 0;
|
|
19
|
+
}
|
|
20
|
+
// Nếu là node selection, thì có selection
|
|
21
|
+
if (isNodeSelection(selection))
|
|
22
|
+
return false;
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Gets the text content of the current selection
|
|
27
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
28
|
+
* @returns Selected text content
|
|
29
|
+
*/
|
|
30
|
+
export const getSelectionText = (state) => {
|
|
31
|
+
const { selection } = state;
|
|
32
|
+
const { from, to } = selection;
|
|
33
|
+
return textBetween(state, from, to);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Checks if selection spans multiple nodes
|
|
37
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
38
|
+
* @returns true if selection spans multiple nodes
|
|
39
|
+
*/
|
|
40
|
+
export const isMultiNodeSelection = (state) => {
|
|
41
|
+
const { selection } = state;
|
|
42
|
+
if (selection.empty)
|
|
43
|
+
return false;
|
|
44
|
+
const { from, to } = selection;
|
|
45
|
+
const $from = state.doc.resolve(from);
|
|
46
|
+
const $to = state.doc.resolve(to);
|
|
47
|
+
return $from.parent !== $to.parent;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Gets the depth of the current selection
|
|
51
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
52
|
+
* @returns Selection depth
|
|
53
|
+
*/
|
|
54
|
+
export const getSelectionDepth = (state) => {
|
|
55
|
+
const { selection } = state;
|
|
56
|
+
const { $from } = selection;
|
|
57
|
+
return $from.depth;
|
|
58
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Range } from '@tiptap/core';
|
|
2
|
+
export declare function clamp(val: number, min: number, max: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* Merges adjacent or overlapping ranges based on a custom merge condition
|
|
5
|
+
* @param ranges - Array of ranges to merge (will be sorted by 'from' position)
|
|
6
|
+
* @param shouldMerge - Function to determine if ranges should be merged
|
|
7
|
+
* @returns Array of merged ranges with combined data
|
|
8
|
+
*/
|
|
9
|
+
export declare function mergeAdjacentRanges<T extends Range>(ranges: T[], shouldMerge: (existingRangeData: T[], candidateRange: T) => boolean): {
|
|
10
|
+
from: number;
|
|
11
|
+
to: number;
|
|
12
|
+
data: T[];
|
|
13
|
+
}[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export function clamp(val, min, max) {
|
|
2
|
+
if (val < min) {
|
|
3
|
+
return min;
|
|
4
|
+
}
|
|
5
|
+
if (val > max) {
|
|
6
|
+
return max;
|
|
7
|
+
}
|
|
8
|
+
return val;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Merges adjacent or overlapping ranges based on a custom merge condition
|
|
12
|
+
* @param ranges - Array of ranges to merge (will be sorted by 'from' position)
|
|
13
|
+
* @param shouldMerge - Function to determine if ranges should be merged
|
|
14
|
+
* @returns Array of merged ranges with combined data
|
|
15
|
+
*/
|
|
16
|
+
export function mergeAdjacentRanges(ranges, shouldMerge) {
|
|
17
|
+
// Return empty array if no ranges provided
|
|
18
|
+
if (ranges.length === 0)
|
|
19
|
+
return [];
|
|
20
|
+
// Sort ranges by starting position to process them in order
|
|
21
|
+
ranges.sort((a, b) => a.from - b.from);
|
|
22
|
+
// Initialize with the first range
|
|
23
|
+
const mergedRanges = [
|
|
24
|
+
{
|
|
25
|
+
from: ranges[0].from,
|
|
26
|
+
to: ranges[0].to,
|
|
27
|
+
data: [ranges[0]],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
// Process remaining ranges
|
|
31
|
+
for (let i = 1; i < ranges.length; i++) {
|
|
32
|
+
const currentRange = ranges[i];
|
|
33
|
+
const lastMergedRange = mergedRanges[mergedRanges.length - 1];
|
|
34
|
+
// Check if current range overlaps with last merged range and should be merged
|
|
35
|
+
const rangesOverlap = currentRange.from <= lastMergedRange.to;
|
|
36
|
+
const canMergeRanges = shouldMerge(lastMergedRange.data, currentRange);
|
|
37
|
+
if (rangesOverlap && canMergeRanges) {
|
|
38
|
+
// Extend the last merged range to include current range
|
|
39
|
+
lastMergedRange.to = Math.max(lastMergedRange.to, currentRange.to);
|
|
40
|
+
lastMergedRange.data.push(currentRange);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Create a new merged range for current range
|
|
44
|
+
mergedRanges.push({
|
|
45
|
+
from: currentRange.from,
|
|
46
|
+
to: currentRange.to,
|
|
47
|
+
data: [currentRange],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return mergedRanges;
|
|
52
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
2
|
+
import { SmartTagHandler } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Handles smart tag actions (create or edit)
|
|
5
|
+
* @param event Mouse event from the action
|
|
6
|
+
* @param view EditorView instance
|
|
7
|
+
* @param smartTagHandler Smart tag handler callbacks
|
|
8
|
+
*/
|
|
9
|
+
export declare const handleSmartTagAction: (event: React.MouseEvent, view: EditorView, smartTagHandler?: SmartTagHandler) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Gets smart tag node at a specific position
|
|
12
|
+
* @param view EditorView instance
|
|
13
|
+
* @param pos Position to check
|
|
14
|
+
* @returns Smart tag node or null
|
|
15
|
+
*/
|
|
16
|
+
export declare const getSmartTagAtPosition: (view: EditorView, pos: number) => import("prosemirror-model").Node | null;
|
|
17
|
+
/**
|
|
18
|
+
* Gets all smart tags in the document
|
|
19
|
+
* @param view EditorView instance
|
|
20
|
+
* @returns Array of smart tag nodes with their positions
|
|
21
|
+
*/
|
|
22
|
+
export declare const getAllSmartTags: (view: EditorView) => {
|
|
23
|
+
node: any;
|
|
24
|
+
pos: number;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* Finds smart tag by ID
|
|
28
|
+
* @param view EditorView instance
|
|
29
|
+
* @param id Smart tag ID to find
|
|
30
|
+
* @returns Smart tag node and position or null
|
|
31
|
+
*/
|
|
32
|
+
export declare const findSmartTagById: (view: EditorView, id: string) => null;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if position is inside a smart tag
|
|
35
|
+
* @param view EditorView instance
|
|
36
|
+
* @param pos Position to check
|
|
37
|
+
* @returns true if position is inside a smart tag
|
|
38
|
+
*/
|
|
39
|
+
export declare const isPositionInSmartTag: (view: EditorView, pos: number) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Gets smart tag content at cursor position
|
|
42
|
+
* @param view EditorView instance
|
|
43
|
+
* @returns Smart tag content or null
|
|
44
|
+
*/
|
|
45
|
+
export declare const getSmartTagAtCursor: (view: EditorView) => {
|
|
46
|
+
id: any;
|
|
47
|
+
content: any;
|
|
48
|
+
node: import("prosemirror-model").Node;
|
|
49
|
+
} | null;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { textBetween } from './documentState';
|
|
2
|
+
/**
|
|
3
|
+
* Handles smart tag actions (create or edit)
|
|
4
|
+
* @param event Mouse event from the action
|
|
5
|
+
* @param view EditorView instance
|
|
6
|
+
* @param smartTagHandler Smart tag handler callbacks
|
|
7
|
+
*/
|
|
8
|
+
export const handleSmartTagAction = (event, view, smartTagHandler) => {
|
|
9
|
+
const { state } = view;
|
|
10
|
+
const { from, to } = state.selection;
|
|
11
|
+
const smartTagNode = state.doc.nodeAt(from);
|
|
12
|
+
const smartTagId = smartTagNode?.attrs.id;
|
|
13
|
+
if (smartTagId) {
|
|
14
|
+
smartTagHandler?.edit?.(smartTagId, event);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
const selectedText = textBetween(state, from, to);
|
|
18
|
+
if (selectedText) {
|
|
19
|
+
smartTagHandler?.setNew?.({
|
|
20
|
+
selectionText: selectedText,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Gets smart tag node at a specific position
|
|
27
|
+
* @param view EditorView instance
|
|
28
|
+
* @param pos Position to check
|
|
29
|
+
* @returns Smart tag node or null
|
|
30
|
+
*/
|
|
31
|
+
export const getSmartTagAtPosition = (view, pos) => {
|
|
32
|
+
const node = view.state.doc.nodeAt(pos);
|
|
33
|
+
if (node && node.type.name === 'smartTag') {
|
|
34
|
+
return node;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Gets all smart tags in the document
|
|
40
|
+
* @param view EditorView instance
|
|
41
|
+
* @returns Array of smart tag nodes with their positions
|
|
42
|
+
*/
|
|
43
|
+
export const getAllSmartTags = (view) => {
|
|
44
|
+
const smartTags = [];
|
|
45
|
+
view.state.doc.descendants((node, pos) => {
|
|
46
|
+
if (node.type.name === 'smartTag') {
|
|
47
|
+
smartTags.push({ node, pos });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return smartTags;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Finds smart tag by ID
|
|
54
|
+
* @param view EditorView instance
|
|
55
|
+
* @param id Smart tag ID to find
|
|
56
|
+
* @returns Smart tag node and position or null
|
|
57
|
+
*/
|
|
58
|
+
export const findSmartTagById = (view, id) => {
|
|
59
|
+
let result = null;
|
|
60
|
+
view.state.doc.descendants((node, pos) => {
|
|
61
|
+
if (node.type.name === 'smartTag' && node.attrs.id === id) {
|
|
62
|
+
result = { node, pos };
|
|
63
|
+
return false; // Stop traversal
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Checks if position is inside a smart tag
|
|
70
|
+
* @param view EditorView instance
|
|
71
|
+
* @param pos Position to check
|
|
72
|
+
* @returns true if position is inside a smart tag
|
|
73
|
+
*/
|
|
74
|
+
export const isPositionInSmartTag = (view, pos) => getSmartTagAtPosition(view, pos) !== null;
|
|
75
|
+
/**
|
|
76
|
+
* Gets smart tag content at cursor position
|
|
77
|
+
* @param view EditorView instance
|
|
78
|
+
* @returns Smart tag content or null
|
|
79
|
+
*/
|
|
80
|
+
export const getSmartTagAtCursor = (view) => {
|
|
81
|
+
const { selection } = view.state;
|
|
82
|
+
const node = getSmartTagAtPosition(view, selection.from);
|
|
83
|
+
return node
|
|
84
|
+
? {
|
|
85
|
+
id: node.attrs.id,
|
|
86
|
+
content: node.attrs.content,
|
|
87
|
+
node,
|
|
88
|
+
}
|
|
89
|
+
: null;
|
|
90
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { TextStyle } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts text style from element's computed style
|
|
4
|
+
* @param style CSSStyleDeclaration from element
|
|
5
|
+
* @returns Partial TextStyle object
|
|
6
|
+
*/
|
|
7
|
+
export declare const textStyleFromElStyle: <T extends CSSStyleDeclaration>(style: T, defaultStyle: TextStyle) => Partial<TextStyle>;
|
|
8
|
+
/**
|
|
9
|
+
* Applies text style to HTML element
|
|
10
|
+
* @param el HTML element to apply styles to
|
|
11
|
+
* @param style TextStyle object
|
|
12
|
+
*/
|
|
13
|
+
export declare const appendTextStyleToEl: (el: HTMLElement, style: Partial<TextStyle>) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Converts a style object to a CSS string representation
|
|
16
|
+
* @param styleObj The style object to convert
|
|
17
|
+
* @returns The CSS string representation
|
|
18
|
+
* @example
|
|
19
|
+
* styleObjectToString({ color: 'red', fontSize: '16px' })
|
|
20
|
+
* // returns "color: red; font-size: 16px"
|
|
21
|
+
*/
|
|
22
|
+
export declare function styleObjectToString(styleObj: Record<string, unknown>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Normalizes a font-family string by adding quotes when needed
|
|
25
|
+
* @param fontFamily The font-family string to normalize
|
|
26
|
+
* @returns The normalized font-family string
|
|
27
|
+
* @description
|
|
28
|
+
* - Preserves existing quoted names
|
|
29
|
+
* - Doesn't quote generic families (e.g. sans-serif)
|
|
30
|
+
* - Quotes names containing spaces or special characters
|
|
31
|
+
* @example
|
|
32
|
+
* normalizeFontFamily('Arial, Helvetica, sans-serif')
|
|
33
|
+
* // returns 'Arial, Helvetica, sans-serif'
|
|
34
|
+
*
|
|
35
|
+
* normalizeFontFamily('Times New Roman, serif')
|
|
36
|
+
* // returns '"Times New Roman", serif'
|
|
37
|
+
*/
|
|
38
|
+
export declare function normalizeFontFamily(fontFamily: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Creates font-family string with fallback
|
|
41
|
+
* @param fontFamily Primary font family
|
|
42
|
+
* @param defaultFont Default fallback font
|
|
43
|
+
* @returns Normalized font-family string with fallback
|
|
44
|
+
*/
|
|
45
|
+
export declare const fontWithFallback: (fontFamily: string, defaultFont?: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a color matches the link color
|
|
48
|
+
* @param color Color to check
|
|
49
|
+
* @returns true if color matches link color
|
|
50
|
+
*/
|
|
51
|
+
export declare const isLinkColor: (color: string) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Extracts CSS variables from a style object
|
|
54
|
+
* @param styleObj Style object that may contain CSS variables
|
|
55
|
+
* @returns Object with CSS variables and regular styles separated
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractCSSVariables(styleObj: Record<string, unknown>): {
|
|
58
|
+
cssVariables: Record<string, unknown>;
|
|
59
|
+
regularStyles: Record<string, unknown>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Merges multiple text styles with priority
|
|
63
|
+
* @param styles Array of text styles to merge
|
|
64
|
+
* @returns Merged text style
|
|
65
|
+
*/
|
|
66
|
+
export declare function mergeTextStyles(...styles: Partial<TextStyle>[]): Partial<TextStyle>;
|
|
67
|
+
/**
|
|
68
|
+
* Validates if a text style is complete
|
|
69
|
+
* @param style Text style to validate
|
|
70
|
+
* @returns true if all required properties are present
|
|
71
|
+
*/
|
|
72
|
+
export declare function isCompleteTextStyle(style: Partial<TextStyle>): style is TextStyle;
|
|
73
|
+
/**
|
|
74
|
+
* Converts text style to CSS style object
|
|
75
|
+
* @param textStyle Text style object
|
|
76
|
+
* @returns CSS style object
|
|
77
|
+
*/
|
|
78
|
+
export declare function textStyleToCSSStyle(textStyle: Partial<TextStyle>): React.CSSProperties;
|