@jackuait/blok 0.6.0-beta.4 → 0.6.0-beta.6

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 (256) hide show
  1. package/README.md +16 -169
  2. package/bin/blok.mjs +10 -0
  3. package/dist/blok.mjs +2 -2
  4. package/dist/chunks/{blok-DK-97ZTf.mjs → blok-BOtlKwVO.mjs} +1486 -1354
  5. package/dist/chunks/{i18next-loader-CRollibS.mjs → i18next-loader-CJNShSyT.mjs} +1 -1
  6. package/dist/chunks/{index-jgHmMDND.mjs → index-BUAPAChM.mjs} +1 -1
  7. package/dist/chunks/{inline-tool-convert-BIwvipPw.mjs → inline-tool-convert-UoYdJJic.mjs} +88 -73
  8. package/dist/chunks/{messages-C5b7hr_E.mjs → messages-1fC8IMyX.mjs} +16 -2
  9. package/dist/chunks/{messages-CQj2JU2j.mjs → messages-7QoX8DkW.mjs} +23 -9
  10. package/dist/{messages-LvFKBBPa.mjs → chunks/messages-7W4d0DwD.mjs} +15 -1
  11. package/dist/{messages-Bn253WWC.mjs → chunks/messages-9SihnaXQ.mjs} +14 -0
  12. package/dist/{messages-Bf6Y3_GI.mjs → chunks/messages-B1Aww8q7.mjs} +16 -2
  13. package/dist/{messages-pA5TvcAj.mjs → chunks/messages-BB5z9Uba.mjs} +14 -0
  14. package/dist/chunks/{messages-wdqp4610.mjs → messages-BC86qLvI.mjs} +17 -3
  15. package/dist/chunks/{messages-o24dK6CU.mjs → messages-BELRf6DU.mjs} +16 -2
  16. package/dist/chunks/{messages-CUZ1x1QD.mjs → messages-BFG6Wlgy.mjs} +16 -2
  17. package/dist/{messages-B5puUm7R.mjs → chunks/messages-BL0tXcDf.mjs} +15 -1
  18. package/dist/chunks/{messages-zS1AXZ0y.mjs → messages-BMXCuEKO.mjs} +19 -5
  19. package/dist/{messages-CyDU5lz9.mjs → chunks/messages-BMv4xwIr.mjs} +16 -2
  20. package/dist/chunks/{messages-BeUhMpsr.mjs → messages-BSbjsyHY.mjs} +25 -11
  21. package/dist/chunks/{messages-JGsXAReJ.mjs → messages-BU2nlrLK.mjs} +16 -2
  22. package/dist/chunks/{messages-srxrv8Yh.mjs → messages-BWF-zUpY.mjs} +17 -3
  23. package/dist/{messages-CXHd9SUK.mjs → chunks/messages-BYyy6Wqf.mjs} +14 -0
  24. package/dist/chunks/{messages-DOlC_Tty.mjs → messages-BdeLo0N9.mjs} +24 -10
  25. package/dist/chunks/{messages-B5jGUnOy.mjs → messages-Bmu_S7GM.mjs} +14 -0
  26. package/dist/chunks/{messages-BmKCChWZ.mjs → messages-BoJc_p1r.mjs} +14 -0
  27. package/dist/chunks/{messages-CvaqJFN-.mjs → messages-BogRq8lt.mjs} +15 -1
  28. package/dist/chunks/{messages-NP1myMGI.mjs → messages-BrPFGbM-.mjs} +14 -0
  29. package/dist/chunks/{messages-D00OjS2n.mjs → messages-C2htQ_3F.mjs} +24 -10
  30. package/dist/chunks/{messages-BiExzWJv.mjs → messages-C99mq906.mjs} +15 -1
  31. package/dist/chunks/{messages-CkFT2gle.mjs → messages-C9eaarcK.mjs} +20 -6
  32. package/dist/chunks/{messages-BrJHUxQL.mjs → messages-CJdUsQ-c.mjs} +15 -1
  33. package/dist/chunks/messages-CKI54h6O.mjs +62 -0
  34. package/dist/{messages-CrsJ1TEJ.mjs → chunks/messages-CLhcMlTc.mjs} +15 -1
  35. package/dist/{messages-CnvW8Slp.mjs → chunks/messages-CMkNSDTo.mjs} +17 -3
  36. package/dist/{messages-BlpqL8vG.mjs → chunks/messages-CQwpzUFp.mjs} +19 -5
  37. package/dist/chunks/{messages-Cu08aLS3.mjs → messages-CVw84KdI.mjs} +21 -7
  38. package/dist/chunks/{messages-B9Oba7sq.mjs → messages-CY8_RyFE.mjs} +15 -1
  39. package/dist/chunks/{messages-B5hdXZwA.mjs → messages-CZygwLwM.mjs} +15 -1
  40. package/dist/chunks/{messages-CVeWVKsV.mjs → messages-CnwibSvh.mjs} +14 -0
  41. package/dist/chunks/{messages-DbVquYKN.mjs → messages-CqWJcCbY.mjs} +14 -0
  42. package/dist/{messages-Dg92dXZ5.mjs → chunks/messages-CvGLfqmV.mjs} +14 -0
  43. package/dist/{messages-AHESHJm_.mjs → chunks/messages-CzTufCHu.mjs} +14 -0
  44. package/dist/chunks/{messages-Cj-t1bdy.mjs → messages-CznZadDf.mjs} +15 -1
  45. package/dist/chunks/{messages-DMQIHGRj.mjs → messages-D-ZtY5v0.mjs} +14 -0
  46. package/dist/chunks/{messages-rRSHQDCX.mjs → messages-D1Hv8XGo.mjs} +14 -0
  47. package/dist/chunks/{messages-0tDXLuyH.mjs → messages-D5C3J9qr.mjs} +15 -1
  48. package/dist/chunks/{messages-RvMHb2Ht.mjs → messages-D5iv1Kox.mjs} +16 -2
  49. package/dist/{messages-zSzDzXej.mjs → chunks/messages-DBRw-7Zc.mjs} +16 -2
  50. package/dist/chunks/{messages-CeCjVKMW.mjs → messages-DBn76jVV.mjs} +16 -2
  51. package/dist/chunks/{messages-C7I_AVH2.mjs → messages-DJDG55Vq.mjs} +16 -2
  52. package/dist/{messages-DDLgIPDF.mjs → chunks/messages-DLfR5bMd.mjs} +16 -2
  53. package/dist/{messages-CbhuIWRJ.mjs → chunks/messages-DT4dP5uK.mjs} +15 -1
  54. package/dist/chunks/{messages-B66ZSDCJ.mjs → messages-DhLKYm2j.mjs} +15 -1
  55. package/dist/{messages-BPqWKx5Z.mjs → chunks/messages-Diu6jAaR.mjs} +17 -3
  56. package/dist/{messages-BA0rcTCY.mjs → chunks/messages-DnIhyAJk.mjs} +18 -4
  57. package/dist/chunks/{messages-DV6shA9b.mjs → messages-DnXLrlHh.mjs} +14 -0
  58. package/dist/chunks/{messages-DcKOuncK.mjs → messages-DprmQg6V.mjs} +16 -2
  59. package/dist/{messages-CJoBtXU6.mjs → chunks/messages-DqM1LFg5.mjs} +14 -0
  60. package/dist/chunks/{messages-Cyi2AMmz.mjs → messages-DvFLX36Q.mjs} +25 -11
  61. package/dist/chunks/{messages-DnbbyJT3.mjs → messages-Dz9L52ol.mjs} +16 -2
  62. package/dist/chunks/{messages-GC2PhgV3.mjs → messages-Dzwxv9v1.mjs} +23 -9
  63. package/dist/chunks/{messages-Q4kc_ZtL.mjs → messages-JELdtT6E.mjs} +15 -1
  64. package/dist/{messages-DY94ykcE.mjs → chunks/messages-LPVfA-8K.mjs} +14 -0
  65. package/dist/{messages-Cr-RJ7YB.mjs → chunks/messages-O5tQus_0.mjs} +14 -0
  66. package/dist/chunks/{messages-CbMyJSzS.mjs → messages-Q7AO_FLv.mjs} +17 -3
  67. package/dist/chunks/{messages-2_xedlYw.mjs → messages-R3hUSvr3.mjs} +15 -1
  68. package/dist/{messages-CUy1vn-b.mjs → chunks/messages-Xq8UmkVs.mjs} +14 -0
  69. package/dist/chunks/{messages-BBJgd5jG.mjs → messages-Z9nEU2xK.mjs} +16 -2
  70. package/dist/chunks/{messages-Cm9aLHeX.mjs → messages-_ErNTNhk.mjs} +15 -1
  71. package/dist/chunks/{messages-JZUhXTuV.mjs → messages-_ncGrKHh.mjs} +16 -2
  72. package/dist/chunks/{messages-ftMcCEuO.mjs → messages-kep5wtm4.mjs} +15 -1
  73. package/dist/chunks/{messages-DteYq0rv.mjs → messages-uKX8WBaD.mjs} +16 -2
  74. package/dist/chunks/{messages-Bdv-IkfG.mjs → messages-w7v1GNaE.mjs} +15 -1
  75. package/dist/cli.mjs +50 -0
  76. package/dist/full.mjs +15 -15
  77. package/dist/locales.mjs +102 -88
  78. package/dist/{messages-C5b7hr_E.mjs → messages-1fC8IMyX.mjs} +16 -2
  79. package/dist/{messages-CQj2JU2j.mjs → messages-7QoX8DkW.mjs} +23 -9
  80. package/dist/{chunks/messages-LvFKBBPa.mjs → messages-7W4d0DwD.mjs} +15 -1
  81. package/dist/{chunks/messages-Bn253WWC.mjs → messages-9SihnaXQ.mjs} +14 -0
  82. package/dist/{chunks/messages-Bf6Y3_GI.mjs → messages-B1Aww8q7.mjs} +16 -2
  83. package/dist/{chunks/messages-pA5TvcAj.mjs → messages-BB5z9Uba.mjs} +14 -0
  84. package/dist/{messages-wdqp4610.mjs → messages-BC86qLvI.mjs} +17 -3
  85. package/dist/{messages-o24dK6CU.mjs → messages-BELRf6DU.mjs} +16 -2
  86. package/dist/{messages-CUZ1x1QD.mjs → messages-BFG6Wlgy.mjs} +16 -2
  87. package/dist/{chunks/messages-B5puUm7R.mjs → messages-BL0tXcDf.mjs} +15 -1
  88. package/dist/{messages-zS1AXZ0y.mjs → messages-BMXCuEKO.mjs} +19 -5
  89. package/dist/{chunks/messages-CyDU5lz9.mjs → messages-BMv4xwIr.mjs} +16 -2
  90. package/dist/{messages-BeUhMpsr.mjs → messages-BSbjsyHY.mjs} +25 -11
  91. package/dist/{messages-JGsXAReJ.mjs → messages-BU2nlrLK.mjs} +16 -2
  92. package/dist/{messages-srxrv8Yh.mjs → messages-BWF-zUpY.mjs} +17 -3
  93. package/dist/{chunks/messages-CXHd9SUK.mjs → messages-BYyy6Wqf.mjs} +14 -0
  94. package/dist/{messages-DOlC_Tty.mjs → messages-BdeLo0N9.mjs} +24 -10
  95. package/dist/{messages-B5jGUnOy.mjs → messages-Bmu_S7GM.mjs} +14 -0
  96. package/dist/{messages-BmKCChWZ.mjs → messages-BoJc_p1r.mjs} +14 -0
  97. package/dist/{messages-CvaqJFN-.mjs → messages-BogRq8lt.mjs} +15 -1
  98. package/dist/{messages-NP1myMGI.mjs → messages-BrPFGbM-.mjs} +14 -0
  99. package/dist/{messages-D00OjS2n.mjs → messages-C2htQ_3F.mjs} +24 -10
  100. package/dist/{messages-BiExzWJv.mjs → messages-C99mq906.mjs} +15 -1
  101. package/dist/{messages-CkFT2gle.mjs → messages-C9eaarcK.mjs} +20 -6
  102. package/dist/{messages-BrJHUxQL.mjs → messages-CJdUsQ-c.mjs} +15 -1
  103. package/dist/messages-CKI54h6O.mjs +62 -0
  104. package/dist/{chunks/messages-CrsJ1TEJ.mjs → messages-CLhcMlTc.mjs} +15 -1
  105. package/dist/{chunks/messages-CnvW8Slp.mjs → messages-CMkNSDTo.mjs} +17 -3
  106. package/dist/{chunks/messages-BlpqL8vG.mjs → messages-CQwpzUFp.mjs} +19 -5
  107. package/dist/{messages-Cu08aLS3.mjs → messages-CVw84KdI.mjs} +21 -7
  108. package/dist/{messages-B9Oba7sq.mjs → messages-CY8_RyFE.mjs} +15 -1
  109. package/dist/{messages-B5hdXZwA.mjs → messages-CZygwLwM.mjs} +15 -1
  110. package/dist/{messages-CVeWVKsV.mjs → messages-CnwibSvh.mjs} +14 -0
  111. package/dist/{messages-DbVquYKN.mjs → messages-CqWJcCbY.mjs} +14 -0
  112. package/dist/{chunks/messages-Dg92dXZ5.mjs → messages-CvGLfqmV.mjs} +14 -0
  113. package/dist/{chunks/messages-AHESHJm_.mjs → messages-CzTufCHu.mjs} +14 -0
  114. package/dist/{messages-Cj-t1bdy.mjs → messages-CznZadDf.mjs} +15 -1
  115. package/dist/{messages-DMQIHGRj.mjs → messages-D-ZtY5v0.mjs} +14 -0
  116. package/dist/{messages-rRSHQDCX.mjs → messages-D1Hv8XGo.mjs} +14 -0
  117. package/dist/{messages-0tDXLuyH.mjs → messages-D5C3J9qr.mjs} +15 -1
  118. package/dist/{messages-RvMHb2Ht.mjs → messages-D5iv1Kox.mjs} +16 -2
  119. package/dist/{chunks/messages-zSzDzXej.mjs → messages-DBRw-7Zc.mjs} +16 -2
  120. package/dist/{messages-CeCjVKMW.mjs → messages-DBn76jVV.mjs} +16 -2
  121. package/dist/{messages-C7I_AVH2.mjs → messages-DJDG55Vq.mjs} +16 -2
  122. package/dist/{chunks/messages-DDLgIPDF.mjs → messages-DLfR5bMd.mjs} +16 -2
  123. package/dist/{chunks/messages-CbhuIWRJ.mjs → messages-DT4dP5uK.mjs} +15 -1
  124. package/dist/{messages-B66ZSDCJ.mjs → messages-DhLKYm2j.mjs} +15 -1
  125. package/dist/{chunks/messages-BPqWKx5Z.mjs → messages-Diu6jAaR.mjs} +17 -3
  126. package/dist/{chunks/messages-BA0rcTCY.mjs → messages-DnIhyAJk.mjs} +18 -4
  127. package/dist/{messages-DV6shA9b.mjs → messages-DnXLrlHh.mjs} +14 -0
  128. package/dist/{messages-DcKOuncK.mjs → messages-DprmQg6V.mjs} +16 -2
  129. package/dist/{chunks/messages-CJoBtXU6.mjs → messages-DqM1LFg5.mjs} +14 -0
  130. package/dist/{messages-Cyi2AMmz.mjs → messages-DvFLX36Q.mjs} +25 -11
  131. package/dist/{messages-DnbbyJT3.mjs → messages-Dz9L52ol.mjs} +16 -2
  132. package/dist/{messages-GC2PhgV3.mjs → messages-Dzwxv9v1.mjs} +23 -9
  133. package/dist/{messages-Q4kc_ZtL.mjs → messages-JELdtT6E.mjs} +15 -1
  134. package/dist/{chunks/messages-DY94ykcE.mjs → messages-LPVfA-8K.mjs} +14 -0
  135. package/dist/{chunks/messages-Cr-RJ7YB.mjs → messages-O5tQus_0.mjs} +14 -0
  136. package/dist/{messages-CbMyJSzS.mjs → messages-Q7AO_FLv.mjs} +17 -3
  137. package/dist/{messages-2_xedlYw.mjs → messages-R3hUSvr3.mjs} +15 -1
  138. package/dist/{chunks/messages-CUy1vn-b.mjs → messages-Xq8UmkVs.mjs} +14 -0
  139. package/dist/{messages-BBJgd5jG.mjs → messages-Z9nEU2xK.mjs} +16 -2
  140. package/dist/{messages-Cm9aLHeX.mjs → messages-_ErNTNhk.mjs} +15 -1
  141. package/dist/{messages-JZUhXTuV.mjs → messages-_ncGrKHh.mjs} +16 -2
  142. package/dist/{messages-ftMcCEuO.mjs → messages-kep5wtm4.mjs} +15 -1
  143. package/dist/{messages-DteYq0rv.mjs → messages-uKX8WBaD.mjs} +16 -2
  144. package/dist/{messages-Bdv-IkfG.mjs → messages-w7v1GNaE.mjs} +15 -1
  145. package/dist/tools.mjs +929 -779
  146. package/dist/vendor.LICENSE.txt +1 -1
  147. package/package.json +15 -14
  148. package/src/cli/commands/migration.ts +16 -0
  149. package/src/cli/commands/migrationContent.ts +6 -0
  150. package/src/cli/index.ts +47 -0
  151. package/src/cli/utils/output.ts +10 -0
  152. package/src/components/i18n/locales/am/messages.json +15 -1
  153. package/src/components/i18n/locales/ar/messages.json +14 -0
  154. package/src/components/i18n/locales/az/messages.json +14 -0
  155. package/src/components/i18n/locales/bg/messages.json +14 -0
  156. package/src/components/i18n/locales/bn/messages.json +25 -11
  157. package/src/components/i18n/locales/bs/messages.json +15 -1
  158. package/src/components/i18n/locales/cs/messages.json +14 -0
  159. package/src/components/i18n/locales/da/messages.json +14 -0
  160. package/src/components/i18n/locales/de/messages.json +14 -0
  161. package/src/components/i18n/locales/dv/messages.json +15 -1
  162. package/src/components/i18n/locales/el/messages.json +15 -1
  163. package/src/components/i18n/locales/en/messages.json +14 -0
  164. package/src/components/i18n/locales/es/messages.json +14 -0
  165. package/src/components/i18n/locales/et/messages.json +14 -0
  166. package/src/components/i18n/locales/fa/messages.json +15 -1
  167. package/src/components/i18n/locales/fi/messages.json +15 -1
  168. package/src/components/i18n/locales/fil/messages.json +20 -6
  169. package/src/components/i18n/locales/fr/messages.json +15 -1
  170. package/src/components/i18n/locales/gu/messages.json +15 -1
  171. package/src/components/i18n/locales/he/messages.json +14 -0
  172. package/src/components/i18n/locales/hi/messages.json +23 -9
  173. package/src/components/i18n/locales/hr/messages.json +14 -0
  174. package/src/components/i18n/locales/hu/messages.json +14 -0
  175. package/src/components/i18n/locales/hy/messages.json +16 -2
  176. package/src/components/i18n/locales/id/messages.json +19 -5
  177. package/src/components/i18n/locales/it/messages.json +14 -0
  178. package/src/components/i18n/locales/ja/messages.json +14 -0
  179. package/src/components/i18n/locales/ka/messages.json +15 -1
  180. package/src/components/i18n/locales/km/messages.json +16 -2
  181. package/src/components/i18n/locales/kn/messages.json +16 -2
  182. package/src/components/i18n/locales/ko/messages.json +14 -0
  183. package/src/components/i18n/locales/ku/messages.json +16 -2
  184. package/src/components/i18n/locales/lo/messages.json +15 -1
  185. package/src/components/i18n/locales/lt/messages.json +15 -1
  186. package/src/components/i18n/locales/lv/messages.json +15 -1
  187. package/src/components/i18n/locales/mk/messages.json +16 -2
  188. package/src/components/i18n/locales/ml/messages.json +16 -2
  189. package/src/components/i18n/locales/mn/messages.json +16 -2
  190. package/src/components/i18n/locales/mr/messages.json +24 -10
  191. package/src/components/i18n/locales/ms/messages.json +17 -3
  192. package/src/components/i18n/locales/my/messages.json +16 -2
  193. package/src/components/i18n/locales/ne/messages.json +24 -10
  194. package/src/components/i18n/locales/nl/messages.json +15 -1
  195. package/src/components/i18n/locales/no/messages.json +16 -2
  196. package/src/components/i18n/locales/pa/messages.json +15 -1
  197. package/src/components/i18n/locales/pl/messages.json +14 -0
  198. package/src/components/i18n/locales/ps/messages.json +17 -3
  199. package/src/components/i18n/locales/pt/messages.json +14 -0
  200. package/src/components/i18n/locales/ro/messages.json +15 -1
  201. package/src/components/i18n/locales/ru/messages.json +14 -0
  202. package/src/components/i18n/locales/sd/messages.json +16 -2
  203. package/src/components/i18n/locales/si/messages.json +23 -9
  204. package/src/components/i18n/locales/sk/messages.json +15 -1
  205. package/src/components/i18n/locales/sl/messages.json +16 -2
  206. package/src/components/i18n/locales/sq/messages.json +16 -2
  207. package/src/components/i18n/locales/sr/messages.json +16 -2
  208. package/src/components/i18n/locales/sv/messages.json +16 -2
  209. package/src/components/i18n/locales/sw/messages.json +16 -2
  210. package/src/components/i18n/locales/ta/messages.json +21 -7
  211. package/src/components/i18n/locales/te/messages.json +40 -26
  212. package/src/components/i18n/locales/th/messages.json +19 -5
  213. package/src/components/i18n/locales/tr/messages.json +15 -1
  214. package/src/components/i18n/locales/ug/messages.json +16 -2
  215. package/src/components/i18n/locales/uk/messages.json +15 -1
  216. package/src/components/i18n/locales/ur/messages.json +15 -1
  217. package/src/components/i18n/locales/vi/messages.json +25 -11
  218. package/src/components/i18n/locales/yi/messages.json +16 -2
  219. package/src/components/i18n/locales/zh/messages.json +15 -1
  220. package/src/components/modules/api/blocks.ts +17 -2
  221. package/src/components/modules/api/history.ts +64 -0
  222. package/src/components/modules/api/index.ts +1 -0
  223. package/src/components/modules/api/readonly.ts +11 -1
  224. package/src/components/modules/blockEvents/composers/markdownShortcuts.ts +12 -1
  225. package/src/components/modules/blockManager/blockManager.ts +7 -0
  226. package/src/components/modules/blockManager/yjs-sync.ts +12 -2
  227. package/src/components/modules/index.ts +3 -0
  228. package/src/components/modules/readonly.ts +11 -0
  229. package/src/components/modules/toolbar/index.ts +29 -7
  230. package/src/components/modules/ui.ts +46 -68
  231. package/src/components/modules/uiControllers/controllers/blockHover.ts +40 -61
  232. package/src/components/modules/yjs/index.ts +23 -0
  233. package/src/components/ui/toolbox.ts +41 -6
  234. package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +3 -1
  235. package/src/components/utils/popover/popover-desktop.ts +27 -8
  236. package/src/tools/table/index.ts +87 -70
  237. package/src/tools/table/table-add-controls.ts +33 -7
  238. package/src/tools/table/table-cell-blocks.ts +77 -5
  239. package/src/tools/table/table-cell-selection.ts +70 -46
  240. package/src/tools/table/table-core.ts +20 -15
  241. package/src/tools/table/table-grip-visuals.ts +4 -4
  242. package/src/tools/table/table-operations.ts +22 -12
  243. package/src/tools/table/table-restrictions.ts +64 -0
  244. package/src/tools/table/table-row-col-action-handler.ts +190 -0
  245. package/src/tools/table/table-row-col-controls.ts +91 -182
  246. package/src/tools/table/table-row-col-drag.ts +4 -4
  247. package/src/tools/table/table-row-col-popover.ts +225 -0
  248. package/src/tools/table/types.ts +2 -0
  249. package/src/types-internal/blok-modules.d.ts +2 -0
  250. package/types/api/history.d.ts +33 -0
  251. package/types/api/index.d.ts +1 -0
  252. package/types/api/readonly.d.ts +12 -2
  253. package/types/index.d.ts +3 -0
  254. package/types/utils/popover/popover.d.ts +7 -0
  255. package/dist/chunks/messages-CySyfkMU.mjs +0 -48
  256. package/dist/messages-CySyfkMU.mjs +0 -48
package/dist/tools.mjs CHANGED
@@ -1,17 +1,17 @@
1
- var Ee = Object.defineProperty, ke = Object.defineProperties;
2
- var xe = Object.getOwnPropertyDescriptors;
3
- var Et = Object.getOwnPropertySymbols;
4
- var Te = Object.prototype.hasOwnProperty, Le = Object.prototype.propertyIsEnumerable;
5
- var kt = (i, t, e) => t in i ? Ee(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, L = (i, t) => {
1
+ var ke = Object.defineProperty, xe = Object.defineProperties;
2
+ var Te = Object.getOwnPropertyDescriptors;
3
+ var xt = Object.getOwnPropertySymbols;
4
+ var Re = Object.prototype.hasOwnProperty, Le = Object.prototype.propertyIsEnumerable;
5
+ var Tt = (i, t, e) => t in i ? ke(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e, x = (i, t) => {
6
6
  for (var e in t || (t = {}))
7
- Te.call(t, e) && kt(i, e, t[e]);
8
- if (Et)
9
- for (var e of Et(t))
10
- Le.call(t, e) && kt(i, e, t[e]);
7
+ Re.call(t, e) && Tt(i, e, t[e]);
8
+ if (xt)
9
+ for (var e of xt(t))
10
+ Le.call(t, e) && Tt(i, e, t[e]);
11
11
  return i;
12
- }, tt = (i, t) => ke(i, xe(t));
13
- import { t as v, D as E, am as Re, an as Be, _ as Ie, ao as De, ap as Ne, aq as Pe, ar as _e, as as He, at as Me, au as te, av as ee, aw as ne, o as Oe, p as xt, a5 as Tt, a3 as $e, J as se, ax as Ge, Q as oe, P as F, ay as We, az as qe, a0 as Lt, aA as Fe, aB as ze, aC as Ve, aD as Ue, aE as Ke, z as O, aF as je, aG as Xe, S as et, aH as Ye, l as Ze, a8 as Je } from "./chunks/inline-tool-convert-BIwvipPw.mjs";
14
- import { ab as fo } from "./chunks/inline-tool-convert-BIwvipPw.mjs";
12
+ }, tt = (i, t) => xe(i, Te(t));
13
+ import { t as v, D as E, am as Be, an as Ie, _ as Ne, ao as De, ap as He, aq as Pe, ar as _e, as as Oe, at as Me, au as Qt, av as te, aw as ee, o as We, p as Rt, a5 as Lt, a3 as $e, ax as Ge, J as ne, Q as se, P as F, ay as qe, az as Fe, a0 as oe, aA as ze, aB as Ve, aC as Ue, aD as Ke, aE as je, z as H, aF as Xe, aG as Ye, S as et, aH as Ze, l as Je, a8 as Qe } from "./chunks/inline-tool-convert-UoYdJJic.mjs";
14
+ import { ab as xo } from "./chunks/inline-tool-convert-UoYdJJic.mjs";
15
15
  const ie = (i) => {
16
16
  if (!i || !i.includes("data-blok-fake-background"))
17
17
  return i;
@@ -24,7 +24,7 @@ const ie = (i) => {
24
24
  s.removeChild(n);
25
25
  }
26
26
  }), t.innerHTML;
27
- }, at = [
27
+ }, ht = [
28
28
  "empty:before:pointer-events-none",
29
29
  "empty:before:text-gray-text",
30
30
  "empty:before:cursor-text",
@@ -33,7 +33,7 @@ const ie = (i) => {
33
33
  "[&[data-blok-empty=true]]:before:text-gray-text",
34
34
  "[&[data-blok-empty=true]]:before:cursor-text",
35
35
  "[&[data-blok-empty=true]]:before:content-[attr(data-placeholder)]"
36
- ], Qe = [
36
+ ], tn = [
37
37
  "empty:focus:before:pointer-events-none",
38
38
  "empty:focus:before:text-gray-text",
39
39
  "empty:focus:before:cursor-text",
@@ -42,22 +42,22 @@ const ie = (i) => {
42
42
  "[&[data-empty=true]:focus]:before:text-gray-text",
43
43
  "[&[data-empty=true]:focus]:before:cursor-text",
44
44
  "[&[data-empty=true]:focus]:before:content-[attr(data-blok-placeholder-active)]"
45
- ], tn = (i) => {
45
+ ], en = (i) => {
46
46
  const t = i.innerHTML.trim();
47
47
  return t === "" || t === "<br>";
48
- }, en = (i) => {
48
+ }, nn = (i) => {
49
49
  i.innerHTML === "<br>" && (i.innerHTML = "");
50
50
  const t = window.getSelection();
51
51
  if (!t) return;
52
52
  const e = document.createRange();
53
53
  e.selectNodeContents(i), e.collapse(!0), t.removeAllRanges(), t.addRange(e);
54
- }, nn = (i) => {
55
- tn(i) && en(i);
56
- }, wt = (i, t, e = "data-placeholder") => {
54
+ }, sn = (i) => {
55
+ en(i) && nn(i);
56
+ }, Et = (i, t, e = "data-placeholder") => {
57
57
  i.setAttribute(e, t != null ? t : "");
58
- const n = () => nn(i);
58
+ const n = () => sn(i);
59
59
  i.addEventListener("focus", n), i.addEventListener("input", n);
60
- }, sn = (i) => {
60
+ }, on = (i) => {
61
61
  const t = document.createElement("div");
62
62
  t.innerHTML = i.trim();
63
63
  const e = document.createDocumentFragment();
@@ -110,10 +110,10 @@ const ie = (i) => {
110
110
  t.className = v(
111
111
  this.api.styles.block,
112
112
  Q.WRAPPER_CLASSES,
113
- Qe
113
+ tn
114
114
  ), t.setAttribute(E.tool, "paragraph"), t.contentEditable = "false";
115
115
  const e = this.buildInlineStyles();
116
- return Object.keys(e).length > 0 && Object.assign(t.style, e), this._data.text && (t.innerHTML = this._data.text), this.readOnly ? t.setAttribute("data-blok-placeholder-active", this.api.i18n.t(this._placeholder)) : (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp), wt(t, this.api.i18n.t(this._placeholder), "data-blok-placeholder-active")), t;
116
+ return Object.keys(e).length > 0 && Object.assign(t.style, e), this._data.text && (t.innerHTML = this._data.text), this.readOnly ? t.setAttribute("data-blok-placeholder-active", this.api.i18n.t(this._placeholder)) : (t.contentEditable = "true", t.addEventListener("keyup", this.onKeyUp), Et(t, this.api.i18n.t(this._placeholder), "data-blok-placeholder-active")), t;
117
117
  }
118
118
  /**
119
119
  * Return Tool's view
@@ -133,7 +133,7 @@ const ie = (i) => {
133
133
  if (!this._element)
134
134
  return;
135
135
  this._data.text += t.text;
136
- const e = sn(t.text);
136
+ const e = on(t.text);
137
137
  this._element.appendChild(e), this._element.normalize();
138
138
  }
139
139
  /**
@@ -224,7 +224,7 @@ const ie = (i) => {
224
224
  */
225
225
  static get toolbox() {
226
226
  return {
227
- icon: Re,
227
+ icon: Be,
228
228
  title: "Text",
229
229
  titleKey: "text",
230
230
  searchTerms: ["p", "paragraph", "plain"]
@@ -239,8 +239,8 @@ Q.WRAPPER_CLASSES = [
239
239
  "[&>p:first-of-type]:mt-0",
240
240
  "[&>p:last-of-type]:mb-0"
241
241
  ];
242
- let Rt = Q;
243
- const q = class q {
242
+ let Bt = Q;
243
+ const O = class O {
244
244
  /**
245
245
  * Render plugin's main Element and fill it with saved data
246
246
  *
@@ -327,9 +327,9 @@ const q = class q {
327
327
  buildSettingsFromToolboxEntries(t) {
328
328
  return t.map((e) => {
329
329
  var c, d, h, p;
330
- const n = e.data, s = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, o = q.DEFAULT_LEVELS.find((m) => m.number === s), r = (d = o == null ? void 0 : o.name) != null ? d : `Heading ${s}`, l = this.resolveToolboxEntryTitle(e, r);
330
+ const n = e.data, s = (c = n == null ? void 0 : n.level) != null ? c : this.defaultLevel.number, o = O.DEFAULT_LEVELS.find((f) => f.number === s), r = (d = o == null ? void 0 : o.name) != null ? d : `Heading ${s}`, l = this.resolveToolboxEntryTitle(e, r);
331
331
  return {
332
- icon: (p = (h = e.icon) != null ? h : o == null ? void 0 : o.icon) != null ? p : Be,
332
+ icon: (p = (h = e.icon) != null ? h : o == null ? void 0 : o.icon) != null ? p : Ie,
333
333
  title: l,
334
334
  onActivate: () => this.setLevel(s),
335
335
  closeOnActivate: !0,
@@ -348,7 +348,7 @@ const q = class q {
348
348
  * @returns Resolved title string
349
349
  */
350
350
  resolveToolboxEntryTitle(t, e) {
351
- return Ie(this.api.i18n, t, e);
351
+ return Ne(this.api.i18n, t, e);
352
352
  }
353
353
  /**
354
354
  * Callback for Block's settings buttons
@@ -450,9 +450,9 @@ const q = class q {
450
450
  */
451
451
  getTag() {
452
452
  const t = document.createElement(this.currentLevel.tag);
453
- t.innerHTML = this._data.text || "", t.className = v(q.BASE_STYLES, this.currentLevel.styles, at);
453
+ t.innerHTML = this._data.text || "", t.className = v(O.BASE_STYLES, this.currentLevel.styles, ht);
454
454
  const { inlineStyles: e } = this.currentLevel;
455
- return e && Object.assign(t.style, e), t.setAttribute(E.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this.readOnly ? t.setAttribute("data-placeholder", this.api.i18n.t(this._settings.placeholder || "")) : wt(t, this.api.i18n.t(this._settings.placeholder || "")), t;
455
+ return e && Object.assign(t.style, e), t.setAttribute(E.tool, "header"), t.contentEditable = this.readOnly ? "false" : "true", this.readOnly ? t.setAttribute("data-placeholder", this.api.i18n.t(this._settings.placeholder || "")) : Et(t, this.api.i18n.t(this._settings.placeholder || "")), t;
456
456
  }
457
457
  /**
458
458
  * Get current level
@@ -480,7 +480,7 @@ const q = class q {
480
480
  * @returns Level array
481
481
  */
482
482
  get levels() {
483
- const t = this._settings.levelOverrides || {}, e = q.DEFAULT_LEVELS.map((s) => {
483
+ const t = this._settings.levelOverrides || {}, e = O.DEFAULT_LEVELS.map((s) => {
484
484
  var l;
485
485
  const o = t[s.number] || {}, r = {};
486
486
  return o.size && (r.fontSize = o.size), o.marginTop && (r.marginTop = o.marginTop), o.marginBottom && (r.marginBottom = o.marginBottom), {
@@ -537,7 +537,7 @@ const q = class q {
537
537
  * @returns ToolboxConfig array with entries for H1-H6
538
538
  */
539
539
  static get toolbox() {
540
- return q.DEFAULT_LEVELS.map((t) => ({
540
+ return O.DEFAULT_LEVELS.map((t) => ({
541
541
  icon: t.icon,
542
542
  title: t.name,
543
543
  titleKey: t.nameKey,
@@ -548,16 +548,16 @@ const q = class q {
548
548
  }));
549
549
  }
550
550
  };
551
- q.BASE_STYLES = "py-[3px] px-[2px] m-0 !leading-[1.3] outline-none [&_p]:!p-0 [&_p]:!m-0 [&_div]:!p-0 [&_div]:!m-0", q.DEFAULT_LEVELS = [
551
+ O.BASE_STYLES = "py-[3px] px-[2px] m-0 !leading-[1.3] outline-none [&_p]:!p-0 [&_p]:!m-0 [&_div]:!p-0 [&_div]:!m-0", O.DEFAULT_LEVELS = [
552
552
  { number: 1, tag: "H1", nameKey: "tools.header.heading1", name: "Heading 1", icon: De, styles: "text-4xl font-bold mt-8 mb-1" },
553
- { number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon: Ne, styles: "text-3xl font-semibold mt-6 mb-px" },
553
+ { number: 2, tag: "H2", nameKey: "tools.header.heading2", name: "Heading 2", icon: He, styles: "text-3xl font-semibold mt-6 mb-px" },
554
554
  { number: 3, tag: "H3", nameKey: "tools.header.heading3", name: "Heading 3", icon: Pe, styles: "text-2xl font-semibold mt-4 mb-px" },
555
555
  { number: 4, tag: "H4", nameKey: "tools.header.heading4", name: "Heading 4", icon: _e, styles: "text-xl font-semibold mt-3 mb-px" },
556
- { number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon: He, styles: "text-base font-semibold mt-3 mb-px" },
556
+ { number: 5, tag: "H5", nameKey: "tools.header.heading5", name: "Heading 5", icon: Oe, styles: "text-base font-semibold mt-3 mb-px" },
557
557
  { number: 6, tag: "H6", nameKey: "tools.header.heading6", name: "Heading 6", icon: Me, styles: "text-sm font-semibold mt-3 mb-px" }
558
558
  ];
559
- let Bt = q;
560
- const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl-0.5 leading-[1.6em]", ln = "flex items-start pl-0.5", an = "mt-1 w-4 mr-2 h-4 cursor-pointer accent-current", cn = "tools.list.placeholder", w = "list", re = {
559
+ let It = O;
560
+ const z = 24, rn = "outline-none py-[3px] mt-[2px] mb-px", ln = "outline-none pl-0.5 leading-[1.6em]", an = "flex items-start pl-0.5", cn = "mt-1 w-4 mr-2 h-4 cursor-pointer accent-current", dn = "tools.list.placeholder", w = "list", re = {
561
561
  contentContainer: "list-content-container",
562
562
  checklistContent: "list-checklist-content"
563
563
  }, le = (i, t) => {
@@ -569,7 +569,7 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
569
569
  configurable: !1
570
570
  });
571
571
  }, ae = (i) => {
572
- const { data: t, keydownHandler: e, readOnly: n } = i, s = dn(i), o = t.style === "checklist" ? un(i) : hn(i);
572
+ const { data: t, keydownHandler: e, readOnly: n } = i, s = hn(i), o = t.style === "checklist" ? pn(i) : un(i);
573
573
  s.appendChild(o), !n && e && s.addEventListener("keydown", e);
574
574
  const r = o.querySelector("[data-list-marker]"), l = o.querySelector('input[type="checkbox"]'), a = o.querySelector("[contenteditable]");
575
575
  return {
@@ -578,47 +578,47 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
578
578
  markerElement: r,
579
579
  checkboxElement: l
580
580
  };
581
- }, dn = (i) => {
581
+ }, hn = (i) => {
582
582
  var n;
583
583
  const { data: t } = i, e = document.createElement("div");
584
- return e.className = on, e.setAttribute(E.tool, w), e.setAttribute("data-list-style", t.style), e.setAttribute("data-list-depth", String((n = t.depth) != null ? n : 0)), t.start !== void 0 && t.start !== 1 && e.setAttribute("data-list-start", String(t.start)), e;
585
- }, hn = (i) => {
584
+ return e.className = rn, e.setAttribute(E.tool, w), e.setAttribute("data-list-style", t.style), e.setAttribute("data-list-depth", String((n = t.depth) != null ? n : 0)), t.start !== void 0 && t.start !== 1 && e.setAttribute("data-list-start", String(t.start)), e;
585
+ }, un = (i) => {
586
586
  var c;
587
587
  const { data: t, itemColor: e, itemSize: n, placeholder: s } = i, o = document.createElement("div");
588
- o.setAttribute("role", "listitem"), o.className = v(rn, "flex", ...at), e && (o.style.color = e), n && (o.style.fontSize = n);
588
+ o.setAttribute("role", "listitem"), o.className = v(ln, "flex", ...ht), e && (o.style.color = e), n && (o.style.fontSize = n);
589
589
  const r = (c = t.depth) != null ? c : 0;
590
- r > 0 && (o.style.marginLeft = `${r * V}px`);
591
- const l = pn(t.style, r);
590
+ r > 0 && (o.style.marginLeft = `${r * z}px`);
591
+ const l = gn(t.style, r);
592
592
  l.setAttribute("data-list-marker", "true"), l.setAttribute("data-blok-mutation-free", "true"), o.appendChild(l);
593
593
  const a = document.createElement("div");
594
- return a.className = v("flex-1 min-w-0 outline-none", ...at), a.setAttribute("data-blok-testid", re.contentContainer), a.contentEditable = i.readOnly ? "false" : "true", a.innerHTML = t.text, le(a, s), o.appendChild(a), o;
595
- }, un = (i) => {
594
+ return a.className = v("flex-1 min-w-0 outline-none", ...ht), a.setAttribute("data-blok-testid", re.contentContainer), a.contentEditable = i.readOnly ? "false" : "true", a.innerHTML = t.text, le(a, s), o.appendChild(a), o;
595
+ }, pn = (i) => {
596
596
  var d;
597
597
  const { data: t, itemColor: e, itemSize: n, placeholder: s, readOnly: o } = i, r = document.createElement("div");
598
- r.setAttribute("role", "listitem"), r.className = ln, e && (r.style.color = e), n && (r.style.fontSize = n);
598
+ r.setAttribute("role", "listitem"), r.className = an, e && (r.style.color = e), n && (r.style.fontSize = n);
599
599
  const l = (d = t.depth) != null ? d : 0;
600
- l > 0 && (r.style.marginLeft = `${l * V}px`);
600
+ l > 0 && (r.style.marginLeft = `${l * z}px`);
601
601
  const a = document.createElement("input");
602
- a.type = "checkbox", a.className = an, a.checked = !!t.checked, a.disabled = o;
602
+ a.type = "checkbox", a.className = cn, a.checked = !!t.checked, a.disabled = o;
603
603
  const c = document.createElement("div");
604
604
  return c.className = v(
605
605
  "flex-1 outline-none leading-[1.6em]",
606
606
  t.checked ? "line-through opacity-60" : "",
607
- ...at
607
+ ...ht
608
608
  ), c.setAttribute("data-blok-testid", re.checklistContent), c.setAttribute("data-checked", String(t.checked)), c.contentEditable = o ? "false" : "true", c.innerHTML = t.text, le(c, s), r.appendChild(a), r.appendChild(c), r;
609
- }, pn = (i, t) => {
609
+ }, gn = (i, t) => {
610
610
  const e = document.createElement("span");
611
611
  if (e.className = "flex-shrink-0 select-none", e.setAttribute("aria-hidden", "true"), e.contentEditable = "false", i === "ordered")
612
612
  e.textContent = "1.", e.className = v(e.className, "text-right"), e.style.paddingRight = "11px", e.style.minWidth = "fit-content";
613
613
  else {
614
- const n = gn(t);
614
+ const n = fn(t);
615
615
  e.textContent = n, e.className = v(e.className, "w-6 text-center flex justify-center"), e.style.paddingLeft = "1px", e.style.paddingRight = "13px", e.style.fontSize = "24px", e.style.fontFamily = "Arial";
616
616
  }
617
617
  return e;
618
- }, gn = (i) => {
618
+ }, fn = (i) => {
619
619
  const t = ["•", "◦", "▪"];
620
620
  return t[i % t.length];
621
- }, fn = (i) => {
621
+ }, mn = (i) => {
622
622
  const { data: t, readOnly: e, placeholder: n, itemColor: s, itemSize: o, element: r, setupItemPlaceholder: l, onCheckboxChange: a, keydownHandler: c } = i;
623
623
  if (!r) return null;
624
624
  const d = r.parentNode;
@@ -638,7 +638,7 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
638
638
  });
639
639
  }
640
640
  return d.replaceChild(h.wrapper, r), h.wrapper;
641
- }, mn = (i, t, e) => {
641
+ }, Cn = (i, t, e) => {
642
642
  if (!t) return i;
643
643
  const n = e(), o = {
644
644
  text: n ? ie(n.innerHTML) : i.text,
@@ -646,18 +646,18 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
646
646
  checked: i.checked
647
647
  };
648
648
  return i.start !== void 0 && i.start !== 1 && (o.start = i.start), i.depth !== void 0 && i.depth > 0 && (o.depth = i.depth), o;
649
- }, Cn = (i, t, e, n, s) => {
650
- var f, y, b;
649
+ }, yn = (i, t, e, n, s) => {
650
+ var m, C, b;
651
651
  if (!e)
652
652
  return { newData: i, inPlace: !1 };
653
- const o = (f = i.depth) != null ? f : 0, r = (y = t.depth) != null ? y : 0, l = i.style, a = t.style;
653
+ const o = (m = i.depth) != null ? m : 0, r = (C = t.depth) != null ? C : 0, l = i.style, a = t.style;
654
654
  if (l !== a)
655
655
  return { newData: i, inPlace: !1 };
656
- const c = "depth" in t ? t.depth : 0, d = tt(L(L({}, i), t), {
656
+ const c = "depth" in t ? t.depth : 0, d = tt(x(x({}, i), t), {
657
657
  depth: c
658
658
  }), h = n();
659
659
  return h && typeof t.text == "string" && (h.innerHTML = t.text), o !== r ? (s.adjustDepthTo(r), s.updateMarkerForDepth(r, a), { newData: d, inPlace: !0 }) : (a === "checklist" && s.updateCheckboxState((b = t.checked) != null ? b : !1), { newData: d, inPlace: !0 });
660
- }, yn = (i, t) => {
660
+ }, bn = (i, t) => {
661
661
  const { element: e, getContentElement: n, parseHTML: s, data: o } = i;
662
662
  if (!e)
663
663
  return;
@@ -667,13 +667,13 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
667
667
  const l = s(t.text);
668
668
  r.appendChild(l), r.normalize();
669
669
  }
670
- }, bn = (i, t, e, n) => i.map((s) => ({
670
+ }, vn = (i, t, e, n) => i.map((s) => ({
671
671
  icon: s.icon,
672
672
  title: e(`toolNames.${s.titleKey}`),
673
673
  onActivate: () => n(s.style),
674
674
  closeOnActivate: !0,
675
675
  isActive: t === s.style
676
- })), vn = (i) => {
676
+ })), Sn = (i) => {
677
677
  if (!i)
678
678
  return;
679
679
  const e = (i.getAttribute("style") || "").match(/margin-left:\s*(\d+)px/);
@@ -681,7 +681,7 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
681
681
  return;
682
682
  const n = parseInt(e[1], 10);
683
683
  return n > 0 ? { left: n } : void 0;
684
- }, Sn = (i) => {
684
+ }, wn = (i) => {
685
685
  const t = i.closest("[data-list-depth]");
686
686
  if (!t)
687
687
  return;
@@ -689,11 +689,11 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
689
689
  if (e === null)
690
690
  return;
691
691
  const n = parseInt(e, 10);
692
- return n > 0 ? { left: n * V } : void 0;
693
- }, wn = (i) => {
694
- const t = i.closest('[role="listitem"]') || i.querySelector('[role="listitem"]'), e = vn(t);
695
- return e !== void 0 ? e : Sn(i);
696
- }, An = (i, t) => {
692
+ return n > 0 ? { left: n * z } : void 0;
693
+ }, An = (i) => {
694
+ const t = i.closest('[role="listitem"]') || i.querySelector('[role="listitem"]'), e = Sn(t);
695
+ return e !== void 0 ? e : wn(i);
696
+ }, En = (i, t) => {
697
697
  const e = document.createRange();
698
698
  if (e.setStart(i, 0), e.setEnd(t.startContainer, t.startOffset), !i.lastChild)
699
699
  return {
@@ -702,33 +702,33 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
702
702
  };
703
703
  const n = document.createRange();
704
704
  return n.setStart(t.endContainer, t.endOffset), n.setEndAfter(i.lastChild), {
705
- beforeContent: It(e.cloneContents()),
706
- afterContent: It(n.cloneContents())
705
+ beforeContent: Nt(e.cloneContents()),
706
+ afterContent: Nt(n.cloneContents())
707
707
  };
708
- }, It = (i) => {
708
+ }, Nt = (i) => {
709
709
  const t = document.createElement("div");
710
710
  return t.appendChild(i), t.innerHTML;
711
- }, En = (i) => {
711
+ }, kn = (i) => {
712
712
  const t = document.createElement("div");
713
713
  t.innerHTML = i.trim();
714
714
  const e = document.createDocumentFragment();
715
715
  return e.append(...Array.from(t.childNodes)), e;
716
- }, kn = (i, t) => {
716
+ }, xn = (i, t) => {
717
717
  const e = document.createRange();
718
718
  return e.selectNodeContents(i), e.setEnd(t.startContainer, t.startOffset), e.toString().length === 0;
719
- }, xn = (i, t) => {
719
+ }, Tn = (i, t) => {
720
720
  const e = document.createRange();
721
721
  e.selectNodeContents(i), e.setEnd(t.startContainer, t.startOffset);
722
722
  const n = e.toString().length === 0, s = document.createRange();
723
723
  s.selectNodeContents(i), s.setStart(t.endContainer, t.endOffset);
724
724
  const o = s.toString().length === 0;
725
725
  return n && o;
726
- }, Tn = (i) => {
726
+ }, Rn = (i) => {
727
727
  if (typeof i != "object" || i === null)
728
728
  return !1;
729
729
  const e = Object.entries(i).find(([n]) => n === "items");
730
730
  return e === void 0 ? !1 : Array.isArray(e[1]);
731
- }, Ln = (i) => typeof i == "object" && i !== null, Rn = (i) => typeof i == "string" ? i : "", Bn = (i, t) => i === "unordered" || i === "ordered" || i === "checklist" ? i : t, In = (i) => !!i, Dn = (i, t) => typeof i == "number" ? i : t, Nn = (i, t) => {
731
+ }, Ln = (i) => typeof i == "object" && i !== null, Bn = (i) => typeof i == "string" ? i : "", In = (i, t) => i === "unordered" || i === "ordered" || i === "checklist" ? i : t, Nn = (i) => !!i, Dn = (i, t) => typeof i == "number" ? i : t, Hn = (i, t) => {
732
732
  const e = t.defaultStyle || "unordered";
733
733
  if (!i || typeof i != "object")
734
734
  return {
@@ -737,9 +737,9 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
737
737
  checked: !1,
738
738
  depth: 0
739
739
  };
740
- if (Tn(i)) {
740
+ if (Rn(i)) {
741
741
  const n = i.items[0], s = (n == null ? void 0 : n.content) || "", o = (n == null ? void 0 : n.checked) || !1;
742
- return L({
742
+ return x({
743
743
  text: s,
744
744
  style: i.style || e,
745
745
  checked: !!o,
@@ -747,8 +747,8 @@ const V = 24, on = "outline-none py-[3px] mt-[2px] mb-px", rn = "outline-none pl
747
747
  }, i.start !== void 0 && i.start !== 1 ? { start: i.start } : {});
748
748
  }
749
749
  if (Ln(i)) {
750
- const n = Rn(i.text), s = Bn(i.style, e), o = In(i.checked), r = Dn(i.depth, 0), l = i.start, a = typeof l == "number" && l !== void 0 && l !== 1 ? l : void 0;
751
- return L({
750
+ const n = Bn(i.text), s = In(i.style, e), o = Nn(i.checked), r = Dn(i.depth, 0), l = i.start, a = typeof l == "number" && l !== void 0 && l !== 1 ? l : void 0;
751
+ return x({
752
752
  text: n,
753
753
  style: s,
754
754
  checked: o,
@@ -819,7 +819,7 @@ class ce {
819
819
  if (!t)
820
820
  return 0;
821
821
  const e = (o = (s = t.holder) == null ? void 0 : s.querySelector('[role="listitem"]')) == null ? void 0 : o.getAttribute("style"), n = e == null ? void 0 : e.match(/margin-left:\s*(\d+)px/);
822
- return n ? Math.round(parseInt(n[1], 10) / V) : 0;
822
+ return n ? Math.round(parseInt(n[1], 10) / z) : 0;
823
823
  }
824
824
  }
825
825
  const Pn = (i, t) => {
@@ -833,8 +833,8 @@ const Pn = (i, t) => {
833
833
  }, _n = (i, t, e) => {
834
834
  i && i.setAttribute("data-list-depth", String(e));
835
835
  const n = i == null ? void 0 : i.querySelector('[role="listitem"]');
836
- n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e * V}px` : ""), t.depth = e;
837
- }, de = (i, t) => t.getBlockDepth(i), he = (i, t) => t.getBlockStyle(i), Hn = (i, t) => t.getBulletCharacter(i), Dt = (i, t, e, n, s) => {
836
+ n instanceof HTMLElement && (n.style.marginLeft = e > 0 ? `${e * z}px` : ""), t.depth = e;
837
+ }, de = (i, t) => t.getBlockDepth(i), he = (i, t) => t.getBlockStyle(i), On = (i, t) => t.getBulletCharacter(i), Dt = (i, t, e, n, s) => {
838
838
  var r;
839
839
  const o = i && (r = n.getBlockIndex(i)) != null ? r : n.getCurrentBlockIndex();
840
840
  return o <= 0 ? 0 : s.getSiblingIndex(o, t, e);
@@ -849,10 +849,10 @@ const Pn = (i, t) => {
849
849
  n.style
850
850
  );
851
851
  return l === null ? 1 : o.getBlockStartValue(l);
852
- }, Nt = (i, t, e, n, s, o) => {
852
+ }, Ht = (i, t, e, n, s, o) => {
853
853
  const l = Mn(i, t, n, e, s, o) + i;
854
854
  return o.formatNumber(l, t);
855
- }, On = (i, t, e, n) => n.findGroupStart(i, t, e), ue = (i, t, e, n) => {
855
+ }, Wn = (i, t, e, n) => n.findGroupStart(i, t, e), ue = (i, t, e, n) => {
856
856
  if (!i)
857
857
  return;
858
858
  const s = i.holder, o = s == null ? void 0 : s.querySelector('[data-list-style="ordered"]');
@@ -864,8 +864,8 @@ const Pn = (i, t) => {
864
864
  const l = t.getBlockIndex(i.id);
865
865
  if (l == null)
866
866
  return;
867
- const a = de(i, e), c = he(i, n) || "ordered", d = n.getSiblingIndex(l, a, c), p = n.getGroupStartValue(l, a, d, c) + d, m = n.formatNumber(p, a);
868
- r.textContent = m;
867
+ const a = de(i, e), c = he(i, n) || "ordered", d = n.getSiblingIndex(l, a, c), p = n.getGroupStartValue(l, a, d, c) + d, f = n.formatNumber(p, a);
868
+ r.textContent = f;
869
869
  }, $n = (i, t, e, n, s, o, r, l) => {
870
870
  const a = (c) => {
871
871
  if (c >= t)
@@ -896,7 +896,7 @@ const Pn = (i, t) => {
896
896
  const r = o.holder;
897
897
  r != null && r.querySelector('[data-list-style="ordered"]') && ue(o, i, t, e);
898
898
  });
899
- }, Y = (i, t, e = "end") => {
899
+ }, X = (i, t, e = "end") => {
900
900
  requestAnimationFrame(() => {
901
901
  const n = t.holder;
902
902
  if (!n) return;
@@ -911,30 +911,30 @@ const Pn = (i, t) => {
911
911
  const r = document.createRange();
912
912
  e === "start" ? (r.setStart(s, 0), r.collapse(!0)) : (r.selectNodeContents(s), r.collapse(!1)), o.removeAllRanges(), o.addRange(r), i.caret.updateLastCaretAfterPosition();
913
913
  });
914
- }, Wn = async (i) => {
915
- var f;
914
+ }, qn = async (i) => {
915
+ var m;
916
916
  const { api: t, blockId: e, data: n, element: s, getContentElement: o } = i, r = window.getSelection();
917
917
  if (!r || !s) return;
918
918
  const l = o();
919
919
  if (!l) return;
920
920
  const a = l.innerHTML.trim();
921
921
  if (a === "" || a === "<br>") {
922
- await qn(i);
922
+ await Fn(i);
923
923
  return;
924
924
  }
925
- const c = r.getRangeAt(0), { beforeContent: d, afterContent: h } = An(l, c), p = e && (f = t.blocks.getBlockIndex(e)) != null ? f : t.blocks.getCurrentBlockIndex();
925
+ const c = r.getRangeAt(0), { beforeContent: d, afterContent: h } = En(l, c), p = e && (m = t.blocks.getBlockIndex(e)) != null ? m : t.blocks.getCurrentBlockIndex();
926
926
  if (!e) {
927
927
  l.innerHTML = d, n.text = d;
928
- const y = t.blocks.insert(w, {
928
+ const C = t.blocks.insert(w, {
929
929
  text: h,
930
930
  style: n.style,
931
931
  checked: !1,
932
932
  depth: n.depth
933
933
  }, void 0, p + 1, !0);
934
- Y(t, y, "start");
934
+ X(t, C, "start");
935
935
  return;
936
936
  }
937
- const m = t.blocks.splitBlock(
937
+ const f = t.blocks.splitBlock(
938
938
  e,
939
939
  { text: d },
940
940
  w,
@@ -946,8 +946,8 @@ const Pn = (i, t) => {
946
946
  },
947
947
  p + 1
948
948
  );
949
- n.text = d, Y(t, m, "start");
950
- }, qn = async (i) => {
949
+ n.text = d, X(t, f, "start");
950
+ }, Fn = async (i) => {
951
951
  const { api: t, blockId: e, getDepth: n } = i;
952
952
  if (n() > 0) {
953
953
  await pe(i);
@@ -956,28 +956,28 @@ const Pn = (i, t) => {
956
956
  if (e === void 0)
957
957
  return;
958
958
  const o = await t.blocks.convert(e, "paragraph", { text: "" });
959
- Y(t, o, "start");
960
- }, Fn = async (i, t) => {
959
+ X(t, o, "start");
960
+ }, zn = async (i, t) => {
961
961
  const { api: e, blockId: n, data: s, element: o, getContentElement: r, getDepth: l, syncContentFromDOM: a } = i, c = window.getSelection();
962
962
  if (!c || !o) return;
963
963
  const d = c.getRangeAt(0), h = r();
964
964
  if (!h) return;
965
965
  a();
966
- const p = s.text, m = l();
967
- if (xn(h, d) && !c.isCollapsed) {
966
+ const p = s.text, f = l();
967
+ if (Tn(h, d) && !c.isCollapsed) {
968
968
  t.preventDefault(), h.innerHTML = "", s.text = "";
969
969
  const b = document.createRange();
970
970
  b.setStart(h, 0), b.collapse(!0), c.removeAllRanges(), c.addRange(b);
971
971
  return;
972
972
  }
973
- if (!kn(h, d) || (t.preventDefault(), n === void 0))
973
+ if (!xn(h, d) || (t.preventDefault(), n === void 0))
974
974
  return;
975
- const y = await e.blocks.convert(n, "paragraph", { text: p });
976
- m > 0 && requestAnimationFrame(() => {
977
- const b = y.holder;
978
- b && (b.style.marginLeft = `${m * V}px`, b.setAttribute("data-blok-depth", String(m)));
979
- }), Y(e, y, "start");
980
- }, zn = async (i, t) => {
975
+ const C = await e.blocks.convert(n, "paragraph", { text: p });
976
+ f > 0 && requestAnimationFrame(() => {
977
+ const b = C.holder;
978
+ b && (b.style.marginLeft = `${f * z}px`, b.setAttribute("data-blok-depth", String(f)));
979
+ }), X(e, C, "start");
980
+ }, Vn = async (i, t) => {
981
981
  const { api: e, blockId: n, data: s, syncContentFromDOM: o, getDepth: r } = i, l = e.blocks.getCurrentBlockIndex();
982
982
  if (l === 0) return;
983
983
  const a = e.blocks.getBlockByIndex(l - 1);
@@ -987,21 +987,21 @@ const Pn = (i, t) => {
987
987
  o();
988
988
  const h = c + 1;
989
989
  s.depth = h;
990
- const p = await e.blocks.update(n || "", tt(L({}, s), {
990
+ const p = await e.blocks.update(n || "", tt(x({}, s), {
991
991
  depth: h
992
992
  }));
993
- Y(e, p);
993
+ X(e, p);
994
994
  }, pe = async (i) => {
995
995
  const { api: t, blockId: e, data: n, syncContentFromDOM: s, getDepth: o } = i, r = o();
996
996
  if (r === 0) return;
997
997
  s();
998
998
  const l = r - 1;
999
999
  n.depth = l;
1000
- const a = await t.blocks.update(e || "", tt(L({}, n), {
1000
+ const a = await t.blocks.update(e || "", tt(x({}, n), {
1001
1001
  depth: l
1002
1002
  }));
1003
- Y(t, a);
1004
- }, Vn = (i) => {
1003
+ X(t, a);
1004
+ }, Un = (i) => {
1005
1005
  const { data: t, readOnly: e, placeholder: n, itemColor: s, itemSize: o, setupItemPlaceholder: r, onCheckboxChange: l, keydownHandler: a } = i, c = ae({
1006
1006
  data: t,
1007
1007
  readOnly: e,
@@ -1017,14 +1017,14 @@ const Pn = (i, t) => {
1017
1017
  });
1018
1018
  }
1019
1019
  return c.wrapper;
1020
- }, Un = (i) => {
1020
+ }, Kn = (i) => {
1021
1021
  const t = (e) => {
1022
1022
  if (e <= 0) return "";
1023
1023
  const n = e - 1;
1024
1024
  return t(Math.floor(n / 26)) + String.fromCharCode(97 + n % 26);
1025
1025
  };
1026
1026
  return t(i);
1027
- }, Kn = (i) => {
1027
+ }, jn = (i) => {
1028
1028
  const t = [
1029
1029
  [1e3, "m"],
1030
1030
  [900, "cm"],
@@ -1105,7 +1105,7 @@ class ge {
1105
1105
  */
1106
1106
  formatNumber(t, e) {
1107
1107
  const n = e % 3;
1108
- return n === 1 ? `${Un(t)}.` : n === 2 ? `${Kn(t)}.` : `${t}.`;
1108
+ return n === 1 ? `${Kn(t)}.` : n === 2 ? `${jn(t)}.` : `${t}.`;
1109
1109
  }
1110
1110
  /**
1111
1111
  * Get the start value for a list group.
@@ -1158,7 +1158,7 @@ class ge {
1158
1158
  if (!t)
1159
1159
  return 0;
1160
1160
  const e = (o = (s = t.holder) == null ? void 0 : s.querySelector('[role="listitem"]')) == null ? void 0 : o.getAttribute("style"), n = e == null ? void 0 : e.match(/margin-left:\s*(\d+)px/);
1161
- return n ? Math.round(parseInt(n[1], 10) / V) : 0;
1161
+ return n ? Math.round(parseInt(n[1], 10) / z) : 0;
1162
1162
  }
1163
1163
  /**
1164
1164
  * Get the style of a block by reading from its DOM.
@@ -1201,8 +1201,8 @@ class ge {
1201
1201
  return r < n ? e : r > n ? this.findGroupStartRecursive(t - 1, e, n, s) : this.getBlockStyle(o) !== s ? e : this.findGroupStartRecursive(t - 1, t, n, s);
1202
1202
  }
1203
1203
  }
1204
- const dt = { value: !1 };
1205
- class jn {
1204
+ const pt = { value: !1 };
1205
+ class Xn {
1206
1206
  constructor(t) {
1207
1207
  this.blocks = t, this.depthValidator = new ce(t), this.markerCalculator = new ge(t);
1208
1208
  }
@@ -1256,8 +1256,8 @@ class jn {
1256
1256
  * Uses a static flag to deduplicate multiple calls in the same frame.
1257
1257
  */
1258
1258
  scheduleUpdateAll() {
1259
- dt.value || (dt.value = !0, requestAnimationFrame(() => {
1260
- dt.value = !1, this.updateAllMarkers();
1259
+ pt.value || (pt.value = !0, requestAnimationFrame(() => {
1260
+ pt.value = !1, this.updateAllMarkers();
1261
1261
  }));
1262
1262
  }
1263
1263
  /**
@@ -1311,15 +1311,15 @@ class jn {
1311
1311
  if (o == null)
1312
1312
  return;
1313
1313
  const r = this.depthValidator.getBlockDepth(t), l = this.getBlockStyle(t) || "ordered", a = this.markerCalculator.getSiblingIndex(o, r, l), c = this.markerCalculator.getGroupStartValue(o, r, a, l), h = (a === 0 && c === 1 ? (() => {
1314
- const m = n.closest("[data-list-start]"), f = m == null ? void 0 : m.getAttribute("data-list-start");
1315
- if (!f) return c;
1316
- const y = parseInt(f, 10);
1317
- return isNaN(y) ? c : y;
1314
+ const f = n.closest("[data-list-start]"), m = f == null ? void 0 : f.getAttribute("data-list-start");
1315
+ if (!m) return c;
1316
+ const C = parseInt(m, 10);
1317
+ return isNaN(C) ? c : C;
1318
1318
  })() : c) + a, p = this.markerCalculator.formatNumber(h, r);
1319
1319
  s.textContent = p;
1320
1320
  }
1321
1321
  }
1322
- const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1322
+ const Yn = (i) => i instanceof HTMLElement, Zn = /* @__PURE__ */ new Set([
1323
1323
  "decimal",
1324
1324
  "decimal-leading-zero",
1325
1325
  "lower-roman",
@@ -1350,12 +1350,12 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1350
1350
  "telugu",
1351
1351
  "thai",
1352
1352
  "tibetan"
1353
- ]), Zn = /* @__PURE__ */ new Set([
1353
+ ]), Jn = /* @__PURE__ */ new Set([
1354
1354
  "disc",
1355
1355
  "circle",
1356
1356
  "square",
1357
1357
  "none"
1358
- ]), Jn = (i) => {
1358
+ ]), Qn = (i) => {
1359
1359
  const t = i.getAttribute("data-list-style");
1360
1360
  if (t === "ordered") return "ordered";
1361
1361
  if (t === "unordered") return "unordered";
@@ -1364,25 +1364,25 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1364
1364
  const n = e.match(/list-style-type\s*:\s*([^;]+)/);
1365
1365
  if (!n) return null;
1366
1366
  const s = n[1].trim().toLowerCase();
1367
- return Yn.has(s) ? "ordered" : Zn.has(s) ? "unordered" : null;
1368
- }, Qn = (i, t) => {
1367
+ return Zn.has(s) ? "ordered" : Jn.has(s) ? "unordered" : null;
1368
+ }, ts = (i, t) => {
1369
1369
  const e = i.parentElement;
1370
1370
  if ((e == null ? void 0 : e.tagName) === "OL") return "ordered";
1371
1371
  if ((e == null ? void 0 : e.tagName) === "UL")
1372
1372
  return i.querySelector('input[type="checkbox"]') ? "checklist" : "unordered";
1373
- const n = Jn(i);
1373
+ const n = Qn(i);
1374
1374
  return n || t;
1375
- }, ts = (i) => {
1375
+ }, es = (i) => {
1376
1376
  const t = i.innerHTML || i.textContent || "", e = i.querySelector('input[type="checkbox"]'), n = e instanceof HTMLInputElement ? e.checked : !1;
1377
1377
  return { text: t, checked: n };
1378
- }, es = (i) => {
1378
+ }, ns = (i) => {
1379
1379
  const t = i.getAttribute("aria-level");
1380
1380
  if (t) {
1381
1381
  const e = parseInt(t, 10);
1382
1382
  return Math.max(0, e - 1);
1383
1383
  }
1384
1384
  return 0;
1385
- }, ns = () => ({
1385
+ }, ss = () => ({
1386
1386
  text: {
1387
1387
  br: !0,
1388
1388
  a: {
@@ -1394,7 +1394,7 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1394
1394
  i: !0,
1395
1395
  mark: !0
1396
1396
  }
1397
- }), ss = () => ({
1397
+ }), os = () => ({
1398
1398
  tags: [
1399
1399
  {
1400
1400
  li: {
@@ -1405,7 +1405,7 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1405
1405
  }
1406
1406
  }
1407
1407
  ]
1408
- }), os = () => ({
1408
+ }), is = () => ({
1409
1409
  export: (i) => i.text,
1410
1410
  import: (i) => ({
1411
1411
  text: i,
@@ -1417,23 +1417,23 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1417
1417
  name: "bulletedList",
1418
1418
  titleKey: "bulletedList",
1419
1419
  style: "unordered",
1420
- icon: te
1420
+ icon: Qt
1421
1421
  },
1422
1422
  {
1423
1423
  name: "numberedList",
1424
1424
  titleKey: "numberedList",
1425
1425
  style: "ordered",
1426
- icon: ee
1426
+ icon: te
1427
1427
  },
1428
1428
  {
1429
1429
  name: "todoList",
1430
1430
  titleKey: "todoList",
1431
1431
  style: "checklist",
1432
- icon: ne
1432
+ icon: ee
1433
1433
  }
1434
- ], is = () => [
1434
+ ], rs = () => [
1435
1435
  {
1436
- icon: te,
1436
+ icon: Qt,
1437
1437
  title: "Bulleted list",
1438
1438
  titleKey: "bulletedList",
1439
1439
  data: { style: "unordered" },
@@ -1442,7 +1442,7 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1442
1442
  shortcut: "-"
1443
1443
  },
1444
1444
  {
1445
- icon: ee,
1445
+ icon: te,
1446
1446
  title: "Numbered list",
1447
1447
  titleKey: "numberedList",
1448
1448
  data: { style: "ordered" },
@@ -1451,7 +1451,7 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1451
1451
  shortcut: "1."
1452
1452
  },
1453
1453
  {
1454
- icon: ne,
1454
+ icon: ee,
1455
1455
  title: "To-do list",
1456
1456
  titleKey: "todoList",
1457
1457
  data: { style: "checklist" },
@@ -1460,18 +1460,18 @@ const Xn = (i) => i instanceof HTMLElement, Yn = /* @__PURE__ */ new Set([
1460
1460
  shortcut: "[]"
1461
1461
  }
1462
1462
  ];
1463
- class ao {
1463
+ class vo {
1464
1464
  constructor({ data: t, config: e, api: n, readOnly: s, block: o }) {
1465
1465
  this._element = null, this.handleBlockChanged = (r) => {
1466
1466
  var l;
1467
1467
  this.isBlockChangedEventPayload(r) && (r.event.type === "block-removed" || r.event.type === "block-added") && ((l = this.markerManager) == null || l.scheduleUpdateAll());
1468
- }, this.api = n, this.readOnly = s, this._settings = e || {}, this._data = this.normalizeData(t), this.depthValidator = new ce(n.blocks), this.markerCalculator = new ge(n.blocks), this.markerManager = this._data.style === "ordered" ? new jn(n.blocks) : null, o && (this.blockId = o.id), this._data.style === "ordered" && this.api.events.on("block changed", this.handleBlockChanged);
1468
+ }, this.api = n, this.readOnly = s, this._settings = e || {}, this._data = this.normalizeData(t), this.depthValidator = new ce(n.blocks), this.markerCalculator = new ge(n.blocks), this.markerManager = this._data.style === "ordered" ? new Xn(n.blocks) : null, o && (this.blockId = o.id), this._data.style === "ordered" && this.api.events.on("block changed", this.handleBlockChanged);
1469
1469
  }
1470
1470
  isBlockChangedEventPayload(t) {
1471
1471
  return typeof t == "object" && t !== null && "event" in t && typeof t.event == "object" && t.event !== null && "type" in t.event && typeof t.event.type == "string";
1472
1472
  }
1473
1473
  normalizeData(t) {
1474
- return Nn(t, this._settings);
1474
+ return Hn(t, this._settings);
1475
1475
  }
1476
1476
  get availableStyles() {
1477
1477
  const t = this._settings.styles;
@@ -1484,13 +1484,13 @@ class ao {
1484
1484
  return this._settings.itemSize;
1485
1485
  }
1486
1486
  get placeholder() {
1487
- return this.api.i18n.t(cn);
1487
+ return this.api.i18n.t(dn);
1488
1488
  }
1489
1489
  setupItemPlaceholder(t) {
1490
- this.readOnly || wt(t, this.placeholder);
1490
+ this.readOnly || Et(t, this.placeholder);
1491
1491
  }
1492
1492
  render() {
1493
- return this._element = Vn({
1493
+ return this._element = Un({
1494
1494
  data: this._data,
1495
1495
  readOnly: this.readOnly,
1496
1496
  placeholder: this.placeholder,
@@ -1535,12 +1535,12 @@ class ao {
1535
1535
  const t = (o = this._element) == null ? void 0 : o.querySelector("[data-list-marker]");
1536
1536
  if (!t)
1537
1537
  return;
1538
- const e = this.getDepth(), n = Dt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), s = Nt(n, e, this._data, this.blockId, this.api.blocks, this.markerCalculator);
1538
+ const e = this.getDepth(), n = Dt(this.blockId, e, this._data.style, this.api.blocks, this.markerCalculator), s = Ht(n, e, this._data, this.blockId, this.api.blocks, this.markerCalculator);
1539
1539
  t.textContent = s;
1540
1540
  }
1541
1541
  updateSiblingListMarkers() {
1542
1542
  var r;
1543
- const t = this.blockId ? (r = this.api.blocks.getBlockIndex(this.blockId)) != null ? r : this.api.blocks.getCurrentBlockIndex() : this.api.blocks.getCurrentBlockIndex(), e = this.getDepth(), n = this._data.style, s = this.api.blocks.getBlocksCount(), o = On(t, e, n, this.markerCalculator);
1543
+ const t = this.blockId ? (r = this.api.blocks.getBlockIndex(this.blockId)) != null ? r : this.api.blocks.getCurrentBlockIndex() : this.api.blocks.getCurrentBlockIndex(), e = this.getDepth(), n = this._data.style, s = this.api.blocks.getBlocksCount(), o = Wn(t, e, n, this.markerCalculator);
1544
1544
  $n(o, s, t, e, n, this.api.blocks, this.depthValidator, this.markerCalculator);
1545
1545
  }
1546
1546
  updateMarkerForDepth(t, e) {
@@ -1548,10 +1548,10 @@ class ao {
1548
1548
  const n = (s = this._element) == null ? void 0 : s.querySelector('[aria-hidden="true"]');
1549
1549
  if (n instanceof HTMLElement)
1550
1550
  if (e === "ordered") {
1551
- const o = Dt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), r = Nt(o, t, this._data, this.blockId, this.api.blocks, this.markerCalculator);
1551
+ const o = Dt(this.blockId, t, this._data.style, this.api.blocks, this.markerCalculator), r = Ht(o, t, this._data, this.blockId, this.api.blocks, this.markerCalculator);
1552
1552
  n.textContent = r;
1553
1553
  } else {
1554
- const o = Hn(t, this.markerCalculator);
1554
+ const o = On(t, this.markerCalculator);
1555
1555
  n.textContent = o;
1556
1556
  }
1557
1557
  }
@@ -1591,7 +1591,7 @@ class ao {
1591
1591
  syncContentFromDOM: this.syncContentFromDOM.bind(this),
1592
1592
  getDepth: this.getDepth.bind(this)
1593
1593
  };
1594
- await Wn(t);
1594
+ await qn(t);
1595
1595
  }
1596
1596
  async handleBackspace(t) {
1597
1597
  const e = {
@@ -1603,7 +1603,7 @@ class ao {
1603
1603
  syncContentFromDOM: this.syncContentFromDOM.bind(this),
1604
1604
  getDepth: this.getDepth.bind(this)
1605
1605
  };
1606
- await Fn(e, t);
1606
+ await zn(e, t);
1607
1607
  }
1608
1608
  async handleIndent() {
1609
1609
  const t = {
@@ -1615,7 +1615,7 @@ class ao {
1615
1615
  syncContentFromDOM: this.syncContentFromDOM.bind(this),
1616
1616
  getDepth: this.getDepth.bind(this)
1617
1617
  };
1618
- await zn(t, this.depthValidator);
1618
+ await Vn(t, this.depthValidator);
1619
1619
  }
1620
1620
  async handleOutdent() {
1621
1621
  const t = {
@@ -1641,7 +1641,7 @@ class ao {
1641
1641
  return Pn(this._element, this._data.style);
1642
1642
  }
1643
1643
  renderSettings() {
1644
- return bn(this.availableStyles, this._data.style, this.api.i18n.t, (t) => this.setStyle(t));
1644
+ return vn(this.availableStyles, this._data.style, this.api.i18n.t, (t) => this.setStyle(t));
1645
1645
  }
1646
1646
  setStyle(t) {
1647
1647
  const e = this._data.style;
@@ -1650,7 +1650,7 @@ class ao {
1650
1650
  });
1651
1651
  }
1652
1652
  rerender() {
1653
- const t = fn({
1653
+ const t = mn({
1654
1654
  data: this._data,
1655
1655
  readOnly: this.readOnly,
1656
1656
  placeholder: this.placeholder,
@@ -1669,10 +1669,10 @@ class ao {
1669
1669
  return typeof t.text == "string";
1670
1670
  }
1671
1671
  save() {
1672
- return mn(this._data, this._element, this.getContentElement.bind(this));
1672
+ return Cn(this._data, this._element, this.getContentElement.bind(this));
1673
1673
  }
1674
1674
  setData(t) {
1675
- const e = Cn(
1675
+ const e = yn(
1676
1676
  this._data,
1677
1677
  t,
1678
1678
  this._element,
@@ -1686,35 +1686,35 @@ class ao {
1686
1686
  return this._data = e.newData, e.inPlace;
1687
1687
  }
1688
1688
  merge(t) {
1689
- yn(
1689
+ bn(
1690
1690
  {
1691
1691
  data: this._data,
1692
1692
  element: this._element,
1693
1693
  getContentElement: this.getContentElement.bind(this),
1694
- parseHTML: En
1694
+ parseHTML: kn
1695
1695
  },
1696
1696
  t
1697
1697
  );
1698
1698
  }
1699
1699
  static get conversionConfig() {
1700
- return os();
1700
+ return is();
1701
1701
  }
1702
1702
  static get sanitize() {
1703
- return ns();
1703
+ return ss();
1704
1704
  }
1705
1705
  static get pasteConfig() {
1706
- return ss();
1706
+ return os();
1707
1707
  }
1708
1708
  onPaste(t) {
1709
1709
  const e = t.detail;
1710
1710
  if (!("data" in e)) return;
1711
1711
  const n = e.data;
1712
- if (!Xn(n))
1712
+ if (!Yn(n))
1713
1713
  return;
1714
- const { text: s, checked: o } = ts(n), r = es(n);
1714
+ const { text: s, checked: o } = es(n), r = ns(n);
1715
1715
  this._data = {
1716
1716
  text: s,
1717
- style: Qn(n, this._data.style),
1717
+ style: ts(n, this._data.style),
1718
1718
  checked: o,
1719
1719
  depth: r
1720
1720
  }, this.rerender();
@@ -1723,19 +1723,19 @@ class ao {
1723
1723
  return !0;
1724
1724
  }
1725
1725
  getContentOffset(t) {
1726
- return wn(t);
1726
+ return An(t);
1727
1727
  }
1728
1728
  static get toolbox() {
1729
- return is();
1729
+ return rs();
1730
1730
  }
1731
1731
  }
1732
- const rs = "data-blok-table-add-row", ls = "data-blok-table-add-col", _t = 150, as = 5, Ht = 40, Mt = [
1732
+ const ls = "data-blok-table-add-row", as = "data-blok-table-add-col", _t = 150, cs = 5, Ot = 40, Mt = [
1733
1733
  "flex",
1734
1734
  "items-center",
1735
1735
  "justify-center",
1736
1736
  "transition-opacity",
1737
1737
  "duration-150"
1738
- ], Ot = [
1738
+ ], Wt = [
1739
1739
  "flex",
1740
1740
  "items-center",
1741
1741
  "justify-center",
@@ -1744,9 +1744,9 @@ const rs = "data-blok-table-add-row", ls = "data-blok-table-add-col", _t = 150,
1744
1744
  "rounded-full",
1745
1745
  "group-hover/add:bg-gray-50"
1746
1746
  ], $t = "12";
1747
- class cs {
1747
+ class ds {
1748
1748
  constructor(t) {
1749
- this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundRowPointerDown = (e) => this.handlePointerDown("row", e), this.boundColPointerDown = (e) => this.handlePointerDown("col", e), this.addRowBtn = this.createAddRowButton(), this.addColBtn = this.createAddColumnButton(), this.wrapper.appendChild(this.addRowBtn), this.grid.appendChild(this.addColBtn), this.syncRowButtonWidth(), this.wrapper.addEventListener("mousemove", this.boundMouseMove), this.wrapper.addEventListener("mouseleave", this.boundMouseLeave), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
1749
+ this.rowHideTimeout = null, this.colHideTimeout = null, this.rowVisible = !1, this.colVisible = !1, this.dragState = null, this.wrapper = t.wrapper, this.grid = t.grid, this.i18n = t.i18n, this.boundAddRowClick = t.onAddRow, this.boundAddColClick = t.onAddColumn, this.onDragStart = t.onDragStart, this.onDragAddRow = t.onDragAddRow, this.onDragRemoveRow = t.onDragRemoveRow, this.onDragAddCol = t.onDragAddCol, this.onDragRemoveCol = t.onDragRemoveCol, this.onDragEnd = t.onDragEnd, this.getNewColumnWidth = t.getNewColumnWidth, this.boundMouseMove = this.handleMouseMove.bind(this), this.boundMouseLeave = this.handleMouseLeave.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundRowPointerDown = (e) => this.handlePointerDown("row", e), this.boundColPointerDown = (e) => this.handlePointerDown("col", e), this.addRowBtn = this.createAddRowButton(), this.addColBtn = this.createAddColumnButton(), this.wrapper.appendChild(this.addRowBtn), this.grid.appendChild(this.addColBtn), this.syncRowButtonWidth(), this.wrapper.addEventListener("mousemove", this.boundMouseMove), this.wrapper.addEventListener("mouseleave", this.boundMouseLeave), this.addRowBtn.addEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.addEventListener("pointerdown", this.boundColPointerDown);
1750
1750
  }
1751
1751
  /**
1752
1752
  * Match the add-row button width to the grid's explicit width.
@@ -1771,8 +1771,11 @@ class cs {
1771
1771
  * Disables pointer events and hover effects during cell selection.
1772
1772
  */
1773
1773
  setInteractive(t) {
1774
- const e = t ? "" : "none";
1775
- this.addRowBtn.style.pointerEvents = e, this.addColBtn.style.pointerEvents = e;
1774
+ if (!t) {
1775
+ this.addRowBtn.style.pointerEvents = "none", this.addColBtn.style.pointerEvents = "none";
1776
+ return;
1777
+ }
1778
+ this.addRowBtn.style.pointerEvents = this.rowVisible ? "" : "none", this.addColBtn.style.pointerEvents = this.colVisible ? "" : "none";
1776
1779
  }
1777
1780
  destroy() {
1778
1781
  if (this.wrapper.removeEventListener("mousemove", this.boundMouseMove), this.wrapper.removeEventListener("mouseleave", this.boundMouseLeave), this.addRowBtn.removeEventListener("pointerdown", this.boundRowPointerDown), this.addColBtn.removeEventListener("pointerdown", this.boundColPointerDown), this.dragState) {
@@ -1803,7 +1806,7 @@ class cs {
1803
1806
  e === "row" ? this.onDragAddRow() : this.onDragAddCol(), this.dragState.addedCount++;
1804
1807
  for (; this.dragState.addedCount > l; )
1805
1808
  e === "row" ? this.onDragRemoveRow() : this.onDragRemoveCol(), this.dragState.addedCount--;
1806
- Math.abs(r) > as && !this.dragState.didDrag && (this.dragState.didDrag = !0, document.body.style.cursor = e === "row" ? "row-resize" : "col-resize", Oe(), this.onDragStart());
1809
+ Math.abs(r) > cs && !this.dragState.didDrag && (this.dragState.didDrag = !0, document.body.style.cursor = e === "row" ? "row-resize" : "col-resize", We(), this.onDragStart());
1807
1810
  }
1808
1811
  handlePointerUp(t) {
1809
1812
  if (!this.dragState)
@@ -1820,6 +1823,8 @@ class cs {
1820
1823
  const o = this.grid.querySelectorAll("[data-blok-table-row]"), r = o[o.length - 1];
1821
1824
  return (r == null ? void 0 : r.offsetHeight) || 30;
1822
1825
  }
1826
+ if (this.getNewColumnWidth)
1827
+ return this.getNewColumnWidth();
1823
1828
  const e = this.grid.querySelector("[data-blok-table-row]");
1824
1829
  if (!e)
1825
1830
  return 100;
@@ -1828,27 +1833,27 @@ class cs {
1828
1833
  }
1829
1834
  handleMouseMove(t) {
1830
1835
  const e = this.grid.getBoundingClientRect(), n = Math.abs(t.clientY - e.bottom), s = Math.abs(t.clientX - e.right);
1831
- n <= Ht ? this.showRow() : this.scheduleHideRow(), s <= Ht ? this.showCol() : this.scheduleHideCol();
1836
+ n <= Ot ? this.showRow() : this.scheduleHideRow(), s <= Ot ? this.showCol() : this.scheduleHideCol();
1832
1837
  }
1833
1838
  handleMouseLeave() {
1834
1839
  this.scheduleHideRow(), this.scheduleHideCol();
1835
1840
  }
1836
1841
  showRow() {
1837
- this.clearRowTimeout(), this.rowVisible || (this.addRowBtn.style.opacity = "1", this.rowVisible = !0);
1842
+ this.clearRowTimeout(), this.rowVisible || (this.addRowBtn.style.opacity = "1", this.addRowBtn.style.pointerEvents = "", this.rowVisible = !0);
1838
1843
  }
1839
1844
  showCol() {
1840
- this.clearColTimeout(), this.colVisible || (this.addColBtn.style.opacity = "1", this.colVisible = !0);
1845
+ this.clearColTimeout(), this.colVisible || (this.addColBtn.style.opacity = "1", this.addColBtn.style.pointerEvents = "", this.colVisible = !0);
1841
1846
  }
1842
1847
  scheduleHideRow() {
1843
1848
  var t;
1844
1849
  !this.rowVisible || this.rowHideTimeout !== null || ((t = this.dragState) == null ? void 0 : t.axis) === "row" || (this.rowHideTimeout = setTimeout(() => {
1845
- this.addRowBtn.style.opacity = "0", this.rowVisible = !1, this.rowHideTimeout = null;
1850
+ this.addRowBtn.style.opacity = "0", this.addRowBtn.style.pointerEvents = "none", this.rowVisible = !1, this.rowHideTimeout = null;
1846
1851
  }, _t));
1847
1852
  }
1848
1853
  scheduleHideCol() {
1849
1854
  var t;
1850
1855
  !this.colVisible || this.colHideTimeout !== null || ((t = this.dragState) == null ? void 0 : t.axis) === "col" || (this.colHideTimeout = setTimeout(() => {
1851
- this.addColBtn.style.opacity = "0", this.colVisible = !1, this.colHideTimeout = null;
1856
+ this.addColBtn.style.opacity = "0", this.addColBtn.style.pointerEvents = "none", this.colVisible = !1, this.colHideTimeout = null;
1852
1857
  }, _t));
1853
1858
  }
1854
1859
  clearRowTimeout() {
@@ -1859,20 +1864,20 @@ class cs {
1859
1864
  }
1860
1865
  createAddRowButton() {
1861
1866
  const t = document.createElement("div");
1862
- t.className = v(Mt, "group/add", "items-start", "cursor-row-resize"), t.setAttribute(rs, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.boxSizing = "content-box", t.style.width = "100%", t.style.height = "32px", t.style.padding = "4px 8px 0", t.style.marginLeft = "-8px";
1867
+ t.className = v(Mt, "group/add", "items-start", "cursor-row-resize"), t.setAttribute(ls, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.left = "0", t.style.bottom = "-36px", t.style.boxSizing = "content-box", t.style.width = "100%", t.style.height = "32px", t.style.padding = "4px 8px 0", t.style.marginLeft = "-8px";
1863
1868
  const e = document.createElement("div");
1864
- return e.className = v(Ot), e.style.width = "100%", e.style.height = "16px", this.appendIcon(e), t.appendChild(e), xt(t, Tt([
1865
- "Click to add a new row",
1866
- "Drag to add or remove rows"
1869
+ return e.className = v(Wt), e.style.width = "100%", e.style.height = "16px", this.appendIcon(e), t.appendChild(e), Rt(t, Lt([
1870
+ this.i18n.t("tools.table.clickToAddRow"),
1871
+ this.i18n.t("tools.table.dragToAddRemoveRows")
1867
1872
  ]), { placement: "bottom", marginTop: -16 }), t;
1868
1873
  }
1869
1874
  createAddColumnButton() {
1870
1875
  const t = document.createElement("div");
1871
- t.className = v(Mt, "group/add", "justify-start", "cursor-col-resize"), t.setAttribute(ls, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.position = "absolute", t.style.right = "-36px", t.style.top = "0px", t.style.bottom = "0px", t.style.width = "32px";
1876
+ t.className = v(Mt, "group/add", "justify-start", "cursor-col-resize"), t.setAttribute(as, ""), t.setAttribute("contenteditable", "false"), t.style.opacity = "0", t.style.pointerEvents = "none", t.style.position = "absolute", t.style.right = "-36px", t.style.top = "0px", t.style.bottom = "0px", t.style.width = "32px";
1872
1877
  const e = document.createElement("div");
1873
- return e.className = v(Ot), e.style.width = "16px", e.style.height = "100%", this.appendIcon(e), t.appendChild(e), xt(t, Tt([
1874
- "Click to add a new column",
1875
- "Drag to add or remove columns"
1878
+ return e.className = v(Wt), e.style.width = "16px", e.style.height = "100%", this.appendIcon(e), t.appendChild(e), Rt(t, Lt([
1879
+ this.i18n.t("tools.table.clickToAddColumn"),
1880
+ this.i18n.t("tools.table.dragToAddRemoveColumns")
1876
1881
  ]), { placement: "bottom" }), t;
1877
1882
  }
1878
1883
  appendIcon(t) {
@@ -1881,20 +1886,21 @@ class cs {
1881
1886
  e && (e.setAttribute("width", $t), e.setAttribute("height", $t), e.setAttribute("viewBox", "0 0 24 24"), e.classList.add("text-gray-500", "pointer-events-none"));
1882
1887
  }
1883
1888
  }
1884
- const g = "data-blok-table-row", u = "data-blok-table-cell", $ = 1, nt = `${$}px solid #d1d5db`, ds = [
1889
+ const g = "data-blok-table-row", u = "data-blok-table-cell", P = 1, nt = `${P}px solid #d1d5db`, hs = [
1885
1890
  "flex"
1886
- ], hs = [
1891
+ ], us = [
1887
1892
  "py-1",
1888
1893
  "px-2",
1889
1894
  "min-h-[2em]",
1890
1895
  "outline-none",
1891
1896
  "leading-normal",
1892
- "text-sm"
1893
- ], us = (i) => {
1897
+ "text-sm",
1898
+ "cursor-text"
1899
+ ], ps = (i) => {
1894
1900
  const t = Math.round(100 / i * 100) / 100;
1895
1901
  return Array.from({ length: i }, () => t);
1896
1902
  };
1897
- class ps {
1903
+ class gs {
1898
1904
  constructor(t) {
1899
1905
  this.readOnly = t.readOnly;
1900
1906
  }
@@ -1904,7 +1910,7 @@ class ps {
1904
1910
  createGrid(t, e, n) {
1905
1911
  const s = document.createElement("div");
1906
1912
  s.style.borderTop = nt, s.style.borderLeft = nt;
1907
- const o = n != null ? n : us(e);
1913
+ const o = n != null ? n : ps(e);
1908
1914
  return Array.from({ length: t }).forEach(() => {
1909
1915
  s.appendChild(this.createRow(e, o));
1910
1916
  }), s;
@@ -1950,9 +1956,9 @@ class ps {
1950
1956
  * those widths and the new column is added in px mode. This prevents
1951
1957
  * existing columns from shrinking when the table is in percent mode.
1952
1958
  */
1953
- addColumn(t, e, n) {
1954
- const s = t.querySelectorAll(`[${g}]`), o = this.getColumnCount(t), r = n !== void 0 && n.length === o, l = r || this.detectWidthUnit(t) === "px";
1955
- return r && this.convertToPixelWidths(s, n), l ? (this.addColumnPx(s, o, e), !0) : (this.addColumnPercent(s, o, e), !0);
1959
+ addColumn(t, e, n, s) {
1960
+ const o = t.querySelectorAll(`[${g}]`), r = this.getColumnCount(t), l = n !== void 0 && n.length === r, a = l || this.detectWidthUnit(t) === "px";
1961
+ return l && this.convertToPixelWidths(o, n), a ? (this.addColumnPx(o, r, e, s), !0) : (this.addColumnPercent(o, r, e), !0);
1956
1962
  }
1957
1963
  /**
1958
1964
  * Convert all cells in each row to the given pixel widths
@@ -1968,22 +1974,26 @@ class ps {
1968
1974
  });
1969
1975
  }
1970
1976
  /**
1971
- * Add column in px mode: keep existing widths, add new column at half the average width
1977
+ * Add column in px mode: keep existing widths, add new column at given width or half the average
1972
1978
  */
1973
- addColumnPx(t, e, n) {
1974
- const s = t[0], o = s == null ? void 0 : s.querySelectorAll(`[${u}]`), r = Array.from(o != null ? o : []).reduce(
1975
- (a, c) => a + (parseFloat(c.style.width) || 0),
1976
- 0
1977
- ), l = e > 0 ? Math.round(r / e / 2 * 100) / 100 : 0;
1978
- t.forEach((a) => {
1979
- const c = a.querySelectorAll(`[${u}]`), d = n === void 0 || n >= c.length, h = this.createCell(`${l}px`);
1980
- if (!d) {
1981
- a.insertBefore(h, c[n]);
1979
+ addColumnPx(t, e, n, s) {
1980
+ const o = s != null ? s : this.computeHalfAvgPxWidth(t, e);
1981
+ t.forEach((r) => {
1982
+ const l = r.querySelectorAll(`[${u}]`), a = n === void 0 || n >= l.length, c = this.createCell(`${o}px`);
1983
+ if (!a) {
1984
+ r.insertBefore(c, l[n]);
1982
1985
  return;
1983
1986
  }
1984
- a.appendChild(h);
1987
+ r.appendChild(c);
1985
1988
  });
1986
1989
  }
1990
+ computeHalfAvgPxWidth(t, e) {
1991
+ const n = t[0], s = n == null ? void 0 : n.querySelectorAll(`[${u}]`), o = Array.from(s != null ? s : []).reduce(
1992
+ (r, l) => r + (parseFloat(l.style.width) || 0),
1993
+ 0
1994
+ );
1995
+ return e > 0 ? Math.round(o / e / 2 * 100) / 100 : 0;
1996
+ }
1987
1997
  /**
1988
1998
  * Add column in % mode: shrink existing columns slightly and add new column at half the average width
1989
1999
  */
@@ -1991,8 +2001,8 @@ class ps {
1991
2001
  const o = 1 - 0.5 / e;
1992
2002
  t.forEach((r) => {
1993
2003
  r.querySelectorAll(`[${u}]`).forEach((p) => {
1994
- const m = p, f = parseFloat(m.style.width) || 100 / e, y = Math.round(f * o * 100) / 100;
1995
- m.style.width = `${y}%`;
2004
+ const f = p, m = parseFloat(f.style.width) || 100 / e, C = Math.round(m * o * 100) / 100;
2005
+ f.style.width = `${C}%`;
1996
2006
  });
1997
2007
  const a = Math.round(100 / e / 2 * 100) / 100, c = r.querySelectorAll(`[${u}]`), d = n === void 0 || n >= c.length, h = this.createCell(`${a}%`);
1998
2008
  if (!d) {
@@ -2083,7 +2093,7 @@ class ps {
2083
2093
  * Get cell content as block references
2084
2094
  */
2085
2095
  getCellContent(t) {
2086
- const e = t.querySelector(`[${B}]`);
2096
+ const e = t.querySelector(`[${k}]`);
2087
2097
  if (!e)
2088
2098
  return { blocks: [] };
2089
2099
  const n = e.querySelectorAll("[data-blok-id]");
@@ -2117,7 +2127,7 @@ class ps {
2117
2127
  */
2118
2128
  createRow(t, e) {
2119
2129
  const n = document.createElement("div");
2120
- return n.className = v(ds), n.setAttribute(g, ""), Array.from({ length: t }).forEach((s, o) => {
2130
+ return n.className = v(hs), n.setAttribute(g, ""), Array.from({ length: t }).forEach((s, o) => {
2121
2131
  n.appendChild(this.createCell(e[o]));
2122
2132
  }), n;
2123
2133
  }
@@ -2126,13 +2136,13 @@ class ps {
2126
2136
  */
2127
2137
  createCell(t) {
2128
2138
  const e = document.createElement("div");
2129
- e.className = v(hs), e.style.borderRight = nt, e.style.borderBottom = nt, e.style.flexShrink = "0", e.style.overflow = "hidden", e.style.overflowWrap = "break-word", t !== void 0 && (e.style.width = typeof t == "string" ? t : `${t}%`), e.setAttribute(u, "");
2139
+ e.className = v(us), e.style.borderRight = nt, e.style.borderBottom = nt, e.style.flexShrink = "0", e.style.overflow = "hidden", e.style.overflowWrap = "break-word", t !== void 0 && (e.style.width = typeof t == "string" ? t : `${t}%`), e.setAttribute(u, "");
2130
2140
  const n = document.createElement("div");
2131
- return n.setAttribute(B, ""), e.appendChild(n), e;
2141
+ return n.setAttribute(k, ""), e.appendChild(n), e;
2132
2142
  }
2133
2143
  }
2134
- const fe = (i) => typeof i == "object" && i !== null && "blocks" in i, B = "data-blok-table-cell-blocks";
2135
- class gs {
2144
+ const yt = (i) => typeof i == "object" && i !== null && "blocks" in i, k = "data-blok-table-cell-blocks";
2145
+ class fs {
2136
2146
  constructor(t) {
2137
2147
  this._activeCellWithBlocks = null, this.cellsPendingCheck = /* @__PURE__ */ new Set(), this.pendingCheckScheduled = !1, this.removedBlockCells = /* @__PURE__ */ new Map(), this.handleBlockMutation = (e) => {
2138
2148
  if (!this.isBlockMutationEvent(e))
@@ -2154,14 +2164,32 @@ class gs {
2154
2164
  this.claimBlockForCell(r, s.target.id), this.cellsPendingCheck.delete(r);
2155
2165
  return;
2156
2166
  }
2157
- const a = s.target.holder.closest(`[${B}]`);
2167
+ const a = s.target.holder.closest(`[${k}]`);
2158
2168
  if (a) {
2159
2169
  this.stripPlaceholders(a);
2160
2170
  return;
2161
2171
  }
2162
2172
  const c = this.findCellForNewBlock(o);
2163
2173
  c && (this.claimBlockForCell(c, s.target.id), this.cellsPendingCheck.delete(c));
2164
- }, this.api = t.api, this.gridElement = t.gridElement, this.onNavigateToCell = t.onNavigateToCell, this.api.events.on("block changed", this.handleBlockMutation);
2174
+ }, this.handleCellBlankSpaceClick = (e) => {
2175
+ const n = e.target;
2176
+ if (!n)
2177
+ return;
2178
+ const s = n.hasAttribute(u), o = n.hasAttribute(k);
2179
+ if (!s && !o)
2180
+ return;
2181
+ const r = s ? n : n.closest(`[${u}]`);
2182
+ if (!r)
2183
+ return;
2184
+ const l = s ? r.querySelector(`[${k}]`) : n;
2185
+ if (!l)
2186
+ return;
2187
+ const a = l.querySelectorAll("[data-blok-id]"), c = a[a.length - 1];
2188
+ if (!c)
2189
+ return;
2190
+ const d = c.getAttribute("data-blok-id");
2191
+ d && this.api.caret.setToBlock(d, "end");
2192
+ }, this.api = t.api, this.gridElement = t.gridElement, this.onNavigateToCell = t.onNavigateToCell, this.api.events.on("block changed", this.handleBlockMutation), this.gridElement.addEventListener("click", this.handleCellBlankSpaceClick);
2165
2193
  }
2166
2194
  /**
2167
2195
  * Get the currently active cell that contains blocks
@@ -2231,7 +2259,7 @@ class gs {
2231
2259
  const n = this.getCell(t.row, t.col);
2232
2260
  if (!n)
2233
2261
  return;
2234
- const s = n.querySelector(`[${B}]`);
2262
+ const s = n.querySelector(`[${k}]`);
2235
2263
  if (!s)
2236
2264
  return;
2237
2265
  const o = s.querySelectorAll('[contenteditable="true"]');
@@ -2265,6 +2293,7 @@ class gs {
2265
2293
  * Initialize all cells with blocks.
2266
2294
  * - Empty cells or legacy string cells get a new paragraph block.
2267
2295
  * - Cells that already have block references get those blocks mounted.
2296
+ * - If referenced blocks are missing from BlockManager, a fallback paragraph is created.
2268
2297
  */
2269
2298
  initializeCells(t) {
2270
2299
  const e = this.gridElement.querySelectorAll(`[${g}]`), n = [];
@@ -2277,16 +2306,17 @@ class gs {
2277
2306
  const h = l[d];
2278
2307
  if (!h)
2279
2308
  return;
2280
- const p = h.querySelector(`[${B}]`);
2281
- if (p) {
2282
- if (fe(c))
2283
- this.mountBlocksInCell(p, c.blocks), a.push(c);
2284
- else {
2285
- const m = typeof c == "string" ? c : "", f = this.api.blocks.insert("paragraph", { text: m }, {}, this.api.blocks.getBlocksCount(), !1);
2286
- p.appendChild(f.holder), a.push({ blocks: [f.id] });
2287
- }
2288
- this.stripPlaceholders(p);
2309
+ const p = h.querySelector(`[${k}]`);
2310
+ if (!p)
2311
+ return;
2312
+ const f = yt(c) ? this.mountBlocksInCell(p, c.blocks) : [];
2313
+ if (f.length > 0)
2314
+ a.push({ blocks: f });
2315
+ else {
2316
+ const m = typeof c == "string" ? c : "", C = this.api.blocks.insert("paragraph", { text: m }, {}, this.api.blocks.getBlocksCount(), !1);
2317
+ p.appendChild(C.holder), a.push({ blocks: [C.id] });
2289
2318
  }
2319
+ this.stripPlaceholders(p);
2290
2320
  }), n.push(a);
2291
2321
  }), n;
2292
2322
  }
@@ -2302,22 +2332,25 @@ class gs {
2302
2332
  });
2303
2333
  }
2304
2334
  /**
2305
- * Mount existing blocks into a cell container by their IDs
2335
+ * Mount existing blocks into a cell container by their IDs.
2336
+ * Returns the IDs of blocks that were successfully mounted.
2306
2337
  */
2307
2338
  mountBlocksInCell(t, e) {
2308
- for (const n of e) {
2309
- const s = this.api.blocks.getBlockIndex(n);
2310
- if (s === void 0)
2339
+ const n = [];
2340
+ for (const s of e) {
2341
+ const o = this.api.blocks.getBlockIndex(s);
2342
+ if (o === void 0)
2311
2343
  continue;
2312
- const o = this.api.blocks.getBlockByIndex(s);
2313
- o && t.appendChild(o.holder);
2344
+ const r = this.api.blocks.getBlockByIndex(o);
2345
+ r && (t.appendChild(r.holder), n.push(s));
2314
2346
  }
2347
+ return n;
2315
2348
  }
2316
2349
  /**
2317
2350
  * Move a block's DOM holder into a cell's blocks container.
2318
2351
  */
2319
2352
  claimBlockForCell(t, e) {
2320
- const n = t.querySelector(`[${B}]`);
2353
+ const n = t.querySelector(`[${k}]`);
2321
2354
  if (!n)
2322
2355
  return;
2323
2356
  const s = this.api.blocks.getBlockIndex(e);
@@ -2349,7 +2382,7 @@ class gs {
2349
2382
  * If the blocks container is empty, insert an empty paragraph.
2350
2383
  */
2351
2384
  ensureCellHasBlock(t) {
2352
- const e = t.querySelector(`[${B}]`);
2385
+ const e = t.querySelector(`[${k}]`);
2353
2386
  if (!e || e.querySelector("[data-blok-id]") !== null)
2354
2387
  return;
2355
2388
  const s = this.api.blocks.insert("paragraph", { text: "" }, {}, this.api.blocks.getBlocksCount(), !0);
@@ -2391,7 +2424,7 @@ class gs {
2391
2424
  getBlockIdsFromCells(t) {
2392
2425
  const e = [];
2393
2426
  return Array.from(t).forEach((s) => {
2394
- const o = s.querySelector(`[${B}]`);
2427
+ const o = s.querySelector(`[${k}]`);
2395
2428
  o && o.querySelectorAll("[data-blok-id]").forEach((r) => {
2396
2429
  const l = r.getAttribute("data-blok-id");
2397
2430
  l && e.push(l);
@@ -2406,28 +2439,36 @@ class gs {
2406
2439
  this.api.blocks.delete(n);
2407
2440
  });
2408
2441
  }
2442
+ /**
2443
+ * Delete all blocks managed by this table from the BlockManager.
2444
+ * Called before the table block itself is removed to prevent orphaned cell blocks.
2445
+ */
2446
+ deleteAllBlocks() {
2447
+ const t = this.gridElement.querySelectorAll(`[${u}]`), e = this.getBlockIdsFromCells(t);
2448
+ this.deleteBlocks(e);
2449
+ }
2409
2450
  /**
2410
2451
  * Clean up event listeners
2411
2452
  */
2412
2453
  destroy() {
2413
- this.api.events.off("block changed", this.handleBlockMutation), this._activeCellWithBlocks = null, this.cellsPendingCheck.clear(), this.removedBlockCells.clear();
2454
+ this.gridElement.removeEventListener("click", this.handleCellBlankSpaceClick), this.api.events.off("block changed", this.handleBlockMutation), this._activeCellWithBlocks = null, this.cellsPendingCheck.clear(), this.removedBlockCells.clear();
2414
2455
  }
2415
2456
  }
2416
- const K = 16, fs = [
2457
+ const Y = 16, ms = [
2417
2458
  [2, 2],
2418
2459
  [8, 2],
2419
2460
  [2, 7],
2420
2461
  [8, 7],
2421
2462
  [2, 12],
2422
2463
  [8, 12]
2423
- ], ms = [
2464
+ ], Cs = [
2424
2465
  [2, 2],
2425
2466
  [7, 2],
2426
2467
  [12, 2],
2427
2468
  [2, 8],
2428
2469
  [7, 8],
2429
2470
  [12, 8]
2430
- ], me = (i) => {
2471
+ ], fe = (i) => {
2431
2472
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg"), e = i === "horizontal";
2432
2473
  t.setAttribute("width", e ? "14" : "10"), t.setAttribute("height", e ? "10" : "14"), t.setAttribute("viewBox", e ? "0 0 14 10" : "0 0 10 14"), t.setAttribute("fill", "currentColor"), t.classList.add(
2433
2474
  "opacity-0",
@@ -2436,21 +2477,21 @@ const K = 16, fs = [
2436
2477
  "text-gray-400",
2437
2478
  "pointer-events-none"
2438
2479
  );
2439
- const n = e ? ms : fs;
2480
+ const n = e ? Cs : ms;
2440
2481
  for (const [s, o] of n) {
2441
2482
  const r = document.createElementNS("http://www.w3.org/2000/svg", "circle");
2442
2483
  r.setAttribute("cx", String(s)), r.setAttribute("cy", String(o)), r.setAttribute("r", "1.5"), t.appendChild(r);
2443
2484
  }
2444
2485
  return t;
2445
- }, Cs = (i, t) => {
2446
- t === "col" ? i.style.height = `${K}px` : i.style.width = `${K}px`, i.classList.add("bg-gray-200"), i.classList.remove("bg-gray-300");
2486
+ }, ys = (i, t) => {
2487
+ t === "col" ? Object.assign(i.style, { height: `${Y}px` }) : Object.assign(i.style, { width: `${Y}px` }), i.classList.add("bg-gray-200"), i.classList.remove("bg-gray-300");
2447
2488
  const e = i.querySelector("svg");
2448
2489
  e && (e.classList.remove("opacity-0"), e.classList.add("opacity-100"));
2449
- }, Gt = (i, t, e) => {
2450
- t === "col" ? i.style.height = `${e}px` : i.style.width = `${e}px`, i.classList.remove("bg-gray-200"), i.classList.add("bg-gray-300");
2490
+ }, gt = (i, t, e) => {
2491
+ t === "col" ? Object.assign(i.style, { height: `${e}px` }) : Object.assign(i.style, { width: `${e}px` }), i.classList.remove("bg-gray-200"), i.classList.add("bg-gray-300");
2451
2492
  const n = i.querySelector("svg");
2452
2493
  n && (n.classList.add("opacity-0"), n.classList.remove("opacity-100"));
2453
- }, ht = "data-blok-table-cell-selected", ys = "2px solid #3b82f6", ut = "data-blok-table-selection-pill", bs = 16, vs = 20, Wt = 4, Ss = [
2494
+ }, ft = "data-blok-table-cell-selected", bs = "2px solid #3b82f6", mt = "data-blok-table-selection-pill", vs = 16, Ss = 20, Gt = 4, ws = [
2454
2495
  "absolute",
2455
2496
  "z-[3]",
2456
2497
  "rounded",
@@ -2463,13 +2504,13 @@ const K = 16, fs = [
2463
2504
  "overflow-hidden",
2464
2505
  "cursor-pointer",
2465
2506
  "bg-blue-500"
2466
- ], ws = (i) => i.style.userSelect === "none";
2467
- class As {
2507
+ ], As = (i) => i.style.userSelect === "none";
2508
+ class Es {
2468
2509
  constructor(t) {
2469
- this.anchorCell = null, this.extentCell = null, this.isSelecting = !1, this.hasSelection = !1, this.selectedCells = [], this.overlay = null, this.pill = null, this.pillPopover = null, this.grid = t.grid, this.rectangleSelection = t.rectangleSelection, this.onSelectionActiveChange = t.onSelectionActiveChange, this.onClearContent = t.onClearContent, this.grid.style.position = "relative", this.boundPointerDown = this.handlePointerDown.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundClearSelection = this.handleClearSelection.bind(this), this.boundCancelRectangle = this.handleCancelRectangle.bind(this), this.grid.addEventListener("pointerdown", this.boundPointerDown);
2510
+ this.anchorCell = null, this.extentCell = null, this.isSelecting = !1, this.hasSelection = !1, this.selectedCells = [], this.overlay = null, this.pill = null, this.pillPopover = null, this.grid = t.grid, this.rectangleSelection = t.rectangleSelection, this.onSelectionActiveChange = t.onSelectionActiveChange, this.onClearContent = t.onClearContent, this.i18n = t.i18n, this.grid.style.position = "relative", this.boundPointerDown = this.handlePointerDown.bind(this), this.boundPointerMove = this.handlePointerMove.bind(this), this.boundPointerUp = this.handlePointerUp.bind(this), this.boundClearSelection = this.handleClearSelection.bind(this), this.boundCancelRectangle = this.handleCancelRectangle.bind(this), this.boundKeyDown = this.handleKeyDown.bind(this), this.grid.addEventListener("pointerdown", this.boundPointerDown), document.addEventListener("keydown", this.boundKeyDown);
2470
2511
  }
2471
2512
  destroy() {
2472
- this.destroyPillPopover(), this.clearSelection(), this.grid.removeEventListener("pointerdown", this.boundPointerDown), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), document.removeEventListener("pointerdown", this.boundClearSelection), document.removeEventListener("mousemove", this.boundCancelRectangle, !0);
2513
+ this.destroyPillPopover(), this.clearSelection(), this.grid.removeEventListener("pointerdown", this.boundPointerDown), document.removeEventListener("pointermove", this.boundPointerMove), document.removeEventListener("pointerup", this.boundPointerUp), document.removeEventListener("pointerdown", this.boundClearSelection), document.removeEventListener("mousemove", this.boundCancelRectangle, !0), document.removeEventListener("keydown", this.boundKeyDown);
2473
2514
  }
2474
2515
  /**
2475
2516
  * Programmatically select an entire row.
@@ -2493,10 +2534,10 @@ class As {
2493
2534
  this.clearSelection();
2494
2535
  }
2495
2536
  handlePointerDown(t) {
2496
- if (ws(this.grid) || t.button !== 0)
2537
+ if (As(this.grid) || t.button !== 0)
2497
2538
  return;
2498
2539
  const e = t.target;
2499
- if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${ut}]`))
2540
+ if (e.closest("[data-blok-table-grip]") || e.closest("[data-blok-table-resize]") || e.closest(`[${mt}]`))
2500
2541
  return;
2501
2542
  const n = this.resolveCellCoord(e);
2502
2543
  n && (this.hasSelection && this.clearSelection(), this.anchorCell = n, this.isSelecting = !1, document.addEventListener("mousemove", this.boundCancelRectangle, !0), document.addEventListener("pointermove", this.boundPointerMove), document.addEventListener("pointerup", this.boundPointerUp));
@@ -2532,7 +2573,11 @@ class As {
2532
2573
  }
2533
2574
  handleClearSelection(t) {
2534
2575
  const e = t.target;
2535
- e instanceof HTMLElement && e.closest(`[${ut}]`) || this.pillPopover === null && (document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
2576
+ e instanceof HTMLElement && e.closest(`[${mt}]`) || this.pillPopover === null && (document.removeEventListener("pointerdown", this.boundClearSelection), this.clearSelection());
2577
+ }
2578
+ handleKeyDown(t) {
2579
+ var e;
2580
+ this.hasSelection && (t.key !== "Delete" && t.key !== "Backspace" || (t.preventDefault(), (e = this.onClearContent) == null || e.call(this, [...this.selectedCells]), this.clearSelection()));
2536
2581
  }
2537
2582
  clearSelection() {
2538
2583
  var e;
@@ -2541,7 +2586,7 @@ class As {
2541
2586
  }
2542
2587
  restoreModifiedCells() {
2543
2588
  this.destroyPillPopover(), this.selectedCells.forEach((t) => {
2544
- t.removeAttribute(ht);
2589
+ t.removeAttribute(ft);
2545
2590
  }), this.pill && (this.pill.remove(), this.pill = null), this.overlay && (this.overlay.remove(), this.overlay = null), this.selectedCells = [];
2546
2591
  }
2547
2592
  showProgrammaticSelection(t, e, n, s) {
@@ -2551,35 +2596,26 @@ class As {
2551
2596
  });
2552
2597
  }
2553
2598
  paintSelection() {
2554
- var D, N;
2599
+ var I, N;
2555
2600
  if (!this.anchorCell || !this.extentCell)
2556
2601
  return;
2557
- this.selectedCells.forEach((P) => {
2558
- P.removeAttribute(ht);
2602
+ this.selectedCells.forEach((M) => {
2603
+ M.removeAttribute(ft);
2559
2604
  }), this.selectedCells = [];
2560
2605
  const t = Math.min(this.anchorCell.row, this.extentCell.row), e = Math.max(this.anchorCell.row, this.extentCell.row), n = Math.min(this.anchorCell.col, this.extentCell.col), s = Math.max(this.anchorCell.col, this.extentCell.col), o = this.grid.querySelectorAll(`[${g}]`);
2561
- for (let P = t; P <= e; P++) {
2562
- const T = o[P];
2563
- if (!T)
2564
- continue;
2565
- const _ = T.querySelectorAll(`[${u}]`);
2566
- for (let H = n; H <= s; H++) {
2567
- const J = _[H];
2568
- J && (J.setAttribute(ht, ""), this.selectedCells.push(J));
2569
- }
2570
- }
2571
- const r = (D = o[t]) == null ? void 0 : D.querySelectorAll(`[${u}]`)[n], l = (N = o[e]) == null ? void 0 : N.querySelectorAll(`[${u}]`)[s];
2606
+ this.selectedCells = this.collectCellsInRange(o, t, e, n, s), this.selectedCells.forEach((M) => {
2607
+ M.setAttribute(ft, "");
2608
+ });
2609
+ const r = (I = o[t]) == null ? void 0 : I.querySelectorAll(`[${u}]`)[n], l = (N = o[e]) == null ? void 0 : N.querySelectorAll(`[${u}]`)[s];
2572
2610
  if (!r || !l)
2573
2611
  return;
2574
- const a = this.grid.getBoundingClientRect(), c = r.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), p = parseFloat(h.borderTopWidth) || 0, m = parseFloat(h.borderLeftWidth) || 0;
2575
- let f = c.top - a.top - p, y = c.left - a.left - m;
2576
- const b = d.right - c.left + 1, I = d.bottom - c.top + 1;
2577
- f -= 1, y -= 1, this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = ys, this.overlay.style.pointerEvents = "none", this.overlay.style.boxSizing = "border-box", this.overlay.style.borderRadius = "2px", this.grid.appendChild(this.overlay)), this.overlay.style.top = `${f}px`, this.overlay.style.left = `${y}px`, this.overlay.style.width = `${b}px`, this.overlay.style.height = `${I}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${y + b - 1}px`, this.pill.style.top = `${f + I / 2}px`;
2612
+ const a = this.grid.getBoundingClientRect(), c = r.getBoundingClientRect(), d = l.getBoundingClientRect(), h = getComputedStyle(this.grid), p = parseFloat(h.borderTopWidth) || 0, f = parseFloat(h.borderLeftWidth) || 0, m = d.right - c.left + 1, C = d.bottom - c.top + 1, b = c.top - a.top - p - 1, B = c.left - a.left - f - 1;
2613
+ this.overlay || (this.overlay = document.createElement("div"), this.overlay.setAttribute("data-blok-table-selection-overlay", ""), this.overlay.style.position = "absolute", this.overlay.style.border = bs, this.overlay.style.pointerEvents = "none", this.overlay.style.boxSizing = "border-box", this.overlay.style.borderRadius = "2px", this.grid.appendChild(this.overlay)), this.overlay.style.top = `${b}px`, this.overlay.style.left = `${B}px`, this.overlay.style.width = `${m}px`, this.overlay.style.height = `${C}px`, this.pill || (this.pill = this.createPill(), this.grid.appendChild(this.pill)), this.pill.style.left = `${B + m - 1}px`, this.pill.style.top = `${b + C / 2}px`;
2578
2614
  }
2579
2615
  createPill() {
2580
2616
  const t = document.createElement("div");
2581
- t.setAttribute(ut, ""), t.setAttribute("contenteditable", "false"), t.className = v(Ss), t.style.width = `${Wt}px`, t.style.height = `${vs}px`, t.style.pointerEvents = "auto", t.style.transform = "translate(-50%, -50%)", t.style.outline = "2px solid white";
2582
- const e = me("vertical");
2617
+ t.setAttribute(mt, ""), t.setAttribute("contenteditable", "false"), t.className = v(ws), t.style.width = `${Gt}px`, t.style.height = `${Ss}px`, t.style.pointerEvents = "auto", t.style.transform = "translate(-50%, -50%)", t.style.outline = "2px solid white";
2618
+ const e = fe("vertical");
2583
2619
  return e.classList.remove("text-gray-400"), e.classList.add("text-white"), t.appendChild(e), t.addEventListener("mouseenter", () => {
2584
2620
  this.pillPopover === null && this.expandPill();
2585
2621
  }), t.addEventListener("mouseleave", () => {
@@ -2595,7 +2631,7 @@ class As {
2595
2631
  const t = [
2596
2632
  {
2597
2633
  icon: Ge,
2598
- title: "Clear",
2634
+ title: this.i18n.t("tools.table.clearSelection"),
2599
2635
  closeOnActivate: !0,
2600
2636
  onActivate: () => {
2601
2637
  var e;
@@ -2603,25 +2639,25 @@ class As {
2603
2639
  }
2604
2640
  }
2605
2641
  ];
2606
- this.pillPopover = new se({
2642
+ this.pillPopover = new ne({
2607
2643
  items: t,
2608
2644
  trigger: this.pill,
2609
2645
  flippable: !0
2610
- }), this.pillPopover.on(oe.Closed, () => {
2646
+ }), this.pillPopover.on(se.Closed, () => {
2611
2647
  this.pillPopover !== null && (this.destroyPillPopover(), this.collapsePill());
2612
2648
  }), this.pillPopover.show();
2613
2649
  }
2614
2650
  expandPill() {
2615
2651
  if (!this.pill)
2616
2652
  return;
2617
- this.pill.style.width = `${bs}px`;
2653
+ this.pill.style.width = `${vs}px`;
2618
2654
  const t = this.pill.querySelector("svg");
2619
2655
  t && (t.classList.remove("opacity-0"), t.classList.add("opacity-100"));
2620
2656
  }
2621
2657
  collapsePill() {
2622
2658
  if (!this.pill)
2623
2659
  return;
2624
- this.pill.style.width = `${Wt}px`;
2660
+ this.pill.style.width = `${Gt}px`;
2625
2661
  const t = this.pill.querySelector("svg");
2626
2662
  t && (t.classList.add("opacity-0"), t.classList.remove("opacity-100"));
2627
2663
  }
@@ -2645,21 +2681,30 @@ class As {
2645
2681
  return l < 0 ? null : { row: o, col: l };
2646
2682
  }
2647
2683
  clampExtentToEdge(t) {
2648
- var c, d, h, p, m, f;
2684
+ var c, d, h, p, f, m;
2649
2685
  if (!this.anchorCell || !this.isSelecting)
2650
2686
  return;
2651
2687
  const e = this.grid.getBoundingClientRect(), n = this.grid.querySelectorAll(`[${g}]`), s = n.length, o = (d = (c = n[0]) == null ? void 0 : c.querySelectorAll(`[${u}]`).length) != null ? d : 0;
2652
2688
  if (s === 0 || o === 0)
2653
2689
  return;
2654
- let r;
2655
- t.clientY < e.top ? r = 0 : t.clientY > e.bottom ? r = s - 1 : r = (p = (h = this.extentCell) == null ? void 0 : h.row) != null ? p : this.anchorCell.row;
2656
- let l;
2657
- t.clientX < e.left ? l = 0 : t.clientX > e.right ? l = o - 1 : l = (f = (m = this.extentCell) == null ? void 0 : m.col) != null ? f : this.anchorCell.col;
2658
- const a = { row: r, col: l };
2690
+ const r = this.clampAxis(t.clientY, e.top, e.bottom, s, (p = (h = this.extentCell) == null ? void 0 : h.row) != null ? p : this.anchorCell.row), l = this.clampAxis(t.clientX, e.left, e.right, o, (m = (f = this.extentCell) == null ? void 0 : f.col) != null ? m : this.anchorCell.col), a = { row: r, col: l };
2659
2691
  (!this.extentCell || this.extentCell.row !== a.row || this.extentCell.col !== a.col) && (this.extentCell = a, this.paintSelection());
2660
2692
  }
2693
+ collectCellsInRange(t, e, n, s, o) {
2694
+ return Array.from(t).slice(e, n + 1).flatMap((r) => {
2695
+ const l = r.querySelectorAll(`[${u}]`);
2696
+ return Array.from(l).slice(s, o + 1).filter((a) => a instanceof HTMLElement);
2697
+ });
2698
+ }
2699
+ /**
2700
+ * Clamp a pointer coordinate to an axis range, returning the edge index
2701
+ * when outside or the fallback when inside.
2702
+ */
2703
+ clampAxis(t, e, n, s, o) {
2704
+ return t < e ? 0 : t > n ? s - 1 : o;
2705
+ }
2661
2706
  }
2662
- const lt = (i) => {
2707
+ const U = (i) => {
2663
2708
  const t = i.querySelector(`[${g}]`);
2664
2709
  if (!t)
2665
2710
  return [];
@@ -2667,9 +2712,9 @@ const lt = (i) => {
2667
2712
  return Array.from(e).map(
2668
2713
  (n) => n.getBoundingClientRect().width
2669
2714
  );
2670
- }, st = (i, t) => {
2715
+ }, ct = (i, t) => {
2671
2716
  const e = t.reduce((o, r) => o + r, 0), n = i;
2672
- n.style.width = `${e + $}px`, i.querySelectorAll(`[${g}]`).forEach((o) => {
2717
+ n.style.width = `${e + P}px`, i.querySelectorAll(`[${g}]`).forEach((o) => {
2673
2718
  o.querySelectorAll(`[${u}]`).forEach((l, a) => {
2674
2719
  if (a < t.length) {
2675
2720
  const c = l;
@@ -2677,29 +2722,29 @@ const lt = (i) => {
2677
2722
  }
2678
2723
  });
2679
2724
  });
2680
- }, Es = (i, t) => {
2725
+ }, ks = (i, t) => {
2681
2726
  const e = Array.from(i.querySelectorAll(`[${g}]`)), n = e.findIndex((r) => Array.from(r.querySelectorAll(`[${u}]`)).includes(t));
2682
2727
  if (n === -1)
2683
2728
  return null;
2684
2729
  const o = Array.from(e[n].querySelectorAll(`[${u}]`)).indexOf(t);
2685
2730
  return { row: n, col: o };
2686
- }, Ce = (i) => {
2731
+ }, me = (i) => {
2687
2732
  var e;
2688
- const t = i.querySelector(`[${B}]`);
2733
+ const t = i.querySelector(`[${k}]`);
2689
2734
  return t ? ((e = t.textContent) != null ? e : "").trim().length === 0 : !0;
2690
- }, ks = (i, t) => {
2735
+ }, xs = (i, t) => {
2691
2736
  const n = i.querySelectorAll(`[${g}]`)[t];
2692
2737
  if (!n)
2693
2738
  return !0;
2694
2739
  const s = n.querySelectorAll(`[${u}]`);
2695
- return Array.from(s).every((o) => Ce(o));
2696
- }, xs = (i, t) => {
2740
+ return Array.from(s).every((o) => me(o));
2741
+ }, Ts = (i, t) => {
2697
2742
  const e = i.querySelectorAll(`[${g}]`);
2698
2743
  return Array.from(e).every((n) => {
2699
2744
  const o = n.querySelectorAll(`[${u}]`)[t];
2700
- return !o || Ce(o);
2745
+ return !o || me(o);
2701
2746
  });
2702
- }, Ts = (i) => {
2747
+ }, Rs = (i) => {
2703
2748
  const t = i.querySelectorAll(`[${g}]`), e = t[0];
2704
2749
  if (!e)
2705
2750
  return;
@@ -2721,28 +2766,26 @@ const lt = (i) => {
2721
2766
  return i;
2722
2767
  const n = [...i], [s] = n.splice(t, 1);
2723
2768
  return n.splice(e, 0, s), n;
2724
- }, Rs = (i, t) => {
2769
+ }, Bs = (i, t) => {
2725
2770
  if (!i)
2726
2771
  return i;
2727
2772
  const e = [...i];
2728
2773
  return e.splice(t, 1), e.length > 0 ? e : void 0;
2729
- }, qt = (i, t, e, n) => {
2774
+ }, Is = (i, t, e, n) => {
2730
2775
  var l;
2731
- const s = (l = e.colWidths) != null ? l : lt(i);
2732
- n.addColumn(i, t, s);
2733
- const o = Math.round(
2734
- s.reduce((a, c) => a + c, 0) / s.length / 2 * 100
2735
- ) / 100, r = [...s];
2776
+ const s = (l = e.colWidths) != null ? l : U(i), o = e.initialColWidth !== void 0 ? Math.round(e.initialColWidth / 2 * 100) / 100 : dt(s);
2777
+ n.addColumn(i, t, s, o);
2778
+ const r = [...s];
2736
2779
  return r.splice(t, 0, o), r;
2737
- }, Ft = (i) => Math.round(
2780
+ }, dt = (i) => Math.round(
2738
2781
  i.reduce((t, e) => t + e, 0) / i.length / 2 * 100
2739
- ) / 100, Bs = (i, t, e) => {
2782
+ ) / 100, Ns = (i) => i.length === 0 ? 0 : Math.round(i.reduce((t, e) => t + e, 0) / i.length * 100) / 100, Ds = (i, t, e) => {
2740
2783
  var o;
2741
2784
  if (!i)
2742
2785
  return [];
2743
2786
  const s = i.querySelectorAll(`[${g}]`)[e];
2744
2787
  return s ? (o = t == null ? void 0 : t.getBlockIdsFromCells(s.querySelectorAll(`[${u}]`))) != null ? o : [] : [];
2745
- }, Is = (i, t, e) => {
2788
+ }, Hs = (i, t, e) => {
2746
2789
  var o;
2747
2790
  if (!i)
2748
2791
  return [];
@@ -2751,14 +2794,14 @@ const lt = (i) => {
2751
2794
  const l = r.querySelectorAll(`[${u}]`);
2752
2795
  e < l.length && s.push(l[e]);
2753
2796
  }), (o = t == null ? void 0 : t.getBlockIdsFromCells(s)) != null ? o : [];
2754
- }, pt = (i, t, e, n) => {
2797
+ }, bt = (i, t, e, n) => {
2755
2798
  const o = i.querySelectorAll(`[${g}]`)[t];
2756
2799
  if (o && n) {
2757
2800
  const r = o.querySelectorAll(`[${u}]`);
2758
2801
  n.deleteBlocks(n.getBlockIdsFromCells(r));
2759
2802
  }
2760
2803
  e.deleteRow(i, t);
2761
- }, gt = (i, t, e, n, s) => {
2804
+ }, vt = (i, t, e, n, s) => {
2762
2805
  if (s) {
2763
2806
  const o = i.querySelectorAll(`[${g}]`), r = [];
2764
2807
  o.forEach((l) => {
@@ -2766,12 +2809,12 @@ const lt = (i) => {
2766
2809
  t < a.length && r.push(a[t]);
2767
2810
  }), s.deleteBlocks(s.getBlockIdsFromCells(r));
2768
2811
  }
2769
- return n.deleteColumn(i, t), Rs(e, t);
2770
- }, W = (i, t) => {
2812
+ return n.deleteColumn(i, t), Bs(e, t);
2813
+ }, G = (i, t) => {
2771
2814
  i.querySelectorAll(`[${u}]`).forEach((n) => {
2772
2815
  t == null || t.ensureCellHasBlock(n);
2773
2816
  });
2774
- }, Ds = (i, t, e) => {
2817
+ }, Ps = (i, t, e) => {
2775
2818
  const n = i.querySelectorAll(`[${g}]`);
2776
2819
  t.forEach((s, o) => {
2777
2820
  const r = n[o];
@@ -2782,33 +2825,34 @@ const lt = (i) => {
2782
2825
  const d = l[c];
2783
2826
  if (!d)
2784
2827
  return;
2785
- const h = d.querySelector(`[${B}]`);
2786
- if (h) {
2787
- if (!fe(a)) {
2788
- if (h.querySelectorAll("[data-blok-id]").length > 0)
2789
- return;
2790
- const m = typeof a == "string" ? a : "", f = e.blocks.insert(
2828
+ const h = d.querySelector(`[${k}]`);
2829
+ if (!h)
2830
+ return;
2831
+ const p = h.querySelectorAll("[data-blok-id]").length > 0;
2832
+ if (!(!yt(a) && p)) {
2833
+ if (!yt(a)) {
2834
+ const f = typeof a == "string" ? a : "", m = e.blocks.insert(
2791
2835
  "paragraph",
2792
- { text: m },
2836
+ { text: f },
2793
2837
  {},
2794
2838
  void 0,
2795
2839
  !0
2796
2840
  );
2797
- f != null && f.holder && h.appendChild(f.holder);
2841
+ m != null && m.holder && h.appendChild(m.holder);
2798
2842
  return;
2799
2843
  }
2800
- for (const p of a.blocks) {
2801
- const m = e.blocks.getBlockIndex(p);
2844
+ for (const f of a.blocks) {
2845
+ const m = e.blocks.getBlockIndex(f);
2802
2846
  if (m === void 0)
2803
2847
  continue;
2804
- const f = e.blocks.getBlockByIndex(m);
2805
- f && h.appendChild(f.holder);
2848
+ const C = e.blocks.getBlockByIndex(m);
2849
+ C && h.appendChild(C.holder);
2806
2850
  }
2807
2851
  }
2808
2852
  });
2809
2853
  });
2810
- }, Ns = (i, t) => {
2811
- var l, a, c, d, h, p, m, f, y, b;
2854
+ }, _s = (i, t) => {
2855
+ var l, a, c, d, h, p, f, m, C, b;
2812
2856
  if (!(typeof i == "object" && i !== null && "content" in i))
2813
2857
  return {
2814
2858
  withHeadings: (l = t.withHeadings) != null ? l : !1,
@@ -2819,22 +2863,23 @@ const lt = (i) => {
2819
2863
  const n = i, s = (d = (c = n.content) == null ? void 0 : c[0]) == null ? void 0 : d.length, o = n.colWidths, r = o && s && o.length === s ? o : void 0;
2820
2864
  return {
2821
2865
  withHeadings: (p = (h = n.withHeadings) != null ? h : t.withHeadings) != null ? p : !1,
2822
- withHeadingColumn: (m = n.withHeadingColumn) != null ? m : !1,
2823
- stretched: (y = (f = n.stretched) != null ? f : t.stretched) != null ? y : !1,
2866
+ withHeadingColumn: (f = n.withHeadingColumn) != null ? f : !1,
2867
+ stretched: (C = (m = n.stretched) != null ? m : t.stretched) != null ? C : !1,
2824
2868
  content: (b = n.content) != null ? b : [],
2825
- colWidths: r
2869
+ colWidths: r,
2870
+ initialColWidth: n.initialColWidth
2826
2871
  };
2827
- }, Ps = (i, t) => {
2872
+ }, Os = (i, t) => {
2828
2873
  i.addEventListener("keydown", (e) => {
2829
2874
  const s = e.target.closest(`[${u}]`);
2830
2875
  if (!s)
2831
2876
  return;
2832
- const o = Es(i, s);
2877
+ const o = ks(i, s);
2833
2878
  o && (t == null || t.handleKeyDown(e, o));
2834
2879
  });
2835
- }, ye = ["overflow-x-auto", "pt-[9px]", "pl-[9px]"], zt = (i) => {
2836
- i == null || i.classList.add(...ye);
2837
- }, ot = (i, t) => {
2880
+ }, Ce = ["overflow-x-auto", "pt-[9px]", "pl-[9px]"], qt = (i) => {
2881
+ i == null || i.classList.add(...Ce);
2882
+ }, st = (i, t) => {
2838
2883
  if (!i)
2839
2884
  return;
2840
2885
  const e = i.firstElementChild;
@@ -2844,7 +2889,7 @@ const lt = (i) => {
2844
2889
  n.forEach((s) => {
2845
2890
  s.removeAttribute("data-blok-table-heading");
2846
2891
  }), t && n.length > 0 && n[0].setAttribute("data-blok-table-heading", "");
2847
- }, U = (i, t) => {
2892
+ }, V = (i, t) => {
2848
2893
  if (!i)
2849
2894
  return;
2850
2895
  const e = i.firstElementChild;
@@ -2856,8 +2901,8 @@ const lt = (i) => {
2856
2901
  const r = o.querySelector(`[${u}]`);
2857
2902
  r && r.setAttribute("data-blok-table-heading-col", "");
2858
2903
  });
2859
- }, Vt = "data-blok-table-resize", _s = "data-blok-table-cell", Hs = "data-blok-table-row", Ms = 50, ft = 16;
2860
- class Os {
2904
+ }, Ft = "data-blok-table-resize", Ms = "data-blok-table-cell", Ws = "data-blok-table-row", $s = 50, Ct = 16;
2905
+ class Gs {
2861
2906
  constructor(t, e, n, s, o, r = !1) {
2862
2907
  this._enabled = !0, this.isDragging = !1, this.dragStartX = 0, this.dragColIndex = -1, this.startColWidth = 0, this.handles = [], this.gridEl = t, this.colWidths = [...e], this.onChange = n, this.onDragStart = s != null ? s : null, this.onDrag = o != null ? o : null, this.needsInitialApply = r, this.boundPointerDown = this.onPointerDown.bind(this), this.boundPointerMove = this.onPointerMove.bind(this), this.boundPointerUp = this.onPointerUp.bind(this), this.gridEl.style.position = "relative", r || this.applyWidths(), this.createHandles(), this.gridEl.addEventListener("pointerdown", this.boundPointerDown);
2863
2908
  }
@@ -2884,7 +2929,7 @@ class Os {
2884
2929
  }
2885
2930
  createHandle(t) {
2886
2931
  const e = document.createElement("div"), n = this.getHandleLeftPx(t);
2887
- return e.setAttribute(Vt, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${$}px`, e.style.bottom = "0px", e.style.width = `${ft}px`, e.style.left = `${n - ft / 2}px`, e.style.cursor = "col-resize", e.style.zIndex = "2", e.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", e.style.opacity = "0", e.style.transition = "opacity 150ms ease", e.setAttribute("contenteditable", "false"), e.addEventListener("mouseenter", () => {
2932
+ return e.setAttribute(Ft, ""), e.setAttribute("data-col", String(t)), e.style.position = "absolute", e.style.top = `-${P}px`, e.style.bottom = "0px", e.style.width = `${Ct}px`, e.style.left = `${n - Ct / 2}px`, e.style.cursor = "col-resize", e.style.zIndex = "2", e.style.background = "linear-gradient(to right, transparent 7px, #3b82f6 7px, #3b82f6 9px, transparent 9px)", e.style.opacity = "0", e.style.transition = "opacity 150ms ease", e.setAttribute("contenteditable", "false"), e.addEventListener("mouseenter", () => {
2888
2933
  this.isDragging || (e.style.opacity = "1");
2889
2934
  }), e.addEventListener("mouseleave", () => {
2890
2935
  this.isDragging || (e.style.opacity = "0");
@@ -2896,7 +2941,7 @@ class Os {
2896
2941
  updateHandlePositions() {
2897
2942
  this.handles.forEach((t, e) => {
2898
2943
  const n = this.getHandleLeftPx(e), s = t;
2899
- s.style.left = `${n - ft / 2}px`;
2944
+ s.style.left = `${n - Ct / 2}px`;
2900
2945
  });
2901
2946
  }
2902
2947
  onPointerDown(t) {
@@ -2904,7 +2949,7 @@ class Os {
2904
2949
  if (!this._enabled)
2905
2950
  return;
2906
2951
  const e = t.target;
2907
- if (!e.hasAttribute(Vt))
2952
+ if (!e.hasAttribute(Ft))
2908
2953
  return;
2909
2954
  t.preventDefault(), this.needsInitialApply && (this.applyWidths(), this.updateHandlePositions(), this.needsInitialApply = !1);
2910
2955
  const n = e.getAttribute("data-col");
@@ -2914,7 +2959,7 @@ class Os {
2914
2959
  var o;
2915
2960
  if (!this.isDragging)
2916
2961
  return;
2917
- const e = t.clientX - this.dragStartX, n = this.startColWidth + e, s = Math.max(Ms, n);
2962
+ const e = t.clientX - this.dragStartX, n = this.startColWidth + e, s = Math.max($s, n);
2918
2963
  this.colWidths[this.dragColIndex] = s, this.applyWidths(), this.updateHandlePositions(), (o = this.onDrag) == null || o.call(this);
2919
2964
  }
2920
2965
  onPointerUp() {
@@ -2926,8 +2971,8 @@ class Os {
2926
2971
  }
2927
2972
  applyWidths() {
2928
2973
  const t = this.colWidths.reduce((n, s) => n + s, 0);
2929
- this.gridEl.style.width = `${t + $}px`, this.gridEl.querySelectorAll(`[${Hs}]`).forEach((n) => {
2930
- n.querySelectorAll(`[${_s}]`).forEach((o, r) => {
2974
+ this.gridEl.style.width = `${t + P}px`, this.gridEl.querySelectorAll(`[${Ws}]`).forEach((n) => {
2975
+ n.querySelectorAll(`[${Ms}]`).forEach((o, r) => {
2931
2976
  if (r < this.colWidths.length) {
2932
2977
  const l = o;
2933
2978
  l.style.width = `${this.colWidths[r]}px`;
@@ -2936,69 +2981,90 @@ class Os {
2936
2981
  });
2937
2982
  }
2938
2983
  }
2939
- const $s = [
2940
- "flex",
2941
- "items-center",
2942
- "select-none",
2943
- "border-none",
2944
- "bg-transparent",
2945
- "rounded-md",
2946
- "p-[var(--item-padding)]",
2947
- "text-text-primary",
2948
- "mb-px",
2949
- "cursor-pointer",
2950
- "can-hover:hover:bg-item-hover-bg"
2951
- ], Gs = [
2952
- "flex",
2953
- "items-center",
2954
- "justify-center",
2955
- "w-[26px]",
2956
- "h-[26px]",
2957
- "mr-2",
2958
- "[&_svg]:w-icon",
2959
- "[&_svg]:h-icon"
2960
- ], Ws = [
2961
- "mr-auto",
2962
- "truncate",
2963
- "text-sm",
2964
- "font-medium",
2965
- "leading-5"
2966
- ], qs = [
2967
- "relative",
2968
- "w-[34px]",
2969
- "h-[20px]",
2970
- "rounded-full",
2971
- "transition-colors",
2972
- "duration-200",
2973
- "shrink-0"
2974
- ], Fs = [
2975
- "absolute",
2976
- "top-[2px]",
2977
- "w-4",
2978
- "h-4",
2979
- "rounded-full",
2980
- "bg-white",
2981
- "shadow-sm",
2982
- "transition-[left]",
2983
- "duration-200"
2984
- ], Ut = (i) => {
2985
- const { icon: t, label: e, isActive: n, onToggle: s } = i, o = { active: n }, r = document.createElement("div");
2986
- r.className = v($s);
2987
- const l = document.createElement("div");
2988
- l.className = v(Gs), l.innerHTML = t, r.appendChild(l);
2989
- const a = document.createElement("span");
2990
- a.className = v(Ws), a.textContent = e, r.appendChild(a);
2991
- const c = document.createElement("div");
2992
- c.className = v(qs);
2993
- const d = document.createElement("div");
2994
- d.className = v(Fs), c.appendChild(d), r.appendChild(c);
2995
- const h = () => {
2996
- c.style.backgroundColor = o.active ? "#3b82f6" : "#d1d5db", d.style.left = o.active ? "16px" : "2px";
2984
+ const zt = (i, t, e) => (e.grid.addRow(i, t), G(i, e.cellBlocks), {
2985
+ pendingHighlight: { type: "row", index: t },
2986
+ moveSelection: null,
2987
+ colWidths: e.data.colWidths,
2988
+ withHeadings: e.data.withHeadings,
2989
+ withHeadingColumn: e.data.withHeadingColumn
2990
+ }), Vt = (i, t, e) => {
2991
+ const n = Is(i, t, e.data, e.grid);
2992
+ return G(i, e.cellBlocks), {
2993
+ pendingHighlight: { type: "col", index: t },
2994
+ moveSelection: null,
2995
+ colWidths: n,
2996
+ withHeadings: e.data.withHeadings,
2997
+ withHeadingColumn: e.data.withHeadingColumn
2997
2998
  };
2998
- return h(), r.addEventListener("click", (p) => {
2999
- p.stopPropagation(), o.active = !o.active, h(), s(o.active);
3000
- }), r;
3001
- }, Kt = 10, zs = "data-blok-table-drag-ghost", bt = (i) => {
2999
+ }, qs = (i, t, e, n) => (n.grid.moveRow(i, t, e), {
3000
+ pendingHighlight: null,
3001
+ moveSelection: { type: "row", index: e },
3002
+ colWidths: n.data.colWidths,
3003
+ withHeadings: n.data.withHeadings,
3004
+ withHeadingColumn: n.data.withHeadingColumn
3005
+ }), Fs = (i, t, e, n) => (n.grid.moveColumn(i, t, e), {
3006
+ pendingHighlight: null,
3007
+ moveSelection: { type: "col", index: e },
3008
+ colWidths: Ls(n.data.colWidths, t, e),
3009
+ withHeadings: n.data.withHeadings,
3010
+ withHeadingColumn: n.data.withHeadingColumn
3011
+ }), zs = (i, t, e) => {
3012
+ bt(i, t, e.grid, e.cellBlocks);
3013
+ const n = e.grid.getRowCount(i);
3014
+ return {
3015
+ pendingHighlight: { type: "row", index: t < n ? t : t - 1 },
3016
+ moveSelection: null,
3017
+ colWidths: e.data.colWidths,
3018
+ withHeadings: e.data.withHeadings,
3019
+ withHeadingColumn: e.data.withHeadingColumn
3020
+ };
3021
+ }, Vs = (i, t, e) => {
3022
+ const n = vt(i, t, e.data.colWidths, e.grid, e.cellBlocks);
3023
+ n ? ct(i, n) : Rs(i);
3024
+ const s = e.grid.getColumnCount(i);
3025
+ return {
3026
+ pendingHighlight: { type: "col", index: t < s ? t : t - 1 },
3027
+ moveSelection: null,
3028
+ colWidths: n,
3029
+ withHeadings: e.data.withHeadings,
3030
+ withHeadingColumn: e.data.withHeadingColumn
3031
+ };
3032
+ }, Us = (i, t, e) => {
3033
+ switch (t.type) {
3034
+ case "insert-row-above":
3035
+ return zt(i, t.index, e);
3036
+ case "insert-row-below":
3037
+ return zt(i, t.index + 1, e);
3038
+ case "insert-col-left":
3039
+ return Vt(i, t.index, e);
3040
+ case "insert-col-right":
3041
+ return Vt(i, t.index + 1, e);
3042
+ case "move-row":
3043
+ return qs(i, t.fromIndex, t.toIndex, e);
3044
+ case "move-col":
3045
+ return Fs(i, t.fromIndex, t.toIndex, e);
3046
+ case "delete-row":
3047
+ return zs(i, t.index, e);
3048
+ case "delete-col":
3049
+ return Vs(i, t.index, e);
3050
+ case "toggle-heading":
3051
+ return {
3052
+ pendingHighlight: { type: "row", index: 0 },
3053
+ moveSelection: null,
3054
+ colWidths: e.data.colWidths,
3055
+ withHeadings: !e.data.withHeadings,
3056
+ withHeadingColumn: e.data.withHeadingColumn
3057
+ };
3058
+ case "toggle-heading-column":
3059
+ return {
3060
+ pendingHighlight: { type: "col", index: 0 },
3061
+ moveSelection: null,
3062
+ colWidths: e.data.colWidths,
3063
+ withHeadings: e.data.withHeadings,
3064
+ withHeadingColumn: !e.data.withHeadingColumn
3065
+ };
3066
+ }
3067
+ }, Ut = 10, Ks = "data-blok-table-drag-ghost", St = (i) => {
3002
3068
  const t = i.querySelector(`[${g}]`);
3003
3069
  return t ? Array.from(t.querySelectorAll(`[${u}]`)).reduce(
3004
3070
  (n, s) => {
@@ -3008,7 +3074,7 @@ const $s = [
3008
3074
  [0]
3009
3075
  ) : [0];
3010
3076
  };
3011
- class Vs {
3077
+ class js {
3012
3078
  constructor(t) {
3013
3079
  var e;
3014
3080
  this.isDragging = !1, this.dragType = null, this.dragFromIndex = -1, this.dragStartX = 0, this.dragStartY = 0, this.dropIndicator = null, this.dragOverlayCells = [], this.ghostEl = null, this.ghostOffsetX = 0, this.ghostOffsetY = 0, this.resolveTracking = null, this.grid = t.grid, this.onAction = t.onAction, this.onDragStateChange = (e = t.onDragStateChange) != null ? e : null, this.boundDocPointerMove = this.handleDocPointerMove.bind(this), this.boundDocPointerUp = this.handleDocPointerUp.bind(this);
@@ -3032,7 +3098,7 @@ class Vs {
3032
3098
  }
3033
3099
  handleDocPointerMove(t) {
3034
3100
  const e = Math.abs(t.clientX - this.dragStartX), n = Math.abs(t.clientY - this.dragStartY);
3035
- !this.isDragging && (e > Kt || n > Kt) && (this.isDragging = !0, this.startDrag()), this.isDragging && (this.updateDragIndicator(t), this.updateGhostPosition(t));
3101
+ !this.isDragging && (e > Ut || n > Ut) && (this.isDragging = !0, this.startDrag()), this.isDragging && (this.updateDragIndicator(t), this.updateGhostPosition(t));
3036
3102
  }
3037
3103
  handleDocPointerUp(t) {
3038
3104
  var e, n;
@@ -3056,7 +3122,7 @@ class Vs {
3056
3122
  return;
3057
3123
  e.querySelectorAll(`[${u}]`).forEach((s) => {
3058
3124
  const o = s;
3059
- o.style.backgroundColor = "#dbeafe", o.style.opacity = "0.6", this.dragOverlayCells.push(o);
3125
+ o.style.backgroundColor = "#f3f4f6", o.style.opacity = "0.7", this.dragOverlayCells.push(o);
3060
3126
  });
3061
3127
  }
3062
3128
  highlightColumnCells(t) {
@@ -3065,17 +3131,17 @@ class Vs {
3065
3131
  if (this.dragFromIndex >= n.length)
3066
3132
  return;
3067
3133
  const s = n[this.dragFromIndex];
3068
- s.style.backgroundColor = "#dbeafe", s.style.opacity = "0.6", this.dragOverlayCells.push(s);
3134
+ s.style.backgroundColor = "#f3f4f6", s.style.opacity = "0.7", this.dragOverlayCells.push(s);
3069
3135
  });
3070
3136
  }
3071
3137
  createDropIndicator() {
3072
3138
  this.dropIndicator = document.createElement("div");
3073
3139
  const t = this.dropIndicator.style;
3074
3140
  if (t.position = "absolute", t.backgroundColor = "#3b82f6", t.borderRadius = "1.5px", t.zIndex = "5", t.pointerEvents = "none", this.dropIndicator.setAttribute("contenteditable", "false"), this.dragType === "row")
3075
- t.height = "3px", t.left = `${-$}px`, t.right = "0", t.transition = "top 100ms ease";
3141
+ t.height = "3px", t.left = `${-P}px`, t.right = "0", t.transition = "top 100ms ease";
3076
3142
  else {
3077
3143
  const e = this.grid.querySelectorAll(`[${g}]`), n = e[e.length - 1], s = n ? n.offsetTop + n.offsetHeight : 0;
3078
- t.width = "3px", t.top = `${-$}px`, t.height = `${s + $}px`, t.transition = "left 100ms ease";
3144
+ t.width = "3px", t.top = `${-P}px`, t.height = `${s + P}px`, t.transition = "left 100ms ease";
3079
3145
  }
3080
3146
  this.grid.appendChild(this.dropIndicator);
3081
3147
  }
@@ -3099,7 +3165,7 @@ class Vs {
3099
3165
  var r;
3100
3166
  if (!this.dropIndicator)
3101
3167
  return;
3102
- const n = t.clientX - e.left, s = this.getColDropIndex(n), o = bt(this.grid);
3168
+ const n = t.clientX - e.left, s = this.getColDropIndex(n), o = St(this.grid);
3103
3169
  this.dropIndicator.style.left = `${((r = o[s]) != null ? r : 0) - 1.5}px`;
3104
3170
  }
3105
3171
  finishDrag(t) {
@@ -3120,7 +3186,7 @@ class Vs {
3120
3186
  }
3121
3187
  createGhost() {
3122
3188
  const t = document.createElement("div");
3123
- t.setAttribute(zs, ""), t.setAttribute("contenteditable", "false");
3189
+ t.setAttribute(Ks, ""), t.setAttribute("contenteditable", "false");
3124
3190
  const e = t.style;
3125
3191
  e.position = "fixed", e.pointerEvents = "none", e.opacity = "0.5", e.zIndex = "50", e.borderRadius = "4px", e.overflow = "hidden", e.boxShadow = "0 4px 12px rgba(0,0,0,0.15)", this.ghostEl = t;
3126
3192
  const n = this.getSourceRect();
@@ -3194,11 +3260,177 @@ class Vs {
3194
3260
  return 0;
3195
3261
  }
3196
3262
  getColDropIndex(t) {
3197
- const n = bt(this.grid).map((o) => Math.abs(t - o)), s = Math.min(...n);
3263
+ const n = St(this.grid).map((o) => Math.abs(t - o)), s = Math.min(...n);
3198
3264
  return n.indexOf(s);
3199
3265
  }
3200
3266
  }
3201
- const jt = "data-blok-table-grip", mt = "data-blok-table-grip-col", Xt = "data-blok-table-grip-row", Us = 150, Ks = 24, Ct = 4, yt = 4, js = 20, it = [
3267
+ const Xs = [
3268
+ "flex",
3269
+ "items-center",
3270
+ "select-none",
3271
+ "border-none",
3272
+ "bg-transparent",
3273
+ "rounded-md",
3274
+ "p-[var(--item-padding)]",
3275
+ "text-text-primary",
3276
+ "mb-px",
3277
+ "cursor-pointer",
3278
+ "can-hover:hover:bg-item-hover-bg"
3279
+ ], Ys = [
3280
+ "flex",
3281
+ "items-center",
3282
+ "justify-center",
3283
+ "w-[26px]",
3284
+ "h-[26px]",
3285
+ "mr-2",
3286
+ "[&_svg]:w-icon",
3287
+ "[&_svg]:h-icon"
3288
+ ], Zs = [
3289
+ "mr-auto",
3290
+ "truncate",
3291
+ "text-sm",
3292
+ "font-medium",
3293
+ "leading-5"
3294
+ ], Js = [
3295
+ "relative",
3296
+ "w-[34px]",
3297
+ "h-[20px]",
3298
+ "rounded-full",
3299
+ "transition-colors",
3300
+ "duration-200",
3301
+ "shrink-0"
3302
+ ], Qs = [
3303
+ "absolute",
3304
+ "top-[2px]",
3305
+ "w-4",
3306
+ "h-4",
3307
+ "rounded-full",
3308
+ "bg-white",
3309
+ "shadow-sm",
3310
+ "transition-[left]",
3311
+ "duration-200"
3312
+ ], ye = (i) => {
3313
+ const { icon: t, label: e, isActive: n, onToggle: s } = i, o = { active: n }, r = document.createElement("div");
3314
+ r.className = v(Xs);
3315
+ const l = document.createElement("div");
3316
+ l.className = v(Ys), l.innerHTML = t, r.appendChild(l);
3317
+ const a = document.createElement("span");
3318
+ a.className = v(Zs), a.textContent = e, r.appendChild(a);
3319
+ const c = document.createElement("div");
3320
+ c.className = v(Js);
3321
+ const d = document.createElement("div");
3322
+ d.className = v(Qs), c.appendChild(d), r.appendChild(c);
3323
+ const h = () => {
3324
+ c.style.backgroundColor = o.active ? "#3b82f6" : "#d1d5db", d.style.left = o.active ? "16px" : "2px";
3325
+ };
3326
+ return h(), r.addEventListener("click", (p) => {
3327
+ p.stopPropagation(), o.active = !o.active, h(), s(o.active);
3328
+ }), r;
3329
+ }, to = (i, t) => {
3330
+ const e = i === 0 ? [
3331
+ {
3332
+ type: F.Html,
3333
+ element: ye({
3334
+ icon: Ue,
3335
+ label: t.i18n.t("tools.table.headerColumn"),
3336
+ isActive: t.isHeadingColumn(),
3337
+ onToggle: () => {
3338
+ t.onAction({ type: "toggle-heading-column" });
3339
+ }
3340
+ })
3341
+ },
3342
+ { type: F.Separator }
3343
+ ] : [], n = [
3344
+ {
3345
+ icon: qe,
3346
+ title: t.i18n.t("tools.table.insertColumnLeft"),
3347
+ closeOnActivate: !0,
3348
+ onActivate: () => {
3349
+ t.onAction({ type: "insert-col-left", index: i });
3350
+ }
3351
+ },
3352
+ {
3353
+ icon: Fe,
3354
+ title: t.i18n.t("tools.table.insertColumnRight"),
3355
+ closeOnActivate: !0,
3356
+ onActivate: () => {
3357
+ t.onAction({ type: "insert-col-right", index: i });
3358
+ }
3359
+ }
3360
+ ], s = t.getColumnCount() > 1, o = [
3361
+ { type: F.Separator },
3362
+ {
3363
+ icon: oe,
3364
+ title: t.i18n.t("tools.table.deleteColumn"),
3365
+ isDestructive: !0,
3366
+ isDisabled: !s,
3367
+ closeOnActivate: !0,
3368
+ onActivate: () => {
3369
+ t.onAction({ type: "delete-col", index: i });
3370
+ }
3371
+ }
3372
+ ];
3373
+ return [...e, ...n, ...o];
3374
+ }, eo = (i, t) => {
3375
+ const e = i === 0 ? [
3376
+ {
3377
+ type: F.Html,
3378
+ element: ye({
3379
+ icon: Ke,
3380
+ label: t.i18n.t("tools.table.headerRow"),
3381
+ isActive: t.isHeadingRow(),
3382
+ onToggle: () => {
3383
+ t.onAction({ type: "toggle-heading" });
3384
+ }
3385
+ })
3386
+ },
3387
+ { type: F.Separator }
3388
+ ] : [], n = [
3389
+ {
3390
+ icon: ze,
3391
+ title: t.i18n.t("tools.table.insertRowAbove"),
3392
+ closeOnActivate: !0,
3393
+ onActivate: () => {
3394
+ t.onAction({ type: "insert-row-above", index: i });
3395
+ }
3396
+ },
3397
+ {
3398
+ icon: Ve,
3399
+ title: t.i18n.t("tools.table.insertRowBelow"),
3400
+ closeOnActivate: !0,
3401
+ onActivate: () => {
3402
+ t.onAction({ type: "insert-row-below", index: i });
3403
+ }
3404
+ }
3405
+ ], s = t.getRowCount() > 1, o = [
3406
+ { type: F.Separator },
3407
+ {
3408
+ icon: oe,
3409
+ title: t.i18n.t("tools.table.deleteRow"),
3410
+ isDestructive: !0,
3411
+ isDisabled: !s,
3412
+ closeOnActivate: !0,
3413
+ onActivate: () => {
3414
+ t.onAction({ type: "delete-row", index: i });
3415
+ }
3416
+ }
3417
+ ];
3418
+ return [...e, ...n, ...o];
3419
+ }, no = (i, t, e, n, s) => {
3420
+ s.destroyPopover(), s.clearHideTimeout();
3421
+ const o = i === "col" ? e.col[t] : e.row[t];
3422
+ if (!o)
3423
+ return { popover: null, grip: null };
3424
+ const r = i === "col" ? to(t, n) : eo(t, n), l = new ne({
3425
+ items: r,
3426
+ trigger: o,
3427
+ flippable: !0
3428
+ });
3429
+ return l.on(se.Closed, () => {
3430
+ var a;
3431
+ s.destroyPopover(), s.applyVisibleClasses(o), s.scheduleHideAll(), (a = s.onGripPopoverClose) == null || a.call(s);
3432
+ }), s.hideAllGripsExcept(o), s.applyActiveClasses(o), i === "col" ? o.style.height = `${Y}px` : o.style.width = `${Y}px`, { popover: l, grip: o };
3433
+ }, Kt = "data-blok-table-grip", ot = "data-blok-table-grip-col", jt = "data-blok-table-grip-row", so = 150, oo = 24, it = 4, rt = 4, io = 20, lt = [
3202
3434
  "absolute",
3203
3435
  "z-[3]",
3204
3436
  "rounded",
@@ -3211,23 +3443,23 @@ const jt = "data-blok-table-grip", mt = "data-blok-table-grip-col", Xt = "data-b
3211
3443
  "items-center",
3212
3444
  "justify-center",
3213
3445
  "overflow-hidden"
3214
- ], Yt = [
3446
+ ], Xt = [
3215
3447
  "bg-gray-300",
3216
3448
  "opacity-0",
3217
3449
  "pointer-events-none"
3218
- ], Xs = [
3450
+ ], ro = [
3219
3451
  "bg-gray-300",
3220
3452
  "opacity-100",
3221
3453
  "pointer-events-auto"
3222
- ], Ys = [
3454
+ ], lo = [
3223
3455
  "bg-blue-500",
3224
3456
  "text-white",
3225
3457
  "opacity-100",
3226
3458
  "pointer-events-auto"
3227
3459
  ];
3228
- class Zs {
3460
+ class ao {
3229
3461
  constructor(t) {
3230
- this.colGrips = [], this.rowGrips = [], this.activePopover = null, this.activePopoverGrip = null, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.grid = t.grid, this.getColumnCount = t.getColumnCount, this.getRowCount = t.getRowCount, this.isHeadingRow = t.isHeadingRow, this.isHeadingColumn = t.isHeadingColumn, this.onAction = t.onAction, this.onGripClick = t.onGripClick, this.onGripPopoverClose = t.onGripPopoverClose, this.drag = new Vs({
3462
+ this.colGrips = [], this.rowGrips = [], this.popoverState = { popover: null, grip: null }, this.lockedGrip = null, this.hideTimeout = null, this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1, this.rowResizeObserver = null, this.grid = t.grid, this.getColumnCount = t.getColumnCount, this.getRowCount = t.getRowCount, this.isHeadingRow = t.isHeadingRow, this.isHeadingColumn = t.isHeadingColumn, this.onAction = t.onAction, this.onGripClick = t.onGripClick, this.onGripPopoverClose = t.onGripPopoverClose, this.i18n = t.i18n, this.drag = new js({
3231
3463
  grid: this.grid,
3232
3464
  onAction: this.onAction,
3233
3465
  onDragStateChange: (e, n) => {
@@ -3248,7 +3480,7 @@ class Zs {
3248
3480
  */
3249
3481
  setActiveGrip(t, e) {
3250
3482
  const n = t === "col" ? this.colGrips[e] : this.rowGrips[e];
3251
- n && (this.unlockGrip(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${K}px` : n.style.width = `${K}px`, this.lockedGrip = n, requestAnimationFrame(() => {
3483
+ n && (this.unlockGrip(), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${Y}px` : n.style.width = `${Y}px`, this.lockedGrip = n, requestAnimationFrame(() => {
3252
3484
  document.addEventListener("pointerdown", this.boundUnlockGrip);
3253
3485
  }));
3254
3486
  }
@@ -3269,19 +3501,20 @@ class Zs {
3269
3501
  }), Array.from({ length: e }).forEach((n, s) => {
3270
3502
  const o = this.createGripElement("row", s);
3271
3503
  this.rowGrips.push(o), this.grid.appendChild(o);
3272
- }), this.positionGrips();
3504
+ }), this.positionGrips(), this.observeRowHeights();
3273
3505
  }
3274
3506
  destroyGrips() {
3275
- this.colGrips.forEach((t) => t.remove()), this.rowGrips.forEach((t) => t.remove()), this.colGrips = [], this.rowGrips = [], this.activeColGripIndex = -1, this.activeRowGripIndex = -1;
3507
+ var t;
3508
+ (t = this.rowResizeObserver) == null || t.disconnect(), this.rowResizeObserver = null, this.colGrips.forEach((e) => e.remove()), this.rowGrips.forEach((e) => e.remove()), this.colGrips = [], this.rowGrips = [], this.activeColGripIndex = -1, this.activeRowGripIndex = -1, this.isInsideTable = !1;
3276
3509
  }
3277
3510
  createGripElement(t, e) {
3278
3511
  const n = document.createElement("div");
3279
- n.className = v(it, Yt), n.setAttribute(jt, ""), n.setAttribute(t === "col" ? mt : Xt, String(e)), n.setAttribute("contenteditable", "false");
3280
- const s = t === "col" ? Ks : yt, o = t === "col" ? Ct : js, r = t === "col" ? Ct : yt;
3281
- return n.style.width = `${s}px`, n.style.height = `${o}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(me(t === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
3282
- this.isGripInteractionLocked() || Cs(n, t);
3512
+ n.className = v(lt, Xt), n.setAttribute(Kt, ""), n.setAttribute(t === "col" ? ot : jt, String(e)), n.setAttribute("contenteditable", "false");
3513
+ const s = t === "col" ? oo : rt, o = t === "col" ? it : io, r = t === "col" ? it : rt;
3514
+ return n.style.width = `${s}px`, n.style.height = `${o}px`, n.style.transform = "translate(-50%, -50%)", n.style.outline = "2px solid white", n.appendChild(fe(t === "col" ? "horizontal" : "vertical")), n.addEventListener("pointerdown", this.boundPointerDown), n.addEventListener("mouseenter", () => {
3515
+ this.isGripInteractionLocked() || ys(n, t);
3283
3516
  }), n.addEventListener("mouseleave", () => {
3284
- this.isGripInteractionLocked() || Gt(n, t, r);
3517
+ this.isGripInteractionLocked() || gt(n, t, r);
3285
3518
  }), n;
3286
3519
  }
3287
3520
  /**
@@ -3292,21 +3525,33 @@ class Zs {
3292
3525
  const t = this.grid.querySelectorAll(`[${g}]`);
3293
3526
  if (!t[0])
3294
3527
  return;
3295
- const n = bt(this.grid);
3528
+ const n = St(this.grid);
3296
3529
  this.colGrips.forEach((s, o) => {
3297
3530
  if (o + 1 >= n.length)
3298
3531
  return;
3299
3532
  const r = (n[o] + n[o + 1]) / 2, l = s.style;
3300
- l.top = `${-$ / 2}px`, l.left = `${r}px`;
3533
+ l.top = `${-P / 2}px`, l.left = `${r}px`;
3301
3534
  }), this.rowGrips.forEach((s, o) => {
3302
3535
  if (o >= t.length)
3303
3536
  return;
3304
3537
  const r = t[o], l = r.offsetTop + r.offsetHeight / 2, a = s.style;
3305
- a.left = `${-$ / 2}px`, a.top = `${l}px`;
3538
+ a.left = `${-P / 2}px`, a.top = `${l}px`;
3539
+ });
3540
+ }
3541
+ /**
3542
+ * Set up ResizeObserver to watch for row height changes and reposition grips.
3543
+ */
3544
+ observeRowHeights() {
3545
+ var e;
3546
+ (e = this.rowResizeObserver) == null || e.disconnect(), this.rowResizeObserver = new ResizeObserver(() => {
3547
+ this.positionGrips();
3548
+ }), this.grid.querySelectorAll(`[${g}]`).forEach((n) => {
3549
+ var s;
3550
+ (s = this.rowResizeObserver) == null || s.observe(n);
3306
3551
  });
3307
3552
  }
3308
3553
  isGripInteractionLocked() {
3309
- return this.activePopover !== null || this.lockedGrip !== null;
3554
+ return this.popoverState.popover !== null || this.lockedGrip !== null;
3310
3555
  }
3311
3556
  handleMouseOver(t) {
3312
3557
  if (this.isGripInteractionLocked())
@@ -3316,7 +3561,7 @@ class Zs {
3316
3561
  return;
3317
3562
  this.clearHideTimeout();
3318
3563
  const s = this.getCellPosition(n);
3319
- s && (this.showColGrip(s.col), this.showRowGrip(s.row));
3564
+ s && (this.showColGrip(s.col), this.showRowGrip(s.row), this.isInsideTable = !0);
3320
3565
  }
3321
3566
  handleMouseLeave() {
3322
3567
  this.isGripInteractionLocked() || this.scheduleHideAll();
@@ -3340,14 +3585,14 @@ class Zs {
3340
3585
  const e = t ? "" : "none";
3341
3586
  [...this.colGrips, ...this.rowGrips].forEach((n) => {
3342
3587
  const s = n;
3343
- !t && n === this.activePopoverGrip || (s.style.display = e);
3588
+ !t && n === this.popoverState.grip || (s.style.display = e);
3344
3589
  });
3345
3590
  }
3346
3591
  /**
3347
3592
  * Immediately hide all grips (no delay). Used when resize drag starts.
3348
3593
  */
3349
3594
  hideAllGrips() {
3350
- this.clearHideTimeout(), this.hideColGrip(), this.hideRowGrip();
3595
+ this.clearHideTimeout(), this.hideColGrip(), this.hideRowGrip(), this.isInsideTable = !1;
3351
3596
  }
3352
3597
  showColGrip(t) {
3353
3598
  this.activeColGripIndex !== t && (this.hideColGrip(), this.activeColGripIndex = t, this.applyVisibleClasses(this.colGrips[t]));
@@ -3362,13 +3607,13 @@ class Zs {
3362
3607
  this.activeRowGripIndex >= 0 && this.activeRowGripIndex < this.rowGrips.length && this.applyIdleClasses(this.rowGrips[this.activeRowGripIndex]), this.activeRowGripIndex = -1;
3363
3608
  }
3364
3609
  applyVisibleClasses(t) {
3365
- const e = t;
3366
- e.className = v(it, Xs), e.setAttribute("data-blok-table-grip-visible", "");
3367
- const n = e.querySelector("svg");
3368
- n && (n.classList.remove("text-white"), n.classList.add("text-gray-400"));
3610
+ const e = t, n = e.hasAttribute(ot);
3611
+ gt(e, n ? "col" : "row", n ? it : rt), this.isInsideTable && (e.style.transition = "none"), e.className = v(lt, ro), e.setAttribute("data-blok-table-grip-visible", ""), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
3612
+ const r = e.querySelector("svg");
3613
+ r && (r.classList.remove("text-white"), r.classList.add("text-gray-400"));
3369
3614
  }
3370
3615
  applyActiveClasses(t) {
3371
- t.className = v(it, Ys), t.setAttribute("data-blok-table-grip-visible", "");
3616
+ Object.assign(t, { className: v(lt, lo) }), t.setAttribute("data-blok-table-grip-visible", "");
3372
3617
  const e = t.querySelector("svg");
3373
3618
  e && (e.classList.remove("text-gray-400", "opacity-0"), e.classList.add("text-white", "opacity-100"));
3374
3619
  }
@@ -3378,8 +3623,8 @@ class Zs {
3378
3623
  });
3379
3624
  }
3380
3625
  applyIdleClasses(t) {
3381
- const e = t, n = e.hasAttribute(mt);
3382
- Gt(e, n ? "col" : "row", n ? Ct : yt), e.className = v(it, Yt), e.removeAttribute("data-blok-table-grip-visible");
3626
+ const e = t, n = e.hasAttribute(ot), s = n ? "col" : "row", o = 12, r = n ? it + o : rt + o;
3627
+ this.isInsideTable && (e.style.transition = "none"), gt(e, s, r), e.className = v(lt, Xt), e.removeAttribute("data-blok-table-grip-visible"), this.isInsideTable && (e.offsetHeight, e.style.transition = "");
3383
3628
  }
3384
3629
  handleDragStateChange(t, e) {
3385
3630
  [...this.colGrips, ...this.rowGrips].forEach((n) => {
@@ -3389,15 +3634,15 @@ class Zs {
3389
3634
  }
3390
3635
  scheduleHideAll() {
3391
3636
  this.hideTimeout = setTimeout(() => {
3392
- this.hideColGrip(), this.hideRowGrip(), this.hideTimeout = null;
3393
- }, Us);
3637
+ this.hideColGrip(), this.hideRowGrip(), this.isInsideTable = !1, this.hideTimeout = null;
3638
+ }, so);
3394
3639
  }
3395
3640
  clearHideTimeout() {
3396
3641
  this.hideTimeout !== null && (clearTimeout(this.hideTimeout), this.hideTimeout = null);
3397
3642
  }
3398
3643
  // ── Click / Drag discrimination ──────────────────────────────
3399
3644
  handlePointerDown(t) {
3400
- const n = t.target.closest(`[${jt}]`);
3645
+ const n = t.target.closest(`[${Kt}]`);
3401
3646
  if (!n)
3402
3647
  return;
3403
3648
  t.preventDefault(), t.stopPropagation();
@@ -3407,141 +3652,58 @@ class Zs {
3407
3652
  });
3408
3653
  }
3409
3654
  detectGripType(t) {
3410
- const e = t.getAttribute(mt);
3655
+ const e = t.getAttribute(ot);
3411
3656
  if (e !== null)
3412
3657
  return { type: "col", index: Number(e) };
3413
- const n = t.getAttribute(Xt);
3658
+ const n = t.getAttribute(jt);
3414
3659
  return n !== null ? { type: "row", index: Number(n) } : null;
3415
3660
  }
3416
3661
  // ── Popover menus ────────────────────────────────────────────
3417
3662
  openPopover(t, e) {
3418
- var o;
3419
- this.destroyPopover(), this.clearHideTimeout();
3420
- const n = t === "col" ? this.colGrips[e] : this.rowGrips[e];
3421
- if (!n)
3422
- return;
3423
- const s = t === "col" ? this.buildColumnMenu(e) : this.buildRowMenu(e);
3424
- this.activePopover = new se({
3425
- items: s,
3426
- trigger: n,
3427
- flippable: !0
3428
- }), this.activePopoverGrip = n, this.activePopover.on(oe.Closed, () => {
3429
- var r;
3430
- this.activePopover !== null && (this.destroyPopover(), this.applyVisibleClasses(n), this.scheduleHideAll(), (r = this.onGripPopoverClose) == null || r.call(this));
3431
- }), this.hideAllGripsExcept(n), this.applyActiveClasses(n), t === "col" ? n.style.height = `${K}px` : n.style.width = `${K}px`, this.activePopover.show(), (o = this.onGripClick) == null || o.call(this, t, e);
3432
- }
3433
- destroyPopover() {
3434
- if (this.activePopover !== null) {
3435
- const t = this.activePopover;
3436
- this.activePopover = null, this.activePopoverGrip = null, t.destroy();
3437
- }
3438
- }
3439
- buildColumnMenu(t) {
3440
- const e = t === 0 ? [
3441
- {
3442
- type: F.Html,
3443
- element: Ut({
3444
- icon: Ve,
3445
- label: "Header column",
3446
- isActive: this.isHeadingColumn(),
3447
- onToggle: () => {
3448
- this.onAction({ type: "toggle-heading-column" });
3449
- }
3450
- })
3451
- },
3452
- { type: F.Separator }
3453
- ] : [], n = [
3663
+ var n, s;
3664
+ this.popoverState = no(
3665
+ t,
3666
+ e,
3667
+ { col: this.colGrips, row: this.rowGrips },
3454
3668
  {
3455
- icon: We,
3456
- title: "Insert Column Left",
3457
- closeOnActivate: !0,
3458
- onActivate: () => {
3459
- this.onAction({ type: "insert-col-left", index: t });
3460
- }
3669
+ getColumnCount: this.getColumnCount,
3670
+ getRowCount: this.getRowCount,
3671
+ isHeadingRow: this.isHeadingRow,
3672
+ isHeadingColumn: this.isHeadingColumn,
3673
+ onAction: this.onAction,
3674
+ i18n: this.i18n
3461
3675
  },
3462
3676
  {
3463
- icon: qe,
3464
- title: "Insert Column Right",
3465
- closeOnActivate: !0,
3466
- onActivate: () => {
3467
- this.onAction({ type: "insert-col-right", index: t });
3468
- }
3469
- }
3470
- ], s = this.getColumnCount() > 1, o = [
3471
- { type: F.Separator },
3472
- {
3473
- icon: Lt,
3474
- title: "Delete",
3475
- isDestructive: !0,
3476
- isDisabled: !s,
3477
- closeOnActivate: !0,
3478
- onActivate: () => {
3479
- this.onAction({ type: "delete-col", index: t });
3480
- }
3677
+ clearHideTimeout: () => this.clearHideTimeout(),
3678
+ hideAllGripsExcept: (o) => this.hideAllGripsExcept(o),
3679
+ applyActiveClasses: (o) => this.applyActiveClasses(o),
3680
+ applyVisibleClasses: (o) => this.applyVisibleClasses(o),
3681
+ scheduleHideAll: () => this.scheduleHideAll(),
3682
+ destroyPopover: () => this.destroyPopover(),
3683
+ onGripPopoverClose: this.onGripPopoverClose
3481
3684
  }
3482
- ];
3483
- return [...e, ...n, ...o];
3685
+ ), (n = this.popoverState.popover) == null || n.show(), (s = this.onGripClick) == null || s.call(this, t, e);
3484
3686
  }
3485
- buildRowMenu(t) {
3486
- const e = t === 0 ? [
3487
- {
3488
- type: F.Html,
3489
- element: Ut({
3490
- icon: Ue,
3491
- label: "Header row",
3492
- isActive: this.isHeadingRow(),
3493
- onToggle: () => {
3494
- this.onAction({ type: "toggle-heading" });
3495
- }
3496
- })
3497
- },
3498
- { type: F.Separator }
3499
- ] : [], n = [
3500
- {
3501
- icon: Fe,
3502
- title: "Insert Row Above",
3503
- closeOnActivate: !0,
3504
- onActivate: () => {
3505
- this.onAction({ type: "insert-row-above", index: t });
3506
- }
3507
- },
3508
- {
3509
- icon: ze,
3510
- title: "Insert Row Below",
3511
- closeOnActivate: !0,
3512
- onActivate: () => {
3513
- this.onAction({ type: "insert-row-below", index: t });
3514
- }
3515
- }
3516
- ], s = this.getRowCount() > 1, o = [
3517
- { type: F.Separator },
3518
- {
3519
- icon: Lt,
3520
- title: "Delete",
3521
- isDestructive: !0,
3522
- isDisabled: !s,
3523
- closeOnActivate: !0,
3524
- onActivate: () => {
3525
- this.onAction({ type: "delete-row", index: t });
3526
- }
3527
- }
3528
- ];
3529
- return [...e, ...n, ...o];
3687
+ destroyPopover() {
3688
+ if (this.popoverState.popover !== null) {
3689
+ const t = this.popoverState.popover;
3690
+ this.popoverState = { popover: null, grip: null }, t.destroy();
3691
+ }
3530
3692
  }
3531
3693
  }
3532
- const Js = 3, Qs = 3, to = [
3694
+ const co = 3, ho = 3, uo = [
3533
3695
  "my-2",
3534
3696
  "pr-5"
3535
- ], eo = [
3697
+ ], po = [
3536
3698
  "relative"
3537
3699
  ];
3538
- class co {
3700
+ class So {
3539
3701
  constructor({ data: t, config: e, api: n, readOnly: s, block: o }) {
3540
- this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.element = null, this.pendingHighlight = null, this.api = n, this.readOnly = s, this.config = e != null ? e : {}, this.data = Ns(t, e != null ? e : {}), this.grid = new ps({ readOnly: s }), this.blockId = o == null ? void 0 : o.id;
3702
+ this.resize = null, this.addControls = null, this.rowColControls = null, this.cellBlocks = null, this.cellSelection = null, this.element = null, this.pendingHighlight = null, this.isNewTable = !1, this.api = n, this.readOnly = s, this.config = e != null ? e : {}, this.data = _s(t, e != null ? e : {}), this.grid = new gs({ readOnly: s }), this.blockId = o == null ? void 0 : o.id;
3541
3703
  }
3542
3704
  static get toolbox() {
3543
3705
  return {
3544
- icon: Ke,
3706
+ icon: je,
3545
3707
  title: "Table",
3546
3708
  titleKey: "tools.table.title",
3547
3709
  searchTerms: ["table", "grid", "spreadsheet"]
@@ -3572,31 +3734,38 @@ class co {
3572
3734
  render() {
3573
3735
  var o;
3574
3736
  const t = document.createElement("div");
3575
- t.className = v(to, !this.readOnly && eo, this.data.colWidths && ye), t.setAttribute(E.tool, "table"), this.readOnly && t.setAttribute("data-blok-table-readonly", "");
3576
- const e = this.data.content.length || this.config.rows || Js, n = ((o = this.data.content[0]) == null ? void 0 : o.length) || this.config.cols || Qs, s = this.grid.createGrid(e, n, this.data.colWidths);
3577
- return this.data.content.length > 0 && this.grid.fillGrid(s, this.data.content), this.data.colWidths && st(s, this.data.colWidths), t.appendChild(s), this.element = t, this.data.withHeadings && ot(this.element, this.data.withHeadings), this.data.withHeadingColumn && U(this.element, this.data.withHeadingColumn), this.readOnly || (this.initCellBlocks(s), Ps(s, this.cellBlocks)), t;
3737
+ t.className = v(uo, !this.readOnly && po, this.data.colWidths && Ce), t.setAttribute(E.tool, "table"), this.readOnly && t.setAttribute("data-blok-table-readonly", ""), this.isNewTable = this.data.content.length === 0;
3738
+ const e = this.data.content.length || this.config.rows || co, n = ((o = this.data.content[0]) == null ? void 0 : o.length) || this.config.cols || ho, s = this.grid.createGrid(e, n, this.data.colWidths);
3739
+ return this.data.content.length > 0 && this.grid.fillGrid(s, this.data.content), this.data.colWidths && ct(s, this.data.colWidths), t.appendChild(s), this.element = t, this.data.withHeadings && st(this.element, this.data.withHeadings), this.data.withHeadingColumn && V(this.element, this.data.withHeadingColumn), this.readOnly || (this.initCellBlocks(s), Os(s, this.cellBlocks)), t;
3578
3740
  }
3579
3741
  rendered() {
3580
- var e, n;
3742
+ var e, n, s;
3581
3743
  if (!this.element)
3582
3744
  return;
3583
3745
  const t = this.element.firstElementChild;
3584
3746
  if (t) {
3585
3747
  if (this.readOnly) {
3586
- Ds(t, this.data.content, this.api);
3748
+ Ps(t, this.data.content, this.api);
3587
3749
  return;
3588
3750
  }
3589
- this.data.content = (n = (e = this.cellBlocks) == null ? void 0 : e.initializeCells(this.data.content)) != null ? n : this.data.content, this.initResize(t), this.initAddControls(t), this.initRowColControls(t), this.initCellSelection(t);
3751
+ if (this.data.content = (n = (e = this.cellBlocks) == null ? void 0 : e.initializeCells(this.data.content)) != null ? n : this.data.content, this.isNewTable && G(t, this.cellBlocks), this.data.initialColWidth === void 0) {
3752
+ const o = (s = this.data.colWidths) != null ? s : U(t);
3753
+ this.data.initialColWidth = o.length > 0 ? Ns(o) : void 0;
3754
+ }
3755
+ if (this.initResize(t), this.initAddControls(t), this.initRowColControls(t), this.initCellSelection(t), this.isNewTable) {
3756
+ const o = t.querySelector('[contenteditable="true"]');
3757
+ o == null || o.focus();
3758
+ }
3590
3759
  }
3591
3760
  }
3592
3761
  save(t) {
3593
3762
  const e = t.firstElementChild, n = this.data.colWidths, s = this.readOnly ? this.data.content : this.grid.getData(e);
3594
- return L({
3763
+ return x(x({
3595
3764
  withHeadings: this.data.withHeadings,
3596
3765
  withHeadingColumn: this.data.withHeadingColumn,
3597
3766
  stretched: this.data.stretched,
3598
3767
  content: s
3599
- }, n ? { colWidths: n } : {});
3768
+ }, n ? { colWidths: n } : {}), this.data.initialColWidth !== void 0 ? { initialColWidth: this.data.initialColWidth } : {});
3600
3769
  }
3601
3770
  validate(t) {
3602
3771
  return t.content.length > 0;
@@ -3605,10 +3774,10 @@ class co {
3605
3774
  var d, h;
3606
3775
  const e = t.detail.data, n = e.querySelectorAll("tr"), s = [];
3607
3776
  n.forEach((p) => {
3608
- const m = p.querySelectorAll("td, th"), f = [];
3609
- m.forEach((y) => {
3610
- f.push(y.innerHTML);
3611
- }), f.length > 0 && s.push(f);
3777
+ const f = p.querySelectorAll("td, th"), m = [];
3778
+ f.forEach((C) => {
3779
+ m.push(C.innerHTML);
3780
+ }), m.length > 0 && s.push(m);
3612
3781
  });
3613
3782
  const o = e.querySelector("thead") !== null, r = ((d = n[0]) == null ? void 0 : d.querySelector("th")) !== null, l = o || r;
3614
3783
  if (this.data = {
@@ -3624,73 +3793,83 @@ class co {
3624
3793
  !this.readOnly && c && (this.initResize(c), this.initAddControls(c), this.initRowColControls(c));
3625
3794
  }
3626
3795
  destroy() {
3627
- var t, e, n, s, o;
3628
- (t = this.resize) == null || t.destroy(), this.resize = null, (e = this.addControls) == null || e.destroy(), this.addControls = null, (n = this.rowColControls) == null || n.destroy(), this.rowColControls = null, (s = this.cellBlocks) == null || s.destroy(), this.cellBlocks = null, (o = this.cellSelection) == null || o.destroy(), this.cellSelection = null, this.element = null;
3796
+ var t, e, n, s, o, r;
3797
+ (t = this.cellBlocks) == null || t.deleteAllBlocks(), (e = this.resize) == null || e.destroy(), this.resize = null, (n = this.addControls) == null || n.destroy(), this.addControls = null, (s = this.rowColControls) == null || s.destroy(), this.rowColControls = null, (o = this.cellBlocks) == null || o.destroy(), this.cellBlocks = null, (r = this.cellSelection) == null || r.destroy(), this.cellSelection = null, this.element = null;
3629
3798
  }
3630
3799
  deleteRowWithCleanup(t) {
3631
3800
  var n;
3632
3801
  const e = (n = this.element) == null ? void 0 : n.firstElementChild;
3633
- e && pt(e, t, this.grid, this.cellBlocks);
3802
+ e && bt(e, t, this.grid, this.cellBlocks);
3634
3803
  }
3635
3804
  deleteColumnWithCleanup(t) {
3636
3805
  var n;
3637
3806
  const e = (n = this.element) == null ? void 0 : n.firstElementChild;
3638
- e && (this.data.colWidths = gt(e, t, this.data.colWidths, this.grid, this.cellBlocks));
3807
+ e && (this.data.colWidths = vt(e, t, this.data.colWidths, this.grid, this.cellBlocks));
3639
3808
  }
3640
3809
  getBlockIdsInRow(t) {
3641
- return Bs(this.element, this.cellBlocks, t);
3810
+ return Ds(this.element, this.cellBlocks, t);
3642
3811
  }
3643
3812
  getBlockIdsInColumn(t) {
3644
- return Is(this.element, this.cellBlocks, t);
3813
+ return Hs(this.element, this.cellBlocks, t);
3645
3814
  }
3646
3815
  initAddControls(t) {
3647
- var e;
3648
- (e = this.addControls) == null || e.destroy(), this.element && (this.addControls = new cs({
3816
+ var n;
3817
+ if ((n = this.addControls) == null || n.destroy(), !this.element)
3818
+ return;
3819
+ const e = { addedCols: 0 };
3820
+ this.addControls = new ds({
3649
3821
  wrapper: this.element,
3650
3822
  grid: t,
3823
+ i18n: this.api.i18n,
3824
+ getNewColumnWidth: () => {
3825
+ var o;
3826
+ const s = (o = this.data.colWidths) != null ? o : U(t);
3827
+ return this.data.initialColWidth !== void 0 ? Math.round(this.data.initialColWidth / 2 * 100) / 100 : dt(s);
3828
+ },
3651
3829
  onAddRow: () => {
3652
- var n, s;
3653
- this.grid.addRow(t), W(t, this.cellBlocks), ot(this.element, this.data.withHeadings), U(this.element, this.data.withHeadingColumn), this.initResize(t), (n = this.addControls) == null || n.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh();
3830
+ var s, o;
3831
+ this.grid.addRow(t), G(t, this.cellBlocks), st(this.element, this.data.withHeadings), V(this.element, this.data.withHeadingColumn), this.initResize(t), (s = this.addControls) == null || s.syncRowButtonWidth(), (o = this.rowColControls) == null || o.refresh();
3654
3832
  },
3655
3833
  onAddColumn: () => {
3656
- var o, r, l;
3657
- const n = (o = this.data.colWidths) != null ? o : lt(t), s = Ft(n);
3658
- this.grid.addColumn(t, void 0, n), this.data.colWidths = [...n, s], W(t, this.cellBlocks), U(this.element, this.data.withHeadingColumn), this.initResize(t), (r = this.addControls) == null || r.syncRowButtonWidth(), (l = this.rowColControls) == null || l.refresh();
3834
+ var r, l, a;
3835
+ const s = (r = this.data.colWidths) != null ? r : U(t), o = this.data.initialColWidth !== void 0 ? Math.round(this.data.initialColWidth / 2 * 100) / 100 : dt(s);
3836
+ this.grid.addColumn(t, void 0, s, o), this.data.colWidths = [...s, o], G(t, this.cellBlocks), V(this.element, this.data.withHeadingColumn), this.initResize(t), (l = this.addControls) == null || l.syncRowButtonWidth(), (a = this.rowColControls) == null || a.refresh();
3659
3837
  },
3660
3838
  onDragStart: () => {
3661
- var n, s;
3662
- this.resize && (this.resize.enabled = !1), (n = this.rowColControls) == null || n.hideAllGrips(), (s = this.rowColControls) == null || s.setGripsDisplay(!1);
3839
+ var s, o;
3840
+ this.resize && (this.resize.enabled = !1), (s = this.rowColControls) == null || s.hideAllGrips(), (o = this.rowColControls) == null || o.setGripsDisplay(!1);
3663
3841
  },
3664
3842
  onDragAddRow: () => {
3665
- this.grid.addRow(t), W(t, this.cellBlocks), ot(this.element, this.data.withHeadings), U(this.element, this.data.withHeadingColumn);
3843
+ this.grid.addRow(t), G(t, this.cellBlocks), st(this.element, this.data.withHeadings), V(this.element, this.data.withHeadingColumn);
3666
3844
  },
3667
3845
  onDragRemoveRow: () => {
3668
- const n = this.grid.getRowCount(t);
3669
- n > 1 && ks(t, n - 1) && pt(t, n - 1, this.grid, this.cellBlocks);
3846
+ const s = this.grid.getRowCount(t);
3847
+ s > 1 && xs(t, s - 1) && bt(t, s - 1, this.grid, this.cellBlocks);
3670
3848
  },
3671
3849
  onDragAddCol: () => {
3672
- var o;
3673
- const n = (o = this.data.colWidths) != null ? o : lt(t), s = Ft(n);
3674
- this.grid.addColumn(t, void 0, n), this.data.colWidths = [...n, s], st(t, this.data.colWidths), W(t, this.cellBlocks), U(this.element, this.data.withHeadingColumn), this.initResize(t);
3850
+ var r;
3851
+ const s = (r = this.data.colWidths) != null ? r : U(t), o = this.data.initialColWidth !== void 0 ? Math.round(this.data.initialColWidth / 2 * 100) / 100 : dt(s);
3852
+ this.grid.addColumn(t, void 0, s, o), this.data.colWidths = [...s, o], ct(t, this.data.colWidths), G(t, this.cellBlocks), V(this.element, this.data.withHeadingColumn), this.initResize(t), e.addedCols++, this.element && (this.element.scrollLeft = this.element.scrollWidth);
3675
3853
  },
3676
3854
  onDragRemoveCol: () => {
3677
- const n = this.grid.getColumnCount(t);
3678
- n <= 1 || !xs(t, n - 1) || (this.data.colWidths = gt(t, n - 1, this.data.colWidths, this.grid, this.cellBlocks), this.data.colWidths && st(t, this.data.colWidths), this.initResize(t));
3855
+ const s = this.grid.getColumnCount(t);
3856
+ s <= 1 || !Ts(t, s - 1) || (this.data.colWidths = vt(t, s - 1, this.data.colWidths, this.grid, this.cellBlocks), this.data.colWidths && ct(t, this.data.colWidths), this.initResize(t), e.addedCols--);
3679
3857
  },
3680
3858
  onDragEnd: () => {
3681
- var n, s;
3682
- this.initResize(t), (n = this.addControls) == null || n.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh(), this.element && (this.element.scrollLeft = 0);
3859
+ var s, o;
3860
+ this.initResize(t), (s = this.addControls) == null || s.syncRowButtonWidth(), (o = this.rowColControls) == null || o.refresh(), this.element && (this.element.scrollLeft = e.addedCols > 0 ? this.element.scrollWidth : 0), e.addedCols = 0;
3683
3861
  }
3684
- }));
3862
+ });
3685
3863
  }
3686
3864
  initRowColControls(t) {
3687
3865
  var e;
3688
- (e = this.rowColControls) == null || e.destroy(), this.element && (this.rowColControls = new Zs({
3866
+ (e = this.rowColControls) == null || e.destroy(), this.element && (this.rowColControls = new ao({
3689
3867
  grid: t,
3690
3868
  getColumnCount: () => this.grid.getColumnCount(t),
3691
3869
  getRowCount: () => this.grid.getRowCount(t),
3692
3870
  isHeadingRow: () => this.data.withHeadings,
3693
3871
  isHeadingColumn: () => this.data.withHeadingColumn,
3872
+ i18n: this.api.i18n,
3694
3873
  onAction: (n) => this.handleRowColAction(t, n),
3695
3874
  onDragStateChange: (n) => {
3696
3875
  var s;
@@ -3714,57 +3893,27 @@ class co {
3714
3893
  }));
3715
3894
  }
3716
3895
  handleRowColAction(t, e) {
3717
- var n, s;
3718
- switch (e.type) {
3719
- case "insert-row-above":
3720
- this.grid.addRow(t, e.index), W(t, this.cellBlocks), this.pendingHighlight = { type: "row", index: e.index };
3721
- break;
3722
- case "insert-row-below":
3723
- this.grid.addRow(t, e.index + 1), W(t, this.cellBlocks), this.pendingHighlight = { type: "row", index: e.index + 1 };
3724
- break;
3725
- case "insert-col-left":
3726
- this.data.colWidths = qt(t, e.index, this.data, this.grid), W(t, this.cellBlocks), this.pendingHighlight = { type: "col", index: e.index };
3727
- break;
3728
- case "insert-col-right":
3729
- this.data.colWidths = qt(t, e.index + 1, this.data, this.grid), W(t, this.cellBlocks), this.pendingHighlight = { type: "col", index: e.index + 1 };
3730
- break;
3731
- case "move-row":
3732
- this.grid.moveRow(t, e.fromIndex, e.toIndex);
3733
- break;
3734
- case "move-col":
3735
- this.grid.moveColumn(t, e.fromIndex, e.toIndex), this.data.colWidths = Ls(this.data.colWidths, e.fromIndex, e.toIndex);
3736
- break;
3737
- case "delete-row": {
3738
- pt(t, e.index, this.grid, this.cellBlocks);
3739
- const o = this.grid.getRowCount(t), r = e.index < o ? e.index : e.index - 1;
3740
- this.pendingHighlight = { type: "row", index: r };
3741
- break;
3742
- }
3743
- case "delete-col": {
3744
- this.data.colWidths = gt(t, e.index, this.data.colWidths, this.grid, this.cellBlocks), this.data.colWidths ? st(t, this.data.colWidths) : Ts(t);
3745
- const o = this.grid.getColumnCount(t), r = e.index < o ? e.index : e.index - 1;
3746
- this.pendingHighlight = { type: "col", index: r };
3747
- break;
3748
- }
3749
- case "toggle-heading":
3750
- this.data.withHeadings = !this.data.withHeadings, this.pendingHighlight = { type: "row", index: 0 };
3751
- break;
3752
- case "toggle-heading-column":
3753
- this.data.withHeadingColumn = !this.data.withHeadingColumn, this.pendingHighlight = { type: "col", index: 0 };
3754
- break;
3755
- }
3756
- ot(this.element, this.data.withHeadings), U(this.element, this.data.withHeadingColumn), this.initResize(t), (n = this.addControls) == null || n.syncRowButtonWidth(), (s = this.rowColControls) == null || s.refresh();
3896
+ var r, l, a, c, d;
3897
+ const n = Us(
3898
+ t,
3899
+ e,
3900
+ { grid: this.grid, data: this.data, cellBlocks: this.cellBlocks }
3901
+ );
3902
+ if (this.data.colWidths = n.colWidths, this.data.withHeadings = n.withHeadings, this.data.withHeadingColumn = n.withHeadingColumn, this.pendingHighlight = n.pendingHighlight, st(this.element, this.data.withHeadings), V(this.element, this.data.withHeadingColumn), this.initResize(t), (r = this.addControls) == null || r.syncRowButtonWidth(), (l = this.rowColControls) == null || l.refresh(), !n.moveSelection)
3903
+ return;
3904
+ const { type: s, index: o } = n.moveSelection;
3905
+ s === "row" ? (a = this.cellSelection) == null || a.selectRow(o) : (c = this.cellSelection) == null || c.selectColumn(o), (d = this.rowColControls) == null || d.setActiveGrip(s, o);
3757
3906
  }
3758
3907
  initResize(t) {
3759
3908
  var s, o;
3760
3909
  (s = this.resize) == null || s.destroy();
3761
- const e = this.data.colWidths === void 0, n = (o = this.data.colWidths) != null ? o : lt(t);
3762
- e || zt(this.element), this.resize = new Os(
3910
+ const e = this.data.colWidths === void 0, n = (o = this.data.colWidths) != null ? o : U(t);
3911
+ e || qt(this.element), this.resize = new Gs(
3763
3912
  t,
3764
3913
  n,
3765
3914
  (r) => {
3766
3915
  var l;
3767
- this.data.colWidths = r, zt(this.element), (l = this.rowColControls) == null || l.positionGrips();
3916
+ this.data.colWidths = r, qt(this.element), (l = this.rowColControls) == null || l.positionGrips();
3768
3917
  },
3769
3918
  () => {
3770
3919
  var r;
@@ -3779,7 +3928,7 @@ class co {
3779
3928
  }
3780
3929
  initCellBlocks(t) {
3781
3930
  var e;
3782
- this.cellBlocks = new gs({
3931
+ this.cellBlocks = new fs({
3783
3932
  api: this.api,
3784
3933
  gridElement: t,
3785
3934
  tableBlockId: (e = this.blockId) != null ? e : ""
@@ -3789,10 +3938,11 @@ class co {
3789
3938
  var n;
3790
3939
  (n = this.cellSelection) == null || n.destroy();
3791
3940
  const e = this.api.rectangleSelection;
3792
- this.cellSelection = new As({
3941
+ this.cellSelection = new Es({
3793
3942
  grid: t,
3794
3943
  rectangleSelection: e,
3795
3944
  // Pass reference
3945
+ i18n: this.api.i18n,
3796
3946
  onSelectionActiveChange: (s) => {
3797
3947
  var o, r;
3798
3948
  this.resize && (this.resize.enabled = !s), (o = this.addControls) == null || o.setInteractive(!s), (r = this.rowColControls) == null || r.setGripsDisplay(!s);
@@ -3806,10 +3956,10 @@ class co {
3806
3956
  });
3807
3957
  }
3808
3958
  }
3809
- const z = (i) => {
3959
+ const q = (i) => {
3810
3960
  const t = i.tagName;
3811
3961
  return t === "B" || t === "STRONG";
3812
- }, ct = (i) => !!(i && i.nodeType === Node.ELEMENT_NODE && z(i)), be = (i) => i.textContent.length === 0, M = (i) => i ? i.nodeType === Node.ELEMENT_NODE && z(i) ? G(i) : M(i.parentNode) : null, G = (i) => {
3962
+ }, ut = (i) => !!(i && i.nodeType === Node.ELEMENT_NODE && q(i)), be = (i) => i.textContent.length === 0, D = (i) => i ? i.nodeType === Node.ELEMENT_NODE && q(i) ? _(i) : D(i.parentNode) : null, _ = (i) => {
3813
3963
  if (i.tagName === "STRONG")
3814
3964
  return i;
3815
3965
  const t = document.createElement("strong");
@@ -3818,7 +3968,7 @@ const z = (i) => {
3818
3968
  }); i.firstChild; )
3819
3969
  t.appendChild(i.firstChild);
3820
3970
  return i.replaceWith(t), t;
3821
- }, no = (i) => {
3971
+ }, go = (i) => {
3822
3972
  const t = i.nextSibling;
3823
3973
  if ((t == null ? void 0 : t.nodeType) === Node.TEXT_NODE)
3824
3974
  return t;
@@ -3827,20 +3977,20 @@ const z = (i) => {
3827
3977
  return null;
3828
3978
  const n = i.ownerDocument.createTextNode("");
3829
3979
  return e.insertBefore(n, t), n;
3830
- }, so = (i) => {
3980
+ }, fo = (i) => {
3831
3981
  if (!i.boldElement.isConnected)
3832
3982
  return null;
3833
- const t = G(i.boldElement), e = i.boundary, s = e.isConnected && e.previousSibling === t ? e : no(t);
3983
+ const t = _(i.boldElement), e = i.boundary, s = e.isConnected && e.previousSibling === t ? e : go(t);
3834
3984
  return s ? {
3835
3985
  boundary: s,
3836
3986
  boldElement: t
3837
3987
  } : null;
3838
- }, vt = (i, t) => i ? i === t || t.contains(i) : !1, S = {
3988
+ }, wt = (i, t) => i ? i === t || t.contains(i) : !1, S = {
3839
3989
  COLLAPSED_LENGTH: "data-blok-bold-collapsed-length",
3840
3990
  COLLAPSED_ACTIVE: "data-blok-bold-collapsed-active",
3841
3991
  PREV_LENGTH: "data-blok-bold-prev-length",
3842
3992
  LEADING_WHITESPACE: "data-blok-bold-leading-ws"
3843
- }, R = class R {
3993
+ }, L = class L {
3844
3994
  constructor() {
3845
3995
  this.records = /* @__PURE__ */ new Set();
3846
3996
  }
@@ -3848,13 +3998,13 @@ const z = (i) => {
3848
3998
  * Get the singleton instance
3849
3999
  */
3850
4000
  static getInstance() {
3851
- return R.instance || (R.instance = new R()), R.instance;
4001
+ return L.instance || (L.instance = new L()), L.instance;
3852
4002
  }
3853
4003
  /**
3854
4004
  * Reset the singleton instance (for testing)
3855
4005
  */
3856
4006
  static reset() {
3857
- R.instance && R.instance.records.clear(), R.instance = null;
4007
+ L.instance && L.instance.records.clear(), L.instance = null;
3858
4008
  }
3859
4009
  /**
3860
4010
  * Check if there are any active exit records
@@ -3923,7 +4073,7 @@ const z = (i) => {
3923
4073
  * @param boldElement - The bold element to exit from
3924
4074
  */
3925
4075
  exit(t, e) {
3926
- const n = G(e), s = n.parentNode;
4076
+ const n = _(e), s = n.parentNode;
3927
4077
  if (s)
3928
4078
  return be(n) ? this.removeEmptyBoldElement(t, n, s) : this.exitBoldWithContent(t, n, s);
3929
4079
  }
@@ -3953,7 +4103,7 @@ const z = (i) => {
3953
4103
  maintain() {
3954
4104
  if (typeof document != "undefined")
3955
4105
  for (const t of Array.from(this.records)) {
3956
- const e = so(t);
4106
+ const e = fo(t);
3957
4107
  if (!e) {
3958
4108
  this.records.delete(t);
3959
4109
  continue;
@@ -3990,33 +4140,33 @@ const z = (i) => {
3990
4140
  */
3991
4141
  synchronize(t) {
3992
4142
  var r, l;
3993
- const e = (r = t == null ? void 0 : t.anchorNode) != null ? r : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = (l = n == null ? void 0 : n.closest(O(E.editor))) != null ? l : n == null ? void 0 : n.ownerDocument;
4143
+ const e = (r = t == null ? void 0 : t.anchorNode) != null ? r : t == null ? void 0 : t.focusNode, n = e && e.nodeType === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = (l = n == null ? void 0 : n.closest(H(E.editor))) != null ? l : n == null ? void 0 : n.ownerDocument;
3994
4144
  if (!s)
3995
4145
  return;
3996
4146
  const o = `strong[${S.COLLAPSED_ACTIVE}="true"]`;
3997
4147
  s.querySelectorAll(o).forEach((a) => {
3998
- var At;
4148
+ var kt;
3999
4149
  const c = a.getAttribute(S.PREV_LENGTH), d = a.previousSibling;
4000
4150
  if (!c || !d || d.nodeType !== Node.TEXT_NODE)
4001
4151
  return;
4002
4152
  const h = Number(c);
4003
4153
  if (!Number.isFinite(h))
4004
4154
  return;
4005
- const p = d, m = p.textContent;
4006
- if (m.length <= h)
4155
+ const p = d, f = p.textContent;
4156
+ if (f.length <= h)
4007
4157
  return;
4008
- const f = m.slice(0, h), y = m.slice(h);
4009
- p.textContent = f;
4010
- const b = y.match(/^[\u00A0\s]+/);
4011
- if (b && !a.hasAttribute(S.LEADING_WHITESPACE) && a.setAttribute(S.LEADING_WHITESPACE, b[0]), y.length === 0)
4158
+ const m = f.slice(0, h), C = f.slice(h);
4159
+ p.textContent = m;
4160
+ const b = C.match(/^[\u00A0\s]+/);
4161
+ if (b && !a.hasAttribute(S.LEADING_WHITESPACE) && a.setAttribute(S.LEADING_WHITESPACE, b[0]), C.length === 0)
4012
4162
  return;
4013
- const I = a.textContent, D = I + y, N = (At = a.getAttribute(S.LEADING_WHITESPACE)) != null ? At : "", T = N.length > 0 && I.length === 0 && !D.startsWith(N) ? N + D : D, _ = document.createTextNode(T);
4163
+ const B = a.textContent, I = B + C, N = (kt = a.getAttribute(S.LEADING_WHITESPACE)) != null ? kt : "", W = N.length > 0 && B.length === 0 && !I.startsWith(N) ? N + I : I, $ = document.createTextNode(W);
4014
4164
  for (; a.firstChild; )
4015
4165
  a.removeChild(a.firstChild);
4016
- if (a.appendChild(_), !(t != null && t.isCollapsed) || !vt(t.focusNode, p))
4166
+ if (a.appendChild($), !(t != null && t.isCollapsed) || !wt(t.focusNode, p))
4017
4167
  return;
4018
- const H = document.createRange(), J = _.textContent.length;
4019
- H.setStart(_, J), H.collapse(!0), t.removeAllRanges(), t.addRange(H);
4168
+ const J = document.createRange(), Ee = $.textContent.length;
4169
+ J.setStart($, Ee), J.collapse(!0), t.removeAllRanges(), t.addRange(J);
4020
4170
  });
4021
4171
  }
4022
4172
  /**
@@ -4028,27 +4178,27 @@ const z = (i) => {
4028
4178
  const e = (r = t == null ? void 0 : t.anchorNode) != null ? r : t == null ? void 0 : t.focusNode;
4029
4179
  if (!e)
4030
4180
  return;
4031
- const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, s = n == null ? void 0 : n.closest(O(E.editor));
4181
+ const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement, s = n == null ? void 0 : n.closest(H(E.editor));
4032
4182
  if (!s)
4033
4183
  return;
4034
4184
  s.querySelectorAll(`strong[${S.COLLAPSED_LENGTH}]`).forEach((l) => {
4035
- var N, P;
4185
+ var N, M;
4036
4186
  const a = l.getAttribute(S.COLLAPSED_LENGTH);
4037
4187
  if (!a)
4038
4188
  return;
4039
4189
  const c = Number(a), d = l.textContent;
4040
4190
  if (!Number.isFinite(c))
4041
4191
  return;
4042
- const h = d.length > c, p = h ? this.splitCollapsedBoldText(l, c, d) : null, m = l.getAttribute(S.PREV_LENGTH), f = m ? Number(m) : NaN, y = l.previousSibling, b = (y == null ? void 0 : y.nodeType) === Node.TEXT_NODE ? y : null, I = (N = b == null ? void 0 : b.textContent) != null ? N : "", D = !!(m && Number.isFinite(f) && b && I.length > f);
4043
- if (D && b) {
4044
- const T = I.slice(0, f), _ = I.slice(f);
4045
- b.textContent = T;
4046
- const H = document.createTextNode(_);
4047
- (P = l.parentNode) == null || P.insertBefore(H, l.nextSibling);
4192
+ const h = d.length > c, p = h ? this.splitCollapsedBoldText(l, c, d) : null, f = l.getAttribute(S.PREV_LENGTH), m = f ? Number(f) : NaN, C = l.previousSibling, b = (C == null ? void 0 : C.nodeType) === Node.TEXT_NODE ? C : null, B = (N = b == null ? void 0 : b.textContent) != null ? N : "", I = !!(f && Number.isFinite(m) && b && B.length > m);
4193
+ if (I && b) {
4194
+ const W = B.slice(0, m), $ = B.slice(m);
4195
+ b.textContent = W;
4196
+ const J = document.createTextNode($);
4197
+ (M = l.parentNode) == null || M.insertBefore(J, l.nextSibling);
4048
4198
  }
4049
- if (D && l.removeAttribute(S.PREV_LENGTH), t != null && t.isCollapsed && p && vt(t.focusNode, l)) {
4050
- const T = document.createRange(), _ = p.textContent.length;
4051
- T.setStart(p, _), T.collapse(!0), t.removeAllRanges(), t.addRange(T);
4199
+ if (I && l.removeAttribute(S.PREV_LENGTH), t != null && t.isCollapsed && p && wt(t.focusNode, l)) {
4200
+ const W = document.createRange(), $ = p.textContent.length;
4201
+ W.setStart(p, $), W.collapse(!0), t.removeAllRanges(), t.addRange(W);
4052
4202
  }
4053
4203
  h && l.removeAttribute(S.COLLAPSED_LENGTH);
4054
4204
  });
@@ -4108,7 +4258,7 @@ const z = (i) => {
4108
4258
  const e = t.getRangeAt(0);
4109
4259
  if (!e.collapsed)
4110
4260
  return;
4111
- const n = M(e.startContainer);
4261
+ const n = D(e.startContainer);
4112
4262
  (n == null ? void 0 : n.getAttribute(S.COLLAPSED_ACTIVE)) !== "true" && (this.moveCaretFromElementContainer(t, e) || this.moveCaretFromTextContainer(t, e));
4113
4263
  }
4114
4264
  /**
@@ -4167,7 +4317,7 @@ const z = (i) => {
4167
4317
  this.setCaret(t, n, o.length);
4168
4318
  return;
4169
4319
  }
4170
- const l = M(n);
4320
+ const l = D(n);
4171
4321
  if (!l || e.startOffset !== n.textContent.length)
4172
4322
  return;
4173
4323
  const a = this.ensureFollowingTextNode(l, l.nextSibling);
@@ -4213,22 +4363,22 @@ const z = (i) => {
4213
4363
  return e.tagName === "STRONG" || e.tagName === "B";
4214
4364
  }
4215
4365
  };
4216
- R.instance = null;
4217
- let A = R;
4218
- const oo = {
4366
+ L.instance = null;
4367
+ let A = L;
4368
+ const mo = {
4219
4369
  convertLegacyTags: !0,
4220
4370
  normalizeWhitespace: !0,
4221
4371
  removeEmpty: !0,
4222
4372
  mergeAdjacent: !0,
4223
4373
  preserveNode: null
4224
4374
  };
4225
- class x {
4375
+ class R {
4226
4376
  /**
4227
4377
  * Create a new normalization pass with specified options
4228
4378
  * @param options - Configuration for the normalization pass
4229
4379
  */
4230
4380
  constructor(t) {
4231
- this.options = L(L({}, oo), t);
4381
+ this.options = x(x({}, mo), t);
4232
4382
  }
4233
4383
  /**
4234
4384
  * Run normalization on a scoped element
@@ -4246,10 +4396,10 @@ class x {
4246
4396
  * @param options - Optional normalization configuration
4247
4397
  */
4248
4398
  static normalizeAroundSelection(t, e) {
4249
- const n = x.findScopeFromSelection(t);
4399
+ const n = R.findScopeFromSelection(t);
4250
4400
  if (!n)
4251
4401
  return;
4252
- new x(e).run(n);
4402
+ new R(e).run(n);
4253
4403
  }
4254
4404
  /**
4255
4405
  * Phase 1: Traverse the scope and normalize text nodes while collecting elements
@@ -4294,7 +4444,7 @@ class x {
4294
4444
  processCollectedElements(t, e) {
4295
4445
  this.options.convertLegacyTags && t.forEach((n) => {
4296
4446
  if (n.isConnected) {
4297
- const s = G(n);
4447
+ const s = _(n);
4298
4448
  e.push(s);
4299
4449
  }
4300
4450
  }), e.forEach((n) => {
@@ -4324,7 +4474,7 @@ class x {
4324
4474
  * @returns true if the element is empty and doesn't contain the preserved node
4325
4475
  */
4326
4476
  isEmptyAndSafe(t) {
4327
- return !(t.textContent.length === 0) || A.getInstance().isActivePlaceholder(t) ? !1 : !(this.options.preserveNode && vt(this.options.preserveNode, t));
4477
+ return !(t.textContent.length === 0) || A.getInstance().isActivePlaceholder(t) ? !1 : !(this.options.preserveNode && wt(this.options.preserveNode, t));
4328
4478
  }
4329
4479
  /**
4330
4480
  * Merge a <strong> element with adjacent <strong> siblings
@@ -4332,12 +4482,12 @@ class x {
4332
4482
  */
4333
4483
  mergeWithAdjacent(t) {
4334
4484
  const e = t.previousSibling;
4335
- if (e && ct(e)) {
4485
+ if (e && ut(e)) {
4336
4486
  this.mergeStrongNodes(e, t);
4337
4487
  return;
4338
4488
  }
4339
4489
  const n = t.nextSibling;
4340
- n && ct(n) && this.mergeStrongNodes(t, n);
4490
+ n && ut(n) && this.mergeStrongNodes(t, n);
4341
4491
  }
4342
4492
  /**
4343
4493
  * Merge two <strong> elements by moving children from right to left
@@ -4345,7 +4495,7 @@ class x {
4345
4495
  * @param right - The right strong element to merge from
4346
4496
  */
4347
4497
  mergeStrongNodes(t, e) {
4348
- const n = G(t), s = G(e);
4498
+ const n = _(t), s = _(e);
4349
4499
  for (; s.firstChild; )
4350
4500
  n.appendChild(s.firstChild);
4351
4501
  s.remove();
@@ -4363,11 +4513,11 @@ class x {
4363
4513
  const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
4364
4514
  if (!n)
4365
4515
  return null;
4366
- const s = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(O(E.elementContent));
4367
- return s || n.closest(O(E.editor));
4516
+ const s = (l = n.closest('[data-blok-component="paragraph"]')) != null ? l : n.closest(H(E.elementContent));
4517
+ return s || n.closest(H(E.editor));
4368
4518
  }
4369
4519
  }
4370
- const k = class k {
4520
+ const T = class T {
4371
4521
  constructor() {
4372
4522
  this.handlers = /* @__PURE__ */ new Map(), this.listenersRegistered = !1, this.handleSelectionChange = () => {
4373
4523
  const t = this.getSelection();
@@ -4400,13 +4550,13 @@ const k = class k {
4400
4550
  * Get the singleton instance
4401
4551
  */
4402
4552
  static getInstance() {
4403
- return k.instance || (k.instance = new k()), k.instance;
4553
+ return T.instance || (T.instance = new T()), T.instance;
4404
4554
  }
4405
4555
  /**
4406
4556
  * Reset the singleton instance (for testing)
4407
4557
  */
4408
4558
  static reset() {
4409
- k.instance && (k.instance.removeListeners(), k.instance.handlers.clear()), k.instance = null;
4559
+ T.instance && (T.instance.removeListeners(), T.instance.handlers.clear()), T.instance = null;
4410
4560
  }
4411
4561
  /**
4412
4562
  * Register a handler for an inline tool
@@ -4458,9 +4608,9 @@ const k = class k {
4458
4608
  return !(e.meta && !o || e.ctrl && !t.ctrlKey);
4459
4609
  }
4460
4610
  };
4461
- k.instance = null;
4462
- let St = k;
4463
- const io = (i, t) => {
4611
+ T.instance = null;
4612
+ let At = T;
4613
+ const Co = (i, t) => {
4464
4614
  try {
4465
4615
  return i.intersectsNode(t);
4466
4616
  } catch (e) {
@@ -4473,7 +4623,7 @@ const io = (i, t) => {
4473
4623
  i.commonAncestorContainer,
4474
4624
  NodeFilter.SHOW_TEXT,
4475
4625
  {
4476
- acceptNode: (t) => io(i, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
4626
+ acceptNode: (t) => Co(i, t) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
4477
4627
  }
4478
4628
  ), Z = (i, t) => i ? i.nodeType === Node.ELEMENT_NODE && t(i) ? i : Z(i.parentNode, t) : null, Se = (i, t) => Z(i, t) !== null, we = (i, t, e = {}) => {
4479
4629
  if (i.collapsed)
@@ -4491,7 +4641,7 @@ const io = (i, t) => {
4491
4641
  s && e.add(s);
4492
4642
  }
4493
4643
  return Array.from(e);
4494
- }, C = class C {
4644
+ }, y = class y {
4495
4645
  /**
4496
4646
  * Sanitizer Rule
4497
4647
  * Leave <strong> tags
@@ -4507,7 +4657,7 @@ const io = (i, t) => {
4507
4657
  *
4508
4658
  */
4509
4659
  constructor() {
4510
- typeof document != "undefined" && (C.instances.add(this), C.initializeGlobalListeners());
4660
+ typeof document != "undefined" && (y.instances.add(this), y.initializeGlobalListeners());
4511
4661
  }
4512
4662
  /**
4513
4663
  * Ensure global event listeners are registered once per document
@@ -4515,24 +4665,24 @@ const io = (i, t) => {
4515
4665
  static initializeGlobalListeners() {
4516
4666
  if (typeof document == "undefined")
4517
4667
  return !1;
4518
- const t = St.getInstance();
4668
+ const t = At.getInstance();
4519
4669
  return t.hasHandler("bold") || (t.register("bold", {
4520
4670
  shortcut: { key: "b", meta: !0 },
4521
4671
  onShortcut: (e, n) => {
4522
- const s = C.instances.values().next().value;
4672
+ const s = y.instances.values().next().value;
4523
4673
  s && s.toggleBold();
4524
4674
  },
4525
4675
  onSelectionChange: (e) => {
4526
- C.refreshSelectionState("selectionchange");
4676
+ y.refreshSelectionState("selectionchange");
4527
4677
  },
4528
4678
  onInput: (e, n) => {
4529
- C.refreshSelectionState("input");
4679
+ y.refreshSelectionState("input");
4530
4680
  },
4531
- onBeforeInput: (e) => e.inputType !== "formatBold" ? !1 : (x.normalizeAroundSelection(window.getSelection()), !0),
4532
- isRelevant: (e) => C.isSelectionInsideBlok(e)
4533
- }), C.guardKeydownListenerRegistered || (document.addEventListener("keydown", (e) => {
4681
+ onBeforeInput: (e) => e.inputType !== "formatBold" ? !1 : (R.normalizeAroundSelection(window.getSelection()), !0),
4682
+ isRelevant: (e) => y.isSelectionInsideBlok(e)
4683
+ }), y.guardKeydownListenerRegistered || (document.addEventListener("keydown", (e) => {
4534
4684
  A.getInstance().guardBoundaryKeydown(e);
4535
- }, !0), C.guardKeydownListenerRegistered = !0), C.ensureMutationObserver()), !0;
4685
+ }, !0), y.guardKeydownListenerRegistered = !0), y.ensureMutationObserver()), !0;
4536
4686
  }
4537
4687
  /**
4538
4688
  * Merge two strong elements by moving children from right to left
@@ -4540,7 +4690,7 @@ const io = (i, t) => {
4540
4690
  * @param right - The right strong element to merge from
4541
4691
  */
4542
4692
  static mergeStrongNodes(t, e) {
4543
- const n = G(t), s = G(e);
4693
+ const n = _(t), s = _(e);
4544
4694
  for (; s.firstChild; )
4545
4695
  n.appendChild(s.firstChild);
4546
4696
  return s.remove(), n;
@@ -4550,7 +4700,7 @@ const io = (i, t) => {
4550
4700
  */
4551
4701
  render() {
4552
4702
  return {
4553
- icon: je,
4703
+ icon: Xe,
4554
4704
  name: "bold",
4555
4705
  onActivate: () => {
4556
4706
  this.toggleBold();
@@ -4594,11 +4744,11 @@ const io = (i, t) => {
4594
4744
  s && n && (s.removeAllRanges(), s.addRange(n));
4595
4745
  const o = this.findBoldElementFromRangeOrSelection(n, s);
4596
4746
  if (!o) {
4597
- x.normalizeAroundSelection(s), this.notifySelectionChange();
4747
+ R.normalizeAroundSelection(s), this.notifySelectionChange();
4598
4748
  return;
4599
4749
  }
4600
4750
  const r = this.mergeAdjacentBold(o);
4601
- this.selectElementContents(r), x.normalizeAroundSelection(s), this.notifySelectionChange();
4751
+ this.selectElementContents(r), R.normalizeAroundSelection(s), this.notifySelectionChange();
4602
4752
  }
4603
4753
  /**
4604
4754
  * Remove bold tags (<strong>) while preserving content
@@ -4609,10 +4759,10 @@ const io = (i, t) => {
4609
4759
  if (!n)
4610
4760
  return;
4611
4761
  const s = document.createElement("span"), o = t.extractContents();
4612
- s.setAttribute("data-blok-bold-marker", `unwrap-${C.markerSequence++}`), s.appendChild(o), this.removeNestedBold(s), t.insertNode(s);
4762
+ s.setAttribute("data-blok-bold-marker", `unwrap-${y.markerSequence++}`), s.appendChild(o), this.removeNestedBold(s), t.insertNode(s);
4613
4763
  const r = document.createRange();
4614
4764
  for (r.selectNodeContents(s), n.removeAllRanges(), n.addRange(r); ; ) {
4615
- const d = M(s);
4765
+ const d = D(s);
4616
4766
  if (!d)
4617
4767
  break;
4618
4768
  this.moveMarkerOutOfBold(s, d);
@@ -4621,7 +4771,7 @@ const io = (i, t) => {
4621
4771
  this.unwrapElement(s), (l && a ? (() => {
4622
4772
  const d = document.createRange();
4623
4773
  return d.setStartBefore(l), d.setEndAfter(a), n.removeAllRanges(), n.addRange(d), d;
4624
- })() : void 0) || n.removeAllRanges(), x.normalizeAroundSelection(n), e.forEach((d) => {
4774
+ })() : void 0) || n.removeAllRanges(), R.normalizeAroundSelection(n), e.forEach((d) => {
4625
4775
  be(d) && d.remove();
4626
4776
  }), this.notifySelectionChange();
4627
4777
  }
@@ -4633,7 +4783,7 @@ const io = (i, t) => {
4633
4783
  */
4634
4784
  replaceRangeWithHtml(t, e) {
4635
4785
  var l, a;
4636
- const n = C.createFragmentFromHtml(e), s = (l = n.firstChild) != null ? l : null, o = (a = n.lastChild) != null ? a : null;
4786
+ const n = y.createFragmentFromHtml(e), s = (l = n.firstChild) != null ? l : null, o = (a = n.lastChild) != null ? a : null;
4637
4787
  if (t.deleteContents(), !s || !o)
4638
4788
  return;
4639
4789
  t.insertNode(n);
@@ -4687,7 +4837,7 @@ const io = (i, t) => {
4687
4837
  * @param options.ignoreWhitespace - Whether to ignore whitespace-only text nodes
4688
4838
  */
4689
4839
  isRangeBold(t, e) {
4690
- return we(t, z, e);
4840
+ return we(t, q, e);
4691
4841
  }
4692
4842
  /**
4693
4843
  * Remove nested bold tags from a root node
@@ -4719,20 +4869,20 @@ const io = (i, t) => {
4719
4869
  */
4720
4870
  findBoldElementFromRangeOrSelection(t, e) {
4721
4871
  if (!t)
4722
- return e ? M(e.focusNode) : null;
4723
- const n = M(t.startContainer);
4872
+ return e ? D(e.focusNode) : null;
4873
+ const n = D(t.startContainer);
4724
4874
  if (n)
4725
4875
  return n;
4726
- const s = M(t.commonAncestorContainer);
4727
- return s || (t.startContainer.nodeType === Node.ELEMENT_NODE && z(t.startContainer) ? t.startContainer : null);
4876
+ const s = D(t.commonAncestorContainer);
4877
+ return s || (t.startContainer.nodeType === Node.ELEMENT_NODE && q(t.startContainer) ? t.startContainer : null);
4728
4878
  }
4729
4879
  /**
4730
4880
  * Merge adjacent bold elements into a single element
4731
4881
  * @param element - The bold element to merge with adjacent elements
4732
4882
  */
4733
4883
  mergeAdjacentBold(t) {
4734
- const e = G(t), n = e.previousSibling, s = n && n.nodeType === Node.ELEMENT_NODE && z(n) ? C.mergeStrongNodes(n, e) : e, o = s.nextSibling;
4735
- return o && o.nodeType === Node.ELEMENT_NODE && z(o) ? C.mergeStrongNodes(s, o) : s;
4884
+ const e = _(t), n = e.previousSibling, s = n && n.nodeType === Node.ELEMENT_NODE && q(n) ? y.mergeStrongNodes(n, e) : e, o = s.nextSibling;
4885
+ return o && o.nodeType === Node.ELEMENT_NODE && q(o) ? y.mergeStrongNodes(s, o) : s;
4736
4886
  }
4737
4887
  /**
4738
4888
  * Toggle bold formatting for a collapsed selection (caret position)
@@ -4742,13 +4892,13 @@ const io = (i, t) => {
4742
4892
  const t = window.getSelection();
4743
4893
  if (!t || t.rangeCount === 0)
4744
4894
  return;
4745
- const e = t.getRangeAt(0), n = M(e.startContainer), s = (() => {
4895
+ const e = t.getRangeAt(0), n = D(e.startContainer), s = (() => {
4746
4896
  if (n && n.getAttribute(A.ATTR.COLLAPSED_ACTIVE) !== "true")
4747
4897
  return A.getInstance().exit(t, n);
4748
- const o = n != null ? n : C.getBoundaryBold(e);
4898
+ const o = n != null ? n : y.getBoundaryBold(e);
4749
4899
  return o ? A.getInstance().exit(t, o) : this.startCollapsedBold(e);
4750
4900
  })();
4751
- document.dispatchEvent(new Event("selectionchange")), s && (t.removeAllRanges(), t.addRange(s)), x.normalizeAroundSelection(t), this.notifySelectionChange();
4901
+ document.dispatchEvent(new Event("selectionchange")), s && (t.removeAllRanges(), t.addRange(s)), R.normalizeAroundSelection(t), this.notifySelectionChange();
4752
4902
  }
4753
4903
  /**
4754
4904
  * Insert a bold wrapper at the caret so newly typed text becomes bold
@@ -4756,7 +4906,7 @@ const io = (i, t) => {
4756
4906
  */
4757
4907
  startCollapsedBold(t) {
4758
4908
  const n = A.getInstance().enter(t, (o) => this.mergeAdjacentBold(o)), s = window.getSelection();
4759
- return x.normalizeAroundSelection(s), s && n && (s.removeAllRanges(), s.addRange(n)), this.notifySelectionChange(), n;
4909
+ return R.normalizeAroundSelection(s), s && n && (s.removeAllRanges(), s.addRange(n)), this.notifySelectionChange(), n;
4760
4910
  }
4761
4911
  /**
4762
4912
  * Notify listeners that the selection state has changed
@@ -4771,7 +4921,7 @@ const io = (i, t) => {
4771
4921
  const t = window.getSelection();
4772
4922
  if (!t)
4773
4923
  return;
4774
- const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = n == null ? void 0 : n.closest(O(E.editor));
4924
+ const e = t.anchorNode, n = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : e == null ? void 0 : e.parentElement, s = n == null ? void 0 : n.closest(H(E.editor));
4775
4925
  if (!s)
4776
4926
  return;
4777
4927
  const o = s.querySelector("[data-blok-testid=inline-toolbar]");
@@ -4788,28 +4938,28 @@ const io = (i, t) => {
4788
4938
  */
4789
4939
  static refreshSelectionState(t) {
4790
4940
  const e = window.getSelection();
4791
- A.getInstance().enforceLengths(e), A.getInstance().maintain(), A.getInstance().synchronize(e), x.normalizeAroundSelection(e, { normalizeWhitespace: !1 }), t === "input" && e && A.getInstance().moveCaretAfterBoundaryBold(e);
4941
+ A.getInstance().enforceLengths(e), A.getInstance().maintain(), A.getInstance().synchronize(e), R.normalizeAroundSelection(e, { normalizeWhitespace: !1 }), t === "input" && e && A.getInstance().moveCaretAfterBoundaryBold(e);
4792
4942
  }
4793
4943
  /**
4794
4944
  * Ensure mutation observer is registered to convert legacy <b> tags
4795
4945
  */
4796
4946
  static ensureMutationObserver() {
4797
- if (typeof MutationObserver == "undefined" || C.mutationObserver)
4947
+ if (typeof MutationObserver == "undefined" || y.mutationObserver)
4798
4948
  return;
4799
4949
  const t = new MutationObserver((e) => {
4800
- if (!C.isProcessingMutation) {
4801
- C.isProcessingMutation = !0;
4950
+ if (!y.isProcessingMutation) {
4951
+ y.isProcessingMutation = !0;
4802
4952
  try {
4803
4953
  const n = (s) => {
4804
- s && new x({ mergeAdjacent: !1, removeEmpty: !1, normalizeWhitespace: !1 }).run(s);
4954
+ s && new R({ mergeAdjacent: !1, removeEmpty: !1, normalizeWhitespace: !1 }).run(s);
4805
4955
  };
4806
4956
  e.forEach((s) => {
4807
4957
  s.addedNodes.forEach((o) => {
4808
- n(C.findBlokScopeFromNode(o));
4809
- }), s.type === "characterData" && n(C.findBlokScopeFromNode(s.target));
4958
+ n(y.findBlokScopeFromNode(o));
4959
+ }), s.type === "characterData" && n(y.findBlokScopeFromNode(s.target));
4810
4960
  });
4811
4961
  } finally {
4812
- C.isProcessingMutation = !1;
4962
+ y.isProcessingMutation = !1;
4813
4963
  }
4814
4964
  }
4815
4965
  });
@@ -4817,7 +4967,7 @@ const io = (i, t) => {
4817
4967
  subtree: !0,
4818
4968
  childList: !0,
4819
4969
  characterData: !0
4820
- }), C.mutationObserver = t;
4970
+ }), y.mutationObserver = t;
4821
4971
  }
4822
4972
  /**
4823
4973
  * Find the blok scope element from a node for normalization
@@ -4826,7 +4976,7 @@ const io = (i, t) => {
4826
4976
  */
4827
4977
  static findBlokScopeFromNode(t) {
4828
4978
  const e = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement;
4829
- return !e || typeof e.closest != "function" ? null : e.closest(`${O(E.interface)}, ${O(E.editor)}`);
4979
+ return !e || typeof e.closest != "function" ? null : e.closest(`${H(E.interface)}, ${H(E.editor)}`);
4830
4980
  }
4831
4981
  /**
4832
4982
  * Get a bold element at the boundary of a collapsed range
@@ -4834,7 +4984,7 @@ const io = (i, t) => {
4834
4984
  */
4835
4985
  static getBoundaryBold(t) {
4836
4986
  const e = t.startContainer;
4837
- return e.nodeType === Node.TEXT_NODE ? C.getBoundaryBoldForText(t, e) : e.nodeType === Node.ELEMENT_NODE ? C.getBoundaryBoldForElement(t, e) : null;
4987
+ return e.nodeType === Node.TEXT_NODE ? y.getBoundaryBoldForText(t, e) : e.nodeType === Node.ELEMENT_NODE ? y.getBoundaryBoldForElement(t, e) : null;
4838
4988
  }
4839
4989
  /**
4840
4990
  * Get boundary bold when caret resides inside a text node
@@ -4844,11 +4994,11 @@ const io = (i, t) => {
4844
4994
  static getBoundaryBoldForText(t, e) {
4845
4995
  const n = e.textContent.length;
4846
4996
  if (t.startOffset === n)
4847
- return M(e);
4997
+ return D(e);
4848
4998
  if (t.startOffset !== 0)
4849
4999
  return null;
4850
5000
  const s = e.previousSibling;
4851
- return ct(s) ? s : null;
5001
+ return ut(s) ? s : null;
4852
5002
  }
4853
5003
  /**
4854
5004
  * Get boundary bold when caret container is an element
@@ -4859,7 +5009,7 @@ const io = (i, t) => {
4859
5009
  if (t.startOffset <= 0)
4860
5010
  return null;
4861
5011
  const n = e.childNodes[t.startOffset - 1];
4862
- return ct(n) ? n : null;
5012
+ return ut(n) ? n : null;
4863
5013
  }
4864
5014
  /**
4865
5015
  * Check if a selection is inside the blok
@@ -4870,7 +5020,7 @@ const io = (i, t) => {
4870
5020
  if (!e)
4871
5021
  return !1;
4872
5022
  const n = e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement;
4873
- return !!(n != null && n.closest(O(E.editor)));
5023
+ return !!(n != null && n.closest(H(E.editor)));
4874
5024
  }
4875
5025
  /**
4876
5026
  * Get HTML content of a range with bold tags removed
@@ -4895,15 +5045,15 @@ const io = (i, t) => {
4895
5045
  * @param range - The range to search for bold ancestors
4896
5046
  */
4897
5047
  collectBoldAncestors(t) {
4898
- return Ae(t, z);
5048
+ return Ae(t, q);
4899
5049
  }
4900
5050
  };
4901
- C.isInline = !0, C.title = "Bold", C.titleKey = "bold", C.markerSequence = 0, C.isProcessingMutation = !1, C.instances = /* @__PURE__ */ new Set(), C.guardKeydownListenerRegistered = !1, C.shortcut = "CMD+B";
4902
- let Zt = C;
4903
- const rt = (i) => {
5051
+ y.isInline = !0, y.title = "Bold", y.titleKey = "bold", y.markerSequence = 0, y.isProcessingMutation = !1, y.instances = /* @__PURE__ */ new Set(), y.guardKeydownListenerRegistered = !1, y.shortcut = "CMD+B";
5052
+ let Yt = y;
5053
+ const at = (i) => {
4904
5054
  const t = i.tagName;
4905
5055
  return t === "I" || t === "EM";
4906
- }, j = class j {
5056
+ }, K = class K {
4907
5057
  /**
4908
5058
  * Sanitizer Rule
4909
5059
  * Leave <i> and <em> tags
@@ -4920,7 +5070,7 @@ const rt = (i) => {
4920
5070
  */
4921
5071
  render() {
4922
5072
  return {
4923
- icon: Xe,
5073
+ icon: Ye,
4924
5074
  name: "italic",
4925
5075
  onActivate: () => {
4926
5076
  this.toggleItalic();
@@ -4979,7 +5129,7 @@ const rt = (i) => {
4979
5129
  * @param options - Options for checking italic status
4980
5130
  */
4981
5131
  isRangeItalic(t, e) {
4982
- return we(t, rt, e);
5132
+ return we(t, at, e);
4983
5133
  }
4984
5134
  /**
4985
5135
  * Wrap selection with <i> tag
@@ -5019,21 +5169,21 @@ const rt = (i) => {
5019
5169
  * @param node - The node to check
5020
5170
  */
5021
5171
  hasItalicParent(t) {
5022
- return Se(t, rt);
5172
+ return Se(t, at);
5023
5173
  }
5024
5174
  /**
5025
5175
  * Find an italic element in the parent chain
5026
5176
  * @param node - The node to start searching from
5027
5177
  */
5028
5178
  findItalicElement(t) {
5029
- return Z(t, rt);
5179
+ return Z(t, at);
5030
5180
  }
5031
5181
  /**
5032
5182
  * Collect all italic ancestor elements within a range
5033
5183
  * @param range - The range to search for italic ancestors
5034
5184
  */
5035
5185
  collectItalicAncestors(t) {
5036
- return Ae(t, rt);
5186
+ return Ae(t, at);
5037
5187
  }
5038
5188
  /**
5039
5189
  * Get HTML content of a range with italic tags removed
@@ -5120,9 +5270,9 @@ const rt = (i) => {
5120
5270
  n.insertBefore(l, e.nextSibling), n.insertBefore(t, l);
5121
5271
  }
5122
5272
  };
5123
- j.isInline = !0, j.title = "Italic", j.titleKey = "italic", j.shortcut = "CMD+I";
5124
- let Jt = j;
5125
- const X = class X {
5273
+ K.isInline = !0, K.title = "Italic", K.titleKey = "italic", K.shortcut = "CMD+I";
5274
+ let Zt = K;
5275
+ const j = class j {
5126
5276
  /**
5127
5277
  * @param api - Blok API
5128
5278
  */
@@ -5157,7 +5307,7 @@ const X = class X {
5157
5307
  */
5158
5308
  render() {
5159
5309
  return {
5160
- icon: Ye,
5310
+ icon: Ze,
5161
5311
  name: "link",
5162
5312
  isActive: () => !!this.selection.findParentTag("A"),
5163
5313
  children: {
@@ -5216,7 +5366,7 @@ const X = class X {
5216
5366
  */
5217
5367
  getButtonElement() {
5218
5368
  const t = document.querySelector(
5219
- `${O(E.interface, Je)} [data-blok-item-name="link"]`
5369
+ `${H(E.interface, Qe)} [data-blok-item-name="link"]`
5220
5370
  );
5221
5371
  return t && t !== this.nodes.button && (t.addEventListener("click", this.handleButtonClick, !0), this.nodes.button = t), t;
5222
5372
  }
@@ -5273,7 +5423,7 @@ const X = class X {
5273
5423
  this.notifier.show({
5274
5424
  message: this.i18n.t("tools.link.invalidLink"),
5275
5425
  style: "error"
5276
- }), Ze("Incorrect Link pasted", "warn", e);
5426
+ }), Je("Incorrect Link pasted", "warn", e);
5277
5427
  return;
5278
5428
  }
5279
5429
  const n = this.prepareLink(e);
@@ -5350,27 +5500,27 @@ const X = class X {
5350
5500
  t && t.setAttribute(e, n ? "true" : "false");
5351
5501
  }
5352
5502
  };
5353
- X.isInline = !0, X.title = "Link", X.titleKey = "link", X.shortcut = "CMD+K";
5354
- let Qt = X;
5355
- const ho = {
5503
+ j.isInline = !0, j.title = "Link", j.titleKey = "link", j.shortcut = "CMD+K";
5504
+ let Jt = j;
5505
+ const wo = {
5356
5506
  paragraph: { preserveBlank: !0 },
5357
5507
  header: {},
5358
5508
  list: {},
5359
5509
  table: {}
5360
- }, uo = {
5510
+ }, Ao = {
5361
5511
  bold: {},
5362
5512
  italic: {},
5363
5513
  link: {}
5364
5514
  };
5365
5515
  export {
5366
- Zt as Bold,
5367
- fo as Convert,
5368
- Bt as Header,
5369
- Jt as Italic,
5370
- Qt as Link,
5371
- ao as List,
5372
- Rt as Paragraph,
5373
- co as Table,
5374
- ho as defaultBlockTools,
5375
- uo as defaultInlineTools
5516
+ Yt as Bold,
5517
+ xo as Convert,
5518
+ It as Header,
5519
+ Zt as Italic,
5520
+ Jt as Link,
5521
+ vo as List,
5522
+ Bt as Paragraph,
5523
+ So as Table,
5524
+ wo as defaultBlockTools,
5525
+ Ao as defaultInlineTools
5376
5526
  };