@blokkli/editor 2.0.0-alpha.24 → 2.0.0-alpha.25

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.
Files changed (182) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +191 -27
  3. package/dist/runtime/blokkliPlugins/BlockIndicator/index.vue.d.ts +38 -0
  4. package/dist/runtime/blokkliPlugins/ContextMenu/index.vue.d.ts +15 -0
  5. package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue.d.ts +6 -0
  6. package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +28 -3
  7. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +6 -4
  8. package/dist/runtime/blokkliPlugins/Sidebar/index.vue +11 -3
  9. package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +138 -3
  10. package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue.d.ts +114 -0
  11. package/dist/runtime/blokkliPlugins/TourItem/index.vue.d.ts +21 -0
  12. package/dist/runtime/blokkliPlugins/ViewOption/index.vue.d.ts +98 -0
  13. package/dist/runtime/components/Blocks/NotImplemented/index.vue +24 -0
  14. package/dist/runtime/components/Blocks/NotImplemented/index.vue.d.ts +6 -0
  15. package/dist/runtime/components/BlokkliEditable.vue.d.ts +11 -0
  16. package/dist/runtime/components/BlokkliItem.vue +16 -3
  17. package/dist/runtime/components/BlokkliItem.vue.d.ts +2 -0
  18. package/dist/runtime/components/Edit/Actions/index.vue +1 -1
  19. package/dist/runtime/components/Edit/AddListItem/index.vue +1 -6
  20. package/dist/runtime/components/Edit/AddListItem/index.vue.d.ts +5 -13
  21. package/dist/runtime/components/Edit/ArtboardTooltip/index.vue +6 -0
  22. package/dist/runtime/components/Edit/BlockProxy/index.vue +2 -2
  23. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +3 -0
  24. package/dist/runtime/components/Edit/BlokkliRootErrorBoundary.vue +4 -1
  25. package/dist/runtime/components/Edit/Dialog/index.vue +15 -50
  26. package/dist/runtime/components/Edit/DraggableList.vue +12 -9
  27. package/dist/runtime/components/Edit/EditIndicator.vue +11 -4
  28. package/dist/runtime/components/Edit/EditProvider.vue +27 -24
  29. package/dist/runtime/components/Edit/Features/AddList/Actions/Action.vue +1 -0
  30. package/dist/runtime/components/Edit/Features/AddList/Blocks/index.vue +2 -3
  31. package/dist/runtime/components/Edit/Features/AddList/index.vue +17 -5
  32. package/dist/runtime/components/Edit/Features/Analyze/Icon.vue +85 -0
  33. package/dist/runtime/components/Edit/Features/Analyze/Icon.vue.d.ts +5 -0
  34. package/dist/runtime/components/Edit/Features/Analyze/Main.vue +288 -59
  35. package/dist/runtime/components/Edit/Features/Analyze/Main.vue.d.ts +8 -1
  36. package/dist/runtime/components/Edit/Features/Analyze/Renderer/fragment.glsl +25 -13
  37. package/dist/runtime/components/Edit/Features/Analyze/Renderer/index.vue +114 -52
  38. package/dist/runtime/components/Edit/Features/Analyze/Renderer/index.vue.d.ts +16 -2
  39. package/dist/runtime/components/Edit/Features/Analyze/Renderer/vertex.glsl +31 -11
  40. package/dist/runtime/components/Edit/Features/Analyze/Results/Results.vue +2 -0
  41. package/dist/runtime/components/Edit/Features/Analyze/Results/Results.vue.d.ts +8 -1
  42. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItem.vue +4 -4
  43. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItem.vue.d.ts +20 -2
  44. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodes.vue +11 -18
  45. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodes.vue.d.ts +10 -3
  46. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +46 -40
  47. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue.d.ts +10 -4
  48. package/dist/runtime/components/Edit/Features/Analyze/Summary/Chart.vue +8 -4
  49. package/dist/runtime/components/Edit/Features/Analyze/analyzers/axe.js +1 -0
  50. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/Context.d.ts +4 -3
  51. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/Context.js +2 -1
  52. package/dist/runtime/components/Edit/Features/Analyze/analyzers/readability.js +61 -20
  53. package/dist/runtime/components/Edit/Features/Analyze/analyzers/types.d.ts +15 -1
  54. package/dist/runtime/components/Edit/Features/Analyze/index.vue +23 -2
  55. package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue +22 -8
  56. package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue +1 -1
  57. package/dist/runtime/components/Edit/Features/Artboard/Scrollbar/index.vue +8 -3
  58. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue +10 -1
  59. package/dist/runtime/components/Edit/Features/Debug/Main.vue.d.ts +1 -1
  60. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +2 -2
  61. package/dist/runtime/components/Edit/Features/Debug/Section/Logging.vue.d.ts +1 -1
  62. package/dist/runtime/components/Edit/Features/EditForm/Frame/index.vue +8 -2
  63. package/dist/runtime/components/Edit/Features/EditForm/index.vue +1 -7
  64. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +1 -1
  65. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +4 -3
  66. package/dist/runtime/components/Edit/Features/EditableMask/index.vue +1 -1
  67. package/dist/runtime/components/Edit/Features/EntityTitle/index.vue +7 -2
  68. package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +2 -2
  69. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +9 -2
  70. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +12 -3
  71. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +3 -2
  72. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue.d.ts +1 -1
  73. package/dist/runtime/components/Edit/Features/PreviewGrant/index.vue +1 -0
  74. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +9 -0
  75. package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue +3 -2
  76. package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +3 -2
  77. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +8 -2
  78. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +12 -2
  79. package/dist/runtime/components/Edit/Features/Search/Overlay/index.vue +11 -3
  80. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue +126 -33
  81. package/dist/runtime/components/Edit/Features/Selection/Renderer/index.vue +1 -1
  82. package/dist/runtime/components/Edit/Features/Settings/index.vue +1 -1
  83. package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +3 -3
  84. package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +2 -2
  85. package/dist/runtime/components/Edit/Features/Transform/Dialog/index.vue +7 -1
  86. package/dist/runtime/components/Edit/Form/Textarea/index.vue +1 -1
  87. package/dist/runtime/components/Edit/FormOverlay/index.vue +1 -1
  88. package/dist/runtime/components/Edit/Indicators/index.vue +1 -1
  89. package/dist/runtime/components/Edit/InfoBox/index.vue +3 -2
  90. package/dist/runtime/components/Edit/InfoBox/index.vue.d.ts +6 -1
  91. package/dist/runtime/components/Edit/Overlay/index.vue +4 -0
  92. package/dist/runtime/components/Edit/PreviewProvider.vue +3 -3
  93. package/dist/runtime/components/Edit/ScaleToFit/index.vue +4 -4
  94. package/dist/runtime/composables/defineBlokkliFeature.d.ts +1 -1
  95. package/dist/runtime/composables/useBlokkli.d.ts +6 -1
  96. package/dist/runtime/composables/useBlokkli.js +4 -1
  97. package/dist/runtime/css/output.css +1 -1
  98. package/dist/runtime/helpers/composables/defineItemDropdownAction.d.ts +1 -1
  99. package/dist/runtime/helpers/composables/defineMenuButton.d.ts +1 -1
  100. package/dist/runtime/helpers/composables/defineRenderer.d.ts +1 -1
  101. package/dist/runtime/helpers/composables/onBroadcastEvent.d.ts +1 -1
  102. package/dist/runtime/helpers/composables/useBlockRegistration.d.ts +1 -1
  103. package/dist/runtime/helpers/composables/useBlockRegistration.js +12 -1
  104. package/dist/runtime/helpers/composables/useDebugLogger.d.ts +1 -1
  105. package/dist/runtime/helpers/composables/useFocusTrap.d.ts +52 -0
  106. package/dist/runtime/helpers/composables/useFocusTrap.js +59 -0
  107. package/dist/runtime/helpers/composables/useGlobalBlokkliObject.d.ts +1 -1
  108. package/dist/runtime/helpers/{useTransitionedValue.js → composables/useTransitionedValue.js} +1 -1
  109. package/dist/runtime/helpers/imports/index.d.ts +2 -1
  110. package/dist/runtime/helpers/imports/index.js +10 -1
  111. package/dist/runtime/helpers/{animationProvider.d.ts → providers/animation.d.ts} +100 -7
  112. package/dist/runtime/helpers/{animationProvider.js → providers/animation.js} +21 -11
  113. package/dist/runtime/helpers/providers/blocks.d.ts +25 -3
  114. package/dist/runtime/helpers/providers/blocks.js +9 -0
  115. package/dist/runtime/helpers/providers/commands.d.ts +41 -0
  116. package/dist/runtime/helpers/{commandsProvider.js → providers/commands.js} +1 -1
  117. package/dist/runtime/helpers/providers/debug.d.ts +125 -0
  118. package/dist/runtime/helpers/{debugProvider.js → providers/debug.js} +2 -2
  119. package/dist/runtime/helpers/providers/definition.d.ts +87 -0
  120. package/dist/runtime/helpers/providers/directive.d.ts +88 -2
  121. package/dist/runtime/helpers/providers/directive.js +18 -2
  122. package/dist/runtime/helpers/providers/dom.d.ts +225 -0
  123. package/dist/runtime/helpers/{domProvider.js → providers/dom.js} +27 -74
  124. package/dist/runtime/helpers/providers/dropArea.d.ts +47 -0
  125. package/dist/runtime/helpers/{dropAreaProvider.js → providers/dropArea.js} +1 -1
  126. package/dist/runtime/helpers/providers/element.d.ts +58 -1
  127. package/dist/runtime/helpers/providers/features.d.ts +56 -0
  128. package/dist/runtime/helpers/{featuresProvider.js → providers/features.js} +1 -1
  129. package/dist/runtime/helpers/providers/fields.d.ts +18 -11
  130. package/dist/runtime/helpers/providers/fields.js +1 -1
  131. package/dist/runtime/helpers/providers/indicators.d.ts +44 -0
  132. package/dist/runtime/helpers/providers/keyboard.d.ts +76 -0
  133. package/dist/runtime/helpers/{keyboardProvider.js → providers/keyboard.js} +1 -8
  134. package/dist/runtime/helpers/{pluginProvider.d.ts → providers/plugin.d.ts} +36 -0
  135. package/dist/runtime/helpers/{selectionProvider.d.ts → providers/selection.d.ts} +4 -1
  136. package/dist/runtime/helpers/{selectionProvider.js → providers/selection.js} +1 -1
  137. package/dist/runtime/helpers/providers/state.d.ts +227 -0
  138. package/dist/runtime/helpers/{stateProvider.js → providers/state.js} +3 -3
  139. package/dist/runtime/helpers/providers/storage.d.ts +64 -0
  140. package/dist/runtime/helpers/{textProvider.d.ts → providers/texts.d.ts} +1 -1
  141. package/dist/runtime/helpers/providers/theme.d.ts +119 -0
  142. package/dist/runtime/helpers/{themeProvider.js → providers/theme.js} +3 -3
  143. package/dist/runtime/helpers/providers/tour.d.ts +49 -0
  144. package/dist/runtime/helpers/{tourProvider.js → providers/tour.js} +1 -1
  145. package/dist/runtime/helpers/providers/types.d.ts +170 -0
  146. package/dist/runtime/helpers/{typesProvider.js → providers/types.js} +45 -1
  147. package/dist/runtime/helpers/providers/ui.d.ts +339 -0
  148. package/dist/runtime/helpers/{uiProvider.js → providers/ui.js} +11 -5
  149. package/dist/runtime/helpers/runtimeHelpers/index.d.ts +1 -1
  150. package/dist/runtime/helpers/symbols.d.ts +1 -0
  151. package/dist/runtime/helpers/symbols.js +3 -0
  152. package/dist/runtime/types/blockOptions.d.ts +349 -0
  153. package/dist/runtime/types/index.d.ts +22 -26
  154. package/package.json +2 -2
  155. package/dist/runtime/helpers/commandsProvider.d.ts +0 -9
  156. package/dist/runtime/helpers/debugProvider.d.ts +0 -33
  157. package/dist/runtime/helpers/definitionProvider.d.ts +0 -19
  158. package/dist/runtime/helpers/domProvider.d.ts +0 -91
  159. package/dist/runtime/helpers/dropAreaProvider.d.ts +0 -9
  160. package/dist/runtime/helpers/featuresProvider.d.ts +0 -17
  161. package/dist/runtime/helpers/indicatorsProvider.d.ts +0 -10
  162. package/dist/runtime/helpers/keyboardProvider.d.ts +0 -20
  163. package/dist/runtime/helpers/stateProvider.d.ts +0 -47
  164. package/dist/runtime/helpers/storageProvider.d.ts +0 -17
  165. package/dist/runtime/helpers/themeProvider.d.ts +0 -30
  166. package/dist/runtime/helpers/tourProvider.d.ts +0 -11
  167. package/dist/runtime/helpers/typesProvider.d.ts +0 -36
  168. package/dist/runtime/helpers/uiProvider.d.ts +0 -57
  169. package/dist/runtime/types/blokkOptions.d.ts +0 -100
  170. /package/dist/runtime/helpers/{addElementClasses.d.ts → composables/addElementClasses.d.ts} +0 -0
  171. /package/dist/runtime/helpers/{addElementClasses.js → composables/addElementClasses.js} +0 -0
  172. /package/dist/runtime/helpers/{defineElementStyle.d.ts → composables/defineElementStyle.d.ts} +0 -0
  173. /package/dist/runtime/helpers/{defineElementStyle.js → composables/defineElementStyle.js} +0 -0
  174. /package/dist/runtime/helpers/{useTransitionedValue.d.ts → composables/useTransitionedValue.d.ts} +0 -0
  175. /package/dist/runtime/helpers/{broadcastProvider.d.ts → providers/broadcast.d.ts} +0 -0
  176. /package/dist/runtime/helpers/{broadcastProvider.js → providers/broadcast.js} +0 -0
  177. /package/dist/runtime/helpers/{definitionProvider.js → providers/definition.js} +0 -0
  178. /package/dist/runtime/helpers/{indicatorsProvider.js → providers/indicators.js} +0 -0
  179. /package/dist/runtime/helpers/{pluginProvider.js → providers/plugin.js} +0 -0
  180. /package/dist/runtime/helpers/{storageProvider.js → providers/storage.js} +0 -0
  181. /package/dist/runtime/helpers/{textProvider.js → providers/texts.js} +0 -0
  182. /package/dist/runtime/types/{blokkOptions.js → blockOptions.js} +0 -0
@@ -1,2 +1,2 @@
1
- import type { ItemDropdownAction } from '../pluginProvider.js';
1
+ import type { ItemDropdownAction } from '../providers/plugin.js';
2
2
  export default function (cb: () => ItemDropdownAction | ItemDropdownAction[] | undefined): void;
@@ -1,2 +1,2 @@
1
- import type { MenuButtonPlugin } from '../pluginProvider.js';
1
+ import type { MenuButtonPlugin } from '../providers/plugin.js';
2
2
  export default function (cb: () => MenuButtonPlugin | MenuButtonPlugin[] | undefined): void;
@@ -1,4 +1,4 @@
1
- import type { Renderer } from '../animationProvider.js';
1
+ import type { Renderer } from '../providers/animation.js';
2
2
  /**
3
3
  * Register a WebGL renderer with automatic cleanup on unmount.
4
4
  *
@@ -1,2 +1,2 @@
1
- import type { BroadcastEvents } from '../broadcastProvider.js';
1
+ import type { BroadcastEvents } from '../providers/broadcast.js';
2
2
  export default function <T extends keyof BroadcastEvents>(name: T, cb: (e: BroadcastEvents[T]) => void): void;
@@ -1,4 +1,4 @@
1
- import type { DomProvider } from '../domProvider.js';
1
+ import type { DomProvider } from '../providers/dom.js';
2
2
  /**
3
3
  * Helper composable to handle registering the block in the DOM provider.
4
4
  */
@@ -8,8 +8,19 @@ export function useBlockRegistration(dom, uuid) {
8
8
  const instance = getCurrentInstance();
9
9
  const key = uuid + Math.round(Math.random() * 1e10).toString() + Date.now().toString();
10
10
  let rootElement = null;
11
+ function getDraggableElement() {
12
+ const blokkliDraggable = instance?.refs.blokkliDraggable;
13
+ if (blokkliDraggable instanceof HTMLElement) {
14
+ return blokkliDraggable;
15
+ }
16
+ const rootElement2 = instance?.proxy?.$el;
17
+ if (rootElement2 instanceof HTMLElement) {
18
+ return rootElement2;
19
+ }
20
+ return null;
21
+ }
11
22
  function setRootElement() {
12
- const newElement = instance?.proxy?.$el;
23
+ const newElement = getDraggableElement();
13
24
  if (newElement && rootElement !== newElement) {
14
25
  rootElement = newElement;
15
26
  dom.registerBlock(key, uuid, newElement);
@@ -1,2 +1,2 @@
1
- import type { DebugLogger } from '../debugProvider.js';
1
+ import type { DebugLogger } from '../providers/debug.js';
2
2
  export default function (): DebugLogger;
@@ -0,0 +1,52 @@
1
+ import { type Ref } from '#imports';
2
+ type FocusableElement = HTMLInputElement | HTMLSelectElement | HTMLButtonElement | HTMLTextAreaElement;
3
+ export type UseFocusTrapOptions = {
4
+ /**
5
+ * The container element to trap focus within.
6
+ */
7
+ container: Ref<HTMLElement | undefined | null>;
8
+ /**
9
+ * Whether to auto-focus the first focusable element on mount.
10
+ *
11
+ * @default true
12
+ */
13
+ autoFocus?: boolean;
14
+ /**
15
+ * Element selector for focusable elements.
16
+ *
17
+ * @default 'input,select,button,textarea'
18
+ */
19
+ selector?: string;
20
+ /**
21
+ * Debug label for element queries.
22
+ */
23
+ debugLabel?: string;
24
+ };
25
+ /**
26
+ * Creates a focus trap within a container element.
27
+ *
28
+ * Handles Tab/Shift+Tab keyboard navigation to cycle through focusable elements,
29
+ * and optionally auto-focuses the first element on mount.
30
+ *
31
+ * @example
32
+ * ```vue
33
+ * <script setup>
34
+ * import { useFocusTrap } from '#blokkli/helpers'
35
+ *
36
+ * const containerEl = useTemplateRef('container')
37
+ * const { onKeyDown } = useFocusTrap({ container: containerEl })
38
+ * </script>
39
+ *
40
+ * <template>
41
+ * <div ref="container" @keydown.stop="onKeyDown">
42
+ * <input type="text" />
43
+ * <button>Submit</button>
44
+ * </div>
45
+ * </template>
46
+ * ```
47
+ */
48
+ export default function useFocusTrap(options: UseFocusTrapOptions): {
49
+ onKeyDown: (e: KeyboardEvent) => void;
50
+ getFocusableElements: () => FocusableElement[];
51
+ };
52
+ export {};
@@ -0,0 +1,59 @@
1
+ import { useBlokkli, onMounted } from "#imports";
2
+ import { modulo } from "#blokkli/helpers";
3
+ export default function useFocusTrap(options) {
4
+ const { element } = useBlokkli();
5
+ const {
6
+ container,
7
+ autoFocus = true,
8
+ selector = "input,select,button,textarea",
9
+ debugLabel = "useFocusTrap"
10
+ } = options;
11
+ const getFocusableElements = () => {
12
+ if (!container.value) {
13
+ return [];
14
+ }
15
+ return element.queryAll(container.value, selector, debugLabel);
16
+ };
17
+ const onKeyDown = (e) => {
18
+ if (!container.value || e.code !== "Tab") {
19
+ return;
20
+ }
21
+ const prev = e.shiftKey;
22
+ const focusableElements = getFocusableElements().filter((el) => {
23
+ if (el.tabIndex === -1) {
24
+ return false;
25
+ }
26
+ const style = window.getComputedStyle(el);
27
+ if (style.pointerEvents === "none") {
28
+ return false;
29
+ } else if (style.display === "none") {
30
+ return false;
31
+ }
32
+ return !el.disabled;
33
+ });
34
+ const activeIndex = Math.max(
35
+ focusableElements.findIndex((el) => document.activeElement === el),
36
+ 0
37
+ );
38
+ const delta = prev ? -1 : 1;
39
+ const indexToFocus = modulo(activeIndex + delta, focusableElements.length);
40
+ const elementToFocus = focusableElements[indexToFocus];
41
+ if (elementToFocus) {
42
+ elementToFocus.focus();
43
+ e.preventDefault();
44
+ }
45
+ };
46
+ if (autoFocus) {
47
+ onMounted(() => {
48
+ const focusableElements = getFocusableElements();
49
+ const bestMatch = focusableElements.find((el) => !(el instanceof HTMLButtonElement)) || focusableElements[0];
50
+ if (bestMatch) {
51
+ bestMatch.focus();
52
+ }
53
+ });
54
+ }
55
+ return {
56
+ onKeyDown,
57
+ getFocusableElements
58
+ };
59
+ }
@@ -1,4 +1,4 @@
1
- import type { LogMessage } from '../debugProvider.js';
1
+ import type { LogMessage } from '../providers/debug.js';
2
2
  type BlokkliGlobalWindowObject = {
3
3
  messages: LogMessage[];
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import { computed, watch } from "vue";
2
- import { easeOutQuad } from "./easing.js";
2
+ import { easeOutQuad } from "./../easing.js";
3
3
  function isRGB(value) {
4
4
  return Array.isArray(value) && value.length === 3;
5
5
  }
@@ -1 +1,2 @@
1
- export declare function getComponent(type: 'block' | 'fragment', bundle: string, fieldListType?: string, parentBundle?: string): any;
1
+ import type { Component } from 'vue';
2
+ export declare function getComponent(type: 'block' | 'fragment', bundle: string, fieldListType?: string, parentBundle?: string, allComponents?: Record<string, Component> | null): any;
@@ -26,19 +26,28 @@ function objectOrImport(key) {
26
26
  }
27
27
  return item;
28
28
  }
29
- export function getComponent(type, bundle, fieldListType, parentBundle) {
29
+ export function getComponent(type, bundle, fieldListType, parentBundle, allComponents) {
30
30
  if (fieldListType) {
31
31
  const key2 = `${type}:${bundle}__f:${fieldListType}`;
32
+ if (allComponents && allComponents[key2]) {
33
+ return allComponents[key2];
34
+ }
32
35
  if (chunkMapping[key2]) {
33
36
  return objectOrImport(key2);
34
37
  }
35
38
  }
36
39
  if (parentBundle) {
37
40
  const key2 = `${type}:${bundle}__p:${parentBundle}`;
41
+ if (allComponents && allComponents[key2]) {
42
+ return allComponents[key2];
43
+ }
38
44
  if (chunkMapping[key2]) {
39
45
  return objectOrImport(key2);
40
46
  }
41
47
  }
42
48
  const key = `${type}:${bundle}`;
49
+ if (allComponents && allComponents[key]) {
50
+ return allComponents[key];
51
+ }
43
52
  return objectOrImport(key);
44
53
  }
@@ -1,31 +1,88 @@
1
1
  import { type ComputedRef, type WritableComputedRef } from '#imports';
2
- import type { UiProvider } from './uiProvider.js';
2
+ import type { UiProvider } from './ui.js';
3
3
  import { type ProgramInfo } from 'twgl.js';
4
- import type { StorageProvider } from './storageProvider.js';
5
- import type { CursorKeyword } from './dom/index.js';
4
+ import type { StorageProvider } from './storage.js';
5
+ import type { CursorKeyword } from '../dom/index.js';
6
6
  import type { CanvasDrawEvent, Coord } from '#blokkli/types';
7
- import type { SelectionProvider } from './selectionProvider.js';
8
- import type { RectangleBufferCollector } from './webgl/index.js';
9
- import type { DebugProvider } from './debugProvider.js';
7
+ import type { SelectionProvider } from './selection.js';
8
+ import type { RectangleBufferCollector } from '../webgl/index.js';
9
+ import type { DebugProvider } from './debug.js';
10
+ import type { KeyboardProvider } from './keyboard.js';
10
11
  export type RenderContext = CanvasDrawEvent & {
11
12
  changeOptionsTransition: number;
12
13
  };
13
14
  type PreferredRenderingMode = 'auto' | 'webgl' | '2d';
14
15
  export type Renderer<T = RectangleBufferCollector<any>> = {
16
+ /**
17
+ * Unique identifier for this renderer.
18
+ */
15
19
  id: string;
20
+ /**
21
+ * Z-index for rendering order.
22
+ *
23
+ * Lower values render first (bottom), higher values render last (top).
24
+ */
16
25
  zIndex: number;
26
+ /**
27
+ * Whether this renderer is currently enabled.
28
+ *
29
+ * If not provided or returns true, the renderer will execute.
30
+ */
17
31
  enabled?: () => boolean;
32
+ /**
33
+ * Whether this renderer should be the only one rendered.
34
+ *
35
+ * When true or returns true, all other renderers are skipped.
36
+ * Useful for debugging or exclusive rendering modes.
37
+ */
18
38
  only?: boolean | (() => boolean);
39
+ /**
40
+ * Get the cursor style when hovering over this renderer's content.
41
+ *
42
+ * Higher zIndex renderers take precedence.
43
+ * @returns The cursor keyword, or null/undefined to defer to lower renderers
44
+ */
19
45
  cursor?: () => CursorKeyword | undefined | null;
46
+ /**
47
+ * Handle click events on this renderer's content.
48
+ *
49
+ * Renderers are checked from highest to lowest zIndex.
50
+ * @param coord - Mouse coordinates in screen and artboard space
51
+ * @returns True to claim the click and stop propagation, false/undefined to continue
52
+ */
20
53
  onClick?: (coord: {
21
54
  mouse: Coord;
22
55
  mouseArtboard: Coord;
23
56
  }) => boolean | undefined;
57
+ /**
58
+ * Create the buffer collector instance for this renderer.
59
+ *
60
+ * The collector manages data buffers and rendering state.
61
+ */
24
62
  collector: () => T;
63
+ /**
64
+ * Define the WebGL shader program for this renderer.
65
+ *
66
+ * @returns Object with vertex and fragment shader source code
67
+ */
25
68
  program?: () => {
26
69
  shaders: [string, string];
27
70
  };
71
+ /**
72
+ * Render using WebGL.
73
+ *
74
+ * @param ctx - Rendering context with viewport, mouse, artboard data
75
+ * @param gl - WebGL rendering context
76
+ * @param program - Compiled shader program
77
+ */
28
78
  render: (ctx: RenderContext, gl: WebGLRenderingContext, program: ProgramInfo) => void;
79
+ /**
80
+ * Fallback rendering using 2D canvas context.
81
+ *
82
+ * Used when WebGL is disabled or unavailable.
83
+ * @param ctx - Rendering context
84
+ * @param ctx2d - 2D canvas rendering context
85
+ */
29
86
  renderFallback?: (ctx: RenderContext, ctx2d: CanvasRenderingContext2D) => void;
30
87
  };
31
88
  export type AnimationProvider = {
@@ -47,10 +104,40 @@ export type AnimationProvider = {
47
104
  * For debugging purposes only (e.g., context loss testing).
48
105
  */
49
106
  getRawGL: () => WebGLRenderingContext | null;
107
+ /**
108
+ * Set shared uniforms that are common across all renderers.
109
+ *
110
+ * Sets resolution, artboard offset, scale, and DPI uniforms.
111
+ * @param gl - WebGL rendering context
112
+ * @param programInfo - Shader program to set uniforms on
113
+ */
50
114
  setSharedUniforms: (gl: WebGLRenderingContext, programInfo: ProgramInfo) => void;
115
+ /**
116
+ * Device pixel ratio adjusted for canvas size limits.
117
+ *
118
+ * Automatically scales down to prevent exceeding WebGL/2D canvas size limits
119
+ * and memory constraints. Lower in low-performance mode.
120
+ */
51
121
  dpi: ComputedRef<number>;
122
+ /**
123
+ * Whether WebGL is supported and enabled.
124
+ *
125
+ * Null initially, then true/false after detection.
126
+ */
52
127
  webglSupported: ComputedRef<boolean | null>;
128
+ /**
129
+ * Whether WebGL rendering is currently enabled.
130
+ *
131
+ * Can be set to force WebGL on/off. Automatically disables if unsupported.
132
+ */
53
133
  webglEnabled: WritableComputedRef<boolean>;
134
+ /**
135
+ * User's preferred rendering mode.
136
+ *
137
+ * - 'auto': Uses WebGL if supported, falls back to 2D
138
+ * - 'webgl': Forces WebGL rendering
139
+ * - '2d': Forces 2D canvas rendering
140
+ */
54
141
  preferredRenderingMode: WritableComputedRef<PreferredRenderingMode>;
55
142
  /**
56
143
  * Reactive property that indicates if we're currently rendering with WebGL.
@@ -87,6 +174,12 @@ export type AnimationProvider = {
87
174
  * The programs are cached by the given ID.
88
175
  */
89
176
  registerProgram: (id: string, gl: WebGLRenderingContext, shaders: string[]) => ProgramInfo;
177
+ /**
178
+ * Current cursor style determined by active renderers.
179
+ *
180
+ * Automatically updated each frame based on mouse position and renderer priorities.
181
+ * Defaults to 'move' when pressing Space, otherwise determined by highest zIndex renderer.
182
+ */
90
183
  cursor: ComputedRef<CursorKeyword>;
91
184
  /**
92
185
  * Handle a click event by calling onClick handlers on renderers.
@@ -106,5 +199,5 @@ export type AnimationProvider = {
106
199
  */
107
200
  unregisterRenderer: (id: string) => void;
108
201
  };
109
- export default function (ui: UiProvider, storage: StorageProvider, selection: SelectionProvider, debug: DebugProvider): AnimationProvider;
202
+ export default function (ui: UiProvider, storage: StorageProvider, selection: SelectionProvider, debug: DebugProvider, keyboard: KeyboardProvider): AnimationProvider;
110
203
  export {};
@@ -1,5 +1,5 @@
1
- import onBlokkliEvent from "./composables/onBlokkliEvent.js";
2
- import useAnimationFrame from "./composables/useAnimationFrame.js";
1
+ import onBlokkliEvent from "../composables/onBlokkliEvent.js";
2
+ import useAnimationFrame from "../composables/useAnimationFrame.js";
3
3
  import {
4
4
  ref,
5
5
  computed,
@@ -9,7 +9,7 @@ import {
9
9
  } from "#imports";
10
10
  import { eventBus } from "#blokkli/helpers/eventBus";
11
11
  import { createProgramInfo } from "twgl.js";
12
- import { useTransitionedValue } from "./useTransitionedValue.js";
12
+ import { useTransitionedValue } from "../composables/useTransitionedValue.js";
13
13
  function configureWebGLContext(gl) {
14
14
  gl.enable(gl.BLEND);
15
15
  gl.disable(gl.DEPTH_TEST);
@@ -17,7 +17,7 @@ function configureWebGLContext(gl) {
17
17
  gl.blendFunc(gl.SRC_ALPHA_SATURATE, gl.ONE);
18
18
  gl.blendEquation(gl.FUNC_ADD);
19
19
  }
20
- export default function(ui, storage, selection, debug) {
20
+ export default function(ui, storage, selection, debug, keyboard) {
21
21
  const logger = debug.createLogger("Animation");
22
22
  const preferredRenderingMode = storage.use(
23
23
  "preferredRenderingMode",
@@ -394,13 +394,17 @@ export default function(ui, storage, selection, debug) {
394
394
  }
395
395
  }
396
396
  let newCursor = "default";
397
- for (let i = sortedRenderers.length - 1; i >= 0; i--) {
398
- const renderer = sortedRenderers[i];
399
- if (renderer.cursor && (!renderer.enabled || renderer.enabled())) {
400
- const cursorValue = renderer.cursor();
401
- if (cursorValue) {
402
- newCursor = cursorValue;
403
- break;
397
+ if (keyboard.isPressingSpace.value) {
398
+ newCursor = "move";
399
+ } else {
400
+ for (let i = sortedRenderers.length - 1; i >= 0; i--) {
401
+ const renderer = sortedRenderers[i];
402
+ if (renderer.cursor && (!renderer.enabled || renderer.enabled())) {
403
+ const cursorValue = renderer.cursor();
404
+ if (cursorValue) {
405
+ newCursor = cursorValue;
406
+ break;
407
+ }
404
408
  }
405
409
  }
406
410
  }
@@ -482,6 +486,12 @@ export default function(ui, storage, selection, debug) {
482
486
  }
483
487
  return registeredPrograms.get(id);
484
488
  }
489
+ watch(keyboard.isPressingSpace, () => {
490
+ requestDraw();
491
+ });
492
+ watch(keyboard.isPressingControl, () => {
493
+ requestDraw();
494
+ });
485
495
  return {
486
496
  requestDraw,
487
497
  gl,
@@ -1,10 +1,32 @@
1
1
  import type { RenderedFieldListItem } from '#blokkli/types';
2
- import type { DomProvider } from '../domProvider.js';
3
- import type { StateProvider } from '../stateProvider.js';
2
+ import type { DomProvider } from './dom.js';
3
+ import type { StateProvider } from './state.js';
4
4
  import type { AdapterContext } from '#blokkli/adapter';
5
- import type { ComputedRef } from 'vue';
5
+ import { type ComputedRef } from '#imports';
6
6
  export type BlocksProvider = {
7
+ /**
8
+ * Get a rendered block by its UUID.
9
+ *
10
+ * Returns a RenderedFieldListItem with complete block metadata including:
11
+ * - Host entity and field information
12
+ * - Publishing status and schedule
13
+ * - Library/fragment data (if applicable)
14
+ * - Parent block bundle (for nested blocks)
15
+ *
16
+ * Results are cached and invalidated on state reload.
17
+ *
18
+ * @param uuid - The block's UUID
19
+ * @returns The rendered block item, or undefined if not found
20
+ */
7
21
  getBlock: (uuid: string) => RenderedFieldListItem | undefined;
22
+ /**
23
+ * Get all rendered blocks in the current state.
24
+ *
25
+ * Returns an array of all blocks with complete metadata.
26
+ * Iterates through all UUIDs in state and builds RenderedFieldListItem for each.
27
+ *
28
+ * @returns Array of all rendered block items
29
+ */
8
30
  getAllBlocks: () => RenderedFieldListItem[];
9
31
  };
10
32
  export default function (state: StateProvider, dom: DomProvider, context: ComputedRef<AdapterContext>): BlocksProvider;
@@ -1,8 +1,10 @@
1
1
  import { itemEntityType } from "#blokkli-build/config";
2
2
  import onBlokkliEvent from "../composables/onBlokkliEvent.js";
3
+ import { ref } from "#imports";
3
4
  import { BUNDLE_BLOKKLI_FRAGMENT } from "#blokkli/constants";
4
5
  export default function(state, dom, context) {
5
6
  const renderedFieldListItemCache = /* @__PURE__ */ new Map();
7
+ const refreshKey = ref(1);
6
8
  function getParentBlockBundle(field) {
7
9
  if (field.entityType !== itemEntityType) {
8
10
  return null;
@@ -36,6 +38,9 @@ export default function(state, dom, context) {
36
38
  return null;
37
39
  }
38
40
  function getBlock(uuid) {
41
+ if (refreshKey.value === 0) {
42
+ return;
43
+ }
39
44
  const cached = renderedFieldListItemCache.get(uuid);
40
45
  if (cached) {
41
46
  return cached;
@@ -76,6 +81,9 @@ export default function(state, dom, context) {
76
81
  return renderedItem;
77
82
  }
78
83
  function getAllBlocks() {
84
+ if (refreshKey.value === 0) {
85
+ return [];
86
+ }
79
87
  const blocks = [];
80
88
  const uuids = state.getAllUuids();
81
89
  for (let i = 0; i < uuids.length; i++) {
@@ -93,6 +101,7 @@ export default function(state, dom, context) {
93
101
  }
94
102
  onBlokkliEvent("state:reloaded", () => {
95
103
  renderedFieldListItemCache.clear();
104
+ refreshKey.value++;
96
105
  });
97
106
  return {
98
107
  getBlock,
@@ -0,0 +1,41 @@
1
+ import type { Command } from '#blokkli/types';
2
+ type CommandsProviderFunction = () => Command[] | Command | undefined;
3
+ export type CommandsProvider = {
4
+ /**
5
+ * Register a command provider function.
6
+ *
7
+ * The function will be called when commands are requested.
8
+ * It can return a single command, an array of commands, or undefined.
9
+ *
10
+ * @param fn - Function that returns commands
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * commands.add(() => ({
15
+ * id: 'my-command',
16
+ * label: 'My Command',
17
+ * callback: () => console.log('executed'),
18
+ * }))
19
+ * ```
20
+ */
21
+ add: (fn: CommandsProviderFunction) => void;
22
+ /**
23
+ * Unregister a command provider function.
24
+ *
25
+ * Removes a previously registered function so it no longer provides commands.
26
+ *
27
+ * @param fn - The function to remove (must be the same reference used in add)
28
+ */
29
+ remove: (fn: CommandsProviderFunction) => void;
30
+ /**
31
+ * Get all commands from all registered providers.
32
+ *
33
+ * Calls all registered provider functions, flattens the results,
34
+ * and filters out undefined values.
35
+ *
36
+ * @returns Array of all available commands
37
+ */
38
+ getCommands: () => Command[];
39
+ };
40
+ export default function (): CommandsProvider;
41
+ export {};
@@ -1,4 +1,4 @@
1
- import { falsy } from "./index.js";
1
+ import { falsy } from "../index.js";
2
2
  export default function() {
3
3
  let functions = [];
4
4
  const add = (fn) => {