@antscorp/antsomi-ui 2.0.110 → 2.0.112
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/assets/css/main.scss +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.d.ts +2 -0
- package/es/components/atoms/Eyedropper/Eyedropper.js +53 -0
- package/es/components/atoms/Eyedropper/index.d.ts +0 -0
- package/es/components/atoms/Eyedropper/index.js +1 -0
- package/es/components/atoms/Eyedropper/styled.d.ts +9 -0
- package/es/components/atoms/Eyedropper/styled.js +45 -0
- package/es/components/atoms/Eyedropper/types.d.ts +5 -0
- package/es/components/atoms/Eyedropper/types.js +1 -0
- package/es/components/icons/ALignRightIcon.d.ts +3 -0
- package/es/components/icons/ALignRightIcon.js +7 -0
- package/es/components/icons/AlignCenterIcon.d.ts +3 -0
- package/es/components/icons/AlignCenterIcon.js +7 -0
- package/es/components/icons/AlignJustifyIcon.d.ts +3 -0
- package/es/components/icons/AlignJustifyIcon.js +7 -0
- package/es/components/icons/AlignLeftIcon.d.ts +3 -0
- package/es/components/icons/AlignLeftIcon.js +7 -0
- package/es/components/icons/ArrowDropDownIcon.d.ts +3 -0
- package/es/components/icons/ArrowDropDownIcon.js +7 -0
- package/es/components/icons/ChevronRightIcon.d.ts +3 -0
- package/es/components/icons/ChevronRightIcon.js +7 -0
- package/es/components/icons/ColorizeIcon.d.ts +3 -0
- package/es/components/icons/ColorizeIcon.js +7 -0
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +9 -0
- package/es/components/icons/LinkOffIcon.d.ts +3 -0
- package/es/components/icons/LinkOffIcon.js +7 -0
- package/es/components/icons/MinusIcon.d.ts +3 -0
- package/es/components/icons/MinusIcon.js +7 -0
- package/es/components/icons/index.d.ts +9 -0
- package/es/components/icons/index.js +9 -0
- package/es/components/index.scss +1 -0
- package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
- package/es/components/molecules/EmojiCollections/types.d.ts +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +2 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +11 -0
- package/es/components/molecules/EyedropperButton/EyedropperButton.js +34 -0
- package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
- package/es/components/molecules/EyedropperButton/index.js +1 -0
- package/es/components/molecules/EyedropperButton/styled.d.ts +7 -0
- package/es/components/molecules/EyedropperButton/styled.js +23 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +134 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +8 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +14 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +21 -0
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +19 -0
- package/es/components/molecules/FontSizeInput/constants.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/constants.js +5 -0
- package/es/components/molecules/FontSizeInput/index.d.ts +2 -0
- package/es/components/molecules/FontSizeInput/index.js +1 -0
- package/es/components/molecules/FontSizeInput/styled.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/styled.js +39 -0
- package/es/components/molecules/FontSizeInput/types.d.ts +23 -0
- package/es/components/molecules/FontSizeInput/types.js +1 -0
- package/es/components/molecules/FontSizeInput/utils.d.ts +7 -0
- package/es/components/molecules/FontSizeInput/utils.js +9 -0
- package/es/components/molecules/SearchPopover/SearchPopover.d.ts +2 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +3 -3
- package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
- package/es/components/molecules/SearchPopover/styled.js +1 -2
- package/es/components/molecules/SearchPopover/types.d.ts +4 -3
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +6 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +49 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
- package/es/components/molecules/VirtualizedMenu/styled.js +24 -3
- package/es/components/molecules/VirtualizedMenu/types.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +2 -0
- package/es/components/molecules/VirtualizedMenu/utils.js +2 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/molecules/index.js +1 -0
- package/es/components/molecules/index.scss +1 -0
- package/es/components/organism/TextEditor/TextEditor.d.ts +10 -0
- package/es/components/organism/TextEditor/TextEditor.js +403 -0
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +47 -0
- package/es/components/organism/TextEditor/constants.d.ts +196 -0
- package/es/components/organism/TextEditor/constants.js +398 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +43 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +18 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +81 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +35 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +16 -0
- package/es/components/organism/TextEditor/extensions/ClearFormatting.js +30 -0
- package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/Color.js +34 -0
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
- package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
- package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +31 -0
- package/es/components/organism/TextEditor/extensions/FontSize.js +46 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
- package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
- package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
- package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
- package/es/components/organism/TextEditor/extensions/LineHeight.js +101 -0
- package/es/components/organism/TextEditor/extensions/Link.d.ts +22 -0
- package/es/components/organism/TextEditor/extensions/Link.js +197 -0
- package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
- package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
- package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +33 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.js +194 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +30 -0
- package/es/components/organism/TextEditor/extensions/TextTransform.js +36 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
- package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
- package/es/components/organism/TextEditor/hooks/index.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/index.js +6 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
- package/es/components/organism/TextEditor/hooks/useColorSet.js +29 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +69 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
- package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
- package/es/components/organism/TextEditor/index.d.ts +18 -0
- package/es/components/organism/TextEditor/index.js +8 -0
- package/es/components/organism/TextEditor/index.scss +65 -0
- package/es/components/organism/TextEditor/provider.d.ts +15 -0
- package/es/components/organism/TextEditor/provider.js +36 -0
- package/es/components/organism/TextEditor/store.d.ts +20 -0
- package/es/components/organism/TextEditor/store.js +40 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
- package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
- package/es/components/organism/TextEditor/stories/shared.js +57 -0
- package/es/components/organism/TextEditor/styled.d.ts +9 -0
- package/es/components/organism/TextEditor/styled.js +61 -0
- package/es/components/organism/TextEditor/types.d.ts +324 -0
- package/es/components/organism/TextEditor/types.js +6 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +3 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +114 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/Button/Button.js +35 -0
- package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontItem.js +27 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +102 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +36 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.d.ts +35 -0
- package/es/components/organism/TextEditor/ui/FontPopover/types.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +58 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +75 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +85 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +93 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +20 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +32 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +19 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +41 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +8 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +51 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.js +45 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +67 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +17 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +7 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +18 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +24 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -0
- package/es/components/organism/TextEditor/utils/documentState.d.ts +73 -0
- package/es/components/organism/TextEditor/utils/documentState.js +149 -0
- package/es/components/organism/TextEditor/utils/font.d.ts +74 -0
- package/es/components/organism/TextEditor/utils/font.js +147 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +87 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +460 -0
- package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
- package/es/components/organism/TextEditor/utils/indent.js +56 -0
- package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
- package/es/components/organism/TextEditor/utils/index.js +16 -0
- package/es/components/organism/TextEditor/utils/link.d.ts +116 -0
- package/es/components/organism/TextEditor/utils/link.js +304 -0
- package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
- package/es/components/organism/TextEditor/utils/menu.js +321 -0
- package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
- package/es/components/organism/TextEditor/utils/selection.js +58 -0
- package/es/components/organism/TextEditor/utils/shared.d.ts +13 -0
- package/es/components/organism/TextEditor/utils/shared.js +52 -0
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
- package/es/components/organism/TextEditor/utils/smartTag.js +90 -0
- package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
- package/es/components/organism/TextEditor/utils/style.js +193 -0
- package/es/components/organism/index.d.ts +1 -0
- package/es/components/organism/index.js +1 -0
- package/es/components/organism/index.scss +1 -0
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/web.d.ts +8 -0
- package/es/constants/web.js +57 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
- package/es/hooks/useBroadcastedLocalStorage.js +71 -0
- package/es/hooks/useElementSize.d.ts +7 -0
- package/es/hooks/useElementSize.js +56 -0
- package/es/hooks/useEyedropper/attach.d.ts +4 -0
- package/es/hooks/useEyedropper/attach.js +9 -0
- package/es/hooks/useEyedropper/eyedropper.d.ts +69 -0
- package/es/hooks/useEyedropper/eyedropper.js +205 -0
- package/es/hooks/useEyedropper/index.d.ts +2 -0
- package/es/hooks/useEyedropper/index.js +7 -0
- package/es/hooks/useEyedropper/support.d.ts +1 -0
- package/es/hooks/useEyedropper/support.js +3 -0
- package/es/hooks/useEyedropper/types.d.ts +9 -0
- package/es/hooks/useEyedropper/types.js +1 -0
- package/es/hooks/useEyedropper/useEyedropper.d.ts +8 -0
- package/es/hooks/useEyedropper/useEyedropper.js +50 -0
- package/es/hooks/useEyedropper/utils.d.ts +11 -0
- package/es/hooks/useEyedropper/utils.js +17 -0
- package/es/hooks/useIsMounted.d.ts +1 -0
- package/es/hooks/useIsMounted.js +11 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/locales/i18n.d.ts +1 -1
- package/es/types/index.d.ts +9 -0
- package/es/utils/common.d.ts +15 -9
- package/es/utils/common.js +62 -24
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/es/utils/web.d.ts +80 -0
- package/es/utils/web.js +226 -0
- package/package.json +26 -17
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
import { type UnorderedListStyleType } from '../types';
|
|
3
|
+
type ListStyleType = UnorderedListStyleType;
|
|
4
|
+
export interface CustomUnorderedListOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The node name for the list items
|
|
7
|
+
* @default 'listItem'
|
|
8
|
+
*/
|
|
9
|
+
itemTypeName: string;
|
|
10
|
+
/**
|
|
11
|
+
* HTML attributes to add to the unordered list element
|
|
12
|
+
* @default {}
|
|
13
|
+
*/
|
|
14
|
+
HTMLAttributes: Record<string, any>;
|
|
15
|
+
/**
|
|
16
|
+
* Keep the marks when splitting the list
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
keepMarks: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Keep the attributes when splitting the list
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
keepAttributes: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Default list style type
|
|
27
|
+
* @default 'disc'
|
|
28
|
+
*/
|
|
29
|
+
defaultListStyleType: ListStyleType;
|
|
30
|
+
}
|
|
31
|
+
declare module '@tiptap/core' {
|
|
32
|
+
interface Commands<ReturnType> {
|
|
33
|
+
customUnorderedList: {
|
|
34
|
+
/**
|
|
35
|
+
* Toggle a custom unordered list
|
|
36
|
+
*/
|
|
37
|
+
toggleCustomUnorderedList: (options?: {
|
|
38
|
+
listStyleType?: ListStyleType;
|
|
39
|
+
customBulletChar?: string;
|
|
40
|
+
}) => ReturnType;
|
|
41
|
+
/**
|
|
42
|
+
* Set list style type for current unordered list
|
|
43
|
+
*/
|
|
44
|
+
setUnorderedListStyle: (options: {
|
|
45
|
+
listStyleType?: ListStyleType;
|
|
46
|
+
customBulletChar?: string;
|
|
47
|
+
}) => ReturnType;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* This extension allows you to create unordered lists with custom bullet styles.
|
|
53
|
+
*/
|
|
54
|
+
export declare const CustomUnorderedList: Node<CustomUnorderedListOptions, any>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core';
|
|
2
|
+
import { UNORDERED_LIST_STYLE_TYPE } from '../constants';
|
|
3
|
+
const ListItemName = 'listItem';
|
|
4
|
+
const TextStyleName = 'textStyle';
|
|
5
|
+
/**
|
|
6
|
+
* Input regex patterns for different bullet styles
|
|
7
|
+
*/
|
|
8
|
+
const inputRegexPatterns = {
|
|
9
|
+
disc: /^\s*([-*•])\s$/,
|
|
10
|
+
circle: /^\s*([○◯])\s$/,
|
|
11
|
+
square: /^\s*([▪■])\s$/,
|
|
12
|
+
plus: /^\s*([+])\s$/,
|
|
13
|
+
arrow: /^\s*([→➤])\s$/,
|
|
14
|
+
star: /^\s*([★☆])\s$/,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Map input characters to bullet style types
|
|
18
|
+
*/
|
|
19
|
+
const charToBulletStyle = {
|
|
20
|
+
'-': UNORDERED_LIST_STYLE_TYPE.disc,
|
|
21
|
+
'*': UNORDERED_LIST_STYLE_TYPE.disc,
|
|
22
|
+
'•': UNORDERED_LIST_STYLE_TYPE.disc,
|
|
23
|
+
'○': UNORDERED_LIST_STYLE_TYPE.circle,
|
|
24
|
+
'◯': UNORDERED_LIST_STYLE_TYPE.circle,
|
|
25
|
+
'▪': UNORDERED_LIST_STYLE_TYPE.square,
|
|
26
|
+
'■': UNORDERED_LIST_STYLE_TYPE.square,
|
|
27
|
+
'+': UNORDERED_LIST_STYLE_TYPE.custom,
|
|
28
|
+
'→': UNORDERED_LIST_STYLE_TYPE.custom,
|
|
29
|
+
'➤': UNORDERED_LIST_STYLE_TYPE.custom,
|
|
30
|
+
'★': UNORDERED_LIST_STYLE_TYPE.custom,
|
|
31
|
+
'☆': UNORDERED_LIST_STYLE_TYPE.custom,
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* This extension allows you to create unordered lists with custom bullet styles.
|
|
35
|
+
*/
|
|
36
|
+
export const CustomUnorderedList = Node.create({
|
|
37
|
+
name: 'customUnorderedList',
|
|
38
|
+
addOptions() {
|
|
39
|
+
return {
|
|
40
|
+
itemTypeName: ListItemName,
|
|
41
|
+
HTMLAttributes: {
|
|
42
|
+
style: 'margin:0.5em 0;padding-inline-start:1.2em',
|
|
43
|
+
},
|
|
44
|
+
keepMarks: false,
|
|
45
|
+
keepAttributes: false,
|
|
46
|
+
defaultListStyleType: UNORDERED_LIST_STYLE_TYPE.disc,
|
|
47
|
+
customBulletChar: '→',
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
group: 'block list',
|
|
51
|
+
content() {
|
|
52
|
+
return `${this.options.itemTypeName}+`;
|
|
53
|
+
},
|
|
54
|
+
addAttributes() {
|
|
55
|
+
return {
|
|
56
|
+
listStyleType: {
|
|
57
|
+
default: this.options.defaultListStyleType,
|
|
58
|
+
parseHTML: element => {
|
|
59
|
+
if (element.dataset.bulletChar) {
|
|
60
|
+
return UNORDERED_LIST_STYLE_TYPE.custom;
|
|
61
|
+
}
|
|
62
|
+
const style = element.getAttribute('style');
|
|
63
|
+
const listStyleType = style?.match(/list-style-type:\s*([^;]+)/)?.[1]?.trim();
|
|
64
|
+
return listStyleType || this.options.defaultListStyleType;
|
|
65
|
+
},
|
|
66
|
+
renderHTML: attributes => {
|
|
67
|
+
if (attributes.listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
style: `list-style-type: ${attributes.listStyleType}`,
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
customBulletChar: {
|
|
76
|
+
default: null,
|
|
77
|
+
parseHTML: element => element.getAttribute('data-bullet-char'),
|
|
78
|
+
renderHTML: attributes => {
|
|
79
|
+
if (attributes.listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
|
|
80
|
+
return {
|
|
81
|
+
'data-bullet-char': attributes.customBulletChar,
|
|
82
|
+
style: `list-style-type: '${attributes.customBulletChar} '`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {};
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
parseHTML() {
|
|
91
|
+
return [{ tag: 'ul' }];
|
|
92
|
+
},
|
|
93
|
+
renderHTML({ HTMLAttributes }) {
|
|
94
|
+
return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
95
|
+
},
|
|
96
|
+
addCommands() {
|
|
97
|
+
return {
|
|
98
|
+
toggleCustomUnorderedList: (options = {}) => ({ chain }) => {
|
|
99
|
+
const { listStyleType = this.options.defaultListStyleType, customBulletChar } = options;
|
|
100
|
+
if (this.options.keepAttributes) {
|
|
101
|
+
return chain()
|
|
102
|
+
.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
103
|
+
.updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))
|
|
104
|
+
.updateAttributes(this.name, {
|
|
105
|
+
listStyleType,
|
|
106
|
+
customBulletChar,
|
|
107
|
+
})
|
|
108
|
+
.run();
|
|
109
|
+
}
|
|
110
|
+
return chain()
|
|
111
|
+
.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
112
|
+
.updateAttributes(this.name, {
|
|
113
|
+
listStyleType,
|
|
114
|
+
customBulletChar,
|
|
115
|
+
})
|
|
116
|
+
.run();
|
|
117
|
+
},
|
|
118
|
+
setUnorderedListStyle: (options = {}) => ({ commands }) => {
|
|
119
|
+
const { listStyleType, customBulletChar } = options;
|
|
120
|
+
return commands.updateAttributes(this.name, {
|
|
121
|
+
listStyleType,
|
|
122
|
+
customBulletChar,
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
addKeyboardShortcuts() {
|
|
128
|
+
return {
|
|
129
|
+
'Mod-Shift-8': () => this.editor.commands.toggleCustomUnorderedList(),
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
addInputRules() {
|
|
133
|
+
const inputRules = [];
|
|
134
|
+
Object.values(inputRegexPatterns).forEach(regex => {
|
|
135
|
+
let inputRule = wrappingInputRule({
|
|
136
|
+
find: regex,
|
|
137
|
+
type: this.type,
|
|
138
|
+
getAttributes: match => {
|
|
139
|
+
const char = match[1];
|
|
140
|
+
const listStyleType = charToBulletStyle[char] || UNORDERED_LIST_STYLE_TYPE.disc;
|
|
141
|
+
if (listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
|
|
142
|
+
return {
|
|
143
|
+
listStyleType: UNORDERED_LIST_STYLE_TYPE.custom,
|
|
144
|
+
customBulletChar: char,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return { listStyleType };
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
if (this.options.keepMarks || this.options.keepAttributes) {
|
|
151
|
+
inputRule = wrappingInputRule({
|
|
152
|
+
find: regex,
|
|
153
|
+
type: this.type,
|
|
154
|
+
keepMarks: this.options.keepMarks,
|
|
155
|
+
keepAttributes: this.options.keepAttributes,
|
|
156
|
+
getAttributes: match => {
|
|
157
|
+
const char = match[1];
|
|
158
|
+
const listStyleType = charToBulletStyle[char] || UNORDERED_LIST_STYLE_TYPE.disc;
|
|
159
|
+
const baseAttributes = this.editor.getAttributes(TextStyleName);
|
|
160
|
+
if (listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
|
|
161
|
+
return {
|
|
162
|
+
...baseAttributes,
|
|
163
|
+
listStyleType: UNORDERED_LIST_STYLE_TYPE.custom,
|
|
164
|
+
customBulletChar: char,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return { ...baseAttributes, listStyleType };
|
|
168
|
+
},
|
|
169
|
+
editor: this.editor,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
inputRules.push(inputRule);
|
|
173
|
+
});
|
|
174
|
+
return inputRules;
|
|
175
|
+
},
|
|
176
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useBroadcastedLocalStorage, useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
|
|
2
|
+
import { useTextEditorStore } from '../provider';
|
|
3
|
+
import { ANTSOMI_COMPONENT_PREFIX_CLS } from '@antscorp/antsomi-ui/es/constants';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import isEqual from 'react-fast-compare';
|
|
6
|
+
export const useColorSet = () => {
|
|
7
|
+
const colors = useTextEditorStore(s => s.colors);
|
|
8
|
+
const setColors = useTextEditorStore(s => s.setColors);
|
|
9
|
+
const { value: storageColors, setValue: setStorageColors } = useBroadcastedLocalStorage(`${ANTSOMI_COMPONENT_PREFIX_CLS}_text-editor`, undefined);
|
|
10
|
+
useDeepCompareEffect(() => {
|
|
11
|
+
if (storageColors === undefined && colors !== undefined) {
|
|
12
|
+
setStorageColors(colors);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (colors === undefined && storageColors !== undefined) {
|
|
16
|
+
setColors(storageColors);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Sync store → localStorage when both defined but different
|
|
20
|
+
if (colors !== undefined && storageColors !== undefined && !isEqual(colors, storageColors)) {
|
|
21
|
+
setStorageColors(colors);
|
|
22
|
+
}
|
|
23
|
+
}, [colors, storageColors, setColors, setStorageColors]);
|
|
24
|
+
const composeSetColors = useCallback((newColors) => {
|
|
25
|
+
setColors(newColors);
|
|
26
|
+
setStorageColors(newColors);
|
|
27
|
+
}, [setColors, setStorageColors]);
|
|
28
|
+
return { colors: colors || [], setColors: composeSetColors };
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { DocumentStateConfig, getDocumentStats } from '../utils/documentState';
|
|
3
|
+
export interface UseDocumentStateOptions extends DocumentStateConfig {
|
|
4
|
+
/** Callback when document becomes empty */
|
|
5
|
+
onBecomeEmpty?: () => void;
|
|
6
|
+
/** Callback when document becomes non-empty */
|
|
7
|
+
onBecomeNonEmpty?: () => void;
|
|
8
|
+
/** Callback when document state changes */
|
|
9
|
+
onStateChange?: (stats: ReturnType<typeof getDocumentStats>) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function useDocumentState(editor: Editor | null, options?: UseDocumentStateOptions): {
|
|
12
|
+
nodeSize: number;
|
|
13
|
+
textLength: number;
|
|
14
|
+
trimmedTextLength: number;
|
|
15
|
+
nodeCount: void;
|
|
16
|
+
isEmpty: boolean;
|
|
17
|
+
emptyDocumentSize: number;
|
|
18
|
+
} | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { DocumentStateTracker, getDocumentStats, } from '../utils/documentState';
|
|
3
|
+
export function useDocumentState(editor, options = {}) {
|
|
4
|
+
const { onBecomeEmpty, onBecomeNonEmpty, onStateChange } = options;
|
|
5
|
+
const [documentStats, setDocumentStats] = useState(() => editor ? getDocumentStats(editor.state) : null);
|
|
6
|
+
const trackerRef = useRef(new DocumentStateTracker());
|
|
7
|
+
const updateDocumentState = useCallback(() => {
|
|
8
|
+
if (!editor)
|
|
9
|
+
return;
|
|
10
|
+
const stats = getDocumentStats(editor.state);
|
|
11
|
+
const changes = trackerRef.current.update(editor.state);
|
|
12
|
+
setDocumentStats(stats);
|
|
13
|
+
// Trigger callbacks
|
|
14
|
+
if (changes.becameEmpty) {
|
|
15
|
+
onBecomeEmpty?.();
|
|
16
|
+
}
|
|
17
|
+
if (changes.becameNonEmpty) {
|
|
18
|
+
onBecomeNonEmpty?.();
|
|
19
|
+
}
|
|
20
|
+
if (changes.sizeChanged || changes.textLengthChanged) {
|
|
21
|
+
onStateChange?.(stats);
|
|
22
|
+
}
|
|
23
|
+
}, [editor, onBecomeEmpty, onBecomeNonEmpty, onStateChange]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!editor)
|
|
26
|
+
return;
|
|
27
|
+
// Initial state
|
|
28
|
+
updateDocumentState();
|
|
29
|
+
// Listen to changes
|
|
30
|
+
editor.on('update', updateDocumentState);
|
|
31
|
+
editor.on('transaction', updateDocumentState);
|
|
32
|
+
return () => {
|
|
33
|
+
editor.off('update', updateDocumentState);
|
|
34
|
+
editor.off('transaction', updateDocumentState);
|
|
35
|
+
};
|
|
36
|
+
}, [editor, updateDocumentState]);
|
|
37
|
+
// Reset tracker when editor changes
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
trackerRef.current.reset();
|
|
40
|
+
}, [editor]);
|
|
41
|
+
return documentStats;
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { Mark } from '@tiptap/pm/model';
|
|
3
|
+
export interface MarkSnapshot {
|
|
4
|
+
marks: Mark[];
|
|
5
|
+
position: number;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
textContent: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UseMarkTrackingOptions {
|
|
10
|
+
/** Maximum number of snapshots to keep */
|
|
11
|
+
maxSnapshots?: number;
|
|
12
|
+
/** Marks to exclude from tracking */
|
|
13
|
+
excludeMarks?: string[];
|
|
14
|
+
/** Debounce delay for tracking (ms) */
|
|
15
|
+
debounceDelay?: number;
|
|
16
|
+
/** Auto-capture snapshots */
|
|
17
|
+
autoCapture?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function useMarkTracking(editor: Editor | null, options?: UseMarkTrackingOptions): {
|
|
20
|
+
snapshots: MarkSnapshot[];
|
|
21
|
+
currentMarks: Mark[];
|
|
22
|
+
captureMarkSnapshot: () => void;
|
|
23
|
+
applySnapshot: (index: number) => void;
|
|
24
|
+
getSimilarSnapshots: (targetMarks?: Mark[]) => MarkSnapshot[];
|
|
25
|
+
clearSnapshots: () => void;
|
|
26
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { textBetween } from '../utils';
|
|
3
|
+
export function useMarkTracking(editor, options = {}) {
|
|
4
|
+
const { maxSnapshots = 10, excludeMarks = ['link', 'smartTag'], debounceDelay = 500, autoCapture = true, } = options;
|
|
5
|
+
const [snapshots, setSnapshots] = useState([]);
|
|
6
|
+
const [currentMarks, setCurrentMarks] = useState([]);
|
|
7
|
+
// Capture current mark state
|
|
8
|
+
const captureMarkSnapshot = useCallback(() => {
|
|
9
|
+
if (!editor)
|
|
10
|
+
return;
|
|
11
|
+
const { selection, storedMarks } = editor.state;
|
|
12
|
+
const { $from } = selection;
|
|
13
|
+
const marks = (storedMarks || $from.marks()).filter(mark => !excludeMarks.includes(mark.type.name));
|
|
14
|
+
const snapshot = {
|
|
15
|
+
marks,
|
|
16
|
+
position: $from.pos,
|
|
17
|
+
timestamp: Date.now(),
|
|
18
|
+
textContent: textBetween(editor.state, Math.max(0, $from.pos - 50), Math.min(editor.state.doc.content.size, $from.pos + 50)),
|
|
19
|
+
};
|
|
20
|
+
setSnapshots(prev => {
|
|
21
|
+
const updated = [snapshot, ...prev];
|
|
22
|
+
return updated.slice(0, maxSnapshots);
|
|
23
|
+
});
|
|
24
|
+
setCurrentMarks(marks);
|
|
25
|
+
}, [editor, excludeMarks, maxSnapshots]);
|
|
26
|
+
// Apply marks from snapshot
|
|
27
|
+
const applySnapshot = useCallback((index) => {
|
|
28
|
+
if (!editor || !snapshots[index])
|
|
29
|
+
return;
|
|
30
|
+
const snapshot = snapshots[index];
|
|
31
|
+
// Clear current marks
|
|
32
|
+
editor.chain().unsetAllMarks().run();
|
|
33
|
+
// Apply snapshot marks
|
|
34
|
+
snapshot.marks.forEach(mark => {
|
|
35
|
+
editor.chain().setMark(mark.type.name, mark.attrs).run();
|
|
36
|
+
});
|
|
37
|
+
}, [editor, snapshots]);
|
|
38
|
+
// Get similar snapshots based on marks
|
|
39
|
+
const getSimilarSnapshots = useCallback((targetMarks = currentMarks) => snapshots.filter(snapshot => {
|
|
40
|
+
const markNames = snapshot.marks.map(m => m.type.name).sort();
|
|
41
|
+
const targetNames = targetMarks.map(m => m.type.name).sort();
|
|
42
|
+
return JSON.stringify(markNames) === JSON.stringify(targetNames);
|
|
43
|
+
}), [snapshots, currentMarks]);
|
|
44
|
+
// Auto-capture setup
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!editor || !autoCapture)
|
|
47
|
+
return;
|
|
48
|
+
let timeoutId;
|
|
49
|
+
const handleUpdate = () => {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
timeoutId = setTimeout(captureMarkSnapshot, debounceDelay);
|
|
52
|
+
};
|
|
53
|
+
editor.on('selectionUpdate', handleUpdate);
|
|
54
|
+
editor.on('update', handleUpdate);
|
|
55
|
+
return () => {
|
|
56
|
+
clearTimeout(timeoutId);
|
|
57
|
+
editor.off('selectionUpdate', handleUpdate);
|
|
58
|
+
editor.off('update', handleUpdate);
|
|
59
|
+
};
|
|
60
|
+
}, [editor, autoCapture, debounceDelay, captureMarkSnapshot]);
|
|
61
|
+
return {
|
|
62
|
+
snapshots,
|
|
63
|
+
currentMarks,
|
|
64
|
+
captureMarkSnapshot,
|
|
65
|
+
applySnapshot,
|
|
66
|
+
getSimilarSnapshots,
|
|
67
|
+
clearSnapshots: () => setSnapshots([]),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
export interface PersistenceConfig {
|
|
3
|
+
/** Storage key */
|
|
4
|
+
key: string;
|
|
5
|
+
/** Storage type */
|
|
6
|
+
storage?: 'localStorage' | 'sessionStorage' | 'indexedDB';
|
|
7
|
+
/** Auto-save delay */
|
|
8
|
+
autoSaveDelay?: number;
|
|
9
|
+
/** Version for data migration */
|
|
10
|
+
version?: number;
|
|
11
|
+
/** Compression */
|
|
12
|
+
compress?: boolean;
|
|
13
|
+
/** Encryption key */
|
|
14
|
+
encryptionKey?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PersistentData {
|
|
17
|
+
content: string;
|
|
18
|
+
marks: any[];
|
|
19
|
+
metadata: {
|
|
20
|
+
timestamp: number;
|
|
21
|
+
version: number;
|
|
22
|
+
wordCount: number;
|
|
23
|
+
characterCount: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare function usePersistence(editor: Editor | null, config: PersistenceConfig): {
|
|
27
|
+
save: () => Promise<void>;
|
|
28
|
+
load: () => Promise<boolean>;
|
|
29
|
+
saveToStorage: (data: PersistentData) => Promise<void>;
|
|
30
|
+
loadFromStorage: () => Promise<PersistentData | null>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useDebouncedCallback } from 'use-debounce';
|
|
3
|
+
// Helper functions (simplified implementations)
|
|
4
|
+
async function compressString(str) {
|
|
5
|
+
// Implement compression logic
|
|
6
|
+
return str;
|
|
7
|
+
}
|
|
8
|
+
async function decompressString(str) {
|
|
9
|
+
// Implement decompression logic
|
|
10
|
+
return str;
|
|
11
|
+
}
|
|
12
|
+
async function encryptString(str, _key) {
|
|
13
|
+
// Implement encryption logic
|
|
14
|
+
return str;
|
|
15
|
+
}
|
|
16
|
+
async function decryptString(str, _key) {
|
|
17
|
+
// Implement decryption logic
|
|
18
|
+
return str;
|
|
19
|
+
}
|
|
20
|
+
async function saveToIndexedDB(_key, _data) {
|
|
21
|
+
// Implement IndexedDB save
|
|
22
|
+
}
|
|
23
|
+
async function loadFromIndexedDB(_key) {
|
|
24
|
+
// Implement IndexedDB load
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
function migrateData(data, _targetVersion) {
|
|
28
|
+
// Implement data migration logic
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
export function usePersistence(editor, config) {
|
|
32
|
+
const { key, storage = 'localStorage', autoSaveDelay = 2000, version = 1, compress = false, encryptionKey, } = config;
|
|
33
|
+
const lastSavedContent = useRef('');
|
|
34
|
+
// Storage operations
|
|
35
|
+
const saveToStorage = useCallback(async (data) => {
|
|
36
|
+
try {
|
|
37
|
+
let serializedData = JSON.stringify(data);
|
|
38
|
+
// Apply compression if enabled
|
|
39
|
+
if (compress && 'CompressionStream' in window) {
|
|
40
|
+
// Use browser compression API if available
|
|
41
|
+
serializedData = await compressString(serializedData);
|
|
42
|
+
}
|
|
43
|
+
// Apply encryption if key provided
|
|
44
|
+
if (encryptionKey) {
|
|
45
|
+
serializedData = await encryptString(serializedData, encryptionKey);
|
|
46
|
+
}
|
|
47
|
+
switch (storage) {
|
|
48
|
+
case 'localStorage':
|
|
49
|
+
localStorage.setItem(key, serializedData);
|
|
50
|
+
break;
|
|
51
|
+
case 'sessionStorage':
|
|
52
|
+
sessionStorage.setItem(key, serializedData);
|
|
53
|
+
break;
|
|
54
|
+
case 'indexedDB':
|
|
55
|
+
await saveToIndexedDB(key, serializedData);
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
// eslint-disable-next-line no-console
|
|
63
|
+
console.error('Failed to save to storage:', error);
|
|
64
|
+
}
|
|
65
|
+
}, [key, storage, compress, encryptionKey]);
|
|
66
|
+
const loadFromStorage = useCallback(async () => {
|
|
67
|
+
try {
|
|
68
|
+
let serializedData = null;
|
|
69
|
+
switch (storage) {
|
|
70
|
+
case 'localStorage':
|
|
71
|
+
serializedData = localStorage.getItem(key);
|
|
72
|
+
break;
|
|
73
|
+
case 'sessionStorage':
|
|
74
|
+
serializedData = sessionStorage.getItem(key);
|
|
75
|
+
break;
|
|
76
|
+
case 'indexedDB':
|
|
77
|
+
serializedData = await loadFromIndexedDB(key);
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (!serializedData)
|
|
83
|
+
return null;
|
|
84
|
+
// Apply decryption if key provided
|
|
85
|
+
if (encryptionKey) {
|
|
86
|
+
serializedData = await decryptString(serializedData, encryptionKey);
|
|
87
|
+
}
|
|
88
|
+
// Apply decompression if enabled
|
|
89
|
+
if (compress && 'DecompressionStream' in window) {
|
|
90
|
+
serializedData = await decompressString(serializedData);
|
|
91
|
+
}
|
|
92
|
+
const data = JSON.parse(serializedData);
|
|
93
|
+
// Handle version migration
|
|
94
|
+
if (data.metadata.version !== version) {
|
|
95
|
+
return migrateData(data, version);
|
|
96
|
+
}
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
// eslint-disable-next-line no-console
|
|
101
|
+
console.error('Failed to load from storage:', error);
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}, [key, storage, compress, encryptionKey, version]);
|
|
105
|
+
// Auto-save debounced function
|
|
106
|
+
const debouncedSave = useDebouncedCallback(async () => {
|
|
107
|
+
if (!editor)
|
|
108
|
+
return;
|
|
109
|
+
const currentContent = editor.getHTML();
|
|
110
|
+
// Only save if content changed
|
|
111
|
+
if (currentContent === lastSavedContent.current)
|
|
112
|
+
return;
|
|
113
|
+
const { selection, storedMarks } = editor.state;
|
|
114
|
+
const marks = storedMarks || selection.$from.marks();
|
|
115
|
+
const data = {
|
|
116
|
+
content: currentContent,
|
|
117
|
+
marks: marks.map(mark => ({
|
|
118
|
+
type: mark.type.name,
|
|
119
|
+
attrs: mark.attrs,
|
|
120
|
+
})),
|
|
121
|
+
metadata: {
|
|
122
|
+
timestamp: Date.now(),
|
|
123
|
+
version,
|
|
124
|
+
wordCount: editor.state.doc.textContent.split(/\s+/).length,
|
|
125
|
+
characterCount: editor.state.doc.textContent.length,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
await saveToStorage(data);
|
|
129
|
+
lastSavedContent.current = currentContent;
|
|
130
|
+
}, autoSaveDelay);
|
|
131
|
+
// Manual save
|
|
132
|
+
const save = useCallback(async () => {
|
|
133
|
+
debouncedSave.flush();
|
|
134
|
+
}, [debouncedSave]);
|
|
135
|
+
// Load data
|
|
136
|
+
const load = useCallback(async () => {
|
|
137
|
+
if (!editor)
|
|
138
|
+
return false;
|
|
139
|
+
const data = await loadFromStorage();
|
|
140
|
+
if (!data)
|
|
141
|
+
return false;
|
|
142
|
+
// Set content
|
|
143
|
+
editor.commands.setContent(data.content);
|
|
144
|
+
// Restore marks if available
|
|
145
|
+
if (data.marks.length > 0) {
|
|
146
|
+
data.marks.forEach(({ type, attrs }) => {
|
|
147
|
+
editor.commands.setMark(type, attrs);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
lastSavedContent.current = data.content;
|
|
151
|
+
return true;
|
|
152
|
+
}, [editor, loadFromStorage]);
|
|
153
|
+
// Auto-save setup
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!editor)
|
|
156
|
+
return;
|
|
157
|
+
editor.on('update', debouncedSave);
|
|
158
|
+
return () => {
|
|
159
|
+
editor.off('update', debouncedSave);
|
|
160
|
+
debouncedSave.flush(); // Save any pending changes
|
|
161
|
+
};
|
|
162
|
+
}, [editor, debouncedSave]);
|
|
163
|
+
return {
|
|
164
|
+
save,
|
|
165
|
+
load,
|
|
166
|
+
saveToStorage,
|
|
167
|
+
loadFromStorage,
|
|
168
|
+
};
|
|
169
|
+
}
|