@jackuait/blok 0.4.1-beta.0 → 0.4.1-beta.11

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 (402) hide show
  1. package/README.md +138 -17
  2. package/codemod/README.md +45 -7
  3. package/codemod/migrate-editorjs-to-blok.js +960 -92
  4. package/codemod/test.js +780 -77
  5. package/dist/blok.mjs +5 -2
  6. package/dist/chunks/blok-oNSQ3HA6.mjs +13217 -0
  7. package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
  8. package/dist/chunks/i18next-loader-BdNRw4n4.mjs +43 -0
  9. package/dist/{index-OwEtDFlk.mjs → chunks/index-DHgXmfki.mjs} +2 -2
  10. package/dist/chunks/inline-tool-convert-CRqgjRim.mjs +1989 -0
  11. package/dist/chunks/messages-0tDXLuyH.mjs +48 -0
  12. package/dist/chunks/messages-2_xedlYw.mjs +48 -0
  13. package/dist/chunks/messages-AHESHJm_.mjs +48 -0
  14. package/dist/chunks/messages-B5hdXZwA.mjs +48 -0
  15. package/dist/chunks/messages-B5jGUnOy.mjs +48 -0
  16. package/dist/chunks/messages-B5puUm7R.mjs +48 -0
  17. package/dist/chunks/messages-B66ZSDCJ.mjs +48 -0
  18. package/dist/chunks/messages-B9Oba7sq.mjs +48 -0
  19. package/dist/chunks/messages-BA0rcTCY.mjs +48 -0
  20. package/dist/chunks/messages-BBJgd5jG.mjs +48 -0
  21. package/dist/chunks/messages-BPqWKx5Z.mjs +48 -0
  22. package/dist/chunks/messages-Bdv-IkfG.mjs +48 -0
  23. package/dist/chunks/messages-BeUhMpsr.mjs +48 -0
  24. package/dist/chunks/messages-Bf6Y3_GI.mjs +48 -0
  25. package/dist/chunks/messages-BiExzWJv.mjs +48 -0
  26. package/dist/chunks/messages-BlpqL8vG.mjs +48 -0
  27. package/dist/chunks/messages-BmKCChWZ.mjs +48 -0
  28. package/dist/chunks/messages-Bn253WWC.mjs +48 -0
  29. package/dist/chunks/messages-BrJHUxQL.mjs +48 -0
  30. package/dist/chunks/messages-C5b7hr_E.mjs +48 -0
  31. package/dist/chunks/messages-C7I_AVH2.mjs +48 -0
  32. package/dist/chunks/messages-CJoBtXU6.mjs +48 -0
  33. package/dist/chunks/messages-CQj2JU2j.mjs +48 -0
  34. package/dist/chunks/messages-CUZ1x1QD.mjs +48 -0
  35. package/dist/chunks/messages-CUy1vn-b.mjs +48 -0
  36. package/dist/chunks/messages-CVeWVKsV.mjs +48 -0
  37. package/dist/chunks/messages-CXHd9SUK.mjs +48 -0
  38. package/dist/chunks/messages-CbMyJSzS.mjs +48 -0
  39. package/dist/chunks/messages-CbhuIWRJ.mjs +48 -0
  40. package/dist/chunks/messages-CeCjVKMW.mjs +48 -0
  41. package/dist/chunks/messages-Cj-t1bdy.mjs +48 -0
  42. package/dist/chunks/messages-CkFT2gle.mjs +48 -0
  43. package/dist/chunks/messages-Cm9aLHeX.mjs +48 -0
  44. package/dist/chunks/messages-CnvW8Slp.mjs +48 -0
  45. package/dist/chunks/messages-Cr-RJ7YB.mjs +48 -0
  46. package/dist/chunks/messages-CrsJ1TEJ.mjs +48 -0
  47. package/dist/chunks/messages-Cu08aLS3.mjs +48 -0
  48. package/dist/chunks/messages-CvaqJFN-.mjs +48 -0
  49. package/dist/chunks/messages-CyDU5lz9.mjs +48 -0
  50. package/dist/chunks/messages-CySyfkMU.mjs +48 -0
  51. package/dist/chunks/messages-Cyi2AMmz.mjs +48 -0
  52. package/dist/chunks/messages-D00OjS2n.mjs +48 -0
  53. package/dist/chunks/messages-DDLgIPDF.mjs +48 -0
  54. package/dist/chunks/messages-DMQIHGRj.mjs +48 -0
  55. package/dist/chunks/messages-DOlC_Tty.mjs +48 -0
  56. package/dist/chunks/messages-DV6shA9b.mjs +48 -0
  57. package/dist/chunks/messages-DY94ykcE.mjs +48 -0
  58. package/dist/chunks/messages-DbVquYKN.mjs +48 -0
  59. package/dist/chunks/messages-DcKOuncK.mjs +48 -0
  60. package/dist/chunks/messages-Dg92dXZ5.mjs +48 -0
  61. package/dist/chunks/messages-DnbbyJT3.mjs +48 -0
  62. package/dist/chunks/messages-DteYq0rv.mjs +48 -0
  63. package/dist/chunks/messages-GC2PhgV3.mjs +48 -0
  64. package/dist/chunks/messages-JGsXAReJ.mjs +48 -0
  65. package/dist/chunks/messages-JZUhXTuV.mjs +48 -0
  66. package/dist/chunks/messages-LvFKBBPa.mjs +48 -0
  67. package/dist/chunks/messages-NP1myMGI.mjs +48 -0
  68. package/dist/chunks/messages-Q4kc_ZtL.mjs +48 -0
  69. package/dist/chunks/messages-RvMHb2Ht.mjs +48 -0
  70. package/dist/chunks/messages-ftMcCEuO.mjs +48 -0
  71. package/dist/chunks/messages-o24dK6CU.mjs +48 -0
  72. package/dist/chunks/messages-pA5TvcAj.mjs +48 -0
  73. package/dist/chunks/messages-rRSHQDCX.mjs +48 -0
  74. package/dist/chunks/messages-srxrv8Yh.mjs +48 -0
  75. package/dist/chunks/messages-wdqp4610.mjs +48 -0
  76. package/dist/chunks/messages-zS1AXZ0y.mjs +48 -0
  77. package/dist/chunks/messages-zSzDzXej.mjs +48 -0
  78. package/dist/full.mjs +50 -0
  79. package/dist/locales.mjs +228 -0
  80. package/dist/messages-0tDXLuyH.mjs +48 -0
  81. package/dist/messages-2_xedlYw.mjs +48 -0
  82. package/dist/messages-AHESHJm_.mjs +48 -0
  83. package/dist/messages-B5hdXZwA.mjs +48 -0
  84. package/dist/messages-B5jGUnOy.mjs +48 -0
  85. package/dist/messages-B5puUm7R.mjs +48 -0
  86. package/dist/messages-B66ZSDCJ.mjs +48 -0
  87. package/dist/messages-B9Oba7sq.mjs +48 -0
  88. package/dist/messages-BA0rcTCY.mjs +48 -0
  89. package/dist/messages-BBJgd5jG.mjs +48 -0
  90. package/dist/messages-BPqWKx5Z.mjs +48 -0
  91. package/dist/messages-Bdv-IkfG.mjs +48 -0
  92. package/dist/messages-BeUhMpsr.mjs +48 -0
  93. package/dist/messages-Bf6Y3_GI.mjs +48 -0
  94. package/dist/messages-BiExzWJv.mjs +48 -0
  95. package/dist/messages-BlpqL8vG.mjs +48 -0
  96. package/dist/messages-BmKCChWZ.mjs +48 -0
  97. package/dist/messages-Bn253WWC.mjs +48 -0
  98. package/dist/messages-BrJHUxQL.mjs +48 -0
  99. package/dist/messages-C5b7hr_E.mjs +48 -0
  100. package/dist/messages-C7I_AVH2.mjs +48 -0
  101. package/dist/messages-CJoBtXU6.mjs +48 -0
  102. package/dist/messages-CQj2JU2j.mjs +48 -0
  103. package/dist/messages-CUZ1x1QD.mjs +48 -0
  104. package/dist/messages-CUy1vn-b.mjs +48 -0
  105. package/dist/messages-CVeWVKsV.mjs +48 -0
  106. package/dist/messages-CXHd9SUK.mjs +48 -0
  107. package/dist/messages-CbMyJSzS.mjs +48 -0
  108. package/dist/messages-CbhuIWRJ.mjs +48 -0
  109. package/dist/messages-CeCjVKMW.mjs +48 -0
  110. package/dist/messages-Cj-t1bdy.mjs +48 -0
  111. package/dist/messages-CkFT2gle.mjs +48 -0
  112. package/dist/messages-Cm9aLHeX.mjs +48 -0
  113. package/dist/messages-CnvW8Slp.mjs +48 -0
  114. package/dist/messages-Cr-RJ7YB.mjs +48 -0
  115. package/dist/messages-CrsJ1TEJ.mjs +48 -0
  116. package/dist/messages-Cu08aLS3.mjs +48 -0
  117. package/dist/messages-CvaqJFN-.mjs +48 -0
  118. package/dist/messages-CyDU5lz9.mjs +48 -0
  119. package/dist/messages-CySyfkMU.mjs +48 -0
  120. package/dist/messages-Cyi2AMmz.mjs +48 -0
  121. package/dist/messages-D00OjS2n.mjs +48 -0
  122. package/dist/messages-DDLgIPDF.mjs +48 -0
  123. package/dist/messages-DMQIHGRj.mjs +48 -0
  124. package/dist/messages-DOlC_Tty.mjs +48 -0
  125. package/dist/messages-DV6shA9b.mjs +48 -0
  126. package/dist/messages-DY94ykcE.mjs +48 -0
  127. package/dist/messages-DbVquYKN.mjs +48 -0
  128. package/dist/messages-DcKOuncK.mjs +48 -0
  129. package/dist/messages-Dg92dXZ5.mjs +48 -0
  130. package/dist/messages-DnbbyJT3.mjs +48 -0
  131. package/dist/messages-DteYq0rv.mjs +48 -0
  132. package/dist/messages-GC2PhgV3.mjs +48 -0
  133. package/dist/messages-JGsXAReJ.mjs +48 -0
  134. package/dist/messages-JZUhXTuV.mjs +48 -0
  135. package/dist/messages-LvFKBBPa.mjs +48 -0
  136. package/dist/messages-NP1myMGI.mjs +48 -0
  137. package/dist/messages-Q4kc_ZtL.mjs +48 -0
  138. package/dist/messages-RvMHb2Ht.mjs +48 -0
  139. package/dist/messages-ftMcCEuO.mjs +48 -0
  140. package/dist/messages-o24dK6CU.mjs +48 -0
  141. package/dist/messages-pA5TvcAj.mjs +48 -0
  142. package/dist/messages-rRSHQDCX.mjs +48 -0
  143. package/dist/messages-srxrv8Yh.mjs +48 -0
  144. package/dist/messages-wdqp4610.mjs +48 -0
  145. package/dist/messages-zS1AXZ0y.mjs +48 -0
  146. package/dist/messages-zSzDzXej.mjs +48 -0
  147. package/dist/tools.mjs +3117 -0
  148. package/dist/vendor.LICENSE.txt +26 -225
  149. package/package.json +63 -24
  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 +1428 -0
  154. package/src/components/block-tunes/block-tune-delete.ts +51 -0
  155. package/src/components/blocks.ts +352 -0
  156. package/src/components/constants/data-attributes.ts +344 -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 +497 -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 +45 -0
  177. package/src/components/i18n/locales/ar/messages.json +45 -0
  178. package/src/components/i18n/locales/az/messages.json +45 -0
  179. package/src/components/i18n/locales/bg/messages.json +45 -0
  180. package/src/components/i18n/locales/bn/messages.json +45 -0
  181. package/src/components/i18n/locales/bs/messages.json +45 -0
  182. package/src/components/i18n/locales/cs/messages.json +45 -0
  183. package/src/components/i18n/locales/da/messages.json +45 -0
  184. package/src/components/i18n/locales/de/messages.json +45 -0
  185. package/src/components/i18n/locales/dv/messages.json +45 -0
  186. package/src/components/i18n/locales/el/messages.json +45 -0
  187. package/src/components/i18n/locales/en/messages.json +45 -0
  188. package/src/components/i18n/locales/es/messages.json +45 -0
  189. package/src/components/i18n/locales/et/messages.json +45 -0
  190. package/src/components/i18n/locales/fa/messages.json +45 -0
  191. package/src/components/i18n/locales/fi/messages.json +45 -0
  192. package/src/components/i18n/locales/fil/messages.json +45 -0
  193. package/src/components/i18n/locales/fr/messages.json +45 -0
  194. package/src/components/i18n/locales/gu/messages.json +45 -0
  195. package/src/components/i18n/locales/he/messages.json +45 -0
  196. package/src/components/i18n/locales/hi/messages.json +45 -0
  197. package/src/components/i18n/locales/hr/messages.json +45 -0
  198. package/src/components/i18n/locales/hu/messages.json +45 -0
  199. package/src/components/i18n/locales/hy/messages.json +45 -0
  200. package/src/components/i18n/locales/id/messages.json +45 -0
  201. package/src/components/i18n/locales/index.ts +231 -0
  202. package/src/components/i18n/locales/it/messages.json +45 -0
  203. package/src/components/i18n/locales/ja/messages.json +45 -0
  204. package/src/components/i18n/locales/ka/messages.json +45 -0
  205. package/src/components/i18n/locales/km/messages.json +45 -0
  206. package/src/components/i18n/locales/kn/messages.json +45 -0
  207. package/src/components/i18n/locales/ko/messages.json +45 -0
  208. package/src/components/i18n/locales/ku/messages.json +45 -0
  209. package/src/components/i18n/locales/lo/messages.json +45 -0
  210. package/src/components/i18n/locales/lt/messages.json +45 -0
  211. package/src/components/i18n/locales/lv/messages.json +45 -0
  212. package/src/components/i18n/locales/mk/messages.json +45 -0
  213. package/src/components/i18n/locales/ml/messages.json +45 -0
  214. package/src/components/i18n/locales/mn/messages.json +45 -0
  215. package/src/components/i18n/locales/mr/messages.json +45 -0
  216. package/src/components/i18n/locales/ms/messages.json +45 -0
  217. package/src/components/i18n/locales/my/messages.json +45 -0
  218. package/src/components/i18n/locales/ne/messages.json +45 -0
  219. package/src/components/i18n/locales/nl/messages.json +45 -0
  220. package/src/components/i18n/locales/no/messages.json +45 -0
  221. package/src/components/i18n/locales/pa/messages.json +45 -0
  222. package/src/components/i18n/locales/pl/messages.json +45 -0
  223. package/src/components/i18n/locales/ps/messages.json +45 -0
  224. package/src/components/i18n/locales/pt/messages.json +45 -0
  225. package/src/components/i18n/locales/ro/messages.json +45 -0
  226. package/src/components/i18n/locales/ru/messages.json +45 -0
  227. package/src/components/i18n/locales/sd/messages.json +45 -0
  228. package/src/components/i18n/locales/si/messages.json +45 -0
  229. package/src/components/i18n/locales/sk/messages.json +45 -0
  230. package/src/components/i18n/locales/sl/messages.json +45 -0
  231. package/src/components/i18n/locales/sq/messages.json +45 -0
  232. package/src/components/i18n/locales/sr/messages.json +45 -0
  233. package/src/components/i18n/locales/sv/messages.json +45 -0
  234. package/src/components/i18n/locales/sw/messages.json +45 -0
  235. package/src/components/i18n/locales/ta/messages.json +45 -0
  236. package/src/components/i18n/locales/te/messages.json +45 -0
  237. package/src/components/i18n/locales/th/messages.json +45 -0
  238. package/src/components/i18n/locales/tr/messages.json +45 -0
  239. package/src/components/i18n/locales/ug/messages.json +45 -0
  240. package/src/components/i18n/locales/uk/messages.json +45 -0
  241. package/src/components/i18n/locales/ur/messages.json +45 -0
  242. package/src/components/i18n/locales/vi/messages.json +45 -0
  243. package/src/components/i18n/locales/yi/messages.json +45 -0
  244. package/src/components/i18n/locales/zh/messages.json +45 -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 +377 -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 +35 -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 +1591 -0
  269. package/src/components/modules/blockManager.ts +1356 -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 +1204 -0
  274. package/src/components/modules/history.ts +1098 -0
  275. package/src/components/modules/i18n.ts +332 -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 +711 -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 +781 -0
  284. package/src/components/modules/toolbar/index.ts +1315 -0
  285. package/src/components/modules/toolbar/inline.ts +956 -0
  286. package/src/components/modules/tools.ts +625 -0
  287. package/src/components/modules/ui.ts +1283 -0
  288. package/src/components/polyfills.ts +113 -0
  289. package/src/components/selection.ts +1179 -0
  290. package/src/components/tools/base.ts +301 -0
  291. package/src/components/tools/block.ts +339 -0
  292. package/src/components/tools/collection.ts +67 -0
  293. package/src/components/tools/factory.ts +138 -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 +601 -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 +680 -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 +186 -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 +178 -0
  330. package/src/components/utils/popover/components/search-input/search-input.types.ts +59 -0
  331. package/src/components/utils/popover/index.ts +13 -0
  332. package/src/components/utils/popover/popover-abstract.ts +457 -0
  333. package/src/components/utils/popover/popover-desktop.ts +676 -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 +110 -0
  344. package/src/components/utils/tooltip.ts +591 -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 +646 -0
  367. package/src/tools/index.ts +45 -0
  368. package/src/tools/list/index.ts +1819 -0
  369. package/src/tools/paragraph/index.ts +412 -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 +9 -1
  378. package/types/api/history.d.ts +7 -0
  379. package/types/api/i18n.d.ts +22 -3
  380. package/types/api/selection.d.ts +6 -0
  381. package/types/api/styles.d.ts +23 -10
  382. package/types/configs/blok-config.d.ts +29 -0
  383. package/types/configs/i18n-config.d.ts +52 -2
  384. package/types/configs/i18n-dictionary.d.ts +16 -90
  385. package/types/data-attributes.d.ts +170 -0
  386. package/types/data-formats/output-data.d.ts +15 -0
  387. package/types/full.d.ts +80 -0
  388. package/types/index.d.ts +30 -13
  389. package/types/locales.d.ts +59 -0
  390. package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
  391. package/types/tools/block-tool.d.ts +9 -0
  392. package/types/tools/header.d.ts +18 -0
  393. package/types/tools/index.d.ts +1 -0
  394. package/types/tools/list.d.ts +91 -0
  395. package/types/tools/paragraph.d.ts +71 -0
  396. package/types/tools/tool-settings.d.ts +92 -6
  397. package/types/tools/tool.d.ts +6 -0
  398. package/types/tools-entry.d.ts +49 -0
  399. package/types/utils/popover/popover-item.d.ts +18 -5
  400. package/types/utils/popover/popover.d.ts +7 -0
  401. package/dist/blok-D_baBvTG.mjs +0 -25795
  402. package/dist/blok.umd.js +0 -181
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 };
@@ -0,0 +1,139 @@
1
+ import type { BlokModules } from '../types-internal/blok-modules';
2
+ import type { BlokConfig } from '../../types';
3
+ import type { ModuleConfig } from '../types-internal/module-config';
4
+ import { Listeners } from './utils/listeners';
5
+ import type { EventsDispatcher } from './utils/events';
6
+ import type { BlokEventMap } from './events';
7
+
8
+ /**
9
+ * The type <T> of the Module generic.
10
+ * It describes the structure of nodes used in modules.
11
+ */
12
+ export type ModuleNodes = object;
13
+
14
+ /**
15
+ * @abstract
16
+ * @class Module
17
+ * @classdesc All modules inherits from this class.
18
+ * @typedef {Module} Module
19
+ * @property {object} config - Blok user settings
20
+ * @property {BlokModules} Blok - List of Blok modules
21
+ */
22
+ export class Module<T extends ModuleNodes = Record<string, HTMLElement>> {
23
+ /**
24
+ * Each module can provide some UI elements that will be stored in this property
25
+ */
26
+
27
+ public nodes: T = {} as any;
28
+
29
+ /**
30
+ * Blok modules list
31
+ * @type {BlokModules}
32
+ */
33
+ protected Blok: BlokModules;
34
+
35
+ /**
36
+ * Blok configuration object
37
+ * @type {BlokConfig}
38
+ */
39
+ protected config: BlokConfig;
40
+
41
+ /**
42
+ * Blok event dispatcher class
43
+ */
44
+ protected eventsDispatcher: EventsDispatcher<BlokEventMap>;
45
+
46
+ /**
47
+ * Util for bind/unbind DOM event listeners
48
+ */
49
+ protected listeners: Listeners = new Listeners();
50
+
51
+ /**
52
+ * This object provides methods to push into set of listeners that being dropped when read-only mode is enabled
53
+ */
54
+ protected readOnlyMutableListeners = {
55
+ /**
56
+ * Assigns event listener on DOM element and pushes into special array that might be removed
57
+ * @param {EventTarget} element - DOM Element
58
+ * @param {string} eventType - Event name
59
+ * @param {Function} handler - Event handler
60
+ * @param {boolean|AddEventListenerOptions} options - Listening options
61
+ */
62
+ on: (
63
+ element: EventTarget,
64
+ eventType: string,
65
+ handler: (event: Event) => void,
66
+ options: boolean | AddEventListenerOptions = false
67
+ ): void => {
68
+ const listenerId = this.listeners.on(element, eventType, handler, options);
69
+
70
+ if (listenerId) {
71
+ this.mutableListenerIds.push(listenerId);
72
+ }
73
+ },
74
+
75
+ /**
76
+ * Clears all mutable listeners
77
+ */
78
+ clearAll: (): void => {
79
+ for (const id of this.mutableListenerIds) {
80
+ this.listeners.offById(id);
81
+ }
82
+
83
+ this.mutableListenerIds = [];
84
+ },
85
+ };
86
+
87
+ /**
88
+ * The set of listener identifiers which will be dropped in read-only mode
89
+ */
90
+ private mutableListenerIds: string[] = [];
91
+
92
+ /**
93
+ * @class
94
+ * @param options - Module options
95
+ * @param options.config - Module config
96
+ * @param options.eventsDispatcher - Common event bus
97
+ */
98
+ constructor({ config, eventsDispatcher }: ModuleConfig) {
99
+ if (new.target === Module) {
100
+ throw new TypeError('Constructors for abstract class Module are not allowed.');
101
+ }
102
+
103
+ this.config = config;
104
+ this.eventsDispatcher = eventsDispatcher;
105
+ // Blok is initialized via the state setter after construction
106
+ this.Blok = {} as BlokModules;
107
+ }
108
+
109
+ /**
110
+ * Blok modules setter
111
+ * @param {BlokModules} Blok - Blok's Modules
112
+ */
113
+ public set state(Blok: BlokModules) {
114
+ this.Blok = Blok;
115
+ }
116
+
117
+ /**
118
+ * Remove memorized nodes
119
+ */
120
+ public removeAllNodes(): void {
121
+ for (const key in this.nodes) {
122
+ const node = this.nodes[key];
123
+
124
+ if (node instanceof HTMLElement) {
125
+ node.remove();
126
+ }
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Returns true if current direction is RTL (Right-To-Left).
132
+ *
133
+ * This reads from config.i18n.direction which is set by the I18n module during prepare().
134
+ * Should only be accessed after modules have been initialized.
135
+ */
136
+ protected get isRtl(): boolean {
137
+ return this.config.i18n?.direction === 'rtl';
138
+ }
139
+ }
@@ -0,0 +1,155 @@
1
+ import type { Block } from './index';
2
+ import type { BlockToolData, ToolConfig, ToolboxConfigEntry } from '../../../types/tools';
3
+ import type { SavedData } from '../../../types/data-formats';
4
+ import type { BlockAPI as BlockAPIInterface } from '../../../types/api';
5
+
6
+ /**
7
+ * Constructs new BlockAPI object
8
+ * @class
9
+ * @param {Block} block - Block to expose
10
+ */
11
+ const BlockAPIConstructor = function BlockAPI(
12
+ this: BlockAPIInterface,
13
+ block: Block
14
+ ): BlockAPIInterface {
15
+ const blockAPI: BlockAPIInterface = {
16
+ /**
17
+ * Block id
18
+ * @returns {string}
19
+ */
20
+ get id(): string {
21
+ return block.id;
22
+ },
23
+ /**
24
+ * Tool name
25
+ * @returns {string}
26
+ */
27
+ get name(): string {
28
+ return block.name;
29
+ },
30
+
31
+ /**
32
+ * Tool config passed on Blok's initialization
33
+ * @returns {ToolConfig}
34
+ */
35
+ get config(): ToolConfig {
36
+ return block.config;
37
+ },
38
+
39
+ /**
40
+ * Element, that wraps plugin contents
41
+ * @returns {HTMLElement}
42
+ */
43
+ get holder(): HTMLElement {
44
+ return block.holder;
45
+ },
46
+
47
+ /**
48
+ * True if Block content is empty
49
+ * @returns {boolean}
50
+ */
51
+ get isEmpty(): boolean {
52
+ return block.isEmpty;
53
+ },
54
+
55
+ /**
56
+ * True if Block is selected with Cross-Block selection
57
+ * @returns {boolean}
58
+ */
59
+ get selected(): boolean {
60
+ return block.selected;
61
+ },
62
+
63
+ /**
64
+ * Set Block's stretch state
65
+ * @param {boolean} state — state to set
66
+ */
67
+ set stretched(state: boolean) {
68
+ block.setStretchState(state);
69
+ },
70
+
71
+ /**
72
+ * True if Block is stretched
73
+ * @returns {boolean}
74
+ */
75
+ get stretched(): boolean {
76
+ return block.stretched;
77
+ },
78
+
79
+ /**
80
+ * True if Block has inputs to be focused
81
+ */
82
+ get focusable(): boolean {
83
+ return block.focusable;
84
+ },
85
+
86
+ /**
87
+ * Call Tool method with errors handler under-the-hood
88
+ * @param {string} methodName - method to call
89
+ * @param {object} param - object with parameters
90
+ * @returns {unknown}
91
+ */
92
+ call(methodName: string, param?: object): unknown {
93
+ return block.call(methodName, param);
94
+ },
95
+
96
+ /**
97
+ * Save Block content
98
+ * @returns {Promise<void|SavedData>}
99
+ */
100
+ save(): Promise<void|SavedData> {
101
+ return block.save();
102
+ },
103
+
104
+ /**
105
+ * Validate Block data
106
+ * @param {BlockToolData} data - data to validate
107
+ * @returns {Promise<boolean>}
108
+ */
109
+ validate(data: BlockToolData): Promise<boolean> {
110
+ return block.validate(data);
111
+ },
112
+
113
+ /**
114
+ * Allows to say Blok that Block was changed. Used to manually trigger Blok's 'onChange' callback
115
+ * Can be useful for block changes invisible for blok core.
116
+ */
117
+ dispatchChange(): void {
118
+ block.dispatchChange();
119
+ },
120
+
121
+ /**
122
+ * Tool could specify several entries to be displayed at the Toolbox (for example, "Heading 1", "Heading 2", "Heading 3")
123
+ * This method returns the entry that is related to the Block (depended on the Block data)
124
+ */
125
+ getActiveToolboxEntry(): Promise<ToolboxConfigEntry | undefined> {
126
+ return block.getActiveToolboxEntry();
127
+ },
128
+ };
129
+
130
+ Object.setPrototypeOf(this, blockAPI);
131
+
132
+ Object.defineProperties(this, {
133
+ id: {
134
+ get(): string {
135
+ return block.id;
136
+ },
137
+ enumerable: true,
138
+ configurable: true,
139
+ },
140
+ name: {
141
+ get(): string {
142
+ return block.name;
143
+ },
144
+ enumerable: true,
145
+ configurable: true,
146
+ },
147
+ });
148
+
149
+ return this;
150
+ };
151
+
152
+ // Export BlockAPI with proper constructor type
153
+ export const BlockAPI = BlockAPIConstructor as unknown as {
154
+ new (block: Block): BlockAPIInterface;
155
+ };