@blokkli/editor 2.0.0-alpha.15 → 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 (116) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +330 -93
  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/Dialog/index.vue +3 -0
  18. package/dist/runtime/components/Edit/Dialog/index.vue.d.ts +2 -0
  19. package/dist/runtime/components/Edit/EditIndicator.vue +118 -44
  20. package/dist/runtime/components/Edit/EditIndicator.vue.d.ts +3 -0
  21. package/dist/runtime/components/Edit/EditProvider.vue +79 -22
  22. package/dist/runtime/components/Edit/EditProvider.vue.d.ts +2 -0
  23. package/dist/runtime/components/Edit/Features/Analyze/Overlay/index.vue +19 -20
  24. package/dist/runtime/components/Edit/Features/BlockAddList/index.vue +1 -1
  25. package/dist/runtime/components/Edit/Features/CommandPalette/index.vue +2 -0
  26. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue +35 -20
  27. package/dist/runtime/components/Edit/Features/Comments/AddForm/index.vue.d.ts +5 -3
  28. package/dist/runtime/components/Edit/Features/Comments/CommentInput/index.vue +29 -0
  29. package/dist/runtime/components/Edit/Features/Comments/CommentInput/index.vue.d.ts +13 -0
  30. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue +22 -16
  31. package/dist/runtime/components/Edit/Features/Comments/Overlay/Item/index.vue.d.ts +1 -0
  32. package/dist/runtime/components/Edit/Features/Comments/Overlay/index.vue +15 -6
  33. package/dist/runtime/components/Edit/Features/Comments/index.vue +20 -8
  34. package/dist/runtime/components/Edit/Features/Debug/Rects/index.vue +26 -35
  35. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue +240 -0
  36. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue.d.ts +6 -0
  37. package/dist/runtime/components/Edit/Features/Debug/index.vue +4 -165
  38. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +1 -1
  39. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +7 -1
  40. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/index.vue +62 -39
  41. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/vertex.glsl +1 -0
  42. package/dist/runtime/components/Edit/Features/Edit/index.vue +1 -1
  43. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Frame/index.vue +63 -3
  44. package/dist/runtime/components/Edit/Features/EditableField/Overlay/Plaintext/index.vue +13 -9
  45. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +17 -76
  46. package/dist/runtime/components/Edit/Features/EditableField/index.vue +1 -1
  47. package/dist/runtime/components/Edit/Features/History/index.vue +5 -2
  48. package/dist/runtime/components/Edit/Features/Hover/Overlay/fragment.glsl +139 -0
  49. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue +270 -0
  50. package/dist/runtime/components/Edit/Features/Hover/Overlay/index.vue.d.ts +6 -0
  51. package/dist/runtime/components/Edit/Features/Hover/Overlay/vertex.glsl +117 -0
  52. package/dist/runtime/components/Edit/Features/Hover/index.vue +25 -0
  53. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/index.vue +19 -27
  54. package/dist/runtime/components/Edit/Features/Library/ReusableDialog/index.vue +27 -23
  55. package/dist/runtime/components/Edit/Features/Library/index.vue +2 -1
  56. package/dist/runtime/components/Edit/Features/MultiSelect/Overlay/index.vue +34 -27
  57. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +2 -4
  58. package/dist/runtime/components/Edit/Features/Options/Form/Item.vue +6 -1
  59. package/dist/runtime/components/Edit/Features/Options/Form/index.vue +1 -0
  60. package/dist/runtime/components/Edit/Features/Ownership/Renderer.vue +35 -0
  61. package/dist/runtime/components/Edit/Features/Ownership/Renderer.vue.d.ts +6 -0
  62. package/dist/runtime/components/Edit/Features/Ownership/index.vue +7 -25
  63. package/dist/runtime/components/Edit/Features/ProxyView/index.vue +5 -1
  64. package/dist/runtime/components/Edit/Features/Publish/Dialog/Summary.vue +2 -2
  65. package/dist/runtime/components/Edit/Features/Publish/Dialog/index.vue +17 -7
  66. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue +39 -74
  67. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +4 -2
  68. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/fragment.glsl +106 -0
  69. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +417 -0
  70. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue.d.ts +32 -0
  71. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/vertex.glsl +102 -0
  72. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +33 -106
  73. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue +88 -29
  74. package/dist/runtime/components/Edit/Features/Selection/Overlay/index.vue.d.ts +2 -0
  75. package/dist/runtime/components/Edit/Features/Selection/Overlay/vertex.glsl +11 -2
  76. package/dist/runtime/components/Edit/Features/Selection/index.vue +26 -19
  77. package/dist/runtime/components/Edit/Features/Translations/Banner/index.vue +17 -11
  78. package/dist/runtime/components/Edit/Features/Translations/index.vue +13 -16
  79. package/dist/runtime/components/Edit/Form/Text/index.vue +2 -1
  80. package/dist/runtime/components/Edit/Form/Text/index.vue.d.ts +1 -0
  81. package/dist/runtime/components/Edit/Indicators/index.vue +1 -1
  82. package/dist/runtime/components/Edit/Konami/Game/index.vue +5 -5
  83. package/dist/runtime/components/Edit/index.d.ts +5 -3
  84. package/dist/runtime/components/Edit/index.js +8 -4
  85. package/dist/runtime/composables/defineBlokkli.js +5 -3
  86. package/dist/runtime/css/output.css +1 -1
  87. package/dist/runtime/helpers/animationProvider.d.ts +34 -1
  88. package/dist/runtime/helpers/animationProvider.js +175 -48
  89. package/dist/runtime/helpers/composables/defineRenderer.d.ts +8 -0
  90. package/dist/runtime/helpers/composables/defineRenderer.js +8 -0
  91. package/dist/runtime/helpers/composables/useDelayedIntersectionObserver.d.ts +1 -1
  92. package/dist/runtime/helpers/composables/useDelayedIntersectionObserver.js +3 -2
  93. package/dist/runtime/helpers/composables/useStickyToolbar.d.ts +4 -1
  94. package/dist/runtime/helpers/composables/useStickyToolbar.js +53 -35
  95. package/dist/runtime/helpers/dom/index.d.ts +1 -0
  96. package/dist/runtime/helpers/domProvider.d.ts +46 -0
  97. package/dist/runtime/helpers/domProvider.js +101 -7
  98. package/dist/runtime/helpers/editableProvider.d.ts +14 -0
  99. package/dist/runtime/helpers/editableProvider.js +144 -0
  100. package/dist/runtime/helpers/stateProvider.d.ts +6 -2
  101. package/dist/runtime/helpers/stateProvider.js +66 -3
  102. package/dist/runtime/helpers/storageProvider.d.ts +3 -2
  103. package/dist/runtime/helpers/storageProvider.js +6 -2
  104. package/dist/runtime/helpers/symbols.d.ts +1 -0
  105. package/dist/runtime/helpers/symbols.js +1 -0
  106. package/dist/runtime/helpers/uiProvider.d.ts +8 -1
  107. package/dist/runtime/helpers/uiProvider.js +34 -2
  108. package/dist/runtime/helpers/webgl/index.d.ts +11 -2
  109. package/dist/runtime/helpers/webgl/index.js +162 -7
  110. package/dist/runtime/plugins/blokkliEditable.js +74 -3
  111. package/dist/runtime/types/index.d.ts +13 -1
  112. package/package.json +1 -1
  113. package/dist/runtime/components/Edit/DragInteractions/index.vue +0 -401
  114. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue +0 -54
  115. package/dist/runtime/components/Edit/Features/Selection/AddButtons/AddButtonsField.vue.d.ts +0 -14
  116. /package/dist/runtime/components/Edit/{DragInteractions → Features/Hover}/index.vue.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,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,14 +0,0 @@
1
- type __VLS_Props = {
2
- fieldKey: string | undefined;
3
- containerRect: {
4
- x: number;
5
- y: number;
6
- } | null;
7
- title: string;
8
- };
9
- declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- click: (element: HTMLElement) => any;
11
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
12
- onClick?: ((element: HTMLElement) => any) | undefined;
13
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
- export default _default;