@antscorp/antsomi-ui 2.0.86-text-editor-beta.5 → 2.0.86

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 (228) hide show
  1. package/es/assets/css/main.scss +2 -4
  2. package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
  3. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
  4. package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
  5. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +3 -13
  6. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
  7. package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
  8. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
  9. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
  10. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
  11. package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
  12. package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
  13. package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
  14. package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
  15. package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
  16. package/es/components/molecules/index.d.ts +0 -1
  17. package/es/components/molecules/index.js +0 -1
  18. package/es/components/organism/index.d.ts +0 -1
  19. package/es/components/organism/index.js +0 -1
  20. package/es/components/template/Layout/constants/permission.d.ts +1 -0
  21. package/es/components/template/Layout/constants/permission.js +1 -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 -7
  96. package/es/components/organism/TextEditor/hooks/index.js +0 -7
  97. package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +0 -4
  98. package/es/components/organism/TextEditor/hooks/useColorSet.js +0 -6
  99. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
  100. package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
  101. package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
  102. package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
  103. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
  104. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
  105. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
  106. package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
  107. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
  108. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
  109. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
  110. package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
  111. package/es/components/organism/TextEditor/index.d.ts +0 -14
  112. package/es/components/organism/TextEditor/index.js +0 -6
  113. package/es/components/organism/TextEditor/index.scss +0 -61
  114. package/es/components/organism/TextEditor/provider.d.ts +0 -12
  115. package/es/components/organism/TextEditor/provider.js +0 -34
  116. package/es/components/organism/TextEditor/store.d.ts +0 -13
  117. package/es/components/organism/TextEditor/store.js +0 -20
  118. package/es/components/organism/TextEditor/styled.d.ts +0 -8
  119. package/es/components/organism/TextEditor/styled.js +0 -90
  120. package/es/components/organism/TextEditor/types.d.ts +0 -92
  121. package/es/components/organism/TextEditor/types.js +0 -1
  122. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
  123. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
  124. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
  125. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
  126. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -43
  127. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -132
  128. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
  129. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
  130. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
  131. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
  132. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
  133. package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
  134. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
  135. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
  136. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
  137. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
  138. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
  139. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -20
  140. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
  141. package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
  142. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
  143. package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
  144. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
  145. package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
  146. package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
  147. package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
  148. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
  149. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
  150. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
  151. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
  152. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -14
  153. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
  154. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
  155. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -7
  156. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
  157. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
  158. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
  159. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
  160. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
  161. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
  162. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
  163. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
  164. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
  165. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
  166. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
  167. package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
  168. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
  169. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
  170. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
  171. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
  172. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
  173. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
  174. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
  175. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
  176. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
  177. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
  178. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
  179. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
  180. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
  181. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
  182. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
  183. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
  184. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
  185. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
  186. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
  187. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
  188. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
  189. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
  190. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -7
  191. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
  192. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
  193. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
  194. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
  195. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
  196. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
  197. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
  198. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
  199. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
  200. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
  201. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
  202. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
  203. package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
  204. package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
  205. package/es/components/organism/TextEditor/utils/documentState.js +0 -100
  206. package/es/components/organism/TextEditor/utils/font.d.ts +0 -84
  207. package/es/components/organism/TextEditor/utils/font.js +0 -175
  208. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
  209. package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -319
  210. package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
  211. package/es/components/organism/TextEditor/utils/index.js +0 -16
  212. package/es/components/organism/TextEditor/utils/link.d.ts +0 -100
  213. package/es/components/organism/TextEditor/utils/link.js +0 -149
  214. package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
  215. package/es/components/organism/TextEditor/utils/menu.js +0 -317
  216. package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
  217. package/es/components/organism/TextEditor/utils/selection.js +0 -57
  218. package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
  219. package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
  220. package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
  221. package/es/components/organism/TextEditor/utils/style.js +0 -193
  222. package/es/components/organism/index.scss +0 -1
  223. package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
  224. package/es/hooks/useBroadcastedLocalStorage.js +0 -71
  225. package/es/hooks/useElementSize.d.ts +0 -7
  226. package/es/hooks/useElementSize.js +0 -56
  227. package/es/utils/tree.d.ts +0 -225
  228. 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,12 +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
- colors?: string[];
8
- children: React.ReactNode | ((props: TextEditorStoreApi) => React.ReactNode);
9
- onChangeColors?: (colors: string[]) => void;
10
- }
11
- export declare const TextEditorProvider: React.FC<React.PropsWithChildren<TextEditorProviderProps>>;
12
- export declare const useTextEditorStore: <T>(selector: (state: TextEditorStore) => T) => T;
@@ -1,34 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // Libraries
3
- import { createContext, useContext, useEffect, useRef } from 'react';
4
- import { useStore } from 'zustand';
5
- // Store
6
- import { createTextEditorStore } from './store';
7
- import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
8
- export const TextEditorStoreContext = createContext(null);
9
- export const TextEditorProvider = ({ colors, children, onChangeColors, }) => {
10
- const storeRef = useRef();
11
- if (!storeRef.current) {
12
- storeRef.current = createTextEditorStore({ colors });
13
- }
14
- useDeepCompareEffect(() => {
15
- if (!colors)
16
- return;
17
- storeRef.current?.getState().setColors(colors);
18
- }, [colors]);
19
- useEffect(() => {
20
- storeRef.current?.setState({
21
- setColors: colors => {
22
- storeRef.current?.getInitialState().setColors(colors);
23
- onChangeColors?.(colors);
24
- },
25
- });
26
- }, [onChangeColors]);
27
- return (_jsx(TextEditorStoreContext.Provider, { value: storeRef.current, children: typeof children === 'function' ? children(storeRef.current) : children }));
28
- };
29
- export const useTextEditorStore = (selector) => {
30
- const store = useContext(TextEditorStoreContext);
31
- if (!store)
32
- throw new Error('Missing TextEditorStoreContext.Provider in the tree');
33
- return useStore(store, selector);
34
- };
@@ -1,13 +0,0 @@
1
- export type TextEditorState = {
2
- bubbleMenuContainer: HTMLDivElement | null;
3
- isShowBubbleMenu: boolean;
4
- colors?: string[];
5
- };
6
- export type TextEditorActions = {
7
- setBubbleMenuContainer: (container: HTMLDivElement | null) => void;
8
- setIsShowBubbleMenu: (isShow: boolean) => void;
9
- setColors: (newColorSet: string[]) => void;
10
- };
11
- export type TextEditorStore = TextEditorState & TextEditorActions;
12
- export declare const defaultTextEditorState: TextEditorState;
13
- export declare const createTextEditorStore: (initState?: Partial<TextEditorState>) => import("zustand").StoreApi<TextEditorStore>;
@@ -1,20 +0,0 @@
1
- // Libraries
2
- import isEqual from 'react-fast-compare';
3
- import { createStore } from 'zustand';
4
- export const defaultTextEditorState = {
5
- bubbleMenuContainer: null,
6
- isShowBubbleMenu: false,
7
- };
8
- export const createTextEditorStore = (initState = {}) => createStore()((set, get) => ({
9
- ...defaultTextEditorState,
10
- ...initState,
11
- setBubbleMenuContainer: container => set(() => ({ bubbleMenuContainer: container })),
12
- setIsShowBubbleMenu: isShow => set(() => ({ isShowBubbleMenu: isShow })),
13
- setColors: newColors => {
14
- const currentColors = get().colors;
15
- if (isEqual(currentColors, newColors)) {
16
- return;
17
- }
18
- set(() => ({ colors: newColors }));
19
- },
20
- }));
@@ -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").NamedExoticComponent<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,132 +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, useCallback } 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
- import { useColorSet } from '../../hooks';
14
- const { COLOR_GIRD } = TEXT_EDITOR_CONSTANTS;
15
- const CustomColorPicker = (props) => {
16
- const { onApply, currentColor } = props;
17
- const [isOpen, setIsOpen] = useState(false);
18
- const [color, setColor] = useState(currentColor);
19
- const bubbleMenuContainer = useTextEditorStore(state => state.bubbleMenuContainer);
20
- useEffect(() => {
21
- setColor(currentColor);
22
- }, [currentColor]);
23
- const handleChangeColor = useDebouncedCallback((newColor) => {
24
- setColor(newColor);
25
- }, 50);
26
- const handleClose = () => {
27
- setIsOpen(false);
28
- handleChangeColor(currentColor);
29
- };
30
- const handleApply = () => {
31
- handleClose();
32
- onApply?.(color);
33
- };
34
- 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" }) }));
35
- };
36
- const BoxColor = (props) => {
37
- const { color, isActive, onClick } = props;
38
- const handleClick = (e) => {
39
- e.stopPropagation();
40
- onClick?.(e);
41
- };
42
- return (_jsx(ColorBox, { style: { backgroundColor: color }, className: clsx({
43
- active: isActive,
44
- }), onClick: handleClick }));
45
- };
46
- const useUsedColors = (params) => {
47
- const { key = 'used-colors', numberOfColors = 10 } = params || {};
48
- const { value: usedColors, setValue: setUsedColors } = useBroadcastedLocalStorage(key, []);
49
- const { colors: textEditorStoreColors, setColors: updateTextEditorColorSet } = useColorSet();
50
- const updateColor = useCallback((colors) => {
51
- setUsedColors(colors);
52
- updateTextEditorColorSet(colors);
53
- }, [setUsedColors, updateTextEditorColorSet]);
54
- useEffect(() => {
55
- if (!textEditorStoreColors) {
56
- return;
57
- }
58
- updateColor(textEditorStoreColors);
59
- }, [textEditorStoreColors, updateColor]);
60
- const addColor = (color) => {
61
- const updatedColors = [...usedColors];
62
- if (!usedColors.includes(color)) {
63
- updatedColors.push(color);
64
- if (usedColors.length >= numberOfColors) {
65
- updatedColors.shift();
66
- }
67
- }
68
- updateColor(updatedColors);
69
- };
70
- return { usedColors, addColor };
71
- };
72
- const UsedColors = (props) => {
73
- const { onChange, value, usedColorsStorageKey } = props;
74
- const { usedColors, addColor: addUsedColor } = useUsedColors({
75
- key: usedColorsStorageKey,
76
- });
77
- const rowColorSize = COLOR_GIRD[0].length;
78
- const handleClick = (color) => {
79
- addUsedColor(color);
80
- onChange?.(color);
81
- };
82
- if (usedColors.length === 0) {
83
- return null;
84
- }
85
- 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)))] }));
86
- };
87
- const GridColor = (props) => {
88
- const { onChange, value, usedColorsStorageKey, colorGrid = COLOR_GIRD } = props;
89
- const rowColorSize = colorGrid[0].length;
90
- const { addColor: addUsedColor } = useUsedColors({
91
- key: usedColorsStorageKey,
92
- });
93
- const handleClick = (color) => {
94
- addUsedColor(color);
95
- onChange?.(color);
96
- };
97
- 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))) }));
98
- };
99
- export const ColorPicker = forwardRef((props, ref) => {
100
- const { value = '', onChange, children, usedColorsStorageKey = 'used-colors', popoverProps, } = props;
101
- const [isOpen, setIsOpen] = useState(false);
102
- useEffect(() => {
103
- if (popoverProps?.open !== undefined) {
104
- setIsOpen(popoverProps.open);
105
- }
106
- }, [popoverProps?.open]);
107
- const handleChangeOpen = (open) => {
108
- setIsOpen(open);
109
- if (popoverProps?.onOpenChange) {
110
- popoverProps.onOpenChange(open);
111
- }
112
- };
113
- const handleOnChange = (color) => {
114
- onChange?.(color);
115
- handleChangeOpen(false);
116
- };
117
- useImperativeHandle(ref, () => ({
118
- setOpen: handleChangeOpen,
119
- }));
120
- const colorGrid = (_jsx(GridColor, { onChange: handleOnChange, value: value, usedColorsStorageKey: usedColorsStorageKey }));
121
- const usedColors = (_jsx(UsedColors, { onChange: handleOnChange, value: value, usedColorsStorageKey: usedColorsStorageKey }));
122
- const customColorPicker = _jsx(CustomColorPicker, { currentColor: value, onApply: handleOnChange });
123
- let content = (_jsxs(Flex, { vertical: true, gap: 8, children: [colorGrid, usedColors, customColorPicker] }));
124
- if (typeof popoverProps?.content === 'function') {
125
- content = popoverProps.content({
126
- colorGrid,
127
- usedColors,
128
- customColorPicker,
129
- });
130
- }
131
- return (_jsx(TextEditorPopover, { trigger: ['click'], placement: "bottomLeft", ...popoverProps, open: isOpen, onOpenChange: handleChangeOpen, content: content, children: children }));
132
- });
@@ -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>>;