@blokkli/editor 2.0.0-alpha.17 → 2.0.0-alpha.19

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 (138) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +380 -59
  3. package/dist/modules/drupal/graphql/base/fragment.paragraphsFieldItem.graphql +3 -1
  4. package/dist/modules/drupal/graphql/base/query.pbConfig.graphql +1 -10
  5. package/dist/modules/drupal/graphql/mutations/set_paragraph_schedule.graphql +15 -0
  6. package/dist/modules/drupal/index.mjs +33 -0
  7. package/dist/modules/drupal/runtime/adapter/index.js +10 -2
  8. package/dist/runtime/adapter/index.d.ts +21 -0
  9. package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +3 -0
  10. package/dist/runtime/blokkliPlugins/ItemAction/index.vue +23 -13
  11. package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +20 -44
  12. package/dist/runtime/blokkliPlugins/TourItem/index.vue +10 -5
  13. package/dist/runtime/components/BlokkliEditable.vue +13 -13
  14. package/dist/runtime/components/BlokkliField.vue.d.ts +3 -3
  15. package/dist/runtime/components/BlokkliItem.vue +1 -1
  16. package/dist/runtime/components/BlokkliItem.vue.d.ts +4 -2
  17. package/dist/runtime/components/BlokkliProvider.vue +12 -8
  18. package/dist/runtime/components/Edit/Actions/index.vue +27 -16
  19. package/dist/runtime/components/Edit/AnimationCanvas/index.vue +26 -10
  20. package/dist/runtime/components/Edit/ArtboardTooltip/index.vue +3 -0
  21. package/dist/runtime/components/Edit/Dialog/index.vue +6 -4
  22. package/dist/runtime/components/Edit/DraggableList.vue +15 -7
  23. package/dist/runtime/components/Edit/DraggableList.vue.d.ts +5 -5
  24. package/dist/runtime/components/Edit/EditProvider.vue +29 -16
  25. package/dist/runtime/components/Edit/EditProvider.vue.d.ts +1 -0
  26. package/dist/runtime/components/Edit/Features/AddList/index.vue +9 -11
  27. package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue +9 -6
  28. package/dist/runtime/components/Edit/Features/Analyze/Renderer.vue +1 -1
  29. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +15 -11
  30. package/dist/runtime/components/Edit/Features/Anchors/Renderer.vue +19 -102
  31. package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue +3 -0
  32. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +28 -52
  33. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/ScheduleSection.vue +154 -0
  34. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/ScheduleSection.vue.d.ts +27 -0
  35. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue +222 -0
  36. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue.d.ts +11 -0
  37. package/dist/runtime/components/Edit/Features/BlockScheduler/index.vue +96 -0
  38. package/dist/runtime/components/Edit/Features/BlockScheduler/index.vue.d.ts +2 -0
  39. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +15 -16
  40. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Item/index.vue +51 -0
  41. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/{Group → Item}/index.vue.d.ts +9 -13
  42. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +46 -66
  43. package/dist/runtime/components/Edit/Features/Comments/index.vue +1 -1
  44. package/dist/runtime/components/Edit/Features/Conversions/index.vue +4 -7
  45. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +2 -2
  46. package/dist/runtime/components/Edit/Features/Debug/index.vue +4 -1
  47. package/dist/runtime/components/Edit/Features/Delete/index.vue +1 -1
  48. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +13 -5
  49. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +14 -11
  50. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +30 -18
  51. package/dist/runtime/components/Edit/Features/Duplicate/index.vue +6 -8
  52. package/dist/runtime/components/Edit/Features/Edit/index.vue +15 -21
  53. package/dist/runtime/components/Edit/Features/EditForm/index.vue +7 -6
  54. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +8 -3
  55. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue.d.ts +2 -2
  56. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +29 -12
  57. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue.d.ts +2 -2
  58. package/dist/runtime/components/Edit/Features/EditableField/index.vue +40 -42
  59. package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +11 -9
  60. package/dist/runtime/components/Edit/Features/Fragments/index.vue +3 -3
  61. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue +16 -25
  62. package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +5 -7
  63. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +5 -5
  64. package/dist/runtime/components/Edit/Features/Library/index.vue +27 -23
  65. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +6 -3
  66. package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +15 -12
  67. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +2 -2
  68. package/dist/runtime/components/Edit/Features/Options/Form/index.vue +7 -6
  69. package/dist/runtime/components/Edit/Features/Options/index.vue +6 -6
  70. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +68 -15
  71. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +15 -15
  72. package/dist/runtime/components/Edit/Features/Search/index.vue +4 -1
  73. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +3 -3
  74. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +34 -11
  75. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +21 -20
  76. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue.d.ts +2 -2
  77. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +3 -3
  78. package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +2 -2
  79. package/dist/runtime/components/Edit/Features/Selection/index.vue +61 -27
  80. package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +2 -2
  81. package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue +13 -6
  82. package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +3 -0
  83. package/dist/runtime/components/Edit/Features/Transform/index.vue +2 -27
  84. package/dist/runtime/components/Edit/Features/Translations/index.vue +7 -7
  85. package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue +5 -5
  86. package/dist/runtime/components/Edit/Features/index.vue +17 -7
  87. package/dist/runtime/components/Edit/Form/Toggle/index.vue +4 -3
  88. package/dist/runtime/components/Edit/Form/Toggle/index.vue.d.ts +12 -2
  89. package/dist/runtime/components/Edit/InfoBox/index.vue +6 -2
  90. package/dist/runtime/components/Edit/InfoBox/index.vue.d.ts +12 -2
  91. package/dist/runtime/components/Edit/{Features/Publish/Dialog/ScheduleDate.vue → ScheduleDate/index.vue} +6 -58
  92. package/dist/runtime/components/Edit/{Features/Publish/Dialog/ScheduleDate.vue.d.ts → ScheduleDate/index.vue.d.ts} +11 -1
  93. package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +3 -0
  94. package/dist/runtime/components/Edit/Transition/Height.vue +95 -0
  95. package/dist/runtime/components/Edit/Transition/Height.vue.d.ts +36 -0
  96. package/dist/runtime/components/Edit/index.d.ts +3 -1
  97. package/dist/runtime/components/Edit/index.js +5 -1
  98. package/dist/runtime/css/output.css +1 -1
  99. package/dist/runtime/helpers/animationProvider.d.ts +2 -1
  100. package/dist/runtime/helpers/animationProvider.js +6 -2
  101. package/dist/runtime/helpers/composables/useStateBasedCache.d.ts +4 -0
  102. package/dist/runtime/helpers/composables/useStateBasedCache.js +13 -0
  103. package/dist/runtime/helpers/definitionProvider.d.ts +1 -1
  104. package/dist/runtime/helpers/dom/index.d.ts +1 -1
  105. package/dist/runtime/helpers/domProvider.d.ts +10 -16
  106. package/dist/runtime/helpers/domProvider.js +80 -135
  107. package/dist/runtime/helpers/index.d.ts +1 -8
  108. package/dist/runtime/helpers/index.js +1 -84
  109. package/dist/runtime/helpers/providers/blocks.d.ts +10 -0
  110. package/dist/runtime/helpers/providers/blocks.js +91 -0
  111. package/dist/runtime/helpers/providers/directive.d.ts +24 -0
  112. package/dist/runtime/helpers/{editableProvider.js → providers/directive.js} +90 -29
  113. package/dist/runtime/helpers/providers/element.d.ts +6 -0
  114. package/dist/runtime/helpers/providers/element.js +35 -0
  115. package/dist/runtime/helpers/providers/fields.d.ts +8 -0
  116. package/dist/runtime/helpers/providers/fields.js +47 -0
  117. package/dist/runtime/helpers/selectionProvider.d.ts +11 -11
  118. package/dist/runtime/helpers/selectionProvider.js +38 -45
  119. package/dist/runtime/helpers/stateProvider.d.ts +1 -0
  120. package/dist/runtime/helpers/stateProvider.js +21 -15
  121. package/dist/runtime/helpers/themeProvider.d.ts +2 -1
  122. package/dist/runtime/helpers/themeProvider.js +24 -14
  123. package/dist/runtime/helpers/typesProvider.js +10 -26
  124. package/dist/runtime/helpers/uiProvider.d.ts +3 -2
  125. package/dist/runtime/helpers/uiProvider.js +11 -15
  126. package/dist/runtime/icons/calendar.svg +1 -0
  127. package/dist/runtime/icons/clock.svg +1 -0
  128. package/dist/runtime/icons/comment_add.svg +1 -5
  129. package/dist/runtime/icons/delete.svg +1 -8
  130. package/dist/runtime/icons/duplicate.svg +1 -12
  131. package/dist/runtime/icons/edit.svg +1 -8
  132. package/dist/runtime/icons/reusable.svg +1 -5
  133. package/dist/runtime/plugins/{blokkliEditable.js → blokkliDirectives.js} +14 -20
  134. package/dist/runtime/types/index.d.ts +55 -36
  135. package/package.json +1 -1
  136. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +0 -63
  137. package/dist/runtime/helpers/editableProvider.d.ts +0 -14
  138. /package/dist/runtime/plugins/{blokkliEditable.d.ts → blokkliDirectives.d.ts} +0 -0
@@ -57,12 +57,12 @@ export default async function(adapter, context, $t, providerKey, permissions) {
57
57
  });
58
58
  let fieldBlockCount = {};
59
59
  const blockBundleCount = ref({});
60
- const fieldListItemMap = /* @__PURE__ */ new Map();
60
+ const fieldListItemMap = ref({});
61
61
  let bundleToUuids = {};
62
62
  const fromLibraryUuids = ref([]);
63
63
  const nestingLevelMap = /* @__PURE__ */ new Map();
64
64
  function getFieldListItem(uuid) {
65
- const fieldKey = fieldListItemMap.get(uuid);
65
+ const fieldKey = fieldListItemMap.value[uuid];
66
66
  if (!fieldKey) {
67
67
  return;
68
68
  }
@@ -72,8 +72,11 @@ export default async function(adapter, context, $t, providerKey, permissions) {
72
72
  }
73
73
  return field.list.find((v) => v.uuid === uuid);
74
74
  }
75
+ function getFieldKeyForUuid(uuid) {
76
+ return fieldListItemMap.value[uuid] ?? null;
77
+ }
75
78
  function getFieldListForBlock(uuid) {
76
- const fieldKey = fieldListItemMap.get(uuid);
79
+ const fieldKey = fieldListItemMap.value[uuid];
77
80
  if (!fieldKey) {
78
81
  return;
79
82
  }
@@ -143,7 +146,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
143
146
  mutatedEntity.value = context2?.mutatedEntity;
144
147
  const visitedFieldKeys = [];
145
148
  const newBlockBundleCount = {};
146
- fieldListItemMap.clear();
149
+ fieldListItemMap.value = {};
147
150
  nestingLevelMap.clear();
148
151
  fieldBlockCount = {};
149
152
  bundleToUuids = {};
@@ -162,7 +165,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
162
165
  newBlockBundleCount[item.bundle] = 0;
163
166
  }
164
167
  newBlockBundleCount[item.bundle]++;
165
- fieldListItemMap.set(item.uuid, key);
168
+ fieldListItemMap.value[item.uuid] = key;
166
169
  if (!bundleToUuids[item.bundle]) {
167
170
  bundleToUuids[item.bundle] = [];
168
171
  }
@@ -217,7 +220,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
217
220
  }
218
221
  function getAllUuids(bundle) {
219
222
  if (!bundle) {
220
- return [...fieldListItemMap.keys()];
223
+ return [...Object.keys(fieldListItemMap.value)];
221
224
  }
222
225
  return bundleToUuids[bundle] ?? [];
223
226
  }
@@ -226,7 +229,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
226
229
  if (cached !== void 0) {
227
230
  return cached;
228
231
  }
229
- const fieldKey = fieldListItemMap.get(uuid);
232
+ const fieldKey = fieldListItemMap.value[uuid];
230
233
  if (!fieldKey) {
231
234
  nestingLevelMap.set(uuid, 0);
232
235
  return 0;
@@ -237,7 +240,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
237
240
  return 0;
238
241
  }
239
242
  const parentEntityUuid = field.entityUuid;
240
- const parentFieldKey = fieldListItemMap.get(parentEntityUuid);
243
+ const parentFieldKey = fieldListItemMap.value[parentEntityUuid];
241
244
  if (!parentFieldKey) {
242
245
  nestingLevelMap.set(uuid, 0);
243
246
  return 0;
@@ -251,7 +254,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
251
254
  return nestingLevelMap.get(uuid) ?? 0;
252
255
  }
253
256
  function isChildOf(childUuid, parentUuid) {
254
- const fieldKey = fieldListItemMap.get(childUuid);
257
+ const fieldKey = fieldListItemMap.value[childUuid];
255
258
  if (!fieldKey) {
256
259
  return false;
257
260
  }
@@ -289,11 +292,13 @@ export default async function(adapter, context, $t, providerKey, permissions) {
289
292
  }
290
293
  return true;
291
294
  } catch (e) {
292
- emitMessage(
293
- errorMessage || $t("unexpectedMutationError", "An unexpected error happened."),
294
- "error",
295
- e
296
- );
295
+ if (errorMessage !== false) {
296
+ emitMessage(
297
+ errorMessage || $t("unexpectedMutationError", "An unexpected error happened."),
298
+ "error",
299
+ e
300
+ );
301
+ }
297
302
  }
298
303
  unlockBody();
299
304
  return false;
@@ -386,6 +391,7 @@ export default async function(adapter, context, $t, providerKey, permissions) {
386
391
  setOverrideState,
387
392
  clearOverrideState,
388
393
  fromLibraryUuids: readonly(fromLibraryUuids),
389
- permissions: computed(() => permissions)
394
+ permissions: computed(() => permissions),
395
+ getFieldKeyForUuid
390
396
  };
391
397
  }
@@ -1,6 +1,7 @@
1
1
  import type { DraggableStyle } from '#blokkli/types';
2
2
  import type { RGB, ThemeColorGroup, ThemeColorShade, ThemeColors, ThemeContextColorGroup, ThemeContextColorShade, ThemeContextColors, ThemeName } from '#blokkli/types/theme';
3
3
  import { type Ref } from '#imports';
4
+ import type { ElementProvider } from './providers/element.js';
4
5
  type ThemeMap = {
5
6
  accent: Ref<ThemeColors>;
6
7
  mono: Ref<ThemeColors>;
@@ -25,5 +26,5 @@ export type ThemeProvider = {
25
26
  getColor<K extends keyof ThemeMap, T extends ThemeMap[K]['value']>(color: K, key: keyof T): RGB;
26
27
  getColorString<K extends keyof ThemeMap, T extends ThemeMap[K]['value']>(color: K, key: keyof T, alpha?: number): string;
27
28
  };
28
- export default function (): ThemeProvider;
29
+ export default function (element: ElementProvider): ThemeProvider;
29
30
  export {};
@@ -3,7 +3,15 @@ import { ref, onMounted, onBeforeUnmount } from "#imports";
3
3
  import { rgbaToString } from "./index.js";
4
4
  import { DragStyle } from "./DragStyle/index.js";
5
5
  import onBlokkliEvent from "./composables/onBlokkliEvent.js";
6
- export default function() {
6
+ export default function(element) {
7
+ const rootElement = element.query(
8
+ document,
9
+ ":root",
10
+ "Get document root element for setting theme color."
11
+ );
12
+ if (!rootElement) {
13
+ throw new Error("Failed to query :root - is this even possible?");
14
+ }
7
15
  const originalBrowserThemeColor = ref("");
8
16
  const THEME_COLOR = "black";
9
17
  const accent = ref(theme.accent);
@@ -44,13 +52,10 @@ export default function() {
44
52
  } else if (group === "lime") {
45
53
  lime.value[shade] = value;
46
54
  }
47
- const root = document.querySelector(":root");
48
- if (root instanceof HTMLElement) {
49
- root.style.setProperty(
50
- `--bk-theme-${group}-${shade}`,
51
- `${value[0]} ${value[1]} ${value[2]}`
52
- );
53
- }
55
+ rootElement.style.setProperty(
56
+ `--bk-theme-${group}-${shade}`,
57
+ `${value[0]} ${value[1]} ${value[2]}`
58
+ );
54
59
  };
55
60
  const setColorsFromTheme = (v) => {
56
61
  Object.entries(v).forEach(([group, colors]) => {
@@ -79,7 +84,11 @@ export default function() {
79
84
  }
80
85
  };
81
86
  onMounted(() => {
82
- const el = document.head.querySelectorAll('[name="theme-color"]');
87
+ const el = element.query(
88
+ document.head,
89
+ '[name="theme-color"]',
90
+ "Theme: theme-color"
91
+ );
83
92
  if (el instanceof HTMLMetaElement) {
84
93
  originalBrowserThemeColor.value = el.content;
85
94
  el.content = THEME_COLOR;
@@ -87,14 +96,15 @@ export default function() {
87
96
  const meta = document.createElement("meta");
88
97
  meta.name = "theme-color";
89
98
  meta.content = THEME_COLOR;
90
- const head = document.getElementsByTagName("head")[0];
91
- if (head) {
92
- head.appendChild(meta);
93
- }
99
+ document.head.appendChild(meta);
94
100
  }
95
101
  });
96
102
  onBeforeUnmount(() => {
97
- const el = document.head.querySelectorAll('[name="theme-color"]');
103
+ const el = element.query(
104
+ document.head,
105
+ '[name="theme-color"]',
106
+ "Theme: theme-color"
107
+ );
98
108
  if (el instanceof HTMLMetaElement) {
99
109
  if (originalBrowserThemeColor.value) {
100
110
  el.content = originalBrowserThemeColor.value;
@@ -1,5 +1,4 @@
1
- import { eventBus } from "#blokkli/helpers/eventBus";
2
- import { useRuntimeConfig, computed, watch } from "#imports";
1
+ import { useRuntimeConfig, computed } from "#imports";
3
2
  import { onlyUnique } from "./index.js";
4
3
  class ConfigMap {
5
4
  configs = [];
@@ -52,38 +51,23 @@ export default async function(adapter, selection, context) {
52
51
  const droppableFieldConfigData = adapter.getDroppableFieldConfig ? await adapter.getDroppableFieldConfig() : [];
53
52
  const droppableFieldConfig = new ConfigMap(droppableFieldConfigData);
54
53
  const allowedTypesInList = computed(() => {
55
- if (!selection.blocks.value.length) {
54
+ if (!selection.items.value.length) {
56
55
  return [];
57
56
  }
58
57
  let hostType = "";
59
58
  let hostBundle = "";
60
59
  let fieldName = "";
61
- for (let i = 0; i < selection.blocks.value.length; i++) {
62
- const block = selection.blocks.value[i];
63
- if (i !== 0 && (hostType !== block.hostType || hostBundle !== block.hostBundle || fieldName !== block.hostFieldName)) {
60
+ for (let i = 0; i < selection.items.value.length; i++) {
61
+ const block = selection.items.value[i];
62
+ if (i !== 0 && (hostType !== block.host.type || hostBundle !== block.host.bundle || fieldName !== block.host.fieldName)) {
64
63
  return [];
65
64
  }
66
- hostType = block.hostType;
67
- hostBundle = block.hostBundle;
68
- fieldName = block.hostFieldName;
65
+ hostType = block.host.type;
66
+ hostBundle = block.host.bundle;
67
+ fieldName = block.host.fieldName;
69
68
  }
70
69
  return fieldConfig.forName(hostType, hostBundle, fieldName)?.allowedBundles || [];
71
70
  });
72
- watch(selection.blocks, () => {
73
- if (selection.blocks.value.length !== 1) {
74
- return;
75
- }
76
- const item = selection.blocks.value[0];
77
- const hasNested = itemBundlesWithNested.includes(item.itemBundle);
78
- if (hasNested) {
79
- const nestedFields = fieldConfig.forEntityTypeAndBundle(itemEntityType, item.itemBundle).map((v) => v.name) || [];
80
- if (nestedFields.length === 1) {
81
- eventBus.emit("setActiveFieldKey", `${item.uuid}:${nestedFields[0]}`);
82
- return;
83
- }
84
- }
85
- eventBus.emit("setActiveFieldKey", `${item.hostUuid}:${item.hostFieldName}`);
86
- });
87
71
  const itemBundlesWithNested = fieldConfig.forEntityType(itemEntityType).map((v) => v.entityBundle) || [];
88
72
  const typeMap = bundleDefinitions.reduce((acc, type) => {
89
73
  acc[type.id] = type;
@@ -96,8 +80,8 @@ export default async function(adapter, selection, context) {
96
80
  return fieldConfig.forName(entityType, entityBundle, fieldName);
97
81
  }
98
82
  function getDroppableFieldConfig(fieldName, host) {
99
- const entityType = "entityType" in host ? host.entityType : host.type;
100
- const entityBundle = "itemBundle" in host ? host.itemBundle : host.bundle;
83
+ const entityType = "itemType" in host ? host.block.host.type : host.type;
84
+ const entityBundle = "itemType" in host ? host.block.host.bundle : host.bundle;
101
85
  const config = droppableFieldConfig.forName(
102
86
  entityType,
103
87
  entityBundle,
@@ -5,10 +5,11 @@ import type { Viewport } from '#blokkli/constants';
5
5
  import type { StateProvider } from './stateProvider.js';
6
6
  import type { AdapterContext } from '#blokkli/adapter';
7
7
  import type { ThemeColorName } from '#blokkli/types/theme';
8
+ import type { ElementProvider } from './providers/element.js';
8
9
  export type UiProvider = {
9
10
  rootElement: () => HTMLElement;
10
11
  artboardElement: () => HTMLElement;
11
- providerElement: () => HTMLElement;
12
+ providerElement: HTMLElement;
12
13
  menu: {
13
14
  isOpen: Readonly<Ref<boolean>>;
14
15
  close: () => void;
@@ -52,4 +53,4 @@ export type UiProvider = {
52
53
  setBannerHeight: (id: string, height: number) => void;
53
54
  removeBanner: (id: string) => void;
54
55
  };
55
- export default function (storage: StorageProvider, state: StateProvider, context: ComputedRef<AdapterContext>): UiProvider;
56
+ export default function (providerElement: HTMLElement, storage: StorageProvider, state: StateProvider, context: ComputedRef<AdapterContext>, element: ElementProvider): UiProvider;
@@ -15,10 +15,9 @@ const localeMap = {
15
15
  it: "it-CH",
16
16
  en: "en-GB"
17
17
  };
18
- export default function(storage, state, context) {
18
+ export default function(providerElement, storage, state, context, element) {
19
19
  let cachedRootElement = null;
20
20
  let cachedArtboardElement = null;
21
- let cachedProviderElement = null;
22
21
  const interfaceLanguage = computed(() => {
23
22
  return forceDefaultLanguage ? defaultLanguage : context.value.language;
24
23
  });
@@ -86,7 +85,11 @@ export default function(storage, state, context) {
86
85
  if (cachedArtboardElement) {
87
86
  return cachedArtboardElement;
88
87
  }
89
- const el = document.querySelector(".bk-main-canvas");
88
+ const el = element.query(
89
+ document.documentElement,
90
+ ".bk-main-canvas",
91
+ "Get main canvas."
92
+ );
90
93
  if (!el || !(el instanceof HTMLElement)) {
91
94
  throw new Error("Failed to locate artboard element.");
92
95
  }
@@ -97,24 +100,17 @@ export default function(storage, state, context) {
97
100
  if (cachedRootElement) {
98
101
  return cachedRootElement;
99
102
  }
100
- const el = document.querySelector("#nuxt-root");
103
+ const el = element.query(
104
+ document.documentElement,
105
+ "#nuxt-root",
106
+ "Get Nuxt root element."
107
+ );
101
108
  if (!el || !(el instanceof HTMLElement)) {
102
109
  throw new Error("Failed to locate root Nuxt element.");
103
110
  }
104
111
  cachedRootElement = el;
105
112
  return el;
106
113
  };
107
- const providerElement = () => {
108
- if (cachedProviderElement) {
109
- return cachedProviderElement;
110
- }
111
- const el = document.querySelector('[data-blokkli-provider-active="true"]');
112
- if (!el || !(el instanceof HTMLElement)) {
113
- throw new Error("Failed to locate provider element.");
114
- }
115
- cachedProviderElement = el;
116
- return el;
117
- };
118
114
  const appViewport = computed(() => {
119
115
  if (viewportWidth.value < 1024) {
120
116
  return "mobile";
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 11H9V13H7V11M21 5V19C21 20.11 20.11 21 19 21H5C3.89 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H6V1H8V3H16V1H18V3H19C20.11 3 21 3.9 21 5M5 7H19V5H5V7M19 19V9H5V19H19M15 13V11H17V13H15M11 13V11H13V13H11M7 15H9V17H7V15M15 17V15H17V17H15M11 17V15H13V17H11Z" /></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z" /></svg>
@@ -1,5 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
- <path
3
- d="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M11,6H13V9H16V11H13V14H11V11H8V9H11V6Z"
4
- />
5
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9,22A1,1 0 0,1 8,21V18H4A2,2 0 0,1 2,16V4C2,2.89 2.9,2 4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H13.9L10.2,21.71C10,21.9 9.75,22 9.5,22V22H9M10,16V19.08L13.08,16H20V4H4V16H10M11,6H13V9H16V11H13V14H11V11H8V9H11V6Z" /></svg>
@@ -1,8 +1 @@
1
- <svg
2
- xmlns="http://www.w3.org/2000/svg"
3
- viewBox="0 0 32 32"
4
- >
5
- <path
6
- d="M 15 4 C 14.476563 4 13.941406 4.183594 13.5625 4.5625 C 13.183594 4.941406 13 5.476563 13 6 L 13 7 L 7 7 L 7 9 L 8 9 L 8 25 C 8 26.644531 9.355469 28 11 28 L 23 28 C 24.644531 28 26 26.644531 26 25 L 26 9 L 27 9 L 27 7 L 21 7 L 21 6 C 21 5.476563 20.816406 4.941406 20.4375 4.5625 C 20.058594 4.183594 19.523438 4 19 4 Z M 15 6 L 19 6 L 19 7 L 15 7 Z M 10 9 L 24 9 L 24 25 C 24 25.554688 23.554688 26 23 26 L 11 26 C 10.445313 26 10 25.554688 10 25 Z M 12 12 L 12 23 L 14 23 L 14 12 Z M 16 12 L 16 23 L 18 23 L 18 12 Z M 20 12 L 20 23 L 22 23 L 22 12 Z"
7
- ></path>
8
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z" /></svg>
@@ -1,12 +1 @@
1
- <svg
2
- xmlns="http://www.w3.org/2000/svg"
3
- x="0px"
4
- y="0px"
5
- width="100"
6
- height="100"
7
- viewBox="0 0 32 32"
8
- >
9
- <path
10
- d="M 8 4 L 8 8 L 4 8 L 4 28 L 24 28 L 24 27 L 24 24 L 28 24 L 28 4 L 8 4 z M 10 6 L 26 6 L 26 22 L 24 22 L 24 8 L 10 8 L 10 6 z M 6 10 L 22 10 L 22 26 L 6 26 L 6 10 z M 13 14 L 13 17 L 10 17 L 10 19 L 13 19 L 13 22 L 15 22 L 15 19 L 18 19 L 18 17 L 15 17 L 15 14 L 13 14 z"
11
- ></path>
12
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18 11H15V14H13V11H10V9H13V6H15V9H18M20 4V16H8V4H20M20 2H8C6.9 2 6 2.9 6 4V16C6 17.11 6.9 18 8 18H20C21.11 18 22 17.11 22 16V4C22 2.9 21.11 2 20 2M4 6H2V20C2 21.11 2.9 22 4 22H18V20H4V6Z" /></svg>
@@ -1,8 +1 @@
1
- <svg
2
- xmlns="http://www.w3.org/2000/svg"
3
- viewBox="0 0 32 32"
4
- >
5
- <path
6
- d="M 23.90625 3.96875 C 22.859375 3.96875 21.8125 4.375 21 5.1875 L 5.1875 21 L 5.125 21.3125 L 4.03125 26.8125 L 3.71875 28.28125 L 5.1875 27.96875 L 10.6875 26.875 L 11 26.8125 L 26.8125 11 C 28.4375 9.375 28.4375 6.8125 26.8125 5.1875 C 26 4.375 24.953125 3.96875 23.90625 3.96875 Z M 23.90625 5.875 C 24.410156 5.875 24.917969 6.105469 25.40625 6.59375 C 26.378906 7.566406 26.378906 8.621094 25.40625 9.59375 L 24.6875 10.28125 L 21.71875 7.3125 L 22.40625 6.59375 C 22.894531 6.105469 23.402344 5.875 23.90625 5.875 Z M 20.3125 8.71875 L 23.28125 11.6875 L 11.1875 23.78125 C 10.53125 22.5 9.5 21.46875 8.21875 20.8125 Z M 6.9375 22.4375 C 8.136719 22.921875 9.078125 23.863281 9.5625 25.0625 L 6.28125 25.71875 Z"
7
- ></path>
8
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z" /></svg>
@@ -1,5 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
2
- <path
3
- d="M7.17 7.91L8.9 8.91L12.08 3.42L14.33 7.31L11.73 8.81L17.19 10.27L18.66 4.81L16.06 6.31L13.81 2.41C13.26 1.45 12.03 1.12 11.08 1.68C10.81 1.83 10.58 2.05 10.41 2.31M10 20V18L3.66 18L5.9 14.1L8.5 15.6L7.04 10.14L1.57 11.6L4.17 13.1L1.92 17C1.37 17.96 1.7 19.18 2.65 19.73C2.92 19.89 3.22 19.97 3.54 20M19.06 11.5L17.32 12.5L20.5 18H16V15L12 19L16 23V20H20.5C21.61 20 22.5 19.11 22.5 18C22.5 17.69 22.42 17.38 22.28 17.11Z"
4
- />
5
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.17 7.91L8.9 8.91L12.08 3.42L14.33 7.31L11.73 8.81L17.19 10.27L18.66 4.81L16.06 6.31L13.81 2.41C13.26 1.45 12.03 1.12 11.08 1.68C10.81 1.83 10.58 2.05 10.41 2.31M10 20V18L3.66 18L5.9 14.1L8.5 15.6L7.04 10.14L1.57 11.6L4.17 13.1L1.92 17C1.37 17.96 1.7 19.18 2.65 19.73C2.92 19.89 3.22 19.97 3.54 20M19.06 11.5L17.32 12.5L20.5 18H16V15L12 19L16 23V20H20.5C21.61 20 22.5 19.11 22.5 18C22.5 17.69 22.42 17.38 22.28 17.11Z" /></svg>
@@ -28,8 +28,9 @@ function isEditing() {
28
28
  }
29
29
  return false;
30
30
  }
31
- export default defineNuxtPlugin((nuxtApp) => {
32
- nuxtApp.vueApp.directive("blokkli-editable", {
31
+ function createDirective(type) {
32
+ const dataset = type === "editable" ? "blokkliEditableField" : "blokkliDroppableField";
33
+ return {
33
34
  created(el, binding, vnode) {
34
35
  if (import.meta.client) {
35
36
  if (!isEditing()) {
@@ -42,7 +43,7 @@ export default defineNuxtPlugin((nuxtApp) => {
42
43
  if (!fieldName) {
43
44
  return;
44
45
  }
45
- el.dataset.blokkliEditableField = fieldName;
46
+ el.dataset[dataset] = fieldName;
46
47
  }
47
48
  },
48
49
  mounted(el, binding, vnode) {
@@ -64,7 +65,7 @@ export default defineNuxtPlugin((nuxtApp) => {
64
65
  if (!fieldName) {
65
66
  return;
66
67
  }
67
- app.editable.registerEditableField(el, fieldName, entity);
68
+ app.directive.registerDirectiveElement(el, fieldName, entity, type);
68
69
  },
69
70
  beforeUnmount(el, binding, vnode) {
70
71
  if (!isEditing()) {
@@ -82,21 +83,14 @@ export default defineNuxtPlugin((nuxtApp) => {
82
83
  if (!fieldName) {
83
84
  return;
84
85
  }
85
- app.editable.unregisterEditableField(el, fieldName, entity);
86
+ app.directive.unregisterDirectiveElement(el, fieldName, entity, type);
86
87
  }
87
- });
88
- nuxtApp.vueApp.directive("blokkli-droppable", {
89
- created(el, binding) {
90
- if (import.meta.client) {
91
- if (!window.location.search.includes("blokkliEditing")) {
92
- return;
93
- }
94
- const fieldName = binding.value?.name || binding.arg;
95
- if (!fieldName) {
96
- return;
97
- }
98
- el.dataset.blokkliDroppableField = fieldName;
99
- }
100
- }
101
- });
88
+ };
89
+ }
90
+ export default defineNuxtPlugin({
91
+ name: "blokkli:directives",
92
+ setup(nuxtApp) {
93
+ nuxtApp.vueApp.directive("blokkli-editable", createDirective("editable"));
94
+ nuxtApp.vueApp.directive("blokkli-droppable", createDirective("droppable"));
95
+ }
102
96
  });
@@ -8,7 +8,7 @@ import type { KeyboardProvider } from '../helpers/keyboardProvider.js';
8
8
  import type { UiProvider } from '../helpers/uiProvider.js';
9
9
  import type { AnimationProvider } from '../helpers/animationProvider.js';
10
10
  import type { StateProvider } from '../helpers/stateProvider.js';
11
- import type { EditableProvider } from '../helpers/editableProvider.js';
11
+ import type { DirectiveProvider } from '../helpers/providers/directive.js';
12
12
  import type { TextProvider } from '../helpers/textProvider.js';
13
13
  import type { PluginProvider } from '../helpers/pluginProvider.js';
14
14
  import type { eventBus } from './../helpers/eventBus.js';
@@ -20,7 +20,7 @@ import type { BlokkliIcon } from '#blokkli-build/icons';
20
20
  import type { SettingsGroup, Viewport } from '#blokkli/constants';
21
21
  import type { BlockBundleWithNested, FieldListItemTyped, GlobalOptionsKey, ValidChunkNames, ValidFieldListTypes, ValidGlobalConfigKeys, BundleProps } from '#blokkli-build/generated-types';
22
22
  import type { ThemeProvider } from '#blokkli/helpers/themeProvider';
23
- import type { GlobalOptionsType } from '#blokkli-build/definitions';
23
+ import type { BlokkliFragmentName, GlobalOptionsType } from '#blokkli-build/definitions';
24
24
  import type { CommandsProvider } from '#blokkli/helpers/commandsProvider';
25
25
  import type { TourProvider } from '#blokkli/helpers/tourProvider';
26
26
  import type { DropAreaProvider } from '#blokkli/helpers/dropAreaProvider';
@@ -29,7 +29,10 @@ import type { DebugProvider } from '#blokkli/helpers/debugProvider';
29
29
  import type getVideoId from 'get-video-id';
30
30
  import type { DefinitionProvider } from '../helpers/definitionProvider.js';
31
31
  import type { IndicatorsProvider } from '#blokkli/helpers/indicatorsProvider';
32
- export type MutateWithLoadingStateFunction = (promise: () => Promise<MutationResponseLike<any>> | undefined, errorMessage?: string, successMessage?: string) => Promise<boolean>;
32
+ import type { BlocksProvider } from '#blokkli/helpers/providers/blocks';
33
+ import type { FieldsProvider } from '#blokkli/helpers/providers/fields';
34
+ import type { ElementProvider } from '#blokkli/helpers/providers/element';
35
+ export type MutateWithLoadingStateFunction = (promise: () => Promise<MutationResponseLike<any>> | undefined, errorMessage?: string | false, successMessage?: string) => Promise<boolean>;
33
36
  type GetType<T> = T extends {
34
37
  options: infer O;
35
38
  } ? T extends {
@@ -342,8 +345,8 @@ export type InjectedBlokkliItem = {
342
345
  export type FieldListItem = {
343
346
  uuid: string;
344
347
  bundle: string;
345
- isNew?: boolean;
346
348
  options?: Record<string, any>;
349
+ editContext?: BlockEditContext;
347
350
  props?: Record<string, any>;
348
351
  };
349
352
  export type MutatedField = {
@@ -570,6 +573,8 @@ export interface BlockBundleDefinition {
570
573
  description?: string;
571
574
  allowReusable?: boolean;
572
575
  isTranslatable?: boolean;
576
+ hasPublishOn?: boolean;
577
+ hasUnpublishOn?: boolean;
573
578
  }
574
579
  export type EditMode = 'readonly' | 'editing' | 'translating' | 'review';
575
580
  export type MutatedOptions = {
@@ -686,36 +691,12 @@ export type DraggableStyle = {
686
691
  };
687
692
  export interface DraggableExistingStructureBlock {
688
693
  itemType: 'existing_structure';
689
- uuid: string;
690
- itemBundle: string;
694
+ block: RenderedFieldListItem;
691
695
  element: () => HTMLElement;
692
696
  }
693
697
  export interface DraggableExistingBlock {
694
698
  itemType: 'existing';
695
- element: () => HTMLElement;
696
- entityType: string;
697
- hostType: string;
698
- hostBundle: string;
699
- hostUuid: string;
700
- hostFieldName: string;
701
- hostFieldListType: ValidFieldListTypes;
702
- itemBundle: string;
703
- isNew: boolean;
704
- uuid: string;
705
- isNested: boolean;
706
- /**
707
- * The bundle if this item is reusable.
708
- */
709
- reusableBundle?: string;
710
- /**
711
- * The UUID of the library item this block belongs to.
712
- */
713
- libraryItemUuid?: string;
714
- /**
715
- * The title to use when displaying the block in lists during editing.
716
- */
717
- editTitle?: string;
718
- parentBlockBundle: BlockBundleWithNested | undefined;
699
+ block: RenderedFieldListItem;
719
700
  }
720
701
  export interface DraggableNewItem {
721
702
  itemType: 'new';
@@ -942,8 +923,9 @@ export type BlokkliFieldElement = {
942
923
  allowedFragments: string[];
943
924
  cardinality: number;
944
925
  element: HTMLElement;
945
- dropAlignment?: 'vertical' | 'horizontal';
926
+ dropAlignment: FieldDropAlignment | null;
946
927
  };
928
+ export type FieldDropAlignment = 'vertical' | 'horizontal';
947
929
  export type ActionPlacedEvent = {
948
930
  id: string;
949
931
  preceedingUuid?: string;
@@ -1027,7 +1009,6 @@ export type EventbusEvents = {
1027
1009
  'dragging:start': DraggableStartEvent;
1028
1010
  'dragging:drop': DropTargetEvent;
1029
1011
  'dragging:end': undefined;
1030
- setActiveFieldKey: string;
1031
1012
  'add:block:new': AddNewBlockEvent;
1032
1013
  updateMutatedFields: UpdateMutatedFieldsEvent;
1033
1014
  animationFrame: AnimationFrameEvent;
@@ -1042,11 +1023,9 @@ export type EventbusEvents = {
1042
1023
  'select:toggle': string;
1043
1024
  'select:shiftToggle': string;
1044
1025
  'select:end': string[] | undefined;
1045
- 'select:previous': undefined;
1046
- 'select:next': undefined;
1047
1026
  'item:dropped': undefined;
1048
1027
  'block:append': BlockAppendEvent;
1049
- 'item:doubleClick': DraggableExistingBlock;
1028
+ 'item:doubleClick': RenderedFieldListItem;
1050
1029
  scrollIntoView: ScrollIntoViewEvent;
1051
1030
  'animationFrame:before': AnimationFrameBeforeEvent;
1052
1031
  'animationFrame:after': undefined;
@@ -1124,7 +1103,9 @@ export interface BlokkliApp {
1124
1103
  storage: StorageProvider;
1125
1104
  types: BlockDefinitionProvider;
1126
1105
  selection: SelectionProvider;
1106
+ blocks: BlocksProvider;
1127
1107
  keyboard: KeyboardProvider;
1108
+ element: ElementProvider;
1128
1109
  ui: UiProvider;
1129
1110
  animation: AnimationProvider;
1130
1111
  definitions: DefinitionProvider;
@@ -1140,7 +1121,8 @@ export interface BlokkliApp {
1140
1121
  debug: DebugProvider;
1141
1122
  indicators: IndicatorsProvider;
1142
1123
  plugins: PluginProvider;
1143
- editable: EditableProvider;
1124
+ directive: DirectiveProvider;
1125
+ fields: FieldsProvider;
1144
1126
  }
1145
1127
  export type PasteExistingBlocksEvent = {
1146
1128
  uuids: string[];
@@ -1396,5 +1378,42 @@ export type AddAction = {
1396
1378
  description?: string;
1397
1379
  enabled?: boolean;
1398
1380
  };
1381
+ export type BlockEditContext = {
1382
+ isPublished: boolean;
1383
+ isNew: boolean;
1384
+ publishOn?: string | null;
1385
+ unpublishOn?: string | null;
1386
+ };
1387
+ export type RenderedFieldListItem = {
1388
+ uuid: string;
1389
+ bundle: string;
1390
+ isNew: boolean;
1391
+ isPublished: boolean;
1392
+ host: DraggableHostData & {
1393
+ bundle: string;
1394
+ };
1395
+ fieldListType: ValidFieldListTypes;
1396
+ parentBlockBundle: BlockBundleWithNested | null;
1397
+ library: {
1398
+ label: string;
1399
+ libraryItemUuid: string;
1400
+ reusableBundle: string;
1401
+ } | null;
1402
+ isNested: boolean;
1403
+ publishOn?: string | null;
1404
+ unpublishOn?: string | null;
1405
+ };
1406
+ export type BlokkliDirectiveType = 'editable' | 'droppable';
1407
+ export type RegisteredField = {
1408
+ element: HTMLElement;
1409
+ entity: EntityContext;
1410
+ fieldName: string;
1411
+ fieldListType: ValidFieldListTypes;
1412
+ allowedFragments: BlokkliFragmentName[];
1413
+ isNested: boolean;
1414
+ nestingLevel: number;
1415
+ dropAlignment: FieldDropAlignment | null;
1416
+ };
1417
+ export type RegisterFieldData = Pick<RegisteredField, 'fieldListType' | 'allowedFragments' | 'isNested' | 'nestingLevel' | 'dropAlignment'>;
1399
1418
  declare const _default: {};
1400
1419
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blokkli/editor",
3
- "version": "2.0.0-alpha.17",
3
+ "version": "2.0.0-alpha.19",
4
4
  "description": "Interactive page building experience for Nuxt",
5
5
  "repository": "blokkli/editor",
6
6
  "type": "module",