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

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 (106) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +265 -83
  3. package/dist/modules/drupal/graphql/base/fragment.blokkliProps.graphql +1 -1
  4. package/dist/modules/drupal/graphql/features/comments.graphql +11 -8
  5. package/dist/modules/drupal/runtime/adapter/index.js +2 -2
  6. package/dist/runtime/blokkliPlugins/ItemAction/index.vue +1 -3
  7. package/dist/runtime/components/Blocks/FromLibrary/index.vue +4 -2
  8. package/dist/runtime/components/BlokkliEditable.vue +22 -4
  9. package/dist/runtime/components/BlokkliProvider.vue +29 -20
  10. package/dist/runtime/components/BlokkliProvider.vue.d.ts +2 -1
  11. package/dist/runtime/components/Edit/Actions/index.vue +9 -4
  12. package/dist/runtime/components/Edit/AnimationCanvas/index.vue +420 -25
  13. package/dist/runtime/components/Edit/ArtboardTooltip/index.vue +80 -0
  14. package/dist/runtime/components/Edit/ArtboardTooltip/index.vue.d.ts +32 -0
  15. package/dist/runtime/components/Edit/Banner/index.vue +51 -0
  16. package/dist/runtime/components/Edit/Banner/index.vue.d.ts +18 -0
  17. package/dist/runtime/components/Edit/EditIndicator.vue +118 -44
  18. package/dist/runtime/components/Edit/EditIndicator.vue.d.ts +3 -0
  19. package/dist/runtime/components/Edit/EditProvider.vue +79 -22
  20. package/dist/runtime/components/Edit/EditProvider.vue.d.ts +2 -0
  21. package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue +19 -20
  22. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +1 -1
  23. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +2 -0
  24. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +35 -20
  25. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue.d.ts +5 -3
  26. package/dist/runtime/components/Edit/Features/Comments/CommentInput/index.vue +29 -0
  27. package/dist/runtime/components/Edit/Features/Comments/CommentInput/index.vue.d.ts +13 -0
  28. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +22 -16
  29. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue.d.ts +1 -0
  30. package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue +15 -6
  31. package/dist/runtime/components/Edit/Features/Comments/index.vue +20 -8
  32. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +26 -35
  33. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue +240 -0
  34. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue.d.ts +6 -0
  35. package/dist/runtime/components/Edit/Features/Debug/index.vue +4 -165
  36. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +1 -1
  37. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +41 -37
  38. package/dist/runtime/components/Edit/Features/Edit/index.vue +1 -1
  39. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +63 -3
  40. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +13 -9
  41. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +17 -76
  42. package/dist/runtime/components/Edit/Features/EditableField/index.vue +1 -1
  43. package/dist/runtime/components/Edit/Features/History/index.vue +5 -2
  44. package/dist/runtime/components/Edit/Features/Hover/Overlay/fragment.glsl +139 -0
  45. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue +270 -0
  46. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue.d.ts +6 -0
  47. package/dist/runtime/components/Edit/Features/Hover/Overlay/vertex.glsl +117 -0
  48. package/dist/runtime/components/Edit/Features/Hover/index.vue +25 -0
  49. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +19 -27
  50. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +27 -23
  51. package/dist/runtime/components/Edit/Features/Library/index.vue +2 -1
  52. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +34 -27
  53. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +2 -4
  54. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +6 -1
  55. package/dist/runtime/components/Edit/Features/Options/Form/index.vue +1 -0
  56. package/dist/runtime/components/Edit/Features/Ownership/Renderer.vue +35 -0
  57. package/dist/runtime/components/Edit/Features/Ownership/Renderer.vue.d.ts +6 -0
  58. package/dist/runtime/components/Edit/Features/Ownership/index.vue +7 -25
  59. package/dist/runtime/components/Edit/Features/ProxyView/index.vue +5 -1
  60. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue +39 -74
  61. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +4 -2
  62. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/fragment.glsl +106 -0
  63. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +417 -0
  64. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue.d.ts +32 -0
  65. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/vertex.glsl +102 -0
  66. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +33 -106
  67. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +88 -29
  68. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +2 -0
  69. package/dist/runtime/components/Edit/Features/Selection/Overlay/vertex.glsl +11 -2
  70. package/dist/runtime/components/Edit/Features/Selection/index.vue +5 -12
  71. package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +17 -11
  72. package/dist/runtime/components/Edit/Features/Translations/index.vue +13 -16
  73. package/dist/runtime/components/Edit/Form/Text/index.vue +2 -1
  74. package/dist/runtime/components/Edit/Form/Text/index.vue.d.ts +1 -0
  75. package/dist/runtime/components/Edit/Indicators/index.vue +1 -1
  76. package/dist/runtime/components/Edit/Konami/Game/index.vue +5 -5
  77. package/dist/runtime/components/Edit/index.d.ts +5 -3
  78. package/dist/runtime/components/Edit/index.js +8 -4
  79. package/dist/runtime/composables/defineBlokkli.js +4 -2
  80. package/dist/runtime/css/output.css +1 -1
  81. package/dist/runtime/helpers/animationProvider.d.ts +34 -1
  82. package/dist/runtime/helpers/animationProvider.js +175 -48
  83. package/dist/runtime/helpers/composables/defineRenderer.d.ts +8 -0
  84. package/dist/runtime/helpers/composables/defineRenderer.js +8 -0
  85. package/dist/runtime/helpers/composables/useStickyToolbar.d.ts +4 -1
  86. package/dist/runtime/helpers/composables/useStickyToolbar.js +53 -35
  87. package/dist/runtime/helpers/dom/index.d.ts +1 -0
  88. package/dist/runtime/helpers/domProvider.d.ts +46 -0
  89. package/dist/runtime/helpers/domProvider.js +95 -6
  90. package/dist/runtime/helpers/editableProvider.d.ts +14 -0
  91. package/dist/runtime/helpers/editableProvider.js +144 -0
  92. package/dist/runtime/helpers/stateProvider.d.ts +6 -2
  93. package/dist/runtime/helpers/stateProvider.js +66 -3
  94. package/dist/runtime/helpers/storageProvider.d.ts +3 -2
  95. package/dist/runtime/helpers/storageProvider.js +6 -2
  96. package/dist/runtime/helpers/symbols.d.ts +1 -0
  97. package/dist/runtime/helpers/symbols.js +1 -0
  98. package/dist/runtime/helpers/uiProvider.d.ts +8 -1
  99. package/dist/runtime/helpers/uiProvider.js +34 -2
  100. package/dist/runtime/plugins/blokkliEditable.js +74 -3
  101. package/dist/runtime/types/index.d.ts +13 -1
  102. package/package.json +1 -1
  103. package/dist/runtime/components/Edit/DragInteractions/index.vue +0 -401
  104. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue +0 -54
  105. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue.d.ts +0 -14
  106. /package/dist/runtime/components/Edit/{DragInteractions → Features/Hover}/index.vue.d.ts +0 -0
@@ -1,32 +1,430 @@
1
1
  <template>
2
- <Teleport to="body">
3
- <canvas id="bk-animation-canvas-webgl" ref="canvasGl" />
2
+ <Teleport to="#bk-canvas-overlay">
3
+ <canvas
4
+ id="bk-animation-canvas-webgl"
5
+ ref="canvasEl"
6
+ :style
7
+ @click.capture="onClick"
8
+ @pointerdown.capture="onPointerDown"
9
+ @pointerup.capture="onPointerUp"
10
+ />
4
11
  </Teleport>
5
12
  </template>
6
13
 
7
14
  <script setup>
15
+ import {
16
+ falsy,
17
+ getDistance,
18
+ getInteractionCoordinates,
19
+ isInsideRect
20
+ } from "#blokkli/helpers";
21
+ import { MOUSE_BUTTON, MOUSE_BUTTONS } from "#blokkli/helpers/dom";
8
22
  import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
9
- import { ref, computed, useBlokkli, onMounted, watch } from "#imports";
10
- const { ui, animation, eventBus } = useBlokkli();
11
- const canvasGl = ref(null);
23
+ import {
24
+ ref,
25
+ computed,
26
+ useBlokkli,
27
+ onMounted,
28
+ watch,
29
+ useTemplateRef,
30
+ onBeforeUnmount
31
+ } from "#imports";
32
+ const {
33
+ dom,
34
+ eventBus,
35
+ selection,
36
+ keyboard,
37
+ ui,
38
+ animation,
39
+ state,
40
+ editable,
41
+ runtimeConfig
42
+ } = useBlokkli();
43
+ const style = computed(() => {
44
+ return {
45
+ imageRendering: "pixelated",
46
+ cursor: animation.cursor.value
47
+ };
48
+ });
49
+ const rects = ref([]);
50
+ function buildRects() {
51
+ const visible = dom.getVisibleBlocks();
52
+ rects.value = visible.map((uuid) => {
53
+ const rect = dom.getBlockRect(uuid);
54
+ if (!rect) {
55
+ return;
56
+ }
57
+ return { uuid, rect };
58
+ }).filter(falsy);
59
+ }
60
+ watch(dom.isReady, buildRects);
61
+ let lastInteractedElement = null;
62
+ let pointerDownElement = null;
63
+ let mouseStartCoordinates = null;
64
+ let pointerDownTimestamp = 0;
65
+ let pointerUpTimestamp = 0;
66
+ function getInteractedElement(e) {
67
+ const { x, y } = getInteractionCoordinates(e);
68
+ const editableField = editable.getEditableAtPoint(x, y);
69
+ if (editableField) {
70
+ const uuid = editableField.type === runtimeConfig.itemEntityType ? editableField.uuid : void 0;
71
+ return {
72
+ editableFieldName: editableField.fieldName,
73
+ uuid,
74
+ timestamp: Date.now(),
75
+ x,
76
+ y
77
+ };
78
+ }
79
+ const visibleUuids = dom.getVisibleBlocks();
80
+ let deepestUuid = "";
81
+ let deepestLevel = -1;
82
+ for (let i = 0; i < visibleUuids.length; i++) {
83
+ const uuid = visibleUuids[i];
84
+ if (!uuid) {
85
+ continue;
86
+ }
87
+ const rect = dom.getBlockRect(uuid);
88
+ if (rect) {
89
+ const level = state.getNestingLevel(uuid);
90
+ if (level <= deepestLevel) {
91
+ continue;
92
+ }
93
+ const relativeRect = ui.getViewportRelativeRect(rect);
94
+ if (isInsideRect(x, y, relativeRect)) {
95
+ deepestUuid = uuid;
96
+ deepestLevel = level;
97
+ }
98
+ }
99
+ }
100
+ if (deepestUuid) {
101
+ return {
102
+ uuid: deepestUuid,
103
+ timestamp: Date.now(),
104
+ x,
105
+ y
106
+ };
107
+ }
108
+ return null;
109
+ }
110
+ function onPointerMove(e) {
111
+ if (keyboard.isPressingSpace.value || e.buttons === MOUSE_BUTTONS.AUXILIARY) {
112
+ return;
113
+ }
114
+ e.preventDefault();
115
+ e.stopPropagation();
116
+ e.stopImmediatePropagation();
117
+ if (e.pointerType === "touch") {
118
+ return onTouchMove(e);
119
+ }
120
+ if (e.buttons !== MOUSE_BUTTONS.PRIMARY) {
121
+ return;
122
+ }
123
+ if (!mouseStartCoordinates || selection.isMultiSelecting.value || selection.isDragging.value || keyboard.isPressingSpace.value) {
124
+ return;
125
+ }
126
+ const diffX = Math.abs(mouseStartCoordinates.x - e.clientX);
127
+ const diffY = Math.abs(mouseStartCoordinates.y - e.clientY);
128
+ if (!pointerDownElement) {
129
+ const timeDelta = Date.now() - pointerDownTimestamp;
130
+ const maxMovement = Math.max(diffX, diffY);
131
+ if (maxMovement > 6 && timeDelta > 150 || maxMovement > 20) {
132
+ canvasEl.value?.removeEventListener("pointermove", onPointerMove);
133
+ eventBus.emit("multi-select:start", {
134
+ x: e.clientX,
135
+ y: e.clientY
136
+ });
137
+ }
138
+ return;
139
+ }
140
+ if (state.editMode.value !== "editing") {
141
+ return;
142
+ }
143
+ if (diffX < 6 && diffY < 6) {
144
+ return;
145
+ }
146
+ const interacted = getInteractedElement(e);
147
+ if (interacted && interacted.uuid) {
148
+ if (selection.uuids.value.includes(interacted.uuid)) {
149
+ eventBus.emit("dragging:start", {
150
+ items: [...selection.blocks.value],
151
+ coords: { x: e.clientX, y: e.clientY },
152
+ mode: "mouse"
153
+ });
154
+ } else {
155
+ const block = dom.findBlock(interacted.uuid);
156
+ if (block) {
157
+ eventBus.emit("dragging:start", {
158
+ items: [block],
159
+ coords: { x: e.clientX, y: e.clientY },
160
+ mode: "mouse"
161
+ });
162
+ }
163
+ }
164
+ canvasEl.value?.removeEventListener("pointermove", onPointerMove);
165
+ }
166
+ }
167
+ function onPointerDown(e) {
168
+ if (e.buttons === MOUSE_BUTTONS.AUXILIARY) {
169
+ return;
170
+ }
171
+ if (!keyboard.isPressingSpace.value) {
172
+ e.preventDefault();
173
+ e.stopPropagation();
174
+ e.stopImmediatePropagation();
175
+ }
176
+ keyboard.setShortcutStateFromEvent(e);
177
+ canvasEl.value?.removeEventListener("pointermove", onPointerMove);
178
+ if (ui.openTooltip.value) {
179
+ return;
180
+ }
181
+ if (state.isLoading.value) {
182
+ return;
183
+ }
184
+ canvasEl.value?.addEventListener("pointermove", onPointerMove);
185
+ if (e.pointerType === "touch") {
186
+ return onTouchStart(e);
187
+ }
188
+ if (selection.isDragging.value) {
189
+ return;
190
+ }
191
+ pointerDownTimestamp = Date.now();
192
+ const coords = { x: e.clientX, y: e.clientY };
193
+ mouseStartCoordinates = coords;
194
+ if (!e.shiftKey && e.buttons === MOUSE_BUTTONS.PRIMARY) {
195
+ const interacted = getInteractedElement(e);
196
+ pointerDownElement = interacted;
197
+ if (interacted) {
198
+ return;
199
+ }
200
+ }
201
+ eventBus.emit("mouse:down", { ...coords, type: "mouse", distance: 0 });
202
+ }
203
+ function isClickInArtboard(coords) {
204
+ const size = ui.artboardSize.value;
205
+ const scale = ui.artboardScale.value;
206
+ const rect = {
207
+ x: ui.artboardOffset.value.x,
208
+ y: ui.artboardOffset.value.y,
209
+ width: size.width * scale,
210
+ height: size.height * scale
211
+ };
212
+ return isInsideRect(coords.x, coords.y, rect);
213
+ }
214
+ function onPointerUp(e) {
215
+ canvasEl.value?.removeEventListener("pointermove", onPointerMove);
216
+ if (e.button === MOUSE_BUTTON.AUXILIARY) {
217
+ e.preventDefault();
218
+ return;
219
+ }
220
+ e.preventDefault();
221
+ e.stopPropagation();
222
+ e.stopImmediatePropagation();
223
+ if (ui.openTooltip.value) {
224
+ ui.openTooltip.value = "";
225
+ return;
226
+ }
227
+ const wasDragging = selection.isDragging.value;
228
+ const wasMultiSelecting = selection.isMultiSelecting.value;
229
+ pointerDownElement = null;
230
+ if (state.isLoading.value) {
231
+ return;
232
+ }
233
+ if (e.pointerType === "touch") {
234
+ return onTouchEnd(e);
235
+ }
236
+ const coords = getInteractionCoordinates(e);
237
+ const distance = mouseStartCoordinates ? getDistance(mouseStartCoordinates, coords) : 0;
238
+ eventBus.emit("mouse:up", {
239
+ x: e.clientX,
240
+ y: e.clientY,
241
+ type: "mouse",
242
+ distance,
243
+ duration: Date.now() - pointerDownTimestamp
244
+ });
245
+ if (wasDragging || wasMultiSelecting) {
246
+ eventBus.emit("dragging:end");
247
+ return;
248
+ }
249
+ if (keyboard.isPressingSpace.value) {
250
+ return;
251
+ }
252
+ if (selection.editableActive.value) {
253
+ eventBus.emit("window:clickAway");
254
+ lastInteractedElement = null;
255
+ return;
256
+ }
257
+ if (animation.handleClick(e.clientX, e.clientY)) {
258
+ return;
259
+ }
260
+ const clicked = getInteractedElement(e);
261
+ if (clicked && pointerUpTimestamp && lastInteractedElement && (clicked.uuid === lastInteractedElement.uuid || clicked.editableFieldName === lastInteractedElement.editableFieldName)) {
262
+ const deltaTime = Date.now() - pointerUpTimestamp;
263
+ const deltaX = Math.abs(lastInteractedElement.x - e.clientX);
264
+ const deltaY = Math.abs(lastInteractedElement.y - e.clientY);
265
+ if (deltaTime < 400 && deltaX < 3 && deltaY < 3) {
266
+ if (clicked.editableFieldName) {
267
+ eventBus.emit("editable:focus", {
268
+ fieldName: clicked.editableFieldName,
269
+ uuid: clicked.uuid
270
+ });
271
+ return;
272
+ }
273
+ if (lastInteractedElement.uuid) {
274
+ const block = dom.findBlock(lastInteractedElement.uuid);
275
+ if (!block) {
276
+ return;
277
+ }
278
+ eventBus.emit("item:doubleClick", block);
279
+ }
280
+ }
281
+ }
282
+ lastInteractedElement = clicked;
283
+ pointerUpTimestamp = Date.now();
284
+ if (clicked?.uuid) {
285
+ dom.refreshBlockRect(clicked.uuid);
286
+ if (keyboard.isPressingControl.value || selection.isMultiSelecting.value) {
287
+ eventBus.emit("select:toggle", clicked.uuid);
288
+ } else if (keyboard.isPressingShift.value) {
289
+ eventBus.emit("select:shiftToggle", clicked.uuid);
290
+ } else {
291
+ eventBus.emit("select", clicked.uuid);
292
+ }
293
+ return;
294
+ }
295
+ eventBus.emit("window:clickAway");
296
+ if (isClickInArtboard(coords)) {
297
+ eventBus.emit("select:host");
298
+ } else {
299
+ eventBus.emit("select:host:unselect");
300
+ }
301
+ }
302
+ let longPressTimeout = null;
303
+ let touchStartInteraction = null;
304
+ let touchStartCoords = null;
305
+ let longPressInteraction = null;
306
+ let touchStartTimestamp = 0;
307
+ function onTouchStart(e) {
308
+ if (e.isPrimary) {
309
+ touchStartTimestamp = Date.now();
310
+ }
311
+ longPressInteraction = null;
312
+ const coords = getInteractionCoordinates(e);
313
+ touchStartCoords = coords;
314
+ eventBus.emit("mouse:down", { ...coords, type: "touch", distance: 0 });
315
+ if (ui.openTooltip.value) {
316
+ return;
317
+ }
318
+ if (selection.isDragging.value) {
319
+ return;
320
+ }
321
+ clearTimeout(longPressTimeout);
322
+ const interacted = getInteractedElement(e);
323
+ if (!interacted?.uuid) {
324
+ return;
325
+ }
326
+ touchStartInteraction = interacted;
327
+ longPressTimeout = setTimeout(() => {
328
+ if (touchStartInteraction?.uuid) {
329
+ longPressInteraction = touchStartInteraction;
330
+ if (selection.uuids.value.includes(touchStartInteraction.uuid) && state.editMode.value === "editing") {
331
+ eventBus.emit("dragging:start", {
332
+ items: [...selection.blocks.value],
333
+ coords: {
334
+ x: touchStartInteraction.x,
335
+ y: touchStartInteraction.y
336
+ },
337
+ mode: "touch"
338
+ });
339
+ return;
340
+ }
341
+ eventBus.emit("select:start", {
342
+ uuids: [...selection.uuids.value, touchStartInteraction.uuid],
343
+ mode: "touch"
344
+ });
345
+ }
346
+ }, 500);
347
+ }
348
+ function onTouchMove(e) {
349
+ if (!longPressTimeout || !touchStartInteraction) {
350
+ return;
351
+ }
352
+ const coords = getInteractionCoordinates(e);
353
+ const deltaX = Math.abs(coords.x - touchStartInteraction.x);
354
+ const deltaY = Math.abs(coords.y - touchStartInteraction.y);
355
+ if (deltaX > 10 || deltaY > 10) {
356
+ clearTimeout(longPressTimeout);
357
+ longPressTimeout = null;
358
+ }
359
+ }
360
+ function onTouchEnd(e) {
361
+ const wasDragging = selection.isDragging.value;
362
+ const coords = getInteractionCoordinates(e);
363
+ const distance = touchStartCoords ? getDistance(touchStartCoords, coords) : 0;
364
+ if (e.isPrimary) {
365
+ eventBus.emit("mouse:up", {
366
+ ...coords,
367
+ type: "touch",
368
+ distance,
369
+ duration: Date.now() - touchStartTimestamp
370
+ });
371
+ }
372
+ clearTimeout(longPressTimeout);
373
+ longPressTimeout = null;
374
+ if (ui.openTooltip.value) {
375
+ ui.openTooltip.value = "";
376
+ return;
377
+ }
378
+ if (wasDragging) {
379
+ return;
380
+ }
381
+ if (!touchStartCoords) {
382
+ return;
383
+ }
384
+ if (distance > 7) {
385
+ return;
386
+ }
387
+ if (animation.handleClick(coords.x, coords.y)) {
388
+ return;
389
+ }
390
+ const interacted = getInteractedElement(e);
391
+ if (interacted?.uuid) {
392
+ if (longPressInteraction && longPressInteraction.uuid === interacted.uuid) {
393
+ return;
394
+ }
395
+ if (selection.isMultiSelecting.value) {
396
+ eventBus.emit("select:toggle", interacted.uuid);
397
+ } else {
398
+ eventBus.emit("select", interacted.uuid);
399
+ }
400
+ } else {
401
+ eventBus.emit("window:clickAway");
402
+ }
403
+ longPressInteraction = null;
404
+ }
405
+ onBlokkliEvent("dragging:start", (e) => {
406
+ mouseStartCoordinates = e.coords;
407
+ });
408
+ function onClick(e) {
409
+ e.preventDefault();
410
+ e.stopImmediatePropagation();
411
+ e.stopPropagation();
412
+ }
413
+ const canvasEl = useTemplateRef("canvasEl");
12
414
  const canvasAttributes = computed(() => {
13
415
  return {
14
416
  width: ui.viewport.value.width * animation.dpi.value,
15
- height: ui.viewport.value.height * animation.dpi.value,
16
- style: {
17
- width: ui.viewport.value.width + "px",
18
- height: ui.viewport.value.height + "px"
19
- }
417
+ height: ui.viewport.value.height * animation.dpi.value
20
418
  };
21
419
  });
22
420
  let gl = null;
23
421
  function initGl() {
24
- if (!canvasGl.value) {
422
+ if (!canvasEl.value) {
25
423
  return;
26
424
  }
27
425
  gl = animation.gl();
28
- canvasGl.value.width = canvasAttributes.value.width;
29
- canvasGl.value.height = canvasAttributes.value.height;
426
+ canvasEl.value.width = canvasAttributes.value.width;
427
+ canvasEl.value.height = canvasAttributes.value.height;
30
428
  if (!gl) {
31
429
  return;
32
430
  }
@@ -57,31 +455,28 @@ function setScissor(v) {
57
455
  watch(scissor, setScissor);
58
456
  let lastCanvasWidth = 0;
59
457
  let lastCanvasHeight = 0;
60
- onBlokkliEvent("animationFrame", (e) => {
61
- if (!canvasGl.value) {
458
+ onBlokkliEvent("animationFrame", () => {
459
+ if (!canvasEl.value) {
62
460
  return;
63
461
  }
64
462
  const canvasWidth = canvasAttributes.value.width;
65
463
  const canvasHeight = canvasAttributes.value.height;
66
464
  if (canvasWidth !== lastCanvasWidth || canvasHeight !== lastCanvasHeight) {
67
- canvasGl.value.width = canvasWidth;
68
- canvasGl.value.height = canvasHeight;
465
+ canvasEl.value.width = canvasWidth;
466
+ canvasEl.value.height = canvasHeight;
69
467
  if (gl) {
70
468
  gl.viewport(0, 0, canvasWidth, canvasHeight);
71
469
  }
72
470
  lastCanvasWidth = canvasWidth;
73
471
  lastCanvasHeight = canvasHeight;
74
472
  }
75
- const offset = ui.artboardOffset.value;
76
- const scale = ui.artboardScale.value;
77
- eventBus.emit("canvas:draw", {
78
- ...e,
79
- artboardOffset: offset,
80
- artboardScale: scale,
81
- time: e.time
82
- });
83
473
  });
84
474
  onMounted(() => {
85
475
  initGl();
86
476
  });
477
+ onBeforeUnmount(() => {
478
+ if (canvasEl.value) {
479
+ canvasEl.value.removeEventListener("pointermove", onPointerMove);
480
+ }
481
+ });
87
482
  </script>
@@ -0,0 +1,80 @@
1
+ <template>
2
+ <div
3
+ ref="el"
4
+ class="bk bk-artboard-tooltip"
5
+ :class="'bk-is-' + placementY"
6
+ :style="{
7
+ '--bk-caret-x': caretX
8
+ }"
9
+ >
10
+ <div class="bk bk-artboard-tooltip-inner bk-caret-tooltip-inner">
11
+ <div class="bk-artboard-tooltip-header">
12
+ <div v-html="title" />
13
+ <button @click="$emit('close')">
14
+ <Icon :name="closeIcon" />
15
+ </button>
16
+ </div>
17
+ <slot />
18
+ </div>
19
+ </div>
20
+ </template>
21
+
22
+ <script setup>
23
+ import useStickyToolbar, {
24
+ } from "#blokkli/helpers/composables/useStickyToolbar";
25
+ import {
26
+ useTemplateRef,
27
+ useBlokkli,
28
+ onMounted,
29
+ onBeforeUnmount,
30
+ watch
31
+ } from "#imports";
32
+ import { Icon } from "#blokkli/components";
33
+ import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
34
+ const props = defineProps({
35
+ id: { type: String, required: true },
36
+ title: { type: String, required: true },
37
+ anchorEl: { type: null, required: false, default: null },
38
+ anchorCoordinates: { type: [Object, null], required: false, default: null },
39
+ placementY: { type: String, required: false, default: "auto" },
40
+ closeIcon: { type: null, required: false, default: "close" }
41
+ });
42
+ const emit = defineEmits(["close"]);
43
+ const el = useTemplateRef("el");
44
+ const { ui } = useBlokkli();
45
+ const { placementY, caretX } = useStickyToolbar(el, {
46
+ getAnchorElement() {
47
+ return props.anchorEl ?? null;
48
+ },
49
+ getAnchorCoordinates() {
50
+ return props.anchorCoordinates ?? null;
51
+ },
52
+ getPlacementY() {
53
+ return props.placementY;
54
+ },
55
+ getPlacementX() {
56
+ return "center";
57
+ },
58
+ getCaretWidth() {
59
+ return 30;
60
+ }
61
+ });
62
+ watch(ui.openTooltip, (id) => {
63
+ if (id !== props.id) {
64
+ emit("close");
65
+ }
66
+ });
67
+ onBlokkliEvent("keyPressed", (e) => {
68
+ if (e.code === "Escape") {
69
+ emit("close");
70
+ }
71
+ });
72
+ onMounted(() => {
73
+ ui.openTooltip.value = props.id;
74
+ });
75
+ onBeforeUnmount(() => {
76
+ if (ui.openTooltip.value === props.id) {
77
+ ui.openTooltip.value = "";
78
+ }
79
+ });
80
+ </script>
@@ -0,0 +1,32 @@
1
+ import { type PlacementVertical } from '#blokkli/helpers/composables/useStickyToolbar';
2
+ import type { BlokkliIcon } from '#blokkli-build/icons';
3
+ import type { Coord } from '#blokkli/types';
4
+ type __VLS_Props = {
5
+ id: string;
6
+ title: string;
7
+ anchorEl?: HTMLElement | null;
8
+ anchorCoordinates?: Coord | null;
9
+ placementY?: PlacementVertical;
10
+ closeIcon?: BlokkliIcon;
11
+ };
12
+ declare var __VLS_5: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_5) => any;
15
+ };
16
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
17
+ close: () => any;
18
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
+ onClose?: (() => any) | undefined;
20
+ }>, {
21
+ anchorEl: HTMLElement | null;
22
+ anchorCoordinates: Coord | null;
23
+ placementY: PlacementVertical;
24
+ closeIcon: BlokkliIcon;
25
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
27
+ export default _default;
28
+ type __VLS_WithSlots<T, S> = T & {
29
+ new (): {
30
+ $slots: S;
31
+ };
32
+ };
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <div
3
+ ref="el"
4
+ class="bk bk-banner"
5
+ :class="scheme ? 'bk-scheme-' + scheme : void 0"
6
+ >
7
+ <Icon :name="icon" />
8
+ <p v-html="text" />
9
+ <button v-if="button" class="bk-banner-close" @click="$emit('click')">
10
+ {{ button }}
11
+ <Icon name="close" />
12
+ </button>
13
+ </div>
14
+ </template>
15
+
16
+ <script setup>
17
+ import { Icon } from "#blokkli/components";
18
+ import {
19
+ onBeforeUnmount,
20
+ onMounted,
21
+ useTemplateRef,
22
+ useBlokkli
23
+ } from "#imports";
24
+ const props = defineProps({
25
+ id: { type: String, required: true },
26
+ icon: { type: null, required: true },
27
+ text: { type: String, required: true },
28
+ button: { type: String, required: false, default: void 0 },
29
+ scheme: { type: String, required: false, default: "accent" }
30
+ });
31
+ defineEmits(["click"]);
32
+ const { ui } = useBlokkli();
33
+ const el = useTemplateRef("el");
34
+ const observer = new ResizeObserver((entries) => {
35
+ const entry = entries.at(0);
36
+ if (!entry) {
37
+ return;
38
+ }
39
+ const height = Math.ceil(entry.borderBoxSize.at(0)?.blockSize ?? 0);
40
+ ui.setBannerHeight(props.id, height);
41
+ });
42
+ onMounted(() => {
43
+ if (el.value) {
44
+ observer.observe(el.value);
45
+ }
46
+ });
47
+ onBeforeUnmount(() => {
48
+ observer.disconnect();
49
+ ui.removeBanner(props.id);
50
+ });
51
+ </script>
@@ -0,0 +1,18 @@
1
+ import type { BlokkliIcon } from '#blokkli-build/icons';
2
+ import type { ThemeColorName } from '#blokkli/types/theme';
3
+ type __VLS_Props = {
4
+ id: string;
5
+ icon: BlokkliIcon;
6
+ text: string;
7
+ button?: string;
8
+ scheme?: ThemeColorName;
9
+ };
10
+ declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
+ click: () => any;
12
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
+ onClick?: (() => any) | undefined;
14
+ }>, {
15
+ button: string;
16
+ scheme: ThemeColorName;
17
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ export default _default;