@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
@@ -34,138 +34,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
34
 
35
35
  ---
36
36
 
37
- Name: nanoid
38
- Version: 5.1.6
39
- License: MIT
40
- Private: false
41
- Description: A tiny (118 bytes), secure URL-friendly unique string ID generator
42
- Repository: undefined
43
- Author: Andrey Sitnik <andrey@sitnik.ru>
44
- License Copyright:
45
- ===
46
-
47
- The MIT License (MIT)
48
-
49
- Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
50
-
51
- Permission is hereby granted, free of charge, to any person obtaining a copy of
52
- this software and associated documentation files (the "Software"), to deal in
53
- the Software without restriction, including without limitation the rights to
54
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
55
- the Software, and to permit persons to whom the Software is furnished to do so,
56
- subject to the following conditions:
57
-
58
- The above copyright notice and this permission notice shall be included in all
59
- copies or substantial portions of the Software.
60
-
61
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
63
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
64
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
65
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
66
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67
-
68
- ---
69
-
70
- Name: lodash
71
- Version: 4.17.21
72
- License: MIT
73
- Private: false
74
- Description: Lodash modular utilities.
75
- Repository: undefined
76
- Homepage: https://lodash.com/
77
- Author: John-David Dalton <john.david.dalton@gmail.com>
78
- Contributors:
79
- John-David Dalton <john.david.dalton@gmail.com>
80
- Mathias Bynens <mathias@qiwi.be>
81
- License Copyright:
82
- ===
83
-
84
- Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
85
-
86
- Based on Underscore.js, copyright Jeremy Ashkenas,
87
- DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
88
-
89
- This software consists of voluntary contributions made by many
90
- individuals. For exact contribution history, see the revision history
91
- available at https://github.com/lodash/lodash
92
-
93
- The following license applies to all parts of this software except as
94
- documented below:
95
-
96
- ====
97
-
98
- Permission is hereby granted, free of charge, to any person obtaining
99
- a copy of this software and associated documentation files (the
100
- "Software"), to deal in the Software without restriction, including
101
- without limitation the rights to use, copy, modify, merge, publish,
102
- distribute, sublicense, and/or sell copies of the Software, and to
103
- permit persons to whom the Software is furnished to do so, subject to
104
- the following conditions:
105
-
106
- The above copyright notice and this permission notice shall be
107
- included in all copies or substantial portions of the Software.
108
-
109
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
110
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
111
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
112
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
113
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
114
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
115
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
116
-
117
- ====
118
-
119
- Copyright and related rights for sample code are waived via CC0. Sample
120
- code is defined as all source code displayed within the prose of the
121
- documentation.
122
-
123
- CC0: http://creativecommons.org/publicdomain/zero/1.0/
124
-
125
- ====
126
-
127
- Files located in the node_modules and vendor directories are externally
128
- maintained libraries used by this software which have their own
129
- licenses; we recommend you read them, as their terms may differ from the
130
- terms above.
131
-
132
- ---
133
-
134
- Name: tailwind-merge
135
- Version: 3.4.0
136
- License: MIT
137
- Private: false
138
- Description: Merge Tailwind CSS classes without style conflicts
139
- Repository: https://github.com/dcastil/tailwind-merge.git
140
- Homepage: https://github.com/dcastil/tailwind-merge
141
- Author: Dany Castillo
142
- License Copyright:
143
- ===
144
-
145
- MIT License
146
-
147
- Copyright (c) 2021 Dany Castillo
148
-
149
- Permission is hereby granted, free of charge, to any person obtaining a copy
150
- of this software and associated documentation files (the "Software"), to deal
151
- in the Software without restriction, including without limitation the rights
152
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
153
- copies of the Software, and to permit persons to whom the Software is
154
- furnished to do so, subject to the following conditions:
155
-
156
- The above copyright notice and this permission notice shall be included in all
157
- copies or substantial portions of the Software.
158
-
159
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
160
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
161
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
162
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
163
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
164
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
165
- SOFTWARE.
166
-
167
- ---
168
-
169
37
  Name: html-janitor
170
38
  Version: 2.0.4
171
39
  License: null
@@ -378,33 +246,68 @@ Apache License
378
246
 
379
247
  ---
380
248
 
381
- Name: sortablejs
382
- Version: 1.15.6
249
+ Name: nanoid
250
+ Version: 5.1.6
251
+ License: MIT
252
+ Private: false
253
+ Description: A tiny (118 bytes), secure URL-friendly unique string ID generator
254
+ Repository: undefined
255
+ Author: Andrey Sitnik <andrey@sitnik.ru>
256
+ License Copyright:
257
+ ===
258
+
259
+ The MIT License (MIT)
260
+
261
+ Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
262
+
263
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
264
+ this software and associated documentation files (the "Software"), to deal in
265
+ the Software without restriction, including without limitation the rights to
266
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
267
+ the Software, and to permit persons to whom the Software is furnished to do so,
268
+ subject to the following conditions:
269
+
270
+ The above copyright notice and this permission notice shall be included in all
271
+ copies or substantial portions of the Software.
272
+
273
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
274
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
275
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
276
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
277
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
278
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
279
+
280
+ ---
281
+
282
+ Name: i18next
283
+ Version: 25.7.3
383
284
  License: MIT
384
285
  Private: false
385
- Description: JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery required. Supports Meteor, AngularJS, React, Polymer, Vue, Knockout and any CSS library, e.g. Bootstrap.
386
- Repository: git://github.com/SortableJS/Sortable.git
286
+ Description: i18next internationalization framework
287
+ Repository: https://github.com/i18next/i18next.git
288
+ Homepage: https://www.i18next.com
289
+ Author: Jan Mühlemann <jan.muehlemann@gmail.com> (https://github.com/jamuhl)
387
290
  License Copyright:
388
291
  ===
389
292
 
390
- MIT License
391
-
392
- Copyright (c) 2019 All contributors to Sortable
393
-
394
- Permission is hereby granted, free of charge, to any person obtaining a copy
395
- of this software and associated documentation files (the "Software"), to deal
396
- in the Software without restriction, including without limitation the rights
397
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
398
- copies of the Software, and to permit persons to whom the Software is
399
- furnished to do so, subject to the following conditions:
400
-
401
- The above copyright notice and this permission notice shall be included in all
402
- copies or substantial portions of the Software.
403
-
404
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
405
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
406
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
407
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
408
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
409
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
293
+ The MIT License (MIT)
294
+
295
+ Copyright (c) 2025 i18next
296
+
297
+ Permission is hereby granted, free of charge, to any person obtaining a copy
298
+ of this software and associated documentation files (the "Software"), to deal
299
+ in the Software without restriction, including without limitation the rights
300
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
301
+ copies of the Software, and to permit persons to whom the Software is
302
+ furnished to do so, subject to the following conditions:
303
+
304
+ The above copyright notice and this permission notice shall be included in all
305
+ copies or substantial portions of the Software.
306
+
307
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
308
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
309
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
310
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
311
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
312
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
410
313
  SOFTWARE.
package/package.json CHANGED
@@ -1,21 +1,42 @@
1
1
  {
2
2
  "name": "@jackuait/blok",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Blok — headless, highly extensible rich text editor built for developers who need to implement a block-based editing experience (similar to Notion) without building it from scratch",
5
- "main": "dist/blok.umd.js",
6
5
  "module": "dist/blok.mjs",
7
6
  "types": "./types/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./types/index.d.ts",
10
+ "import": "./dist/blok.mjs"
11
+ },
12
+ "./tools": {
13
+ "types": "./types/tools-entry.d.ts",
14
+ "import": "./dist/tools.mjs"
15
+ },
16
+ "./full": {
17
+ "types": "./types/full.d.ts",
18
+ "import": "./dist/full.mjs"
19
+ },
20
+ "./locales": {
21
+ "types": "./types/locales.d.ts",
22
+ "import": "./dist/locales.mjs"
23
+ }
24
+ },
8
25
  "bin": {
9
26
  "migrate-from-editorjs": "./codemod/migrate-editorjs-to-blok.js"
10
27
  },
11
28
  "files": [
12
29
  "dist",
13
30
  "types",
31
+ "src",
14
32
  "codemod"
15
33
  ],
16
34
  "publishConfig": {
17
35
  "access": "public"
18
36
  },
37
+ "engines": {
38
+ "node": ">=18.0.0"
39
+ },
19
40
  "keywords": [
20
41
  "blok",
21
42
  "text editor",
@@ -25,15 +46,21 @@
25
46
  "headless editor",
26
47
  "extensible editor"
27
48
  ],
49
+ "sideEffects": [
50
+ "./src/components/polyfills.ts",
51
+ "*.css"
52
+ ],
28
53
  "scripts": {
29
54
  "serve": "vite --no-open",
30
- "build": "vite build --mode production",
31
- "build:test": "vite build --mode test",
55
+ "build": "vite build --mode production && node scripts/build-locales.mjs",
56
+ "build:test": "vite build --mode test && node scripts/build-locales.mjs test",
32
57
  "lint": "sh -c 'eslint .; ESLINT_EXIT=$?; tsc --noEmit; TSC_EXIT=$?; if [ $ESLINT_EXIT -ne 0 ] || [ $TSC_EXIT -ne 0 ]; then exit 1; fi'",
33
58
  "lint:fix": "eslint . --fix",
34
59
  "lint:tests": "eslint test/",
35
60
  "lint:types": "tsc --noEmit",
61
+ "i18n:check": "node scripts/i18n/check-translations.mjs",
36
62
  "e2e": "playwright test",
63
+ "e2e:smoke": "playwright test --project=chromium --grep=\"@smoke\"",
37
64
  "e2e:chrome": "playwright test --project=chromium",
38
65
  "e2e:firefox": "playwright test --project=firefox",
39
66
  "e2e:safari": "playwright test --project=webkit",
@@ -48,16 +75,22 @@
48
75
  "jscpd:report": "jscpd . --reporters html,json --output .jscpd-report",
49
76
  "prepublishOnly": "yarn build",
50
77
  "prepare": "husky",
51
- "release": "./scripts/release.sh release",
52
- "release:alpha": "./scripts/release.sh prerelease alpha",
53
- "release:rc": "./scripts/release.sh prerelease rc",
54
- "release:dry": "./scripts/release.sh release beta true",
55
78
  "storybook": "storybook dev -p 6006 --no-open",
56
79
  "storybook:build": "storybook build --stats-json",
57
80
  "storybook:test": "vitest --project=storybook --run",
58
81
  "chromatic": "chromatic --exit-zero-on-changes",
59
- "release:beta": "npm version prerelease --preid=beta",
60
- "publish:beta": "npm publish --tag beta"
82
+ "verify:package": "node scripts/verify-published-package.mjs",
83
+ "verify:package:local": "npm pack && node scripts/verify-published-package.mjs --local",
84
+ "verify:version": "node scripts/verify-version.mjs",
85
+ "unpublish": "node scripts/unpublish-package.mjs",
86
+ "bundle:track": "node scripts/track-bundle-size.mjs --verbose",
87
+ "bundle:variants": "node scripts/build-bundle-variants.mjs --verbose",
88
+ "bundle:trends": "node scripts/view-bundle-trends.mjs --trends",
89
+ "bundle:history": "node scripts/view-bundle-trends.mjs",
90
+ "perf:analyze": "node scripts/analyze-performance.mjs",
91
+ "perf:compare": "node scripts/analyze-performance.mjs --baseline",
92
+ "perf:dashboard": "node scripts/generate-performance-dashboard.mjs",
93
+ "e2e:validate-categories": "node scripts/validate-test-categories.mjs"
61
94
  },
62
95
  "author": "JackUait",
63
96
  "contributors": [
@@ -75,13 +108,14 @@
75
108
  "@commitlint/cli": "20.1.0",
76
109
  "@commitlint/config-conventional": "20.0.0",
77
110
  "@playwright/test": "1.57.0",
111
+ "@semantic-release/changelog": "^6.0.3",
112
+ "@semantic-release/git": "^10.0.1",
78
113
  "@storybook/addon-a11y": "10.1.1",
79
114
  "@storybook/addon-vitest": "10.1.1",
80
115
  "@storybook/global": "5.0.0",
81
116
  "@storybook/html-vite": "10.1.1",
82
117
  "@types/eslint-plugin-tailwindcss": "3",
83
118
  "@types/node": "22.19.0",
84
- "@types/sortablejs": "1.15.9",
85
119
  "@vitest/browser-playwright": "4.0.14",
86
120
  "@vitest/coverage-v8": "4.0.14",
87
121
  "@vitest/ui": "4.0.14",
@@ -103,6 +137,7 @@
103
137
  "playwright": "1.57.0",
104
138
  "postcss": "8.5.6",
105
139
  "rollup-plugin-license": "3.6.0",
140
+ "semantic-release": "^25.0.2",
106
141
  "storybook": "10.1.1",
107
142
  "tailwindcss": "3",
108
143
  "tslint": "6.1.3",
@@ -114,9 +149,6 @@
114
149
  "yaml": "2.8.1"
115
150
  },
116
151
  "dependencies": {
117
- "@types/lodash": "4.17.21",
118
- "lodash": "4.17.21",
119
- "sortablejs": "1.15.6",
120
- "tailwind-merge": "3.4.0"
152
+ "i18next": "^25.7.3"
121
153
  }
122
154
  }
package/src/blok.ts ADDED
@@ -0,0 +1,267 @@
1
+ 'use strict';
2
+
3
+ import type { BlokConfig, API } from '../types';
4
+ import type { BlokModules } from './types-internal/blok-modules';
5
+
6
+ /**
7
+ * Apply polyfills
8
+ */
9
+ import '@babel/register';
10
+
11
+ import './components/polyfills';
12
+ import { Core } from './components/core';
13
+ import { getBlokVersion, isObject, isFunction } from './components/utils';
14
+ import { destroy as destroyTooltip } from './components/utils/tooltip';
15
+ import { DATA_ATTR } from './components/constants/data-attributes';
16
+
17
+ /**
18
+ * Export version as a named export
19
+ */
20
+ export const version = getBlokVersion();
21
+
22
+ /**
23
+ * Re-export DATA_ATTR for querying editor elements
24
+ */
25
+ export { DATA_ATTR } from './components/constants/data-attributes';
26
+
27
+ /**
28
+ * Blok
29
+ * @license Apache-2.0
30
+ */
31
+ class Blok {
32
+ /**
33
+ * Store user-provided configuration for later export
34
+ */
35
+ private readonly initialConfiguration: BlokConfig|string|undefined;
36
+
37
+ /**
38
+ * Promise that resolves when core modules are ready and UI is rendered on the page
39
+ */
40
+ public isReady: Promise<void>;
41
+
42
+ /**
43
+ * Stores destroy method implementation.
44
+ * Clear heap occupied by Blok and remove UI components from the DOM.
45
+ */
46
+ public destroy: () => void;
47
+
48
+ /** Blok version */
49
+ public static get version(): string {
50
+ return getBlokVersion();
51
+ }
52
+
53
+ /**
54
+ * Data attributes used by the editor.
55
+ * Single source of truth for all data-blok-* attributes.
56
+ *
57
+ * @example
58
+ * // Query editor elements
59
+ * document.querySelectorAll(`[${Blok.DATA_ATTR.element}]`);
60
+ *
61
+ * // Check if block is selected
62
+ * block.getAttribute(Blok.DATA_ATTR.selected) === 'true';
63
+ */
64
+ public static DATA_ATTR = DATA_ATTR;
65
+
66
+ /**
67
+ * @param {BlokConfig|string|undefined} [configuration] - user configuration
68
+ */
69
+ constructor(configuration?: BlokConfig|string) {
70
+ this.initialConfiguration = isObject(configuration)
71
+ ? { ...configuration }
72
+ : configuration;
73
+
74
+ /**
75
+ * Set default onReady function or use the one from configuration if provided
76
+ */
77
+
78
+ const onReady = (isObject(configuration) && isFunction(configuration.onReady))
79
+ ? configuration.onReady
80
+ : () => {};
81
+
82
+ /**
83
+ * Create a Blok instance
84
+ */
85
+ const blok = new Core(configuration);
86
+
87
+ /**
88
+ * Initialize destroy with a no-op function that will be replaced in exportAPI
89
+ */
90
+
91
+ this.destroy = (): void => {};
92
+
93
+ /**
94
+ * We need to export isReady promise in the constructor
95
+ * as it can be used before other API methods are exported
96
+ * @type {Promise<void>}
97
+ */
98
+ this.isReady = blok.isReady.then(() => {
99
+ this.exportAPI(blok);
100
+ /**
101
+ * @todo pass API as an argument. It will allow to use Blok's API when blok is ready
102
+ */
103
+ onReady();
104
+ });
105
+ }
106
+
107
+ /**
108
+ * Export external API methods
109
+ * @param {Core} blok — Blok's instance
110
+ */
111
+ public exportAPI(blok: Core): void {
112
+ const fieldsToExport = [ 'configuration' ];
113
+ const destroy = (): void => {
114
+ Object.values(blok.moduleInstances)
115
+ .forEach((moduleInstance) => {
116
+ if (moduleInstance === undefined || moduleInstance === null) {
117
+ return;
118
+ }
119
+
120
+ if (isFunction((moduleInstance as { destroy?: () => void }).destroy)) {
121
+ (moduleInstance as { destroy: () => void }).destroy();
122
+ }
123
+
124
+ const listeners = (moduleInstance as { listeners?: { removeAll?: () => void } }).listeners;
125
+
126
+ if (listeners && isFunction(listeners.removeAll)) {
127
+ listeners.removeAll();
128
+ }
129
+ });
130
+
131
+ destroyTooltip();
132
+
133
+ for (const field in this) {
134
+ if (Object.prototype.hasOwnProperty.call(this, field)) {
135
+ delete (this as Record<string, unknown>)[field];
136
+ }
137
+ }
138
+
139
+ Object.setPrototypeOf(this, null);
140
+ };
141
+
142
+ fieldsToExport.forEach((field) => {
143
+ if (field !== 'configuration') {
144
+ (this as Record<string, unknown>)[field] = (blok as unknown as Record<string, unknown>)[field];
145
+
146
+ return;
147
+ }
148
+
149
+ const coreConfiguration = (blok as unknown as { configuration?: BlokConfig|string|undefined }).configuration;
150
+ const configurationToExport = isObject(this.initialConfiguration)
151
+ ? this.initialConfiguration
152
+ : coreConfiguration ?? this.initialConfiguration;
153
+
154
+ if (configurationToExport === undefined) {
155
+ return;
156
+ }
157
+
158
+ (this as Record<string, unknown>)[field] = configurationToExport as BlokConfig|string;
159
+ });
160
+
161
+ this.destroy = destroy;
162
+
163
+ const apiMethods = blok.moduleInstances.API.methods;
164
+ const eventsDispatcherApi = blok.moduleInstances.EventsAPI?.methods ?? apiMethods.events;
165
+
166
+ if (eventsDispatcherApi !== undefined) {
167
+ const defineDispatcher = (target: object): void => {
168
+ if (!Object.prototype.hasOwnProperty.call(target, 'eventsDispatcher')) {
169
+ Object.defineProperty(target, 'eventsDispatcher', {
170
+ value: eventsDispatcherApi,
171
+ configurable: true,
172
+ enumerable: true,
173
+ writable: false,
174
+ });
175
+ }
176
+ };
177
+
178
+ defineDispatcher(apiMethods);
179
+ defineDispatcher(this as Record<string, unknown>);
180
+ }
181
+
182
+ if (Object.getPrototypeOf(apiMethods) !== Blok.prototype) {
183
+ Object.setPrototypeOf(apiMethods, Blok.prototype);
184
+ }
185
+
186
+ Object.setPrototypeOf(this, apiMethods);
187
+
188
+ const moduleAliases = Object.create(null) as Record<string, unknown>;
189
+ const moduleInstances = blok.moduleInstances as Partial<BlokModules>;
190
+ const moduleInstancesRecord = moduleInstances as unknown as Record<string, unknown>;
191
+
192
+ const getAliasName = (name: string): string => (
193
+ /^[A-Z]+$/.test(name)
194
+ ? name.toLowerCase()
195
+ : name.charAt(0).toLowerCase() + name.slice(1)
196
+ );
197
+
198
+ Object.keys(moduleInstancesRecord)
199
+ .forEach((name) => {
200
+ const alias = getAliasName(name);
201
+
202
+ Object.defineProperty(moduleAliases, alias, {
203
+ configurable: true,
204
+ enumerable: true,
205
+ get: () => moduleInstancesRecord[name],
206
+ });
207
+ });
208
+
209
+ type ToolbarModuleWithSettings = {
210
+ blockSettings?: unknown;
211
+ inlineToolbar?: unknown;
212
+ };
213
+
214
+ const toolbarModule = moduleInstances.Toolbar as unknown as ToolbarModuleWithSettings | undefined;
215
+ const blockSettingsModule = moduleInstances.BlockSettings;
216
+
217
+ if (toolbarModule !== undefined && blockSettingsModule !== undefined && toolbarModule.blockSettings === undefined) {
218
+ toolbarModule.blockSettings = blockSettingsModule;
219
+ }
220
+
221
+ const inlineToolbarModule = moduleInstances.InlineToolbar;
222
+
223
+ if (toolbarModule !== undefined && inlineToolbarModule !== undefined && toolbarModule.inlineToolbar === undefined) {
224
+ toolbarModule.inlineToolbar = inlineToolbarModule;
225
+ }
226
+
227
+ Object.defineProperty(this, 'module', {
228
+ value: moduleAliases,
229
+ configurable: true,
230
+ enumerable: false,
231
+ writable: false,
232
+ });
233
+
234
+ delete (this as Partial<Blok>).exportAPI;
235
+
236
+ const shorthands = {
237
+ blocks: {
238
+ clear: 'clear',
239
+ render: 'render',
240
+ },
241
+ caret: {
242
+ focus: 'focus',
243
+ },
244
+ events: {
245
+ on: 'on',
246
+ off: 'off',
247
+ emit: 'emit',
248
+ },
249
+ saver: {
250
+ save: 'save',
251
+ },
252
+ };
253
+
254
+ Object.entries(shorthands)
255
+ .forEach(([key, methods]) => {
256
+ Object.entries(methods)
257
+ .forEach(([name, alias]) => {
258
+ const apiKey = key as keyof API;
259
+ const apiMethodGroup = blok.moduleInstances.API.methods[apiKey] as unknown as Record<string, unknown>;
260
+
261
+ (this as Record<string, unknown>)[alias] = apiMethodGroup[name];
262
+ });
263
+ });
264
+ }
265
+ }
266
+
267
+ export { Blok };