@jackuait/blok 0.4.1-beta.5 → 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-Cl_5rkKS.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 +59 -156
- package/package.json +48 -16
- 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 +0 -5
- package/types/configs/blok-config.d.ts +21 -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 +0 -5
- package/dist/blok-DvN73wsH.mjs +0 -19922
- package/dist/blok.umd.js +0 -166
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { InlineToolbar } from '../../../../types/api/inline-toolbar';
|
|
2
|
+
import { Module } from '../../__module';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class InlineToolbarAPI
|
|
6
|
+
* Provides methods for working with the Inline Toolbar
|
|
7
|
+
*/
|
|
8
|
+
export class InlineToolbarAPI extends Module {
|
|
9
|
+
/**
|
|
10
|
+
* Available methods
|
|
11
|
+
* @returns {InlineToolbar}
|
|
12
|
+
*/
|
|
13
|
+
public get methods(): InlineToolbar {
|
|
14
|
+
return {
|
|
15
|
+
close: (): void => this.close(),
|
|
16
|
+
open: (): void => this.open(),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Open Inline Toolbar
|
|
22
|
+
*/
|
|
23
|
+
public open(): void {
|
|
24
|
+
void this.Blok.InlineToolbar.tryToShow();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Close Inline Toolbar
|
|
29
|
+
*/
|
|
30
|
+
public close(): void {
|
|
31
|
+
this.Blok.InlineToolbar.close();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Listeners } from '../../../../types/api';
|
|
2
|
+
import { Module } from '../../__module';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class ListenersAPI
|
|
6
|
+
* Provides with methods working with DOM Listener
|
|
7
|
+
*/
|
|
8
|
+
export class ListenersAPI extends Module {
|
|
9
|
+
/**
|
|
10
|
+
* Available methods
|
|
11
|
+
* @returns {Listeners}
|
|
12
|
+
*/
|
|
13
|
+
public get methods(): Listeners {
|
|
14
|
+
return {
|
|
15
|
+
on: (element: HTMLElement, eventType, handler, useCapture): string | undefined =>
|
|
16
|
+
this.on(element, eventType, handler, useCapture),
|
|
17
|
+
off: (element, eventType, handler, useCapture): void => this.off(element, eventType, handler, useCapture),
|
|
18
|
+
offById: (id): void => this.offById(id),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Ads a DOM event listener. Return it's id.
|
|
24
|
+
* @param {HTMLElement} element - Element to set handler to
|
|
25
|
+
* @param {string} eventType - event type
|
|
26
|
+
* @param {() => void} handler - event handler
|
|
27
|
+
* @param {boolean} useCapture - capture event or not
|
|
28
|
+
*/
|
|
29
|
+
public on(
|
|
30
|
+
element: HTMLElement,
|
|
31
|
+
eventType: string,
|
|
32
|
+
handler: () => void,
|
|
33
|
+
useCapture?: boolean
|
|
34
|
+
): string | undefined {
|
|
35
|
+
return this.listeners.on(element, eventType, handler, useCapture);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Removes DOM listener from element
|
|
40
|
+
* @param {Element} element - Element to remove handler from
|
|
41
|
+
* @param eventType - event type
|
|
42
|
+
* @param handler - event handler
|
|
43
|
+
* @param {boolean} useCapture - capture event or not
|
|
44
|
+
*/
|
|
45
|
+
public off(element: Element, eventType: string, handler: () => void, useCapture?: boolean): void {
|
|
46
|
+
this.listeners.off(element, eventType, handler, useCapture);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Removes DOM listener by the listener id
|
|
51
|
+
* @param id - id of the listener to remove
|
|
52
|
+
*/
|
|
53
|
+
public offById(id: string): void {
|
|
54
|
+
this.listeners.offById(id);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Notifier as INotifier } from '../../../../types/api';
|
|
2
|
+
import { Notifier } from '../../utils/notifier';
|
|
3
|
+
import type { ConfirmNotifierOptions, NotifierOptions, PromptNotifierOptions } from '../../utils/notifier/types';
|
|
4
|
+
import { Module } from '../../__module';
|
|
5
|
+
import type { ModuleConfig } from '../../../types-internal/module-config';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export class NotifierAPI extends Module {
|
|
11
|
+
/**
|
|
12
|
+
* Notifier utility Instance
|
|
13
|
+
*/
|
|
14
|
+
private notifier: Notifier;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param moduleConfiguration - Module Configuration
|
|
18
|
+
* @param moduleConfiguration.config - Blok's config
|
|
19
|
+
* @param moduleConfiguration.eventsDispatcher - Blok's event dispatcher
|
|
20
|
+
*/
|
|
21
|
+
constructor({ config, eventsDispatcher }: ModuleConfig) {
|
|
22
|
+
super({
|
|
23
|
+
config,
|
|
24
|
+
eventsDispatcher,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
this.notifier = new Notifier();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Available methods
|
|
32
|
+
*/
|
|
33
|
+
public get methods(): INotifier {
|
|
34
|
+
return {
|
|
35
|
+
show: (options: NotifierOptions | ConfirmNotifierOptions | PromptNotifierOptions): void => this.show(options),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Show notification
|
|
41
|
+
* @param {NotifierOptions} options - message option
|
|
42
|
+
*/
|
|
43
|
+
public show(options: NotifierOptions | ConfirmNotifierOptions | PromptNotifierOptions): void {
|
|
44
|
+
return this.notifier.show(options);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReadOnly } from '../../../../types/api';
|
|
2
|
+
import { Module } from '../../__module';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class ReadOnlyAPI
|
|
6
|
+
* @classdesc ReadOnly API
|
|
7
|
+
*/
|
|
8
|
+
export class ReadOnlyAPI extends Module {
|
|
9
|
+
/**
|
|
10
|
+
* Available methods
|
|
11
|
+
*/
|
|
12
|
+
public get methods(): ReadOnly {
|
|
13
|
+
const getIsEnabled = (): boolean => this.isEnabled;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
toggle: (state): Promise<boolean> => this.toggle(state),
|
|
18
|
+
get isEnabled(): boolean {
|
|
19
|
+
return getIsEnabled();
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Set or toggle read-only state
|
|
26
|
+
* @param {boolean|undefined} state - set or toggle state
|
|
27
|
+
* @returns {boolean} current value
|
|
28
|
+
*/
|
|
29
|
+
public toggle(state?: boolean): Promise<boolean> {
|
|
30
|
+
return this.Blok.ReadOnly.toggle(state);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns current read-only state
|
|
35
|
+
*/
|
|
36
|
+
public get isEnabled(): boolean {
|
|
37
|
+
return this.Blok.ReadOnly.isEnabled;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Sanitizer as ISanitizer } from '../../../../types/api';
|
|
2
|
+
import type { SanitizerConfig } from '../../../../types/configs';
|
|
3
|
+
import { Module } from '../../__module';
|
|
4
|
+
import { clean } from '../../utils/sanitizer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class SanitizerAPI
|
|
8
|
+
* Provides Blok Sanitizer that allows developers to clean their HTML
|
|
9
|
+
*/
|
|
10
|
+
export class SanitizerAPI extends Module {
|
|
11
|
+
/**
|
|
12
|
+
* Available methods
|
|
13
|
+
* @returns {SanitizerConfig}
|
|
14
|
+
*/
|
|
15
|
+
public get methods(): ISanitizer {
|
|
16
|
+
return {
|
|
17
|
+
clean: (taintString, config): string => this.clean(taintString, config),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Perform sanitizing of a string
|
|
23
|
+
* @param {string} taintString - what to sanitize
|
|
24
|
+
* @param {SanitizerConfig} config - sanitizer config
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
public clean(taintString: string, config: SanitizerConfig): string {
|
|
28
|
+
return clean(taintString, config);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Saver } from '../../../../types/api';
|
|
2
|
+
import type { OutputData } from '../../../../types';
|
|
3
|
+
import { logLabeled } from '../../utils';
|
|
4
|
+
import { Module } from '../../__module';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class SaverAPI
|
|
8
|
+
* provides with methods to save data
|
|
9
|
+
*/
|
|
10
|
+
export class SaverAPI extends Module {
|
|
11
|
+
/**
|
|
12
|
+
* Available methods
|
|
13
|
+
* @returns {Saver}
|
|
14
|
+
*/
|
|
15
|
+
public get methods(): Saver {
|
|
16
|
+
return {
|
|
17
|
+
save: (): Promise<OutputData> => this.save(),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Return Blok's data
|
|
23
|
+
* @returns {OutputData}
|
|
24
|
+
*/
|
|
25
|
+
public async save(): Promise<OutputData> {
|
|
26
|
+
const errorText = 'Blok\'s content can not be saved in read-only mode';
|
|
27
|
+
|
|
28
|
+
if (this.Blok.ReadOnly.isEnabled) {
|
|
29
|
+
logLabeled(errorText, 'warn');
|
|
30
|
+
|
|
31
|
+
throw new Error(errorText);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const savedData = await this.Blok.Saver.save();
|
|
35
|
+
|
|
36
|
+
if (savedData !== undefined) {
|
|
37
|
+
return savedData;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const lastError = this.Blok.Saver.getLastSaveError?.();
|
|
41
|
+
|
|
42
|
+
if (lastError instanceof Error) {
|
|
43
|
+
throw lastError;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const errorMessage = lastError !== undefined
|
|
47
|
+
? String(lastError)
|
|
48
|
+
: 'Blok\'s content can not be saved because collecting data failed';
|
|
49
|
+
|
|
50
|
+
throw new Error(errorMessage);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SelectionUtils } from '../../selection';
|
|
2
|
+
import type { Selection as SelectionAPIInterface } from '../../../../types/api';
|
|
3
|
+
import { Module } from '../../__module';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @class SelectionAPI
|
|
7
|
+
* Provides with methods working with SelectionUtils
|
|
8
|
+
*/
|
|
9
|
+
export class SelectionAPI extends Module {
|
|
10
|
+
/**
|
|
11
|
+
* Global SelectionUtils instance
|
|
12
|
+
*/
|
|
13
|
+
private selectionUtils = new SelectionUtils();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Available methods
|
|
17
|
+
* @returns {SelectionAPIInterface}
|
|
18
|
+
*/
|
|
19
|
+
public get methods(): SelectionAPIInterface {
|
|
20
|
+
return {
|
|
21
|
+
findParentTag: (tagName: string, className?: string): HTMLElement | null => this.findParentTag(tagName, className),
|
|
22
|
+
expandToTag: (node: HTMLElement): void => this.expandToTag(node),
|
|
23
|
+
save: () => this.selectionUtils.save(),
|
|
24
|
+
restore: () => this.selectionUtils.restore(),
|
|
25
|
+
setFakeBackground: () => this.selectionUtils.setFakeBackground(),
|
|
26
|
+
removeFakeBackground: () => this.selectionUtils.removeFakeBackground(),
|
|
27
|
+
clearFakeBackground: () => this.selectionUtils.clearFakeBackground(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Looks ahead from selection and find passed tag with class name
|
|
33
|
+
* @param {string} tagName - tag to find
|
|
34
|
+
* @param {string} className - tag's class name
|
|
35
|
+
* @returns {HTMLElement|null}
|
|
36
|
+
*/
|
|
37
|
+
public findParentTag(tagName: string, className?: string): HTMLElement | null {
|
|
38
|
+
return this.selectionUtils.findParentTag(tagName, className);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Expand selection to passed tag
|
|
43
|
+
* @param {HTMLElement} node - tag that should contain selection
|
|
44
|
+
*/
|
|
45
|
+
public expandToTag(node: HTMLElement): void {
|
|
46
|
+
this.selectionUtils.expandToTag(node);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Styles } from '../../../../types/api';
|
|
2
|
+
import { Module } from '../../__module';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* StylesAPI provides CSS class names for tool authors.
|
|
6
|
+
*
|
|
7
|
+
* These are single class names that can be safely used with classList.add():
|
|
8
|
+
* @example
|
|
9
|
+
* element.classList.add(api.styles.block);
|
|
10
|
+
*
|
|
11
|
+
* They can also be extended using tailwind-merge:
|
|
12
|
+
* @example
|
|
13
|
+
* import { twMerge } from '@jackuait/blok/utils/tw';
|
|
14
|
+
* const customBlock = twMerge(api.styles.block, 'my-4 bg-gray-100');
|
|
15
|
+
*/
|
|
16
|
+
export class StylesAPI extends Module {
|
|
17
|
+
/**
|
|
18
|
+
* Exported CSS class names for tool styling.
|
|
19
|
+
* These are single class names that can be safely used with classList.add().
|
|
20
|
+
* The actual styles are defined in src/styles/main.css using @apply.
|
|
21
|
+
*/
|
|
22
|
+
public get classes(): Styles {
|
|
23
|
+
return {
|
|
24
|
+
/**
|
|
25
|
+
* Base Block styles - applied to block tool wrappers
|
|
26
|
+
* Includes placeholder styling via pseudo-element
|
|
27
|
+
*/
|
|
28
|
+
block: 'blok-block',
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Inline Tools styles
|
|
32
|
+
*/
|
|
33
|
+
inlineToolButton: 'blok-inline-tool-button',
|
|
34
|
+
inlineToolButtonActive: 'blok-inline-tool-button--active',
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Input element styles with Firefox placeholder workaround
|
|
38
|
+
*/
|
|
39
|
+
input: 'blok-input',
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Loader styles with spinning animation
|
|
43
|
+
*/
|
|
44
|
+
loader: 'blok-loader',
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Button styles with hover state
|
|
48
|
+
*/
|
|
49
|
+
button: 'blok-button',
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Settings button base styles with mobile responsive sizing
|
|
53
|
+
*/
|
|
54
|
+
settingsButton: 'blok-settings-button',
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Settings button active state
|
|
58
|
+
*/
|
|
59
|
+
settingsButtonActive: 'blok-settings-button--active',
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Settings button focused state
|
|
63
|
+
*/
|
|
64
|
+
settingsButtonFocused: 'blok-settings-button--focused',
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Settings button focused with animation
|
|
68
|
+
*/
|
|
69
|
+
settingsButtonFocusedAnimated: 'blok-settings-button--focused-animated',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Toolbar } from '../../../../types/api';
|
|
2
|
+
import { Module } from '../../__module';
|
|
3
|
+
import { logLabeled } from './../../utils';
|
|
4
|
+
/**
|
|
5
|
+
* @class ToolbarAPI
|
|
6
|
+
* Provides methods for working with the Toolbar
|
|
7
|
+
*/
|
|
8
|
+
export class ToolbarAPI extends Module {
|
|
9
|
+
/**
|
|
10
|
+
* Available methods
|
|
11
|
+
* @returns {Toolbar}
|
|
12
|
+
*/
|
|
13
|
+
public get methods(): Toolbar {
|
|
14
|
+
return {
|
|
15
|
+
close: (): void => this.close(),
|
|
16
|
+
open: (): void => this.open(),
|
|
17
|
+
toggleBlockSettings: (openingState?: boolean): void => this.toggleBlockSettings(openingState),
|
|
18
|
+
toggleToolbox: (openingState?: boolean): void => this.toggleToolbox(openingState),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Open toolbar
|
|
24
|
+
*/
|
|
25
|
+
public open(): void {
|
|
26
|
+
this.Blok.Toolbar.moveAndOpen();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Close toolbar and all included elements
|
|
31
|
+
*/
|
|
32
|
+
public close(): void {
|
|
33
|
+
this.Blok.Toolbar.close();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Toggles Block Setting of the current block
|
|
38
|
+
* @param {boolean} openingState — opening state of Block Setting
|
|
39
|
+
*/
|
|
40
|
+
public toggleBlockSettings(openingState?: boolean): void {
|
|
41
|
+
if (this.Blok.BlockManager.currentBlockIndex === -1) {
|
|
42
|
+
logLabeled('Could\'t toggle the Toolbar because there is no block selected ', 'warn');
|
|
43
|
+
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Check that opening state is set or not */
|
|
48
|
+
const canOpenBlockSettings = openingState ?? !this.Blok.BlockSettings.opened;
|
|
49
|
+
|
|
50
|
+
if (canOpenBlockSettings) {
|
|
51
|
+
this.Blok.Toolbar.moveAndOpen();
|
|
52
|
+
void this.Blok.BlockSettings.open();
|
|
53
|
+
} else {
|
|
54
|
+
this.Blok.BlockSettings.close();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Open toolbox
|
|
61
|
+
* @param {boolean} openingState - Opening state of toolbox
|
|
62
|
+
*/
|
|
63
|
+
public toggleToolbox(openingState?: boolean): void {
|
|
64
|
+
if (this.Blok.BlockManager.currentBlockIndex === -1) {
|
|
65
|
+
logLabeled('Could\'t toggle the Toolbox because there is no block selected ', 'warn');
|
|
66
|
+
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const canOpenToolbox = openingState ?? !this.Blok.Toolbar.toolbox.opened;
|
|
71
|
+
|
|
72
|
+
if (canOpenToolbox) {
|
|
73
|
+
this.Blok.Toolbar.moveAndOpen();
|
|
74
|
+
this.Blok.Toolbar.toolbox.open();
|
|
75
|
+
} else {
|
|
76
|
+
this.Blok.Toolbar.toolbox.close();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Tools as ToolsAPIInterface } from '../../../../types/api';
|
|
2
|
+
import { Module } from '../../__module';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Provides methods for accessing installed Blok tools
|
|
6
|
+
*/
|
|
7
|
+
export class ToolsAPI extends Module {
|
|
8
|
+
/**
|
|
9
|
+
* Available methods
|
|
10
|
+
*/
|
|
11
|
+
public get methods(): ToolsAPIInterface {
|
|
12
|
+
return {
|
|
13
|
+
getBlockTools: () => Array.from(this.Blok.Tools.blockTools.values()),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Tooltip as ITooltip } from '../../../../types/api';
|
|
2
|
+
import type { TooltipOptions, TooltipContent } from '../../utils/tooltip';
|
|
3
|
+
import { Module } from '../../__module';
|
|
4
|
+
import type { ModuleConfig } from '../../../types-internal/module-config';
|
|
5
|
+
import { hide, onHover, show } from '../../utils/tooltip';
|
|
6
|
+
/**
|
|
7
|
+
* @class TooltipAPI
|
|
8
|
+
* @classdesc Tooltip API
|
|
9
|
+
*/
|
|
10
|
+
export class TooltipAPI extends Module {
|
|
11
|
+
/**
|
|
12
|
+
* @class
|
|
13
|
+
* @param moduleConfiguration - Module Configuration
|
|
14
|
+
* @param moduleConfiguration.config - Blok's config
|
|
15
|
+
* @param moduleConfiguration.eventsDispatcher - Blok's event dispatcher
|
|
16
|
+
*/
|
|
17
|
+
constructor({ config, eventsDispatcher }: ModuleConfig) {
|
|
18
|
+
super({
|
|
19
|
+
config,
|
|
20
|
+
eventsDispatcher,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Available methods
|
|
26
|
+
*/
|
|
27
|
+
public get methods(): ITooltip {
|
|
28
|
+
return {
|
|
29
|
+
show: (element: HTMLElement,
|
|
30
|
+
content: TooltipContent,
|
|
31
|
+
options?: TooltipOptions
|
|
32
|
+
): void => this.show(element, content, options),
|
|
33
|
+
hide: (): void => this.hide(),
|
|
34
|
+
onHover: (element: HTMLElement,
|
|
35
|
+
content: TooltipContent,
|
|
36
|
+
options?: TooltipOptions
|
|
37
|
+
): void => this.onHover(element, content, options),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Method show tooltip on element with passed HTML content
|
|
43
|
+
* @param {HTMLElement} element - element on which tooltip should be shown
|
|
44
|
+
* @param {TooltipContent} content - tooltip content
|
|
45
|
+
* @param {TooltipOptions} options - tooltip options
|
|
46
|
+
*/
|
|
47
|
+
public show(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
|
48
|
+
show(element, content, options);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Method hides tooltip on HTML page
|
|
53
|
+
*/
|
|
54
|
+
public hide(): void {
|
|
55
|
+
hide();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Decorator for showing Tooltip by mouseenter/mouseleave
|
|
60
|
+
* @param {HTMLElement} element - element on which tooltip should be shown
|
|
61
|
+
* @param {TooltipContent} content - tooltip content
|
|
62
|
+
* @param {TooltipOptions} options - tooltip options
|
|
63
|
+
*/
|
|
64
|
+
public onHover(element: HTMLElement, content: TooltipContent, options?: TooltipOptions): void {
|
|
65
|
+
onHover(element, content, options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Module } from '../../__module';
|
|
2
|
+
import type { Ui, UiNodes } from '../../../../types/api';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* API module allowing to access some Blok UI elements
|
|
6
|
+
*/
|
|
7
|
+
export class UiAPI extends Module {
|
|
8
|
+
/**
|
|
9
|
+
* Available methods / getters
|
|
10
|
+
*/
|
|
11
|
+
public get methods(): Ui {
|
|
12
|
+
return {
|
|
13
|
+
nodes: this.blokNodes,
|
|
14
|
+
/**
|
|
15
|
+
* There can be added some UI methods, like toggleThinMode() etc
|
|
16
|
+
*/
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Exported classes
|
|
22
|
+
*/
|
|
23
|
+
private get blokNodes(): UiNodes {
|
|
24
|
+
return {
|
|
25
|
+
/**
|
|
26
|
+
* Top-level blok instance wrapper
|
|
27
|
+
*/
|
|
28
|
+
wrapper: this.Blok.UI.nodes.wrapper,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Element that holds all the Blocks
|
|
32
|
+
*/
|
|
33
|
+
redactor: this.Blok.UI.nodes.redactor,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|