@forgedevstack/ink 1.1.3 → 1.1.5

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 (316) hide show
  1. package/CHANGELOG.md +64 -1
  2. package/dist/common-components/Box/Box.cjs +1 -0
  3. package/dist/common-components/Box/Box.const.cjs +1 -0
  4. package/dist/common-components/Box/Box.const.d.ts +3 -0
  5. package/dist/common-components/Box/Box.const.d.ts.map +1 -0
  6. package/dist/common-components/Box/Box.const.js +5 -0
  7. package/dist/common-components/Box/Box.d.ts +4 -0
  8. package/dist/common-components/Box/Box.d.ts.map +1 -0
  9. package/dist/common-components/Box/Box.js +14 -0
  10. package/dist/common-components/Box/Box.types.d.ts +6 -0
  11. package/dist/common-components/Box/Box.types.d.ts.map +1 -0
  12. package/dist/common-components/Box/index.d.ts +3 -0
  13. package/dist/common-components/Box/index.d.ts.map +1 -0
  14. package/dist/common-components/Button/Button.cjs +1 -0
  15. package/dist/common-components/Button/Button.const.cjs +1 -0
  16. package/dist/common-components/Button/Button.const.d.ts +5 -0
  17. package/dist/common-components/Button/Button.const.d.ts.map +1 -0
  18. package/dist/common-components/Button/Button.const.js +7 -0
  19. package/dist/common-components/Button/Button.d.ts +4 -0
  20. package/dist/common-components/Button/Button.d.ts.map +1 -0
  21. package/dist/common-components/Button/Button.js +28 -0
  22. package/dist/common-components/Button/Button.types.d.ts +6 -0
  23. package/dist/common-components/Button/Button.types.d.ts.map +1 -0
  24. package/dist/common-components/Button/index.d.ts +3 -0
  25. package/dist/common-components/Button/index.d.ts.map +1 -0
  26. package/dist/common-components/Canvas/Canvas.cjs +1 -0
  27. package/dist/common-components/Canvas/Canvas.const.cjs +1 -0
  28. package/dist/common-components/Canvas/Canvas.const.d.ts +2 -0
  29. package/dist/common-components/Canvas/Canvas.const.d.ts.map +1 -0
  30. package/dist/common-components/Canvas/Canvas.const.js +4 -0
  31. package/dist/common-components/Canvas/Canvas.d.ts +4 -0
  32. package/dist/common-components/Canvas/Canvas.d.ts.map +1 -0
  33. package/dist/common-components/Canvas/Canvas.js +14 -0
  34. package/dist/common-components/Canvas/Canvas.types.d.ts +5 -0
  35. package/dist/common-components/Canvas/Canvas.types.d.ts.map +1 -0
  36. package/dist/common-components/Canvas/index.d.ts +3 -0
  37. package/dist/common-components/Canvas/index.d.ts.map +1 -0
  38. package/dist/common-components/ContextMenu/ContextMenu.cjs +1 -0
  39. package/dist/common-components/ContextMenu/ContextMenu.const.cjs +1 -0
  40. package/dist/common-components/ContextMenu/ContextMenu.const.d.ts +11 -0
  41. package/dist/common-components/ContextMenu/ContextMenu.const.d.ts.map +1 -0
  42. package/dist/common-components/ContextMenu/ContextMenu.const.js +14 -0
  43. package/dist/common-components/ContextMenu/ContextMenu.d.ts +4 -0
  44. package/dist/common-components/ContextMenu/ContextMenu.d.ts.map +1 -0
  45. package/dist/common-components/ContextMenu/ContextMenu.js +69 -0
  46. package/dist/common-components/ContextMenu/ContextMenu.types.d.ts +33 -0
  47. package/dist/common-components/ContextMenu/ContextMenu.types.d.ts.map +1 -0
  48. package/dist/common-components/ContextMenu/ContextMenu.utils.cjs +1 -0
  49. package/dist/common-components/ContextMenu/ContextMenu.utils.d.ts +3 -0
  50. package/dist/common-components/ContextMenu/ContextMenu.utils.d.ts.map +1 -0
  51. package/dist/common-components/ContextMenu/ContextMenu.utils.js +11 -0
  52. package/dist/common-components/ContextMenu/ContextMenu.utils.test.d.ts +2 -0
  53. package/dist/common-components/ContextMenu/ContextMenu.utils.test.d.ts.map +1 -0
  54. package/dist/common-components/ContextMenu/index.d.ts +5 -0
  55. package/dist/common-components/ContextMenu/index.d.ts.map +1 -0
  56. package/dist/common-components/Field/Field.cjs +1 -0
  57. package/dist/common-components/Field/Field.const.cjs +1 -0
  58. package/dist/common-components/Field/Field.const.d.ts +3 -0
  59. package/dist/common-components/Field/Field.const.d.ts.map +1 -0
  60. package/dist/common-components/Field/Field.const.js +5 -0
  61. package/dist/common-components/Field/Field.d.ts +4 -0
  62. package/dist/common-components/Field/Field.d.ts.map +1 -0
  63. package/dist/common-components/Field/Field.js +26 -0
  64. package/dist/common-components/Field/Field.types.d.ts +10 -0
  65. package/dist/common-components/Field/Field.types.d.ts.map +1 -0
  66. package/dist/common-components/Field/index.d.ts +3 -0
  67. package/dist/common-components/Field/index.d.ts.map +1 -0
  68. package/dist/common-components/icons/GripIcon.cjs +1 -0
  69. package/dist/common-components/icons/GripIcon.d.ts +3 -0
  70. package/dist/common-components/icons/GripIcon.d.ts.map +1 -0
  71. package/dist/common-components/icons/GripIcon.js +13 -0
  72. package/dist/common-components/icons/Icon.const.cjs +1 -0
  73. package/dist/common-components/icons/Icon.const.d.ts +7 -0
  74. package/dist/common-components/icons/Icon.const.d.ts.map +1 -0
  75. package/dist/common-components/icons/Icon.const.js +10 -0
  76. package/dist/common-components/icons/RedoIcon.cjs +1 -0
  77. package/dist/common-components/icons/RedoIcon.d.ts +3 -0
  78. package/dist/common-components/icons/RedoIcon.d.ts.map +1 -0
  79. package/dist/common-components/icons/RedoIcon.js +9 -0
  80. package/dist/common-components/icons/UndoIcon.cjs +1 -0
  81. package/dist/common-components/icons/UndoIcon.d.ts +3 -0
  82. package/dist/common-components/icons/UndoIcon.d.ts.map +1 -0
  83. package/dist/common-components/icons/UndoIcon.js +9 -0
  84. package/dist/common-components/icons/index.d.ts +4 -0
  85. package/dist/common-components/icons/index.d.ts.map +1 -0
  86. package/dist/common-components/index.d.ts +12 -0
  87. package/dist/common-components/index.d.ts.map +1 -0
  88. package/dist/components/InkEditor/InkEditor.cjs +1 -1
  89. package/dist/components/InkEditor/InkEditor.d.ts.map +1 -1
  90. package/dist/components/InkEditor/InkEditor.js +917 -432
  91. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.cjs +1 -0
  92. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.const.cjs +1 -0
  93. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.const.d.ts +7 -0
  94. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.const.d.ts.map +1 -0
  95. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.const.js +10 -0
  96. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.d.ts +4 -0
  97. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.d.ts.map +1 -0
  98. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.js +17 -0
  99. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.types.d.ts +12 -0
  100. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.types.d.ts.map +1 -0
  101. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.utils.cjs +1 -0
  102. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.utils.d.ts +4 -0
  103. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.utils.d.ts.map +1 -0
  104. package/dist/components/InkEditor/components/AiAutocomplete/AiAutocomplete.utils.js +25 -0
  105. package/dist/components/InkEditor/components/AiAutocomplete/index.d.ts +5 -0
  106. package/dist/components/InkEditor/components/AiAutocomplete/index.d.ts.map +1 -0
  107. package/dist/components/InkEditor/components/AiPanel/AiPanel.cjs +1 -1
  108. package/dist/components/InkEditor/components/AiPanel/AiPanel.d.ts +1 -0
  109. package/dist/components/InkEditor/components/AiPanel/AiPanel.d.ts.map +1 -1
  110. package/dist/components/InkEditor/components/AiPanel/AiPanel.js +53 -49
  111. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.cjs +1 -1
  112. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.const.cjs +1 -0
  113. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.const.d.ts +15 -0
  114. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.const.d.ts.map +1 -0
  115. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.const.js +18 -0
  116. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.d.ts +1 -6
  117. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.d.ts.map +1 -1
  118. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.js +53 -8
  119. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.types.d.ts +9 -0
  120. package/dist/components/InkEditor/components/BlockHandles/BlockHandles.types.d.ts.map +1 -0
  121. package/dist/components/InkEditor/components/BlockHandles/index.d.ts +2 -1
  122. package/dist/components/InkEditor/components/BlockHandles/index.d.ts.map +1 -1
  123. package/dist/components/InkEditor/components/FindReplace/FindReplace.cjs +1 -1
  124. package/dist/components/InkEditor/components/FindReplace/FindReplace.d.ts.map +1 -1
  125. package/dist/components/InkEditor/components/FindReplace/FindReplace.js +63 -44
  126. package/dist/components/InkEditor/components/FindReplace/FindReplace.types.d.ts +2 -0
  127. package/dist/components/InkEditor/components/FindReplace/FindReplace.types.d.ts.map +1 -1
  128. package/dist/components/InkEditor/components/FindReplace/index.d.ts +1 -1
  129. package/dist/components/InkEditor/components/FindReplace/index.d.ts.map +1 -1
  130. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.cjs +1 -0
  131. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.const.cjs +1 -0
  132. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.const.d.ts +25 -0
  133. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.const.d.ts.map +1 -0
  134. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.const.js +28 -0
  135. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.d.ts +4 -0
  136. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.d.ts.map +1 -0
  137. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.js +140 -0
  138. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.types.d.ts +32 -0
  139. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.types.d.ts.map +1 -0
  140. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.utils.cjs +1 -0
  141. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.utils.d.ts +4 -0
  142. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.utils.d.ts.map +1 -0
  143. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.utils.js +16 -0
  144. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.utils.test.d.ts +2 -0
  145. package/dist/components/InkEditor/components/InlineToolbar/InlineToolbar.utils.test.d.ts.map +1 -0
  146. package/dist/components/InkEditor/components/InlineToolbar/index.d.ts +5 -0
  147. package/dist/components/InkEditor/components/InlineToolbar/index.d.ts.map +1 -0
  148. package/dist/components/InkEditor/components/SignPad/SignPad.cjs +1 -1
  149. package/dist/components/InkEditor/components/SignPad/SignPad.d.ts.map +1 -1
  150. package/dist/components/InkEditor/components/SignPad/SignPad.js +47 -51
  151. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
  152. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.d.ts.map +1 -1
  153. package/dist/components/InkEditor/components/ToolbarButton/ToolbarButton.js +20 -16
  154. package/dist/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
  155. package/dist/components/InkEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +16 -12
  156. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.cjs +1 -0
  157. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.const.cjs +1 -0
  158. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.const.d.ts +10 -0
  159. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.const.d.ts.map +1 -0
  160. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.const.js +18 -0
  161. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.d.ts +4 -0
  162. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.d.ts.map +1 -0
  163. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.js +43 -0
  164. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.types.d.ts +12 -0
  165. package/dist/components/InkEditor/components/ToolbarCustomize/ToolbarCustomize.types.d.ts.map +1 -0
  166. package/dist/components/InkEditor/components/ToolbarCustomize/index.d.ts +4 -0
  167. package/dist/components/InkEditor/components/ToolbarCustomize/index.d.ts.map +1 -0
  168. package/dist/components/InkEditor/components/index.d.ts +7 -1
  169. package/dist/components/InkEditor/components/index.d.ts.map +1 -1
  170. package/dist/components/InkEditor/helpers/format.utils.cjs +2 -1
  171. package/dist/components/InkEditor/helpers/format.utils.d.ts +9 -0
  172. package/dist/components/InkEditor/helpers/format.utils.d.ts.map +1 -1
  173. package/dist/components/InkEditor/helpers/format.utils.js +113 -20
  174. package/dist/components/InkEditor/helpers/index.d.ts +1 -1
  175. package/dist/components/InkEditor/helpers/index.d.ts.map +1 -1
  176. package/dist/constants/blocks.const.cjs +1 -0
  177. package/dist/constants/blocks.const.d.ts +11 -0
  178. package/dist/constants/blocks.const.d.ts.map +1 -0
  179. package/dist/constants/blocks.const.js +14 -0
  180. package/dist/constants/colorMode.const.cjs +1 -0
  181. package/dist/constants/colorMode.const.d.ts +6 -0
  182. package/dist/constants/colorMode.const.d.ts.map +1 -0
  183. package/dist/constants/colorMode.const.js +7 -0
  184. package/dist/constants/contextMenu.const.cjs +1 -0
  185. package/dist/constants/contextMenu.const.d.ts +37 -0
  186. package/dist/constants/contextMenu.const.d.ts.map +1 -0
  187. package/dist/constants/contextMenu.const.js +39 -0
  188. package/dist/constants/defaultIcons.cjs +1 -0
  189. package/dist/constants/defaultIcons.d.ts +4 -0
  190. package/dist/constants/defaultIcons.d.ts.map +1 -0
  191. package/dist/constants/defaultIcons.js +42 -0
  192. package/dist/constants/defaults.const.cjs +1 -1
  193. package/dist/constants/defaults.const.d.ts +4 -0
  194. package/dist/constants/defaults.const.d.ts.map +1 -1
  195. package/dist/constants/defaults.const.js +56 -48
  196. package/dist/constants/findReplaceMenu.const.cjs +1 -0
  197. package/dist/constants/findReplaceMenu.const.d.ts +10 -0
  198. package/dist/constants/findReplaceMenu.const.d.ts.map +1 -0
  199. package/dist/constants/findReplaceMenu.const.js +14 -0
  200. package/dist/constants/fonts.const.cjs +1 -0
  201. package/dist/constants/fonts.const.d.ts +25 -0
  202. package/dist/constants/fonts.const.d.ts.map +1 -0
  203. package/dist/constants/fonts.const.js +40 -0
  204. package/dist/constants/index.d.ts +11 -0
  205. package/dist/constants/index.d.ts.map +1 -1
  206. package/dist/constants/keyboard.const.cjs +1 -0
  207. package/dist/constants/keyboard.const.d.ts +5 -0
  208. package/dist/constants/keyboard.const.d.ts.map +1 -0
  209. package/dist/constants/keyboard.const.js +7 -0
  210. package/dist/constants/lists.const.cjs +1 -0
  211. package/dist/constants/lists.const.d.ts +24 -0
  212. package/dist/constants/lists.const.d.ts.map +1 -0
  213. package/dist/constants/lists.const.js +28 -0
  214. package/dist/constants/numbers.cjs +1 -1
  215. package/dist/constants/numbers.js +30 -15
  216. package/dist/constants/openai.const.cjs +1 -0
  217. package/dist/constants/openai.const.d.ts +42 -0
  218. package/dist/constants/openai.const.d.ts.map +1 -0
  219. package/dist/constants/openai.const.js +58 -0
  220. package/dist/constants/premium.const.cjs +1 -1
  221. package/dist/constants/premium.const.d.ts +1 -2
  222. package/dist/constants/premium.const.d.ts.map +1 -1
  223. package/dist/constants/premium.const.js +6 -34
  224. package/dist/constants/table.const.cjs +1 -0
  225. package/dist/constants/table.const.d.ts +8 -0
  226. package/dist/constants/table.const.d.ts.map +1 -0
  227. package/dist/constants/table.const.js +10 -0
  228. package/dist/constants/toolbar.const.cjs +1 -1
  229. package/dist/constants/toolbar.const.d.ts +7 -0
  230. package/dist/constants/toolbar.const.d.ts.map +1 -1
  231. package/dist/constants/toolbar.const.js +11 -4
  232. package/dist/constants/toolbarMenu.const.cjs +1 -0
  233. package/dist/constants/toolbarMenu.const.d.ts +20 -0
  234. package/dist/constants/toolbarMenu.const.d.ts.map +1 -0
  235. package/dist/constants/toolbarMenu.const.js +66 -0
  236. package/dist/index.cjs +1 -1
  237. package/dist/index.d.ts +7 -4
  238. package/dist/index.d.ts.map +1 -1
  239. package/dist/index.js +103 -47
  240. package/dist/plugins/ai/demoProvider.cjs +1 -1
  241. package/dist/plugins/ai/demoProvider.d.ts.map +1 -1
  242. package/dist/plugins/ai/demoProvider.js +65 -40
  243. package/dist/plugins/ai/index.cjs +1 -1
  244. package/dist/plugins/ai/index.d.ts +3 -1
  245. package/dist/plugins/ai/index.d.ts.map +1 -1
  246. package/dist/plugins/ai/index.js +28 -14
  247. package/dist/plugins/ai/inkServerProvider.cjs +1 -0
  248. package/dist/plugins/ai/inkServerProvider.d.ts +4 -0
  249. package/dist/plugins/ai/inkServerProvider.d.ts.map +1 -0
  250. package/dist/plugins/ai/inkServerProvider.js +52 -0
  251. package/dist/plugins/ai/inkServerProvider.types.d.ts +15 -0
  252. package/dist/plugins/ai/inkServerProvider.types.d.ts.map +1 -0
  253. package/dist/plugins/ai/openaiProvider.cjs +1 -0
  254. package/dist/plugins/ai/openaiProvider.d.ts +4 -0
  255. package/dist/plugins/ai/openaiProvider.d.ts.map +1 -0
  256. package/dist/plugins/ai/openaiProvider.js +128 -0
  257. package/dist/plugins/ai/openaiProvider.types.d.ts +32 -0
  258. package/dist/plugins/ai/openaiProvider.types.d.ts.map +1 -0
  259. package/dist/plugins/ai/openaiProvider.utils.cjs +5 -0
  260. package/dist/plugins/ai/openaiProvider.utils.d.ts +14 -0
  261. package/dist/plugins/ai/openaiProvider.utils.d.ts.map +1 -0
  262. package/dist/plugins/ai/openaiProvider.utils.js +57 -0
  263. package/dist/styles.css +1 -721
  264. package/dist/types/ai.types.d.ts +2 -1
  265. package/dist/types/ai.types.d.ts.map +1 -1
  266. package/dist/types/features.types.d.ts +3 -1
  267. package/dist/types/features.types.d.ts.map +1 -1
  268. package/dist/types/index.d.ts +1 -1
  269. package/dist/types/index.d.ts.map +1 -1
  270. package/dist/types/ink.types.d.ts +7 -2
  271. package/dist/types/ink.types.d.ts.map +1 -1
  272. package/dist/types/premium.types.d.ts +1 -1
  273. package/dist/types/premium.types.d.ts.map +1 -1
  274. package/dist/utils/blocks.utils.cjs +1 -1
  275. package/dist/utils/blocks.utils.d.ts +8 -0
  276. package/dist/utils/blocks.utils.d.ts.map +1 -1
  277. package/dist/utils/blocks.utils.js +61 -19
  278. package/dist/utils/blocks.utils.test.d.ts +2 -0
  279. package/dist/utils/blocks.utils.test.d.ts.map +1 -0
  280. package/dist/utils/comments.utils.cjs +1 -1
  281. package/dist/utils/comments.utils.js +23 -18
  282. package/dist/utils/history.utils.cjs +1 -1
  283. package/dist/utils/history.utils.js +7 -2
  284. package/dist/utils/index.d.ts +6 -2
  285. package/dist/utils/index.d.ts.map +1 -1
  286. package/dist/utils/license.utils.cjs +1 -1
  287. package/dist/utils/license.utils.js +15 -10
  288. package/dist/utils/paste.utils.cjs +1 -1
  289. package/dist/utils/paste.utils.js +27 -23
  290. package/dist/utils/premium.utils.cjs +1 -1
  291. package/dist/utils/premium.utils.js +23 -18
  292. package/dist/utils/selection.utils.cjs +1 -0
  293. package/dist/utils/selection.utils.d.ts +10 -0
  294. package/dist/utils/selection.utils.d.ts.map +1 -0
  295. package/dist/utils/selection.utils.js +58 -0
  296. package/dist/utils/selection.utils.test.d.ts +2 -0
  297. package/dist/utils/selection.utils.test.d.ts.map +1 -0
  298. package/dist/utils/slash.utils.cjs +1 -1
  299. package/dist/utils/slash.utils.js +13 -8
  300. package/dist/utils/table.utils.cjs +1 -1
  301. package/dist/utils/table.utils.d.ts +5 -0
  302. package/dist/utils/table.utils.d.ts.map +1 -1
  303. package/dist/utils/table.utils.js +69 -10
  304. package/dist/utils/table.utils.test.d.ts +2 -0
  305. package/dist/utils/table.utils.test.d.ts.map +1 -0
  306. package/dist/utils/toolbarStorage.utils.cjs +1 -0
  307. package/dist/utils/toolbarStorage.utils.d.ts +12 -0
  308. package/dist/utils/toolbarStorage.utils.d.ts.map +1 -0
  309. package/dist/utils/toolbarStorage.utils.js +92 -0
  310. package/dist/utils/toolbarStorage.utils.test.d.ts +2 -0
  311. package/dist/utils/toolbarStorage.utils.test.d.ts.map +1 -0
  312. package/dist/utils/trackChanges.utils.cjs +1 -1
  313. package/dist/utils/trackChanges.utils.js +14 -9
  314. package/dist/utils/typo.utils.cjs +1 -1
  315. package/dist/utils/typo.utils.js +15 -10
  316. package/package.json +2 -1
@@ -1,651 +1,1136 @@
1
- import { jsxs as M, jsx as a } from "react/jsx-runtime";
2
- import { useRef as Pe, useState as m, useEffect as _ } from "react";
3
- import { INK_MIN_HEIGHT as Wt, INK_DEFAULT_TEXT_COLOR as $t, INK_DEFAULT_HIGHLIGHT_COLOR as zt } from "../../constants/numbers.js";
4
- import { TOOLBAR_OPTION_SIGNATURE as xe, TOOLBAR_OPTION_FIND_REPLACE as Be, TOOLBAR_OPTION_HORIZONTAL_RULE as Ue } from "../../constants/toolbar.const.js";
5
- import { INK_PLACEHOLDER_DEFAULT as qt, INK_DEFAULT_TOOLBAR as Xt, INK_DEFAULT_VARIANT as Qt, INK_DEFAULT_AUTHOR as Yt, INK_TABLE_DEFAULT_ROWS as Zt, INK_TABLE_DEFAULT_COLS as Jt, INK_DEFAULT_FEATURES as en, INK_CLASS_TOOLBAR as tn, INK_CLASS_SHELL as nn, INK_CLASS_BODY as rn, INK_CLASS_CONTENT as on, INK_CLASS_FOOTER as cn, INK_CLASS_DIVIDER as sn, INK_HEADING_OPTIONS as an, INK_BUTTON_CONFIG as De, INK_CLASS_ROOT as ln } from "../../constants/defaults.const.js";
6
- import { INK_DEFAULT_ICONS as Fe } from "../../constants/premium.const.js";
7
- import { cn as un } from "../../utils/cn.utils.js";
8
- import { applyTypoAutoFix as mn } from "../../utils/typo.utils.js";
9
- import { createInkId as Ke } from "../../utils/id.utils.js";
10
- import { buildTableHtml as dn } from "../../utils/table.utils.js";
11
- import { getBlockElement as Me, moveBlock as fn, markActiveBlock as pn } from "../../utils/blocks.utils.js";
12
- import { createTrackChange as J, rejectTrackChangeInHtml as hn, acceptTrackChangeInHtml as gn, wrapInsertHtml as Ve, wrapDeleteHtml as Cn } from "../../utils/trackChanges.utils.js";
13
- import { removeCommentMark as kn, wrapSelectionAsComment as Tn, createCommentThread as In } from "../../utils/comments.utils.js";
14
- import { InkHistoryStack as ee } from "../../utils/history.utils.js";
15
- import { extractSlashQuery as bn, filterSlashCommands as An } from "../../utils/slash.utils.js";
16
- import { resolveInkPremium as Ln, hasInkPremiumFeature as U, themeTokensToStyle as wn } from "../../utils/premium.utils.js";
17
- import { extractClipboardHtml as Hn, sanitizePastedHtml as yn, extractClipboardText as _n } from "../../utils/paste.utils.js";
18
- import { readInkMemory as Nn, writeInkMemory as Sn } from "../../utils/memory.utils.js";
19
- import { replaceInHtml as Rn } from "../../utils/findReplace.utils.js";
20
- import { insertImage as te, insertHTML as A, setTextColor as vn, setHighlightColor as On, getActiveFormats as En, queryCommandValue as Pn, execCommand as k, insertLink as xn, fileToDataUrl as Bn } from "./helpers/format.utils.js";
21
- import { ToolbarButton as h } from "./components/ToolbarButton/ToolbarButton.js";
22
- import { ToolbarDropdown as Un } from "./components/ToolbarDropdown/ToolbarDropdown.js";
23
- import { ToolbarColorPicker as je } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
24
- import { CommentsPanel as Dn } from "./components/CommentsPanel/CommentsPanel.js";
25
- import { AiPanel as Fn } from "./components/AiPanel/AiPanel.js";
26
- import { BlockHandles as Kn } from "./components/BlockHandles/BlockHandles.js";
27
- import { SlashMenu as Mn } from "./components/SlashMenu/SlashMenu.js";
28
- import { TrackChangesBar as Vn } from "./components/TrackChangesBar/TrackChangesBar.js";
29
- import { SignPad as jn } from "./components/SignPad/SignPad.js";
30
- import { FindReplace as Gn } from "./components/FindReplace/FindReplace.js";
31
- const ne = () => {
32
- const N = window.getSelection();
33
- if (!N || N.rangeCount === 0) return "";
34
- const g = N.getRangeAt(0), T = document.createElement("div");
35
- return T.appendChild(g.cloneContents()), T.innerHTML;
36
- }, br = (N) => {
37
- var Ee;
1
+ import { jsxs as ce, jsx as c } from "react/jsx-runtime";
2
+ import { useRef as S, useState as a, useEffect as I } from "react";
3
+ import { INK_MIN_HEIGHT as bo, INK_DEFAULT_TEXT_COLOR as Ro, INK_DEFAULT_HIGHLIGHT_COLOR as Do, NUMBER_ZERO as _ } from "../../constants/numbers.js";
4
+ import { TOOLBAR_OPTION_FONT_DROPDOWN as Mt, TOOLBAR_OPTION_LIST_DROPDOWN as kt, TOOLBAR_OPTION_SIGNATURE as Ut, TOOLBAR_OPTION_FIND_REPLACE as Ht, TOOLBAR_OPTION_FIND_REPLACE_DROPDOWN as wt, TOOLBAR_OPTION_HORIZONTAL_RULE as Pt } from "../../constants/toolbar.const.js";
5
+ import { TOOLBAR_SHOW_CONTROL_LABEL as Bo, TOOLBAR_SHOW_CONTROL_ARIA_LABEL as So, AGENT_BAR_PLACEHOLDER as Mo, CONTEXT_MENU_LABEL_SHOW_TOOLBAR as ko, CONTEXT_MENU_ID_SHOW_TOOLBAR as Uo, TOOLBAR_CONTEXT_MENU_LABEL_CUSTOMIZE as Ho, TOOLBAR_CONTEXT_MENU_ID_CUSTOMIZE as wo, TOOLBAR_CONTEXT_MENU_LABEL_HIDE as Po, TOOLBAR_CONTEXT_MENU_ID_HIDE as yo, TOOLBAR_OPTION_DIVIDER as yt } from "../../constants/toolbarMenu.const.js";
6
+ import { INK_DEFAULT_COLOR_MODE as Fo, COLOR_MODE_SYSTEM as vo } from "../../constants/colorMode.const.js";
7
+ import { KEY_TAB as xo, KEY_ENTER as Xo, KEY_ESCAPE as Ko, KEY_Z as Wo } from "../../constants/keyboard.const.js";
8
+ import { FONT_VALUE_SYSTEM as Vo, INK_FONT_OPTIONS as Go, FONT_DROPDOWN_TITLE as Yo } from "../../constants/fonts.const.js";
9
+ import { LIST_VALUE_BULLET as zo, INK_LIST_OPTIONS as jo, LIST_DROPDOWN_TITLE as $o } from "../../constants/lists.const.js";
10
+ import { FIND_REPLACE_FOCUS_FIND as se, INK_FIND_REPLACE_OPTIONS as qo, FIND_REPLACE_DROPDOWN_TITLE as Zo, FIND_REPLACE_FOCUS_REPLACE as Qo, FIND_REPLACE_VALUE_REPLACE as Jo } from "../../constants/findReplaceMenu.const.js";
11
+ import { BLOCK_DROP_POSITION_BEFORE as er, DIR_LTR as tr, DIR_RTL as nr } from "../../constants/blocks.const.js";
12
+ import { INK_PLACEHOLDER_DEFAULT as or, INK_DEFAULT_TOOLBAR as rr, INK_DEFAULT_VARIANT as lr, INK_DEFAULT_CHROME as ir, INK_DEFAULT_AUTHOR as cr, INK_TABLE_DEFAULT_ROWS as sr, INK_TABLE_DEFAULT_COLS as ar, INK_DEFAULT_FEATURES as ur, INK_CLASS_TOOLBAR_SHOW as dr, INK_CLASS_TOOLBAR as fr, INK_CLASS_SHELL as mr, INK_CLASS_BODY as _r, INK_CLASS_CONTENT as Tr, INK_CLASS_FOOTER as Er, INK_CLASS_DIVIDER as pr, INK_HEADING_OPTIONS as Cr, INK_BUTTON_CONFIG as Ft, INK_CLASS_BLOCK_ACTIVE as Lr, INK_CLASS_ROOT as Or } from "../../constants/defaults.const.js";
13
+ import { INK_AI_DEMO_PROVIDER_ID as Nr } from "../../constants/aiModels.const.js";
14
+ import "../../constants/openai.const.js";
15
+ import { INK_DEFAULT_ICONS as vt } from "../../constants/defaultIcons.js";
16
+ import { CONTEXT_MENU_LABEL_TABLE_ROW_ABOVE as Ir, CONTEXT_MENU_ID_TABLE_ROW_ABOVE as gr, CONTEXT_MENU_LABEL_TABLE_ROW_BELOW as hr, CONTEXT_MENU_ID_TABLE_ROW_BELOW as Ar, CONTEXT_MENU_LABEL_TABLE_COL_LEFT as br, CONTEXT_MENU_ID_TABLE_COL_LEFT as Rr, CONTEXT_MENU_LABEL_TABLE_COL_RIGHT as Dr, CONTEXT_MENU_ID_TABLE_COL_RIGHT as Br, CONTEXT_MENU_LABEL_TABLE_DELETE_ROW as Sr, CONTEXT_MENU_ID_TABLE_DELETE_ROW as Mr, CONTEXT_MENU_LABEL_TABLE_DELETE_COL as kr, CONTEXT_MENU_ID_TABLE_DELETE_COL as Ur, CONTEXT_MENU_LABEL_BOLD as Hr, CONTEXT_MENU_ID_BOLD as wr, CONTEXT_MENU_LABEL_ITALIC as Pr, CONTEXT_MENU_ID_ITALIC as yr, CONTEXT_MENU_LABEL_UNDERLINE as Fr, CONTEXT_MENU_ID_UNDERLINE as vr, CONTEXT_MENU_LABEL_STRIKE as xr, CONTEXT_MENU_ID_STRIKE as Xr, CONTEXT_MENU_LABEL_HEADING as Kr, CONTEXT_MENU_ID_HEADING as Wr, CONTEXT_MENU_LABEL_BULLET as Vr, CONTEXT_MENU_ID_BULLET as Gr, CONTEXT_MENU_LABEL_ORDERED as Yr, CONTEXT_MENU_ID_ORDERED as zr, CONTEXT_MENU_LABEL_LINK as jr, CONTEXT_MENU_ID_LINK as $r, CONTEXT_MENU_LABEL_CLEAR as qr, CONTEXT_MENU_ID_CLEAR as Zr, CONTEXT_MENU_LABEL_FIND as Qr, CONTEXT_MENU_ID_FIND as Jr, CONTEXT_MENU_LABEL_SIGNATURE as el, CONTEXT_MENU_ID_SIGNATURE as tl, CONTEXT_MENU_LABEL_COMMENT as nl, CONTEXT_MENU_ID_COMMENT as ol } from "../../constants/contextMenu.const.js";
17
+ import { cn as rl } from "../../utils/cn.utils.js";
18
+ import { applyTypoAutoFix as ll } from "../../utils/typo.utils.js";
19
+ import { createInkId as xt } from "../../utils/id.utils.js";
20
+ import { getTableCellFromSelection as Xt, buildTableHtml as il, insertTableRow as Kt, insertTableColumn as Wt, deleteTableRow as cl, deleteTableColumn as sl } from "../../utils/table.utils.js";
21
+ import { getBlockElement as ee, clearBlockDragClasses as Pe, markActiveBlock as Vt, markDraggingBlock as al, moveBlock as ul, resolveDropPosition as Gt, reorderBlockBefore as dl, reorderBlockAfter as fl, markDropTarget as Yt } from "../../utils/blocks.utils.js";
22
+ import { createTrackChange as ye, rejectTrackChangeInHtml as ml, acceptTrackChangeInHtml as _l, wrapInsertHtml as zt, wrapDeleteHtml as Tl } from "../../utils/trackChanges.utils.js";
23
+ import { removeCommentMark as El, wrapSelectionAsComment as pl, createCommentThread as Cl } from "../../utils/comments.utils.js";
24
+ import { InkHistoryStack as Fe } from "../../utils/history.utils.js";
25
+ import { extractSlashQuery as Ll, filterSlashCommands as Ol } from "../../utils/slash.utils.js";
26
+ import { resolveInkPremium as Nl, hasInkPremiumFeature as te, themeTokensToStyle as Il } from "../../utils/premium.utils.js";
27
+ import { extractClipboardHtml as gl, sanitizePastedHtml as hl, extractClipboardText as Al } from "../../utils/paste.utils.js";
28
+ import { readInkMemory as bl, writeInkMemory as Rl } from "../../utils/memory.utils.js";
29
+ import { replaceInHtml as Dl } from "../../utils/findReplace.utils.js";
30
+ import { withPreservedSelection as ve } from "../../utils/selection.utils.js";
31
+ import { readToolbarItems as Bl, readToolbarHidden as Sl, listCustomizableToolbarOptions as Ml, writeToolbarHidden as kl, buildVisibleToolbarItems as Ul, writeToolbarItems as Hl } from "../../utils/toolbarStorage.utils.js";
32
+ import { Button as wl } from "../../common-components/Button/Button.js";
33
+ import { ContextMenu as jt } from "../../common-components/ContextMenu/ContextMenu.js";
34
+ import { insertImage as xe, insertHTML as M, setTextColor as Pl, setHighlightColor as yl, getActiveFormats as Fl, queryCommandValue as vl, detectListType as xl, tryConvertMarkdownListPrefix as Xl, execCommand as L, insertLink as Kl, applyFontFamily as Wl, applyListType as Vl, clearFormatDeep as Gl, setBlockDirection as $t, fileToDataUrl as Yl } from "./helpers/format.utils.js";
35
+ import { inkAi as zl } from "../../plugins/ai/aiPlugin.js";
36
+ import { ToolbarButton as C } from "./components/ToolbarButton/ToolbarButton.js";
37
+ import { ToolbarDropdown as ae } from "./components/ToolbarDropdown/ToolbarDropdown.js";
38
+ import { ToolbarColorPicker as qt } from "./components/ToolbarColorPicker/ToolbarColorPicker.js";
39
+ import { CommentsPanel as jl } from "./components/CommentsPanel/CommentsPanel.js";
40
+ import { AiPanel as $l } from "./components/AiPanel/AiPanel.js";
41
+ import { AiAutocomplete as ql } from "./components/AiAutocomplete/AiAutocomplete.js";
42
+ import { AI_AUTOCOMPLETE_DEBOUNCE_MS as Zl, AI_AUTOCOMPLETE_COMMAND_INSERT_TEXT as Ql } from "./components/AiAutocomplete/AiAutocomplete.const.js";
43
+ import { getTextBeforeCaret as Jl, getCaretPositionInRoot as Zt } from "./components/AiAutocomplete/AiAutocomplete.utils.js";
44
+ import { BlockHandles as ei } from "./components/BlockHandles/BlockHandles.js";
45
+ import { BLOCK_HANDLES_DRAG_MIME as ti, BLOCK_HANDLES_DRAG_PAYLOAD as ni, BLOCK_HANDLES_DRAG_EFFECT_MOVE as Qt } from "./components/BlockHandles/BlockHandles.const.js";
46
+ import { InlineToolbar as oi } from "./components/InlineToolbar/InlineToolbar.js";
47
+ import { INLINE_TOOLBAR_EDGE_PADDING_PX as ri, INLINE_TOOLBAR_ESTIMATED_WIDTH_PX as li, INLINE_TOOLBAR_ESTIMATED_HEIGHT_PX as ii, INLINE_TOOLBAR_GAP_PX as ci } from "./components/InlineToolbar/InlineToolbar.const.js";
48
+ import { selectionIsInsideElement as si, clampInlineToolbarPosition as ai } from "./components/InlineToolbar/InlineToolbar.utils.js";
49
+ import { SlashMenu as ui } from "./components/SlashMenu/SlashMenu.js";
50
+ import { TrackChangesBar as di } from "./components/TrackChangesBar/TrackChangesBar.js";
51
+ import { SignPad as fi } from "./components/SignPad/SignPad.js";
52
+ import { FindReplace as mi } from "./components/FindReplace/FindReplace.js";
53
+ import { ToolbarCustomize as _i } from "./components/ToolbarCustomize/ToolbarCustomize.js";
54
+ const Xe = () => {
55
+ const g = window.getSelection();
56
+ if (!g || g.rangeCount === _) return "";
57
+ const p = g.getRangeAt(_), h = document.createElement("div");
58
+ return h.appendChild(p.cloneContents()), h.innerHTML;
59
+ }, T = (g) => {
60
+ g == null || g.focus({ preventScroll: !0 });
61
+ }, Tc = (g) => {
62
+ var Dt;
38
63
  const {
39
- value: g,
40
- defaultValue: T = "",
41
- onChange: C,
42
- placeholder: re = qt,
43
- disabled: c = !1,
64
+ value: p,
65
+ defaultValue: h = "",
66
+ onChange: A,
67
+ placeholder: Ke = or,
68
+ disabled: l = !1,
44
69
  readOnly: i = !1,
45
- minHeight: V = Wt,
46
- maxHeight: j,
47
- toolbar: Ge = Xt,
48
- className: We = "",
49
- testId: $e,
50
- allowImagePaste: oe = !0,
51
- showCharCount: ce = !1,
52
- charCountMax: ie,
53
- typoAutoFix: ze = !0,
54
- variant: qe = Qt,
55
- features: Xe,
56
- author: w = Yt,
57
- trackChanges: S,
58
- onTrackChangesChange: G,
59
- trackChangesEnabled: D,
60
- onTrackChangesEnabledChange: W,
61
- comments: R,
62
- onCommentsChange: $,
63
- showCommentsPanel: v,
64
- onShowCommentsPanelChange: z,
65
- ai: d,
66
- slashCommands: Qe,
67
- tableRows: Ye = Zt,
68
- tableCols: Ze = Jt,
69
- premium: Je,
70
- theme: et,
71
- icons: se,
72
- pasteMode: tt = "plain",
73
- onImageUpload: ae,
74
- wysiwyg: nt = !1,
75
- keepInMemory: le = !1,
76
- memoryKey: ue,
77
- style: rt,
78
- ...ot
79
- } = N, u = { ...en, ...Xe }, H = Ln(Je), ct = U(H, "icons"), it = U(H, "theme"), st = U(H, "richPaste"), at = U(H, "imageUpload"), lt = U(H, "wysiwyg") && nt, f = ct && se ? { ...Fe, ...se } : Fe, ut = it ? wn(et) : {}, mt = st && tt === "rich", r = Pe(null), O = Pe(new ee(g ?? T)), [dt, ft] = m(/* @__PURE__ */ new Set()), [pt, me] = m("p"), [ht, gt] = m(0), [Ct, kt] = m($t), [Tt, It] = m(zt), [y, de] = m(D ?? !1), [bt, fe] = m(S ?? []), [At, pe] = m(R ?? []), [Lt, he] = m(v ?? !1), [ge, q] = m(!!(d != null && d.enabled && d.openOnInit)), [Ce, wt] = m(""), [Ht, yt] = m(0), [_t, ke] = m(!1), [Nt, F] = m([]), [Te, St] = m({ top: 0, left: 0 }), [Ie, be] = m(!1), [Ae, Le] = m(!1), I = S ?? bt, E = R ?? At, X = v ?? Lt, we = Qe ?? u.slash;
80
- _(() => {
81
- D !== void 0 && de(D);
82
- }, [D]), _(() => {
83
- S && fe(S);
84
- }, [S]), _(() => {
85
- R && pe(R);
86
- }, [R]), _(() => {
87
- v !== void 0 && he(v);
88
- }, [v]), _(() => {
89
- !r.current || g === void 0 || r.current.innerHTML !== g && (r.current.innerHTML = g);
90
- }, [g]), _(() => {
91
- if (!r.current) return;
92
- const e = le ? Nn(ue) : "";
70
+ minHeight: ue = bo,
71
+ maxHeight: de,
72
+ toolbar: ne = rr,
73
+ className: Jt = "",
74
+ testId: en,
75
+ allowImagePaste: We = !0,
76
+ showCharCount: Ve = !1,
77
+ charCountMax: Ge,
78
+ typoAutoFix: tn = !0,
79
+ variant: Ye = lr,
80
+ chrome: nn = ir,
81
+ colorMode: ze = Fo,
82
+ features: on,
83
+ author: w = cr,
84
+ trackChanges: G,
85
+ onTrackChangesChange: fe,
86
+ trackChangesEnabled: oe,
87
+ onTrackChangesEnabledChange: me,
88
+ comments: Y,
89
+ onCommentsChange: _e,
90
+ showCommentsPanel: z,
91
+ onShowCommentsPanelChange: Te,
92
+ ai: f,
93
+ slashCommands: rn,
94
+ tableRows: ln = sr,
95
+ tableCols: cn = ar,
96
+ premium: sn,
97
+ theme: an,
98
+ icons: je,
99
+ pasteMode: un = "plain",
100
+ onImageUpload: $e,
101
+ wysiwyg: dn = !1,
102
+ keepInMemory: P = !1,
103
+ memoryKey: y,
104
+ onToolbarChange: Ee,
105
+ toolbarHidden: F,
106
+ onToolbarHiddenChange: pe,
107
+ style: fn,
108
+ ...mn
109
+ } = g, d = { ...ur, ...on }, v = Nl(sn), _n = te(v, "icons"), Tn = te(v, "theme"), En = te(v, "richPaste"), pn = te(v, "imageUpload"), Cn = te(v, "wysiwyg") && dn, m = _n && je ? { ...vt, ...je } : vt, Ln = Tn ? Il(an) : {}, On = En && un === "rich", n = S(null), j = S(new Fe(p ?? h)), x = S(null), k = S(null), [qe, Nn] = a(/* @__PURE__ */ new Set()), [In, Ze] = a("p"), [gn, hn] = a(0), [An, bn] = a(Ro), [Rn, Dn] = a(Do), [X, Qe] = a(oe ?? !1), [Bn, Je] = a(G ?? []), [Sn, et] = a(Y ?? []), [Mn, tt] = a(z ?? !1), [nt, Ce] = a(!!(f != null && f.enabled && f.openOnInit)), [re, kn] = a(!1), ot = S(!1), [R, $] = a({
110
+ visible: !1,
111
+ suggestion: "",
112
+ top: _,
113
+ left: _
114
+ }), q = S(null), K = S(_), [rt, Un] = a(""), [Hn, wn] = a(0), [Pn, lt] = a(!1), [yn, le] = a([]), [it, Fn] = a({ top: 0, left: 0 }), [ct, Le] = a(!1), [Oe, ie] = a(!1), [vn, xn] = a(se), [Xn, Kn] = a(Vo), [Wn, st] = a(zo), [Vn, Gn] = a(se), [Ne, Ie] = a({ open: !1, x: _, y: _ }), [Yn, at] = a(!1), [ge, he] = a({
115
+ open: !1,
116
+ x: _,
117
+ y: _
118
+ }), [Ae, W] = a({
119
+ open: !1,
120
+ top: _,
121
+ left: _
122
+ }), [be, ut] = a(
123
+ () => Bl(P, y) ?? ne
124
+ ), [zn, dt] = a(() => F !== void 0 ? F : Sl(P, y) ?? !1), [jn, ft] = a(!1), mt = S(!0), $n = ne.join(","), D = G ?? Bn, Z = Y ?? Sn, Re = z ?? Mn, _t = rn ?? d.slash, Tt = F ?? zn, Et = ne, qn = Ml(Et), De = ze === vo ? void 0 : ze, Be = !!(d.ai && (f != null && f.enabled) && f.autocomplete !== !1 && !l && !i), Se = () => {
125
+ q.current !== null && (window.clearTimeout(q.current), q.current = null);
126
+ }, b = () => {
127
+ Se(), K.current += 1, $(
128
+ (e) => e.visible || e.suggestion ? { visible: !1, suggestion: "", top: _, left: _ } : e
129
+ );
130
+ }, Zn = () => {
131
+ if (!Be || re || !n.current) {
132
+ b();
133
+ return;
134
+ }
135
+ const e = window.getSelection();
136
+ if (!e || !e.isCollapsed) {
137
+ b();
138
+ return;
139
+ }
140
+ Se(), $(
141
+ (o) => o.visible || o.suggestion ? { ...o, visible: !1, suggestion: "" } : o
142
+ );
143
+ const t = (f == null ? void 0 : f.providerId) || Nr;
144
+ q.current = window.setTimeout(() => {
145
+ if (q.current = null, !n.current || ot.current) return;
146
+ const o = window.getSelection();
147
+ if (!o || !o.isCollapsed) return;
148
+ const r = Jl(n.current), s = Zt(n.current);
149
+ if (!r.trim() || !s) return;
150
+ const E = K.current + 1;
151
+ K.current = E;
152
+ const N = n.current.innerHTML;
153
+ zl.runProvider(t, {
154
+ capability: "autocomplete",
155
+ html: N,
156
+ prompt: r,
157
+ modelId: f == null ? void 0 : f.modelId
158
+ }).then((H) => {
159
+ var St;
160
+ if (E !== K.current) return;
161
+ const B = ((St = H.text) == null ? void 0 : St.trim()) || "";
162
+ if (!B) {
163
+ $({
164
+ visible: !1,
165
+ suggestion: "",
166
+ top: _,
167
+ left: _
168
+ });
169
+ return;
170
+ }
171
+ const Bt = n.current && Zt(n.current) || s;
172
+ $({
173
+ visible: !0,
174
+ suggestion: B,
175
+ top: Bt.top,
176
+ left: Bt.left
177
+ });
178
+ }).catch(() => {
179
+ E === K.current && $({
180
+ visible: !1,
181
+ suggestion: "",
182
+ top: _,
183
+ left: _
184
+ });
185
+ });
186
+ }, Zl);
187
+ };
188
+ I(() => () => {
189
+ Se(), K.current += 1;
190
+ }, []), I(() => {
191
+ ot.current = re, re && b();
192
+ }, [re]), I(() => {
193
+ oe !== void 0 && Qe(oe);
194
+ }, [oe]), I(() => {
195
+ G && Je(G);
196
+ }, [G]), I(() => {
197
+ Y && et(Y);
198
+ }, [Y]), I(() => {
199
+ z !== void 0 && tt(z);
200
+ }, [z]), I(() => {
201
+ F !== void 0 && dt(F);
202
+ }, [F]), I(() => {
203
+ if (mt.current) {
204
+ mt.current = !1;
205
+ return;
206
+ }
207
+ ut(ne);
208
+ }, [$n]), I(() => {
209
+ if (!n.current || p === void 0 || p === x.current) return;
210
+ if (n.current.innerHTML === p) {
211
+ x.current = p;
212
+ return;
213
+ }
214
+ const e = document.activeElement === n.current;
215
+ ve(e ? n.current : null, () => {
216
+ n.current && (n.current.innerHTML = p);
217
+ }), x.current = p;
218
+ }, [p]), I(() => {
219
+ if (!n.current) return;
220
+ const e = P ? bl(y) : "";
93
221
  if (e) {
94
- r.current.innerHTML = e, O.current = new ee(e), C == null || C(e);
222
+ n.current.innerHTML = e, x.current = e, j.current = new Fe(e), A == null || A(e);
95
223
  return;
96
224
  }
97
- g === void 0 && T && (r.current.innerHTML = T, O.current = new ee(T), C == null || C(T));
225
+ p === void 0 && h && (n.current.innerHTML = h, x.current = h, j.current = new Fe(h), A == null || A(h));
98
226
  }, []);
99
- const Q = (e) => {
227
+ const Me = (e) => {
100
228
  var t;
101
- O.current.push(e), C == null || C(e), le && Sn(e, ue), ce && r.current && gt(((t = r.current.textContent) == null ? void 0 : t.length) ?? 0);
102
- }, L = (e) => {
103
- r.current && (r.current.innerHTML = e, Q(e));
104
- }, P = (e) => {
105
- fe(e), G == null || G(e);
106
- }, Y = (e) => {
107
- pe(e), $ == null || $(e);
108
- }, Z = (e) => {
109
- he(e), z == null || z(e);
110
- }, Rt = (e) => {
111
- de(e), W == null || W(e);
112
- }, K = () => {
113
- ft(En());
114
- const e = Pn("formatBlock");
115
- if (e && me(e.toLowerCase().replace(/[<>]/g, "")), wt(ne()), !r.current || !u.blocks) return;
116
- const t = window.getSelection(), n = (t == null ? void 0 : t.anchorNode) ?? null, o = Me(n, r.current);
117
- if (pn(r.current, o), o) {
118
- const s = r.current.getBoundingClientRect(), p = o.getBoundingClientRect();
119
- yt(p.top - s.top + r.current.scrollTop), ke(!0);
229
+ j.current.push(e), x.current = e, A == null || A(e), P && Rl(e, y), Ve && n.current && hn(((t = n.current.textContent) == null ? void 0 : t.length) ?? 0);
230
+ }, U = (e) => {
231
+ n.current && (ve(n.current, () => {
232
+ n.current && (n.current.innerHTML = e);
233
+ }), Me(e));
234
+ }, ke = (e) => {
235
+ dt(e), pe == null || pe(e), kl(e, P, y);
236
+ }, Qn = (e) => {
237
+ ut(e), Ee == null || Ee(e), Hl(e, P, y);
238
+ }, Jn = (e, t) => {
239
+ if (e === yt) return;
240
+ const o = new Set(
241
+ be.filter((r) => r !== yt)
242
+ );
243
+ t ? o.add(e) : o.delete(e), Qn(Ul(Et, o));
244
+ }, Q = (e) => {
245
+ Je(e), fe == null || fe(e);
246
+ }, Ue = (e) => {
247
+ et(e), _e == null || _e(e);
248
+ }, He = (e) => {
249
+ tt(e), Te == null || Te(e);
250
+ }, eo = (e) => {
251
+ Qe(e), me == null || me(e);
252
+ }, to = () => {
253
+ if (l || i) {
254
+ W((s) => s.open ? { ...s, open: !1 } : s);
255
+ return;
256
+ }
257
+ const e = window.getSelection();
258
+ if (!e || e.isCollapsed || e.rangeCount === 0 || !si(e, n.current)) {
259
+ W((s) => s.open ? { ...s, open: !1 } : s);
260
+ return;
261
+ }
262
+ const o = e.getRangeAt(0).getBoundingClientRect();
263
+ if (o.width === 0 && o.height === 0) {
264
+ W((s) => s.open ? { ...s, open: !1 } : s);
265
+ return;
266
+ }
267
+ const r = ai({
268
+ selectionRect: o,
269
+ toolbarWidth: li,
270
+ toolbarHeight: ii,
271
+ viewport: { width: window.innerWidth, height: window.innerHeight },
272
+ gap: ci,
273
+ edgePadding: ri
274
+ });
275
+ W({ open: !0, top: r.top, left: r.left });
276
+ }, J = () => {
277
+ Nn(Fl());
278
+ const e = vl("formatBlock");
279
+ if (e && Ze(e.toLowerCase().replace(/[<>]/g, "")), st(xl()), Un(Xe()), to(), !n.current || !d.blocks) return;
280
+ const t = window.getSelection(), o = (t == null ? void 0 : t.anchorNode) ?? null, r = ee(o, n.current);
281
+ if (Vt(n.current, r), r) {
282
+ const s = n.current.getBoundingClientRect(), E = r.getBoundingClientRect();
283
+ wn(E.top - s.top + n.current.scrollTop), lt(!0);
120
284
  } else
121
- ke(!1);
122
- }, l = () => {
123
- var t, n, o;
124
- if (!r.current) return;
125
- let e = r.current.innerHTML;
126
- if (y && u.trackChanges) {
285
+ lt(!1);
286
+ }, u = () => {
287
+ var t, o, r;
288
+ if (!n.current) return;
289
+ let e = n.current.innerHTML;
290
+ if (X && d.trackChanges) {
127
291
  const s = window.getSelection();
128
292
  if (s && !s.isCollapsed) {
129
- const p = ne();
130
- if (p) {
131
- const b = J("delete", p, w);
132
- P([...I, b]), vt(b.id), e = r.current.innerHTML;
293
+ const E = Xe();
294
+ if (E) {
295
+ const N = ye("delete", E, w);
296
+ Q([...D, N]), no(N.id), e = n.current.innerHTML;
133
297
  }
134
298
  }
135
299
  }
136
- if (Q(e), K(), we && r.current) {
137
- const s = ((n = (t = window.getSelection()) == null ? void 0 : t.anchorNode) == null ? void 0 : n.textContent) ?? "", p = bn(s);
138
- if (p !== null) {
139
- F(An(p));
140
- const b = (o = window.getSelection()) == null ? void 0 : o.getRangeAt(0);
141
- if (b && r.current) {
142
- const x = b.getBoundingClientRect(), B = r.current.getBoundingClientRect();
143
- St({
144
- top: x.bottom - B.top + 8,
145
- left: x.left - B.left
300
+ if (Me(e), J(), _t && n.current) {
301
+ const s = ((o = (t = window.getSelection()) == null ? void 0 : t.anchorNode) == null ? void 0 : o.textContent) ?? "", E = Ll(s);
302
+ if (E !== null) {
303
+ le(Ol(E));
304
+ const N = (r = window.getSelection()) == null ? void 0 : r.getRangeAt(0);
305
+ if (N && n.current) {
306
+ const H = N.getBoundingClientRect(), B = n.current.getBoundingClientRect();
307
+ Fn({
308
+ top: H.bottom - B.top + 8,
309
+ left: H.left - B.left
146
310
  });
147
311
  }
148
312
  } else
149
- F([]);
313
+ le([]);
314
+ }
315
+ Be ? Zn() : b();
316
+ }, pt = () => {
317
+ const e = R.suggestion;
318
+ if (!e) {
319
+ b();
320
+ return;
150
321
  }
151
- }, vt = (e) => {
322
+ T(n.current), L(Ql, e), b(), u();
323
+ }, no = (e) => {
152
324
  const t = window.getSelection();
153
325
  if (!t || t.rangeCount === 0) return;
154
- const n = ne();
155
- n && A(Cn(n, e));
156
- }, Ot = () => {
157
- if (!r.current || !ze || !u.typoAutoFix || c || i) return;
158
- const e = r.current.innerHTML, t = mn(e);
159
- t.html !== e && (r.current.innerHTML = t.html, Q(t.html));
160
- }, Et = (e) => {
161
- var n;
162
- if (c || i) return;
163
- (n = r.current) == null || n.focus();
164
- const t = De[e];
165
- t && (t.value ? k(t.command, t.value) : k(t.command), l());
166
- }, Pt = (e) => {
167
- var t;
168
- c || i || ((t = r.current) == null || t.focus(), k("formatBlock", e), me(e), l());
169
- }, xt = () => {
170
- var t;
171
- if (c || i) return;
326
+ const o = Xe();
327
+ o && M(Tl(o, e));
328
+ }, oo = () => {
329
+ if (!n.current || !tn || !d.typoAutoFix || l || i) return;
330
+ const e = n.current.innerHTML, t = ll(e);
331
+ t.html !== e && (ve(n.current, () => {
332
+ n.current && (n.current.innerHTML = t.html);
333
+ }), Me(t.html));
334
+ }, O = (e) => {
335
+ if (l || i) return;
336
+ if (T(n.current), e === "clearFormat") {
337
+ Gl(), u();
338
+ return;
339
+ }
340
+ if (e === "directionLtr" && n.current) {
341
+ $t(n.current, tr), u();
342
+ return;
343
+ }
344
+ if (e === "directionRtl" && n.current) {
345
+ $t(n.current, nr), u();
346
+ return;
347
+ }
348
+ if (e === "superscript" || e === "subscript") {
349
+ L(e), u();
350
+ return;
351
+ }
352
+ const t = Ft[e];
353
+ t && (t.value ? L(t.command, t.value) : L(t.command), u());
354
+ }, ro = (e) => {
355
+ l || i || (T(n.current), L("formatBlock", e), Ze(e), u());
356
+ }, lo = (e) => {
357
+ l || i || (T(n.current), Wl(e), Kn(e), u());
358
+ }, io = (e) => {
359
+ l || i || (T(n.current), Vl(e), st(e), u());
360
+ }, Ct = (e) => {
361
+ xn(e), Gn(e), ie(!0);
362
+ }, co = (e) => {
363
+ if (l || i) return;
364
+ Ct(e === Jo ? Qo : se);
365
+ }, we = () => {
366
+ if (l || i) return;
172
367
  const e = window.prompt("Enter URL:", "https://");
173
- e && ((t = r.current) == null || t.focus(), xn(e), l());
174
- }, He = async (e) => at && ae ? ae(e) : Bn(e), Bt = async () => {
175
- if (c || i) return;
368
+ e && (T(n.current), Kl(e), u());
369
+ }, Lt = async (e) => pn && $e ? $e(e) : Yl(e), so = async () => {
370
+ if (l || i) return;
176
371
  const e = document.createElement("input");
177
372
  e.type = "file", e.accept = "image/*", e.onchange = async () => {
178
- var o, s;
179
- const t = (o = e.files) == null ? void 0 : o[0];
373
+ var r;
374
+ const t = (r = e.files) == null ? void 0 : r[0];
180
375
  if (!t) return;
181
- const n = await He(t);
182
- (s = r.current) == null || s.focus(), te(n, t.name), l();
376
+ const o = await Lt(t);
377
+ T(n.current), xe(o, t.name), u();
183
378
  }, e.click();
184
- }, ye = () => {
185
- var t;
186
- if (c || i || !u.table) return;
187
- (t = r.current) == null || t.focus();
188
- const e = dn(Ye, Ze);
189
- if (y && u.trackChanges) {
190
- const n = J("insert", e, w);
191
- P([...I, n]), A(Ve(e, n.id));
379
+ }, Ot = () => {
380
+ if (l || i || !d.table) return;
381
+ T(n.current);
382
+ const e = il(ln, cn);
383
+ if (X && d.trackChanges) {
384
+ const t = ye("insert", e, w);
385
+ Q([...D, t]), M(zt(e, t.id));
192
386
  } else
193
- A(e);
194
- l();
195
- }, _e = () => {
196
- const e = O.current.undo();
197
- if (e === null || !r.current) {
198
- k("undo"), l();
387
+ M(e);
388
+ u();
389
+ }, Nt = () => {
390
+ const e = j.current.undo();
391
+ if (e === null || !n.current) {
392
+ L("undo"), u();
199
393
  return;
200
394
  }
201
- L(e);
202
- }, Ne = () => {
203
- const e = O.current.redo();
204
- if (e === null || !r.current) {
205
- k("redo"), l();
395
+ U(e);
396
+ }, It = () => {
397
+ const e = j.current.redo();
398
+ if (e === null || !n.current) {
399
+ L("redo"), u();
206
400
  return;
207
401
  }
208
- L(e);
209
- }, Ut = () => {
210
- var s;
211
- if (c || i || !u.comments) return;
402
+ U(e);
403
+ }, ao = (e) => {
404
+ l || i || (e.preventDefault(), he((t) => t.open ? { ...t, open: !1 } : t), at(!!(d.table && Xt())), Ie({ open: !0, x: e.clientX, y: e.clientY }));
405
+ }, uo = (e) => {
406
+ l || i || (e.preventDefault(), Ie((t) => t.open ? { ...t, open: !1 } : t), he({ open: !0, x: e.clientX, y: e.clientY }));
407
+ }, gt = () => {
408
+ if (l || i || !d.comments) return;
212
409
  const e = window.prompt("Comment:");
213
410
  if (!(e != null && e.trim())) return;
214
- const t = Ke("hl");
215
- if ((s = r.current) == null || s.focus(), !Tn(t)) return;
216
- const o = In(w, e.trim(), t);
217
- Y([o, ...E]), Z(!0), l();
218
- }, Se = (e) => {
219
- if (!r.current) return;
220
- const t = gn(r.current.innerHTML, e);
221
- L(t), P(
222
- I.map((n) => n.id === e ? { ...n, accepted: !0 } : n)
411
+ const t = xt("hl");
412
+ if (T(n.current), !pl(t)) return;
413
+ const r = Cl(w, e.trim(), t);
414
+ Ue([r, ...Z]), He(!0), u();
415
+ }, fo = [
416
+ {
417
+ id: wo,
418
+ label: Ho,
419
+ onSelect: () => ft(!0)
420
+ },
421
+ {
422
+ id: yo,
423
+ label: Po,
424
+ onSelect: () => ke(!0)
425
+ }
426
+ ], V = (e) => {
427
+ const t = Xt();
428
+ !t || !d.table || e(t) && u();
429
+ }, mo = [
430
+ ...d.table && Yn ? [
431
+ {
432
+ id: gr,
433
+ label: Ir,
434
+ onSelect: () => V((e) => Kt(e, "before"))
435
+ },
436
+ {
437
+ id: Ar,
438
+ label: hr,
439
+ onSelect: () => V((e) => Kt(e, "after"))
440
+ },
441
+ {
442
+ id: Rr,
443
+ label: br,
444
+ onSelect: () => V((e) => Wt(e, "before"))
445
+ },
446
+ {
447
+ id: Br,
448
+ label: Dr,
449
+ onSelect: () => V((e) => Wt(e, "after"))
450
+ },
451
+ {
452
+ id: Mr,
453
+ label: Sr,
454
+ onSelect: () => V((e) => cl(e))
455
+ },
456
+ {
457
+ id: Ur,
458
+ label: kr,
459
+ onSelect: () => V((e) => sl(e))
460
+ }
461
+ ] : [],
462
+ {
463
+ id: wr,
464
+ label: Hr,
465
+ onSelect: () => O("bold")
466
+ },
467
+ {
468
+ id: yr,
469
+ label: Pr,
470
+ onSelect: () => O("italic")
471
+ },
472
+ {
473
+ id: vr,
474
+ label: Fr,
475
+ onSelect: () => O("underline")
476
+ },
477
+ {
478
+ id: Xr,
479
+ label: xr,
480
+ onSelect: () => O("strikethrough")
481
+ },
482
+ {
483
+ id: Wr,
484
+ label: Kr,
485
+ onSelect: () => O("heading2")
486
+ },
487
+ {
488
+ id: Gr,
489
+ label: Vr,
490
+ onSelect: () => O("bulletList")
491
+ },
492
+ {
493
+ id: zr,
494
+ label: Yr,
495
+ onSelect: () => O("orderedList")
496
+ },
497
+ {
498
+ id: $r,
499
+ label: jr,
500
+ onSelect: () => we()
501
+ },
502
+ {
503
+ id: Zr,
504
+ label: qr,
505
+ onSelect: () => O("clearFormat")
506
+ },
507
+ {
508
+ id: Jr,
509
+ label: Qr,
510
+ disabled: !d.findReplace,
511
+ onSelect: () => ie(!0)
512
+ },
513
+ {
514
+ id: tl,
515
+ label: el,
516
+ disabled: !d.signature,
517
+ onSelect: () => Le(!0)
518
+ },
519
+ {
520
+ id: ol,
521
+ label: nl,
522
+ disabled: !d.comments,
523
+ onSelect: () => gt()
524
+ },
525
+ ...Tt ? [
526
+ {
527
+ id: Uo,
528
+ label: ko,
529
+ onSelect: () => ke(!1)
530
+ }
531
+ ] : []
532
+ ], ht = (e) => {
533
+ if (!n.current) return;
534
+ const t = _l(n.current.innerHTML, e);
535
+ U(t), Q(
536
+ D.map((o) => o.id === e ? { ...o, accepted: !0 } : o)
223
537
  );
224
- }, Re = (e) => {
225
- if (!r.current) return;
226
- const t = hn(r.current.innerHTML, e);
227
- L(t), P(
228
- I.map((n) => n.id === e ? { ...n, rejected: !0 } : n)
538
+ }, At = (e) => {
539
+ if (!n.current) return;
540
+ const t = ml(n.current.innerHTML, e);
541
+ U(t), Q(
542
+ D.map((o) => o.id === e ? { ...o, rejected: !0 } : o)
229
543
  );
230
- }, ve = async (e) => {
231
- const t = await He(e), n = `<img src="${t}" alt="" style="max-width:100%;height:auto;" />`;
232
- if (y && u.trackChanges) {
233
- const o = J("insert", n, w);
234
- P([...I, o]), A(Ve(n, o.id));
544
+ }, bt = async (e) => {
545
+ const t = await Lt(e), o = `<img src="${t}" alt="" style="max-width:100%;height:auto;" />`;
546
+ if (X && d.trackChanges) {
547
+ const r = ye("insert", o, w);
548
+ Q([...D, r]), M(zt(o, r.id));
235
549
  } else
236
- te(t);
237
- l();
238
- }, Dt = async (e) => {
239
- if (c || i) return;
550
+ xe(t);
551
+ u();
552
+ }, _o = async (e) => {
553
+ if (l || i) return;
240
554
  const t = e.clipboardData;
241
555
  if (!t) return;
242
- if (mt) {
243
- const o = Hn(t);
244
- if (o) {
556
+ if (On) {
557
+ const r = gl(t);
558
+ if (r) {
245
559
  e.preventDefault();
246
- const p = yn(o);
247
- p && (A(p), l());
248
- const b = t.items;
249
- if (oe && b)
250
- for (const x of Array.from(b)) {
251
- if (!x.type.startsWith("image/")) continue;
252
- const B = x.getAsFile();
253
- B && await ve(B);
560
+ const E = hl(r);
561
+ E && (M(E), u());
562
+ const N = t.items;
563
+ if (We && N)
564
+ for (const H of Array.from(N)) {
565
+ if (!H.type.startsWith("image/")) continue;
566
+ const B = H.getAsFile();
567
+ B && await bt(B);
254
568
  }
255
569
  return;
256
570
  }
257
- const s = _n(t);
571
+ const s = Al(t);
258
572
  if (s) {
259
- e.preventDefault(), A(s.replace(/\n/g, "<br />")), l();
573
+ e.preventDefault(), M(s.replace(/\n/g, "<br />")), u();
260
574
  return;
261
575
  }
262
576
  }
263
- if (!oe) return;
264
- const n = t.items;
265
- if (n)
266
- for (const o of Array.from(n)) {
267
- if (!o.type.startsWith("image/")) continue;
577
+ if (!We) return;
578
+ const o = t.items;
579
+ if (o)
580
+ for (const r of Array.from(o)) {
581
+ if (!r.type.startsWith("image/")) continue;
268
582
  e.preventDefault();
269
- const s = o.getAsFile();
270
- s && await ve(s);
583
+ const s = r.getAsFile();
584
+ s && await bt(s);
585
+ }
586
+ }, To = (e) => {
587
+ O(e);
588
+ }, Eo = (e) => {
589
+ if (e.key === xo && R.visible && R.suggestion) {
590
+ e.preventDefault(), pt();
591
+ return;
592
+ }
593
+ if (e.key === Xo) {
594
+ b();
595
+ return;
596
+ }
597
+ if (Xl(e.nativeEvent)) {
598
+ u();
599
+ return;
600
+ }
601
+ if (e.key === Ko) {
602
+ if (R.visible) {
603
+ e.preventDefault(), b();
604
+ return;
271
605
  }
272
- }, Ft = (e) => {
273
- e.key === "Escape" && F([]), (e.metaKey || e.ctrlKey) && e.key === "z" && (e.preventDefault(), e.shiftKey ? Ne() : _e());
274
- }, Kt = (e) => {
275
- var n, o;
276
- (n = r.current) == null || n.focus();
606
+ le([]), W((t) => t.open ? { ...t, open: !1 } : t);
607
+ }
608
+ (e.metaKey || e.ctrlKey) && e.key === Wo && (e.preventDefault(), e.shiftKey ? It() : Nt());
609
+ }, po = (e) => {
610
+ var o;
611
+ T(n.current);
277
612
  const t = window.getSelection();
278
613
  if ((o = t == null ? void 0 : t.anchorNode) != null && o.textContent) {
279
- const p = t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/, " ");
280
- t.anchorNode.nodeType === Node.TEXT_NODE && (t.anchorNode.textContent = p);
614
+ const s = t.anchorNode.textContent.replace(/(?:^|\s)\/[^\s]*$/, " ");
615
+ t.anchorNode.nodeType === Node.TEXT_NODE && (t.anchorNode.textContent = s);
281
616
  }
282
- switch (F([]), e.insert) {
617
+ switch (le([]), e.insert) {
283
618
  case "heading1":
284
- k("formatBlock", "h1");
619
+ L("formatBlock", "h1");
285
620
  break;
286
621
  case "heading2":
287
- k("formatBlock", "h2");
622
+ L("formatBlock", "h2");
288
623
  break;
289
624
  case "bulletList":
290
- k("insertUnorderedList");
625
+ L("insertUnorderedList");
291
626
  break;
292
627
  case "orderedList":
293
- k("insertOrderedList");
628
+ L("insertOrderedList");
294
629
  break;
295
630
  case "table":
296
- ye();
631
+ Ot();
297
632
  return;
298
633
  case "ai":
299
- q(!0);
634
+ Ce(!0);
300
635
  break;
301
636
  }
302
- l();
303
- }, Oe = (e) => {
304
- if (!r.current) return;
305
- const t = window.getSelection(), n = Me((t == null ? void 0 : t.anchorNode) ?? null, r.current);
306
- n && fn(n, e) && (l(), K());
307
- }, Mt = (e, t) => {
637
+ u();
638
+ }, Rt = (e) => {
639
+ if (!n.current) return;
640
+ const t = window.getSelection(), o = ee((t == null ? void 0 : t.anchorNode) ?? null, n.current);
641
+ o && ul(o, e) && (u(), J());
642
+ }, Co = (e) => {
643
+ if (!n.current) return;
644
+ const t = window.getSelection(), o = ee((t == null ? void 0 : t.anchorNode) ?? null, n.current), r = n.current.querySelector(`.${Lr}`), s = o ?? (r instanceof HTMLElement ? r : null);
645
+ if (!s) {
646
+ e.preventDefault();
647
+ return;
648
+ }
649
+ k.current = s, Pe(n.current), Vt(n.current, s), al(s), e.dataTransfer.setData(ti, ni), e.dataTransfer.effectAllowed = Qt;
650
+ }, Lo = (e) => {
651
+ if (!n.current || !k.current) return;
652
+ e.preventDefault(), e.dataTransfer.dropEffect = Qt;
653
+ const t = ee(e.target, n.current);
654
+ if (!t || t === k.current) {
655
+ Yt(n.current, null, null);
656
+ return;
657
+ }
658
+ const o = Gt(e.clientY, t);
659
+ Yt(n.current, t, o);
660
+ }, Oo = (e) => {
661
+ if (!n.current || !k.current) return;
662
+ e.preventDefault();
663
+ const t = ee(e.target, n.current), o = k.current;
664
+ t && t !== o && (Gt(e.clientY, t) === er ? dl(o, t) : fl(o, t)) && (u(), J()), Pe(n.current), k.current = null;
665
+ }, No = () => {
666
+ n.current && Pe(n.current), k.current = null;
667
+ }, Io = (e, t) => {
308
668
  if (e === "divider")
309
- return /* @__PURE__ */ a("span", { className: sn }, `divider-${t}`);
669
+ return /* @__PURE__ */ c("span", { className: pr }, `divider-${t}`);
310
670
  if (e === "headingDropdown")
311
- return /* @__PURE__ */ a(
312
- Un,
671
+ return /* @__PURE__ */ c(
672
+ ae,
313
673
  {
314
674
  title: "Heading",
315
- options: an,
316
- value: pt || "p",
317
- disabled: c || i,
318
- onChange: Pt
675
+ options: Cr,
676
+ value: In || "p",
677
+ disabled: l || i,
678
+ onChange: ro
319
679
  },
320
680
  "heading"
321
681
  );
682
+ if (e === Mt)
683
+ return /* @__PURE__ */ c(
684
+ ae,
685
+ {
686
+ title: Yo,
687
+ options: Go,
688
+ value: Xn,
689
+ disabled: l || i,
690
+ onChange: lo
691
+ },
692
+ Mt
693
+ );
694
+ if (e === kt)
695
+ return /* @__PURE__ */ c(
696
+ ae,
697
+ {
698
+ title: $o,
699
+ options: jo,
700
+ value: Wn,
701
+ disabled: l || i,
702
+ onChange: io
703
+ },
704
+ kt
705
+ );
322
706
  if (e === "textColor")
323
- return /* @__PURE__ */ a(
324
- je,
707
+ return /* @__PURE__ */ c(
708
+ qt,
325
709
  {
326
710
  title: "Text color",
327
711
  type: "text",
328
- value: Ct,
329
- disabled: c || i,
330
- onChange: (o) => {
331
- var s;
332
- (s = r.current) == null || s.focus(), vn(o), kt(o), l();
712
+ value: An,
713
+ disabled: l || i,
714
+ onChange: (r) => {
715
+ T(n.current), Pl(r), bn(r), u();
333
716
  }
334
717
  },
335
718
  "textColor"
336
719
  );
337
720
  if (e === "highlightColor")
338
- return /* @__PURE__ */ a(
339
- je,
721
+ return /* @__PURE__ */ c(
722
+ qt,
340
723
  {
341
724
  title: "Highlight color",
342
725
  type: "highlight",
343
- value: Tt,
344
- disabled: c || i,
345
- onChange: (o) => {
346
- var s;
347
- (s = r.current) == null || s.focus(), On(o), It(o), l();
726
+ value: Rn,
727
+ disabled: l || i,
728
+ onChange: (r) => {
729
+ T(n.current), yl(r), Dn(r), u();
348
730
  }
349
731
  },
350
732
  "highlightColor"
351
733
  );
352
734
  if (e === "link")
353
- return /* @__PURE__ */ a(
354
- h,
735
+ return /* @__PURE__ */ c(
736
+ C,
355
737
  {
356
- icon: f.link,
738
+ icon: m.link,
357
739
  title: "Insert link",
358
- disabled: c || i,
359
- onClick: xt
740
+ disabled: l || i,
741
+ onClick: we
360
742
  },
361
743
  "link"
362
744
  );
363
745
  if (e === "image")
364
- return /* @__PURE__ */ a(
365
- h,
746
+ return /* @__PURE__ */ c(
747
+ C,
366
748
  {
367
- icon: f.image,
749
+ icon: m.image,
368
750
  title: "Insert image",
369
- disabled: c || i,
751
+ disabled: l || i,
370
752
  onClick: () => {
371
- Bt();
753
+ so();
372
754
  }
373
755
  },
374
756
  "image"
375
757
  );
376
758
  if (e === "table")
377
- return u.table ? /* @__PURE__ */ a(
378
- h,
759
+ return d.table ? /* @__PURE__ */ c(
760
+ C,
379
761
  {
380
- icon: f.table,
762
+ icon: m.table,
381
763
  title: "Insert table",
382
- disabled: c || i,
383
- onClick: ye
764
+ disabled: l || i,
765
+ onClick: Ot
384
766
  },
385
767
  "table"
386
768
  ) : null;
387
- if (e === xe)
388
- return u.signature ? /* @__PURE__ */ a(
389
- h,
769
+ if (e === Ut)
770
+ return d.signature ? /* @__PURE__ */ c(
771
+ C,
390
772
  {
391
- icon: f.signature,
773
+ icon: m.signature,
392
774
  title: "Sign pad",
393
- active: Ie,
394
- disabled: c || i,
395
- onClick: () => be(!0)
775
+ active: ct,
776
+ disabled: l || i,
777
+ onClick: () => Le(!0)
396
778
  },
397
- xe
779
+ Ut
398
780
  ) : null;
399
- if (e === Be)
400
- return u.findReplace ? /* @__PURE__ */ a(
401
- h,
781
+ if (e === Ht)
782
+ return d.findReplace ? /* @__PURE__ */ c(
783
+ C,
402
784
  {
403
- icon: f.findReplace,
785
+ icon: m.findReplace,
404
786
  title: "Find and replace",
405
- active: Ae,
406
- disabled: c || i,
407
- onClick: () => Le((o) => !o)
787
+ active: Oe,
788
+ disabled: l || i,
789
+ onClick: () => {
790
+ Oe ? ie(!1) : Ct(se);
791
+ }
408
792
  },
409
- Be
793
+ Ht
410
794
  ) : null;
411
- if (e === Ue)
412
- return u.horizontalRule ? /* @__PURE__ */ a(
413
- h,
795
+ if (e === wt)
796
+ return d.findReplace ? /* @__PURE__ */ c(
797
+ ae,
414
798
  {
415
- icon: f.horizontalRule,
799
+ title: Zo,
800
+ options: qo,
801
+ value: Vn,
802
+ disabled: l || i,
803
+ onChange: co
804
+ },
805
+ wt
806
+ ) : null;
807
+ if (e === Pt)
808
+ return d.horizontalRule ? /* @__PURE__ */ c(
809
+ C,
810
+ {
811
+ icon: m.horizontalRule,
416
812
  title: "Horizontal rule",
417
- disabled: c || i,
813
+ disabled: l || i,
418
814
  onClick: () => {
419
- var o;
420
- (o = r.current) == null || o.focus(), A("<hr />"), l();
815
+ T(n.current), M("<hr />"), u();
421
816
  }
422
817
  },
423
- Ue
818
+ Pt
424
819
  ) : null;
425
820
  if (e === "undo")
426
- return /* @__PURE__ */ a(
427
- h,
821
+ return /* @__PURE__ */ c(
822
+ C,
428
823
  {
429
- icon: f.undo,
824
+ icon: m.undo,
430
825
  title: "Undo",
431
- disabled: c || i,
432
- onClick: _e
826
+ disabled: l || i,
827
+ onClick: Nt
433
828
  },
434
829
  "undo"
435
830
  );
436
831
  if (e === "redo")
437
- return /* @__PURE__ */ a(
438
- h,
832
+ return /* @__PURE__ */ c(
833
+ C,
439
834
  {
440
- icon: f.redo,
835
+ icon: m.redo,
441
836
  title: "Redo",
442
- disabled: c || i,
443
- onClick: Ne
837
+ disabled: l || i,
838
+ onClick: It
444
839
  },
445
840
  "redo"
446
841
  );
447
842
  if (e === "trackChanges")
448
- return u.trackChanges ? /* @__PURE__ */ a(
449
- h,
843
+ return d.trackChanges ? /* @__PURE__ */ c(
844
+ C,
450
845
  {
451
- icon: f.trackChanges,
846
+ icon: m.trackChanges,
452
847
  title: "Track changes",
453
- active: y,
454
- disabled: c || i,
455
- onClick: () => Rt(!y)
848
+ active: X,
849
+ disabled: l || i,
850
+ onClick: () => eo(!X)
456
851
  },
457
852
  "trackChanges"
458
853
  ) : null;
459
854
  if (e === "comments")
460
- return u.comments ? /* @__PURE__ */ a(
461
- h,
855
+ return d.comments ? /* @__PURE__ */ c(
856
+ C,
462
857
  {
463
- icon: f.comments,
858
+ icon: m.comments,
464
859
  title: "Comments",
465
- active: X,
466
- disabled: c || i,
860
+ active: Re,
861
+ disabled: l || i,
467
862
  onClick: () => {
468
- X ? Z(!1) : Ut();
863
+ Re ? He(!1) : gt();
469
864
  }
470
865
  },
471
866
  "comments"
472
867
  ) : null;
473
868
  if (e === "ai")
474
- return !u.ai || !(d != null && d.enabled) ? null : /* @__PURE__ */ a(
475
- h,
869
+ return !d.ai || !(f != null && f.enabled) ? null : /* @__PURE__ */ c(
870
+ C,
476
871
  {
477
- icon: f.ai,
872
+ icon: m.ai,
478
873
  title: "Ink AI",
479
- active: ge,
480
- disabled: c || i,
481
- onClick: () => q((o) => !o)
874
+ active: nt,
875
+ disabled: l || i,
876
+ onClick: () => Ce((r) => !r)
482
877
  },
483
878
  "ai"
484
879
  );
485
- const n = De[e];
486
- return n ? /* @__PURE__ */ a(
487
- h,
880
+ const o = Ft[e];
881
+ return o ? /* @__PURE__ */ c(
882
+ C,
488
883
  {
489
- icon: f[e] ?? e.slice(0, 1).toUpperCase(),
490
- title: n.title,
491
- active: dt.has(e),
492
- disabled: c || i,
493
- onClick: () => Et(e)
884
+ icon: m[e] ?? e.slice(0, 1).toUpperCase(),
885
+ title: o.title,
886
+ active: qe.has(e),
887
+ disabled: l || i,
888
+ onClick: () => O(e)
494
889
  },
495
890
  e
496
891
  ) : null;
497
- }, Vt = typeof V == "number" ? `${V}px` : V, jt = typeof j == "number" ? `${j}px` : j, Gt = !!(d != null && d.enabled && ge);
498
- return /* @__PURE__ */ M(
892
+ }, go = typeof ue == "number" ? `${ue}px` : ue, ho = typeof de == "number" ? `${de}px` : de, Ao = !!(f != null && f.enabled && nt);
893
+ return /* @__PURE__ */ ce(
499
894
  "div",
500
895
  {
501
- className: un(ln, We),
502
- "data-testid": $e,
503
- "data-disabled": c || void 0,
504
- "data-variant": qe,
505
- "data-premium": H.active || void 0,
506
- "data-wysiwyg": lt || void 0,
507
- style: { ...ut, ...rt },
508
- ...ot,
896
+ className: rl(Or, Jt),
897
+ "data-testid": en,
898
+ "data-disabled": l || void 0,
899
+ "data-variant": Ye,
900
+ "data-chrome": nn,
901
+ "data-color-mode": De,
902
+ "data-premium": v.active || void 0,
903
+ "data-wysiwyg": Cn || void 0,
904
+ style: { ...Ln, ...fn },
905
+ ...mn,
509
906
  children: [
510
- /* @__PURE__ */ a("div", { className: tn, role: "toolbar", "aria-label": "Ink formatting toolbar", children: Ge.map(Mt) }),
511
- /* @__PURE__ */ a(
512
- jn,
907
+ Tt ? /* @__PURE__ */ c("div", { className: dr, children: /* @__PURE__ */ c(
908
+ wl,
909
+ {
910
+ type: "button",
911
+ "aria-label": So,
912
+ onClick: () => ke(!1),
913
+ children: Bo
914
+ }
915
+ ) }) : /* @__PURE__ */ c(
916
+ "div",
513
917
  {
514
- open: Ie,
515
- onClose: () => be(!1),
918
+ className: fr,
919
+ role: "toolbar",
920
+ "aria-label": "Ink formatting toolbar",
921
+ onContextMenu: uo,
922
+ children: be.map(Io)
923
+ }
924
+ ),
925
+ /* @__PURE__ */ c(
926
+ _i,
927
+ {
928
+ open: jn,
929
+ options: qn,
930
+ visibleItems: be,
931
+ onToggle: Jn,
932
+ onClose: () => ft(!1)
933
+ }
934
+ ),
935
+ /* @__PURE__ */ c(
936
+ fi,
937
+ {
938
+ open: ct,
939
+ onClose: () => Le(!1),
516
940
  onConfirm: (e) => {
517
- var t;
518
- (t = r.current) == null || t.focus(), te(e), l();
941
+ T(n.current), xe(e), u();
519
942
  }
520
943
  }
521
944
  ),
522
- /* @__PURE__ */ a(
523
- Gn,
945
+ /* @__PURE__ */ c(
946
+ mi,
524
947
  {
525
- open: Ae,
526
- onClose: () => Le(!1),
527
- onReplace: (e, t, n) => {
528
- if (!r.current) return;
529
- const o = Rn(r.current.innerHTML, e, t, n);
530
- L(o);
948
+ open: Oe,
949
+ focusField: vn,
950
+ onClose: () => ie(!1),
951
+ onReplace: (e, t, o) => {
952
+ if (!n.current) return;
953
+ const r = Dl(n.current.innerHTML, e, t, o);
954
+ U(r);
531
955
  }
532
956
  }
533
957
  ),
534
- y && u.trackChanges ? /* @__PURE__ */ a(
535
- Vn,
958
+ X && d.trackChanges ? /* @__PURE__ */ c(
959
+ di,
536
960
  {
537
- changes: I,
538
- onAccept: Se,
539
- onReject: Re,
540
- onAcceptAll: () => I.forEach((e) => Se(e.id)),
541
- onRejectAll: () => I.forEach((e) => Re(e.id))
961
+ changes: D,
962
+ onAccept: ht,
963
+ onReject: At,
964
+ onAcceptAll: () => D.forEach((e) => ht(e.id)),
965
+ onRejectAll: () => D.forEach((e) => At(e.id))
542
966
  }
543
967
  ) : null,
544
- /* @__PURE__ */ M("div", { className: nn, children: [
545
- /* @__PURE__ */ M("div", { className: rn, children: [
546
- u.blocks ? /* @__PURE__ */ a(
547
- Kn,
968
+ Ye === "agent" ? /* @__PURE__ */ c("div", { className: "Ink-Editor__agent-bar", role: "status", children: Mo }) : null,
969
+ /* @__PURE__ */ ce("div", { className: mr, children: [
970
+ /* @__PURE__ */ ce("div", { className: _r, children: [
971
+ d.blocks ? /* @__PURE__ */ c(
972
+ ei,
548
973
  {
549
- visible: _t && !c && !i,
550
- top: Ht,
551
- onMoveUp: () => Oe("up"),
552
- onMoveDown: () => Oe("down")
974
+ visible: Pn && !l && !i,
975
+ top: Hn,
976
+ onMoveUp: () => Rt("up"),
977
+ onMoveDown: () => Rt("down"),
978
+ onDragStart: Co
553
979
  }
554
980
  ) : null,
555
- /* @__PURE__ */ a(
981
+ /* @__PURE__ */ c(
556
982
  "div",
557
983
  {
558
- ref: r,
559
- className: on,
560
- contentEditable: !c && !i,
984
+ ref: n,
985
+ className: Tr,
986
+ contentEditable: !l && !i,
561
987
  role: "textbox",
562
988
  "aria-multiline": "true",
563
- "aria-placeholder": re,
564
- "data-placeholder": re,
989
+ "aria-placeholder": Ke,
990
+ "data-placeholder": Ke,
565
991
  suppressContentEditableWarning: !0,
566
- style: { minHeight: Vt, maxHeight: jt },
567
- onInput: l,
568
- onBlur: Ot,
569
- onKeyUp: K,
570
- onKeyDown: Ft,
571
- onMouseUp: K,
992
+ style: { minHeight: go, maxHeight: ho },
993
+ onInput: u,
994
+ onBlur: oo,
995
+ onKeyUp: J,
996
+ onKeyDown: Eo,
997
+ onMouseUp: J,
998
+ onContextMenu: ao,
999
+ onDragOver: Lo,
1000
+ onDrop: Oo,
1001
+ onDragEnd: No,
572
1002
  onPaste: (e) => {
573
- Dt(e);
1003
+ _o(e);
1004
+ }
1005
+ }
1006
+ ),
1007
+ _t ? /* @__PURE__ */ c(
1008
+ ui,
1009
+ {
1010
+ items: yn,
1011
+ top: it.top,
1012
+ left: it.left,
1013
+ onSelect: po
1014
+ }
1015
+ ) : null,
1016
+ Be ? /* @__PURE__ */ c(
1017
+ ql,
1018
+ {
1019
+ suggestion: R.suggestion,
1020
+ position: { top: R.top, left: R.left },
1021
+ visible: R.visible,
1022
+ onAccept: pt,
1023
+ onDismiss: b
1024
+ }
1025
+ ) : null,
1026
+ /* @__PURE__ */ c(
1027
+ oi,
1028
+ {
1029
+ open: Ae.open,
1030
+ top: Ae.top,
1031
+ left: Ae.left,
1032
+ icons: {
1033
+ bold: m.bold,
1034
+ italic: m.italic,
1035
+ underline: m.underline,
1036
+ code: m.code,
1037
+ link: m.link,
1038
+ clearFormat: m.clearFormat
1039
+ },
1040
+ activeFormats: qe,
1041
+ disabled: l || i,
1042
+ onFormat: To,
1043
+ onLink: we,
1044
+ onClose: () => W((e) => ({ ...e, open: !1 }))
1045
+ }
1046
+ ),
1047
+ /* @__PURE__ */ c(
1048
+ jt,
1049
+ {
1050
+ open: Ne.open,
1051
+ x: Ne.x,
1052
+ y: Ne.y,
1053
+ items: mo,
1054
+ colorMode: De,
1055
+ onClose: () => {
1056
+ at(!1), Ie((e) => ({ ...e, open: !1 }));
574
1057
  }
575
1058
  }
576
1059
  ),
577
- we ? /* @__PURE__ */ a(
578
- Mn,
1060
+ /* @__PURE__ */ c(
1061
+ jt,
579
1062
  {
580
- items: Nt,
581
- top: Te.top,
582
- left: Te.left,
583
- onSelect: Kt
1063
+ open: ge.open,
1064
+ x: ge.x,
1065
+ y: ge.y,
1066
+ items: fo,
1067
+ colorMode: De,
1068
+ onClose: () => he((e) => ({ ...e, open: !1 }))
584
1069
  }
585
- ) : null
1070
+ )
586
1071
  ] }),
587
- X && u.comments ? /* @__PURE__ */ a(
588
- Dn,
1072
+ Re && d.comments ? /* @__PURE__ */ c(
1073
+ jl,
589
1074
  {
590
- comments: E,
1075
+ comments: Z,
591
1076
  author: w,
592
- onClose: () => Z(!1),
1077
+ onClose: () => He(!1),
593
1078
  onResolve: (e) => {
594
- const t = E.find((n) => n.id === e);
595
- Y(
596
- E.map(
597
- (n) => n.id === e ? { ...n, resolved: !0 } : n
1079
+ const t = Z.find((o) => o.id === e);
1080
+ Ue(
1081
+ Z.map(
1082
+ (o) => o.id === e ? { ...o, resolved: !0 } : o
598
1083
  )
599
- ), t && r.current && L(kn(r.current.innerHTML, t.highlightId));
1084
+ ), t && n.current && U(El(n.current.innerHTML, t.highlightId));
600
1085
  },
601
1086
  onAddReply: (e, t) => {
602
- Y(
603
- E.map(
604
- (n) => n.id === e ? {
605
- ...n,
1087
+ Ue(
1088
+ Z.map(
1089
+ (o) => o.id === e ? {
1090
+ ...o,
606
1091
  replies: [
607
- ...n.replies,
1092
+ ...o.replies,
608
1093
  {
609
- id: Ke("reply"),
1094
+ id: xt("reply"),
610
1095
  author: w,
611
1096
  body: t,
612
1097
  timestamp: Date.now()
613
1098
  }
614
1099
  ]
615
- } : n
1100
+ } : o
616
1101
  )
617
1102
  );
618
1103
  }
619
1104
  }
620
1105
  ) : null,
621
- Gt && d ? /* @__PURE__ */ a(
622
- Fn,
1106
+ Ao && f ? /* @__PURE__ */ c(
1107
+ $l,
623
1108
  {
624
- config: d,
625
- documentHtml: ((Ee = r.current) == null ? void 0 : Ee.innerHTML) ?? g ?? "",
626
- selectionHtml: Ce,
627
- onClose: () => q(!1),
1109
+ config: f,
1110
+ documentHtml: ((Dt = n.current) == null ? void 0 : Dt.innerHTML) ?? p ?? "",
1111
+ selectionHtml: rt,
1112
+ onBusyChange: kn,
1113
+ onClose: () => Ce(!1),
628
1114
  onApplyHtml: (e) => {
629
- var t;
630
- if ((t = r.current) == null || t.focus(), Ce)
631
- A(e);
1115
+ if (T(n.current), rt)
1116
+ M(e);
632
1117
  else {
633
- L(e);
1118
+ U(e);
634
1119
  return;
635
1120
  }
636
- l();
1121
+ u();
637
1122
  }
638
1123
  }
639
1124
  ) : null
640
1125
  ] }),
641
- ce ? /* @__PURE__ */ M("div", { className: cn, children: [
642
- ht,
643
- ie ? ` / ${ie}` : ""
1126
+ Ve ? /* @__PURE__ */ ce("div", { className: Er, children: [
1127
+ gn,
1128
+ Ge ? ` / ${Ge}` : ""
644
1129
  ] }) : null
645
1130
  ]
646
1131
  }
647
1132
  );
648
1133
  };
649
1134
  export {
650
- br as InkEditor
1135
+ Tc as InkEditor
651
1136
  };