@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,193 @@
|
|
|
1
|
+
import { DEFAULT_TEXT_STYLE, LINK_TEXT_COLOR } from '../constants';
|
|
2
|
+
import { uniqBy } from 'lodash';
|
|
3
|
+
import tinycolor from 'tinycolor2';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts text style from element's computed style
|
|
6
|
+
* @param style CSSStyleDeclaration from element
|
|
7
|
+
* @returns Partial TextStyle object
|
|
8
|
+
*/
|
|
9
|
+
export const textStyleFromElStyle = (style, defaultStyle) => ({
|
|
10
|
+
color: style.color || defaultStyle.color || 'inherit',
|
|
11
|
+
fontFamily: style.fontFamily || defaultStyle.fontFamily || 'inherit',
|
|
12
|
+
fontSize: style.fontSize || defaultStyle.fontSize || 'inherit',
|
|
13
|
+
lineHeight: style.lineHeight || defaultStyle.lineHeight || '1.15',
|
|
14
|
+
backgroundColor: style.backgroundColor,
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Applies text style to HTML element
|
|
18
|
+
* @param el HTML element to apply styles to
|
|
19
|
+
* @param style TextStyle object
|
|
20
|
+
*/
|
|
21
|
+
export const appendTextStyleToEl = (el, style) => {
|
|
22
|
+
if (style.color) {
|
|
23
|
+
el.style.color = style.color;
|
|
24
|
+
}
|
|
25
|
+
if (style.fontSize) {
|
|
26
|
+
el.style.fontSize = style.fontSize;
|
|
27
|
+
}
|
|
28
|
+
if (style.fontFamily) {
|
|
29
|
+
el.style.fontFamily = style.fontFamily;
|
|
30
|
+
}
|
|
31
|
+
if (style.backgroundColor) {
|
|
32
|
+
el.style.backgroundColor = style.backgroundColor;
|
|
33
|
+
}
|
|
34
|
+
if (style.lineHeight) {
|
|
35
|
+
el.style.lineHeight = style.lineHeight;
|
|
36
|
+
}
|
|
37
|
+
if (style.fontWeight) {
|
|
38
|
+
el.style.fontWeight = style.fontWeight;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Converts a style object to a CSS string representation
|
|
43
|
+
* @param styleObj The style object to convert
|
|
44
|
+
* @returns The CSS string representation
|
|
45
|
+
* @example
|
|
46
|
+
* styleObjectToString({ color: 'red', fontSize: '16px' })
|
|
47
|
+
* // returns "color: red; font-size: 16px"
|
|
48
|
+
*/
|
|
49
|
+
export function styleObjectToString(styleObj) {
|
|
50
|
+
return Object.entries(styleObj)
|
|
51
|
+
.map(([key, value]) => {
|
|
52
|
+
// Nếu key đã là kebab-case hoặc bắt đầu bằng dấu '-', giữ nguyên
|
|
53
|
+
const isPrefixed = key.startsWith('-');
|
|
54
|
+
const kebabKey = isPrefixed ? key : key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
|
|
55
|
+
return `${kebabKey}: ${value}`;
|
|
56
|
+
})
|
|
57
|
+
.join('; ');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Normalizes a font-family string by adding quotes when needed
|
|
61
|
+
* @param fontFamily The font-family string to normalize
|
|
62
|
+
* @returns The normalized font-family string
|
|
63
|
+
* @description
|
|
64
|
+
* - Preserves existing quoted names
|
|
65
|
+
* - Doesn't quote generic families (e.g. sans-serif)
|
|
66
|
+
* - Quotes names containing spaces or special characters
|
|
67
|
+
* @example
|
|
68
|
+
* normalizeFontFamily('Arial, Helvetica, sans-serif')
|
|
69
|
+
* // returns 'Arial, Helvetica, sans-serif'
|
|
70
|
+
*
|
|
71
|
+
* normalizeFontFamily('Times New Roman, serif')
|
|
72
|
+
* // returns '"Times New Roman", serif'
|
|
73
|
+
*/
|
|
74
|
+
export function normalizeFontFamily(fontFamily) {
|
|
75
|
+
if (!fontFamily || typeof fontFamily !== 'string')
|
|
76
|
+
return '';
|
|
77
|
+
const genericFamilies = new Set([
|
|
78
|
+
'serif',
|
|
79
|
+
'sans-serif',
|
|
80
|
+
'monospace',
|
|
81
|
+
'cursive',
|
|
82
|
+
'fantasy',
|
|
83
|
+
'system-ui',
|
|
84
|
+
'ui-serif',
|
|
85
|
+
'ui-sans-serif',
|
|
86
|
+
'ui-monospace',
|
|
87
|
+
'ui-rounded',
|
|
88
|
+
'math',
|
|
89
|
+
'emoji',
|
|
90
|
+
'fangsong',
|
|
91
|
+
]);
|
|
92
|
+
return uniqBy(fontFamily.split(','), name => name.trim())
|
|
93
|
+
.map(name => {
|
|
94
|
+
const trimmed = name.trim();
|
|
95
|
+
// Preserve already quoted names
|
|
96
|
+
const isQuoted = (trimmed.startsWith('"') && trimmed.endsWith('"')) ||
|
|
97
|
+
(trimmed.startsWith("'") && trimmed.endsWith("'"));
|
|
98
|
+
if (isQuoted)
|
|
99
|
+
return trimmed;
|
|
100
|
+
// Do not quote generic family names
|
|
101
|
+
if (genericFamilies.has(trimmed))
|
|
102
|
+
return trimmed;
|
|
103
|
+
// Quote if contains whitespace or special characters
|
|
104
|
+
const needsQuotes = /[^\w-]/.test(trimmed);
|
|
105
|
+
return needsQuotes ? `"${trimmed}"` : trimmed;
|
|
106
|
+
})
|
|
107
|
+
.join(', ');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates font-family string with fallback
|
|
111
|
+
* @param fontFamily Primary font family
|
|
112
|
+
* @param defaultFont Default fallback font
|
|
113
|
+
* @returns Normalized font-family string with fallback
|
|
114
|
+
*/
|
|
115
|
+
export const fontWithFallback = (fontFamily, defaultFont = DEFAULT_TEXT_STYLE.fontFamily) => normalizeFontFamily(fontFamily ? `${fontFamily}, ${defaultFont}` : defaultFont);
|
|
116
|
+
/**
|
|
117
|
+
* Checks if a color matches the link color
|
|
118
|
+
* @param color Color to check
|
|
119
|
+
* @returns true if color matches link color
|
|
120
|
+
*/
|
|
121
|
+
export const isLinkColor = (color) => tinycolor.equals(color, LINK_TEXT_COLOR);
|
|
122
|
+
/**
|
|
123
|
+
* Extracts CSS variables from a style object
|
|
124
|
+
* @param styleObj Style object that may contain CSS variables
|
|
125
|
+
* @returns Object with CSS variables and regular styles separated
|
|
126
|
+
*/
|
|
127
|
+
export function extractCSSVariables(styleObj) {
|
|
128
|
+
const cssVariables = {};
|
|
129
|
+
const regularStyles = {};
|
|
130
|
+
Object.entries(styleObj).forEach(([key, value]) => {
|
|
131
|
+
if (key.startsWith('--')) {
|
|
132
|
+
cssVariables[key] = value;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
regularStyles[key] = value;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return { cssVariables, regularStyles };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Merges multiple text styles with priority
|
|
142
|
+
* @param styles Array of text styles to merge
|
|
143
|
+
* @returns Merged text style
|
|
144
|
+
*/
|
|
145
|
+
export function mergeTextStyles(...styles) {
|
|
146
|
+
return styles.reduce((merged, style) => ({
|
|
147
|
+
...merged,
|
|
148
|
+
...Object.fromEntries(Object.entries(style).filter(([_, value]) => value !== undefined && value !== null)),
|
|
149
|
+
}), {});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Validates if a text style is complete
|
|
153
|
+
* @param style Text style to validate
|
|
154
|
+
* @returns true if all required properties are present
|
|
155
|
+
*/
|
|
156
|
+
export function isCompleteTextStyle(style) {
|
|
157
|
+
const requiredProps = [
|
|
158
|
+
'fontFamily',
|
|
159
|
+
'fontSize',
|
|
160
|
+
'color',
|
|
161
|
+
'backgroundColor',
|
|
162
|
+
'lineHeight',
|
|
163
|
+
'fontWeight',
|
|
164
|
+
];
|
|
165
|
+
return requiredProps.every(prop => style[prop] !== undefined);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Converts text style to CSS style object
|
|
169
|
+
* @param textStyle Text style object
|
|
170
|
+
* @returns CSS style object
|
|
171
|
+
*/
|
|
172
|
+
export function textStyleToCSSStyle(textStyle) {
|
|
173
|
+
const cssStyle = {};
|
|
174
|
+
if (textStyle.fontFamily) {
|
|
175
|
+
cssStyle.fontFamily = textStyle.fontFamily;
|
|
176
|
+
}
|
|
177
|
+
if (textStyle.fontSize) {
|
|
178
|
+
cssStyle.fontSize = textStyle.fontSize;
|
|
179
|
+
}
|
|
180
|
+
if (textStyle.color) {
|
|
181
|
+
cssStyle.color = textStyle.color;
|
|
182
|
+
}
|
|
183
|
+
if (textStyle.backgroundColor) {
|
|
184
|
+
cssStyle.backgroundColor = textStyle.backgroundColor;
|
|
185
|
+
}
|
|
186
|
+
if (textStyle.lineHeight) {
|
|
187
|
+
cssStyle.lineHeight = textStyle.lineHeight;
|
|
188
|
+
}
|
|
189
|
+
if (textStyle.fontWeight) {
|
|
190
|
+
cssStyle.fontWeight = textStyle.fontWeight;
|
|
191
|
+
}
|
|
192
|
+
return cssStyle;
|
|
193
|
+
}
|
|
@@ -16,5 +16,6 @@ export * from './Login';
|
|
|
16
16
|
export * from './BasicLogin';
|
|
17
17
|
export * from './Filter';
|
|
18
18
|
export { ActivityTimeline, type ActivityTimeLineProps } from './ActivityTimeline';
|
|
19
|
+
export { TextEditor, TextEditorProvider, type TextEditorWithProviderRef, type TextEditorAllProps, type TextEditorProps, type TextEditorRef, type TextEditorJSONContent, type TextEditorProviderProps, type TextEditorProviderRefHandler, type TextEditorComponentsRender, type FontConfig, CUSTOM_LINK_EXTENSION_NAME, } from './TextEditor';
|
|
19
20
|
export { SQLGeneration, SQLGenerationIntegrations, SQLGenerationProvider, useSQLGenerationStore, type SQLGenerationProps, type SQLGenerationProviderProps, } from './SQLGeneration';
|
|
20
21
|
export { WhatsappMobile, SAMPLE_PREVIEW } from './PreviewCollections';
|
|
@@ -16,5 +16,6 @@ export * from './Login';
|
|
|
16
16
|
export * from './BasicLogin';
|
|
17
17
|
export * from './Filter';
|
|
18
18
|
export { ActivityTimeline } from './ActivityTimeline';
|
|
19
|
+
export { TextEditor, TextEditorProvider, CUSTOM_LINK_EXTENSION_NAME, } from './TextEditor';
|
|
19
20
|
export { SQLGeneration, SQLGenerationIntegrations, SQLGenerationProvider, useSQLGenerationStore, } from './SQLGeneration';
|
|
20
21
|
export { WhatsappMobile, SAMPLE_PREVIEW } from './PreviewCollections';
|
package/es/constants/index.d.ts
CHANGED
package/es/constants/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic font families that are CSS keywords, not specific fonts
|
|
3
|
+
*/
|
|
4
|
+
export declare const GENERIC_FONT_FAMILIES: readonly ["serif", "sans-serif", "monospace", "cursive", "fantasy", "system-ui", "ui-serif", "ui-sans-serif", "ui-monospace", "ui-rounded"];
|
|
5
|
+
/**
|
|
6
|
+
* List of web safe fonts that are commonly available across different operating systems
|
|
7
|
+
*/
|
|
8
|
+
export declare const WEB_SAFE_FONTS: readonly ["times new roman", "times", "georgia", "garamond", "book antiqua", "palatino linotype", "palatino", "arial", "helvetica", "arial black", "impact", "lucida sans unicode", "tahoma", "verdana", "ms sans serif", "geneva", "lucida console", "lucida sans", "trebuchet ms", "courier new", "courier", "monaco", "menlo", "consolas", "lucida console", "comic sans ms", "brush script mt", "papyrus", "copperplate", "fantasy", "system ui"];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic font families that are CSS keywords, not specific fonts
|
|
3
|
+
*/
|
|
4
|
+
export const GENERIC_FONT_FAMILIES = [
|
|
5
|
+
'serif',
|
|
6
|
+
'sans-serif',
|
|
7
|
+
'monospace',
|
|
8
|
+
'cursive',
|
|
9
|
+
'fantasy',
|
|
10
|
+
'system-ui',
|
|
11
|
+
'ui-serif',
|
|
12
|
+
'ui-sans-serif',
|
|
13
|
+
'ui-monospace',
|
|
14
|
+
'ui-rounded',
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* List of web safe fonts that are commonly available across different operating systems
|
|
18
|
+
*/
|
|
19
|
+
export const WEB_SAFE_FONTS = [
|
|
20
|
+
// Serif fonts
|
|
21
|
+
'times new roman',
|
|
22
|
+
'times',
|
|
23
|
+
'georgia',
|
|
24
|
+
'garamond',
|
|
25
|
+
'book antiqua',
|
|
26
|
+
'palatino linotype',
|
|
27
|
+
'palatino',
|
|
28
|
+
// Sans-serif fonts
|
|
29
|
+
'arial',
|
|
30
|
+
'helvetica',
|
|
31
|
+
'arial black',
|
|
32
|
+
'impact',
|
|
33
|
+
'lucida sans unicode',
|
|
34
|
+
'tahoma',
|
|
35
|
+
'verdana',
|
|
36
|
+
'ms sans serif',
|
|
37
|
+
'geneva',
|
|
38
|
+
'lucida console',
|
|
39
|
+
'lucida sans',
|
|
40
|
+
'trebuchet ms', // Added: Microsoft font since Windows 2000, but use carefully
|
|
41
|
+
// Monospace fonts
|
|
42
|
+
'courier new',
|
|
43
|
+
'courier',
|
|
44
|
+
'monaco',
|
|
45
|
+
'menlo',
|
|
46
|
+
'consolas',
|
|
47
|
+
'lucida console',
|
|
48
|
+
// Cursive fonts
|
|
49
|
+
'comic sans ms',
|
|
50
|
+
'brush script mt',
|
|
51
|
+
// Fantasy fonts
|
|
52
|
+
'papyrus',
|
|
53
|
+
'copperplate',
|
|
54
|
+
'fantasy',
|
|
55
|
+
// Unknown
|
|
56
|
+
'system ui',
|
|
57
|
+
];
|
package/es/hooks/index.d.ts
CHANGED
|
@@ -26,5 +26,9 @@ export * from './useCustomRouter';
|
|
|
26
26
|
export * from './useUpdateEffect';
|
|
27
27
|
export * from './useOutsideClick';
|
|
28
28
|
export * from './useDebouncedCallbackV2';
|
|
29
|
+
export * from './useElementSize';
|
|
30
|
+
export * from './useIsMounted';
|
|
31
|
+
export * from './useBroadcastedLocalStorage';
|
|
32
|
+
export * from './useEyedropper';
|
|
29
33
|
export * from './useFocusManagement';
|
|
30
34
|
export * from './useCountdown';
|
package/es/hooks/index.js
CHANGED
|
@@ -45,5 +45,9 @@ export * from './useCustomRouter';
|
|
|
45
45
|
export * from './useUpdateEffect';
|
|
46
46
|
export * from './useOutsideClick';
|
|
47
47
|
export * from './useDebouncedCallbackV2';
|
|
48
|
+
export * from './useElementSize';
|
|
49
|
+
export * from './useIsMounted';
|
|
50
|
+
export * from './useBroadcastedLocalStorage';
|
|
51
|
+
export * from './useEyedropper';
|
|
48
52
|
export * from './useFocusManagement';
|
|
49
53
|
export * from './useCountdown';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { useEffect, useState, useRef } from 'react';
|
|
3
|
+
import { useDeepCompareEffect } from './useDeepCompareEffect';
|
|
4
|
+
export function useBroadcastedLocalStorage(key, initialValue) {
|
|
5
|
+
const [value, setValue] = useState(() => {
|
|
6
|
+
if (typeof window === 'undefined')
|
|
7
|
+
return initialValue;
|
|
8
|
+
try {
|
|
9
|
+
const saved = window.localStorage.getItem(key);
|
|
10
|
+
return saved != null ? JSON.parse(saved) : initialValue;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return initialValue;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
// We keep a ref to avoid re-creating the channel on every render
|
|
17
|
+
const channelRef = useRef(null);
|
|
18
|
+
// Initialize BroadcastChannel once
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (typeof window === 'undefined' || !('BroadcastChannel' in window)) {
|
|
21
|
+
console.warn('BroadcastChannel not supported in this environment');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const channel = new BroadcastChannel(`localstorage_${key}`);
|
|
25
|
+
channelRef.current = channel;
|
|
26
|
+
// Listen for incoming messages
|
|
27
|
+
const onMessage = (event) => {
|
|
28
|
+
setValue(event.data.value);
|
|
29
|
+
};
|
|
30
|
+
channel.addEventListener('message', onMessage);
|
|
31
|
+
return () => {
|
|
32
|
+
channel.removeEventListener('message', onMessage);
|
|
33
|
+
channel.close();
|
|
34
|
+
};
|
|
35
|
+
}, [key]);
|
|
36
|
+
// Whenever `value` changes, persist and broadcast
|
|
37
|
+
useDeepCompareEffect(() => {
|
|
38
|
+
if (typeof window === 'undefined')
|
|
39
|
+
return;
|
|
40
|
+
try {
|
|
41
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
console.error('Failed to write to localStorage:', err);
|
|
45
|
+
}
|
|
46
|
+
if (channelRef.current) {
|
|
47
|
+
channelRef.current.postMessage({ value });
|
|
48
|
+
}
|
|
49
|
+
}, [key, value]);
|
|
50
|
+
// Expose setter that mirrors functional API of useState
|
|
51
|
+
const setValueAndBroadcast = (next) => {
|
|
52
|
+
setValue(prev => {
|
|
53
|
+
const computed = next instanceof Function ? next(prev) : next;
|
|
54
|
+
return computed;
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
// Optional: a remove function
|
|
58
|
+
const remove = () => {
|
|
59
|
+
try {
|
|
60
|
+
window.localStorage.removeItem(key);
|
|
61
|
+
setValue(initialValue);
|
|
62
|
+
if (channelRef.current) {
|
|
63
|
+
channelRef.current.postMessage({ value: initialValue });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.error('Failed to remove localStorage item:', err);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return { value, setValue: setValueAndBroadcast, remove };
|
|
71
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
2
|
+
export const useElementSize = (options = { type: 'offset' }) => {
|
|
3
|
+
const { type = 'offset' } = options;
|
|
4
|
+
const [size, setSize] = useState({
|
|
5
|
+
width: 0,
|
|
6
|
+
height: 0,
|
|
7
|
+
});
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const updateSize = useCallback(() => {
|
|
10
|
+
if (ref.current) {
|
|
11
|
+
let width;
|
|
12
|
+
let height;
|
|
13
|
+
switch (type) {
|
|
14
|
+
case 'client':
|
|
15
|
+
width = ref.current.clientWidth; // excludes padding, border, scrollbar
|
|
16
|
+
height = ref.current.clientHeight;
|
|
17
|
+
break;
|
|
18
|
+
case 'scroll':
|
|
19
|
+
width = ref.current.scrollWidth; // includes all scrollable content
|
|
20
|
+
height = ref.current.scrollHeight;
|
|
21
|
+
break;
|
|
22
|
+
case 'offset':
|
|
23
|
+
default:
|
|
24
|
+
width = ref.current.offsetWidth; // includes padding and border
|
|
25
|
+
height = ref.current.offsetHeight;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
setSize({ width, height });
|
|
29
|
+
}
|
|
30
|
+
}, [type]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const element = ref.current;
|
|
33
|
+
if (!element)
|
|
34
|
+
return;
|
|
35
|
+
// Set initial size
|
|
36
|
+
updateSize();
|
|
37
|
+
// Use ResizeObserver if available
|
|
38
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
39
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
40
|
+
// Always use the same measurement method as updateSize
|
|
41
|
+
updateSize();
|
|
42
|
+
});
|
|
43
|
+
resizeObserver.observe(element);
|
|
44
|
+
return () => {
|
|
45
|
+
resizeObserver.unobserve(element);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Fallback to window resize event
|
|
49
|
+
const handleResize = () => updateSize();
|
|
50
|
+
window.addEventListener('resize', handleResize);
|
|
51
|
+
return () => {
|
|
52
|
+
window.removeEventListener('resize', handleResize);
|
|
53
|
+
};
|
|
54
|
+
}, [updateSize]);
|
|
55
|
+
return [ref, size];
|
|
56
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EyeDropperPolyfill } from './eyedropper';
|
|
2
|
+
/**
|
|
3
|
+
* Attaches polyfill to the current window
|
|
4
|
+
*/
|
|
5
|
+
export function attachPolyfill() {
|
|
6
|
+
if (!Reflect.defineProperty(window, 'EyeDropper', { value: EyeDropperPolyfill })) {
|
|
7
|
+
throw Error("Error attaching `EyeDropper` polyfill: couldn't attach `EyeDropper` to `window`");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { EyeDropper, ColorSelectionOptions, ColorSelectionResult } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* EyeDropper API polyfill
|
|
4
|
+
* https://wicg.github.io/eyedropper-api/#dom-colorselectionoptions
|
|
5
|
+
*/
|
|
6
|
+
export declare class EyeDropperPolyfill implements EyeDropper {
|
|
7
|
+
private colorSelectionResult?;
|
|
8
|
+
private previousDocumentCursor?;
|
|
9
|
+
private canvas?;
|
|
10
|
+
private canvasCtx?;
|
|
11
|
+
private resolve?;
|
|
12
|
+
private lastPoint?;
|
|
13
|
+
private magnification;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* Opens the polyfilled eyedropper
|
|
17
|
+
*
|
|
18
|
+
* §3.3 EyeDropper interface ► `open()`
|
|
19
|
+
*/
|
|
20
|
+
open(options?: ColorSelectionOptions): Promise<ColorSelectionResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Starting eyedropper mode
|
|
23
|
+
*/
|
|
24
|
+
private start;
|
|
25
|
+
/**
|
|
26
|
+
* Stopping eyedropper mode
|
|
27
|
+
*/
|
|
28
|
+
private stop;
|
|
29
|
+
/**
|
|
30
|
+
* Creates fake screenshot of page and assign it to the body
|
|
31
|
+
*/
|
|
32
|
+
private createScreenshot;
|
|
33
|
+
/**
|
|
34
|
+
* Removes screenshot from page
|
|
35
|
+
*/
|
|
36
|
+
private removeScreenshot;
|
|
37
|
+
/**
|
|
38
|
+
* Sets waiting cursor
|
|
39
|
+
*/
|
|
40
|
+
private setWaitingCursor;
|
|
41
|
+
/**
|
|
42
|
+
* Removes waiting cursor
|
|
43
|
+
*/
|
|
44
|
+
private revertWaitingCursor;
|
|
45
|
+
/**
|
|
46
|
+
* Binds events
|
|
47
|
+
*/
|
|
48
|
+
private bindEvents;
|
|
49
|
+
/**
|
|
50
|
+
* Unbinds `mousemove` events
|
|
51
|
+
*/
|
|
52
|
+
private unbindEvents;
|
|
53
|
+
/**
|
|
54
|
+
* `click` handler
|
|
55
|
+
*/
|
|
56
|
+
private onClick;
|
|
57
|
+
/**
|
|
58
|
+
* `mousemove` handler
|
|
59
|
+
*/
|
|
60
|
+
private onMouseMove;
|
|
61
|
+
/**
|
|
62
|
+
* Detects color from canvas data
|
|
63
|
+
*/
|
|
64
|
+
private detectColor;
|
|
65
|
+
/**
|
|
66
|
+
* Canvas styles creator
|
|
67
|
+
*/
|
|
68
|
+
private addCanvasStyle;
|
|
69
|
+
}
|