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

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 +4 -2
  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 +27 -3
  122. package/dist/runtime/helpers/providers/dom.d.ts +225 -0
  123. package/dist/runtime/helpers/{domProvider.js → providers/dom.js} +31 -75
  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
@@ -0,0 +1,125 @@
1
+ import type { StorageProvider } from './storage.js';
2
+ import { type ComputedRef } from '#imports';
3
+ export type DebugLogger = {
4
+ /**
5
+ * Log a debug message.
6
+ *
7
+ * The message is always stored in the message history.
8
+ * It's only output to console if debug mode is enabled and this logger is active.
9
+ *
10
+ * @param message - The log message
11
+ * @param v - Additional context values to log
12
+ */
13
+ log: (message: string, ...v: any) => void;
14
+ /**
15
+ * Log an error message.
16
+ *
17
+ * The message is always stored in the message history.
18
+ * It's only output to console if debug mode is enabled and this logger is active.
19
+ *
20
+ * @param message - The error message
21
+ * @param v - Additional context values to log
22
+ */
23
+ error: (message: string, ...v: any) => void;
24
+ };
25
+ export type LogMessage = {
26
+ type: 'log' | 'error' | 'event';
27
+ name: string;
28
+ date: string;
29
+ message: string;
30
+ context?: string;
31
+ };
32
+ type RegisteredDebugOverlay = {
33
+ id: string;
34
+ label: string;
35
+ active: boolean;
36
+ };
37
+ export type DebugProvider = {
38
+ /**
39
+ * Whether debug mode is currently enabled.
40
+ *
41
+ * Persisted in storage and controls console output for all loggers.
42
+ */
43
+ isEnabled: ComputedRef<boolean>;
44
+ /**
45
+ * Toggle debug mode on/off.
46
+ *
47
+ * When disabled, debug messages are still collected but not output to console.
48
+ */
49
+ toggle: () => void;
50
+ /**
51
+ * Create a named debug logger.
52
+ *
53
+ * Each logger has a unique name that appears in console output and can be
54
+ * individually enabled/disabled. The logger is automatically registered.
55
+ *
56
+ * @param name - Unique name for this logger (e.g., 'DomProvider', 'Animation')
57
+ * @returns Logger instance with log and error methods
58
+ */
59
+ createLogger: (name: string) => DebugLogger;
60
+ /**
61
+ * Register a debug overlay.
62
+ *
63
+ * Debug overlays are visual debugging tools that can be toggled on/off.
64
+ * Examples include viewport visualization, rect debugging, etc.
65
+ *
66
+ * @param id - Unique identifier for the overlay
67
+ * @param label - Human-readable label for the overlay
68
+ */
69
+ registerOverlay: (id: string, label: string) => void;
70
+ /**
71
+ * Unregister a debug overlay.
72
+ *
73
+ * Removes an overlay from the available overlays list.
74
+ *
75
+ * @param id - Identifier of the overlay to remove
76
+ */
77
+ unregisterOverlay: (id: string) => void;
78
+ /**
79
+ * List of all registered debug overlays with their active state.
80
+ *
81
+ * Each overlay includes whether it's currently visible.
82
+ */
83
+ overlays: ComputedRef<RegisteredDebugOverlay[]>;
84
+ /**
85
+ * Toggle a debug overlay on/off.
86
+ *
87
+ * Active state is persisted in storage.
88
+ *
89
+ * @param id - Identifier of the overlay to toggle
90
+ */
91
+ toggleOverlay: (id: string) => void;
92
+ /**
93
+ * List of all registered logger names.
94
+ *
95
+ * Includes all loggers created via createLogger().
96
+ */
97
+ registeredLoggers: ComputedRef<string[]>;
98
+ /**
99
+ * List of currently enabled logger names.
100
+ *
101
+ * When empty, all loggers are active.
102
+ * When non-empty, only listed loggers output to console.
103
+ */
104
+ enabledLoggers: ComputedRef<string[]>;
105
+ /**
106
+ * Toggle a logger's enabled state.
107
+ *
108
+ * Adds or removes the logger from the enabled list.
109
+ * State is persisted in storage.
110
+ *
111
+ * @param name - Name of the logger to toggle
112
+ */
113
+ toggleLogger: (name: string) => void;
114
+ /**
115
+ * Get all collected debug messages.
116
+ *
117
+ * Returns messages from all loggers and events, regardless of enabled state.
118
+ * Useful for debugging issues after they occur.
119
+ *
120
+ * @returns Array of all log messages with timestamps
121
+ */
122
+ getMessages: () => LogMessage[];
123
+ };
124
+ export default function (storage: StorageProvider): DebugProvider;
125
+ export {};
@@ -4,8 +4,8 @@ import {
4
4
  onMounted,
5
5
  ref
6
6
  } from "#imports";
7
- import { eventBus } from "./eventBus.js";
8
- import { useGlobalBlokkliObject } from "./composables/useGlobalBlokkliObject.js";
7
+ import { eventBus } from "./../eventBus.js";
8
+ import { useGlobalBlokkliObject } from "./../composables/useGlobalBlokkliObject.js";
9
9
  export default function(storage) {
10
10
  const showDebug = storage.use("showDebug", false);
11
11
  const visible = storage.use("visibleDebugOverlays", []);
@@ -0,0 +1,87 @@
1
+ import { type Ref, type ComputedRef } from '#imports';
2
+ import type { BlockDefinition, FragmentDefinition, ProviderDefinition } from '#blokkli-build/definitions';
3
+ import type { ValidFieldListTypes, BlockBundleWithNested } from '#blokkli-build/generated-types';
4
+ import type { DeepReadonly } from 'vue';
5
+ import type { BlockDefinitionOptionsInput } from '../../types/index.js';
6
+ import { type RuntimeBlockOptionArray } from '#blokkli-build/runtime-options';
7
+ export type DefinitionProvider = {
8
+ /**
9
+ * Get the block definition for a specific context.
10
+ *
11
+ * Checks for context-specific definitions in this order:
12
+ * 1. Field list type specific (e.g., bundle__field:canvas)
13
+ * 2. Parent bundle specific (e.g., bundle__parent:accordion)
14
+ * 3. Default bundle definition
15
+ *
16
+ * @param bundle - The block bundle name
17
+ * @param fieldListType - The field list type context
18
+ * @param parentBundle - Optional parent block bundle for nested blocks
19
+ * @returns The block definition, or undefined if not found
20
+ */
21
+ getBlockDefinition: (bundle: string, fieldListType: ValidFieldListTypes, parentBundle?: BlockBundleWithNested | null) => BlockDefinition | undefined;
22
+ /**
23
+ * Get the default block definition for a bundle.
24
+ *
25
+ * Returns the base definition without considering context (field list type or parent).
26
+ *
27
+ * @param bundle - The block bundle name
28
+ * @returns The default block definition, or undefined if not found
29
+ */
30
+ getDefaultDefinition: (bundle: string) => BlockDefinition | undefined;
31
+ /**
32
+ * Get a fragment definition by name.
33
+ *
34
+ * @param name - The fragment name
35
+ * @returns The fragment definition, or undefined if not found
36
+ */
37
+ getFragmentDefinition: (name: string) => FragmentDefinition | undefined;
38
+ /**
39
+ * Get a provider definition for an entity type and bundle.
40
+ *
41
+ * @param entityType - The entity type (e.g., 'node', 'block_content')
42
+ * @param entityBundle - The entity bundle (e.g., 'article', 'page')
43
+ * @returns The provider definition, or undefined if not found
44
+ */
45
+ getProviderDefinition: (entityType: string, entityBundle: string) => ProviderDefinition | undefined;
46
+ /**
47
+ * Get the icon name for a block bundle.
48
+ *
49
+ * @param bundle - The block bundle name
50
+ * @returns The icon name, or undefined if no icon is defined
51
+ */
52
+ getBlockIcon: (bundle: string) => string | undefined;
53
+ /**
54
+ * List of all registered fragment definitions.
55
+ *
56
+ * Updates automatically via HMR during development.
57
+ */
58
+ fragmentDefinitions: ComputedRef<FragmentDefinition[]>;
59
+ /**
60
+ * List of all registered block definitions.
61
+ *
62
+ * Updates automatically via HMR during development.
63
+ */
64
+ blockDefinitions: ComputedRef<BlockDefinition[]>;
65
+ /**
66
+ * Global options that apply to all blocks.
67
+ */
68
+ globalOptions: DeepReadonly<Ref<BlockDefinitionOptionsInput>>;
69
+ /**
70
+ * Runtime option values for all blocks.
71
+ *
72
+ * Maps block UUIDs to their option values. Structure:
73
+ * - First level: block UUID
74
+ * - Second level: option key → option value array
75
+ *
76
+ * Updates automatically via HMR during development.
77
+ */
78
+ runtimeOptions: DeepReadonly<Ref<Record<string, Record<string, RuntimeBlockOptionArray>>>>;
79
+ /**
80
+ * Render key that changes when definitions are updated.
81
+ *
82
+ * Use as a component key to force remounting when definitions change.
83
+ * Automatically increments via HMR during development.
84
+ */
85
+ renderKey: DeepReadonly<Ref<string>>;
86
+ };
87
+ export default function (): DefinitionProvider;
@@ -1,7 +1,7 @@
1
1
  import type { BlokkliDirectiveType, EntityContext, Rectangle } from '#blokkli/types';
2
- import type { UiProvider } from './../uiProvider.js';
2
+ import type { UiProvider } from './ui.js';
3
3
  import { type ComputedRef } from '#imports';
4
- import type { DebugProvider } from '../debugProvider.js';
4
+ import type { DebugProvider } from './debug.js';
5
5
  type EditableFieldData = EntityContext & {
6
6
  key: string;
7
7
  fieldName: string;
@@ -13,16 +13,102 @@ type DroppableFieldElementData = EditableFieldData & {
13
13
  element: HTMLElement;
14
14
  };
15
15
  export type DirectiveProvider = {
16
+ /**
17
+ * Initialize the directive provider.
18
+ *
19
+ * Starts the IntersectionObserver to track directive element visibility and positions.
20
+ */
16
21
  init: () => void;
22
+ /**
23
+ * Register a directive element for tracking.
24
+ *
25
+ * Starts observing the element with IntersectionObserver to track visibility and position.
26
+ * For 'editable' directives on blocks, also indexes by UUID for quick lookup.
27
+ *
28
+ * @param el - The HTML element with the directive
29
+ * @param fieldName - The field name
30
+ * @param entity - The entity context (type, bundle, UUID)
31
+ * @param type - The directive type ('editable' or 'droppable')
32
+ * @param isComponent - Whether this is a component-based field
33
+ * @param getValue - Optional function to get the current field value
34
+ */
17
35
  registerDirectiveElement: (el: HTMLElement, fieldName: string, entity: EntityContext, type: BlokkliDirectiveType, isComponent: boolean, getValue?: () => string) => void;
36
+ /**
37
+ * Unregister a directive element from tracking.
38
+ *
39
+ * Stops observing the element and removes it from all tracking maps.
40
+ *
41
+ * @param el - The HTML element to unregister
42
+ * @param fieldName - The field name
43
+ * @param entity - The entity context
44
+ * @param type - The directive type
45
+ */
18
46
  unregisterDirectiveElement: (el: HTMLElement, fieldName: string, entity: EntityContext, type: BlokkliDirectiveType) => void;
47
+ /**
48
+ * Get rectangles for all visible directives of a specific type.
49
+ *
50
+ * Only includes directives currently in the viewport.
51
+ *
52
+ * @param directiveType - The directive type to filter by
53
+ * @returns Array of rectangles for visible directives
54
+ */
19
55
  getVisible: (directiveType: BlokkliDirectiveType) => Rectangle[];
56
+ /**
57
+ * Find the editable field at a specific screen coordinate.
58
+ *
59
+ * Converts screen coordinates to artboard space and checks if any visible
60
+ * editable field contains the point.
61
+ *
62
+ * @param x - Screen X coordinate
63
+ * @param y - Screen Y coordinate
64
+ * @returns The editable field data at that point, or undefined
65
+ */
20
66
  getEditableAtPoint: (x: number, y: number) => EditableFieldData | undefined;
67
+ /**
68
+ * Get all editable fields for a specific block.
69
+ *
70
+ * Only returns 'editable' type directives on block entities.
71
+ *
72
+ * @param uuid - The block UUID
73
+ * @returns Array of editable fields for the block
74
+ */
21
75
  getEditablesForBlock: (uuid: string) => EditableFieldData[];
76
+ /**
77
+ * Get all droppable field elements.
78
+ *
79
+ * Returns fields with the 'droppable' directive type along with their HTML elements.
80
+ *
81
+ * @returns Array of droppable field data with elements
82
+ */
22
83
  getDroppableElements: () => DroppableFieldElementData[];
84
+ /**
85
+ * Find the HTML element for an editable field.
86
+ *
87
+ * @param fieldName - The field name
88
+ * @param host - The host entity context
89
+ * @returns The field's HTML element, or undefined if not found
90
+ */
23
91
  findEditableElement: (fieldName: string, host: EntityContext) => HTMLElement | undefined;
92
+ /**
93
+ * Find the editable field data.
94
+ *
95
+ * @param fieldName - The field name
96
+ * @param host - The host entity context
97
+ * @returns The editable field data, or undefined if not found
98
+ */
24
99
  findEditable: (fieldName: string, host: EntityContext) => EditableFieldData | undefined;
100
+ /**
101
+ * Whether the directive provider is ready.
102
+ *
103
+ * Ready when IntersectionObserver is initialized and initial measurements are complete.
104
+ */
25
105
  isReady: ComputedRef<boolean>;
106
+ /**
107
+ * Settlement key that increments after directive changes settle.
108
+ *
109
+ * Useful for triggering reactivity after directives are registered/unregistered.
110
+ */
111
+ settleKey: ComputedRef<number>;
26
112
  };
27
113
  export default function (debug: DebugProvider, ui: UiProvider): DirectiveProvider;
28
114
  export {};
@@ -1,6 +1,11 @@
1
1
  import { falsy } from "#blokkli/helpers";
2
2
  import useDelayedIntersectionObserver from "./../composables/useDelayedIntersectionObserver.js";
3
- import { computed, onBeforeUnmount, ref } from "#imports";
3
+ import {
4
+ computed,
5
+ onBeforeUnmount,
6
+ onMounted,
7
+ ref
8
+ } from "#imports";
4
9
  import onBlokkliEvent from "./../composables/onBlokkliEvent.js";
5
10
  import { itemEntityType } from "#blokkli-build/config";
6
11
  export default function(debug, ui) {
@@ -14,6 +19,8 @@ export default function(debug, ui) {
14
19
  const rects = {};
15
20
  const visible = /* @__PURE__ */ new Set();
16
21
  const editablesByUuid = {};
22
+ let settleTimeout = null;
23
+ const settleKey = ref(0);
17
24
  function doInitTimeout() {
18
25
  if (initTimeout) {
19
26
  window.clearTimeout(initTimeout);
@@ -24,6 +31,14 @@ export default function(debug, ui) {
24
31
  }, 500);
25
32
  }
26
33
  }
34
+ function doSettleTimeout() {
35
+ if (settleTimeout) {
36
+ window.clearTimeout(settleTimeout);
37
+ }
38
+ settleTimeout = window.setTimeout(() => {
39
+ settleKey.value++;
40
+ }, 50);
41
+ }
27
42
  function getVisible(directiveType) {
28
43
  return [...visible.keys()].map((key) => {
29
44
  if (key.startsWith(directiveType)) {
@@ -91,6 +106,7 @@ export default function(debug, ui) {
91
106
  }
92
107
  logger.log("Registered directive element", data);
93
108
  doInitTimeout();
109
+ doSettleTimeout();
94
110
  }
95
111
  function unregisterDirectiveElement(el, fieldName, entity, directiveType) {
96
112
  const key = getEditableKey(fieldName, entity, directiveType);
@@ -106,6 +122,7 @@ export default function(debug, ui) {
106
122
  editablesByUuid[entity.uuid][fieldName] = void 0;
107
123
  }
108
124
  }
125
+ doSettleTimeout();
109
126
  }
110
127
  function init() {
111
128
  intersectionObserver.init();
@@ -192,9 +209,15 @@ export default function(debug, ui) {
192
209
  const key = getEditableKey(fieldName, host, "editable");
193
210
  return fieldData.get(key);
194
211
  }
195
- onBlokkliEvent("state:reloaded", handleRefresh);
212
+ onBlokkliEvent("state:reloaded", () => {
213
+ handleRefresh();
214
+ doSettleTimeout();
215
+ });
196
216
  onBlokkliEvent("ui:resized", handleRefresh);
197
217
  onBlokkliEvent("option:finish-change", handleRefresh);
218
+ onMounted(() => {
219
+ doInitTimeout();
220
+ });
198
221
  onBeforeUnmount(() => {
199
222
  if (stateReloadTimeout) {
200
223
  window.clearTimeout(stateReloadTimeout);
@@ -210,6 +233,7 @@ export default function(debug, ui) {
210
233
  getEditablesForBlock,
211
234
  findEditableElement,
212
235
  getDroppableElements,
213
- isReady: computed(() => !isInitalizing.value)
236
+ isReady: computed(() => !isInitalizing.value),
237
+ settleKey: computed(() => settleKey.value)
214
238
  };
215
239
  }
@@ -0,0 +1,225 @@
1
+ import { type ComputedRef } from '#imports';
2
+ import type { DraggableExistingBlock, DraggableItem, EntityContext, Rectangle, RenderedFieldListItem, RegisteredField, RegisterFieldData } from '#blokkli/types';
3
+ import type { UiProvider } from './ui.js';
4
+ import type { DebugProvider } from './debug.js';
5
+ import type { StateProvider } from './state.js';
6
+ import type { ElementProvider } from './element.js';
7
+ type RegisteredFieldType = {
8
+ entityType: string;
9
+ entityBundle: string;
10
+ fieldName: string;
11
+ };
12
+ type MeasuredBlockRect = Rectangle & {
13
+ time: number;
14
+ };
15
+ export type DomProvider = {
16
+ /**
17
+ * Get the bounding client rect for an element.
18
+ *
19
+ * Wrapper around `getBoundingClientRect()` with debug logging.
20
+ */
21
+ getBoundingClientRect: (element: HTMLElement) => DOMRect;
22
+ /**
23
+ * Return the droppable markup for a draggable item.
24
+ */
25
+ getDropElementMarkup(item: DraggableItem | RenderedFieldListItem, checkSize?: boolean): string;
26
+ /**
27
+ * Register a block element for observation and tracking.
28
+ *
29
+ * Starts observing the element with IntersectionObserver and ResizeObserver
30
+ * to track visibility and dimensions.
31
+ *
32
+ * @param key - Unique key identifying the block's location (field + index)
33
+ * @param uuid - The block's UUID
34
+ * @param el - The block's root HTML element
35
+ */
36
+ registerBlock: (key: string, uuid: string, el: HTMLElement | null) => void;
37
+ /**
38
+ * Unregister a block element from observation.
39
+ *
40
+ * Stops observing the element and removes it from tracking.
41
+ *
42
+ * @param key - Unique key identifying the block's location
43
+ * @param uuid - The block's UUID
44
+ */
45
+ unregisterBlock: (key: string, uuid: string) => void;
46
+ /**
47
+ * Register a field element for observation.
48
+ *
49
+ * Starts observing the field element with IntersectionObserver to track
50
+ * visibility and position.
51
+ *
52
+ * @param entity - The entity context (UUID, type, bundle)
53
+ * @param fieldName - The field's machine name
54
+ * @param instance - The field's HTML element
55
+ * @param data - Additional field registration data
56
+ */
57
+ registerField: (entity: EntityContext, fieldName: string, instance: HTMLElement, data: RegisterFieldData) => void;
58
+ /**
59
+ * Update the element reference for an already registered field.
60
+ *
61
+ * Stops observing the old element and starts observing the new one.
62
+ *
63
+ * @param entity - The entity context
64
+ * @param fieldName - The field's machine name
65
+ * @param element - The new field HTML element
66
+ * @param data - Additional field registration data
67
+ */
68
+ updateFieldElement: (entity: EntityContext, fieldName: string, element: HTMLElement, data: RegisterFieldData) => void;
69
+ /**
70
+ * Unregister a field element from observation.
71
+ *
72
+ * @param entity - The entity context
73
+ * @param fieldName - The field's machine name
74
+ */
75
+ unregisterField: (entity: EntityContext, fieldName: string) => void;
76
+ /**
77
+ * Get a registered field by entity UUID and field name.
78
+ *
79
+ * @param uuid - The entity UUID
80
+ * @param fieldName - The field's machine name
81
+ * @returns The registered field data, or undefined if not found
82
+ */
83
+ getRegisteredField: (uuid: string, fieldName: string) => RegisteredField | undefined;
84
+ /**
85
+ * List of unique field types currently registered.
86
+ *
87
+ * Returns unique combinations of entity type, bundle, and field name.
88
+ */
89
+ registeredFieldTypes: ComputedRef<RegisteredFieldType[]>;
90
+ /**
91
+ * List of UUIDs for all blocks with registered elements.
92
+ *
93
+ * Only includes blocks that have a valid HTML element reference.
94
+ */
95
+ registeredBlockUuids: ComputedRef<string[]>;
96
+ /**
97
+ * Get UUIDs of all currently visible blocks.
98
+ *
99
+ * @returns Array of block UUIDs that are currently in the viewport
100
+ */
101
+ getVisibleBlocks(): string[];
102
+ /**
103
+ * Get keys of all currently visible fields.
104
+ *
105
+ * @returns Array of field keys (uuid:fieldName) that are currently in the viewport
106
+ */
107
+ getVisibleFields(): string[];
108
+ /**
109
+ * Check if a block is currently visible in the viewport.
110
+ *
111
+ * @param uuid - The block's UUID
112
+ * @returns True if the block is visible
113
+ */
114
+ isBlockVisible(uuid: string): boolean;
115
+ /**
116
+ * Get rectangles for all registered blocks.
117
+ *
118
+ * @returns Record mapping UUIDs to their measured rectangles with timestamps
119
+ */
120
+ getBlockRects: () => Record<string, MeasuredBlockRect>;
121
+ /**
122
+ * Get the rectangle for a specific block.
123
+ *
124
+ * @param uuid - The block's UUID
125
+ * @param refresh - Whether to refresh the rect before returning
126
+ * @returns The block's rectangle, or undefined if not found
127
+ */
128
+ getBlockRect: (uuid: string, refresh?: boolean) => MeasuredBlockRect | undefined;
129
+ /**
130
+ * Refresh the cached rectangle for a specific block.
131
+ *
132
+ * Recalculates the block's position and dimensions immediately.
133
+ *
134
+ * @param uuid - The block's UUID
135
+ */
136
+ refreshBlockRect: (uuid: string) => void;
137
+ /**
138
+ * Get the rectangle for a specific field.
139
+ *
140
+ * @param key - The field key (uuid:fieldName)
141
+ * @returns The field's rectangle, or undefined if not found
142
+ */
143
+ getFieldRect: (key: string) => Rectangle | undefined;
144
+ /**
145
+ * Record of all registered block elements.
146
+ *
147
+ * Maps UUIDs to their corresponding HTML elements.
148
+ */
149
+ registeredBlocks: ComputedRef<Record<string, HTMLElement | undefined>>;
150
+ /**
151
+ * Update rectangles for all visible blocks and fields.
152
+ *
153
+ * Recalculates positions and dimensions for currently visible items.
154
+ * For performance, only updates visible items when there are many blocks.
155
+ */
156
+ updateVisibleRects: () => void;
157
+ /**
158
+ * Whether the DOM provider is ready.
159
+ *
160
+ * Ready when IntersectionObserver is initialized and initial measurements are complete.
161
+ */
162
+ isReady: ComputedRef<boolean>;
163
+ /**
164
+ * Settlement key that increments after DOM changes settle.
165
+ *
166
+ * Useful for triggering reactivity after blocks/fields are registered/unregistered.
167
+ */
168
+ settleKey: ComputedRef<number>;
169
+ /**
170
+ * Initialize the DOM provider.
171
+ *
172
+ * Starts the IntersectionObserver and marks the provider as ready.
173
+ */
174
+ init: () => void;
175
+ /**
176
+ * Get the drag element for a block.
177
+ */
178
+ getDragElement: (block: DraggableExistingBlock | RenderedFieldListItem) => HTMLElement | undefined;
179
+ /**
180
+ * Get debug data for troubleshooting.
181
+ */
182
+ getDebugData: () => {
183
+ registeredBlocks: Array<{
184
+ uuid: string;
185
+ hasElement: boolean;
186
+ hasObservedElement: boolean;
187
+ hasRect: boolean;
188
+ hasCurrentKey: boolean;
189
+ isVisible: boolean;
190
+ elementInfo?: {
191
+ tagName: string;
192
+ bundle?: string;
193
+ hostBundle?: string;
194
+ fieldListType?: string;
195
+ };
196
+ }>;
197
+ fields: Array<{
198
+ key: string;
199
+ isVisible: boolean;
200
+ hasRect: boolean;
201
+ entityType: string;
202
+ entityBundle: string;
203
+ fieldName: string;
204
+ }>;
205
+ summary: {
206
+ totalRegisteredBlocks: number;
207
+ totalBlocksWithElements: number;
208
+ totalObservedElements: number;
209
+ totalBlockRects: number;
210
+ totalVisibleBlocks: number;
211
+ totalRegisteredFields: number;
212
+ totalVisibleFields: number;
213
+ totalFieldRects: number;
214
+ isInitializing: boolean;
215
+ isReady: boolean;
216
+ };
217
+ orphanedData: {
218
+ rectsWithoutRegistration: string[];
219
+ observedElementsWithoutRegistration: string[];
220
+ keysWithoutRegistration: string[];
221
+ };
222
+ };
223
+ };
224
+ export default function (ui: UiProvider, debug: DebugProvider, state: StateProvider, element: ElementProvider): DomProvider;
225
+ export {};