@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,187 +0,0 @@
|
|
|
1
|
-
import TiptapLinkExtension from '@tiptap/extension-link';
|
|
2
|
-
import { CUSTOM_LINK_EXTENSION_NAME, LINK_TEXT_COLOR } from '../constants';
|
|
3
|
-
import { TextSelection } from '@tiptap/pm/state';
|
|
4
|
-
import { dataAttrArrayToObject } from '@antscorp/antsomi-ui/es/utils';
|
|
5
|
-
import { isEmpty, kebabCase, toString } from 'lodash';
|
|
6
|
-
import { getLinkMarkRanges, getLinkRange, isLinkColor } from '../utils';
|
|
7
|
-
export const CustomLink = TiptapLinkExtension.extend({
|
|
8
|
-
name: CUSTOM_LINK_EXTENSION_NAME,
|
|
9
|
-
addOptions() {
|
|
10
|
-
return {
|
|
11
|
-
...this.parent(),
|
|
12
|
-
openOnClick: false,
|
|
13
|
-
highlight: false,
|
|
14
|
-
};
|
|
15
|
-
},
|
|
16
|
-
addStorage() {
|
|
17
|
-
return {
|
|
18
|
-
highlight: this.options.highlight,
|
|
19
|
-
};
|
|
20
|
-
},
|
|
21
|
-
addAttributes() {
|
|
22
|
-
return {
|
|
23
|
-
...this.parent?.(),
|
|
24
|
-
title: {
|
|
25
|
-
default: null,
|
|
26
|
-
parseHTML: el => el.title,
|
|
27
|
-
},
|
|
28
|
-
data: {
|
|
29
|
-
default: [],
|
|
30
|
-
parseHTML: el => el.dataset,
|
|
31
|
-
renderHTML: attrs => {
|
|
32
|
-
const dataAttrs = Object.entries(attrs.data).map(([key, value]) => ({
|
|
33
|
-
key: `data-${kebabCase(key)}`,
|
|
34
|
-
value: toString(value),
|
|
35
|
-
}));
|
|
36
|
-
return dataAttrArrayToObject(dataAttrs);
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
addCommands() {
|
|
42
|
-
return {
|
|
43
|
-
...this.parent?.(),
|
|
44
|
-
setCustomLink: ({ attrs, content }) => ({ editor, chain }) => {
|
|
45
|
-
const { selection } = editor?.state;
|
|
46
|
-
const { from, to } = selection;
|
|
47
|
-
let linkContent = editor.state.doc.textBetween(from, to);
|
|
48
|
-
if (content && linkContent !== content) {
|
|
49
|
-
linkContent = content;
|
|
50
|
-
}
|
|
51
|
-
return chain()
|
|
52
|
-
.focus()
|
|
53
|
-
.deleteSelection()
|
|
54
|
-
.insertContent(linkContent)
|
|
55
|
-
.command(({ tr }) => {
|
|
56
|
-
const endPos = tr.selection.from;
|
|
57
|
-
const startPos = endPos - linkContent.length;
|
|
58
|
-
tr.setSelection(TextSelection.create(tr.doc, startPos, endPos));
|
|
59
|
-
return true;
|
|
60
|
-
})
|
|
61
|
-
.setUnderline()
|
|
62
|
-
.setColor(LINK_TEXT_COLOR)
|
|
63
|
-
.setLink({
|
|
64
|
-
...attrs,
|
|
65
|
-
href: attrs?.href || './',
|
|
66
|
-
class: this.storage.highlight ? 'highlight' : undefined,
|
|
67
|
-
})
|
|
68
|
-
.command(({ tr }) => {
|
|
69
|
-
const endPos = tr.selection.to;
|
|
70
|
-
tr.setSelection(TextSelection.create(tr.doc, endPos, endPos));
|
|
71
|
-
return true;
|
|
72
|
-
})
|
|
73
|
-
.run();
|
|
74
|
-
},
|
|
75
|
-
deleteCustomLink: predicate => ({ editor }) => {
|
|
76
|
-
const { state } = editor;
|
|
77
|
-
const { doc } = state;
|
|
78
|
-
let linkMark;
|
|
79
|
-
doc.descendants((node, pos) => {
|
|
80
|
-
if (linkMark)
|
|
81
|
-
return;
|
|
82
|
-
linkMark = getLinkMarkRanges({
|
|
83
|
-
state,
|
|
84
|
-
from: pos,
|
|
85
|
-
to: pos + node.nodeSize,
|
|
86
|
-
}).find(range => predicate(range.mark.attrs));
|
|
87
|
-
});
|
|
88
|
-
if (!linkMark)
|
|
89
|
-
return false;
|
|
90
|
-
return editor
|
|
91
|
-
.chain()
|
|
92
|
-
.deleteRange({
|
|
93
|
-
from: linkMark.from,
|
|
94
|
-
to: linkMark.to,
|
|
95
|
-
})
|
|
96
|
-
.run();
|
|
97
|
-
},
|
|
98
|
-
unsetCustomLink: () => ({ editor }) => {
|
|
99
|
-
const { state } = editor;
|
|
100
|
-
const linkRange = getLinkRange({ state, pos: state.selection.from });
|
|
101
|
-
if (!linkRange)
|
|
102
|
-
return false;
|
|
103
|
-
const command = editor
|
|
104
|
-
.chain()
|
|
105
|
-
.setTextSelection({
|
|
106
|
-
from: linkRange.from,
|
|
107
|
-
to: linkRange.to,
|
|
108
|
-
})
|
|
109
|
-
.unsetUnderline()
|
|
110
|
-
.unsetLink();
|
|
111
|
-
if (isLinkColor(editor.getAttributes('textStyle').color)) {
|
|
112
|
-
command.unsetColor();
|
|
113
|
-
}
|
|
114
|
-
return command.run();
|
|
115
|
-
},
|
|
116
|
-
updateCustomLinkAttrsGlobally: (predicate, updateFn) => ({ editor, tr, dispatch }) => {
|
|
117
|
-
const { state } = editor;
|
|
118
|
-
const { doc, schema } = state;
|
|
119
|
-
if (!dispatch)
|
|
120
|
-
return true;
|
|
121
|
-
const linkType = schema.marks[CustomLink.name];
|
|
122
|
-
let somethingChanged = false;
|
|
123
|
-
doc.descendants((node, pos) => {
|
|
124
|
-
// Get all link mark ranges within this node
|
|
125
|
-
const linkMarkRanges = getLinkMarkRanges({
|
|
126
|
-
state,
|
|
127
|
-
from: pos,
|
|
128
|
-
to: pos + node.nodeSize,
|
|
129
|
-
});
|
|
130
|
-
linkMarkRanges.forEach(markRange => {
|
|
131
|
-
const currentLinkAttrs = markRange.mark.attrs;
|
|
132
|
-
const currentLinkContent = doc.textBetween(markRange.from, markRange.to);
|
|
133
|
-
const isMatched = predicate(currentLinkAttrs);
|
|
134
|
-
if (!isMatched)
|
|
135
|
-
return;
|
|
136
|
-
const updated = updateFn({
|
|
137
|
-
currentAttrs: currentLinkAttrs,
|
|
138
|
-
currentContent: currentLinkContent,
|
|
139
|
-
});
|
|
140
|
-
if (!updated || isEmpty(updated))
|
|
141
|
-
return;
|
|
142
|
-
const from = tr.mapping.map(markRange.from);
|
|
143
|
-
const to = tr.mapping.map(markRange.to);
|
|
144
|
-
if (!isEmpty(updated.attrs)) {
|
|
145
|
-
somethingChanged = true;
|
|
146
|
-
// Remove the old mark
|
|
147
|
-
tr.removeMark(from, to, linkType);
|
|
148
|
-
// Create a new mark with updated attributes and add it
|
|
149
|
-
const newMark = linkType.create({
|
|
150
|
-
...markRange.mark.attrs,
|
|
151
|
-
...updated.attrs,
|
|
152
|
-
});
|
|
153
|
-
tr.addMark(from, to, newMark);
|
|
154
|
-
}
|
|
155
|
-
if (updated.content && updated.content !== currentLinkContent) {
|
|
156
|
-
somethingChanged = true;
|
|
157
|
-
tr.insertText(updated.content, from, to);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
return somethingChanged;
|
|
162
|
-
},
|
|
163
|
-
updateCustomLinkHighlight: enabled => ({ tr }) => {
|
|
164
|
-
// Update the storage value
|
|
165
|
-
this.storage.highlight = enabled;
|
|
166
|
-
// Set metadata on the transaction to trigger the plugin to update decorations
|
|
167
|
-
tr.setMeta('updateCustomLinkHighlight', {
|
|
168
|
-
highlight: enabled,
|
|
169
|
-
});
|
|
170
|
-
return true;
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
addKeyboardShortcuts() {
|
|
175
|
-
return {
|
|
176
|
-
...this.parent?.(),
|
|
177
|
-
Enter: ({ editor }) => {
|
|
178
|
-
editor.chain().unsetUnderline().run();
|
|
179
|
-
const currentColor = editor.getAttributes('textStyle').color;
|
|
180
|
-
if (currentColor === LINK_TEXT_COLOR) {
|
|
181
|
-
editor.chain().unsetColor().run();
|
|
182
|
-
}
|
|
183
|
-
return false;
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
export interface ListItemMarkerOptions {
|
|
3
|
-
paddingRight: number;
|
|
4
|
-
defaultFontSize: string;
|
|
5
|
-
defaultFontFamily: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Extension tạo marker tùy chỉnh cho danh sách trong p
|
|
9
|
-
*
|
|
10
|
-
* Extension này thay thế marker mặc định của danh sách bằng các marker
|
|
11
|
-
* có thể kế thừa style (font, size, color...) từ text node đầu tiên.
|
|
12
|
-
*/
|
|
13
|
-
export declare const ListItemMarker: Extension<ListItemMarkerOptions, any>;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
|
-
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
3
|
-
import { Decoration, DecorationSet } from '@tiptap/pm/view';
|
|
4
|
-
import { kebabCase } from 'lodash';
|
|
5
|
-
function getMaxMarkerWidth(markers, font = '16px Arial') {
|
|
6
|
-
let max = 0;
|
|
7
|
-
const canvas = document.createElement('canvas');
|
|
8
|
-
const ctx = canvas.getContext('2d');
|
|
9
|
-
if (!ctx)
|
|
10
|
-
return max;
|
|
11
|
-
ctx.font = font;
|
|
12
|
-
for (const m of markers) {
|
|
13
|
-
const w = ctx.measureText(m).width;
|
|
14
|
-
if (w > max)
|
|
15
|
-
max = w;
|
|
16
|
-
}
|
|
17
|
-
return max;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Tạo các marker tùy chỉnh cho danh sách (bullet và ordered) với style kế thừa từ text node
|
|
21
|
-
*
|
|
22
|
-
* @param doc - ProseMirror document node
|
|
23
|
-
* @returns DecorationSet chứa tất cả các widget decoration cho marker
|
|
24
|
-
*/
|
|
25
|
-
const styleMarker = (doc, options) => {
|
|
26
|
-
const decorations = [];
|
|
27
|
-
doc.descendants((listNode, listNodePos) => {
|
|
28
|
-
const isBulletList = listNode.type.name === 'bulletList';
|
|
29
|
-
const isOrderedList = listNode.type.name === 'orderedList';
|
|
30
|
-
if (!isBulletList && !isOrderedList) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
// Khởi tạo marker dựa trên loại danh sách
|
|
34
|
-
const getMarker = (isOrderedList, index) => isOrderedList ? `${index + 1}.` : '•';
|
|
35
|
-
const markers = [];
|
|
36
|
-
const listItems = [];
|
|
37
|
-
listNode.descendants((listItem, listItemPos) => {
|
|
38
|
-
if (listItem.type.name !== 'listItem') {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const itemInfo = {
|
|
42
|
-
node: listItem,
|
|
43
|
-
pos: listItemPos,
|
|
44
|
-
isEmpty: true,
|
|
45
|
-
};
|
|
46
|
-
listItems.push(itemInfo);
|
|
47
|
-
// Tìm paragraph đầu tiên và text node đầu tiên
|
|
48
|
-
let foundText = false;
|
|
49
|
-
let foundParagraph = false;
|
|
50
|
-
listItem.descendants((node, nodePos) => {
|
|
51
|
-
if (!foundParagraph && node.type.name === 'paragraph') {
|
|
52
|
-
foundParagraph = true;
|
|
53
|
-
itemInfo.paragraphPos = nodePos;
|
|
54
|
-
itemInfo.paragraphNode = node;
|
|
55
|
-
}
|
|
56
|
-
if (!foundText && node.type.name === 'text') {
|
|
57
|
-
foundText = true;
|
|
58
|
-
itemInfo.isEmpty = false;
|
|
59
|
-
itemInfo.textNode = node;
|
|
60
|
-
itemInfo.textNodePos = nodePos;
|
|
61
|
-
const textStyleMark = node.marks.find(nodeMark => nodeMark.type.name === 'textStyle');
|
|
62
|
-
if (textStyleMark) {
|
|
63
|
-
itemInfo.textStyleMark = textStyleMark;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
const index = listItems.length;
|
|
68
|
-
const marker = getMarker(isOrderedList, index - 1);
|
|
69
|
-
markers.push(marker);
|
|
70
|
-
});
|
|
71
|
-
for (let i = 0; i < listItems.length; i++) {
|
|
72
|
-
const item = listItems[i];
|
|
73
|
-
if (!item.textStyleMark) {
|
|
74
|
-
for (let j = i - 1; j >= 0; j--) {
|
|
75
|
-
if (listItems[j].textStyleMark) {
|
|
76
|
-
item.textStyleMark = listItems[j].textStyleMark;
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
let font = `${options.defaultFontSize} ${options.defaultFontFamily}`;
|
|
83
|
-
for (const item of listItems) {
|
|
84
|
-
if (item.textStyleMark) {
|
|
85
|
-
const { fontSize, fontFamily } = item.textStyleMark.attrs;
|
|
86
|
-
if (fontSize && fontFamily) {
|
|
87
|
-
font = `${fontSize} ${fontFamily}`;
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const maxWidth = getMaxMarkerWidth(markers, font);
|
|
93
|
-
const { paddingRight } = options;
|
|
94
|
-
const totalWidth = maxWidth + paddingRight;
|
|
95
|
-
listItems.forEach((item, index) => {
|
|
96
|
-
if (item.paragraphPos === undefined) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const marker = getMarker(isOrderedList, index);
|
|
100
|
-
const widget = document.createElement('span');
|
|
101
|
-
widget.innerHTML = marker;
|
|
102
|
-
// Đặt các thuộc tính style cơ bản
|
|
103
|
-
widget.style.setProperty('user-select', 'none');
|
|
104
|
-
widget.style.setProperty('text-decoration', 'none');
|
|
105
|
-
widget.style.setProperty('display', 'inline-block');
|
|
106
|
-
widget.style.setProperty('width', `${totalWidth}px`);
|
|
107
|
-
widget.style.setProperty('text-align', 'left');
|
|
108
|
-
// Sao chép tất cả các thuộc tính style từ mark textStyle
|
|
109
|
-
if (item.textStyleMark) {
|
|
110
|
-
for (const styleProp in item.textStyleMark.attrs) {
|
|
111
|
-
widget.style.setProperty(kebabCase(styleProp), String(item.textStyleMark.attrs[styleProp]));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
// Tính toán vị trí chính xác cho marker
|
|
115
|
-
const absoluteListItemPos = listNodePos + item.pos + 1;
|
|
116
|
-
const absoluteParagraphPos = absoluteListItemPos + item.paragraphPos;
|
|
117
|
-
const markerPos = absoluteParagraphPos + 1;
|
|
118
|
-
// Đặt marker widget tại vị trí đã tính toán (bên trong paragraph)
|
|
119
|
-
// Decoration.widget sẽ tạo một widget tại vị trí markerPos
|
|
120
|
-
decorations.push(Decoration.widget(markerPos, widget, {
|
|
121
|
-
ignoreSelection: true,
|
|
122
|
-
}));
|
|
123
|
-
if (item.paragraphNode) {
|
|
124
|
-
// Tính toán vị trí bắt đầu và kết thúc của paragraph
|
|
125
|
-
const paragraphStart = absoluteParagraphPos;
|
|
126
|
-
const paragraphEnd = paragraphStart + item.paragraphNode.nodeSize;
|
|
127
|
-
// Thêm decoration cho paragraph với style inline-block
|
|
128
|
-
decorations.push(Decoration.node(paragraphStart + 1, paragraphEnd + 1, {
|
|
129
|
-
style: 'display: inline;',
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
return DecorationSet.create(doc, decorations);
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* Extension tạo marker tùy chỉnh cho danh sách trong p
|
|
138
|
-
*
|
|
139
|
-
* Extension này thay thế marker mặc định của danh sách bằng các marker
|
|
140
|
-
* có thể kế thừa style (font, size, color...) từ text node đầu tiên.
|
|
141
|
-
*/
|
|
142
|
-
export const ListItemMarker = Extension.create({
|
|
143
|
-
name: 'list-item-marker',
|
|
144
|
-
addOptions() {
|
|
145
|
-
return {
|
|
146
|
-
...this.parent?.(),
|
|
147
|
-
paddingRight: 10,
|
|
148
|
-
defaultFontSize: '16px',
|
|
149
|
-
defaultFontFamily: 'Arial',
|
|
150
|
-
};
|
|
151
|
-
},
|
|
152
|
-
addProseMirrorPlugins() {
|
|
153
|
-
const { options } = this;
|
|
154
|
-
return [
|
|
155
|
-
new Plugin({
|
|
156
|
-
key: new PluginKey('custom-list-item-marker'),
|
|
157
|
-
state: {
|
|
158
|
-
init(_, { doc }) {
|
|
159
|
-
return styleMarker(doc, options);
|
|
160
|
-
},
|
|
161
|
-
// Chỉ tính toán lại nếu document thay đổi
|
|
162
|
-
apply(tr, oldState) {
|
|
163
|
-
return tr.docChanged ? styleMarker(tr.doc, options) : oldState;
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
props: {
|
|
167
|
-
decorations(state) {
|
|
168
|
-
return this.getState(state);
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
}),
|
|
172
|
-
];
|
|
173
|
-
},
|
|
174
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
import { OrderedListStyleType } from '../types';
|
|
3
|
-
type ListStyleType = OrderedListStyleType;
|
|
4
|
-
export interface CustomOrderedListOptions {
|
|
5
|
-
/**
|
|
6
|
-
* The node type name for list items.
|
|
7
|
-
* @default 'listItem'
|
|
8
|
-
*/
|
|
9
|
-
itemTypeName: string;
|
|
10
|
-
/**
|
|
11
|
-
* The HTML attributes for an ordered list node.
|
|
12
|
-
* @default {}
|
|
13
|
-
*/
|
|
14
|
-
HTMLAttributes: Record<string, any>;
|
|
15
|
-
/**
|
|
16
|
-
* Keep the marks when splitting a list item.
|
|
17
|
-
* @default false
|
|
18
|
-
*/
|
|
19
|
-
keepMarks: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Keep the attributes when splitting a list item.
|
|
22
|
-
* @default false
|
|
23
|
-
*/
|
|
24
|
-
keepAttributes: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Default list style type
|
|
27
|
-
* @default 'decimal'
|
|
28
|
-
*/
|
|
29
|
-
defaultListStyleType: ListStyleType;
|
|
30
|
-
/**
|
|
31
|
-
* Available list style types
|
|
32
|
-
* @default ['decimal', 'lower-alpha', 'upper-alpha', 'lower-roman', 'upper-roman']
|
|
33
|
-
*/
|
|
34
|
-
availableListStyleTypes: ListStyleType[];
|
|
35
|
-
}
|
|
36
|
-
declare module '@tiptap/core' {
|
|
37
|
-
interface Commands<ReturnType> {
|
|
38
|
-
customOrderedList: {
|
|
39
|
-
/**
|
|
40
|
-
* Toggle a custom ordered list
|
|
41
|
-
*/
|
|
42
|
-
toggleCustomOrderedList: (options?: {
|
|
43
|
-
listStyleType?: ListStyleType;
|
|
44
|
-
}) => ReturnType;
|
|
45
|
-
/**
|
|
46
|
-
* Set list style type for current ordered list
|
|
47
|
-
*/
|
|
48
|
-
setOrderedListStyleType: (listStyleType: ListStyleType) => ReturnType;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* This extension allows you to create ordered lists with custom list-style-type.
|
|
54
|
-
*/
|
|
55
|
-
export declare const CustomOrderedList: Node<CustomOrderedListOptions, any>;
|
|
56
|
-
export {};
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core';
|
|
2
|
-
import { ORDERED_LIST_STYLE_TYPE } from '../constants';
|
|
3
|
-
const ListItemName = 'listItem';
|
|
4
|
-
const TextStyleName = 'textStyle';
|
|
5
|
-
/**
|
|
6
|
-
* Input regex patterns for different list styles
|
|
7
|
-
*/
|
|
8
|
-
const inputRegexPatterns = {
|
|
9
|
-
decimal: /^(\d+)\.\s$/,
|
|
10
|
-
'lower-alpha': /^([a-z])\.\s$/,
|
|
11
|
-
'upper-alpha': /^([A-Z])\.\s$/,
|
|
12
|
-
'lower-roman': /^(i{1,3}|iv|v|vi{0,3}|ix|x)\.\s$/,
|
|
13
|
-
'upper-roman': /^(I{1,3}|IV|V|VI{0,3}|IX|X)\.\s$/,
|
|
14
|
-
'lower-greek': /^(α|β|γ|δ|ε|ζ|η|θ|ι|κ)\.\s$/,
|
|
15
|
-
'decimal-leading-zero': /^(0\d+)\.\s$/,
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Convert roman numerals to numbers
|
|
19
|
-
*/
|
|
20
|
-
function romanToNumber(roman) {
|
|
21
|
-
const romanNumerals = {
|
|
22
|
-
i: 1,
|
|
23
|
-
v: 5,
|
|
24
|
-
x: 10,
|
|
25
|
-
};
|
|
26
|
-
let result = 0;
|
|
27
|
-
for (let i = 0; i < roman.length; i++) {
|
|
28
|
-
const current = romanNumerals[roman[i]];
|
|
29
|
-
const next = romanNumerals[roman[i + 1]];
|
|
30
|
-
if (next && current < next) {
|
|
31
|
-
result += next - current;
|
|
32
|
-
i++;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
result += current;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Helper function to convert different formats to numeric start value
|
|
42
|
-
*/
|
|
43
|
-
function getStartValue(match, listStyleType) {
|
|
44
|
-
switch (listStyleType) {
|
|
45
|
-
case ORDERED_LIST_STYLE_TYPE.decimal:
|
|
46
|
-
case ORDERED_LIST_STYLE_TYPE.decimalLeadingZero:
|
|
47
|
-
return parseInt(match, 10);
|
|
48
|
-
case ORDERED_LIST_STYLE_TYPE.lowerAlpha:
|
|
49
|
-
return match.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) + 1;
|
|
50
|
-
case ORDERED_LIST_STYLE_TYPE.upperAlpha:
|
|
51
|
-
return match.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
|
|
52
|
-
case ORDERED_LIST_STYLE_TYPE.lowerRoman:
|
|
53
|
-
case ORDERED_LIST_STYLE_TYPE.upperRoman:
|
|
54
|
-
return romanToNumber(match.toLowerCase());
|
|
55
|
-
case ORDERED_LIST_STYLE_TYPE.lowerGreek: {
|
|
56
|
-
const greekLetters = 'αβγδεζηθικ';
|
|
57
|
-
return greekLetters.indexOf(match) + 1;
|
|
58
|
-
}
|
|
59
|
-
default:
|
|
60
|
-
return 1;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* This extension allows you to create ordered lists with custom list-style-type.
|
|
65
|
-
*/
|
|
66
|
-
export const CustomOrderedList = Node.create({
|
|
67
|
-
name: 'customOrderedList',
|
|
68
|
-
addOptions() {
|
|
69
|
-
return {
|
|
70
|
-
itemTypeName: ListItemName,
|
|
71
|
-
HTMLAttributes: {
|
|
72
|
-
style: 'margin:0.5em 0;padding-inline-start:1.2em',
|
|
73
|
-
},
|
|
74
|
-
keepMarks: false,
|
|
75
|
-
keepAttributes: false,
|
|
76
|
-
defaultListStyleType: ORDERED_LIST_STYLE_TYPE.decimal,
|
|
77
|
-
availableListStyleTypes: [
|
|
78
|
-
ORDERED_LIST_STYLE_TYPE.decimal,
|
|
79
|
-
ORDERED_LIST_STYLE_TYPE.lowerAlpha,
|
|
80
|
-
ORDERED_LIST_STYLE_TYPE.upperAlpha,
|
|
81
|
-
ORDERED_LIST_STYLE_TYPE.lowerRoman,
|
|
82
|
-
ORDERED_LIST_STYLE_TYPE.upperRoman,
|
|
83
|
-
],
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
group: 'block list',
|
|
87
|
-
content() {
|
|
88
|
-
return `${this.options.itemTypeName}+`;
|
|
89
|
-
},
|
|
90
|
-
addAttributes() {
|
|
91
|
-
return {
|
|
92
|
-
start: {
|
|
93
|
-
default: 1,
|
|
94
|
-
parseHTML: element => element.hasAttribute('start') ? parseInt(element.getAttribute('start') || '', 10) : 1,
|
|
95
|
-
},
|
|
96
|
-
type: {
|
|
97
|
-
default: null,
|
|
98
|
-
parseHTML: element => element.getAttribute('type'),
|
|
99
|
-
},
|
|
100
|
-
listStyleType: {
|
|
101
|
-
default: this.options.defaultListStyleType,
|
|
102
|
-
parseHTML: element => {
|
|
103
|
-
const style = element.getAttribute('style');
|
|
104
|
-
const listStyleType = style?.match(/list-style-type:\s*([^;]+)/)?.[1]?.trim();
|
|
105
|
-
return listStyleType || this.options.defaultListStyleType;
|
|
106
|
-
},
|
|
107
|
-
renderHTML: attributes => ({
|
|
108
|
-
style: `list-style-type: ${attributes.listStyleType}`,
|
|
109
|
-
}),
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
parseHTML() {
|
|
114
|
-
return [
|
|
115
|
-
{
|
|
116
|
-
tag: 'ol',
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
},
|
|
120
|
-
renderHTML({ HTMLAttributes }) {
|
|
121
|
-
const { start, ...attributesWithoutStart } = HTMLAttributes;
|
|
122
|
-
return start === 1
|
|
123
|
-
? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
|
|
124
|
-
: ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
125
|
-
},
|
|
126
|
-
addCommands() {
|
|
127
|
-
return {
|
|
128
|
-
toggleCustomOrderedList: (options = {}) => ({ chain }) => {
|
|
129
|
-
const { listStyleType = this.options.defaultListStyleType } = options;
|
|
130
|
-
if (this.options.keepAttributes) {
|
|
131
|
-
return chain()
|
|
132
|
-
.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
133
|
-
.updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))
|
|
134
|
-
.updateAttributes(this.name, { listStyleType })
|
|
135
|
-
.run();
|
|
136
|
-
}
|
|
137
|
-
return chain()
|
|
138
|
-
.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
139
|
-
.updateAttributes(this.name, { listStyleType })
|
|
140
|
-
.run();
|
|
141
|
-
},
|
|
142
|
-
setOrderedListStyleType: (listStyleType) => ({ commands }) => commands.updateAttributes(this.name, { listStyleType }),
|
|
143
|
-
};
|
|
144
|
-
},
|
|
145
|
-
addKeyboardShortcuts() {
|
|
146
|
-
return {
|
|
147
|
-
'Mod-Shift-7': () => this.editor.commands.toggleCustomOrderedList(),
|
|
148
|
-
};
|
|
149
|
-
},
|
|
150
|
-
addInputRules() {
|
|
151
|
-
const inputRules = this.options.availableListStyleTypes.map(listStyleType => {
|
|
152
|
-
const regex = inputRegexPatterns[listStyleType];
|
|
153
|
-
let inputRule = wrappingInputRule({
|
|
154
|
-
find: regex,
|
|
155
|
-
type: this.type,
|
|
156
|
-
getAttributes: match => ({
|
|
157
|
-
start: getStartValue(match[1], listStyleType),
|
|
158
|
-
listStyleType,
|
|
159
|
-
}),
|
|
160
|
-
joinPredicate: (match, node) => {
|
|
161
|
-
const startValue = getStartValue(match[1], listStyleType);
|
|
162
|
-
return node.childCount + node.attrs.start === startValue;
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
166
|
-
inputRule = wrappingInputRule({
|
|
167
|
-
find: regex,
|
|
168
|
-
type: this.type,
|
|
169
|
-
keepMarks: this.options.keepMarks,
|
|
170
|
-
keepAttributes: this.options.keepAttributes,
|
|
171
|
-
getAttributes: match => ({
|
|
172
|
-
start: getStartValue(match[1], listStyleType),
|
|
173
|
-
listStyleType,
|
|
174
|
-
...this.editor.getAttributes(TextStyleName),
|
|
175
|
-
}),
|
|
176
|
-
joinPredicate: (match, node) => {
|
|
177
|
-
const startValue = getStartValue(match[1], listStyleType);
|
|
178
|
-
return node.childCount + node.attrs.start === startValue;
|
|
179
|
-
},
|
|
180
|
-
editor: this.editor,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
return inputRule;
|
|
184
|
-
});
|
|
185
|
-
return inputRules;
|
|
186
|
-
},
|
|
187
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Node } from '@tiptap/core';
|
|
2
|
-
import { Attrs } from '@tiptap/pm/model';
|
|
3
|
-
export type SmartTagAttrs = {
|
|
4
|
-
id: string;
|
|
5
|
-
} & Partial<{
|
|
6
|
-
content: string;
|
|
7
|
-
tag: string;
|
|
8
|
-
}>;
|
|
9
|
-
/**
|
|
10
|
-
* Represents the options for the SmartTag node.
|
|
11
|
-
*/
|
|
12
|
-
export interface SmartTagOptions {
|
|
13
|
-
HTMLAttributes: Record<string, unknown>;
|
|
14
|
-
highlight: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface SmartTagStorage {
|
|
17
|
-
highlight: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Represents the options for the SmartTag node.
|
|
21
|
-
*/
|
|
22
|
-
declare module '@tiptap/core' {
|
|
23
|
-
interface Commands<ReturnType> {
|
|
24
|
-
smartTag: {
|
|
25
|
-
setSmartTag: (attrs: {
|
|
26
|
-
id: string;
|
|
27
|
-
content?: string;
|
|
28
|
-
}) => ReturnType;
|
|
29
|
-
deleteSmartTagGlobally: (predicate: (attrs: Attrs) => boolean) => ReturnType;
|
|
30
|
-
updateSmartTagAttrsGlobally: (updateFn: (attrs: Attrs) => Attrs | undefined) => ReturnType;
|
|
31
|
-
updateSmartTagHighlight: (enabled: boolean) => ReturnType;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export declare const EXTENSION_NAME = "smartTag";
|
|
36
|
-
/**
|
|
37
|
-
* Represents a dynamic tag node in the editor.
|
|
38
|
-
*/
|
|
39
|
-
export declare const SmartTag: Node<SmartTagOptions, SmartTagStorage>;
|