@antscorp/antsomi-ui 2.0.92-text-editor-beta.6 → 2.0.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/assets/css/main.scss +2 -4
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -18
- package/es/components/icons/LazyIcon/LazyIcon.js +9 -18
- package/es/components/icons/index.d.ts +9 -18
- package/es/components/icons/index.js +9 -18
- package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
- package/es/components/molecules/EmojiCollections/types.d.ts +0 -1
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +0 -1
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +6 -10
- package/es/components/molecules/EmojiPopover/styled.d.ts +2 -2
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/TagifyInput/patternHandlers.js +12 -0
- package/es/components/molecules/TagifyInput/utils.d.ts +1 -0
- package/es/components/molecules/TagifyInput/utils.js +1 -0
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
- package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +11 -1
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
- package/es/components/molecules/VirtualizedMenu/styled.d.ts +2 -2
- package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
- package/es/components/molecules/VirtualizedMenu/types.d.ts +10 -27
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
- package/es/components/molecules/index.d.ts +0 -1
- package/es/components/molecules/index.js +0 -1
- package/es/components/organism/index.d.ts +0 -1
- package/es/components/organism/index.js +0 -1
- package/es/constants/api.js +3 -3
- package/es/hooks/index.d.ts +0 -4
- package/es/hooks/index.js +0 -4
- package/es/locales/i18n.d.ts +1 -1
- package/es/utils/common.d.ts +9 -14
- package/es/utils/common.js +23 -60
- package/es/utils/index.d.ts +0 -1
- package/es/utils/index.js +0 -1
- package/es/utils/web.d.ts +0 -15
- package/es/utils/web.js +0 -39
- package/package.json +4 -22
- package/es/components/atoms/Eyedropper/Eyedropper.d.ts +0 -2
- package/es/components/atoms/Eyedropper/Eyedropper.js +0 -53
- package/es/components/atoms/Eyedropper/index.d.ts +0 -0
- package/es/components/atoms/Eyedropper/index.js +0 -1
- package/es/components/atoms/Eyedropper/styled.d.ts +0 -9
- package/es/components/atoms/Eyedropper/styled.js +0 -45
- package/es/components/atoms/Eyedropper/types.d.ts +0 -5
- package/es/components/atoms/Eyedropper/types.js +0 -1
- package/es/components/icons/ALignRightIcon.d.ts +0 -3
- package/es/components/icons/ALignRightIcon.js +0 -7
- package/es/components/icons/AlignCenterIcon.d.ts +0 -3
- package/es/components/icons/AlignCenterIcon.js +0 -7
- package/es/components/icons/AlignJustifyIcon.d.ts +0 -3
- package/es/components/icons/AlignJustifyIcon.js +0 -7
- package/es/components/icons/AlignLeftIcon.d.ts +0 -3
- package/es/components/icons/AlignLeftIcon.js +0 -7
- package/es/components/icons/ArrowDropDownIcon.d.ts +0 -3
- package/es/components/icons/ArrowDropDownIcon.js +0 -7
- package/es/components/icons/ChevronRightIcon.d.ts +0 -3
- package/es/components/icons/ChevronRightIcon.js +0 -7
- package/es/components/icons/ColorizeIcon.d.ts +0 -3
- package/es/components/icons/ColorizeIcon.js +0 -7
- package/es/components/icons/LinkOffIcon.d.ts +0 -3
- package/es/components/icons/LinkOffIcon.js +0 -7
- package/es/components/icons/MinusIcon.d.ts +0 -3
- package/es/components/icons/MinusIcon.js +0 -7
- package/es/components/index.scss +0 -2
- package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +0 -11
- package/es/components/molecules/EyedropperButton/EyedropperButton.js +0 -34
- package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
- package/es/components/molecules/EyedropperButton/index.js +0 -1
- package/es/components/molecules/EyedropperButton/styled.d.ts +0 -7
- package/es/components/molecules/EyedropperButton/styled.js +0 -23
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -134
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -21
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -19
- package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/constants.js +0 -5
- package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/index.js +0 -1
- package/es/components/molecules/FontSizeInput/styled.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/styled.js +0 -40
- package/es/components/molecules/FontSizeInput/styles.scss +0 -15
- package/es/components/molecules/FontSizeInput/types.d.ts +0 -23
- package/es/components/molecules/FontSizeInput/types.js +0 -1
- package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/utils.js +0 -9
- package/es/components/molecules/index.scss +0 -1
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
- package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
- package/es/components/organism/TextEditor/TextEditor.js +0 -264
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
- package/es/components/organism/TextEditor/constants.d.ts +0 -177
- package/es/components/organism/TextEditor/constants.js +0 -323
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -140
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -366
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
- package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +0 -16
- package/es/components/organism/TextEditor/extensions/ClearFormatting.js +0 -26
- package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Color.js +0 -34
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
- package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -36
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -31
- package/es/components/organism/TextEditor/extensions/FontSize.js +0 -46
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
- package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -21
- package/es/components/organism/TextEditor/extensions/Indent.js +0 -63
- package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +0 -32
- package/es/components/organism/TextEditor/extensions/LetterSpacing.js +0 -48
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
- package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
- package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -29
- package/es/components/organism/TextEditor/extensions/Link.js +0 -187
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
- package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +0 -56
- package/es/components/organism/TextEditor/extensions/OrderedList.js +0 -187
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
- package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -30
- package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -36
- package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +0 -55
- package/es/components/organism/TextEditor/extensions/UnorderedList.js +0 -176
- package/es/components/organism/TextEditor/hooks/index.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/index.js +0 -6
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +0 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.js +0 -22
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
- package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
- package/es/components/organism/TextEditor/index.d.ts +0 -16
- package/es/components/organism/TextEditor/index.js +0 -8
- package/es/components/organism/TextEditor/index.scss +0 -61
- package/es/components/organism/TextEditor/provider.d.ts +0 -14
- package/es/components/organism/TextEditor/provider.js +0 -33
- package/es/components/organism/TextEditor/store.d.ts +0 -13
- package/es/components/organism/TextEditor/store.js +0 -20
- package/es/components/organism/TextEditor/styled.d.ts +0 -10
- package/es/components/organism/TextEditor/styled.js +0 -94
- package/es/components/organism/TextEditor/types.d.ts +0 -139
- package/es/components/organism/TextEditor/types.js +0 -5
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -84
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Button/Button.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Button/Button.js +0 -31
- package/es/components/organism/TextEditor/ui/Button/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Button/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Button/types.d.ts +0 -10
- package/es/components/organism/TextEditor/ui/Button/types.js +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -39
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -131
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +0 -17
- package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +0 -51
- package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/DropdownButton/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -22
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -9
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +0 -44
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +0 -1
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +0 -52
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +0 -19
- package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -77
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -16
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -93
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -31
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -28
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -44
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +0 -21
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -17
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +0 -28
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -17
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -67
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -17
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -10
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -45
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -26
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -26
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -29
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -22
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -36
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -19
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -24
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -24
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
- package/es/components/organism/TextEditor/utils/documentState.js +0 -100
- package/es/components/organism/TextEditor/utils/font.d.ts +0 -73
- package/es/components/organism/TextEditor/utils/font.js +0 -160
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -75
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -343
- package/es/components/organism/TextEditor/utils/indent.d.ts +0 -11
- package/es/components/organism/TextEditor/utils/indent.js +0 -56
- package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
- package/es/components/organism/TextEditor/utils/index.js +0 -16
- package/es/components/organism/TextEditor/utils/link.d.ts +0 -108
- package/es/components/organism/TextEditor/utils/link.js +0 -151
- package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
- package/es/components/organism/TextEditor/utils/menu.js +0 -317
- package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
- package/es/components/organism/TextEditor/utils/selection.js +0 -57
- package/es/components/organism/TextEditor/utils/shared.d.ts +0 -1
- package/es/components/organism/TextEditor/utils/shared.js +0 -9
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
- package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
- package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
- package/es/components/organism/TextEditor/utils/style.js +0 -193
- package/es/components/organism/index.scss +0 -1
- package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
- package/es/hooks/useBroadcastedLocalStorage.js +0 -71
- package/es/hooks/useElementSize.d.ts +0 -7
- package/es/hooks/useElementSize.js +0 -56
- package/es/hooks/useEyedropper/attach.d.ts +0 -4
- package/es/hooks/useEyedropper/attach.js +0 -9
- package/es/hooks/useEyedropper/eyedropper.d.ts +0 -69
- package/es/hooks/useEyedropper/eyedropper.js +0 -205
- package/es/hooks/useEyedropper/index.d.ts +0 -2
- package/es/hooks/useEyedropper/index.js +0 -7
- package/es/hooks/useEyedropper/support.d.ts +0 -1
- package/es/hooks/useEyedropper/support.js +0 -3
- package/es/hooks/useEyedropper/types.d.ts +0 -9
- package/es/hooks/useEyedropper/types.js +0 -1
- package/es/hooks/useEyedropper/useEyedropper.d.ts +0 -8
- package/es/hooks/useEyedropper/useEyedropper.js +0 -50
- package/es/hooks/useEyedropper/utils.d.ts +0 -11
- package/es/hooks/useEyedropper/utils.js +0 -17
- package/es/hooks/useIsMounted.d.ts +0 -1
- package/es/hooks/useIsMounted.js +0 -11
- package/es/utils/tree.d.ts +0 -225
- package/es/utils/tree.js +0 -469
|
@@ -1,193 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import url('./TextEditor/index.scss');
|
|
@@ -1,71 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-bitwise */
|
|
2
|
-
import html2canvas from 'html2canvas-pro';
|
|
3
|
-
import { errors, px } from './utils';
|
|
4
|
-
/** Global `isOpen` state */
|
|
5
|
-
const isOpenState = {
|
|
6
|
-
value: false,
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* EyeDropper API polyfill
|
|
10
|
-
* https://wicg.github.io/eyedropper-api/#dom-colorselectionoptions
|
|
11
|
-
*/
|
|
12
|
-
export class EyeDropperPolyfill {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.magnification = {
|
|
15
|
-
size: 4,
|
|
16
|
-
scale: 12,
|
|
17
|
-
};
|
|
18
|
-
this.onMouseMove = this.onMouseMove.bind(this);
|
|
19
|
-
this.onClick = this.onClick.bind(this);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Opens the polyfilled eyedropper
|
|
23
|
-
*
|
|
24
|
-
* §3.3 EyeDropper interface ► `open()`
|
|
25
|
-
*/
|
|
26
|
-
async open(options = {}) {
|
|
27
|
-
// §3.3 EyeDropper interface ► `open()` ► p.2
|
|
28
|
-
// Prevent opening if already open
|
|
29
|
-
if (isOpenState.value) {
|
|
30
|
-
return Promise.reject(new DOMException('Invalid state', 'InvalidStateError'));
|
|
31
|
-
}
|
|
32
|
-
// §3.3 EyeDropper interface ► `open()` ► p.3
|
|
33
|
-
// Create a promise to handle the color selection
|
|
34
|
-
const result = new Promise((resolve, reject) => {
|
|
35
|
-
// §3.3 EyeDropper interface ► `open()` ► p.4
|
|
36
|
-
// Handle possible signal abortion
|
|
37
|
-
if (options.signal) {
|
|
38
|
-
if (options.signal.aborted) {
|
|
39
|
-
this.stop();
|
|
40
|
-
reject(options.signal.reason || new DOMException('Aborted', 'AbortError'));
|
|
41
|
-
}
|
|
42
|
-
const abortListener = () => {
|
|
43
|
-
this.stop();
|
|
44
|
-
if (options.signal) {
|
|
45
|
-
reject(options.signal.reason || new DOMException('Aborted', 'AbortError'));
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
options.signal.addEventListener('abort', abortListener);
|
|
49
|
-
}
|
|
50
|
-
// §3.3 EyeDropper interface ► `open()` ► p.5
|
|
51
|
-
// Store the resolve function and start the eyedropper
|
|
52
|
-
this.resolve = resolve;
|
|
53
|
-
this.start();
|
|
54
|
-
});
|
|
55
|
-
return result;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Starting eyedropper mode
|
|
59
|
-
*/
|
|
60
|
-
async start() {
|
|
61
|
-
document.body.style.overflow = 'hidden';
|
|
62
|
-
this.setWaitingCursor();
|
|
63
|
-
await this.createScreenshot();
|
|
64
|
-
this.revertWaitingCursor();
|
|
65
|
-
this.bindEvents();
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Stopping eyedropper mode
|
|
69
|
-
*/
|
|
70
|
-
stop() {
|
|
71
|
-
document.body.style.overflow = '';
|
|
72
|
-
this.unbindEvents();
|
|
73
|
-
this.removeScreenshot();
|
|
74
|
-
this.colorSelectionResult = undefined;
|
|
75
|
-
this.lastPoint = undefined;
|
|
76
|
-
isOpenState.value = false;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Creates fake screenshot of page and assign it to the body
|
|
80
|
-
*/
|
|
81
|
-
async createScreenshot() {
|
|
82
|
-
this.canvas = await html2canvas(document.body, {
|
|
83
|
-
allowTaint: true,
|
|
84
|
-
useCORS: true,
|
|
85
|
-
height: document.body.scrollHeight,
|
|
86
|
-
width: document.body.scrollWidth,
|
|
87
|
-
});
|
|
88
|
-
this.addCanvasStyle(this.canvas);
|
|
89
|
-
this.canvasCtx = this.canvas.getContext('2d', {
|
|
90
|
-
willReadFrequently: true,
|
|
91
|
-
});
|
|
92
|
-
document.body.appendChild(this.canvas);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Removes screenshot from page
|
|
96
|
-
*/
|
|
97
|
-
removeScreenshot() {
|
|
98
|
-
if (!this.canvas) {
|
|
99
|
-
throw new Error(errors.canvasError);
|
|
100
|
-
}
|
|
101
|
-
document.body.removeChild(this.canvas);
|
|
102
|
-
this.canvas = undefined;
|
|
103
|
-
this.canvasCtx = undefined;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Sets waiting cursor
|
|
107
|
-
*/
|
|
108
|
-
setWaitingCursor() {
|
|
109
|
-
this.previousDocumentCursor = document.documentElement.style.cursor;
|
|
110
|
-
document.documentElement.style.cursor = 'wait';
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Removes waiting cursor
|
|
114
|
-
*/
|
|
115
|
-
revertWaitingCursor() {
|
|
116
|
-
if (this.previousDocumentCursor) {
|
|
117
|
-
document.documentElement.style.cursor = this.previousDocumentCursor;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
document.documentElement.style.cursor = '';
|
|
121
|
-
}
|
|
122
|
-
this.previousDocumentCursor = undefined;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Binds events
|
|
126
|
-
*/
|
|
127
|
-
bindEvents() {
|
|
128
|
-
window.addEventListener('mousemove', this.onMouseMove);
|
|
129
|
-
window.addEventListener('click', this.onClick);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Unbinds `mousemove` events
|
|
133
|
-
*/
|
|
134
|
-
unbindEvents() {
|
|
135
|
-
window.removeEventListener('mousemove', this.onMouseMove);
|
|
136
|
-
window.removeEventListener('click', this.onClick);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* `click` handler
|
|
140
|
-
*/
|
|
141
|
-
onClick() {
|
|
142
|
-
if (!this.lastPoint) {
|
|
143
|
-
throw new Error(errors.color);
|
|
144
|
-
}
|
|
145
|
-
this.detectColor(this.lastPoint);
|
|
146
|
-
const newValue = this.colorSelectionResult;
|
|
147
|
-
this.stop();
|
|
148
|
-
if (newValue && this.resolve) {
|
|
149
|
-
this.resolve(newValue);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* `mousemove` handler
|
|
154
|
-
*/
|
|
155
|
-
onMouseMove(event) {
|
|
156
|
-
if (!this.canvas || !this.canvasCtx) {
|
|
157
|
-
throw new Error(errors.canvasError);
|
|
158
|
-
}
|
|
159
|
-
const dpr = window.devicePixelRatio;
|
|
160
|
-
this.lastPoint = {
|
|
161
|
-
x: (event.clientX + window.scrollX) * dpr,
|
|
162
|
-
y: (event.clientY + window.scrollY) * dpr,
|
|
163
|
-
};
|
|
164
|
-
// Move magnifier
|
|
165
|
-
// const position = `${this.lastPoint.x / dpr} ${this.lastPoint.y / dpr}px`;
|
|
166
|
-
const position = [px(this.lastPoint.x / dpr), px(this.lastPoint.y / dpr)].join(' ');
|
|
167
|
-
Object.assign(this.canvas.style, {
|
|
168
|
-
opacity: 1,
|
|
169
|
-
transformOrigin: position,
|
|
170
|
-
clipPath: `circle(${px(this.magnification.size)} at ${position})`,
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Detects color from canvas data
|
|
175
|
-
*/
|
|
176
|
-
detectColor(point) {
|
|
177
|
-
if (!this.canvasCtx) {
|
|
178
|
-
throw new Error(errors.canvasError);
|
|
179
|
-
}
|
|
180
|
-
const pixelData = this.canvasCtx.getImageData(point.x, point.y, 1, 1).data;
|
|
181
|
-
const red = pixelData[0];
|
|
182
|
-
const green = pixelData[1];
|
|
183
|
-
const blue = pixelData[2];
|
|
184
|
-
const hex = ((1 << 24) + (red << 16) + (green << 8) + blue).toString(16).slice(1);
|
|
185
|
-
this.colorSelectionResult = {
|
|
186
|
-
sRGBHex: `#${hex}`,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Canvas styles creator
|
|
191
|
-
*/
|
|
192
|
-
addCanvasStyle(canvas) {
|
|
193
|
-
Object.assign(canvas.style, {
|
|
194
|
-
position: 'fixed',
|
|
195
|
-
top: '0px',
|
|
196
|
-
marginTop: `${-window.scrollY}px`,
|
|
197
|
-
left: '0px',
|
|
198
|
-
zIndex: 999999,
|
|
199
|
-
opacity: 0,
|
|
200
|
-
transform: `scale(${this.magnification.scale})`,
|
|
201
|
-
imageRendering: 'pixelated',
|
|
202
|
-
border: '1px solid #000000',
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isEyeDropperSupported(): boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface UseEyedropperResult {
|
|
2
|
-
pickedColor: string | null;
|
|
3
|
-
isLoading: boolean;
|
|
4
|
-
apiSupported: boolean;
|
|
5
|
-
pickColor: () => Promise<string | null>;
|
|
6
|
-
copyToClipboard: (color: string) => Promise<boolean>;
|
|
7
|
-
}
|
|
8
|
-
export declare const useEyedropper: (defaultColor?: string) => UseEyedropperResult;
|