@blokkli/editor 1.1.1 → 1.1.2

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 (37) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +1 -1
  3. package/dist/runtime/components/Blocks/FromLibrary/index.vue +2 -8
  4. package/dist/runtime/components/BlokkliItem.vue +1 -0
  5. package/dist/runtime/components/Edit/Actions/index.vue +5 -0
  6. package/dist/runtime/components/Edit/AnimationCanvas/index.vue +2 -2
  7. package/dist/runtime/components/Edit/BlockProxy/index.vue +40 -9
  8. package/dist/runtime/components/Edit/DragInteractions/index.vue +16 -7
  9. package/dist/runtime/components/Edit/Features/Artboard/Overview/index.vue +7 -5
  10. package/dist/runtime/components/Edit/Features/Artboard/index.vue +7 -1
  11. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +27 -9
  12. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +7 -1
  13. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +1 -1
  14. package/dist/runtime/components/Edit/Features/Delete/index.vue +46 -2
  15. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +2 -2
  16. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +14 -6
  17. package/dist/runtime/components/Edit/Features/Duplicate/index.vue +33 -15
  18. package/dist/runtime/components/Edit/Features/History/List/index.vue +149 -0
  19. package/dist/runtime/components/Edit/Features/History/index.vue +7 -134
  20. package/dist/runtime/components/Edit/Features/Library/index.vue +1 -1
  21. package/dist/runtime/components/Edit/Features/Structure/index.vue +1 -0
  22. package/dist/runtime/components/Edit/ScrollBoundary/index.vue +17 -2
  23. package/dist/runtime/composables/defineBlokkli.js +10 -3
  24. package/dist/runtime/composables/defineBlokkliFragment.js +6 -3
  25. package/dist/runtime/css/output.css +1 -1
  26. package/dist/runtime/helpers/domProvider.d.ts +0 -2
  27. package/dist/runtime/helpers/domProvider.js +0 -22
  28. package/dist/runtime/helpers/index.d.ts +2 -1
  29. package/dist/runtime/helpers/index.js +9 -0
  30. package/dist/runtime/helpers/keyboardProvider.d.ts +1 -0
  31. package/dist/runtime/helpers/keyboardProvider.js +13 -2
  32. package/dist/runtime/helpers/selectionProvider.d.ts +1 -1
  33. package/dist/runtime/helpers/selectionProvider.js +6 -0
  34. package/dist/runtime/helpers/stateProvider.d.ts +1 -0
  35. package/dist/runtime/helpers/stateProvider.js +9 -1
  36. package/dist/runtime/types/index.d.ts +6 -0
  37. package/package.json +1 -1
@@ -20,7 +20,6 @@ export type DomProvider = {
20
20
  * Return the droppable markup for a draggable item.
21
21
  */
22
22
  getDropElementMarkup(item: DraggableItem, checkSize?: boolean): string;
23
- getBlockField(uuid: string): BlokkliFieldElement;
24
23
  findField(entityUuid: string, fieldName: string): BlokkliFieldElement | undefined;
25
24
  registerBlock: (uuid: string, instance: ComponentInternalInstance | null | HTMLElement, bundle: string, fieldListType: ValidFieldListTypes, parentBlockBundle?: BlockBundleWithNested) => void;
26
25
  unregisterBlock: (uuid: string) => void;
@@ -33,7 +32,6 @@ export type DomProvider = {
33
32
  */
34
33
  getAllDroppableFields(): DroppableEntityField[];
35
34
  findClosestEntityContext(el: HTMLElement): EntityContext | undefined;
36
- getBlockVisibilities(): Record<string, boolean>;
37
35
  getVisibleBlocks(): string[];
38
36
  getVisibleFields(): string[];
39
37
  isBlockVisible(uuid: string): boolean;
@@ -63,7 +63,6 @@ export default function(ui, debug) {
63
63
  const logger = debug.createLogger("DomProvider");
64
64
  const mutationsReady = ref(true);
65
65
  const intersectionReady = ref(false);
66
- const blockVisibility = {};
67
66
  const visibleBlocks = /* @__PURE__ */ new Set();
68
67
  const visibleFields = /* @__PURE__ */ new Set();
69
68
  const blockRects = {};
@@ -133,7 +132,6 @@ export default function(ui, debug) {
133
132
  } else {
134
133
  visibleBlocks.delete(uuid);
135
134
  }
136
- blockVisibility[uuid] = entry.isIntersecting;
137
135
  }
138
136
  }
139
137
  }
@@ -279,21 +277,6 @@ export default function(ui, debug) {
279
277
  ""
280
278
  );
281
279
  };
282
- const getBlockField = (uuid) => {
283
- const block = findBlock(uuid);
284
- if (!block) {
285
- throw new Error("Block does not exist: " + uuid);
286
- }
287
- const el = block.element().closest(".bk-draggable-list-container");
288
- if (!(el instanceof HTMLElement)) {
289
- throw new TypeError("Failed to locate field element for block: " + uuid);
290
- }
291
- const field = buildFieldElement(el);
292
- if (!field) {
293
- throw new Error("Failed to build field for block: " + uuid);
294
- }
295
- return field;
296
- };
297
280
  const findField = (uuid, fieldName) => {
298
281
  const el = document.querySelector(
299
282
  `[data-field-name="${fieldName}"][data-host-entity-uuid="${uuid}"]`
@@ -306,9 +289,6 @@ export default function(ui, debug) {
306
289
  const getAllDroppableFields = () => [...document.querySelectorAll("[data-blokkli-droppable-field]")].filter((el) => {
307
290
  return !el.closest('[data-bk-in-proxy="true"]');
308
291
  }).map(mapDroppableField);
309
- const getBlockVisibilities = () => {
310
- return blockVisibility;
311
- };
312
292
  const getVisibleBlocks = () => Array.from(visibleBlocks);
313
293
  const getVisibleFields = () => Array.from(visibleFields);
314
294
  const getActiveProviderElement = () => {
@@ -463,13 +443,11 @@ export default function(ui, debug) {
463
443
  getAllBlocks,
464
444
  findClosestBlock,
465
445
  getDropElementMarkup,
466
- getBlockField,
467
446
  findField,
468
447
  registerBlock,
469
448
  unregisterBlock,
470
449
  getAllDroppableFields,
471
450
  findClosestEntityContext,
472
- getBlockVisibilities,
473
451
  getVisibleBlocks,
474
452
  getVisibleFields,
475
453
  registerField,
@@ -1,4 +1,4 @@
1
- import type { DraggableItem, Rectangle, DroppableEntityField, DraggableExistingBlock, EntityContext, Coord } from '#blokkli/types';
1
+ import type { DraggableItem, Rectangle, DroppableEntityField, DraggableExistingBlock, EntityContext, Coord, LibraryItemProps } from '#blokkli/types';
2
2
  import type { RGB } from '#blokkli/types/theme';
3
3
  /**
4
4
  * Type check for falsy values.
@@ -85,3 +85,4 @@ export declare function getFieldKey(uuid: string, fieldName: string): string;
85
85
  export declare function getInteractionCoordinates(e: MouseEvent | TouchEvent): Coord;
86
86
  export declare function toShaderColor(rgba: RGB): RGB;
87
87
  export declare function generateUUID(): string;
88
+ export declare function buildAttributesForLibraryItem(props: LibraryItemProps): Record<string, string | undefined>;
@@ -465,3 +465,12 @@ export function generateUUID() {
465
465
  return (c == "x" ? r : r & 7 | 8).toString(16);
466
466
  });
467
467
  }
468
+ export function buildAttributesForLibraryItem(props) {
469
+ return {
470
+ "data-reusable-bundle": props.block?.bundle,
471
+ "data-reusable-uuid": props.block?.uuid,
472
+ "data-bk-library-label": props.label,
473
+ "data-bk-library-item-uuid": props.uuid,
474
+ "data-blokkli-is-reusable": "true"
475
+ };
476
+ }
@@ -9,6 +9,7 @@ export type KeyboardProvider = {
9
9
  isPressingSpace: Readonly<Ref<boolean>>;
10
10
  isPressingControl: Readonly<Ref<boolean>>;
11
11
  isPressingShift: Readonly<Ref<boolean>>;
12
+ setShortcutStateFromEvent: (e: MouseEvent | PointerEvent) => void;
12
13
  shortcuts: ComputedRef<RegisteredShortcut[]>;
13
14
  registerShortcut: (shortcut: KeyboardShortcut) => void;
14
15
  unregisterShortcut: (shortcut: KeyboardShortcut) => void;
@@ -7,6 +7,12 @@ import {
7
7
  computed
8
8
  } from "vue";
9
9
  import { eventBus } from "#blokkli/helpers/eventBus";
10
+ function getControlState(e) {
11
+ if ("code" in e && e.code === "CapsLock") {
12
+ return true;
13
+ }
14
+ return e.getModifierState("Control") || e.getModifierState("Meta");
15
+ }
10
16
  export default function(animationProvider) {
11
17
  const isPressingControl = ref(false);
12
18
  const isPressingSpace = ref(false);
@@ -23,7 +29,7 @@ export default function(animationProvider) {
23
29
  }
24
30
  };
25
31
  const onKeyDown = (e) => {
26
- isPressingControl.value = e.getModifierState("Control") || e.getModifierState("Meta") || e.code === "CapsLock";
32
+ isPressingControl.value = getControlState(e);
27
33
  isPressingShift.value = e.getModifierState("Shift");
28
34
  if (!isPressingSpace.value) {
29
35
  eventBus.emit("keyPressed", {
@@ -68,12 +74,17 @@ export default function(animationProvider) {
68
74
  );
69
75
  };
70
76
  const shortcuts = computed(() => registeredShortcuts.value);
77
+ function setShortcutStateFromEvent(e) {
78
+ isPressingControl.value = getControlState(e);
79
+ isPressingShift.value = !!e.shiftKey;
80
+ }
71
81
  return {
72
82
  isPressingSpace: readonly(isPressingSpace),
73
83
  isPressingControl: readonly(isPressingControl),
74
84
  isPressingShift: readonly(isPressingShift),
75
85
  shortcuts,
76
86
  registerShortcut,
77
- unregisterShortcut
87
+ unregisterShortcut,
88
+ setShortcutStateFromEvent
78
89
  };
79
90
  }
@@ -7,7 +7,7 @@ export type SelectionProvider = {
7
7
  */
8
8
  uuids: Readonly<Ref<string[]>>;
9
9
  /**
10
- * The currently selected UUIDs as a map.
10
+ * The currently selected UUIDs as a Set.
11
11
  */
12
12
  uuidsSet: ComputedRef<Set<string>>;
13
13
  /**
@@ -98,6 +98,9 @@ export default function(dom) {
98
98
  onBlokkliEvent("select:next", selectInList);
99
99
  onBlokkliEvent("setActiveFieldKey", setActiveFieldKey);
100
100
  onBlokkliEvent("state:reloaded", () => {
101
+ selectedUuids.value = selectedUuids.value.filter((uuid) => {
102
+ return !!dom.findBlock(uuid);
103
+ });
101
104
  });
102
105
  onBlokkliEvent("dragging:start", (e) => {
103
106
  draggingMode.value = e.mode;
@@ -113,6 +116,9 @@ export default function(dom) {
113
116
  onBlokkliEvent("dragging:end", () => {
114
117
  draggingMode.value = null;
115
118
  });
119
+ onBlokkliEvent("select:unselect", () => {
120
+ selectedUuids.value = [];
121
+ });
116
122
  onBlokkliEvent("window:clickAway", () => {
117
123
  unselectItems();
118
124
  activeFieldKey.value = "";
@@ -30,6 +30,7 @@ export type StateProvider = {
30
30
  getFieldBlockCount: (key: string) => number;
31
31
  getBlockBundleCount: (bundle: string) => number;
32
32
  getFieldListItem: (uuid: string) => FieldListItem | undefined;
33
+ getFieldListForBlock: (uuid: string) => MutatedField | undefined;
33
34
  getMutatedField: (uuid: string, fieldName: string) => MutatedField | undefined;
34
35
  };
35
36
  export default function (adapter: BlokkliAdapter<any>, context: ComputedRef<AdapterContext>, $t: TextProvider): Promise<StateProvider>;
@@ -42,6 +42,13 @@ export default async function(adapter, context, $t) {
42
42
  }
43
43
  return field.list.find((v) => v.uuid === uuid);
44
44
  }
45
+ function getFieldListForBlock(uuid) {
46
+ const fieldKey = fieldListItemMap[uuid];
47
+ if (!fieldKey) {
48
+ return;
49
+ }
50
+ return mutatedFieldsMap[fieldKey];
51
+ }
45
52
  const mutatedOptions = reactive({});
46
53
  const translation = ref({
47
54
  isTranslatable: false,
@@ -221,6 +228,7 @@ export default async function(adapter, context, $t) {
221
228
  getFieldBlockCount,
222
229
  getBlockBundleCount,
223
230
  getFieldListItem,
224
- getMutatedField
231
+ getMutatedField,
232
+ getFieldListForBlock
225
233
  };
226
234
  }
@@ -844,6 +844,7 @@ export type LibraryEditItemEvent = {
844
844
  };
845
845
  export type EventbusEvents = {
846
846
  select: string | string[];
847
+ 'select:unselect': undefined;
847
848
  'item:edit': EditBlockEvent;
848
849
  batchTranslate: undefined;
849
850
  'dragging:start': DraggableStartEvent;
@@ -1094,5 +1095,10 @@ export type SelectedRect = Rectangle & {
1094
1095
  uuid: string;
1095
1096
  style: DraggableStyle;
1096
1097
  };
1098
+ export interface LibraryItemProps {
1099
+ block?: FieldListItem;
1100
+ label?: string;
1101
+ uuid?: string;
1102
+ }
1097
1103
  declare const _default: {};
1098
1104
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blokkli/editor",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Interactive page building experience for Nuxt",
5
5
  "repository": "blokkli/editor",
6
6
  "type": "module",