@jackuait/blok 0.4.1 → 0.4.2

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 (397) hide show
  1. package/README.md +136 -17
  2. package/codemod/README.md +16 -0
  3. package/codemod/migrate-editorjs-to-blok.js +859 -92
  4. package/codemod/test.js +682 -77
  5. package/dist/blok.mjs +5 -2
  6. package/dist/chunks/blok-BjgH1REI.mjs +12838 -0
  7. package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
  8. package/dist/chunks/i18next-loader-DfiUa_gd.mjs +43 -0
  9. package/dist/{index-CBkApZKo.mjs → chunks/index-5m5JWNey.mjs} +2 -2
  10. package/dist/chunks/inline-tool-convert-Bx5BVd8I.mjs +1988 -0
  11. package/dist/chunks/messages-2434tVOK.mjs +47 -0
  12. package/dist/chunks/messages-3DcCwXMF.mjs +47 -0
  13. package/dist/chunks/messages-4kMwVAKY.mjs +47 -0
  14. package/dist/chunks/messages-57uL5htT.mjs +47 -0
  15. package/dist/chunks/messages-76-iJV9Q.mjs +47 -0
  16. package/dist/chunks/messages-8p86Eyf2.mjs +47 -0
  17. package/dist/chunks/messages-BBX0p0Pi.mjs +47 -0
  18. package/dist/chunks/messages-BCm2eudQ.mjs +47 -0
  19. package/dist/chunks/messages-BFiUomgG.mjs +47 -0
  20. package/dist/chunks/messages-BIPNHHAV.mjs +47 -0
  21. package/dist/chunks/messages-BUlwu9mo.mjs +47 -0
  22. package/dist/chunks/messages-BX-DPa-z.mjs +47 -0
  23. package/dist/chunks/messages-BextV3Qh.mjs +47 -0
  24. package/dist/chunks/messages-BiPSFlUG.mjs +47 -0
  25. package/dist/chunks/messages-BiXe9G-O.mjs +47 -0
  26. package/dist/chunks/messages-Bl5z_Igo.mjs +47 -0
  27. package/dist/chunks/messages-BnsE97ku.mjs +47 -0
  28. package/dist/chunks/messages-BoO8gsVD.mjs +47 -0
  29. package/dist/chunks/messages-BqWaOGMn.mjs +47 -0
  30. package/dist/chunks/messages-BqkL2_Ro.mjs +47 -0
  31. package/dist/chunks/messages-BvCkXKX-.mjs +47 -0
  32. package/dist/chunks/messages-C6tbPLoj.mjs +47 -0
  33. package/dist/chunks/messages-CA6T3-gQ.mjs +47 -0
  34. package/dist/chunks/messages-CFFPFdWP.mjs +47 -0
  35. package/dist/chunks/messages-CFrKE-TN.mjs +47 -0
  36. package/dist/chunks/messages-CHz8VlG-.mjs +47 -0
  37. package/dist/chunks/messages-CLixzySl.mjs +47 -0
  38. package/dist/chunks/messages-CV7OM_qk.mjs +47 -0
  39. package/dist/chunks/messages-CXHt3eCC.mjs +47 -0
  40. package/dist/chunks/messages-CbmsBrB0.mjs +47 -0
  41. package/dist/chunks/messages-Ceo1KtFx.mjs +47 -0
  42. package/dist/chunks/messages-Cm0LJLtB.mjs +47 -0
  43. package/dist/chunks/messages-CmymP_Ar.mjs +47 -0
  44. package/dist/chunks/messages-D0ohMB5H.mjs +47 -0
  45. package/dist/chunks/messages-D3GrDwXh.mjs +47 -0
  46. package/dist/chunks/messages-D3vTzIpL.mjs +47 -0
  47. package/dist/chunks/messages-D5WeksbV.mjs +47 -0
  48. package/dist/chunks/messages-DGaab4EP.mjs +47 -0
  49. package/dist/chunks/messages-DKha57ZU.mjs +47 -0
  50. package/dist/chunks/messages-DOaujgMW.mjs +47 -0
  51. package/dist/chunks/messages-DVbPLd_0.mjs +47 -0
  52. package/dist/chunks/messages-D_FCyfW6.mjs +47 -0
  53. package/dist/chunks/messages-Dd5iZN3c.mjs +47 -0
  54. package/dist/chunks/messages-DehM7135.mjs +47 -0
  55. package/dist/chunks/messages-Dg1OHftD.mjs +47 -0
  56. package/dist/chunks/messages-Di6Flq-b.mjs +47 -0
  57. package/dist/chunks/messages-Dqhhex6e.mjs +47 -0
  58. package/dist/chunks/messages-DueVe0F1.mjs +47 -0
  59. package/dist/chunks/messages-Dx3eFwI0.mjs +47 -0
  60. package/dist/chunks/messages-FOtiUoKl.mjs +47 -0
  61. package/dist/chunks/messages-FTOZNhRD.mjs +47 -0
  62. package/dist/chunks/messages-IQxGfQIV.mjs +47 -0
  63. package/dist/chunks/messages-JF2fzCkK.mjs +47 -0
  64. package/dist/chunks/messages-MOGl7I5v.mjs +47 -0
  65. package/dist/chunks/messages-QgYhPL-3.mjs +47 -0
  66. package/dist/chunks/messages-WYWIbQwo.mjs +47 -0
  67. package/dist/chunks/messages-a6A_LgDv.mjs +47 -0
  68. package/dist/chunks/messages-bSf31LJi.mjs +47 -0
  69. package/dist/chunks/messages-diGozhTn.mjs +47 -0
  70. package/dist/chunks/messages-er-kd-VO.mjs +47 -0
  71. package/dist/chunks/messages-ez3w5NBn.mjs +47 -0
  72. package/dist/chunks/messages-f3uXjegd.mjs +47 -0
  73. package/dist/chunks/messages-ohwI1UGv.mjs +47 -0
  74. package/dist/chunks/messages-p9BZJaFV.mjs +47 -0
  75. package/dist/chunks/messages-qIQ4L4rw.mjs +47 -0
  76. package/dist/chunks/messages-qWkXPggi.mjs +47 -0
  77. package/dist/chunks/messages-w5foGze_.mjs +47 -0
  78. package/dist/full.mjs +50 -0
  79. package/dist/locales.mjs +227 -0
  80. package/dist/messages-2434tVOK.mjs +47 -0
  81. package/dist/messages-3DcCwXMF.mjs +47 -0
  82. package/dist/messages-4kMwVAKY.mjs +47 -0
  83. package/dist/messages-57uL5htT.mjs +47 -0
  84. package/dist/messages-76-iJV9Q.mjs +47 -0
  85. package/dist/messages-8p86Eyf2.mjs +47 -0
  86. package/dist/messages-BBX0p0Pi.mjs +47 -0
  87. package/dist/messages-BCm2eudQ.mjs +47 -0
  88. package/dist/messages-BFiUomgG.mjs +47 -0
  89. package/dist/messages-BIPNHHAV.mjs +47 -0
  90. package/dist/messages-BUlwu9mo.mjs +47 -0
  91. package/dist/messages-BX-DPa-z.mjs +47 -0
  92. package/dist/messages-BextV3Qh.mjs +47 -0
  93. package/dist/messages-BiPSFlUG.mjs +47 -0
  94. package/dist/messages-BiXe9G-O.mjs +47 -0
  95. package/dist/messages-Bl5z_Igo.mjs +47 -0
  96. package/dist/messages-BnsE97ku.mjs +47 -0
  97. package/dist/messages-BoO8gsVD.mjs +47 -0
  98. package/dist/messages-BqWaOGMn.mjs +47 -0
  99. package/dist/messages-BqkL2_Ro.mjs +47 -0
  100. package/dist/messages-BvCkXKX-.mjs +47 -0
  101. package/dist/messages-C6tbPLoj.mjs +47 -0
  102. package/dist/messages-CA6T3-gQ.mjs +47 -0
  103. package/dist/messages-CFFPFdWP.mjs +47 -0
  104. package/dist/messages-CFrKE-TN.mjs +47 -0
  105. package/dist/messages-CHz8VlG-.mjs +47 -0
  106. package/dist/messages-CLixzySl.mjs +47 -0
  107. package/dist/messages-CV7OM_qk.mjs +47 -0
  108. package/dist/messages-CXHt3eCC.mjs +47 -0
  109. package/dist/messages-CbmsBrB0.mjs +47 -0
  110. package/dist/messages-Ceo1KtFx.mjs +47 -0
  111. package/dist/messages-Cm0LJLtB.mjs +47 -0
  112. package/dist/messages-CmymP_Ar.mjs +47 -0
  113. package/dist/messages-D0ohMB5H.mjs +47 -0
  114. package/dist/messages-D3GrDwXh.mjs +47 -0
  115. package/dist/messages-D3vTzIpL.mjs +47 -0
  116. package/dist/messages-D5WeksbV.mjs +47 -0
  117. package/dist/messages-DGaab4EP.mjs +47 -0
  118. package/dist/messages-DKha57ZU.mjs +47 -0
  119. package/dist/messages-DOaujgMW.mjs +47 -0
  120. package/dist/messages-DVbPLd_0.mjs +47 -0
  121. package/dist/messages-D_FCyfW6.mjs +47 -0
  122. package/dist/messages-Dd5iZN3c.mjs +47 -0
  123. package/dist/messages-DehM7135.mjs +47 -0
  124. package/dist/messages-Dg1OHftD.mjs +47 -0
  125. package/dist/messages-Di6Flq-b.mjs +47 -0
  126. package/dist/messages-Dqhhex6e.mjs +47 -0
  127. package/dist/messages-DueVe0F1.mjs +47 -0
  128. package/dist/messages-Dx3eFwI0.mjs +47 -0
  129. package/dist/messages-FOtiUoKl.mjs +47 -0
  130. package/dist/messages-FTOZNhRD.mjs +47 -0
  131. package/dist/messages-IQxGfQIV.mjs +47 -0
  132. package/dist/messages-JF2fzCkK.mjs +47 -0
  133. package/dist/messages-MOGl7I5v.mjs +47 -0
  134. package/dist/messages-QgYhPL-3.mjs +47 -0
  135. package/dist/messages-WYWIbQwo.mjs +47 -0
  136. package/dist/messages-a6A_LgDv.mjs +47 -0
  137. package/dist/messages-bSf31LJi.mjs +47 -0
  138. package/dist/messages-diGozhTn.mjs +47 -0
  139. package/dist/messages-er-kd-VO.mjs +47 -0
  140. package/dist/messages-ez3w5NBn.mjs +47 -0
  141. package/dist/messages-f3uXjegd.mjs +47 -0
  142. package/dist/messages-ohwI1UGv.mjs +47 -0
  143. package/dist/messages-p9BZJaFV.mjs +47 -0
  144. package/dist/messages-qIQ4L4rw.mjs +47 -0
  145. package/dist/messages-qWkXPggi.mjs +47 -0
  146. package/dist/messages-w5foGze_.mjs +47 -0
  147. package/dist/tools.mjs +3073 -0
  148. package/dist/vendor.LICENSE.txt +59 -156
  149. package/package.json +47 -15
  150. package/src/blok.ts +267 -0
  151. package/src/components/__module.ts +139 -0
  152. package/src/components/block/api.ts +155 -0
  153. package/src/components/block/index.ts +1427 -0
  154. package/src/components/block-tunes/block-tune-delete.ts +51 -0
  155. package/src/components/blocks.ts +338 -0
  156. package/src/components/constants/data-attributes.ts +342 -0
  157. package/src/components/constants.ts +76 -0
  158. package/src/components/core.ts +392 -0
  159. package/src/components/dom.ts +773 -0
  160. package/src/components/domIterator.ts +189 -0
  161. package/src/components/errors/critical.ts +5 -0
  162. package/src/components/events/BlockChanged.ts +16 -0
  163. package/src/components/events/BlockHovered.ts +21 -0
  164. package/src/components/events/BlockSettingsClosed.ts +12 -0
  165. package/src/components/events/BlockSettingsOpened.ts +12 -0
  166. package/src/components/events/BlokMobileLayoutToggled.ts +15 -0
  167. package/src/components/events/FakeCursorAboutToBeToggled.ts +17 -0
  168. package/src/components/events/FakeCursorHaveBeenSet.ts +17 -0
  169. package/src/components/events/HistoryStateChanged.ts +19 -0
  170. package/src/components/events/RedactorDomChanged.ts +14 -0
  171. package/src/components/events/index.ts +46 -0
  172. package/src/components/flipper.ts +481 -0
  173. package/src/components/i18n/i18next-loader.ts +84 -0
  174. package/src/components/i18n/lightweight-i18n.ts +86 -0
  175. package/src/components/i18n/locales/TRANSLATION_GUIDELINES.md +113 -0
  176. package/src/components/i18n/locales/am/messages.json +44 -0
  177. package/src/components/i18n/locales/ar/messages.json +44 -0
  178. package/src/components/i18n/locales/az/messages.json +44 -0
  179. package/src/components/i18n/locales/bg/messages.json +44 -0
  180. package/src/components/i18n/locales/bn/messages.json +44 -0
  181. package/src/components/i18n/locales/bs/messages.json +44 -0
  182. package/src/components/i18n/locales/cs/messages.json +44 -0
  183. package/src/components/i18n/locales/da/messages.json +44 -0
  184. package/src/components/i18n/locales/de/messages.json +44 -0
  185. package/src/components/i18n/locales/dv/messages.json +44 -0
  186. package/src/components/i18n/locales/el/messages.json +44 -0
  187. package/src/components/i18n/locales/en/messages.json +44 -0
  188. package/src/components/i18n/locales/es/messages.json +44 -0
  189. package/src/components/i18n/locales/et/messages.json +44 -0
  190. package/src/components/i18n/locales/fa/messages.json +44 -0
  191. package/src/components/i18n/locales/fi/messages.json +44 -0
  192. package/src/components/i18n/locales/fil/messages.json +44 -0
  193. package/src/components/i18n/locales/fr/messages.json +44 -0
  194. package/src/components/i18n/locales/gu/messages.json +44 -0
  195. package/src/components/i18n/locales/he/messages.json +44 -0
  196. package/src/components/i18n/locales/hi/messages.json +44 -0
  197. package/src/components/i18n/locales/hr/messages.json +44 -0
  198. package/src/components/i18n/locales/hu/messages.json +44 -0
  199. package/src/components/i18n/locales/hy/messages.json +44 -0
  200. package/src/components/i18n/locales/id/messages.json +44 -0
  201. package/src/components/i18n/locales/index.ts +225 -0
  202. package/src/components/i18n/locales/it/messages.json +44 -0
  203. package/src/components/i18n/locales/ja/messages.json +44 -0
  204. package/src/components/i18n/locales/ka/messages.json +44 -0
  205. package/src/components/i18n/locales/km/messages.json +44 -0
  206. package/src/components/i18n/locales/kn/messages.json +44 -0
  207. package/src/components/i18n/locales/ko/messages.json +44 -0
  208. package/src/components/i18n/locales/ku/messages.json +44 -0
  209. package/src/components/i18n/locales/lo/messages.json +44 -0
  210. package/src/components/i18n/locales/lt/messages.json +44 -0
  211. package/src/components/i18n/locales/lv/messages.json +44 -0
  212. package/src/components/i18n/locales/mk/messages.json +44 -0
  213. package/src/components/i18n/locales/ml/messages.json +44 -0
  214. package/src/components/i18n/locales/mn/messages.json +44 -0
  215. package/src/components/i18n/locales/mr/messages.json +44 -0
  216. package/src/components/i18n/locales/ms/messages.json +44 -0
  217. package/src/components/i18n/locales/my/messages.json +44 -0
  218. package/src/components/i18n/locales/ne/messages.json +44 -0
  219. package/src/components/i18n/locales/nl/messages.json +44 -0
  220. package/src/components/i18n/locales/no/messages.json +44 -0
  221. package/src/components/i18n/locales/pa/messages.json +44 -0
  222. package/src/components/i18n/locales/pl/messages.json +44 -0
  223. package/src/components/i18n/locales/ps/messages.json +44 -0
  224. package/src/components/i18n/locales/pt/messages.json +44 -0
  225. package/src/components/i18n/locales/ro/messages.json +44 -0
  226. package/src/components/i18n/locales/ru/messages.json +44 -0
  227. package/src/components/i18n/locales/sd/messages.json +44 -0
  228. package/src/components/i18n/locales/si/messages.json +44 -0
  229. package/src/components/i18n/locales/sk/messages.json +44 -0
  230. package/src/components/i18n/locales/sl/messages.json +44 -0
  231. package/src/components/i18n/locales/sq/messages.json +44 -0
  232. package/src/components/i18n/locales/sr/messages.json +44 -0
  233. package/src/components/i18n/locales/sv/messages.json +44 -0
  234. package/src/components/i18n/locales/sw/messages.json +44 -0
  235. package/src/components/i18n/locales/ta/messages.json +44 -0
  236. package/src/components/i18n/locales/te/messages.json +44 -0
  237. package/src/components/i18n/locales/th/messages.json +44 -0
  238. package/src/components/i18n/locales/tr/messages.json +44 -0
  239. package/src/components/i18n/locales/ug/messages.json +44 -0
  240. package/src/components/i18n/locales/uk/messages.json +44 -0
  241. package/src/components/i18n/locales/ur/messages.json +44 -0
  242. package/src/components/i18n/locales/vi/messages.json +44 -0
  243. package/src/components/i18n/locales/yi/messages.json +44 -0
  244. package/src/components/i18n/locales/zh/messages.json +44 -0
  245. package/src/components/icons/index.ts +242 -0
  246. package/src/components/inline-tools/inline-tool-bold.ts +2213 -0
  247. package/src/components/inline-tools/inline-tool-convert.ts +141 -0
  248. package/src/components/inline-tools/inline-tool-italic.ts +500 -0
  249. package/src/components/inline-tools/inline-tool-link.ts +539 -0
  250. package/src/components/modules/api/blocks.ts +363 -0
  251. package/src/components/modules/api/caret.ts +125 -0
  252. package/src/components/modules/api/events.ts +51 -0
  253. package/src/components/modules/api/history.ts +73 -0
  254. package/src/components/modules/api/i18n.ts +33 -0
  255. package/src/components/modules/api/index.ts +39 -0
  256. package/src/components/modules/api/inlineToolbar.ts +33 -0
  257. package/src/components/modules/api/listeners.ts +56 -0
  258. package/src/components/modules/api/notifier.ts +46 -0
  259. package/src/components/modules/api/readonly.ts +39 -0
  260. package/src/components/modules/api/sanitizer.ts +30 -0
  261. package/src/components/modules/api/saver.ts +52 -0
  262. package/src/components/modules/api/selection.ts +48 -0
  263. package/src/components/modules/api/styles.ts +72 -0
  264. package/src/components/modules/api/toolbar.ts +79 -0
  265. package/src/components/modules/api/tools.ts +16 -0
  266. package/src/components/modules/api/tooltip.ts +67 -0
  267. package/src/components/modules/api/ui.ts +36 -0
  268. package/src/components/modules/blockEvents.ts +1375 -0
  269. package/src/components/modules/blockManager.ts +1348 -0
  270. package/src/components/modules/blockSelection.ts +708 -0
  271. package/src/components/modules/caret.ts +853 -0
  272. package/src/components/modules/crossBlockSelection.ts +329 -0
  273. package/src/components/modules/dragManager.ts +1141 -0
  274. package/src/components/modules/history.ts +1098 -0
  275. package/src/components/modules/i18n.ts +325 -0
  276. package/src/components/modules/index.ts +139 -0
  277. package/src/components/modules/modificationsObserver.ts +147 -0
  278. package/src/components/modules/paste.ts +1092 -0
  279. package/src/components/modules/readonly.ts +136 -0
  280. package/src/components/modules/rectangleSelection.ts +668 -0
  281. package/src/components/modules/renderer.ts +155 -0
  282. package/src/components/modules/saver.ts +283 -0
  283. package/src/components/modules/toolbar/blockSettings.ts +776 -0
  284. package/src/components/modules/toolbar/index.ts +1311 -0
  285. package/src/components/modules/toolbar/inline.ts +956 -0
  286. package/src/components/modules/tools.ts +589 -0
  287. package/src/components/modules/ui.ts +1179 -0
  288. package/src/components/polyfills.ts +113 -0
  289. package/src/components/selection.ts +1189 -0
  290. package/src/components/tools/base.ts +274 -0
  291. package/src/components/tools/block.ts +291 -0
  292. package/src/components/tools/collection.ts +67 -0
  293. package/src/components/tools/factory.ts +85 -0
  294. package/src/components/tools/inline.ts +71 -0
  295. package/src/components/tools/tune.ts +33 -0
  296. package/src/components/ui/toolbox.ts +497 -0
  297. package/src/components/utils/announcer.ts +205 -0
  298. package/src/components/utils/api.ts +20 -0
  299. package/src/components/utils/bem.ts +26 -0
  300. package/src/components/utils/blocks.ts +284 -0
  301. package/src/components/utils/caret.ts +1067 -0
  302. package/src/components/utils/data-model-transform.ts +382 -0
  303. package/src/components/utils/events.ts +117 -0
  304. package/src/components/utils/keyboard.ts +60 -0
  305. package/src/components/utils/listeners.ts +296 -0
  306. package/src/components/utils/mutations.ts +39 -0
  307. package/src/components/utils/notifier/draw.ts +190 -0
  308. package/src/components/utils/notifier/index.ts +66 -0
  309. package/src/components/utils/notifier/types.ts +1 -0
  310. package/src/components/utils/notifier.ts +77 -0
  311. package/src/components/utils/placeholder.ts +140 -0
  312. package/src/components/utils/popover/components/hint/hint.const.ts +10 -0
  313. package/src/components/utils/popover/components/hint/hint.ts +46 -0
  314. package/src/components/utils/popover/components/hint/index.ts +6 -0
  315. package/src/components/utils/popover/components/popover-header/index.ts +2 -0
  316. package/src/components/utils/popover/components/popover-header/popover-header.const.ts +8 -0
  317. package/src/components/utils/popover/components/popover-header/popover-header.ts +80 -0
  318. package/src/components/utils/popover/components/popover-header/popover-header.types.ts +14 -0
  319. package/src/components/utils/popover/components/popover-item/index.ts +13 -0
  320. package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +50 -0
  321. package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +666 -0
  322. package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.const.ts +14 -0
  323. package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts +136 -0
  324. package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.const.ts +20 -0
  325. package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.ts +117 -0
  326. package/src/components/utils/popover/components/popover-item/popover-item.ts +187 -0
  327. package/src/components/utils/popover/components/search-input/index.ts +2 -0
  328. package/src/components/utils/popover/components/search-input/search-input.const.ts +8 -0
  329. package/src/components/utils/popover/components/search-input/search-input.ts +181 -0
  330. package/src/components/utils/popover/components/search-input/search-input.types.ts +30 -0
  331. package/src/components/utils/popover/index.ts +13 -0
  332. package/src/components/utils/popover/popover-abstract.ts +448 -0
  333. package/src/components/utils/popover/popover-desktop.ts +643 -0
  334. package/src/components/utils/popover/popover-inline.ts +338 -0
  335. package/src/components/utils/popover/popover-mobile.ts +201 -0
  336. package/src/components/utils/popover/popover.const.ts +81 -0
  337. package/src/components/utils/popover/utils/popover-states-history.ts +72 -0
  338. package/src/components/utils/promise-queue.ts +43 -0
  339. package/src/components/utils/sanitizer.ts +537 -0
  340. package/src/components/utils/scroll-locker.ts +87 -0
  341. package/src/components/utils/shortcut.ts +231 -0
  342. package/src/components/utils/shortcuts.ts +113 -0
  343. package/src/components/utils/tools.ts +105 -0
  344. package/src/components/utils/tooltip.ts +642 -0
  345. package/src/components/utils/tw.ts +241 -0
  346. package/src/components/utils.ts +1081 -0
  347. package/src/env.d.ts +13 -0
  348. package/src/full.ts +69 -0
  349. package/src/locales.ts +51 -0
  350. package/src/stories/Block.stories.ts +498 -0
  351. package/src/stories/EditorModes.stories.ts +505 -0
  352. package/src/stories/Header.stories.ts +137 -0
  353. package/src/stories/InlineToolbar.stories.ts +498 -0
  354. package/src/stories/List.stories.ts +259 -0
  355. package/src/stories/Notifier.stories.ts +340 -0
  356. package/src/stories/Paragraph.stories.ts +112 -0
  357. package/src/stories/Placeholder.stories.ts +319 -0
  358. package/src/stories/Popover.stories.ts +844 -0
  359. package/src/stories/Selection.stories.ts +250 -0
  360. package/src/stories/StubBlock.stories.ts +156 -0
  361. package/src/stories/Toolbar.stories.ts +223 -0
  362. package/src/stories/Toolbox.stories.ts +166 -0
  363. package/src/stories/Tooltip.stories.ts +198 -0
  364. package/src/stories/helpers.ts +463 -0
  365. package/src/styles/main.css +123 -0
  366. package/src/tools/header/index.ts +570 -0
  367. package/src/tools/index.ts +38 -0
  368. package/src/tools/list/index.ts +1803 -0
  369. package/src/tools/paragraph/index.ts +411 -0
  370. package/src/tools/stub/index.ts +107 -0
  371. package/src/types-internal/blok-modules.d.ts +87 -0
  372. package/src/types-internal/html-janitor.d.ts +28 -0
  373. package/src/types-internal/module-config.d.ts +11 -0
  374. package/src/variants/all-locales.ts +155 -0
  375. package/src/variants/blok-maximum.ts +20 -0
  376. package/src/variants/blok-minimum.ts +243 -0
  377. package/types/api/blocks.d.ts +1 -1
  378. package/types/api/i18n.d.ts +5 -3
  379. package/types/api/selection.d.ts +6 -0
  380. package/types/api/styles.d.ts +0 -5
  381. package/types/configs/blok-config.d.ts +21 -0
  382. package/types/configs/i18n-config.d.ts +52 -2
  383. package/types/configs/i18n-dictionary.d.ts +16 -90
  384. package/types/data-attributes.d.ts +169 -0
  385. package/types/data-formats/output-data.d.ts +15 -0
  386. package/types/full.d.ts +80 -0
  387. package/types/index.d.ts +9 -24
  388. package/types/locales.d.ts +59 -0
  389. package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
  390. package/types/tools/block-tool.d.ts +9 -0
  391. package/types/tools/list.d.ts +25 -18
  392. package/types/tools/tool-settings.d.ts +8 -1
  393. package/types/tools/tool.d.ts +6 -0
  394. package/types/tools-entry.d.ts +49 -0
  395. package/types/utils/popover/popover-item.d.ts +0 -5
  396. package/dist/blok-BwPfU8ro.mjs +0 -21510
  397. package/dist/blok.umd.js +0 -198
@@ -0,0 +1,1988 @@
1
+ var Y = Object.defineProperty, Q = Object.defineProperties;
2
+ var tt = Object.getOwnPropertyDescriptors;
3
+ var W = Object.getOwnPropertySymbols;
4
+ var et = Object.prototype.hasOwnProperty, nt = Object.prototype.propertyIsEnumerable;
5
+ var D = (o, t, e) => t in o ? Y(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, I = (o, t) => {
6
+ for (var e in t || (t = {}))
7
+ et.call(t, e) && D(o, e, t[e]);
8
+ if (W)
9
+ for (var e of W(t))
10
+ nt.call(t, e) && D(o, e, t[e]);
11
+ return o;
12
+ }, O = (o, t) => Q(o, tt(t));
13
+ const ot = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
14
+ let rt = (o = 21) => {
15
+ let t = "", e = crypto.getRandomValues(new Uint8Array(o |= 0));
16
+ for (; o--; )
17
+ t += ot[e[o] & 63];
18
+ return t;
19
+ };
20
+ var st = /* @__PURE__ */ ((o) => (o.VERBOSE = "VERBOSE", o.INFO = "INFO", o.WARN = "WARN", o.ERROR = "ERROR", o))(st || {});
21
+ const it = () => "0.4.2", Et = {
22
+ BACKSPACE: 8,
23
+ TAB: 9,
24
+ ENTER: 13,
25
+ LEFT: 37,
26
+ UP: 38,
27
+ DOWN: 40,
28
+ RIGHT: 39,
29
+ DELETE: 46
30
+ }, Tt = {
31
+ LEFT: 0
32
+ }, at = 1e8, lt = 16, m = (() => {
33
+ try {
34
+ return Function("return this")();
35
+ } catch (o) {
36
+ return;
37
+ }
38
+ })();
39
+ m && typeof m.window == "undefined" && (m.window = m);
40
+ const B = () => {
41
+ if (m != null && m.window)
42
+ return m.window;
43
+ }, X = () => {
44
+ if (m != null && m.navigator)
45
+ return m.navigator;
46
+ const o = B();
47
+ return o == null ? void 0 : o.navigator;
48
+ }, N = (o, t, e = "log", n, r = "color: inherit") => {
49
+ const s = typeof console == "undefined" ? void 0 : console;
50
+ if (!s || typeof s[e] != "function")
51
+ return;
52
+ const i = ["info", "log", "warn", "error"].includes(e), l = [];
53
+ switch (N.logLevel) {
54
+ case "ERROR":
55
+ if (e !== "error")
56
+ return;
57
+ break;
58
+ case "WARN":
59
+ if (!["error", "warn"].includes(e))
60
+ return;
61
+ break;
62
+ case "INFO":
63
+ if (!i || o)
64
+ return;
65
+ break;
66
+ }
67
+ n && l.push(n);
68
+ const c = `Blok ${it()}`, a = `line-height: 1em;
69
+ color: #006FEA;
70
+ display: inline-block;
71
+ font-size: 11px;
72
+ line-height: 1em;
73
+ background-color: #fff;
74
+ padding: 4px 9px;
75
+ border-radius: 30px;
76
+ border: 1px solid rgba(56, 138, 229, 0.16);
77
+ margin: 4px 5px 4px 0;`, d = o ? i ? (l.unshift(a, r), `%c${c}%c ${t}`) : `( ${c} )${t}` : t, u = i ? n !== void 0 ? [`${d} %o`, ...l] : [d, ...l] : [d];
78
+ try {
79
+ s[e](...u);
80
+ } catch (g) {
81
+ }
82
+ };
83
+ N.logLevel = "VERBOSE";
84
+ const xt = (o) => {
85
+ N.logLevel = o;
86
+ }, M = (o, t = "log", e, n) => {
87
+ N(!1, o, t, e, n);
88
+ }, At = (o, t = "log", e, n) => {
89
+ N(!0, o, t, e, n);
90
+ }, F = (o) => typeof o == "function", L = (o) => {
91
+ if (o === null || typeof o != "object")
92
+ return !1;
93
+ const t = Object.getPrototypeOf(o);
94
+ return t === null || t === Object.prototype;
95
+ }, x = (o) => typeof o == "string", Nt = (o) => typeof o == "boolean", _ = (o) => typeof o == "number", St = function(o) {
96
+ return o === void 0;
97
+ }, q = (o) => o == null ? !0 : typeof o == "string" || Array.isArray(o) ? o.length === 0 : o instanceof Map || o instanceof Set ? o.size === 0 : typeof o == "object" ? Object.keys(o).length === 0 : !1, ct = (o) => Array.from(o), It = (o, t) => function(...e) {
98
+ setTimeout(() => o.apply(this, e), t);
99
+ }, Rt = (o) => {
100
+ var t;
101
+ return (t = o.name.split(".").pop()) != null ? t : "";
102
+ }, Mt = (o) => /^[-\w]+\/([-+\w]+|\*)$/.test(o), Lt = (o, t, e) => {
103
+ const n = {
104
+ timeoutId: null
105
+ };
106
+ return function(...r) {
107
+ const s = () => {
108
+ n.timeoutId = null, o.apply(this, r);
109
+ };
110
+ n.timeoutId !== null && clearTimeout(n.timeoutId), n.timeoutId = setTimeout(s, t);
111
+ };
112
+ }, Bt = (o, t, e) => {
113
+ const n = {
114
+ lastCallTime: void 0,
115
+ lastInvokeTime: 0,
116
+ timerId: void 0,
117
+ lastArgs: void 0,
118
+ lastThis: void 0
119
+ }, r = (a) => {
120
+ n.lastInvokeTime = a;
121
+ const d = n.lastArgs, u = n.lastThis;
122
+ return n.lastArgs = void 0, n.lastThis = void 0, o.apply(u, d != null ? d : []);
123
+ }, s = (a) => {
124
+ var h;
125
+ const d = a - ((h = n.lastCallTime) != null ? h : 0), u = a - n.lastInvokeTime, g = t - d;
126
+ return Math.min(g, t - u);
127
+ }, i = (a) => {
128
+ var g;
129
+ const d = a - ((g = n.lastCallTime) != null ? g : 0), u = a - n.lastInvokeTime;
130
+ return n.lastCallTime === void 0 || d >= t || d < 0 || u >= t;
131
+ }, l = () => {
132
+ const a = Date.now();
133
+ if (!i(a)) {
134
+ n.timerId = setTimeout(l, s(a));
135
+ return;
136
+ }
137
+ n.timerId = void 0, n.lastArgs !== void 0 && r(a), n.lastArgs = void 0, n.lastThis = void 0;
138
+ };
139
+ return function(...a) {
140
+ const d = Date.now(), u = i(d);
141
+ if (n.lastArgs = a, n.lastThis = this, n.lastCallTime = d, !!(u && n.timerId === void 0))
142
+ return n.lastInvokeTime = d, n.timerId = setTimeout(l, t), r(d);
143
+ };
144
+ }, dt = () => {
145
+ var r, s;
146
+ const o = {
147
+ win: !1,
148
+ mac: !1,
149
+ x11: !1,
150
+ linux: !1
151
+ }, t = X(), e = (s = (r = t == null ? void 0 : t.userAgent) == null ? void 0 : r.toLowerCase()) != null ? s : "", n = e ? Object.keys(o).find((i) => e.indexOf(i) !== -1) : void 0;
152
+ return n !== void 0 && (o[n] = !0), o;
153
+ }, ut = (o) => o && o.slice(0, 1).toUpperCase() + o.slice(1), K = (o, t) => {
154
+ const e = I({}, o);
155
+ return Object.keys(t).forEach((n) => {
156
+ const r = e[n], s = t[n];
157
+ if (s === void 0)
158
+ return;
159
+ if (L(s) && L(r) && !Array.isArray(s)) {
160
+ e[n] = K(
161
+ r,
162
+ s
163
+ );
164
+ return;
165
+ }
166
+ e[n] = s;
167
+ }), e;
168
+ }, Ot = (o, ...t) => {
169
+ if (!L(o) || t.length === 0)
170
+ return o;
171
+ const e = t.reduce((n, r) => L(r) ? K(n, r) : n, o);
172
+ return Object.assign(o, e), o;
173
+ }, $t = (o) => {
174
+ const t = dt(), e = o.replace(/shift/gi, "⇧").replace(/backspace/gi, "⌫").replace(/enter/gi, "⏎").replace(/up/gi, "↑").replace(/left/gi, "→").replace(/down/gi, "↓").replace(/right/gi, "←").replace(/escape/gi, "⎋").replace(/insert/gi, "Ins").replace(/delete/gi, "␡").replace(/\+/gi, " + ");
175
+ return t.mac ? e.replace(/ctrl|cmd/gi, "⌘").replace(/alt/gi, "⌥") : e.replace(/cmd/gi, "Ctrl").replace(/windows/gi, "WIN");
176
+ }, Ft = (o) => {
177
+ try {
178
+ return new URL(o).href;
179
+ } catch (e) {
180
+ }
181
+ const t = B();
182
+ return o.substring(0, 2) === "//" ? t ? `${t.location.protocol}${o}` : o : t ? `${t.location.origin}${o}` : o;
183
+ }, Ht = () => rt(10), Gt = (o) => {
184
+ const t = B();
185
+ t && t.open(o, "_blank");
186
+ }, jt = (o = "") => `${o}${Math.floor(Math.random() * at).toString(lt)}`, pt = 650, gt = () => {
187
+ const o = B();
188
+ return !o || typeof o.matchMedia != "function" ? !1 : o.matchMedia(`(max-width: ${pt}px)`).matches;
189
+ }, Pt = (() => {
190
+ var c;
191
+ const o = X();
192
+ if (!o)
193
+ return !1;
194
+ const t = o.userAgent || "", e = o.userAgentData, n = e == null ? void 0 : e.platform;
195
+ if (/iP(ad|hone|od)/.test(t) || n !== void 0 && n !== "" && /iP(ad|hone|od)/.test(n))
196
+ return !0;
197
+ const r = ((c = o.maxTouchPoints) != null ? c : 0) > 1, s = () => (
198
+ // eslint-disable-next-line @typescript-eslint/no-deprecated -- Fallback for older browsers that don't support User-Agent Client Hints
199
+ o.platform
200
+ ), i = n !== void 0 && n !== "" ? n : void 0;
201
+ return (r ? i != null ? i : s() : void 0) === "MacIntel";
202
+ })(), ht = (o, t) => o.length !== t.length ? !1 : o.every((e, n) => H(e, t[n])), H = (o, t) => {
203
+ if (o === t)
204
+ return !0;
205
+ if (o === null || t === null || typeof o != "object" || typeof t != "object" || Array.isArray(o) !== Array.isArray(t))
206
+ return !1;
207
+ if (Array.isArray(o) && Array.isArray(t))
208
+ return ht(o, t);
209
+ const e = Object.keys(o), n = Object.keys(t);
210
+ return e.length !== n.length ? !1 : e.every(
211
+ (r) => Object.prototype.hasOwnProperty.call(t, r) && H(o[r], t[r])
212
+ );
213
+ }, Vt = (o) => {
214
+ if (!o || !o.includes("data-blok-fake-background"))
215
+ return o;
216
+ const t = document.createElement("div");
217
+ return t.innerHTML = o, t.querySelectorAll('[data-blok-fake-background="true"]').forEach((n) => {
218
+ const r = n.parentNode;
219
+ if (r) {
220
+ for (; n.firstChild; )
221
+ r.insertBefore(n.firstChild, n);
222
+ r.removeChild(n);
223
+ }
224
+ }), t.innerHTML;
225
+ };
226
+ class p {
227
+ /**
228
+ * Check if passed tag has no closed tag
229
+ * @param {HTMLElement} tag - element to check
230
+ * @returns {boolean}
231
+ */
232
+ static isSingleTag(t) {
233
+ return !!t.tagName && [
234
+ "AREA",
235
+ "BASE",
236
+ "BR",
237
+ "COL",
238
+ "COMMAND",
239
+ "EMBED",
240
+ "HR",
241
+ "IMG",
242
+ "INPUT",
243
+ "KEYGEN",
244
+ "LINK",
245
+ "META",
246
+ "PARAM",
247
+ "SOURCE",
248
+ "TRACK",
249
+ "WBR"
250
+ ].includes(t.tagName);
251
+ }
252
+ /**
253
+ * Check if element is BR or WBR
254
+ * @param {HTMLElement} element - element to check
255
+ * @returns {boolean}
256
+ */
257
+ static isLineBreakTag(t) {
258
+ return !!t && ["BR", "WBR"].includes(t.tagName);
259
+ }
260
+ /**
261
+ * Checks if a class name is valid for use with classList.add()
262
+ * classList.add() throws if class contains whitespace, is empty, or contains invalid characters
263
+ * @param className - class name to validate
264
+ * @returns {boolean} - true if valid for classList.add()
265
+ */
266
+ static isValidClassName(t) {
267
+ if (t === "" || /\s/.test(t))
268
+ return !1;
269
+ try {
270
+ return document.createElement("div").classList.add(t), !0;
271
+ } catch (e) {
272
+ return !1;
273
+ }
274
+ }
275
+ /**
276
+ * Safely adds class names to an element, filtering out invalid ones
277
+ * @param element - element to add classes to
278
+ * @param classNames - array of class names to add
279
+ */
280
+ static safelyAddClasses(t, e) {
281
+ const n = [], r = [];
282
+ for (const s of e)
283
+ p.isValidClassName(s) ? n.push(s) : r.push(s);
284
+ if (n.length > 0 && t.classList.add(...n), r.length > 0) {
285
+ const s = t.className, i = s ? `${s} ${r.join(" ")}` : r.join(" ");
286
+ t.setAttribute("class", i);
287
+ }
288
+ }
289
+ /**
290
+ * Helper for making Elements with class name and attributes
291
+ * @param {string} tagName - new Element tag name
292
+ * @param {string[]|string} [classNames] - list or name of CSS class name(s)
293
+ * @param {object} [attributes] - any attributes
294
+ * @returns {HTMLElement}
295
+ */
296
+ static make(t, e = null, n = {}) {
297
+ const r = document.createElement(t);
298
+ if (Array.isArray(e)) {
299
+ const s = e.filter((i) => i !== void 0 && i !== "").flatMap((i) => i.split(" ")).filter((i) => i !== "");
300
+ p.safelyAddClasses(r, s);
301
+ }
302
+ if (typeof e == "string" && e !== "") {
303
+ const s = e.split(" ").filter((i) => i !== "");
304
+ p.safelyAddClasses(r, s);
305
+ }
306
+ for (const s in n) {
307
+ if (!Object.prototype.hasOwnProperty.call(n, s))
308
+ continue;
309
+ const i = n[s];
310
+ if (i != null) {
311
+ if (s in r) {
312
+ r[s] = i;
313
+ continue;
314
+ }
315
+ r.setAttribute(s, String(i));
316
+ }
317
+ }
318
+ return r;
319
+ }
320
+ /**
321
+ * Creates Text Node with the passed content
322
+ * @param {string} content - text content
323
+ * @returns {Text}
324
+ */
325
+ static text(t) {
326
+ return document.createTextNode(t);
327
+ }
328
+ /**
329
+ * Append one or several elements to the parent
330
+ * @param {Element|DocumentFragment} parent - where to append
331
+ * @param {Element|Element[]|DocumentFragment|Text|Text[]} elements - element or elements list
332
+ */
333
+ static append(t, e) {
334
+ Array.isArray(e) ? e.forEach((n) => t.appendChild(n)) : t.appendChild(e);
335
+ }
336
+ /**
337
+ * Append element or a couple to the beginning of the parent elements
338
+ * @param {Element} parent - where to append
339
+ * @param {Element|Element[]} elements - element or elements list
340
+ */
341
+ static prepend(t, e) {
342
+ Array.isArray(e) ? [...e].reverse().forEach((r) => t.prepend(r)) : t.prepend(e);
343
+ }
344
+ /**
345
+ * Selector Decorator
346
+ *
347
+ * Returns first match
348
+ * @param {Element} el - element we searching inside. Default - DOM Document
349
+ * @param {string} selector - searching string
350
+ * @returns {Element}
351
+ */
352
+ static find(t = document, e) {
353
+ return t.querySelector(e);
354
+ }
355
+ /**
356
+ * Get Element by Id
357
+ * @param {string} id - id to find
358
+ * @returns {HTMLElement | null}
359
+ */
360
+ static get(t) {
361
+ return document.getElementById(t);
362
+ }
363
+ /**
364
+ * Selector Decorator.
365
+ *
366
+ * Returns all matches
367
+ * @param {Element|Document} el - element we searching inside. Default - DOM Document
368
+ * @param {string} selector - searching string
369
+ * @returns {NodeList}
370
+ */
371
+ static findAll(t = document, e) {
372
+ return t.querySelectorAll(e);
373
+ }
374
+ /**
375
+ * Returns CSS selector for all text inputs
376
+ */
377
+ static get allInputsSelector() {
378
+ return "[contenteditable=true], textarea, input:not([type]), " + ["text", "password", "email", "number", "search", "tel", "url"].map((e) => `input[type="${e}"]`).join(", ");
379
+ }
380
+ /**
381
+ * Find all contenteditable, textarea and editable input elements passed holder contains
382
+ * @param holder - element where to find inputs
383
+ */
384
+ static findAllInputs(t) {
385
+ return ct(t.querySelectorAll(p.allInputsSelector)).reduce((e, n) => p.isNativeInput(n) || p.containsOnlyInlineElements(n) ? [...e, n] : [...e, ...p.getDeepestBlockElements(n)], []);
386
+ }
387
+ /**
388
+ * Search for deepest node which is Leaf.
389
+ * Leaf is the vertex that doesn't have any child nodes
390
+ * @description Method recursively goes throw the all Node until it finds the Leaf
391
+ * @param {Node} node - root Node. From this vertex we start Deep-first search
392
+ * {@link https://en.wikipedia.org/wiki/Depth-first_search}
393
+ * @param {boolean} [atLast] - find last text node
394
+ * @returns - it can be text Node or Element Node, so that caret will able to work with it
395
+ * Can return null if node is Document or DocumentFragment, or node is not attached to the DOM
396
+ */
397
+ static getDeepestNode(t, e = !1) {
398
+ var d;
399
+ const n = e ? "lastChild" : "firstChild", r = e ? "previousSibling" : "nextSibling";
400
+ if (t === null || t.nodeType !== Node.ELEMENT_NODE)
401
+ return t;
402
+ const s = t[n];
403
+ if (s === null)
404
+ return t;
405
+ const i = s;
406
+ if (!(p.isSingleTag(i) && !p.isNativeInput(i) && !p.isLineBreakTag(i)))
407
+ return this.getDeepestNode(i, e);
408
+ const c = i[r];
409
+ if (c)
410
+ return this.getDeepestNode(c, e);
411
+ const a = (d = i.parentNode) == null ? void 0 : d[r];
412
+ return a ? this.getDeepestNode(a, e) : i.parentNode;
413
+ }
414
+ /**
415
+ * Check if object is DOM node
416
+ * @param {*} node - object to check
417
+ * @returns {boolean}
418
+ */
419
+ static isElement(t) {
420
+ return _(t) ? !1 : t != null && t.nodeType != null && t.nodeType === Node.ELEMENT_NODE;
421
+ }
422
+ /**
423
+ * Check if object is DocumentFragment node
424
+ * @param {object} node - object to check
425
+ * @returns {boolean}
426
+ */
427
+ static isFragment(t) {
428
+ return _(t) ? !1 : t != null && t.nodeType != null && t.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
429
+ }
430
+ /**
431
+ * Check if passed element is contenteditable
432
+ * @param {HTMLElement} element - html element to check
433
+ * @returns {boolean}
434
+ */
435
+ static isContentEditable(t) {
436
+ return t.contentEditable === "true";
437
+ }
438
+ /**
439
+ * Checks target if it is native input
440
+ * @param {*} target - HTML element or string
441
+ * @returns {boolean}
442
+ */
443
+ static isNativeInput(t) {
444
+ const e = [
445
+ "INPUT",
446
+ "TEXTAREA"
447
+ ];
448
+ return t != null && typeof t.tagName == "string" ? e.includes(t.tagName) : !1;
449
+ }
450
+ /**
451
+ * Checks if we can set caret
452
+ * @param {HTMLElement} target - target to check
453
+ * @returns {boolean}
454
+ */
455
+ static canSetCaret(t) {
456
+ return p.isNativeInput(t) ? !(/* @__PURE__ */ new Set([
457
+ "file",
458
+ "checkbox",
459
+ "radio",
460
+ "hidden",
461
+ "submit",
462
+ "button",
463
+ "image",
464
+ "reset"
465
+ ])).has(t.type) : p.isContentEditable(t);
466
+ }
467
+ /**
468
+ * Checks node if it is empty
469
+ * @description Method checks simple Node without any childs for emptiness
470
+ * If you have Node with 2 or more children id depth, you better use {@link Dom#isEmpty} method
471
+ * @param {Node} node - node to check
472
+ * @param {string} [ignoreChars] - char or substring to treat as empty
473
+ * @returns {boolean} true if it is empty
474
+ */
475
+ static isNodeEmpty(t, e) {
476
+ var s, i;
477
+ if (this.isSingleTag(t) && !this.isLineBreakTag(t))
478
+ return !1;
479
+ const n = this.isElement(t) && this.isNativeInput(t) ? t.value : (s = t.textContent) == null ? void 0 : s.replace("​", ""), r = e ? n == null ? void 0 : n.replace(new RegExp(e, "g"), "") : n;
480
+ return ((i = r == null ? void 0 : r.length) != null ? i : 0) === 0;
481
+ }
482
+ /**
483
+ * checks node if it is doesn't have any child nodes
484
+ * @param {Node} node - node to check
485
+ * @returns {boolean}
486
+ */
487
+ static isLeaf(t) {
488
+ return t ? t.childNodes.length === 0 : !1;
489
+ }
490
+ /**
491
+ * breadth-first search (BFS)
492
+ * {@link https://en.wikipedia.org/wiki/Breadth-first_search}
493
+ * @description Pushes to stack all DOM leafs and checks for emptiness
494
+ * @param {Node} node - node to check
495
+ * @param {string} [ignoreChars] - char or substring to treat as empty
496
+ * @returns {boolean}
497
+ */
498
+ static isEmpty(t, e) {
499
+ const n = [t];
500
+ for (; n.length > 0; ) {
501
+ const r = n.shift();
502
+ if (r) {
503
+ if (this.isLeaf(r) && !this.isNodeEmpty(r, e))
504
+ return !1;
505
+ r.childNodes && n.push(...Array.from(r.childNodes));
506
+ }
507
+ }
508
+ return !0;
509
+ }
510
+ /**
511
+ * Check if string contains html elements
512
+ * @param {string} str - string to check
513
+ * @returns {boolean}
514
+ */
515
+ static isHTMLString(t) {
516
+ const e = p.make("div");
517
+ return e.innerHTML = t, e.childElementCount > 0;
518
+ }
519
+ /**
520
+ * Return length of node`s text content
521
+ * @param {Node} node - node with content
522
+ * @returns {number}
523
+ */
524
+ static getContentLength(t) {
525
+ var e, n;
526
+ return p.isNativeInput(t) ? t.value.length : t.nodeType === Node.TEXT_NODE ? t.length : (n = (e = t.textContent) == null ? void 0 : e.length) != null ? n : 0;
527
+ }
528
+ /**
529
+ * Return array of names of block html elements
530
+ * @returns {string[]}
531
+ */
532
+ static get blockElements() {
533
+ return [
534
+ "address",
535
+ "article",
536
+ "aside",
537
+ "blockquote",
538
+ "canvas",
539
+ "div",
540
+ "dl",
541
+ "dt",
542
+ "fieldset",
543
+ "figcaption",
544
+ "figure",
545
+ "footer",
546
+ "form",
547
+ "h1",
548
+ "h2",
549
+ "h3",
550
+ "h4",
551
+ "h5",
552
+ "h6",
553
+ "header",
554
+ "hgroup",
555
+ "hr",
556
+ "li",
557
+ "main",
558
+ "nav",
559
+ "noscript",
560
+ "ol",
561
+ "output",
562
+ "p",
563
+ "pre",
564
+ "ruby",
565
+ "section",
566
+ "table",
567
+ "tbody",
568
+ "thead",
569
+ "tr",
570
+ "tfoot",
571
+ "ul",
572
+ "video"
573
+ ];
574
+ }
575
+ /**
576
+ * Check if passed content includes only inline elements
577
+ * @param {string|HTMLElement} data - element or html string
578
+ * @returns {boolean}
579
+ */
580
+ static containsOnlyInlineElements(t) {
581
+ const e = x(t) ? (() => {
582
+ const r = document.createElement("div");
583
+ return r.innerHTML = t, r;
584
+ })() : t, n = (r) => !p.blockElements.includes(r.tagName.toLowerCase()) && Array.from(r.children).every(n);
585
+ return Array.from(e.children).every(n);
586
+ }
587
+ /**
588
+ * Find and return all block elements in the passed parent (including subtree)
589
+ * @param {HTMLElement} parent - root element
590
+ * @returns {HTMLElement[]}
591
+ */
592
+ static getDeepestBlockElements(t) {
593
+ return p.containsOnlyInlineElements(t) ? [t] : Array.from(t.children).reduce((e, n) => [...e, ...p.getDeepestBlockElements(n)], []);
594
+ }
595
+ /**
596
+ * Helper for get holder from {string} or return HTMLElement
597
+ * @param {string | HTMLElement} element - holder's id or holder's HTML Element
598
+ * @returns {HTMLElement}
599
+ */
600
+ static getHolder(t) {
601
+ if (!x(t))
602
+ return t;
603
+ const e = document.getElementById(t);
604
+ if (e !== null)
605
+ return e;
606
+ throw new Error(`Element with id "${t}" not found`);
607
+ }
608
+ /**
609
+ * Returns true if element is anchor (is A tag)
610
+ * @param {Element} element - element to check
611
+ * @returns {boolean}
612
+ */
613
+ static isAnchor(t) {
614
+ return t.tagName.toLowerCase() === "a";
615
+ }
616
+ /**
617
+ * Return element's offset related to the document
618
+ * @todo handle case when blok initialized in scrollable popup
619
+ * @param el - element to compute offset
620
+ */
621
+ static offset(t) {
622
+ const e = t.getBoundingClientRect(), n = window.scrollX || document.documentElement.scrollLeft, r = window.scrollY || document.documentElement.scrollTop, s = e.top + r, i = e.left + n;
623
+ return {
624
+ top: s,
625
+ left: i,
626
+ bottom: s + e.height,
627
+ right: i + e.width
628
+ };
629
+ }
630
+ /**
631
+ * Find text node and offset by total content offset
632
+ * @param {Node} root - root node to start search from
633
+ * @param {number} totalOffset - offset relative to the root node content
634
+ * @returns {{node: Node | null, offset: number}} - node and offset inside node
635
+ */
636
+ static getNodeByOffset(t, e) {
637
+ const n = document.createTreeWalker(
638
+ t,
639
+ NodeFilter.SHOW_TEXT,
640
+ null
641
+ ), r = (a, d, u, g) => {
642
+ var w;
643
+ if (!a && u) {
644
+ const k = d - g, C = Math.max(e - k, 0), y = Math.min(C, g);
645
+ return {
646
+ node: u,
647
+ offset: y
648
+ };
649
+ }
650
+ if (!a)
651
+ return {
652
+ node: null,
653
+ offset: 0
654
+ };
655
+ const f = ((w = a.textContent) != null ? w : "").length;
656
+ return d + f >= e ? {
657
+ node: a,
658
+ offset: Math.min(e - d, f)
659
+ } : r(
660
+ n.nextNode(),
661
+ d + f,
662
+ a,
663
+ f
664
+ );
665
+ }, s = n.nextNode(), { node: i, offset: l } = r(s, 0, null, 0);
666
+ if (!i)
667
+ return {
668
+ node: null,
669
+ offset: 0
670
+ };
671
+ const c = i.textContent;
672
+ return !c || c.length === 0 ? {
673
+ node: null,
674
+ offset: 0
675
+ } : {
676
+ node: i,
677
+ offset: l
678
+ };
679
+ }
680
+ }
681
+ const Wt = (o) => !/[^\t\n\r \u200B]/.test(o), Dt = (o) => {
682
+ o.setAttribute("data-blok-empty", p.isEmpty(o) ? "true" : "false");
683
+ }, ft = [
684
+ // Max-width: max-w-* classes conflict with each other
685
+ { pattern: /^max-w-(.+)$/, getGroup: () => "max-w" },
686
+ // Width: w-* classes conflict with each other
687
+ { pattern: /^w-(.+)$/, getGroup: () => "w" },
688
+ // Min-width: min-w-* classes conflict with each other
689
+ { pattern: /^min-w-(.+)$/, getGroup: () => "min-w" },
690
+ // Height: h-* classes conflict with each other
691
+ { pattern: /^h-(.+)$/, getGroup: () => "h" },
692
+ // Display: block, inline-block, flex, hidden, etc.
693
+ { pattern: /^(block|inline-block|inline|flex|inline-flex|grid|inline-grid|hidden|contents|flow-root|list-item)$/, getGroup: () => "display" },
694
+ // Flex direction: flex-row, flex-col
695
+ { pattern: /^flex-(row|col|row-reverse|col-reverse)$/, getGroup: () => "flex-dir" },
696
+ // Justify content: justify-*
697
+ { pattern: /^justify-(.+)$/, getGroup: () => "justify" },
698
+ // Align items: items-*
699
+ { pattern: /^items-(.+)$/, getGroup: () => "items" },
700
+ // Text alignment: text-left, text-center, text-right
701
+ { pattern: /^text-(left|center|right|justify|start|end)$/, getGroup: () => "text-align" },
702
+ // Text color: text-{color} (but not text-align classes)
703
+ { pattern: /^text-((?!left|center|right|justify|start|end).+)$/, getGroup: () => "text-color" },
704
+ // Background: bg-*
705
+ { pattern: /^bg-(.+)$/, getGroup: () => "bg" },
706
+ // Opacity: opacity-*
707
+ { pattern: /^opacity-(.+)$/, getGroup: () => "opacity" },
708
+ // Z-index: z-*
709
+ { pattern: /^z-(.+)$/, getGroup: () => "z" },
710
+ // Position: static, fixed, absolute, relative, sticky
711
+ { pattern: /^(static|fixed|absolute|relative|sticky)$/, getGroup: () => "position" },
712
+ // Inset (all sides): inset-*
713
+ { pattern: /^inset-(.+)$/, getGroup: () => "inset" },
714
+ // Top/Right/Bottom/Left positioning
715
+ { pattern: /^(top|right|bottom|left)-(.+)$/, getGroup: (o) => o[1] },
716
+ // Margin: m-*, mx-*, my-*, mt-*, mr-*, mb-*, ml-*
717
+ { pattern: /^!?m-(.+)$/, getGroup: () => "m" },
718
+ { pattern: /^!?mx-(.+)$/, getGroup: () => "mx" },
719
+ { pattern: /^!?my-(.+)$/, getGroup: () => "my" },
720
+ { pattern: /^!?mt-(.+)$/, getGroup: () => "mt" },
721
+ { pattern: /^!?mr-(.+)$/, getGroup: () => "mr" },
722
+ { pattern: /^!?mb-(.+)$/, getGroup: () => "mb" },
723
+ { pattern: /^!?ml-(.+)$/, getGroup: () => "ml" },
724
+ // Padding: p-*, px-*, py-*, pt-*, pr-*, pb-*, pl-*
725
+ { pattern: /^p-(.+)$/, getGroup: () => "p" },
726
+ { pattern: /^px-(.+)$/, getGroup: () => "px" },
727
+ { pattern: /^py-(.+)$/, getGroup: () => "py" },
728
+ { pattern: /^pt-(.+)$/, getGroup: () => "pt" },
729
+ { pattern: /^pr-(.+)$/, getGroup: () => "pr" },
730
+ { pattern: /^pb-(.+)$/, getGroup: () => "pb" },
731
+ { pattern: /^pl-(.+)$/, getGroup: () => "pl" },
732
+ // Gap: gap-*, gap-x-*, gap-y-*
733
+ { pattern: /^gap-(.+)$/, getGroup: () => "gap" },
734
+ // Border radius: rounded-*
735
+ { pattern: /^rounded(-.*)?$/, getGroup: () => "rounded" },
736
+ // Visibility: visible, invisible
737
+ { pattern: /^(visible|invisible)$/, getGroup: () => "visibility" },
738
+ // Overflow: overflow-*
739
+ { pattern: /^overflow-(.+)$/, getGroup: () => "overflow" },
740
+ // Cursor: cursor-*
741
+ { pattern: /^cursor-(.+)$/, getGroup: () => "cursor" },
742
+ // Pointer events: pointer-events-*
743
+ { pattern: /^pointer-events-(.+)$/, getGroup: () => "pointer-events" },
744
+ // Transition: transition-*
745
+ { pattern: /^transition(-.*)?$/, getGroup: () => "transition" },
746
+ // Duration: duration-*
747
+ { pattern: /^duration-(.+)$/, getGroup: () => "duration" },
748
+ // Ease: ease-*
749
+ { pattern: /^ease-(.+)$/, getGroup: () => "ease" },
750
+ // Animation: animate-*
751
+ { pattern: /^animate-(.+)$/, getGroup: () => "animate" },
752
+ // Font weight: font-*
753
+ { pattern: /^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black)$/, getGroup: () => "font-weight" },
754
+ // Font size: text-{size}
755
+ { pattern: /^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/, getGroup: () => "font-size" },
756
+ // Line height: leading-*
757
+ { pattern: /^leading-(.+)$/, getGroup: () => "leading" },
758
+ // Outline: outline-*
759
+ { pattern: /^outline(-.*)?$/, getGroup: () => "outline" },
760
+ // Border: border-*
761
+ { pattern: /^border(-.*)?$/, getGroup: () => "border" },
762
+ // Shadow: shadow-*
763
+ { pattern: /^shadow(-.*)?$/, getGroup: () => "shadow" }
764
+ ], $ = /* @__PURE__ */ new Map(), mt = (o) => {
765
+ const t = $.get(o);
766
+ if (t !== void 0)
767
+ return t;
768
+ for (const { pattern: e, getGroup: n } of ft) {
769
+ const r = o.match(e);
770
+ if (r) {
771
+ const s = n(r);
772
+ return $.set(o, s), s;
773
+ }
774
+ }
775
+ return $.set(o, null), null;
776
+ }, kt = (o, t, e) => {
777
+ const n = mt(o);
778
+ if (n) {
779
+ t.set(n, o);
780
+ return;
781
+ }
782
+ e.includes(o) || e.push(o);
783
+ }, bt = (o) => {
784
+ const t = [];
785
+ for (const e of o)
786
+ if (e) {
787
+ if (Array.isArray(e)) {
788
+ t.push(...e.filter(Boolean));
789
+ continue;
790
+ }
791
+ t.push(e);
792
+ }
793
+ return t;
794
+ }, _t = (...o) => {
795
+ const t = /* @__PURE__ */ new Map(), e = [], n = bt(o);
796
+ for (const r of n)
797
+ r.split(/\s+/).filter(Boolean).forEach((i) => kt(i, t, e));
798
+ return [...e, ...t.values()].join(" ");
799
+ }, Ut = (...o) => o.filter(Boolean).join(" "), E = {
800
+ // ============================================
801
+ // Core Element Identifiers
802
+ // ============================================
803
+ /** Interface type identifier (blok, inline-toolbar, tooltip) */
804
+ interface: "data-blok-interface",
805
+ /** Block element wrapper */
806
+ element: "data-blok-element",
807
+ /** Block element content wrapper */
808
+ elementContent: "data-blok-element-content",
809
+ /** Editor wrapper container */
810
+ editor: "data-blok-editor",
811
+ /** Redactor zone */
812
+ redactor: "data-blok-redactor",
813
+ // ============================================
814
+ // Block Identifiers
815
+ // ============================================
816
+ /** Block unique identifier */
817
+ id: "data-blok-id",
818
+ /** Block component/tool type */
819
+ component: "data-blok-component",
820
+ /** Tool type attribute */
821
+ tool: "data-blok-tool",
822
+ /** Block nesting depth */
823
+ depth: "data-blok-depth",
824
+ // ============================================
825
+ // Global States
826
+ // ============================================
827
+ /** Element is hidden from view */
828
+ hidden: "data-blok-hidden",
829
+ /** Element is disabled and non-interactive */
830
+ disabled: "data-blok-disabled",
831
+ /** Element is focused via keyboard navigation */
832
+ focused: "data-blok-focused",
833
+ /** Block is selected */
834
+ selected: "data-blok-selected",
835
+ /** Block is stretched */
836
+ stretched: "data-blok-stretched",
837
+ /** Editor or element is empty */
838
+ empty: "data-blok-empty",
839
+ // ============================================
840
+ // Editor Modes
841
+ // ============================================
842
+ /** Narrow mode state */
843
+ narrow: "data-blok-narrow",
844
+ /** Right-to-left mode */
845
+ rtl: "data-blok-rtl",
846
+ // ============================================
847
+ // Drag and Drop
848
+ // ============================================
849
+ /** Block is being dragged */
850
+ dragging: "data-blok-dragging",
851
+ /** Multiple blocks being dragged */
852
+ draggingMulti: "data-blok-dragging-multi",
853
+ /** Block is being duplicated (Alt+drag) */
854
+ duplicating: "data-blok-duplicating",
855
+ /** Drag handle element */
856
+ dragHandle: "data-blok-drag-handle",
857
+ // ============================================
858
+ // Toolbar
859
+ // ============================================
860
+ /** Toolbar element */
861
+ toolbar: "data-blok-toolbar",
862
+ /** Settings toggler button */
863
+ settingsToggler: "data-blok-settings-toggler",
864
+ /** Toolbox is open */
865
+ toolboxOpened: "data-blok-toolbox-opened",
866
+ /** Element is opened (generic) */
867
+ opened: "data-blok-opened",
868
+ // ============================================
869
+ // Popover Container
870
+ // ============================================
871
+ /** Root popover element */
872
+ popover: "data-blok-popover",
873
+ /** Popover container wrapper */
874
+ popoverContainer: "data-blok-popover-container",
875
+ /** Popover items list */
876
+ popoverItems: "data-blok-popover-items",
877
+ /** Popover overlay element */
878
+ popoverOverlay: "data-blok-popover-overlay",
879
+ /** Popover custom content area */
880
+ popoverCustomContent: "data-blok-popover-custom-content",
881
+ /** Popover custom class */
882
+ popoverCustomClass: "data-blok-popover-custom-class",
883
+ /** Inline popover variant */
884
+ popoverInline: "data-blok-popover-inline",
885
+ /** Popover is open */
886
+ popoverOpened: "data-blok-popover-opened",
887
+ /** Popover opens upward */
888
+ popoverOpenTop: "data-blok-popover-open-top",
889
+ /** Popover opens leftward */
890
+ popoverOpenLeft: "data-blok-popover-open-left",
891
+ // ============================================
892
+ // Popover Nesting
893
+ // ============================================
894
+ /** Nested popover indicator */
895
+ nested: "data-blok-nested",
896
+ /** Nesting level value */
897
+ nestedLevel: "data-blok-nested-level",
898
+ // ============================================
899
+ // Popover Header
900
+ // ============================================
901
+ /** Header container */
902
+ popoverHeader: "data-blok-popover-header",
903
+ /** Header text element */
904
+ popoverHeaderText: "data-blok-popover-header-text",
905
+ /** Back button in nested popover */
906
+ popoverHeaderBackButton: "data-blok-popover-header-back-button",
907
+ // ============================================
908
+ // Popover Items
909
+ // ============================================
910
+ /** Item container */
911
+ popoverItem: "data-blok-popover-item",
912
+ /** Item icon wrapper */
913
+ popoverItemIcon: "data-blok-popover-item-icon",
914
+ /** Chevron icon for nested items */
915
+ popoverItemIconChevronRight: "data-blok-popover-item-icon-chevron-right",
916
+ /** Item title text */
917
+ popoverItemTitle: "data-blok-popover-item-title",
918
+ /** Item secondary title */
919
+ popoverItemSecondaryTitle: "data-blok-popover-item-secondary-title",
920
+ /** Item is active/selected */
921
+ popoverItemActive: "data-blok-popover-item-active",
922
+ /** Confirmation state */
923
+ popoverItemConfirmation: "data-blok-popover-item-confirmation",
924
+ /** Disable hover styling */
925
+ popoverItemNoHover: "data-blok-popover-item-no-hover",
926
+ /** Disable focus handling */
927
+ popoverItemNoFocus: "data-blok-popover-item-no-focus",
928
+ /** Wobble animation */
929
+ popoverItemWobble: "data-blok-popover-item-wobble",
930
+ /** Separator item */
931
+ popoverItemSeparator: "data-blok-popover-item-separator",
932
+ /** Separator line element */
933
+ popoverItemSeparatorLine: "data-blok-popover-item-separator-line",
934
+ /** HTML-based item */
935
+ popoverItemHtml: "data-blok-popover-item-html",
936
+ /** Item has child menu */
937
+ hasChildren: "data-blok-has-children",
938
+ /** Item name identifier */
939
+ itemName: "data-blok-item-name",
940
+ /** No search results shown */
941
+ nothingFoundDisplayed: "data-blok-nothing-found-displayed",
942
+ // ============================================
943
+ // Overlay / Selection
944
+ // ============================================
945
+ /** Selection overlay */
946
+ overlay: "data-blok-overlay",
947
+ /** Overlay container */
948
+ overlayContainer: "data-blok-overlay-container",
949
+ /** Selection rectangle */
950
+ overlayRectangle: "data-blok-overlay-rectangle",
951
+ /** Overlay is hidden */
952
+ overlayHidden: "data-blok-overlay-hidden",
953
+ /** Fake cursor indicator */
954
+ fakeCursor: "data-blok-fake-cursor",
955
+ /** Fake background for selection */
956
+ fakeBackground: "data-blok-fake-background",
957
+ // ============================================
958
+ // Scroll
959
+ // ============================================
960
+ /** Auto-scroll zone (top/bottom) */
961
+ scrollZone: "data-blok-scroll-zone",
962
+ /** Scroll is locked */
963
+ scrollLocked: "data-blok-scroll-locked",
964
+ /** Hard scroll lock */
965
+ scrollLockedHard: "data-blok-scroll-locked-hard",
966
+ // ============================================
967
+ // Caret
968
+ // ============================================
969
+ /** Shadow caret element */
970
+ shadowCaret: "data-blok-shadow-caret",
971
+ // ============================================
972
+ // Placeholders
973
+ // ============================================
974
+ /** Placeholder text */
975
+ placeholder: "data-blok-placeholder",
976
+ /** Active placeholder text */
977
+ placeholderActive: "data-blok-placeholder-active",
978
+ // ============================================
979
+ // Mutation Tracking
980
+ // ============================================
981
+ /** Element excluded from mutation tracking */
982
+ mutationFree: "data-blok-mutation-free",
983
+ // ============================================
984
+ // Navigation
985
+ // ============================================
986
+ /** Block has navigation focus */
987
+ navigationFocused: "data-blok-navigation-focused",
988
+ /** Flipper navigation target */
989
+ flipperNavigationTarget: "data-blok-flipper-navigation-target",
990
+ // ============================================
991
+ // Inline Toolbar
992
+ // ============================================
993
+ /** Inline toolbar enabled on external element */
994
+ inlineToolbar: "data-blok-inline-toolbar",
995
+ // ============================================
996
+ // Link Tool
997
+ // ============================================
998
+ /** Link tool is active */
999
+ linkToolActive: "data-blok-link-tool-active",
1000
+ /** Link tool unlink mode */
1001
+ linkToolUnlink: "data-blok-link-tool-unlink",
1002
+ /** Link tool input is opened */
1003
+ linkToolInputOpened: "data-blok-link-tool-input-opened",
1004
+ // ============================================
1005
+ // Bold Tool
1006
+ // ============================================
1007
+ /** Bold collapsed length tracking */
1008
+ boldCollapsedLength: "data-blok-bold-collapsed-length",
1009
+ /** Bold collapsed active state */
1010
+ boldCollapsedActive: "data-blok-bold-collapsed-active",
1011
+ /** Bold previous length tracking */
1012
+ boldPrevLength: "data-blok-bold-prev-length",
1013
+ /** Bold leading whitespace */
1014
+ boldLeadingWs: "data-blok-bold-leading-ws",
1015
+ /** Bold marker */
1016
+ boldMarker: "data-blok-bold-marker",
1017
+ // ============================================
1018
+ // Tooltip
1019
+ // ============================================
1020
+ /** Tooltip is shown */
1021
+ shown: "data-blok-shown",
1022
+ /** Tooltip placement */
1023
+ placement: "data-blok-placement",
1024
+ // ============================================
1025
+ // Notifier
1026
+ // ============================================
1027
+ /** Bounce in animation */
1028
+ bounceIn: "data-blok-bounce-in",
1029
+ // ============================================
1030
+ // Announcer (Accessibility)
1031
+ // ============================================
1032
+ /** Live region announcer */
1033
+ announcer: "data-blok-announcer",
1034
+ // ============================================
1035
+ // Stub Block
1036
+ // ============================================
1037
+ /** Stub block element */
1038
+ stub: "data-blok-stub",
1039
+ /** Stub info section */
1040
+ stubInfo: "data-blok-stub-info",
1041
+ /** Stub title */
1042
+ stubTitle: "data-blok-stub-title",
1043
+ /** Stub subtitle */
1044
+ stubSubtitle: "data-blok-stub-subtitle",
1045
+ // ============================================
1046
+ // Testing
1047
+ // ============================================
1048
+ /** Test identifier (for E2E tests) */
1049
+ testid: "data-blok-testid",
1050
+ /** Force hover state (for tests/storybook) */
1051
+ forceHover: "data-blok-force-hover"
1052
+ }, R = (o, t) => t === void 0 ? `[${o}]` : `[${o}="${t}"]`, Zt = 180, zt = 400, Xt = "blok", qt = "inline-toolbar", Kt = "tooltip", Jt = "[data-blok-interface=inline-toolbar]";
1053
+ typeof process != "undefined" && process.platform ? process.platform === "darwin" ? "Meta" : "Control" : typeof navigator != "undefined" && navigator.userAgent.toLowerCase().includes("mac") ? "Meta" : "Control";
1054
+ class v {
1055
+ constructor() {
1056
+ this.instance = null, this.selection = null, this.savedSelectionRange = null, this.isFakeBackgroundEnabled = !1, this.selectionContainer = null;
1057
+ }
1058
+ /**
1059
+ * Returns selected anchor
1060
+ * {@link https://developer.mozilla.org/ru/docs/Web/API/Selection/anchorNode}
1061
+ * @returns {Node|null}
1062
+ */
1063
+ static get anchorNode() {
1064
+ const t = window.getSelection();
1065
+ return t ? t.anchorNode : null;
1066
+ }
1067
+ /**
1068
+ * Returns selected anchor element
1069
+ * @returns {Element|null}
1070
+ */
1071
+ static get anchorElement() {
1072
+ const t = window.getSelection();
1073
+ if (!t)
1074
+ return null;
1075
+ const e = t.anchorNode;
1076
+ return e ? p.isElement(e) ? e : e.parentElement : null;
1077
+ }
1078
+ /**
1079
+ * Returns selection offset according to the anchor node
1080
+ * {@link https://developer.mozilla.org/ru/docs/Web/API/Selection/anchorOffset}
1081
+ * @returns {number|null}
1082
+ */
1083
+ static get anchorOffset() {
1084
+ const t = window.getSelection();
1085
+ return t ? t.anchorOffset : null;
1086
+ }
1087
+ /**
1088
+ * Is current selection range collapsed
1089
+ * @returns {boolean|null}
1090
+ */
1091
+ static get isCollapsed() {
1092
+ const t = window.getSelection();
1093
+ return t ? t.isCollapsed : null;
1094
+ }
1095
+ /**
1096
+ * Check current selection if it is at Blok's zone
1097
+ * @returns {boolean}
1098
+ */
1099
+ static get isAtBlok() {
1100
+ return this.isSelectionAtBlok(v.get());
1101
+ }
1102
+ /**
1103
+ * Check if passed selection is at Blok's zone
1104
+ * @param selection - Selection object to check
1105
+ */
1106
+ static isSelectionAtBlok(t) {
1107
+ if (!t)
1108
+ return !1;
1109
+ const e = t.anchorNode || t.focusNode, n = e && e.nodeType === Node.TEXT_NODE ? e.parentNode : e, r = n && n instanceof Element ? n.closest(R(E.redactor)) : null;
1110
+ return r ? r.nodeType === Node.ELEMENT_NODE : !1;
1111
+ }
1112
+ /**
1113
+ * Check if passed range at Blok zone
1114
+ * @param range - range to check
1115
+ */
1116
+ static isRangeAtBlok(t) {
1117
+ if (!t)
1118
+ return;
1119
+ const e = t.startContainer && t.startContainer.nodeType === Node.TEXT_NODE ? t.startContainer.parentNode : t.startContainer, n = e && e instanceof Element ? e.closest(R(E.redactor)) : null;
1120
+ return n ? n.nodeType === Node.ELEMENT_NODE : !1;
1121
+ }
1122
+ /**
1123
+ * Methods return boolean that true if selection exists on the page
1124
+ */
1125
+ static get isSelectionExists() {
1126
+ const t = v.get();
1127
+ return !!(t != null && t.anchorNode);
1128
+ }
1129
+ /**
1130
+ * Return first range
1131
+ * @returns {Range|null}
1132
+ */
1133
+ static get range() {
1134
+ return this.getRangeFromSelection(this.get());
1135
+ }
1136
+ /**
1137
+ * Returns range from passed Selection object
1138
+ * @param selection - Selection object to get Range from
1139
+ */
1140
+ static getRangeFromSelection(t) {
1141
+ return t && t.rangeCount ? t.getRangeAt(0) : null;
1142
+ }
1143
+ /**
1144
+ * Calculates position and size of selected text
1145
+ * @returns {DOMRect}
1146
+ */
1147
+ static get rect() {
1148
+ const t = document.selection, e = {
1149
+ x: 0,
1150
+ y: 0,
1151
+ width: 0,
1152
+ height: 0
1153
+ };
1154
+ if (t && t.type !== "Control") {
1155
+ const l = t.createRange();
1156
+ return e.x = l.boundingLeft, e.y = l.boundingTop, e.width = l.boundingWidth, e.height = l.boundingHeight, e;
1157
+ }
1158
+ const n = window.getSelection();
1159
+ if (!n)
1160
+ return M("Method window.getSelection returned null", "warn"), e;
1161
+ if (n.rangeCount === null || isNaN(n.rangeCount))
1162
+ return M("Method SelectionUtils.rangeCount is not supported", "warn"), e;
1163
+ if (n.rangeCount === 0)
1164
+ return e;
1165
+ const r = n.getRangeAt(0).cloneRange(), s = r.getBoundingClientRect();
1166
+ if (s.x === 0 && s.y === 0) {
1167
+ const i = document.createElement("span");
1168
+ i.appendChild(document.createTextNode("​")), r.insertNode(i);
1169
+ const l = i.getBoundingClientRect(), c = i.parentNode;
1170
+ return c == null || c.removeChild(i), c == null || c.normalize(), l;
1171
+ }
1172
+ return s;
1173
+ }
1174
+ /**
1175
+ * Returns selected text as String
1176
+ * @returns {string}
1177
+ */
1178
+ static get text() {
1179
+ var e;
1180
+ const t = window.getSelection();
1181
+ return (e = t == null ? void 0 : t.toString()) != null ? e : "";
1182
+ }
1183
+ /**
1184
+ * Returns window SelectionUtils
1185
+ * {@link https://developer.mozilla.org/ru/docs/Web/API/Window/getSelection}
1186
+ * @returns {Selection}
1187
+ */
1188
+ static get() {
1189
+ return window.getSelection();
1190
+ }
1191
+ /**
1192
+ * Set focus to contenteditable or native input element
1193
+ * @param element - element where to set focus
1194
+ * @param offset - offset of cursor
1195
+ */
1196
+ static setCursor(t, e = 0) {
1197
+ const n = document.createRange(), r = window.getSelection(), s = p.isNativeInput(t);
1198
+ if (s && !p.canSetCaret(t))
1199
+ return t.getBoundingClientRect();
1200
+ if (s) {
1201
+ const i = t;
1202
+ return i.focus(), i.selectionStart = e, i.selectionEnd = e, i.getBoundingClientRect();
1203
+ }
1204
+ return n.setStart(t, e), n.setEnd(t, e), r ? (r.removeAllRanges(), r.addRange(n), n.getBoundingClientRect()) : t.getBoundingClientRect();
1205
+ }
1206
+ /**
1207
+ * Check if current range exists and belongs to container
1208
+ * @param container - where range should be
1209
+ */
1210
+ static isRangeInsideContainer(t) {
1211
+ const e = v.range;
1212
+ return e === null ? !1 : t.contains(e.startContainer);
1213
+ }
1214
+ /**
1215
+ * Adds fake cursor to the current range
1216
+ */
1217
+ static addFakeCursor() {
1218
+ const t = v.range;
1219
+ if (t === null)
1220
+ return;
1221
+ const e = p.make("span");
1222
+ e.setAttribute(E.fakeCursor, ""), e.setAttribute("data-blok-mutation-free", "true"), t.collapse(), t.insertNode(e);
1223
+ }
1224
+ /**
1225
+ * Check if passed element contains a fake cursor
1226
+ * @param el - where to check
1227
+ */
1228
+ static isFakeCursorInsideContainer(t) {
1229
+ return p.find(t, R(E.fakeCursor)) !== null;
1230
+ }
1231
+ /**
1232
+ * Removes fake cursor from a container
1233
+ * @param container - container to look for
1234
+ */
1235
+ static removeFakeCursor(t = document.body) {
1236
+ const e = p.find(t, R(E.fakeCursor));
1237
+ e && e.remove();
1238
+ }
1239
+ /**
1240
+ * Removes fake background
1241
+ * Unwraps the highlight spans and restores the selection
1242
+ */
1243
+ removeFakeBackground() {
1244
+ this.removeOrphanedFakeBackgroundElements(), this.isFakeBackgroundEnabled && (this.removeHighlightSpans(), this.isFakeBackgroundEnabled = !1, this.selectionContainer = null);
1245
+ }
1246
+ /**
1247
+ * Removes highlight spans and reconstructs the saved selection range
1248
+ */
1249
+ removeHighlightSpans() {
1250
+ var i;
1251
+ const t = document.querySelectorAll('[data-blok-fake-background="true"]');
1252
+ if (t.length === 0)
1253
+ return;
1254
+ const e = t[0], n = t[t.length - 1], r = e.firstChild, s = n.lastChild;
1255
+ if (t.forEach((l) => {
1256
+ this.unwrapFakeBackground(l);
1257
+ }), r && s) {
1258
+ const l = document.createRange();
1259
+ l.setStart(r, 0), l.setEnd(s, ((i = s.textContent) == null ? void 0 : i.length) || 0), this.savedSelectionRange = l;
1260
+ }
1261
+ }
1262
+ /**
1263
+ * Removes any fake background elements from the DOM that are not tracked
1264
+ * This handles cleanup after undo/redo operations that may restore fake background elements
1265
+ * Also provides backwards compatibility with old fake background approach
1266
+ */
1267
+ removeOrphanedFakeBackgroundElements() {
1268
+ document.querySelectorAll('[data-blok-fake-background="true"]').forEach((e) => {
1269
+ this.unwrapFakeBackground(e);
1270
+ });
1271
+ }
1272
+ /**
1273
+ * Clears all fake background state - both DOM elements and internal flags
1274
+ * This is useful for cleanup after undo/redo operations or when the selection context has been lost
1275
+ */
1276
+ clearFakeBackground() {
1277
+ this.removeOrphanedFakeBackgroundElements(), this.isFakeBackgroundEnabled = !1, this.selectionContainer = null;
1278
+ }
1279
+ /**
1280
+ * Sets fake background by wrapping selected text in highlight spans
1281
+ * Uses a gray background color to simulate the "unfocused selection" appearance
1282
+ * similar to how Notion shows selections when focus moves to another element
1283
+ */
1284
+ setFakeBackground() {
1285
+ this.removeFakeBackground();
1286
+ const t = window.getSelection();
1287
+ if (!t || t.rangeCount === 0)
1288
+ return;
1289
+ const e = t.getRangeAt(0);
1290
+ if (e.collapsed)
1291
+ return;
1292
+ const n = e.commonAncestorContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement;
1293
+ this.selectionContainer = r == null ? void 0 : r.closest('[contenteditable="true"]');
1294
+ const s = this.collectTextNodes(e);
1295
+ if (s.length === 0)
1296
+ return;
1297
+ const i = e.startContainer, l = e.startOffset, c = e.endContainer, a = e.endOffset, d = [];
1298
+ if (s.forEach((f) => {
1299
+ var P, V;
1300
+ const b = document.createRange(), w = f === i, k = f === c, C = w ? l : 0, y = (V = (P = f.textContent) == null ? void 0 : P.length) != null ? V : 0, S = k ? a : y;
1301
+ if (C === S)
1302
+ return;
1303
+ b.setStart(f, C), b.setEnd(f, S);
1304
+ const j = this.wrapRangeWithHighlight(b);
1305
+ j && d.push(j);
1306
+ }), d.length === 0)
1307
+ return;
1308
+ const u = this.postProcessHighlightWrappers(d);
1309
+ this.applyLineHeightExtensions(u);
1310
+ const g = document.createRange();
1311
+ g.setStartBefore(u[0]), g.setEndAfter(u[u.length - 1]), this.savedSelectionRange = g.cloneRange();
1312
+ const h = window.getSelection();
1313
+ h && (h.removeAllRanges(), h.addRange(g)), this.isFakeBackgroundEnabled = !0;
1314
+ }
1315
+ /**
1316
+ * Collects text nodes that intersect with the passed range
1317
+ * @param range - selection range
1318
+ */
1319
+ collectTextNodes(t) {
1320
+ const e = [], { commonAncestorContainer: n } = t;
1321
+ if (n.nodeType === Node.TEXT_NODE)
1322
+ return e.push(n), e;
1323
+ const r = document.createTreeWalker(
1324
+ n,
1325
+ NodeFilter.SHOW_TEXT,
1326
+ {
1327
+ acceptNode: (s) => t.intersectsNode(s) && s.textContent && s.textContent.length > 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
1328
+ }
1329
+ );
1330
+ for (; r.nextNode(); )
1331
+ e.push(r.currentNode);
1332
+ return e;
1333
+ }
1334
+ /**
1335
+ * Wraps passed range with a highlight span styled like an unfocused selection (gray)
1336
+ * @param range - range to wrap
1337
+ */
1338
+ wrapRangeWithHighlight(t) {
1339
+ if (t.collapsed)
1340
+ return null;
1341
+ const e = p.make("span");
1342
+ e.setAttribute("data-blok-testid", "fake-background"), e.setAttribute("data-blok-fake-background", "true"), e.setAttribute("data-blok-mutation-free", "true"), e.style.color = "inherit", e.style.boxDecorationBreak = "clone", e.style["-webkit-box-decoration-break"] = "clone", e.style.whiteSpace = "pre-wrap";
1343
+ const n = t.extractContents();
1344
+ return n.childNodes.length === 0 ? null : (e.appendChild(n), t.insertNode(e), e);
1345
+ }
1346
+ /**
1347
+ * Post-processes highlight wrappers to split multi-line spans and apply proper styling
1348
+ * @param wrappers - array of wrapper elements
1349
+ * @returns array of all wrapper elements (may be more than input if splits occurred)
1350
+ */
1351
+ postProcessHighlightWrappers(t) {
1352
+ const e = [];
1353
+ return t.forEach((n) => {
1354
+ const r = this.splitMultiLineWrapper(n);
1355
+ e.push(...r);
1356
+ }), e;
1357
+ }
1358
+ /**
1359
+ * Splits a multi-line wrapper into separate spans per line and applies box-shadow to each
1360
+ * This ensures gaps between lines are properly filled
1361
+ * @param wrapper - the highlight wrapper element
1362
+ * @returns array of wrapper elements (original if single line, or new per-line wrappers)
1363
+ */
1364
+ splitMultiLineWrapper(t) {
1365
+ const e = t.getClientRects();
1366
+ if (e.length <= 1)
1367
+ return this.applyBoxShadowToWrapper(t), [t];
1368
+ const n = t.textContent || "", r = t.parentNode;
1369
+ if (!r || !n)
1370
+ return this.applyBoxShadowToWrapper(t), [t];
1371
+ const s = [], i = t.firstChild;
1372
+ if (!i || i.nodeType !== Node.TEXT_NODE)
1373
+ return this.applyBoxShadowToWrapper(t), [t];
1374
+ const l = this.findLineBreakPositions(i, e.length);
1375
+ if (l.length === 0)
1376
+ return this.applyBoxShadowToWrapper(t), [t];
1377
+ const c = this.splitTextAtPositions(n, l), a = document.createDocumentFragment();
1378
+ return c.forEach((d) => {
1379
+ if (d.length === 0)
1380
+ return;
1381
+ const u = p.make("span");
1382
+ u.setAttribute("data-blok-testid", "fake-background"), u.setAttribute("data-blok-fake-background", "true"), u.setAttribute("data-blok-mutation-free", "true"), u.style.color = "inherit", u.style.boxDecorationBreak = "clone", u.style["-webkit-box-decoration-break"] = "clone", u.style.whiteSpace = "pre-wrap", u.textContent = d, a.appendChild(u), s.push(u);
1383
+ }), r.replaceChild(a, t), s;
1384
+ }
1385
+ /**
1386
+ * Splits text content at given positions
1387
+ */
1388
+ splitTextAtPositions(t, e) {
1389
+ const n = [0, ...e, t.length];
1390
+ return n.slice(0, -1).map((r, s) => t.substring(r, n[s + 1])).filter((r) => r.length > 0);
1391
+ }
1392
+ /**
1393
+ * Finds positions in text where line breaks occur
1394
+ * @param textNode - the text node to analyze
1395
+ * @param expectedLines - expected number of lines
1396
+ */
1397
+ findLineBreakPositions(t, e) {
1398
+ const n = t.textContent || "", r = document.createRange();
1399
+ return Array.from({ length: n.length }, (l, c) => c).reduce(
1400
+ (l, c) => {
1401
+ if (l.positions.length >= e - 1)
1402
+ return l;
1403
+ r.setStart(t, c), r.setEnd(t, c + 1);
1404
+ const a = r.getBoundingClientRect();
1405
+ return l.lastTop !== -1 && Math.abs(a.top - l.lastTop) > 5 && l.positions.push(c), { positions: l.positions, lastTop: a.top };
1406
+ },
1407
+ { positions: [], lastTop: -1 }
1408
+ ).positions;
1409
+ }
1410
+ /**
1411
+ * Applies box-shadow to a wrapper to extend the background to fill line-height
1412
+ * @param wrapper - the wrapper element
1413
+ */
1414
+ applyBoxShadowToWrapper(t) {
1415
+ const e = t.parentElement;
1416
+ if (!e)
1417
+ return;
1418
+ const n = window.getComputedStyle(e), r = window.getComputedStyle(t), s = parseFloat(n.lineHeight), i = parseFloat(r.fontSize), l = isNaN(s) ? i * 1.2 : s, c = t.getBoundingClientRect(), a = Math.max(0, (l - c.height) / 2);
1419
+ if (a > 0) {
1420
+ const d = "rgba(0, 0, 0, 0.08)";
1421
+ t.style.boxShadow = `0 ${a}px 0 ${d}, 0 -${a}px 0 ${d}`;
1422
+ }
1423
+ }
1424
+ /**
1425
+ * Applies additional box-shadow extensions to fill gaps between separate spans
1426
+ * This is only needed when there are multiple spans that may have gaps between them
1427
+ * @param spans - array of highlight span elements
1428
+ */
1429
+ applyLineHeightExtensions(t) {
1430
+ const e = "rgba(0, 0, 0, 0.08)", n = this.collectAllLineRects(t);
1431
+ if (n.length === 0)
1432
+ return;
1433
+ n.sort((s, i) => s.top - i.top);
1434
+ const r = this.groupRectsByLine(n);
1435
+ t.forEach((s) => {
1436
+ this.applyMultiLineBoxShadow(s, r, e);
1437
+ });
1438
+ }
1439
+ /**
1440
+ * Collects all line rectangles from all spans using getClientRects()
1441
+ */
1442
+ collectAllLineRects(t) {
1443
+ const e = [];
1444
+ return t.forEach((n) => {
1445
+ const r = n.getClientRects();
1446
+ Array.from(r).forEach((s) => {
1447
+ e.push({
1448
+ top: s.top,
1449
+ bottom: s.bottom,
1450
+ span: n
1451
+ });
1452
+ });
1453
+ }), e;
1454
+ }
1455
+ /**
1456
+ * Groups rectangles by their visual line
1457
+ */
1458
+ groupRectsByLine(t) {
1459
+ const e = [];
1460
+ return t.forEach((n) => {
1461
+ const r = e.find((s) => Math.abs(s.top - n.top) < 2);
1462
+ r ? (r.top = Math.min(r.top, n.top), r.bottom = Math.max(r.bottom, n.bottom)) : e.push({ top: n.top, bottom: n.bottom });
1463
+ }), e.sort((n, r) => n.top - r.top), e;
1464
+ }
1465
+ /**
1466
+ * Applies box-shadow to a span that may span multiple lines
1467
+ * Calculates extensions based on the span's position within the overall selection
1468
+ */
1469
+ applyMultiLineBoxShadow(t, e, n) {
1470
+ const r = t.getClientRects();
1471
+ if (r.length === 0)
1472
+ return;
1473
+ const s = t.parentElement;
1474
+ if (!s)
1475
+ return;
1476
+ const i = window.getComputedStyle(s), l = parseFloat(i.lineHeight), c = parseFloat(window.getComputedStyle(t).fontSize), a = isNaN(l) ? c * 1.2 : l, d = r[0], u = r[r.length - 1], g = this.findLineIndex(d.top, e), h = this.findLineIndex(u.top, e), f = r.length > 1 && g !== h, b = g === 0, w = h === e.length - 1, k = Math.max(0, (a - d.height) / 2), C = f ? this.calculateLineTopExtension(k, b, e, g) : k, y = f ? this.calculateLineBottomExtension(k, w, e, h) : k, S = this.buildBoxShadow(C, y, n);
1477
+ t.style.boxShadow = S;
1478
+ }
1479
+ /**
1480
+ * Finds the line index for a given top position
1481
+ */
1482
+ findLineIndex(t, e) {
1483
+ const n = e.findIndex((r) => Math.abs(r.top - t) < 5);
1484
+ return n >= 0 ? n : 0;
1485
+ }
1486
+ /**
1487
+ * Calculates top extension for a line
1488
+ * Only uses base extension - gaps are filled by the previous line's bottom extension
1489
+ */
1490
+ calculateLineTopExtension(t, e, n, r) {
1491
+ return t;
1492
+ }
1493
+ /**
1494
+ * Calculates bottom extension for a line, accounting for gap to next line
1495
+ * The bottom extension fills the gap up to where the next line's top extension begins
1496
+ * This prevents overlap: line N's bottom shadow meets line N+1's top shadow exactly
1497
+ */
1498
+ calculateLineBottomExtension(t, e, n, r) {
1499
+ if (e)
1500
+ return t;
1501
+ const s = n[r], l = n[r + 1].top - s.bottom, a = Math.max(0, l - t);
1502
+ return t + a;
1503
+ }
1504
+ /**
1505
+ * Builds box-shadow CSS value from top and bottom extensions
1506
+ * Uses inset shadow for the element's own background (to avoid using background-color)
1507
+ * and regular shadows for vertical extensions
1508
+ */
1509
+ buildBoxShadow(t, e, n) {
1510
+ const r = [];
1511
+ return r.push(`inset 0 0 0 9999px ${n}`), e > 0 && r.push(`0 ${e}px 0 ${n}`), t > 0 && r.push(`0 -${t}px 0 ${n}`), r.join(", ");
1512
+ }
1513
+ /**
1514
+ * Removes fake background wrapper (legacy support)
1515
+ * @param element - wrapper element
1516
+ */
1517
+ unwrapFakeBackground(t) {
1518
+ const e = t.parentNode;
1519
+ if (e) {
1520
+ for (; t.firstChild; )
1521
+ e.insertBefore(t.firstChild, t);
1522
+ e.removeChild(t);
1523
+ }
1524
+ }
1525
+ /**
1526
+ * Save SelectionUtils's range
1527
+ */
1528
+ save() {
1529
+ this.savedSelectionRange = v.range;
1530
+ }
1531
+ /**
1532
+ * Restore saved SelectionUtils's range
1533
+ */
1534
+ restore() {
1535
+ if (!this.savedSelectionRange)
1536
+ return;
1537
+ const t = window.getSelection();
1538
+ t && (t.removeAllRanges(), t.addRange(this.savedSelectionRange));
1539
+ }
1540
+ /**
1541
+ * Clears saved selection
1542
+ */
1543
+ clearSaved() {
1544
+ this.savedSelectionRange = null;
1545
+ }
1546
+ /**
1547
+ * Collapse current selection
1548
+ */
1549
+ collapseToEnd() {
1550
+ const t = window.getSelection();
1551
+ if (!t || !t.focusNode)
1552
+ return;
1553
+ const e = document.createRange();
1554
+ e.selectNodeContents(t.focusNode), e.collapse(!1), t.removeAllRanges(), t.addRange(e);
1555
+ }
1556
+ /**
1557
+ * Looks ahead to find passed tag from current selection
1558
+ * @param {string} tagName - tag to found
1559
+ * @param {string} [className] - tag's class name
1560
+ * @param {number} [searchDepth] - count of tags that can be included. For better performance.
1561
+ * @returns {HTMLElement|null}
1562
+ */
1563
+ findParentTag(t, e, n = 10) {
1564
+ const r = window.getSelection();
1565
+ if (!r || !r.anchorNode || !r.focusNode)
1566
+ return null;
1567
+ const s = [
1568
+ /** the Node in which the selection begins */
1569
+ r.anchorNode,
1570
+ /** the Node in which the selection ends */
1571
+ r.focusNode
1572
+ ], i = (l) => {
1573
+ const c = (a, d) => {
1574
+ if (d <= 0 || !a)
1575
+ return null;
1576
+ const u = a.nodeType === Node.ELEMENT_NODE && a.tagName === t, g = !e || a.classList && a.classList.contains(e);
1577
+ if (u && g)
1578
+ return a;
1579
+ if (!a.parentNode)
1580
+ return null;
1581
+ const h = a.parentNode, f = !e || h.classList && h.classList.contains(e);
1582
+ return h.tagName === t && f ? h : c(h, d - 1);
1583
+ };
1584
+ return c(l, n);
1585
+ };
1586
+ for (const l of s) {
1587
+ const c = i(l);
1588
+ if (c)
1589
+ return c;
1590
+ }
1591
+ return null;
1592
+ }
1593
+ /**
1594
+ * Expands selection range to the passed parent node
1595
+ * @param {HTMLElement} element - element which contents should be selected
1596
+ */
1597
+ expandToTag(t) {
1598
+ const e = window.getSelection();
1599
+ if (!e)
1600
+ return;
1601
+ e.removeAllRanges();
1602
+ const n = document.createRange();
1603
+ n.selectNodeContents(t), e.addRange(n);
1604
+ }
1605
+ }
1606
+ const A = (o, t) => {
1607
+ if (!o.conversionConfig)
1608
+ return !1;
1609
+ const e = o.conversionConfig[t];
1610
+ return F(e) || x(e);
1611
+ }, T = (o, t) => {
1612
+ const e = `toolNames.${t}`;
1613
+ return o.has(e) ? o.t(e) : void 0;
1614
+ }, U = (o, t, e = "") => {
1615
+ const n = t.titleKey ? T(o, t.titleKey) : void 0;
1616
+ if (n !== void 0)
1617
+ return n;
1618
+ const r = t.title ? T(o, t.title) : void 0;
1619
+ if (r !== void 0)
1620
+ return r;
1621
+ if (t.title)
1622
+ return t.title;
1623
+ const s = e ? T(o, e) : void 0;
1624
+ return s != null ? s : e;
1625
+ }, vt = (o, t, e) => {
1626
+ const n = t ? T(o, t) : void 0;
1627
+ if (n !== void 0)
1628
+ return n;
1629
+ const r = T(o, e);
1630
+ return r != null ? r : e;
1631
+ }, Z = (o, t) => A(o.tool, t), wt = (o, t) => Object.entries(o).some((([e, n]) => t[e] && H(t[e], n))), J = async (o, t) => {
1632
+ const n = (await o.save()).data, r = t.find((s) => s.name === o.name);
1633
+ return r !== void 0 && !A(r, "export") ? [] : t.reduce((s, i) => {
1634
+ if (!A(i, "import") || i.toolbox === void 0)
1635
+ return s;
1636
+ const l = i.toolbox.filter((c) => {
1637
+ if (q(c) || c.icon === void 0)
1638
+ return !1;
1639
+ const a = c.data !== void 0;
1640
+ return !(a && wt(c.data, n) || !a && i.name === o.name);
1641
+ });
1642
+ return s.push(O(I({}, i), {
1643
+ toolbox: l
1644
+ })), s;
1645
+ }, []);
1646
+ }, Yt = (o, t) => o.mergeable ? o.name === t.name ? !0 : Z(t, "export") && Z(o, "import") : !1, Qt = async (o, t) => {
1647
+ if (o.length === 0)
1648
+ return [];
1649
+ if (o.length === 1)
1650
+ return J(o[0], t);
1651
+ for (const n of o) {
1652
+ const r = t.find((s) => s.name === n.name);
1653
+ if (r !== void 0 && !A(r, "export"))
1654
+ return [];
1655
+ }
1656
+ const e = new Set(o.map((n) => n.name));
1657
+ return t.reduce((n, r) => {
1658
+ if (!A(r, "import") || r.toolbox === void 0)
1659
+ return n;
1660
+ const s = r.toolbox.filter((i) => !(q(i) || i.icon === void 0 || !(i.data !== void 0) && e.size === 1 && e.has(r.name)));
1661
+ return s.length > 0 && n.push(O(I({}, r), {
1662
+ toolbox: s
1663
+ })), n;
1664
+ }, []);
1665
+ }, te = (o, t) => {
1666
+ const e = t == null ? void 0 : t.export;
1667
+ return F(e) ? e(o) : x(e) ? o[e] : (e !== void 0 && M("Conversion «export» property must be a string or function. String means key of saved data object to export. Function should export processed string to export."), "");
1668
+ }, ee = (o, t, e) => {
1669
+ const n = t == null ? void 0 : t.import;
1670
+ return F(n) ? n(o, e) : x(n) ? {
1671
+ [n]: o
1672
+ } : (n !== void 0 && M("Conversion «import» property must be a string or function. String means key of tool data to import. Function accepts a imported string and return composed tool data."), {});
1673
+ };
1674
+ var Ct = /* @__PURE__ */ ((o) => (o.Default = "default", o.Separator = "separator", o.Html = "html", o))(Ct || {});
1675
+ const ne = `
1676
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1677
+ <path d="m4.5 15 11-11m0 11L4.5 4" stroke="currentColor" stroke-linecap="round"/>
1678
+ </svg>
1679
+ `, oe = `
1680
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1681
+ <path
1682
+ d="M5.5 11h4.9231c.6528 0 1.2789-.3161 1.7405-.8787.4617-.56259.721-1.32565.721-2.1213 0-.79565-.2593-1.55871-.721-2.12132C11.702 5.31607 11.0759 5 10.4231 5H5.5v6Zm0 0h5.5385c.6528 0 1.2789.3161 1.7405.8787.4617.5626.721 1.3257.721 2.1213 0 .7956-.2593 1.5587-.721 2.1213-.4616.5626-1.0877.8787-1.7405.8787H5.5v-6Z"
1683
+ stroke="currentColor"
1684
+ stroke-width="1.25"
1685
+ stroke-linecap="round"
1686
+ stroke-linejoin="round"
1687
+ />
1688
+ </svg>
1689
+ `, re = `
1690
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1691
+ <path
1692
+ d="M8.5 5h6m-10 12h6m1-12-4 12"
1693
+ stroke="currentColor"
1694
+ stroke-linecap="round"
1695
+ stroke-linejoin="round"
1696
+ />
1697
+ </svg>
1698
+ `, se = `
1699
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1700
+ <path
1701
+ d="m9.98288 15.0959-.91628.9157c-.29867.3092-.65593.5559-1.05095.7255-.39502.1697-.81987.259-1.24978.2628-.4299.0037-.85625-.0782-1.25415-.241-.39791-.1628-.75941-.4032-1.06341-.7072-.304-.304-.54441-.6655-.70721-1.0634-.16279-.3979-.24471-.8243-.24098-1.2542.00374-.4299.09306-.8547.26274-1.2497.16969-.3951.41635-.7523.72558-1.051l.91499-.9163m8.24197.9156.9163-.9156c.6028-.60809.9402-1.43021.9383-2.28645-.0019-.85625-.3429-1.67688-.9483-2.28234-.6055-.60546-1.4261-.94643-2.2823-.9483-.8563-.00188-1.6784.3355-2.28652.9383l-.91628.91563M7.258 13.2413l4.5328-4.53278"
1702
+ stroke="currentColor"
1703
+ stroke-width=".784151"
1704
+ stroke-linecap="round"
1705
+ stroke-linejoin="round"
1706
+ />
1707
+ </svg>
1708
+ `, ie = `
1709
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1710
+ <path
1711
+ d="M15.5 14.003h-3v-3.0004m-9-6.00078h3v3.0004m1.55478-3.80901A5.2170862 5.2170862 0 0 1 9.5 4.00014c1.1682.00058 2.3059.37321 3.2481 1.06388.9422.69067 1.64 1.66348 1.9923 2.77744.3523 1.11396.3407 2.31114-.033 3.41814-.3738 1.1069-1.0903 2.0661-2.0457 2.7384m-1.7165.8088c-.4703.1317-.9568.1967-1.4452.1931-1.16819-.0006-2.30585-.3733-3.24807-1.0639-.94222-.6907-1.64004-1.6635-1.99232-2.7775-.35229-1.1139-.34072-2.31114.03302-3.41808.37375-1.10694 1.09024-2.06608 2.04563-2.73841"
1712
+ stroke="currentColor"
1713
+ stroke-miterlimit="10"
1714
+ stroke-linecap="round"
1715
+ />
1716
+ </svg>
1717
+ `, ae = `
1718
+ <svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
1719
+ <path
1720
+ d="M8 6c0-.55228.44772-1 1-1s1 .44772 1 1-.44772 1-1 1-1-.44772-1-1Zm0 6c0-.5523.44772-1 1-1s1 .4477 1 1-.44772 1-1 1-1-.4477-1-1Zm0 6c0-.5523.44772-1 1-1s1 .4477 1 1-.44772 1-1 1-1-.4477-1-1Zm6-12c0-.55228.4477-1 1-1s1 .44772 1 1-.4477 1-1 1-1-.44772-1-1Zm0 6c0-.5523.4477-1 1-1s1 .4477 1 1-.4477 1-1 1-1-.4477-1-1Zm0 6c0-.5523.4477-1 1-1s1 .4477 1 1-.4477 1-1 1-1-.4477-1-1Z"
1721
+ fill="currentColor"
1722
+ />
1723
+ </svg>
1724
+ `, le = `
1725
+ <svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
1726
+ <path d="M4.5 11.0711h14.1421m-7.071 7.071V4" stroke="currentColor" stroke-linecap="round"/>
1727
+ </svg>
1728
+ `, ce = `
1729
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1730
+ <path d="m12.5 5-5 5 5 5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
1731
+ </svg>
1732
+ `, de = `
1733
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1734
+ <path d="m7.5 15 5-5-5-5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
1735
+ </svg>
1736
+ `, ue = `
1737
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1738
+ <path
1739
+ d="m17.5 17.5-5-5m1.6667-4.16667c0 .76605-.1509 1.52459-.4441 2.23237-.2931.7077-.7228 1.3507-1.2645 1.8924-.5417.5417-1.1847.9714-1.8924 1.2645-.70778.2932-1.46632.4441-2.23237.4441-.76604 0-1.52458-.1509-2.23232-.4441-.70773-.2931-1.35079-.7228-1.89247-1.2645-.54167-.5417-.97135-1.1847-1.2645-1.8924C2.65088 9.85792 2.5 9.09938 2.5 8.33333c0-1.54709.61458-3.03082 1.70854-4.12479C5.30251 3.11458 6.78624 2.5 8.33333 2.5c1.5471 0 3.03087.61458 4.12477 1.70854 1.094 1.09397 1.7086 2.5777 1.7086 4.12479Z"
1740
+ stroke="currentColor"
1741
+ stroke-linecap="round"
1742
+ stroke-linejoin="round"
1743
+ />
1744
+ </svg>
1745
+ `, pe = `
1746
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1747
+ <path
1748
+ d="M3.33334 10H10m-6.66666 5V5M10 15V5m4.1667 5 2.5-1.66667V15"
1749
+ stroke="currentColor"
1750
+ stroke-linecap="round"
1751
+ stroke-linejoin="round"
1752
+ />
1753
+ </svg>
1754
+ `, ge = `
1755
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1756
+ <path
1757
+ d="M3.33334 10H10m-6.66666 5V5M10 15V5m7.5 10h-3.3333c0-3.3333 3.3333-2.5 3.3333-5 0-1.25-1.6667-2.08333-3.3333-.83333"
1758
+ stroke="currentColor"
1759
+ stroke-linecap="round"
1760
+ stroke-linejoin="round"
1761
+ />
1762
+ </svg>
1763
+ `, he = `
1764
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1765
+ <path
1766
+ d="M3.33334 10H10m-6.66666 5V5M10 15V5m4.5833 3.75C16 7.91667 17.5 8.75 17.5 10c0 .442-.1756.866-.4882 1.1785-.3125.3126-.7364.4882-1.1785.4882.4421 0 .866.1756 1.1785.4881.3126.3126.4882.7365.4882 1.1785 0 1.5-1.6667 2.5-3.3333 1.25"
1767
+ stroke="currentColor"
1768
+ stroke-linecap="round"
1769
+ stroke-linejoin="round"
1770
+ />
1771
+ </svg>
1772
+ `, fe = `
1773
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
1774
+ <path
1775
+ d="M10 15V5M14.1667 8.33333V10.8333C14.1667 11.0543 14.2545 11.2663 14.4107 11.4226C14.567 11.5789 14.779 11.6667 15 11.6667H17.5M17.5 8.33333V15M3.33334 10H10M3.33334 15V5"
1776
+ stroke="black"
1777
+ stroke-linecap="round"
1778
+ stroke-linejoin="round"
1779
+ />
1780
+ </svg>
1781
+ `, me = `
1782
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
1783
+ <path
1784
+ d="M3.33334 10H10M3.33334 15V5M10 15V5M17.5 8.33333H14.1667V10.8333H15.25C16.5 10.8333 17.5 11.75 17.5 12.9167C17.5 14.0833 16.5 15 15.25 15C14.8333 15 14.5 14.9167 14.1667 14.75"
1785
+ stroke="black"
1786
+ stroke-linecap="round"
1787
+ stroke-linejoin="round"
1788
+ />
1789
+ </svg>
1790
+ `, ke = `
1791
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1792
+ <path
1793
+ d="M3.33334 10H10m-6.66666 5V5M10 15V5m4.1667 8.3333c0 .9205.7462 1.6667 1.6666 1.6667.9205 0 1.6667-.7462 1.6667-1.6667 0-.9204-.7462-1.6666-1.6667-1.6666-.9204 0-1.6666.7462-1.6666 1.6666Zm0 0c0-2.0833.8333-3.3333 2.5-4.99997"
1794
+ stroke="currentColor"
1795
+ stroke-linecap="round"
1796
+ stroke-linejoin="round"
1797
+ />
1798
+ </svg>
1799
+ `, be = `
1800
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1801
+ <path
1802
+ d="M6.5 10h6.6667M6.5 15V5m6.6667 10V5"
1803
+ stroke="currentColor"
1804
+ stroke-linecap="round"
1805
+ stroke-linejoin="round"
1806
+ />
1807
+ </svg>
1808
+ `, ve = `
1809
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1810
+ <path
1811
+ d="M14.5 7.28571V6h-9v1.28571M10 6v9m0 0H8.71429M10 15h1.2857"
1812
+ stroke="currentColor"
1813
+ stroke-linecap="round"
1814
+ stroke-linejoin="round"
1815
+ />
1816
+ </svg>
1817
+ `, we = `
1818
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1819
+ <path
1820
+ d="M18.5667 18H1.5l8.5333-16 8.5334 16Z"
1821
+ stroke="currentColor"
1822
+ stroke-width="1.06667"
1823
+ stroke-linecap="round"
1824
+ stroke-linejoin="round"
1825
+ />
1826
+ <rect x="9.75" y="14.25" width=".5" height=".5" rx=".25" fill="currentColor" stroke="currentColor" stroke-width=".5"/>
1827
+ <rect x="9.75" y="8.25" width=".5" height="4.5" rx=".25" fill="currentColor" stroke="currentColor" stroke-width=".5"/>
1828
+ </svg>
1829
+ `, Ce = `
1830
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1831
+ <path
1832
+ d="M8 5h9M8 10h9M8 15h9M4 5h.01M4 10h.01M4 15h.01"
1833
+ stroke="currentColor"
1834
+ stroke-linecap="round"
1835
+ stroke-linejoin="round"
1836
+ />
1837
+ </svg>
1838
+ `, ye = `
1839
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1840
+ <path d="M7.90873 4.60317h9.61907M4.70238 6.20635V3L3.5 4.20238m1.60317 7.61512H3.5l1.52702-2.37514c.02625-.03721.04486-.07925.05477-.12369.0099-.04444.01091-.09039.00295-.13523-.04569-.2068-.20922-.57233-.78315-.57233-.80159 0-.80159.71261-.80159.71261v.17795m0 7.92693h.80159c.21259 0 .41648-.0845.56681-.2348.15032-.1503.23477-.3542.23477-.5668 0-.2126-.08445-.4165-.23477-.5668-.15033-.1503-.35422-.2348-.56681-.2348h-.4008l1.20238-1.6032H3.5m4.40873-4.0079h9.61907m-9.61907 5.6111h9.61907" stroke="#000" stroke-width=".841667" stroke-linecap="round" stroke-linejoin="round"/>
1841
+ </svg>
1842
+ `, Ee = `
1843
+ <svg width="20" height="20" fill="none" xmlns="http://www.w3.org/2000/svg">
1844
+ <path
1845
+ d="M10 5h7M10 10h7M10 15h7M3 5l1 1 2-2M3 10l1 1 2-2M3 15l1 1 2-2"
1846
+ stroke="currentColor"
1847
+ stroke-linecap="round"
1848
+ stroke-linejoin="round"
1849
+ />
1850
+ </svg>
1851
+ `, G = class G {
1852
+ /**
1853
+ * @param api - Blok API
1854
+ */
1855
+ constructor({ api: t }) {
1856
+ this.i18nAPI = t.i18n, this.blocksAPI = t.blocks, this.selectionAPI = t.selection, this.toolsAPI = t.tools, this.caretAPI = t.caret, this.i18nInstance = {
1857
+ t: (e, n) => this.i18nAPI.t(e),
1858
+ has: (e) => this.i18nAPI.t(e) !== e
1859
+ };
1860
+ }
1861
+ /**
1862
+ * Returns tool's UI config
1863
+ */
1864
+ async render() {
1865
+ const t = v.get();
1866
+ if (t === null)
1867
+ return [];
1868
+ const e = this.blocksAPI.getBlockByElement(t.anchorNode);
1869
+ if (e === void 0)
1870
+ return [];
1871
+ const n = this.toolsAPI.getBlockTools(), r = await J(e, n);
1872
+ if (r.length === 0)
1873
+ return [];
1874
+ const s = r.reduce((a, d) => {
1875
+ var u;
1876
+ return (u = d.toolbox) == null || u.forEach((g) => {
1877
+ g.title !== void 0 && a.push({
1878
+ icon: g.icon,
1879
+ title: U(this.i18nInstance, g, d.name),
1880
+ name: d.name,
1881
+ closeOnActivate: !0,
1882
+ onActivate: async () => {
1883
+ const h = await this.blocksAPI.convert(e.id, d.name, g.data);
1884
+ this.caretAPI.setToBlock(h, "end");
1885
+ }
1886
+ });
1887
+ }), a;
1888
+ }, []), i = await e.getActiveToolboxEntry(), l = i ? U(this.i18nInstance, i, e.name) : vt(this.i18nInstance, e.name, ut(e.name)), c = !gt();
1889
+ return {
1890
+ name: "convert-to",
1891
+ title: l,
1892
+ hint: {
1893
+ title: this.i18nAPI.t("popover.convertTo")
1894
+ },
1895
+ children: {
1896
+ items: s,
1897
+ onOpen: () => {
1898
+ c && (this.selectionAPI.setFakeBackground(), this.selectionAPI.save());
1899
+ },
1900
+ onClose: () => {
1901
+ c && (this.selectionAPI.restore(), this.selectionAPI.removeFakeBackground());
1902
+ }
1903
+ }
1904
+ };
1905
+ }
1906
+ };
1907
+ G.isInline = !0;
1908
+ let z = G;
1909
+ export {
1910
+ St as $,
1911
+ U as A,
1912
+ ie as B,
1913
+ ne as C,
1914
+ E as D,
1915
+ $t as E,
1916
+ le as F,
1917
+ dt as G,
1918
+ ae as H,
1919
+ de as I,
1920
+ qt as J,
1921
+ vt as K,
1922
+ Wt as L,
1923
+ Yt as M,
1924
+ ct as N,
1925
+ Z as O,
1926
+ Ct as P,
1927
+ ee as Q,
1928
+ Tt as R,
1929
+ v as S,
1930
+ Kt as T,
1931
+ zt as U,
1932
+ Mt as V,
1933
+ Rt as W,
1934
+ Jt as X,
1935
+ Bt as Y,
1936
+ it as Z,
1937
+ we as _,
1938
+ p as a,
1939
+ z as a0,
1940
+ Lt as a1,
1941
+ Xt as a2,
1942
+ Ft as a3,
1943
+ Gt as a4,
1944
+ pt as a5,
1945
+ Zt as a6,
1946
+ st as a7,
1947
+ xt as a8,
1948
+ Vt as a9,
1949
+ ve as aa,
1950
+ pe as ab,
1951
+ ge as ac,
1952
+ he as ad,
1953
+ fe as ae,
1954
+ me as af,
1955
+ ke as ag,
1956
+ be as ah,
1957
+ Ce as ai,
1958
+ ye as aj,
1959
+ Ee as ak,
1960
+ oe as al,
1961
+ re as am,
1962
+ se as an,
1963
+ Ht as b,
1964
+ F as c,
1965
+ wt as d,
1966
+ te as e,
1967
+ R as f,
1968
+ jt as g,
1969
+ Dt as h,
1970
+ q as i,
1971
+ ut as j,
1972
+ At as k,
1973
+ M as l,
1974
+ L as m,
1975
+ Ot as n,
1976
+ x as o,
1977
+ Nt as p,
1978
+ Ut as q,
1979
+ It as r,
1980
+ Et as s,
1981
+ _t as t,
1982
+ ue as u,
1983
+ gt as v,
1984
+ Pt as w,
1985
+ ce as x,
1986
+ Qt as y,
1987
+ J as z
1988
+ };