@jackuait/blok 0.4.1 → 0.4.3-beta.1

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 +45 -7
  3. package/codemod/migrate-editorjs-to-blok.js +951 -92
  4. package/codemod/test.js +780 -77
  5. package/dist/blok.mjs +5 -2
  6. package/dist/chunks/blok-8ptWuVZC.mjs +12838 -0
  7. package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
  8. package/dist/chunks/i18next-loader-bLawSYRV.mjs +43 -0
  9. package/dist/{index-CBkApZKo.mjs → chunks/index-5nYtWZD2.mjs} +2 -2
  10. package/dist/chunks/inline-tool-convert-CvMDAIzb.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 +60 -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,589 @@
1
+ import { Module } from '../__module';
2
+ import { deepMerge, isFunction, isObject, isUndefined, log } from '../utils';
3
+ import { PromiseQueue } from '../utils/promise-queue';
4
+ import type { SanitizerConfig, ToolConfig, ToolConstructable, ToolSettings } from '../../../types';
5
+ import { Stub } from '../../tools/stub';
6
+ import { ToolsFactory } from '../tools/factory';
7
+ import type { InlineToolAdapter } from '../tools/inline';
8
+ import type { BlockToolAdapter } from '../tools/block';
9
+ import type { BlockTuneAdapter } from '../tools/tune';
10
+ import { DeleteTune } from '../block-tunes/block-tune-delete';
11
+ import { ConvertInlineTool } from '../inline-tools/inline-tool-convert';
12
+ import { ToolsCollection } from '../tools/collection';
13
+ import { CriticalError } from '../errors/critical';
14
+
15
+ /**
16
+ * @typedef {object} ChainData
17
+ * @property {object} data - data that will be passed to the success or fallback
18
+ * @property {Function} function - function's that must be called asynchronously
19
+ * @interface ChainData
20
+ */
21
+ export interface ChainData {
22
+ data?: object;
23
+ function: (data?: object) => unknown;
24
+ }
25
+
26
+ type ToolPrepareData = {
27
+ toolName: string;
28
+ config: ToolConfig;
29
+ };
30
+
31
+ type ToolPrepareFunction = (data: ToolPrepareData) => void | Promise<void>;
32
+
33
+ const toToolConstructable = (constructable: unknown): ToolConstructable => {
34
+ if (!isFunction(constructable)) {
35
+ throw new Error('Tool constructable must be a function');
36
+ }
37
+
38
+ return constructable as unknown as ToolConstructable;
39
+ };
40
+
41
+ /**
42
+ * @module Blok Tools Submodule
43
+ *
44
+ * Creates Instances from Plugins and binds external config to the instances
45
+ */
46
+
47
+ /**
48
+ * Modules that works with tools classes
49
+ */
50
+ export class Tools extends Module {
51
+ /**
52
+ * Name of Stub Tool
53
+ * Stub Tool is used to substitute unavailable block Tools and store their data
54
+ * @type {string}
55
+ */
56
+ public stubTool = 'stub';
57
+
58
+ /**
59
+ * Returns available Tools
60
+ */
61
+ public get available(): ToolsCollection {
62
+ return this.toolsAvailable;
63
+ }
64
+
65
+ /**
66
+ * Returns unavailable Tools
67
+ */
68
+ public get unavailable(): ToolsCollection {
69
+ return this.toolsUnavailable;
70
+ }
71
+
72
+ /**
73
+ * Return Tools for the Inline Toolbar
74
+ */
75
+ public get inlineTools(): ToolsCollection<InlineToolAdapter> {
76
+ return this.available.inlineTools;
77
+ }
78
+
79
+ /**
80
+ * Return blok block tools
81
+ */
82
+ public get blockTools(): ToolsCollection<BlockToolAdapter> {
83
+ return this.available.blockTools;
84
+ }
85
+
86
+ /**
87
+ * Return available Block Tunes
88
+ * @returns {object} - object of Inline Tool's classes
89
+ */
90
+ public get blockTunes(): ToolsCollection<BlockTuneAdapter> {
91
+ return this.available.blockTunes;
92
+ }
93
+
94
+ /**
95
+ * Returns default Tool object
96
+ */
97
+ public get defaultTool(): BlockToolAdapter {
98
+ const defaultBlockName = this.config.defaultBlock;
99
+
100
+ if (!defaultBlockName) {
101
+ throw new Error('Default block tool name is not configured');
102
+ }
103
+
104
+ const tool = this.blockTools.get(defaultBlockName);
105
+
106
+ if (!tool) {
107
+ throw new Error(`Default block tool "${defaultBlockName}" not found in available block tools`);
108
+ }
109
+
110
+ return tool;
111
+ }
112
+
113
+ /**
114
+ * Tools objects factory
115
+ */
116
+ private factory: ToolsFactory | null = null;
117
+
118
+ /**
119
+ * Tools` classes available to use
120
+ */
121
+ private readonly toolsAvailable: ToolsCollection = new ToolsCollection();
122
+
123
+ /**
124
+ * Tools` classes not available to use because of preparation failure
125
+ */
126
+ private readonly toolsUnavailable: ToolsCollection = new ToolsCollection();
127
+
128
+ /**
129
+ * Cache for the sanitizer config
130
+ */
131
+ private inlineToolsSanitizeConfigCache: SanitizerConfig | null = null;
132
+
133
+ /**
134
+ * Returns internal tools
135
+ */
136
+ public get internal(): ToolsCollection {
137
+ return this.available.internalTools;
138
+ }
139
+
140
+ /**
141
+ * Creates instances via passed or default configuration
142
+ * @returns {Promise<void>}
143
+ */
144
+ public async prepare(): Promise<void> {
145
+ /**
146
+ * Assign internal tools before validation so required fallbacks (like stub) are always present
147
+ */
148
+ const userTools = this.config.tools ?? {};
149
+
150
+ this.config.tools = deepMerge({}, this.internalTools, userTools);
151
+
152
+ this.validateTools();
153
+
154
+ const toolsConfig = this.config.tools;
155
+
156
+ if (!toolsConfig || Object.keys(toolsConfig).length === 0) {
157
+ throw Error('Can\'t start without tools');
158
+ }
159
+
160
+ const config = this.prepareConfig(toolsConfig);
161
+
162
+ this.factory = new ToolsFactory(config, this.config, this.Blok.API);
163
+
164
+ /**
165
+ * getting classes that has prepare method
166
+ */
167
+ const sequenceData = this.getListOfPrepareFunctions(config);
168
+
169
+ /**
170
+ * if sequence data contains nothing then resolve current chain and run other module prepare
171
+ */
172
+ if (sequenceData.length === 0) {
173
+ return Promise.resolve();
174
+ }
175
+
176
+ const handlePrepareSuccess = (data: object): void => {
177
+ if (!this.isToolPrepareData(data)) {
178
+ return;
179
+ }
180
+
181
+ this.toolPrepareMethodSuccess({ toolName: data.toolName });
182
+ };
183
+
184
+ const handlePrepareFallback = (data: object): void => {
185
+ if (!this.isToolPrepareData(data)) {
186
+ return;
187
+ }
188
+
189
+ this.toolPrepareMethodFallback({ toolName: data.toolName });
190
+ };
191
+
192
+ const queue = new PromiseQueue();
193
+
194
+ sequenceData.forEach(chainData => {
195
+ void queue.add(async () => {
196
+ const callbackData = !isUndefined(chainData.data) ? chainData.data : {};
197
+
198
+ try {
199
+ await chainData.function(chainData.data);
200
+ handlePrepareSuccess(callbackData);
201
+ } catch (_error) {
202
+ handlePrepareFallback(callbackData);
203
+ }
204
+ });
205
+ });
206
+
207
+ await queue.completed;
208
+
209
+ this.prepareBlockTools();
210
+ }
211
+
212
+ /**
213
+ * Return general Sanitizer config for all inline tools
214
+ */
215
+ public getAllInlineToolsSanitizeConfig(): SanitizerConfig {
216
+ if (this.inlineToolsSanitizeConfigCache) {
217
+ return this.inlineToolsSanitizeConfigCache;
218
+ }
219
+
220
+ const config: SanitizerConfig = {} as SanitizerConfig;
221
+
222
+ Array.from(this.inlineTools.values())
223
+ .forEach(inlineTool => {
224
+ Object.assign(config, inlineTool.sanitizeConfig);
225
+ });
226
+
227
+ this.inlineToolsSanitizeConfigCache = config;
228
+
229
+ return config;
230
+ }
231
+
232
+ /**
233
+ * Calls each Tool reset method to clean up anything set by Tool
234
+ */
235
+ public destroy(): void {
236
+ for (const tool of this.available.values()) {
237
+ const resetResult = (() => {
238
+ try {
239
+ return tool.reset();
240
+ } catch (error) {
241
+ log(`Tool "${tool.name}" reset failed`, 'warn', error);
242
+
243
+ return undefined;
244
+ }
245
+ })();
246
+
247
+ if (resetResult instanceof Promise) {
248
+ resetResult.catch(error => {
249
+ log(`Tool "${tool.name}" reset failed`, 'warn', error);
250
+ });
251
+ }
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Returns essential internal tools that are always bundled.
257
+ * Includes:
258
+ * - stub: for graceful handling of unknown block types
259
+ * - delete: fundamental block operation in settings menu
260
+ * - convertTo: inline tool for converting blocks between types
261
+ *
262
+ * Other tools (paragraph, header, list, bold, italic, link) are optional
263
+ * and should be imported from '@jackuait/blok/tools' or '@jackuait/blok/full'.
264
+ */
265
+ private get internalTools(): { [toolName: string]: ToolConstructable | ToolSettings & { isInternal?: boolean } } {
266
+ return {
267
+ stub: {
268
+ class: toToolConstructable(Stub),
269
+ isInternal: true,
270
+ },
271
+ delete: {
272
+ class: toToolConstructable(DeleteTune),
273
+ isInternal: true,
274
+ },
275
+ convertTo: {
276
+ class: toToolConstructable(ConvertInlineTool),
277
+ isInternal: true,
278
+ },
279
+ };
280
+ }
281
+
282
+ /**
283
+ * Tool prepare method success callback
284
+ * @param {object} data - append tool to available list
285
+ */
286
+ private toolPrepareMethodSuccess(data: { toolName: string }): void {
287
+ const tool = this.getFactory().get(data.toolName);
288
+
289
+ if (!tool.isInline()) {
290
+ this.toolsAvailable.set(tool.name, tool);
291
+
292
+ return;
293
+ }
294
+
295
+ /**
296
+ * Some Tools validation
297
+ */
298
+ const inlineToolRequiredMethods = [ 'render' ];
299
+ const notImplementedMethods = tool.getMissingMethods(inlineToolRequiredMethods);
300
+
301
+ if (notImplementedMethods.length) {
302
+ log(
303
+ `Incorrect Inline Tool: ${tool.name}. Some of required methods is not implemented %o`,
304
+ 'warn',
305
+ notImplementedMethods
306
+ );
307
+
308
+ this.toolsUnavailable.set(tool.name, tool);
309
+
310
+ return;
311
+ }
312
+
313
+ this.toolsAvailable.set(tool.name, tool);
314
+ }
315
+
316
+ /**
317
+ * Tool prepare method fail callback
318
+ * @param {object} data - append tool to unavailable list
319
+ */
320
+ private toolPrepareMethodFallback(data: { toolName: string }): void {
321
+ const factory = this.getFactory();
322
+
323
+ this.toolsUnavailable.set(data.toolName, factory.get(data.toolName));
324
+ }
325
+
326
+ /**
327
+ * Binds prepare function of plugins with user or default config
328
+ * @returns {Array} list of functions that needs to be fired sequentially
329
+ * @param config - tools config
330
+ */
331
+ private getListOfPrepareFunctions(config: Record<string, ToolSettings>): ChainData[] {
332
+ return Object
333
+ .entries(config)
334
+ .map(([toolName, settings]): ChainData => {
335
+ const toolData: ToolPrepareData = {
336
+ toolName,
337
+ config: (settings.config ?? {}) as ToolConfig,
338
+ };
339
+
340
+ const prepareFunction: ChainData['function'] = async (payload?: unknown) => {
341
+ const constructable = settings.class;
342
+
343
+ if (!constructable || !isFunction(constructable.prepare)) {
344
+ return;
345
+ }
346
+
347
+ const data = (payload ?? toolData) as ToolPrepareData;
348
+ const prepareMethod = constructable.prepare as unknown as ToolPrepareFunction;
349
+
350
+ return prepareMethod.call(constructable, data);
351
+ };
352
+
353
+ return {
354
+ function: prepareFunction,
355
+ data: toolData,
356
+ };
357
+ });
358
+ }
359
+
360
+ /**
361
+ * Assign enabled Inline Tools and Block Tunes for Block Tool
362
+ */
363
+ private prepareBlockTools(): void {
364
+ Array.from(this.blockTools.values()).forEach(tool => {
365
+ this.assignInlineToolsToBlockTool(tool);
366
+ this.assignBlockTunesToBlockTool(tool);
367
+ });
368
+ }
369
+
370
+ /**
371
+ * Assign enabled Inline Tools for Block Tool
372
+ * @param tool - Block Tool
373
+ */
374
+ private assignInlineToolsToBlockTool(tool: BlockToolAdapter): void {
375
+ const blockTool = tool;
376
+
377
+ /**
378
+ * If common inlineToolbar property is false no Inline Tools should be assigned
379
+ */
380
+ if (this.config.inlineToolbar === false) {
381
+ return;
382
+ }
383
+
384
+ /**
385
+ * If user pass just 'true' for tool, get common inlineToolbar settings
386
+ * - if common settings is an array, use it
387
+ * - if common settings is 'true' or not specified, get default order
388
+ */
389
+ if (blockTool.enabledInlineTools === true) {
390
+ const inlineTools = Array.isArray(this.config.inlineToolbar)
391
+ ? this.createInlineToolsCollection(this.config.inlineToolbar)
392
+ /**
393
+ * If common settings is 'true' or not specified (will be set as true at core.ts), get the default order.
394
+ * Prepend convertTo so it appears first (same as when explicit array is passed).
395
+ */
396
+ : this.createInlineToolsCollection(['convertTo', ...this.inlineTools.keys()]);
397
+
398
+ blockTool.inlineTools = inlineTools;
399
+
400
+ return;
401
+ }
402
+
403
+ /**
404
+ * If user pass the list of inline tools for the particular tool, return it.
405
+ */
406
+ if (Array.isArray(blockTool.enabledInlineTools)) {
407
+ /** Prepend ConvertTo Inline Tool */
408
+ const inlineTools = this.createInlineToolsCollection(['convertTo', ...blockTool.enabledInlineTools]);
409
+
410
+ blockTool.inlineTools = inlineTools;
411
+ }
412
+ }
413
+
414
+ /**
415
+ * Assign enabled Block Tunes for Block Tool
416
+ * @param tool — Block Tool
417
+ */
418
+ private assignBlockTunesToBlockTool(tool: BlockToolAdapter): void {
419
+ const blockTool = tool;
420
+
421
+ if (blockTool.enabledBlockTunes === false) {
422
+ return;
423
+ }
424
+
425
+ if (Array.isArray(blockTool.enabledBlockTunes)) {
426
+ const userTunes = this.createBlockTunesCollection(blockTool.enabledBlockTunes);
427
+ const combinedEntries = [
428
+ ...Array.from(userTunes.entries()),
429
+ ...Array.from(this.blockTunes.internalTools.entries()),
430
+ ];
431
+
432
+ blockTool.tunes = new ToolsCollection<BlockTuneAdapter>(combinedEntries);
433
+
434
+ return;
435
+ }
436
+
437
+ if (Array.isArray(this.config.tunes)) {
438
+ const userTunes = this.createBlockTunesCollection(this.config.tunes);
439
+ const combinedEntries = [
440
+ ...Array.from(userTunes.entries()),
441
+ ...Array.from(this.blockTunes.internalTools.entries()),
442
+ ];
443
+
444
+ blockTool.tunes = new ToolsCollection<BlockTuneAdapter>(combinedEntries);
445
+
446
+ return;
447
+ }
448
+
449
+ blockTool.tunes = new ToolsCollection<BlockTuneAdapter>(
450
+ Array.from(this.blockTunes.internalTools.entries())
451
+ );
452
+ }
453
+
454
+ /**
455
+ * Validate Tools configuration objects and throw Error for user if it is invalid
456
+ */
457
+ private validateTools(): void {
458
+ const toolsConfig = this.config.tools;
459
+
460
+ if (!toolsConfig) {
461
+ return;
462
+ }
463
+
464
+ const internalTools = this.internalTools;
465
+
466
+ /**
467
+ * Check Tools for a class containing
468
+ */
469
+ for (const toolName in toolsConfig) {
470
+ if (!Object.prototype.hasOwnProperty.call(toolsConfig, toolName)) {
471
+ continue;
472
+ }
473
+
474
+ if (toolName in internalTools) {
475
+ continue;
476
+ }
477
+
478
+ const tool = toolsConfig[toolName];
479
+ const isConstructorFunction = isFunction(tool);
480
+ const toolSettings = tool as ToolSettings;
481
+ const hasToolClass = isFunction(toolSettings.class);
482
+
483
+ if (!isConstructorFunction && !hasToolClass) {
484
+ throw new CriticalError(
485
+ `Tool «${toolName}» must be a constructor function or an object with function in the «class» property`
486
+ );
487
+ }
488
+ }
489
+ }
490
+
491
+ /**
492
+ * Unify tools config
493
+ * @param toolsConfig - raw tools configuration
494
+ */
495
+ private prepareConfig(toolsConfig: Record<string, ToolConstructable | ToolSettings>): Record<string, ToolSettings> {
496
+ const config: Record<string, ToolSettings> = {};
497
+
498
+ /**
499
+ * Save Tools settings to a map
500
+ */
501
+ for (const toolName in toolsConfig) {
502
+ /**
503
+ * If Tool is an object not a Tool's class then
504
+ * save class and settings separately
505
+ */
506
+ if (!Object.prototype.hasOwnProperty.call(toolsConfig, toolName)) {
507
+ continue;
508
+ }
509
+
510
+ const tool = toolsConfig[toolName];
511
+
512
+ if (isObject(tool)) {
513
+ config[toolName] = tool as ToolSettings;
514
+
515
+ continue;
516
+ }
517
+
518
+ config[toolName] = { class: tool as ToolConstructable };
519
+ }
520
+
521
+ return config;
522
+ }
523
+
524
+ /**
525
+ * Type guard that ensures provided data contains tool preparation metadata.
526
+ * @param data - data passed to prepare sequence callbacks
527
+ */
528
+ private isToolPrepareData(data: object): data is ToolPrepareData {
529
+ const candidate = data as Partial<ToolPrepareData>;
530
+
531
+ return typeof candidate?.toolName === 'string';
532
+ }
533
+
534
+ /**
535
+ * Returns initialized tools factory instance.
536
+ * @returns tools factory
537
+ */
538
+ private getFactory(): ToolsFactory {
539
+ if (this.factory === null) {
540
+ throw new Error('Tools factory is not initialized');
541
+ }
542
+
543
+ return this.factory;
544
+ }
545
+
546
+ /**
547
+ * Builds inline tools collection for provided tool names, skipping unavailable ones.
548
+ * @param toolNames - inline tool names to include
549
+ * @returns tools collection containing available inline tools
550
+ */
551
+ private createInlineToolsCollection(toolNames: Iterable<string>): ToolsCollection<InlineToolAdapter> {
552
+ const entries: [string, InlineToolAdapter][] = [];
553
+
554
+ for (const name of toolNames) {
555
+ const inlineTool = this.inlineTools.get(name);
556
+
557
+ if (!inlineTool) {
558
+ log(`Inline tool "${name}" is not available and will be skipped`, 'warn');
559
+ continue;
560
+ }
561
+
562
+ entries.push([name, inlineTool]);
563
+ }
564
+
565
+ return new ToolsCollection<InlineToolAdapter>(entries);
566
+ }
567
+
568
+ /**
569
+ * Builds block tunes collection for provided tune names, skipping unavailable ones.
570
+ * @param tuneNames - block tune names to include
571
+ * @returns tools collection containing available block tunes
572
+ */
573
+ private createBlockTunesCollection(tuneNames: Iterable<string>): ToolsCollection<BlockTuneAdapter> {
574
+ const entries: [string, BlockTuneAdapter][] = [];
575
+
576
+ for (const name of tuneNames) {
577
+ const tune = this.blockTunes.get(name);
578
+
579
+ if (!tune) {
580
+ log(`Block tune "${name}" is not available and will be skipped`, 'warn');
581
+ continue;
582
+ }
583
+
584
+ entries.push([name, tune]);
585
+ }
586
+
587
+ return new ToolsCollection<BlockTuneAdapter>(entries);
588
+ }
589
+ }