@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,401 +0,0 @@
1
- <template>
2
- <div />
3
- </template>
4
-
5
- <script setup>
6
- import {
7
- falsy,
8
- getDistance,
9
- getInteractionCoordinates,
10
- isInsideRect
11
- } from "#blokkli/helpers";
12
- import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
13
- import { MOUSE_BUTTON, MOUSE_BUTTONS } from "#blokkli/helpers/dom";
14
- import { watch, ref, useBlokkli, onMounted, onBeforeUnmount } from "#imports";
15
- const { dom, eventBus, selection, keyboard, ui, state } = useBlokkli();
16
- const rootEl = ui.rootElement();
17
- const rects = ref([]);
18
- function buildRects() {
19
- const visible = dom.getVisibleBlocks();
20
- rects.value = visible.map((uuid) => {
21
- const rect = dom.getBlockRect(uuid);
22
- if (!rect) {
23
- return;
24
- }
25
- return { uuid, rect };
26
- }).filter(falsy);
27
- }
28
- watch(dom.isReady, buildRects);
29
- let lastInteractedElement = null;
30
- let pointerDownElement = null;
31
- let mouseStartCoordinates = null;
32
- let pointerDownTimestamp = 0;
33
- let pointerUpTimestamp = 0;
34
- function getInteractedElement(e) {
35
- const { x, y } = getInteractionCoordinates(e);
36
- const elements = document.elementsFromPoint(x, y);
37
- let editableFieldName = "";
38
- let uuid = "";
39
- for (let i = 0; i < elements.length; i++) {
40
- let el = elements[i];
41
- if (!(el instanceof HTMLElement)) {
42
- continue;
43
- }
44
- if (el.dataset.blokkliEditableField && !el.closest('[data-bk-in-proxy="true"]')) {
45
- editableFieldName = el.dataset.blokkliEditableField;
46
- }
47
- if (el instanceof HTMLTableCellElement) {
48
- const parent = el.parentElement;
49
- if (parent instanceof HTMLTableRowElement) {
50
- el = parent;
51
- }
52
- }
53
- if (!(el instanceof HTMLElement)) {
54
- continue;
55
- }
56
- if (!el.dataset.uuid) {
57
- continue;
58
- }
59
- const block = dom.findBlock(el.dataset.uuid);
60
- if (!block) {
61
- continue;
62
- }
63
- const draggableEl = dom.getDragElement(block);
64
- if (draggableEl && el !== draggableEl && !elements.includes(draggableEl)) {
65
- continue;
66
- }
67
- uuid = el.dataset.uuid;
68
- break;
69
- }
70
- if (editableFieldName || uuid) {
71
- return { editableFieldName, uuid, timestamp: Date.now(), x, y };
72
- }
73
- const visibleUuids = dom.getVisibleBlocks();
74
- for (let i = 0; i < visibleUuids.length; i++) {
75
- const rect = dom.getBlockRect(visibleUuids[i]);
76
- if (rect) {
77
- const relativeRect = ui.getViewportRelativeRect(rect);
78
- if (isInsideRect(x, y, relativeRect)) {
79
- return {
80
- uuid: visibleUuids[i],
81
- timestamp: Date.now(),
82
- x,
83
- y
84
- };
85
- }
86
- }
87
- }
88
- return null;
89
- }
90
- function onPointerMove(e) {
91
- if (keyboard.isPressingSpace.value || state.editMode.value !== "editing" || e.buttons === MOUSE_BUTTONS.AUXILIARY) {
92
- return;
93
- }
94
- e.preventDefault();
95
- e.stopPropagation();
96
- e.stopImmediatePropagation();
97
- if (e.pointerType === "touch") {
98
- return onTouchMove(e);
99
- }
100
- if (e.buttons !== MOUSE_BUTTONS.PRIMARY) {
101
- return;
102
- }
103
- if (!mouseStartCoordinates || selection.isMultiSelecting.value || selection.isDragging.value || keyboard.isPressingSpace.value) {
104
- return;
105
- }
106
- const diffX = Math.abs(mouseStartCoordinates.x - e.clientX);
107
- const diffY = Math.abs(mouseStartCoordinates.y - e.clientY);
108
- if (!pointerDownElement) {
109
- const timeDelta = Date.now() - pointerDownTimestamp;
110
- const maxMovement = Math.max(diffX, diffY);
111
- if (maxMovement > 6 && timeDelta > 150 || maxMovement > 20) {
112
- rootEl.removeEventListener("pointermove", onPointerMove);
113
- eventBus.emit("multi-select:start", {
114
- x: e.clientX,
115
- y: e.clientY
116
- });
117
- }
118
- return;
119
- }
120
- if (diffX < 6 && diffY < 6) {
121
- return;
122
- }
123
- const interacted = getInteractedElement(e);
124
- if (interacted && interacted.uuid) {
125
- if (selection.uuids.value.includes(interacted.uuid)) {
126
- eventBus.emit("dragging:start", {
127
- items: [...selection.blocks.value],
128
- coords: { x: e.clientX, y: e.clientY },
129
- mode: "mouse"
130
- });
131
- } else {
132
- const block = dom.findBlock(interacted.uuid);
133
- if (block) {
134
- eventBus.emit("dragging:start", {
135
- items: [block],
136
- coords: { x: e.clientX, y: e.clientY },
137
- mode: "mouse"
138
- });
139
- }
140
- }
141
- rootEl.removeEventListener("pointermove", onPointerMove);
142
- }
143
- }
144
- function onPointerDown(e) {
145
- if (e.buttons === MOUSE_BUTTONS.AUXILIARY) {
146
- return;
147
- }
148
- if (!keyboard.isPressingSpace.value) {
149
- e.preventDefault();
150
- e.stopPropagation();
151
- e.stopImmediatePropagation();
152
- }
153
- keyboard.setShortcutStateFromEvent(e);
154
- rootEl.removeEventListener("pointermove", onPointerMove);
155
- if (state.isLoading.value) {
156
- return;
157
- }
158
- rootEl.addEventListener("pointermove", onPointerMove);
159
- if (e.pointerType === "touch") {
160
- return onTouchStart(e);
161
- }
162
- if (selection.isDragging.value) {
163
- return;
164
- }
165
- pointerDownTimestamp = Date.now();
166
- const coords = { x: e.clientX, y: e.clientY };
167
- mouseStartCoordinates = coords;
168
- if (!e.shiftKey && e.buttons === MOUSE_BUTTONS.PRIMARY) {
169
- const interacted = getInteractedElement(e);
170
- pointerDownElement = interacted;
171
- if (interacted) {
172
- return;
173
- }
174
- }
175
- eventBus.emit("mouse:down", { ...coords, type: "mouse", distance: 0 });
176
- }
177
- function isClickInArtboard(coords) {
178
- const size = ui.artboardSize.value;
179
- const scale = ui.artboardScale.value;
180
- const rect = {
181
- x: ui.artboardOffset.value.x,
182
- y: ui.artboardOffset.value.y,
183
- width: size.width * scale,
184
- height: size.height * scale
185
- };
186
- return isInsideRect(coords.x, coords.y, rect);
187
- }
188
- function onPointerUp(e) {
189
- rootEl.removeEventListener("pointermove", onPointerMove);
190
- if (e.button === MOUSE_BUTTON.AUXILIARY) {
191
- e.preventDefault();
192
- return;
193
- }
194
- e.preventDefault();
195
- e.stopPropagation();
196
- e.stopImmediatePropagation();
197
- const wasDragging = selection.isDragging.value;
198
- const wasMultiSelecting = selection.isMultiSelecting.value;
199
- pointerDownElement = null;
200
- if (state.isLoading.value) {
201
- return;
202
- }
203
- if (e.pointerType === "touch") {
204
- return onTouchEnd(e);
205
- }
206
- const coords = getInteractionCoordinates(e);
207
- const distance = mouseStartCoordinates ? getDistance(mouseStartCoordinates, coords) : 0;
208
- eventBus.emit("mouse:up", {
209
- x: e.clientX,
210
- y: e.clientY,
211
- type: "mouse",
212
- distance,
213
- duration: Date.now() - pointerDownTimestamp
214
- });
215
- if (wasDragging || wasMultiSelecting) {
216
- eventBus.emit("dragging:end");
217
- return;
218
- }
219
- if (keyboard.isPressingSpace.value) {
220
- return;
221
- }
222
- if (selection.editableActive.value) {
223
- eventBus.emit("window:clickAway");
224
- lastInteractedElement = null;
225
- return;
226
- }
227
- const clicked = getInteractedElement(e);
228
- if (clicked && pointerUpTimestamp && lastInteractedElement && (clicked.uuid === lastInteractedElement.uuid || clicked.editableFieldName === lastInteractedElement.editableFieldName)) {
229
- const deltaTime = Date.now() - pointerUpTimestamp;
230
- const deltaX = Math.abs(lastInteractedElement.x - e.clientX);
231
- const deltaY = Math.abs(lastInteractedElement.y - e.clientY);
232
- if (deltaTime < 400 && deltaX < 3 && deltaY < 3) {
233
- if (clicked.editableFieldName) {
234
- eventBus.emit("editable:focus", {
235
- fieldName: clicked.editableFieldName,
236
- uuid: clicked.uuid
237
- });
238
- return;
239
- }
240
- if (lastInteractedElement.uuid) {
241
- const block = dom.findBlock(lastInteractedElement.uuid);
242
- if (!block) {
243
- return;
244
- }
245
- eventBus.emit("item:doubleClick", block);
246
- }
247
- }
248
- }
249
- lastInteractedElement = clicked;
250
- pointerUpTimestamp = Date.now();
251
- if (clicked?.uuid) {
252
- dom.refreshBlockRect(clicked.uuid);
253
- if (keyboard.isPressingControl.value || selection.isMultiSelecting.value) {
254
- eventBus.emit("select:toggle", clicked.uuid);
255
- } else if (keyboard.isPressingShift.value) {
256
- eventBus.emit("select:shiftToggle", clicked.uuid);
257
- } else {
258
- eventBus.emit("select", clicked.uuid);
259
- }
260
- return;
261
- }
262
- eventBus.emit("window:clickAway");
263
- if (isClickInArtboard(coords)) {
264
- eventBus.emit("select:host");
265
- } else {
266
- eventBus.emit("select:host:unselect");
267
- }
268
- }
269
- let longPressTimeout = null;
270
- let touchStartInteraction = null;
271
- let touchStartCoords = null;
272
- let longPressInteraction = null;
273
- let touchStartTimestamp = 0;
274
- function onTouchStart(e) {
275
- if (e.isPrimary) {
276
- touchStartTimestamp = Date.now();
277
- }
278
- longPressInteraction = null;
279
- const coords = getInteractionCoordinates(e);
280
- touchStartCoords = coords;
281
- eventBus.emit("mouse:down", { ...coords, type: "touch", distance: 0 });
282
- if (selection.isDragging.value) {
283
- return;
284
- }
285
- clearTimeout(longPressTimeout);
286
- const interacted = getInteractedElement(e);
287
- if (!interacted?.uuid) {
288
- return;
289
- }
290
- touchStartInteraction = interacted;
291
- longPressTimeout = setTimeout(() => {
292
- if (touchStartInteraction?.uuid) {
293
- longPressInteraction = touchStartInteraction;
294
- if (selection.uuids.value.includes(touchStartInteraction.uuid) && state.editMode.value === "editing") {
295
- eventBus.emit("dragging:start", {
296
- items: [...selection.blocks.value],
297
- coords: {
298
- x: touchStartInteraction.x,
299
- y: touchStartInteraction.y
300
- },
301
- mode: "touch"
302
- });
303
- return;
304
- }
305
- eventBus.emit("select:start", {
306
- uuids: [...selection.uuids.value, touchStartInteraction.uuid],
307
- mode: "touch"
308
- });
309
- }
310
- }, 500);
311
- }
312
- function onTouchMove(e) {
313
- if (!longPressTimeout || !touchStartInteraction) {
314
- return;
315
- }
316
- const coords = getInteractionCoordinates(e);
317
- const deltaX = Math.abs(coords.x - touchStartInteraction.x);
318
- const deltaY = Math.abs(coords.y - touchStartInteraction.y);
319
- if (deltaX > 10 || deltaY > 10) {
320
- clearTimeout(longPressTimeout);
321
- longPressTimeout = null;
322
- }
323
- }
324
- function onTouchEnd(e) {
325
- const wasDragging = selection.isDragging.value;
326
- const coords = getInteractionCoordinates(e);
327
- const distance = touchStartCoords ? getDistance(touchStartCoords, coords) : 0;
328
- if (e.isPrimary) {
329
- eventBus.emit("mouse:up", {
330
- ...coords,
331
- type: "touch",
332
- distance,
333
- duration: Date.now() - touchStartTimestamp
334
- });
335
- }
336
- clearTimeout(longPressTimeout);
337
- longPressTimeout = null;
338
- if (wasDragging) {
339
- return;
340
- }
341
- if (!touchStartCoords) {
342
- return;
343
- }
344
- if (distance > 7) {
345
- return;
346
- }
347
- const interacted = getInteractedElement(e);
348
- if (interacted?.uuid) {
349
- if (longPressInteraction && longPressInteraction.uuid === interacted.uuid) {
350
- return;
351
- }
352
- if (selection.isMultiSelecting.value) {
353
- eventBus.emit("select:toggle", interacted.uuid);
354
- } else {
355
- eventBus.emit("select", interacted.uuid);
356
- }
357
- } else {
358
- eventBus.emit("window:clickAway");
359
- }
360
- longPressInteraction = null;
361
- }
362
- onBlokkliEvent("dragging:start", (e) => {
363
- mouseStartCoordinates = e.coords;
364
- });
365
- function onClick(e) {
366
- e.preventDefault();
367
- e.stopImmediatePropagation();
368
- e.stopPropagation();
369
- }
370
- onMounted(() => {
371
- const providerElement = ui.providerElement();
372
- providerElement.addEventListener("click", onClick, {
373
- capture: true
374
- });
375
- rootEl.addEventListener("click", onClick, {
376
- capture: true
377
- });
378
- rootEl.addEventListener("pointerdown", onPointerDown, {
379
- capture: true
380
- });
381
- rootEl.addEventListener("pointerup", onPointerUp, {
382
- capture: true
383
- });
384
- });
385
- onBeforeUnmount(() => {
386
- const providerElement = ui.providerElement();
387
- providerElement.removeEventListener("click", onClick, {
388
- capture: true
389
- });
390
- rootEl.removeEventListener("click", onClick, {
391
- capture: true
392
- });
393
- rootEl.removeEventListener("pointerdown", onPointerDown, {
394
- capture: true
395
- });
396
- rootEl.removeEventListener("pointermove", onPointerMove);
397
- rootEl.removeEventListener("pointerup", onPointerUp, {
398
- capture: true
399
- });
400
- });
401
- </script>
@@ -1,63 +0,0 @@
1
- <template>
2
- <div v-if="shouldRender" class="bk-command-palette-results-list">
3
- <div>
4
- <button
5
- v-for="item in mapped"
6
- v-show="item.visible"
7
- :key="item.id"
8
- :data-command-id="item.id"
9
- :data-command-visible="item.visible"
10
- class="bk-command"
11
- :class="{ 'bk-is-focused': focusedId === item.id }"
12
- @mouseenter="$emit('focus', item.id)"
13
- @click.prevent="$emit('select', item.id)"
14
- >
15
- <div class="bk-command-icon">
16
- <Icon v-if="item.icon" :name="item.icon" />
17
- <ItemIcon v-else :bundle="item.bundle" />
18
- </div>
19
- <Highlight :text="item.label" tag="span" :positions="item.positions" />
20
- <div class="bk-command-group">{{ getGroupLabel(item.group) }}</div>
21
- </button>
22
- </div>
23
- </div>
24
- </template>
25
-
26
- <script setup>
27
- import { computed, useBlokkli } from "#imports";
28
- import { Icon, ItemIcon, Highlight } from "#blokkli/components";
29
- const props = defineProps({
30
- commands: { type: Array, required: true },
31
- visibleIds: { type: null, required: true },
32
- focusedId: { type: String, required: true }
33
- });
34
- defineEmits(["close", "focus", "select"]);
35
- const { $t } = useBlokkli();
36
- const mapped = computed(() => {
37
- return props.commands.map((v) => {
38
- const found = props.visibleIds?.find((w) => w.id === v._id);
39
- return {
40
- ...v,
41
- visible: props.visibleIds === void 0 || !!found,
42
- positions: found?.positions
43
- };
44
- }).sort((a, b) => {
45
- const indexA = props.visibleIds?.findIndex((w) => w.id === a._id) || -1;
46
- const indexB = props.visibleIds?.findIndex((w) => w.id === b._id) || -1;
47
- return indexA - indexB;
48
- });
49
- });
50
- const getGroupLabel = (id) => {
51
- if (id === "ui") {
52
- return $t("commandGroup.ui", "Interface");
53
- } else if (id === "add") {
54
- return $t("commandGroup.add", "Add new");
55
- } else if (id === "action") {
56
- return $t("commandGroup.action", "Actions");
57
- } else if (id === "selection") {
58
- return $t("commandGroup.selection", "Selection");
59
- }
60
- return $t("commandGroup.misc", "Miscellaneous");
61
- };
62
- const shouldRender = computed(() => mapped.value.some((v) => v.visible));
63
- </script>
@@ -1,54 +0,0 @@
1
- <template>
2
- <button
3
- ref="button"
4
- class="bk-selection-add-button bk-is-field"
5
- tabindex="-1"
6
- :data-title="title"
7
- :style="{
8
- transform: `translate(${left}px, ${top}px)`,
9
- visibility: isVisible ? 'visible' : 'hidden'
10
- }"
11
- @click="onClick"
12
- >
13
- <div>
14
- <Icon name="plus" />
15
- </div>
16
- </button>
17
- </template>
18
-
19
- <script setup>
20
- import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
21
- import { useBlokkli, ref, useTemplateRef } from "#imports";
22
- import { Icon } from "#blokkli/components";
23
- const props = defineProps({
24
- fieldKey: { type: null, required: true },
25
- containerRect: { type: [Object, null], required: true },
26
- title: { type: String, required: true }
27
- });
28
- const emit = defineEmits(["click"]);
29
- const { dom } = useBlokkli();
30
- const button = useTemplateRef("button");
31
- const left = ref(0);
32
- const top = ref(0);
33
- const isVisible = ref(false);
34
- const BUTTON_SIZE = 30;
35
- function onClick() {
36
- if (button.value) {
37
- emit("click", button.value);
38
- }
39
- }
40
- onBlokkliEvent("canvas:draw", () => {
41
- if (!props.fieldKey || !props.containerRect) {
42
- isVisible.value = false;
43
- return;
44
- }
45
- const fieldRect = dom.getFieldRect(props.fieldKey);
46
- if (!fieldRect) {
47
- isVisible.value = false;
48
- return;
49
- }
50
- left.value = Math.round(fieldRect.x + fieldRect.width / 2 - BUTTON_SIZE / 2);
51
- top.value = Math.round(fieldRect.y + fieldRect.height / 2 - BUTTON_SIZE / 2);
52
- isVisible.value = true;
53
- });
54
- </script>
@@ -1,31 +0,0 @@
1
- import { defineNuxtPlugin } from "#imports";
2
- export default defineNuxtPlugin((nuxtApp) => {
3
- nuxtApp.vueApp.directive("blokkli-editable", {
4
- created(el, binding) {
5
- if (import.meta.client) {
6
- if (!window.location.search.includes("blokkliEditing")) {
7
- return;
8
- }
9
- const fieldName = binding.value?.name || binding.arg;
10
- if (!fieldName) {
11
- return;
12
- }
13
- el.dataset.blokkliEditableField = fieldName;
14
- }
15
- }
16
- });
17
- nuxtApp.vueApp.directive("blokkli-droppable", {
18
- created(el, binding) {
19
- if (import.meta.client) {
20
- if (!window.location.search.includes("blokkliEditing")) {
21
- return;
22
- }
23
- const fieldName = binding.value?.name || binding.arg;
24
- if (!fieldName) {
25
- return;
26
- }
27
- el.dataset.blokkliDroppableField = fieldName;
28
- }
29
- }
30
- });
31
- });