@blokkli/editor 2.0.0-alpha.16 → 2.0.0-alpha.18

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 (194) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +640 -137
  3. package/dist/modules/drupal/graphql/base/fragment.blokkliProps.graphql +1 -1
  4. package/dist/modules/drupal/graphql/base/fragment.paragraphsFieldItem.graphql +3 -1
  5. package/dist/modules/drupal/graphql/base/query.pbConfig.graphql +1 -10
  6. package/dist/modules/drupal/graphql/features/comments.graphql +11 -8
  7. package/dist/modules/drupal/graphql/mutations/set_paragraph_schedule.graphql +15 -0
  8. package/dist/modules/drupal/index.mjs +33 -0
  9. package/dist/modules/drupal/runtime/adapter/index.js +12 -4
  10. package/dist/runtime/adapter/index.d.ts +21 -0
  11. package/dist/runtime/blokkliPlugins/ContextMenu/Menu/index.vue +3 -0
  12. package/dist/runtime/blokkliPlugins/ItemAction/index.vue +23 -15
  13. package/dist/runtime/blokkliPlugins/ItemAction/index.vue.d.ts +20 -44
  14. package/dist/runtime/blokkliPlugins/TourItem/index.vue +10 -5
  15. package/dist/runtime/components/Blocks/FromLibrary/index.vue +4 -2
  16. package/dist/runtime/components/BlokkliEditable.vue +32 -14
  17. package/dist/runtime/components/BlokkliField.vue +3 -0
  18. package/dist/runtime/components/BlokkliField.vue.d.ts +3 -3
  19. package/dist/runtime/components/BlokkliItem.vue +1 -1
  20. package/dist/runtime/components/BlokkliItem.vue.d.ts +4 -2
  21. package/dist/runtime/components/BlokkliProvider.vue +41 -28
  22. package/dist/runtime/components/BlokkliProvider.vue.d.ts +2 -1
  23. package/dist/runtime/components/Edit/Actions/index.vue +36 -20
  24. package/dist/runtime/components/Edit/AnimationCanvas/index.vue +436 -25
  25. package/dist/runtime/components/Edit/ArtboardTooltip/index.vue +83 -0
  26. package/dist/runtime/components/Edit/ArtboardTooltip/index.vue.d.ts +32 -0
  27. package/dist/runtime/components/Edit/Banner/index.vue +51 -0
  28. package/dist/runtime/components/Edit/Banner/index.vue.d.ts +18 -0
  29. package/dist/runtime/components/Edit/Dialog/index.vue +6 -4
  30. package/dist/runtime/components/Edit/DraggableList.vue +15 -7
  31. package/dist/runtime/components/Edit/DraggableList.vue.d.ts +5 -5
  32. package/dist/runtime/components/Edit/EditIndicator.vue +118 -44
  33. package/dist/runtime/components/Edit/EditIndicator.vue.d.ts +3 -0
  34. package/dist/runtime/components/Edit/EditProvider.vue +101 -31
  35. package/dist/runtime/components/Edit/EditProvider.vue.d.ts +3 -0
  36. package/dist/runtime/components/Edit/Features/AddList/index.vue +9 -11
  37. package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue +28 -26
  38. package/dist/runtime/components/Edit/Features/Analyze/Renderer.vue +1 -1
  39. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +15 -11
  40. package/dist/runtime/components/Edit/Features/Anchors/Renderer.vue +19 -102
  41. package/dist/runtime/components/Edit/Features/Artboard/Renderer.vue +3 -0
  42. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +29 -53
  43. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/ScheduleSection.vue +154 -0
  44. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/ScheduleSection.vue.d.ts +27 -0
  45. package/dist/runtime/components/Edit/Features/BlockScheduler/Dialog/index.vue +222 -0
  46. package/dist/runtime/components/Edit/Features/{Selection/AddButtons/AddButtonsField.vue.d.ts → BlockScheduler/Dialog/index.vue.d.ts} +6 -9
  47. package/dist/runtime/components/Edit/Features/BlockScheduler/index.vue +96 -0
  48. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +15 -16
  49. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Item/index.vue +51 -0
  50. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/{Group → Item}/index.vue.d.ts +9 -13
  51. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/index.vue +46 -66
  52. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +2 -0
  53. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +35 -20
  54. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue.d.ts +5 -3
  55. package/dist/runtime/components/Edit/Features/Comments/CommentInput/index.vue +29 -0
  56. package/dist/runtime/components/Edit/Features/{Publish/Dialog/ScheduleDate.vue.d.ts → Comments/CommentInput/index.vue.d.ts} +2 -2
  57. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +22 -16
  58. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue.d.ts +1 -0
  59. package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue +15 -6
  60. package/dist/runtime/components/Edit/Features/Comments/index.vue +21 -9
  61. package/dist/runtime/components/Edit/Features/Conversions/index.vue +4 -7
  62. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +26 -35
  63. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue +240 -0
  64. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue.d.ts +6 -0
  65. package/dist/runtime/components/Edit/Features/Debug/index.vue +7 -165
  66. package/dist/runtime/components/Edit/Features/Delete/index.vue +1 -1
  67. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +14 -6
  68. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +55 -48
  69. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +30 -18
  70. package/dist/runtime/components/Edit/Features/Duplicate/index.vue +6 -8
  71. package/dist/runtime/components/Edit/Features/Edit/index.vue +16 -22
  72. package/dist/runtime/components/Edit/Features/EditForm/index.vue +7 -6
  73. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +69 -4
  74. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue.d.ts +2 -2
  75. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +13 -9
  76. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +45 -87
  77. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue.d.ts +2 -2
  78. package/dist/runtime/components/Edit/Features/EditableField/index.vue +41 -43
  79. package/dist/runtime/components/Edit/Features/Fragments/Dialog/index.vue +11 -9
  80. package/dist/runtime/components/Edit/Features/Fragments/index.vue +3 -3
  81. package/dist/runtime/components/Edit/Features/History/index.vue +5 -2
  82. package/dist/runtime/components/Edit/Features/Hover/Overlay/fragment.glsl +139 -0
  83. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue +261 -0
  84. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue.d.ts +6 -0
  85. package/dist/runtime/components/Edit/Features/Hover/Overlay/vertex.glsl +117 -0
  86. package/dist/runtime/components/Edit/Features/Hover/index.vue +25 -0
  87. package/dist/runtime/components/Edit/Features/Hover/index.vue.d.ts +2 -0
  88. package/dist/runtime/components/Edit/Features/Library/EditReusable/index.vue +5 -7
  89. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +19 -27
  90. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +32 -28
  91. package/dist/runtime/components/Edit/Features/Library/index.vue +28 -23
  92. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +6 -3
  93. package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +15 -12
  94. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +36 -29
  95. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +2 -4
  96. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +6 -1
  97. package/dist/runtime/components/Edit/Features/Options/Form/index.vue +8 -6
  98. package/dist/runtime/components/Edit/Features/Options/index.vue +6 -6
  99. package/dist/runtime/components/Edit/Features/Ownership/Renderer.vue +35 -0
  100. package/dist/runtime/components/Edit/Features/Ownership/Renderer.vue.d.ts +6 -0
  101. package/dist/runtime/components/Edit/Features/Ownership/index.vue +7 -25
  102. package/dist/runtime/components/Edit/Features/ProxyView/index.vue +5 -1
  103. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +68 -15
  104. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Page/index.vue +15 -15
  105. package/dist/runtime/components/Edit/Features/Search/index.vue +4 -1
  106. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue +39 -74
  107. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +7 -5
  108. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/fragment.glsl +106 -0
  109. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +440 -0
  110. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue.d.ts +32 -0
  111. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/vertex.glsl +102 -0
  112. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +53 -125
  113. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue.d.ts +2 -2
  114. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +88 -29
  115. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +5 -3
  116. package/dist/runtime/components/Edit/Features/Selection/Overlay/vertex.glsl +11 -2
  117. package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +2 -2
  118. package/dist/runtime/components/Edit/Features/Selection/index.vue +66 -39
  119. package/dist/runtime/components/Edit/Features/Structure/List/Field/index.vue +2 -2
  120. package/dist/runtime/components/Edit/Features/Structure/List/Item/index.vue +13 -6
  121. package/dist/runtime/components/Edit/Features/Tour/Overlay/index.vue +3 -0
  122. package/dist/runtime/components/Edit/Features/Transform/index.vue +2 -27
  123. package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +17 -11
  124. package/dist/runtime/components/Edit/Features/Translations/index.vue +20 -23
  125. package/dist/runtime/components/Edit/Features/Validations/SidebarItem/index.vue +5 -5
  126. package/dist/runtime/components/Edit/Features/index.vue +17 -7
  127. package/dist/runtime/components/Edit/Form/Text/index.vue +2 -1
  128. package/dist/runtime/components/Edit/Form/Text/index.vue.d.ts +1 -0
  129. package/dist/runtime/components/Edit/Form/Toggle/index.vue +4 -3
  130. package/dist/runtime/components/Edit/Form/Toggle/index.vue.d.ts +12 -2
  131. package/dist/runtime/components/Edit/Indicators/index.vue +1 -1
  132. package/dist/runtime/components/Edit/InfoBox/index.vue +6 -2
  133. package/dist/runtime/components/Edit/InfoBox/index.vue.d.ts +12 -2
  134. package/dist/runtime/components/Edit/Konami/Game/index.vue +5 -5
  135. package/dist/runtime/components/Edit/{Features/Publish/Dialog/ScheduleDate.vue → ScheduleDate/index.vue} +6 -58
  136. package/dist/runtime/components/Edit/ScheduleDate/index.vue.d.ts +23 -0
  137. package/dist/runtime/components/Edit/ShortcutIndicator/index.vue +3 -0
  138. package/dist/runtime/components/Edit/Transition/Height.vue +95 -0
  139. package/dist/runtime/components/Edit/Transition/Height.vue.d.ts +36 -0
  140. package/dist/runtime/components/Edit/index.d.ts +7 -3
  141. package/dist/runtime/components/Edit/index.js +12 -4
  142. package/dist/runtime/composables/defineBlokkli.js +4 -2
  143. package/dist/runtime/css/output.css +1 -1
  144. package/dist/runtime/helpers/animationProvider.d.ts +35 -1
  145. package/dist/runtime/helpers/animationProvider.js +179 -48
  146. package/dist/runtime/helpers/composables/defineRenderer.d.ts +8 -0
  147. package/dist/runtime/helpers/composables/defineRenderer.js +8 -0
  148. package/dist/runtime/helpers/composables/useStateBasedCache.d.ts +4 -0
  149. package/dist/runtime/helpers/composables/useStateBasedCache.js +13 -0
  150. package/dist/runtime/helpers/composables/useStickyToolbar.d.ts +4 -1
  151. package/dist/runtime/helpers/composables/useStickyToolbar.js +53 -35
  152. package/dist/runtime/helpers/definitionProvider.d.ts +1 -1
  153. package/dist/runtime/helpers/dom/index.d.ts +1 -0
  154. package/dist/runtime/helpers/domProvider.d.ts +54 -14
  155. package/dist/runtime/helpers/domProvider.js +168 -134
  156. package/dist/runtime/helpers/index.d.ts +1 -8
  157. package/dist/runtime/helpers/index.js +1 -84
  158. package/dist/runtime/helpers/providers/blocks.d.ts +10 -0
  159. package/dist/runtime/helpers/providers/blocks.js +91 -0
  160. package/dist/runtime/helpers/providers/directive.d.ts +24 -0
  161. package/dist/runtime/helpers/providers/directive.js +205 -0
  162. package/dist/runtime/helpers/providers/element.d.ts +6 -0
  163. package/dist/runtime/helpers/providers/element.js +35 -0
  164. package/dist/runtime/helpers/providers/fields.d.ts +8 -0
  165. package/dist/runtime/helpers/providers/fields.js +47 -0
  166. package/dist/runtime/helpers/selectionProvider.d.ts +11 -11
  167. package/dist/runtime/helpers/selectionProvider.js +38 -45
  168. package/dist/runtime/helpers/stateProvider.d.ts +7 -2
  169. package/dist/runtime/helpers/stateProvider.js +83 -14
  170. package/dist/runtime/helpers/storageProvider.d.ts +3 -2
  171. package/dist/runtime/helpers/storageProvider.js +6 -2
  172. package/dist/runtime/helpers/symbols.d.ts +1 -0
  173. package/dist/runtime/helpers/symbols.js +1 -0
  174. package/dist/runtime/helpers/themeProvider.d.ts +2 -1
  175. package/dist/runtime/helpers/themeProvider.js +24 -14
  176. package/dist/runtime/helpers/typesProvider.js +10 -26
  177. package/dist/runtime/helpers/uiProvider.d.ts +11 -3
  178. package/dist/runtime/helpers/uiProvider.js +45 -17
  179. package/dist/runtime/icons/calendar.svg +1 -0
  180. package/dist/runtime/icons/clock.svg +1 -0
  181. package/dist/runtime/icons/comment_add.svg +1 -5
  182. package/dist/runtime/icons/delete.svg +1 -8
  183. package/dist/runtime/icons/duplicate.svg +1 -12
  184. package/dist/runtime/icons/edit.svg +1 -8
  185. package/dist/runtime/icons/reusable.svg +1 -5
  186. package/dist/runtime/plugins/blokkliDirectives.js +96 -0
  187. package/dist/runtime/types/index.d.ts +66 -35
  188. package/package.json +1 -1
  189. package/dist/runtime/components/Edit/DragInteractions/index.vue +0 -401
  190. package/dist/runtime/components/Edit/Features/CommandPalette/Palette/Group/index.vue +0 -63
  191. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue +0 -54
  192. package/dist/runtime/plugins/blokkliEditable.js +0 -31
  193. /package/dist/runtime/components/Edit/{DragInteractions → Features/BlockScheduler}/index.vue.d.ts +0 -0
  194. /package/dist/runtime/plugins/{blokkliEditable.d.ts → blokkliDirectives.d.ts} +0 -0
@@ -1,20 +1,12 @@
1
1
  <template>
2
2
  <Overlay
3
3
  v-if="isVisible && gl && animation.webglEnabled.value"
4
- :blocks="selection.blocks.value"
4
+ :blocks="selection.items.value"
5
5
  :uuids="selection.uuids.value"
6
6
  :gl="gl"
7
+ :has-host-selected="selection.hasHostSelected.value"
7
8
  />
8
9
  <OverlayFallback v-if="isVisible && !gl" :uuids="selection.uuids.value" />
9
- <Teleport :to="artboardElement">
10
- <div
11
- class="bk bk-host-selection-overlay"
12
- :style="{
13
- visibility: selection.hasHostSelected.value ? 'visible' : 'hidden'
14
- }"
15
- />
16
- </Teleport>
17
-
18
10
  <PluginItemDropdown
19
11
  v-if="itemDropdownItems.length"
20
12
  id="selection"
@@ -28,7 +20,7 @@
28
20
 
29
21
  <SelectionAddButtons
30
22
  v-if="state.editMode.value === 'editing'"
31
- :blocks="selection.blocks.value"
23
+ :items="selection.items.value"
32
24
  />
33
25
  </template>
34
26
 
@@ -40,9 +32,11 @@ import {
40
32
  calculateIntersection,
41
33
  getBounds,
42
34
  intersects,
35
+ modulo,
43
36
  originatesFromTextInput
44
37
  } from "#blokkli/helpers";
45
38
  import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
39
+ import useStateBasedCache from "#blokkli/helpers/composables/useStateBasedCache";
46
40
  import { PluginItemDropdown } from "#blokkli/plugins";
47
41
  import {
48
42
  computed,
@@ -51,26 +45,39 @@ import {
51
45
  ref,
52
46
  watch
53
47
  } from "#imports";
48
+ import { itemEntityType } from "#blokkli-build/config";
54
49
  defineBlokkliFeature({
55
50
  id: "selection",
56
51
  icon: "selection",
57
52
  label: "Selection",
58
53
  description: "Renders an overlay that highlights the selected blocks."
59
54
  });
60
- const { selection, ui, eventBus, animation, dom, tour, $t, types, state } = useBlokkli();
55
+ const {
56
+ selection,
57
+ ui,
58
+ eventBus,
59
+ animation,
60
+ dom,
61
+ tour,
62
+ $t,
63
+ types,
64
+ state,
65
+ blocks,
66
+ element
67
+ } = useBlokkli();
68
+ const getSelectionOrder = useStateBasedCache(() => {
69
+ return element.queryAll(
70
+ ui.artboardElement(),
71
+ "[data-uuid]",
72
+ "getSelectionOrder",
73
+ (el) => el.dataset.uuid
74
+ );
75
+ });
61
76
  const selectedBundle = computed(() => {
62
- let bundle = "";
63
- for (let i = 0; i < selection.blocks.value.length; i++) {
64
- const block = selection.blocks.value[i];
65
- if (!block) {
66
- return null;
67
- }
68
- if (bundle && bundle !== block.itemBundle) {
69
- return null;
70
- }
71
- bundle = block.itemBundle;
77
+ if (selection.bundles.value.length === 1) {
78
+ return selection.bundles.value[0] ?? null;
72
79
  }
73
- return bundle || null;
80
+ return null;
74
81
  });
75
82
  const itemDropdownEnabled = computed(() => true);
76
83
  const itemDropdownItems = computed(() => {
@@ -105,7 +112,6 @@ function onSelectDropdownItem(item) {
105
112
  selectAllBlocks();
106
113
  }
107
114
  }
108
- const artboardElement = ui.artboardElement();
109
115
  const gl = animation.gl();
110
116
  const hasSelectedOnce = ref(false);
111
117
  const stop = watch(
@@ -144,10 +150,10 @@ const findMostVisibleBlock = () => {
144
150
  };
145
151
  const getSelectAllUuids = (allBlocks, currentlySelected) => {
146
152
  if (currentlySelected.length >= 1) {
147
- const selectedHostUuids = currentlySelected.map((block) => block.hostUuid);
148
- const selectedHostTypes = currentlySelected.map((block) => block.hostType);
153
+ const selectedHostUuids = currentlySelected.map((block) => block.host.uuid);
154
+ const selectedHostTypes = currentlySelected.map((block) => block.host.type);
149
155
  const selectedHostFieldNames = currentlySelected.map(
150
- (block) => block.hostFieldName
156
+ (block) => block.host.fieldName
151
157
  );
152
158
  const selectedUuids = currentlySelected.map((v) => v.uuid);
153
159
  const commonHostUuids = selectedHostUuids.filter(
@@ -160,14 +166,14 @@ const getSelectAllUuids = (allBlocks, currentlySelected) => {
160
166
  (fieldName, index, self) => self.indexOf(fieldName) === index
161
167
  );
162
168
  const newUuids = allBlocks.filter(
163
- (block) => commonHostUuids.includes(block.hostUuid) && commonHostTypes.includes(block.hostType) && commonHostFieldNames.includes(block.hostFieldName)
169
+ (block) => commonHostUuids.includes(block.host.uuid) && commonHostTypes.includes(block.host.type) && commonHostFieldNames.includes(block.host.fieldName)
164
170
  ).map((block) => block.uuid);
165
171
  const isSame = newUuids.every((uuid) => selectedUuids.includes(uuid));
166
172
  if (!isSame) {
167
173
  return newUuids;
168
174
  }
169
175
  }
170
- return allBlocks.filter((block) => block.hostType !== "block").map((block) => block.uuid);
176
+ return allBlocks.filter((block) => block.host.type !== itemEntityType).map((block) => block.uuid);
171
177
  };
172
178
  const visuallySelectBlocks = (toggleUuid) => {
173
179
  const rects = dom.getBlockRects();
@@ -176,12 +182,12 @@ const visuallySelectBlocks = (toggleUuid) => {
176
182
  if (selected.length === 0) {
177
183
  return [toggleUuid];
178
184
  }
179
- const singleSelectedBlock = selected.length === 1 ? dom.findBlock(selected[0]) : null;
185
+ const singleSelectedBlock = selected.length === 1 ? blocks.getBlock(selected[0]) : null;
180
186
  const toggleRect = rects[toggleUuid];
181
187
  if (!toggleRect) {
182
188
  return;
183
189
  }
184
- const toggleBlock = dom.findBlock(toggleUuid);
190
+ const toggleBlock = blocks.getBlock(toggleUuid);
185
191
  if (!toggleBlock) {
186
192
  return;
187
193
  }
@@ -196,7 +202,7 @@ const visuallySelectBlocks = (toggleUuid) => {
196
202
  if (!intersects(rect, encompassingRect2)) {
197
203
  continue;
198
204
  }
199
- const block = dom.findBlock(uuid);
205
+ const block = blocks.getBlock(uuid);
200
206
  if (!block) {
201
207
  continue;
202
208
  }
@@ -240,7 +246,7 @@ const visuallySelectBlocks = (toggleUuid) => {
240
246
  function selectAllBlocks() {
241
247
  eventBus.emit(
242
248
  "select:end",
243
- getSelectAllUuids(dom.getAllBlocks(), selection.blocks.value)
249
+ getSelectAllUuids(blocks.getAllBlocks(), selection.items.value)
244
250
  );
245
251
  }
246
252
  onBlokkliEvent("select:shiftToggle", (uuid) => {
@@ -249,19 +255,40 @@ onBlokkliEvent("select:shiftToggle", (uuid) => {
249
255
  eventBus.emit("select", uuids);
250
256
  }
251
257
  });
258
+ function selectBlock(uuid) {
259
+ eventBus.emit("select", uuid);
260
+ dom.refreshBlockRect(uuid);
261
+ eventBus.emit("scrollIntoView", { uuid });
262
+ }
263
+ function selectInList(prev) {
264
+ const currentUuid = selection.uuids.value[selection.uuids.value.length - 1];
265
+ if (!currentUuid) {
266
+ return;
267
+ }
268
+ const selectionOrder = getSelectionOrder();
269
+ const currentIndex = selectionOrder.indexOf(currentUuid);
270
+ const delta = prev ? -1 : 1;
271
+ const newIndex = modulo(currentIndex + delta, selectionOrder.length);
272
+ const newUuid = selectionOrder[newIndex];
273
+ if (newUuid) {
274
+ selectBlock(newUuid);
275
+ }
276
+ }
252
277
  onBlokkliEvent("keyPressed", (e) => {
253
- if (selection.isDragging.value || selection.isMultiSelecting.value) {
278
+ if (selection.isDragging.value || selection.isMultiSelecting.value || ui.hasDialogOpen.value || ui.hasTooltipOpen.value) {
254
279
  return;
255
280
  }
256
281
  if (e.code === "Escape") {
257
- eventBus.emit("select:end", []);
258
- eventBus.emit("select:host:unselect");
282
+ if (!ui.openTooltip.value) {
283
+ eventBus.emit("select:end", []);
284
+ eventBus.emit("select:host:unselect");
285
+ }
259
286
  } else if (e.code === "Tab") {
260
287
  if (tour.isTouring.value || ui.hasDialogOpen.value) {
261
288
  return;
262
289
  }
263
290
  e.originalEvent.preventDefault();
264
- if (selection.blocks.value.length !== 1) {
291
+ if (!selection.items.value.length) {
265
292
  const uuid = findMostVisibleBlock();
266
293
  if (uuid) {
267
294
  eventBus.emit("select", uuid);
@@ -270,9 +297,9 @@ onBlokkliEvent("keyPressed", (e) => {
270
297
  return;
271
298
  }
272
299
  if (e.shift) {
273
- eventBus.emit("select:previous");
300
+ selectInList(true);
274
301
  } else {
275
- eventBus.emit("select:next");
302
+ selectInList();
276
303
  }
277
304
  animation.requestDraw();
278
305
  } else if (e.code === "a" && e.meta) {
@@ -75,14 +75,14 @@ const targetStyle = computed(() => {
75
75
  zIndex: 50 + props.level
76
76
  };
77
77
  });
78
- const { types, state, selection, dom, eventBus } = useBlokkli();
78
+ const { types, state, selection, eventBus, fields } = useBlokkli();
79
79
  const mutatedField = computed(
80
80
  () => state.getMutatedField(props.entityUuid, props.name)
81
81
  );
82
82
  const list = computed(() => mutatedField.value?.list || []);
83
83
  const key = computed(() => props.entityUuid + ":" + props.name);
84
84
  function onMouseUp(preceedingUuid) {
85
- const field = dom.findField(props.entityUuid, props.name);
85
+ const field = fields.find(props.entityUuid, props.name);
86
86
  if (!field) {
87
87
  return;
88
88
  }
@@ -33,14 +33,18 @@ const props = defineProps({
33
33
  isVisible: { type: Boolean, required: true },
34
34
  isSelectedFromParent: { type: Boolean, required: false }
35
35
  });
36
+ const { runtimeConfig, types, selection, eventBus, state, element } = useBlokkli();
36
37
  function getRootEl() {
37
- const rootEl = document.querySelector("#bk-structure");
38
+ const rootEl = element.query(
39
+ document.documentElement,
40
+ "#bk-structure",
41
+ "Get root structure element."
42
+ );
38
43
  if (!(rootEl instanceof HTMLElement)) {
39
44
  throw new TypeError("Failed to locate root structure element.");
40
45
  }
41
46
  return rootEl;
42
47
  }
43
- const { runtimeConfig, types, selection, eventBus, state } = useBlokkli();
44
48
  const canMove = computed(() => state.editMode.value === "editing");
45
49
  const isSelected = computed(() => selection.uuids.value.includes(props.uuid));
46
50
  const type = computed(() => types.getBlockBundleDefinition(props.bundle));
@@ -66,15 +70,18 @@ function onMouseUp(e) {
66
70
  }
67
71
  }
68
72
  function buildDraggableItems() {
69
- return selection.blocks.value.map((block) => {
70
- const el = document.querySelector(`[bk-structure-uuid="${block.uuid}"]`);
73
+ return selection.items.value.map((block) => {
74
+ const el = element.query(
75
+ document.documentElement,
76
+ `[bk-structure-uuid="${block.uuid}"]`,
77
+ "Get structure item for draggable item."
78
+ );
71
79
  if (!(el instanceof HTMLElement)) {
72
80
  return null;
73
81
  }
74
82
  return {
75
83
  itemType: "existing_structure",
76
- uuid: block.uuid,
77
- itemBundle: block.itemBundle,
84
+ block,
78
85
  element: function() {
79
86
  return el;
80
87
  }
@@ -188,6 +188,9 @@ function calculatePosition(rect) {
188
188
  };
189
189
  }
190
190
  onBlokkliEvent("keyPressed", (e) => {
191
+ if (ui.hasDialogOpen.value) {
192
+ return;
193
+ }
191
194
  if (e.code === "Tab") {
192
195
  e.originalEvent.preventDefault();
193
196
  if (e.shift) {
@@ -2,7 +2,7 @@
2
2
  <PluginItemDropdown
3
3
  id="transform"
4
4
  :title="$t('transformTo', 'Actions')"
5
- :enabled="!!(itemBundleIds.length && possibleTransforms.length)"
5
+ :enabled="!!possibleTransforms.length"
6
6
  :items="possibleTransforms"
7
7
  icon="script"
8
8
  weight="100"
@@ -43,7 +43,6 @@ import {
43
43
  useLazyAsyncData
44
44
  } from "#imports";
45
45
  import { PluginItemDropdown } from "#blokkli/plugins";
46
- import { onlyUnique } from "#blokkli/helpers";
47
46
  import { BlokkliTransition } from "#blokkli/components";
48
47
  import { filterTransforms } from "#blokkli/helpers/transform";
49
48
  import defineCommands from "#blokkli/helpers/composables/defineCommands";
@@ -200,14 +199,11 @@ async function onTransformHost(plugin, values) {
200
199
  );
201
200
  ui.setTransform();
202
201
  }
203
- const itemBundleIds = computed(
204
- () => selection.blocks.value.map((v) => v.itemBundle).filter(onlyUnique)
205
- );
206
202
  const possibleTransforms = computed(
207
203
  () => filterTransforms(
208
204
  plugins.value || [],
209
205
  selection.uuids.value,
210
- itemBundleIds.value,
206
+ selection.bundles.value,
211
207
  types.allowedTypesInList.value
212
208
  )
213
209
  );
@@ -222,27 +218,6 @@ defineCommands(
222
218
  }
223
219
  }))
224
220
  );
225
- const getPossibleDropTransforms = (plugins2, allBlocks, dragItems) => {
226
- const notDraggedBlocks = allBlocks.filter(
227
- (block) => !dragItems.find((dragItem) => dragItem.uuid === block.uuid)
228
- );
229
- const validPlugins = plugins2.filter((plugin) => {
230
- const draggedBundles = dragItems.map((item) => item.itemBundle);
231
- return draggedBundles.every((bundle) => plugin.bundles.includes(bundle)) && dragItems.length + 1 >= plugin.min && (plugin.max === -1 || dragItems.length + 1 <= plugin.max);
232
- });
233
- const possibleTransforms2 = [];
234
- validPlugins.forEach((plugin) => {
235
- notDraggedBlocks.forEach((block) => {
236
- if (!plugin.targetBundles || plugin.targetBundles.includes(block.itemBundle)) {
237
- possibleTransforms2.push({
238
- plugin,
239
- block
240
- });
241
- }
242
- });
243
- });
244
- return possibleTransforms2;
245
- };
246
221
  </script>
247
222
 
248
223
  <script>
@@ -1,21 +1,21 @@
1
1
  <template>
2
- <div class="bk bk-translations-banner">
3
- <Icon name="translate" />
4
- <p v-html="text" />
5
- <button class="bk-translations-banner-close" @click="onClick">
6
- {{ $t("translationsBannerButton", "Edit source language instead") }}
7
- <Icon name="close" />
8
- </button>
9
- </div>
2
+ <Banner
3
+ id="translate"
4
+ icon="translate"
5
+ :text
6
+ :button="$t('translationsBannerButton', 'Edit source language instead')"
7
+ scheme="yellow"
8
+ @click="onClick"
9
+ />
10
10
  </template>
11
11
 
12
12
  <script setup>
13
- import { computed, useBlokkli } from "#imports";
14
- import { Icon } from "#blokkli/components";
13
+ import { computed, useBlokkli, onMounted, onBeforeUnmount } from "#imports";
14
+ import { Banner } from "#blokkli/components";
15
15
  const props = defineProps({
16
16
  activeLanguage: { type: Object, required: true }
17
17
  });
18
- const { $t, adapter, state } = useBlokkli();
18
+ const { $t, adapter, state, ui } = useBlokkli();
19
19
  const onClick = () => {
20
20
  const sourceLanguage = state.translation.value.sourceLanguage;
21
21
  if (!sourceLanguage) {
@@ -39,4 +39,10 @@ const text = computed(() => {
39
39
  "You are currently editing the <strong>@language</strong> translation. Some features like adding, moving or deleting blocks are not available."
40
40
  ).replace("@language", props.activeLanguage.name);
41
41
  });
42
+ onMounted(() => {
43
+ ui.setSelectionColor("translating", "mono");
44
+ });
45
+ onBeforeUnmount(() => {
46
+ ui.removeSelectionColor("translating");
47
+ });
42
48
  </script>
@@ -48,11 +48,8 @@
48
48
  </PluginTourItem>
49
49
  </Teleport>
50
50
 
51
- <Teleport to="#bk-banner-container">
52
- <Banner
53
- v-if="state.editMode.value === 'translating'"
54
- :active-language="activeLanguage"
55
- />
51
+ <Teleport to="#bk-banner-list">
52
+ <Banner v-if="isTranslating" :active-language />
56
53
  </Teleport>
57
54
 
58
55
  <PluginMenuButton
@@ -61,14 +58,14 @@
61
58
  :description="
62
59
  $t('translationsBatchTranslateMenuDescription', 'Translate all blocks')
63
60
  "
64
- :disabled="editMode !== 'translating'"
61
+ :disabled="!isTranslating"
65
62
  :weight="60"
66
63
  icon="translate"
67
64
  @click="eventBus.emit('batchTranslate')"
68
65
  />
69
66
 
70
67
  <PluginItemAction
71
- v-if="editMode === 'translating'"
68
+ v-if="isTranslating"
72
69
  id="translate"
73
70
  :disabled="!canTranslateBlock"
74
71
  :title="$t('translationsItemAction', 'Translate')"
@@ -102,7 +99,7 @@ const { adapter } = defineBlokkliFeature({
102
99
  description: "Adds support for block translations."
103
100
  });
104
101
  const { eventBus, state, context, $t, ui, selection, types, definitions } = useBlokkli();
105
- const { translation, editMode } = state;
102
+ const isTranslating = computed(() => state.editMode.value === "translating");
106
103
  const isOpen = ref(false);
107
104
  const isDropdown = computed(() => {
108
105
  if (ui.isMobile.value) {
@@ -113,7 +110,7 @@ const isDropdown = computed(() => {
113
110
  });
114
111
  const activeLangcode = computed(() => context.value.language);
115
112
  const activeLanguage = computed(() => {
116
- return translation.value.availableLanguages?.find(
113
+ return state.translation.value.availableLanguages?.find(
117
114
  (v) => v.id === activeLangcode.value
118
115
  ) || {
119
116
  id: activeLangcode.value,
@@ -121,14 +118,14 @@ const activeLanguage = computed(() => {
121
118
  };
122
119
  });
123
120
  const items = computed(() => {
124
- return (translation.value.availableLanguages || []).map((language) => {
121
+ return (state.translation.value.availableLanguages || []).map((language) => {
125
122
  if (language && language.id) {
126
123
  return {
127
124
  id: language.id,
128
125
  code: language.id.toUpperCase(),
129
126
  label: language.name,
130
127
  checked: context.value.language === language.id,
131
- translation: (translation.value.translations || []).find(
128
+ translation: (state.translation.value.translations || []).find(
132
129
  (v) => v.id === language.id
133
130
  )
134
131
  };
@@ -137,22 +134,22 @@ const items = computed(() => {
137
134
  }).filter(falsy);
138
135
  });
139
136
  const canTranslateBlock = computed(() => {
140
- if (selection.blocks.value.length !== 1) {
137
+ const block = selection.item.value;
138
+ if (!block) {
141
139
  return false;
142
140
  }
143
- const block = selection.blocks.value[0];
144
- if (block.libraryItemUuid) {
141
+ if (block.library?.libraryItemUuid) {
145
142
  return false;
146
143
  }
147
144
  const definition = definitions.getBlockDefinition(
148
- block.itemBundle,
149
- block.hostFieldListType,
145
+ block.bundle,
146
+ block.fieldListType,
150
147
  block.parentBlockBundle
151
148
  );
152
149
  if (definition?.editor?.disableEdit) {
153
150
  return false;
154
151
  }
155
- const type = types.getBlockBundleDefinition(block.itemBundle);
152
+ const type = types.getBlockBundleDefinition(block.bundle);
156
153
  if (!type) {
157
154
  return false;
158
155
  }
@@ -175,17 +172,17 @@ function onTranslate(items2) {
175
172
  if (item) {
176
173
  eventBus.emit("item:edit", {
177
174
  uuid: item.uuid,
178
- bundle: item.itemBundle
175
+ bundle: item.bundle
179
176
  });
180
177
  }
181
178
  }
182
179
  onBlokkliEvent("item:doubleClick", function(block) {
183
- if (editMode.value === "translating" && canTranslateBlock.value) {
180
+ if (isTranslating.value && canTranslateBlock.value) {
184
181
  onTranslate([block]);
185
182
  }
186
183
  });
187
184
  onBlokkliEvent("entity:translated", (langcode) => {
188
- const targetTranslation = translation.value.translations?.find(
185
+ const targetTranslation = state.translation.value.translations?.find(
189
186
  (v) => v.id === langcode
190
187
  );
191
188
  if (targetTranslation) {
@@ -193,12 +190,12 @@ onBlokkliEvent("entity:translated", (langcode) => {
193
190
  }
194
191
  });
195
192
  onMounted(() => {
196
- const translationExists = !!translation.value.translations?.find(
193
+ const translationExists = !!state.translation.value.translations?.find(
197
194
  (v) => v.id === context.value.language
198
195
  );
199
196
  if (!translationExists) {
200
- const sourceTranslation = translation.value.translations?.find(
201
- (v) => v.id === translation.value.sourceLanguage
197
+ const sourceTranslation = state.translation.value.translations?.find(
198
+ (v) => v.id === state.translation.value.sourceLanguage
202
199
  );
203
200
  if (sourceTranslation) {
204
201
  return adapter.changeLanguage(sourceTranslation);
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <button class="bk-validation-item" @click.prevent="onClick">
3
3
  <div v-if="block" class="bk-validation-item-header">
4
- <ItemIcon :bundle="block.itemBundle" />
4
+ <ItemIcon :bundle="block.bundle" />
5
5
  <div>{{ itemBundle?.label }}</div>
6
6
  </div>
7
7
  <div v-html="message" />
@@ -18,19 +18,19 @@ const props = defineProps({
18
18
  entityType: { type: String, required: false },
19
19
  entityUuid: { type: String, required: false }
20
20
  });
21
- const { runtimeConfig, eventBus, dom, types } = useBlokkli();
21
+ const { runtimeConfig, eventBus, types, blocks } = useBlokkli();
22
22
  const isBlock = computed(
23
23
  () => props.entityType === runtimeConfig.itemEntityType
24
24
  );
25
25
  const block = computed(() => {
26
26
  if (isBlock.value && props.entityUuid) {
27
- return dom.findBlock(props.entityUuid);
27
+ return blocks.getBlock(props.entityUuid);
28
28
  }
29
29
  return null;
30
30
  });
31
31
  const itemBundle = computed(() => {
32
- if (block.value?.itemBundle) {
33
- return types.getBlockBundleDefinition(block.value.itemBundle);
32
+ if (block.value?.bundle) {
33
+ return types.getBlockBundleDefinition(block.value.bundle);
34
34
  }
35
35
  return null;
36
36
  });
@@ -10,7 +10,7 @@
10
10
  import {
11
11
  featureComponents
12
12
  } from "#blokkli-build/features";
13
- import { useBlokkli, onMounted, nextTick, computed } from "#imports";
13
+ import { useBlokkli, computed, watch } from "#imports";
14
14
  const emit = defineEmits(["loaded"]);
15
15
  const { adapter, features, ui, debug } = useBlokkli();
16
16
  const logger = debug.createLogger("Features");
@@ -37,12 +37,22 @@ const availableFeatures = computed(() => {
37
37
  return v.id;
38
38
  });
39
39
  });
40
- onMounted(() => {
41
- nextTick(() => {
42
- emit("loaded");
43
- logger.log("Features loaded", renderedFeatures.value);
44
- });
45
- });
40
+ const hasLoadedFeatures = computed(
41
+ () => renderedFeatures.value.length === availableFeatures.value.length
42
+ );
43
+ const unwatchInit = watch(
44
+ hasLoadedFeatures,
45
+ (hasLoaded) => {
46
+ if (hasLoaded) {
47
+ emit("loaded");
48
+ logger.log("Features loaded", renderedFeatures.value);
49
+ unwatchInit();
50
+ }
51
+ },
52
+ {
53
+ immediate: true
54
+ }
55
+ );
46
56
  </script>
47
57
 
48
58
  <script>
@@ -27,7 +27,8 @@ defineProps({
27
27
  required: { type: Boolean, required: false },
28
28
  disabled: { type: Boolean, required: false },
29
29
  minlength: { type: [String, Number], required: false },
30
- maxlength: { type: [String, Number], required: false }
30
+ maxlength: { type: [String, Number], required: false },
31
+ type: { type: String, required: false }
31
32
  });
32
33
  const value = defineModel({ type: String });
33
34
  </script>
@@ -7,6 +7,7 @@ type __VLS_Props = {
7
7
  disabled?: boolean;
8
8
  minlength?: string | number;
9
9
  maxlength?: string | number;
10
+ type?: string;
10
11
  };
11
12
  type __VLS_PublicProps = __VLS_Props & {
12
13
  modelValue?: string;
@@ -1,9 +1,10 @@
1
1
  <template>
2
2
  <label class="bk-checkbox-toggle">
3
+ <slot />
3
4
  <input v-model="value" type="checkbox" class="peer" :disabled />
4
5
  <div class="bk-checkbox-toggle-toggle" />
5
- <div class="bk-checkbox-toggle-label">
6
- <div>{{ label }}</div>
6
+ <div v-if="label || description" class="bk-checkbox-toggle-label">
7
+ <div v-if="label">{{ label }}</div>
7
8
  <div v-if="description">
8
9
  {{ description }}
9
10
  </div>
@@ -13,7 +14,7 @@
13
14
 
14
15
  <script setup>
15
16
  defineProps({
16
- label: { type: String, required: true },
17
+ label: { type: String, required: false },
17
18
  description: { type: String, required: false },
18
19
  disabled: { type: Boolean, required: false }
19
20
  });
@@ -1,14 +1,24 @@
1
1
  type __VLS_Props = {
2
- label: string;
2
+ label?: string;
3
3
  description?: string;
4
4
  disabled?: boolean;
5
5
  };
6
6
  type __VLS_PublicProps = __VLS_Props & {
7
7
  modelValue?: boolean;
8
8
  };
9
- declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
+ declare var __VLS_1: {};
10
+ type __VLS_Slots = {} & {
11
+ default?: (props: typeof __VLS_1) => any;
12
+ };
13
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
14
  "update:modelValue": (value: boolean | undefined) => any;
11
15
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
12
16
  "onUpdate:modelValue"?: ((value: boolean | undefined) => any) | undefined;
13
17
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
14
19
  export default _default;
20
+ type __VLS_WithSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };