@prolibu-suite/cobalt-core 0.2.0 → 0.3.0

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 (590) hide show
  1. package/custom-elements.json +15675 -11199
  2. package/dist/cjs/co-accordion.cjs.entry.js +3 -3
  3. package/dist/cjs/co-app-shell.cjs.entry.js +4 -4
  4. package/dist/cjs/co-autocomplete.cjs.entry.js +10 -7
  5. package/dist/cjs/co-avatar-group.cjs.entry.js +77 -0
  6. package/dist/cjs/co-avatar.cjs.entry.js +6 -4
  7. package/dist/cjs/co-badge.cjs.entry.js +2 -2
  8. package/dist/cjs/co-bottom-sheet.cjs.entry.js +325 -0
  9. package/dist/cjs/co-button-group.cjs.entry.js +3 -3
  10. package/dist/cjs/co-button.cjs.entry.js +6 -6
  11. package/dist/cjs/co-calendar-month.cjs.entry.js +381 -0
  12. package/dist/cjs/co-calendar_3.cjs.entry.js +11 -11
  13. package/dist/cjs/co-card.cjs.entry.js +3 -3
  14. package/dist/cjs/co-checkbox-group.cjs.entry.js +5 -5
  15. package/dist/cjs/co-checkbox.cjs.entry.js +5 -5
  16. package/dist/cjs/co-chip.cjs.entry.js +11 -8
  17. package/dist/cjs/co-color-picker.cjs.entry.js +7 -5
  18. package/dist/cjs/co-column-picker.cjs.entry.js +3 -3
  19. package/dist/cjs/co-combobox.cjs.entry.js +7 -7
  20. package/dist/cjs/co-command-search.cjs.entry.js +151 -12
  21. package/dist/cjs/co-data-table-pagination.cjs.entry.js +5 -5
  22. package/dist/cjs/co-data-table.cjs.entry.js +25 -11
  23. package/dist/cjs/co-date-picker.cjs.entry.js +2 -2
  24. package/dist/cjs/co-date-range-picker.cjs.entry.js +3 -3
  25. package/dist/cjs/co-date-range.cjs.entry.js +2 -2
  26. package/dist/cjs/co-empty-state.cjs.entry.js +2 -2
  27. package/dist/cjs/co-event-calendar.cjs.entry.js +318 -0
  28. package/dist/cjs/co-fab.cjs.entry.js +3 -3
  29. package/dist/cjs/co-file-field.cjs.entry.js +8 -8
  30. package/dist/cjs/co-helper-text.cjs.entry.js +3 -3
  31. package/dist/cjs/co-icon-button.cjs.entry.js +5 -5
  32. package/dist/cjs/co-icon.cjs.entry.js +33 -25
  33. package/dist/cjs/co-input.cjs.entry.js +6 -6
  34. package/dist/cjs/co-json-field.cjs.entry.js +10 -6
  35. package/dist/cjs/co-lightbox.cjs.entry.js +5 -5
  36. package/dist/cjs/co-list-footer.cjs.entry.js +25 -0
  37. package/dist/cjs/co-list-item.cjs.entry.js +60 -4
  38. package/dist/cjs/co-loader_2.cjs.entry.js +293 -0
  39. package/dist/cjs/co-menu-divider.cjs.entry.js +2 -2
  40. package/dist/cjs/co-menu-item.cjs.entry.js +17 -10
  41. package/dist/cjs/co-menu.cjs.entry.js +2 -2
  42. package/dist/cjs/co-modal.cjs.entry.js +16 -4
  43. package/dist/cjs/co-navbar.cjs.entry.js +3 -3
  44. package/dist/cjs/co-number-field.cjs.entry.js +18 -6
  45. package/dist/cjs/co-page-header.cjs.entry.js +2 -2
  46. package/dist/cjs/co-phone-field.cjs.entry.js +6 -4
  47. package/dist/cjs/co-popover.cjs.entry.js +45 -14
  48. package/dist/cjs/co-progress-bar.cjs.entry.js +8 -4
  49. package/dist/cjs/co-progress-circle.cjs.entry.js +3 -3
  50. package/dist/cjs/co-radio-group.cjs.entry.js +4 -4
  51. package/dist/cjs/co-radio.cjs.entry.js +4 -4
  52. package/dist/cjs/co-rating.cjs.entry.js +4 -4
  53. package/dist/cjs/co-ref-field.cjs.entry.js +36 -13
  54. package/dist/cjs/co-rich-text-editor.cjs.entry.js +1879 -33
  55. package/dist/cjs/co-rich-text-toolbar.cjs.entry.js +995 -71
  56. package/dist/cjs/co-rich-text-viewer.cjs.entry.js +55 -19
  57. package/dist/cjs/co-row.cjs.entry.js +3 -3
  58. package/dist/cjs/co-select.cjs.entry.js +8 -8
  59. package/dist/cjs/co-separator.cjs.entry.js +2 -2
  60. package/dist/cjs/co-sidebar-nav.cjs.entry.js +29 -9
  61. package/dist/cjs/co-sidebar.cjs.entry.js +3 -3
  62. package/dist/cjs/co-skeleton.cjs.entry.js +26 -0
  63. package/dist/cjs/co-slider.cjs.entry.js +3 -3
  64. package/dist/cjs/co-switch.cjs.entry.js +6 -6
  65. package/dist/cjs/co-tab-group.cjs.entry.js +2 -2
  66. package/dist/cjs/co-tab.cjs.entry.js +3 -3
  67. package/dist/cjs/co-tags-field.cjs.entry.js +19 -13
  68. package/dist/cjs/co-textarea.cjs.entry.js +11 -7
  69. package/dist/cjs/co-toast.cjs.entry.js +2 -2
  70. package/dist/cjs/co-toggle-button-group.cjs.entry.js +4 -4
  71. package/dist/cjs/co-toggle-button.cjs.entry.js +4 -4
  72. package/dist/cjs/co-tooltip.cjs.entry.js +51 -16
  73. package/dist/cjs/co-transfer-list.cjs.entry.js +3 -3
  74. package/dist/cjs/co-video.cjs.entry.js +839 -0
  75. package/dist/cjs/cobalt.cjs.js +2 -2
  76. package/dist/cjs/fieldChip-CDIMz_Y6.js +7 -0
  77. package/dist/cjs/{index-CaEJnpZe.js → index-5NdsiFjZ.js} +14509 -6317
  78. package/dist/cjs/{index-DoFnrUVH.js → index-BumlM92r.js} +45 -21
  79. package/dist/cjs/loader.cjs.js +2 -2
  80. package/dist/cjs/overlayAfterClose-BdeXrhVY.js +12 -0
  81. package/dist/{esm/sanitizer-DcK0GGZC.js → cjs/purify.es-DX41ZWS2.js} +3 -107
  82. package/dist/cjs/{requiredMark-DA6y-4rp.js → requiredMark-CqMGt1H1.js} +1 -1
  83. package/dist/cjs/richTextI18n-B7ktXg3M.js +382 -0
  84. package/dist/cjs/toolbar-config-3PlT-3zm.js +216 -0
  85. package/dist/cjs/tz-Dgom0W69.js +127 -0
  86. package/dist/cobalt/cobalt.css +1 -1
  87. package/dist/cobalt/cobalt.esm.js +1 -1
  88. package/dist/cobalt/p-0a506c9d.entry.js +1 -0
  89. package/dist/cobalt/p-0bb55163.entry.js +1 -0
  90. package/dist/cobalt/{p-6404bd21.entry.js → p-0e8c0d87.entry.js} +1 -1
  91. package/dist/cobalt/p-12e2c2c4.entry.js +1 -0
  92. package/dist/cobalt/p-136ad468.entry.js +1 -0
  93. package/dist/cobalt/{p-654bbc2a.entry.js → p-14b59277.entry.js} +1 -1
  94. package/dist/cobalt/p-1531d3c9.entry.js +1 -0
  95. package/dist/cobalt/p-1774d211.entry.js +1 -0
  96. package/dist/cobalt/p-180e1106.entry.js +1 -0
  97. package/dist/cobalt/p-1a07c23c.entry.js +1 -0
  98. package/dist/cobalt/p-1dc9c49e.entry.js +1 -0
  99. package/dist/cobalt/p-1f747e45.entry.js +1 -0
  100. package/dist/cobalt/p-201eaf35.entry.js +1 -0
  101. package/dist/cobalt/p-260101ab.entry.js +1 -0
  102. package/dist/cobalt/p-279bf91c.entry.js +1 -0
  103. package/dist/cobalt/p-29be61a9.entry.js +1 -0
  104. package/dist/cobalt/p-2d2ce434.entry.js +1 -0
  105. package/dist/cobalt/{p-aa63812a.entry.js → p-2f86e1e0.entry.js} +1 -1
  106. package/dist/cobalt/{p-522fcdb7.entry.js → p-31ab9a46.entry.js} +1 -1
  107. package/dist/cobalt/{p-fe9e85b6.entry.js → p-37595103.entry.js} +1 -1
  108. package/dist/cobalt/{p-def448e4.entry.js → p-377c2ccc.entry.js} +1 -1
  109. package/dist/cobalt/p-3863ea91.entry.js +1 -0
  110. package/dist/cobalt/p-3a257cb0.entry.js +1 -0
  111. package/dist/cobalt/p-3e187456.entry.js +1 -0
  112. package/dist/cobalt/{p-5d01bd4d.entry.js → p-4431faac.entry.js} +1 -1
  113. package/dist/cobalt/{p-54f26e95.entry.js → p-4504f7b0.entry.js} +1 -1
  114. package/dist/cobalt/{p-f8728b21.entry.js → p-456fa86f.entry.js} +1 -1
  115. package/dist/cobalt/{p-3f9b3fcb.entry.js → p-4871690e.entry.js} +1 -1
  116. package/dist/cobalt/{p-d17e1444.entry.js → p-4c01d984.entry.js} +1 -1
  117. package/dist/cobalt/p-51a53177.entry.js +1 -0
  118. package/dist/cobalt/p-52de17da.entry.js +1 -0
  119. package/dist/cobalt/p-5890e4d1.entry.js +1 -0
  120. package/dist/cobalt/{p-f2c5cb74.entry.js → p-58a53421.entry.js} +1 -1
  121. package/dist/cobalt/p-62274eba.entry.js +1 -0
  122. package/dist/cobalt/p-635b03d5.entry.js +1 -0
  123. package/dist/cobalt/p-64ddee92.entry.js +1 -0
  124. package/dist/cobalt/p-65af5017.entry.js +1 -0
  125. package/dist/cobalt/p-69d4c0c8.entry.js +1 -0
  126. package/dist/cobalt/p-6c480916.entry.js +1 -0
  127. package/dist/cobalt/p-6d1217c3.entry.js +1 -0
  128. package/dist/cobalt/{p-f0e8fa7d.entry.js → p-6e808b3a.entry.js} +1 -1
  129. package/dist/cobalt/{p-f97ad9ad.entry.js → p-70b14b05.entry.js} +1 -1
  130. package/dist/cobalt/{p-97c20011.entry.js → p-790d384e.entry.js} +1 -1
  131. package/dist/cobalt/p-8012e152.entry.js +1 -0
  132. package/dist/cobalt/p-80b27203.entry.js +1 -0
  133. package/dist/cobalt/p-867c1465.entry.js +1 -0
  134. package/dist/cobalt/p-86a143d7.entry.js +1 -0
  135. package/dist/cobalt/{p-e8b58332.entry.js → p-8d59f5ad.entry.js} +1 -1
  136. package/dist/cobalt/p-8d7fdb9d.entry.js +1 -0
  137. package/dist/cobalt/{p-7f818368.entry.js → p-8dc1dab8.entry.js} +1 -1
  138. package/dist/cobalt/{p-beb9c11d.entry.js → p-8e1dc062.entry.js} +1 -1
  139. package/dist/cobalt/p-929e647f.entry.js +1 -0
  140. package/dist/cobalt/p-92bd9b29.entry.js +1 -0
  141. package/dist/cobalt/p-93046365.entry.js +1 -0
  142. package/dist/cobalt/p-98ab5f3f.entry.js +1 -0
  143. package/dist/cobalt/{p-c87285b6.entry.js → p-9a04ca90.entry.js} +1 -1
  144. package/dist/cobalt/{p-7ef766c6.entry.js → p-9a088515.entry.js} +1 -1
  145. package/dist/cobalt/p-9abbd436.entry.js +1 -0
  146. package/dist/cobalt/p-9d69c067.entry.js +1 -0
  147. package/dist/cobalt/p-B-ckjCUA.js +1 -0
  148. package/dist/cobalt/p-B2QLgWrz.js +2 -0
  149. package/dist/cobalt/p-B6JZk8fL.js +1 -0
  150. package/dist/cobalt/p-BZJ7NCm5.js +1 -0
  151. package/dist/cobalt/p-CYsftTKf.js +2 -0
  152. package/dist/cobalt/p-CegCk7FL.js +1 -0
  153. package/dist/cobalt/p-Ch1jfwZ2.js +1 -0
  154. package/dist/cobalt/p-ChibIpZv.js +1 -0
  155. package/dist/cobalt/p-afb7e19e.entry.js +1 -0
  156. package/dist/cobalt/{p-b758c2e6.entry.js → p-b6f20268.entry.js} +1 -1
  157. package/dist/cobalt/{p-bb07da22.entry.js → p-ba90e871.entry.js} +1 -1
  158. package/dist/cobalt/p-c10697e1.entry.js +1 -0
  159. package/dist/cobalt/p-c4f59532.entry.js +1 -0
  160. package/dist/cobalt/{p-1e0282b8.entry.js → p-cb235aa7.entry.js} +1 -1
  161. package/dist/cobalt/p-cfb36943.entry.js +1 -0
  162. package/dist/cobalt/p-d809bd44.entry.js +1 -0
  163. package/dist/cobalt/p-e53861e4.entry.js +1 -0
  164. package/dist/cobalt/p-e54dd404.entry.js +1 -0
  165. package/dist/cobalt/{p-01fc77c4.entry.js → p-eb18fdbf.entry.js} +1 -1
  166. package/dist/cobalt/{p-95d14878.entry.js → p-eb73052a.entry.js} +1 -1
  167. package/dist/cobalt/{p-273afd93.entry.js → p-ef7d4ae3.entry.js} +1 -1
  168. package/dist/cobalt/p-f4063c41.entry.js +1 -0
  169. package/dist/cobalt/p-oImf-7fN.js +1 -0
  170. package/dist/cobalt/{p-CyYF8IJE.js → p-tPYikBRJ.js} +1 -1
  171. package/dist/collection/collection-manifest.json +10 -3
  172. package/dist/collection/components/co-accordion/co-accordion.js +2 -2
  173. package/dist/collection/components/co-app-shell/co-app-shell.css +79 -6
  174. package/dist/collection/components/co-app-shell/co-app-shell.js +2 -2
  175. package/dist/collection/components/co-autocomplete/co-autocomplete.css +28 -1
  176. package/dist/collection/components/co-autocomplete/co-autocomplete.js +27 -4
  177. package/dist/collection/components/co-avatar/co-avatar.css +38 -1
  178. package/dist/collection/components/co-avatar/co-avatar.js +23 -2
  179. package/dist/collection/components/co-avatar-group/co-avatar-group.css +86 -0
  180. package/dist/collection/components/co-avatar-group/co-avatar-group.js +224 -0
  181. package/dist/collection/components/co-badge/co-badge.js +1 -1
  182. package/dist/collection/components/co-bottom-sheet/co-bottom-sheet.css +136 -0
  183. package/dist/collection/components/co-bottom-sheet/co-bottom-sheet.js +507 -0
  184. package/dist/collection/components/co-button/co-button.css +40 -7
  185. package/dist/collection/components/co-button/co-button.js +26 -7
  186. package/dist/collection/components/co-button-group/co-button-group.js +2 -2
  187. package/dist/collection/components/co-calendar/co-calendar.js +1 -1
  188. package/dist/collection/components/co-calendar-month/co-calendar-month.css +231 -0
  189. package/dist/collection/components/co-calendar-month/co-calendar-month.js +594 -0
  190. package/dist/collection/components/co-card/co-card.js +2 -2
  191. package/dist/collection/components/co-checkbox/co-checkbox.css +7 -1
  192. package/dist/collection/components/co-checkbox/co-checkbox.js +3 -3
  193. package/dist/collection/components/co-checkbox-group/co-checkbox-group.css +7 -1
  194. package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +3 -3
  195. package/dist/collection/components/co-chip/co-chip.css +27 -7
  196. package/dist/collection/components/co-chip/co-chip.js +52 -10
  197. package/dist/collection/components/co-color-picker/co-color-picker.css +35 -1
  198. package/dist/collection/components/co-color-picker/co-color-picker.js +24 -2
  199. package/dist/collection/components/co-column-picker/co-column-picker.js +2 -2
  200. package/dist/collection/components/co-combobox/co-combobox.css +7 -47
  201. package/dist/collection/components/co-combobox/co-combobox.js +4 -4
  202. package/dist/collection/components/co-command-search/co-command-search.css +163 -1
  203. package/dist/collection/components/co-command-search/co-command-search.js +355 -14
  204. package/dist/collection/components/co-command-search/commandSearchGroup.js +17 -0
  205. package/dist/collection/components/co-command-search/commandSearchLogic.js +27 -0
  206. package/dist/collection/components/co-data-table/co-data-table.css +37 -1
  207. package/dist/collection/components/co-data-table/co-data-table.js +25 -11
  208. package/dist/collection/components/co-data-table-pagination/co-data-table-pagination.js +4 -4
  209. package/dist/collection/components/co-date-field/co-date-field.css +7 -1
  210. package/dist/collection/components/co-date-field/co-date-field.js +4 -4
  211. package/dist/collection/components/co-date-range/co-date-range.js +1 -1
  212. package/dist/collection/components/co-date-range-picker/co-date-range-picker.css +7 -1
  213. package/dist/collection/components/co-drawer/co-drawer.css +1 -0
  214. package/dist/collection/components/co-drawer/co-drawer.js +2 -2
  215. package/dist/collection/components/co-empty-state/co-empty-state.js +1 -1
  216. package/dist/collection/components/co-event-calendar/co-event-calendar.css +146 -0
  217. package/dist/collection/components/co-event-calendar/co-event-calendar.js +620 -0
  218. package/dist/collection/components/co-fab/co-fab.js +2 -2
  219. package/dist/collection/components/co-file-field/co-file-field.css +7 -1
  220. package/dist/collection/components/co-file-field/co-file-field.js +5 -5
  221. package/dist/collection/components/co-helper-text/co-helper-text.js +2 -2
  222. package/dist/collection/components/co-icon/co-icon.js +7 -37
  223. package/dist/collection/components/co-icon/iconLoader.js +39 -0
  224. package/dist/collection/components/co-icon-button/co-icon-button.css +19 -8
  225. package/dist/collection/components/co-icon-button/co-icon-button.js +23 -4
  226. package/dist/collection/components/co-input/co-input.css +7 -1
  227. package/dist/collection/components/co-input/co-input.js +3 -3
  228. package/dist/collection/components/co-json-field/co-json-field.css +25 -1
  229. package/dist/collection/components/co-json-field/co-json-field.js +27 -3
  230. package/dist/collection/components/co-lightbox/co-lightbox.js +4 -4
  231. package/dist/collection/components/co-list-footer/co-list-footer.css +50 -0
  232. package/dist/collection/components/co-list-footer/co-list-footer.js +149 -0
  233. package/dist/collection/components/co-list-item/co-list-item.css +7 -0
  234. package/dist/collection/components/co-list-item/co-list-item.js +65 -2
  235. package/dist/collection/components/co-loader/co-loader.css +9 -0
  236. package/dist/collection/components/co-menu/co-menu.js +1 -1
  237. package/dist/collection/components/co-menu-divider/co-menu-divider.js +1 -1
  238. package/dist/collection/components/co-menu-item/co-menu-item.css +18 -0
  239. package/dist/collection/components/co-menu-item/co-menu-item.js +15 -8
  240. package/dist/collection/components/co-modal/co-modal.css +42 -2
  241. package/dist/collection/components/co-modal/co-modal.js +42 -2
  242. package/dist/collection/components/co-navbar/co-navbar.js +2 -2
  243. package/dist/collection/components/co-number-field/co-number-field.css +19 -1
  244. package/dist/collection/components/co-number-field/co-number-field.js +34 -3
  245. package/dist/collection/components/co-overlay/co-overlay.css +15 -1
  246. package/dist/collection/components/co-overlay/co-overlay.js +266 -1
  247. package/dist/collection/components/co-overlay/focusTrap.js +53 -0
  248. package/dist/collection/components/co-overlay/overlayAfterClose.js +8 -0
  249. package/dist/collection/components/co-page-header/co-page-header.js +1 -1
  250. package/dist/collection/components/co-phone-field/co-phone-field.css +30 -2
  251. package/dist/collection/components/co-phone-field/co-phone-field.js +23 -1
  252. package/dist/collection/components/co-popover/co-popover.css +9 -0
  253. package/dist/collection/components/co-popover/co-popover.js +43 -12
  254. package/dist/collection/components/co-progress-bar/co-progress-bar.css +22 -0
  255. package/dist/collection/components/co-progress-bar/co-progress-bar.js +26 -2
  256. package/dist/collection/components/co-progress-circle/co-progress-circle.js +2 -2
  257. package/dist/collection/components/co-radio/co-radio.js +3 -3
  258. package/dist/collection/components/co-radio-group/co-radio-group.js +3 -3
  259. package/dist/collection/components/co-rating/co-rating.js +3 -3
  260. package/dist/collection/components/co-ref-field/co-ref-field.css +64 -6
  261. package/dist/collection/components/co-ref-field/co-ref-field.js +0 -0
  262. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.css +1125 -41
  263. package/dist/collection/components/co-rich-text-editor/co-rich-text-editor.js +2008 -53
  264. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.css +791 -9
  265. package/dist/collection/components/co-rich-text-toolbar/co-rich-text-toolbar.js +1071 -71
  266. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.css +78 -0
  267. package/dist/collection/components/co-rich-text-viewer/co-rich-text-viewer.js +46 -41
  268. package/dist/collection/components/co-row/co-row.js +2 -2
  269. package/dist/collection/components/co-select/co-select.css +7 -1
  270. package/dist/collection/components/co-select/co-select.js +5 -5
  271. package/dist/collection/components/co-separator/co-separator.js +1 -1
  272. package/dist/collection/components/co-sidebar/co-sidebar.js +2 -2
  273. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.css +99 -12
  274. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +28 -8
  275. package/dist/collection/components/co-skeleton/co-skeleton.css +28 -0
  276. package/dist/collection/components/co-skeleton/co-skeleton.js +97 -0
  277. package/dist/collection/components/co-slider/co-slider.js +2 -2
  278. package/dist/collection/components/co-switch/co-switch.css +9 -1
  279. package/dist/collection/components/co-switch/co-switch.js +3 -3
  280. package/dist/collection/components/co-tab/co-tab.js +2 -2
  281. package/dist/collection/components/co-tab-group/co-tab-group.js +1 -1
  282. package/dist/collection/components/co-tags-field/co-tags-field.css +39 -1
  283. package/dist/collection/components/co-tags-field/co-tags-field.js +36 -10
  284. package/dist/collection/components/co-textarea/co-textarea.css +26 -1
  285. package/dist/collection/components/co-textarea/co-textarea.js +28 -4
  286. package/dist/collection/components/co-toast/co-toast.js +1 -1
  287. package/dist/collection/components/co-toggle-button/co-toggle-button.css +26 -4
  288. package/dist/collection/components/co-toggle-button/co-toggle-button.js +3 -3
  289. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.css +16 -12
  290. package/dist/collection/components/co-toggle-button-group/co-toggle-button-group.js +2 -2
  291. package/dist/collection/components/co-tooltip/co-tooltip.css +8 -0
  292. package/dist/collection/components/co-tooltip/co-tooltip.js +69 -14
  293. package/dist/collection/components/co-transfer-list/co-transfer-list.js +2 -2
  294. package/dist/collection/components/co-video/co-video.css +497 -0
  295. package/dist/collection/components/co-video/co-video.js +1772 -0
  296. package/dist/collection/utils/fieldChip.js +2 -0
  297. package/dist/collection/utils/icon-config.js +12 -0
  298. package/dist/collection/utils/richTextI18n.js +378 -0
  299. package/dist/collection/utils/sheetGesture.js +53 -0
  300. package/dist/components/co-accordion.js +1 -1
  301. package/dist/components/co-app-shell.js +1 -1
  302. package/dist/components/co-autocomplete.js +1 -1
  303. package/dist/components/co-avatar-group.d.ts +11 -0
  304. package/dist/components/co-avatar-group.js +1 -0
  305. package/dist/components/co-avatar.js +1 -1
  306. package/dist/components/co-badge.js +1 -1
  307. package/dist/components/co-bottom-sheet.d.ts +11 -0
  308. package/dist/components/co-bottom-sheet.js +1 -0
  309. package/dist/components/co-button-group.js +1 -1
  310. package/dist/components/co-button.js +1 -1
  311. package/dist/components/co-calendar-month.d.ts +11 -0
  312. package/dist/components/co-calendar-month.js +1 -0
  313. package/dist/components/co-calendar.js +1 -1
  314. package/dist/components/co-card.js +1 -1
  315. package/dist/components/co-checkbox-group.js +1 -1
  316. package/dist/components/co-checkbox.js +1 -1
  317. package/dist/components/co-chip.js +1 -1
  318. package/dist/components/co-color-picker.js +1 -1
  319. package/dist/components/co-column-picker.js +1 -1
  320. package/dist/components/co-combobox.js +1 -1
  321. package/dist/components/co-command-search.js +1 -1
  322. package/dist/components/co-data-table-pagination.js +1 -1
  323. package/dist/components/co-data-table.js +1 -1
  324. package/dist/components/co-date-field.js +1 -1
  325. package/dist/components/co-date-picker.js +1 -1
  326. package/dist/components/co-date-range-picker.js +1 -1
  327. package/dist/components/co-date-range.js +1 -1
  328. package/dist/components/co-drawer.js +1 -1
  329. package/dist/components/co-empty-state.js +1 -1
  330. package/dist/components/co-event-calendar.d.ts +11 -0
  331. package/dist/components/co-event-calendar.js +1 -0
  332. package/dist/components/co-fab.js +1 -1
  333. package/dist/components/co-file-field.js +1 -1
  334. package/dist/components/co-helper-text.js +1 -1
  335. package/dist/components/co-icon-button.js +1 -1
  336. package/dist/components/co-icon.js +1 -1
  337. package/dist/components/co-input.js +1 -1
  338. package/dist/components/co-json-field.js +1 -1
  339. package/dist/components/co-lightbox.js +1 -1
  340. package/dist/components/co-list-footer.d.ts +11 -0
  341. package/dist/components/co-list-footer.js +1 -0
  342. package/dist/components/co-list-item.js +1 -1
  343. package/dist/components/co-loader.js +1 -1
  344. package/dist/components/co-menu-divider.js +1 -1
  345. package/dist/components/co-menu-item.js +1 -1
  346. package/dist/components/co-menu.js +1 -1
  347. package/dist/components/co-modal.js +1 -1
  348. package/dist/components/co-navbar.js +1 -1
  349. package/dist/components/co-number-field.js +1 -1
  350. package/dist/components/co-overlay.js +1 -1
  351. package/dist/components/co-page-header.js +1 -1
  352. package/dist/components/co-phone-field.js +1 -1
  353. package/dist/components/co-popover.js +1 -1
  354. package/dist/components/co-progress-bar.js +1 -1
  355. package/dist/components/co-progress-circle.js +1 -1
  356. package/dist/components/co-radio-group.js +1 -1
  357. package/dist/components/co-radio.js +1 -1
  358. package/dist/components/co-rating.js +1 -1
  359. package/dist/components/co-ref-field.js +1 -1
  360. package/dist/components/co-rich-text-editor.js +1 -1
  361. package/dist/components/co-rich-text-toolbar.js +1 -1
  362. package/dist/components/co-rich-text-viewer.js +1 -1
  363. package/dist/components/co-row.js +1 -1
  364. package/dist/components/co-select.js +1 -1
  365. package/dist/components/co-separator.js +1 -1
  366. package/dist/components/co-sidebar-nav.js +1 -1
  367. package/dist/components/co-sidebar.js +1 -1
  368. package/dist/components/co-skeleton.d.ts +11 -0
  369. package/dist/components/co-skeleton.js +1 -0
  370. package/dist/components/co-slider.js +1 -1
  371. package/dist/components/co-switch.js +1 -1
  372. package/dist/components/co-tab-group.js +1 -1
  373. package/dist/components/co-tab.js +1 -1
  374. package/dist/components/co-tags-field.js +1 -1
  375. package/dist/components/co-textarea.js +1 -1
  376. package/dist/components/co-toast.js +1 -1
  377. package/dist/components/co-toggle-button-group.js +1 -1
  378. package/dist/components/co-toggle-button.js +1 -1
  379. package/dist/components/co-tooltip.js +1 -1
  380. package/dist/components/co-transfer-list.js +1 -1
  381. package/dist/components/co-video.d.ts +11 -0
  382. package/dist/components/co-video.js +1 -0
  383. package/dist/components/index.js +1 -1
  384. package/dist/components/p-B2QLgWrz.js +2 -0
  385. package/dist/components/{p-BeWXpX8I.js → p-B7vGYFbO.js} +1 -1
  386. package/dist/components/p-BB2OaYKF.js +1 -0
  387. package/dist/components/p-BFeE_fiq.js +1 -0
  388. package/dist/components/p-BNKz39GA.js +1 -0
  389. package/dist/components/p-Ba4v1NXo.js +1 -0
  390. package/dist/components/p-C_ULDaks.js +1 -0
  391. package/dist/components/p-CegCk7FL.js +1 -0
  392. package/dist/components/p-ChibIpZv.js +1 -0
  393. package/dist/components/p-D3Y_ti3Q.js +1 -0
  394. package/dist/components/{p-DObrQi5F.js → p-DKh8ZK4U.js} +1 -1
  395. package/dist/components/{p-C9tHLXKS.js → p-DeZxp9vb.js} +1 -1
  396. package/dist/components/p-DvhR3H61.js +1 -0
  397. package/dist/components/p-DxCFMMfY.js +1 -0
  398. package/dist/components/{p-OGpfa9Yd.js → p-DzoNGEDU.js} +1 -1
  399. package/dist/components/p-EPZfLt5l.js +1 -0
  400. package/dist/components/p-FMnqPWcM.js +1 -0
  401. package/dist/components/p-Hzh9U2cM.js +1 -0
  402. package/dist/components/p-WZ06pT2Y.js +1 -0
  403. package/dist/components/p-tloAgDin.js +1 -0
  404. package/dist/esm/co-accordion.entry.js +3 -3
  405. package/dist/esm/co-app-shell.entry.js +4 -4
  406. package/dist/esm/co-autocomplete.entry.js +10 -7
  407. package/dist/esm/co-avatar-group.entry.js +75 -0
  408. package/dist/esm/co-avatar.entry.js +6 -4
  409. package/dist/esm/co-badge.entry.js +2 -2
  410. package/dist/esm/co-bottom-sheet.entry.js +323 -0
  411. package/dist/esm/co-button-group.entry.js +3 -3
  412. package/dist/esm/co-button.entry.js +6 -6
  413. package/dist/esm/co-calendar-month.entry.js +379 -0
  414. package/dist/esm/co-calendar_3.entry.js +12 -12
  415. package/dist/esm/co-card.entry.js +3 -3
  416. package/dist/esm/co-checkbox-group.entry.js +5 -5
  417. package/dist/esm/co-checkbox.entry.js +5 -5
  418. package/dist/esm/co-chip.entry.js +11 -8
  419. package/dist/esm/co-color-picker.entry.js +7 -5
  420. package/dist/esm/co-column-picker.entry.js +3 -3
  421. package/dist/esm/co-combobox.entry.js +7 -7
  422. package/dist/esm/co-command-search.entry.js +151 -12
  423. package/dist/esm/co-data-table-pagination.entry.js +5 -5
  424. package/dist/esm/co-data-table.entry.js +25 -11
  425. package/dist/esm/co-date-picker.entry.js +2 -2
  426. package/dist/esm/co-date-range-picker.entry.js +4 -4
  427. package/dist/esm/co-date-range.entry.js +2 -2
  428. package/dist/esm/co-empty-state.entry.js +2 -2
  429. package/dist/esm/co-event-calendar.entry.js +316 -0
  430. package/dist/esm/co-fab.entry.js +3 -3
  431. package/dist/esm/co-file-field.entry.js +8 -8
  432. package/dist/esm/co-helper-text.entry.js +3 -3
  433. package/dist/esm/co-icon-button.entry.js +5 -5
  434. package/dist/esm/co-icon.entry.js +33 -25
  435. package/dist/esm/co-input.entry.js +6 -6
  436. package/dist/esm/co-json-field.entry.js +10 -6
  437. package/dist/esm/co-lightbox.entry.js +5 -5
  438. package/dist/esm/co-list-footer.entry.js +23 -0
  439. package/dist/esm/co-list-item.entry.js +60 -4
  440. package/dist/esm/co-loader_2.entry.js +290 -0
  441. package/dist/esm/co-menu-divider.entry.js +2 -2
  442. package/dist/esm/co-menu-item.entry.js +17 -10
  443. package/dist/esm/co-menu.entry.js +2 -2
  444. package/dist/esm/co-modal.entry.js +16 -4
  445. package/dist/esm/co-navbar.entry.js +3 -3
  446. package/dist/esm/co-number-field.entry.js +18 -6
  447. package/dist/esm/co-page-header.entry.js +2 -2
  448. package/dist/esm/co-phone-field.entry.js +6 -4
  449. package/dist/esm/co-popover.entry.js +45 -14
  450. package/dist/esm/co-progress-bar.entry.js +8 -4
  451. package/dist/esm/co-progress-circle.entry.js +3 -3
  452. package/dist/esm/co-radio-group.entry.js +4 -4
  453. package/dist/esm/co-radio.entry.js +4 -4
  454. package/dist/esm/co-rating.entry.js +4 -4
  455. package/dist/esm/co-ref-field.entry.js +36 -13
  456. package/dist/esm/co-rich-text-editor.entry.js +1879 -33
  457. package/dist/esm/co-rich-text-toolbar.entry.js +995 -71
  458. package/dist/esm/co-rich-text-viewer.entry.js +55 -19
  459. package/dist/esm/co-row.entry.js +3 -3
  460. package/dist/esm/co-select.entry.js +8 -8
  461. package/dist/esm/co-separator.entry.js +2 -2
  462. package/dist/esm/co-sidebar-nav.entry.js +29 -9
  463. package/dist/esm/co-sidebar.entry.js +3 -3
  464. package/dist/esm/co-skeleton.entry.js +24 -0
  465. package/dist/esm/co-slider.entry.js +3 -3
  466. package/dist/esm/co-switch.entry.js +6 -6
  467. package/dist/esm/co-tab-group.entry.js +2 -2
  468. package/dist/esm/co-tab.entry.js +3 -3
  469. package/dist/esm/co-tags-field.entry.js +19 -13
  470. package/dist/esm/co-textarea.entry.js +11 -7
  471. package/dist/esm/co-toast.entry.js +2 -2
  472. package/dist/esm/co-toggle-button-group.entry.js +4 -4
  473. package/dist/esm/co-toggle-button.entry.js +4 -4
  474. package/dist/esm/co-tooltip.entry.js +51 -16
  475. package/dist/esm/co-transfer-list.entry.js +3 -3
  476. package/dist/esm/co-video.entry.js +837 -0
  477. package/dist/esm/cobalt.js +3 -3
  478. package/dist/esm/{dates-CyYF8IJE.js → dates-tPYikBRJ.js} +1 -1
  479. package/dist/esm/fieldChip-GPikjpYw.js +5 -0
  480. package/dist/esm/{index-BKmfyPZK.js → index-CYsftTKf.js} +45 -21
  481. package/dist/esm/{index-BjAqSidM.js → index-w_Wxgclf.js} +14508 -6305
  482. package/dist/esm/loader.js +3 -3
  483. package/dist/esm/overlayAfterClose-Ch1jfwZ2.js +10 -0
  484. package/dist/{cjs/sanitizer-CjHZAkOm.js → esm/purify.es-B2QLgWrz.js} +1 -110
  485. package/dist/esm/{requiredMark-DFvtYtkE.js → requiredMark-CEbXKHcU.js} +1 -1
  486. package/dist/esm/richTextI18n-B-ckjCUA.js +380 -0
  487. package/dist/esm/toolbar-config-ChibIpZv.js +212 -0
  488. package/dist/esm/tz-B6JZk8fL.js +119 -0
  489. package/dist/types/components/co-autocomplete/co-autocomplete.d.ts +2 -0
  490. package/dist/types/components/co-avatar/co-avatar.d.ts +2 -0
  491. package/dist/types/components/co-avatar-group/co-avatar-group.d.ts +33 -0
  492. package/dist/types/components/co-bottom-sheet/co-bottom-sheet.d.ts +81 -0
  493. package/dist/types/components/co-button/co-button.d.ts +3 -1
  494. package/dist/types/components/co-calendar-month/co-calendar-month.d.ts +83 -0
  495. package/dist/types/components/co-chip/co-chip.d.ts +7 -2
  496. package/dist/types/components/co-color-picker/co-color-picker.d.ts +2 -0
  497. package/dist/types/components/co-command-search/co-command-search.d.ts +39 -6
  498. package/dist/types/components/co-command-search/commandSearchGroup.d.ts +20 -0
  499. package/dist/types/components/co-command-search/commandSearchLogic.d.ts +17 -0
  500. package/dist/types/components/co-data-table/co-data-table.d.ts +2 -1
  501. package/dist/types/components/co-event-calendar/co-event-calendar.d.ts +110 -0
  502. package/dist/types/components/co-icon/co-icon.d.ts +1 -1
  503. package/dist/types/components/co-icon/iconLoader.d.ts +6 -0
  504. package/dist/types/components/co-icon-button/co-icon-button.d.ts +2 -0
  505. package/dist/types/components/co-json-field/co-json-field.d.ts +3 -0
  506. package/dist/types/components/co-list-footer/co-list-footer.d.ts +26 -0
  507. package/dist/types/components/co-list-item/co-list-item.d.ts +11 -0
  508. package/dist/types/components/co-modal/co-modal.d.ts +6 -0
  509. package/dist/types/components/co-number-field/co-number-field.d.ts +13 -0
  510. package/dist/types/components/co-overlay/co-overlay.d.ts +45 -0
  511. package/dist/types/components/co-overlay/focusTrap.d.ts +20 -0
  512. package/dist/types/components/co-overlay/overlayAfterClose.d.ts +5 -0
  513. package/dist/types/components/co-phone-field/co-phone-field.d.ts +2 -0
  514. package/dist/types/components/co-popover/co-popover.d.ts +9 -0
  515. package/dist/types/components/co-progress-bar/co-progress-bar.d.ts +2 -0
  516. package/dist/types/components/co-ref-field/co-ref-field.d.ts +17 -2
  517. package/dist/types/components/co-rich-text-editor/co-rich-text-editor.d.ts +161 -9
  518. package/dist/types/components/co-rich-text-toolbar/co-rich-text-toolbar.d.ts +119 -13
  519. package/dist/types/components/co-rich-text-viewer/co-rich-text-viewer.d.ts +1 -14
  520. package/dist/types/components/co-skeleton/co-skeleton.d.ts +13 -0
  521. package/dist/types/components/co-tags-field/co-tags-field.d.ts +2 -0
  522. package/dist/types/components/co-textarea/co-textarea.d.ts +3 -0
  523. package/dist/types/components/co-tooltip/co-tooltip.d.ts +12 -0
  524. package/dist/types/components/co-video/co-video.d.ts +203 -0
  525. package/dist/types/components.d.ts +1729 -72
  526. package/dist/types/utils/fieldChip.d.ts +37 -0
  527. package/dist/types/utils/icon-config.d.ts +11 -0
  528. package/dist/types/utils/richTextI18n.d.ts +130 -0
  529. package/dist/types/utils/sheetGesture.d.ts +31 -0
  530. package/package.json +3 -2
  531. package/dist/cjs/co-loader.cjs.entry.js +0 -34
  532. package/dist/cjs/co-overlay.cjs.entry.js +0 -23
  533. package/dist/cobalt/p-0a6d8061.entry.js +0 -1
  534. package/dist/cobalt/p-0bf288cd.entry.js +0 -1
  535. package/dist/cobalt/p-136bdbd2.entry.js +0 -1
  536. package/dist/cobalt/p-15708d32.entry.js +0 -1
  537. package/dist/cobalt/p-1578b019.entry.js +0 -1
  538. package/dist/cobalt/p-23d48581.entry.js +0 -1
  539. package/dist/cobalt/p-2718ff27.entry.js +0 -1
  540. package/dist/cobalt/p-2b4d8535.entry.js +0 -1
  541. package/dist/cobalt/p-3190d715.entry.js +0 -1
  542. package/dist/cobalt/p-41228dce.entry.js +0 -1
  543. package/dist/cobalt/p-44672953.entry.js +0 -1
  544. package/dist/cobalt/p-53ce9023.entry.js +0 -1
  545. package/dist/cobalt/p-5e7141aa.entry.js +0 -1
  546. package/dist/cobalt/p-5f905739.entry.js +0 -1
  547. package/dist/cobalt/p-6678ac0a.entry.js +0 -1
  548. package/dist/cobalt/p-66a912dd.entry.js +0 -1
  549. package/dist/cobalt/p-6759ee1c.entry.js +0 -1
  550. package/dist/cobalt/p-69a40bfd.entry.js +0 -1
  551. package/dist/cobalt/p-6a6a62cb.entry.js +0 -1
  552. package/dist/cobalt/p-6d43b6cd.entry.js +0 -1
  553. package/dist/cobalt/p-759c3dd0.entry.js +0 -1
  554. package/dist/cobalt/p-782f729f.entry.js +0 -1
  555. package/dist/cobalt/p-83b89bf8.entry.js +0 -1
  556. package/dist/cobalt/p-88dc561a.entry.js +0 -1
  557. package/dist/cobalt/p-8c27aff7.entry.js +0 -1
  558. package/dist/cobalt/p-996179f7.entry.js +0 -1
  559. package/dist/cobalt/p-9c533830.entry.js +0 -1
  560. package/dist/cobalt/p-9d89bf47.entry.js +0 -1
  561. package/dist/cobalt/p-BKmfyPZK.js +0 -2
  562. package/dist/cobalt/p-BchB6Hdr.js +0 -1
  563. package/dist/cobalt/p-DcK0GGZC.js +0 -2
  564. package/dist/cobalt/p-Qqq8fysz.js +0 -1
  565. package/dist/cobalt/p-aa17c70b.entry.js +0 -1
  566. package/dist/cobalt/p-ad4c1b41.entry.js +0 -1
  567. package/dist/cobalt/p-ae4d3207.entry.js +0 -1
  568. package/dist/cobalt/p-af64da37.entry.js +0 -1
  569. package/dist/cobalt/p-c6a242e4.entry.js +0 -1
  570. package/dist/cobalt/p-cd57e8b4.entry.js +0 -1
  571. package/dist/cobalt/p-ce3a535f.entry.js +0 -1
  572. package/dist/cobalt/p-d958566a.entry.js +0 -1
  573. package/dist/cobalt/p-dd873bf8.entry.js +0 -1
  574. package/dist/cobalt/p-e4de8865.entry.js +0 -1
  575. package/dist/cobalt/p-eba0bf7f.entry.js +0 -1
  576. package/dist/cobalt/p-fad3605d.entry.js +0 -1
  577. package/dist/cobalt/p-ff2690e5.entry.js +0 -1
  578. package/dist/components/p-BXdfh__-.js +0 -1
  579. package/dist/components/p-BchB6Hdr.js +0 -1
  580. package/dist/components/p-BiW0ubLs.js +0 -1
  581. package/dist/components/p-CaMgu2_g.js +0 -1
  582. package/dist/components/p-DBhNS7JD.js +0 -1
  583. package/dist/components/p-DPi_U-Kl.js +0 -1
  584. package/dist/components/p-DcK0GGZC.js +0 -2
  585. package/dist/components/p-MiSJXuBx.js +0 -1
  586. package/dist/components/p-Sgn-2g8m.js +0 -1
  587. package/dist/components/p-jDjfGZJp.js +0 -1
  588. package/dist/components/p-o8hrDIKe.js +0 -1
  589. package/dist/esm/co-loader.entry.js +0 -32
  590. package/dist/esm/co-overlay.entry.js +0 -21
@@ -1,24 +1,70 @@
1
- import { r as registerInstance, c as createEvent, h } from './index-BKmfyPZK.js';
1
+ import { r as registerInstance, c as createEvent, h, a as getElement } from './index-CYsftTKf.js';
2
+ import { g as getRichTextStrings } from './richTextI18n-B-ckjCUA.js';
3
+ import { C as COLOR_PALETTE, T as TABLE_CONTEXT_ITEMS, t as toolbarItems } from './toolbar-config-ChibIpZv.js';
2
4
 
3
- const coRichTextToolbarCss = () => `:host{display:block;font-family:var(--co-font-family-primary)}.co-rich-text-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--co-spacing-xxs, 2px);padding:var(--co-spacing-xs) var(--co-spacing-sm);border-bottom:1px solid var(--co-semantic-border-subtle);background:var(--co-semantic-surface-secondary)}.co-rich-text-toolbar__btn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:var(--co-border-radius-xxs);background:transparent;color:var(--co-semantic-text-secondary);cursor:pointer;transition:background 0.12s ease, color 0.12s ease}.co-rich-text-toolbar__btn:hover:not(:disabled){background:var(--co-semantic-surface-hover, rgba(0, 0, 0, 0.06));color:var(--co-semantic-text-default)}.co-rich-text-toolbar__btn--active{background:var(--co-semantic-surface-hover, rgba(37, 99, 235, 0.12));color:var(--co-color-primary-azul)}.co-rich-text-toolbar__btn:disabled{opacity:0.4;cursor:not-allowed}.co-rich-text-toolbar__btn:focus-visible{outline:2px solid var(--co-semantic-border-focus, var(--co-color-primary-azul));outline-offset:1px}`;
5
+ const coRichTextToolbarCss = () => `:host{display:block;font-family:var(--co-font-family-primary);z-index:10;flex-shrink:0;background:var(--co-semantic-surface-secondary, #fff);overflow:visible}.co-rich-text-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:var(--co-spacing-xxs, 2px);padding:var(--co-spacing-xs) var(--co-spacing-sm);border-bottom:1px solid var(--co-semantic-border-subtle);background:var(--co-semantic-surface-secondary)}.co-rich-text-toolbar__btn-wrap,.co-rich-text-toolbar__split-wrap{overflow:visible}[data-tooltip]{position:relative}[data-tooltip]::after{content:attr(data-tooltip);position:absolute;top:calc(100% + 4px);left:50%;transform:translateX(-50%);padding:4px 8px;background:var(--co-color-base-negro, #1a1a1a);color:var(--co-color-base-blanco, #fff);font-size:11px;font-weight:500;line-height:1.3;white-space:nowrap;border-radius:4px;pointer-events:none;opacity:0;transition:opacity 0.15s ease;z-index:9999}[data-tooltip]:hover::after{opacity:1;transition-delay:0.4s}[data-tooltip]:active::after,[data-tooltip][aria-expanded="true"]::after{opacity:0 !important;transition-delay:0s}.co-rich-text-toolbar__btn-wrap{position:relative;display:inline-flex}.co-rich-text-toolbar__btn{display:inline-flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:var(--co-border-radius-xxs);background:transparent;color:var(--co-semantic-text-default, #333);cursor:pointer;transition:background 0.12s ease, color 0.12s ease}.co-rich-text-toolbar__btn:hover:not(:disabled):not(.co-rich-text-toolbar__btn--active){background:var(--co-semantic-surface-hover, rgba(0, 0, 0, 0.08));color:var(--co-semantic-text-default, #1a1a1a)}.co-rich-text-toolbar__btn--active{background:var(--co-color-base-negro, #1a1a1a);color:var(--co-color-base-blanco, #fff)}.co-rich-text-toolbar__btn--active:hover{background:var(--co-color-base-negro, #333);color:var(--co-color-base-blanco, #fff)}.co-rich-text-toolbar__btn:disabled{opacity:0.4;cursor:not-allowed}.co-rich-text-toolbar__btn:focus-visible{outline:2px solid var(--co-semantic-border-focus, var(--co-color-base-negro, #1a1a1a));outline-offset:1px}.co-rich-text-toolbar__select-btn{display:inline-flex;align-items:center;gap:2px;height:30px;padding:0 6px;border:1px solid transparent;border-radius:var(--co-border-radius-xxs, 4px);background:transparent;color:var(--co-semantic-text-default, #333);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12, 12px);cursor:pointer;white-space:nowrap;transition:background 0.12s, border-color 0.12s}.co-rich-text-toolbar__select-btn:hover:not(:disabled){background:var(--co-semantic-surface-hover, rgba(0, 0, 0, 0.06));border-color:var(--co-semantic-border-default, #e0e0e0)}.co-rich-text-toolbar__select-btn--open{background:var(--co-semantic-surface-hover, rgba(0, 0, 0, 0.06));border-color:var(--co-semantic-border-default, #e0e0e0)}.co-rich-text-toolbar__select-btn:disabled{opacity:0.4;cursor:not-allowed}.co-rich-text-toolbar__select-label{max-width:100px;overflow:hidden;text-overflow:ellipsis}.co-rich-text-toolbar__sep{display:inline-block;width:1px;height:20px;margin:0 var(--co-spacing-xs, 4px);background:var(--co-semantic-border-subtle, rgba(0, 0, 0, 0.12))}.co-rich-text-toolbar__popover{position:absolute;top:100%;left:0;z-index:100;display:flex;flex-direction:column;gap:var(--co-spacing-xs, 4px);min-width:280px;padding:var(--co-spacing-sm, 8px);background:var(--co-semantic-surface-secondary, #fff);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xs, 8px);box-shadow:0 4px 16px rgba(0, 0, 0, 0.12);margin-top:var(--co-spacing-xs, 4px)}.co-rich-text-toolbar__popover-input{width:100%;padding:6px 10px;border:1px solid var(--co-semantic-border-default, #ccc);border-radius:var(--co-border-radius-xxs, 4px);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14, 14px);outline:none;box-sizing:border-box}.co-rich-text-toolbar__popover-input:focus{border-color:var(--co-color-base-negro, #1a1a1a);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.1)}.co-rich-text-toolbar__popover-actions{display:flex;gap:var(--co-spacing-xs, 4px)}.co-rich-text-toolbar__popover-btn{padding:4px 12px;border:1px solid var(--co-semantic-border-default, #ccc);border-radius:var(--co-border-radius-xxs, 4px);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12, 12px);cursor:pointer;background:var(--co-semantic-surface-secondary, #fff);color:var(--co-semantic-text-default, #333);transition:background 0.12s}.co-rich-text-toolbar__popover-btn:hover:not(.co-rich-text-toolbar__popover-btn--primary){background:var(--co-semantic-surface-hover, #f5f5f5)}.co-rich-text-toolbar__popover-btn--primary{background:var(--co-color-base-negro, #1a1a1a);color:#fff;border-color:var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__popover-btn--primary:hover{background:var(--co-color-base-negro, #333);color:#fff}.co-rich-text-toolbar__popover-btn--danger{color:var(--co-color-status-error, #aa2e1b);border-color:var(--co-color-status-error, #aa2e1b)}.co-rich-text-toolbar__popover-option{display:flex;align-items:center;gap:var(--co-spacing-sm, 8px);width:100%;padding:8px 10px;border:none;border-radius:var(--co-border-radius-xxs, 4px);background:transparent;color:var(--co-semantic-text-default, #333);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14, 14px);cursor:pointer;text-align:left;transition:background 0.1s}.co-rich-text-toolbar__popover-option:hover{background:var(--co-semantic-surface-hover, #f5f5f5)}.co-rich-text-toolbar__dropdown{position:absolute;top:100%;left:0;z-index:100;display:flex;flex-direction:column;min-width:180px;max-height:360px;overflow-y:auto;padding:var(--co-spacing-xs, 4px);background:var(--co-semantic-surface-secondary, #fff);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xs, 8px);box-shadow:0 4px 16px rgba(0, 0, 0, 0.12);margin-top:var(--co-spacing-xs, 4px)}.co-rich-text-toolbar__dropdown-item{display:flex;align-items:center;gap:var(--co-spacing-sm, 8px);padding:6px 10px;border:none;border-radius:var(--co-border-radius-xxs, 4px);background:transparent;color:var(--co-semantic-text-default, #333);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14, 14px);cursor:pointer;text-align:left;transition:background 0.12s}.co-rich-text-toolbar__dropdown-item:hover{background:var(--co-semantic-surface-hover, #f5f5f5)}.co-rich-text-toolbar__dropdown-sep{height:1px;margin:4px 0;background:var(--co-semantic-border-default, #e0e0e0)}.co-rich-text-toolbar__dropdown-sep-label{padding:6px 10px 2px;font-family:var(--co-font-family-primary);font-size:11px;font-weight:600;color:var(--co-semantic-text-muted, #999);letter-spacing:0.03em;border-top:1px solid var(--co-semantic-border-default, #e0e0e0);margin-top:2px}.co-rich-text-toolbar__dropdown-input-wrap{padding:6px 8px;border-bottom:1px solid var(--co-semantic-border-default, #e0e0e0)}.co-rich-text-toolbar__dropdown-input{width:100%;padding:4px 8px;border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:4px;font-size:13px;font-family:var(--co-font-family-primary);outline:none;box-sizing:border-box}.co-rich-text-toolbar__dropdown-input:focus{border-color:var(--co-color-base-negro, #1a1a1a);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.1)}.co-rich-text-toolbar__color-picker{position:absolute;top:100%;left:0;z-index:100;display:flex;flex-direction:column;gap:var(--co-spacing-xs, 4px);padding:var(--co-spacing-sm, 8px);background:var(--co-semantic-surface-secondary, #fff);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xs, 8px);box-shadow:0 4px 16px rgba(0, 0, 0, 0.12);margin-top:var(--co-spacing-xs, 4px)}.co-rich-text-toolbar__color-grid{display:grid;grid-template-columns:repeat(10, 1fr);gap:2px}.co-rich-text-toolbar__color-swatch{width:22px;height:22px;padding:0;border:none;border-radius:3px;cursor:pointer;transition:transform 0.1s, box-shadow 0.1s}.co-rich-text-toolbar__color-swatch:hover{transform:scale(1.2);box-shadow:0 0 0 2px var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__color-clear{display:flex;align-items:center;gap:var(--co-spacing-xs, 4px);padding:4px 8px;border:none;background:transparent;color:var(--co-semantic-text-secondary, #666);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12, 12px);cursor:pointer;border-radius:var(--co-border-radius-xxs, 4px);margin-top:var(--co-spacing-xxs, 2px)}.co-rich-text-toolbar__color-clear:hover{background:var(--co-semantic-surface-hover, #f5f5f5);color:var(--co-semantic-text-default, #333)}.co-rich-text-toolbar__table-picker{position:absolute;top:100%;left:0;z-index:100;display:flex;flex-direction:column;width:280px;padding:var(--co-spacing-lg, 16px);background:var(--co-semantic-surface-secondary, #fff);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xs, 8px);box-shadow:0 8px 24px rgba(0, 0, 0, 0.12);margin-top:var(--co-spacing-xs, 4px)}.co-rich-text-toolbar__table-header{display:flex;align-items:center;gap:var(--co-spacing-sm, 8px);margin-bottom:var(--co-spacing-md, 12px)}.co-rich-text-toolbar__table-title{flex:1;font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12, 12px);font-weight:600;letter-spacing:0.06em;color:var(--co-semantic-text-secondary, #666)}.co-rich-text-toolbar__table-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--co-border-radius-xxs, 4px);background:transparent;color:var(--co-semantic-text-secondary, #666);cursor:pointer}.co-rich-text-toolbar__table-close:hover{background:var(--co-semantic-surface-hover, #f0f0f0)}.co-rich-text-toolbar__table-tabs{display:flex;gap:0;margin-bottom:var(--co-spacing-md, 12px);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xxs, 4px);overflow:hidden}.co-rich-text-toolbar__table-tab{flex:1;padding:var(--co-spacing-sm, 8px) var(--co-spacing-md, 12px);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-13, 13px);font-weight:500;border:none;background:transparent;color:var(--co-semantic-text-secondary, #666);cursor:pointer;transition:background 0.12s, color 0.12s}.co-rich-text-toolbar__table-tab:hover{background:var(--co-semantic-surface-hover, #f5f5f5)}.co-rich-text-toolbar__table-tab--active{background:var(--co-color-base-negro, #1a1a1a);color:var(--co-color-base-blanco, #fff)}.co-rich-text-toolbar__grid-container{display:flex;flex-direction:column;gap:var(--co-spacing-sm, 8px);margin-bottom:var(--co-spacing-md, 12px)}.co-rich-text-toolbar__grid{display:grid;gap:3px}.co-rich-text-toolbar__grid-cell{width:24px;height:24px;border:1px solid var(--co-semantic-border-default, #d0d0d0);border-radius:3px;background:transparent;cursor:pointer;transition:background 0.08s, border-color 0.08s}.co-rich-text-toolbar__grid-cell:hover,.co-rich-text-toolbar__grid-cell--active{background:var(--co-color-base-negro, #1a1a1a);border-color:var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__grid-footer{display:flex;align-items:center;justify-content:space-between}.co-rich-text-toolbar__grid-label{font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12, 12px);color:var(--co-semantic-text-muted, #999)}.co-rich-text-toolbar__grid-reset{font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12, 12px);color:var(--co-semantic-text-default, #333);text-decoration:underline;border:none;background:transparent;cursor:pointer;padding:0}.co-rich-text-toolbar__table-manual{display:flex;flex-direction:column;gap:var(--co-spacing-md, 12px);margin-bottom:var(--co-spacing-md, 12px)}.co-rich-text-toolbar__table-field{display:flex;align-items:center;gap:var(--co-spacing-md, 12px)}.co-rich-text-toolbar__table-field label{font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14, 14px);color:var(--co-semantic-text-default, #333);min-width:70px}.co-rich-text-toolbar__table-field input{flex:1;padding:var(--co-spacing-sm, 8px) var(--co-spacing-md, 12px);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14, 14px);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xxs, 4px);background:var(--co-semantic-surface-secondary, #fff);outline:none}.co-rich-text-toolbar__table-field input:focus{border-color:var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__table-check{display:flex;align-items:center;gap:var(--co-spacing-sm, 8px);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-14, 14px);color:var(--co-semantic-text-default, #333);cursor:pointer;margin-bottom:var(--co-spacing-md, 12px)}.co-rich-text-toolbar__table-check input{width:18px;height:18px;cursor:pointer;accent-color:var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__table-actions{display:flex;gap:var(--co-spacing-sm, 8px);justify-content:flex-end}.co-rich-text-toolbar__table-btn{padding:var(--co-spacing-sm, 8px) var(--co-spacing-lg, 16px);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-13, 13px);font-weight:500;border:none;border-radius:var(--co-border-radius-xxs, 4px);cursor:pointer;transition:opacity 0.12s}.co-rich-text-toolbar__table-btn--primary{background:var(--co-color-base-negro, #1a1a1a);color:var(--co-color-base-blanco, #fff)}.co-rich-text-toolbar__table-btn--primary:hover{opacity:0.85}.co-rich-text-toolbar__table-btn--secondary{background:transparent;color:var(--co-semantic-text-default, #333)}.co-rich-text-toolbar__table-btn--secondary:hover{background:var(--co-semantic-surface-hover, #f5f5f5)}.co-rich-text-toolbar__split-wrap{position:relative;display:inline-flex;align-items:center}.co-rich-text-toolbar__split-main{border-top-right-radius:0;border-bottom-right-radius:0;width:28px}.co-rich-text-toolbar__split-caret{display:inline-flex;align-items:center;justify-content:center;width:16px;height:30px;padding:0;border:none;border-radius:var(--co-border-radius-xxs);border-top-left-radius:0;border-bottom-left-radius:0;background:transparent;color:var(--co-semantic-text-default, #333);cursor:pointer;transition:background 0.12s ease}.co-rich-text-toolbar__split-caret:hover:not(:disabled),.co-rich-text-toolbar__split-caret--open{background:var(--co-semantic-surface-hover, rgba(0, 0, 0, 0.08))}.co-rich-text-toolbar__split-caret:disabled{opacity:0.4;cursor:not-allowed}.co-rich-text-toolbar__listpicker{position:absolute;top:100%;left:0;z-index:100;display:grid;grid-template-columns:repeat(3, 1fr);gap:14px;padding:16px;background:var(--co-semantic-surface-secondary, #fff);border:1px solid var(--co-semantic-border-default, #e0e0e0);border-radius:var(--co-border-radius-xs, 8px);box-shadow:0 8px 24px rgba(0, 0, 0, 0.14);margin-top:var(--co-spacing-xs, 4px)}.co-rich-text-toolbar__listpicker-item{display:flex;align-items:center;justify-content:flex-start;width:76px;height:60px;padding:0;border:1px solid var(--co-semantic-border-default, #e3e3e3);border-radius:8px;background:var(--co-semantic-surface-secondary, #fff);cursor:pointer;transition:border-color 0.12s, box-shadow 0.12s, background 0.12s}.co-rich-text-toolbar__listpicker-item:hover{border-color:var(--co-color-base-negro, #1a1a1a);background:var(--co-semantic-surface-hover, #fafafa)}.co-rich-text-toolbar__listpicker-item--active{border-color:var(--co-color-base-negro, #1a1a1a);box-shadow:0 0 0 1.5px var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__listpicker-preview{margin:0;padding:0 0 0 22px;list-style-position:outside;pointer-events:none}.co-rich-text-toolbar__listpicker-preview li{height:3px;width:30px;margin:7px 0;background:var(--co-semantic-border-default, #cfcfcf);border-radius:2px}.co-rich-text-toolbar__listpicker-preview li::marker{color:var(--co-color-base-negro, #1a1a1a);font-size:11px;font-weight:600}.co-rich-text-toolbar__listpicker--task{grid-template-columns:repeat(2, 1fr)}.co-rich-text-toolbar__listpicker-item--task{width:92px;justify-content:center}.co-rich-text-toolbar__taskpreview{display:flex;flex-direction:column;gap:9px}.co-rich-text-toolbar__taskpreview-row{display:flex;align-items:center;gap:7px}.co-rich-text-toolbar__taskpreview-box{flex:0 0 auto;width:11px;height:11px;border:1.5px solid var(--co-color-base-negro, #1a1a1a);border-radius:3px;box-sizing:border-box}.co-rich-text-toolbar__taskpreview-box--checked{position:relative;background:var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__taskpreview-box--checked::after{content:'';position:absolute;left:3px;top:0.5px;width:3px;height:6px;border:solid #fff;border-width:0 1.5px 1.5px 0;transform:rotate(45deg)}.co-rich-text-toolbar__taskpreview-line{position:relative;width:34px;height:3px;background:var(--co-semantic-border-default, #cfcfcf);border-radius:2px}.co-rich-text-toolbar__taskpreview[data-variant="strike"] .co-rich-text-toolbar__taskpreview-row--checked .co-rich-text-toolbar__taskpreview-line::after{content:'';position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);height:1.5px;background:var(--co-color-base-negro, #1a1a1a)}.co-rich-text-toolbar__dropdown-check{display:inline-flex;align-items:center;justify-content:center;width:18px;flex-shrink:0}.co-rich-text-toolbar__dropdown-item--active{background:var(--co-semantic-surface-hover, rgba(0, 0, 0, 0.04));font-weight:600}.co-rich-text-toolbar__align-group{display:inline-flex;align-items:center;gap:0}.co-rich-text-toolbar__color-indicator{display:flex;flex-direction:column;align-items:center;gap:1px;line-height:1}.co-rich-text-toolbar__color-letter{font-family:var(--co-font-family-primary);font-size:14px;font-weight:700;color:var(--co-semantic-text-default, #333);line-height:1}.co-rich-text-toolbar__color-bar{width:14px;height:3px;border-radius:1px}.co-rich-text-toolbar__color-hex{display:flex;align-items:center;gap:4px;margin-top:6px}.co-rich-text-toolbar__color-hex-input{width:100%;padding:3px 6px;border:1px solid var(--co-semantic-border-default, #ccc);border-radius:3px;background:var(--co-semantic-surface-secondary, #fff);color:var(--co-semantic-text-default, #333);font-family:var(--co-font-family-mono, monospace);font-size:11px;outline:none;box-sizing:border-box}.co-rich-text-toolbar__color-hex-input:focus{border-color:var(--co-color-base-negro, #1a1a1a);box-shadow:0 0 0 2px rgba(0, 0, 0, 0.1)}`;
4
6
 
5
7
  const CoRichTextToolbar = class {
6
8
  constructor(hostRef) {
7
9
  registerInstance(this, hostRef);
8
10
  this.coAction = createEvent(this, "coAction", 7);
11
+ this.coPopoverChange = createEvent(this, "coPopoverChange", 7);
9
12
  /** Toolbar layout variant. */
10
13
  this.variant = 'basic';
11
14
  this.disabled = false;
15
+ /** BCP-47 locale for UI strings (e.g. 'en', 'es-CO', 'pt-BR'). Default English. */
16
+ this.locale = 'en';
12
17
  this.items = [];
13
18
  /** Bumped on every editor transaction to refresh active state. */
14
19
  this.tick = 0;
15
- this.onTransaction = () => { this.tick++; };
20
+ /** Currently open popover/dropdown (action id) or null. */
21
+ this.openPopover = null;
22
+ /** Input value for popover forms (link URL, image URL, etc.). */
23
+ this.popoverInput = '';
24
+ /** Table grid picker state. */
25
+ this.gridHoverRows = 0;
26
+ this.gridHoverCols = 0;
27
+ this.gridLockedRows = 0;
28
+ this.gridLockedCols = 0;
29
+ this.tableTab = 'grid';
30
+ this.tableManualRows = 3;
31
+ this.tableManualCols = 3;
32
+ this.tableWithHeader = false;
33
+ /** Table context items shown when cursor is inside a table. */
34
+ this.tableContextItems = [];
35
+ /** Image popover sub-view: 'menu' shows options, 'url' shows URL input. */
36
+ this.imagePopoverMode = 'menu';
37
+ /** Hex input for toolbar color picker. */
38
+ this.colorHexInput = '';
39
+ this.onTransaction = () => {
40
+ this.tick++;
41
+ // Show/hide table context buttons based on whether cursor is in a table
42
+ this.updateTableContext();
43
+ };
44
+ this.colorPalette = [];
45
+ this._tableContextItems = [];
46
+ /**
47
+ * Prevent toolbar clicks from stealing focus from the editor.
48
+ * This handler is on the HOST element (light DOM), which reliably
49
+ * prevents focus change even when Shadow DOM retargets events.
50
+ */
51
+ this.handleHostMouseDown = (e) => {
52
+ const path = e.composedPath();
53
+ const isInput = path.some(n => n instanceof HTMLElement && n.tagName === 'INPUT');
54
+ if (!isInput)
55
+ e.preventDefault();
56
+ };
57
+ this.handleDocumentClick = (e) => {
58
+ if (!this.openPopover)
59
+ return;
60
+ if (this.el.contains(e.target))
61
+ return;
62
+ this.closePopover();
63
+ };
16
64
  this.run = (item) => {
17
65
  const editor = this.editor;
18
66
  if (!editor || this.disabled)
19
67
  return;
20
- // Cast: link/undo/redo command types are registered by their extensions,
21
- // which are bundled via StarterKit and not visible to core's TS view.
22
68
  const chain = editor.chain().focus();
23
69
  switch (item.action) {
24
70
  case 'bold':
@@ -42,141 +88,1019 @@ const CoRichTextToolbar = class {
42
88
  case 'orderedList':
43
89
  chain.toggleOrderedList().run();
44
90
  break;
91
+ // Split-button main area: toggle the list on/off (caret opens styles)
92
+ case 'bulletListMenu':
93
+ chain.toggleBulletList().run();
94
+ break;
95
+ case 'orderedListMenu':
96
+ chain.toggleOrderedList().run();
97
+ break;
98
+ case 'taskListMenu':
99
+ chain.toggleTaskList().run();
100
+ break;
45
101
  case 'blockquote':
46
102
  chain.toggleBlockquote().run();
47
103
  break;
104
+ case 'codeBlock':
105
+ chain.toggleCodeBlock().run();
106
+ break;
48
107
  case 'heading':
49
108
  chain.toggleHeading(item.payload).run();
50
109
  break;
110
+ case 'horizontalRule':
111
+ chain.setHorizontalRule().run();
112
+ break;
113
+ case 'textAlign':
114
+ chain.setTextAlign(item.payload).run();
115
+ break;
51
116
  case 'undo':
52
117
  chain.undo().run();
53
118
  break;
54
119
  case 'redo':
55
120
  chain.redo().run();
56
121
  break;
57
- case 'link':
58
- this.toggleLink();
122
+ // Table context operations
123
+ case 'addColumnAfter':
124
+ chain.addColumnAfter().run();
59
125
  break;
60
- case 'image':
61
- this.insertImage();
126
+ case 'addColumnBefore':
127
+ chain.addColumnBefore().run();
128
+ break;
129
+ case 'deleteColumn':
130
+ chain.deleteColumn().run();
131
+ break;
132
+ case 'addRowAfter':
133
+ chain.addRowAfter().run();
134
+ break;
135
+ case 'addRowBefore':
136
+ chain.addRowBefore().run();
137
+ break;
138
+ case 'deleteRow':
139
+ chain.deleteRow().run();
140
+ break;
141
+ case 'deleteTable':
142
+ chain.deleteTable().run();
143
+ break;
144
+ case 'mergeCells':
145
+ chain.mergeCells().run();
146
+ break;
147
+ case 'splitCell':
148
+ chain.splitCell().run();
149
+ break;
150
+ case 'toggleHeaderRow':
151
+ chain.toggleHeaderRow().run();
152
+ break;
153
+ // popover/dropdown/color/grid actions are handled via toggle
154
+ case 'indentIncrease':
155
+ if (editor.isActive('bulletList') || editor.isActive('orderedList')) {
156
+ chain.sinkListItem('listItem').run();
157
+ }
158
+ else {
159
+ chain.indent().run();
160
+ }
62
161
  break;
162
+ case 'indentDecrease':
163
+ if (editor.isActive('bulletList') || editor.isActive('orderedList')) {
164
+ chain.liftListItem('listItem').run();
165
+ }
166
+ else {
167
+ chain.outdent().run();
168
+ }
169
+ break;
170
+ case 'link':
171
+ case 'image':
172
+ case 'youtube':
173
+ case 'iframe':
174
+ case 'callout':
175
+ case 'fontSize':
176
+ case 'fontFamily':
177
+ case 'headingStyle':
178
+ case 'lineSpacing':
179
+ case 'letterSpacing':
180
+ case 'table':
181
+ case 'textColor':
182
+ case 'highlight':
183
+ this.togglePopover(item.action);
184
+ return; // don't emit action yet
63
185
  default: chain.run();
64
186
  }
65
187
  this.coAction.emit({ action: item.action, payload: item.payload });
66
188
  };
67
189
  }
68
- async componentWillLoad() {
69
- const rt = await import('./index-BjAqSidM.js');
70
- this.items = rt.toolbarItems(this.variant === 'none' ? 'compact' : this.variant);
190
+ get s() {
191
+ return getRichTextStrings(this.locale);
71
192
  }
72
- async onVariantChange(v) {
73
- const rt = await import('./index-BjAqSidM.js');
74
- this.items = rt.toolbarItems((v === 'none' ? 'compact' : v));
193
+ tItem(item) {
194
+ var _a;
195
+ const s = this.s;
196
+ const map = {
197
+ bold: s.bold, italic: s.italic, underline: s.underline,
198
+ strike: s.strikethrough, code: s.code, headingStyle: s.styles,
199
+ fontSize: s.fontSize, fontFamily: s.font,
200
+ bulletList: s.bulletList, orderedList: s.orderedList,
201
+ bulletListMenu: s.bulletList, orderedListMenu: s.orderedList,
202
+ taskListMenu: s.taskList,
203
+ blockquote: s.quote, codeBlock: s.codeBlock,
204
+ horizontalRule: s.horizontalRule,
205
+ link: s.link, image: s.image, youtube: s.youtubeVideo, iframe: s.iframeEmbed,
206
+ table: s.table, textColor: s.textColor, highlight: s.highlight,
207
+ alignment: s.alignment, lineSpacing: s.lineSpacing,
208
+ letterSpacing: s.letterSpacing,
209
+ indentIncrease: s.increaseIndent, indentDecrease: s.decreaseIndent,
210
+ callout: s.callout, undo: s.undo, redo: s.redo,
211
+ addColumnAfter: s.addColumnAfter, addColumnBefore: s.addColumnBefore,
212
+ deleteColumn: s.deleteColumn, addRowAfter: s.addRowAfter,
213
+ addRowBefore: s.addRowBefore, deleteRow: s.deleteRow,
214
+ deleteTable: s.deleteTable, mergeCells: s.mergeCells,
215
+ splitCell: s.splitCell, toggleHeaderRow: s.headerRow,
216
+ };
217
+ return (_a = map[item.action]) !== null && _a !== void 0 ? _a : item.label;
218
+ }
219
+ tOpt(opt) {
220
+ var _a, _b, _c, _d, _e;
221
+ const s = this.s;
222
+ if (opt.action === 'separator')
223
+ return `─── ${s.systemFonts} ───`;
224
+ if (opt.action === 'paragraph')
225
+ return s.normalText;
226
+ if (opt.action === 'heading') {
227
+ const level = (_a = opt.payload) === null || _a === void 0 ? void 0 : _a.level;
228
+ if (level === 1)
229
+ return s.title;
230
+ if (level === 2)
231
+ return s.subtitle;
232
+ if (level === 3)
233
+ return s.heading3;
234
+ }
235
+ if (opt.action === 'bulletStyle') {
236
+ const m = { disc: s.disc, circle: s.circle, square: s.square };
237
+ return (_b = m[opt.payload]) !== null && _b !== void 0 ? _b : opt.label;
238
+ }
239
+ if (opt.action === 'taskStyle') {
240
+ if (opt.payload === 'strike')
241
+ return s.strikeOnComplete;
242
+ if (opt.payload === 'plain')
243
+ return s.noStrikethrough;
244
+ }
245
+ if (opt.action === 'textAlign') {
246
+ const m = { left: s.left, center: s.center, right: s.right, justify: s.justify };
247
+ return (_c = m[opt.payload]) !== null && _c !== void 0 ? _c : opt.label;
248
+ }
249
+ if (opt.action === 'lineHeight') {
250
+ if (opt.payload === '1')
251
+ return s.single;
252
+ if (opt.payload === '2')
253
+ return s.double;
254
+ }
255
+ if (opt.action === 'letterSpacing') {
256
+ const m = { normal: s.normal, '-0.05em': s.tight, '0.05em': s.light, '0.1em': s.wide, '0.2em': s.veryWide };
257
+ return (_d = m[opt.payload]) !== null && _d !== void 0 ? _d : opt.label;
258
+ }
259
+ if (opt.action === 'callout') {
260
+ const m = { info: s.info, warning: s.warning, success: s.success, error: s.error };
261
+ return (_e = m[opt.payload]) !== null && _e !== void 0 ? _e : opt.label;
262
+ }
263
+ return opt.label;
264
+ }
265
+ connectedCallback() {
266
+ this.el.addEventListener('mousedown', this.handleHostMouseDown);
267
+ document.addEventListener('click', this.handleDocumentClick, true);
268
+ }
269
+ componentWillLoad() {
270
+ this.items = this.resolveItems(this.variant);
271
+ this.colorPalette = COLOR_PALETTE;
272
+ this._tableContextItems = TABLE_CONTEXT_ITEMS;
273
+ }
274
+ onVariantChange(v) {
275
+ this.items = this.resolveItems(v);
75
276
  }
76
277
  onEditorChange(next, prev) {
77
278
  prev === null || prev === void 0 ? void 0 : prev.off('transaction', this.onTransaction);
78
279
  next === null || next === void 0 ? void 0 : next.on('transaction', this.onTransaction);
280
+ // The active preset decides which extensions are loaded; re-filter now that
281
+ // we can inspect the editor so a toolbar variant wider than the schema
282
+ // (e.g. `full` on a preset without tables/images) drops the dead buttons.
283
+ this.items = this.resolveItems(this.variant);
79
284
  this.tick++;
80
285
  }
286
+ /**
287
+ * Resolve a variant to the items actually usable in the current editor:
288
+ * hide any control whose extension the active preset didn't load, then
289
+ * collapse the separators left dangling by the removals. Until the editor is
290
+ * wired we can't inspect the schema, so the full variant is shown and
291
+ * re-filtered from `onEditorChange`.
292
+ */
293
+ resolveItems(variant) {
294
+ const base = toolbarItems((variant === 'none' ? 'compact' : variant));
295
+ const editor = this.editor;
296
+ if (!editor)
297
+ return base;
298
+ const available = (cmd) => {
299
+ try {
300
+ return typeof editor.can()[cmd] === 'function';
301
+ }
302
+ catch (_a) {
303
+ return true; // never hide a control because a probe threw
304
+ }
305
+ };
306
+ const kept = base.filter((entry) => {
307
+ if (this.isSeparator(entry))
308
+ return true;
309
+ const cmd = CoRichTextToolbar.ITEM_COMMAND[entry.action];
310
+ return cmd ? available(cmd) : true;
311
+ });
312
+ // Drop separators that ended up leading, trailing, or doubled-up.
313
+ const out = [];
314
+ for (const entry of kept) {
315
+ if (this.isSeparator(entry) && (!out.length || this.isSeparator(out[out.length - 1])))
316
+ continue;
317
+ out.push(entry);
318
+ }
319
+ if (out.length && this.isSeparator(out[out.length - 1]))
320
+ out.pop();
321
+ return out;
322
+ }
323
+ onOpenPopoverChange(next, prev) {
324
+ if (!!next === !!prev)
325
+ return;
326
+ this.coPopoverChange.emit({ open: !!next });
327
+ }
81
328
  disconnectedCallback() {
82
329
  var _a;
83
330
  (_a = this.editor) === null || _a === void 0 ? void 0 : _a.off('transaction', this.onTransaction);
331
+ this.el.removeEventListener('mousedown', this.handleHostMouseDown);
332
+ document.removeEventListener('click', this.handleDocumentClick, true);
333
+ }
334
+ updateTableContext() {
335
+ if (!this.editor) {
336
+ if (this.tableContextItems.length)
337
+ this.tableContextItems = [];
338
+ return;
339
+ }
340
+ const isInTable = this.editor.isActive('table');
341
+ if (isInTable && !this.tableContextItems.length) {
342
+ this.tableContextItems = this._tableContextItems;
343
+ }
344
+ else if (!isInTable && this.tableContextItems.length) {
345
+ this.tableContextItems = [];
346
+ }
347
+ }
348
+ isSeparator(entry) {
349
+ return entry.type === 'separator';
84
350
  }
85
351
  isActive(item) {
86
352
  if (!this.editor)
87
353
  return false;
88
- if (item.type !== 'toggle')
89
- return false;
90
354
  try {
91
- return this.editor.isActive(item.action, item.payload);
355
+ if (item.action === 'textAlign')
356
+ return this.editor.isActive({ textAlign: item.payload });
357
+ if (item.action === 'heading')
358
+ return this.editor.isActive('heading', item.payload);
359
+ if (item.action === 'bulletListMenu')
360
+ return this.editor.isActive('bulletList');
361
+ if (item.action === 'orderedListMenu')
362
+ return this.editor.isActive('orderedList');
363
+ if (item.action === 'taskListMenu')
364
+ return this.editor.isActive('taskList');
365
+ if (item.action === 'iframe')
366
+ return this.editor.isActive('iframe');
367
+ if (item.action === 'youtube')
368
+ return this.editor.isActive('youtube');
369
+ if (item.type === 'toggle')
370
+ return this.editor.isActive(item.action);
371
+ }
372
+ catch ( /* ignore */_a) { /* ignore */ }
373
+ return false;
374
+ }
375
+ /** Toolbar icon that reflects current state (e.g. alignment shows the active alignment). */
376
+ getDynamicIcon(item) {
377
+ if (item.action === 'alignment' && this.editor) {
378
+ if (this.editor.isActive({ textAlign: 'center' }))
379
+ return 'text-align-center';
380
+ if (this.editor.isActive({ textAlign: 'right' }))
381
+ return 'text-align-right';
382
+ if (this.editor.isActive({ textAlign: 'justify' }))
383
+ return 'text-align-justify';
384
+ return 'text-align-left';
385
+ }
386
+ return item.icon;
387
+ }
388
+ togglePopover(action) {
389
+ var _a, _b;
390
+ if (this.openPopover === action) {
391
+ this.openPopover = null;
392
+ this.popoverInput = '';
393
+ }
394
+ else {
395
+ this.openPopover = action;
396
+ this.popoverInput = '';
397
+ // Pre-fill URL if editing existing link or iframe
398
+ if (action === 'link' && ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.isActive('link'))) {
399
+ this.popoverInput = this.editor.getAttributes('link').href || '';
400
+ }
401
+ else if (action === 'iframe' && ((_b = this.editor) === null || _b === void 0 ? void 0 : _b.isActive('iframe'))) {
402
+ this.popoverInput = this.editor.getAttributes('iframe').src || '';
403
+ }
404
+ }
405
+ }
406
+ closePopover() {
407
+ this.openPopover = null;
408
+ this.popoverInput = '';
409
+ this.colorHexInput = '';
410
+ this.imagePopoverMode = 'menu';
411
+ this.gridLockedRows = 0;
412
+ this.gridLockedCols = 0;
413
+ this.gridHoverRows = 0;
414
+ this.gridHoverCols = 0;
415
+ }
416
+ submitPopover(action) {
417
+ const editor = this.editor;
418
+ if (!editor || !this.popoverInput.trim()) {
419
+ this.closePopover();
420
+ return;
421
+ }
422
+ const url = this.popoverInput.trim();
423
+ const isEmbed = action === 'youtube' || action === 'iframe';
424
+ if (isEmbed) {
425
+ editor.view.focus();
426
+ }
427
+ const chain = isEmbed
428
+ ? editor.chain()
429
+ : editor.chain().focus();
430
+ switch (action) {
431
+ case 'link':
432
+ chain.setLink({ href: url }).run();
433
+ break;
434
+ case 'image':
435
+ chain.setImage({ src: url }).run();
436
+ break;
437
+ case 'youtube':
438
+ chain.setYoutubeVideo({ src: url }).run();
439
+ break;
440
+ case 'iframe':
441
+ if (editor.isActive('iframe')) {
442
+ chain.updateIframe({ src: url }).run();
443
+ }
444
+ else {
445
+ chain.setIframe({ src: url }).run();
446
+ }
447
+ break;
448
+ }
449
+ this.coAction.emit({ action, payload: url });
450
+ this.closePopover();
451
+ if (isEmbed)
452
+ this.smoothScrollToInserted();
453
+ }
454
+ smoothScrollToInserted() {
455
+ requestAnimationFrame(() => {
456
+ const editor = this.editor;
457
+ if (!editor)
458
+ return;
459
+ const dom = editor.view.dom;
460
+ const selected = dom.querySelector('.ProseMirror-selectednode');
461
+ if (selected) {
462
+ selected.scrollIntoView({ behavior: 'smooth', block: 'center' });
463
+ return;
464
+ }
465
+ const { from } = editor.state.selection;
466
+ const resolved = editor.state.doc.resolve(from);
467
+ if (resolved.nodeBefore) {
468
+ try {
469
+ const nodeDom = editor.view.nodeDOM(from - resolved.nodeBefore.nodeSize);
470
+ if (nodeDom instanceof HTMLElement) {
471
+ nodeDom.scrollIntoView({ behavior: 'smooth', block: 'center' });
472
+ }
473
+ }
474
+ catch ( /* ignore */_a) { /* ignore */ }
475
+ }
476
+ });
477
+ }
478
+ removeLink() {
479
+ const editor = this.editor;
480
+ if (!editor)
481
+ return;
482
+ editor.chain().focus().unsetLink().run();
483
+ this.coAction.emit({ action: 'link', payload: null });
484
+ this.closePopover();
485
+ }
486
+ removeIframe() {
487
+ const editor = this.editor;
488
+ if (!editor)
489
+ return;
490
+ editor.chain().focus().deleteSelection().run();
491
+ this.coAction.emit({ action: 'iframe', payload: null });
492
+ this.closePopover();
493
+ }
494
+ selectColor(action, color) {
495
+ const editor = this.editor;
496
+ if (!editor)
497
+ return;
498
+ const chain = editor.chain().focus();
499
+ if (action === 'textColor') {
500
+ chain.setColor(color).run();
501
+ }
502
+ else if (action === 'highlight') {
503
+ chain.setHighlight({ color }).run();
504
+ }
505
+ this.coAction.emit({ action, payload: color });
506
+ this.closePopover();
507
+ }
508
+ clearColor(action) {
509
+ const editor = this.editor;
510
+ if (!editor)
511
+ return;
512
+ const chain = editor.chain().focus();
513
+ if (action === 'textColor') {
514
+ chain.unsetColor().run();
515
+ }
516
+ else if (action === 'highlight') {
517
+ chain.unsetHighlight().run();
92
518
  }
93
- catch (_a) {
519
+ this.coAction.emit({ action, payload: null });
520
+ this.closePopover();
521
+ }
522
+ /**
523
+ * Whether an action is allowed in the current selection. Beyond undo/redo,
524
+ * this disables commands that would produce content the editor can't
525
+ * represent — most importantly the Table button while the cursor is already
526
+ * inside a table, since nested tables are invalid and corrupt the document
527
+ * when it's reloaded (tiptap throws "Invalid HTML content" on such markup).
528
+ *
529
+ * Each command is probed through tiptap's `can()` dry-run, so a button also
530
+ * disables automatically anywhere ProseMirror's schema would reject it (e.g.
531
+ * marks inside a code block). The probe defaults to enabled on any error or
532
+ * unknown command so a quirk never makes a control silently disappear.
533
+ */
534
+ /**
535
+ * Whether an action can run *right now*. Extension availability is already
536
+ * handled by `resolveItems` (unavailable controls aren't rendered), so this
537
+ * only covers the dynamic, cursor-dependent cases: the hard "no table inside
538
+ * a table" rule, and position validity (e.g. marks inside a code block) via
539
+ * tiptap's `can()` dry-run. A thrown dry-run defaults to enabled so a quirk
540
+ * never makes a visible control silently lock up.
541
+ */
542
+ canRun(item) {
543
+ if (!this.editor || this.disabled)
94
544
  return false;
545
+ const editor = this.editor;
546
+ const can = editor.can();
547
+ const probe = (name, ...args) => {
548
+ if (typeof can[name] !== 'function')
549
+ return true;
550
+ try {
551
+ return can[name](...args);
552
+ }
553
+ catch (_a) {
554
+ return true;
555
+ }
556
+ };
557
+ switch (item.action) {
558
+ case 'undo': return probe('undo');
559
+ case 'redo': return probe('redo');
560
+ // Hard rule: a table can never nest inside another table.
561
+ case 'table': return !editor.isActive('table');
562
+ case 'bold': return probe('toggleBold');
563
+ case 'italic': return probe('toggleItalic');
564
+ case 'underline': return probe('toggleUnderline');
565
+ case 'strike': return probe('toggleStrike');
566
+ case 'code': return probe('toggleCode');
567
+ case 'blockquote': return probe('toggleBlockquote');
568
+ case 'codeBlock': return probe('toggleCodeBlock');
569
+ case 'horizontalRule': return probe('setHorizontalRule');
570
+ case 'bulletList':
571
+ case 'bulletListMenu': return probe('toggleBulletList');
572
+ case 'orderedList':
573
+ case 'orderedListMenu': return probe('toggleOrderedList');
574
+ case 'taskListMenu': return probe('toggleTaskList');
575
+ default: return true;
576
+ }
577
+ }
578
+ getDropdownLabel(item) {
579
+ if (!this.editor)
580
+ return null;
581
+ const s = this.s;
582
+ if (item.action === 'headingStyle') {
583
+ if (this.editor.isActive('heading', { level: 1 }))
584
+ return s.title;
585
+ if (this.editor.isActive('heading', { level: 2 }))
586
+ return s.subtitle;
587
+ if (this.editor.isActive('heading', { level: 3 }))
588
+ return s.headingAbbr3;
589
+ return s.normal;
95
590
  }
591
+ if (item.action === 'fontSize') {
592
+ const attrs = this.editor.getAttributes('textStyle');
593
+ const fs = attrs === null || attrs === void 0 ? void 0 : attrs.fontSize;
594
+ return fs ? fs.replace('px', '') : '16';
595
+ }
596
+ if (item.action === 'fontFamily') {
597
+ const attrs = this.editor.getAttributes('textStyle');
598
+ const ff = attrs === null || attrs === void 0 ? void 0 : attrs.fontFamily;
599
+ if (!ff)
600
+ return 'Sans-serif';
601
+ const match = ff.replace(/['"]/g, '').split(',')[0].trim();
602
+ return match.length > 10 ? match.substring(0, 10) + '…' : match;
603
+ }
604
+ return null;
605
+ }
606
+ getActiveColor(action) {
607
+ var _a, _b;
608
+ if (!this.editor)
609
+ return action === 'textColor' ? '#000000' : 'transparent';
610
+ const attrs = this.editor.getAttributes('textStyle');
611
+ if (action === 'textColor')
612
+ return (_a = attrs === null || attrs === void 0 ? void 0 : attrs.color) !== null && _a !== void 0 ? _a : '#000000';
613
+ const hlAttrs = this.editor.getAttributes('highlight');
614
+ return (_b = hlAttrs === null || hlAttrs === void 0 ? void 0 : hlAttrs.color) !== null && _b !== void 0 ? _b : 'transparent';
96
615
  }
97
- /** Accept only fetchable URL schemes from the prompt (no javascript: etc.). */
98
- static safeUrl(raw, schemes) {
616
+ renderButton(item) {
99
617
  var _a, _b;
100
- const url = raw === null || raw === void 0 ? void 0 : raw.trim();
101
- if (!url)
618
+ const isPopoverType = item.type === 'popover' || item.type === 'dropdown' || item.type === 'color' || item.type === 'grid';
619
+ const isOpen = this.openPopover === item.action;
620
+ const isLabelDropdown = item.action === 'headingStyle' || item.action === 'fontSize' || item.action === 'fontFamily';
621
+ const dropdownLabel = isLabelDropdown ? this.getDropdownLabel(item) : null;
622
+ // Alignment: render as icon-only button group (Google Docs style)
623
+ if (item.action === 'alignment' && ((_a = item.options) === null || _a === void 0 ? void 0 : _a.length)) {
624
+ return this.renderAlignmentGroup(item);
625
+ }
626
+ // Split button: main area toggles, caret opens the marker-style grid.
627
+ if (item.type === 'listpicker') {
628
+ const active = this.isActive(item);
629
+ const label = this.tItem(item);
630
+ return (h("div", { class: "co-rich-text-toolbar__split-wrap", key: item.action }, h("button", { type: "button", class: {
631
+ 'co-rich-text-toolbar__btn': true,
632
+ 'co-rich-text-toolbar__split-main': true,
633
+ 'co-rich-text-toolbar__btn--active': active,
634
+ }, "data-tooltip": label, "aria-label": label, "aria-pressed": String(active), disabled: !this.canRun(item), onMouseDown: (e) => e.preventDefault(), onClick: () => this.run(item), part: "button" }, h("co-icon", { name: item.icon, size: 18 })), h("button", { type: "button", class: {
635
+ 'co-rich-text-toolbar__split-caret': true,
636
+ 'co-rich-text-toolbar__split-caret--open': isOpen,
637
+ }, "data-tooltip": `${this.s.stylesPrefix} ${label}`, "aria-label": `${this.s.stylesPrefix} ${label}`, "aria-expanded": String(isOpen), disabled: !this.canRun(item), onMouseDown: (e) => e.preventDefault(), onClick: () => this.togglePopover(item.action) }, h("co-icon", { name: "caret-down", size: 10 })), isOpen && this.renderListPicker(item)));
638
+ }
639
+ // Color buttons: render with color indicator bar
640
+ if (item.type === 'color') {
641
+ return this.renderColorButton(item);
642
+ }
643
+ const itemLabel = this.tItem(item);
644
+ return (h("div", { class: "co-rich-text-toolbar__btn-wrap", key: `${item.action}-${JSON.stringify((_b = item.payload) !== null && _b !== void 0 ? _b : '')}` }, isLabelDropdown ? (h("button", { type: "button", class: {
645
+ 'co-rich-text-toolbar__select-btn': true,
646
+ 'co-rich-text-toolbar__select-btn--open': isOpen,
647
+ }, "data-tooltip": itemLabel, "aria-label": itemLabel, "aria-expanded": String(isOpen), disabled: !this.canRun(item), onMouseDown: (e) => e.preventDefault(), onClick: () => this.run(item), part: "button" }, h("span", { class: "co-rich-text-toolbar__select-label" }, dropdownLabel), h("co-icon", { name: "caret-down", size: 10 }))) : (h("button", { type: "button", class: {
648
+ 'co-rich-text-toolbar__btn': true,
649
+ 'co-rich-text-toolbar__btn--active': this.isActive(item) || isOpen,
650
+ }, "data-tooltip": itemLabel, "aria-label": itemLabel, "aria-pressed": item.type === 'toggle' ? String(this.isActive(item)) : undefined, "aria-expanded": isPopoverType ? String(isOpen) : undefined, disabled: !this.canRun(item), onMouseDown: (e) => e.preventDefault(), onClick: () => this.run(item), part: "button" }, h("co-icon", { name: this.getDynamicIcon(item), size: 18 }))), isOpen && item.type === 'popover' && this.renderInputPopover(item), isOpen && item.type === 'dropdown' && this.renderDropdown(item), isOpen && item.type === 'grid' && this.renderTableGrid()));
651
+ }
652
+ renderAlignmentGroup(item) {
653
+ const s = this.s;
654
+ const alignLabels = {
655
+ left: s.alignLeft, center: s.center, right: s.alignRight, justify: s.justify,
656
+ };
657
+ return (h("div", { class: "co-rich-text-toolbar__align-group", key: item.action }, item.options.map((opt) => {
658
+ var _a, _b, _c;
659
+ const active = (_b = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.isActive({ textAlign: opt.payload })) !== null && _b !== void 0 ? _b : false;
660
+ const label = (_c = alignLabels[opt.payload]) !== null && _c !== void 0 ? _c : opt.label;
661
+ return (h("button", { type: "button", class: {
662
+ 'co-rich-text-toolbar__btn': true,
663
+ 'co-rich-text-toolbar__btn--active': active,
664
+ }, "data-tooltip": label, "aria-label": label, "aria-pressed": String(active), disabled: !this.editor || this.disabled, onMouseDown: (e) => e.preventDefault(), onClick: () => {
665
+ if (!this.editor)
666
+ return;
667
+ this.editor.chain().focus().setTextAlign(opt.payload).run();
668
+ this.coAction.emit({ action: 'textAlign', payload: opt.payload });
669
+ }, part: "button" }, h("co-icon", { name: opt.icon, size: 18 })));
670
+ })));
671
+ }
672
+ renderColorButton(item) {
673
+ const isOpen = this.openPopover === item.action;
674
+ const itemLabel = this.tItem(item);
675
+ const activeColor = this.getActiveColor(item.action);
676
+ const isTextColor = item.action === 'textColor';
677
+ return (h("div", { class: "co-rich-text-toolbar__btn-wrap", key: item.action }, h("button", { type: "button", class: {
678
+ 'co-rich-text-toolbar__btn': true,
679
+ 'co-rich-text-toolbar__btn--active': isOpen,
680
+ }, "data-tooltip": itemLabel, "aria-label": itemLabel, "aria-expanded": String(isOpen), disabled: !this.canRun(item), onMouseDown: (e) => e.preventDefault(), onClick: () => this.run(item), part: "button" }, isTextColor ? (h("span", { class: "co-rich-text-toolbar__color-indicator" }, h("span", { class: "co-rich-text-toolbar__color-letter" }, "A"), h("span", { class: "co-rich-text-toolbar__color-bar", style: { background: activeColor } }))) : (h("span", { class: "co-rich-text-toolbar__color-indicator" }, h("co-icon", { name: item.icon, size: 16 }), h("span", { class: "co-rich-text-toolbar__color-bar", style: { background: activeColor === 'transparent' ? '#cccccc' : activeColor } })))), isOpen && this.renderColorPicker(item)));
681
+ }
682
+ /** Visual grid of list-marker styles (Google-Docs style). */
683
+ renderListPicker(item) {
684
+ var _a, _b;
685
+ if (!((_a = item.options) === null || _a === void 0 ? void 0 : _a.length))
102
686
  return null;
103
- const scheme = (_b = (_a = /^([a-z][a-z0-9+.-]*):/i.exec(url)) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.toLowerCase();
104
- if (!scheme)
105
- return url; // relative URL
106
- return schemes.includes(scheme) ? url : null;
687
+ if (item.action === 'taskListMenu')
688
+ return this.renderTaskListPicker(item);
689
+ const isOrdered = item.action === 'orderedListMenu';
690
+ const activeStyle = this.editor
691
+ ? (_b = this.editor.getAttributes(isOrdered ? 'orderedList' : 'bulletList')) === null || _b === void 0 ? void 0 : _b.listStyleType
692
+ : null;
693
+ return (h("div", { class: "co-rich-text-toolbar__listpicker", onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); } }, item.options.map((opt) => {
694
+ const isActive = activeStyle === opt.payload;
695
+ return (h("button", { type: "button", class: {
696
+ 'co-rich-text-toolbar__listpicker-item': true,
697
+ 'co-rich-text-toolbar__listpicker-item--active': isActive,
698
+ }, "data-tooltip": opt.label, onMouseDown: (e) => e.preventDefault(), onClick: () => this.applyListStyle(isOrdered, opt.payload) }, h("ol", { class: {
699
+ 'co-rich-text-toolbar__listpicker-preview': true,
700
+ 'co-rich-text-toolbar__listpicker-preview--ordered': isOrdered,
701
+ }, style: { 'list-style-type': opt.payload } }, h("li", null), h("li", null), h("li", null))));
702
+ })));
703
+ }
704
+ /** Visual picker for task-list variants (checkboxes; strike vs plain). */
705
+ renderTaskListPicker(item) {
706
+ var _a, _b;
707
+ const activeVariant = this.editor && this.editor.isActive('taskList')
708
+ ? ((_b = (_a = this.editor.getAttributes('taskList')) === null || _a === void 0 ? void 0 : _a.variant) !== null && _b !== void 0 ? _b : 'strike')
709
+ : null;
710
+ return (h("div", { class: "co-rich-text-toolbar__listpicker co-rich-text-toolbar__listpicker--task", onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); } }, item.options.map((opt) => {
711
+ const variant = opt.payload;
712
+ const isActive = activeVariant === variant;
713
+ return (h("button", { type: "button", class: {
714
+ 'co-rich-text-toolbar__listpicker-item': true,
715
+ 'co-rich-text-toolbar__listpicker-item--task': true,
716
+ 'co-rich-text-toolbar__listpicker-item--active': isActive,
717
+ }, "data-tooltip": opt.label, onMouseDown: (e) => e.preventDefault(), onClick: () => this.applyTaskStyle(variant) }, h("span", { class: "co-rich-text-toolbar__taskpreview", "data-variant": variant }, h("span", { class: "co-rich-text-toolbar__taskpreview-row" }, h("span", { class: "co-rich-text-toolbar__taskpreview-box" }), h("span", { class: "co-rich-text-toolbar__taskpreview-line" })), h("span", { class: "co-rich-text-toolbar__taskpreview-row co-rich-text-toolbar__taskpreview-row--checked" }, h("span", { class: "co-rich-text-toolbar__taskpreview-box co-rich-text-toolbar__taskpreview-box--checked" }), h("span", { class: "co-rich-text-toolbar__taskpreview-line" })))));
718
+ })));
107
719
  }
108
- toggleLink() {
720
+ applyListStyle(isOrdered, style) {
109
721
  const editor = this.editor;
110
722
  if (!editor)
111
723
  return;
112
724
  const chain = editor.chain().focus();
113
- if (editor.isActive('link')) {
114
- chain.unsetLink().run();
725
+ // Ensure the right list type is active, then apply the marker style.
726
+ if (isOrdered) {
727
+ if (!editor.isActive('orderedList'))
728
+ chain.toggleOrderedList();
729
+ }
730
+ else {
731
+ if (!editor.isActive('bulletList'))
732
+ chain.toggleBulletList();
733
+ }
734
+ chain.setListStyleType(style).run();
735
+ this.coAction.emit({ action: isOrdered ? 'orderedStyle' : 'bulletStyle', payload: style });
736
+ this.closePopover();
737
+ }
738
+ applyTaskStyle(variant) {
739
+ const editor = this.editor;
740
+ if (!editor)
741
+ return;
742
+ const chain = editor.chain().focus();
743
+ if (!editor.isActive('taskList'))
744
+ chain.toggleTaskList();
745
+ chain.setTaskListVariant(variant).run();
746
+ this.coAction.emit({ action: 'taskStyle', payload: variant });
747
+ this.closePopover();
748
+ }
749
+ renderInputPopover(item) {
750
+ var _a, _b;
751
+ if (item.action === 'image')
752
+ return this.renderImagePopover();
753
+ const isLink = item.action === 'link';
754
+ const isIframe = item.action === 'iframe';
755
+ const hasExisting = (isLink && ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.isActive('link'))) || (isIframe && ((_b = this.editor) === null || _b === void 0 ? void 0 : _b.isActive('iframe')));
756
+ const placeholder = item.action === 'iframe'
757
+ ? this.s.iframeUrlPlaceholder
758
+ : item.action === 'link'
759
+ ? 'https://...'
760
+ : this.s.youtubeUrlPlaceholder;
761
+ return (h("div", { class: "co-rich-text-toolbar__popover", onMouseDown: (e) => {
762
+ if (e.target.tagName !== 'INPUT')
763
+ e.preventDefault();
764
+ e.stopPropagation();
765
+ } }, h("input", { type: "url", class: "co-rich-text-toolbar__popover-input", placeholder: placeholder, value: this.popoverInput, onInput: (e) => { this.popoverInput = e.target.value; }, onKeyDown: (e) => {
766
+ if (e.key === 'Enter')
767
+ this.submitPopover(item.action);
768
+ if (e.key === 'Escape')
769
+ this.closePopover();
770
+ }, ref: (el) => el && setTimeout(() => el.focus(), 0) }), h("div", { class: "co-rich-text-toolbar__popover-actions" }, h("button", { type: "button", class: "co-rich-text-toolbar__popover-btn co-rich-text-toolbar__popover-btn--primary", onMouseDown: (e) => e.preventDefault(), onClick: () => this.submitPopover(item.action) }, this.s.add), hasExisting && (h("button", { type: "button", class: "co-rich-text-toolbar__popover-btn co-rich-text-toolbar__popover-btn--danger", onMouseDown: (e) => e.preventDefault(), onClick: () => isLink ? this.removeLink() : this.removeIframe() }, this.s.remove)), h("button", { type: "button", class: "co-rich-text-toolbar__popover-btn", onMouseDown: (e) => e.preventDefault(), onClick: () => this.closePopover() }, this.s.cancel))));
771
+ }
772
+ renderImagePopover() {
773
+ if (this.imagePopoverMode === 'url') {
774
+ return (h("div", { class: "co-rich-text-toolbar__popover", onMouseDown: (e) => {
775
+ if (e.target.tagName !== 'INPUT')
776
+ e.preventDefault();
777
+ e.stopPropagation();
778
+ } }, h("input", { type: "url", class: "co-rich-text-toolbar__popover-input", placeholder: this.s.imageUrlPlaceholder, value: this.popoverInput, onInput: (e) => { this.popoverInput = e.target.value; }, onKeyDown: (e) => {
779
+ if (e.key === 'Enter')
780
+ this.submitPopover('image');
781
+ if (e.key === 'Escape') {
782
+ this.imagePopoverMode = 'menu';
783
+ }
784
+ }, ref: (el) => el && setTimeout(() => el.focus(), 0) }), h("div", { class: "co-rich-text-toolbar__popover-actions" }, h("button", { type: "button", class: "co-rich-text-toolbar__popover-btn co-rich-text-toolbar__popover-btn--primary", onMouseDown: (e) => e.preventDefault(), onClick: () => this.submitPopover('image') }, this.s.add), h("button", { type: "button", class: "co-rich-text-toolbar__popover-btn", onMouseDown: (e) => e.preventDefault(), onClick: () => { this.imagePopoverMode = 'menu'; } }, this.s.back))));
785
+ }
786
+ return (h("div", { class: "co-rich-text-toolbar__popover", onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); } }, h("button", { type: "button", class: "co-rich-text-toolbar__popover-option", onMouseDown: (e) => e.preventDefault(), onClick: () => this.triggerImageFileUpload() }, h("co-icon", { name: "upload-simple", size: 16 }), h("span", null, this.s.uploadFromComputer)), h("button", { type: "button", class: "co-rich-text-toolbar__popover-option", onMouseDown: (e) => e.preventDefault(), onClick: () => { this.imagePopoverMode = 'url'; } }, h("co-icon", { name: "link", size: 16 }), h("span", null, this.s.viaUrl))));
787
+ }
788
+ triggerImageFileUpload() {
789
+ const input = document.createElement('input');
790
+ input.type = 'file';
791
+ input.accept = 'image/*';
792
+ input.onchange = () => {
793
+ var _a;
794
+ const file = (_a = input.files) === null || _a === void 0 ? void 0 : _a[0];
795
+ if (!file || !this.editor)
796
+ return;
797
+ const reader = new FileReader();
798
+ reader.onload = () => {
799
+ const base64 = reader.result;
800
+ this.editor.chain().focus().setImage({ src: base64 }).run();
801
+ if (this.imageUpload) {
802
+ this.imageUpload(file).then((result) => {
803
+ var _a;
804
+ const newAttrs = typeof result === 'string'
805
+ ? { src: result }
806
+ : { src: result.src, dataFileId: (_a = result.fileId) !== null && _a !== void 0 ? _a : null };
807
+ const { state } = this.editor.view;
808
+ state.doc.descendants((node, pos) => {
809
+ if (node.type.name === 'image' && node.attrs.src === base64) {
810
+ const tr = this.editor.view.state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, node.attrs), newAttrs));
811
+ this.editor.view.dispatch(tr);
812
+ return false;
813
+ }
814
+ });
815
+ }).catch(() => { });
816
+ }
817
+ this.coAction.emit({ action: 'image', payload: base64 });
818
+ };
819
+ reader.readAsDataURL(file);
820
+ this.closePopover();
821
+ };
822
+ input.click();
823
+ }
824
+ isDropdownOptionActive(opt) {
825
+ var _a, _b, _c;
826
+ if (!this.editor)
827
+ return false;
828
+ try {
829
+ if (opt.action === 'textAlign')
830
+ return this.editor.isActive({ textAlign: opt.payload });
831
+ if (opt.action === 'lineHeight') {
832
+ const attrs = this.editor.getAttributes('paragraph');
833
+ return ((_a = attrs === null || attrs === void 0 ? void 0 : attrs.lineHeight) !== null && _a !== void 0 ? _a : null) === ((_b = opt.payload) !== null && _b !== void 0 ? _b : null);
834
+ }
835
+ if (opt.action === 'letterSpacing') {
836
+ const attrs = this.editor.getAttributes('textStyle');
837
+ const cur = (_c = attrs === null || attrs === void 0 ? void 0 : attrs.letterSpacing) !== null && _c !== void 0 ? _c : null;
838
+ if (opt.payload === 'normal')
839
+ return cur === null || cur === 'normal';
840
+ return cur === opt.payload;
841
+ }
842
+ if (opt.action === 'heading')
843
+ return this.editor.isActive('heading', opt.payload);
844
+ if (opt.action === 'paragraph')
845
+ return !this.editor.isActive('heading');
846
+ }
847
+ catch ( /* ignore */_d) { /* ignore */ }
848
+ return false;
849
+ }
850
+ /** Apply a free-form value typed into a dropdown's custom input. */
851
+ applyDropdownCustom(action, raw) {
852
+ const editor = this.editor;
853
+ const value = raw.trim();
854
+ if (!editor || !value)
115
855
  return;
856
+ const chain = editor.chain().focus();
857
+ if (action === 'fontSize') {
858
+ const n = parseFloat(value);
859
+ if (!(n > 0))
860
+ return;
861
+ chain.setFontSize(/^\d+(\.\d+)?$/.test(value) ? `${n}px` : value).run();
116
862
  }
117
- const raw = typeof window !== 'undefined' ? window.prompt('Enter URL') : null;
118
- const url = CoRichTextToolbar.safeUrl(raw, ['http', 'https', 'mailto', 'tel']);
119
- if (url)
120
- chain.setLink({ href: url }).run();
863
+ else if (action === 'lineSpacing') {
864
+ chain.setLineHeight(value).run();
865
+ }
866
+ else if (action === 'letterSpacing') {
867
+ if (value === 'normal')
868
+ chain.unsetLetterSpacing().run();
869
+ else
870
+ chain.setLetterSpacing(value).run();
871
+ }
872
+ this.closePopover();
121
873
  }
122
- insertImage() {
874
+ renderDropdown(item) {
875
+ var _a;
876
+ if (!((_a = item.options) === null || _a === void 0 ? void 0 : _a.length))
877
+ return null;
878
+ const isFontSize = item.action === 'fontSize';
879
+ const isFontFamily = item.action === 'fontFamily';
880
+ const isHeadingStyle = item.action === 'headingStyle';
881
+ const isAlignment = item.action === 'alignment';
882
+ const isLineSpacing = item.action === 'lineSpacing';
883
+ const isLetterSpacing = item.action === 'letterSpacing';
884
+ const showCheckmarks = isAlignment || isLineSpacing || isLetterSpacing || isHeadingStyle;
885
+ const customInput = isFontSize
886
+ ? { placeholder: this.s.sizePlaceholder }
887
+ : isLineSpacing
888
+ ? { placeholder: this.s.lineSpacingPlaceholder }
889
+ : isLetterSpacing
890
+ ? { placeholder: this.s.letterSpacingPlaceholder }
891
+ : null;
892
+ return (h("div", { class: "co-rich-text-toolbar__dropdown", onMouseDown: (e) => { e.preventDefault(); e.stopPropagation(); } }, customInput && (h("div", { class: "co-rich-text-toolbar__dropdown-input-wrap" }, h("input", { type: "text", class: "co-rich-text-toolbar__dropdown-input", placeholder: customInput.placeholder, onMouseDown: (e) => e.stopPropagation(), onKeyDown: (e) => {
893
+ if (e.key === 'Enter') {
894
+ this.applyDropdownCustom(item.action, e.target.value);
895
+ e.target.value = '';
896
+ }
897
+ else if (e.key === 'Escape') {
898
+ this.closePopover();
899
+ }
900
+ } }))), item.options.map((opt) => {
901
+ var _a;
902
+ if (opt.action === 'separator') {
903
+ return (h("div", { class: "co-rich-text-toolbar__dropdown-sep-label" }, h("span", null, this.tOpt(opt))));
904
+ }
905
+ const style = {};
906
+ const active = showCheckmarks && this.isDropdownOptionActive(opt);
907
+ if (isHeadingStyle) {
908
+ if (opt.action === 'heading') {
909
+ const lvl = (_a = opt.payload) === null || _a === void 0 ? void 0 : _a.level;
910
+ style.fontSize = lvl === 1 ? '20px' : lvl === 2 ? '16px' : '14px';
911
+ style.fontWeight = '600';
912
+ }
913
+ }
914
+ if (isFontFamily && opt.payload) {
915
+ style.fontFamily = opt.payload;
916
+ }
917
+ return (h("button", { type: "button", class: {
918
+ 'co-rich-text-toolbar__dropdown-item': true,
919
+ 'co-rich-text-toolbar__dropdown-item--active': active,
920
+ }, style: style, onMouseDown: (e) => e.preventDefault(), onClick: () => this.handleDropdownSelect(item, opt) }, showCheckmarks && (h("span", { class: "co-rich-text-toolbar__dropdown-check" }, active ? h("co-icon", { name: "check", size: 14 }) : null)), opt.icon && h("co-icon", { name: opt.icon, size: 16 }), h("span", null, this.tOpt(opt))));
921
+ })));
922
+ }
923
+ handleDropdownSelect(item, opt) {
123
924
  const editor = this.editor;
124
- if (!(editor === null || editor === void 0 ? void 0 : editor.schema.nodes.image))
925
+ if (!editor)
125
926
  return;
126
- const raw = typeof window !== 'undefined' ? window.prompt('Image URL') : null;
127
- const url = CoRichTextToolbar.safeUrl(raw, ['http', 'https']);
128
- if (url)
129
- editor.chain().focus().setImage({ src: url }).run();
130
- }
131
- /** Hide buttons whose node/mark isn't in the editor's schema — e.g. the
132
- * image button on the `full` toolbar with a preset that has no image node
133
- * (clicking it would call an unregistered command and throw). */
134
- supportedBySchema(item) {
927
+ const chain = editor.chain().focus();
928
+ switch (opt.action) {
929
+ case 'heading':
930
+ chain.toggleHeading(opt.payload).run();
931
+ break;
932
+ case 'paragraph':
933
+ chain.setParagraph().run();
934
+ break;
935
+ case 'fontSize':
936
+ chain.setFontSize(opt.payload).run();
937
+ break;
938
+ case 'fontFamily':
939
+ chain.setFontFamily(opt.payload).run();
940
+ break;
941
+ case 'textAlign':
942
+ chain.setTextAlign(opt.payload).run();
943
+ break;
944
+ case 'lineHeight':
945
+ chain.setLineHeight(opt.payload).run();
946
+ break;
947
+ case 'letterSpacing':
948
+ if (opt.payload === 'normal')
949
+ chain.unsetLetterSpacing().run();
950
+ else
951
+ chain.setLetterSpacing(opt.payload).run();
952
+ break;
953
+ case 'callout':
954
+ chain.insertCallout(opt.payload).run();
955
+ break;
956
+ }
957
+ this.coAction.emit({ action: opt.action, payload: opt.payload });
958
+ this.closePopover();
959
+ }
960
+ renderTableGrid() {
961
+ return (h("div", { class: "co-rich-text-toolbar__table-picker", onMouseDown: (e) => {
962
+ if (e.target.tagName !== 'INPUT')
963
+ e.preventDefault();
964
+ e.stopPropagation();
965
+ } }, h("div", { class: "co-rich-text-toolbar__table-header" }, h("co-icon", { name: "table", size: 16 }), h("span", { class: "co-rich-text-toolbar__table-title" }, this.s.configureTable), h("button", { type: "button", class: "co-rich-text-toolbar__table-close", onMouseDown: (e) => e.preventDefault(), onClick: () => this.closePopover() }, h("co-icon", { name: "x", size: 16 }))), h("div", { class: "co-rich-text-toolbar__table-tabs" }, h("button", { type: "button", class: { 'co-rich-text-toolbar__table-tab': true, 'co-rich-text-toolbar__table-tab--active': this.tableTab === 'grid' }, onMouseDown: (e) => e.preventDefault(), onClick: () => { this.tableTab = 'grid'; } }, this.s.grid), h("button", { type: "button", class: { 'co-rich-text-toolbar__table-tab': true, 'co-rich-text-toolbar__table-tab--active': this.tableTab === 'manual' }, onMouseDown: (e) => e.preventDefault(), onClick: () => { this.tableTab = 'manual'; } }, this.s.manual)), this.tableTab === 'grid' && this.renderGridTab(), this.tableTab === 'manual' && this.renderManualTab(), h("label", { class: "co-rich-text-toolbar__table-check" }, h("input", { type: "checkbox", checked: this.tableWithHeader, onChange: (e) => { this.tableWithHeader = e.target.checked; } }), h("span", null, this.s.includeHeaderRow)), this.tableTab === 'manual' && (h("div", { class: "co-rich-text-toolbar__table-actions" }, h("button", { type: "button", class: "co-rich-text-toolbar__table-btn co-rich-text-toolbar__table-btn--secondary", onMouseDown: (e) => e.preventDefault(), onClick: () => this.closePopover() }, this.s.cancel), h("button", { type: "button", class: "co-rich-text-toolbar__table-btn co-rich-text-toolbar__table-btn--primary", onMouseDown: (e) => e.preventDefault(), onClick: () => this.insertTable(this.tableManualRows, this.tableManualCols) }, this.s.createTable)))));
966
+ }
967
+ renderGridTab() {
968
+ const ROWS = 8;
969
+ const COLS = 8;
970
+ const cells = [];
971
+ const isLocked = this.gridLockedRows > 0;
972
+ const displayRows = isLocked ? this.gridLockedRows : this.gridHoverRows;
973
+ const displayCols = isLocked ? this.gridLockedCols : this.gridHoverCols;
974
+ for (let r = 1; r <= ROWS; r++) {
975
+ for (let c = 1; c <= COLS; c++) {
976
+ const isHighlighted = r <= displayRows && c <= displayCols;
977
+ cells.push(h("div", { class: { 'co-rich-text-toolbar__grid-cell': true, 'co-rich-text-toolbar__grid-cell--active': isHighlighted }, onMouseEnter: () => {
978
+ if (!isLocked) {
979
+ this.gridHoverRows = r;
980
+ this.gridHoverCols = c;
981
+ }
982
+ }, onMouseDown: (e) => e.preventDefault(), onClick: () => { this.gridLockedRows = r; this.gridLockedCols = c; } }));
983
+ }
984
+ }
985
+ const s = this.s;
986
+ const label = displayRows > 0
987
+ ? `${displayCols} × ${displayRows} (${displayCols} ${s.columns.toLowerCase()} × ${displayRows} ${s.rows.toLowerCase()})`
988
+ : s.selectSize;
989
+ return (h("div", { class: "co-rich-text-toolbar__grid-container", onMouseLeave: () => {
990
+ if (!isLocked) {
991
+ this.gridHoverRows = 0;
992
+ this.gridHoverCols = 0;
993
+ }
994
+ } }, h("div", { class: "co-rich-text-toolbar__grid", style: { 'grid-template-columns': `repeat(${COLS}, 1fr)` } }, cells), h("div", { class: "co-rich-text-toolbar__grid-footer" }, h("span", { class: "co-rich-text-toolbar__grid-label" }, label), isLocked && (h("button", { type: "button", class: "co-rich-text-toolbar__grid-reset", onMouseDown: (e) => e.preventDefault(), onClick: () => { this.gridLockedRows = 0; this.gridLockedCols = 0; this.gridHoverRows = 0; this.gridHoverCols = 0; } }, s.changeSelection))), isLocked && (h("div", { class: "co-rich-text-toolbar__table-actions" }, h("button", { type: "button", class: "co-rich-text-toolbar__table-btn co-rich-text-toolbar__table-btn--secondary", onMouseDown: (e) => e.preventDefault(), onClick: () => this.closePopover() }, s.cancel), h("button", { type: "button", class: "co-rich-text-toolbar__table-btn co-rich-text-toolbar__table-btn--primary", onMouseDown: (e) => e.preventDefault(), onClick: () => this.insertTable(this.gridLockedRows, this.gridLockedCols) }, s.createTable)))));
995
+ }
996
+ renderManualTab() {
997
+ return (h("div", { class: "co-rich-text-toolbar__table-manual" }, h("div", { class: "co-rich-text-toolbar__table-field" }, h("label", null, this.s.columns, ":"), h("input", { type: "number", min: "1", max: "20", value: this.tableManualCols, onInput: (e) => { this.tableManualCols = Math.max(1, parseInt(e.target.value) || 1); } })), h("div", { class: "co-rich-text-toolbar__table-field" }, h("label", null, this.s.rows, ":"), h("input", { type: "number", min: "1", max: "50", value: this.tableManualRows, onInput: (e) => { this.tableManualRows = Math.max(1, parseInt(e.target.value) || 1); } }))));
998
+ }
999
+ insertTable(rows, cols) {
135
1000
  const editor = this.editor;
136
1001
  if (!editor)
137
- return true; // optimistic until the editor is wired
138
- const { nodes, marks } = editor.schema;
139
- switch (item.action) {
140
- case 'image': return !!nodes.image;
141
- case 'bulletList': return !!nodes.bulletList;
142
- case 'orderedList': return !!nodes.orderedList;
143
- case 'blockquote': return !!nodes.blockquote;
144
- case 'heading': return !!nodes.heading;
145
- case 'code': return !!marks.code;
146
- case 'underline': return !!marks.underline;
147
- case 'strike': return !!marks.strike;
148
- case 'link': return !!marks.link;
149
- default: return true;
1002
+ return;
1003
+ // Defense in depth: never nest a table inside a table cell. The toolbar
1004
+ // button is already disabled in this case, but guard the insert itself so
1005
+ // no other caller can produce the invalid markup.
1006
+ if (editor.isActive('table')) {
1007
+ this.closePopover();
1008
+ return;
1009
+ }
1010
+ const withHeader = this.tableWithHeader;
1011
+ // Build the table node by hand so a header row can ship with placeholder
1012
+ // titles ("Header 1", "Header 2", …) instead of empty header cells. Tiptap's
1013
+ // insertTable() only toggles header cells on, it can't seed their content.
1014
+ const emptyCell = () => ({ type: 'tableCell', content: [{ type: 'paragraph' }] });
1015
+ const headerCell = (i) => ({
1016
+ type: 'tableHeader',
1017
+ content: [{ type: 'paragraph', content: [{ type: 'text', text: `${this.s.tableHeaderLabel} ${i + 1}` }] }],
1018
+ });
1019
+ const content = [];
1020
+ if (withHeader) {
1021
+ content.push({
1022
+ type: 'tableRow',
1023
+ content: Array.from({ length: cols }, (_, i) => headerCell(i)),
1024
+ });
150
1025
  }
1026
+ const bodyRows = withHeader ? rows - 1 : rows;
1027
+ for (let r = 0; r < bodyRows; r++) {
1028
+ content.push({
1029
+ type: 'tableRow',
1030
+ content: Array.from({ length: cols }, () => emptyCell()),
1031
+ });
1032
+ }
1033
+ editor.chain().focus().insertContent({ type: 'table', content }).run();
1034
+ this.coAction.emit({ action: 'table', payload: { rows, cols, withHeaderRow: withHeader } });
1035
+ this.closePopover();
151
1036
  }
152
- canRun(item) {
153
- var _a, _b, _c, _d;
154
- if (!this.editor || this.disabled)
155
- return false;
156
- const can = this.editor.can();
157
- if (item.action === 'undo')
158
- return (_b = (_a = can.undo) === null || _a === void 0 ? void 0 : _a.call(can)) !== null && _b !== void 0 ? _b : true;
159
- if (item.action === 'redo')
160
- return (_d = (_c = can.redo) === null || _c === void 0 ? void 0 : _c.call(can)) !== null && _d !== void 0 ? _d : true;
161
- return true;
1037
+ renderColorPicker(item) {
1038
+ return (h("div", { class: "co-rich-text-toolbar__color-picker", onMouseDown: (e) => {
1039
+ if (e.target.tagName !== 'INPUT')
1040
+ e.preventDefault();
1041
+ e.stopPropagation();
1042
+ } }, h("div", { class: "co-rich-text-toolbar__color-grid" }, this.colorPalette.map((color) => (h("button", { type: "button", class: "co-rich-text-toolbar__color-swatch", style: Object.assign({ background: color }, (color === '#ffffff' ? { border: '1px solid #ccc' } : {})), title: color, onMouseDown: (e) => e.preventDefault(), onClick: () => this.selectColor(item.action, color) })))), h("div", { class: "co-rich-text-toolbar__color-hex" }, h("input", { type: "text", class: "co-rich-text-toolbar__color-hex-input", placeholder: "#hex", maxLength: 7, value: this.colorHexInput, onInput: (e) => { this.colorHexInput = e.target.value; }, onKeyDown: (e) => {
1043
+ if (e.key === 'Enter') {
1044
+ const val = this.colorHexInput.trim();
1045
+ if (/^#[0-9a-fA-F]{3,6}$/.test(val)) {
1046
+ this.selectColor(item.action, val);
1047
+ this.colorHexInput = '';
1048
+ }
1049
+ }
1050
+ else if (e.key === 'Escape') {
1051
+ this.closePopover();
1052
+ }
1053
+ } })), h("button", { type: "button", class: "co-rich-text-toolbar__color-clear", onMouseDown: (e) => e.preventDefault(), onClick: () => this.clearColor(item.action) }, h("co-icon", { name: "x", size: 12 }), h("span", null, this.s.removeColor))));
162
1054
  }
163
1055
  render() {
164
1056
  if (this.variant === 'none' || this.items.length === 0)
165
1057
  return null;
166
- return (h("div", { class: "co-rich-text-toolbar", role: "toolbar", "aria-label": "Formatting", part: "toolbar" }, this.items.filter((item) => this.supportedBySchema(item)).map((item) => {
167
- var _a;
168
- return (h("button", { key: `${item.action}-${JSON.stringify((_a = item.payload) !== null && _a !== void 0 ? _a : '')}`, type: "button", class: { 'co-rich-text-toolbar__btn': true, 'co-rich-text-toolbar__btn--active': this.isActive(item) }, title: item.label, "aria-label": item.label, "aria-pressed": item.type === 'toggle' ? String(this.isActive(item)) : undefined, disabled: !this.canRun(item), onMouseDown: (e) => e.preventDefault(), onClick: () => this.run(item), part: "button" }, h("co-icon", { name: item.icon, size: 18 })));
1058
+ return (h("div", { class: "co-rich-text-toolbar", role: "toolbar", "aria-label": "Formatting", part: "toolbar" }, this.items.map((entry) => {
1059
+ if (this.isSeparator(entry)) {
1060
+ return h("span", { class: "co-rich-text-toolbar__sep" });
1061
+ }
1062
+ return this.renderButton(entry);
169
1063
  })));
170
1064
  }
1065
+ get el() { return getElement(this); }
171
1066
  static get watchers() { return {
172
1067
  "variant": [{
173
1068
  "onVariantChange": 0
174
1069
  }],
175
1070
  "editor": [{
176
1071
  "onEditorChange": 0
1072
+ }],
1073
+ "openPopover": [{
1074
+ "onOpenPopoverChange": 0
177
1075
  }]
178
1076
  }; }
179
1077
  };
1078
+ /**
1079
+ * Command whose presence in the schema proves an item's extension is loaded.
1080
+ * Items without an entry have no extension dependency (separators, core marks,
1081
+ * link, paragraph/heading, undo/redo, text color) and are always shown.
1082
+ */
1083
+ CoRichTextToolbar.ITEM_COMMAND = {
1084
+ table: 'insertTable',
1085
+ image: 'setImage',
1086
+ youtube: 'setYoutubeVideo',
1087
+ iframe: 'setIframe',
1088
+ callout: 'insertCallout',
1089
+ fontFamily: 'setFontFamily',
1090
+ fontSize: 'setFontSize',
1091
+ highlight: 'toggleHighlight',
1092
+ alignment: 'setTextAlign',
1093
+ lineSpacing: 'setLineHeight',
1094
+ letterSpacing: 'setLetterSpacing',
1095
+ taskListMenu: 'toggleTaskList',
1096
+ indentIncrease: 'indent',
1097
+ indentDecrease: 'outdent',
1098
+ codeBlock: 'toggleCodeBlock',
1099
+ blockquote: 'toggleBlockquote',
1100
+ horizontalRule: 'setHorizontalRule',
1101
+ bulletListMenu: 'toggleBulletList',
1102
+ orderedListMenu: 'toggleOrderedList',
1103
+ };
180
1104
  CoRichTextToolbar.style = coRichTextToolbarCss();
181
1105
 
182
1106
  export { CoRichTextToolbar as co_rich_text_toolbar };