@jackuait/blok 0.4.1 → 0.4.3-beta.1
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 +45 -7
- package/codemod/migrate-editorjs-to-blok.js +951 -92
- package/codemod/test.js +780 -77
- package/dist/blok.mjs +5 -2
- package/dist/chunks/blok-8ptWuVZC.mjs +12838 -0
- package/dist/chunks/i18next-CugVlwWp.mjs +1292 -0
- package/dist/chunks/i18next-loader-bLawSYRV.mjs +43 -0
- package/dist/{index-CBkApZKo.mjs → chunks/index-5nYtWZD2.mjs} +2 -2
- package/dist/chunks/inline-tool-convert-CvMDAIzb.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 +60 -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,259 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/html-vite';
|
|
2
|
+
import { userEvent, waitFor, expect } from 'storybook/test';
|
|
3
|
+
import type { OutputData, ToolSettings } from '@/types';
|
|
4
|
+
import { createEditorContainer } from './helpers';
|
|
5
|
+
import type { EditorFactoryOptions } from './helpers';
|
|
6
|
+
import { Paragraph, List } from '../tools';
|
|
7
|
+
import type { ListConfig } from '../../types/tools/list';
|
|
8
|
+
|
|
9
|
+
// Constants
|
|
10
|
+
const TIMEOUT_INIT = { timeout: 5000 };
|
|
11
|
+
const TIMEOUT_ACTION = { timeout: 5000 };
|
|
12
|
+
|
|
13
|
+
interface ListCustomStylesArgs extends EditorFactoryOptions {
|
|
14
|
+
minHeight: number;
|
|
15
|
+
data: OutputData | undefined;
|
|
16
|
+
readOnly: boolean;
|
|
17
|
+
itemColor: string;
|
|
18
|
+
itemSize: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Sample data with all three list types (ListItem model - each item is a separate block)
|
|
23
|
+
*/
|
|
24
|
+
const allListTypesData: OutputData = {
|
|
25
|
+
time: Date.now(),
|
|
26
|
+
version: '1.0.0',
|
|
27
|
+
blocks: [
|
|
28
|
+
// Unordered list items
|
|
29
|
+
{ id: 'unordered-1', type: 'list', data: { text: 'Unordered item one', style: 'unordered' } },
|
|
30
|
+
{ id: 'unordered-2', type: 'list', data: { text: 'Unordered item two', style: 'unordered' } },
|
|
31
|
+
{ id: 'unordered-3', type: 'list', data: { text: 'Unordered item three', style: 'unordered' } },
|
|
32
|
+
// Ordered list items
|
|
33
|
+
{ id: 'ordered-1', type: 'list', data: { text: 'Ordered item one', style: 'ordered' } },
|
|
34
|
+
{ id: 'ordered-2', type: 'list', data: { text: 'Ordered item two', style: 'ordered' } },
|
|
35
|
+
{ id: 'ordered-3', type: 'list', data: { text: 'Ordered item three', style: 'ordered' } },
|
|
36
|
+
// Checklist items
|
|
37
|
+
{ id: 'checklist-1', type: 'list', data: { text: 'Checklist item one', style: 'checklist', checked: false } },
|
|
38
|
+
{ id: 'checklist-2', type: 'list', data: { text: 'Checklist item two (completed)', style: 'checklist', checked: true } },
|
|
39
|
+
{ id: 'checklist-3', type: 'list', data: { text: 'Checklist item three', style: 'checklist', checked: false } },
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Sample data with nested list items (using depth property)
|
|
45
|
+
*/
|
|
46
|
+
const allListTypesWithNestedData: OutputData = {
|
|
47
|
+
time: Date.now(),
|
|
48
|
+
version: '1.0.0',
|
|
49
|
+
blocks: [
|
|
50
|
+
// Unordered nested list
|
|
51
|
+
{ id: 'u-1', type: 'list', data: { text: 'Fruits', style: 'unordered', depth: 0 } },
|
|
52
|
+
{ id: 'u-2', type: 'list', data: { text: 'Citrus', style: 'unordered', depth: 1 } },
|
|
53
|
+
{ id: 'u-3', type: 'list', data: { text: 'Orange', style: 'unordered', depth: 2 } },
|
|
54
|
+
{ id: 'u-4', type: 'list', data: { text: 'Lemon', style: 'unordered', depth: 2 } },
|
|
55
|
+
{ id: 'u-5', type: 'list', data: { text: 'Berries', style: 'unordered', depth: 1 } },
|
|
56
|
+
{ id: 'u-6', type: 'list', data: { text: 'Strawberry', style: 'unordered', depth: 2 } },
|
|
57
|
+
{ id: 'u-7', type: 'list', data: { text: 'Blueberry', style: 'unordered', depth: 2 } },
|
|
58
|
+
{ id: 'u-8', type: 'list', data: { text: 'Vegetables', style: 'unordered', depth: 0 } },
|
|
59
|
+
{ id: 'u-9', type: 'list', data: { text: 'Carrot', style: 'unordered', depth: 1 } },
|
|
60
|
+
// Ordered nested list
|
|
61
|
+
{ id: 'o-1', type: 'list', data: { text: 'Getting Started', style: 'ordered', depth: 0 } },
|
|
62
|
+
{ id: 'o-2', type: 'list', data: { text: 'Install dependencies', style: 'ordered', depth: 1 } },
|
|
63
|
+
{ id: 'o-3', type: 'list', data: { text: 'Configure environment', style: 'ordered', depth: 1 } },
|
|
64
|
+
{ id: 'o-4', type: 'list', data: { text: 'Set up database', style: 'ordered', depth: 1 } },
|
|
65
|
+
{ id: 'o-5', type: 'list', data: { text: 'Create schema', style: 'ordered', depth: 2 } },
|
|
66
|
+
{ id: 'o-6', type: 'list', data: { text: 'Run migrations', style: 'ordered', depth: 2 } },
|
|
67
|
+
{ id: 'o-7', type: 'list', data: { text: 'Development', style: 'ordered', depth: 0 } },
|
|
68
|
+
{ id: 'o-8', type: 'list', data: { text: 'Write code', style: 'ordered', depth: 1 } },
|
|
69
|
+
{ id: 'o-9', type: 'list', data: { text: 'Write tests', style: 'ordered', depth: 1 } },
|
|
70
|
+
// Checklist nested list
|
|
71
|
+
{ id: 'c-1', type: 'list', data: { text: 'Project Setup', style: 'checklist', checked: true, depth: 0 } },
|
|
72
|
+
{ id: 'c-2', type: 'list', data: { text: 'Create repository', style: 'checklist', checked: true, depth: 1 } },
|
|
73
|
+
{ id: 'c-3', type: 'list', data: { text: 'Initialize project', style: 'checklist', checked: true, depth: 1 } },
|
|
74
|
+
{ id: 'c-4', type: 'list', data: { text: 'Configure tooling', style: 'checklist', checked: false, depth: 1 } },
|
|
75
|
+
{ id: 'c-5', type: 'list', data: { text: 'ESLint', style: 'checklist', checked: true, depth: 2 } },
|
|
76
|
+
{ id: 'c-6', type: 'list', data: { text: 'Prettier', style: 'checklist', checked: true, depth: 2 } },
|
|
77
|
+
{ id: 'c-7', type: 'list', data: { text: 'TypeScript', style: 'checklist', checked: false, depth: 2 } },
|
|
78
|
+
{ id: 'c-8', type: 'list', data: { text: 'Feature Development', style: 'checklist', checked: false, depth: 0 } },
|
|
79
|
+
{ id: 'c-9', type: 'list', data: { text: 'Design UI mockups', style: 'checklist', checked: true, depth: 1 } },
|
|
80
|
+
{ id: 'c-10', type: 'list', data: { text: 'Implement components', style: 'checklist', checked: false, depth: 1 } },
|
|
81
|
+
],
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const createEditor = (args: ListCustomStylesArgs): HTMLElement => {
|
|
85
|
+
const hasCustomStyles = args.itemColor || args.itemSize;
|
|
86
|
+
|
|
87
|
+
const listTool = hasCustomStyles
|
|
88
|
+
? ({
|
|
89
|
+
class: List,
|
|
90
|
+
inlineToolbar: true,
|
|
91
|
+
config: {
|
|
92
|
+
itemColor: args.itemColor,
|
|
93
|
+
itemSize: args.itemSize,
|
|
94
|
+
} as ListConfig,
|
|
95
|
+
} as ToolSettings)
|
|
96
|
+
: ({
|
|
97
|
+
class: List,
|
|
98
|
+
inlineToolbar: true,
|
|
99
|
+
} as ToolSettings);
|
|
100
|
+
|
|
101
|
+
return createEditorContainer({
|
|
102
|
+
...args,
|
|
103
|
+
tools: {
|
|
104
|
+
paragraph: Paragraph,
|
|
105
|
+
list: listTool,
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const meta: Meta<ListCustomStylesArgs> = {
|
|
111
|
+
title: 'Tools/List',
|
|
112
|
+
tags: ['autodocs'],
|
|
113
|
+
args: {
|
|
114
|
+
minHeight: 400,
|
|
115
|
+
data: allListTypesData,
|
|
116
|
+
readOnly: false,
|
|
117
|
+
itemColor: '',
|
|
118
|
+
itemSize: '',
|
|
119
|
+
},
|
|
120
|
+
argTypes: {
|
|
121
|
+
itemColor: {
|
|
122
|
+
control: 'color',
|
|
123
|
+
description: 'Custom color for list items (any valid CSS color)',
|
|
124
|
+
},
|
|
125
|
+
itemSize: {
|
|
126
|
+
control: 'text',
|
|
127
|
+
description: 'Custom font size for list items (any valid CSS font-size)',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
render: createEditor,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default meta;
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
type Story = StoryObj<ListCustomStylesArgs>;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Large red list items.
|
|
140
|
+
*/
|
|
141
|
+
export const LargeRedItems: Story = {
|
|
142
|
+
args: {
|
|
143
|
+
data: allListTypesData,
|
|
144
|
+
itemColor: '#dc2626',
|
|
145
|
+
itemSize: '24px',
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Interactive checklist - click checkboxes to toggle completion state.
|
|
151
|
+
*/
|
|
152
|
+
export const InteractiveChecklist: Story = {
|
|
153
|
+
args: {
|
|
154
|
+
data: {
|
|
155
|
+
time: Date.now(),
|
|
156
|
+
version: '1.0.0',
|
|
157
|
+
blocks: [
|
|
158
|
+
{ id: 'ic-1', type: 'list', data: { text: 'Click me to mark as done', style: 'checklist', checked: false } },
|
|
159
|
+
{ id: 'ic-2', type: 'list', data: { text: 'Already completed task', style: 'checklist', checked: true } },
|
|
160
|
+
{ id: 'ic-3', type: 'list', data: { text: 'Another task to check off', style: 'checklist', checked: false } },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
readOnly: false,
|
|
164
|
+
},
|
|
165
|
+
play: async ({ canvasElement, step }) => {
|
|
166
|
+
await step('Wait for editor to initialize', async () => {
|
|
167
|
+
await waitFor(
|
|
168
|
+
() => {
|
|
169
|
+
const checkbox = canvasElement.querySelector('input[type="checkbox"]');
|
|
170
|
+
|
|
171
|
+
expect(checkbox).toBeInTheDocument();
|
|
172
|
+
},
|
|
173
|
+
TIMEOUT_INIT
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
await step('Toggle first checkbox', async () => {
|
|
178
|
+
const checkboxes = canvasElement.querySelectorAll('input[type="checkbox"]');
|
|
179
|
+
const firstCheckbox = checkboxes[0] as HTMLInputElement;
|
|
180
|
+
|
|
181
|
+
if (firstCheckbox) {
|
|
182
|
+
await userEvent.click(firstCheckbox);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
await waitFor(
|
|
186
|
+
() => {
|
|
187
|
+
expect(firstCheckbox.checked).toBe(true);
|
|
188
|
+
},
|
|
189
|
+
TIMEOUT_ACTION
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Read-only mode - lists are displayed but not editable.
|
|
197
|
+
*/
|
|
198
|
+
export const ReadOnlyLists: Story = {
|
|
199
|
+
args: {
|
|
200
|
+
data: allListTypesData,
|
|
201
|
+
readOnly: true,
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* All three list types (unordered, ordered, checklist) with nested items using depth.
|
|
207
|
+
* Demonstrates hierarchical data structures with multiple nesting levels.
|
|
208
|
+
*/
|
|
209
|
+
export const AllListTypesWithNestedItems: Story = {
|
|
210
|
+
args: {
|
|
211
|
+
data: allListTypesWithNestedData,
|
|
212
|
+
minHeight: 600,
|
|
213
|
+
readOnly: false,
|
|
214
|
+
},
|
|
215
|
+
play: async ({ canvasElement, step }) => {
|
|
216
|
+
await step('Wait for editor to initialize with list blocks', async () => {
|
|
217
|
+
await waitFor(
|
|
218
|
+
() => {
|
|
219
|
+
const listBlocks = canvasElement.querySelectorAll('[data-blok-component="list"]');
|
|
220
|
+
|
|
221
|
+
expect(listBlocks.length).toBeGreaterThan(0);
|
|
222
|
+
},
|
|
223
|
+
TIMEOUT_INIT
|
|
224
|
+
);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
await step('Verify checklist items have checkboxes', async () => {
|
|
228
|
+
// Check for checkboxes in checklist items
|
|
229
|
+
const checkboxes = canvasElement.querySelectorAll('input[type="checkbox"]');
|
|
230
|
+
|
|
231
|
+
expect(checkboxes.length).toBeGreaterThan(0);
|
|
232
|
+
|
|
233
|
+
// Verify some checkboxes are checked (based on our test data)
|
|
234
|
+
const checkedBoxes = canvasElement.querySelectorAll('input[type="checkbox"]:checked');
|
|
235
|
+
|
|
236
|
+
expect(checkedBoxes.length).toBeGreaterThan(0);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
await step('Toggle a checklist item', async () => {
|
|
240
|
+
const checkboxes = canvasElement.querySelectorAll('input[type="checkbox"]');
|
|
241
|
+
|
|
242
|
+
// Find an unchecked checkbox to toggle
|
|
243
|
+
const uncheckedCheckbox = Array.from(checkboxes).find(
|
|
244
|
+
(cb) => !(cb as HTMLInputElement).checked
|
|
245
|
+
) as HTMLInputElement | undefined;
|
|
246
|
+
|
|
247
|
+
if (uncheckedCheckbox) {
|
|
248
|
+
await userEvent.click(uncheckedCheckbox);
|
|
249
|
+
|
|
250
|
+
await waitFor(
|
|
251
|
+
() => {
|
|
252
|
+
expect(uncheckedCheckbox.checked).toBe(true);
|
|
253
|
+
},
|
|
254
|
+
TIMEOUT_ACTION
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
};
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notifier.stories.ts - Stories for notification component states.
|
|
3
|
+
*
|
|
4
|
+
* This file covers notification types and styles:
|
|
5
|
+
* - Alert (default, success, error)
|
|
6
|
+
* - Confirm (with ok/cancel buttons)
|
|
7
|
+
* - Prompt (with input field)
|
|
8
|
+
*/
|
|
9
|
+
import type { Meta, StoryObj } from '@storybook/html-vite';
|
|
10
|
+
import { waitFor, expect } from 'storybook/test';
|
|
11
|
+
|
|
12
|
+
interface NotifierArgs {
|
|
13
|
+
message: string;
|
|
14
|
+
style?: 'success' | 'error';
|
|
15
|
+
type?: 'alert' | 'confirm' | 'prompt';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const TIMEOUT_ACTION = { timeout: 5000 };
|
|
19
|
+
|
|
20
|
+
// Helper functions to find notification elements using data-blok-testid selectors
|
|
21
|
+
const getNotifyWrapper = (): Element | null => document.querySelector('[data-blok-testid="notifier-container"]');
|
|
22
|
+
const getNotify = (): Element | null => document.querySelector('[data-blok-testid="notification"]');
|
|
23
|
+
const getNotifyByStyle = (style: string): Element | null => document.querySelector(`[data-blok-testid="notification-${style}"]`);
|
|
24
|
+
const getNotifyButton = (type: 'confirm' | 'cancel'): Element | null => document.querySelector(`[data-blok-testid="notification-${type}-button"]`);
|
|
25
|
+
const getNotifyInput = (): Element | null => document.querySelector('[data-blok-testid="notification-input"]');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Clean up any existing notifications before each test
|
|
29
|
+
*/
|
|
30
|
+
const cleanupNotifications = (): void => {
|
|
31
|
+
const wrapper = document.querySelector('[data-blok-testid="notifier-container"]');
|
|
32
|
+
|
|
33
|
+
if (wrapper) {
|
|
34
|
+
wrapper.innerHTML = '';
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Dynamically imports and shows notification
|
|
40
|
+
*/
|
|
41
|
+
const showNotification = async (options: {
|
|
42
|
+
message: string;
|
|
43
|
+
type?: string;
|
|
44
|
+
style?: string;
|
|
45
|
+
time?: number;
|
|
46
|
+
okText?: string;
|
|
47
|
+
cancelText?: string;
|
|
48
|
+
okHandler?: (event: Event | string) => void;
|
|
49
|
+
cancelHandler?: (event: Event) => void;
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
default?: string;
|
|
52
|
+
}): Promise<void> => {
|
|
53
|
+
const notifierModule = await import('../components/utils/notifier/index');
|
|
54
|
+
|
|
55
|
+
notifierModule.show(options);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const createNotifierDemo = (): HTMLElement => {
|
|
59
|
+
const container = document.createElement('div');
|
|
60
|
+
|
|
61
|
+
container.style.minHeight = '200px';
|
|
62
|
+
container.style.backgroundColor = '#f5f5f5';
|
|
63
|
+
container.style.padding = '20px';
|
|
64
|
+
container.style.position = 'relative';
|
|
65
|
+
|
|
66
|
+
const info = document.createElement('p');
|
|
67
|
+
|
|
68
|
+
info.textContent = 'Notifications appear in the bottom-left corner of the viewport.';
|
|
69
|
+
info.style.color = '#666';
|
|
70
|
+
info.style.fontSize = '14px';
|
|
71
|
+
container.appendChild(info);
|
|
72
|
+
|
|
73
|
+
return container;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const meta: Meta<NotifierArgs> = {
|
|
77
|
+
title: 'Components/Notifier',
|
|
78
|
+
tags: ['autodocs'],
|
|
79
|
+
args: {
|
|
80
|
+
message: 'This is a notification message',
|
|
81
|
+
style: undefined,
|
|
82
|
+
type: 'alert',
|
|
83
|
+
},
|
|
84
|
+
argTypes: {
|
|
85
|
+
message: {
|
|
86
|
+
control: 'text',
|
|
87
|
+
description: 'Notification message (can contain HTML)',
|
|
88
|
+
},
|
|
89
|
+
style: {
|
|
90
|
+
control: 'select',
|
|
91
|
+
options: [undefined, 'success', 'error'],
|
|
92
|
+
description: 'Notification style variant',
|
|
93
|
+
},
|
|
94
|
+
type: {
|
|
95
|
+
control: 'select',
|
|
96
|
+
options: ['alert', 'confirm', 'prompt'],
|
|
97
|
+
description: 'Notification type',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
render: createNotifierDemo,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default meta;
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
type Story = StoryObj<NotifierArgs>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Default alert notification.
|
|
110
|
+
*/
|
|
111
|
+
export const AlertDefault: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
message: 'This is a default notification',
|
|
114
|
+
type: 'alert',
|
|
115
|
+
},
|
|
116
|
+
play: async ({ step }) => {
|
|
117
|
+
await step('Show default alert notification', async () => {
|
|
118
|
+
await showNotification({
|
|
119
|
+
message: 'This is a default notification',
|
|
120
|
+
time: 30000, // Keep visible for story
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
await waitFor(
|
|
124
|
+
() => {
|
|
125
|
+
const wrapper = getNotifyWrapper();
|
|
126
|
+
|
|
127
|
+
expect(wrapper).toBeTruthy();
|
|
128
|
+
|
|
129
|
+
const notify = getNotify();
|
|
130
|
+
|
|
131
|
+
expect(notify).toBeTruthy();
|
|
132
|
+
},
|
|
133
|
+
TIMEOUT_ACTION
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Success style alert notification (green accent).
|
|
141
|
+
*/
|
|
142
|
+
export const AlertSuccess: Story = {
|
|
143
|
+
args: {
|
|
144
|
+
message: 'Operation completed successfully!',
|
|
145
|
+
type: 'alert',
|
|
146
|
+
style: 'success',
|
|
147
|
+
},
|
|
148
|
+
play: async ({ step }) => {
|
|
149
|
+
await step('Show success alert notification', async () => {
|
|
150
|
+
await showNotification({
|
|
151
|
+
message: 'Operation completed successfully!',
|
|
152
|
+
style: 'success',
|
|
153
|
+
time: 30000,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
await waitFor(
|
|
157
|
+
() => {
|
|
158
|
+
const notify = getNotifyByStyle('success');
|
|
159
|
+
|
|
160
|
+
expect(notify).toBeTruthy();
|
|
161
|
+
},
|
|
162
|
+
TIMEOUT_ACTION
|
|
163
|
+
);
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Error style alert notification (red accent).
|
|
170
|
+
*/
|
|
171
|
+
export const AlertError: Story = {
|
|
172
|
+
args: {
|
|
173
|
+
message: 'Something went wrong!',
|
|
174
|
+
type: 'alert',
|
|
175
|
+
style: 'error',
|
|
176
|
+
},
|
|
177
|
+
play: async ({ step }) => {
|
|
178
|
+
await step('Show error alert notification', async () => {
|
|
179
|
+
await showNotification({
|
|
180
|
+
message: 'Something went wrong!',
|
|
181
|
+
style: 'error',
|
|
182
|
+
time: 30000,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
await waitFor(
|
|
186
|
+
() => {
|
|
187
|
+
const notify = getNotifyByStyle('error');
|
|
188
|
+
|
|
189
|
+
expect(notify).toBeTruthy();
|
|
190
|
+
},
|
|
191
|
+
TIMEOUT_ACTION
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Confirm notification with OK and Cancel buttons.
|
|
199
|
+
*/
|
|
200
|
+
export const ConfirmNotification: Story = {
|
|
201
|
+
args: {
|
|
202
|
+
message: 'Are you sure you want to proceed?',
|
|
203
|
+
type: 'confirm',
|
|
204
|
+
},
|
|
205
|
+
play: async ({ step }) => {
|
|
206
|
+
await step('Show confirm notification', async () => {
|
|
207
|
+
await showNotification({
|
|
208
|
+
message: 'Are you sure you want to proceed?',
|
|
209
|
+
type: 'confirm',
|
|
210
|
+
okText: 'Yes, proceed',
|
|
211
|
+
cancelText: 'Cancel',
|
|
212
|
+
okHandler: () => {
|
|
213
|
+
// Handler for story demo
|
|
214
|
+
},
|
|
215
|
+
cancelHandler: () => {
|
|
216
|
+
// Handler for story demo
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
await waitFor(
|
|
221
|
+
() => {
|
|
222
|
+
const notify = getNotify();
|
|
223
|
+
|
|
224
|
+
expect(notify).toBeTruthy();
|
|
225
|
+
|
|
226
|
+
// Check for confirm/cancel buttons
|
|
227
|
+
const confirmBtn = getNotifyButton('confirm');
|
|
228
|
+
const cancelBtn = getNotifyButton('cancel');
|
|
229
|
+
|
|
230
|
+
expect(confirmBtn).toBeTruthy();
|
|
231
|
+
expect(cancelBtn).toBeTruthy();
|
|
232
|
+
},
|
|
233
|
+
TIMEOUT_ACTION
|
|
234
|
+
);
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Prompt notification with input field.
|
|
241
|
+
*/
|
|
242
|
+
export const PromptNotification: Story = {
|
|
243
|
+
args: {
|
|
244
|
+
message: 'Enter your name:',
|
|
245
|
+
type: 'prompt',
|
|
246
|
+
},
|
|
247
|
+
play: async ({ step }) => {
|
|
248
|
+
await step('Show prompt notification', async () => {
|
|
249
|
+
await showNotification({
|
|
250
|
+
message: 'Enter your name:',
|
|
251
|
+
type: 'prompt',
|
|
252
|
+
placeholder: 'Your name',
|
|
253
|
+
default: '',
|
|
254
|
+
okHandler: () => {
|
|
255
|
+
// Handler for story demo
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
await waitFor(
|
|
260
|
+
() => {
|
|
261
|
+
const notify = getNotify();
|
|
262
|
+
|
|
263
|
+
expect(notify).toBeTruthy();
|
|
264
|
+
|
|
265
|
+
// Check for input field
|
|
266
|
+
const input = getNotifyInput();
|
|
267
|
+
|
|
268
|
+
expect(input).toBeTruthy();
|
|
269
|
+
},
|
|
270
|
+
TIMEOUT_ACTION
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Notification with HTML content.
|
|
278
|
+
*/
|
|
279
|
+
export const WithHTMLContent: Story = {
|
|
280
|
+
args: {
|
|
281
|
+
message: 'Block <strong>deleted</strong> successfully',
|
|
282
|
+
type: 'alert',
|
|
283
|
+
style: 'success',
|
|
284
|
+
},
|
|
285
|
+
play: async ({ step }) => {
|
|
286
|
+
await step('Clean up and show notification with HTML', async () => {
|
|
287
|
+
cleanupNotifications();
|
|
288
|
+
|
|
289
|
+
await showNotification({
|
|
290
|
+
message: 'Block <strong>deleted</strong> successfully',
|
|
291
|
+
style: 'success',
|
|
292
|
+
time: 30000,
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
await waitFor(
|
|
296
|
+
() => {
|
|
297
|
+
const notify = getNotifyByStyle('success');
|
|
298
|
+
|
|
299
|
+
expect(notify).toBeTruthy();
|
|
300
|
+
|
|
301
|
+
// Check that notification contains the word 'deleted' (HTML may be sanitized)
|
|
302
|
+
expect(notify?.textContent).toContain('deleted');
|
|
303
|
+
},
|
|
304
|
+
TIMEOUT_ACTION
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Bounce-in animation on notification appear.
|
|
312
|
+
*/
|
|
313
|
+
export const BounceInAnimation: Story = {
|
|
314
|
+
args: {
|
|
315
|
+
message: 'Watch the bounce animation!',
|
|
316
|
+
type: 'alert',
|
|
317
|
+
},
|
|
318
|
+
parameters: {
|
|
319
|
+
chromatic: { disableSnapshot: true },
|
|
320
|
+
},
|
|
321
|
+
play: async ({ step }) => {
|
|
322
|
+
await step('Show notification with bounce animation', async () => {
|
|
323
|
+
await showNotification({
|
|
324
|
+
message: 'Watch the bounce animation!',
|
|
325
|
+
time: 30000,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
await waitFor(
|
|
329
|
+
() => {
|
|
330
|
+
const notify = getNotify();
|
|
331
|
+
|
|
332
|
+
expect(notify).toBeTruthy();
|
|
333
|
+
// Check animation state via data attribute
|
|
334
|
+
expect(notify?.getAttribute('data-blok-bounce-in')).toBe('true');
|
|
335
|
+
},
|
|
336
|
+
TIMEOUT_ACTION
|
|
337
|
+
);
|
|
338
|
+
});
|
|
339
|
+
},
|
|
340
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/html-vite';
|
|
2
|
+
import type { OutputData } from '@/types';
|
|
3
|
+
import { createEditorContainer } from './helpers';
|
|
4
|
+
import type { EditorFactoryOptions } from './helpers';
|
|
5
|
+
import { Paragraph, type ParagraphConfig } from '../tools/paragraph';
|
|
6
|
+
|
|
7
|
+
interface ParagraphArgs extends EditorFactoryOptions {
|
|
8
|
+
minHeight: number;
|
|
9
|
+
data: OutputData | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Creates sample data with a paragraph block
|
|
14
|
+
*/
|
|
15
|
+
const createParagraphData = (id: string, text: string): OutputData => ({
|
|
16
|
+
time: Date.now(),
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
blocks: [
|
|
19
|
+
{
|
|
20
|
+
id,
|
|
21
|
+
type: 'paragraph',
|
|
22
|
+
data: { text },
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates sample data with multiple paragraph blocks
|
|
29
|
+
*/
|
|
30
|
+
const createMultipleParagraphsData = (): OutputData => ({
|
|
31
|
+
time: Date.now(),
|
|
32
|
+
version: '1.0.0',
|
|
33
|
+
blocks: [
|
|
34
|
+
{
|
|
35
|
+
id: 'para-1',
|
|
36
|
+
type: 'paragraph',
|
|
37
|
+
data: { text: 'This is the first paragraph with custom styling.' },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'para-2',
|
|
41
|
+
type: 'paragraph',
|
|
42
|
+
data: { text: 'This is the second paragraph. It demonstrates how multiple paragraphs look together.' },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'para-3',
|
|
46
|
+
type: 'paragraph',
|
|
47
|
+
data: { text: 'And here is a third paragraph to show the spacing between blocks.' },
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const createEditor = (args: ParagraphArgs): HTMLElement => createEditorContainer({
|
|
53
|
+
...args,
|
|
54
|
+
tools: {
|
|
55
|
+
paragraph: Paragraph,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const meta: Meta<ParagraphArgs> = {
|
|
60
|
+
title: 'Components/Paragraph',
|
|
61
|
+
tags: ['autodocs'],
|
|
62
|
+
args: {
|
|
63
|
+
minHeight: 300,
|
|
64
|
+
data: createParagraphData('paragraph-default', 'This is a sample paragraph with default styling.'),
|
|
65
|
+
},
|
|
66
|
+
render: createEditor,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default meta;
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
type Story = StoryObj<ParagraphArgs>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Default paragraph state with no custom styling.
|
|
76
|
+
*/
|
|
77
|
+
export const Default: Story = {
|
|
78
|
+
args: {
|
|
79
|
+
data: createParagraphData('paragraph-default', 'This is a sample paragraph with default styling.'),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Custom paragraph configuration with all style options.
|
|
85
|
+
*/
|
|
86
|
+
const fullCustomConfig: ParagraphConfig = {
|
|
87
|
+
placeholder: 'Start writing here...',
|
|
88
|
+
styles: {
|
|
89
|
+
size: '18px',
|
|
90
|
+
lineHeight: '2',
|
|
91
|
+
marginTop: '16px',
|
|
92
|
+
marginBottom: '16px',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const createFullCustomEditor = (args: ParagraphArgs): HTMLElement => createEditorContainer({
|
|
97
|
+
...args,
|
|
98
|
+
tools: {
|
|
99
|
+
paragraph: {
|
|
100
|
+
class: Paragraph,
|
|
101
|
+
config: fullCustomConfig,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export const CustomStyles: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
minHeight: 400,
|
|
109
|
+
data: createMultipleParagraphsData(),
|
|
110
|
+
},
|
|
111
|
+
render: createFullCustomEditor,
|
|
112
|
+
};
|