@antscorp/antsomi-ui 2.0.89 → 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 (336) 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/QuillEditor/EditorToolbar.js +1 -0
  74. package/es/components/molecules/QuillEditor/QuillEditor.d.ts +6 -1
  75. package/es/components/molecules/QuillEditor/QuillEditor.js +90 -55
  76. package/es/components/molecules/QuillEditor/styled.d.ts +5 -0
  77. package/es/components/molecules/QuillEditor/styled.js +29 -0
  78. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +6 -3
  79. package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +2550 -938
  80. package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +1 -11
  81. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +53 -25
  82. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +8 -5
  83. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +289 -46
  84. package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +1 -0
  85. package/es/components/molecules/VirtualizedMenu/styled.d.ts +2 -2
  86. package/es/components/molecules/VirtualizedMenu/styled.js +23 -4
  87. package/es/components/molecules/VirtualizedMenu/types.d.ts +27 -10
  88. package/es/components/molecules/VirtualizedMenu/utils.d.ts +8 -5
  89. package/es/components/molecules/VirtualizedMenu/utils.js +13 -18
  90. package/es/components/molecules/index.d.ts +2 -0
  91. package/es/components/molecules/index.js +2 -0
  92. package/es/components/molecules/index.scss +1 -0
  93. package/es/components/organism/ActivityTimeline/ActivityTimeline.js +15 -9
  94. package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -0
  95. package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -0
  96. package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.d.ts +3 -4
  97. package/es/components/organism/ActivityTimeline/components/ItemEvent/ItemEvent.js +4 -3
  98. package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.d.ts +4 -6
  99. package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.js +4 -4
  100. package/es/components/organism/ActivityTimeline/components/TimeLineTitle/TimelineTitle.js +1 -1
  101. package/es/components/organism/ActivityTimeline/types.d.ts +2 -1
  102. package/es/components/organism/ActivityTimeline/utils.d.ts +1 -1
  103. package/es/components/organism/ActivityTimeline/utils.js +1 -1
  104. package/es/components/organism/Help/Help.js +47 -10
  105. package/es/components/organism/TextEditor/TextEditor.d.ts +3 -0
  106. package/es/components/organism/TextEditor/TextEditor.js +257 -0
  107. package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
  108. package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
  109. package/es/components/organism/TextEditor/__mocks__/text-contennt.js +38 -0
  110. package/es/components/organism/TextEditor/constants.d.ts +175 -0
  111. package/es/components/organism/TextEditor/constants.js +321 -0
  112. package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
  113. package/es/components/organism/TextEditor/extensions/BackgroundColor.js +46 -0
  114. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +130 -0
  115. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +247 -0
  116. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
  117. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +31 -0
  118. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
  119. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
  120. package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
  121. package/es/components/organism/TextEditor/extensions/Color.js +34 -0
  122. package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
  123. package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
  124. package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
  125. package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
  126. package/es/components/organism/TextEditor/extensions/FontSize.d.ts +32 -0
  127. package/es/components/organism/TextEditor/extensions/FontSize.js +47 -0
  128. package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
  129. package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
  130. package/es/components/organism/TextEditor/extensions/Highlight.d.ts +1 -0
  131. package/es/components/organism/TextEditor/extensions/Highlight.js +14 -0
  132. package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
  133. package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
  134. package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
  135. package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
  136. package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
  137. package/es/components/organism/TextEditor/extensions/LineHeight.js +36 -0
  138. package/es/components/organism/TextEditor/extensions/Link.d.ts +16 -0
  139. package/es/components/organism/TextEditor/extensions/Link.js +48 -0
  140. package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
  141. package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
  142. package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
  143. package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
  144. package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +39 -0
  145. package/es/components/organism/TextEditor/extensions/SmartTag.js +167 -0
  146. package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
  147. package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
  148. package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +31 -0
  149. package/es/components/organism/TextEditor/extensions/TextTransform.js +37 -0
  150. package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
  151. package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
  152. package/es/components/organism/TextEditor/hooks/index.d.ts +7 -0
  153. package/es/components/organism/TextEditor/hooks/index.js +7 -0
  154. package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
  155. package/es/components/organism/TextEditor/hooks/useColorSet.js +22 -0
  156. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
  157. package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
  158. package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +11 -0
  159. package/es/components/organism/TextEditor/hooks/useLinkHandler.js +125 -0
  160. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
  161. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +68 -0
  162. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
  163. package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
  164. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
  165. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
  166. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
  167. package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
  168. package/es/components/organism/TextEditor/index.d.ts +14 -0
  169. package/es/components/organism/TextEditor/index.js +6 -0
  170. package/es/components/organism/TextEditor/index.scss +61 -0
  171. package/es/components/organism/TextEditor/provider.d.ts +15 -0
  172. package/es/components/organism/TextEditor/provider.js +33 -0
  173. package/es/components/organism/TextEditor/store.d.ts +13 -0
  174. package/es/components/organism/TextEditor/store.js +20 -0
  175. package/es/components/organism/TextEditor/styled.d.ts +10 -0
  176. package/es/components/organism/TextEditor/styled.js +94 -0
  177. package/es/components/organism/TextEditor/types.d.ts +96 -0
  178. package/es/components/organism/TextEditor/types.js +3 -0
  179. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +6 -0
  180. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +85 -0
  181. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
  182. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
  183. package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.d.ts +1 -0
  184. package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +1 -0
  185. package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
  186. package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +1 -0
  187. package/es/components/organism/TextEditor/ui/Button/Button.d.ts +2 -0
  188. package/es/components/organism/TextEditor/ui/Button/Button.js +31 -0
  189. package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
  190. package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
  191. package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
  192. package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
  193. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
  194. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
  195. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
  196. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
  197. package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
  198. package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
  199. package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
  200. package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
  201. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
  202. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
  203. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
  204. package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
  205. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
  206. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
  207. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +12 -0
  208. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +69 -0
  209. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +1 -0
  210. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +22 -0
  211. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
  212. package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
  213. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
  214. package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
  215. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
  216. package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
  217. package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
  218. package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
  219. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
  220. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
  221. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
  222. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
  223. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
  224. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +52 -0
  225. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
  226. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
  227. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
  228. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +77 -0
  229. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
  230. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
  231. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +15 -0
  232. package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +41 -0
  233. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +5 -0
  234. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +18 -0
  235. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
  236. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +84 -0
  237. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
  238. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +27 -0
  239. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
  240. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +31 -0
  241. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +7 -0
  242. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +28 -0
  243. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +7 -0
  244. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +47 -0
  245. package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
  246. package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
  247. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
  248. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
  249. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
  250. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
  251. package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
  252. package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
  253. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +6 -0
  254. package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +17 -0
  255. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +5 -0
  256. package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +67 -0
  257. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +5 -0
  258. package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +17 -0
  259. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +7 -0
  260. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +18 -0
  261. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +10 -0
  262. package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +45 -0
  263. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +5 -0
  264. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
  265. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
  266. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
  267. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
  268. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
  269. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
  270. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
  271. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
  272. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
  273. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
  274. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
  275. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
  276. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
  277. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
  278. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
  279. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +6 -0
  280. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +19 -0
  281. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +19 -0
  282. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +19 -0
  283. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +1 -0
  284. package/es/components/organism/TextEditor/ui/Toolbar/index.js +1 -0
  285. package/es/components/organism/TextEditor/utils/documentState.d.ts +57 -0
  286. package/es/components/organism/TextEditor/utils/documentState.js +100 -0
  287. package/es/components/organism/TextEditor/utils/font.d.ts +73 -0
  288. package/es/components/organism/TextEditor/utils/font.js +160 -0
  289. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +63 -0
  290. package/es/components/organism/TextEditor/utils/htmlProcessing.js +319 -0
  291. package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
  292. package/es/components/organism/TextEditor/utils/indent.js +56 -0
  293. package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
  294. package/es/components/organism/TextEditor/utils/index.js +16 -0
  295. package/es/components/organism/TextEditor/utils/link.d.ts +100 -0
  296. package/es/components/organism/TextEditor/utils/link.js +149 -0
  297. package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
  298. package/es/components/organism/TextEditor/utils/menu.js +317 -0
  299. package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
  300. package/es/components/organism/TextEditor/utils/selection.js +57 -0
  301. package/es/components/organism/TextEditor/utils/shared.d.ts +1 -0
  302. package/es/components/organism/TextEditor/utils/shared.js +9 -0
  303. package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
  304. package/es/components/organism/TextEditor/utils/smartTag.js +89 -0
  305. package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
  306. package/es/components/organism/TextEditor/utils/style.js +193 -0
  307. package/es/components/organism/TicketEditor/Content.js +47 -33
  308. package/es/components/organism/TicketEditor/components/MessageComponent.js +1 -0
  309. package/es/components/organism/TicketEditor/index.js +24 -16
  310. package/es/components/organism/TicketEditor/styled.js +1 -0
  311. package/es/components/organism/TicketEditorV2/Content.js +41 -7
  312. package/es/components/organism/TicketEditorV2/components/MessageComponent.js +1 -0
  313. package/es/components/organism/TicketEditorV2/styled.js +2 -1
  314. package/es/components/organism/index.d.ts +1 -0
  315. package/es/components/organism/index.js +1 -0
  316. package/es/components/organism/index.scss +1 -0
  317. package/es/hooks/index.d.ts +3 -0
  318. package/es/hooks/index.js +3 -0
  319. package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
  320. package/es/hooks/useBroadcastedLocalStorage.js +71 -0
  321. package/es/hooks/useElementSize.d.ts +7 -0
  322. package/es/hooks/useElementSize.js +56 -0
  323. package/es/hooks/useIsMounted.d.ts +1 -0
  324. package/es/hooks/useIsMounted.js +11 -0
  325. package/es/locales/en/translation.json +2 -1
  326. package/es/locales/i18n.d.ts +3 -1
  327. package/es/locales/vi/translation.json +2 -1
  328. package/es/utils/common.d.ts +6 -9
  329. package/es/utils/common.js +44 -23
  330. package/es/utils/index.d.ts +1 -0
  331. package/es/utils/index.js +1 -0
  332. package/es/utils/tree.d.ts +225 -0
  333. package/es/utils/tree.js +469 -0
  334. package/es/utils/web.d.ts +15 -0
  335. package/es/utils/web.js +39 -0
  336. package/package.json +25 -4
@@ -0,0 +1,55 @@
1
+ import { Node } from '@tiptap/core';
2
+ import { type UnorderedListStyleType } from '../types';
3
+ type ListStyleType = UnorderedListStyleType;
4
+ export interface CustomUnorderedListOptions {
5
+ /**
6
+ * The node name for the list items
7
+ * @default 'listItem'
8
+ */
9
+ itemTypeName: string;
10
+ /**
11
+ * HTML attributes to add to the unordered list element
12
+ * @default {}
13
+ */
14
+ HTMLAttributes: Record<string, any>;
15
+ /**
16
+ * Keep the marks when splitting the list
17
+ * @default false
18
+ */
19
+ keepMarks: boolean;
20
+ /**
21
+ * Keep the attributes when splitting the list
22
+ * @default false
23
+ */
24
+ keepAttributes: boolean;
25
+ /**
26
+ * Default list style type
27
+ * @default 'disc'
28
+ */
29
+ defaultListStyleType: ListStyleType;
30
+ }
31
+ declare module '@tiptap/core' {
32
+ interface Commands<ReturnType> {
33
+ customUnorderedList: {
34
+ /**
35
+ * Toggle a custom unordered list
36
+ */
37
+ toggleCustomUnorderedList: (options?: {
38
+ listStyleType?: ListStyleType;
39
+ customBulletChar?: string;
40
+ }) => ReturnType;
41
+ /**
42
+ * Set list style type for current unordered list
43
+ */
44
+ setUnorderedListStyle: (options: {
45
+ listStyleType?: ListStyleType;
46
+ customBulletChar?: string;
47
+ }) => ReturnType;
48
+ };
49
+ }
50
+ }
51
+ /**
52
+ * This extension allows you to create unordered lists with custom bullet styles.
53
+ */
54
+ export declare const CustomUnorderedList: Node<CustomUnorderedListOptions, any>;
55
+ export {};
@@ -0,0 +1,176 @@
1
+ import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core';
2
+ import { UNORDERED_LIST_STYLE_TYPE } from '../constants';
3
+ const ListItemName = 'listItem';
4
+ const TextStyleName = 'textStyle';
5
+ /**
6
+ * Input regex patterns for different bullet styles
7
+ */
8
+ const inputRegexPatterns = {
9
+ disc: /^\s*([-*•])\s$/,
10
+ circle: /^\s*([○◯])\s$/,
11
+ square: /^\s*([▪■])\s$/,
12
+ plus: /^\s*([+])\s$/,
13
+ arrow: /^\s*([→➤])\s$/,
14
+ star: /^\s*([★☆])\s$/,
15
+ };
16
+ /**
17
+ * Map input characters to bullet style types
18
+ */
19
+ const charToBulletStyle = {
20
+ '-': UNORDERED_LIST_STYLE_TYPE.disc,
21
+ '*': UNORDERED_LIST_STYLE_TYPE.disc,
22
+ '•': UNORDERED_LIST_STYLE_TYPE.disc,
23
+ '○': UNORDERED_LIST_STYLE_TYPE.circle,
24
+ '◯': UNORDERED_LIST_STYLE_TYPE.circle,
25
+ '▪': UNORDERED_LIST_STYLE_TYPE.square,
26
+ '■': UNORDERED_LIST_STYLE_TYPE.square,
27
+ '+': UNORDERED_LIST_STYLE_TYPE.custom,
28
+ '→': UNORDERED_LIST_STYLE_TYPE.custom,
29
+ '➤': UNORDERED_LIST_STYLE_TYPE.custom,
30
+ '★': UNORDERED_LIST_STYLE_TYPE.custom,
31
+ '☆': UNORDERED_LIST_STYLE_TYPE.custom,
32
+ };
33
+ /**
34
+ * This extension allows you to create unordered lists with custom bullet styles.
35
+ */
36
+ export const CustomUnorderedList = Node.create({
37
+ name: 'customUnorderedList',
38
+ addOptions() {
39
+ return {
40
+ itemTypeName: ListItemName,
41
+ HTMLAttributes: {
42
+ style: 'margin:0.5em 0;padding-inline-start:1.2em',
43
+ },
44
+ keepMarks: false,
45
+ keepAttributes: false,
46
+ defaultListStyleType: UNORDERED_LIST_STYLE_TYPE.disc,
47
+ customBulletChar: '→',
48
+ };
49
+ },
50
+ group: 'block list',
51
+ content() {
52
+ return `${this.options.itemTypeName}+`;
53
+ },
54
+ addAttributes() {
55
+ return {
56
+ listStyleType: {
57
+ default: this.options.defaultListStyleType,
58
+ parseHTML: element => {
59
+ if (element.dataset.bulletChar) {
60
+ return UNORDERED_LIST_STYLE_TYPE.custom;
61
+ }
62
+ const style = element.getAttribute('style');
63
+ const listStyleType = style?.match(/list-style-type:\s*([^;]+)/)?.[1]?.trim();
64
+ return listStyleType || this.options.defaultListStyleType;
65
+ },
66
+ renderHTML: attributes => {
67
+ if (attributes.listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
68
+ return {};
69
+ }
70
+ return {
71
+ style: `list-style-type: ${attributes.listStyleType}`,
72
+ };
73
+ },
74
+ },
75
+ customBulletChar: {
76
+ default: null,
77
+ parseHTML: element => element.getAttribute('data-bullet-char'),
78
+ renderHTML: attributes => {
79
+ if (attributes.listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
80
+ return {
81
+ 'data-bullet-char': attributes.customBulletChar,
82
+ style: `list-style-type: '${attributes.customBulletChar} '`,
83
+ };
84
+ }
85
+ return {};
86
+ },
87
+ },
88
+ };
89
+ },
90
+ parseHTML() {
91
+ return [{ tag: 'ul' }];
92
+ },
93
+ renderHTML({ HTMLAttributes }) {
94
+ return ['ul', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
95
+ },
96
+ addCommands() {
97
+ return {
98
+ toggleCustomUnorderedList: (options = {}) => ({ chain }) => {
99
+ const { listStyleType = this.options.defaultListStyleType, customBulletChar } = options;
100
+ if (this.options.keepAttributes) {
101
+ return chain()
102
+ .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
103
+ .updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))
104
+ .updateAttributes(this.name, {
105
+ listStyleType,
106
+ customBulletChar,
107
+ })
108
+ .run();
109
+ }
110
+ return chain()
111
+ .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
112
+ .updateAttributes(this.name, {
113
+ listStyleType,
114
+ customBulletChar,
115
+ })
116
+ .run();
117
+ },
118
+ setUnorderedListStyle: (options = {}) => ({ commands }) => {
119
+ const { listStyleType, customBulletChar } = options;
120
+ return commands.updateAttributes(this.name, {
121
+ listStyleType,
122
+ customBulletChar,
123
+ });
124
+ },
125
+ };
126
+ },
127
+ addKeyboardShortcuts() {
128
+ return {
129
+ 'Mod-Shift-8': () => this.editor.commands.toggleCustomUnorderedList(),
130
+ };
131
+ },
132
+ addInputRules() {
133
+ const inputRules = [];
134
+ Object.values(inputRegexPatterns).forEach(regex => {
135
+ let inputRule = wrappingInputRule({
136
+ find: regex,
137
+ type: this.type,
138
+ getAttributes: match => {
139
+ const char = match[1];
140
+ const listStyleType = charToBulletStyle[char] || UNORDERED_LIST_STYLE_TYPE.disc;
141
+ if (listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
142
+ return {
143
+ listStyleType: UNORDERED_LIST_STYLE_TYPE.custom,
144
+ customBulletChar: char,
145
+ };
146
+ }
147
+ return { listStyleType };
148
+ },
149
+ });
150
+ if (this.options.keepMarks || this.options.keepAttributes) {
151
+ inputRule = wrappingInputRule({
152
+ find: regex,
153
+ type: this.type,
154
+ keepMarks: this.options.keepMarks,
155
+ keepAttributes: this.options.keepAttributes,
156
+ getAttributes: match => {
157
+ const char = match[1];
158
+ const listStyleType = charToBulletStyle[char] || UNORDERED_LIST_STYLE_TYPE.disc;
159
+ const baseAttributes = this.editor.getAttributes(TextStyleName);
160
+ if (listStyleType === UNORDERED_LIST_STYLE_TYPE.custom) {
161
+ return {
162
+ ...baseAttributes,
163
+ listStyleType: UNORDERED_LIST_STYLE_TYPE.custom,
164
+ customBulletChar: char,
165
+ };
166
+ }
167
+ return { ...baseAttributes, listStyleType };
168
+ },
169
+ editor: this.editor,
170
+ });
171
+ }
172
+ inputRules.push(inputRule);
173
+ });
174
+ return inputRules;
175
+ },
176
+ });
@@ -0,0 +1,7 @@
1
+ export * from './usePersistence';
2
+ export * from './useLinkHandler';
3
+ export * from './useMarkTracking';
4
+ export * from './useStyleMemory';
5
+ export * from './useStylePresets';
6
+ export * from './useDocumentState';
7
+ export * from './useColorSet';
@@ -0,0 +1,7 @@
1
+ export * from './usePersistence';
2
+ export * from './useLinkHandler';
3
+ export * from './useMarkTracking';
4
+ export * from './useStyleMemory';
5
+ export * from './useStylePresets';
6
+ export * from './useDocumentState';
7
+ export * from './useColorSet';
@@ -0,0 +1,4 @@
1
+ export declare const useColorSet: () => {
2
+ colors: string[];
3
+ setColors: (newColors: string[]) => void;
4
+ };
@@ -0,0 +1,22 @@
1
+ import { useBroadcastedLocalStorage, useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
2
+ import { useTextEditorStore } from '../provider';
3
+ import { ANTSOMI_COMPONENT_PREFIX_CLS } from '@antscorp/antsomi-ui/es/constants';
4
+ import { useCallback } from 'react';
5
+ export const useColorSet = () => {
6
+ const colors = useTextEditorStore(s => s.colors);
7
+ const setColors = useTextEditorStore(s => s.setColors);
8
+ const { value: storageColors, setValue: setStorageColors } = useBroadcastedLocalStorage(`${ANTSOMI_COMPONENT_PREFIX_CLS}_text-editor`, undefined);
9
+ useDeepCompareEffect(() => {
10
+ if (storageColors === undefined && colors !== undefined) {
11
+ setStorageColors(colors);
12
+ }
13
+ if (colors === undefined && storageColors !== undefined) {
14
+ setColors(storageColors);
15
+ }
16
+ }, [colors, storageColors, setColors, setStorageColors]);
17
+ const composeSetColors = useCallback((newColors) => {
18
+ setColors(newColors);
19
+ setStorageColors(newColors);
20
+ }, [setColors, setStorageColors]);
21
+ return { colors: colors || [], setColors: composeSetColors };
22
+ };
@@ -0,0 +1,18 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { DocumentStateConfig, getDocumentStats } from '../utils/documentState';
3
+ export interface UseDocumentStateOptions extends DocumentStateConfig {
4
+ /** Callback when document becomes empty */
5
+ onBecomeEmpty?: () => void;
6
+ /** Callback when document becomes non-empty */
7
+ onBecomeNonEmpty?: () => void;
8
+ /** Callback when document state changes */
9
+ onStateChange?: (stats: ReturnType<typeof getDocumentStats>) => void;
10
+ }
11
+ export declare function useDocumentState(editor: Editor | null, options?: UseDocumentStateOptions): {
12
+ nodeSize: number;
13
+ textLength: number;
14
+ trimmedTextLength: number;
15
+ nodeCount: void;
16
+ isEmpty: boolean;
17
+ emptyDocumentSize: number;
18
+ } | null;
@@ -0,0 +1,42 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { DocumentStateTracker, getDocumentStats, } from '../utils/documentState';
3
+ export function useDocumentState(editor, options = {}) {
4
+ const { onBecomeEmpty, onBecomeNonEmpty, onStateChange } = options;
5
+ const [documentStats, setDocumentStats] = useState(() => editor ? getDocumentStats(editor.state) : null);
6
+ const trackerRef = useRef(new DocumentStateTracker());
7
+ const updateDocumentState = useCallback(() => {
8
+ if (!editor)
9
+ return;
10
+ const stats = getDocumentStats(editor.state);
11
+ const changes = trackerRef.current.update(editor.state);
12
+ setDocumentStats(stats);
13
+ // Trigger callbacks
14
+ if (changes.becameEmpty) {
15
+ onBecomeEmpty?.();
16
+ }
17
+ if (changes.becameNonEmpty) {
18
+ onBecomeNonEmpty?.();
19
+ }
20
+ if (changes.sizeChanged || changes.textLengthChanged) {
21
+ onStateChange?.(stats);
22
+ }
23
+ }, [editor, onBecomeEmpty, onBecomeNonEmpty, onStateChange]);
24
+ useEffect(() => {
25
+ if (!editor)
26
+ return;
27
+ // Initial state
28
+ updateDocumentState();
29
+ // Listen to changes
30
+ editor.on('update', updateDocumentState);
31
+ editor.on('transaction', updateDocumentState);
32
+ return () => {
33
+ editor.off('update', updateDocumentState);
34
+ editor.off('transaction', updateDocumentState);
35
+ };
36
+ }, [editor, updateDocumentState]);
37
+ // Reset tracker when editor changes
38
+ useEffect(() => {
39
+ trackerRef.current.reset();
40
+ }, [editor]);
41
+ return documentStats;
42
+ }
@@ -0,0 +1,11 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { Attrs } from '@tiptap/pm/model';
3
+ export declare function useLinkHandler(params: {
4
+ editor?: Editor | null;
5
+ highlight?: boolean;
6
+ }): {
7
+ setLink: (attrs: import("../extensions/Link").LinkAttrs) => void;
8
+ deleteLink: (id: string) => void;
9
+ unsetLink: () => void;
10
+ updateLinkAttrsGlobally: (updateFn: (attrs: Attrs) => Attrs | undefined) => void;
11
+ };
@@ -0,0 +1,125 @@
1
+ import { useCallback } from 'react';
2
+ import { TextSelection } from '@tiptap/pm/state';
3
+ import { getLinkMarkRanges, getLinkRange, isLinkColor } from '../utils';
4
+ import { TEXT_EDITOR_CONSTANTS } from '../constants';
5
+ const { LINK_TEXT_COLOR } = TEXT_EDITOR_CONSTANTS;
6
+ export function useLinkHandler(params) {
7
+ const { editor, highlight } = params;
8
+ const setLink = useCallback(attrs => {
9
+ if (!editor)
10
+ return;
11
+ const { selection } = editor?.state;
12
+ const { from, to } = selection;
13
+ let linkContent = editor.state.doc.textBetween(from, to);
14
+ if (attrs.content && linkContent !== attrs.content) {
15
+ linkContent = attrs.content;
16
+ }
17
+ editor
18
+ .chain()
19
+ .focus()
20
+ .deleteSelection()
21
+ .insertContent(linkContent)
22
+ .command(({ tr }) => {
23
+ const endPos = tr.selection.from;
24
+ const startPos = endPos - linkContent.length;
25
+ tr.setSelection(TextSelection.create(tr.doc, startPos, endPos));
26
+ return true;
27
+ })
28
+ .setUnderline()
29
+ .setColor(LINK_TEXT_COLOR)
30
+ .setLink({
31
+ ...attrs,
32
+ class: highlight ? 'highlight' : undefined,
33
+ })
34
+ .command(({ tr }) => {
35
+ const endPos = tr.selection.to;
36
+ tr.setSelection(TextSelection.create(tr.doc, endPos, endPos));
37
+ return true;
38
+ })
39
+ .run();
40
+ }, [editor, highlight]);
41
+ const deleteLink = useCallback((id) => {
42
+ if (!editor)
43
+ return;
44
+ const { state } = editor;
45
+ const { doc } = state;
46
+ let linkMark;
47
+ doc.descendants((node, pos) => {
48
+ if (linkMark)
49
+ return;
50
+ linkMark = getLinkMarkRanges({
51
+ state,
52
+ from: pos,
53
+ to: pos + node.nodeSize,
54
+ }).find(range => range.mark.attrs.id === id);
55
+ });
56
+ if (linkMark) {
57
+ editor
58
+ .chain()
59
+ .deleteRange({
60
+ from: linkMark.from,
61
+ to: linkMark.to,
62
+ })
63
+ .run();
64
+ }
65
+ }, [editor]);
66
+ const updateLinkAttrsGlobally = useCallback((updateFn) => {
67
+ if (!editor)
68
+ return;
69
+ const { state, view } = editor;
70
+ const { doc, schema, tr } = state;
71
+ const linkType = schema.marks.link;
72
+ let somethingChanged = false;
73
+ doc.descendants((node, pos) => {
74
+ // Get all link mark ranges within this node
75
+ const linkMarkRanges = getLinkMarkRanges({
76
+ state,
77
+ from: pos,
78
+ to: pos + node.nodeSize,
79
+ });
80
+ linkMarkRanges.forEach(markRange => {
81
+ const updatedAttrs = updateFn(markRange.mark.attrs);
82
+ if (updatedAttrs) {
83
+ // Remove the old mark
84
+ tr.removeMark(markRange.from, markRange.to, markRange.mark);
85
+ // Create a new mark with updated attributes and add it
86
+ const newMark = linkType.create({
87
+ ...markRange.mark.attrs,
88
+ ...updatedAttrs,
89
+ });
90
+ tr.addMark(markRange.from, markRange.to, newMark);
91
+ somethingChanged = true;
92
+ }
93
+ });
94
+ });
95
+ if (somethingChanged) {
96
+ view.dispatch(tr);
97
+ }
98
+ }, [editor]);
99
+ const unsetLink = useCallback(() => {
100
+ if (!editor)
101
+ return;
102
+ const { state } = editor;
103
+ const linkRange = getLinkRange({ state, pos: state.selection.from });
104
+ if (!linkRange)
105
+ return;
106
+ const command = editor
107
+ .chain()
108
+ .setTextSelection({
109
+ from: linkRange.from,
110
+ to: linkRange.to,
111
+ })
112
+ .unsetUnderline()
113
+ .unsetLink();
114
+ if (isLinkColor(editor.getAttributes('textStyle').color)) {
115
+ command.unsetColor();
116
+ }
117
+ command.run();
118
+ }, [editor]);
119
+ return {
120
+ setLink,
121
+ deleteLink,
122
+ unsetLink,
123
+ updateLinkAttrsGlobally,
124
+ };
125
+ }
@@ -0,0 +1,26 @@
1
+ import { Editor } from '@tiptap/react';
2
+ import { Mark } from '@tiptap/pm/model';
3
+ export interface MarkSnapshot {
4
+ marks: Mark[];
5
+ position: number;
6
+ timestamp: number;
7
+ textContent: string;
8
+ }
9
+ export interface UseMarkTrackingOptions {
10
+ /** Maximum number of snapshots to keep */
11
+ maxSnapshots?: number;
12
+ /** Marks to exclude from tracking */
13
+ excludeMarks?: string[];
14
+ /** Debounce delay for tracking (ms) */
15
+ debounceDelay?: number;
16
+ /** Auto-capture snapshots */
17
+ autoCapture?: boolean;
18
+ }
19
+ export declare function useMarkTracking(editor: Editor | null, options?: UseMarkTrackingOptions): {
20
+ snapshots: MarkSnapshot[];
21
+ currentMarks: Mark[];
22
+ captureMarkSnapshot: () => void;
23
+ applySnapshot: (index: number) => void;
24
+ getSimilarSnapshots: (targetMarks?: Mark[]) => MarkSnapshot[];
25
+ clearSnapshots: () => void;
26
+ };
@@ -0,0 +1,68 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ export function useMarkTracking(editor, options = {}) {
3
+ const { maxSnapshots = 10, excludeMarks = ['link', 'smartTag'], debounceDelay = 500, autoCapture = true, } = options;
4
+ const [snapshots, setSnapshots] = useState([]);
5
+ const [currentMarks, setCurrentMarks] = useState([]);
6
+ // Capture current mark state
7
+ const captureMarkSnapshot = useCallback(() => {
8
+ if (!editor)
9
+ return;
10
+ const { selection, storedMarks } = editor.state;
11
+ const { $from } = selection;
12
+ const marks = (storedMarks || $from.marks()).filter(mark => !excludeMarks.includes(mark.type.name));
13
+ const snapshot = {
14
+ marks,
15
+ position: $from.pos,
16
+ timestamp: Date.now(),
17
+ textContent: editor.state.doc.textBetween(Math.max(0, $from.pos - 50), Math.min(editor.state.doc.content.size, $from.pos + 50)),
18
+ };
19
+ setSnapshots(prev => {
20
+ const updated = [snapshot, ...prev];
21
+ return updated.slice(0, maxSnapshots);
22
+ });
23
+ setCurrentMarks(marks);
24
+ }, [editor, excludeMarks, maxSnapshots]);
25
+ // Apply marks from snapshot
26
+ const applySnapshot = useCallback((index) => {
27
+ if (!editor || !snapshots[index])
28
+ return;
29
+ const snapshot = snapshots[index];
30
+ // Clear current marks
31
+ editor.chain().unsetAllMarks().run();
32
+ // Apply snapshot marks
33
+ snapshot.marks.forEach(mark => {
34
+ editor.chain().setMark(mark.type.name, mark.attrs).run();
35
+ });
36
+ }, [editor, snapshots]);
37
+ // Get similar snapshots based on marks
38
+ const getSimilarSnapshots = useCallback((targetMarks = currentMarks) => snapshots.filter(snapshot => {
39
+ const markNames = snapshot.marks.map(m => m.type.name).sort();
40
+ const targetNames = targetMarks.map(m => m.type.name).sort();
41
+ return JSON.stringify(markNames) === JSON.stringify(targetNames);
42
+ }), [snapshots, currentMarks]);
43
+ // Auto-capture setup
44
+ useEffect(() => {
45
+ if (!editor || !autoCapture)
46
+ return;
47
+ let timeoutId;
48
+ const handleUpdate = () => {
49
+ clearTimeout(timeoutId);
50
+ timeoutId = setTimeout(captureMarkSnapshot, debounceDelay);
51
+ };
52
+ editor.on('selectionUpdate', handleUpdate);
53
+ editor.on('update', handleUpdate);
54
+ return () => {
55
+ clearTimeout(timeoutId);
56
+ editor.off('selectionUpdate', handleUpdate);
57
+ editor.off('update', handleUpdate);
58
+ };
59
+ }, [editor, autoCapture, debounceDelay, captureMarkSnapshot]);
60
+ return {
61
+ snapshots,
62
+ currentMarks,
63
+ captureMarkSnapshot,
64
+ applySnapshot,
65
+ getSimilarSnapshots,
66
+ clearSnapshots: () => setSnapshots([]),
67
+ };
68
+ }
@@ -0,0 +1,31 @@
1
+ import { Editor } from '@tiptap/react';
2
+ export interface PersistenceConfig {
3
+ /** Storage key */
4
+ key: string;
5
+ /** Storage type */
6
+ storage?: 'localStorage' | 'sessionStorage' | 'indexedDB';
7
+ /** Auto-save delay */
8
+ autoSaveDelay?: number;
9
+ /** Version for data migration */
10
+ version?: number;
11
+ /** Compression */
12
+ compress?: boolean;
13
+ /** Encryption key */
14
+ encryptionKey?: string;
15
+ }
16
+ export interface PersistentData {
17
+ content: string;
18
+ marks: any[];
19
+ metadata: {
20
+ timestamp: number;
21
+ version: number;
22
+ wordCount: number;
23
+ characterCount: number;
24
+ };
25
+ }
26
+ export declare function usePersistence(editor: Editor | null, config: PersistenceConfig): {
27
+ save: () => Promise<void>;
28
+ load: () => Promise<boolean>;
29
+ saveToStorage: (data: PersistentData) => Promise<void>;
30
+ loadFromStorage: () => Promise<PersistentData | null>;
31
+ };