@jackuait/blok 0.4.1-beta.4 → 0.4.1-beta.6
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 +136 -17
- package/codemod/README.md +16 -0
- package/codemod/migrate-editorjs-to-blok.js +868 -92
- package/codemod/test.js +682 -77
- package/dist/blok.mjs +5 -2
- package/dist/chunks/blok-B5qs7C5l.mjs +12838 -0
- package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
- package/dist/chunks/i18next-loader-CTrK3HzG.mjs +43 -0
- package/dist/{index-XWGz4gev.mjs → chunks/index-DDpzQn-0.mjs} +2 -2
- package/dist/chunks/inline-tool-convert-RBcopmCh.mjs +1988 -0
- package/dist/chunks/messages-2434tVOK.mjs +47 -0
- package/dist/chunks/messages-3DcCwXMF.mjs +47 -0
- package/dist/chunks/messages-4kMwVAKY.mjs +47 -0
- package/dist/chunks/messages-57uL5htT.mjs +47 -0
- package/dist/chunks/messages-76-iJV9Q.mjs +47 -0
- package/dist/chunks/messages-8p86Eyf2.mjs +47 -0
- package/dist/chunks/messages-BBX0p0Pi.mjs +47 -0
- package/dist/chunks/messages-BCm2eudQ.mjs +47 -0
- package/dist/chunks/messages-BFiUomgG.mjs +47 -0
- package/dist/chunks/messages-BIPNHHAV.mjs +47 -0
- package/dist/chunks/messages-BUlwu9mo.mjs +47 -0
- package/dist/chunks/messages-BX-DPa-z.mjs +47 -0
- package/dist/chunks/messages-BextV3Qh.mjs +47 -0
- package/dist/chunks/messages-BiPSFlUG.mjs +47 -0
- package/dist/chunks/messages-BiXe9G-O.mjs +47 -0
- package/dist/chunks/messages-Bl5z_Igo.mjs +47 -0
- package/dist/chunks/messages-BnsE97ku.mjs +47 -0
- package/dist/chunks/messages-BoO8gsVD.mjs +47 -0
- package/dist/chunks/messages-BqWaOGMn.mjs +47 -0
- package/dist/chunks/messages-BqkL2_Ro.mjs +47 -0
- package/dist/chunks/messages-BvCkXKX-.mjs +47 -0
- package/dist/chunks/messages-C6tbPLoj.mjs +47 -0
- package/dist/chunks/messages-CA6T3-gQ.mjs +47 -0
- package/dist/chunks/messages-CFFPFdWP.mjs +47 -0
- package/dist/chunks/messages-CFrKE-TN.mjs +47 -0
- package/dist/chunks/messages-CHz8VlG-.mjs +47 -0
- package/dist/chunks/messages-CLixzySl.mjs +47 -0
- package/dist/chunks/messages-CV7OM_qk.mjs +47 -0
- package/dist/chunks/messages-CXHt3eCC.mjs +47 -0
- package/dist/chunks/messages-CbmsBrB0.mjs +47 -0
- package/dist/chunks/messages-Ceo1KtFx.mjs +47 -0
- package/dist/chunks/messages-Cm0LJLtB.mjs +47 -0
- package/dist/chunks/messages-CmymP_Ar.mjs +47 -0
- package/dist/chunks/messages-D0ohMB5H.mjs +47 -0
- package/dist/chunks/messages-D3GrDwXh.mjs +47 -0
- package/dist/chunks/messages-D3vTzIpL.mjs +47 -0
- package/dist/chunks/messages-D5WeksbV.mjs +47 -0
- package/dist/chunks/messages-DGaab4EP.mjs +47 -0
- package/dist/chunks/messages-DKha57ZU.mjs +47 -0
- package/dist/chunks/messages-DOaujgMW.mjs +47 -0
- package/dist/chunks/messages-DVbPLd_0.mjs +47 -0
- package/dist/chunks/messages-D_FCyfW6.mjs +47 -0
- package/dist/chunks/messages-Dd5iZN3c.mjs +47 -0
- package/dist/chunks/messages-DehM7135.mjs +47 -0
- package/dist/chunks/messages-Dg1OHftD.mjs +47 -0
- package/dist/chunks/messages-Di6Flq-b.mjs +47 -0
- package/dist/chunks/messages-Dqhhex6e.mjs +47 -0
- package/dist/chunks/messages-DueVe0F1.mjs +47 -0
- package/dist/chunks/messages-Dx3eFwI0.mjs +47 -0
- package/dist/chunks/messages-FOtiUoKl.mjs +47 -0
- package/dist/chunks/messages-FTOZNhRD.mjs +47 -0
- package/dist/chunks/messages-IQxGfQIV.mjs +47 -0
- package/dist/chunks/messages-JF2fzCkK.mjs +47 -0
- package/dist/chunks/messages-MOGl7I5v.mjs +47 -0
- package/dist/chunks/messages-QgYhPL-3.mjs +47 -0
- package/dist/chunks/messages-WYWIbQwo.mjs +47 -0
- package/dist/chunks/messages-a6A_LgDv.mjs +47 -0
- package/dist/chunks/messages-bSf31LJi.mjs +47 -0
- package/dist/chunks/messages-diGozhTn.mjs +47 -0
- package/dist/chunks/messages-er-kd-VO.mjs +47 -0
- package/dist/chunks/messages-ez3w5NBn.mjs +47 -0
- package/dist/chunks/messages-f3uXjegd.mjs +47 -0
- package/dist/chunks/messages-ohwI1UGv.mjs +47 -0
- package/dist/chunks/messages-p9BZJaFV.mjs +47 -0
- package/dist/chunks/messages-qIQ4L4rw.mjs +47 -0
- package/dist/chunks/messages-qWkXPggi.mjs +47 -0
- package/dist/chunks/messages-w5foGze_.mjs +47 -0
- package/dist/full.mjs +50 -0
- package/dist/locales.mjs +227 -0
- package/dist/messages-2434tVOK.mjs +47 -0
- package/dist/messages-3DcCwXMF.mjs +47 -0
- package/dist/messages-4kMwVAKY.mjs +47 -0
- package/dist/messages-57uL5htT.mjs +47 -0
- package/dist/messages-76-iJV9Q.mjs +47 -0
- package/dist/messages-8p86Eyf2.mjs +47 -0
- package/dist/messages-BBX0p0Pi.mjs +47 -0
- package/dist/messages-BCm2eudQ.mjs +47 -0
- package/dist/messages-BFiUomgG.mjs +47 -0
- package/dist/messages-BIPNHHAV.mjs +47 -0
- package/dist/messages-BUlwu9mo.mjs +47 -0
- package/dist/messages-BX-DPa-z.mjs +47 -0
- package/dist/messages-BextV3Qh.mjs +47 -0
- package/dist/messages-BiPSFlUG.mjs +47 -0
- package/dist/messages-BiXe9G-O.mjs +47 -0
- package/dist/messages-Bl5z_Igo.mjs +47 -0
- package/dist/messages-BnsE97ku.mjs +47 -0
- package/dist/messages-BoO8gsVD.mjs +47 -0
- package/dist/messages-BqWaOGMn.mjs +47 -0
- package/dist/messages-BqkL2_Ro.mjs +47 -0
- package/dist/messages-BvCkXKX-.mjs +47 -0
- package/dist/messages-C6tbPLoj.mjs +47 -0
- package/dist/messages-CA6T3-gQ.mjs +47 -0
- package/dist/messages-CFFPFdWP.mjs +47 -0
- package/dist/messages-CFrKE-TN.mjs +47 -0
- package/dist/messages-CHz8VlG-.mjs +47 -0
- package/dist/messages-CLixzySl.mjs +47 -0
- package/dist/messages-CV7OM_qk.mjs +47 -0
- package/dist/messages-CXHt3eCC.mjs +47 -0
- package/dist/messages-CbmsBrB0.mjs +47 -0
- package/dist/messages-Ceo1KtFx.mjs +47 -0
- package/dist/messages-Cm0LJLtB.mjs +47 -0
- package/dist/messages-CmymP_Ar.mjs +47 -0
- package/dist/messages-D0ohMB5H.mjs +47 -0
- package/dist/messages-D3GrDwXh.mjs +47 -0
- package/dist/messages-D3vTzIpL.mjs +47 -0
- package/dist/messages-D5WeksbV.mjs +47 -0
- package/dist/messages-DGaab4EP.mjs +47 -0
- package/dist/messages-DKha57ZU.mjs +47 -0
- package/dist/messages-DOaujgMW.mjs +47 -0
- package/dist/messages-DVbPLd_0.mjs +47 -0
- package/dist/messages-D_FCyfW6.mjs +47 -0
- package/dist/messages-Dd5iZN3c.mjs +47 -0
- package/dist/messages-DehM7135.mjs +47 -0
- package/dist/messages-Dg1OHftD.mjs +47 -0
- package/dist/messages-Di6Flq-b.mjs +47 -0
- package/dist/messages-Dqhhex6e.mjs +47 -0
- package/dist/messages-DueVe0F1.mjs +47 -0
- package/dist/messages-Dx3eFwI0.mjs +47 -0
- package/dist/messages-FOtiUoKl.mjs +47 -0
- package/dist/messages-FTOZNhRD.mjs +47 -0
- package/dist/messages-IQxGfQIV.mjs +47 -0
- package/dist/messages-JF2fzCkK.mjs +47 -0
- package/dist/messages-MOGl7I5v.mjs +47 -0
- package/dist/messages-QgYhPL-3.mjs +47 -0
- package/dist/messages-WYWIbQwo.mjs +47 -0
- package/dist/messages-a6A_LgDv.mjs +47 -0
- package/dist/messages-bSf31LJi.mjs +47 -0
- package/dist/messages-diGozhTn.mjs +47 -0
- package/dist/messages-er-kd-VO.mjs +47 -0
- package/dist/messages-ez3w5NBn.mjs +47 -0
- package/dist/messages-f3uXjegd.mjs +47 -0
- package/dist/messages-ohwI1UGv.mjs +47 -0
- package/dist/messages-p9BZJaFV.mjs +47 -0
- package/dist/messages-qIQ4L4rw.mjs +47 -0
- package/dist/messages-qWkXPggi.mjs +47 -0
- package/dist/messages-w5foGze_.mjs +47 -0
- package/dist/tools.mjs +3073 -0
- package/dist/vendor.LICENSE.txt +26 -225
- package/package.json +49 -23
- 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 +1427 -0
- package/src/components/block-tunes/block-tune-delete.ts +51 -0
- package/src/components/blocks.ts +338 -0
- package/src/components/constants/data-attributes.ts +342 -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 +481 -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 +44 -0
- package/src/components/i18n/locales/ar/messages.json +44 -0
- package/src/components/i18n/locales/az/messages.json +44 -0
- package/src/components/i18n/locales/bg/messages.json +44 -0
- package/src/components/i18n/locales/bn/messages.json +44 -0
- package/src/components/i18n/locales/bs/messages.json +44 -0
- package/src/components/i18n/locales/cs/messages.json +44 -0
- package/src/components/i18n/locales/da/messages.json +44 -0
- package/src/components/i18n/locales/de/messages.json +44 -0
- package/src/components/i18n/locales/dv/messages.json +44 -0
- package/src/components/i18n/locales/el/messages.json +44 -0
- package/src/components/i18n/locales/en/messages.json +44 -0
- package/src/components/i18n/locales/es/messages.json +44 -0
- package/src/components/i18n/locales/et/messages.json +44 -0
- package/src/components/i18n/locales/fa/messages.json +44 -0
- package/src/components/i18n/locales/fi/messages.json +44 -0
- package/src/components/i18n/locales/fil/messages.json +44 -0
- package/src/components/i18n/locales/fr/messages.json +44 -0
- package/src/components/i18n/locales/gu/messages.json +44 -0
- package/src/components/i18n/locales/he/messages.json +44 -0
- package/src/components/i18n/locales/hi/messages.json +44 -0
- package/src/components/i18n/locales/hr/messages.json +44 -0
- package/src/components/i18n/locales/hu/messages.json +44 -0
- package/src/components/i18n/locales/hy/messages.json +44 -0
- package/src/components/i18n/locales/id/messages.json +44 -0
- package/src/components/i18n/locales/index.ts +225 -0
- package/src/components/i18n/locales/it/messages.json +44 -0
- package/src/components/i18n/locales/ja/messages.json +44 -0
- package/src/components/i18n/locales/ka/messages.json +44 -0
- package/src/components/i18n/locales/km/messages.json +44 -0
- package/src/components/i18n/locales/kn/messages.json +44 -0
- package/src/components/i18n/locales/ko/messages.json +44 -0
- package/src/components/i18n/locales/ku/messages.json +44 -0
- package/src/components/i18n/locales/lo/messages.json +44 -0
- package/src/components/i18n/locales/lt/messages.json +44 -0
- package/src/components/i18n/locales/lv/messages.json +44 -0
- package/src/components/i18n/locales/mk/messages.json +44 -0
- package/src/components/i18n/locales/ml/messages.json +44 -0
- package/src/components/i18n/locales/mn/messages.json +44 -0
- package/src/components/i18n/locales/mr/messages.json +44 -0
- package/src/components/i18n/locales/ms/messages.json +44 -0
- package/src/components/i18n/locales/my/messages.json +44 -0
- package/src/components/i18n/locales/ne/messages.json +44 -0
- package/src/components/i18n/locales/nl/messages.json +44 -0
- package/src/components/i18n/locales/no/messages.json +44 -0
- package/src/components/i18n/locales/pa/messages.json +44 -0
- package/src/components/i18n/locales/pl/messages.json +44 -0
- package/src/components/i18n/locales/ps/messages.json +44 -0
- package/src/components/i18n/locales/pt/messages.json +44 -0
- package/src/components/i18n/locales/ro/messages.json +44 -0
- package/src/components/i18n/locales/ru/messages.json +44 -0
- package/src/components/i18n/locales/sd/messages.json +44 -0
- package/src/components/i18n/locales/si/messages.json +44 -0
- package/src/components/i18n/locales/sk/messages.json +44 -0
- package/src/components/i18n/locales/sl/messages.json +44 -0
- package/src/components/i18n/locales/sq/messages.json +44 -0
- package/src/components/i18n/locales/sr/messages.json +44 -0
- package/src/components/i18n/locales/sv/messages.json +44 -0
- package/src/components/i18n/locales/sw/messages.json +44 -0
- package/src/components/i18n/locales/ta/messages.json +44 -0
- package/src/components/i18n/locales/te/messages.json +44 -0
- package/src/components/i18n/locales/th/messages.json +44 -0
- package/src/components/i18n/locales/tr/messages.json +44 -0
- package/src/components/i18n/locales/ug/messages.json +44 -0
- package/src/components/i18n/locales/uk/messages.json +44 -0
- package/src/components/i18n/locales/ur/messages.json +44 -0
- package/src/components/i18n/locales/vi/messages.json +44 -0
- package/src/components/i18n/locales/yi/messages.json +44 -0
- package/src/components/i18n/locales/zh/messages.json +44 -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 +363 -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 +33 -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 +1375 -0
- package/src/components/modules/blockManager.ts +1348 -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 +1141 -0
- package/src/components/modules/history.ts +1098 -0
- package/src/components/modules/i18n.ts +325 -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 +668 -0
- package/src/components/modules/renderer.ts +155 -0
- package/src/components/modules/saver.ts +283 -0
- package/src/components/modules/toolbar/blockSettings.ts +776 -0
- package/src/components/modules/toolbar/index.ts +1311 -0
- package/src/components/modules/toolbar/inline.ts +956 -0
- package/src/components/modules/tools.ts +589 -0
- package/src/components/modules/ui.ts +1179 -0
- package/src/components/polyfills.ts +113 -0
- package/src/components/selection.ts +1189 -0
- package/src/components/tools/base.ts +274 -0
- package/src/components/tools/block.ts +291 -0
- package/src/components/tools/collection.ts +67 -0
- package/src/components/tools/factory.ts +85 -0
- package/src/components/tools/inline.ts +71 -0
- package/src/components/tools/tune.ts +33 -0
- package/src/components/ui/toolbox.ts +497 -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 +666 -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 +187 -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 +181 -0
- package/src/components/utils/popover/components/search-input/search-input.types.ts +30 -0
- package/src/components/utils/popover/index.ts +13 -0
- package/src/components/utils/popover/popover-abstract.ts +448 -0
- package/src/components/utils/popover/popover-desktop.ts +643 -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 +105 -0
- package/src/components/utils/tooltip.ts +642 -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 +570 -0
- package/src/tools/index.ts +38 -0
- package/src/tools/list/index.ts +1803 -0
- package/src/tools/paragraph/index.ts +411 -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 +1 -1
- package/types/api/i18n.d.ts +5 -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 +169 -0
- package/types/data-formats/output-data.d.ts +15 -0
- package/types/full.d.ts +80 -0
- package/types/index.d.ts +9 -12
- 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 +16 -2
- package/types/tools/tool.d.ts +6 -0
- package/types/tools-entry.d.ts +49 -0
- package/types/utils/popover/popover-item.d.ts +6 -5
- package/dist/blok-B870U2fw.mjs +0 -25803
- 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
|
+
};
|