@blokkli/editor 2.0.0-alpha.21 → 2.0.0-alpha.23

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 (154) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +97 -169
  3. package/dist/runtime/blokkliPlugins/MenuButton/index.vue +3 -1
  4. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue +20 -14
  5. package/dist/runtime/blokkliPlugins/Sidebar/Detached/index.vue.d.ts +8 -4
  6. package/dist/runtime/blokkliPlugins/Sidebar/index.vue +55 -25
  7. package/dist/runtime/blokkliPlugins/Sidebar/index.vue.d.ts +4 -3
  8. package/dist/runtime/blokkliPlugins/ToolbarButton/index.vue +4 -1
  9. package/dist/runtime/blokkliPlugins/ViewOption/index.vue +3 -1
  10. package/dist/runtime/blokkliPlugins/index.d.ts +1 -3
  11. package/dist/runtime/blokkliPlugins/index.js +0 -4
  12. package/dist/runtime/components/Blocks/FromLibrary/index.vue +0 -5
  13. package/dist/runtime/components/BlokkliEditable.vue +6 -1
  14. package/dist/runtime/components/BlokkliField.vue +1 -1
  15. package/dist/runtime/components/BlokkliProvider.vue +4 -4
  16. package/dist/runtime/components/Edit/Actions/ItemDropdown.vue +66 -0
  17. package/dist/runtime/components/Edit/Actions/ItemDropdown.vue.d.ts +6 -0
  18. package/dist/runtime/components/Edit/Actions/index.vue +7 -49
  19. package/dist/runtime/components/Edit/AnimationCanvas/index.vue +23 -68
  20. package/dist/runtime/components/Edit/BlockProxy/index.vue +2 -8
  21. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue +33 -49
  22. package/dist/runtime/components/Edit/BlokkliErrorBoundary.vue.d.ts +14 -1
  23. package/dist/runtime/components/Edit/BlokkliRootErrorBoundary.vue +93 -0
  24. package/dist/runtime/components/Edit/BlokkliRootErrorBoundary.vue.d.ts +12 -0
  25. package/dist/runtime/components/Edit/DraggableList.vue +5 -25
  26. package/dist/runtime/components/Edit/EditProvider.vue +24 -11
  27. package/dist/runtime/components/Edit/Features/{BlockAddList → AddList/Blocks}/index.vue +26 -62
  28. package/dist/runtime/components/Edit/Features/{Hover/Overlay → AddList/Blocks}/index.vue.d.ts +2 -2
  29. package/dist/runtime/components/Edit/Features/AddList/index.vue +29 -8
  30. package/dist/runtime/components/Edit/Features/Analyze/{Renderer.vue → Main.vue} +4 -8
  31. package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/fragment.glsl +10 -6
  32. package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/index.vue +43 -15
  33. package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/index.vue.d.ts +0 -2
  34. package/dist/runtime/components/Edit/Features/Analyze/{Overlay → Renderer}/vertex.glsl +11 -9
  35. package/dist/runtime/components/Edit/Features/Analyze/Results/ResultsItemNodesTarget.vue +15 -3
  36. package/dist/runtime/components/Edit/Features/Analyze/analyzers/helpers/collectTextElements.js +3 -0
  37. package/dist/runtime/components/Edit/Features/Analyze/index.vue +7 -3
  38. package/dist/runtime/components/Edit/Features/Anchors/index.vue +2 -2
  39. package/dist/runtime/components/Edit/Features/Clipboard/List/index.vue +21 -10
  40. package/dist/runtime/components/Edit/Features/Clipboard/index.vue +18 -11
  41. package/dist/runtime/components/Edit/Features/Conversions/index.vue +16 -9
  42. package/dist/runtime/components/Edit/Features/Debug/DebugSection.vue +24 -0
  43. package/dist/runtime/components/Edit/Features/Debug/DebugSection.vue.d.ts +16 -0
  44. package/dist/runtime/components/Edit/Features/Debug/Main.vue +80 -0
  45. package/dist/runtime/components/Edit/Features/Debug/Section/Features.vue +34 -0
  46. package/dist/runtime/components/Edit/Features/Debug/Section/Icons.vue +15 -0
  47. package/dist/runtime/components/Edit/Features/Debug/Section/Icons.vue.d.ts +2 -0
  48. package/dist/runtime/components/Edit/Features/Debug/Section/Keyboard.vue +17 -0
  49. package/dist/runtime/components/Edit/Features/Debug/Section/Keyboard.vue.d.ts +2 -0
  50. package/dist/runtime/components/Edit/Features/Debug/Section/Logging.vue +66 -0
  51. package/dist/runtime/components/Edit/Features/{Selection/OverlayFallback/index.vue.d.ts → Debug/Section/Logging.vue.d.ts} +2 -1
  52. package/dist/runtime/components/Edit/Features/Debug/Section/Rendering.vue +96 -0
  53. package/dist/runtime/components/Edit/Features/Debug/Section/Rendering.vue.d.ts +2 -0
  54. package/dist/runtime/components/Edit/Features/Debug/Section/Selection.vue +25 -0
  55. package/dist/runtime/components/Edit/Features/Debug/Section/Selection.vue.d.ts +2 -0
  56. package/dist/runtime/components/Edit/Features/Debug/index.vue +2 -2
  57. package/dist/runtime/components/Edit/Features/DraggingOverlay/DragItems/index.vue +20 -27
  58. package/dist/runtime/components/Edit/Features/DraggingOverlay/Renderer/fragment.glsl +80 -0
  59. package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/index.vue +100 -87
  60. package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/vertex.glsl +51 -8
  61. package/dist/runtime/components/Edit/Features/DraggingOverlay/index.vue +3 -3
  62. package/dist/runtime/components/Edit/Features/EditableField/Overlay/index.vue +0 -6
  63. package/dist/runtime/components/Edit/Features/EditableField/index.vue +6 -2
  64. package/dist/runtime/components/Edit/Features/Fragments/Dialog/Item/index.vue +1 -5
  65. package/dist/runtime/components/Edit/Features/Hover/Renderer/fragment.glsl +141 -0
  66. package/dist/runtime/components/Edit/Features/Hover/{Overlay → Renderer}/index.vue +225 -38
  67. package/dist/runtime/components/Edit/Features/Hover/Renderer/index.vue.d.ts +2 -0
  68. package/dist/runtime/components/Edit/Features/Hover/{Overlay → Renderer}/vertex.glsl +49 -11
  69. package/dist/runtime/components/Edit/Features/Hover/index.vue +9 -6
  70. package/dist/runtime/components/Edit/Features/Library/LibraryDialog/Item/index.vue +1 -5
  71. package/dist/runtime/components/Edit/Features/Library/index.vue +24 -12
  72. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/Item.vue +1 -1
  73. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue +26 -13
  74. package/dist/runtime/components/Edit/Features/MediaLibrary/Library/index.vue.d.ts +0 -1
  75. package/dist/runtime/components/Edit/Features/MediaLibrary/index.vue +3 -47
  76. package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/fragment.glsl +13 -26
  77. package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/index.vue +130 -72
  78. package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/index.vue.d.ts +0 -1
  79. package/dist/runtime/components/Edit/Features/MultiSelect/{Overlay → Renderer}/vertex.glsl +27 -2
  80. package/dist/runtime/components/Edit/Features/MultiSelect/index.vue +25 -12
  81. package/dist/runtime/components/Edit/Features/Ownership/index.vue +2 -2
  82. package/dist/runtime/components/Edit/Features/ResponsivePreview/index.vue +1 -1
  83. package/dist/runtime/components/Edit/Features/Search/Overlay/Results/Content/index.vue +23 -6
  84. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Overlay/index.vue.d.ts +2 -2
  85. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/fragment.glsl +19 -17
  86. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/index.vue +242 -131
  87. package/dist/runtime/components/Edit/Features/Selection/AddButtons/Renderer/vertex.glsl +29 -12
  88. package/dist/runtime/components/Edit/Features/Selection/AddButtons/index.vue +12 -4
  89. package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/fragment.glsl +23 -14
  90. package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/index.vue +121 -28
  91. package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/index.vue.d.ts +0 -2
  92. package/dist/runtime/components/Edit/Features/Selection/{Overlay → Renderer}/vertex.glsl +23 -14
  93. package/dist/runtime/components/Edit/Features/Selection/index.vue +46 -59
  94. package/dist/runtime/components/Edit/Features/Transform/Dialog/index.vue +5 -5
  95. package/dist/runtime/components/Edit/Features/Transform/index.vue +29 -22
  96. package/dist/runtime/components/Edit/Form/Checkboxes/index.vue +43 -0
  97. package/dist/runtime/components/Edit/Form/Checkboxes/index.vue.d.ts +20 -0
  98. package/dist/runtime/components/Edit/Messages/Item/index.vue.d.ts +1 -1
  99. package/dist/runtime/components/Edit/PreviewProvider.vue +1 -1
  100. package/dist/runtime/components/Edit/Sortli/index.vue +5 -8
  101. package/dist/runtime/components/Edit/Sortli/index.vue.d.ts +2 -0
  102. package/dist/runtime/components/Edit/Toolbar/index.vue +1 -4
  103. package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue +9 -2
  104. package/dist/runtime/components/Edit/ViewportBlockingRect/index.vue.d.ts +4 -1
  105. package/dist/runtime/components/Edit/index.d.ts +6 -4
  106. package/dist/runtime/components/Edit/index.js +11 -7
  107. package/dist/runtime/css/output.css +1 -1
  108. package/dist/runtime/helpers/animationProvider.d.ts +58 -9
  109. package/dist/runtime/helpers/animationProvider.js +318 -75
  110. package/dist/runtime/helpers/composables/defineItemDropdownAction.d.ts +2 -0
  111. package/dist/runtime/helpers/composables/defineItemDropdownAction.js +10 -0
  112. package/dist/runtime/helpers/composables/defineRenderer.d.ts +5 -2
  113. package/dist/runtime/helpers/composables/defineRenderer.js +3 -2
  114. package/dist/runtime/helpers/composables/useGlobalBlokkliObject.d.ts +16 -0
  115. package/dist/runtime/helpers/composables/useGlobalBlokkliObject.js +36 -0
  116. package/dist/runtime/helpers/debugProvider.d.ts +13 -3
  117. package/dist/runtime/helpers/debugProvider.js +80 -12
  118. package/dist/runtime/helpers/domProvider.js +46 -32
  119. package/dist/runtime/helpers/dropTargets/index.js +1 -1
  120. package/dist/runtime/helpers/eventBus.d.ts +1 -1
  121. package/dist/runtime/helpers/index.d.ts +1 -6
  122. package/dist/runtime/helpers/index.js +0 -81
  123. package/dist/runtime/helpers/pluginProvider.d.ts +16 -0
  124. package/dist/runtime/helpers/pluginProvider.js +30 -1
  125. package/dist/runtime/helpers/providers/directive.d.ts +4 -1
  126. package/dist/runtime/helpers/providers/directive.js +9 -2
  127. package/dist/runtime/helpers/stateProvider.js +1 -0
  128. package/dist/runtime/helpers/uiProvider.d.ts +5 -1
  129. package/dist/runtime/helpers/uiProvider.js +41 -7
  130. package/dist/runtime/helpers/webgl/index.d.ts +2 -3
  131. package/dist/runtime/helpers/webgl/index.js +9 -14
  132. package/dist/runtime/icons/dock-left.svg +1 -0
  133. package/dist/runtime/icons/dock-right.svg +1 -0
  134. package/dist/runtime/icons/dock-window.svg +1 -0
  135. package/dist/runtime/plugins/blokkliDirectives.js +1 -1
  136. package/dist/runtime/types/index.d.ts +4 -21
  137. package/package.json +1 -1
  138. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue +0 -56
  139. package/dist/runtime/blokkliPlugins/DroppableEdit/index.vue.d.ts +0 -24
  140. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue +0 -76
  141. package/dist/runtime/blokkliPlugins/ItemDropdown/index.vue.d.ts +0 -31
  142. package/dist/runtime/components/Edit/Features/BlockAddList/docs.md +0 -15
  143. package/dist/runtime/components/Edit/Features/Debug/Renderer.vue +0 -240
  144. package/dist/runtime/components/Edit/Features/DraggingOverlay/DropTargets/fragment.glsl +0 -96
  145. package/dist/runtime/components/Edit/Features/Hover/Overlay/fragment.glsl +0 -139
  146. package/dist/runtime/components/Edit/Features/Selection/OverlayFallback/index.vue +0 -42
  147. /package/dist/runtime/components/Edit/Features/Analyze/{Renderer.vue.d.ts → Main.vue.d.ts} +0 -0
  148. /package/dist/runtime/components/Edit/Features/Anchors/{Renderer.vue → Overlay/index.vue} +0 -0
  149. /package/dist/runtime/components/Edit/Features/{BlockAddList → Anchors/Overlay}/index.vue.d.ts +0 -0
  150. /package/dist/runtime/components/Edit/Features/Debug/{Renderer.vue.d.ts → Main.vue.d.ts} +0 -0
  151. /package/dist/runtime/components/Edit/Features/{Anchors/Renderer.vue.d.ts → Debug/Section/Features.vue.d.ts} +0 -0
  152. /package/dist/runtime/components/Edit/Features/DraggingOverlay/{DropTargets → Renderer}/index.vue.d.ts +0 -0
  153. /package/dist/runtime/components/Edit/Features/Ownership/{Renderer.vue → Banner/index.vue} +0 -0
  154. /package/dist/runtime/components/Edit/Features/Ownership/{Renderer.vue.d.ts → Banner/index.vue.d.ts} +0 -0
@@ -15,7 +15,7 @@ import {
15
15
  } from "#blokkli/helpers";
16
16
  import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
17
17
  import defineRenderer from "#blokkli/helpers/composables/defineRenderer";
18
- import { ref, computed, useBlokkli, onBeforeUnmount } from "#imports";
18
+ import { ref, computed, useBlokkli } from "#imports";
19
19
  import {
20
20
  setBuffersAndAttributes,
21
21
  drawBufferInfo,
@@ -64,10 +64,6 @@ const {
64
64
  types,
65
65
  fields
66
66
  } = useBlokkli();
67
- const gl = animation.gl();
68
- const canvas = animation.getCanvasElement();
69
- const ctx = !gl && canvas ? canvas.getContext("2d") : null;
70
- const programInfo = gl ? animation.registerProgram("drop_targets", gl, [vs, fs]) : null;
71
67
  const areas = dropAreas.getDropAreas(props.items).reduce((acc, v) => {
72
68
  acc[v.id] = v;
73
69
  return acc;
@@ -189,7 +185,7 @@ const buildChildren = (field, visible) => {
189
185
  if (!(el instanceof HTMLElement)) {
190
186
  continue;
191
187
  }
192
- const uuid = el.dataset.uuid;
188
+ const uuid = el.dataset.bkUuid;
193
189
  if (!uuid) {
194
190
  continue;
195
191
  }
@@ -371,7 +367,7 @@ const buildDropAreaRect = (area) => {
371
367
  cachedDropAreaRects[area.id] = dropAreaRect;
372
368
  return dropAreaRect;
373
369
  };
374
- const alphaBase = gl ? 0.7 : 0.3;
370
+ const alphaBase = 0.7;
375
371
  const colorTeal = rgbaToString(theme.teal.value.normal);
376
372
  const colorTealAlpha = rgbaToString(theme.teal.value.normal, alphaBase);
377
373
  const colorAccent = rgbaToString(theme.accent.value[800]);
@@ -387,7 +383,7 @@ function getRectType(field) {
387
383
  return 1 /* FIELD_1 */;
388
384
  }
389
385
  class DropTargetRectangleBufferCollector extends RectangleBufferCollector {
390
- getBufferInfo() {
386
+ getBufferInfo(gl) {
391
387
  const visibleFields = dom.getVisibleFields();
392
388
  const visibleBlocks = dom.getVisibleBlocks();
393
389
  const lengthBefore = this.positions.length;
@@ -450,8 +446,8 @@ class DropTargetRectangleBufferCollector extends RectangleBufferCollector {
450
446
  }
451
447
  this.processPendingRects();
452
448
  const hasChanged = lengthBefore !== this.positions.length;
453
- if (hasChanged) {
454
- this.bufferInfo = this.createBufferInfo();
449
+ if (hasChanged && gl) {
450
+ this.bufferInfo = this.createBufferInfo(gl);
455
451
  }
456
452
  return { info: this.bufferInfo, hasChanged };
457
453
  }
@@ -488,26 +484,6 @@ class DropTargetRectangleBufferCollector extends RectangleBufferCollector {
488
484
  return null;
489
485
  }
490
486
  }
491
- const collector = new DropTargetRectangleBufferCollector(gl, {
492
- deferredMode: true
493
- });
494
- if (gl) {
495
- collector.addRectangle(
496
- {
497
- id: "active-hover-rect",
498
- type: "active-area",
499
- label: "Field Area",
500
- color: "red",
501
- colorAlpha: "red",
502
- x: 0,
503
- y: 0,
504
- width: ui.artboardSize.value.width,
505
- height: ui.artboardSize.value.height
506
- },
507
- 5 /* ACTIVE_AREA */,
508
- false
509
- );
510
- }
511
487
  const fieldColors = computed(() => {
512
488
  return {
513
489
  "0": theme.accent.value[900],
@@ -632,72 +608,109 @@ function setHoveredFieldArea(box, mouse) {
632
608
  }
633
609
  let bufferInfo = null;
634
610
  let bufferChanged = false;
635
- onBlokkliEvent("canvas:draw", () => {
636
- const scale = ui.artboardScale.value;
637
- const offset = { ...ui.artboardOffset.value };
638
- dragBox.value = {
639
- x: (props.box.x - offset.x) / scale,
640
- y: (props.box.y - offset.y) / scale,
641
- width: props.box.width / scale,
642
- height: props.box.height / scale
643
- };
644
- const mouseAbsolute = toCanvasSpaceCoordinates(props.mouseX, props.mouseY);
645
- const result = collector.getBufferInfo();
646
- bufferInfo = result.info;
647
- bufferChanged = result.hasChanged;
648
- if (!props.isTouch) {
649
- if (cursorIsInsideClipped()) {
650
- const closest = collector.getClosestIntersectingRect(
651
- dragBox.value,
652
- mouseAbsolute
653
- );
654
- active.value = closest || null;
655
- } else {
656
- active.value = null;
611
+ const { collector } = defineRenderer("drop-targets", {
612
+ zIndex: 400,
613
+ only: true,
614
+ collector: () => {
615
+ const c = new DropTargetRectangleBufferCollector({ deferredMode: true });
616
+ c.addRectangle(
617
+ {
618
+ id: "active-hover-rect",
619
+ type: "active-area",
620
+ label: "Field Area",
621
+ color: "red",
622
+ colorAlpha: "red",
623
+ x: 0,
624
+ y: 0,
625
+ width: ui.artboardSize.value.width,
626
+ height: ui.artboardSize.value.height
627
+ },
628
+ 5 /* ACTIVE_AREA */,
629
+ false
630
+ );
631
+ return c;
632
+ },
633
+ program: () => ({ shaders: [vs, fs] }),
634
+ cursor: () => "grabbing",
635
+ render: (_ctx, gl, program) => {
636
+ const scale = ui.artboardScale.value;
637
+ const offset = { ...ui.artboardOffset.value };
638
+ dragBox.value = {
639
+ x: (props.box.x - offset.x) / scale,
640
+ y: (props.box.y - offset.y) / scale,
641
+ width: props.box.width / scale,
642
+ height: props.box.height / scale
643
+ };
644
+ const mouseAbsolute = toCanvasSpaceCoordinates(props.mouseX, props.mouseY);
645
+ const result = collector.getBufferInfo(gl);
646
+ bufferInfo = result.info;
647
+ bufferChanged = result.hasChanged;
648
+ if (!props.isTouch) {
649
+ if (cursorIsInsideClipped()) {
650
+ const closest = collector.getClosestIntersectingRect(
651
+ dragBox.value,
652
+ mouseAbsolute
653
+ );
654
+ active.value = closest || null;
655
+ } else {
656
+ active.value = null;
657
+ }
657
658
  }
658
- }
659
- setHoveredFieldArea(dragBox.value, mouseAbsolute);
660
- if (!gl && ctx) {
661
- ctx.clearRect(0, 0, canvas.width, canvas.height);
659
+ setHoveredFieldArea(dragBox.value, mouseAbsolute);
660
+ gl.useProgram(program.program);
661
+ animation.setSharedUniforms(gl, program);
662
+ setUniforms(program, uniforms.value);
663
+ if (!bufferInfo) {
664
+ return;
665
+ }
666
+ if (bufferChanged) {
667
+ setBuffersAndAttributes(gl, program, bufferInfo);
668
+ }
669
+ drawBufferInfo(gl, bufferInfo, gl.TRIANGLES);
670
+ },
671
+ renderFallback: (ctx, ctx2d) => {
672
+ const scale = ui.artboardScale.value;
673
+ const offset = { ...ui.artboardOffset.value };
674
+ dragBox.value = {
675
+ x: (props.box.x - offset.x) / scale,
676
+ y: (props.box.y - offset.y) / scale,
677
+ width: props.box.width / scale,
678
+ height: props.box.height / scale
679
+ };
680
+ const mouseAbsolute = toCanvasSpaceCoordinates(props.mouseX, props.mouseY);
681
+ const result = collector.getBufferInfo(void 0);
682
+ bufferInfo = result.info;
683
+ bufferChanged = result.hasChanged;
684
+ if (!props.isTouch) {
685
+ if (cursorIsInsideClipped()) {
686
+ const closest = collector.getClosestIntersectingRect(
687
+ dragBox.value,
688
+ mouseAbsolute
689
+ );
690
+ active.value = closest || null;
691
+ } else {
692
+ active.value = null;
693
+ }
694
+ }
695
+ setHoveredFieldArea(dragBox.value, mouseAbsolute);
662
696
  const rects = Object.values(collector.rects);
663
697
  for (let i = 0; i < rects.length; i++) {
664
698
  const rect = rects[i];
699
+ if (rect.id === "active-hover-rect") {
700
+ continue;
701
+ }
665
702
  if (active.value?.id === rect.id) {
666
- ctx.fillStyle = rect.color;
703
+ ctx2d.fillStyle = rect.color;
667
704
  } else {
668
- ctx.fillStyle = rect.colorAlpha;
705
+ ctx2d.fillStyle = rect.colorAlpha;
669
706
  }
670
- ctx.fillRect(
671
- (rect.x * scale + offset.x) * animation.dpi.value,
672
- (rect.y * scale + offset.y) * animation.dpi.value,
673
- rect.width * animation.dpi.value * scale,
674
- rect.height * animation.dpi.value * scale
707
+ ctx2d.fillRect(
708
+ (rect.x * scale + offset.x) * ctx.dpi,
709
+ (rect.y * scale + offset.y) * ctx.dpi,
710
+ rect.width * ctx.dpi * scale,
711
+ rect.height * ctx.dpi * scale
675
712
  );
676
713
  }
677
714
  }
678
715
  });
679
- if (gl && programInfo) {
680
- defineRenderer("drop-targets", {
681
- zIndex: 400,
682
- only: true,
683
- cursor: () => "grabbing",
684
- render: () => {
685
- gl.useProgram(programInfo.program);
686
- animation.setSharedUniforms(gl, programInfo);
687
- setUniforms(programInfo, uniforms.value);
688
- if (!bufferInfo) {
689
- return;
690
- }
691
- if (bufferChanged) {
692
- setBuffersAndAttributes(gl, programInfo, bufferInfo);
693
- }
694
- drawBufferInfo(gl, bufferInfo, gl.TRIANGLES);
695
- }
696
- });
697
- }
698
- onBeforeUnmount(() => {
699
- if (ctx) {
700
- ctx.clearRect(0, 0, canvas.width, canvas.height);
701
- }
702
- });
703
716
  </script>
@@ -1,9 +1,11 @@
1
+ #version 300 es
2
+
1
3
  precision highp float;
2
4
 
3
- attribute vec2 a_position;
4
- attribute vec4 a_quad;
5
- attribute float a_rect_id;
6
- attribute float a_rect_type;
5
+ in vec2 a_position;
6
+ in vec4 a_quad;
7
+ in float a_rect_id;
8
+ in float a_rect_type;
7
9
 
8
10
  uniform float u_scale;
9
11
  uniform float u_offset_x;
@@ -20,10 +22,19 @@ uniform vec4 u_active_hover_rect;
20
22
  uniform float u_active_hover_nesting_level;
21
23
  uniform float u_dpi;
22
24
 
23
- varying vec4 v_quad;
24
- varying float v_intersecting;
25
- varying float v_is_hover_area;
26
- varying vec3 v_color;
25
+ out vec4 v_quad;
26
+ out float v_intersecting;
27
+ out float v_is_hover_area;
28
+ out vec3 v_color;
29
+
30
+ // Optimized varyings - values computed once per vertex instead of per pixel
31
+ out vec2 v_size;
32
+ out vec2 v_location;
33
+ out vec2 v_size_inner;
34
+ out float v_thickness;
35
+ out float v_edge_softness;
36
+ out float v_radius_outer;
37
+ out float v_radius_inner;
27
38
 
28
39
  vec4 getQuad() {
29
40
  if (a_rect_type >= 5.0) {
@@ -75,4 +86,36 @@ void main() {
75
86
  } else {
76
87
  v_color = u_color_hover_area;
77
88
  }
89
+
90
+ // Compute values that are constant per quad (optimization)
91
+ bool isHoverArea = v_is_hover_area >= 1.0;
92
+ float stroke = isHoverArea ? 0.75 : 2.0;
93
+ float radiusBase = stroke * u_scale;
94
+
95
+ v_thickness = max(min(1.0 * u_scale, 3.0), 0.5);
96
+
97
+ // Calculate inset to draw border inside the quad
98
+ float inset = max(min(2.0 * u_scale, 1.0), 3.0) * v_thickness + stroke;
99
+
100
+ // Rectangle dimensions with inset
101
+ float u_rect_x = transformed_quad.x + inset;
102
+ float u_rect_y = transformed_quad.y + inset;
103
+ float u_rectWidth = transformed_quad.z - 2.0 * inset;
104
+ float u_rectHeight = transformed_quad.w - 2.0 * inset;
105
+
106
+ v_size = vec2(u_rectWidth, u_rectHeight);
107
+
108
+ // Center position of the rectangle
109
+ v_location = vec2(u_rect_x + v_size.x / 2.0, u_rect_y + v_size.y / 2.0);
110
+
111
+ v_edge_softness = 0.5 * u_dpi;
112
+
113
+ float borderWidth = stroke * u_scale * u_dpi;
114
+
115
+ // Different radius for inner and outer
116
+ v_radius_outer =
117
+ min(radiusBase * u_dpi, min(v_size.x, v_size.y)) + v_thickness;
118
+ v_radius_inner = v_radius_outer - borderWidth;
119
+
120
+ v_size_inner = v_size - 2.0 * borderWidth;
78
121
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <DropTargets
2
+ <Renderer
3
3
  v-if="dragItems.length && isVisible"
4
4
  v-slot="{ color, label }"
5
5
  :items="dragItems"
@@ -18,12 +18,12 @@
18
18
  :active-color="color"
19
19
  :active-label="label"
20
20
  />
21
- </DropTargets>
21
+ </Renderer>
22
22
  </template>
23
23
 
24
24
  <script setup>
25
25
  import DragItems from "./DragItems/index.vue";
26
- import DropTargets from "./DropTargets/index.vue";
26
+ import Renderer from "./Renderer/index.vue";
27
27
  import {
28
28
  ref,
29
29
  useBlokkli,
@@ -166,9 +166,6 @@ const close = async () => {
166
166
  el.textContent = originalText.value;
167
167
  }
168
168
  }
169
- if (el) {
170
- el.dataset.blokkliEditableActive = void 0;
171
- }
172
169
  };
173
170
  watch(modelValue, (newText) => {
174
171
  if (props.element && selection.editableActive.value && !props.isComponent) {
@@ -232,7 +229,6 @@ onMounted(() => {
232
229
  }
233
230
  originalText.value = modelValue.value;
234
231
  selection.editableActive.value = true;
235
- el.dataset.blokkliEditableActive = "true";
236
232
  const computedStyle = window.getComputedStyle(el);
237
233
  inputStyle.value = {
238
234
  textAlign: computedStyle.textAlign
@@ -246,8 +242,6 @@ onMounted(() => {
246
242
  });
247
243
  });
248
244
  onBeforeUnmount(async () => {
249
- const el = getElement();
250
245
  await close();
251
- el.dataset.blokkliEditableActive = void 0;
252
246
  });
253
247
  </script>
@@ -85,12 +85,16 @@ const buildEditable = (fieldName, uuid) => {
85
85
  if (!(element instanceof HTMLElement)) {
86
86
  return;
87
87
  }
88
+ const editable = directive.findEditable(fieldName, host);
89
+ if (!editable) {
90
+ return;
91
+ }
88
92
  return {
89
93
  fieldName,
90
94
  host,
91
95
  element,
92
- isComponent: element.dataset.blokkliEditableComponent === "true",
93
- value: element.dataset.blokkliEditableValue || "",
96
+ isComponent: editable.isComponent,
97
+ value: editable.getValue ? editable.getValue() : "",
94
98
  config
95
99
  };
96
100
  };
@@ -10,11 +10,7 @@
10
10
  :class="backgroundClass"
11
11
  >
12
12
  <ScaleToFit :width="previewWidth" :max-height="500">
13
- <BlokkliItem
14
- v-bind="item"
15
- parent-type="nested"
16
- class="bk-drop-element"
17
- />
13
+ <BlokkliItem v-bind="item" parent-type="nested" />
18
14
  </ScaleToFit>
19
15
  </div>
20
16
  </div>
@@ -0,0 +1,141 @@
1
+ #version 300 es
2
+
3
+ precision highp float;
4
+
5
+ in vec4 v_quad;
6
+ in vec4 v_rect_radius;
7
+ in vec2 v_rect_size;
8
+ in vec2 v_rect_center;
9
+ in float v_rect_type;
10
+ in vec2 v_quad_artboard_pos;
11
+ // Optimized varyings calculated in vertex shader
12
+ in vec4 v_corner_radii;
13
+ in float v_border_thickness;
14
+ in vec2 v_half_size;
15
+ in vec3 v_color;
16
+ in float v_dash_cycle;
17
+ in vec2 v_rect_size_artboard;
18
+
19
+ out vec4 fragColor;
20
+
21
+ uniform float u_opacity;
22
+
23
+ int pseudoQuadrant(vec2 p) {
24
+ return int(floor(step(0.0, p.x) + 2.0 * step(0.0, -p.y)));
25
+ }
26
+
27
+ float sdRoundBox(vec2 p, vec2 b, vec4 radii) {
28
+ int idx = pseudoQuadrant(p);
29
+ float cr;
30
+ if (idx == 0) cr = radii[0];
31
+ else if (idx == 1) cr = radii[1];
32
+ else if (idx == 2) cr = radii[3];
33
+ else cr = radii[2];
34
+ vec2 q = abs(p) - b + cr;
35
+ return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - cr;
36
+ }
37
+
38
+ void main() {
39
+ vec2 posRelativeToQuad = gl_FragCoord.xy - v_rect_center;
40
+
41
+ float mainDist = sdRoundBox(posRelativeToQuad, v_half_size, v_corner_radii);
42
+
43
+ // For editable fields (type 2), render both fill and solid border
44
+ if (v_rect_type > 1.5 && v_rect_type < 2.5) {
45
+ float u_edgeSoftness = 1.0;
46
+ float u_borderSoftness = 1.0;
47
+
48
+ // Render fill
49
+ float fillAlpha = 1.0 - smoothstep(-u_edgeSoftness, 0.0, mainDist);
50
+ vec4 fillColor = vec4(v_color, 0.2);
51
+
52
+ // Render solid border (non-dashed)
53
+ float borderAlpha =
54
+ 1.0 -
55
+ smoothstep(-u_borderSoftness, 0.0, abs(mainDist) - v_border_thickness);
56
+ vec4 borderColor = vec4(v_color, 1.0);
57
+
58
+ // Combine fill and border
59
+ vec4 combined = mix(
60
+ vec4(fillColor.rgb, fillAlpha * fillColor.a),
61
+ borderColor,
62
+ borderAlpha * borderColor.a
63
+ );
64
+
65
+ combined.a *= u_opacity;
66
+ fragColor = combined;
67
+ return;
68
+ }
69
+
70
+ // For blocks (type 0, 1, and 3), render border
71
+ float u_borderSoftness = 1.0;
72
+
73
+ float borderAlpha =
74
+ 1.0 -
75
+ smoothstep(-u_borderSoftness, 0.0, abs(mainDist) - v_border_thickness);
76
+
77
+ // Apply dashed pattern for all blocks
78
+ // Calculate perimeter distance in artboard space for scale-independent dashing
79
+
80
+ // Convert pixel position from viewport to artboard space
81
+ vec2 viewportToArtboardRatio = v_rect_size_artboard / v_rect_size;
82
+ vec2 posRelativeToQuad_artboard = posRelativeToQuad * viewportToArtboardRatio;
83
+
84
+ // Get artboard-space half dimensions
85
+ vec2 halfSize_artboard = v_rect_size_artboard / 2.0;
86
+
87
+ // Convert from center-relative to top-left-relative coordinates
88
+ vec2 posFromTopLeft = posRelativeToQuad_artboard + halfSize_artboard;
89
+
90
+ // Clamp to rect bounds to avoid edge issues
91
+ vec2 p = clamp(posFromTopLeft, vec2(0.0), v_rect_size_artboard);
92
+
93
+ // Two continuous dash paths anchored to visual top-left:
94
+ // Path 1: TOP (left→right) → RIGHT (top→bottom)
95
+ // Path 2: LEFT (top→bottom) → BOTTOM (left→right)
96
+ float perimeterDistance = 0.0;
97
+ float width = v_rect_size_artboard.x;
98
+ float height = v_rect_size_artboard.y;
99
+
100
+ // Determine which edge we're on based on distance to edges
101
+ vec2 absP = abs(posRelativeToQuad_artboard);
102
+ float dx = absP.x - halfSize_artboard.x;
103
+ float dy = absP.y - halfSize_artboard.y;
104
+
105
+ if (dy > dx) {
106
+ // Closer to top or bottom edge
107
+ if (posRelativeToQuad_artboard.y > 0.0) {
108
+ // Visual TOP edge: starts at top-left, goes left to right
109
+ perimeterDistance = p.x;
110
+ } else {
111
+ // Visual BOTTOM edge: continues from LEFT edge, then goes left to right
112
+ perimeterDistance = height + p.x;
113
+ }
114
+ } else {
115
+ // Closer to left or right edge
116
+ if (posRelativeToQuad_artboard.x < 0.0) {
117
+ // Visual LEFT edge: starts at visual top-left (0 at top, height at bottom)
118
+ perimeterDistance = height - p.y;
119
+ } else {
120
+ // Visual RIGHT edge: continues from TOP edge (width at visual top, width+height at visual bottom)
121
+ perimeterDistance = width + (height - p.y);
122
+ }
123
+ }
124
+
125
+ float dashPosition = mod(perimeterDistance, v_dash_cycle);
126
+ // dashWidth = v_dash_cycle / 2.0 (since dashWidth = dashGap = 7.0, dashCycle = 14.0)
127
+ float dashFactor = step(dashPosition, v_dash_cycle / 2.0);
128
+
129
+ // Only show dashes...
130
+ borderAlpha *= dashFactor;
131
+
132
+ vec4 borderColor = vec4(v_color, 1.0);
133
+ vec4 finalColor = mix(
134
+ vec4(0.0, 0.0, 0.0, 0.0),
135
+ borderColor,
136
+ borderAlpha * borderColor.a
137
+ );
138
+
139
+ finalColor.a *= u_opacity;
140
+ fragColor = finalColor;
141
+ }