@jackuait/blok 0.4.1-beta.1 → 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.
- package/README.md +138 -17
- package/codemod/README.md +45 -7
- package/codemod/migrate-editorjs-to-blok.js +960 -92
- package/codemod/test.js +780 -77
- package/dist/blok.mjs +5 -2
- package/dist/chunks/blok-oNSQ3HA6.mjs +13217 -0
- package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
- package/dist/chunks/i18next-loader-BdNRw4n4.mjs +43 -0
- package/dist/{index-CEXLTV6f.mjs → chunks/index-DHgXmfki.mjs} +2 -2
- package/dist/chunks/inline-tool-convert-CRqgjRim.mjs +1989 -0
- package/dist/chunks/messages-0tDXLuyH.mjs +48 -0
- package/dist/chunks/messages-2_xedlYw.mjs +48 -0
- package/dist/chunks/messages-AHESHJm_.mjs +48 -0
- package/dist/chunks/messages-B5hdXZwA.mjs +48 -0
- package/dist/chunks/messages-B5jGUnOy.mjs +48 -0
- package/dist/chunks/messages-B5puUm7R.mjs +48 -0
- package/dist/chunks/messages-B66ZSDCJ.mjs +48 -0
- package/dist/chunks/messages-B9Oba7sq.mjs +48 -0
- package/dist/chunks/messages-BA0rcTCY.mjs +48 -0
- package/dist/chunks/messages-BBJgd5jG.mjs +48 -0
- package/dist/chunks/messages-BPqWKx5Z.mjs +48 -0
- package/dist/chunks/messages-Bdv-IkfG.mjs +48 -0
- package/dist/chunks/messages-BeUhMpsr.mjs +48 -0
- package/dist/chunks/messages-Bf6Y3_GI.mjs +48 -0
- package/dist/chunks/messages-BiExzWJv.mjs +48 -0
- package/dist/chunks/messages-BlpqL8vG.mjs +48 -0
- package/dist/chunks/messages-BmKCChWZ.mjs +48 -0
- package/dist/chunks/messages-Bn253WWC.mjs +48 -0
- package/dist/chunks/messages-BrJHUxQL.mjs +48 -0
- package/dist/chunks/messages-C5b7hr_E.mjs +48 -0
- package/dist/chunks/messages-C7I_AVH2.mjs +48 -0
- package/dist/chunks/messages-CJoBtXU6.mjs +48 -0
- package/dist/chunks/messages-CQj2JU2j.mjs +48 -0
- package/dist/chunks/messages-CUZ1x1QD.mjs +48 -0
- package/dist/chunks/messages-CUy1vn-b.mjs +48 -0
- package/dist/chunks/messages-CVeWVKsV.mjs +48 -0
- package/dist/chunks/messages-CXHd9SUK.mjs +48 -0
- package/dist/chunks/messages-CbMyJSzS.mjs +48 -0
- package/dist/chunks/messages-CbhuIWRJ.mjs +48 -0
- package/dist/chunks/messages-CeCjVKMW.mjs +48 -0
- package/dist/chunks/messages-Cj-t1bdy.mjs +48 -0
- package/dist/chunks/messages-CkFT2gle.mjs +48 -0
- package/dist/chunks/messages-Cm9aLHeX.mjs +48 -0
- package/dist/chunks/messages-CnvW8Slp.mjs +48 -0
- package/dist/chunks/messages-Cr-RJ7YB.mjs +48 -0
- package/dist/chunks/messages-CrsJ1TEJ.mjs +48 -0
- package/dist/chunks/messages-Cu08aLS3.mjs +48 -0
- package/dist/chunks/messages-CvaqJFN-.mjs +48 -0
- package/dist/chunks/messages-CyDU5lz9.mjs +48 -0
- package/dist/chunks/messages-CySyfkMU.mjs +48 -0
- package/dist/chunks/messages-Cyi2AMmz.mjs +48 -0
- package/dist/chunks/messages-D00OjS2n.mjs +48 -0
- package/dist/chunks/messages-DDLgIPDF.mjs +48 -0
- package/dist/chunks/messages-DMQIHGRj.mjs +48 -0
- package/dist/chunks/messages-DOlC_Tty.mjs +48 -0
- package/dist/chunks/messages-DV6shA9b.mjs +48 -0
- package/dist/chunks/messages-DY94ykcE.mjs +48 -0
- package/dist/chunks/messages-DbVquYKN.mjs +48 -0
- package/dist/chunks/messages-DcKOuncK.mjs +48 -0
- package/dist/chunks/messages-Dg92dXZ5.mjs +48 -0
- package/dist/chunks/messages-DnbbyJT3.mjs +48 -0
- package/dist/chunks/messages-DteYq0rv.mjs +48 -0
- package/dist/chunks/messages-GC2PhgV3.mjs +48 -0
- package/dist/chunks/messages-JGsXAReJ.mjs +48 -0
- package/dist/chunks/messages-JZUhXTuV.mjs +48 -0
- package/dist/chunks/messages-LvFKBBPa.mjs +48 -0
- package/dist/chunks/messages-NP1myMGI.mjs +48 -0
- package/dist/chunks/messages-Q4kc_ZtL.mjs +48 -0
- package/dist/chunks/messages-RvMHb2Ht.mjs +48 -0
- package/dist/chunks/messages-ftMcCEuO.mjs +48 -0
- package/dist/chunks/messages-o24dK6CU.mjs +48 -0
- package/dist/chunks/messages-pA5TvcAj.mjs +48 -0
- package/dist/chunks/messages-rRSHQDCX.mjs +48 -0
- package/dist/chunks/messages-srxrv8Yh.mjs +48 -0
- package/dist/chunks/messages-wdqp4610.mjs +48 -0
- package/dist/chunks/messages-zS1AXZ0y.mjs +48 -0
- package/dist/chunks/messages-zSzDzXej.mjs +48 -0
- package/dist/full.mjs +50 -0
- package/dist/locales.mjs +228 -0
- package/dist/messages-0tDXLuyH.mjs +48 -0
- package/dist/messages-2_xedlYw.mjs +48 -0
- package/dist/messages-AHESHJm_.mjs +48 -0
- package/dist/messages-B5hdXZwA.mjs +48 -0
- package/dist/messages-B5jGUnOy.mjs +48 -0
- package/dist/messages-B5puUm7R.mjs +48 -0
- package/dist/messages-B66ZSDCJ.mjs +48 -0
- package/dist/messages-B9Oba7sq.mjs +48 -0
- package/dist/messages-BA0rcTCY.mjs +48 -0
- package/dist/messages-BBJgd5jG.mjs +48 -0
- package/dist/messages-BPqWKx5Z.mjs +48 -0
- package/dist/messages-Bdv-IkfG.mjs +48 -0
- package/dist/messages-BeUhMpsr.mjs +48 -0
- package/dist/messages-Bf6Y3_GI.mjs +48 -0
- package/dist/messages-BiExzWJv.mjs +48 -0
- package/dist/messages-BlpqL8vG.mjs +48 -0
- package/dist/messages-BmKCChWZ.mjs +48 -0
- package/dist/messages-Bn253WWC.mjs +48 -0
- package/dist/messages-BrJHUxQL.mjs +48 -0
- package/dist/messages-C5b7hr_E.mjs +48 -0
- package/dist/messages-C7I_AVH2.mjs +48 -0
- package/dist/messages-CJoBtXU6.mjs +48 -0
- package/dist/messages-CQj2JU2j.mjs +48 -0
- package/dist/messages-CUZ1x1QD.mjs +48 -0
- package/dist/messages-CUy1vn-b.mjs +48 -0
- package/dist/messages-CVeWVKsV.mjs +48 -0
- package/dist/messages-CXHd9SUK.mjs +48 -0
- package/dist/messages-CbMyJSzS.mjs +48 -0
- package/dist/messages-CbhuIWRJ.mjs +48 -0
- package/dist/messages-CeCjVKMW.mjs +48 -0
- package/dist/messages-Cj-t1bdy.mjs +48 -0
- package/dist/messages-CkFT2gle.mjs +48 -0
- package/dist/messages-Cm9aLHeX.mjs +48 -0
- package/dist/messages-CnvW8Slp.mjs +48 -0
- package/dist/messages-Cr-RJ7YB.mjs +48 -0
- package/dist/messages-CrsJ1TEJ.mjs +48 -0
- package/dist/messages-Cu08aLS3.mjs +48 -0
- package/dist/messages-CvaqJFN-.mjs +48 -0
- package/dist/messages-CyDU5lz9.mjs +48 -0
- package/dist/messages-CySyfkMU.mjs +48 -0
- package/dist/messages-Cyi2AMmz.mjs +48 -0
- package/dist/messages-D00OjS2n.mjs +48 -0
- package/dist/messages-DDLgIPDF.mjs +48 -0
- package/dist/messages-DMQIHGRj.mjs +48 -0
- package/dist/messages-DOlC_Tty.mjs +48 -0
- package/dist/messages-DV6shA9b.mjs +48 -0
- package/dist/messages-DY94ykcE.mjs +48 -0
- package/dist/messages-DbVquYKN.mjs +48 -0
- package/dist/messages-DcKOuncK.mjs +48 -0
- package/dist/messages-Dg92dXZ5.mjs +48 -0
- package/dist/messages-DnbbyJT3.mjs +48 -0
- package/dist/messages-DteYq0rv.mjs +48 -0
- package/dist/messages-GC2PhgV3.mjs +48 -0
- package/dist/messages-JGsXAReJ.mjs +48 -0
- package/dist/messages-JZUhXTuV.mjs +48 -0
- package/dist/messages-LvFKBBPa.mjs +48 -0
- package/dist/messages-NP1myMGI.mjs +48 -0
- package/dist/messages-Q4kc_ZtL.mjs +48 -0
- package/dist/messages-RvMHb2Ht.mjs +48 -0
- package/dist/messages-ftMcCEuO.mjs +48 -0
- package/dist/messages-o24dK6CU.mjs +48 -0
- package/dist/messages-pA5TvcAj.mjs +48 -0
- package/dist/messages-rRSHQDCX.mjs +48 -0
- package/dist/messages-srxrv8Yh.mjs +48 -0
- package/dist/messages-wdqp4610.mjs +48 -0
- package/dist/messages-zS1AXZ0y.mjs +48 -0
- package/dist/messages-zSzDzXej.mjs +48 -0
- package/dist/tools.mjs +3117 -0
- package/dist/vendor.LICENSE.txt +26 -225
- package/package.json +63 -24
- package/src/blok.ts +267 -0
- package/src/components/__module.ts +139 -0
- package/src/components/block/api.ts +155 -0
- package/src/components/block/index.ts +1428 -0
- package/src/components/block-tunes/block-tune-delete.ts +51 -0
- package/src/components/blocks.ts +352 -0
- package/src/components/constants/data-attributes.ts +344 -0
- package/src/components/constants.ts +76 -0
- package/src/components/core.ts +392 -0
- package/src/components/dom.ts +773 -0
- package/src/components/domIterator.ts +189 -0
- package/src/components/errors/critical.ts +5 -0
- package/src/components/events/BlockChanged.ts +16 -0
- package/src/components/events/BlockHovered.ts +21 -0
- package/src/components/events/BlockSettingsClosed.ts +12 -0
- package/src/components/events/BlockSettingsOpened.ts +12 -0
- package/src/components/events/BlokMobileLayoutToggled.ts +15 -0
- package/src/components/events/FakeCursorAboutToBeToggled.ts +17 -0
- package/src/components/events/FakeCursorHaveBeenSet.ts +17 -0
- package/src/components/events/HistoryStateChanged.ts +19 -0
- package/src/components/events/RedactorDomChanged.ts +14 -0
- package/src/components/events/index.ts +46 -0
- package/src/components/flipper.ts +497 -0
- package/src/components/i18n/i18next-loader.ts +84 -0
- package/src/components/i18n/lightweight-i18n.ts +86 -0
- package/src/components/i18n/locales/TRANSLATION_GUIDELINES.md +113 -0
- package/src/components/i18n/locales/am/messages.json +45 -0
- package/src/components/i18n/locales/ar/messages.json +45 -0
- package/src/components/i18n/locales/az/messages.json +45 -0
- package/src/components/i18n/locales/bg/messages.json +45 -0
- package/src/components/i18n/locales/bn/messages.json +45 -0
- package/src/components/i18n/locales/bs/messages.json +45 -0
- package/src/components/i18n/locales/cs/messages.json +45 -0
- package/src/components/i18n/locales/da/messages.json +45 -0
- package/src/components/i18n/locales/de/messages.json +45 -0
- package/src/components/i18n/locales/dv/messages.json +45 -0
- package/src/components/i18n/locales/el/messages.json +45 -0
- package/src/components/i18n/locales/en/messages.json +45 -0
- package/src/components/i18n/locales/es/messages.json +45 -0
- package/src/components/i18n/locales/et/messages.json +45 -0
- package/src/components/i18n/locales/fa/messages.json +45 -0
- package/src/components/i18n/locales/fi/messages.json +45 -0
- package/src/components/i18n/locales/fil/messages.json +45 -0
- package/src/components/i18n/locales/fr/messages.json +45 -0
- package/src/components/i18n/locales/gu/messages.json +45 -0
- package/src/components/i18n/locales/he/messages.json +45 -0
- package/src/components/i18n/locales/hi/messages.json +45 -0
- package/src/components/i18n/locales/hr/messages.json +45 -0
- package/src/components/i18n/locales/hu/messages.json +45 -0
- package/src/components/i18n/locales/hy/messages.json +45 -0
- package/src/components/i18n/locales/id/messages.json +45 -0
- package/src/components/i18n/locales/index.ts +231 -0
- package/src/components/i18n/locales/it/messages.json +45 -0
- package/src/components/i18n/locales/ja/messages.json +45 -0
- package/src/components/i18n/locales/ka/messages.json +45 -0
- package/src/components/i18n/locales/km/messages.json +45 -0
- package/src/components/i18n/locales/kn/messages.json +45 -0
- package/src/components/i18n/locales/ko/messages.json +45 -0
- package/src/components/i18n/locales/ku/messages.json +45 -0
- package/src/components/i18n/locales/lo/messages.json +45 -0
- package/src/components/i18n/locales/lt/messages.json +45 -0
- package/src/components/i18n/locales/lv/messages.json +45 -0
- package/src/components/i18n/locales/mk/messages.json +45 -0
- package/src/components/i18n/locales/ml/messages.json +45 -0
- package/src/components/i18n/locales/mn/messages.json +45 -0
- package/src/components/i18n/locales/mr/messages.json +45 -0
- package/src/components/i18n/locales/ms/messages.json +45 -0
- package/src/components/i18n/locales/my/messages.json +45 -0
- package/src/components/i18n/locales/ne/messages.json +45 -0
- package/src/components/i18n/locales/nl/messages.json +45 -0
- package/src/components/i18n/locales/no/messages.json +45 -0
- package/src/components/i18n/locales/pa/messages.json +45 -0
- package/src/components/i18n/locales/pl/messages.json +45 -0
- package/src/components/i18n/locales/ps/messages.json +45 -0
- package/src/components/i18n/locales/pt/messages.json +45 -0
- package/src/components/i18n/locales/ro/messages.json +45 -0
- package/src/components/i18n/locales/ru/messages.json +45 -0
- package/src/components/i18n/locales/sd/messages.json +45 -0
- package/src/components/i18n/locales/si/messages.json +45 -0
- package/src/components/i18n/locales/sk/messages.json +45 -0
- package/src/components/i18n/locales/sl/messages.json +45 -0
- package/src/components/i18n/locales/sq/messages.json +45 -0
- package/src/components/i18n/locales/sr/messages.json +45 -0
- package/src/components/i18n/locales/sv/messages.json +45 -0
- package/src/components/i18n/locales/sw/messages.json +45 -0
- package/src/components/i18n/locales/ta/messages.json +45 -0
- package/src/components/i18n/locales/te/messages.json +45 -0
- package/src/components/i18n/locales/th/messages.json +45 -0
- package/src/components/i18n/locales/tr/messages.json +45 -0
- package/src/components/i18n/locales/ug/messages.json +45 -0
- package/src/components/i18n/locales/uk/messages.json +45 -0
- package/src/components/i18n/locales/ur/messages.json +45 -0
- package/src/components/i18n/locales/vi/messages.json +45 -0
- package/src/components/i18n/locales/yi/messages.json +45 -0
- package/src/components/i18n/locales/zh/messages.json +45 -0
- package/src/components/icons/index.ts +242 -0
- package/src/components/inline-tools/inline-tool-bold.ts +2213 -0
- package/src/components/inline-tools/inline-tool-convert.ts +141 -0
- package/src/components/inline-tools/inline-tool-italic.ts +500 -0
- package/src/components/inline-tools/inline-tool-link.ts +539 -0
- package/src/components/modules/api/blocks.ts +377 -0
- package/src/components/modules/api/caret.ts +125 -0
- package/src/components/modules/api/events.ts +51 -0
- package/src/components/modules/api/history.ts +73 -0
- package/src/components/modules/api/i18n.ts +35 -0
- package/src/components/modules/api/index.ts +39 -0
- package/src/components/modules/api/inlineToolbar.ts +33 -0
- package/src/components/modules/api/listeners.ts +56 -0
- package/src/components/modules/api/notifier.ts +46 -0
- package/src/components/modules/api/readonly.ts +39 -0
- package/src/components/modules/api/sanitizer.ts +30 -0
- package/src/components/modules/api/saver.ts +52 -0
- package/src/components/modules/api/selection.ts +48 -0
- package/src/components/modules/api/styles.ts +72 -0
- package/src/components/modules/api/toolbar.ts +79 -0
- package/src/components/modules/api/tools.ts +16 -0
- package/src/components/modules/api/tooltip.ts +67 -0
- package/src/components/modules/api/ui.ts +36 -0
- package/src/components/modules/blockEvents.ts +1591 -0
- package/src/components/modules/blockManager.ts +1356 -0
- package/src/components/modules/blockSelection.ts +708 -0
- package/src/components/modules/caret.ts +853 -0
- package/src/components/modules/crossBlockSelection.ts +329 -0
- package/src/components/modules/dragManager.ts +1204 -0
- package/src/components/modules/history.ts +1098 -0
- package/src/components/modules/i18n.ts +332 -0
- package/src/components/modules/index.ts +139 -0
- package/src/components/modules/modificationsObserver.ts +147 -0
- package/src/components/modules/paste.ts +1092 -0
- package/src/components/modules/readonly.ts +136 -0
- package/src/components/modules/rectangleSelection.ts +711 -0
- package/src/components/modules/renderer.ts +155 -0
- package/src/components/modules/saver.ts +283 -0
- package/src/components/modules/toolbar/blockSettings.ts +781 -0
- package/src/components/modules/toolbar/index.ts +1315 -0
- package/src/components/modules/toolbar/inline.ts +956 -0
- package/src/components/modules/tools.ts +625 -0
- package/src/components/modules/ui.ts +1283 -0
- package/src/components/polyfills.ts +113 -0
- package/src/components/selection.ts +1179 -0
- package/src/components/tools/base.ts +301 -0
- package/src/components/tools/block.ts +339 -0
- package/src/components/tools/collection.ts +67 -0
- package/src/components/tools/factory.ts +138 -0
- package/src/components/tools/inline.ts +71 -0
- package/src/components/tools/tune.ts +33 -0
- package/src/components/ui/toolbox.ts +601 -0
- package/src/components/utils/announcer.ts +205 -0
- package/src/components/utils/api.ts +20 -0
- package/src/components/utils/bem.ts +26 -0
- package/src/components/utils/blocks.ts +284 -0
- package/src/components/utils/caret.ts +1067 -0
- package/src/components/utils/data-model-transform.ts +382 -0
- package/src/components/utils/events.ts +117 -0
- package/src/components/utils/keyboard.ts +60 -0
- package/src/components/utils/listeners.ts +296 -0
- package/src/components/utils/mutations.ts +39 -0
- package/src/components/utils/notifier/draw.ts +190 -0
- package/src/components/utils/notifier/index.ts +66 -0
- package/src/components/utils/notifier/types.ts +1 -0
- package/src/components/utils/notifier.ts +77 -0
- package/src/components/utils/placeholder.ts +140 -0
- package/src/components/utils/popover/components/hint/hint.const.ts +10 -0
- package/src/components/utils/popover/components/hint/hint.ts +46 -0
- package/src/components/utils/popover/components/hint/index.ts +6 -0
- package/src/components/utils/popover/components/popover-header/index.ts +2 -0
- package/src/components/utils/popover/components/popover-header/popover-header.const.ts +8 -0
- package/src/components/utils/popover/components/popover-header/popover-header.ts +80 -0
- package/src/components/utils/popover/components/popover-header/popover-header.types.ts +14 -0
- package/src/components/utils/popover/components/popover-item/index.ts +13 -0
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.const.ts +50 -0
- package/src/components/utils/popover/components/popover-item/popover-item-default/popover-item-default.ts +680 -0
- package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.const.ts +14 -0
- package/src/components/utils/popover/components/popover-item/popover-item-html/popover-item-html.ts +136 -0
- package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.const.ts +20 -0
- package/src/components/utils/popover/components/popover-item/popover-item-separator/popover-item-separator.ts +117 -0
- package/src/components/utils/popover/components/popover-item/popover-item.ts +186 -0
- package/src/components/utils/popover/components/search-input/index.ts +2 -0
- package/src/components/utils/popover/components/search-input/search-input.const.ts +8 -0
- package/src/components/utils/popover/components/search-input/search-input.ts +178 -0
- package/src/components/utils/popover/components/search-input/search-input.types.ts +59 -0
- package/src/components/utils/popover/index.ts +13 -0
- package/src/components/utils/popover/popover-abstract.ts +457 -0
- package/src/components/utils/popover/popover-desktop.ts +676 -0
- package/src/components/utils/popover/popover-inline.ts +338 -0
- package/src/components/utils/popover/popover-mobile.ts +201 -0
- package/src/components/utils/popover/popover.const.ts +81 -0
- package/src/components/utils/popover/utils/popover-states-history.ts +72 -0
- package/src/components/utils/promise-queue.ts +43 -0
- package/src/components/utils/sanitizer.ts +537 -0
- package/src/components/utils/scroll-locker.ts +87 -0
- package/src/components/utils/shortcut.ts +231 -0
- package/src/components/utils/shortcuts.ts +113 -0
- package/src/components/utils/tools.ts +110 -0
- package/src/components/utils/tooltip.ts +591 -0
- package/src/components/utils/tw.ts +241 -0
- package/src/components/utils.ts +1081 -0
- package/src/env.d.ts +13 -0
- package/src/full.ts +69 -0
- package/src/locales.ts +51 -0
- package/src/stories/Block.stories.ts +498 -0
- package/src/stories/EditorModes.stories.ts +505 -0
- package/src/stories/Header.stories.ts +137 -0
- package/src/stories/InlineToolbar.stories.ts +498 -0
- package/src/stories/List.stories.ts +259 -0
- package/src/stories/Notifier.stories.ts +340 -0
- package/src/stories/Paragraph.stories.ts +112 -0
- package/src/stories/Placeholder.stories.ts +319 -0
- package/src/stories/Popover.stories.ts +844 -0
- package/src/stories/Selection.stories.ts +250 -0
- package/src/stories/StubBlock.stories.ts +156 -0
- package/src/stories/Toolbar.stories.ts +223 -0
- package/src/stories/Toolbox.stories.ts +166 -0
- package/src/stories/Tooltip.stories.ts +198 -0
- package/src/stories/helpers.ts +463 -0
- package/src/styles/main.css +123 -0
- package/src/tools/header/index.ts +646 -0
- package/src/tools/index.ts +45 -0
- package/src/tools/list/index.ts +1819 -0
- package/src/tools/paragraph/index.ts +412 -0
- package/src/tools/stub/index.ts +107 -0
- package/src/types-internal/blok-modules.d.ts +87 -0
- package/src/types-internal/html-janitor.d.ts +28 -0
- package/src/types-internal/module-config.d.ts +11 -0
- package/src/variants/all-locales.ts +155 -0
- package/src/variants/blok-maximum.ts +20 -0
- package/src/variants/blok-minimum.ts +243 -0
- package/types/api/blocks.d.ts +9 -1
- package/types/api/history.d.ts +7 -0
- package/types/api/i18n.d.ts +22 -3
- package/types/api/selection.d.ts +6 -0
- package/types/api/styles.d.ts +23 -10
- package/types/configs/blok-config.d.ts +29 -0
- package/types/configs/i18n-config.d.ts +52 -2
- package/types/configs/i18n-dictionary.d.ts +16 -90
- package/types/data-attributes.d.ts +170 -0
- package/types/data-formats/output-data.d.ts +15 -0
- package/types/full.d.ts +80 -0
- package/types/index.d.ts +29 -13
- package/types/locales.d.ts +59 -0
- package/types/tools/adapters/inline-tool-adapter.d.ts +10 -0
- package/types/tools/block-tool.d.ts +9 -0
- package/types/tools/header.d.ts +18 -0
- package/types/tools/index.d.ts +1 -0
- package/types/tools/list.d.ts +91 -0
- package/types/tools/paragraph.d.ts +71 -0
- package/types/tools/tool-settings.d.ts +92 -6
- package/types/tools/tool.d.ts +6 -0
- package/types/tools-entry.d.ts +49 -0
- package/types/utils/popover/popover-item.d.ts +18 -5
- package/types/utils/popover/popover.d.ts +7 -0
- package/dist/blok-C8XbyLHh.mjs +0 -25795
- package/dist/blok.umd.js +0 -181
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class DeleteTune
|
|
3
|
+
* @classdesc Blok's default tune that moves up selected block
|
|
4
|
+
* @copyright <CodeX Team> 2018
|
|
5
|
+
*/
|
|
6
|
+
import type { API, BlockTune } from '../../../types';
|
|
7
|
+
import { IconCross } from '../icons';
|
|
8
|
+
import type { MenuConfig } from '../../../types/tools/menu-config';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export class DeleteTune implements BlockTune {
|
|
14
|
+
/**
|
|
15
|
+
* Set Tool is Tune
|
|
16
|
+
*/
|
|
17
|
+
public static readonly isTune = true;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Property that contains Blok API methods
|
|
21
|
+
* @see {@link docs/api.md}
|
|
22
|
+
*/
|
|
23
|
+
private readonly api: API;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* DeleteTune constructor
|
|
27
|
+
* @param {API} api - Blok's API
|
|
28
|
+
*/
|
|
29
|
+
constructor({ api }: { api: API }) {
|
|
30
|
+
this.api = api;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Tune's appearance in block settings menu
|
|
35
|
+
*/
|
|
36
|
+
public render(): MenuConfig {
|
|
37
|
+
return {
|
|
38
|
+
icon: IconCross,
|
|
39
|
+
title: this.api.i18n.t('blockSettings.delete'),
|
|
40
|
+
name: 'delete',
|
|
41
|
+
onActivate: (): void => this.handleClick(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Delete block conditions passed
|
|
47
|
+
*/
|
|
48
|
+
public handleClick(): void {
|
|
49
|
+
void this.api.blocks.delete();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { array } from './utils';
|
|
2
|
+
import type { Block } from './block';
|
|
3
|
+
import { BlockToolAPI } from './block';
|
|
4
|
+
import type { MoveEvent } from '../../types/tools';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class Blocks
|
|
8
|
+
* @classdesc Class to work with Block instances array
|
|
9
|
+
* @private
|
|
10
|
+
* @property {HTMLElement} workingArea — blok`s working node
|
|
11
|
+
*/
|
|
12
|
+
export class Blocks {
|
|
13
|
+
/**
|
|
14
|
+
* Array of Block instances in order of addition
|
|
15
|
+
*/
|
|
16
|
+
public blocks: Block[];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Blok`s area where to add Block`s HTML
|
|
20
|
+
*/
|
|
21
|
+
public workingArea: HTMLElement;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @class
|
|
25
|
+
* @param {HTMLElement} workingArea — blok`s working node
|
|
26
|
+
*/
|
|
27
|
+
constructor(workingArea: HTMLElement) {
|
|
28
|
+
this.blocks = [];
|
|
29
|
+
this.workingArea = workingArea;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get length of Block instances array
|
|
34
|
+
* @returns {number}
|
|
35
|
+
*/
|
|
36
|
+
public get length(): number {
|
|
37
|
+
return this.blocks.length;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get Block instances array
|
|
42
|
+
* @returns {Block[]}
|
|
43
|
+
*/
|
|
44
|
+
public get array(): Block[] {
|
|
45
|
+
return this.blocks;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get blocks html elements array
|
|
50
|
+
* @returns {HTMLElement[]}
|
|
51
|
+
*/
|
|
52
|
+
public get nodes(): HTMLElement[] {
|
|
53
|
+
return array(this.workingArea.children);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Proxy trap to implement array-like setter
|
|
58
|
+
* @example
|
|
59
|
+
* blocks[0] = new Block(...)
|
|
60
|
+
* @param {Blocks} instance — Blocks instance
|
|
61
|
+
* @param {PropertyKey} property — block index or any Blocks class property key to set
|
|
62
|
+
* @param {Block} value — value to set
|
|
63
|
+
* @returns {boolean}
|
|
64
|
+
*/
|
|
65
|
+
public static set(instance: Blocks, property: PropertyKey, value: Block | unknown): boolean {
|
|
66
|
+
/**
|
|
67
|
+
* If property name is not a number (method or other property, access it via reflect
|
|
68
|
+
*/
|
|
69
|
+
if (isNaN(Number(property))) {
|
|
70
|
+
Reflect.set(instance, property, value);
|
|
71
|
+
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* If property is number, call insert method to emulate array behaviour
|
|
77
|
+
* @example
|
|
78
|
+
* blocks[0] = new Block();
|
|
79
|
+
*/
|
|
80
|
+
instance.insert(+(property as number), value as Block);
|
|
81
|
+
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Proxy trap to implement array-like getter
|
|
87
|
+
* @param {Blocks} instance — Blocks instance
|
|
88
|
+
* @param {PropertyKey} property — Blocks class property key
|
|
89
|
+
* @returns {Block|*}
|
|
90
|
+
*/
|
|
91
|
+
public static get(instance: Blocks, property: PropertyKey): Block | unknown {
|
|
92
|
+
/**
|
|
93
|
+
* If property is not a number, get it via Reflect object
|
|
94
|
+
*/
|
|
95
|
+
if (isNaN(Number(property))) {
|
|
96
|
+
return Reflect.get(instance, property);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* If property is a number (Block index) return Block by passed index
|
|
101
|
+
*/
|
|
102
|
+
return instance.get(+(property as number));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Push new Block to the blocks array and append it to working area
|
|
107
|
+
* @param {Block} block - Block to add
|
|
108
|
+
*/
|
|
109
|
+
public push(block: Block): void {
|
|
110
|
+
this.blocks.push(block);
|
|
111
|
+
this.insertToDOM(block);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Move a block from one to another index
|
|
116
|
+
* @param {number} toIndex - new index of the block
|
|
117
|
+
* @param {number} fromIndex - block to move
|
|
118
|
+
* @param {boolean} skipDOM - if true, do not manipulate DOM (useful when SortableJS already did it)
|
|
119
|
+
*/
|
|
120
|
+
public move(toIndex: number, fromIndex: number, skipDOM = false): void {
|
|
121
|
+
/**
|
|
122
|
+
* cut out the block, move the DOM element and insert at the desired index
|
|
123
|
+
* again (the shifting within the blocks array will happen automatically).
|
|
124
|
+
* @see https://stackoverflow.com/a/44932690/1238150
|
|
125
|
+
*/
|
|
126
|
+
const block = this.blocks.splice(fromIndex, 1)[0];
|
|
127
|
+
|
|
128
|
+
if (!skipDOM) {
|
|
129
|
+
// manipulate DOM
|
|
130
|
+
const prevIndex = toIndex - 1;
|
|
131
|
+
const previousBlockIndex = Math.max(0, prevIndex);
|
|
132
|
+
const previousBlock = this.blocks[previousBlockIndex];
|
|
133
|
+
|
|
134
|
+
const position = toIndex > 0 ? 'afterend' : 'beforebegin';
|
|
135
|
+
|
|
136
|
+
this.insertToDOM(block, position, previousBlock);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// move in array
|
|
140
|
+
this.blocks.splice(toIndex, 0, block);
|
|
141
|
+
|
|
142
|
+
// invoke hook
|
|
143
|
+
const event: MoveEvent = this.composeBlockEvent('move', {
|
|
144
|
+
fromIndex,
|
|
145
|
+
toIndex,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
block.call(BlockToolAPI.MOVED, event);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Insert new Block at passed index
|
|
153
|
+
* @param {number} index — index to insert Block
|
|
154
|
+
* @param {Block} block — Block to insert
|
|
155
|
+
* @param {boolean} replace — it true, replace block on given index
|
|
156
|
+
*/
|
|
157
|
+
public insert(index: number, block: Block, replace = false): void {
|
|
158
|
+
if (!this.length) {
|
|
159
|
+
this.push(block);
|
|
160
|
+
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const insertIndex = index > this.length ? this.length : index;
|
|
165
|
+
|
|
166
|
+
if (replace) {
|
|
167
|
+
const blockToReplace = this.blocks[insertIndex];
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Call REMOVED lifecycle hook first, then destroy to unsubscribe from
|
|
171
|
+
* mutation events, then remove DOM element. This prevents spurious
|
|
172
|
+
* 'block-changed' events from being fired when the DOM element is removed.
|
|
173
|
+
*/
|
|
174
|
+
blockToReplace.call(BlockToolAPI.REMOVED);
|
|
175
|
+
blockToReplace.destroy();
|
|
176
|
+
blockToReplace.holder.remove();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const deleteCount = replace ? 1 : 0;
|
|
180
|
+
|
|
181
|
+
this.blocks.splice(insertIndex, deleteCount, block);
|
|
182
|
+
|
|
183
|
+
if (insertIndex > 0) {
|
|
184
|
+
const previousBlock = this.blocks[insertIndex - 1];
|
|
185
|
+
|
|
186
|
+
this.insertToDOM(block, 'afterend', previousBlock);
|
|
187
|
+
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const nextBlock = this.blocks[insertIndex + 1];
|
|
192
|
+
|
|
193
|
+
if (nextBlock !== undefined) {
|
|
194
|
+
this.insertToDOM(block, 'beforebegin', nextBlock);
|
|
195
|
+
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.insertToDOM(block);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Replaces block under passed index with passed block
|
|
204
|
+
* @param index - index of existed block
|
|
205
|
+
* @param block - new block
|
|
206
|
+
*/
|
|
207
|
+
public replace(index: number, block: Block): void {
|
|
208
|
+
if (this.blocks[index] === undefined) {
|
|
209
|
+
throw Error('Incorrect index');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const prevBlock = this.blocks[index];
|
|
213
|
+
|
|
214
|
+
prevBlock.holder.replaceWith(block.holder);
|
|
215
|
+
prevBlock.call(BlockToolAPI.REMOVED);
|
|
216
|
+
|
|
217
|
+
this.blocks[index] = block;
|
|
218
|
+
|
|
219
|
+
block.call(BlockToolAPI.RENDERED);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Inserts several blocks at once
|
|
224
|
+
* @param blocks - blocks to insert
|
|
225
|
+
* @param index - index to insert blocks at
|
|
226
|
+
*/
|
|
227
|
+
public insertMany(blocks: Block[], index: number ): void {
|
|
228
|
+
const fragment = new DocumentFragment();
|
|
229
|
+
|
|
230
|
+
for (const block of blocks) {
|
|
231
|
+
fragment.appendChild(block.holder);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (!this.length) {
|
|
235
|
+
this.blocks.push(...blocks);
|
|
236
|
+
this.workingArea.appendChild(fragment);
|
|
237
|
+
|
|
238
|
+
blocks.forEach((block) => block.call(BlockToolAPI.RENDERED));
|
|
239
|
+
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (index > 0) {
|
|
244
|
+
const previousBlockIndex = Math.min(index - 1, this.length - 1);
|
|
245
|
+
const previousBlock = this.blocks[previousBlockIndex];
|
|
246
|
+
|
|
247
|
+
previousBlock.holder.after(fragment);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (index === 0) {
|
|
251
|
+
this.workingArea.prepend(fragment);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Insert blocks to the array at the specified index
|
|
256
|
+
*/
|
|
257
|
+
this.blocks.splice(index, 0, ...blocks);
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Call Rendered event for each block
|
|
261
|
+
*/
|
|
262
|
+
blocks.forEach((block) => block.call(BlockToolAPI.RENDERED));
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Remove block
|
|
267
|
+
* @param {number} index - index of Block to remove
|
|
268
|
+
*/
|
|
269
|
+
public remove(index: number): void {
|
|
270
|
+
const removeIndex = isNaN(index) ? this.length - 1 : index;
|
|
271
|
+
const blockToRemove = this.blocks[removeIndex];
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Call REMOVED lifecycle hook first, then destroy to unsubscribe from
|
|
275
|
+
* mutation events, then remove DOM element. This prevents spurious
|
|
276
|
+
* 'block-changed' events from being fired when the DOM element is removed.
|
|
277
|
+
*/
|
|
278
|
+
blockToRemove.call(BlockToolAPI.REMOVED);
|
|
279
|
+
blockToRemove.destroy();
|
|
280
|
+
blockToRemove.holder.remove();
|
|
281
|
+
|
|
282
|
+
this.blocks.splice(removeIndex, 1);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Remove all blocks
|
|
287
|
+
*/
|
|
288
|
+
public removeAll(): void {
|
|
289
|
+
this.workingArea.innerHTML = '';
|
|
290
|
+
|
|
291
|
+
this.blocks.forEach((block) => block.call(BlockToolAPI.REMOVED));
|
|
292
|
+
|
|
293
|
+
this.blocks.length = 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Insert Block after passed target
|
|
298
|
+
* @todo decide if this method is necessary
|
|
299
|
+
* @param {Block} targetBlock — target after which Block should be inserted
|
|
300
|
+
* @param {Block} newBlock — Block to insert
|
|
301
|
+
*/
|
|
302
|
+
public insertAfter(targetBlock: Block, newBlock: Block): void {
|
|
303
|
+
const index = this.blocks.indexOf(targetBlock);
|
|
304
|
+
|
|
305
|
+
this.insert(index + 1, newBlock);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Get Block by index
|
|
310
|
+
* @param {number} index — Block index
|
|
311
|
+
* @returns {Block}
|
|
312
|
+
*/
|
|
313
|
+
public get(index: number): Block | undefined {
|
|
314
|
+
return this.blocks[index];
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Return index of passed Block
|
|
319
|
+
* @param {Block} block - Block to find
|
|
320
|
+
* @returns {number}
|
|
321
|
+
*/
|
|
322
|
+
public indexOf(block: Block): number {
|
|
323
|
+
return this.blocks.indexOf(block);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Insert new Block into DOM
|
|
328
|
+
* @param {Block} block - Block to insert
|
|
329
|
+
* @param {InsertPosition} position — insert position (if set, will use insertAdjacentElement)
|
|
330
|
+
* @param {Block} target — Block related to position
|
|
331
|
+
*/
|
|
332
|
+
private insertToDOM(block: Block, position?: InsertPosition, target?: Block): void {
|
|
333
|
+
if (position && target !== undefined) {
|
|
334
|
+
target.holder.insertAdjacentElement(position, block.holder);
|
|
335
|
+
} else {
|
|
336
|
+
this.workingArea.appendChild(block.holder);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
block.call(BlockToolAPI.RENDERED);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Composes Block event with passed type and details
|
|
344
|
+
* @param {string} type - event type
|
|
345
|
+
* @param {object} detail - event detail
|
|
346
|
+
*/
|
|
347
|
+
private composeBlockEvent(type: string, detail: object): MoveEvent {
|
|
348
|
+
return new CustomEvent(type, {
|
|
349
|
+
detail,
|
|
350
|
+
}) as MoveEvent;
|
|
351
|
+
}
|
|
352
|
+
}
|