@antscorp/antsomi-ui 2.0.90 → 2.0.91-text-editor-beta.1

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 (324) hide show
  1. package/es/assets/css/main.scss +4 -2
  2. package/es/components/icons/ALignRightIcon.d.ts +3 -0
  3. package/es/components/icons/ALignRightIcon.js +7 -0
  4. package/es/components/icons/AlignCenterIcon.d.ts +3 -0
  5. package/es/components/icons/AlignCenterIcon.js +7 -0
  6. package/es/components/icons/AlignJustifyIcon.d.ts +3 -0
  7. package/es/components/icons/AlignJustifyIcon.js +7 -0
  8. package/es/components/icons/AlignLeftIcon.d.ts +3 -0
  9. package/es/components/icons/AlignLeftIcon.js +7 -0
  10. package/es/components/icons/AntsomiAIIcon.d.ts +3 -0
  11. package/es/components/icons/AntsomiAIIcon.js +7 -0
  12. package/es/components/icons/ArrowDropDownIcon.d.ts +3 -0
  13. package/es/components/icons/ArrowDropDownIcon.js +7 -0
  14. package/es/components/icons/ChevronRightIcon.d.ts +3 -0
  15. package/es/components/icons/ChevronRightIcon.js +7 -0
  16. package/es/components/icons/EmotionFeedbackIcon.d.ts +6 -0
  17. package/es/components/icons/EmotionFeedbackIcon.js +8 -0
  18. package/es/components/icons/FeedbackRatingIcon.d.ts +3 -0
  19. package/es/components/icons/FeedbackRatingIcon.js +7 -0
  20. package/es/components/icons/LazyIcon/LazyIcon.d.ts +17 -0
  21. package/es/components/icons/LazyIcon/LazyIcon.js +14 -0
  22. package/es/components/icons/LinkOffIcon.d.ts +3 -0
  23. package/es/components/icons/LinkOffIcon.js +7 -0
  24. package/es/components/icons/MinusIcon.d.ts +3 -0
  25. package/es/components/icons/MinusIcon.js +7 -0
  26. package/es/components/icons/NoteNewIcon.d.ts +3 -0
  27. package/es/components/icons/NoteNewIcon.js +7 -0
  28. package/es/components/icons/SearchNotFoundIcon.d.ts +3 -0
  29. package/es/components/icons/SearchNotFoundIcon.js +7 -0
  30. package/es/components/icons/SummarizeIcon.d.ts +3 -0
  31. package/es/components/icons/SummarizeIcon.js +7 -0
  32. package/es/components/icons/index.d.ts +14 -0
  33. package/es/components/icons/index.js +14 -0
  34. package/es/components/index.scss +2 -0
  35. package/es/components/molecules/ColorSetting/index.js +2 -11
  36. package/es/components/molecules/ColorSetting/styled.d.ts +1 -1
  37. package/es/components/molecules/ColorSetting/styled.js +9 -1
  38. package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
  39. package/es/components/molecules/EmojiCollections/types.d.ts +1 -0
  40. package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +1 -0
  41. package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
  42. package/es/components/molecules/EmojiPopover/styled.d.ts +2 -2
  43. package/es/components/molecules/EmojiPopover/styled.js +1 -1
  44. package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
  45. package/es/components/molecules/FontSizeInput/FontSizeInput.js +127 -0
  46. package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +8 -0
  47. package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +14 -0
  48. package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +20 -0
  49. package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +19 -0
  50. package/es/components/molecules/FontSizeInput/constants.d.ts +2 -0
  51. package/es/components/molecules/FontSizeInput/constants.js +5 -0
  52. package/es/components/molecules/FontSizeInput/index.d.ts +2 -0
  53. package/es/components/molecules/FontSizeInput/index.js +1 -0
  54. package/es/components/molecules/FontSizeInput/styled.d.ts +7 -0
  55. package/es/components/molecules/FontSizeInput/styled.js +36 -0
  56. package/es/components/molecules/FontSizeInput/styles.scss +15 -0
  57. package/es/components/molecules/FontSizeInput/types.d.ts +23 -0
  58. package/es/components/molecules/FontSizeInput/types.js +1 -0
  59. package/es/components/molecules/FontSizeInput/utils.d.ts +7 -0
  60. package/es/components/molecules/FontSizeInput/utils.js +9 -0
  61. package/es/components/molecules/ItemNotFound/ItemNotFound.d.ts +6 -0
  62. package/es/components/molecules/ItemNotFound/ItemNotFound.js +9 -0
  63. package/es/components/molecules/ItemNotFound/index.d.ts +1 -0
  64. package/es/components/molecules/ItemNotFound/index.js +1 -0
  65. package/es/components/molecules/ItemNotFound/styled.d.ts +4 -0
  66. package/es/components/molecules/ItemNotFound/styled.js +29 -0
  67. package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +23 -7
  68. package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.d.ts +1 -0
  69. package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.js +7 -2
  70. package/es/components/molecules/MatchAnySelect/types.d.ts +2 -1
  71. package/es/components/molecules/MatchAnySelect/utils.d.ts +1 -0
  72. package/es/components/molecules/MatchAnySelect/utils.js +2 -0
  73. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +6 -3
  74. package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +2550 -938
  75. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +1 -11
  76. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +53 -25
  77. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +8 -5
  78. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +289 -46
  79. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +1 -0
  80. package/es/components/molecules/VirtualizedMenu/styled.d.ts +2 -2
  81. package/es/components/molecules/VirtualizedMenu/styled.js +23 -4
  82. package/es/components/molecules/VirtualizedMenu/types.d.ts +27 -10
  83. package/es/components/molecules/VirtualizedMenu/utils.d.ts +8 -5
  84. package/es/components/molecules/VirtualizedMenu/utils.js +13 -18
  85. package/es/components/molecules/index.d.ts +2 -0
  86. package/es/components/molecules/index.js +2 -0
  87. package/es/components/molecules/index.scss +1 -0
  88. package/es/components/organism/ActivityTimeline/ActivityTimeline.js +15 -9
  89. package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -0
  90. package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -0
  91. package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.d.ts +3 -4
  92. package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.js +4 -3
  93. package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.d.ts +4 -6
  94. package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.js +4 -4
  95. package/es/components/organism/ActivityTimeline/components/TimeLineTitle/TimelineTitle.js +1 -1
  96. package/es/components/organism/ActivityTimeline/types.d.ts +2 -1
  97. package/es/components/organism/ActivityTimeline/utils.d.ts +1 -1
  98. package/es/components/organism/ActivityTimeline/utils.js +1 -1
  99. package/es/components/organism/TextEditor/TextEditor.d.ts +3 -0
  100. package/es/components/organism/TextEditor/TextEditor.js +257 -0
  101. package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
  102. package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
  103. package/es/components/organism/TextEditor/__mocks__/text-contennt.js +38 -0
  104. package/es/components/organism/TextEditor/constants.d.ts +175 -0
  105. package/es/components/organism/TextEditor/constants.js +321 -0
  106. package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
  107. package/es/components/organism/TextEditor/extensions/BackgroundColor.js +46 -0
  108. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +130 -0
  109. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +247 -0
  110. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
  111. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +31 -0
  112. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
  113. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
  114. package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
  115. package/es/components/organism/TextEditor/extensions/Color.js +34 -0
  116. package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
  117. package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
  118. package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
  119. package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
  120. package/es/components/organism/TextEditor/extensions/FontSize.d.ts +32 -0
  121. package/es/components/organism/TextEditor/extensions/FontSize.js +47 -0
  122. package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
  123. package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
  124. package/es/components/organism/TextEditor/extensions/Highlight.d.ts +1 -0
  125. package/es/components/organism/TextEditor/extensions/Highlight.js +14 -0
  126. package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
  127. package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
  128. package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
  129. package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
  130. package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
  131. package/es/components/organism/TextEditor/extensions/LineHeight.js +36 -0
  132. package/es/components/organism/TextEditor/extensions/Link.d.ts +16 -0
  133. package/es/components/organism/TextEditor/extensions/Link.js +48 -0
  134. package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
  135. package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
  136. package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
  137. package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
  138. package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +39 -0
  139. package/es/components/organism/TextEditor/extensions/SmartTag.js +167 -0
  140. package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
  141. package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
  142. package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +31 -0
  143. package/es/components/organism/TextEditor/extensions/TextTransform.js +37 -0
  144. package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
  145. package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
  146. package/es/components/organism/TextEditor/hooks/index.d.ts +7 -0
  147. package/es/components/organism/TextEditor/hooks/index.js +7 -0
  148. package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
  149. package/es/components/organism/TextEditor/hooks/useColorSet.js +22 -0
  150. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
  151. package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
  152. package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +11 -0
  153. package/es/components/organism/TextEditor/hooks/useLinkHandler.js +125 -0
  154. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
  155. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +68 -0
  156. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
  157. package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
  158. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
  159. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
  160. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
  161. package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
  162. package/es/components/organism/TextEditor/index.d.ts +14 -0
  163. package/es/components/organism/TextEditor/index.js +6 -0
  164. package/es/components/organism/TextEditor/index.scss +61 -0
  165. package/es/components/organism/TextEditor/provider.d.ts +15 -0
  166. package/es/components/organism/TextEditor/provider.js +33 -0
  167. package/es/components/organism/TextEditor/store.d.ts +13 -0
  168. package/es/components/organism/TextEditor/store.js +20 -0
  169. package/es/components/organism/TextEditor/styled.d.ts +10 -0
  170. package/es/components/organism/TextEditor/styled.js +94 -0
  171. package/es/components/organism/TextEditor/types.d.ts +96 -0
  172. package/es/components/organism/TextEditor/types.js +3 -0
  173. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +6 -0
  174. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +85 -0
  175. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
  176. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
  177. package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.d.ts +1 -0
  178. package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +1 -0
  179. package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
  180. package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +1 -0
  181. package/es/components/organism/TextEditor/ui/Button/Button.d.ts +2 -0
  182. package/es/components/organism/TextEditor/ui/Button/Button.js +31 -0
  183. package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
  184. package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
  185. package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
  186. package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
  187. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
  188. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
  189. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
  190. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
  191. package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
  192. package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
  193. package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
  194. package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
  195. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
  196. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
  197. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
  198. package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
  199. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
  200. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
  201. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +12 -0
  202. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +69 -0
  203. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +1 -0
  204. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +22 -0
  205. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
  206. package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
  207. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
  208. package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
  209. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
  210. package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
  211. package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
  212. package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
  213. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
  214. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
  215. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
  216. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
  217. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
  218. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +52 -0
  219. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
  220. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
  221. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
  222. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +77 -0
  223. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
  224. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
  225. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +15 -0
  226. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +41 -0
  227. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +5 -0
  228. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +18 -0
  229. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
  230. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +84 -0
  231. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
  232. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +27 -0
  233. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
  234. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +31 -0
  235. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +7 -0
  236. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +28 -0
  237. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +7 -0
  238. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +47 -0
  239. package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
  240. package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
  241. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
  242. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
  243. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
  244. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
  245. package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
  246. package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
  247. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
  248. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +17 -0
  249. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
  250. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +67 -0
  251. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
  252. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +17 -0
  253. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
  254. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +18 -0
  255. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +10 -0
  256. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +45 -0
  257. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
  258. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
  259. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
  260. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
  261. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
  262. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
  263. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
  264. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
  265. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
  266. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
  267. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
  268. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
  269. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
  270. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
  271. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
  272. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
  273. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +6 -0
  274. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +19 -0
  275. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +19 -0
  276. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +19 -0
  277. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +1 -0
  278. package/es/components/organism/TextEditor/ui/Toolbar/index.js +1 -0
  279. package/es/components/organism/TextEditor/utils/documentState.d.ts +57 -0
  280. package/es/components/organism/TextEditor/utils/documentState.js +100 -0
  281. package/es/components/organism/TextEditor/utils/font.d.ts +73 -0
  282. package/es/components/organism/TextEditor/utils/font.js +160 -0
  283. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +63 -0
  284. package/es/components/organism/TextEditor/utils/htmlProcessing.js +319 -0
  285. package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
  286. package/es/components/organism/TextEditor/utils/indent.js +56 -0
  287. package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
  288. package/es/components/organism/TextEditor/utils/index.js +16 -0
  289. package/es/components/organism/TextEditor/utils/link.d.ts +100 -0
  290. package/es/components/organism/TextEditor/utils/link.js +149 -0
  291. package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
  292. package/es/components/organism/TextEditor/utils/menu.js +317 -0
  293. package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
  294. package/es/components/organism/TextEditor/utils/selection.js +57 -0
  295. package/es/components/organism/TextEditor/utils/shared.d.ts +1 -0
  296. package/es/components/organism/TextEditor/utils/shared.js +9 -0
  297. package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
  298. package/es/components/organism/TextEditor/utils/smartTag.js +89 -0
  299. package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
  300. package/es/components/organism/TextEditor/utils/style.js +193 -0
  301. package/es/components/organism/TicketEditor/index.js +24 -16
  302. package/es/components/organism/index.d.ts +1 -0
  303. package/es/components/organism/index.js +1 -0
  304. package/es/components/organism/index.scss +1 -0
  305. package/es/hooks/index.d.ts +3 -0
  306. package/es/hooks/index.js +3 -0
  307. package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
  308. package/es/hooks/useBroadcastedLocalStorage.js +71 -0
  309. package/es/hooks/useElementSize.d.ts +7 -0
  310. package/es/hooks/useElementSize.js +56 -0
  311. package/es/hooks/useIsMounted.d.ts +1 -0
  312. package/es/hooks/useIsMounted.js +11 -0
  313. package/es/locales/en/translation.json +2 -1
  314. package/es/locales/i18n.d.ts +3 -1
  315. package/es/locales/vi/translation.json +2 -1
  316. package/es/utils/common.d.ts +6 -9
  317. package/es/utils/common.js +44 -23
  318. package/es/utils/index.d.ts +1 -0
  319. package/es/utils/index.js +1 -0
  320. package/es/utils/tree.d.ts +225 -0
  321. package/es/utils/tree.js +469 -0
  322. package/es/utils/web.d.ts +15 -0
  323. package/es/utils/web.js +39 -0
  324. package/package.json +24 -4
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Gets the appropriate bold font weight for a given font family
3
+ * @param currentFontFamily The font family to find bold weight for
4
+ * @param fonts Array of available font configurations
5
+ * @param minBoldWeight Minimum weight considered bold (default 700)
6
+ * @returns The first available bold weight for the font family, or minBoldWeight if none found
7
+ */
8
+ export const getBoldFontWeight = (currentFontFamily, fonts, minBoldWeight = 700) => {
9
+ if (!currentFontFamily || !fonts?.length)
10
+ return minBoldWeight;
11
+ const fontConfig = fonts.find(font => font.fontFamily.name === currentFontFamily);
12
+ return fontConfig?.fontWeight.find(weight => weight >= minBoldWeight) ?? minBoldWeight;
13
+ };
14
+ /**
15
+ * Validates if a font family name is a generic CSS font
16
+ * @param fontFamily Font family name to check
17
+ * @returns true if it's a generic font family
18
+ */
19
+ export function isGenericFontFamily(fontFamily) {
20
+ const genericFamilies = new Set([
21
+ 'serif',
22
+ 'sans-serif',
23
+ 'monospace',
24
+ 'cursive',
25
+ 'fantasy',
26
+ 'system-ui',
27
+ 'ui-serif',
28
+ 'ui-sans-serif',
29
+ 'ui-monospace',
30
+ 'ui-rounded',
31
+ 'math',
32
+ 'emoji',
33
+ 'fangsong',
34
+ ]);
35
+ return genericFamilies.has(fontFamily.toLowerCase().trim());
36
+ }
37
+ /**
38
+ * Extracts the primary font from a font-family string
39
+ * @param fontFamily Font family string (may contain fallbacks)
40
+ * @returns Primary font name
41
+ */
42
+ export function getPrimaryFontFamily(fontFamily) {
43
+ if (!fontFamily)
44
+ return '';
45
+ const fonts = fontFamily.split(',');
46
+ const primaryFont = fonts[0].trim();
47
+ // Remove quotes if present
48
+ return primaryFont.replace(/^["']|["']$/g, '');
49
+ }
50
+ /**
51
+ * Checks if a font weight is considered bold
52
+ * @param weight Font weight to check
53
+ * @param threshold Bold threshold (default 600)
54
+ * @returns true if weight is bold
55
+ */
56
+ export function isBoldWeight(weight, threshold = 600) {
57
+ const numericWeight = typeof weight === 'string' ? parseInt(weight, 10) : weight;
58
+ return !isNaN(numericWeight) && numericWeight >= threshold;
59
+ }
60
+ /**
61
+ * Gets all available font weights for a font family
62
+ * @param fontFamily Font family name
63
+ * @param fonts Array of font configurations
64
+ * @returns Array of available weights
65
+ */
66
+ export function getFontWeights(fontFamily, fonts) {
67
+ const fontConfig = fonts.find(font => font.fontFamily.name === fontFamily);
68
+ return fontConfig?.fontWeight || [400];
69
+ }
70
+ /**
71
+ * Finds the closest available font weight
72
+ * @param targetWeight Desired font weight
73
+ * @param availableWeights Array of available weights
74
+ * @returns Closest available weight
75
+ */
76
+ export function getClosestFontWeight(targetWeight, availableWeights) {
77
+ if (availableWeights.includes(targetWeight)) {
78
+ return targetWeight;
79
+ }
80
+ return availableWeights.reduce((closest, weight) => Math.abs(weight - targetWeight) < Math.abs(closest - targetWeight) ? weight : closest);
81
+ }
82
+ /**
83
+ * Validates font configuration
84
+ * @param fontConfig Font configuration to validate
85
+ * @returns true if configuration is valid
86
+ */
87
+ export function isValidFontConfig(fontConfig) {
88
+ return !!(fontConfig.fontFamily?.name &&
89
+ fontConfig.fontWeight &&
90
+ Array.isArray(fontConfig.fontWeight) &&
91
+ fontConfig.fontWeight.length > 0 &&
92
+ fontConfig.fontWeight.every(weight => typeof weight === 'number' && weight > 0));
93
+ }
94
+ /**
95
+ * Sorts font configurations alphabetically by name
96
+ * @param fonts Array of font configurations
97
+ * @returns Sorted array of font configurations
98
+ */
99
+ export function sortFontsByName(fonts) {
100
+ return [...fonts].sort((a, b) => a.fontFamily.name.localeCompare(b.fontFamily.name));
101
+ }
102
+ /**
103
+ * Groups fonts by category (if category property exists)
104
+ * @param fonts Array of font configurations
105
+ * @returns Object with fonts grouped by category
106
+ */
107
+ export function groupFontsByCategory(fonts) {
108
+ const grouped = {};
109
+ fonts.forEach(font => {
110
+ const category = font.category || 'Other';
111
+ if (!grouped[category]) {
112
+ grouped[category] = [];
113
+ }
114
+ grouped[category].push(font);
115
+ });
116
+ return grouped;
117
+ }
118
+ /**
119
+ * Checks if a font is web safe
120
+ * @param fontFamily Font family name
121
+ * @returns true if font is web safe
122
+ */
123
+ export function isWebSafeFont(fontFamily) {
124
+ const webSafeFonts = new Set([
125
+ 'arial',
126
+ 'helvetica',
127
+ 'times new roman',
128
+ 'times',
129
+ 'courier new',
130
+ 'courier',
131
+ 'verdana',
132
+ 'georgia',
133
+ 'palatino',
134
+ 'garamond',
135
+ 'bookman',
136
+ 'comic sans ms',
137
+ 'trebuchet ms',
138
+ 'arial black',
139
+ 'impact',
140
+ 'lucida sans unicode',
141
+ 'tahoma',
142
+ 'lucida console',
143
+ ]);
144
+ return webSafeFonts.has(fontFamily.toLowerCase().trim());
145
+ }
146
+ /**
147
+ * Creates a font stack with appropriate fallbacks
148
+ * @param primaryFont Primary font family
149
+ * @param category Font category for fallback selection
150
+ * @returns Complete font stack string
151
+ */
152
+ export function createFontStack(primaryFont, category = 'sans-serif') {
153
+ const fallbacks = {
154
+ serif: ['Georgia', 'Times New Roman', 'Times', 'serif'],
155
+ 'sans-serif': ['Arial', 'Helvetica', 'sans-serif'],
156
+ monospace: ['Courier New', 'Courier', 'monospace'],
157
+ };
158
+ const stack = [primaryFont, ...fallbacks[category]];
159
+ return stack.join(', ');
160
+ }
@@ -0,0 +1,63 @@
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;
@@ -0,0 +1,319 @@
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
+ };
@@ -0,0 +1,11 @@
1
+ import type { Command } from '@tiptap/core';
2
+ export declare const enum IndentProps {
3
+ max = 7,
4
+ min = 0,
5
+ more = 1,
6
+ less = -1
7
+ }
8
+ export declare function createIndentCommand({ delta, types }: {
9
+ delta: number;
10
+ types: string[];
11
+ }): Command;
@@ -0,0 +1,56 @@
1
+ import { isList } from '@tiptap/core';
2
+ import { TextSelection, AllSelection } from '@tiptap/pm/state';
3
+ import { clamp } from './shared';
4
+ function setNodeIndentMarkup(tr, pos, delta) {
5
+ if (!tr.doc)
6
+ return tr;
7
+ const node = tr.doc.nodeAt(pos);
8
+ if (!node)
9
+ return tr;
10
+ const minIndent = 0 /* IndentProps.min */;
11
+ const maxIndent = 7 /* IndentProps.max */;
12
+ const indent = clamp((node.attrs.indent || 0) + delta, minIndent, maxIndent);
13
+ if (indent === node.attrs.indent)
14
+ return tr;
15
+ const nodeAttrs = {
16
+ ...node.attrs,
17
+ indent,
18
+ };
19
+ return tr.setNodeMarkup(pos, node.type, nodeAttrs, node.marks);
20
+ }
21
+ function updateIndentLevel(tr, delta, types, editor) {
22
+ const { doc, selection } = tr;
23
+ if (!doc || !selection)
24
+ return tr;
25
+ if (!(selection instanceof TextSelection || selection instanceof AllSelection)) {
26
+ return tr;
27
+ }
28
+ const { from, to } = selection;
29
+ doc.nodesBetween(from, to, (node, pos) => {
30
+ const nodeType = node.type;
31
+ if (types.includes(nodeType.name)) {
32
+ tr = setNodeIndentMarkup(tr, pos, delta);
33
+ return false;
34
+ }
35
+ if (isList(node.type.name, editor.extensionManager.extensions)) {
36
+ return false;
37
+ }
38
+ return true;
39
+ });
40
+ return tr;
41
+ }
42
+ export function createIndentCommand({ delta, types }) {
43
+ return ({ state, dispatch, editor }) => {
44
+ const { selection } = state;
45
+ let { tr } = state;
46
+ tr = tr.setSelection(selection);
47
+ tr = updateIndentLevel(tr, delta, types, editor);
48
+ if (tr.docChanged) {
49
+ if (dispatch) {
50
+ dispatch(tr);
51
+ }
52
+ return true;
53
+ }
54
+ return false;
55
+ };
56
+ }
@@ -0,0 +1,8 @@
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';
@@ -0,0 +1,16 @@
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';