@blokkli/editor 1.0.0
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/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +129 -0
- package/dist/module.d.ts +129 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +5430 -0
- package/dist/runtime/adapter/drupal/graphql/base.graphql +906 -0
- package/dist/runtime/adapter/drupal/graphql/comments.graphql +56 -0
- package/dist/runtime/adapter/drupal/graphql/fragments.graphql +25 -0
- package/dist/runtime/adapter/drupal/graphql/library.graphql +66 -0
- package/dist/runtime/adapter/drupal/graphql/search.graphql +19 -0
- package/dist/runtime/adapter/drupal/graphql/transform.graphql +27 -0
- package/dist/runtime/adapter/drupal/graphqlMiddleware.d.ts +2 -0
- package/dist/runtime/adapter/drupal/graphqlMiddleware.js +643 -0
- package/dist/runtime/adapter/index.d.ts +352 -0
- package/dist/runtime/adapter/index.js +3 -0
- package/dist/runtime/blokkliPlugins/AddAction/index.vue +87 -0
- package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +95 -0
- package/dist/runtime/blokkliPlugins/ContextMenu/index.vue +49 -0
- package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue +34 -0
- package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +73 -0
- package/dist/runtime/blokkliPlugins/ItemAction/index.vue +132 -0
- package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue +42 -0
- package/dist/runtime/blokkliPlugins/MenuButton/index.vue +74 -0
- package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +334 -0
- package/dist/runtime/blokkliPlugins/Sidebar/index.vue +286 -0
- package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +104 -0
- package/dist/runtime/blokkliPlugins/TourItem/index.vue +45 -0
- package/dist/runtime/blokkliPlugins/ViewOption/index.vue +106 -0
- package/dist/runtime/blokkliPlugins/index.d.ts +12 -0
- package/dist/runtime/blokkliPlugins/index.js +24 -0
- package/dist/runtime/components/Blocks/Fragment/icon.svg +1 -0
- package/dist/runtime/components/Blocks/Fragment/index.vue +24 -0
- package/dist/runtime/components/Blocks/FromLibrary/index.vue +58 -0
- package/dist/runtime/components/BlokkliEditable.vue +73 -0
- package/dist/runtime/components/BlokkliField.vue +157 -0
- package/dist/runtime/components/BlokkliItem.vue +79 -0
- package/dist/runtime/components/BlokkliProvider.vue +160 -0
- package/dist/runtime/components/Edit/Actions/index.vue +263 -0
- package/dist/runtime/components/Edit/AddListItem/index.vue +116 -0
- package/dist/runtime/components/Edit/AnimationCanvas/index.vue +122 -0
- package/dist/runtime/components/Edit/AppMenu/index.vue +60 -0
- package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +64 -0
- package/dist/runtime/components/Edit/Dialog/index.vue +163 -0
- package/dist/runtime/components/Edit/DragInteractions/index.vue +439 -0
- package/dist/runtime/components/Edit/DraggableList.vue +110 -0
- package/dist/runtime/components/Edit/EditIndicator.vue +82 -0
- package/dist/runtime/components/Edit/EditProvider.vue +213 -0
- package/dist/runtime/components/Edit/Features/AddList/docs.md +4 -0
- package/dist/runtime/components/Edit/Features/AddList/index.vue +205 -0
- package/dist/runtime/components/Edit/Features/Artboard/Manager/Artboard.d.ts +204 -0
- package/dist/runtime/components/Edit/Features/Artboard/Manager/Artboard.js +748 -0
- package/dist/runtime/components/Edit/Features/Artboard/Manager/Scrollbar/index.vue +176 -0
- package/dist/runtime/components/Edit/Features/Artboard/Manager/index.vue +317 -0
- package/dist/runtime/components/Edit/Features/Artboard/index.vue +45 -0
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/ResultMarkup/index.vue +17 -0
- package/dist/runtime/components/Edit/Features/Assistant/Overlay/index.vue +147 -0
- package/dist/runtime/components/Edit/Features/Assistant/docs.md +7 -0
- package/dist/runtime/components/Edit/Features/Assistant/index.vue +68 -0
- package/dist/runtime/components/Edit/Features/BlockAddList/docs.md +15 -0
- package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +440 -0
- package/dist/runtime/components/Edit/Features/Clipboard/List/Item/File.vue +68 -0
- package/dist/runtime/components/Edit/Features/Clipboard/List/Item/Video.vue +56 -0
- package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue +69 -0
- package/dist/runtime/components/Edit/Features/Clipboard/docs.md +16 -0
- package/dist/runtime/components/Edit/Features/Clipboard/index.vue +485 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +61 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +280 -0
- package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +51 -0
- package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +32 -0
- package/dist/runtime/components/Edit/Features/Comments/Comment/index.vue +53 -0
- package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +100 -0
- package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue +133 -0
- package/dist/runtime/components/Edit/Features/Comments/docs.md +13 -0
- package/dist/runtime/components/Edit/Features/Comments/index.vue +110 -0
- package/dist/runtime/components/Edit/Features/Conversions/index.vue +98 -0
- package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +55 -0
- package/dist/runtime/components/Edit/Features/Debug/Viewport/index.vue +93 -0
- package/dist/runtime/components/Edit/Features/Debug/docs.md +3 -0
- package/dist/runtime/components/Edit/Features/Debug/index.vue +178 -0
- package/dist/runtime/components/Edit/Features/Delete/index.vue +43 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +420 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +58 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +808 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/vertex.glsl +57 -0
- package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +410 -0
- package/dist/runtime/components/Edit/Features/Duplicate/index.vue +109 -0
- package/dist/runtime/components/Edit/Features/Edit/index.vue +63 -0
- package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue +73 -0
- package/dist/runtime/components/Edit/Features/EditForm/index.vue +217 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Contenteditable/index.vue +42 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +68 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +81 -0
- package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +357 -0
- package/dist/runtime/components/Edit/Features/EditableField/index.vue +192 -0
- package/dist/runtime/components/Edit/Features/EditableMask/index.vue +64 -0
- package/dist/runtime/components/Edit/Features/EntityTitle/index.vue +108 -0
- package/dist/runtime/components/Edit/Features/Exit/index.vue +38 -0
- package/dist/runtime/components/Edit/Features/FieldAreas/Overlay/index.vue +33 -0
- package/dist/runtime/components/Edit/Features/FieldAreas/index.vue +43 -0
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +68 -0
- package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +137 -0
- package/dist/runtime/components/Edit/Features/Fragments/docs.md +101 -0
- package/dist/runtime/components/Edit/Features/Fragments/index.vue +86 -0
- package/dist/runtime/components/Edit/Features/Grid/index.vue +40 -0
- package/dist/runtime/components/Edit/Features/Help/Shortcuts/index.vue +71 -0
- package/dist/runtime/components/Edit/Features/Help/index.vue +53 -0
- package/dist/runtime/components/Edit/Features/History/index.vue +263 -0
- package/dist/runtime/components/Edit/Features/ImportExisting/Dialog/index.vue +140 -0
- package/dist/runtime/components/Edit/Features/ImportExisting/index.vue +92 -0
- package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +0 -0
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +73 -0
- package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +184 -0
- package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +88 -0
- package/dist/runtime/components/Edit/Features/Library/docs.md +127 -0
- package/dist/runtime/components/Edit/Features/Library/index.vue +184 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +184 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +182 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/types.d.ts +57 -0
- package/dist/runtime/components/Edit/Features/MediaLibrary/types.js +0 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/fragment.glsl +90 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +289 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/vertex.glsl +182 -0
- package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +76 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Checkbox/index.vue +52 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Checkboxes/index.vue +129 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Color/index.vue +38 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Group.vue +25 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +155 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Number/index.vue +74 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Radios/index.vue +135 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Range/index.vue +47 -0
- package/dist/runtime/components/Edit/Features/Options/Form/Text/index.vue +38 -0
- package/dist/runtime/components/Edit/Features/Options/Form/index.vue +342 -0
- package/dist/runtime/components/Edit/Features/Options/index.vue +88 -0
- package/dist/runtime/components/Edit/Features/Ownership/index.vue +57 -0
- package/dist/runtime/components/Edit/Features/Preview/index.vue +45 -0
- package/dist/runtime/components/Edit/Features/PreviewGrant/QrCode/index.vue +30 -0
- package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue +73 -0
- package/dist/runtime/components/Edit/Features/Publish/index.vue +50 -0
- package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue +81 -0
- package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +217 -0
- package/dist/runtime/components/Edit/Features/Revert/index.vue +68 -0
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +165 -0
- package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +211 -0
- package/dist/runtime/components/Edit/Features/Search/Overlay/index.vue +214 -0
- package/dist/runtime/components/Edit/Features/Search/index.vue +79 -0
- package/dist/runtime/components/Edit/Features/Selection/Overlay/fragment.glsl +99 -0
- package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +144 -0
- package/dist/runtime/components/Edit/Features/Selection/Overlay/vertex.glsl +85 -0
- package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +50 -0
- package/dist/runtime/components/Edit/Features/Selection/index.vue +295 -0
- package/dist/runtime/components/Edit/Features/Settings/Dialog/FeatureSetting/index.vue +141 -0
- package/dist/runtime/components/Edit/Features/Settings/Dialog/index.vue +138 -0
- package/dist/runtime/components/Edit/Features/Settings/index.vue +92 -0
- package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +181 -0
- package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue +149 -0
- package/dist/runtime/components/Edit/Features/Structure/List/index.vue +55 -0
- package/dist/runtime/components/Edit/Features/Structure/index.vue +83 -0
- package/dist/runtime/components/Edit/Features/Theme/Color/index.vue +81 -0
- package/dist/runtime/components/Edit/Features/Theme/GeneratedCode/index.vue +24 -0
- package/dist/runtime/components/Edit/Features/Theme/index.vue +122 -0
- package/dist/runtime/components/Edit/Features/TouchActionBar/Bar/index.vue +26 -0
- package/dist/runtime/components/Edit/Features/TouchActionBar/index.vue +42 -0
- package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +270 -0
- package/dist/runtime/components/Edit/Features/Tour/Popup/index.vue +36 -0
- package/dist/runtime/components/Edit/Features/Tour/docs.md +0 -0
- package/dist/runtime/components/Edit/Features/Tour/index.vue +46 -0
- package/dist/runtime/components/Edit/Features/Transform/docs.md +67 -0
- package/dist/runtime/components/Edit/Features/Transform/index.vue +177 -0
- package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +50 -0
- package/dist/runtime/components/Edit/Features/Translations/index.vue +193 -0
- package/dist/runtime/components/Edit/Features/Validations/Overlay/Item.vue +50 -0
- package/dist/runtime/components/Edit/Features/Validations/Overlay/index.vue +51 -0
- package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue +50 -0
- package/dist/runtime/components/Edit/Features/Validations/index.vue +70 -0
- package/dist/runtime/components/Edit/Features/index.vue +67 -0
- package/dist/runtime/components/Edit/FormOverlay/Header/index.vue +39 -0
- package/dist/runtime/components/Edit/FormOverlay/index.vue +52 -0
- package/dist/runtime/components/Edit/Highlight/index.vue +94 -0
- package/dist/runtime/components/Edit/Icon/index.vue +21 -0
- package/dist/runtime/components/Edit/ItemIcon/index.vue +27 -0
- package/dist/runtime/components/Edit/Loading/index.vue +19 -0
- package/dist/runtime/components/Edit/Messages/Item/index.vue +107 -0
- package/dist/runtime/components/Edit/Messages/index.vue +37 -0
- package/dist/runtime/components/Edit/PreviewProvider.vue +223 -0
- package/dist/runtime/components/Edit/RelativeTime/index.vue +37 -0
- package/dist/runtime/components/Edit/Resizable/index.vue +90 -0
- package/dist/runtime/components/Edit/ScaleToFit/index.vue +57 -0
- package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +90 -0
- package/dist/runtime/components/Edit/Sortli/index.vue +92 -0
- package/dist/runtime/components/Edit/SystemRequirements/index.vue +91 -0
- package/dist/runtime/components/Edit/Toolbar/index.vue +106 -0
- package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue +75 -0
- package/dist/runtime/components/Edit/index.d.ts +14 -0
- package/dist/runtime/components/Edit/index.js +28 -0
- package/dist/runtime/composables/defineBlokkli.d.ts +6 -0
- package/dist/runtime/composables/defineBlokkli.js +108 -0
- package/dist/runtime/composables/defineBlokkliFeature.d.ts +28 -0
- package/dist/runtime/composables/defineBlokkliFeature.js +62 -0
- package/dist/runtime/composables/defineBlokkliFragment.d.ts +3 -0
- package/dist/runtime/composables/defineBlokkliFragment.js +54 -0
- package/dist/runtime/composables/useBlokkli.d.ts +8 -0
- package/dist/runtime/composables/useBlokkli.js +5 -0
- package/dist/runtime/constants/index.d.ts +4 -0
- package/dist/runtime/constants/index.js +2 -0
- package/dist/runtime/css/output.css +1 -0
- package/dist/runtime/helpers/Artboard/index.d.ts +16 -0
- package/dist/runtime/helpers/Artboard/index.js +20 -0
- package/dist/runtime/helpers/DragStyle/index.d.ts +12 -0
- package/dist/runtime/helpers/DragStyle/index.js +86 -0
- package/dist/runtime/helpers/animationProvider.d.ts +25 -0
- package/dist/runtime/helpers/animationProvider.js +116 -0
- package/dist/runtime/helpers/broadcastProvider.d.ts +7 -0
- package/dist/runtime/helpers/broadcastProvider.js +26 -0
- package/dist/runtime/helpers/commandsProvider.d.ts +9 -0
- package/dist/runtime/helpers/commandsProvider.js +16 -0
- package/dist/runtime/helpers/composables/defineCommands.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineCommands.js +10 -0
- package/dist/runtime/helpers/composables/defineDropAreas.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineDropAreas.js +10 -0
- package/dist/runtime/helpers/composables/defineShortcut.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineShortcut.js +19 -0
- package/dist/runtime/helpers/composables/defineTourItem.d.ts +2 -0
- package/dist/runtime/helpers/composables/defineTourItem.js +10 -0
- package/dist/runtime/helpers/composables/onBlokkliEvent.d.ts +2 -0
- package/dist/runtime/helpers/composables/onBlokkliEvent.js +10 -0
- package/dist/runtime/helpers/composables/useAnimationFrame.d.ts +1 -0
- package/dist/runtime/helpers/composables/useAnimationFrame.js +14 -0
- package/dist/runtime/helpers/composables/useDebugLogger.d.ts +2 -0
- package/dist/runtime/helpers/composables/useDebugLogger.js +5 -0
- package/dist/runtime/helpers/composables/useDelayedIntersectionObserver.d.ts +5 -0
- package/dist/runtime/helpers/composables/useDelayedIntersectionObserver.js +26 -0
- package/dist/runtime/helpers/debugProvider.d.ts +23 -0
- package/dist/runtime/helpers/debugProvider.js +65 -0
- package/dist/runtime/helpers/dom/index.d.ts +5 -0
- package/dist/runtime/helpers/dom/index.js +37 -0
- package/dist/runtime/helpers/domProvider.d.ts +46 -0
- package/dist/runtime/helpers/domProvider.js +446 -0
- package/dist/runtime/helpers/dropAreaProvider.d.ts +9 -0
- package/dist/runtime/helpers/dropAreaProvider.js +22 -0
- package/dist/runtime/helpers/easing.d.ts +3 -0
- package/dist/runtime/helpers/easing.js +16 -0
- package/dist/runtime/helpers/eventBus.d.ts +3 -0
- package/dist/runtime/helpers/eventBus.js +5 -0
- package/dist/runtime/helpers/featuresProvider.d.ts +23 -0
- package/dist/runtime/helpers/featuresProvider.js +16 -0
- package/dist/runtime/helpers/frameEventBus.d.ts +9 -0
- package/dist/runtime/helpers/frameEventBus.js +2 -0
- package/dist/runtime/helpers/index.d.ts +87 -0
- package/dist/runtime/helpers/index.js +467 -0
- package/dist/runtime/helpers/keyboardProvider.d.ts +17 -0
- package/dist/runtime/helpers/keyboardProvider.js +79 -0
- package/dist/runtime/helpers/options.d.ts +2 -0
- package/dist/runtime/helpers/options.js +21 -0
- package/dist/runtime/helpers/runtimeHelpers/index.d.ts +10 -0
- package/dist/runtime/helpers/runtimeHelpers/index.js +35 -0
- package/dist/runtime/helpers/selectionProvider.d.ts +62 -0
- package/dist/runtime/helpers/selectionProvider.js +149 -0
- package/dist/runtime/helpers/stateProvider.d.ts +35 -0
- package/dist/runtime/helpers/stateProvider.js +226 -0
- package/dist/runtime/helpers/storageProvider.d.ts +15 -0
- package/dist/runtime/helpers/storageProvider.js +61 -0
- package/dist/runtime/helpers/symbols.d.ts +16 -0
- package/dist/runtime/helpers/symbols.js +18 -0
- package/dist/runtime/helpers/textProvider.d.ts +4 -0
- package/dist/runtime/helpers/textProvider.js +20 -0
- package/dist/runtime/helpers/themeProvider.d.ts +27 -0
- package/dist/runtime/helpers/themeProvider.js +124 -0
- package/dist/runtime/helpers/tourProvider.d.ts +11 -0
- package/dist/runtime/helpers/tourProvider.js +19 -0
- package/dist/runtime/helpers/transform.d.ts +2 -0
- package/dist/runtime/helpers/transform.js +17 -0
- package/dist/runtime/helpers/typesProvider.d.ts +36 -0
- package/dist/runtime/helpers/typesProvider.js +138 -0
- package/dist/runtime/helpers/uiProvider.d.ts +36 -0
- package/dist/runtime/helpers/uiProvider.js +278 -0
- package/dist/runtime/helpers/webgl/index.d.ts +32 -0
- package/dist/runtime/helpers/webgl/index.js +132 -0
- package/dist/runtime/icons/alert.svg +6 -0
- package/dist/runtime/icons/area.svg +5 -0
- package/dist/runtime/icons/arrow-down.svg +1 -0
- package/dist/runtime/icons/arrow-left.svg +1 -0
- package/dist/runtime/icons/arrow-right.svg +1 -0
- package/dist/runtime/icons/arrow-up.svg +1 -0
- package/dist/runtime/icons/artboard-disabled.svg +9 -0
- package/dist/runtime/icons/artboard-enabled.svg +29 -0
- package/dist/runtime/icons/artboard.svg +1 -0
- package/dist/runtime/icons/bug.svg +1 -0
- package/dist/runtime/icons/button-pointer.svg +1 -0
- package/dist/runtime/icons/caret.svg +12 -0
- package/dist/runtime/icons/cellphone.svg +1 -0
- package/dist/runtime/icons/chat-question.svg +1 -0
- package/dist/runtime/icons/check.svg +1 -0
- package/dist/runtime/icons/checkbox.svg +5 -0
- package/dist/runtime/icons/checks.svg +1 -0
- package/dist/runtime/icons/chevron-left.svg +1 -0
- package/dist/runtime/icons/chevron-right.svg +1 -0
- package/dist/runtime/icons/clipboard.svg +5 -0
- package/dist/runtime/icons/close.svg +5 -0
- package/dist/runtime/icons/cog.svg +5 -0
- package/dist/runtime/icons/command.svg +1 -0
- package/dist/runtime/icons/comment.svg +5 -0
- package/dist/runtime/icons/comment_add.svg +5 -0
- package/dist/runtime/icons/convert.svg +1 -0
- package/dist/runtime/icons/cursor-move.svg +1 -0
- package/dist/runtime/icons/dead.svg +1 -0
- package/dist/runtime/icons/delete.svg +8 -0
- package/dist/runtime/icons/detach.svg +7 -0
- package/dist/runtime/icons/drag.svg +1 -0
- package/dist/runtime/icons/duplicate.svg +12 -0
- package/dist/runtime/icons/edit.svg +8 -0
- package/dist/runtime/icons/exit.svg +6 -0
- package/dist/runtime/icons/expand.svg +1 -0
- package/dist/runtime/icons/file.svg +1 -0
- package/dist/runtime/icons/form.svg +1 -0
- package/dist/runtime/icons/fragment.svg +1 -0
- package/dist/runtime/icons/grid.svg +13 -0
- package/dist/runtime/icons/group.svg +5 -0
- package/dist/runtime/icons/help.svg +1 -0
- package/dist/runtime/icons/history.svg +1 -0
- package/dist/runtime/icons/image.svg +1 -0
- package/dist/runtime/icons/import.svg +5 -0
- package/dist/runtime/icons/laptop.svg +1 -0
- package/dist/runtime/icons/list-view-grid.svg +1 -0
- package/dist/runtime/icons/list-view-horizontal.svg +1 -0
- package/dist/runtime/icons/loader.svg +1 -0
- package/dist/runtime/icons/logo.svg +5 -0
- package/dist/runtime/icons/magnifier.svg +5 -0
- package/dist/runtime/icons/menu.svg +1 -0
- package/dist/runtime/icons/minus.svg +1 -0
- package/dist/runtime/icons/monitor.svg +1 -0
- package/dist/runtime/icons/multi-select.svg +1 -0
- package/dist/runtime/icons/multimedia.svg +1 -0
- package/dist/runtime/icons/opacity.svg +5 -0
- package/dist/runtime/icons/open_in_new.svg +3 -0
- package/dist/runtime/icons/palette.svg +1 -0
- package/dist/runtime/icons/plus-box.svg +1 -0
- package/dist/runtime/icons/plus.svg +1 -0
- package/dist/runtime/icons/preview.svg +5 -0
- package/dist/runtime/icons/publish.svg +12 -0
- package/dist/runtime/icons/puzzle.svg +1 -0
- package/dist/runtime/icons/qrcode.svg +5 -0
- package/dist/runtime/icons/question.svg +5 -0
- package/dist/runtime/icons/redo.svg +12 -0
- package/dist/runtime/icons/resize.svg +1 -0
- package/dist/runtime/icons/reusable.svg +5 -0
- package/dist/runtime/icons/revert.svg +5 -0
- package/dist/runtime/icons/robot.svg +1 -0
- package/dist/runtime/icons/rotate-phone.svg +1 -0
- package/dist/runtime/icons/sad.svg +1 -0
- package/dist/runtime/icons/save.svg +1 -0
- package/dist/runtime/icons/script.svg +1 -0
- package/dist/runtime/icons/scrolltotop.svg +6 -0
- package/dist/runtime/icons/search.svg +1 -0
- package/dist/runtime/icons/selection.svg +5 -0
- package/dist/runtime/icons/spinner.svg +15 -0
- package/dist/runtime/icons/star.svg +1 -0
- package/dist/runtime/icons/swap-horizontal.svg +1 -0
- package/dist/runtime/icons/tablet.svg +1 -0
- package/dist/runtime/icons/textbox.svg +1 -0
- package/dist/runtime/icons/texturebox.svg +5 -0
- package/dist/runtime/icons/tiktok.svg +1 -0
- package/dist/runtime/icons/title.svg +1 -0
- package/dist/runtime/icons/tools.svg +1 -0
- package/dist/runtime/icons/translate.svg +5 -0
- package/dist/runtime/icons/tree.svg +5 -0
- package/dist/runtime/icons/tutor.svg +1 -0
- package/dist/runtime/icons/ui-list-horizontal.svg +19 -0
- package/dist/runtime/icons/ui-list-sidebar.svg +21 -0
- package/dist/runtime/icons/ui-list-vertical.svg +9 -0
- package/dist/runtime/icons/undo.svg +12 -0
- package/dist/runtime/icons/unstar.svg +1 -0
- package/dist/runtime/icons/upload.svg +1 -0
- package/dist/runtime/icons/user.svg +1 -0
- package/dist/runtime/icons/video-outline.svg +1 -0
- package/dist/runtime/icons/vimeo.svg +3 -0
- package/dist/runtime/icons/window-maximize.svg +1 -0
- package/dist/runtime/icons/window-minimize.svg +1 -0
- package/dist/runtime/icons/youtube.svg +3 -0
- package/dist/runtime/plugins/blokkliEditable.d.ts +2 -0
- package/dist/runtime/plugins/blokkliEditable.js +31 -0
- package/dist/runtime/public/Inter.var.woff2 +0 -0
- package/dist/runtime/types/blokkOptions.d.ts +83 -0
- package/dist/runtime/types/blokkOptions.js +0 -0
- package/dist/runtime/types/generatedModuleTypes.d.ts +41 -0
- package/dist/runtime/types/generatedModuleTypes.js +0 -0
- package/dist/runtime/types/index.d.ts +1052 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/theme.d.ts +33 -0
- package/dist/runtime/types/theme.js +0 -0
- package/dist/types.d.mts +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +103 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<FormOverlay
|
|
3
|
+
id="library"
|
|
4
|
+
:title="$t('libraryPlaceDialogTitle', 'Add block from library')"
|
|
5
|
+
icon="reusable"
|
|
6
|
+
@close="onClose"
|
|
7
|
+
>
|
|
8
|
+
<div class="bk-library-dialog">
|
|
9
|
+
<p class="bk-lead">
|
|
10
|
+
{{
|
|
11
|
+
$t(
|
|
12
|
+
'libraryPlaceDialogLead',
|
|
13
|
+
'Select a reusable block from the library to add it to your layout. You can detach the block later.',
|
|
14
|
+
)
|
|
15
|
+
}}
|
|
16
|
+
</p>
|
|
17
|
+
<div class="bk">
|
|
18
|
+
<div class="bk-form-group">
|
|
19
|
+
<div>
|
|
20
|
+
<label class="bk-form-label" for="library_search">
|
|
21
|
+
{{ $t('libraryPlaceSearchLabel', 'Filter library items') }}
|
|
22
|
+
</label>
|
|
23
|
+
<input
|
|
24
|
+
id="library_search"
|
|
25
|
+
v-model.lazy="searchText"
|
|
26
|
+
type="text"
|
|
27
|
+
class="bk-form-input"
|
|
28
|
+
:placeholder="
|
|
29
|
+
$t('libraryPlaceSearchInputPlaceholder', 'Search library items')
|
|
30
|
+
"
|
|
31
|
+
required
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
<div>
|
|
35
|
+
<label class="bk-form-label" for="library_bundle">
|
|
36
|
+
{{ $t('libraryPlaceBundleSelectLabel', 'Bundle') }}
|
|
37
|
+
</label>
|
|
38
|
+
<select
|
|
39
|
+
id="library_bundle"
|
|
40
|
+
v-model="selectedBundle"
|
|
41
|
+
class="bk-form-input"
|
|
42
|
+
>
|
|
43
|
+
<option
|
|
44
|
+
v-for="v in bundleOptions"
|
|
45
|
+
:key="v.bundle"
|
|
46
|
+
:value="v.bundle"
|
|
47
|
+
>
|
|
48
|
+
{{ v.label }}
|
|
49
|
+
</option>
|
|
50
|
+
</select>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="bk-library-dialog-content">
|
|
55
|
+
<Loading v-if="status === 'pending'" />
|
|
56
|
+
<ul ref="listEl" class="bk-library-dialog-list">
|
|
57
|
+
<li
|
|
58
|
+
v-for="item in items"
|
|
59
|
+
:key="item.uuid"
|
|
60
|
+
:class="{
|
|
61
|
+
'bk-is-selected': selectedItem === item.uuid,
|
|
62
|
+
}"
|
|
63
|
+
@click="selectedItem = item.uuid"
|
|
64
|
+
>
|
|
65
|
+
<LibraryListItem v-bind="item" />
|
|
66
|
+
</li>
|
|
67
|
+
</ul>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<div class="bk">
|
|
71
|
+
<div class="bk-pagination">
|
|
72
|
+
<button :disabled="page === 0" @click="page--">
|
|
73
|
+
<Icon name="arrow-left" />
|
|
74
|
+
</button>
|
|
75
|
+
<div>{{ page + 1 }} / {{ totalPages }}</div>
|
|
76
|
+
<button :disabled="page >= totalPages - 1" @click="page++">
|
|
77
|
+
<Icon name="arrow-right" />
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
<template #footer>
|
|
82
|
+
<button class="bk-button bk-is-primary" @click="onSubmit">
|
|
83
|
+
{{ $t('libraryPlaceDialogSubmit', 'Add reusable block') }}
|
|
84
|
+
</button>
|
|
85
|
+
</template>
|
|
86
|
+
</FormOverlay>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<script setup lang="ts">
|
|
90
|
+
import type {
|
|
91
|
+
BlokkliAdapterGetLibraryItemsData,
|
|
92
|
+
BlokkliAdapterGetLibraryItemsResult,
|
|
93
|
+
} from '#blokkli/adapter'
|
|
94
|
+
import { FormOverlay, Icon } from '#blokkli/components'
|
|
95
|
+
import Loading from './../../../Loading/index.vue'
|
|
96
|
+
import type { BlokkliFieldElement } from '#blokkli/types'
|
|
97
|
+
import { ref, useBlokkli, useAsyncData, computed, watch } from '#imports'
|
|
98
|
+
import LibraryListItem from './Item/index.vue'
|
|
99
|
+
|
|
100
|
+
const props = defineProps<{
|
|
101
|
+
field: BlokkliFieldElement
|
|
102
|
+
}>()
|
|
103
|
+
|
|
104
|
+
const { $t, adapter, types } = useBlokkli()
|
|
105
|
+
|
|
106
|
+
const emit = defineEmits<{
|
|
107
|
+
(e: 'close'): void
|
|
108
|
+
(e: 'submit', uuid: string): void
|
|
109
|
+
}>()
|
|
110
|
+
|
|
111
|
+
const searchText = ref('')
|
|
112
|
+
const selectedBundle = ref('all')
|
|
113
|
+
const listEl = ref<HTMLDivElement | null>(null)
|
|
114
|
+
const selectedItem = ref('')
|
|
115
|
+
const page = ref(0)
|
|
116
|
+
|
|
117
|
+
const allowedBundles = computed<string[]>(() => {
|
|
118
|
+
return (
|
|
119
|
+
types.getFieldConfig(
|
|
120
|
+
props.field.hostEntityType,
|
|
121
|
+
props.field.hostEntityBundle,
|
|
122
|
+
props.field.name,
|
|
123
|
+
)?.allowedBundles || []
|
|
124
|
+
).filter((v) => {
|
|
125
|
+
return types.getBlockBundleDefinition(v)?.allowReusable
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const onSubmit = () => {
|
|
130
|
+
if (selectedItem.value) {
|
|
131
|
+
emit('submit', selectedItem.value)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const onClose = () => {
|
|
135
|
+
emit('close')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const searchParams = computed<BlokkliAdapterGetLibraryItemsData>(() => {
|
|
139
|
+
return {
|
|
140
|
+
bundles:
|
|
141
|
+
selectedBundle.value !== 'all'
|
|
142
|
+
? [selectedBundle.value]
|
|
143
|
+
: allowedBundles.value,
|
|
144
|
+
page: page.value,
|
|
145
|
+
text: searchText.value,
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
watch(searchText, function () {
|
|
150
|
+
page.value = 0
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
const { data, status } =
|
|
154
|
+
await useAsyncData<BlokkliAdapterGetLibraryItemsResult>(
|
|
155
|
+
() => adapter.getLibraryItems!(searchParams.value),
|
|
156
|
+
{
|
|
157
|
+
watch: [searchParams],
|
|
158
|
+
default: () => {
|
|
159
|
+
return {
|
|
160
|
+
items: [],
|
|
161
|
+
total: 0,
|
|
162
|
+
perPage: 50,
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
const perPage = computed(() => data.value.perPage)
|
|
169
|
+
const totalPages = computed(() => Math.ceil(data.value.total / perPage.value))
|
|
170
|
+
|
|
171
|
+
const items = computed(() => data.value.items)
|
|
172
|
+
|
|
173
|
+
const bundleOptions = computed(() => {
|
|
174
|
+
const bundles = allowedBundles.value.map((bundle) => {
|
|
175
|
+
const definition = types.getBlockBundleDefinition(bundle)
|
|
176
|
+
return {
|
|
177
|
+
bundle,
|
|
178
|
+
label: definition?.label || bundle,
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
return [{ bundle: 'all', label: $t('all', 'All') }, ...bundles]
|
|
183
|
+
})
|
|
184
|
+
</script>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogModal
|
|
3
|
+
:title="$t('libraryDialogTitle', 'Add to library')"
|
|
4
|
+
:lead="
|
|
5
|
+
$t(
|
|
6
|
+
'libraryDialogLead',
|
|
7
|
+
'When you add an item to the library, you can use it on multiple pages at the same time. Changes to this item are then immediately published on all pages.',
|
|
8
|
+
)
|
|
9
|
+
"
|
|
10
|
+
:width="1200"
|
|
11
|
+
icon="reusable"
|
|
12
|
+
:submit-label="$t('libraryDialogSubmit', 'Add to library')"
|
|
13
|
+
:can-submit="!!label.length"
|
|
14
|
+
@submit="$emit('confirm', label)"
|
|
15
|
+
@cancel="$emit('cancel')"
|
|
16
|
+
>
|
|
17
|
+
<div>
|
|
18
|
+
<label for="reusable_label" class="bk-form-label">{{
|
|
19
|
+
$t('libraryDialogDescriptionLabel', 'Description')
|
|
20
|
+
}}</label>
|
|
21
|
+
<input
|
|
22
|
+
id="reusable_label"
|
|
23
|
+
v-model="label"
|
|
24
|
+
type="text"
|
|
25
|
+
class="bk-form-input"
|
|
26
|
+
:placeholder="
|
|
27
|
+
$t('libraryDialogTitleInputPlaceholder', 'e.g. Teaser Campaign 2024')
|
|
28
|
+
"
|
|
29
|
+
required
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="bk-form-label">
|
|
33
|
+
{{ $t('libraryPreviewLabel', 'Preview') }}
|
|
34
|
+
</div>
|
|
35
|
+
<div
|
|
36
|
+
class="bk-dialog-content-element"
|
|
37
|
+
:class="[backgroundClass, { 'bk-default-bg': !backgroundClass }]"
|
|
38
|
+
:style="backgroundClass ? {} : { backgroundColor }"
|
|
39
|
+
>
|
|
40
|
+
<div ref="previewEl" />
|
|
41
|
+
</div>
|
|
42
|
+
</DialogModal>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script lang="ts" setup>
|
|
46
|
+
import { ref, useBlokkli, onMounted } from '#imports'
|
|
47
|
+
|
|
48
|
+
import { DialogModal } from '#blokkli/components'
|
|
49
|
+
import { realBackgroundColor } from '#blokkli/helpers'
|
|
50
|
+
|
|
51
|
+
defineEmits<{
|
|
52
|
+
(e: 'confirm', label: string): void
|
|
53
|
+
(e: 'cancel'): void
|
|
54
|
+
}>()
|
|
55
|
+
|
|
56
|
+
const { dom, $t } = useBlokkli()
|
|
57
|
+
|
|
58
|
+
const props = defineProps<{
|
|
59
|
+
uuid: string
|
|
60
|
+
backgroundClass?: string
|
|
61
|
+
}>()
|
|
62
|
+
|
|
63
|
+
const label = ref('')
|
|
64
|
+
const width = ref(450)
|
|
65
|
+
const previewEl = ref<HTMLDivElement | null>(null)
|
|
66
|
+
const backgroundColor = ref('')
|
|
67
|
+
|
|
68
|
+
onMounted(() => {
|
|
69
|
+
if (previewEl.value) {
|
|
70
|
+
const item = dom.findBlock(props.uuid)
|
|
71
|
+
if (!item) {
|
|
72
|
+
return
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (item.editTitle) {
|
|
76
|
+
label.value = item.editTitle.substring(0, 40)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const element = item.element()
|
|
80
|
+
const markup = dom.getDropElementMarkup(item)
|
|
81
|
+
width.value = element.getBoundingClientRect().width + 40
|
|
82
|
+
const clone = document.createElement('div')
|
|
83
|
+
clone.innerHTML = markup
|
|
84
|
+
previewEl.value.appendChild(clone)
|
|
85
|
+
backgroundColor.value = realBackgroundColor(element)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
</script>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
The library feature provides a way to have reusable blocks that can be added to
|
|
2
|
+
multiple host entities (e.g. pages).
|
|
3
|
+
|
|
4
|
+
## Architecture
|
|
5
|
+
|
|
6
|
+
Since a block always belongs to exactly one host entity, we cannot directly add
|
|
7
|
+
the same block with the same UUID on two pages.
|
|
8
|
+
|
|
9
|
+
In order to still have reusable blocks, we can instead do the following:
|
|
10
|
+
|
|
11
|
+
- Define an entity type named "library_item" that is used as the host entity for
|
|
12
|
+
our reusable blocks
|
|
13
|
+
- Create a block bundle named "from_library" that references a library_item
|
|
14
|
+
entity
|
|
15
|
+
- Add the "from_library" block to the pages we want to display the reusable
|
|
16
|
+
block
|
|
17
|
+
|
|
18
|
+
That way, when we want to add a reusable block to a page, we instead add a block
|
|
19
|
+
of bundle "from_library", where we reference the library item that hosts our
|
|
20
|
+
block.
|
|
21
|
+
|
|
22
|
+
blökkli provides an abstraction layer to make this easier.
|
|
23
|
+
|
|
24
|
+
## `from_library` block
|
|
25
|
+
|
|
26
|
+
When the feature is enabled, blökkli includes a block component that handles the
|
|
27
|
+
rendering of a reusable block.
|
|
28
|
+
|
|
29
|
+
## Data Structure
|
|
30
|
+
|
|
31
|
+
Let's see how our data structure looks like if we have a reusable block on our
|
|
32
|
+
page:
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import type { FieldListItem } from '#blokkli/types'
|
|
36
|
+
|
|
37
|
+
const blocks: FieldListItem[] = [
|
|
38
|
+
// Normal non-reusable block.
|
|
39
|
+
{
|
|
40
|
+
uuid: '96f7fbda-04d9-4662-9a6c-6aa3bcf964f2',
|
|
41
|
+
bundle: 'title',
|
|
42
|
+
props: {
|
|
43
|
+
title: 'Hello world',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
// The "from_library" block.
|
|
47
|
+
{
|
|
48
|
+
uuid: '9485812c-0ecd-4699-85b2-3a031d47a0a1',
|
|
49
|
+
bundle: 'from_library',
|
|
50
|
+
// blökkli expects a single prop named libraryItem.
|
|
51
|
+
props: {
|
|
52
|
+
// The referenced library item entity.
|
|
53
|
+
libraryItem: {
|
|
54
|
+
// The actual reusable block.
|
|
55
|
+
block: {
|
|
56
|
+
uuid: '9485812c-0ecd-4699-85b2-3a031d47a0a1',
|
|
57
|
+
bundle: 'rich_text',
|
|
58
|
+
props: {
|
|
59
|
+
text: '<p>Lorem ipsum dolor sit amet</p>',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Rendering
|
|
69
|
+
|
|
70
|
+
Rendering a reusable block results in the same DOM markup as if the block were
|
|
71
|
+
placed directly, e.g. no wrapping divs.
|
|
72
|
+
|
|
73
|
+
## Option inheritance
|
|
74
|
+
|
|
75
|
+
The `from_library` block inherits the options defined by the reusable block it
|
|
76
|
+
contains. This means the block displays the same options in the editor.
|
|
77
|
+
|
|
78
|
+
When changing options on a reusable block, we store the overrides on the
|
|
79
|
+
`from_library` block. This makes it possible to vary the appearance of reusable
|
|
80
|
+
blocks per page.
|
|
81
|
+
|
|
82
|
+
## Allowing reusable blocks
|
|
83
|
+
|
|
84
|
+
Because we "wrap" the reusable block in another block, we also have to make sure
|
|
85
|
+
to allow the "from_library" bundle in the fields where reusable blocks should be
|
|
86
|
+
placed, in addition to allowing the bundle of the reusable block.
|
|
87
|
+
|
|
88
|
+
This is done in the [getFieldConfig()](/adapter/getFieldConfig) adapter method.
|
|
89
|
+
An example field config that only allows `text` blocks might look like this:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import type { FieldConfig } from '#blokkli/types'
|
|
93
|
+
|
|
94
|
+
const fieldConfig: FieldConfig[] = [
|
|
95
|
+
{
|
|
96
|
+
name: 'field_blocks',
|
|
97
|
+
entityType: 'content',
|
|
98
|
+
entityBundle: 'blog_post',
|
|
99
|
+
label: 'Blocks',
|
|
100
|
+
cardinality: -1,
|
|
101
|
+
canEdit: true,
|
|
102
|
+
allowedBundles: ['text'],
|
|
103
|
+
},
|
|
104
|
+
]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
If we allow the `text` block bundle to be made reusable, we also have to allow
|
|
108
|
+
the `from_library` block bundle in our field config:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import type { FieldConfig } from '#blokkli/types'
|
|
112
|
+
|
|
113
|
+
const fieldConfig: FieldConfig[] = [
|
|
114
|
+
{
|
|
115
|
+
name: 'field_blocks',
|
|
116
|
+
entityType: 'content',
|
|
117
|
+
entityBundle: 'blog_post',
|
|
118
|
+
label: 'Blocks',
|
|
119
|
+
cardinality: -1,
|
|
120
|
+
canEdit: true,
|
|
121
|
+
allowedBundles: ['text', 'from_library'],
|
|
122
|
+
},
|
|
123
|
+
]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Basically: blökkli checks **both** bundles in the field config. This structure
|
|
127
|
+
allows us to also restrict placement of reusable blocks.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PluginItemAction
|
|
3
|
+
v-if="isReusable"
|
|
4
|
+
id="library_detach"
|
|
5
|
+
:title="$t('libraryDetach', 'Detach from library')"
|
|
6
|
+
icon="detach"
|
|
7
|
+
multiple
|
|
8
|
+
:weight="-70"
|
|
9
|
+
@click="onDetach"
|
|
10
|
+
/>
|
|
11
|
+
<PluginItemAction
|
|
12
|
+
v-else-if="!isReusable"
|
|
13
|
+
id="library_make_reusable"
|
|
14
|
+
:title="$t('libraryAdd', 'Add to library')"
|
|
15
|
+
:disabled="!canMakeReusable || state.editMode.value !== 'editing'"
|
|
16
|
+
icon="reusable"
|
|
17
|
+
:weight="-70"
|
|
18
|
+
@click="showReusableDialog = true"
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
<PluginAddAction
|
|
22
|
+
v-if="
|
|
23
|
+
adapter.addLibraryItem && adapter.getLibraryItems && isSupportedOnEntity
|
|
24
|
+
"
|
|
25
|
+
type="library"
|
|
26
|
+
:title="$t('libraryAddFromLibrary', 'Add from library')"
|
|
27
|
+
:description="
|
|
28
|
+
$t(
|
|
29
|
+
'libraryAddDescription',
|
|
30
|
+
'Add a reusable block from the block library.',
|
|
31
|
+
)
|
|
32
|
+
"
|
|
33
|
+
icon="reusable"
|
|
34
|
+
color="lime"
|
|
35
|
+
item-bundle="from_library"
|
|
36
|
+
:disabled="!fromLibraryAllowedInList"
|
|
37
|
+
@placed="placedAction = $event"
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
<Teleport to="body">
|
|
41
|
+
<transition appear name="bk-slide-up" :duration="300">
|
|
42
|
+
<ReusableDialog
|
|
43
|
+
v-if="showReusableDialog && selectedItem"
|
|
44
|
+
:uuid="selectedItem.uuid"
|
|
45
|
+
:background-class="definition?.editor?.previewBackgroundClass"
|
|
46
|
+
@confirm="onMakeReusable"
|
|
47
|
+
@cancel="showReusableDialog = false"
|
|
48
|
+
/>
|
|
49
|
+
</transition>
|
|
50
|
+
</Teleport>
|
|
51
|
+
|
|
52
|
+
<Teleport to="body">
|
|
53
|
+
<transition name="bk-slide-in" :duration="200">
|
|
54
|
+
<LibraryDialog
|
|
55
|
+
v-if="placedAction && adapter.getLibraryItems"
|
|
56
|
+
:field="placedAction.field"
|
|
57
|
+
@close="placedAction = null"
|
|
58
|
+
@submit="onAddLibraryItem"
|
|
59
|
+
/>
|
|
60
|
+
</transition>
|
|
61
|
+
</Teleport>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script lang="ts" setup>
|
|
65
|
+
import { ref, computed, useBlokkli, defineBlokkliFeature } from '#imports'
|
|
66
|
+
import { PluginItemAction, PluginAddAction } from '#blokkli/plugins'
|
|
67
|
+
import ReusableDialog from './ReusableDialog/index.vue'
|
|
68
|
+
import LibraryDialog from './LibraryDialog/index.vue'
|
|
69
|
+
import { getDefinition } from '#blokkli/definitions'
|
|
70
|
+
import type { ActionPlacedEvent } from '#blokkli/types'
|
|
71
|
+
|
|
72
|
+
const { adapter } = defineBlokkliFeature({
|
|
73
|
+
id: 'library',
|
|
74
|
+
icon: 'reusable',
|
|
75
|
+
label: 'Library',
|
|
76
|
+
description:
|
|
77
|
+
'Implements support for a block library to manage reusable blocks.',
|
|
78
|
+
requiredAdapterMethods: ['makeBlockReusable', 'detachReusableBlock'],
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const { selection, state, types, $t, eventBus } = useBlokkli()
|
|
82
|
+
const showReusableDialog = ref(false)
|
|
83
|
+
|
|
84
|
+
const selectedItem = computed(() => {
|
|
85
|
+
if (selection.blocks.value.length !== 1) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return selection.blocks.value[0]
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
const onDetach = async () => {
|
|
93
|
+
if (!adapter.detachReusableBlock || !selection.uuids.value.length) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
await state.mutateWithLoadingState(() =>
|
|
97
|
+
adapter.detachReusableBlock({
|
|
98
|
+
uuids: selection.uuids.value,
|
|
99
|
+
}),
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
eventBus.emit('select:end')
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const placedAction = ref<ActionPlacedEvent | null>(null)
|
|
106
|
+
const onAddLibraryItem = async (uuid: string) => {
|
|
107
|
+
if (!placedAction.value || !adapter.addLibraryItem) {
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
await state.mutateWithLoadingState(() =>
|
|
112
|
+
adapter.addLibraryItem({
|
|
113
|
+
libraryItemUuid: uuid,
|
|
114
|
+
host: placedAction.value!.host,
|
|
115
|
+
afterUuid: placedAction.value!.preceedingUuid,
|
|
116
|
+
}),
|
|
117
|
+
)
|
|
118
|
+
placedAction.value = null
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const definition = computed(() =>
|
|
122
|
+
selectedItem?.value
|
|
123
|
+
? getDefinition(
|
|
124
|
+
selectedItem.value.itemBundle,
|
|
125
|
+
selectedItem.value.hostFieldListType,
|
|
126
|
+
selectedItem.value.parentBlockBundle,
|
|
127
|
+
)
|
|
128
|
+
: null,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
const itemBundle = computed(() =>
|
|
132
|
+
selectedItem?.value
|
|
133
|
+
? types.getBlockBundleDefinition(selectedItem.value.itemBundle)
|
|
134
|
+
: null,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
const isReusable = computed(
|
|
138
|
+
() =>
|
|
139
|
+
selection.blocks.value.length &&
|
|
140
|
+
selection.blocks.value.every((v) => v.itemBundle === 'from_library'),
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
async function onMakeReusable(label: string) {
|
|
144
|
+
showReusableDialog.value = false
|
|
145
|
+
if (!selectedItem?.value?.uuid) {
|
|
146
|
+
return
|
|
147
|
+
}
|
|
148
|
+
await state.mutateWithLoadingState(
|
|
149
|
+
() =>
|
|
150
|
+
adapter.makeBlockReusable({
|
|
151
|
+
label,
|
|
152
|
+
uuid: selectedItem.value!.uuid,
|
|
153
|
+
}),
|
|
154
|
+
$t('libraryError', 'Failed to add block to library.'),
|
|
155
|
+
)
|
|
156
|
+
eventBus.emit('select:end')
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const isSupportedOnEntity = computed(() =>
|
|
160
|
+
types.generallyAvailableBundles.find((v) => v.id === 'from_library'),
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
const fromLibraryAllowedInList = computed(() => {
|
|
164
|
+
if (!selection.uuids.value.length) {
|
|
165
|
+
return !!types.generallyAvailableBundles.find(
|
|
166
|
+
(v) => v.id === 'from_library',
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
return types.allowedTypesInList.value.includes('from_library')
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
const canMakeReusable = computed(
|
|
173
|
+
() =>
|
|
174
|
+
!isReusable.value &&
|
|
175
|
+
itemBundle?.value?.allowReusable &&
|
|
176
|
+
fromLibraryAllowedInList.value,
|
|
177
|
+
)
|
|
178
|
+
</script>
|
|
179
|
+
|
|
180
|
+
<script lang="ts">
|
|
181
|
+
export default {
|
|
182
|
+
name: 'Library',
|
|
183
|
+
}
|
|
184
|
+
</script>
|