@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,100 @@
1
+ import { EditorState } from '@tiptap/pm/state';
2
+ import { MarkRange } from '@tiptap/core';
3
+ import { EditorView } from '@tiptap/pm/view';
4
+ import { LinkHandler } from '../types';
5
+ /**
6
+ * Kiểm tra xem cursor có đang nằm trong một đoạn text có mark là link hay không
7
+ * @param state EditorState của Tiptap/ProseMirror
8
+ * @returns true nếu cursor đang nằm trong link, false nếu không
9
+ */
10
+ export declare const isCursorInLink: (state: EditorState) => boolean;
11
+ /**
12
+ * Gets all link mark ranges within a specified range
13
+ * @param params Object containing state, from and to positions
14
+ * @returns Array of MarkRange objects for links
15
+ */
16
+ export declare const getLinkMarkRanges: (params: {
17
+ state: EditorState;
18
+ from: number;
19
+ to: number;
20
+ }) => MarkRange[];
21
+ /**
22
+ * Gets the range of a link mark at a specific position
23
+ * @param params Object containing state and optional position
24
+ * @returns Link mark range or undefined
25
+ */
26
+ export declare const getLinkRange: (params: {
27
+ state: EditorState;
28
+ pos?: number;
29
+ }) => void | import("@tiptap/core").Range;
30
+ /**
31
+ * Gets the first link mark in a range
32
+ * @param params Object containing state, optional from and to positions
33
+ * @returns Link mark or undefined
34
+ */
35
+ export declare const getLinkMark: (params: {
36
+ state: EditorState;
37
+ from?: number;
38
+ to?: number;
39
+ }) => import("prosemirror-model").Mark | undefined;
40
+ /**
41
+ * Gets all link marks in a range
42
+ * @param params Object containing state, from and to positions
43
+ * @returns Array of link marks
44
+ */
45
+ export declare const getLinkMarks: (params: {
46
+ state: EditorState;
47
+ from: number;
48
+ to: number;
49
+ }) => import("prosemirror-model").Mark[];
50
+ /**
51
+ * Gets all link IDs from a range
52
+ * @param params Object containing state, optional from and to positions
53
+ * @returns Array of link IDs
54
+ */
55
+ export declare const getLinkIdsFromRange: (params: {
56
+ state: EditorState;
57
+ from?: number;
58
+ to?: number;
59
+ }) => string[];
60
+ /**
61
+ * Gets the active link ID and inactive links from a range
62
+ * @param params Object containing state, optional from and to positions
63
+ * @returns Object with activeId and inactiveLinks or undefined
64
+ */
65
+ export declare const getActiveLinkIdFromRange: (params: {
66
+ state: EditorState;
67
+ from?: number;
68
+ to?: number;
69
+ }) => {
70
+ activeId: string;
71
+ inactiveLinks: string[];
72
+ } | undefined;
73
+ /**
74
+ * Extends selection to include full link marks
75
+ * @param state EditorState
76
+ * @param from Start position
77
+ * @param to End position
78
+ * @returns Object with extended from, to positions and linkId
79
+ */
80
+ export declare const extendSelectionToFullLinks: (state: EditorState, from: number, to: number) => {
81
+ from: number;
82
+ to: number;
83
+ linkId?: undefined;
84
+ } | {
85
+ from: number;
86
+ to: number;
87
+ linkId: string;
88
+ };
89
+ /**
90
+ * Handles link actions (create or edit)
91
+ * @param view EditorView instance
92
+ * @param linkHandler Link handler callbacks
93
+ */
94
+ export declare function handleLinkAction(view: EditorView, linkHandler: LinkHandler | undefined): void;
95
+ /**
96
+ * Checks if the link menu should be shown
97
+ * @param state EditorState
98
+ * @returns true if link menu should be shown
99
+ */
100
+ export declare const isShowLinkMenu: (state: EditorState) => boolean;
@@ -0,0 +1,149 @@
1
+ import { TextSelection } from '@tiptap/pm/state';
2
+ import { getMarkRange, getMarksBetween, isMarkActive } from '@tiptap/core';
3
+ import { isNoSelection } from './selection';
4
+ /**
5
+ * Kiểm tra xem cursor có đang nằm trong một đoạn text có mark là link hay không
6
+ * @param state EditorState của Tiptap/ProseMirror
7
+ * @returns true nếu cursor đang nằm trong link, false nếu không
8
+ */
9
+ export const isCursorInLink = (state) => isMarkActive(state, 'link');
10
+ /**
11
+ * Gets all link mark ranges within a specified range
12
+ * @param params Object containing state, from and to positions
13
+ * @returns Array of MarkRange objects for links
14
+ */
15
+ export const getLinkMarkRanges = (params) => {
16
+ const { state } = params;
17
+ const from = params.from ?? state.selection.from;
18
+ const to = params.to ?? state.selection.to;
19
+ return getMarksBetween(from, to, state.doc).filter(({ mark }) => mark.type.name === 'link');
20
+ };
21
+ /**
22
+ * Gets the range of a link mark at a specific position
23
+ * @param params Object containing state and optional position
24
+ * @returns Link mark range or undefined
25
+ */
26
+ export const getLinkRange = (params) => {
27
+ const { state } = params;
28
+ const { schema } = state;
29
+ const $pos = state.doc.resolve(params?.pos || state.selection.from);
30
+ return getMarkRange($pos, schema.marks.link);
31
+ };
32
+ /**
33
+ * Gets the first link mark in a range
34
+ * @param params Object containing state, optional from and to positions
35
+ * @returns Link mark or undefined
36
+ */
37
+ export const getLinkMark = (params) => {
38
+ const { state } = params;
39
+ const from = params.from ?? state.selection.from;
40
+ const to = params.to ?? state.selection.to;
41
+ return getLinkMarkRanges({ state, from, to }).at(0)?.mark;
42
+ };
43
+ /**
44
+ * Gets all link marks in a range
45
+ * @param params Object containing state, from and to positions
46
+ * @returns Array of link marks
47
+ */
48
+ export const getLinkMarks = (params) => {
49
+ const { state, from, to } = params;
50
+ return getMarksBetween(from, to, state.doc)
51
+ .filter(({ mark }) => mark.type.name === 'link')
52
+ .map(range => range.mark);
53
+ };
54
+ /**
55
+ * Gets all link IDs from a range
56
+ * @param params Object containing state, optional from and to positions
57
+ * @returns Array of link IDs
58
+ */
59
+ export const getLinkIdsFromRange = (params) => {
60
+ const { state } = params;
61
+ const from = params.from ?? state.selection.from;
62
+ const to = params.to ?? state.selection.to;
63
+ return getLinkMarkRanges({ state, from, to })
64
+ .map(r => r.mark.attrs.id)
65
+ .filter((id) => typeof id === 'string');
66
+ };
67
+ /**
68
+ * Gets the active link ID and inactive links from a range
69
+ * @param params Object containing state, optional from and to positions
70
+ * @returns Object with activeId and inactiveLinks or undefined
71
+ */
72
+ export const getActiveLinkIdFromRange = (params) => {
73
+ const { state } = params;
74
+ const from = params.from ?? state.selection.from;
75
+ const to = params.to ?? state.selection.to;
76
+ const linkIds = getLinkIdsFromRange({ state, from, to });
77
+ if (linkIds.length === 0)
78
+ return undefined;
79
+ const activeId = linkIds[0];
80
+ return {
81
+ activeId,
82
+ inactiveLinks: linkIds.filter(id => id !== activeId),
83
+ };
84
+ };
85
+ /**
86
+ * Extends selection to include full link marks
87
+ * @param state EditorState
88
+ * @param from Start position
89
+ * @param to End position
90
+ * @returns Object with extended from, to positions and linkId
91
+ */
92
+ export const extendSelectionToFullLinks = (state, from, to) => {
93
+ const { activeId } = getActiveLinkIdFromRange({ state, from, to }) || {};
94
+ const linkMarkRanges = getLinkMarkRanges({ state, from, to });
95
+ if (linkMarkRanges.length === 0 || !activeId)
96
+ return { from, to };
97
+ // Tính toán range mới
98
+ const newFrom = Math.min(...linkMarkRanges.map(range => range.from), from);
99
+ const newTo = Math.max(...linkMarkRanges.map(range => range.to), to);
100
+ return {
101
+ from: newFrom,
102
+ to: newTo,
103
+ linkId: activeId,
104
+ };
105
+ };
106
+ /**
107
+ * Handles link actions (create or edit)
108
+ * @param view EditorView instance
109
+ * @param linkHandler Link handler callbacks
110
+ */
111
+ export function handleLinkAction(view, linkHandler) {
112
+ const { state } = view;
113
+ const { tr } = state;
114
+ const { from, to, empty } = state.selection;
115
+ if (empty && isMarkActive(state, 'link')) {
116
+ const linkRange = getLinkRange({ state, pos: from });
117
+ const linkMark = getLinkMark({ state });
118
+ if (linkRange && linkMark) {
119
+ // Update selection to include full link
120
+ view.dispatch(tr.setSelection(TextSelection.create(tr.doc, linkRange.from, linkRange.to)));
121
+ linkHandler?.edit?.({
122
+ id: linkMark.attrs.id,
123
+ selectionText: state.doc.textBetween(linkRange.from, linkRange.to),
124
+ });
125
+ return;
126
+ }
127
+ }
128
+ const { from: newFrom, to: newTo, linkId } = extendSelectionToFullLinks(state, from, to);
129
+ // Update selection to include full links
130
+ view.dispatch(tr.setSelection(TextSelection.create(tr.doc, newFrom, newTo)));
131
+ const selectedText = state.doc.textBetween(newFrom, newTo);
132
+ if (linkId) {
133
+ linkHandler?.edit?.({
134
+ id: linkId,
135
+ selectionText: selectedText,
136
+ });
137
+ }
138
+ else {
139
+ linkHandler?.setNew?.({
140
+ selectionText: selectedText,
141
+ });
142
+ }
143
+ }
144
+ /**
145
+ * Checks if the link menu should be shown
146
+ * @param state EditorState
147
+ * @returns true if link menu should be shown
148
+ */
149
+ export const isShowLinkMenu = (state) => isNoSelection(state) && isCursorInLink(state);
@@ -0,0 +1,134 @@
1
+ import { EditorState } from '@tiptap/pm/state';
2
+ import { Editor } from '@tiptap/core';
3
+ import { EditorView } from '@tiptap/pm/view';
4
+ /**
5
+ * Default function to determine if bubble menu should be shown
6
+ * @param params Object containing editor state and view information
7
+ * @returns true if bubble menu should be shown
8
+ */
9
+ export declare const defaultShouldShowBubbleMenu: (params: {
10
+ state: EditorState;
11
+ view: EditorView;
12
+ element: HTMLElement;
13
+ editor: Editor;
14
+ }) => boolean;
15
+ /**
16
+ * Checks if link menu should be shown
17
+ * @param state EditorState
18
+ * @returns true if link menu should be shown
19
+ */
20
+ export declare const shouldShowLinkMenu: (state: EditorState) => boolean;
21
+ /**
22
+ * Calculates optimal menu position relative to selection
23
+ * @param view EditorView instance
24
+ * @param menuElement Menu element to position
25
+ * @returns Position coordinates
26
+ */
27
+ export declare function calculateMenuPosition(view: EditorView, menuElement: HTMLElement): {
28
+ top: number;
29
+ left: number;
30
+ };
31
+ /**
32
+ * Checks if menu should be hidden based on editor state
33
+ * @param editor Editor instance
34
+ * @returns true if menu should be hidden
35
+ */
36
+ export declare function shouldHideMenu(editor: Editor): boolean;
37
+ /**
38
+ * Gets the active menu type based on current selection
39
+ * @param state EditorState
40
+ * @returns Menu type identifier
41
+ */
42
+ export declare function getActiveMenuType(state: EditorState): 'default' | 'link' | 'smartTag' | null;
43
+ /**
44
+ * Menu visibility manager class
45
+ */
46
+ export declare class MenuVisibilityManager {
47
+ private visibleMenus;
48
+ private callbacks;
49
+ /**
50
+ * Shows a menu with given ID
51
+ * @param menuId Menu identifier
52
+ * @param onShow Optional callback when menu is shown
53
+ */
54
+ showMenu(menuId: string, onShow?: () => void): void;
55
+ /**
56
+ * Hides a specific menu
57
+ * @param menuId Menu identifier
58
+ */
59
+ hideMenu(menuId: string): void;
60
+ /**
61
+ * Hides all visible menus
62
+ */
63
+ hideAllMenus(): void;
64
+ /**
65
+ * Checks if a menu is visible
66
+ * @param menuId Menu identifier
67
+ * @returns true if menu is visible
68
+ */
69
+ isMenuVisible(menuId: string): boolean;
70
+ /**
71
+ * Gets all visible menu IDs
72
+ * @returns Array of visible menu IDs
73
+ */
74
+ getVisibleMenus(): string[];
75
+ }
76
+ /**
77
+ * Menu positioning utilities
78
+ */
79
+ export declare class MenuPositioner {
80
+ private container;
81
+ constructor(container?: HTMLElement);
82
+ /**
83
+ * Positions menu relative to a DOM element
84
+ * @param menuElement Menu element to position
85
+ * @param targetElement Target element to position relative to
86
+ * @param placement Placement preference
87
+ */
88
+ positionRelativeToElement(menuElement: HTMLElement, targetElement: HTMLElement, placement?: 'top' | 'bottom' | 'left' | 'right'): void;
89
+ /**
90
+ * Positions menu at specific coordinates
91
+ * @param menuElement Menu element to position
92
+ * @param x X coordinate
93
+ * @param y Y coordinate
94
+ */
95
+ positionAtCoordinates(menuElement: HTMLElement, x: number, y: number): void;
96
+ }
97
+ /**
98
+ * Menu keyboard navigation handler
99
+ */
100
+ export declare class MenuKeyboardHandler {
101
+ private menuElement;
102
+ private focusableElements;
103
+ private currentIndex;
104
+ constructor(menuElement: HTMLElement);
105
+ /**
106
+ * Updates the list of focusable elements
107
+ */
108
+ updateFocusableElements(): void;
109
+ /**
110
+ * Handles keyboard events for menu navigation
111
+ * @param event Keyboard event
112
+ */
113
+ handleKeyDown(event: KeyboardEvent): boolean;
114
+ /**
115
+ * Focuses the next focusable element
116
+ */
117
+ focusNext(): void;
118
+ /**
119
+ * Focuses the previous focusable element
120
+ */
121
+ focusPrevious(): void;
122
+ /**
123
+ * Focuses the first focusable element
124
+ */
125
+ focusFirst(): void;
126
+ /**
127
+ * Focuses the last focusable element
128
+ */
129
+ focusLast(): void;
130
+ /**
131
+ * Removes focus from menu
132
+ */
133
+ blur(): void;
134
+ }
@@ -0,0 +1,317 @@
1
+ import { isTextSelection } from '@tiptap/core';
2
+ import { isNoSelection } from './selection';
3
+ import { isCursorInLink } from './link';
4
+ /**
5
+ * Default function to determine if bubble menu should be shown
6
+ * @param params Object containing editor state and view information
7
+ * @returns true if bubble menu should be shown
8
+ */
9
+ export const defaultShouldShowBubbleMenu = (params) => {
10
+ const { element, editor, state, view } = params;
11
+ const shouldShow = () => {
12
+ const { doc, selection } = state;
13
+ const { empty, ranges } = selection;
14
+ const from = Math.min(...ranges.map(range => range.$from.pos));
15
+ const to = Math.max(...ranges.map(range => range.$to.pos));
16
+ // Sometime check for `empty` is not enough.
17
+ // Doubleclick an empty paragraph returns a node size of 2.
18
+ // So we check also for an empty text size.
19
+ const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
20
+ // When clicking on a element inside the bubble menu the editor "blur" event
21
+ // is called and the bubble menu item is focussed. In this case we should
22
+ // consider the menu as part of the editor and keep showing the menu
23
+ const isChildOfMenu = element.contains(document.activeElement);
24
+ const hasEditorFocus = view.hasFocus() || isChildOfMenu;
25
+ if (!hasEditorFocus || empty || isEmptyTextBlock || !editor.isEditable) {
26
+ return false;
27
+ }
28
+ return true;
29
+ };
30
+ const show = shouldShow();
31
+ return show;
32
+ };
33
+ /**
34
+ * Checks if link menu should be shown
35
+ * @param state EditorState
36
+ * @returns true if link menu should be shown
37
+ */
38
+ export const shouldShowLinkMenu = (state) => isNoSelection(state) && isCursorInLink(state);
39
+ /**
40
+ * Calculates optimal menu position relative to selection
41
+ * @param view EditorView instance
42
+ * @param menuElement Menu element to position
43
+ * @returns Position coordinates
44
+ */
45
+ export function calculateMenuPosition(view, menuElement) {
46
+ const { selection } = view.state;
47
+ const { from, to } = selection;
48
+ // Get DOM coordinates of selection
49
+ const start = view.coordsAtPos(from);
50
+ const end = view.coordsAtPos(to);
51
+ // Calculate menu dimensions
52
+ const menuRect = menuElement.getBoundingClientRect();
53
+ const viewportWidth = window.innerWidth;
54
+ // const viewportHeight = window.innerHeight;
55
+ // Calculate optimal position
56
+ let top = start.top - menuRect.height - 10; // 10px gap above selection
57
+ let left = (start.left + end.left) / 2 - menuRect.width / 2; // Center horizontally
58
+ // Adjust if menu would go off-screen
59
+ if (top < 0) {
60
+ top = end.bottom + 10; // Show below if no space above
61
+ }
62
+ if (left < 0) {
63
+ left = 10; // 10px from left edge
64
+ }
65
+ else if (left + menuRect.width > viewportWidth) {
66
+ left = viewportWidth - menuRect.width - 10; // 10px from right edge
67
+ }
68
+ return { top, left };
69
+ }
70
+ /**
71
+ * Checks if menu should be hidden based on editor state
72
+ * @param editor Editor instance
73
+ * @returns true if menu should be hidden
74
+ */
75
+ export function shouldHideMenu(editor) {
76
+ if (!editor.isEditable)
77
+ return true;
78
+ if (!editor.isFocused)
79
+ return true;
80
+ const { selection } = editor.state;
81
+ if (selection.empty)
82
+ return true;
83
+ return false;
84
+ }
85
+ /**
86
+ * Gets the active menu type based on current selection
87
+ * @param state EditorState
88
+ * @returns Menu type identifier
89
+ */
90
+ export function getActiveMenuType(state) {
91
+ if (shouldShowLinkMenu(state)) {
92
+ return 'link';
93
+ }
94
+ const { selection } = state;
95
+ if (selection.empty)
96
+ return null;
97
+ // Check if smart tag is selected
98
+ const node = state.doc.nodeAt(selection.from);
99
+ if (node && node.type.name === 'smartTag') {
100
+ return 'smartTag';
101
+ }
102
+ return 'default';
103
+ }
104
+ /**
105
+ * Menu visibility manager class
106
+ */
107
+ export class MenuVisibilityManager {
108
+ constructor() {
109
+ this.visibleMenus = new Set();
110
+ this.callbacks = new Map();
111
+ }
112
+ /**
113
+ * Shows a menu with given ID
114
+ * @param menuId Menu identifier
115
+ * @param onShow Optional callback when menu is shown
116
+ */
117
+ showMenu(menuId, onShow) {
118
+ this.hideAllMenus();
119
+ this.visibleMenus.add(menuId);
120
+ if (onShow) {
121
+ this.callbacks.set(menuId, onShow);
122
+ onShow();
123
+ }
124
+ }
125
+ /**
126
+ * Hides a specific menu
127
+ * @param menuId Menu identifier
128
+ */
129
+ hideMenu(menuId) {
130
+ this.visibleMenus.delete(menuId);
131
+ this.callbacks.delete(menuId);
132
+ }
133
+ /**
134
+ * Hides all visible menus
135
+ */
136
+ hideAllMenus() {
137
+ this.visibleMenus.clear();
138
+ this.callbacks.clear();
139
+ }
140
+ /**
141
+ * Checks if a menu is visible
142
+ * @param menuId Menu identifier
143
+ * @returns true if menu is visible
144
+ */
145
+ isMenuVisible(menuId) {
146
+ return this.visibleMenus.has(menuId);
147
+ }
148
+ /**
149
+ * Gets all visible menu IDs
150
+ * @returns Array of visible menu IDs
151
+ */
152
+ getVisibleMenus() {
153
+ return Array.from(this.visibleMenus);
154
+ }
155
+ }
156
+ /**
157
+ * Menu positioning utilities
158
+ */
159
+ export class MenuPositioner {
160
+ constructor(container = document.body) {
161
+ this.container = container;
162
+ }
163
+ /**
164
+ * Positions menu relative to a DOM element
165
+ * @param menuElement Menu element to position
166
+ * @param targetElement Target element to position relative to
167
+ * @param placement Placement preference
168
+ */
169
+ positionRelativeToElement(menuElement, targetElement, placement = 'top') {
170
+ const targetRect = targetElement.getBoundingClientRect();
171
+ const menuRect = menuElement.getBoundingClientRect();
172
+ const containerRect = this.container.getBoundingClientRect();
173
+ let top = 0;
174
+ let left = 0;
175
+ switch (placement) {
176
+ case 'top':
177
+ top = targetRect.top - menuRect.height - 5;
178
+ left = targetRect.left + (targetRect.width - menuRect.width) / 2;
179
+ break;
180
+ case 'bottom':
181
+ top = targetRect.bottom + 5;
182
+ left = targetRect.left + (targetRect.width - menuRect.width) / 2;
183
+ break;
184
+ case 'left':
185
+ top = targetRect.top + (targetRect.height - menuRect.height) / 2;
186
+ left = targetRect.left - menuRect.width - 5;
187
+ break;
188
+ case 'right':
189
+ top = targetRect.top + (targetRect.height - menuRect.height) / 2;
190
+ left = targetRect.right + 5;
191
+ break;
192
+ default:
193
+ // Default to 'top' placement
194
+ top = targetRect.top - menuRect.height - 5;
195
+ left = targetRect.left + (targetRect.width - menuRect.width) / 2;
196
+ break;
197
+ }
198
+ // Adjust for container offset
199
+ top -= containerRect.top;
200
+ left -= containerRect.left;
201
+ // Ensure menu stays within container bounds
202
+ top = Math.max(0, Math.min(top, containerRect.height - menuRect.height));
203
+ left = Math.max(0, Math.min(left, containerRect.width - menuRect.width));
204
+ menuElement.style.position = 'absolute';
205
+ menuElement.style.top = `${top}px`;
206
+ menuElement.style.left = `${left}px`;
207
+ }
208
+ /**
209
+ * Positions menu at specific coordinates
210
+ * @param menuElement Menu element to position
211
+ * @param x X coordinate
212
+ * @param y Y coordinate
213
+ */
214
+ positionAtCoordinates(menuElement, x, y) {
215
+ const containerRect = this.container.getBoundingClientRect();
216
+ // Adjust coordinates relative to container
217
+ const relativeX = x - containerRect.left;
218
+ const relativeY = y - containerRect.top;
219
+ menuElement.style.position = 'absolute';
220
+ menuElement.style.left = `${relativeX}px`;
221
+ menuElement.style.top = `${relativeY}px`;
222
+ }
223
+ }
224
+ /**
225
+ * Menu keyboard navigation handler
226
+ */
227
+ export class MenuKeyboardHandler {
228
+ constructor(menuElement) {
229
+ this.focusableElements = [];
230
+ this.currentIndex = -1;
231
+ this.menuElement = menuElement;
232
+ this.updateFocusableElements();
233
+ }
234
+ /**
235
+ * Updates the list of focusable elements
236
+ */
237
+ updateFocusableElements() {
238
+ const focusableSelector = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
239
+ this.focusableElements = Array.from(this.menuElement.querySelectorAll(focusableSelector));
240
+ }
241
+ /**
242
+ * Handles keyboard events for menu navigation
243
+ * @param event Keyboard event
244
+ */
245
+ handleKeyDown(event) {
246
+ switch (event.key) {
247
+ case 'ArrowDown':
248
+ event.preventDefault();
249
+ this.focusNext();
250
+ return true;
251
+ case 'ArrowUp':
252
+ event.preventDefault();
253
+ this.focusPrevious();
254
+ return true;
255
+ case 'Home':
256
+ event.preventDefault();
257
+ this.focusFirst();
258
+ return true;
259
+ case 'End':
260
+ event.preventDefault();
261
+ this.focusLast();
262
+ return true;
263
+ case 'Escape':
264
+ event.preventDefault();
265
+ this.blur();
266
+ return true;
267
+ default:
268
+ return false;
269
+ }
270
+ }
271
+ /**
272
+ * Focuses the next focusable element
273
+ */
274
+ focusNext() {
275
+ if (this.focusableElements.length === 0)
276
+ return;
277
+ this.currentIndex = (this.currentIndex + 1) % this.focusableElements.length;
278
+ this.focusableElements[this.currentIndex].focus();
279
+ }
280
+ /**
281
+ * Focuses the previous focusable element
282
+ */
283
+ focusPrevious() {
284
+ if (this.focusableElements.length === 0)
285
+ return;
286
+ this.currentIndex =
287
+ this.currentIndex <= 0 ? this.focusableElements.length - 1 : this.currentIndex - 1;
288
+ this.focusableElements[this.currentIndex].focus();
289
+ }
290
+ /**
291
+ * Focuses the first focusable element
292
+ */
293
+ focusFirst() {
294
+ if (this.focusableElements.length === 0)
295
+ return;
296
+ this.currentIndex = 0;
297
+ this.focusableElements[this.currentIndex].focus();
298
+ }
299
+ /**
300
+ * Focuses the last focusable element
301
+ */
302
+ focusLast() {
303
+ if (this.focusableElements.length === 0)
304
+ return;
305
+ this.currentIndex = this.focusableElements.length - 1;
306
+ this.focusableElements[this.currentIndex].focus();
307
+ }
308
+ /**
309
+ * Removes focus from menu
310
+ */
311
+ blur() {
312
+ this.currentIndex = -1;
313
+ if (document.activeElement instanceof HTMLElement) {
314
+ document.activeElement.blur();
315
+ }
316
+ }
317
+ }