@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,467 @@
|
|
|
1
|
+
import { easeOutSine } from "./easing.js";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { getDefinition } from "#blokkli/definitions";
|
|
4
|
+
export function falsy(value) {
|
|
5
|
+
return value !== null && value !== void 0;
|
|
6
|
+
}
|
|
7
|
+
export function buildDraggableItem(element) {
|
|
8
|
+
if (!(element instanceof HTMLElement)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const itemEntityType = useRuntimeConfig().public.blokkli.itemEntityType;
|
|
12
|
+
const dataset = element.dataset;
|
|
13
|
+
if (dataset.elementType === "existing") {
|
|
14
|
+
const uuid = dataset.uuid;
|
|
15
|
+
const itemBundle = dataset.itemBundle;
|
|
16
|
+
const entityType = dataset.entityType;
|
|
17
|
+
const hostType = dataset.hostType;
|
|
18
|
+
const hostUuid = dataset.hostUuid;
|
|
19
|
+
const hostBundle = dataset.hostBundle;
|
|
20
|
+
const hostFieldName = dataset.hostFieldName;
|
|
21
|
+
const reusableBundle = dataset.reusableBundle;
|
|
22
|
+
const hostFieldListType = dataset.hostFieldListType;
|
|
23
|
+
const reusableUuid = dataset.reusableUuid;
|
|
24
|
+
const isNew = dataset.isNew === "true";
|
|
25
|
+
const parentBlockBundle = hostType === itemEntityType ? hostBundle : void 0;
|
|
26
|
+
if (uuid && hostType && hostUuid && hostFieldName && itemBundle && hostBundle && entityType && hostFieldListType) {
|
|
27
|
+
const definition = getDefinition(
|
|
28
|
+
itemBundle,
|
|
29
|
+
hostFieldListType,
|
|
30
|
+
parentBlockBundle
|
|
31
|
+
);
|
|
32
|
+
const libraryLabel = dataset.bkLibraryLabel;
|
|
33
|
+
const editTitle = libraryLabel || (definition?.editor?.editTitle ? definition?.editor.editTitle(element) : void 0);
|
|
34
|
+
return {
|
|
35
|
+
itemType: "existing",
|
|
36
|
+
element: () => document.querySelector(`[data-uuid="${uuid}"]`),
|
|
37
|
+
itemBundle,
|
|
38
|
+
entityType,
|
|
39
|
+
isNested: hostType === itemEntityType,
|
|
40
|
+
uuid,
|
|
41
|
+
hostType,
|
|
42
|
+
hostBundle,
|
|
43
|
+
hostUuid,
|
|
44
|
+
hostFieldName,
|
|
45
|
+
hostFieldListType,
|
|
46
|
+
reusableBundle,
|
|
47
|
+
reusableUuid,
|
|
48
|
+
editTitle: editTitle || void 0,
|
|
49
|
+
isNew,
|
|
50
|
+
parentBlockBundle
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
} else if (dataset.elementType === "new") {
|
|
54
|
+
const itemBundle = dataset.itemBundle;
|
|
55
|
+
if (itemBundle) {
|
|
56
|
+
return {
|
|
57
|
+
itemType: "new",
|
|
58
|
+
element: () => document.querySelector(
|
|
59
|
+
`[data-sortli-id="${itemBundle}"]`
|
|
60
|
+
),
|
|
61
|
+
itemBundle
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
} else if (dataset.elementType === "action") {
|
|
65
|
+
const actionType = dataset.actionType;
|
|
66
|
+
const itemBundle = dataset.itemBundle;
|
|
67
|
+
if (actionType) {
|
|
68
|
+
return {
|
|
69
|
+
itemType: "action",
|
|
70
|
+
actionType,
|
|
71
|
+
itemBundle,
|
|
72
|
+
element: () => document.querySelector(
|
|
73
|
+
`[data-element-type="action"][data-sortli-id="${actionType}"]`
|
|
74
|
+
)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
} else if (dataset.elementType === "clipboard") {
|
|
78
|
+
const additional = dataset.clipboardAdditional;
|
|
79
|
+
const itemBundle = dataset.itemBundle;
|
|
80
|
+
const clipboardId = dataset.clipboardId;
|
|
81
|
+
const id = dataset.sortliId;
|
|
82
|
+
if (itemBundle && clipboardId) {
|
|
83
|
+
return {
|
|
84
|
+
itemType: "clipboard",
|
|
85
|
+
element: () => document.querySelector(`[data-sortli-id="${id}"]`),
|
|
86
|
+
itemBundle,
|
|
87
|
+
additional,
|
|
88
|
+
clipboardId
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
} else if (dataset.elementType === "media_library") {
|
|
92
|
+
const mediaId = dataset.mediaId;
|
|
93
|
+
const itemBundle = dataset.itemBundle;
|
|
94
|
+
const mediaBundle = dataset.mediaBundle;
|
|
95
|
+
if (mediaId && itemBundle && mediaBundle) {
|
|
96
|
+
return {
|
|
97
|
+
itemType: "media_library",
|
|
98
|
+
mediaId,
|
|
99
|
+
itemBundle,
|
|
100
|
+
mediaBundle,
|
|
101
|
+
element: () => document.querySelector(
|
|
102
|
+
`[data-element-type="media_library"][data-media-id="${mediaId}"]`
|
|
103
|
+
)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
} else if (dataset.elementType === "search_content") {
|
|
107
|
+
const searchItemData = dataset.searchItem;
|
|
108
|
+
const id = dataset.sortliId;
|
|
109
|
+
if (searchItemData && id) {
|
|
110
|
+
const searchItem = JSON.parse(searchItemData);
|
|
111
|
+
return {
|
|
112
|
+
itemType: "search_content",
|
|
113
|
+
element: () => document.querySelector(`[data-sortli-id="${id}"]`),
|
|
114
|
+
itemBundle: searchItem.targetBundles[0],
|
|
115
|
+
searchItem
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export function findElement(uuid) {
|
|
121
|
+
const el = document.querySelector(
|
|
122
|
+
`[data-uuid="${uuid}"]:not(.bk-sortli-leave-from)`
|
|
123
|
+
);
|
|
124
|
+
if (el instanceof HTMLElement) {
|
|
125
|
+
return el;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export function onlyUnique(value, index, self) {
|
|
129
|
+
return self.indexOf(value) === index;
|
|
130
|
+
}
|
|
131
|
+
export function getRelativeTimeString(date, lang = navigator.language) {
|
|
132
|
+
const timeMs = typeof date === "number" ? date : date.getTime();
|
|
133
|
+
const deltaSeconds = Math.round((timeMs - Date.now()) / 1e3);
|
|
134
|
+
const cutoffs = [
|
|
135
|
+
60,
|
|
136
|
+
3600,
|
|
137
|
+
86400,
|
|
138
|
+
86400 * 7,
|
|
139
|
+
86400 * 30,
|
|
140
|
+
86400 * 365,
|
|
141
|
+
Infinity
|
|
142
|
+
];
|
|
143
|
+
const units = [
|
|
144
|
+
"second",
|
|
145
|
+
"minute",
|
|
146
|
+
"hour",
|
|
147
|
+
"day",
|
|
148
|
+
"week",
|
|
149
|
+
"month",
|
|
150
|
+
"year"
|
|
151
|
+
];
|
|
152
|
+
const unitIndex = cutoffs.findIndex(
|
|
153
|
+
(cutoff) => cutoff > Math.abs(deltaSeconds)
|
|
154
|
+
);
|
|
155
|
+
const divisor = unitIndex ? cutoffs[unitIndex - 1] : 1;
|
|
156
|
+
const rtf = new Intl.RelativeTimeFormat(lang, { numeric: "auto" });
|
|
157
|
+
return rtf.format(Math.floor(deltaSeconds / divisor), units[unitIndex]);
|
|
158
|
+
}
|
|
159
|
+
export function modulo(n, m) {
|
|
160
|
+
return (n % m + m) % m;
|
|
161
|
+
}
|
|
162
|
+
export function getBounds(rects) {
|
|
163
|
+
if (!rects.length) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const firstRect = rects[0];
|
|
167
|
+
let minX = firstRect.x;
|
|
168
|
+
let minY = firstRect.y;
|
|
169
|
+
let maxX = minX + firstRect.width;
|
|
170
|
+
let maxY = minY + firstRect.height;
|
|
171
|
+
for (const rect of rects.slice(1)) {
|
|
172
|
+
minX = Math.min(minX, rect.x);
|
|
173
|
+
minY = Math.min(minY, rect.y);
|
|
174
|
+
maxX = Math.max(maxX, rect.x + rect.width);
|
|
175
|
+
maxY = Math.max(maxY, rect.y + rect.height);
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
x: minX,
|
|
179
|
+
y: minY,
|
|
180
|
+
width: maxX - minX,
|
|
181
|
+
height: maxY - minY
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
export function intersects(a, b) {
|
|
185
|
+
return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;
|
|
186
|
+
}
|
|
187
|
+
export function isInsideRect(x, y, rect) {
|
|
188
|
+
return x > rect.x && x < rect.x + rect.width && y > rect.y && y < rect.y + rect.height;
|
|
189
|
+
}
|
|
190
|
+
export function calculateIntersection(rectA, rectB) {
|
|
191
|
+
if (!intersects(rectA, rectB)) {
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
const xOverlap = Math.max(
|
|
195
|
+
0,
|
|
196
|
+
Math.min(rectA.x + rectA.width, rectB.x + rectB.width) - Math.max(rectA.x, rectB.x)
|
|
197
|
+
);
|
|
198
|
+
const yOverlap = Math.max(
|
|
199
|
+
0,
|
|
200
|
+
Math.min(rectA.y + rectA.height, rectB.y + rectB.height) - Math.max(rectA.y, rectB.y)
|
|
201
|
+
);
|
|
202
|
+
const intersectionArea = xOverlap * yOverlap;
|
|
203
|
+
const rectAArea = rectA.width * rectA.height;
|
|
204
|
+
return intersectionArea / rectAArea;
|
|
205
|
+
}
|
|
206
|
+
export function findClosestRectangle(x, y, rects) {
|
|
207
|
+
let closestRect = rects[0];
|
|
208
|
+
let minDistance = distanceToClosestRectangleEdge(x, y, rects[0]);
|
|
209
|
+
for (let i = 1; i < rects.length; i++) {
|
|
210
|
+
const rect = rects[i];
|
|
211
|
+
const distance = distanceToClosestRectangleEdge(x, y, rect);
|
|
212
|
+
if (distance < minDistance) {
|
|
213
|
+
closestRect = rect;
|
|
214
|
+
minDistance = distance;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return closestRect;
|
|
218
|
+
}
|
|
219
|
+
export function distanceToRectangle(x, y, rect) {
|
|
220
|
+
const minX = rect.x;
|
|
221
|
+
const minY = rect.y;
|
|
222
|
+
const maxX = rect.x + rect.width;
|
|
223
|
+
const maxY = rect.y + rect.height;
|
|
224
|
+
const dx = Math.max(minX - x, 0, x - maxX);
|
|
225
|
+
const dy = Math.max(minY - y, 0, y - maxY);
|
|
226
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
227
|
+
}
|
|
228
|
+
export function distanceToClosestRectangleEdge(x, y, rect) {
|
|
229
|
+
if (isInsideRect(x, y, rect)) {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
const minX = rect.x;
|
|
233
|
+
const minY = rect.y;
|
|
234
|
+
const maxX = rect.x + rect.width;
|
|
235
|
+
const maxY = rect.y + rect.height;
|
|
236
|
+
const dx = Math.max(minX - x, 0, x - maxX);
|
|
237
|
+
const dy = Math.max(minY - y, 0, y - maxY);
|
|
238
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
239
|
+
}
|
|
240
|
+
export function getDistance(a, b) {
|
|
241
|
+
const dx = a.x - b.x;
|
|
242
|
+
const dy = a.y - b.y;
|
|
243
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
244
|
+
}
|
|
245
|
+
export const parseColorString = (color) => {
|
|
246
|
+
const rgbaRegex = /^rgba?\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})(?:,\s*(0|1|0?\.\d+))?\)$/;
|
|
247
|
+
const match = color.match(rgbaRegex);
|
|
248
|
+
if (!match) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const r = Number.parseInt(match[1]);
|
|
252
|
+
const g = Number.parseInt(match[2]);
|
|
253
|
+
const b = Number.parseInt(match[3]);
|
|
254
|
+
const a = match[4] !== void 0 ? Number.parseFloat(match[4]) : 1;
|
|
255
|
+
if ([r, g, b, a].some((val) => Number.isNaN(val))) {
|
|
256
|
+
throw new Error("Invalid color values");
|
|
257
|
+
}
|
|
258
|
+
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
return [r, g, b];
|
|
262
|
+
};
|
|
263
|
+
export const realBackgroundColor = (el) => {
|
|
264
|
+
const transparent = "rgba(0, 0, 0, 0)";
|
|
265
|
+
if (!el) return transparent;
|
|
266
|
+
const bg = getComputedStyle(el).backgroundColor;
|
|
267
|
+
if (bg === transparent || bg === "transparent") {
|
|
268
|
+
return realBackgroundColor(el.parentElement);
|
|
269
|
+
}
|
|
270
|
+
return bg;
|
|
271
|
+
};
|
|
272
|
+
export const lerp = (s, e, t) => s * (1 - t) + e * t;
|
|
273
|
+
export const calculateCenterPosition = (blockingRects, viewport, widthToPlace) => {
|
|
274
|
+
const viewportCenterX = (viewport.x + viewport.width) / 2;
|
|
275
|
+
const blockingThreshold = viewport.width / 7;
|
|
276
|
+
const x = blockingRects.reduce((acc, rect) => {
|
|
277
|
+
if (rect.x < viewportCenterX && viewportCenterX - rect.x > blockingThreshold && rect.x + rect.width > acc) {
|
|
278
|
+
return rect.x + rect.width;
|
|
279
|
+
}
|
|
280
|
+
return acc;
|
|
281
|
+
}, viewport.x);
|
|
282
|
+
const width = blockingRects.reduce((acc, rect) => {
|
|
283
|
+
if (rect.x > viewportCenterX && rect.x - viewportCenterX > blockingThreshold && rect.x < acc) {
|
|
284
|
+
return rect.x;
|
|
285
|
+
}
|
|
286
|
+
return acc;
|
|
287
|
+
}, viewport.width + viewport.x);
|
|
288
|
+
return (x + width) / 2 - widthToPlace / 2;
|
|
289
|
+
};
|
|
290
|
+
export function getContrastRatio(color1, color2) {
|
|
291
|
+
const luminance1 = getLuminance(color1);
|
|
292
|
+
const luminance2 = getLuminance(color2);
|
|
293
|
+
const lighter = Math.max(luminance1, luminance2);
|
|
294
|
+
const darker = Math.min(luminance1, luminance2);
|
|
295
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
296
|
+
}
|
|
297
|
+
function getLuminance(color) {
|
|
298
|
+
const [r, g, b] = color.map((val) => {
|
|
299
|
+
val /= 255;
|
|
300
|
+
return val <= 0.03928 ? val / 12.92 : Math.pow((val + 0.055) / 1.055, 2.4);
|
|
301
|
+
});
|
|
302
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
303
|
+
}
|
|
304
|
+
export function findHighestContrastColor(colors, backgroundColor = [255, 255, 255]) {
|
|
305
|
+
let maxContrast = 0;
|
|
306
|
+
let maxContrastColor = colors[0];
|
|
307
|
+
for (const color of colors) {
|
|
308
|
+
const contrast = getContrastRatio(color, backgroundColor);
|
|
309
|
+
if (contrast > maxContrast) {
|
|
310
|
+
maxContrast = contrast;
|
|
311
|
+
maxContrastColor = color;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return maxContrastColor;
|
|
315
|
+
}
|
|
316
|
+
export const rgbaToString = (color, alpha = 1) => `rgba(${[...color, alpha].join(", ")})`;
|
|
317
|
+
export const getNumericStyleValue = (str, fallback = 0) => {
|
|
318
|
+
const v = str.replace("px", "");
|
|
319
|
+
const num = Number.parseFloat(v);
|
|
320
|
+
if (Number.isNaN(num) || num === 0) {
|
|
321
|
+
return fallback;
|
|
322
|
+
}
|
|
323
|
+
return num;
|
|
324
|
+
};
|
|
325
|
+
export function findIdealRectPosition(blockingRects, rectToPlace, viewport, maxOverlap = 60) {
|
|
326
|
+
let targetX = rectToPlace.x;
|
|
327
|
+
for (const blockingRect of blockingRects) {
|
|
328
|
+
if (intersects(rectToPlace, blockingRect)) {
|
|
329
|
+
const a = Math.abs(rectToPlace.y + rectToPlace.height - blockingRect.y);
|
|
330
|
+
const b = Math.abs(blockingRect.y + blockingRect.height - rectToPlace.y);
|
|
331
|
+
const verticalOverlap = Math.min(a, b);
|
|
332
|
+
const smoothingFactor = easeOutSine(
|
|
333
|
+
Math.min(verticalOverlap, maxOverlap) / maxOverlap
|
|
334
|
+
);
|
|
335
|
+
if (rectToPlace.x + rectToPlace.width / 2 > blockingRect.x + blockingRect.width / 2) {
|
|
336
|
+
targetX = blockingRect.x + blockingRect.width;
|
|
337
|
+
} else {
|
|
338
|
+
targetX = blockingRect.x - rectToPlace.width;
|
|
339
|
+
}
|
|
340
|
+
targetX = rectToPlace.x + smoothingFactor * (targetX - rectToPlace.x);
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
x: Math.min(
|
|
346
|
+
Math.max(targetX, viewport.x),
|
|
347
|
+
viewport.x + viewport.width - rectToPlace.width
|
|
348
|
+
),
|
|
349
|
+
y: Math.min(
|
|
350
|
+
Math.max(viewport.y, rectToPlace.y),
|
|
351
|
+
viewport.height + viewport.y - rectToPlace.height
|
|
352
|
+
)
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
export const findClosestBlock = (el) => {
|
|
356
|
+
if (!(el instanceof Element)) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const closest = el.closest('[data-element-type="existing"]');
|
|
360
|
+
if (!closest) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const item = buildDraggableItem(closest);
|
|
364
|
+
if (item?.itemType !== "existing") {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
return item;
|
|
368
|
+
};
|
|
369
|
+
export const findClosestEntityContext = (el) => {
|
|
370
|
+
const provider = el.closest('[data-blokkli-provider-active="true"]');
|
|
371
|
+
if (!(provider instanceof HTMLElement)) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
const uuid = provider.dataset.providerUuid;
|
|
375
|
+
const type = provider.dataset.providerEntityType;
|
|
376
|
+
const bundle = provider.dataset.providerEntityBundle;
|
|
377
|
+
if (uuid && type && bundle) {
|
|
378
|
+
return {
|
|
379
|
+
uuid,
|
|
380
|
+
type,
|
|
381
|
+
bundle
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
export const findParentContext = (el) => {
|
|
386
|
+
const block = findClosestBlock(el);
|
|
387
|
+
if (block) {
|
|
388
|
+
return block;
|
|
389
|
+
}
|
|
390
|
+
return findClosestEntityContext(el);
|
|
391
|
+
};
|
|
392
|
+
export const mapDroppableField = (el) => {
|
|
393
|
+
if (!(el instanceof HTMLElement)) {
|
|
394
|
+
throw new TypeError(
|
|
395
|
+
`v-blokkli-droppable directive is only allowed on elements of type HTMLElement.`
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
const fieldName = el.dataset.blokkliDroppableField;
|
|
399
|
+
if (!fieldName) {
|
|
400
|
+
throw new Error(`Missing field name in v-blokkli-droppable directive.`);
|
|
401
|
+
}
|
|
402
|
+
const host = findParentContext(el);
|
|
403
|
+
if (!host) {
|
|
404
|
+
throw new Error(
|
|
405
|
+
`Failed to locate parent context for v-blokkli-droppable field with name "${fieldName}". Make sure the element is always rendered inside a block component or inside a <BlokkliProvider>.`
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
element: el,
|
|
410
|
+
host,
|
|
411
|
+
fieldName
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
export const originatesFromEditable = (e) => {
|
|
415
|
+
if (e.target instanceof HTMLElement) {
|
|
416
|
+
const el = e.target.closest("[data-blokkli-editable-field]");
|
|
417
|
+
if (el instanceof HTMLElement) {
|
|
418
|
+
return el;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
export const getOriginatingDroppableElement = (e) => {
|
|
423
|
+
if (e.target instanceof HTMLElement) {
|
|
424
|
+
const el = e.target.closest("[data-blokkli-droppable-field]");
|
|
425
|
+
if (el instanceof HTMLElement) {
|
|
426
|
+
return el;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
export const originatesFromTextInput = (e) => e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement;
|
|
431
|
+
export function getFieldKey(uuid, fieldName) {
|
|
432
|
+
return uuid + ":" + fieldName;
|
|
433
|
+
}
|
|
434
|
+
export function getInteractionCoordinates(e) {
|
|
435
|
+
if ("touches" in e) {
|
|
436
|
+
const touch = e.touches[0] || e.changedTouches[0];
|
|
437
|
+
return {
|
|
438
|
+
x: touch.clientX,
|
|
439
|
+
y: touch.clientY
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return {
|
|
443
|
+
x: e.clientX,
|
|
444
|
+
y: e.clientY
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
export function toShaderColor(rgba) {
|
|
448
|
+
return rgba.map((v) => v / 255);
|
|
449
|
+
}
|
|
450
|
+
export function generateUUID() {
|
|
451
|
+
try {
|
|
452
|
+
return crypto.randomUUID();
|
|
453
|
+
} catch {
|
|
454
|
+
}
|
|
455
|
+
let d = (/* @__PURE__ */ new Date()).getTime(), d2 = typeof performance !== "undefined" && performance.now && performance.now() * 1e3 || 0;
|
|
456
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
457
|
+
let r = Math.random() * 16;
|
|
458
|
+
if (d > 0) {
|
|
459
|
+
r = (d + r) % 16 | 0;
|
|
460
|
+
d = Math.floor(d / 16);
|
|
461
|
+
} else {
|
|
462
|
+
r = (d2 + r) % 16 | 0;
|
|
463
|
+
d2 = Math.floor(d2 / 16);
|
|
464
|
+
}
|
|
465
|
+
return (c == "x" ? r : r & 7 | 8).toString(16);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Ref, type ComputedRef } from 'vue';
|
|
2
|
+
import type { AnimationProvider } from './animationProvider.js';
|
|
3
|
+
import type { KeyboardShortcut } from '#blokkli/types';
|
|
4
|
+
type RegisteredShortcut = {
|
|
5
|
+
key: string;
|
|
6
|
+
shortcut: KeyboardShortcut;
|
|
7
|
+
};
|
|
8
|
+
export type KeyboardProvider = {
|
|
9
|
+
isPressingSpace: Readonly<Ref<boolean>>;
|
|
10
|
+
isPressingControl: Readonly<Ref<boolean>>;
|
|
11
|
+
isPressingShift: Readonly<Ref<boolean>>;
|
|
12
|
+
shortcuts: ComputedRef<RegisteredShortcut[]>;
|
|
13
|
+
registerShortcut: (shortcut: KeyboardShortcut) => void;
|
|
14
|
+
unregisterShortcut: (shortcut: KeyboardShortcut) => void;
|
|
15
|
+
};
|
|
16
|
+
export default function (animationProvider: AnimationProvider): KeyboardProvider;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ref,
|
|
3
|
+
readonly,
|
|
4
|
+
onMounted,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
watch,
|
|
7
|
+
computed
|
|
8
|
+
} from "vue";
|
|
9
|
+
import { eventBus } from "#blokkli/helpers/eventBus";
|
|
10
|
+
export default function(animationProvider) {
|
|
11
|
+
const isPressingControl = ref(false);
|
|
12
|
+
const isPressingSpace = ref(false);
|
|
13
|
+
const isPressingShift = ref(false);
|
|
14
|
+
const registeredShortcuts = ref([]);
|
|
15
|
+
const onKeyUp = (e) => {
|
|
16
|
+
isPressingControl.value = e.getModifierState("Control") || e.getModifierState("Meta");
|
|
17
|
+
isPressingShift.value = e.getModifierState("Shift");
|
|
18
|
+
if (e.code === "Space") {
|
|
19
|
+
isPressingSpace.value = false;
|
|
20
|
+
}
|
|
21
|
+
if (e.code === "Control" || e.key === "CapsLock") {
|
|
22
|
+
isPressingControl.value = false;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const onKeyDown = (e) => {
|
|
26
|
+
isPressingControl.value = e.getModifierState("Control") || e.getModifierState("Meta") || e.code === "CapsLock";
|
|
27
|
+
isPressingShift.value = e.getModifierState("Shift");
|
|
28
|
+
if (!isPressingSpace.value) {
|
|
29
|
+
eventBus.emit("keyPressed", {
|
|
30
|
+
code: e.key,
|
|
31
|
+
shift: e.shiftKey,
|
|
32
|
+
meta: e.ctrlKey || e.metaKey || isPressingControl.value,
|
|
33
|
+
originalEvent: e
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (e.code === "Space") {
|
|
37
|
+
isPressingSpace.value = true;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const onVisibilityChange = () => {
|
|
41
|
+
isPressingControl.value = false;
|
|
42
|
+
isPressingSpace.value = false;
|
|
43
|
+
};
|
|
44
|
+
onMounted(() => {
|
|
45
|
+
document.addEventListener("keydown", onKeyDown);
|
|
46
|
+
document.addEventListener("keyup", onKeyUp);
|
|
47
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
48
|
+
});
|
|
49
|
+
onBeforeUnmount(() => {
|
|
50
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
51
|
+
document.removeEventListener("keyup", onKeyUp);
|
|
52
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
53
|
+
});
|
|
54
|
+
watch(isPressingSpace, () => {
|
|
55
|
+
animationProvider.requestDraw();
|
|
56
|
+
});
|
|
57
|
+
watch(isPressingControl, () => {
|
|
58
|
+
animationProvider.requestDraw();
|
|
59
|
+
});
|
|
60
|
+
const getShortcutKey = (shortcut) => [!!shortcut.meta, !!shortcut.shift, shortcut.code].join("-");
|
|
61
|
+
const registerShortcut = (shortcut) => {
|
|
62
|
+
registeredShortcuts.value.push({ key: getShortcutKey(shortcut), shortcut });
|
|
63
|
+
};
|
|
64
|
+
const unregisterShortcut = (shortcut) => {
|
|
65
|
+
const key = getShortcutKey(shortcut);
|
|
66
|
+
registeredShortcuts.value = registeredShortcuts.value.filter(
|
|
67
|
+
(v) => v.key !== key
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
const shortcuts = computed(() => registeredShortcuts.value);
|
|
71
|
+
return {
|
|
72
|
+
isPressingSpace: readonly(isPressingSpace),
|
|
73
|
+
isPressingControl: readonly(isPressingControl),
|
|
74
|
+
isPressingShift: readonly(isPressingShift),
|
|
75
|
+
shortcuts,
|
|
76
|
+
registerShortcut,
|
|
77
|
+
unregisterShortcut
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function optionValueToStorable(definition, value) {
|
|
2
|
+
if (definition.type === "checkbox") {
|
|
3
|
+
if (typeof value === "string" && (value === "1" || value === "0")) {
|
|
4
|
+
return value;
|
|
5
|
+
} else if (typeof value === "boolean") {
|
|
6
|
+
return value === true ? "1" : "0";
|
|
7
|
+
}
|
|
8
|
+
return "0";
|
|
9
|
+
} else if (definition.type === "text" || definition.type === "radios") {
|
|
10
|
+
if (typeof value === "string") {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
} else if (definition.type === "checkboxes") {
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return value.join(",");
|
|
16
|
+
} else if (typeof value === "string") {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file should contain all helpers that are meant for runtime functionality, such as defineBlokkli composable or <BlokkliProvider>.
|
|
3
|
+
*/
|
|
4
|
+
import type { BlockOptionDefinition } from '#blokkli/types/blokkOptions';
|
|
5
|
+
/**
|
|
6
|
+
* Get the runtime value for an option.
|
|
7
|
+
*
|
|
8
|
+
* Internally, all option values are stored as strings. This function maps the stored data to the runtime value.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRuntimeOptionValue(definition: Pick<BlockOptionDefinition, 'type' | 'default'>, value: string | string[] | boolean | undefined | null | number): string | string[] | boolean | number;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function getRuntimeOptionValue(definition, value) {
|
|
2
|
+
if (definition.type === "checkbox") {
|
|
3
|
+
if (typeof value === "string") {
|
|
4
|
+
return value === "1" || value === "true";
|
|
5
|
+
} else if (typeof value === "boolean") {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
return false;
|
|
9
|
+
} else if (definition.type === "radios") {
|
|
10
|
+
if (typeof value === "string") {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
return "";
|
|
14
|
+
} else if (definition.type === "checkboxes") {
|
|
15
|
+
if (typeof value === "string") {
|
|
16
|
+
return value.split(",");
|
|
17
|
+
} else if (Array.isArray(value)) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return [];
|
|
21
|
+
} else if (definition.type === "range" || definition.type === "number") {
|
|
22
|
+
if (typeof value === "number" && !Number.isNaN(value)) {
|
|
23
|
+
return value;
|
|
24
|
+
} else if (typeof value === "string") {
|
|
25
|
+
const parsed = Number.parseFloat(value);
|
|
26
|
+
if (!Number.isNaN(parsed)) {
|
|
27
|
+
return parsed;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DomProvider } from './domProvider.js';
|
|
2
|
+
import { type Ref, type ComputedRef } from '#imports';
|
|
3
|
+
import type { DraggableExistingBlock, DraggableItem, InteractionMode } from '#blokkli/types';
|
|
4
|
+
export type SelectionProvider = {
|
|
5
|
+
/**
|
|
6
|
+
* The currently selected UUIDs.
|
|
7
|
+
*/
|
|
8
|
+
uuids: Readonly<Ref<string[]>>;
|
|
9
|
+
/**
|
|
10
|
+
* The currently selected UUIDs as a map.
|
|
11
|
+
*/
|
|
12
|
+
uuidsMap: ComputedRef<Record<string, boolean>>;
|
|
13
|
+
/**
|
|
14
|
+
* The currently selected blocks.
|
|
15
|
+
*/
|
|
16
|
+
blocks: ComputedRef<DraggableExistingBlock[]>;
|
|
17
|
+
/**
|
|
18
|
+
* The active field key.
|
|
19
|
+
*/
|
|
20
|
+
activeFieldKey: Readonly<Ref<string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the user is currently dragging a block.
|
|
23
|
+
*/
|
|
24
|
+
isDragging: ComputedRef<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the user is currently dragging at least one existing block.
|
|
27
|
+
*/
|
|
28
|
+
isDraggingExisting: ComputedRef<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the user is currently dragging a block.
|
|
31
|
+
*/
|
|
32
|
+
draggingMode: Readonly<Ref<InteractionMode | null>>;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the user is currently dragging a block.
|
|
35
|
+
*/
|
|
36
|
+
interactionMode: Readonly<Ref<InteractionMode | null>>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the user is currently in multi select mode.
|
|
39
|
+
*/
|
|
40
|
+
isMultiSelecting: Ref<boolean>;
|
|
41
|
+
/**
|
|
42
|
+
* Update the active field key.
|
|
43
|
+
*/
|
|
44
|
+
setActiveFieldKey: (key: string) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Whether an editable field is currently being edited.
|
|
47
|
+
*/
|
|
48
|
+
editableActive: Ref<boolean>;
|
|
49
|
+
/**
|
|
50
|
+
* Whether the user is currently changing block options.
|
|
51
|
+
*/
|
|
52
|
+
isChangingOptions: Ref<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* The items that are currently being dragged.
|
|
55
|
+
*/
|
|
56
|
+
dragItems: Ref<DraggableItem[]>;
|
|
57
|
+
/**
|
|
58
|
+
* The block bundles of the items being dragged.
|
|
59
|
+
*/
|
|
60
|
+
dragItemsBundles: ComputedRef<string[]>;
|
|
61
|
+
};
|
|
62
|
+
export default function (dom: DomProvider): SelectionProvider;
|