@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,175 +0,0 @@
1
- import { isMacOS } from '@tiptap/core';
2
- /**
3
- * Gets the appropriate bold font weight for a given font family
4
- * @param currentFontFamily The font family to find bold weight for
5
- * @param fonts Array of available font configurations
6
- * @param minBoldWeight Minimum weight considered bold (default 700)
7
- * @returns The first available bold weight for the font family, or minBoldWeight if none found
8
- */
9
- export const getBoldFontWeight = (currentFontFamily, fonts, minBoldWeight = 700) => {
10
- if (!currentFontFamily || !fonts?.length)
11
- return minBoldWeight;
12
- const fontConfig = fonts.find(font => font.fontFamily.name === currentFontFamily);
13
- return fontConfig?.fontWeight.find(weight => weight >= minBoldWeight) ?? minBoldWeight;
14
- };
15
- /**
16
- * Gets the modifier key based on the platform
17
- * @returns Platform-appropriate modifier key
18
- */
19
- export const getModifierKey = () => (isMacOS() ? '⌘' : 'Ctrl');
20
- /**
21
- * Formats a hotkey string with the appropriate modifier
22
- * @param key The key to format
23
- * @returns Formatted hotkey string
24
- */
25
- export const formatHotkey = (key) => {
26
- const modifier = getModifierKey();
27
- return `${modifier}+${key}`;
28
- };
29
- /**
30
- * Validates if a font family name is a generic CSS font
31
- * @param fontFamily Font family name to check
32
- * @returns true if it's a generic font family
33
- */
34
- export function isGenericFontFamily(fontFamily) {
35
- const genericFamilies = new Set([
36
- 'serif',
37
- 'sans-serif',
38
- 'monospace',
39
- 'cursive',
40
- 'fantasy',
41
- 'system-ui',
42
- 'ui-serif',
43
- 'ui-sans-serif',
44
- 'ui-monospace',
45
- 'ui-rounded',
46
- 'math',
47
- 'emoji',
48
- 'fangsong',
49
- ]);
50
- return genericFamilies.has(fontFamily.toLowerCase().trim());
51
- }
52
- /**
53
- * Extracts the primary font from a font-family string
54
- * @param fontFamily Font family string (may contain fallbacks)
55
- * @returns Primary font name
56
- */
57
- export function getPrimaryFontFamily(fontFamily) {
58
- if (!fontFamily)
59
- return '';
60
- const fonts = fontFamily.split(',');
61
- const primaryFont = fonts[0].trim();
62
- // Remove quotes if present
63
- return primaryFont.replace(/^["']|["']$/g, '');
64
- }
65
- /**
66
- * Checks if a font weight is considered bold
67
- * @param weight Font weight to check
68
- * @param threshold Bold threshold (default 600)
69
- * @returns true if weight is bold
70
- */
71
- export function isBoldWeight(weight, threshold = 600) {
72
- const numericWeight = typeof weight === 'string' ? parseInt(weight, 10) : weight;
73
- return !isNaN(numericWeight) && numericWeight >= threshold;
74
- }
75
- /**
76
- * Gets all available font weights for a font family
77
- * @param fontFamily Font family name
78
- * @param fonts Array of font configurations
79
- * @returns Array of available weights
80
- */
81
- export function getFontWeights(fontFamily, fonts) {
82
- const fontConfig = fonts.find(font => font.fontFamily.name === fontFamily);
83
- return fontConfig?.fontWeight || [400];
84
- }
85
- /**
86
- * Finds the closest available font weight
87
- * @param targetWeight Desired font weight
88
- * @param availableWeights Array of available weights
89
- * @returns Closest available weight
90
- */
91
- export function getClosestFontWeight(targetWeight, availableWeights) {
92
- if (availableWeights.includes(targetWeight)) {
93
- return targetWeight;
94
- }
95
- return availableWeights.reduce((closest, weight) => Math.abs(weight - targetWeight) < Math.abs(closest - targetWeight) ? weight : closest);
96
- }
97
- /**
98
- * Validates font configuration
99
- * @param fontConfig Font configuration to validate
100
- * @returns true if configuration is valid
101
- */
102
- export function isValidFontConfig(fontConfig) {
103
- return !!(fontConfig.fontFamily?.name &&
104
- fontConfig.fontWeight &&
105
- Array.isArray(fontConfig.fontWeight) &&
106
- fontConfig.fontWeight.length > 0 &&
107
- fontConfig.fontWeight.every(weight => typeof weight === 'number' && weight > 0));
108
- }
109
- /**
110
- * Sorts font configurations alphabetically by name
111
- * @param fonts Array of font configurations
112
- * @returns Sorted array of font configurations
113
- */
114
- export function sortFontsByName(fonts) {
115
- return [...fonts].sort((a, b) => a.fontFamily.name.localeCompare(b.fontFamily.name));
116
- }
117
- /**
118
- * Groups fonts by category (if category property exists)
119
- * @param fonts Array of font configurations
120
- * @returns Object with fonts grouped by category
121
- */
122
- export function groupFontsByCategory(fonts) {
123
- const grouped = {};
124
- fonts.forEach(font => {
125
- const category = font.category || 'Other';
126
- if (!grouped[category]) {
127
- grouped[category] = [];
128
- }
129
- grouped[category].push(font);
130
- });
131
- return grouped;
132
- }
133
- /**
134
- * Checks if a font is web safe
135
- * @param fontFamily Font family name
136
- * @returns true if font is web safe
137
- */
138
- export function isWebSafeFont(fontFamily) {
139
- const webSafeFonts = new Set([
140
- 'arial',
141
- 'helvetica',
142
- 'times new roman',
143
- 'times',
144
- 'courier new',
145
- 'courier',
146
- 'verdana',
147
- 'georgia',
148
- 'palatino',
149
- 'garamond',
150
- 'bookman',
151
- 'comic sans ms',
152
- 'trebuchet ms',
153
- 'arial black',
154
- 'impact',
155
- 'lucida sans unicode',
156
- 'tahoma',
157
- 'lucida console',
158
- ]);
159
- return webSafeFonts.has(fontFamily.toLowerCase().trim());
160
- }
161
- /**
162
- * Creates a font stack with appropriate fallbacks
163
- * @param primaryFont Primary font family
164
- * @param category Font category for fallback selection
165
- * @returns Complete font stack string
166
- */
167
- export function createFontStack(primaryFont, category = 'sans-serif') {
168
- const fallbacks = {
169
- serif: ['Georgia', 'Times New Roman', 'Times', 'serif'],
170
- 'sans-serif': ['Arial', 'Helvetica', 'sans-serif'],
171
- monospace: ['Courier New', 'Courier', 'monospace'],
172
- };
173
- const stack = [primaryFont, ...fallbacks[category]];
174
- return stack.join(', ');
175
- }
@@ -1,63 +0,0 @@
1
- /**
2
- * Restructures dynamic tags from Froala editor format to be compatible with Tiptap editor.
3
- * This function preserves styling and attributes of dynamic tags while cleaning up their structure.
4
- *
5
- * @param html - The HTML string containing dynamic tags
6
- * @param options - Configuration options for the restructuring process
7
- * @returns The restructured HTML string
8
- */
9
- export declare function restructureDynamicTagsWithOptions(html: string, options?: {
10
- attributesToClone: string[];
11
- }): string;
12
- /**
13
- * Safely parses and processes HTML content for editor use
14
- * @param html - HTML string to process
15
- * @returns Processed HTML string
16
- */
17
- export declare function safeParseHTMLContent(html: string): string;
18
- /**
19
- * Sanitizes HTML by removing potentially dangerous elements and attributes
20
- * @param html - HTML string to sanitize
21
- * @returns Sanitized HTML string
22
- */
23
- export declare function sanitizeHTML(html: string): string;
24
- /**
25
- * Extracts text content from HTML
26
- * @param html - HTML string
27
- * @returns Plain text content
28
- */
29
- export declare function extractTextFromHTML(html: string): string;
30
- /**
31
- * Counts words in HTML content
32
- * @param html - HTML string
33
- * @returns Word count
34
- */
35
- export declare function countWordsInHTML(html: string): number;
36
- /**
37
- * Counts characters in HTML content
38
- * @param html - HTML string
39
- * @param includeSpaces - Whether to include spaces in count
40
- * @returns Character count
41
- */
42
- export declare function countCharactersInHTML(html: string, includeSpaces?: boolean): number;
43
- /**
44
- * Wraps text nodes with specified tag
45
- * @param html - HTML string
46
- * @param tagName - Tag name to wrap with
47
- * @param className - Optional class name for wrapper
48
- * @returns HTML with wrapped text nodes
49
- */
50
- export declare function wrapTextNodes(html: string, tagName?: string, className?: string): string;
51
- /**
52
- * Removes empty elements from HTML
53
- * @param html - HTML string
54
- * @returns HTML with empty elements removed
55
- */
56
- export declare function removeEmptyElements(html: string): string;
57
- /**
58
- * Normalizes whitespace in HTML
59
- * @param html - HTML string
60
- * @returns HTML with normalized whitespace
61
- */
62
- export declare function normalizeWhitespace(html: string): string;
63
- export declare const htmlMinifyForEmail: (htmlEditorContent: string) => string;
@@ -1,319 +0,0 @@
1
- import { SMART_TAG_HIGHLIGHT_BG } from '../constants';
2
- import { textStyleFromElStyle, appendTextStyleToEl } from './style';
3
- import tinycolor from 'tinycolor2';
4
- /**
5
- * Creates a clean span element for a dynamic tag with only the essential attributes
6
- *
7
- * @param doc - The document used to create the new element
8
- * @param originalSpan - The original dynamic tag span element
9
- * @param attributesToPreserve - List of attribute names to copy from the original span
10
- * @returns A new span element with preserved attributes
11
- */
12
- function createCleanDynamicSpan(doc, originalSpan, attributesToPreserve) {
13
- const cleanSpan = doc.createElement('span');
14
- // Preserve only the specified attributes
15
- for (const attrName of attributesToPreserve) {
16
- if (originalSpan.hasAttribute(attrName)) {
17
- cleanSpan.setAttribute(attrName, originalSpan.getAttribute(attrName));
18
- }
19
- }
20
- // Preserve the text content
21
- cleanSpan.textContent = originalSpan.textContent?.trim() || '';
22
- return cleanSpan;
23
- }
24
- /**
25
- * Extracts style wrapper elements that need to be preserved from the original dynamic tag
26
- *
27
- * @param doc - The document containing the dynamic tag
28
- * @param html - The original HTML string
29
- * @param dynamicSpan - The original dynamic tag span element
30
- * @returns Array of wrapper elements that provide styling
31
- */
32
- function extractStyleWrappers(doc, html, dynamicSpan) {
33
- const styleWrappers = [];
34
- // Create a temporary container for style computation
35
- const tempStyleContainer = document.createElement('div');
36
- tempStyleContainer.style.display = 'none';
37
- document.body.appendChild(tempStyleContainer);
38
- try {
39
- // Extract computed styles from the original element
40
- if (doc.body.firstElementChild) {
41
- const tempDoc = new DOMParser().parseFromString(html, 'text/html');
42
- if (tempDoc.body.firstElementChild) {
43
- tempStyleContainer.appendChild(tempDoc.body.firstElementChild);
44
- const originalDynamicElement = tempStyleContainer.querySelector(`span[data-dynamic-id="${dynamicSpan.dataset.dynamicId}"]`);
45
- if (originalDynamicElement) {
46
- // Create a span with the computed text styles
47
- const computedTextStyle = textStyleFromElStyle(window.getComputedStyle(originalDynamicElement));
48
- // Remove background color if it matches the highlight color
49
- if (tinycolor.equals(computedTextStyle.backgroundColor, SMART_TAG_HIGHLIGHT_BG)) {
50
- computedTextStyle.backgroundColor = '';
51
- }
52
- const textStyleWrapper = document.createElement('span');
53
- appendTextStyleToEl(textStyleWrapper, computedTextStyle);
54
- styleWrappers.push(textStyleWrapper);
55
- }
56
- }
57
- }
58
- // Extract nested style wrappers
59
- let nestedElement = dynamicSpan.firstElementChild;
60
- while (nestedElement && nestedElement.children.length <= 1) {
61
- styleWrappers.push(nestedElement);
62
- nestedElement = nestedElement.firstElementChild || null;
63
- }
64
- return styleWrappers;
65
- }
66
- finally {
67
- // Clean up the temporary container
68
- document.body.removeChild(tempStyleContainer);
69
- }
70
- }
71
- /**
72
- * Reconstructs the dynamic tag element hierarchy with preserved style wrappers
73
- *
74
- * @param doc - The document used to create new elements
75
- * @param baseSpan - The clean base span element for the dynamic tag
76
- * @param styleWrappers - Array of style wrapper elements to apply
77
- * @returns The reconstructed dynamic tag with preserved styling
78
- */
79
- function reconstructDynamicTagHierarchy(doc, baseSpan, styleWrappers) {
80
- let resultNode = baseSpan;
81
- // Apply style wrappers from innermost to outermost
82
- styleWrappers.reverse().forEach(originalWrapper => {
83
- const wrapperClone = doc.createElement(originalWrapper.tagName.toLowerCase());
84
- // Clone all attributes from the original wrapper
85
- for (let i = 0; i < originalWrapper.attributes.length; i++) {
86
- const { name, value } = originalWrapper.attributes[i];
87
- wrapperClone.setAttribute(name, value);
88
- }
89
- wrapperClone.appendChild(resultNode);
90
- resultNode = wrapperClone;
91
- });
92
- return resultNode;
93
- }
94
- /**
95
- * Restructures dynamic tags from Froala editor format to be compatible with Tiptap editor.
96
- * This function preserves styling and attributes of dynamic tags while cleaning up their structure.
97
- *
98
- * @param html - The HTML string containing dynamic tags
99
- * @param options - Configuration options for the restructuring process
100
- * @returns The restructured HTML string
101
- */
102
- export function restructureDynamicTagsWithOptions(html, options = {
103
- attributesToClone: [
104
- 'class',
105
- 'id',
106
- 'style',
107
- 'data-dynamic',
108
- 'data-dynamic-id',
109
- 'direction',
110
- 'unicode-bidi',
111
- 'text-align',
112
- 'background-color',
113
- 'color',
114
- ],
115
- }) {
116
- // Parse the HTML string into a DOM
117
- const parser = new DOMParser();
118
- const parsedDoc = parser.parseFromString(html, 'text/html');
119
- // Find all dynamic tag spans
120
- const dynamicTagSpans = parsedDoc.querySelectorAll('span[data-dynamic]');
121
- // Process each dynamic span
122
- dynamicTagSpans.forEach(originalDynamicSpan => {
123
- // Step 1: Create a new clean span with essential attributes
124
- const cleanDynamicSpan = createCleanDynamicSpan(parsedDoc, originalDynamicSpan, options.attributesToClone);
125
- // Step 2: Extract style wrappers that need to be preserved
126
- const styleWrappers = extractStyleWrappers(parsedDoc, html, originalDynamicSpan);
127
- // Step 3: Reconstruct the element hierarchy with preserved styles
128
- const restructuredDynamicTag = reconstructDynamicTagHierarchy(parsedDoc, cleanDynamicSpan, styleWrappers);
129
- // Step 4: Replace the original span with the restructured node
130
- originalDynamicSpan.replaceWith(restructuredDynamicTag);
131
- });
132
- return parsedDoc.body.innerHTML;
133
- }
134
- /**
135
- * Converts inherited text styles to computed styles for span elements in HTML content.
136
- * This function processes span elements to ensure text styles are explicitly set rather than inherited.
137
- *
138
- * @param html - The HTML string to process
139
- * @returns The processed HTML string with computed styles applied
140
- */
141
- const inheritStyleToComputedStyle = (html) => {
142
- try {
143
- // Create a new DOM parser and parse the HTML
144
- const parser = new DOMParser();
145
- const doc = parser.parseFromString(html, 'text/html');
146
- if (!doc.body) {
147
- // eslint-disable-next-line no-console
148
- console.warn('Failed to parse HTML: body not found');
149
- return html;
150
- }
151
- // Create a hidden container
152
- const container = document.createElement('div');
153
- container.style.visibility = 'hidden';
154
- container.innerHTML = doc.body.innerHTML;
155
- // Add container to DOM temporarily to compute styles
156
- document.body.appendChild(container);
157
- // Process all span elements
158
- const spanElements = container.querySelectorAll('span');
159
- spanElements.forEach(span => {
160
- const textStyle = textStyleFromElStyle(span.style);
161
- const computedStyle = window.getComputedStyle(span);
162
- // Only update styles if there are inherited values
163
- const shouldUpdateStyle = Object.values(textStyle).some(value => value === 'inherit');
164
- if (!shouldUpdateStyle) {
165
- return;
166
- }
167
- // Update inherited styles with computed values
168
- Object.entries(textStyle).forEach(([key, value]) => {
169
- if (value === 'inherit' && key in span.style) {
170
- span.style[key] = computedStyle[key];
171
- }
172
- });
173
- });
174
- const resultHTML = container.innerHTML;
175
- // Clean up
176
- container.remove();
177
- return resultHTML;
178
- }
179
- catch (error) {
180
- // eslint-disable-next-line no-console
181
- console.error('Error processing styles:', error);
182
- return html; // Return original HTML in case of error
183
- }
184
- };
185
- /**
186
- * Safely parses and processes HTML content for editor use
187
- * @param html - HTML string to process
188
- * @returns Processed HTML string
189
- */
190
- export function safeParseHTMLContent(html) {
191
- let resultHTML = html;
192
- const isFroala = html.includes('fr-box');
193
- if (isFroala) {
194
- // console.log('safeParseHTMLContent', html);
195
- resultHTML = inheritStyleToComputedStyle(html);
196
- // console.log('after inheritStyleToComputedStyle', resultHTML);
197
- resultHTML = restructureDynamicTagsWithOptions(resultHTML);
198
- // console.log('after restructureDynamicTagsWithOptions', resultHTML);
199
- }
200
- return resultHTML;
201
- }
202
- /**
203
- * Sanitizes HTML by removing potentially dangerous elements and attributes
204
- * @param html - HTML string to sanitize
205
- * @returns Sanitized HTML string
206
- */
207
- export function sanitizeHTML(html) {
208
- const parser = new DOMParser();
209
- const doc = parser.parseFromString(html, 'text/html');
210
- // Remove script tags
211
- const scripts = doc.querySelectorAll('script');
212
- scripts.forEach(script => script.remove());
213
- // Remove on* event attributes
214
- const allElements = doc.querySelectorAll('*');
215
- allElements.forEach(element => {
216
- Array.from(element.attributes).forEach(attr => {
217
- if (attr.name.startsWith('on')) {
218
- element.removeAttribute(attr.name);
219
- }
220
- });
221
- });
222
- return doc.body.innerHTML;
223
- }
224
- /**
225
- * Extracts text content from HTML
226
- * @param html - HTML string
227
- * @returns Plain text content
228
- */
229
- export function extractTextFromHTML(html) {
230
- const parser = new DOMParser();
231
- const doc = parser.parseFromString(html, 'text/html');
232
- return doc.body.textContent || '';
233
- }
234
- /**
235
- * Counts words in HTML content
236
- * @param html - HTML string
237
- * @returns Word count
238
- */
239
- export function countWordsInHTML(html) {
240
- const text = extractTextFromHTML(html);
241
- return text
242
- .trim()
243
- .split(/\s+/)
244
- .filter(word => word.length > 0).length;
245
- }
246
- /**
247
- * Counts characters in HTML content
248
- * @param html - HTML string
249
- * @param includeSpaces - Whether to include spaces in count
250
- * @returns Character count
251
- */
252
- export function countCharactersInHTML(html, includeSpaces = true) {
253
- const text = extractTextFromHTML(html);
254
- return includeSpaces ? text.length : text.replace(/\s/g, '').length;
255
- }
256
- /**
257
- * Wraps text nodes with specified tag
258
- * @param html - HTML string
259
- * @param tagName - Tag name to wrap with
260
- * @param className - Optional class name for wrapper
261
- * @returns HTML with wrapped text nodes
262
- */
263
- export function wrapTextNodes(html, tagName = 'span', className) {
264
- const parser = new DOMParser();
265
- const doc = parser.parseFromString(html, 'text/html');
266
- function wrapTextNodesRecursive(node) {
267
- if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {
268
- const wrapper = doc.createElement(tagName);
269
- if (className) {
270
- wrapper.className = className;
271
- }
272
- wrapper.textContent = node.textContent;
273
- node.parentNode?.replaceChild(wrapper, node);
274
- }
275
- else {
276
- Array.from(node.childNodes).forEach(wrapTextNodesRecursive);
277
- }
278
- }
279
- wrapTextNodesRecursive(doc.body);
280
- return doc.body.innerHTML;
281
- }
282
- /**
283
- * Removes empty elements from HTML
284
- * @param html - HTML string
285
- * @returns HTML with empty elements removed
286
- */
287
- export function removeEmptyElements(html) {
288
- const parser = new DOMParser();
289
- const doc = parser.parseFromString(html, 'text/html');
290
- function removeEmptyRecursive(node) {
291
- Array.from(node.children).forEach(child => {
292
- removeEmptyRecursive(child);
293
- if (!child.textContent?.trim() && child.children.length === 0) {
294
- child.remove();
295
- }
296
- });
297
- }
298
- removeEmptyRecursive(doc.body);
299
- return doc.body.innerHTML;
300
- }
301
- /**
302
- * Normalizes whitespace in HTML
303
- * @param html - HTML string
304
- * @returns HTML with normalized whitespace
305
- */
306
- export function normalizeWhitespace(html) {
307
- return html.replace(/\s+/g, ' ').replace(/>\s+</g, '><').trim();
308
- }
309
- export const htmlMinifyForEmail = (htmlEditorContent) => {
310
- const parser = new DOMParser();
311
- const doc = parser.parseFromString(htmlEditorContent, 'text/html');
312
- const allElements = doc.body.querySelectorAll('*');
313
- allElements.forEach(element => {
314
- element.removeAttribute('spellcheck');
315
- element.removeAttribute('class');
316
- element.removeAttribute('contenteditable');
317
- });
318
- return doc.body.innerHTML;
319
- };
@@ -1,8 +0,0 @@
1
- export * from './selection';
2
- export * from './link';
3
- export * from './smartTag';
4
- export * from './style';
5
- export * from './font';
6
- export * from './htmlProcessing';
7
- export * from './menu';
8
- export * from './documentState';
@@ -1,16 +0,0 @@
1
- // Selection utilities
2
- export * from './selection';
3
- // Link utilities
4
- export * from './link';
5
- // Smart tag utilities
6
- export * from './smartTag';
7
- // Style utilities
8
- export * from './style';
9
- // Font utilities
10
- export * from './font';
11
- // HTML processing utilities
12
- export * from './htmlProcessing';
13
- // Menu utilities
14
- export * from './menu';
15
- // Document state utilities
16
- export * from './documentState';
@@ -1,100 +0,0 @@
1
- import { EditorState } from '@tiptap/pm/state';
2
- import { MarkRange } from '@tiptap/core';
3
- import { EditorView } from '@tiptap/pm/view';
4
- import { LinkHandler } from '../types';
5
- /**
6
- * Kiểm tra xem cursor có đang nằm trong một đoạn text có mark là link hay không
7
- * @param state EditorState của Tiptap/ProseMirror
8
- * @returns true nếu cursor đang nằm trong link, false nếu không
9
- */
10
- export declare const isCursorInLink: (state: EditorState) => boolean;
11
- /**
12
- * Gets all link mark ranges within a specified range
13
- * @param params Object containing state, from and to positions
14
- * @returns Array of MarkRange objects for links
15
- */
16
- export declare const getLinkMarkRanges: (params: {
17
- state: EditorState;
18
- from: number;
19
- to: number;
20
- }) => MarkRange[];
21
- /**
22
- * Gets the range of a link mark at a specific position
23
- * @param params Object containing state and optional position
24
- * @returns Link mark range or undefined
25
- */
26
- export declare const getLinkRange: (params: {
27
- state: EditorState;
28
- pos?: number;
29
- }) => void | import("@tiptap/core").Range;
30
- /**
31
- * Gets the first link mark in a range
32
- * @param params Object containing state, optional from and to positions
33
- * @returns Link mark or undefined
34
- */
35
- export declare const getLinkMark: (params: {
36
- state: EditorState;
37
- from?: number;
38
- to?: number;
39
- }) => import("prosemirror-model").Mark | undefined;
40
- /**
41
- * Gets all link marks in a range
42
- * @param params Object containing state, from and to positions
43
- * @returns Array of link marks
44
- */
45
- export declare const getLinkMarks: (params: {
46
- state: EditorState;
47
- from: number;
48
- to: number;
49
- }) => import("prosemirror-model").Mark[];
50
- /**
51
- * Gets all link IDs from a range
52
- * @param params Object containing state, optional from and to positions
53
- * @returns Array of link IDs
54
- */
55
- export declare const getLinkIdsFromRange: (params: {
56
- state: EditorState;
57
- from?: number;
58
- to?: number;
59
- }) => string[];
60
- /**
61
- * Gets the active link ID and inactive links from a range
62
- * @param params Object containing state, optional from and to positions
63
- * @returns Object with activeId and inactiveLinks or undefined
64
- */
65
- export declare const getActiveLinkIdFromRange: (params: {
66
- state: EditorState;
67
- from?: number;
68
- to?: number;
69
- }) => {
70
- activeId: string;
71
- inactiveLinks: string[];
72
- } | undefined;
73
- /**
74
- * Extends selection to include full link marks
75
- * @param state EditorState
76
- * @param from Start position
77
- * @param to End position
78
- * @returns Object with extended from, to positions and linkId
79
- */
80
- export declare const extendSelectionToFullLinks: (state: EditorState, from: number, to: number) => {
81
- from: number;
82
- to: number;
83
- linkId?: undefined;
84
- } | {
85
- from: number;
86
- to: number;
87
- linkId: string;
88
- };
89
- /**
90
- * Handles link actions (create or edit)
91
- * @param view EditorView instance
92
- * @param linkHandler Link handler callbacks
93
- */
94
- export declare function handleLinkAction(view: EditorView, linkHandler: LinkHandler | undefined): void;
95
- /**
96
- * Checks if the link menu should be shown
97
- * @param state EditorState
98
- * @returns true if link menu should be shown
99
- */
100
- export declare const isShowLinkMenu: (state: EditorState) => boolean;