@antscorp/antsomi-ui 2.0.83-text-editor-beta.10 → 2.0.84
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/molecules/DisplayFormat/constants.js +2 -2
- package/es/components/molecules/DisplayFormat/utils.js +2 -2
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
- 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 +3 -13
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
- package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
- 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 +1 -1
- package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
- package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
- 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/hooks/index.d.ts +0 -1
- package/es/hooks/index.js +0 -1
- package/es/utils/common.d.ts +9 -6
- package/es/utils/common.js +23 -44
- package/es/utils/index.d.ts +0 -1
- package/es/utils/index.js +0 -1
- package/es/utils/web.d.ts +0 -4
- package/es/utils/web.js +0 -25
- package/package.json +3 -29
- package/es/components/index.scss +0 -2
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -128
- 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 -20
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -17
- 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 -3
- package/es/components/molecules/FontSizeInput/styled.js +0 -22
- package/es/components/molecules/FontSizeInput/styles.scss +0 -15
- package/es/components/molecules/FontSizeInput/types.d.ts +0 -24
- 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 -251
- 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 -135
- package/es/components/organism/TextEditor/constants.js +0 -280
- 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 -130
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -247
- 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/Color.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Color.js +0 -41
- 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 -43
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -32
- package/es/components/organism/TextEditor/extensions/FontSize.js +0 -47
- 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/Highlight.d.ts +0 -1
- package/es/components/organism/TextEditor/extensions/Highlight.js +0 -14
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -28
- package/es/components/organism/TextEditor/extensions/Indent.js +0 -68
- 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 -15
- package/es/components/organism/TextEditor/extensions/Link.js +0 -50
- 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/Selection.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Selection.js +0 -40
- 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 -31
- package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -37
- 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/useDocumentState.d.ts +0 -18
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
- package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
- package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
- 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 -14
- package/es/components/organism/TextEditor/index.js +0 -6
- package/es/components/organism/TextEditor/index.scss +0 -61
- package/es/components/organism/TextEditor/provider.d.ts +0 -10
- package/es/components/organism/TextEditor/provider.js +0 -20
- package/es/components/organism/TextEditor/store.d.ts +0 -11
- package/es/components/organism/TextEditor/store.js +0 -12
- package/es/components/organism/TextEditor/styled.d.ts +0 -8
- package/es/components/organism/TextEditor/styled.js +0 -90
- package/es/components/organism/TextEditor/types.d.ts +0 -92
- package/es/components/organism/TextEditor/types.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
- 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/ColorPicker/ColorPicker.d.ts +0 -43
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -120
- 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/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 -20
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
- 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/TextAlignSelect/TextAlignSelect.d.ts +0 -30
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
- 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 -14
- 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 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
- 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 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
- 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 -84
- package/es/components/organism/TextEditor/utils/font.js +0 -175
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -321
- 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 -100
- package/es/components/organism/TextEditor/utils/link.js +0 -149
- 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/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/utils/tree.d.ts +0 -225
- package/es/utils/tree.js +0 -469
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { JSONContent } from '@tiptap/core';
|
|
3
|
-
export type { TextEditorProps, TextEditorRef } from './types';
|
|
4
|
-
export type { JSONContent as TextEditorJSONContent };
|
|
5
|
-
export { TextEditorProvider } from './provider';
|
|
6
|
-
export declare const TextEditor: import("react").NamedExoticComponent<Omit<import("./types").TextEditorProps & import("react").RefAttributes<import("./types").TextEditorRef>, "ref"> & {
|
|
7
|
-
ref?: ((instance: import("./types").TextEditorRef | null) => void) | import("react").RefObject<import("./types").TextEditorRef> | null | undefined;
|
|
8
|
-
}> & {
|
|
9
|
-
readonly type: import("react").ForwardRefExoticComponent<import("./types").TextEditorProps & import("react").RefAttributes<import("./types").TextEditorRef>>;
|
|
10
|
-
} & {
|
|
11
|
-
Utils: {
|
|
12
|
-
htmlMinifyForEmail: (htmlEditorContent: string) => string;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
.antsomi-text-editor-bubble-menu {
|
|
2
|
-
visibility: hidden;
|
|
3
|
-
position: absolute;
|
|
4
|
-
pointer-events: auto;
|
|
5
|
-
z-index: 999;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.antsomi-text-editor-emoji-popover {
|
|
9
|
-
position: absolute;
|
|
10
|
-
width: 180px;
|
|
11
|
-
z-index: 1000;
|
|
12
|
-
|
|
13
|
-
.antsomi-text-editor-emoji-list {
|
|
14
|
-
.antsomi-virtualize-menu-menu-inline {
|
|
15
|
-
background-color: white;
|
|
16
|
-
box-shadow: var(--antsomi-box-shadow-secondary);
|
|
17
|
-
border-radius: 10px;
|
|
18
|
-
|
|
19
|
-
.antsomi-virtualize-menu-item-label {
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: center;
|
|
22
|
-
gap: 10px;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.font-popover-overlay {
|
|
29
|
-
padding: 0;
|
|
30
|
-
|
|
31
|
-
.font-popover-item {
|
|
32
|
-
width: 100%;
|
|
33
|
-
height: 100%;
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
padding-left: 10px;
|
|
36
|
-
padding-right: 8px;
|
|
37
|
-
|
|
38
|
-
&:hover,
|
|
39
|
-
&.active {
|
|
40
|
-
background-color: #f2f9ff;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.font-weight-popover {
|
|
46
|
-
&.antsomi-popover {
|
|
47
|
-
.antsomi-popover-inner {
|
|
48
|
-
padding: 10px 0px;
|
|
49
|
-
|
|
50
|
-
.font-weight-item {
|
|
51
|
-
padding: 4px 10px;
|
|
52
|
-
cursor: pointer;
|
|
53
|
-
|
|
54
|
-
&:hover,
|
|
55
|
-
&.active {
|
|
56
|
-
background-color: #f2f9ff;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { StoreApi } from 'zustand';
|
|
3
|
-
import type { TextEditorStore } from './store';
|
|
4
|
-
export type TextEditorStoreApi = StoreApi<TextEditorStore>;
|
|
5
|
-
export declare const TextEditorStoreContext: import("react").Context<TextEditorStoreApi | null>;
|
|
6
|
-
export interface TextEditorProviderProps {
|
|
7
|
-
children: React.ReactNode | ((props: TextEditorStoreApi) => React.ReactNode);
|
|
8
|
-
}
|
|
9
|
-
export declare const TextEditorProvider: React.FC<React.PropsWithChildren<TextEditorProviderProps>>;
|
|
10
|
-
export declare const useTextEditorStore: <T>(selector: (state: TextEditorStore) => T) => T;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
// Libraries
|
|
3
|
-
import { createContext, useContext, useRef } from 'react';
|
|
4
|
-
import { useStore } from 'zustand';
|
|
5
|
-
// Store
|
|
6
|
-
import { createTextEditorStore } from './store';
|
|
7
|
-
export const TextEditorStoreContext = createContext(null);
|
|
8
|
-
export const TextEditorProvider = ({ children, }) => {
|
|
9
|
-
const storeRef = useRef();
|
|
10
|
-
if (!storeRef.current) {
|
|
11
|
-
storeRef.current = createTextEditorStore();
|
|
12
|
-
}
|
|
13
|
-
return (_jsx(TextEditorStoreContext.Provider, { value: storeRef.current, children: typeof children === 'function' ? children(storeRef.current) : children }));
|
|
14
|
-
};
|
|
15
|
-
export const useTextEditorStore = (selector) => {
|
|
16
|
-
const store = useContext(TextEditorStoreContext);
|
|
17
|
-
if (!store)
|
|
18
|
-
throw new Error('Missing TextEditorStoreContext.Provider in the tree');
|
|
19
|
-
return useStore(store, selector);
|
|
20
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type TextEditorState = {
|
|
2
|
-
bubbleMenuContainer: HTMLDivElement | null;
|
|
3
|
-
isShowBubbleMenu: boolean;
|
|
4
|
-
};
|
|
5
|
-
export type TextEditorActions = {
|
|
6
|
-
setBubbleMenuContainer: (container: HTMLDivElement | null) => void;
|
|
7
|
-
setIsShowBubbleMenu: (isShow: boolean) => void;
|
|
8
|
-
};
|
|
9
|
-
export type TextEditorStore = TextEditorState & TextEditorActions;
|
|
10
|
-
export declare const defaultTextEditorState: TextEditorState;
|
|
11
|
-
export declare const createTextEditorStore: (initState?: Partial<TextEditorState>) => import("zustand").StoreApi<TextEditorStore>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Libraries
|
|
2
|
-
import { createStore } from 'zustand';
|
|
3
|
-
export const defaultTextEditorState = {
|
|
4
|
-
bubbleMenuContainer: null,
|
|
5
|
-
isShowBubbleMenu: false,
|
|
6
|
-
};
|
|
7
|
-
export const createTextEditorStore = (initState = {}) => createStore()(set => ({
|
|
8
|
-
...defaultTextEditorState,
|
|
9
|
-
...initState,
|
|
10
|
-
setBubbleMenuContainer: container => set(() => ({ bubbleMenuContainer: container })),
|
|
11
|
-
setIsShowBubbleMenu: isShow => set(() => ({ isShowBubbleMenu: isShow })),
|
|
12
|
-
}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { TextStyle } from './types';
|
|
3
|
-
export declare const StyledBubbleMenu: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<Pick<Partial<Omit<Pick<Partial<import("./extensions/BubbleMenu").BubbleMenuPluginProps>, "pluginKey"> & Omit<import("./extensions/BubbleMenu").BubbleMenuPluginProps, "pluginKey">, "element">>, "editor"> & Omit<Omit<Pick<Partial<import("./extensions/BubbleMenu").BubbleMenuPluginProps>, "pluginKey"> & Omit<import("./extensions/BubbleMenu").BubbleMenuPluginProps, "pluginKey">, "element">, "editor"> & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>, any, {}, never>;
|
|
4
|
-
export declare const StyledEditorContent: import("styled-components").StyledComponent<import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<import("@tiptap/react").EditorContentProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>>, any, {
|
|
5
|
-
$textStyle: TextStyle;
|
|
6
|
-
}, never>;
|
|
7
|
-
export declare const ColorBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
-
export declare const ToolbarWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").FlexProps<import("antd/es/_util/type").AnyObject> & import("react").RefAttributes<HTMLElement>>, any, {}, never>;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { EditorContent } from '@tiptap/react';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
import { BubbleMenu } from './ui/BubbleMenu';
|
|
4
|
-
import { SMART_TAG_HIGHLIGHT_BG } from './constants';
|
|
5
|
-
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
6
|
-
import { Flex } from 'antd';
|
|
7
|
-
export const StyledBubbleMenu = styled(BubbleMenu) `
|
|
8
|
-
background-color: white;
|
|
9
|
-
border: 1px solid ${THEME.token?.blue1};
|
|
10
|
-
border-radius: 5px;
|
|
11
|
-
padding: 8px;
|
|
12
|
-
`;
|
|
13
|
-
const dynContentStyles = css `
|
|
14
|
-
background-color: ${SMART_TAG_HIGHLIGHT_BG};
|
|
15
|
-
background-color: color-mix(
|
|
16
|
-
in lab,
|
|
17
|
-
var(--text-style-bg-color, transparent),
|
|
18
|
-
${SMART_TAG_HIGHLIGHT_BG}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
&:hover {
|
|
22
|
-
background-color: ${SMART_TAG_HIGHLIGHT_BG};
|
|
23
|
-
background-color: color-mix(
|
|
24
|
-
in lab,
|
|
25
|
-
var(--text-style-bg-color, transparent),
|
|
26
|
-
${SMART_TAG_HIGHLIGHT_BG} 80%
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
export const StyledEditorContent = styled(EditorContent) `
|
|
31
|
-
.tiptap {
|
|
32
|
-
outline: none;
|
|
33
|
-
|
|
34
|
-
p {
|
|
35
|
-
margin: 0;
|
|
36
|
-
padding: 0;
|
|
37
|
-
|
|
38
|
-
line-height: ${p => p.$textStyle.lineHeight};
|
|
39
|
-
font-family: ${p => p.$textStyle.fontFamily};
|
|
40
|
-
font-size: ${p => p.$textStyle.fontSize};
|
|
41
|
-
color: ${p => p.$textStyle.color};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&:not([contenteditable='false']) {
|
|
45
|
-
p {
|
|
46
|
-
cursor: text;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.selection {
|
|
50
|
-
background-color: #d7cac9;
|
|
51
|
-
background-color: color-mix(in lab, var(--text-style-bg-color, transparent), #d7cac9);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.smart-tag {
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
|
|
57
|
-
&.highlight {
|
|
58
|
-
${dynContentStyles}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.link {
|
|
63
|
-
&.highlight > span {
|
|
64
|
-
${dynContentStyles}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
export const ColorBox = styled.div `
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
width: 20px;
|
|
73
|
-
height: 20px;
|
|
74
|
-
border-radius: 50%;
|
|
75
|
-
border: 1px solid #d9d9d9;
|
|
76
|
-
|
|
77
|
-
&:hover {
|
|
78
|
-
box-shadow: rgba(0, 0, 0, 0.35) 0px 0px 3px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
&.active {
|
|
82
|
-
box-shadow: blue 0px 0px 3px;
|
|
83
|
-
}
|
|
84
|
-
`;
|
|
85
|
-
export const ToolbarWrapper = styled(Flex) `
|
|
86
|
-
.antsomi-divider.toolbar-separator {
|
|
87
|
-
height: 20px;
|
|
88
|
-
margin: 2px;
|
|
89
|
-
}
|
|
90
|
-
`;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { JSONContent, Editor } from '@tiptap/core';
|
|
3
|
-
import { LinkAttrs } from './extensions/Link';
|
|
4
|
-
import { SmartTagAttrs } from './extensions/SmartTag';
|
|
5
|
-
export type HandleSmartTagRef = {
|
|
6
|
-
setSmartTag: (attrs: SmartTagAttrs) => void;
|
|
7
|
-
deleteSmartTag: (id: string) => void;
|
|
8
|
-
updateSmartTagAttrs: (id: string, updatedAttrs: Omit<SmartTagAttrs, 'id'>) => void;
|
|
9
|
-
};
|
|
10
|
-
export type HandleLinkRef = {
|
|
11
|
-
setLink: (attrs: LinkAttrs) => void;
|
|
12
|
-
deleteLink: (id: string) => void;
|
|
13
|
-
updateLinkAttrs: (id: string, updatedAttrs: Omit<LinkAttrs, 'id'>) => void;
|
|
14
|
-
};
|
|
15
|
-
export type TextEditorRef = HandleSmartTagRef & HandleLinkRef & {
|
|
16
|
-
blur: (perserveSelection?: boolean) => void;
|
|
17
|
-
style?: CSSStyleDeclaration;
|
|
18
|
-
readonly editor: Editor | null;
|
|
19
|
-
};
|
|
20
|
-
export type SmartTagHandler = Partial<{
|
|
21
|
-
edit: (id: string, event: React.MouseEvent) => void;
|
|
22
|
-
setNew: (args: {
|
|
23
|
-
selectionText: string;
|
|
24
|
-
}) => void;
|
|
25
|
-
}>;
|
|
26
|
-
export type LinkHandler = Partial<{
|
|
27
|
-
setNew: (args: {
|
|
28
|
-
selectionText: string;
|
|
29
|
-
}) => void;
|
|
30
|
-
edit: (args: {
|
|
31
|
-
id: string;
|
|
32
|
-
selectionText: string;
|
|
33
|
-
}) => void;
|
|
34
|
-
}>;
|
|
35
|
-
export type FontConfig = {
|
|
36
|
-
fontFamily: {
|
|
37
|
-
name: string;
|
|
38
|
-
fallback?: string[];
|
|
39
|
-
};
|
|
40
|
-
fontWeight: number[];
|
|
41
|
-
};
|
|
42
|
-
export type Config = Partial<{
|
|
43
|
-
SmartTag: Partial<{
|
|
44
|
-
highlight: boolean;
|
|
45
|
-
}>;
|
|
46
|
-
Link: Partial<{
|
|
47
|
-
highlightDynamic: boolean;
|
|
48
|
-
}>;
|
|
49
|
-
Color: {
|
|
50
|
-
colorPickerStorageKey: string;
|
|
51
|
-
};
|
|
52
|
-
BackgroundColor: {
|
|
53
|
-
colorPickerStorageKey: string;
|
|
54
|
-
};
|
|
55
|
-
FontFamily: {
|
|
56
|
-
fonts: FontConfig[];
|
|
57
|
-
};
|
|
58
|
-
}>;
|
|
59
|
-
export type TextStyle = {
|
|
60
|
-
fontFamily: string;
|
|
61
|
-
fontSize: string;
|
|
62
|
-
color: string;
|
|
63
|
-
backgroundColor: string;
|
|
64
|
-
lineHeight: string;
|
|
65
|
-
fontWeight: string;
|
|
66
|
-
};
|
|
67
|
-
export type TextEditorProps = {
|
|
68
|
-
id?: string;
|
|
69
|
-
className?: string;
|
|
70
|
-
style?: React.CSSProperties;
|
|
71
|
-
initialContent?: string;
|
|
72
|
-
config?: Config;
|
|
73
|
-
smartTagHandler?: SmartTagHandler;
|
|
74
|
-
linkHandler?: LinkHandler;
|
|
75
|
-
editable?: boolean;
|
|
76
|
-
bubbleMenuProps?: {
|
|
77
|
-
container?: HTMLElement | null;
|
|
78
|
-
};
|
|
79
|
-
defaultTextStyle?: Partial<TextStyle>;
|
|
80
|
-
dataAttributes?: Record<`data-${string}`, unknown>;
|
|
81
|
-
onFocus?: (event: FocusEvent) => void;
|
|
82
|
-
onUpdate?: (args: {
|
|
83
|
-
html: string;
|
|
84
|
-
text: string;
|
|
85
|
-
json: JSONContent;
|
|
86
|
-
}) => void;
|
|
87
|
-
onCreate?: (args: {
|
|
88
|
-
html: string;
|
|
89
|
-
text: string;
|
|
90
|
-
json: JSONContent;
|
|
91
|
-
}) => void;
|
|
92
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { BubbleMenuPluginProps } from '../../extensions/BubbleMenu';
|
|
3
|
-
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
4
|
-
export type BubbleMenuProps = Optional<Omit<Optional<BubbleMenuPluginProps, 'pluginKey'>, 'element'>, 'editor'> & React.HTMLAttributes<HTMLDivElement>;
|
|
5
|
-
export declare const BubbleMenu: React.ForwardRefExoticComponent<Pick<Partial<Omit<Optional<BubbleMenuPluginProps, "pluginKey">, "element">>, "editor"> & Omit<Omit<Optional<BubbleMenuPluginProps, "pluginKey">, "element">, "editor"> & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
import { useCurrentEditor } from '@tiptap/react';
|
|
4
|
-
import { forwardRef, useRef } from 'react';
|
|
5
|
-
import { createPortal } from 'react-dom';
|
|
6
|
-
import { BubbleMenuPlugin } from '../../extensions/BubbleMenu';
|
|
7
|
-
import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
|
|
8
|
-
import { useTextEditorStore } from '../../provider';
|
|
9
|
-
import clsx from 'clsx';
|
|
10
|
-
import { ANTSOMI_COMPONENT_PREFIX_CLS } from '@antscorp/antsomi-ui/es/constants';
|
|
11
|
-
export const BubbleMenu = forwardRef(({ pluginKey = 'bubbleMenu', editor, updateDelay, resizeDelay, shouldShow = null, options, children, container, className, ...restProps }, ref) => {
|
|
12
|
-
const menuEl = useRef(document.createElement('div'));
|
|
13
|
-
const setIsShowBubbleMenu = useTextEditorStore(state => state.setIsShowBubbleMenu);
|
|
14
|
-
if (typeof ref === 'function') {
|
|
15
|
-
ref(menuEl.current);
|
|
16
|
-
}
|
|
17
|
-
else if (ref) {
|
|
18
|
-
ref.current = menuEl.current;
|
|
19
|
-
}
|
|
20
|
-
const { editor: currentEditor } = useCurrentEditor();
|
|
21
|
-
useDeepCompareEffect(() => {
|
|
22
|
-
const bubbleMenuElement = menuEl.current;
|
|
23
|
-
bubbleMenuElement.className = clsx(className, `${ANTSOMI_COMPONENT_PREFIX_CLS}-text-editor-bubble-menu`);
|
|
24
|
-
if (editor?.isDestroyed || currentEditor?.isDestroyed) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const attachToEditor = editor || currentEditor;
|
|
28
|
-
if (!attachToEditor) {
|
|
29
|
-
console.warn('BubbleMenu component is not rendered inside of an editor component or does not have editor prop.');
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const plugin = BubbleMenuPlugin({
|
|
33
|
-
updateDelay,
|
|
34
|
-
resizeDelay,
|
|
35
|
-
editor: attachToEditor,
|
|
36
|
-
element: bubbleMenuElement,
|
|
37
|
-
container,
|
|
38
|
-
pluginKey,
|
|
39
|
-
shouldShow,
|
|
40
|
-
onShow: () => {
|
|
41
|
-
setIsShowBubbleMenu(true);
|
|
42
|
-
},
|
|
43
|
-
onHide: () => {
|
|
44
|
-
setIsShowBubbleMenu(false);
|
|
45
|
-
},
|
|
46
|
-
options: {
|
|
47
|
-
...options,
|
|
48
|
-
strategy: options?.strategy || 'absolute',
|
|
49
|
-
placement: options?.placement || 'top-start',
|
|
50
|
-
offset: options?.offset || {
|
|
51
|
-
alignmentAxis: -20,
|
|
52
|
-
mainAxis: 10,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
attachToEditor.registerPlugin(plugin);
|
|
57
|
-
return () => {
|
|
58
|
-
attachToEditor.unregisterPlugin(pluginKey);
|
|
59
|
-
window.requestAnimationFrame(() => {
|
|
60
|
-
if (bubbleMenuElement.parentNode) {
|
|
61
|
-
bubbleMenuElement.parentNode.removeChild(bubbleMenuElement);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
}, [
|
|
66
|
-
editor,
|
|
67
|
-
container,
|
|
68
|
-
updateDelay,
|
|
69
|
-
resizeDelay,
|
|
70
|
-
pluginKey,
|
|
71
|
-
options,
|
|
72
|
-
className,
|
|
73
|
-
currentEditor,
|
|
74
|
-
shouldShow,
|
|
75
|
-
setIsShowBubbleMenu,
|
|
76
|
-
]);
|
|
77
|
-
return createPortal(_jsx("div", { ...restProps, children: children }), menuEl.current);
|
|
78
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { BubbleMenu, type BubbleMenuProps } from './BubbleMenu';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { BubbleMenu } from './BubbleMenu';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PopoverProps } from 'antd/lib';
|
|
3
|
-
export interface ColorPickerProps {
|
|
4
|
-
value?: string;
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
usedColorsStorageKey?: string;
|
|
7
|
-
onChange?: (value: string) => void;
|
|
8
|
-
popoverProps?: Omit<PopoverProps, 'content'> & {
|
|
9
|
-
content?: ((args: {
|
|
10
|
-
colorGrid: React.ReactNode;
|
|
11
|
-
usedColors: React.ReactNode;
|
|
12
|
-
customColorPicker: React.ReactNode;
|
|
13
|
-
}) => React.ReactNode) | React.ReactNode;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export interface ColorPickerRef {
|
|
17
|
-
setOpen: (open: boolean) => void;
|
|
18
|
-
}
|
|
19
|
-
export interface UsedColorsProps {
|
|
20
|
-
value?: string;
|
|
21
|
-
usedColorsStorageKey?: string;
|
|
22
|
-
onChange?: (value: string) => void;
|
|
23
|
-
}
|
|
24
|
-
export interface GridColorProps {
|
|
25
|
-
value?: string;
|
|
26
|
-
usedColorsStorageKey?: string;
|
|
27
|
-
colorGrid?: string[][];
|
|
28
|
-
onChange?: (value: string) => void;
|
|
29
|
-
}
|
|
30
|
-
export interface UseUsedColorsParams {
|
|
31
|
-
key?: string;
|
|
32
|
-
numberOfColors?: number;
|
|
33
|
-
}
|
|
34
|
-
export interface BoxColorProps {
|
|
35
|
-
color?: string;
|
|
36
|
-
isActive?: boolean;
|
|
37
|
-
onClick?: (e: React.MouseEvent) => void;
|
|
38
|
-
}
|
|
39
|
-
export interface CustomColorPickerProps {
|
|
40
|
-
currentColor: string;
|
|
41
|
-
onApply?: (value: string) => void;
|
|
42
|
-
}
|
|
43
|
-
export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<ColorPickerRef>>;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable react/no-array-index-key */
|
|
3
|
-
import { ColorPicker as AntdColorPicker, Button, Col, Flex, Row, Typography } from 'antd';
|
|
4
|
-
import { chunk } from 'lodash';
|
|
5
|
-
import { TEXT_EDITOR_CONSTANTS } from '../../constants';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
import { forwardRef, useEffect, useState, useImperativeHandle } from 'react';
|
|
8
|
-
import { useDebouncedCallback } from 'use-debounce';
|
|
9
|
-
import { useBroadcastedLocalStorage } from '@antscorp/antsomi-ui/es/hooks/useBroadcastedLocalStorage';
|
|
10
|
-
import { useTextEditorStore } from '../../provider';
|
|
11
|
-
import { ColorBox } from '../../styled';
|
|
12
|
-
import { TextEditorPopover } from '../Popover';
|
|
13
|
-
const { COLOR_GIRD } = TEXT_EDITOR_CONSTANTS;
|
|
14
|
-
const CustomColorPicker = (props) => {
|
|
15
|
-
const { onApply, currentColor } = props;
|
|
16
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
-
const [color, setColor] = useState(currentColor);
|
|
18
|
-
const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
setColor(currentColor);
|
|
21
|
-
}, [currentColor]);
|
|
22
|
-
const handleChangeColor = useDebouncedCallback((newColor) => {
|
|
23
|
-
setColor(newColor);
|
|
24
|
-
}, 50);
|
|
25
|
-
const handleClose = () => {
|
|
26
|
-
setIsOpen(false);
|
|
27
|
-
handleChangeColor(currentColor);
|
|
28
|
-
};
|
|
29
|
-
const handleApply = () => {
|
|
30
|
-
handleClose();
|
|
31
|
-
onApply?.(color);
|
|
32
|
-
};
|
|
33
|
-
return (_jsx(AntdColorPicker, { getPopupContainer: () => bubbleMenuContainer || document.body, open: isOpen, value: color, onOpenChange: setOpen => setIsOpen(setOpen), onChange: newColor => handleChangeColor(newColor.toRgbString()), placement: "bottomRight", destroyTooltipOnHide: true, panelRender: panel => (_jsxs(_Fragment, { children: [panel, _jsxs(Flex, { justify: "end", gap: 8, style: { marginTop: 10 }, children: [_jsx(Button, { size: "small", type: "default", onClick: handleClose, children: "Cancel" }), _jsx(Button, { size: "small", type: "primary", onClick: handleApply, children: "Apply" })] })] })), children: _jsx(Button, { children: "Custom" }) }));
|
|
34
|
-
};
|
|
35
|
-
const BoxColor = (props) => {
|
|
36
|
-
const { color, isActive, onClick } = props;
|
|
37
|
-
const handleClick = (e) => {
|
|
38
|
-
e.stopPropagation();
|
|
39
|
-
onClick?.(e);
|
|
40
|
-
};
|
|
41
|
-
return (_jsx(ColorBox, { style: { backgroundColor: color }, className: clsx({
|
|
42
|
-
active: isActive,
|
|
43
|
-
}), onClick: handleClick }));
|
|
44
|
-
};
|
|
45
|
-
const useUsedColors = (params) => {
|
|
46
|
-
const { key = 'used-colors', numberOfColors = 10 } = params || {};
|
|
47
|
-
const { value: usedColors, setValue: setUsedColors } = useBroadcastedLocalStorage(key, []);
|
|
48
|
-
const addColor = (color) => {
|
|
49
|
-
const updatedColors = [...usedColors];
|
|
50
|
-
if (!usedColors.includes(color)) {
|
|
51
|
-
updatedColors.push(color);
|
|
52
|
-
if (usedColors.length >= numberOfColors) {
|
|
53
|
-
updatedColors.shift();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
setUsedColors(updatedColors);
|
|
57
|
-
};
|
|
58
|
-
return { usedColors, addColor };
|
|
59
|
-
};
|
|
60
|
-
const UsedColors = (props) => {
|
|
61
|
-
const { onChange, value, usedColorsStorageKey } = props;
|
|
62
|
-
const { usedColors, addColor: addUsedColor } = useUsedColors({
|
|
63
|
-
key: usedColorsStorageKey,
|
|
64
|
-
});
|
|
65
|
-
const rowColorSize = COLOR_GIRD[0].length;
|
|
66
|
-
const handleClick = (color) => {
|
|
67
|
-
addUsedColor(color);
|
|
68
|
-
onChange?.(color);
|
|
69
|
-
};
|
|
70
|
-
if (usedColors.length === 0) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
return (_jsxs(Flex, { vertical: true, gap: 2, children: [_jsx(Typography.Text, { children: "Recently used" }), chunk(usedColors, rowColorSize).map((row, rowIndex) => (_jsx(Row, { gutter: [2, 2], children: row.map((color, colIndex) => (_jsx(Col, { span: 24 / rowColorSize, children: _jsx(BoxColor, { color: color, isActive: color === value, onClick: () => handleClick(color) }) }, `${rowIndex}-${colIndex}`))) }, rowIndex)))] }));
|
|
74
|
-
};
|
|
75
|
-
const GridColor = (props) => {
|
|
76
|
-
const { onChange, value, usedColorsStorageKey, colorGrid = COLOR_GIRD } = props;
|
|
77
|
-
const rowColorSize = colorGrid[0].length;
|
|
78
|
-
const { addColor: addUsedColor } = useUsedColors({
|
|
79
|
-
key: usedColorsStorageKey,
|
|
80
|
-
});
|
|
81
|
-
const handleClick = (color) => {
|
|
82
|
-
addUsedColor(color);
|
|
83
|
-
onChange?.(color);
|
|
84
|
-
};
|
|
85
|
-
return (_jsx(Flex, { vertical: true, gap: 2, children: colorGrid.map((row, rowIndex) => (_jsx(Row, { gutter: [2, 2], children: row.map((color, colIndex) => (_jsx(Col, { span: 24 / rowColorSize, children: _jsx(BoxColor, { color: color, isActive: color === value, onClick: () => handleClick(color) }) }, `${rowIndex}-${colIndex}`))) }, rowIndex))) }));
|
|
86
|
-
};
|
|
87
|
-
export const ColorPicker = forwardRef((props, ref) => {
|
|
88
|
-
const { value = '', onChange, children, usedColorsStorageKey = 'used-colors', popoverProps, } = props;
|
|
89
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (popoverProps?.open !== undefined) {
|
|
92
|
-
setIsOpen(popoverProps.open);
|
|
93
|
-
}
|
|
94
|
-
}, [popoverProps?.open]);
|
|
95
|
-
const handleChangeOpen = (open) => {
|
|
96
|
-
setIsOpen(open);
|
|
97
|
-
if (popoverProps?.onOpenChange) {
|
|
98
|
-
popoverProps.onOpenChange(open);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const handleOnChange = (color) => {
|
|
102
|
-
onChange?.(color);
|
|
103
|
-
handleChangeOpen(false);
|
|
104
|
-
};
|
|
105
|
-
useImperativeHandle(ref, () => ({
|
|
106
|
-
setOpen: handleChangeOpen,
|
|
107
|
-
}));
|
|
108
|
-
const colorGrid = (_jsx(GridColor, { onChange: handleOnChange, value: value, usedColorsStorageKey: usedColorsStorageKey }));
|
|
109
|
-
const usedColors = (_jsx(UsedColors, { onChange: handleOnChange, value: value, usedColorsStorageKey: usedColorsStorageKey }));
|
|
110
|
-
const customColorPicker = _jsx(CustomColorPicker, { currentColor: value, onApply: handleOnChange });
|
|
111
|
-
let content = (_jsxs(Flex, { vertical: true, gap: 8, children: [colorGrid, usedColors, customColorPicker] }));
|
|
112
|
-
if (typeof popoverProps?.content === 'function') {
|
|
113
|
-
content = popoverProps.content({
|
|
114
|
-
colorGrid,
|
|
115
|
-
usedColors,
|
|
116
|
-
customColorPicker,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return (_jsx(TextEditorPopover, { trigger: ['click'], placement: "bottomLeft", ...popoverProps, open: isOpen, onOpenChange: handleChangeOpen, content: content, children: children }));
|
|
120
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ColorPicker } from './ColorPicker';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ColorPicker } from './ColorPicker';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { EmojiNodeAttrs, SuggestionItem } from '../../extensions/Emoji';
|
|
3
|
-
import { SuggestionProps } from '@tiptap/suggestion';
|
|
4
|
-
export declare const ITEM_SIZE = 28;
|
|
5
|
-
export type EmojiListRef = {
|
|
6
|
-
onKeyDown: (args: {
|
|
7
|
-
event: KeyboardEvent;
|
|
8
|
-
}) => boolean;
|
|
9
|
-
};
|
|
10
|
-
export type EmojiListProps = SuggestionProps<SuggestionItem, EmojiNodeAttrs>;
|
|
11
|
-
export declare const EmojiList: import("react").ForwardRefExoticComponent<EmojiListProps & import("react").RefAttributes<EmojiListRef>>;
|