@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,460 @@
|
|
|
1
|
+
import { isEmpty } from 'lodash';
|
|
2
|
+
import { textStyleFromElStyle, appendTextStyleToEl } from './style';
|
|
3
|
+
import tinycolor from 'tinycolor2';
|
|
4
|
+
const SMART_TAG_HIGHLIGHT_BG = 'rgba(0, 199, 97, 0.2)'; // old texteditor (floara version)
|
|
5
|
+
/**
|
|
6
|
+
* Creates a clean span element for a dynamic tag with only the essential attributes
|
|
7
|
+
*
|
|
8
|
+
* @param doc - The document used to create the new element
|
|
9
|
+
* @param originalSpan - The original dynamic tag span element
|
|
10
|
+
* @param attributesToPreserve - List of attribute names to copy from the original span
|
|
11
|
+
* @returns A new span element with preserved attributes
|
|
12
|
+
*/
|
|
13
|
+
function createCleanDynamicSpan(doc, originalSpan, attributesToPreserve) {
|
|
14
|
+
const cleanSpan = doc.createElement('span');
|
|
15
|
+
// Preserve only the specified attributes
|
|
16
|
+
for (const attrName of attributesToPreserve) {
|
|
17
|
+
if (originalSpan.hasAttribute(attrName)) {
|
|
18
|
+
cleanSpan.setAttribute(attrName, originalSpan.getAttribute(attrName));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Preserve the text content
|
|
22
|
+
cleanSpan.textContent = originalSpan.textContent?.trim() || '';
|
|
23
|
+
return cleanSpan;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Extracts style wrapper elements that need to be preserved from the original dynamic tag
|
|
27
|
+
*
|
|
28
|
+
* @param doc - The document containing the dynamic tag
|
|
29
|
+
* @param html - The original HTML string
|
|
30
|
+
* @param dynamicSpan - The original dynamic tag span element
|
|
31
|
+
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
32
|
+
* @returns Array of wrapper elements that provide styling
|
|
33
|
+
*/
|
|
34
|
+
function extractStyleWrappers(params) {
|
|
35
|
+
const { doc, html, dynamicSpan, wrapperElement, defaultStyle } = params;
|
|
36
|
+
const styleWrappers = [];
|
|
37
|
+
// Create a temporary container for style computation
|
|
38
|
+
const tempStyleContainer = document.createElement('div');
|
|
39
|
+
tempStyleContainer.style.display = 'none';
|
|
40
|
+
const targetWrapper = wrapperElement || document.body;
|
|
41
|
+
targetWrapper.appendChild(tempStyleContainer);
|
|
42
|
+
try {
|
|
43
|
+
// Extract computed styles from the original element
|
|
44
|
+
if (doc.body.firstElementChild) {
|
|
45
|
+
const tempDoc = new DOMParser().parseFromString(html, 'text/html');
|
|
46
|
+
if (tempDoc.body.firstElementChild) {
|
|
47
|
+
tempStyleContainer.appendChild(tempDoc.body.firstElementChild);
|
|
48
|
+
const originalDynamicElement = tempStyleContainer.querySelector(`span[data-dynamic-id="${dynamicSpan.dataset.dynamicId}"]`);
|
|
49
|
+
if (originalDynamicElement) {
|
|
50
|
+
// Create a span with the computed text styles
|
|
51
|
+
const computedTextStyle = textStyleFromElStyle(window.getComputedStyle(originalDynamicElement), defaultStyle);
|
|
52
|
+
// Remove background color if it matches the highlight color
|
|
53
|
+
if (tinycolor.equals(computedTextStyle.backgroundColor, SMART_TAG_HIGHLIGHT_BG)) {
|
|
54
|
+
computedTextStyle.backgroundColor = '';
|
|
55
|
+
}
|
|
56
|
+
const textStyleWrapper = document.createElement('span');
|
|
57
|
+
appendTextStyleToEl(textStyleWrapper, computedTextStyle);
|
|
58
|
+
styleWrappers.push(textStyleWrapper);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Extract nested style wrappers
|
|
63
|
+
let nestedElement = dynamicSpan.firstElementChild;
|
|
64
|
+
while (nestedElement && nestedElement.children.length <= 1) {
|
|
65
|
+
styleWrappers.push(nestedElement);
|
|
66
|
+
nestedElement = nestedElement.firstElementChild || null;
|
|
67
|
+
}
|
|
68
|
+
return styleWrappers;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
// Clean up the temporary container
|
|
72
|
+
targetWrapper.removeChild(tempStyleContainer);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Reconstructs the dynamic tag element hierarchy with preserved style wrappers
|
|
77
|
+
*
|
|
78
|
+
* @param doc - The document used to create new elements
|
|
79
|
+
* @param baseSpan - The clean base span element for the dynamic tag
|
|
80
|
+
* @param styleWrappers - Array of style wrapper elements to apply
|
|
81
|
+
* @returns The reconstructed dynamic tag with preserved styling
|
|
82
|
+
*/
|
|
83
|
+
function reconstructDynamicTagHierarchy(doc, baseSpan, styleWrappers) {
|
|
84
|
+
let resultNode = baseSpan;
|
|
85
|
+
// Apply style wrappers from innermost to outermost
|
|
86
|
+
styleWrappers.reverse().forEach(originalWrapper => {
|
|
87
|
+
const wrapperClone = doc.createElement(originalWrapper.tagName.toLowerCase());
|
|
88
|
+
// Clone all attributes from the original wrapper
|
|
89
|
+
for (let i = 0; i < originalWrapper.attributes.length; i++) {
|
|
90
|
+
const { name, value } = originalWrapper.attributes[i];
|
|
91
|
+
wrapperClone.setAttribute(name, value);
|
|
92
|
+
}
|
|
93
|
+
wrapperClone.appendChild(resultNode);
|
|
94
|
+
resultNode = wrapperClone;
|
|
95
|
+
});
|
|
96
|
+
return resultNode;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Restructures dynamic tags from Froala editor format to be compatible with Tiptap editor.
|
|
100
|
+
* This function preserves styling and attributes of dynamic tags while cleaning up their structure.
|
|
101
|
+
*
|
|
102
|
+
* @param html - The HTML string containing dynamic tags
|
|
103
|
+
* @param options - Configuration options for the restructuring process
|
|
104
|
+
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
105
|
+
* @returns The restructured HTML string
|
|
106
|
+
*/
|
|
107
|
+
export function restructureDynamicTagsWithOptions(params) {
|
|
108
|
+
const { html, options = {
|
|
109
|
+
attributesToClone: [
|
|
110
|
+
'class',
|
|
111
|
+
'id',
|
|
112
|
+
'style',
|
|
113
|
+
'data-dynamic',
|
|
114
|
+
'data-dynamic-id',
|
|
115
|
+
'direction',
|
|
116
|
+
'unicode-bidi',
|
|
117
|
+
'text-align',
|
|
118
|
+
'background-color',
|
|
119
|
+
'color',
|
|
120
|
+
],
|
|
121
|
+
}, wrapperElement, defaultStyle, } = params;
|
|
122
|
+
// Parse the HTML string into a DOM
|
|
123
|
+
const parser = new DOMParser();
|
|
124
|
+
const parsedDoc = parser.parseFromString(html, 'text/html');
|
|
125
|
+
// Find all dynamic tag spans
|
|
126
|
+
const dynamicTagSpans = parsedDoc.querySelectorAll('span[data-dynamic]');
|
|
127
|
+
// Process each dynamic span
|
|
128
|
+
dynamicTagSpans.forEach(originalDynamicSpan => {
|
|
129
|
+
// Step 1: Create a new clean span with essential attributes
|
|
130
|
+
const cleanDynamicSpan = createCleanDynamicSpan(parsedDoc, originalDynamicSpan, options.attributesToClone);
|
|
131
|
+
// Step 2: Extract style wrappers that need to be preserved
|
|
132
|
+
const styleWrappers = extractStyleWrappers({
|
|
133
|
+
doc: parsedDoc,
|
|
134
|
+
html,
|
|
135
|
+
dynamicSpan: originalDynamicSpan,
|
|
136
|
+
wrapperElement,
|
|
137
|
+
defaultStyle,
|
|
138
|
+
});
|
|
139
|
+
// Step 3: Reconstruct the element hierarchy with preserved styles
|
|
140
|
+
const restructuredDynamicTag = reconstructDynamicTagHierarchy(parsedDoc, cleanDynamicSpan, styleWrappers);
|
|
141
|
+
// Step 4: Replace the original span with the restructured node
|
|
142
|
+
originalDynamicSpan.replaceWith(restructuredDynamicTag);
|
|
143
|
+
});
|
|
144
|
+
return parsedDoc.body.innerHTML;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Converts inherited text styles to computed styles for span elements in HTML content.
|
|
148
|
+
* This function processes span elements to ensure text styles are explicitly set rather than inherited.
|
|
149
|
+
*
|
|
150
|
+
* @param html - The HTML string to process
|
|
151
|
+
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
152
|
+
* @returns The processed HTML string with computed styles applied
|
|
153
|
+
*/
|
|
154
|
+
const inheritStyleToComputedStyle = (params) => {
|
|
155
|
+
const { html, wrapperElement, defaultStyle } = params;
|
|
156
|
+
try {
|
|
157
|
+
// Create a new DOM parser and parse the HTML
|
|
158
|
+
const parser = new DOMParser();
|
|
159
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
160
|
+
if (!doc.body) {
|
|
161
|
+
// eslint-disable-next-line no-console
|
|
162
|
+
console.warn('Failed to parse HTML: body not found');
|
|
163
|
+
return html;
|
|
164
|
+
}
|
|
165
|
+
// Create a hidden container
|
|
166
|
+
const container = document.createElement('div');
|
|
167
|
+
container.style.visibility = 'hidden';
|
|
168
|
+
container.innerHTML = doc.body.innerHTML;
|
|
169
|
+
// Add container to DOM temporarily to compute styles
|
|
170
|
+
const targetWrapper = wrapperElement || document.body;
|
|
171
|
+
targetWrapper.appendChild(container);
|
|
172
|
+
// Process all span elements
|
|
173
|
+
const spanElements = container.querySelectorAll('span');
|
|
174
|
+
spanElements.forEach(span => {
|
|
175
|
+
const textStyle = textStyleFromElStyle(span.style, defaultStyle);
|
|
176
|
+
const computedStyle = window.getComputedStyle(span);
|
|
177
|
+
// Only update styles if there are inherited values
|
|
178
|
+
const shouldUpdateStyle = Object.values(textStyle).some(value => value === 'inherit');
|
|
179
|
+
if (!shouldUpdateStyle) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Update inherited styles with computed values
|
|
183
|
+
Object.entries(textStyle).forEach(([key, value]) => {
|
|
184
|
+
if (value === 'inherit' && key in span.style) {
|
|
185
|
+
span.style[key] = computedStyle[key];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
const resultHTML = container.innerHTML;
|
|
190
|
+
// Clean up
|
|
191
|
+
container.remove();
|
|
192
|
+
return resultHTML;
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
// eslint-disable-next-line no-console
|
|
196
|
+
console.error('Error processing styles:', error);
|
|
197
|
+
return html; // Return original HTML in case of error
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Removes empty paragraphs and spans with only break lines.
|
|
202
|
+
* @param html - The HTML string to process
|
|
203
|
+
* @returns The processed HTML string
|
|
204
|
+
*/
|
|
205
|
+
export function cleanLineBreaks(html) {
|
|
206
|
+
try {
|
|
207
|
+
const parser = new DOMParser();
|
|
208
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
209
|
+
const allSpans = doc.body.querySelectorAll('span');
|
|
210
|
+
const paragraphs = doc.body.querySelectorAll('p');
|
|
211
|
+
paragraphs.forEach(paragraph => {
|
|
212
|
+
const paragraphText = paragraph.textContent;
|
|
213
|
+
const breakLines = paragraph.querySelectorAll('br');
|
|
214
|
+
if (isEmpty(paragraphText) && isEmpty(breakLines)) {
|
|
215
|
+
paragraph.remove();
|
|
216
|
+
}
|
|
217
|
+
else if (isEmpty(paragraphText)) {
|
|
218
|
+
breakLines.forEach(breakLine => {
|
|
219
|
+
breakLine.remove();
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
allSpans.forEach(span => {
|
|
224
|
+
const spanText = span.textContent;
|
|
225
|
+
const breakLines = span.querySelectorAll('br');
|
|
226
|
+
if (isEmpty(spanText) && breakLines.length > 0) {
|
|
227
|
+
breakLines.forEach(breakLine => {
|
|
228
|
+
breakLine.remove();
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
return doc.body.innerHTML;
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
// eslint-disable-next-line no-console
|
|
236
|
+
console.error('Error cleaning line breaks:', error);
|
|
237
|
+
return html;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Swaps the structure when a dynamic tag contains only a single link.
|
|
242
|
+
* Changes from: <span data-dynamic><a>text</a></span>
|
|
243
|
+
* To: <a><span data-dynamic>text</span></a>
|
|
244
|
+
*
|
|
245
|
+
* @param html - HTML string to process
|
|
246
|
+
* @returns Processed HTML string with swapped structure
|
|
247
|
+
*/
|
|
248
|
+
function swapDynamicTagWithLink(html) {
|
|
249
|
+
try {
|
|
250
|
+
const parser = new DOMParser();
|
|
251
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
252
|
+
// Find all dynamic tag spans
|
|
253
|
+
const dynamicSpans = doc.querySelectorAll('span[data-dynamic="true"]');
|
|
254
|
+
dynamicSpans.forEach(dynamicSpan => {
|
|
255
|
+
// Get all child nodes (elements and text nodes)
|
|
256
|
+
const childNodes = Array.from(dynamicSpan.childNodes);
|
|
257
|
+
// Filter out empty text nodes (whitespace only)
|
|
258
|
+
const nonEmptyNodes = childNodes.filter(node => {
|
|
259
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
260
|
+
return node.textContent?.trim() !== '';
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
263
|
+
});
|
|
264
|
+
// Check if there's exactly one child and it's an <a> element
|
|
265
|
+
if (nonEmptyNodes.length === 1 && nonEmptyNodes[0].nodeType === Node.ELEMENT_NODE) {
|
|
266
|
+
const childElement = nonEmptyNodes[0];
|
|
267
|
+
if (childElement instanceof HTMLElement && childElement.tagName.toLowerCase() === 'a') {
|
|
268
|
+
const linkElement = childElement;
|
|
269
|
+
// Create new span with dynamic attributes
|
|
270
|
+
const newSpan = doc.createElement('span');
|
|
271
|
+
// Copy all attributes from original dynamic span
|
|
272
|
+
Array.from(dynamicSpan.attributes).forEach(attr => {
|
|
273
|
+
newSpan.setAttribute(attr.name, attr.value);
|
|
274
|
+
});
|
|
275
|
+
// Set the text content from the link
|
|
276
|
+
newSpan.textContent = linkElement.textContent;
|
|
277
|
+
// Create new link element
|
|
278
|
+
const newLink = doc.createElement('a');
|
|
279
|
+
// Copy all attributes from original link
|
|
280
|
+
Array.from(linkElement.attributes).forEach(attr => {
|
|
281
|
+
newLink.setAttribute(attr.name, attr.value);
|
|
282
|
+
});
|
|
283
|
+
// Put span inside link
|
|
284
|
+
newLink.appendChild(newSpan);
|
|
285
|
+
// Replace original dynamic span with the new link
|
|
286
|
+
dynamicSpan.replaceWith(newLink);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
return doc.body.innerHTML;
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
// eslint-disable-next-line no-console
|
|
294
|
+
console.error('Error swapping dynamic tag with link:', error);
|
|
295
|
+
return html; // Return original HTML in case of error
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Safely parses and processes HTML content for editor use
|
|
300
|
+
* @param html - HTML string to process
|
|
301
|
+
* @param wrapperElement - Optional wrapper element to use instead of document.body for temporary DOM operations
|
|
302
|
+
* @returns Processed HTML string
|
|
303
|
+
*/
|
|
304
|
+
export function safeParseHTMLContent(params) {
|
|
305
|
+
const { html, wrapperElement, defaultStyle } = params;
|
|
306
|
+
let resultHTML = html;
|
|
307
|
+
resultHTML = cleanLineBreaks(resultHTML);
|
|
308
|
+
const isFroala = html.includes('fr-box') || html.includes('fr-tag');
|
|
309
|
+
if (isFroala) {
|
|
310
|
+
resultHTML = inheritStyleToComputedStyle({
|
|
311
|
+
html,
|
|
312
|
+
wrapperElement,
|
|
313
|
+
defaultStyle,
|
|
314
|
+
});
|
|
315
|
+
resultHTML = restructureDynamicTagsWithOptions({
|
|
316
|
+
html: resultHTML,
|
|
317
|
+
wrapperElement,
|
|
318
|
+
defaultStyle,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
// Swap dynamic tag structure when it contains only a link
|
|
322
|
+
resultHTML = swapDynamicTagWithLink(resultHTML);
|
|
323
|
+
// console.log('after safeParseHTMLContent', resultHTML);
|
|
324
|
+
return resultHTML;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Sanitizes HTML by removing potentially dangerous elements and attributes
|
|
328
|
+
* @param html - HTML string to sanitize
|
|
329
|
+
* @returns Sanitized HTML string
|
|
330
|
+
*/
|
|
331
|
+
export function sanitizeHTML(html) {
|
|
332
|
+
const parser = new DOMParser();
|
|
333
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
334
|
+
// Remove script tags
|
|
335
|
+
const scripts = doc.querySelectorAll('script');
|
|
336
|
+
scripts.forEach(script => script.remove());
|
|
337
|
+
// Remove on* event attributes
|
|
338
|
+
const allElements = doc.querySelectorAll('*');
|
|
339
|
+
allElements.forEach(element => {
|
|
340
|
+
Array.from(element.attributes).forEach(attr => {
|
|
341
|
+
if (attr.name.startsWith('on')) {
|
|
342
|
+
element.removeAttribute(attr.name);
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
return doc.body.innerHTML;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Extracts text content from HTML
|
|
350
|
+
* @param html - HTML string
|
|
351
|
+
* @returns Plain text content
|
|
352
|
+
*/
|
|
353
|
+
export function extractTextFromHTML(html) {
|
|
354
|
+
const parser = new DOMParser();
|
|
355
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
356
|
+
return doc.body.textContent || '';
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Counts words in HTML content
|
|
360
|
+
* @param html - HTML string
|
|
361
|
+
* @returns Word count
|
|
362
|
+
*/
|
|
363
|
+
export function countWordsInHTML(html) {
|
|
364
|
+
const text = extractTextFromHTML(html);
|
|
365
|
+
return text
|
|
366
|
+
.trim()
|
|
367
|
+
.split(/\s+/)
|
|
368
|
+
.filter(word => word.length > 0).length;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Counts characters in HTML content
|
|
372
|
+
* @param html - HTML string
|
|
373
|
+
* @param includeSpaces - Whether to include spaces in count
|
|
374
|
+
* @returns Character count
|
|
375
|
+
*/
|
|
376
|
+
export function countCharactersInHTML(html, includeSpaces = true) {
|
|
377
|
+
const text = extractTextFromHTML(html);
|
|
378
|
+
return includeSpaces ? text.length : text.replace(/\s/g, '').length;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Wraps text nodes with specified tag
|
|
382
|
+
* @param html - HTML string
|
|
383
|
+
* @param tagName - Tag name to wrap with
|
|
384
|
+
* @param className - Optional class name for wrapper
|
|
385
|
+
* @returns HTML with wrapped text nodes
|
|
386
|
+
*/
|
|
387
|
+
export function wrapTextNodes(html, tagName = 'span', className) {
|
|
388
|
+
const parser = new DOMParser();
|
|
389
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
390
|
+
function wrapTextNodesRecursive(node) {
|
|
391
|
+
if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {
|
|
392
|
+
const wrapper = doc.createElement(tagName);
|
|
393
|
+
if (className) {
|
|
394
|
+
wrapper.className = className;
|
|
395
|
+
}
|
|
396
|
+
wrapper.textContent = node.textContent;
|
|
397
|
+
node.parentNode?.replaceChild(wrapper, node);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
Array.from(node.childNodes).forEach(wrapTextNodesRecursive);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
wrapTextNodesRecursive(doc.body);
|
|
404
|
+
return doc.body.innerHTML;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Removes empty elements from HTML
|
|
408
|
+
* @param html - HTML string
|
|
409
|
+
* @returns HTML with empty elements removed
|
|
410
|
+
*/
|
|
411
|
+
export function removeEmptyElements(html) {
|
|
412
|
+
const parser = new DOMParser();
|
|
413
|
+
const doc = parser.parseFromString(html, 'text/html');
|
|
414
|
+
function removeEmptyRecursive(node) {
|
|
415
|
+
Array.from(node.children).forEach(child => {
|
|
416
|
+
removeEmptyRecursive(child);
|
|
417
|
+
if (!child.textContent?.trim() && child.children.length === 0) {
|
|
418
|
+
child.remove();
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
removeEmptyRecursive(doc.body);
|
|
423
|
+
return doc.body.innerHTML;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Normalizes whitespace in HTML
|
|
427
|
+
* @param html - HTML string
|
|
428
|
+
* @returns HTML with normalized whitespace
|
|
429
|
+
*/
|
|
430
|
+
export function normalizeWhitespace(html) {
|
|
431
|
+
return html.replace(/\s+/g, ' ').replace(/>\s+</g, '><').trim();
|
|
432
|
+
}
|
|
433
|
+
export const htmlMinifyForEmail = (htmlEditorContent) => {
|
|
434
|
+
const parser = new DOMParser();
|
|
435
|
+
const doc = parser.parseFromString(htmlEditorContent, 'text/html');
|
|
436
|
+
const allElements = doc.body.querySelectorAll('*');
|
|
437
|
+
allElements.forEach(element => {
|
|
438
|
+
element.removeAttribute('spellcheck');
|
|
439
|
+
element.removeAttribute('class');
|
|
440
|
+
element.removeAttribute('contenteditable');
|
|
441
|
+
});
|
|
442
|
+
return doc.body.innerHTML;
|
|
443
|
+
};
|
|
444
|
+
/**
|
|
445
|
+
* Serializes HTML for output
|
|
446
|
+
* @param htmlEditorContent - HTML string to serialize
|
|
447
|
+
* @returns Serialized HTML string
|
|
448
|
+
*/
|
|
449
|
+
export const htmlSerializerForOutput = (htmlEditorContent) => {
|
|
450
|
+
const parser = new DOMParser();
|
|
451
|
+
const doc = parser.parseFromString(htmlEditorContent, 'text/html');
|
|
452
|
+
const paragraphs = doc.body.querySelectorAll('p');
|
|
453
|
+
paragraphs.forEach(paragraph => {
|
|
454
|
+
if (paragraph.innerHTML?.trim() === '') {
|
|
455
|
+
const br = doc.createElement('br');
|
|
456
|
+
paragraph.appendChild(br);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
return doc.body.innerHTML;
|
|
460
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { isList } from '@tiptap/core';
|
|
2
|
+
import { TextSelection, AllSelection } from '@tiptap/pm/state';
|
|
3
|
+
import { clamp } from './shared';
|
|
4
|
+
function setNodeIndentMarkup(tr, pos, delta) {
|
|
5
|
+
if (!tr.doc)
|
|
6
|
+
return tr;
|
|
7
|
+
const node = tr.doc.nodeAt(pos);
|
|
8
|
+
if (!node)
|
|
9
|
+
return tr;
|
|
10
|
+
const minIndent = 0 /* IndentProps.min */;
|
|
11
|
+
const maxIndent = 7 /* IndentProps.max */;
|
|
12
|
+
const indent = clamp((node.attrs.indent || 0) + delta, minIndent, maxIndent);
|
|
13
|
+
if (indent === node.attrs.indent)
|
|
14
|
+
return tr;
|
|
15
|
+
const nodeAttrs = {
|
|
16
|
+
...node.attrs,
|
|
17
|
+
indent,
|
|
18
|
+
};
|
|
19
|
+
return tr.setNodeMarkup(pos, node.type, nodeAttrs, node.marks);
|
|
20
|
+
}
|
|
21
|
+
function updateIndentLevel(tr, delta, types, editor) {
|
|
22
|
+
const { doc, selection } = tr;
|
|
23
|
+
if (!doc || !selection)
|
|
24
|
+
return tr;
|
|
25
|
+
if (!(selection instanceof TextSelection || selection instanceof AllSelection)) {
|
|
26
|
+
return tr;
|
|
27
|
+
}
|
|
28
|
+
const { from, to } = selection;
|
|
29
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
30
|
+
const nodeType = node.type;
|
|
31
|
+
if (types.includes(nodeType.name)) {
|
|
32
|
+
tr = setNodeIndentMarkup(tr, pos, delta);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (isList(node.type.name, editor.extensionManager.extensions)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
});
|
|
40
|
+
return tr;
|
|
41
|
+
}
|
|
42
|
+
export function createIndentCommand({ delta, types }) {
|
|
43
|
+
return ({ state, dispatch, editor }) => {
|
|
44
|
+
const { selection } = state;
|
|
45
|
+
let { tr } = state;
|
|
46
|
+
tr = tr.setSelection(selection);
|
|
47
|
+
tr = updateIndentLevel(tr, delta, types, editor);
|
|
48
|
+
if (tr.docChanged) {
|
|
49
|
+
if (dispatch) {
|
|
50
|
+
dispatch(tr);
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Selection utilities
|
|
2
|
+
export * from './selection';
|
|
3
|
+
// Link utilities
|
|
4
|
+
export * from './link';
|
|
5
|
+
// Smart tag utilities
|
|
6
|
+
export * from './smartTag';
|
|
7
|
+
// Style utilities
|
|
8
|
+
export * from './style';
|
|
9
|
+
// Font utilities
|
|
10
|
+
export * from './font';
|
|
11
|
+
// HTML processing utilities
|
|
12
|
+
export * from './htmlProcessing';
|
|
13
|
+
// Menu utilities
|
|
14
|
+
export * from './menu';
|
|
15
|
+
// Document state utilities
|
|
16
|
+
export * from './documentState';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { EditorState } from '@tiptap/pm/state';
|
|
2
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
3
|
+
import { LinkHandler, LinkMark, LinkMarkRange } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Kiểm tra xem cursor có đang nằm trong một đoạn text có mark là link hay không
|
|
6
|
+
* @param state EditorState của Tiptap/ProseMirror
|
|
7
|
+
* @returns true nếu cursor đang nằm trong link, false nếu không
|
|
8
|
+
*/
|
|
9
|
+
export declare const isCursorInLink: (state: EditorState) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Gets all link mark ranges within a specified range
|
|
12
|
+
* @param params Object containing state, from and to positions
|
|
13
|
+
* @returns Array of MarkRange objects for links
|
|
14
|
+
*/
|
|
15
|
+
export declare const getLinkMarkRanges: (params: {
|
|
16
|
+
state: EditorState;
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
}) => LinkMarkRange[];
|
|
20
|
+
/**
|
|
21
|
+
* Gets the range of a link mark at a specific position
|
|
22
|
+
* @param params Object containing state and optional position
|
|
23
|
+
* @returns Link mark range or undefined
|
|
24
|
+
*/
|
|
25
|
+
export declare const getLinkRange: (params: {
|
|
26
|
+
state: EditorState;
|
|
27
|
+
pos?: number;
|
|
28
|
+
}) => void | import("@tiptap/core").Range;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the first link mark in a range
|
|
31
|
+
* @param params Object containing state, optional from and to positions
|
|
32
|
+
* @returns Link mark or undefined
|
|
33
|
+
*/
|
|
34
|
+
export declare const getLinkMark: (params: {
|
|
35
|
+
state: EditorState;
|
|
36
|
+
from?: number;
|
|
37
|
+
to?: number;
|
|
38
|
+
}) => {
|
|
39
|
+
readonly type: import("prosemirror-model").MarkType;
|
|
40
|
+
addToSet: (set: readonly import("prosemirror-model").Mark[]) => readonly import("prosemirror-model").Mark[];
|
|
41
|
+
removeFromSet: (set: readonly import("prosemirror-model").Mark[]) => readonly import("prosemirror-model").Mark[];
|
|
42
|
+
isInSet: (set: readonly import("prosemirror-model").Mark[]) => boolean;
|
|
43
|
+
eq: (other: import("prosemirror-model").Mark) => boolean;
|
|
44
|
+
toJSON: () => any;
|
|
45
|
+
attrs: import("../types").LinkAttrs;
|
|
46
|
+
} | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Gets all link marks in a range
|
|
49
|
+
* @param params Object containing state, from and to positions
|
|
50
|
+
* @returns Array of link marks
|
|
51
|
+
*/
|
|
52
|
+
export declare const getLinkMarks: (params: {
|
|
53
|
+
state: EditorState;
|
|
54
|
+
from: number;
|
|
55
|
+
to: number;
|
|
56
|
+
}) => LinkMark[];
|
|
57
|
+
/**
|
|
58
|
+
* Gets all link attrs from a range
|
|
59
|
+
* @param params Object containing state, optional from and to positions
|
|
60
|
+
* @returns Array of link attrs
|
|
61
|
+
*/
|
|
62
|
+
export declare const getLinkAttrsFromRange: (params: {
|
|
63
|
+
state: EditorState;
|
|
64
|
+
from?: number;
|
|
65
|
+
to?: number;
|
|
66
|
+
}) => import("../types").LinkAttrs[];
|
|
67
|
+
/**
|
|
68
|
+
* Gets the active link attrs and inactive links from a range
|
|
69
|
+
* @param params Object containing state, optional from and to positions
|
|
70
|
+
* @returns Object with active link Attrs and inactiveLink Attrs or undefined
|
|
71
|
+
*/
|
|
72
|
+
export declare const getActiveLinkAttrsFromRange: (params: {
|
|
73
|
+
state: EditorState;
|
|
74
|
+
from?: number;
|
|
75
|
+
to?: number;
|
|
76
|
+
}) => {
|
|
77
|
+
readonly activeAttrs: import("../types").LinkAttrs;
|
|
78
|
+
readonly inactiveLinks: import("../types").LinkAttrs[];
|
|
79
|
+
} | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Extends selection to include full link marks and adjacent links with same href
|
|
82
|
+
* @param state EditorState
|
|
83
|
+
* @param from Start position
|
|
84
|
+
* @param to End position
|
|
85
|
+
* @returns Object with extended from, to positions and link attrs
|
|
86
|
+
*/
|
|
87
|
+
export declare const extendSelectionToFullLinks: (state: EditorState, from: number, to: number) => {
|
|
88
|
+
from: number;
|
|
89
|
+
to: number;
|
|
90
|
+
linkAttrs?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
from: number;
|
|
93
|
+
to: number;
|
|
94
|
+
linkAttrs: import("../types").LinkAttrs;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Gets all full link groups in the document (adjacent links with same href are grouped)
|
|
98
|
+
* @param state EditorState
|
|
99
|
+
* @returns Array of link groups with attrs and content
|
|
100
|
+
*/
|
|
101
|
+
export declare const getAllFullLinkGroups: (state: EditorState) => {
|
|
102
|
+
attrs: LinkMarkRange['mark']['attrs'];
|
|
103
|
+
content: string;
|
|
104
|
+
}[];
|
|
105
|
+
/**
|
|
106
|
+
* Handles link actions (create or edit)
|
|
107
|
+
* @param view EditorView instance
|
|
108
|
+
* @param linkHandler Link handler callbacks
|
|
109
|
+
*/
|
|
110
|
+
export declare function handleLinkAction(view: EditorView, linkHandler: LinkHandler | undefined): void;
|
|
111
|
+
/**
|
|
112
|
+
* Checks if the link menu should be shown
|
|
113
|
+
* @param state EditorState
|
|
114
|
+
* @returns true if link menu should be shown
|
|
115
|
+
*/
|
|
116
|
+
export declare const isShowLinkToolbar: (state: EditorState) => boolean;
|