@blokkli/editor 2.0.0-alpha.4 → 2.0.0-alpha.7

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 (39) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +5 -2
  3. package/dist/runtime/blokkliPlugins/ContextMenu/index.vue.d.ts +2 -19
  4. package/dist/runtime/blokkliPlugins/DebugOverlay/index.vue.d.ts +2 -7
  5. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue.d.ts +2 -19
  6. package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +4 -3
  7. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +1 -1
  8. package/dist/runtime/blokkliPlugins/MenuButton/index.vue.d.ts +1 -1
  9. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue.d.ts +2 -51
  10. package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +11 -5
  11. package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue.d.ts +1 -1
  12. package/dist/runtime/blokkliPlugins/TourItem/index.vue.d.ts +2 -4
  13. package/dist/runtime/blokkliPlugins/ViewOption/index.vue.d.ts +4 -3
  14. package/dist/runtime/components/BlokkliItem.vue +4 -1
  15. package/dist/runtime/components/Edit/Actions/index.vue +4 -1
  16. package/dist/runtime/components/Edit/BlockProxy/index.vue +3 -1
  17. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue.d.ts +2 -13
  18. package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +1 -1
  19. package/dist/runtime/components/Edit/EditProvider.vue +3 -1
  20. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue.d.ts +3 -132
  21. package/dist/runtime/components/Edit/Features/Options/Form/Group.vue.d.ts +2 -11
  22. package/dist/runtime/components/Edit/Features/ResponsivePreview/Frame/index.vue.d.ts +2 -13
  23. package/dist/runtime/components/Edit/Form/Group/index.vue.d.ts +2 -4
  24. package/dist/runtime/components/Edit/Form/Item/index.vue.d.ts +2 -4
  25. package/dist/runtime/components/Edit/FormOverlay/index.vue.d.ts +3 -2
  26. package/dist/runtime/components/Edit/RelativeTime/index.vue.d.ts +2 -2
  27. package/dist/runtime/components/Edit/Resizable/index.vue.d.ts +1 -1
  28. package/dist/runtime/components/Edit/ScaleToFit/index.vue.d.ts +1 -1
  29. package/dist/runtime/components/Edit/ScrollBoundary/index.vue.d.ts +2 -7
  30. package/dist/runtime/components/Edit/Sortli/index.vue.d.ts +1 -1
  31. package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue.d.ts +2 -7
  32. package/dist/runtime/composables/defineBlokkli.js +3 -0
  33. package/dist/runtime/composables/defineBlokkliFragment.js +8 -1
  34. package/dist/runtime/helpers/composables/useBlockRegistration.d.ts +5 -0
  35. package/dist/runtime/helpers/composables/useBlockRegistration.js +23 -0
  36. package/dist/runtime/helpers/domProvider.d.ts +2 -0
  37. package/dist/runtime/helpers/domProvider.js +50 -65
  38. package/dist/runtime/types/index.d.ts +1 -0
  39. package/package.json +4 -4
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "blokkli",
3
3
  "configKey": "blokkli",
4
- "version": "2.0.0-alpha.4",
4
+ "version": "2.0.0-alpha.7",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.15.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -13,7 +13,7 @@ import { BK_VISIBLE_LANGUAGES, BK_HIDDEN_GLOBALLY } from '../dist/runtime/helper
13
13
  import fs from 'node:fs';
14
14
  import { defu, createDefu } from 'defu';
15
15
 
16
- const version = "2.0.0-alpha.4";
16
+ const version = "2.0.0-alpha.7";
17
17
 
18
18
  function sortObjectKeys(obj) {
19
19
  if (Array.isArray(obj)) {
@@ -6345,6 +6345,9 @@ declare const adapter: BlokkliAdapterFactory<any>
6345
6345
 
6346
6346
  export default adapter
6347
6347
  `;
6348
+ },
6349
+ {
6350
+ write: true
6348
6351
  }
6349
6352
  );
6350
6353
 
@@ -6353,7 +6356,7 @@ const styles = defineFileTemplate("styles.css", (ctx) => {
6353
6356
  "./runtime/css/output.css"
6354
6357
  );
6355
6358
  return `
6356
- @import url("${relative(ctx.helper.paths.blokkliBuildDir, cssFilePath)}");
6359
+ @import url("${cssFilePath}");
6357
6360
 
6358
6361
  ${ctx.theme.css}
6359
6362
  `;
@@ -1,30 +1,13 @@
1
1
  import type { ContextMenu } from '#blokkli/types';
2
- import ContextMenuMenu from './Menu/index.vue.js';
3
2
  type __VLS_Props = {
4
3
  id: string;
5
4
  menu: ContextMenu[];
6
5
  tag?: string;
7
6
  };
8
- declare const ui: import("../../helpers/uiProvider.js").UiProvider;
9
- declare const isVisible: import("vue").ComputedRef<boolean>;
10
- declare const x: import("vue").Ref<number, number>;
11
- declare const y: import("vue").Ref<number, number>;
12
- declare const onContextMenu: (e: MouseEvent) => void;
13
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
14
7
  declare var __VLS_10: {};
15
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
8
+ type __VLS_Slots = {} & {
16
9
  default?: (props: typeof __VLS_10) => any;
17
- }>;
18
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
19
- ContextMenuMenu: typeof ContextMenuMenu;
20
- ui: typeof ui;
21
- isVisible: typeof isVisible;
22
- x: typeof x;
23
- y: typeof y;
24
- onContextMenu: typeof onContextMenu;
25
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
26
- tag: string;
27
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ };
28
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
29
12
  tag: string;
30
13
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -2,15 +2,10 @@ type __VLS_Props = {
2
2
  id: string;
3
3
  title: string;
4
4
  };
5
- declare const isVisible: import("vue").ComputedRef<boolean | undefined>;
6
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
7
5
  declare var __VLS_5: {};
8
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
6
+ type __VLS_Slots = {} & {
9
7
  default?: (props: typeof __VLS_5) => any;
10
- }>;
11
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
12
- isVisible: typeof isVisible;
13
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ };
14
9
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
10
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
16
11
  export default _default;
@@ -1,4 +1,3 @@
1
- import { FormOverlay } from '#blokkli/components';
2
1
  import type { BlokkliIcon } from '#blokkli-build/icons';
3
2
  import type { DroppableEntityField } from '#blokkli/types';
4
3
  type __VLS_Props = {
@@ -7,26 +6,10 @@ type __VLS_Props = {
7
6
  icon: BlokkliIcon;
8
7
  entityType: string;
9
8
  };
10
- declare const $t: import("../../helpers/textProvider.js").TextProvider;
11
- declare const isVisible: import("vue").Ref<boolean, boolean>;
12
- declare const onClose: () => void;
13
- declare const onSubmit: () => void;
14
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
15
9
  declare var __VLS_18: {};
16
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
10
+ type __VLS_Slots = {} & {
17
11
  default?: (props: typeof __VLS_18) => any;
18
- }>;
19
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
20
- FormOverlay: typeof FormOverlay;
21
- $t: typeof $t;
22
- isVisible: typeof isVisible;
23
- onClose: typeof onClose;
24
- onSubmit: typeof onSubmit;
25
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
26
- save: (data: DroppableEntityField) => any;
27
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
28
- onSave?: ((data: DroppableEntityField) => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
12
+ };
30
13
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
31
14
  save: (data: DroppableEntityField) => any;
32
15
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
@@ -69,11 +69,12 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
69
69
  }> & Readonly<{
70
70
  onClick?: ((items: DraggableExistingBlock[]) => any) | undefined;
71
71
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
72
- icon?: ((props: {}) => any) | undefined;
73
- default?: ((props: {
72
+ icon?: (props: {}) => any;
73
+ } & {
74
+ default?: (props: {
74
75
  items: DraggableExistingBlock[];
75
76
  uuids: string[];
76
- }) => any) | undefined;
77
+ }) => any;
77
78
  }>;
78
79
  export default _default;
79
80
  type __VLS_WithSlots<T, S> = T & {
@@ -7,7 +7,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
7
7
  title: string;
8
8
  enabled: boolean;
9
9
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
10
- default?: ((props: {}) => any) | undefined;
10
+ default?: (props: {}) => any;
11
11
  }>;
12
12
  export default _default;
13
13
  type __VLS_WithSlots<T, S> = T & {
@@ -22,7 +22,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
22
22
  }> & Readonly<{
23
23
  onClick?: ((...args: any[]) => any) | undefined;
24
24
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
25
- default?: ((props: {}) => any) | undefined;
25
+ default?: (props: {}) => any;
26
26
  }>;
27
27
  export default _default;
28
28
  type __VLS_WithSlots<T, S> = T & {
@@ -1,4 +1,3 @@
1
- import { Icon, ViewportBlockingRect, ScrollBoundary } from '#blokkli/components';
2
1
  import type { BlokkliIcon } from '#blokkli-build/icons';
3
2
  type __VLS_Props = {
4
3
  id: string;
@@ -12,64 +11,16 @@ type __VLS_Props = {
12
11
  };
13
12
  isLeft?: boolean;
14
13
  };
15
- declare function onPointerMove(e: PointerEvent): void;
16
- declare const isMinimized: import("vue").WritableComputedRef<boolean, boolean>;
17
- declare const storageKey: import("vue").ComputedRef<string>;
18
- declare const focusedSidebar: import("vue").WritableComputedRef<string, string>;
19
- type MouseMode = 'move' | 'resize-right' | 'resize-bottom' | 'resize-bottom-right' | '';
20
- declare const isResizing: import("vue").ComputedRef<boolean>;
21
- declare const userWidth: import("vue").Ref<number, number>;
22
- declare const userHeight: import("vue").Ref<number, number>;
23
- declare const style: import("vue").ComputedRef<{
24
- transform: string;
25
- zIndex: number;
26
- }>;
27
- declare const innerStyle: import("vue").ComputedRef<{
28
- width: string;
29
- height: string | number;
30
- }>;
31
- declare const onFocus: () => void;
32
- declare const onMouseDown: (e: MouseEvent, mode: MouseMode) => void;
33
- declare const el: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
34
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
35
14
  declare var __VLS_16: {}, __VLS_30: {
36
15
  width: number;
37
16
  height: number;
38
17
  isResizing: boolean;
39
18
  };
40
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
19
+ type __VLS_Slots = {} & {
41
20
  icon?: (props: typeof __VLS_16) => any;
42
21
  } & {
43
22
  default?: (props: typeof __VLS_30) => any;
44
- }>;
45
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
46
- Icon: typeof Icon;
47
- ViewportBlockingRect: typeof ViewportBlockingRect;
48
- ScrollBoundary: typeof ScrollBoundary;
49
- onPointerMove: typeof onPointerMove;
50
- isMinimized: typeof isMinimized;
51
- storageKey: typeof storageKey;
52
- focusedSidebar: typeof focusedSidebar;
53
- isResizing: typeof isResizing;
54
- userWidth: typeof userWidth;
55
- userHeight: typeof userHeight;
56
- style: typeof style;
57
- innerStyle: typeof innerStyle;
58
- onFocus: typeof onFocus;
59
- onMouseDown: typeof onMouseDown;
60
- el: typeof el;
61
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
62
- close: (...args: any[]) => void;
63
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
64
- onClose?: ((...args: any[]) => any) | undefined;
65
- }>, {
66
- size: {
67
- width: number;
68
- height: number;
69
- };
70
- minWidth: number;
71
- minHeight: number;
72
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ };
73
24
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
74
25
  close: (...args: any[]) => void;
75
26
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
@@ -57,9 +57,13 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
57
57
  minHeight: number;
58
58
  region: "left" | "right";
59
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
60
- icon?: (((props: {}) => any) & ((props: {}) => any)) | undefined;
61
- badge?: ((props: {}) => any) | undefined;
62
- default?: (((props: {
60
+ icon?: (props: {}) => any;
61
+ } & {
62
+ badge?: (props: {}) => any;
63
+ } & {
64
+ icon?: (props: {}) => any;
65
+ } & {
66
+ default?: (props: {
63
67
  key: string;
64
68
  scrolledToEnd: boolean;
65
69
  isDetached: true;
@@ -67,7 +71,9 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
67
71
  height: number;
68
72
  toggleSidebar: () => void;
69
73
  isResizing: boolean;
70
- }) => any) & ((props: {
74
+ }) => any;
75
+ } & {
76
+ default?: (props: {
71
77
  key: string;
72
78
  scrolledToEnd: boolean;
73
79
  isDetached: false;
@@ -75,7 +81,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
75
81
  height: undefined;
76
82
  toggleSidebar: () => void;
77
83
  isResizing: boolean;
78
- }) => any)) | undefined;
84
+ }) => any;
79
85
  }>;
80
86
  export default _default;
81
87
  type __VLS_WithSlots<T, S> = T & {
@@ -38,7 +38,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
38
38
  }> & Readonly<{
39
39
  onClick?: ((...args: any[]) => any) | undefined;
40
40
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
41
- default?: ((props: {}) => any) | undefined;
41
+ default?: (props: {}) => any;
42
42
  }>;
43
43
  export default _default;
44
44
  type __VLS_WithSlots<T, S> = T & {
@@ -4,12 +4,10 @@ type __VLS_Props = {
4
4
  text: string;
5
5
  selector?: string;
6
6
  };
7
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
8
7
  declare var __VLS_1: {};
9
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
8
+ type __VLS_Slots = {} & {
10
9
  default?: (props: typeof __VLS_1) => any;
11
- }>;
12
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ };
13
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
12
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
15
13
  export default _default;
@@ -26,10 +26,11 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
26
26
  }> & Readonly<{
27
27
  "onUpdate:modelValue"?: ((data: boolean) => any) | undefined;
28
28
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
29
- icon?: ((props: {}) => any) | undefined;
30
- default?: ((props: {
29
+ icon?: (props: {}) => any;
30
+ } & {
31
+ default?: (props: {
31
32
  isActive: boolean;
32
- }) => any) | undefined;
33
+ }) => any;
33
34
  }>;
34
35
  export default _default;
35
36
  type __VLS_WithSlots<T, S> = T & {
@@ -23,7 +23,9 @@ import {
23
23
  provide,
24
24
  useRuntimeConfig,
25
25
  inject,
26
- defineAsyncComponent
26
+ defineAsyncComponent,
27
+ getCurrentInstance,
28
+ onMounted
27
29
  } from "#imports";
28
30
  import { getComponent } from "#blokkli/helpers/imports";
29
31
  import {
@@ -45,6 +47,7 @@ const componentProps = defineProps({
45
47
  parentType: { type: String, required: false, default: "" },
46
48
  isEditing: { type: Boolean, required: false, default: false }
47
49
  });
50
+ const instance = componentProps.isEditing ? getCurrentInstance() : null;
48
51
  const isProxyMode = inject(INJECT_FIELD_PROXY_MODE, false);
49
52
  const fieldUsesProxy = inject(INJECT_FIELD_USES_PROXY, false);
50
53
  const isGlobalProxyMode = inject(
@@ -75,7 +75,7 @@ import {
75
75
  import { onlyUnique, findIdealRectPosition, falsy } from "#blokkli/helpers";
76
76
  import { ItemIcon, Icon } from "#blokkli/components";
77
77
  import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
78
- const { selection, $t, types, state, ui, dom, definitions } = useBlokkli();
78
+ const { selection, $t, types, state, ui, dom, definitions, debug } = useBlokkli();
79
79
  const editingEnabled = computed(
80
80
  () => state.editMode.value === "editing" || state.editMode.value === "translating"
81
81
  );
@@ -100,6 +100,9 @@ const title = computed(() => {
100
100
  if (ui.transformLabel.value) {
101
101
  return ui.transformLabel.value;
102
102
  }
103
+ if (debug.isEnabled.value && selection.uuids.value.length === 1) {
104
+ return selection.uuids.value[0];
105
+ }
103
106
  if (itemBundle.value) {
104
107
  if (itemBundle.value.id === "blokkli_fragment") {
105
108
  const fragments = selection.uuids.value.map((uuid) => {
@@ -34,6 +34,7 @@ import { computed, useBlokkli, ref } from "#imports";
34
34
  import { getBlokkliItemProxyComponent } from "#blokkli/helpers/editComponents";
35
35
  import { ItemIcon } from "#blokkli/components";
36
36
  import { buildAttributesForLibraryItem, falsy } from "#blokkli/helpers";
37
+ import { useBlockRegistration } from "#blokkli/helpers/composables/useBlockRegistration";
37
38
  const props = defineProps({
38
39
  uuid: { type: String, required: true },
39
40
  bundle: { type: String, required: true },
@@ -63,7 +64,7 @@ const rootProps = computed(() => {
63
64
  const proxyBundle = computed(
64
65
  () => libraryItemProps.value?.block?.bundle || props.bundle
65
66
  );
66
- const { types, runtimeConfig, definitions } = useBlokkli();
67
+ const { types, runtimeConfig, definitions, dom } = useBlokkli();
67
68
  const root = ref(null);
68
69
  const type = computed(() => types.getBlockBundleDefinition(proxyBundle.value));
69
70
  const proxyComponent = getBlokkliItemProxyComponent(proxyBundle.value);
@@ -89,4 +90,5 @@ const fieldLayout = computed(() => {
89
90
  }
90
91
  return types.fieldConfig.forEntityTypeAndBundle(runtimeConfig.itemEntityType, proxyBundle.value).map((config) => [config]);
91
92
  });
93
+ useBlockRegistration(dom, props.uuid);
92
94
  </script>
@@ -1,18 +1,7 @@
1
- import { Icon } from '#blokkli/components';
2
- declare const errors: import("vue").Ref<Error[], Error[]>;
3
- declare const $t: import("#blokkli/helpers/textProvider").TextProvider;
4
- declare const unique: import("vue").ComputedRef<Error[]>;
5
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
6
1
  declare var __VLS_1: {};
7
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
2
+ type __VLS_Slots = {} & {
8
3
  default?: (props: typeof __VLS_1) => any;
9
- }>;
10
- declare const __VLS_self: import("vue").DefineComponent<{}, {
11
- Icon: typeof Icon;
12
- errors: typeof errors;
13
- $t: typeof $t;
14
- unique: typeof unique;
15
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
4
+ };
16
5
  declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
6
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
7
  export default _default;
@@ -34,7 +34,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
34
34
  submitLabel: string;
35
35
  canSubmit: boolean;
36
36
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
37
- default?: ((props: {}) => any) | undefined;
37
+ default?: (props: {}) => any;
38
38
  }>;
39
39
  export default _default;
40
40
  type __VLS_WithSlots<T, S> = T & {
@@ -94,6 +94,7 @@ import {
94
94
  INJECT_GLOBAL_PROXY_MODE,
95
95
  INJECT_IS_EDITING
96
96
  } from "#blokkli/helpers/symbols";
97
+ import { useBlockRegistration } from "#blokkli/helpers/composables/useBlockRegistration";
97
98
  const props = defineProps({
98
99
  entity: { type: null, required: false, default: void 0 },
99
100
  entityType: { type: String, required: true },
@@ -184,7 +185,8 @@ provide(INJECT_EDIT_CONTEXT, {
184
185
  eventBus,
185
186
  mutatedOptions: state.mutatedOptions,
186
187
  dom,
187
- definitions
188
+ definitions,
189
+ useBlockRegistration
188
190
  });
189
191
  provide(INJECT_APP, {
190
192
  adapter,
@@ -1,4 +1,4 @@
1
- import type { DropTargetEvent, BlokkliFieldElement, DraggableItem, Rectangle } from '#blokkli/types';
1
+ import type { DropTargetEvent, DraggableItem, Rectangle } from '#blokkli/types';
2
2
  type __VLS_Props = {
3
3
  items: DraggableItem[];
4
4
  box: Rectangle;
@@ -6,142 +6,13 @@ type __VLS_Props = {
6
6
  mouseY: number;
7
7
  isTouch: boolean;
8
8
  };
9
- type Orientation = 'horizontal' | 'vertical';
10
- type FieldRectChild = Rectangle & {
11
- id: string;
12
- label: string;
13
- };
14
- type FieldRect = Rectangle & {
15
- key: string;
16
- field: BlokkliFieldElement;
17
- label: string;
18
- canAddChildren: boolean;
19
- emptyChild?: FieldRectChild;
20
- orientation: Orientation;
21
- gap: number;
22
- childrenElements: HTMLElement[];
23
- };
24
- type DrawnRect = Rectangle & {
25
- id: string;
26
- type: 'field' | 'drop-area' | 'active-area';
27
- label: string;
28
- color: string;
29
- colorAlpha: string;
30
- field?: FieldRect;
31
- index: number;
32
- };
33
- declare const active: import("vue").Ref<{
34
- width: number;
35
- height: number;
36
- x: number;
37
- y: number;
38
- id: string;
39
- type: "field" | "drop-area" | "active-area";
40
- label: string;
41
- color: string;
42
- colorAlpha: string;
43
- field?: {
44
- width: number;
45
- height: number;
46
- x: number;
47
- y: number;
48
- key: string;
49
- field: {
50
- key: string;
51
- name: string;
52
- label: string;
53
- isNested: boolean;
54
- nestingLevel: number;
55
- fieldListType: import("#blokkli-build/generated-types").ValidFieldListTypes;
56
- hostEntityType: string;
57
- hostEntityBundle: string;
58
- hostEntityUuid: string;
59
- allowedBundles: string[];
60
- allowedFragments: string[];
61
- cardinality: number;
62
- element: HTMLElement;
63
- dropAlignment?: "vertical" | "horizontal" | undefined;
64
- };
65
- label: string;
66
- canAddChildren: boolean;
67
- emptyChild?: {
68
- width: number;
69
- height: number;
70
- x: number;
71
- y: number;
72
- id: string;
73
- label: string;
74
- } | undefined;
75
- orientation: Orientation;
76
- gap: number;
77
- childrenElements: HTMLElement[];
78
- } | undefined;
79
- index: number;
80
- } | null, DrawnRect | {
81
- width: number;
82
- height: number;
83
- x: number;
84
- y: number;
85
- id: string;
86
- type: "field" | "drop-area" | "active-area";
87
- label: string;
88
- color: string;
89
- colorAlpha: string;
90
- field?: {
91
- width: number;
92
- height: number;
93
- x: number;
94
- y: number;
95
- key: string;
96
- field: {
97
- key: string;
98
- name: string;
99
- label: string;
100
- isNested: boolean;
101
- nestingLevel: number;
102
- fieldListType: import("#blokkli-build/generated-types").ValidFieldListTypes;
103
- hostEntityType: string;
104
- hostEntityBundle: string;
105
- hostEntityUuid: string;
106
- allowedBundles: string[];
107
- allowedFragments: string[];
108
- cardinality: number;
109
- element: HTMLElement;
110
- dropAlignment?: "vertical" | "horizontal" | undefined;
111
- };
112
- label: string;
113
- canAddChildren: boolean;
114
- emptyChild?: {
115
- width: number;
116
- height: number;
117
- x: number;
118
- y: number;
119
- id: string;
120
- label: string;
121
- } | undefined;
122
- orientation: Orientation;
123
- gap: number;
124
- childrenElements: HTMLElement[];
125
- } | undefined;
126
- index: number;
127
- } | null>;
128
- declare const activeColorHex: import("vue").ComputedRef<string>;
129
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
130
9
  declare var __VLS_5: {
131
10
  color: string;
132
11
  label: string | undefined;
133
12
  };
134
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
13
+ type __VLS_Slots = {} & {
135
14
  default?: (props: typeof __VLS_5) => any;
136
- }>;
137
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
138
- active: typeof active;
139
- activeColorHex: typeof activeColorHex;
140
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
141
- drop: (data: DropTargetEvent) => any;
142
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
143
- onDrop?: ((data: DropTargetEvent) => any) | undefined;
144
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
+ };
145
16
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
146
17
  drop: (data: DropTargetEvent) => any;
147
18
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
@@ -1,20 +1,11 @@
1
- import { Icon } from '#blokkli/components';
2
1
  type __VLS_Props = {
3
2
  label: string;
4
3
  isActive: boolean;
5
4
  };
6
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
7
5
  declare var __VLS_5: {};
8
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
6
+ type __VLS_Slots = {} & {
9
7
  default?: (props: typeof __VLS_5) => any;
10
- }>;
11
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
12
- Icon: typeof Icon;
13
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
14
- toggle: (...args: any[]) => void;
15
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
- onToggle?: ((...args: any[]) => any) | undefined;
17
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ };
18
9
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
10
  toggle: (...args: any[]) => void;
20
11
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
@@ -1,22 +1,11 @@
1
- import { Icon } from '#blokkli/components';
2
1
  type __VLS_Props = {
3
2
  detached?: boolean;
4
3
  isResizing?: boolean;
5
4
  };
6
- declare const isLoading: import("vue").Ref<boolean, boolean>;
7
- declare const iframe: import("vue").Ref<HTMLIFrameElement | null, HTMLIFrameElement | null>;
8
- declare const src: import("vue").ComputedRef<string>;
9
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
10
5
  declare var __VLS_5: {};
11
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
6
+ type __VLS_Slots = {} & {
12
7
  default?: (props: typeof __VLS_5) => any;
13
- }>;
14
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
15
- Icon: typeof Icon;
16
- isLoading: typeof isLoading;
17
- iframe: typeof iframe;
18
- src: typeof src;
19
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ };
20
9
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
10
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
22
11
  export default _default;
@@ -2,14 +2,12 @@ type __VLS_Props = {
2
2
  title?: string;
3
3
  horizontal?: boolean;
4
4
  };
5
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
6
5
  declare var __VLS_1: {}, __VLS_3: {};
7
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
6
+ type __VLS_Slots = {} & {
8
7
  addon?: (props: typeof __VLS_1) => any;
9
8
  } & {
10
9
  default?: (props: typeof __VLS_3) => any;
11
- }>;
12
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ };
13
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
12
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
15
13
  export default _default;
@@ -1,9 +1,7 @@
1
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
2
1
  declare var __VLS_1: {};
3
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
2
+ type __VLS_Slots = {} & {
4
3
  default?: (props: typeof __VLS_1) => any;
5
- }>;
6
- declare const __VLS_self: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
4
+ };
7
5
  declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
6
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
9
7
  export default _default;
@@ -14,8 +14,9 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
14
14
  }> & Readonly<{
15
15
  onClose?: (() => any) | undefined;
16
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
17
- default?: ((props: {}) => any) | undefined;
18
- footer?: ((props: {}) => any) | undefined;
17
+ default?: (props: {}) => any;
18
+ } & {
19
+ footer?: (props: {}) => any;
19
20
  }>;
20
21
  export default _default;
21
22
  type __VLS_WithSlots<T, S> = T & {
@@ -3,9 +3,9 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
3
3
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
4
4
  timestamp: number;
5
5
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
6
- default?: ((props: {
6
+ default?: (props: {
7
7
  formatted: string;
8
- }) => any) | undefined;
8
+ }) => any;
9
9
  }>;
10
10
  export default _default;
11
11
  type __VLS_WithSlots<T, S> = T & {
@@ -3,7 +3,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
3
3
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
4
4
  id: string;
5
5
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
6
- default?: ((props: {}) => any) | undefined;
6
+ default?: (props: {}) => any;
7
7
  }>;
8
8
  export default _default;
9
9
  type __VLS_WithSlots<T, S> = T & {
@@ -5,7 +5,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
5
5
  width?: number;
6
6
  maxHeight?: number;
7
7
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
8
- default?: ((props: {}) => any) | undefined;
8
+ default?: (props: {}) => any;
9
9
  }>;
10
10
  export default _default;
11
11
  type __VLS_WithSlots<T, S> = T & {
@@ -4,15 +4,10 @@ type __VLS_Props = {
4
4
  */
5
5
  dragging?: boolean;
6
6
  };
7
- declare function onWheel(e: WheelEvent): void;
8
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
9
7
  declare var __VLS_1: {};
10
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
8
+ type __VLS_Slots = {} & {
11
9
  default?: (props: typeof __VLS_1) => any;
12
- }>;
13
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
14
- onWheel: typeof onWheel;
15
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ };
16
11
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
12
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
18
13
  export default _default;
@@ -4,7 +4,7 @@ declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
4
4
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
5
5
  getDragItems?: (activeItem?: DraggableItem) => DraggableItem[] | null;
6
6
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
7
- default?: ((props: {}) => any) | undefined;
7
+ default?: (props: {}) => any;
8
8
  }>;
9
9
  export default _default;
10
10
  type __VLS_WithSlots<T, S> = T & {
@@ -1,15 +1,10 @@
1
1
  type __VLS_Props = {
2
2
  id: string;
3
3
  };
4
- declare const el: import("vue").Ref<HTMLDivElement | null, HTMLDivElement | null>;
5
- declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
6
4
  declare var __VLS_1: {};
7
- type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
5
+ type __VLS_Slots = {} & {
8
6
  default?: (props: typeof __VLS_1) => any;
9
- }>;
10
- declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
11
- el: typeof el;
12
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ };
13
8
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
9
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
15
10
  export default _default;
@@ -87,6 +87,9 @@ export function defineBlokkli(arg) {
87
87
  import.meta.hot.accept("#blokkli/helpers/runtimeHelpers", () => {
88
88
  });
89
89
  }
90
+ if (editContext?.useBlockRegistration && editContext.dom && bundle !== "from_library" && bundle !== "blokkli_fragment") {
91
+ editContext.useBlockRegistration(editContext.dom, uuid);
92
+ }
90
93
  return {
91
94
  uuid,
92
95
  index,
@@ -1,4 +1,7 @@
1
- import { INJECT_FRAGMENT_CONTEXT } from "../helpers/symbols.js";
1
+ import {
2
+ INJECT_EDIT_CONTEXT,
3
+ INJECT_FRAGMENT_CONTEXT
4
+ } from "../helpers/symbols.js";
2
5
  import { inject, computed } from "#imports";
3
6
  export function defineBlokkliFragment(_config) {
4
7
  const ctx = inject(
@@ -18,5 +21,9 @@ export function defineBlokkliFragment(_config) {
18
21
  provider: computed(() => null)
19
22
  };
20
23
  }
24
+ const editContext = inject(INJECT_EDIT_CONTEXT, null);
25
+ if (editContext?.dom && editContext.useBlockRegistration) {
26
+ editContext.useBlockRegistration(editContext.dom, ctx.uuid);
27
+ }
21
28
  return ctx;
22
29
  }
@@ -0,0 +1,5 @@
1
+ import type { DomProvider } from '../domProvider.js';
2
+ /**
3
+ * Helper composable to handle registering the block in the DOM provider.
4
+ */
5
+ export declare function useBlockRegistration(dom: DomProvider, uuid: string): void;
@@ -0,0 +1,23 @@
1
+ import {
2
+ getCurrentInstance,
3
+ onBeforeUnmount,
4
+ onMounted,
5
+ onUpdated
6
+ } from "#imports";
7
+ export function useBlockRegistration(dom, uuid) {
8
+ const instance = getCurrentInstance();
9
+ const key = uuid + Math.round(Math.random() * 1e10).toString() + Date.now().toString();
10
+ let rootElement = null;
11
+ function setRootElement() {
12
+ const newElement = instance?.proxy?.$el;
13
+ if (newElement && rootElement !== newElement) {
14
+ rootElement = newElement;
15
+ dom.registerBlock(key, uuid, newElement);
16
+ }
17
+ }
18
+ onMounted(setRootElement);
19
+ onUpdated(setRootElement);
20
+ onBeforeUnmount(() => {
21
+ dom.unregisterBlock(key, uuid);
22
+ });
23
+ }
@@ -20,6 +20,8 @@ export type DomProvider = {
20
20
  */
21
21
  getDropElementMarkup(item: DraggableItem, checkSize?: boolean): string;
22
22
  findField(entityUuid: string, fieldName: string): BlokkliFieldElement | undefined;
23
+ registerBlock: (key: string, uuid: string, el: HTMLElement | null) => void;
24
+ unregisterBlock: (key: string, uuid: string) => void;
23
25
  registerField: (entity: EntityContext, fieldName: string, instance: HTMLElement) => void;
24
26
  updateFieldElement: (entity: EntityContext, fieldName: string, element: HTMLElement) => void;
25
27
  unregisterField: (entity: EntityContext, fieldName: string) => void;
@@ -49,7 +49,6 @@ function rectWithTime(rect, time) {
49
49
  };
50
50
  }
51
51
  export default function(ui, debug, definitions) {
52
- const artboardElement = ui.artboardElement();
53
52
  const logger = debug.createLogger("DomProvider");
54
53
  const mutationsReady = ref(true);
55
54
  const intersectionReady = ref(false);
@@ -57,6 +56,7 @@ export default function(ui, debug, definitions) {
57
56
  const visibleFields = /* @__PURE__ */ new Set();
58
57
  const blockRects = {};
59
58
  const fieldRects = {};
59
+ const blockUuidCurrentKey = {};
60
60
  let draggableBlockCache = {};
61
61
  const resizeObserver = new ResizeObserver(function(entries) {
62
62
  for (const entry of entries) {
@@ -360,66 +360,6 @@ export default function(ui, debug, definitions) {
360
360
  }
361
361
  const dragElementUuidMap = /* @__PURE__ */ new WeakMap();
362
362
  const dragElementCache = /* @__PURE__ */ new Map();
363
- function handleNodeAdded(node) {
364
- if (!(node instanceof HTMLElement)) {
365
- return;
366
- }
367
- if (node.dataset.uuid) {
368
- const item = buildDraggableItem(node);
369
- if (item && item.itemType === "existing") {
370
- const observableElement = getElementToObserve(
371
- node,
372
- item.itemBundle,
373
- item.hostFieldListType,
374
- item.hostBundle
375
- );
376
- intersectionObserver.observe(observableElement);
377
- resizeObserver.observe(observableElement);
378
- registeredBlocks[item.uuid] = node;
379
- }
380
- } else if (node.dataset.fieldName && node.dataset.fieldKey && node.dataset.fieldCardinality) {
381
- const blocks = node.querySelectorAll('[data-element-type="existing"]');
382
- for (const block of blocks) {
383
- handleNodeAdded(block);
384
- }
385
- }
386
- }
387
- function handleNodeRemoved(node) {
388
- if (node instanceof HTMLElement && node.dataset.uuid) {
389
- const uuid = node.dataset.uuid;
390
- const el = registeredBlocks[uuid];
391
- if (el !== node) {
392
- return;
393
- }
394
- if (el) {
395
- intersectionObserver.unobserve(el);
396
- resizeObserver.unobserve(el);
397
- dragElementUuidMap.delete(el);
398
- }
399
- dragElementUuidMap.delete(node);
400
- dragElementCache.delete(uuid);
401
- registeredBlocks[uuid] = void 0;
402
- delete blockRects[uuid];
403
- visibleBlocks.delete(uuid);
404
- }
405
- }
406
- const mutationObserverCallback = function(mutationsList) {
407
- for (const mutation of mutationsList) {
408
- if (mutation.type === "childList") {
409
- for (const node of mutation.removedNodes) {
410
- handleNodeRemoved(node);
411
- }
412
- for (const node of mutation.addedNodes) {
413
- handleNodeAdded(node);
414
- }
415
- }
416
- }
417
- };
418
- const mutationObserver = new MutationObserver(mutationObserverCallback);
419
- mutationObserver.observe(artboardElement, {
420
- subtree: true,
421
- childList: true
422
- });
423
363
  function getDragElement(block) {
424
364
  const cached = dragElementCache.get(block.uuid);
425
365
  if (cached && document.body.contains(cached)) {
@@ -429,9 +369,6 @@ export default function(ui, debug, definitions) {
429
369
  if (!el) {
430
370
  return;
431
371
  }
432
- if (el.parentNode) {
433
- mutationObserver.observe(el.parentNode, { childList: true });
434
- }
435
372
  dragElementUuidMap.set(el, block.uuid);
436
373
  dragElementCache.set(block.uuid, el);
437
374
  return el;
@@ -439,6 +376,52 @@ export default function(ui, debug, definitions) {
439
376
  function isBlockVisible(uuid) {
440
377
  return visibleBlocks.has(uuid);
441
378
  }
379
+ function registerBlock(key, uuid, el) {
380
+ logger.log("registerBlock: " + uuid);
381
+ blockUuidCurrentKey[uuid] = key;
382
+ if (!el) {
383
+ logger.log("registerBlock call unregisterBlock because no element", uuid);
384
+ unregisterBlock(key, uuid);
385
+ return;
386
+ }
387
+ if (registeredBlocks[uuid]) {
388
+ logger.log(
389
+ "registerBlock call unregisterBlock because already registered",
390
+ uuid
391
+ );
392
+ unregisterBlock(key, uuid);
393
+ }
394
+ const item = buildDraggableItem(el);
395
+ if (item && item.itemType === "existing") {
396
+ const observableElement = getElementToObserve(
397
+ el,
398
+ item.itemBundle,
399
+ item.hostFieldListType,
400
+ item.hostBundle
401
+ );
402
+ intersectionObserver.observe(observableElement);
403
+ resizeObserver.observe(observableElement);
404
+ registeredBlocks[item.uuid] = el;
405
+ }
406
+ }
407
+ function unregisterBlock(key, uuid) {
408
+ const currentKey = blockUuidCurrentKey[uuid];
409
+ if (currentKey && currentKey !== key) {
410
+ return;
411
+ }
412
+ logger.log("unregisterBlock: " + uuid);
413
+ const el = registeredBlocks[uuid];
414
+ if (el) {
415
+ intersectionObserver.unobserve(el);
416
+ resizeObserver.unobserve(el);
417
+ dragElementUuidMap.delete(el);
418
+ dragElementUuidMap.delete(el);
419
+ }
420
+ dragElementCache.delete(uuid);
421
+ registeredBlocks[uuid] = void 0;
422
+ delete blockRects[uuid];
423
+ visibleBlocks.delete(uuid);
424
+ }
442
425
  return {
443
426
  findBlock,
444
427
  getAllBlocks,
@@ -462,6 +445,8 @@ export default function(ui, debug, definitions) {
462
445
  init,
463
446
  getDragElement,
464
447
  updateVisibleRects,
465
- registeredFieldTypes
448
+ registeredFieldTypes,
449
+ registerBlock,
450
+ unregisterBlock
466
451
  };
467
452
  }
@@ -936,6 +936,7 @@ export type ItemEditContext = {
936
936
  mutatedOptions: MutatedOptions;
937
937
  dom?: DomProvider;
938
938
  definitions: DefinitionProvider;
939
+ useBlockRegistration?: (dom: DomProvider, uuid: string) => void;
939
940
  };
940
941
  export interface BlokkliApp {
941
942
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blokkli/editor",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.7",
4
4
  "description": "Interactive page building experience for Nuxt",
5
5
  "repository": "blokkli/editor",
6
6
  "type": "module",
@@ -71,9 +71,9 @@
71
71
  "@ckeditor/ckeditor5-vue": "^7.0.0",
72
72
  "@nuxt/devtools": "latest",
73
73
  "@nuxt/eslint-config": "^1.3.0",
74
- "@nuxt/kit": "^3.16.2",
74
+ "@nuxt/kit": "^3.17.2",
75
75
  "@nuxt/module-builder": "^1.0.1",
76
- "@nuxt/schema": "^3.16.2",
76
+ "@nuxt/schema": "^3.17.2",
77
77
  "@nuxt/test-utils": "^3.14.2",
78
78
  "@nuxtjs/tailwindcss": "^6.12.1",
79
79
  "@tailwindcss/forms": "^0.5.9",
@@ -89,7 +89,7 @@
89
89
  "eslint-plugin-tailwindcss": "^3.18.0",
90
90
  "gettext-parser": "^8.0.0",
91
91
  "happy-dom": "^15.7.4",
92
- "nuxt": "^3.16.2",
92
+ "nuxt": "^3.17.2",
93
93
  "nuxt-graphql-middleware": "^5.0.0-alpha.18",
94
94
  "nuxt-svg-icon-sprite": "^2.0.0-alpha.1",
95
95
  "openai": "^4.59.0",