@jackuait/blok 0.4.1 → 0.4.2
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 +859 -92
- package/codemod/test.js +682 -77
- package/dist/blok.mjs +5 -2
- package/dist/chunks/blok-BjgH1REI.mjs +12838 -0
- package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
- package/dist/chunks/i18next-loader-DfiUa_gd.mjs +43 -0
- package/dist/{index-CBkApZKo.mjs → chunks/index-5m5JWNey.mjs} +2 -2
- package/dist/chunks/inline-tool-convert-Bx5BVd8I.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 +47 -15
- 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 -24
- 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/list.d.ts +25 -18
- package/types/tools/tool-settings.d.ts +8 -1
- 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-BwPfU8ro.mjs +0 -21510
- package/dist/blok.umd.js +0 -198
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported modifier commands and their aliases
|
|
3
|
+
*/
|
|
4
|
+
const SUPPORTED_COMMANDS = {
|
|
5
|
+
SHIFT: ['SHIFT'],
|
|
6
|
+
CMD: ['CMD', 'CONTROL', 'COMMAND', 'WINDOWS', 'CTRL'],
|
|
7
|
+
ALT: ['ALT', 'OPTION'],
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Key name mappings to event.code values
|
|
12
|
+
*/
|
|
13
|
+
const KEY_CODES: Record<string, string> = {
|
|
14
|
+
'0': 'Digit0',
|
|
15
|
+
'1': 'Digit1',
|
|
16
|
+
'2': 'Digit2',
|
|
17
|
+
'3': 'Digit3',
|
|
18
|
+
'4': 'Digit4',
|
|
19
|
+
'5': 'Digit5',
|
|
20
|
+
'6': 'Digit6',
|
|
21
|
+
'7': 'Digit7',
|
|
22
|
+
'8': 'Digit8',
|
|
23
|
+
'9': 'Digit9',
|
|
24
|
+
'A': 'KeyA',
|
|
25
|
+
'B': 'KeyB',
|
|
26
|
+
'C': 'KeyC',
|
|
27
|
+
'D': 'KeyD',
|
|
28
|
+
'E': 'KeyE',
|
|
29
|
+
'F': 'KeyF',
|
|
30
|
+
'G': 'KeyG',
|
|
31
|
+
'H': 'KeyH',
|
|
32
|
+
'I': 'KeyI',
|
|
33
|
+
'J': 'KeyJ',
|
|
34
|
+
'K': 'KeyK',
|
|
35
|
+
'L': 'KeyL',
|
|
36
|
+
'M': 'KeyM',
|
|
37
|
+
'N': 'KeyN',
|
|
38
|
+
'O': 'KeyO',
|
|
39
|
+
'P': 'KeyP',
|
|
40
|
+
'Q': 'KeyQ',
|
|
41
|
+
'R': 'KeyR',
|
|
42
|
+
'S': 'KeyS',
|
|
43
|
+
'T': 'KeyT',
|
|
44
|
+
'U': 'KeyU',
|
|
45
|
+
'V': 'KeyV',
|
|
46
|
+
'W': 'KeyW',
|
|
47
|
+
'X': 'KeyX',
|
|
48
|
+
'Y': 'KeyY',
|
|
49
|
+
'Z': 'KeyZ',
|
|
50
|
+
'BACKSPACE': 'Backspace',
|
|
51
|
+
'ENTER': 'Enter',
|
|
52
|
+
'ESCAPE': 'Escape',
|
|
53
|
+
'LEFT': 'ArrowLeft',
|
|
54
|
+
'UP': 'ArrowUp',
|
|
55
|
+
'RIGHT': 'ArrowRight',
|
|
56
|
+
'DOWN': 'ArrowDown',
|
|
57
|
+
'INSERT': 'Insert',
|
|
58
|
+
'DELETE': 'Delete',
|
|
59
|
+
'.': 'Period',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
type ModifierKey = keyof typeof SUPPORTED_COMMANDS;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Finds the modifier key that matches the given alias
|
|
66
|
+
* @param alias - The alias to check (e.g., 'CMD', 'CTRL', 'OPTION')
|
|
67
|
+
* @returns The modifier key if found, undefined otherwise
|
|
68
|
+
*/
|
|
69
|
+
const findModifierKey = (alias: string): ModifierKey | undefined => {
|
|
70
|
+
const modifierKeys = Object.keys(SUPPORTED_COMMANDS) as ModifierKey[];
|
|
71
|
+
|
|
72
|
+
return modifierKeys.find((command) =>
|
|
73
|
+
SUPPORTED_COMMANDS[command].includes(alias as never)
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Options for creating a keyboard shortcut
|
|
79
|
+
*/
|
|
80
|
+
export interface ShortcutOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Shortcut name (e.g., 'CMD+K', 'CMD+B')
|
|
83
|
+
*/
|
|
84
|
+
name: string;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Element to attach the shortcut to
|
|
88
|
+
*/
|
|
89
|
+
on: HTMLElement | Document;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Callback function to execute when shortcut is triggered
|
|
93
|
+
*/
|
|
94
|
+
callback: (event: KeyboardEvent) => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Shortcut class for handling keyboard shortcuts
|
|
99
|
+
*
|
|
100
|
+
* Listens for keydown events on the specified element and executes
|
|
101
|
+
* the callback when the configured key combination is pressed.
|
|
102
|
+
*/
|
|
103
|
+
export class Shortcut {
|
|
104
|
+
/**
|
|
105
|
+
* Shortcut name
|
|
106
|
+
*/
|
|
107
|
+
public name: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Parsed modifier commands state
|
|
111
|
+
*/
|
|
112
|
+
private commands: Record<ModifierKey, boolean>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Parsed key codes to match
|
|
116
|
+
*/
|
|
117
|
+
private keys: Record<string, boolean>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Element the shortcut is attached to
|
|
121
|
+
*/
|
|
122
|
+
private element: HTMLElement | Document;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Callback to execute when shortcut is triggered
|
|
126
|
+
*/
|
|
127
|
+
private callback: (event: KeyboardEvent) => void;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Bound event handler for removal
|
|
131
|
+
*/
|
|
132
|
+
private executeShortcut: EventListener;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Creates a new Shortcut instance
|
|
136
|
+
* @param options - Configuration options
|
|
137
|
+
*/
|
|
138
|
+
constructor(options: ShortcutOptions) {
|
|
139
|
+
this.commands = {
|
|
140
|
+
SHIFT: false,
|
|
141
|
+
CMD: false,
|
|
142
|
+
ALT: false,
|
|
143
|
+
};
|
|
144
|
+
this.keys = {};
|
|
145
|
+
this.name = options.name;
|
|
146
|
+
this.element = options.on;
|
|
147
|
+
this.callback = options.callback;
|
|
148
|
+
|
|
149
|
+
this.parseShortcutName(options.name);
|
|
150
|
+
|
|
151
|
+
this.executeShortcut = (event: Event): void => {
|
|
152
|
+
this.execute(event as KeyboardEvent);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
this.element.addEventListener('keydown', this.executeShortcut, false);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Removes the shortcut event listener
|
|
160
|
+
*/
|
|
161
|
+
public remove(): void {
|
|
162
|
+
this.element.removeEventListener('keydown', this.executeShortcut);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Parses the shortcut name and extracts modifier keys and regular keys
|
|
167
|
+
* @param name - Shortcut name like 'CMD+K' or 'SHIFT+CMD+B'
|
|
168
|
+
*/
|
|
169
|
+
private parseShortcutName(name: string): void {
|
|
170
|
+
const parts = name.split('+');
|
|
171
|
+
|
|
172
|
+
for (const part of parts) {
|
|
173
|
+
const upperPart = part.toUpperCase();
|
|
174
|
+
const modifierKey = findModifierKey(upperPart);
|
|
175
|
+
|
|
176
|
+
if (modifierKey !== undefined) {
|
|
177
|
+
this.commands[modifierKey] = true;
|
|
178
|
+
} else {
|
|
179
|
+
this.keys[upperPart] = true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Checks if all modifier commands match the event
|
|
186
|
+
* @param event - Keyboard event to check
|
|
187
|
+
* @returns True if all modifiers match
|
|
188
|
+
*/
|
|
189
|
+
private checkModifiers(event: KeyboardEvent): boolean {
|
|
190
|
+
const eventModifiers: Record<ModifierKey, boolean> = {
|
|
191
|
+
CMD: event.ctrlKey || event.metaKey,
|
|
192
|
+
SHIFT: event.shiftKey,
|
|
193
|
+
ALT: event.altKey,
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const modifierKeys = Object.keys(this.commands) as ModifierKey[];
|
|
197
|
+
|
|
198
|
+
return modifierKeys.every(
|
|
199
|
+
(command) => this.commands[command] === eventModifiers[command]
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Checks if all required keys match the event
|
|
205
|
+
* @param event - Keyboard event to check
|
|
206
|
+
* @returns True if all keys match
|
|
207
|
+
*/
|
|
208
|
+
private checkKeys(event: KeyboardEvent): boolean {
|
|
209
|
+
const requiredKeys = Object.keys(this.keys);
|
|
210
|
+
|
|
211
|
+
return requiredKeys.every((key) => {
|
|
212
|
+
const expectedCode = KEY_CODES[key];
|
|
213
|
+
|
|
214
|
+
return event.code === expectedCode;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Executes the callback if the keyboard event matches the shortcut
|
|
220
|
+
* @param event - Keyboard event to check
|
|
221
|
+
*/
|
|
222
|
+
private execute(event: KeyboardEvent): void {
|
|
223
|
+
const commandsMatch = this.checkModifiers(event);
|
|
224
|
+
const keysMatch = this.checkKeys(event);
|
|
225
|
+
|
|
226
|
+
if (commandsMatch && keysMatch) {
|
|
227
|
+
this.callback(event);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Shortcut } from './shortcut';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Contains keyboard and mouse events binded on each Block by Block Manager
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ShortcutData interface
|
|
9
|
+
* Each shortcut must have name and handler
|
|
10
|
+
* `name` is a shortcut, like 'CMD+K', 'CMD+B' etc
|
|
11
|
+
* `handler` is a callback
|
|
12
|
+
* @interface ShortcutData
|
|
13
|
+
*/
|
|
14
|
+
export interface ShortcutData {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Shortcut name
|
|
18
|
+
* Ex. CMD+I, CMD+B ....
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Shortcut handler
|
|
24
|
+
*/
|
|
25
|
+
handler(event: KeyboardEvent): void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Element handler should be added for
|
|
29
|
+
*/
|
|
30
|
+
on: HTMLElement | Document;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @class Shortcut
|
|
35
|
+
* @classdesc Allows to register new shortcut
|
|
36
|
+
*
|
|
37
|
+
* Internal Shortcuts Module
|
|
38
|
+
*/
|
|
39
|
+
class ShortcutsClass {
|
|
40
|
+
/**
|
|
41
|
+
* All registered shortcuts
|
|
42
|
+
* @type {Map<HTMLElement | Document, Shortcut[]>}
|
|
43
|
+
*/
|
|
44
|
+
private registeredShortcuts: Map<HTMLElement | Document, Shortcut[]> = new Map();
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Register shortcut
|
|
48
|
+
* @param shortcut - shortcut options
|
|
49
|
+
*/
|
|
50
|
+
public add(shortcut: ShortcutData): void {
|
|
51
|
+
const foundShortcut = this.findShortcut(shortcut.on, shortcut.name);
|
|
52
|
+
|
|
53
|
+
if (foundShortcut) {
|
|
54
|
+
throw Error(
|
|
55
|
+
`Shortcut ${shortcut.name} is already registered for ${shortcut.on}. Please remove it before add a new handler.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const newShortcut = new Shortcut({
|
|
60
|
+
name: shortcut.name,
|
|
61
|
+
on: shortcut.on,
|
|
62
|
+
callback: shortcut.handler,
|
|
63
|
+
});
|
|
64
|
+
const shortcuts = this.registeredShortcuts.get(shortcut.on) || [];
|
|
65
|
+
|
|
66
|
+
this.registeredShortcuts.set(shortcut.on, [...shortcuts, newShortcut]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Remove shortcut
|
|
71
|
+
* @param element - Element shortcut is set for
|
|
72
|
+
* @param name - shortcut name
|
|
73
|
+
*/
|
|
74
|
+
public remove(element: HTMLElement | Document, name: string): void {
|
|
75
|
+
const shortcut = this.findShortcut(element, name);
|
|
76
|
+
|
|
77
|
+
if (!shortcut) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
shortcut.remove();
|
|
82
|
+
|
|
83
|
+
const shortcuts = this.registeredShortcuts.get(element);
|
|
84
|
+
|
|
85
|
+
if (!shortcuts) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const filteredShortcuts = shortcuts.filter(el => el !== shortcut);
|
|
90
|
+
|
|
91
|
+
if (filteredShortcuts.length === 0) {
|
|
92
|
+
this.registeredShortcuts.delete(element);
|
|
93
|
+
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.registeredShortcuts.set(element, filteredShortcuts);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get Shortcut instance if exist
|
|
102
|
+
* @param element - Element shorcut is set for
|
|
103
|
+
* @param shortcut - shortcut name
|
|
104
|
+
* @returns {number} index - shortcut index if exist
|
|
105
|
+
*/
|
|
106
|
+
private findShortcut(element: HTMLElement | Document, shortcut: string): Shortcut | void {
|
|
107
|
+
const shortcuts = this.registeredShortcuts.get(element) || [];
|
|
108
|
+
|
|
109
|
+
return shortcuts.find(({ name }) => name === shortcut);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const Shortcuts = new ShortcutsClass();
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { BlockToolAdapter } from '../tools/block';
|
|
2
|
+
import type { ToolboxConfigEntry } from '@/types';
|
|
3
|
+
import { isFunction, isString } from '../utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Interface for i18n instance needed by tool utilities
|
|
7
|
+
*/
|
|
8
|
+
export interface I18nInstance {
|
|
9
|
+
t(key: string, vars?: Record<string, string | number>): string;
|
|
10
|
+
has(key: string): boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if tool has valid conversion config for export or import.
|
|
15
|
+
* @param tool - tool to check
|
|
16
|
+
* @param direction - export for tool to merge from, import for tool to merge to
|
|
17
|
+
*/
|
|
18
|
+
export const isToolConvertable = (tool: BlockToolAdapter, direction: 'export' | 'import'): boolean => {
|
|
19
|
+
if (!tool.conversionConfig) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const conversionProp = tool.conversionConfig[direction];
|
|
24
|
+
|
|
25
|
+
return isFunction(conversionProp) || isString(conversionProp);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Try to translate a key in the toolNames namespace.
|
|
30
|
+
*
|
|
31
|
+
* @param i18n - I18n instance
|
|
32
|
+
* @param key - The key to look up (without the toolNames prefix)
|
|
33
|
+
* @returns The translated string or undefined if not found
|
|
34
|
+
*/
|
|
35
|
+
const tryTranslate = (i18n: I18nInstance, key: string): string | undefined => {
|
|
36
|
+
const fullKey = `toolNames.${key}`;
|
|
37
|
+
|
|
38
|
+
return i18n.has(fullKey) ? i18n.t(fullKey) : undefined;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Translate a toolbox entry title using the i18n system.
|
|
43
|
+
*
|
|
44
|
+
* Priority:
|
|
45
|
+
* 1. If titleKey is set, look up toolNames.{titleKey}
|
|
46
|
+
* 2. If title is set, look up toolNames.{title} (for external tools without titleKey)
|
|
47
|
+
* 3. If fallback is set, look up toolNames.{fallback} (for tools without title)
|
|
48
|
+
* 4. Return the first available string: title or fallback
|
|
49
|
+
*
|
|
50
|
+
* @param i18n - I18n instance
|
|
51
|
+
* @param entry - Toolbox config entry with title and optional titleKey
|
|
52
|
+
* @param fallback - Fallback string if no translation or title exists
|
|
53
|
+
* @returns Translated title string
|
|
54
|
+
*/
|
|
55
|
+
export const translateToolTitle = (i18n: I18nInstance, entry: ToolboxConfigEntry, fallback = ''): string => {
|
|
56
|
+
// Try titleKey first (explicit translation key)
|
|
57
|
+
const titleKeyTranslation = entry.titleKey ? tryTranslate(i18n, entry.titleKey) : undefined;
|
|
58
|
+
|
|
59
|
+
if (titleKeyTranslation !== undefined) {
|
|
60
|
+
return titleKeyTranslation;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Try title as translation key (for external tools without titleKey)
|
|
64
|
+
const titleTranslation = entry.title ? tryTranslate(i18n, entry.title) : undefined;
|
|
65
|
+
|
|
66
|
+
if (titleTranslation !== undefined) {
|
|
67
|
+
return titleTranslation;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (entry.title) {
|
|
71
|
+
return entry.title;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Try fallback as translation key (for tools without title)
|
|
75
|
+
const fallbackTranslation = fallback ? tryTranslate(i18n, fallback) : undefined;
|
|
76
|
+
|
|
77
|
+
return fallbackTranslation ?? fallback;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Translate a tool name using the toolNames namespace.
|
|
82
|
+
*
|
|
83
|
+
* Priority:
|
|
84
|
+
* 1. If titleKey is set, look up toolNames.{titleKey}
|
|
85
|
+
* 2. If title is set, look up toolNames.{title} (for external tools without titleKey)
|
|
86
|
+
* 3. Return the title as-is
|
|
87
|
+
*
|
|
88
|
+
* @param i18n - I18n instance
|
|
89
|
+
* @param titleKey - Translation key (e.g., 'bold', 'link', 'text')
|
|
90
|
+
* @param title - Fallback title string (e.g., 'Bold', 'Link', 'Text')
|
|
91
|
+
* @returns Translated tool name, or the title as fallback
|
|
92
|
+
*/
|
|
93
|
+
export const translateToolName = (i18n: I18nInstance, titleKey: string | undefined, title: string): string => {
|
|
94
|
+
// Try explicit titleKey first
|
|
95
|
+
const titleKeyTranslation = titleKey ? tryTranslate(i18n, titleKey) : undefined;
|
|
96
|
+
|
|
97
|
+
if (titleKeyTranslation !== undefined) {
|
|
98
|
+
return titleKeyTranslation;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Try title as translation key (for external tools without titleKey)
|
|
102
|
+
const titleTranslation = tryTranslate(i18n, title);
|
|
103
|
+
|
|
104
|
+
return titleTranslation ?? title;
|
|
105
|
+
};
|