@antscorp/antsomi-ui 2.0.92-text-editor-beta.6 → 2.0.93
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 -4
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -18
- package/es/components/icons/LazyIcon/LazyIcon.js +9 -18
- package/es/components/icons/index.d.ts +9 -18
- package/es/components/icons/index.js +9 -18
- package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
- package/es/components/molecules/EmojiCollections/types.d.ts +0 -1
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +0 -1
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +6 -10
- package/es/components/molecules/EmojiPopover/styled.d.ts +2 -2
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/TagifyInput/patternHandlers.js +12 -0
- package/es/components/molecules/TagifyInput/utils.d.ts +1 -0
- package/es/components/molecules/TagifyInput/utils.js +1 -0
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
- package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +11 -1
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
- package/es/components/molecules/VirtualizedMenu/styled.d.ts +2 -2
- package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
- package/es/components/molecules/VirtualizedMenu/types.d.ts +10 -27
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
- package/es/components/molecules/index.d.ts +0 -1
- package/es/components/molecules/index.js +0 -1
- package/es/components/organism/index.d.ts +0 -1
- package/es/components/organism/index.js +0 -1
- package/es/constants/api.js +3 -3
- package/es/hooks/index.d.ts +0 -4
- package/es/hooks/index.js +0 -4
- package/es/locales/i18n.d.ts +1 -1
- package/es/utils/common.d.ts +9 -14
- package/es/utils/common.js +23 -60
- package/es/utils/index.d.ts +0 -1
- package/es/utils/index.js +0 -1
- package/es/utils/web.d.ts +0 -15
- package/es/utils/web.js +0 -39
- package/package.json +4 -22
- package/es/components/atoms/Eyedropper/Eyedropper.d.ts +0 -2
- package/es/components/atoms/Eyedropper/Eyedropper.js +0 -53
- package/es/components/atoms/Eyedropper/index.d.ts +0 -0
- package/es/components/atoms/Eyedropper/index.js +0 -1
- package/es/components/atoms/Eyedropper/styled.d.ts +0 -9
- package/es/components/atoms/Eyedropper/styled.js +0 -45
- package/es/components/atoms/Eyedropper/types.d.ts +0 -5
- package/es/components/atoms/Eyedropper/types.js +0 -1
- package/es/components/icons/ALignRightIcon.d.ts +0 -3
- package/es/components/icons/ALignRightIcon.js +0 -7
- package/es/components/icons/AlignCenterIcon.d.ts +0 -3
- package/es/components/icons/AlignCenterIcon.js +0 -7
- package/es/components/icons/AlignJustifyIcon.d.ts +0 -3
- package/es/components/icons/AlignJustifyIcon.js +0 -7
- package/es/components/icons/AlignLeftIcon.d.ts +0 -3
- package/es/components/icons/AlignLeftIcon.js +0 -7
- package/es/components/icons/ArrowDropDownIcon.d.ts +0 -3
- package/es/components/icons/ArrowDropDownIcon.js +0 -7
- package/es/components/icons/ChevronRightIcon.d.ts +0 -3
- package/es/components/icons/ChevronRightIcon.js +0 -7
- package/es/components/icons/ColorizeIcon.d.ts +0 -3
- package/es/components/icons/ColorizeIcon.js +0 -7
- package/es/components/icons/LinkOffIcon.d.ts +0 -3
- package/es/components/icons/LinkOffIcon.js +0 -7
- package/es/components/icons/MinusIcon.d.ts +0 -3
- package/es/components/icons/MinusIcon.js +0 -7
- package/es/components/index.scss +0 -2
- package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +0 -11
- package/es/components/molecules/EyedropperButton/EyedropperButton.js +0 -34
- package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
- package/es/components/molecules/EyedropperButton/index.js +0 -1
- package/es/components/molecules/EyedropperButton/styled.d.ts +0 -7
- package/es/components/molecules/EyedropperButton/styled.js +0 -23
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -134
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -21
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -19
- package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/constants.js +0 -5
- package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/index.js +0 -1
- package/es/components/molecules/FontSizeInput/styled.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/styled.js +0 -40
- package/es/components/molecules/FontSizeInput/styles.scss +0 -15
- package/es/components/molecules/FontSizeInput/types.d.ts +0 -23
- package/es/components/molecules/FontSizeInput/types.js +0 -1
- package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/utils.js +0 -9
- package/es/components/molecules/index.scss +0 -1
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
- package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
- package/es/components/organism/TextEditor/TextEditor.js +0 -264
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
- package/es/components/organism/TextEditor/constants.d.ts +0 -177
- package/es/components/organism/TextEditor/constants.js +0 -323
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -140
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -366
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
- package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +0 -16
- package/es/components/organism/TextEditor/extensions/ClearFormatting.js +0 -26
- package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Color.js +0 -34
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
- package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -36
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -31
- package/es/components/organism/TextEditor/extensions/FontSize.js +0 -46
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
- package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -21
- package/es/components/organism/TextEditor/extensions/Indent.js +0 -63
- package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +0 -32
- package/es/components/organism/TextEditor/extensions/LetterSpacing.js +0 -48
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
- package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
- package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -29
- package/es/components/organism/TextEditor/extensions/Link.js +0 -187
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
- package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +0 -56
- package/es/components/organism/TextEditor/extensions/OrderedList.js +0 -187
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
- package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -30
- package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -36
- package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +0 -55
- package/es/components/organism/TextEditor/extensions/UnorderedList.js +0 -176
- package/es/components/organism/TextEditor/hooks/index.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/index.js +0 -6
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +0 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.js +0 -22
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
- package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
- package/es/components/organism/TextEditor/index.d.ts +0 -16
- package/es/components/organism/TextEditor/index.js +0 -8
- package/es/components/organism/TextEditor/index.scss +0 -61
- package/es/components/organism/TextEditor/provider.d.ts +0 -14
- package/es/components/organism/TextEditor/provider.js +0 -33
- package/es/components/organism/TextEditor/store.d.ts +0 -13
- package/es/components/organism/TextEditor/store.js +0 -20
- package/es/components/organism/TextEditor/styled.d.ts +0 -10
- package/es/components/organism/TextEditor/styled.js +0 -94
- package/es/components/organism/TextEditor/types.d.ts +0 -139
- package/es/components/organism/TextEditor/types.js +0 -5
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -84
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Button/Button.js +0 -31
- package/es/components/organism/TextEditor/ui/Button/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Button/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Button/types.d.ts +0 -10
- package/es/components/organism/TextEditor/ui/Button/types.js +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -39
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -131
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +0 -17
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +0 -51
- package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/DropdownButton/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -22
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -9
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +0 -44
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +0 -1
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +0 -52
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +0 -19
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -77
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -16
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -93
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -31
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -28
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -44
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +0 -21
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -17
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +0 -28
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -17
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -67
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -17
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -10
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -45
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -26
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -26
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -29
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -22
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -36
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -19
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -24
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -24
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
- package/es/components/organism/TextEditor/utils/documentState.js +0 -100
- package/es/components/organism/TextEditor/utils/font.d.ts +0 -73
- package/es/components/organism/TextEditor/utils/font.js +0 -160
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -75
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -343
- package/es/components/organism/TextEditor/utils/indent.d.ts +0 -11
- package/es/components/organism/TextEditor/utils/indent.js +0 -56
- package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
- package/es/components/organism/TextEditor/utils/index.js +0 -16
- package/es/components/organism/TextEditor/utils/link.d.ts +0 -108
- package/es/components/organism/TextEditor/utils/link.js +0 -151
- package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
- package/es/components/organism/TextEditor/utils/menu.js +0 -317
- package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
- package/es/components/organism/TextEditor/utils/selection.js +0 -57
- package/es/components/organism/TextEditor/utils/shared.d.ts +0 -1
- package/es/components/organism/TextEditor/utils/shared.js +0 -9
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
- package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
- package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
- package/es/components/organism/TextEditor/utils/style.js +0 -193
- package/es/components/organism/index.scss +0 -1
- package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
- package/es/hooks/useBroadcastedLocalStorage.js +0 -71
- package/es/hooks/useElementSize.d.ts +0 -7
- package/es/hooks/useElementSize.js +0 -56
- package/es/hooks/useEyedropper/attach.d.ts +0 -4
- package/es/hooks/useEyedropper/attach.js +0 -9
- package/es/hooks/useEyedropper/eyedropper.d.ts +0 -69
- package/es/hooks/useEyedropper/eyedropper.js +0 -205
- package/es/hooks/useEyedropper/index.d.ts +0 -2
- package/es/hooks/useEyedropper/index.js +0 -7
- package/es/hooks/useEyedropper/support.d.ts +0 -1
- package/es/hooks/useEyedropper/support.js +0 -3
- package/es/hooks/useEyedropper/types.d.ts +0 -9
- package/es/hooks/useEyedropper/types.js +0 -1
- package/es/hooks/useEyedropper/useEyedropper.d.ts +0 -8
- package/es/hooks/useEyedropper/useEyedropper.js +0 -50
- package/es/hooks/useEyedropper/utils.d.ts +0 -11
- package/es/hooks/useEyedropper/utils.js +0 -17
- package/es/hooks/useIsMounted.d.ts +0 -1
- package/es/hooks/useIsMounted.js +0 -11
- package/es/utils/tree.d.ts +0 -225
- package/es/utils/tree.js +0 -469
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the appropriate bold font weight for a given font family
|
|
3
|
-
* @param currentFontFamily The font family to find bold weight for
|
|
4
|
-
* @param fonts Array of available font configurations
|
|
5
|
-
* @param minBoldWeight Minimum weight considered bold (default 700)
|
|
6
|
-
* @returns The first available bold weight for the font family, or minBoldWeight if none found
|
|
7
|
-
*/
|
|
8
|
-
export const getBoldFontWeight = (currentFontFamily, fonts, minBoldWeight = 700) => {
|
|
9
|
-
if (!currentFontFamily || !fonts?.length)
|
|
10
|
-
return minBoldWeight;
|
|
11
|
-
const fontConfig = fonts.find(font => font.fontFamily.name === currentFontFamily);
|
|
12
|
-
return fontConfig?.fontWeight.find(weight => weight >= minBoldWeight) ?? minBoldWeight;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Validates if a font family name is a generic CSS font
|
|
16
|
-
* @param fontFamily Font family name to check
|
|
17
|
-
* @returns true if it's a generic font family
|
|
18
|
-
*/
|
|
19
|
-
export function isGenericFontFamily(fontFamily) {
|
|
20
|
-
const genericFamilies = new Set([
|
|
21
|
-
'serif',
|
|
22
|
-
'sans-serif',
|
|
23
|
-
'monospace',
|
|
24
|
-
'cursive',
|
|
25
|
-
'fantasy',
|
|
26
|
-
'system-ui',
|
|
27
|
-
'ui-serif',
|
|
28
|
-
'ui-sans-serif',
|
|
29
|
-
'ui-monospace',
|
|
30
|
-
'ui-rounded',
|
|
31
|
-
'math',
|
|
32
|
-
'emoji',
|
|
33
|
-
'fangsong',
|
|
34
|
-
]);
|
|
35
|
-
return genericFamilies.has(fontFamily.toLowerCase().trim());
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Extracts the primary font from a font-family string
|
|
39
|
-
* @param fontFamily Font family string (may contain fallbacks)
|
|
40
|
-
* @returns Primary font name
|
|
41
|
-
*/
|
|
42
|
-
export function getPrimaryFontFamily(fontFamily) {
|
|
43
|
-
if (!fontFamily)
|
|
44
|
-
return '';
|
|
45
|
-
const fonts = fontFamily.split(',');
|
|
46
|
-
const primaryFont = fonts[0].trim();
|
|
47
|
-
// Remove quotes if present
|
|
48
|
-
return primaryFont.replace(/^["']|["']$/g, '');
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Checks if a font weight is considered bold
|
|
52
|
-
* @param weight Font weight to check
|
|
53
|
-
* @param threshold Bold threshold (default 600)
|
|
54
|
-
* @returns true if weight is bold
|
|
55
|
-
*/
|
|
56
|
-
export function isBoldWeight(weight, threshold = 600) {
|
|
57
|
-
const numericWeight = typeof weight === 'string' ? parseInt(weight, 10) : weight;
|
|
58
|
-
return !isNaN(numericWeight) && numericWeight >= threshold;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Gets all available font weights for a font family
|
|
62
|
-
* @param fontFamily Font family name
|
|
63
|
-
* @param fonts Array of font configurations
|
|
64
|
-
* @returns Array of available weights
|
|
65
|
-
*/
|
|
66
|
-
export function getFontWeights(fontFamily, fonts) {
|
|
67
|
-
const fontConfig = fonts.find(font => font.fontFamily.name === fontFamily);
|
|
68
|
-
return fontConfig?.fontWeight || [400];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Finds the closest available font weight
|
|
72
|
-
* @param targetWeight Desired font weight
|
|
73
|
-
* @param availableWeights Array of available weights
|
|
74
|
-
* @returns Closest available weight
|
|
75
|
-
*/
|
|
76
|
-
export function getClosestFontWeight(targetWeight, availableWeights) {
|
|
77
|
-
if (availableWeights.includes(targetWeight)) {
|
|
78
|
-
return targetWeight;
|
|
79
|
-
}
|
|
80
|
-
return availableWeights.reduce((closest, weight) => Math.abs(weight - targetWeight) < Math.abs(closest - targetWeight) ? weight : closest);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Validates font configuration
|
|
84
|
-
* @param fontConfig Font configuration to validate
|
|
85
|
-
* @returns true if configuration is valid
|
|
86
|
-
*/
|
|
87
|
-
export function isValidFontConfig(fontConfig) {
|
|
88
|
-
return !!(fontConfig.fontFamily?.name &&
|
|
89
|
-
fontConfig.fontWeight &&
|
|
90
|
-
Array.isArray(fontConfig.fontWeight) &&
|
|
91
|
-
fontConfig.fontWeight.length > 0 &&
|
|
92
|
-
fontConfig.fontWeight.every(weight => typeof weight === 'number' && weight > 0));
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Sorts font configurations alphabetically by name
|
|
96
|
-
* @param fonts Array of font configurations
|
|
97
|
-
* @returns Sorted array of font configurations
|
|
98
|
-
*/
|
|
99
|
-
export function sortFontsByName(fonts) {
|
|
100
|
-
return [...fonts].sort((a, b) => a.fontFamily.name.localeCompare(b.fontFamily.name));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Groups fonts by category (if category property exists)
|
|
104
|
-
* @param fonts Array of font configurations
|
|
105
|
-
* @returns Object with fonts grouped by category
|
|
106
|
-
*/
|
|
107
|
-
export function groupFontsByCategory(fonts) {
|
|
108
|
-
const grouped = {};
|
|
109
|
-
fonts.forEach(font => {
|
|
110
|
-
const category = font.category || 'Other';
|
|
111
|
-
if (!grouped[category]) {
|
|
112
|
-
grouped[category] = [];
|
|
113
|
-
}
|
|
114
|
-
grouped[category].push(font);
|
|
115
|
-
});
|
|
116
|
-
return grouped;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Checks if a font is web safe
|
|
120
|
-
* @param fontFamily Font family name
|
|
121
|
-
* @returns true if font is web safe
|
|
122
|
-
*/
|
|
123
|
-
export function isWebSafeFont(fontFamily) {
|
|
124
|
-
const webSafeFonts = new Set([
|
|
125
|
-
'arial',
|
|
126
|
-
'helvetica',
|
|
127
|
-
'times new roman',
|
|
128
|
-
'times',
|
|
129
|
-
'courier new',
|
|
130
|
-
'courier',
|
|
131
|
-
'verdana',
|
|
132
|
-
'georgia',
|
|
133
|
-
'palatino',
|
|
134
|
-
'garamond',
|
|
135
|
-
'bookman',
|
|
136
|
-
'comic sans ms',
|
|
137
|
-
'trebuchet ms',
|
|
138
|
-
'arial black',
|
|
139
|
-
'impact',
|
|
140
|
-
'lucida sans unicode',
|
|
141
|
-
'tahoma',
|
|
142
|
-
'lucida console',
|
|
143
|
-
]);
|
|
144
|
-
return webSafeFonts.has(fontFamily.toLowerCase().trim());
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Creates a font stack with appropriate fallbacks
|
|
148
|
-
* @param primaryFont Primary font family
|
|
149
|
-
* @param category Font category for fallback selection
|
|
150
|
-
* @returns Complete font stack string
|
|
151
|
-
*/
|
|
152
|
-
export function createFontStack(primaryFont, category = 'sans-serif') {
|
|
153
|
-
const fallbacks = {
|
|
154
|
-
serif: ['Georgia', 'Times New Roman', 'Times', 'serif'],
|
|
155
|
-
'sans-serif': ['Arial', 'Helvetica', 'sans-serif'],
|
|
156
|
-
monospace: ['Courier New', 'Courier', 'monospace'],
|
|
157
|
-
};
|
|
158
|
-
const stack = [primaryFont, ...fallbacks[category]];
|
|
159
|
-
return stack.join(', ');
|
|
160
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { TextStyle } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Restructures dynamic tags from Froala editor format to be compatible with Tiptap editor.
|
|
4
|
-
* This function preserves styling and attributes of dynamic tags while cleaning up their structure.
|
|
5
|
-
*
|
|
6
|
-
* @param html - The HTML string containing dynamic tags
|
|
7
|
-
* @param options - Configuration options for the restructuring process
|
|
8
|
-
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
9
|
-
* @returns The restructured HTML string
|
|
10
|
-
*/
|
|
11
|
-
export declare function restructureDynamicTagsWithOptions(params: {
|
|
12
|
-
html: string;
|
|
13
|
-
options?: {
|
|
14
|
-
attributesToClone: string[];
|
|
15
|
-
};
|
|
16
|
-
defaultStyle: TextStyle;
|
|
17
|
-
wrapperElement?: Element;
|
|
18
|
-
}): string;
|
|
19
|
-
/**
|
|
20
|
-
* Safely parses and processes HTML content for editor use
|
|
21
|
-
* @param html - HTML string to process
|
|
22
|
-
* @param wrapperElement - Optional wrapper element to use instead of document.body for temporary DOM operations
|
|
23
|
-
* @returns Processed HTML string
|
|
24
|
-
*/
|
|
25
|
-
export declare function safeParseHTMLContent(params: {
|
|
26
|
-
html: string;
|
|
27
|
-
wrapperElement?: Element;
|
|
28
|
-
defaultStyle: TextStyle;
|
|
29
|
-
}): string;
|
|
30
|
-
/**
|
|
31
|
-
* Sanitizes HTML by removing potentially dangerous elements and attributes
|
|
32
|
-
* @param html - HTML string to sanitize
|
|
33
|
-
* @returns Sanitized HTML string
|
|
34
|
-
*/
|
|
35
|
-
export declare function sanitizeHTML(html: string): string;
|
|
36
|
-
/**
|
|
37
|
-
* Extracts text content from HTML
|
|
38
|
-
* @param html - HTML string
|
|
39
|
-
* @returns Plain text content
|
|
40
|
-
*/
|
|
41
|
-
export declare function extractTextFromHTML(html: string): string;
|
|
42
|
-
/**
|
|
43
|
-
* Counts words in HTML content
|
|
44
|
-
* @param html - HTML string
|
|
45
|
-
* @returns Word count
|
|
46
|
-
*/
|
|
47
|
-
export declare function countWordsInHTML(html: string): number;
|
|
48
|
-
/**
|
|
49
|
-
* Counts characters in HTML content
|
|
50
|
-
* @param html - HTML string
|
|
51
|
-
* @param includeSpaces - Whether to include spaces in count
|
|
52
|
-
* @returns Character count
|
|
53
|
-
*/
|
|
54
|
-
export declare function countCharactersInHTML(html: string, includeSpaces?: boolean): number;
|
|
55
|
-
/**
|
|
56
|
-
* Wraps text nodes with specified tag
|
|
57
|
-
* @param html - HTML string
|
|
58
|
-
* @param tagName - Tag name to wrap with
|
|
59
|
-
* @param className - Optional class name for wrapper
|
|
60
|
-
* @returns HTML with wrapped text nodes
|
|
61
|
-
*/
|
|
62
|
-
export declare function wrapTextNodes(html: string, tagName?: string, className?: string): string;
|
|
63
|
-
/**
|
|
64
|
-
* Removes empty elements from HTML
|
|
65
|
-
* @param html - HTML string
|
|
66
|
-
* @returns HTML with empty elements removed
|
|
67
|
-
*/
|
|
68
|
-
export declare function removeEmptyElements(html: string): string;
|
|
69
|
-
/**
|
|
70
|
-
* Normalizes whitespace in HTML
|
|
71
|
-
* @param html - HTML string
|
|
72
|
-
* @returns HTML with normalized whitespace
|
|
73
|
-
*/
|
|
74
|
-
export declare function normalizeWhitespace(html: string): string;
|
|
75
|
-
export declare const htmlMinifyForEmail: (htmlEditorContent: string) => string;
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { SMART_TAG_HIGHLIGHT_BG } from '../constants';
|
|
2
|
-
import { textStyleFromElStyle, appendTextStyleToEl } from './style';
|
|
3
|
-
import tinycolor from 'tinycolor2';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a clean span element for a dynamic tag with only the essential attributes
|
|
6
|
-
*
|
|
7
|
-
* @param doc - The document used to create the new element
|
|
8
|
-
* @param originalSpan - The original dynamic tag span element
|
|
9
|
-
* @param attributesToPreserve - List of attribute names to copy from the original span
|
|
10
|
-
* @returns A new span element with preserved attributes
|
|
11
|
-
*/
|
|
12
|
-
function createCleanDynamicSpan(doc, originalSpan, attributesToPreserve) {
|
|
13
|
-
const cleanSpan = doc.createElement('span');
|
|
14
|
-
// Preserve only the specified attributes
|
|
15
|
-
for (const attrName of attributesToPreserve) {
|
|
16
|
-
if (originalSpan.hasAttribute(attrName)) {
|
|
17
|
-
cleanSpan.setAttribute(attrName, originalSpan.getAttribute(attrName));
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// Preserve the text content
|
|
21
|
-
cleanSpan.textContent = originalSpan.textContent?.trim() || '';
|
|
22
|
-
return cleanSpan;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Extracts style wrapper elements that need to be preserved from the original dynamic tag
|
|
26
|
-
*
|
|
27
|
-
* @param doc - The document containing the dynamic tag
|
|
28
|
-
* @param html - The original HTML string
|
|
29
|
-
* @param dynamicSpan - The original dynamic tag span element
|
|
30
|
-
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
31
|
-
* @returns Array of wrapper elements that provide styling
|
|
32
|
-
*/
|
|
33
|
-
function extractStyleWrappers(params) {
|
|
34
|
-
const { doc, html, dynamicSpan, wrapperElement, defaultStyle } = params;
|
|
35
|
-
const styleWrappers = [];
|
|
36
|
-
// Create a temporary container for style computation
|
|
37
|
-
const tempStyleContainer = document.createElement('div');
|
|
38
|
-
tempStyleContainer.style.display = 'none';
|
|
39
|
-
const targetWrapper = wrapperElement || document.body;
|
|
40
|
-
targetWrapper.appendChild(tempStyleContainer);
|
|
41
|
-
try {
|
|
42
|
-
// Extract computed styles from the original element
|
|
43
|
-
if (doc.body.firstElementChild) {
|
|
44
|
-
const tempDoc = new DOMParser().parseFromString(html, 'text/html');
|
|
45
|
-
if (tempDoc.body.firstElementChild) {
|
|
46
|
-
tempStyleContainer.appendChild(tempDoc.body.firstElementChild);
|
|
47
|
-
const originalDynamicElement = tempStyleContainer.querySelector(`span[data-dynamic-id="${dynamicSpan.dataset.dynamicId}"]`);
|
|
48
|
-
if (originalDynamicElement) {
|
|
49
|
-
// Create a span with the computed text styles
|
|
50
|
-
const computedTextStyle = textStyleFromElStyle(window.getComputedStyle(originalDynamicElement), defaultStyle);
|
|
51
|
-
// Remove background color if it matches the highlight color
|
|
52
|
-
if (tinycolor.equals(computedTextStyle.backgroundColor, SMART_TAG_HIGHLIGHT_BG)) {
|
|
53
|
-
computedTextStyle.backgroundColor = '';
|
|
54
|
-
}
|
|
55
|
-
const textStyleWrapper = document.createElement('span');
|
|
56
|
-
appendTextStyleToEl(textStyleWrapper, computedTextStyle);
|
|
57
|
-
styleWrappers.push(textStyleWrapper);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// Extract nested style wrappers
|
|
62
|
-
let nestedElement = dynamicSpan.firstElementChild;
|
|
63
|
-
while (nestedElement && nestedElement.children.length <= 1) {
|
|
64
|
-
styleWrappers.push(nestedElement);
|
|
65
|
-
nestedElement = nestedElement.firstElementChild || null;
|
|
66
|
-
}
|
|
67
|
-
return styleWrappers;
|
|
68
|
-
}
|
|
69
|
-
finally {
|
|
70
|
-
// Clean up the temporary container
|
|
71
|
-
targetWrapper.removeChild(tempStyleContainer);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Reconstructs the dynamic tag element hierarchy with preserved style wrappers
|
|
76
|
-
*
|
|
77
|
-
* @param doc - The document used to create new elements
|
|
78
|
-
* @param baseSpan - The clean base span element for the dynamic tag
|
|
79
|
-
* @param styleWrappers - Array of style wrapper elements to apply
|
|
80
|
-
* @returns The reconstructed dynamic tag with preserved styling
|
|
81
|
-
*/
|
|
82
|
-
function reconstructDynamicTagHierarchy(doc, baseSpan, styleWrappers) {
|
|
83
|
-
let resultNode = baseSpan;
|
|
84
|
-
// Apply style wrappers from innermost to outermost
|
|
85
|
-
styleWrappers.reverse().forEach(originalWrapper => {
|
|
86
|
-
const wrapperClone = doc.createElement(originalWrapper.tagName.toLowerCase());
|
|
87
|
-
// Clone all attributes from the original wrapper
|
|
88
|
-
for (let i = 0; i < originalWrapper.attributes.length; i++) {
|
|
89
|
-
const { name, value } = originalWrapper.attributes[i];
|
|
90
|
-
wrapperClone.setAttribute(name, value);
|
|
91
|
-
}
|
|
92
|
-
wrapperClone.appendChild(resultNode);
|
|
93
|
-
resultNode = wrapperClone;
|
|
94
|
-
});
|
|
95
|
-
return resultNode;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Restructures dynamic tags from Froala editor format to be compatible with Tiptap editor.
|
|
99
|
-
* This function preserves styling and attributes of dynamic tags while cleaning up their structure.
|
|
100
|
-
*
|
|
101
|
-
* @param html - The HTML string containing dynamic tags
|
|
102
|
-
* @param options - Configuration options for the restructuring process
|
|
103
|
-
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
104
|
-
* @returns The restructured HTML string
|
|
105
|
-
*/
|
|
106
|
-
export function restructureDynamicTagsWithOptions(params) {
|
|
107
|
-
const { html, options = {
|
|
108
|
-
attributesToClone: [
|
|
109
|
-
'class',
|
|
110
|
-
'id',
|
|
111
|
-
'style',
|
|
112
|
-
'data-dynamic',
|
|
113
|
-
'data-dynamic-id',
|
|
114
|
-
'direction',
|
|
115
|
-
'unicode-bidi',
|
|
116
|
-
'text-align',
|
|
117
|
-
'background-color',
|
|
118
|
-
'color',
|
|
119
|
-
],
|
|
120
|
-
}, wrapperElement, defaultStyle, } = params;
|
|
121
|
-
// Parse the HTML string into a DOM
|
|
122
|
-
const parser = new DOMParser();
|
|
123
|
-
const parsedDoc = parser.parseFromString(html, 'text/html');
|
|
124
|
-
// Find all dynamic tag spans
|
|
125
|
-
const dynamicTagSpans = parsedDoc.querySelectorAll('span[data-dynamic]');
|
|
126
|
-
// Process each dynamic span
|
|
127
|
-
dynamicTagSpans.forEach(originalDynamicSpan => {
|
|
128
|
-
// Step 1: Create a new clean span with essential attributes
|
|
129
|
-
const cleanDynamicSpan = createCleanDynamicSpan(parsedDoc, originalDynamicSpan, options.attributesToClone);
|
|
130
|
-
// Step 2: Extract style wrappers that need to be preserved
|
|
131
|
-
const styleWrappers = extractStyleWrappers({
|
|
132
|
-
doc: parsedDoc,
|
|
133
|
-
html,
|
|
134
|
-
dynamicSpan: originalDynamicSpan,
|
|
135
|
-
wrapperElement,
|
|
136
|
-
defaultStyle,
|
|
137
|
-
});
|
|
138
|
-
// Step 3: Reconstruct the element hierarchy with preserved styles
|
|
139
|
-
const restructuredDynamicTag = reconstructDynamicTagHierarchy(parsedDoc, cleanDynamicSpan, styleWrappers);
|
|
140
|
-
// Step 4: Replace the original span with the restructured node
|
|
141
|
-
originalDynamicSpan.replaceWith(restructuredDynamicTag);
|
|
142
|
-
});
|
|
143
|
-
return parsedDoc.body.innerHTML;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Converts inherited text styles to computed styles for span elements in HTML content.
|
|
147
|
-
* This function processes span elements to ensure text styles are explicitly set rather than inherited.
|
|
148
|
-
*
|
|
149
|
-
* @param html - The HTML string to process
|
|
150
|
-
* @param wrapperElement - Optional wrapper element to use instead of document.body
|
|
151
|
-
* @returns The processed HTML string with computed styles applied
|
|
152
|
-
*/
|
|
153
|
-
const inheritStyleToComputedStyle = (params) => {
|
|
154
|
-
const { html, wrapperElement, defaultStyle } = params;
|
|
155
|
-
try {
|
|
156
|
-
// Create a new DOM parser and parse the HTML
|
|
157
|
-
const parser = new DOMParser();
|
|
158
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
159
|
-
if (!doc.body) {
|
|
160
|
-
// eslint-disable-next-line no-console
|
|
161
|
-
console.warn('Failed to parse HTML: body not found');
|
|
162
|
-
return html;
|
|
163
|
-
}
|
|
164
|
-
// Create a hidden container
|
|
165
|
-
const container = document.createElement('div');
|
|
166
|
-
container.style.visibility = 'hidden';
|
|
167
|
-
container.innerHTML = doc.body.innerHTML;
|
|
168
|
-
// Add container to DOM temporarily to compute styles
|
|
169
|
-
const targetWrapper = wrapperElement || document.body;
|
|
170
|
-
targetWrapper.appendChild(container);
|
|
171
|
-
// Process all span elements
|
|
172
|
-
const spanElements = container.querySelectorAll('span');
|
|
173
|
-
spanElements.forEach(span => {
|
|
174
|
-
const textStyle = textStyleFromElStyle(span.style, defaultStyle);
|
|
175
|
-
const computedStyle = window.getComputedStyle(span);
|
|
176
|
-
// Only update styles if there are inherited values
|
|
177
|
-
const shouldUpdateStyle = Object.values(textStyle).some(value => value === 'inherit');
|
|
178
|
-
if (!shouldUpdateStyle) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
// Update inherited styles with computed values
|
|
182
|
-
Object.entries(textStyle).forEach(([key, value]) => {
|
|
183
|
-
if (value === 'inherit' && key in span.style) {
|
|
184
|
-
span.style[key] = computedStyle[key];
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
const resultHTML = container.innerHTML;
|
|
189
|
-
// Clean up
|
|
190
|
-
container.remove();
|
|
191
|
-
return resultHTML;
|
|
192
|
-
}
|
|
193
|
-
catch (error) {
|
|
194
|
-
// eslint-disable-next-line no-console
|
|
195
|
-
console.error('Error processing styles:', error);
|
|
196
|
-
return html; // Return original HTML in case of error
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Safely parses and processes HTML content for editor use
|
|
201
|
-
* @param html - HTML string to process
|
|
202
|
-
* @param wrapperElement - Optional wrapper element to use instead of document.body for temporary DOM operations
|
|
203
|
-
* @returns Processed HTML string
|
|
204
|
-
*/
|
|
205
|
-
export function safeParseHTMLContent(params) {
|
|
206
|
-
const { html, wrapperElement, defaultStyle } = params;
|
|
207
|
-
let resultHTML = html;
|
|
208
|
-
const isFroala = html.includes('fr-box');
|
|
209
|
-
if (isFroala) {
|
|
210
|
-
// console.log('safeParseHTMLContent', html);
|
|
211
|
-
resultHTML = inheritStyleToComputedStyle({
|
|
212
|
-
html,
|
|
213
|
-
wrapperElement,
|
|
214
|
-
defaultStyle,
|
|
215
|
-
});
|
|
216
|
-
// console.log('after inheritStyleToComputedStyle', resultHTML);
|
|
217
|
-
resultHTML = restructureDynamicTagsWithOptions({
|
|
218
|
-
html: resultHTML,
|
|
219
|
-
wrapperElement,
|
|
220
|
-
defaultStyle,
|
|
221
|
-
});
|
|
222
|
-
// console.log('after restructureDynamicTagsWithOptions', resultHTML);
|
|
223
|
-
}
|
|
224
|
-
return resultHTML;
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Sanitizes HTML by removing potentially dangerous elements and attributes
|
|
228
|
-
* @param html - HTML string to sanitize
|
|
229
|
-
* @returns Sanitized HTML string
|
|
230
|
-
*/
|
|
231
|
-
export function sanitizeHTML(html) {
|
|
232
|
-
const parser = new DOMParser();
|
|
233
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
234
|
-
// Remove script tags
|
|
235
|
-
const scripts = doc.querySelectorAll('script');
|
|
236
|
-
scripts.forEach(script => script.remove());
|
|
237
|
-
// Remove on* event attributes
|
|
238
|
-
const allElements = doc.querySelectorAll('*');
|
|
239
|
-
allElements.forEach(element => {
|
|
240
|
-
Array.from(element.attributes).forEach(attr => {
|
|
241
|
-
if (attr.name.startsWith('on')) {
|
|
242
|
-
element.removeAttribute(attr.name);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
return doc.body.innerHTML;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Extracts text content from HTML
|
|
250
|
-
* @param html - HTML string
|
|
251
|
-
* @returns Plain text content
|
|
252
|
-
*/
|
|
253
|
-
export function extractTextFromHTML(html) {
|
|
254
|
-
const parser = new DOMParser();
|
|
255
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
256
|
-
return doc.body.textContent || '';
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Counts words in HTML content
|
|
260
|
-
* @param html - HTML string
|
|
261
|
-
* @returns Word count
|
|
262
|
-
*/
|
|
263
|
-
export function countWordsInHTML(html) {
|
|
264
|
-
const text = extractTextFromHTML(html);
|
|
265
|
-
return text
|
|
266
|
-
.trim()
|
|
267
|
-
.split(/\s+/)
|
|
268
|
-
.filter(word => word.length > 0).length;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Counts characters in HTML content
|
|
272
|
-
* @param html - HTML string
|
|
273
|
-
* @param includeSpaces - Whether to include spaces in count
|
|
274
|
-
* @returns Character count
|
|
275
|
-
*/
|
|
276
|
-
export function countCharactersInHTML(html, includeSpaces = true) {
|
|
277
|
-
const text = extractTextFromHTML(html);
|
|
278
|
-
return includeSpaces ? text.length : text.replace(/\s/g, '').length;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Wraps text nodes with specified tag
|
|
282
|
-
* @param html - HTML string
|
|
283
|
-
* @param tagName - Tag name to wrap with
|
|
284
|
-
* @param className - Optional class name for wrapper
|
|
285
|
-
* @returns HTML with wrapped text nodes
|
|
286
|
-
*/
|
|
287
|
-
export function wrapTextNodes(html, tagName = 'span', className) {
|
|
288
|
-
const parser = new DOMParser();
|
|
289
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
290
|
-
function wrapTextNodesRecursive(node) {
|
|
291
|
-
if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {
|
|
292
|
-
const wrapper = doc.createElement(tagName);
|
|
293
|
-
if (className) {
|
|
294
|
-
wrapper.className = className;
|
|
295
|
-
}
|
|
296
|
-
wrapper.textContent = node.textContent;
|
|
297
|
-
node.parentNode?.replaceChild(wrapper, node);
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
Array.from(node.childNodes).forEach(wrapTextNodesRecursive);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
wrapTextNodesRecursive(doc.body);
|
|
304
|
-
return doc.body.innerHTML;
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Removes empty elements from HTML
|
|
308
|
-
* @param html - HTML string
|
|
309
|
-
* @returns HTML with empty elements removed
|
|
310
|
-
*/
|
|
311
|
-
export function removeEmptyElements(html) {
|
|
312
|
-
const parser = new DOMParser();
|
|
313
|
-
const doc = parser.parseFromString(html, 'text/html');
|
|
314
|
-
function removeEmptyRecursive(node) {
|
|
315
|
-
Array.from(node.children).forEach(child => {
|
|
316
|
-
removeEmptyRecursive(child);
|
|
317
|
-
if (!child.textContent?.trim() && child.children.length === 0) {
|
|
318
|
-
child.remove();
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
removeEmptyRecursive(doc.body);
|
|
323
|
-
return doc.body.innerHTML;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Normalizes whitespace in HTML
|
|
327
|
-
* @param html - HTML string
|
|
328
|
-
* @returns HTML with normalized whitespace
|
|
329
|
-
*/
|
|
330
|
-
export function normalizeWhitespace(html) {
|
|
331
|
-
return html.replace(/\s+/g, ' ').replace(/>\s+</g, '><').trim();
|
|
332
|
-
}
|
|
333
|
-
export const htmlMinifyForEmail = (htmlEditorContent) => {
|
|
334
|
-
const parser = new DOMParser();
|
|
335
|
-
const doc = parser.parseFromString(htmlEditorContent, 'text/html');
|
|
336
|
-
const allElements = doc.body.querySelectorAll('*');
|
|
337
|
-
allElements.forEach(element => {
|
|
338
|
-
element.removeAttribute('spellcheck');
|
|
339
|
-
element.removeAttribute('class');
|
|
340
|
-
element.removeAttribute('contenteditable');
|
|
341
|
-
});
|
|
342
|
-
return doc.body.innerHTML;
|
|
343
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
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';
|