@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.
Files changed (226) hide show
  1. package/es/assets/css/main.scss +2 -4
  2. package/es/components/molecules/DisplayFormat/constants.js +2 -2
  3. package/es/components/molecules/DisplayFormat/utils.js +2 -2
  4. package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
  5. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
  6. package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
  7. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +3 -13
  8. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
  9. package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
  10. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
  11. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
  12. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
  13. package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
  14. package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
  15. package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
  16. package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
  17. package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
  18. package/es/components/molecules/index.d.ts +0 -1
  19. package/es/components/molecules/index.js +0 -1
  20. package/es/components/organism/index.d.ts +0 -1
  21. package/es/components/organism/index.js +0 -1
  22. package/es/hooks/index.d.ts +0 -1
  23. package/es/hooks/index.js +0 -1
  24. package/es/utils/common.d.ts +9 -6
  25. package/es/utils/common.js +23 -44
  26. package/es/utils/index.d.ts +0 -1
  27. package/es/utils/index.js +0 -1
  28. package/es/utils/web.d.ts +0 -4
  29. package/es/utils/web.js +0 -25
  30. package/package.json +3 -29
  31. package/es/components/index.scss +0 -2
  32. package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
  33. package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -128
  34. package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
  35. package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
  36. package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -20
  37. package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -17
  38. package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
  39. package/es/components/molecules/FontSizeInput/constants.js +0 -5
  40. package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
  41. package/es/components/molecules/FontSizeInput/index.js +0 -1
  42. package/es/components/molecules/FontSizeInput/styled.d.ts +0 -3
  43. package/es/components/molecules/FontSizeInput/styled.js +0 -22
  44. package/es/components/molecules/FontSizeInput/styles.scss +0 -15
  45. package/es/components/molecules/FontSizeInput/types.d.ts +0 -24
  46. package/es/components/molecules/FontSizeInput/types.js +0 -1
  47. package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
  48. package/es/components/molecules/FontSizeInput/utils.js +0 -9
  49. package/es/components/molecules/index.scss +0 -1
  50. package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
  51. package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
  52. package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
  53. package/es/components/organism/TextEditor/TextEditor.js +0 -251
  54. package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
  55. package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
  56. package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
  57. package/es/components/organism/TextEditor/constants.d.ts +0 -135
  58. package/es/components/organism/TextEditor/constants.js +0 -280
  59. package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
  60. package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
  61. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -130
  62. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -247
  63. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
  64. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
  65. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
  66. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
  67. package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
  68. package/es/components/organism/TextEditor/extensions/Color.js +0 -41
  69. package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
  70. package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
  71. package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
  72. package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -43
  73. package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -32
  74. package/es/components/organism/TextEditor/extensions/FontSize.js +0 -47
  75. package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
  76. package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
  77. package/es/components/organism/TextEditor/extensions/Highlight.d.ts +0 -1
  78. package/es/components/organism/TextEditor/extensions/Highlight.js +0 -14
  79. package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -28
  80. package/es/components/organism/TextEditor/extensions/Indent.js +0 -68
  81. package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
  82. package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
  83. package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -15
  84. package/es/components/organism/TextEditor/extensions/Link.js +0 -50
  85. package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
  86. package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
  87. package/es/components/organism/TextEditor/extensions/Selection.d.ts +0 -6
  88. package/es/components/organism/TextEditor/extensions/Selection.js +0 -40
  89. package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
  90. package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
  91. package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
  92. package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
  93. package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -31
  94. package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -37
  95. package/es/components/organism/TextEditor/hooks/index.d.ts +0 -6
  96. package/es/components/organism/TextEditor/hooks/index.js +0 -6
  97. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
  98. package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
  99. package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
  100. package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
  101. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
  102. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
  103. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
  104. package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
  105. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
  106. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
  107. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
  108. package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
  109. package/es/components/organism/TextEditor/index.d.ts +0 -14
  110. package/es/components/organism/TextEditor/index.js +0 -6
  111. package/es/components/organism/TextEditor/index.scss +0 -61
  112. package/es/components/organism/TextEditor/provider.d.ts +0 -10
  113. package/es/components/organism/TextEditor/provider.js +0 -20
  114. package/es/components/organism/TextEditor/store.d.ts +0 -11
  115. package/es/components/organism/TextEditor/store.js +0 -12
  116. package/es/components/organism/TextEditor/styled.d.ts +0 -8
  117. package/es/components/organism/TextEditor/styled.js +0 -90
  118. package/es/components/organism/TextEditor/types.d.ts +0 -92
  119. package/es/components/organism/TextEditor/types.js +0 -1
  120. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
  121. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
  122. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
  123. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
  124. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -43
  125. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -120
  126. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
  127. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
  128. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
  129. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
  130. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
  131. package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
  132. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
  133. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
  134. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
  135. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
  136. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
  137. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -20
  138. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
  139. package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
  140. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
  141. package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
  142. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
  143. package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
  144. package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
  145. package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
  146. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
  147. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
  148. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
  149. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
  150. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -14
  151. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
  152. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
  153. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -7
  154. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
  155. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
  156. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
  157. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
  158. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
  159. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
  160. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
  161. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
  162. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
  163. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
  164. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
  165. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
  166. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
  167. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
  168. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
  169. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
  170. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
  171. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
  172. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
  173. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
  174. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
  175. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
  176. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
  177. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
  178. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
  179. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
  180. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
  181. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
  182. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
  183. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
  184. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
  185. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
  186. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
  187. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
  188. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -7
  189. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
  190. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
  191. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
  192. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
  193. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
  194. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
  195. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
  196. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
  197. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
  198. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
  199. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
  200. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
  201. package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
  202. package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
  203. package/es/components/organism/TextEditor/utils/documentState.js +0 -100
  204. package/es/components/organism/TextEditor/utils/font.d.ts +0 -84
  205. package/es/components/organism/TextEditor/utils/font.js +0 -175
  206. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
  207. package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -321
  208. package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
  209. package/es/components/organism/TextEditor/utils/index.js +0 -16
  210. package/es/components/organism/TextEditor/utils/link.d.ts +0 -100
  211. package/es/components/organism/TextEditor/utils/link.js +0 -149
  212. package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
  213. package/es/components/organism/TextEditor/utils/menu.js +0 -317
  214. package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
  215. package/es/components/organism/TextEditor/utils/selection.js +0 -57
  216. package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
  217. package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
  218. package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
  219. package/es/components/organism/TextEditor/utils/style.js +0 -193
  220. package/es/components/organism/index.scss +0 -1
  221. package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
  222. package/es/hooks/useBroadcastedLocalStorage.js +0 -71
  223. package/es/hooks/useElementSize.d.ts +0 -7
  224. package/es/hooks/useElementSize.js +0 -56
  225. package/es/utils/tree.d.ts +0 -225
  226. 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,6 +0,0 @@
1
- import { TextEditor as TextEditorComponent } from './TextEditor';
2
- import { htmlMinifyForEmail } from './utils';
3
- export { TextEditorProvider } from './provider';
4
- export const TextEditor = Object.assign(TextEditorComponent, {
5
- Utils: { htmlMinifyForEmail },
6
- });
@@ -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>>;