@antscorp/antsomi-ui 2.0.110 → 2.0.112

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 (344) hide show
  1. package/es/assets/css/main.scss +2 -0
  2. package/es/components/atoms/Eyedropper/Eyedropper.d.ts +2 -0
  3. package/es/components/atoms/Eyedropper/Eyedropper.js +53 -0
  4. package/es/components/atoms/Eyedropper/index.d.ts +0 -0
  5. package/es/components/atoms/Eyedropper/index.js +1 -0
  6. package/es/components/atoms/Eyedropper/styled.d.ts +9 -0
  7. package/es/components/atoms/Eyedropper/styled.js +45 -0
  8. package/es/components/atoms/Eyedropper/types.d.ts +5 -0
  9. package/es/components/atoms/Eyedropper/types.js +1 -0
  10. package/es/components/icons/ALignRightIcon.d.ts +3 -0
  11. package/es/components/icons/ALignRightIcon.js +7 -0
  12. package/es/components/icons/AlignCenterIcon.d.ts +3 -0
  13. package/es/components/icons/AlignCenterIcon.js +7 -0
  14. package/es/components/icons/AlignJustifyIcon.d.ts +3 -0
  15. package/es/components/icons/AlignJustifyIcon.js +7 -0
  16. package/es/components/icons/AlignLeftIcon.d.ts +3 -0
  17. package/es/components/icons/AlignLeftIcon.js +7 -0
  18. package/es/components/icons/ArrowDropDownIcon.d.ts +3 -0
  19. package/es/components/icons/ArrowDropDownIcon.js +7 -0
  20. package/es/components/icons/ChevronRightIcon.d.ts +3 -0
  21. package/es/components/icons/ChevronRightIcon.js +7 -0
  22. package/es/components/icons/ColorizeIcon.d.ts +3 -0
  23. package/es/components/icons/ColorizeIcon.js +7 -0
  24. package/es/components/icons/LazyIcon/LazyIcon.d.ts +9 -0
  25. package/es/components/icons/LazyIcon/LazyIcon.js +9 -0
  26. package/es/components/icons/LinkOffIcon.d.ts +3 -0
  27. package/es/components/icons/LinkOffIcon.js +7 -0
  28. package/es/components/icons/MinusIcon.d.ts +3 -0
  29. package/es/components/icons/MinusIcon.js +7 -0
  30. package/es/components/icons/index.d.ts +9 -0
  31. package/es/components/icons/index.js +9 -0
  32. package/es/components/index.scss +1 -0
  33. package/es/components/molecules/EmojiCollections/CommonCollection/index.js +2 -2
  34. package/es/components/molecules/EmojiCollections/types.d.ts +1 -0
  35. package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +2 -0
  36. package/es/components/molecules/EmojiPopover/EmojiPopover.js +10 -6
  37. package/es/components/molecules/EmojiPopover/styled.js +1 -1
  38. package/es/components/molecules/EyedropperButton/EyedropperButton.d.ts +11 -0
  39. package/es/components/molecules/EyedropperButton/EyedropperButton.js +34 -0
  40. package/es/components/molecules/EyedropperButton/index.d.ts +0 -0
  41. package/es/components/molecules/EyedropperButton/index.js +1 -0
  42. package/es/components/molecules/EyedropperButton/styled.d.ts +7 -0
  43. package/es/components/molecules/EyedropperButton/styled.js +23 -0
  44. package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +3 -0
  45. package/es/components/molecules/FontSizeInput/FontSizeInput.js +134 -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 +21 -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 +39 -0
  56. package/es/components/molecules/FontSizeInput/types.d.ts +23 -0
  57. package/es/components/molecules/FontSizeInput/types.js +1 -0
  58. package/es/components/molecules/FontSizeInput/utils.d.ts +7 -0
  59. package/es/components/molecules/FontSizeInput/utils.js +9 -0
  60. package/es/components/molecules/SearchPopover/SearchPopover.d.ts +2 -1
  61. package/es/components/molecules/SearchPopover/SearchPopover.js +3 -3
  62. package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
  63. package/es/components/molecules/SearchPopover/styled.js +1 -2
  64. package/es/components/molecules/SearchPopover/types.d.ts +4 -3
  65. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
  66. package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +6 -8
  67. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
  68. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +49 -289
  69. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
  70. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
  71. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
  72. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
  73. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
  74. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
  75. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
  76. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
  77. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
  78. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
  79. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
  80. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
  81. package/es/components/molecules/VirtualizedMenu/styled.js +24 -3
  82. package/es/components/molecules/VirtualizedMenu/types.d.ts +2 -0
  83. package/es/components/molecules/VirtualizedMenu/utils.d.ts +2 -0
  84. package/es/components/molecules/VirtualizedMenu/utils.js +2 -0
  85. package/es/components/molecules/index.d.ts +1 -0
  86. package/es/components/molecules/index.js +1 -0
  87. package/es/components/molecules/index.scss +1 -0
  88. package/es/components/organism/TextEditor/TextEditor.d.ts +10 -0
  89. package/es/components/organism/TextEditor/TextEditor.js +403 -0
  90. package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +320 -0
  91. package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +1 -0
  92. package/es/components/organism/TextEditor/__mocks__/text-contennt.js +47 -0
  93. package/es/components/organism/TextEditor/constants.d.ts +196 -0
  94. package/es/components/organism/TextEditor/constants.js +398 -0
  95. package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +25 -0
  96. package/es/components/organism/TextEditor/extensions/BackgroundColor.js +43 -0
  97. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +18 -0
  98. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +81 -0
  99. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +15 -0
  100. package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +35 -0
  101. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +2 -0
  102. package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +2 -0
  103. package/es/components/organism/TextEditor/extensions/ClearFormatting.d.ts +16 -0
  104. package/es/components/organism/TextEditor/extensions/ClearFormatting.js +30 -0
  105. package/es/components/organism/TextEditor/extensions/Color.d.ts +6 -0
  106. package/es/components/organism/TextEditor/extensions/Color.js +34 -0
  107. package/es/components/organism/TextEditor/extensions/Emoji.d.ts +57 -0
  108. package/es/components/organism/TextEditor/extensions/Emoji.js +184 -0
  109. package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +6 -0
  110. package/es/components/organism/TextEditor/extensions/FontFamily.js +36 -0
  111. package/es/components/organism/TextEditor/extensions/FontSize.d.ts +31 -0
  112. package/es/components/organism/TextEditor/extensions/FontSize.js +46 -0
  113. package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +23 -0
  114. package/es/components/organism/TextEditor/extensions/FontWeight.js +41 -0
  115. package/es/components/organism/TextEditor/extensions/Indent.d.ts +21 -0
  116. package/es/components/organism/TextEditor/extensions/Indent.js +63 -0
  117. package/es/components/organism/TextEditor/extensions/LetterSpacing.d.ts +32 -0
  118. package/es/components/organism/TextEditor/extensions/LetterSpacing.js +48 -0
  119. package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +20 -0
  120. package/es/components/organism/TextEditor/extensions/LineHeight.js +101 -0
  121. package/es/components/organism/TextEditor/extensions/Link.d.ts +22 -0
  122. package/es/components/organism/TextEditor/extensions/Link.js +197 -0
  123. package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
  124. package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
  125. package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +13 -0
  126. package/es/components/organism/TextEditor/extensions/ListItemMarker.js +174 -0
  127. package/es/components/organism/TextEditor/extensions/OrderedList.d.ts +56 -0
  128. package/es/components/organism/TextEditor/extensions/OrderedList.js +187 -0
  129. package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +33 -0
  130. package/es/components/organism/TextEditor/extensions/SmartTag.js +194 -0
  131. package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +36 -0
  132. package/es/components/organism/TextEditor/extensions/StyleMemory.js +163 -0
  133. package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +30 -0
  134. package/es/components/organism/TextEditor/extensions/TextTransform.js +36 -0
  135. package/es/components/organism/TextEditor/extensions/UnorderedList.d.ts +55 -0
  136. package/es/components/organism/TextEditor/extensions/UnorderedList.js +176 -0
  137. package/es/components/organism/TextEditor/hooks/index.d.ts +6 -0
  138. package/es/components/organism/TextEditor/hooks/index.js +6 -0
  139. package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +4 -0
  140. package/es/components/organism/TextEditor/hooks/useColorSet.js +29 -0
  141. package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +18 -0
  142. package/es/components/organism/TextEditor/hooks/useDocumentState.js +42 -0
  143. package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +26 -0
  144. package/es/components/organism/TextEditor/hooks/useMarkTracking.js +69 -0
  145. package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +31 -0
  146. package/es/components/organism/TextEditor/hooks/usePersistence.js +169 -0
  147. package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +6 -0
  148. package/es/components/organism/TextEditor/hooks/useStyleMemory.js +42 -0
  149. package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +34 -0
  150. package/es/components/organism/TextEditor/hooks/useStylePresets.js +83 -0
  151. package/es/components/organism/TextEditor/index.d.ts +18 -0
  152. package/es/components/organism/TextEditor/index.js +8 -0
  153. package/es/components/organism/TextEditor/index.scss +65 -0
  154. package/es/components/organism/TextEditor/provider.d.ts +15 -0
  155. package/es/components/organism/TextEditor/provider.js +36 -0
  156. package/es/components/organism/TextEditor/store.d.ts +20 -0
  157. package/es/components/organism/TextEditor/store.js +40 -0
  158. package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
  159. package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
  160. package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
  161. package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
  162. package/es/components/organism/TextEditor/stories/shared.js +57 -0
  163. package/es/components/organism/TextEditor/styled.d.ts +9 -0
  164. package/es/components/organism/TextEditor/styled.js +61 -0
  165. package/es/components/organism/TextEditor/types.d.ts +324 -0
  166. package/es/components/organism/TextEditor/types.js +6 -0
  167. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +3 -0
  168. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +114 -0
  169. package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +1 -0
  170. package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +1 -0
  171. package/es/components/organism/TextEditor/ui/Button/Button.d.ts +9 -0
  172. package/es/components/organism/TextEditor/ui/Button/Button.js +35 -0
  173. package/es/components/organism/TextEditor/ui/Button/index.d.ts +2 -0
  174. package/es/components/organism/TextEditor/ui/Button/index.js +1 -0
  175. package/es/components/organism/TextEditor/ui/Button/types.d.ts +10 -0
  176. package/es/components/organism/TextEditor/ui/Button/types.js +1 -0
  177. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +39 -0
  178. package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +131 -0
  179. package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +1 -0
  180. package/es/components/organism/TextEditor/ui/ColorPicker/index.js +1 -0
  181. package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.d.ts +17 -0
  182. package/es/components/organism/TextEditor/ui/DropdownButton/DropdownButton.js +51 -0
  183. package/es/components/organism/TextEditor/ui/DropdownButton/index.d.ts +1 -0
  184. package/es/components/organism/TextEditor/ui/DropdownButton/index.js +1 -0
  185. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +11 -0
  186. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +66 -0
  187. package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +2 -0
  188. package/es/components/organism/TextEditor/ui/Emoji/index.js +2 -0
  189. package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +4 -0
  190. package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +71 -0
  191. package/es/components/organism/TextEditor/ui/FontPopover/FontItem.d.ts +2 -0
  192. package/es/components/organism/TextEditor/ui/FontPopover/FontItem.js +27 -0
  193. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +16 -0
  194. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +102 -0
  195. package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +2 -0
  196. package/es/components/organism/TextEditor/ui/FontPopover/styled.js +36 -0
  197. package/es/components/organism/TextEditor/ui/FontPopover/types.d.ts +35 -0
  198. package/es/components/organism/TextEditor/ui/FontPopover/types.js +1 -0
  199. package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
  200. package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
  201. package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
  202. package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
  203. package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
  204. package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
  205. package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
  206. package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
  207. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +6 -0
  208. package/es/components/organism/TextEditor/ui/Popover/Popover.js +9 -0
  209. package/es/components/organism/TextEditor/ui/Popover/index.d.ts +1 -0
  210. package/es/components/organism/TextEditor/ui/Popover/index.js +1 -0
  211. package/es/components/organism/TextEditor/ui/Select/Select.d.ts +4 -0
  212. package/es/components/organism/TextEditor/ui/Select/Select.js +7 -0
  213. package/es/components/organism/TextEditor/ui/Select/index.d.ts +1 -0
  214. package/es/components/organism/TextEditor/ui/Select/index.js +1 -0
  215. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.d.ts +2 -0
  216. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/SplitButtonDropdown.js +44 -0
  217. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.d.ts +1 -0
  218. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/index.js +1 -0
  219. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +2 -0
  220. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.js +58 -0
  221. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +19 -0
  222. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.js +1 -0
  223. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +30 -0
  224. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +75 -0
  225. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +1 -0
  226. package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +1 -0
  227. package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.d.ts +19 -0
  228. package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +85 -0
  229. package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
  230. package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
  231. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +6 -0
  232. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +19 -0
  233. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +6 -0
  234. package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +93 -0
  235. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +5 -0
  236. package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +20 -0
  237. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +4 -0
  238. package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +32 -0
  239. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +19 -0
  240. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +41 -0
  241. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +8 -0
  242. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +51 -0
  243. package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.d.ts +5 -0
  244. package/es/components/organism/TextEditor/ui/Toolbar/actions/HistoryAction.js +21 -0
  245. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +5 -0
  246. package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +17 -0
  247. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +5 -0
  248. package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +18 -0
  249. package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.d.ts +5 -0
  250. package/es/components/organism/TextEditor/ui/Toolbar/actions/LetterSpacing.js +28 -0
  251. package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.d.ts +10 -0
  252. package/es/components/organism/TextEditor/ui/Toolbar/actions/LineSpacingAction.js +45 -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/StrikeAction.d.ts +5 -0
  262. package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +18 -0
  263. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +5 -0
  264. package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +26 -0
  265. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +5 -0
  266. package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +26 -0
  267. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +5 -0
  268. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +3 -0
  269. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +5 -0
  270. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +29 -0
  271. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +14 -0
  272. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +22 -0
  273. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +5 -0
  274. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +36 -0
  275. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +5 -0
  276. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +18 -0
  277. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +7 -0
  278. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +18 -0
  279. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +24 -0
  280. package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +24 -0
  281. package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -0
  282. package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -0
  283. package/es/components/organism/TextEditor/utils/documentState.d.ts +73 -0
  284. package/es/components/organism/TextEditor/utils/documentState.js +149 -0
  285. package/es/components/organism/TextEditor/utils/font.d.ts +74 -0
  286. package/es/components/organism/TextEditor/utils/font.js +147 -0
  287. package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +87 -0
  288. package/es/components/organism/TextEditor/utils/htmlProcessing.js +460 -0
  289. package/es/components/organism/TextEditor/utils/indent.d.ts +11 -0
  290. package/es/components/organism/TextEditor/utils/indent.js +56 -0
  291. package/es/components/organism/TextEditor/utils/index.d.ts +8 -0
  292. package/es/components/organism/TextEditor/utils/index.js +16 -0
  293. package/es/components/organism/TextEditor/utils/link.d.ts +116 -0
  294. package/es/components/organism/TextEditor/utils/link.js +304 -0
  295. package/es/components/organism/TextEditor/utils/menu.d.ts +134 -0
  296. package/es/components/organism/TextEditor/utils/menu.js +321 -0
  297. package/es/components/organism/TextEditor/utils/selection.d.ts +25 -0
  298. package/es/components/organism/TextEditor/utils/selection.js +58 -0
  299. package/es/components/organism/TextEditor/utils/shared.d.ts +13 -0
  300. package/es/components/organism/TextEditor/utils/shared.js +52 -0
  301. package/es/components/organism/TextEditor/utils/smartTag.d.ts +49 -0
  302. package/es/components/organism/TextEditor/utils/smartTag.js +90 -0
  303. package/es/components/organism/TextEditor/utils/style.d.ts +78 -0
  304. package/es/components/organism/TextEditor/utils/style.js +193 -0
  305. package/es/components/organism/index.d.ts +1 -0
  306. package/es/components/organism/index.js +1 -0
  307. package/es/components/organism/index.scss +1 -0
  308. package/es/constants/index.d.ts +1 -0
  309. package/es/constants/index.js +1 -0
  310. package/es/constants/web.d.ts +8 -0
  311. package/es/constants/web.js +57 -0
  312. package/es/hooks/index.d.ts +4 -0
  313. package/es/hooks/index.js +4 -0
  314. package/es/hooks/useBroadcastedLocalStorage.d.ts +5 -0
  315. package/es/hooks/useBroadcastedLocalStorage.js +71 -0
  316. package/es/hooks/useElementSize.d.ts +7 -0
  317. package/es/hooks/useElementSize.js +56 -0
  318. package/es/hooks/useEyedropper/attach.d.ts +4 -0
  319. package/es/hooks/useEyedropper/attach.js +9 -0
  320. package/es/hooks/useEyedropper/eyedropper.d.ts +69 -0
  321. package/es/hooks/useEyedropper/eyedropper.js +205 -0
  322. package/es/hooks/useEyedropper/index.d.ts +2 -0
  323. package/es/hooks/useEyedropper/index.js +7 -0
  324. package/es/hooks/useEyedropper/support.d.ts +1 -0
  325. package/es/hooks/useEyedropper/support.js +3 -0
  326. package/es/hooks/useEyedropper/types.d.ts +9 -0
  327. package/es/hooks/useEyedropper/types.js +1 -0
  328. package/es/hooks/useEyedropper/useEyedropper.d.ts +8 -0
  329. package/es/hooks/useEyedropper/useEyedropper.js +50 -0
  330. package/es/hooks/useEyedropper/utils.d.ts +11 -0
  331. package/es/hooks/useEyedropper/utils.js +17 -0
  332. package/es/hooks/useIsMounted.d.ts +1 -0
  333. package/es/hooks/useIsMounted.js +11 -0
  334. package/es/index.d.ts +1 -1
  335. package/es/index.js +1 -1
  336. package/es/locales/i18n.d.ts +1 -1
  337. package/es/types/index.d.ts +9 -0
  338. package/es/utils/common.d.ts +15 -9
  339. package/es/utils/common.js +62 -24
  340. package/es/utils/index.d.ts +1 -0
  341. package/es/utils/index.js +1 -0
  342. package/es/utils/web.d.ts +80 -0
  343. package/es/utils/web.js +226 -0
  344. package/package.json +26 -17
@@ -0,0 +1,187 @@
1
+ import { mergeAttributes, Node, wrappingInputRule } from '@tiptap/core';
2
+ import { ORDERED_LIST_STYLE_TYPE } from '../constants';
3
+ const ListItemName = 'listItem';
4
+ const TextStyleName = 'textStyle';
5
+ /**
6
+ * Input regex patterns for different list styles
7
+ */
8
+ const inputRegexPatterns = {
9
+ decimal: /^(\d+)\.\s$/,
10
+ 'lower-alpha': /^([a-z])\.\s$/,
11
+ 'upper-alpha': /^([A-Z])\.\s$/,
12
+ 'lower-roman': /^(i{1,3}|iv|v|vi{0,3}|ix|x)\.\s$/,
13
+ 'upper-roman': /^(I{1,3}|IV|V|VI{0,3}|IX|X)\.\s$/,
14
+ 'lower-greek': /^(α|β|γ|δ|ε|ζ|η|θ|ι|κ)\.\s$/,
15
+ 'decimal-leading-zero': /^(0\d+)\.\s$/,
16
+ };
17
+ /**
18
+ * Convert roman numerals to numbers
19
+ */
20
+ function romanToNumber(roman) {
21
+ const romanNumerals = {
22
+ i: 1,
23
+ v: 5,
24
+ x: 10,
25
+ };
26
+ let result = 0;
27
+ for (let i = 0; i < roman.length; i++) {
28
+ const current = romanNumerals[roman[i]];
29
+ const next = romanNumerals[roman[i + 1]];
30
+ if (next && current < next) {
31
+ result += next - current;
32
+ i++;
33
+ }
34
+ else {
35
+ result += current;
36
+ }
37
+ }
38
+ return result;
39
+ }
40
+ /**
41
+ * Helper function to convert different formats to numeric start value
42
+ */
43
+ function getStartValue(match, listStyleType) {
44
+ switch (listStyleType) {
45
+ case ORDERED_LIST_STYLE_TYPE.decimal:
46
+ case ORDERED_LIST_STYLE_TYPE.decimalLeadingZero:
47
+ return parseInt(match, 10);
48
+ case ORDERED_LIST_STYLE_TYPE.lowerAlpha:
49
+ return match.toLowerCase().charCodeAt(0) - 'a'.charCodeAt(0) + 1;
50
+ case ORDERED_LIST_STYLE_TYPE.upperAlpha:
51
+ return match.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
52
+ case ORDERED_LIST_STYLE_TYPE.lowerRoman:
53
+ case ORDERED_LIST_STYLE_TYPE.upperRoman:
54
+ return romanToNumber(match.toLowerCase());
55
+ case ORDERED_LIST_STYLE_TYPE.lowerGreek: {
56
+ const greekLetters = 'αβγδεζηθικ';
57
+ return greekLetters.indexOf(match) + 1;
58
+ }
59
+ default:
60
+ return 1;
61
+ }
62
+ }
63
+ /**
64
+ * This extension allows you to create ordered lists with custom list-style-type.
65
+ */
66
+ export const CustomOrderedList = Node.create({
67
+ name: 'customOrderedList',
68
+ addOptions() {
69
+ return {
70
+ itemTypeName: ListItemName,
71
+ HTMLAttributes: {
72
+ style: 'margin:0.5em 0;padding-inline-start:1.2em',
73
+ },
74
+ keepMarks: false,
75
+ keepAttributes: false,
76
+ defaultListStyleType: ORDERED_LIST_STYLE_TYPE.decimal,
77
+ availableListStyleTypes: [
78
+ ORDERED_LIST_STYLE_TYPE.decimal,
79
+ ORDERED_LIST_STYLE_TYPE.lowerAlpha,
80
+ ORDERED_LIST_STYLE_TYPE.upperAlpha,
81
+ ORDERED_LIST_STYLE_TYPE.lowerRoman,
82
+ ORDERED_LIST_STYLE_TYPE.upperRoman,
83
+ ],
84
+ };
85
+ },
86
+ group: 'block list',
87
+ content() {
88
+ return `${this.options.itemTypeName}+`;
89
+ },
90
+ addAttributes() {
91
+ return {
92
+ start: {
93
+ default: 1,
94
+ parseHTML: element => element.hasAttribute('start') ? parseInt(element.getAttribute('start') || '', 10) : 1,
95
+ },
96
+ type: {
97
+ default: null,
98
+ parseHTML: element => element.getAttribute('type'),
99
+ },
100
+ listStyleType: {
101
+ default: this.options.defaultListStyleType,
102
+ parseHTML: element => {
103
+ const style = element.getAttribute('style');
104
+ const listStyleType = style?.match(/list-style-type:\s*([^;]+)/)?.[1]?.trim();
105
+ return listStyleType || this.options.defaultListStyleType;
106
+ },
107
+ renderHTML: attributes => ({
108
+ style: `list-style-type: ${attributes.listStyleType}`,
109
+ }),
110
+ },
111
+ };
112
+ },
113
+ parseHTML() {
114
+ return [
115
+ {
116
+ tag: 'ol',
117
+ },
118
+ ];
119
+ },
120
+ renderHTML({ HTMLAttributes }) {
121
+ const { start, ...attributesWithoutStart } = HTMLAttributes;
122
+ return start === 1
123
+ ? ['ol', mergeAttributes(this.options.HTMLAttributes, attributesWithoutStart), 0]
124
+ : ['ol', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
125
+ },
126
+ addCommands() {
127
+ return {
128
+ toggleCustomOrderedList: (options = {}) => ({ chain }) => {
129
+ const { listStyleType = this.options.defaultListStyleType } = options;
130
+ if (this.options.keepAttributes) {
131
+ return chain()
132
+ .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
133
+ .updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName))
134
+ .updateAttributes(this.name, { listStyleType })
135
+ .run();
136
+ }
137
+ return chain()
138
+ .toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
139
+ .updateAttributes(this.name, { listStyleType })
140
+ .run();
141
+ },
142
+ setOrderedListStyleType: (listStyleType) => ({ commands }) => commands.updateAttributes(this.name, { listStyleType }),
143
+ };
144
+ },
145
+ addKeyboardShortcuts() {
146
+ return {
147
+ 'Mod-Shift-7': () => this.editor.commands.toggleCustomOrderedList(),
148
+ };
149
+ },
150
+ addInputRules() {
151
+ const inputRules = this.options.availableListStyleTypes.map(listStyleType => {
152
+ const regex = inputRegexPatterns[listStyleType];
153
+ let inputRule = wrappingInputRule({
154
+ find: regex,
155
+ type: this.type,
156
+ getAttributes: match => ({
157
+ start: getStartValue(match[1], listStyleType),
158
+ listStyleType,
159
+ }),
160
+ joinPredicate: (match, node) => {
161
+ const startValue = getStartValue(match[1], listStyleType);
162
+ return node.childCount + node.attrs.start === startValue;
163
+ },
164
+ });
165
+ if (this.options.keepMarks || this.options.keepAttributes) {
166
+ inputRule = wrappingInputRule({
167
+ find: regex,
168
+ type: this.type,
169
+ keepMarks: this.options.keepMarks,
170
+ keepAttributes: this.options.keepAttributes,
171
+ getAttributes: match => ({
172
+ start: getStartValue(match[1], listStyleType),
173
+ listStyleType,
174
+ ...this.editor.getAttributes(TextStyleName),
175
+ }),
176
+ joinPredicate: (match, node) => {
177
+ const startValue = getStartValue(match[1], listStyleType);
178
+ return node.childCount + node.attrs.start === startValue;
179
+ },
180
+ editor: this.editor,
181
+ });
182
+ }
183
+ return inputRule;
184
+ });
185
+ return inputRules;
186
+ },
187
+ });
@@ -0,0 +1,33 @@
1
+ import { Node } from '@tiptap/core';
2
+ import { Attrs } from '@tiptap/pm/model';
3
+ /**
4
+ * Represents the options for the SmartTag node.
5
+ */
6
+ export interface SmartTagOptions {
7
+ HTMLAttributes: Record<string, unknown>;
8
+ /**
9
+ * Custom function to generate unique IDs for smart tags
10
+ * If not provided, falls back to uniqid library
11
+ */
12
+ generateSmartTagId?: () => string;
13
+ }
14
+ /**
15
+ * Represents the options for the SmartTag node.
16
+ */
17
+ declare module '@tiptap/core' {
18
+ interface Commands<ReturnType> {
19
+ smartTag: {
20
+ setSmartTag: (attrs: {
21
+ id: string;
22
+ content?: string;
23
+ }) => ReturnType;
24
+ deleteSmartTagGlobally: (predicate: (attrs: Attrs) => boolean) => ReturnType;
25
+ updateSmartTagAttrsGlobally: (updateFn: (attrs: Attrs) => Attrs | undefined) => ReturnType;
26
+ };
27
+ }
28
+ }
29
+ export declare const EXTENSION_NAME = "smartTag";
30
+ /**
31
+ * Represents a dynamic tag node in the editor.
32
+ */
33
+ export declare const SmartTag: Node<SmartTagOptions, any>;
@@ -0,0 +1,194 @@
1
+ import { Node, getMarksBetween, mergeAttributes } from '@tiptap/core';
2
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
3
+ import uniqid from 'uniqid';
4
+ import { isSmartTagNode } from '../types';
5
+ export const EXTENSION_NAME = 'smartTag';
6
+ /**
7
+ * Represents a dynamic tag node in the editor.
8
+ */
9
+ export const SmartTag = Node.create({
10
+ name: EXTENSION_NAME,
11
+ group: 'inline',
12
+ atom: true,
13
+ inline: true,
14
+ selectable: true,
15
+ addOptions() {
16
+ return {
17
+ HTMLAttributes: {},
18
+ generateSmartTagId: () => uniqid(),
19
+ };
20
+ },
21
+ addAttributes() {
22
+ return {
23
+ id: {
24
+ default: '',
25
+ parseHTML: el => el.getAttribute('data-dynamic-id'),
26
+ },
27
+ content: {
28
+ default: '',
29
+ parseHTML: el => el.innerText,
30
+ },
31
+ tag: {
32
+ default: null,
33
+ parseHTML: el => el.getAttribute('tag'),
34
+ renderHTML: attrs => (attrs.tag ? { tag: attrs.tag } : null),
35
+ },
36
+ // Transient attribute - not persisted to HTML, used for tracking paste operations
37
+ sourceId: {
38
+ default: null,
39
+ rendered: false, // Don't include in HTML output
40
+ },
41
+ };
42
+ },
43
+ parseHTML() {
44
+ return [
45
+ {
46
+ tag: 'span[data-dynamic="true"]',
47
+ priority: 1000,
48
+ getAttrs: node => node.getAttribute('data-dynamic') === 'true' && null,
49
+ },
50
+ ];
51
+ },
52
+ renderHTML({ node }) {
53
+ return [
54
+ 'span',
55
+ mergeAttributes(this.options.HTMLAttributes, {
56
+ 'data-dynamic': 'true',
57
+ 'data-dynamic-id': node.attrs.id,
58
+ class: 'smart-tag',
59
+ }),
60
+ node.attrs.content,
61
+ ];
62
+ },
63
+ renderText({ node }) {
64
+ return node.attrs.content;
65
+ },
66
+ addCommands() {
67
+ return {
68
+ setSmartTag: attrs => ({ chain, state }) => {
69
+ const { selection } = state;
70
+ const { from, to } = selection;
71
+ // Get marks from inside the selection to capture boundary marks
72
+ const marks = getMarksBetween(from, to, state.doc).map(markRange => markRange.mark);
73
+ const smartTagNode = this.type.create(attrs);
74
+ const nodeWithMarks = marks.length > 0 ? smartTagNode.mark(marks) : smartTagNode;
75
+ return chain()
76
+ .command(({ tr }) => {
77
+ tr.replaceSelectionWith(nodeWithMarks, false);
78
+ return true;
79
+ })
80
+ .run();
81
+ },
82
+ deleteSmartTagGlobally: predicate => ({ tr, state }) => {
83
+ let hasDeleted = false;
84
+ const { doc } = state;
85
+ doc.descendants((node, pos) => {
86
+ if (node.type.name === this.name && predicate(node.attrs)) {
87
+ tr.delete(pos, pos + node.nodeSize);
88
+ hasDeleted = true;
89
+ }
90
+ });
91
+ return hasDeleted;
92
+ },
93
+ updateSmartTagAttrsGlobally: updateFn => ({ tr, state }) => {
94
+ let hasUpdated = false;
95
+ const { doc } = state;
96
+ doc.descendants((node, pos) => {
97
+ if (node.type.name === this.name) {
98
+ const updatedAttrs = updateFn(node.attrs);
99
+ if (updatedAttrs) {
100
+ tr.setNodeMarkup(pos, undefined, {
101
+ ...node.attrs,
102
+ ...updatedAttrs,
103
+ });
104
+ hasUpdated = true;
105
+ }
106
+ }
107
+ });
108
+ return hasUpdated;
109
+ },
110
+ };
111
+ },
112
+ addProseMirrorPlugins() {
113
+ // Smart Tag Deduplication Plugin
114
+ // Responsibility: Set sourceId for pasted smart tags (for external component to handle cloning)
115
+ const deduplicationPlugin = new Plugin({
116
+ key: new PluginKey('smartTagDeduplication'),
117
+ appendTransaction: (transactions, oldState, newState) => {
118
+ // Only process if there was a paste or document change
119
+ const hasPaste = transactions.some(tr => tr.getMeta('paste'));
120
+ const hasDocChange = transactions.some(tr => tr.docChanged);
121
+ if (!hasPaste && !hasDocChange) {
122
+ return null;
123
+ }
124
+ // Build position mapping from oldState to newState
125
+ // This accounts for position shifts when pasting
126
+ const { mapping } = transactions[0];
127
+ // Build a map of existing smart tag IDs in oldState (before paste)
128
+ const oldStateIds = new Map();
129
+ oldState.doc.descendants((node, pos) => {
130
+ if (isSmartTagNode(node)) {
131
+ oldStateIds.set(node.attrs.id, { pos });
132
+ }
133
+ });
134
+ // Collect all smart tag IDs in newState (after paste)
135
+ const newStateIds = new Map();
136
+ newState.doc.descendants((node, pos) => {
137
+ if (isSmartTagNode(node)) {
138
+ const { id } = node.attrs;
139
+ if (!newStateIds.has(id)) {
140
+ newStateIds.set(id, []);
141
+ }
142
+ newStateIds.get(id).push({ pos, node });
143
+ }
144
+ });
145
+ // Find duplicates: IDs that appear multiple times in newState
146
+ const nodesToSetSourceId = new Map();
147
+ newStateIds.forEach((positions, id) => {
148
+ if (positions.length > 1) {
149
+ // This ID has duplicates
150
+ const oldInfo = oldStateIds.get(id);
151
+ if (oldInfo) {
152
+ // Map old position to new position accounting for document changes
153
+ const mappedPos = mapping.map(oldInfo.pos);
154
+ // Filter out the original node (by mapped position), keep only pasted nodes
155
+ const pastedNodes = positions.filter(({ pos }) => pos !== mappedPos);
156
+ if (pastedNodes.length > 0) {
157
+ nodesToSetSourceId.set(id, pastedNodes);
158
+ }
159
+ }
160
+ else {
161
+ // No original in oldState - all are new (e.g., paste multiple new smart tags)
162
+ // Pick first as "original", rest get sourceId
163
+ const [_first, ...rest] = positions;
164
+ if (rest.length > 0) {
165
+ nodesToSetSourceId.set(id, rest);
166
+ }
167
+ }
168
+ }
169
+ });
170
+ // If no duplicates found, no action needed
171
+ if (nodesToSetSourceId.size === 0) {
172
+ return null;
173
+ }
174
+ // Set sourceId for pasted nodes (do NOT generate new IDs)
175
+ // External component will handle ID generation and attrs cloning
176
+ const { tr } = newState;
177
+ let hasChanges = false;
178
+ nodesToSetSourceId.forEach((positions, sourceId) => {
179
+ positions.forEach(({ pos, node }) => {
180
+ // Only set sourceId, keep original ID
181
+ tr.setNodeMarkup(pos, undefined, {
182
+ ...node.attrs,
183
+ sourceId,
184
+ id: this.options.generateSmartTagId?.() || uniqid(),
185
+ });
186
+ hasChanges = true;
187
+ });
188
+ });
189
+ return hasChanges ? tr : null;
190
+ },
191
+ });
192
+ return [deduplicationPlugin];
193
+ },
194
+ });
@@ -0,0 +1,36 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { Mark } from '@tiptap/pm/model';
3
+ import { DocumentStateConfig } from '../utils/documentState';
4
+ export interface StyleMemoryOptions {
5
+ /**
6
+ * Marks to exclude from being stored
7
+ * @default ['link', 'smartTag']
8
+ */
9
+ excludeMarks: string[];
10
+ /**
11
+ * Configuration for document emptiness detection
12
+ */
13
+ documentStateConfig?: DocumentStateConfig;
14
+ }
15
+ export interface StyleMemoryStorage {
16
+ storedMarks: Mark[];
17
+ }
18
+ declare module '@tiptap/core' {
19
+ interface Commands<ReturnType> {
20
+ styleMemory: {
21
+ /**
22
+ * Manually store current marks
23
+ */
24
+ storeCurrentMarks: () => ReturnType;
25
+ /**
26
+ * Clear stored marks
27
+ */
28
+ clearStoredMarks: () => ReturnType;
29
+ /**
30
+ * Apply stored marks to current selection
31
+ */
32
+ applyStoredMarks: () => ReturnType;
33
+ };
34
+ }
35
+ }
36
+ export declare const StyleMemory: Extension<StyleMemoryOptions, StyleMemoryStorage>;
@@ -0,0 +1,163 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
3
+ import { isDocumentEmpty, DocumentStateTracker } from '../utils/documentState';
4
+ export const StyleMemory = Extension.create({
5
+ name: 'styleMemory',
6
+ addOptions() {
7
+ return {
8
+ excludeMarks: ['link', 'smartTag'],
9
+ documentStateConfig: {
10
+ ignoreWhitespace: true,
11
+ },
12
+ };
13
+ },
14
+ addStorage() {
15
+ return {
16
+ storedMarks: [],
17
+ };
18
+ },
19
+ addCommands() {
20
+ return {
21
+ storeCurrentMarks: () => ({ state }) => {
22
+ const { selection, storedMarks } = state;
23
+ const { $from } = selection;
24
+ // Get marks from current position or stored marks
25
+ const currentMarks = storedMarks || $from.marks();
26
+ // Filter out excluded marks
27
+ const filteredMarks = currentMarks.filter(mark => !this.options.excludeMarks.includes(mark.type.name));
28
+ this.storage.storedMarks = filteredMarks;
29
+ return true;
30
+ },
31
+ clearStoredMarks: () => () => {
32
+ this.storage.storedMarks = [];
33
+ return true;
34
+ },
35
+ applyStoredMarks: () => ({ commands }) => {
36
+ if (this.storage.storedMarks.length === 0) {
37
+ return true;
38
+ }
39
+ // Apply each stored mark
40
+ this.storage.storedMarks.forEach(mark => {
41
+ commands.setMark(mark.type.name, mark.attrs);
42
+ });
43
+ return true;
44
+ },
45
+ };
46
+ },
47
+ addProseMirrorPlugins() {
48
+ const stateTracker = new DocumentStateTracker();
49
+ return [
50
+ new Plugin({
51
+ key: new PluginKey('styleMemory'),
52
+ state: {
53
+ init: (_, initialState) => {
54
+ const isEmpty = isDocumentEmpty(initialState, this.options.documentStateConfig);
55
+ return {
56
+ lastContentSize: initialState.doc.content.size,
57
+ wasEmpty: isEmpty,
58
+ };
59
+ },
60
+ apply: (tr, _oldState, _oldEditorState, newEditorState) => {
61
+ const changes = stateTracker.update(newEditorState);
62
+ const isEmpty = isDocumentEmpty(newEditorState, this.options.documentStateConfig);
63
+ const hasContent = !isEmpty;
64
+ // Store marks when content exists and user has selection with marks
65
+ if (hasContent && tr.selection && !tr.selection.empty) {
66
+ const { $from } = tr.selection;
67
+ const marks = tr.storedMarks || $from.marks();
68
+ if (marks.length > 0) {
69
+ const filteredMarks = marks.filter(mark => !this.options.excludeMarks.includes(mark.type.name));
70
+ if (filteredMarks.length > 0) {
71
+ this.storage.storedMarks = filteredMarks;
72
+ }
73
+ }
74
+ }
75
+ // Also store marks when selection changes and we have marks
76
+ if (hasContent && tr.selectionSet) {
77
+ const { $from } = tr.selection;
78
+ const marks = tr.storedMarks || $from.marks();
79
+ if (marks.length > 0) {
80
+ const filteredMarks = marks.filter(mark => !this.options.excludeMarks.includes(mark.type.name));
81
+ if (filteredMarks.length > 0) {
82
+ this.storage.storedMarks = filteredMarks;
83
+ }
84
+ }
85
+ }
86
+ // Apply stored marks when transitioning from empty to non-empty
87
+ if (changes.becameNonEmpty && this.storage.storedMarks.length > 0) {
88
+ // Set stored marks for the next input
89
+ tr.setStoredMarks(this.storage.storedMarks);
90
+ }
91
+ return {
92
+ lastContentSize: newEditorState.doc.content.size,
93
+ wasEmpty: isEmpty,
94
+ };
95
+ },
96
+ },
97
+ appendTransaction: (transactions, oldState, newState) => {
98
+ const wasEmpty = isDocumentEmpty(oldState, this.options.documentStateConfig);
99
+ const hasContent = !isDocumentEmpty(newState, this.options.documentStateConfig);
100
+ // Check if we need to restore marks after content was added to empty editor
101
+ if (wasEmpty && hasContent && this.storage.storedMarks.length > 0) {
102
+ const { tr } = newState;
103
+ let hasChanges = false;
104
+ // Find the newly added content
105
+ let newContentStart = -1;
106
+ let newContentEnd = -1;
107
+ for (const transaction of transactions) {
108
+ if (transaction.docChanged) {
109
+ transaction.steps.forEach(step => {
110
+ if ('from' in step &&
111
+ 'to' in step &&
112
+ typeof step.from === 'number' &&
113
+ typeof step.to === 'number') {
114
+ if (newContentStart === -1 || step.from < newContentStart) {
115
+ newContentStart = step.from;
116
+ }
117
+ if (newContentEnd === -1 || step.to > newContentEnd) {
118
+ newContentEnd = step.to;
119
+ }
120
+ }
121
+ });
122
+ }
123
+ }
124
+ // Apply stored marks to the new content if we found the range
125
+ if (newContentStart !== -1 && newContentEnd !== -1) {
126
+ this.storage.storedMarks.forEach(mark => {
127
+ tr.addMark(newContentStart, newContentEnd, mark);
128
+ hasChanges = true;
129
+ });
130
+ }
131
+ // Also set stored marks for future typing
132
+ if (this.storage.storedMarks.length > 0) {
133
+ tr.setStoredMarks(this.storage.storedMarks);
134
+ hasChanges = true;
135
+ }
136
+ if (hasChanges) {
137
+ return tr;
138
+ }
139
+ }
140
+ return null;
141
+ },
142
+ // Handle view updates for better mark application
143
+ view: () => ({
144
+ update: (view, prevState) => {
145
+ const prevEmpty = isDocumentEmpty(prevState, this.options.documentStateConfig);
146
+ const currentEmpty = isDocumentEmpty(view.state, this.options.documentStateConfig);
147
+ // When transitioning from empty to non-empty, ensure stored marks are applied
148
+ if (prevEmpty && !currentEmpty && this.storage.storedMarks.length > 0) {
149
+ // Use setTimeout to ensure this runs after the current transaction
150
+ setTimeout(() => {
151
+ const { state, dispatch } = view;
152
+ const { tr } = state;
153
+ // Set stored marks for the current position
154
+ tr.setStoredMarks(this.storage.storedMarks);
155
+ dispatch(tr);
156
+ }, 0);
157
+ }
158
+ },
159
+ }),
160
+ }),
161
+ ];
162
+ },
163
+ });
@@ -0,0 +1,30 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export type TextTransformOptions = {
3
+ /**
4
+ * A list of node names where the text transform can be applied.
5
+ * @default ['textStyle']
6
+ * @example ['heading', 'paragraph']
7
+ */
8
+ types: string[];
9
+ };
10
+ declare module '@tiptap/core' {
11
+ interface Commands<ReturnType> {
12
+ textTransform: {
13
+ /**
14
+ * Set the text transform
15
+ * @param textTransform The text transform
16
+ * @example editor.commands.setTextTransform('uppercase')
17
+ */
18
+ setTextTransform: (textTransform: string | null) => ReturnType;
19
+ /**
20
+ * Unset the text transform
21
+ * @example editor.commands.unsetTextTransform()
22
+ */
23
+ unsetTextTransform: () => ReturnType;
24
+ };
25
+ }
26
+ }
27
+ /**
28
+ * This extension allows you to set a text transform for text.
29
+ */
30
+ export declare const TextTransform: Extension<TextTransformOptions, any>;
@@ -0,0 +1,36 @@
1
+ import { Extension } from '@tiptap/core';
2
+ /**
3
+ * This extension allows you to set a text transform for text.
4
+ */
5
+ export const TextTransform = Extension.create({
6
+ name: 'textTransform',
7
+ addOptions() {
8
+ return {
9
+ types: ['textStyle'],
10
+ };
11
+ },
12
+ addGlobalAttributes() {
13
+ return [
14
+ {
15
+ types: this.options.types,
16
+ attributes: {
17
+ textTransform: {
18
+ default: null,
19
+ renderHTML: attrs => attrs.textTransform
20
+ ? {
21
+ style: `text-transform: ${attrs.textTransform}`,
22
+ }
23
+ : {},
24
+ parseHTML: element => element.style.textTransform,
25
+ },
26
+ },
27
+ },
28
+ ];
29
+ },
30
+ addCommands() {
31
+ return {
32
+ setTextTransform: textTransform => ({ chain }) => chain().setMark('textStyle', { textTransform }).run(),
33
+ unsetTextTransform: () => ({ chain }) => chain().setMark('textStyle', { textTransform: 'none' }).removeEmptyTextStyle().run(),
34
+ };
35
+ },
36
+ });