@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
@@ -18,16 +18,14 @@ import { useTransitionedValue } from "#blokkli/helpers/useTransitionedValue";
18
18
  import { toShaderColor } from "#blokkli/helpers";
19
19
  const props = defineProps({
20
20
  blocks: { type: Array, required: true },
21
- gl: { type: null, required: true },
22
21
  hasHostSelected: { type: Boolean, required: true }
23
22
  });
24
23
  const { animation, theme, dom, ui, state } = useBlokkli();
25
- const programInfo = animation.registerProgram("selection", props.gl, [vs, fs]);
26
24
  class SelectionRectangleBufferCollector extends RectangleBufferCollector {
27
25
  uuids = [];
28
26
  lastCount = 0;
29
27
  prevKey = "";
30
- getBufferInfo(force) {
28
+ getBufferInfo(gl, force) {
31
29
  const key = props.blocks.map((block) => {
32
30
  const uuid = block.uuid;
33
31
  const rect = dom.getBlockRect(uuid);
@@ -93,13 +91,12 @@ class SelectionRectangleBufferCollector extends RectangleBufferCollector {
93
91
  }
94
92
  this.prevKey = key;
95
93
  }
96
- if (hasChanged) {
97
- this.bufferInfo = this.createBufferInfo();
94
+ if (hasChanged && gl) {
95
+ this.bufferInfo = this.createBufferInfo(gl);
98
96
  }
99
97
  return { info: this.bufferInfo, hasChanged };
100
98
  }
101
99
  }
102
- const collector = new SelectionRectangleBufferCollector(props.gl);
103
100
  const hasTransformingStyle = computed(
104
101
  () => ui.hasTransformOverlayOpen.value || ui.isTransforming.value
105
102
  );
@@ -109,68 +106,164 @@ const selectionColorOverride = computed(() => {
109
106
  return null;
110
107
  }
111
108
  if (color === "mono") {
112
- return toShaderColor(theme.getColor(color, "500"));
109
+ return theme.getColor(color, "500");
113
110
  } else if (color === "accent") {
114
- return toShaderColor(theme.getColor(color, "700"));
111
+ return theme.getColor(color, "700");
115
112
  }
116
- return toShaderColor(theme.getColor(color, "normal"));
113
+ return theme.getColor(color, "normal");
117
114
  });
118
115
  const getColorDefault = useTransitionedValue(() => {
119
116
  if (selectionColorOverride.value) {
120
117
  return selectionColorOverride.value;
121
118
  }
122
119
  if (hasTransformingStyle.value) {
123
- return toShaderColor(theme.orange.value.normal);
120
+ return theme.orange.value.normal;
124
121
  }
125
- return toShaderColor(theme.accent.value[600]);
122
+ return theme.accent.value[600];
126
123
  });
127
124
  const getColorInverted = useTransitionedValue(() => {
128
125
  if (selectionColorOverride.value) {
129
126
  return selectionColorOverride.value;
130
127
  }
131
128
  if (hasTransformingStyle.value) {
132
- return toShaderColor(theme.orange.value.normal);
129
+ return theme.orange.value.normal;
133
130
  }
134
- return toShaderColor([255, 255, 255]);
131
+ return [255, 255, 255];
135
132
  });
136
133
  const getColorLibrary = useTransitionedValue(() => {
137
134
  if (selectionColorOverride.value) {
138
135
  return selectionColorOverride.value;
139
136
  }
140
137
  if (hasTransformingStyle.value) {
141
- return toShaderColor(theme.orange.value.normal);
138
+ return theme.orange.value.normal;
142
139
  }
143
- return toShaderColor(theme.lime.value.normal);
140
+ return theme.lime.value.normal;
144
141
  });
145
142
  const getColorHost = useTransitionedValue(() => {
146
- return toShaderColor(theme.mono.value[700]);
143
+ return theme.mono.value[700];
147
144
  });
148
145
  const getTransforming = useTransitionedValue(() => {
149
146
  return ui.isTransforming.value ? 1 : 0;
150
147
  });
151
- defineRenderer("selection-overlay", {
148
+ const { collector } = defineRenderer("selection-overlay", {
152
149
  zIndex: 100,
153
- render: (ctx) => {
154
- props.gl.useProgram(programInfo.program);
155
- const { info } = collector.getBufferInfo();
150
+ collector: () => new SelectionRectangleBufferCollector(),
151
+ program: () => ({ shaders: [vs, fs] }),
152
+ render: (ctx, gl, program) => {
153
+ gl.useProgram(program.program);
154
+ const { info } = collector.getBufferInfo(gl);
156
155
  if (!info) {
157
156
  return;
158
157
  }
159
- setUniforms(programInfo, {
160
- u_color_default: getColorDefault(),
161
- u_color_inverted: getColorInverted(),
162
- u_color_library: getColorLibrary(),
163
- u_color_host: getColorHost(),
158
+ setUniforms(program, {
159
+ u_color_default: toShaderColor(getColorDefault()),
160
+ u_color_inverted: toShaderColor(getColorInverted()),
161
+ u_color_library: toShaderColor(getColorLibrary()),
162
+ u_color_host: toShaderColor(getColorHost()),
164
163
  u_artboard_size: [
165
164
  ui.artboardSize.value.width,
166
165
  ui.artboardSize.value.height
167
166
  ],
168
167
  u_is_transforming: getTransforming(),
168
+ u_opacity: ctx.changeOptionsTransition,
169
169
  u_time: ctx.time
170
170
  });
171
- animation.setSharedUniforms(props.gl, programInfo);
172
- setBuffersAndAttributes(props.gl, programInfo, info);
173
- drawBufferInfo(props.gl, info, props.gl.TRIANGLES);
171
+ animation.setSharedUniforms(gl, program);
172
+ setBuffersAndAttributes(gl, program, info);
173
+ drawBufferInfo(gl, info, gl.TRIANGLES);
174
+ },
175
+ renderFallback: (ctx, ctx2d) => {
176
+ collector.getBufferInfo();
177
+ const rects = Object.values(collector.rects);
178
+ if (rects.length === 0) {
179
+ return;
180
+ }
181
+ ctx2d.globalAlpha = ctx.changeOptionsTransition;
182
+ const rgbaToCss = (rgb) => {
183
+ return `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
184
+ };
185
+ const colorDefault = rgbaToCss(getColorDefault());
186
+ const colorInverted = rgbaToCss(getColorInverted());
187
+ const colorLibrary = rgbaToCss(getColorLibrary());
188
+ const colorHost = rgbaToCss(getColorHost());
189
+ const smoothstepValue = Math.max(
190
+ 0,
191
+ Math.min(1, (ctx.artboardScale - 0.3) / 0.7)
192
+ );
193
+ const thickness = (0.5 + smoothstepValue * 2.5) * ctx.dpi;
194
+ for (let i = 0; i < rects.length; i++) {
195
+ const rect = rects[i];
196
+ let strokeColor = colorDefault;
197
+ if (rect.isFromLibrary) {
198
+ strokeColor = colorLibrary;
199
+ } else if (rect.isInverted) {
200
+ strokeColor = colorInverted;
201
+ } else if (rect.id === "host") {
202
+ strokeColor = colorHost;
203
+ }
204
+ ctx2d.strokeStyle = strokeColor;
205
+ ctx2d.lineWidth = thickness;
206
+ const viewportX = (rect.x * ctx.artboardScale + ctx.artboardOffset.x) * ctx.dpi;
207
+ const viewportY = (rect.y * ctx.artboardScale + ctx.artboardOffset.y) * ctx.dpi;
208
+ const viewportWidth = rect.width * ctx.artboardScale * ctx.dpi;
209
+ const viewportHeight = rect.height * ctx.artboardScale * ctx.dpi;
210
+ const maxRadius = Math.min(viewportWidth, viewportHeight) / 2;
211
+ const rtl = Math.min(
212
+ rect.radius[0] * ctx.artboardScale * ctx.dpi,
213
+ maxRadius
214
+ );
215
+ const rtr = Math.min(
216
+ rect.radius[1] * ctx.artboardScale * ctx.dpi,
217
+ maxRadius
218
+ );
219
+ const rbr = Math.min(
220
+ rect.radius[2] * ctx.artboardScale * ctx.dpi,
221
+ maxRadius
222
+ );
223
+ const rbl = Math.min(
224
+ rect.radius[3] * ctx.artboardScale * ctx.dpi,
225
+ maxRadius
226
+ );
227
+ ctx2d.beginPath();
228
+ ctx2d.moveTo(viewportX + rtl, viewportY);
229
+ ctx2d.lineTo(viewportX + viewportWidth - rtr, viewportY);
230
+ if (rtr > 0) {
231
+ ctx2d.arcTo(
232
+ viewportX + viewportWidth,
233
+ viewportY,
234
+ viewportX + viewportWidth,
235
+ viewportY + rtr,
236
+ rtr
237
+ );
238
+ }
239
+ ctx2d.lineTo(viewportX + viewportWidth, viewportY + viewportHeight - rbr);
240
+ if (rbr > 0) {
241
+ ctx2d.arcTo(
242
+ viewportX + viewportWidth,
243
+ viewportY + viewportHeight,
244
+ viewportX + viewportWidth - rbr,
245
+ viewportY + viewportHeight,
246
+ rbr
247
+ );
248
+ }
249
+ ctx2d.lineTo(viewportX + rbl, viewportY + viewportHeight);
250
+ if (rbl > 0) {
251
+ ctx2d.arcTo(
252
+ viewportX,
253
+ viewportY + viewportHeight,
254
+ viewportX,
255
+ viewportY + viewportHeight - rbl,
256
+ rbl
257
+ );
258
+ }
259
+ ctx2d.lineTo(viewportX, viewportY + rtl);
260
+ if (rtl > 0) {
261
+ ctx2d.arcTo(viewportX, viewportY, viewportX + rtl, viewportY, rtl);
262
+ }
263
+ ctx2d.closePath();
264
+ ctx2d.stroke();
265
+ }
266
+ ctx2d.globalAlpha = 1;
174
267
  }
175
268
  });
176
269
  onBlokkliEvent("ui:resized", function() {
@@ -1,11 +1,9 @@
1
1
  import type { RenderedFieldListItem } from '#blokkli/types';
2
2
  declare const _default: import("vue").DefineComponent<{
3
3
  blocks: RenderedFieldListItem[];
4
- gl: WebGLRenderingContext;
5
4
  hasHostSelected: boolean;
6
5
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
7
6
  blocks: RenderedFieldListItem[];
8
- gl: WebGLRenderingContext;
9
7
  hasHostSelected: boolean;
10
8
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
9
  export default _default;
@@ -1,12 +1,14 @@
1
+ #version 300 es
2
+
1
3
  precision highp float;
2
4
 
3
5
  // [x, y] position.
4
- attribute vec2 a_position;
6
+ in vec2 a_position;
5
7
  // The [x,y,width, height] of the quad the vertex belongs to.
6
- attribute vec4 a_quad;
7
- attribute float a_rect_id;
8
- attribute float a_rect_type;
9
- attribute vec4 a_rect_radius;
8
+ in vec4 a_quad;
9
+ in float a_rect_id;
10
+ in float a_rect_type;
11
+ in vec4 a_rect_radius;
10
12
 
11
13
  // The global scaling applied to all quads.
12
14
  uniform float u_scale;
@@ -22,15 +24,18 @@ uniform vec3 u_color_library;
22
24
  uniform vec3 u_color_host;
23
25
 
24
26
  // The transformed quad for the fragment shader.
25
- varying vec4 v_quad;
26
- varying vec3 v_color;
27
- varying vec4 v_rect_radius;
28
- varying float v_thickness;
29
- varying vec2 v_rect_size;
30
- varying vec2 v_rect_center;
31
- varying float v_transition;
32
- varying float v_rect_id;
33
- varying float v_rect_width;
27
+ out vec4 v_quad;
28
+ out vec3 v_color;
29
+ out vec4 v_rect_radius;
30
+ out float v_thickness;
31
+ out vec2 v_rect_size;
32
+ out vec2 v_rect_center;
33
+ out float v_transition;
34
+ out float v_rect_id;
35
+ out float v_rect_width;
36
+ // Optimized varyings calculated in vertex shader
37
+ out float v_stripe_distance;
38
+ out vec4 v_base_scaled_radius;
34
39
 
35
40
  void main() {
36
41
  // Define the increase size in viewport terms (not affected by u_scale)
@@ -96,4 +101,8 @@ void main() {
96
101
  v_rect_size = vec2(v_quad.z, v_quad.w);
97
102
  v_rect_center = vec2(v_quad.x + v_quad.z / 2.0, v_quad.y + v_quad.w / 2.0); // The pixel-space rectangle center location
98
103
  v_transition = smoothstep(0.5, 0.8, u_scale);
104
+
105
+ // Calculate optimized values once per vertex
106
+ v_stripe_distance = 300.0 * u_scale;
107
+ v_base_scaled_radius = v_rect_radius * u_scale;
99
108
  }
@@ -1,22 +1,11 @@
1
1
  <template>
2
- <Overlay
3
- v-if="isVisible && gl && animation.webglEnabled.value"
2
+ <Renderer
3
+ v-if="isVisible"
4
+ :key="animation.renderKey.value"
4
5
  :blocks="selection.items.value"
5
6
  :uuids="selection.uuids.value"
6
- :gl="gl"
7
7
  :has-host-selected="selection.hasHostSelected.value"
8
8
  />
9
- <OverlayFallback v-if="isVisible && !gl" :uuids="selection.uuids.value" />
10
- <PluginItemDropdown
11
- v-if="itemDropdownItems.length"
12
- id="selection"
13
- :title="$t('selectionActionGroupTitle', 'Selection')"
14
- :enabled="itemDropdownEnabled"
15
- :items="itemDropdownItems"
16
- icon="selection"
17
- weight="200"
18
- @select="onSelectDropdownItem"
19
- />
20
9
 
21
10
  <SelectionAddButtons
22
11
  v-if="state.editMode.value === 'editing'"
@@ -25,8 +14,7 @@
25
14
  </template>
26
15
 
27
16
  <script setup>
28
- import Overlay from "./Overlay/index.vue";
29
- import OverlayFallback from "./OverlayFallback/index.vue";
17
+ import Renderer from "./Renderer/index.vue";
30
18
  import SelectionAddButtons from "./AddButtons/index.vue";
31
19
  import {
32
20
  calculateIntersection,
@@ -37,7 +25,7 @@ import {
37
25
  } from "#blokkli/helpers";
38
26
  import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
39
27
  import useStateBasedCache from "#blokkli/helpers/composables/useStateBasedCache";
40
- import { PluginItemDropdown } from "#blokkli/plugins";
28
+ import defineItemDropdownAction from "#blokkli/helpers/composables/defineItemDropdownAction";
41
29
  import {
42
30
  computed,
43
31
  useBlokkli,
@@ -65,54 +53,20 @@ const {
65
53
  blocks,
66
54
  element
67
55
  } = useBlokkli();
68
- const getSelectionOrder = useStateBasedCache(() => {
69
- return element.queryAll(
70
- ui.artboardElement(),
71
- "[data-uuid]",
56
+ const getSelectionOrder = useStateBasedCache(
57
+ () => element.queryAll(
58
+ ui.providerElement,
59
+ ".bk-field-list-item",
72
60
  "getSelectionOrder",
73
- (el) => el.dataset.uuid
74
- );
75
- });
61
+ (el) => el.dataset.bkUuid
62
+ )
63
+ );
76
64
  const selectedBundle = computed(() => {
77
65
  if (selection.bundles.value.length === 1) {
78
66
  return selection.bundles.value[0] ?? null;
79
67
  }
80
68
  return null;
81
69
  });
82
- const itemDropdownEnabled = computed(() => true);
83
- const itemDropdownItems = computed(() => {
84
- if (selectedBundle.value) {
85
- const label = types.getBlockBundleDefinition(selectedBundle.value)?.label ?? selectedBundle.value;
86
- return [
87
- {
88
- id: "select-all-of-bundle",
89
- label: $t("selectAllOfBundle", 'Select all "@bundle" blocks').replace(
90
- "@bundle",
91
- label
92
- )
93
- }
94
- ];
95
- } else if (selection.hasHostSelected.value) {
96
- return [
97
- {
98
- id: "select-all-blocks",
99
- label: $t("selectAllBlocks", "Select all blocks")
100
- }
101
- ];
102
- }
103
- return [];
104
- });
105
- function onSelectDropdownItem(item) {
106
- if (item.id === "select-all-of-bundle") {
107
- if (selectedBundle.value) {
108
- const uuids = state.getAllUuids(selectedBundle.value);
109
- eventBus.emit("select", uuids);
110
- }
111
- } else if (item.id === "select-all-blocks") {
112
- selectAllBlocks();
113
- }
114
- }
115
- const gl = animation.gl();
116
70
  const hasSelectedOnce = ref(false);
117
71
  const stop = watch(
118
72
  selection.hasAnythingSelected,
@@ -124,7 +78,7 @@ const stop = watch(
124
78
  }
125
79
  );
126
80
  const isVisible = computed(
127
- () => dom.isReady.value && !selection.isMultiSelecting.value && !selection.editableActive.value && !selection.isChangingOptions.value && !selection.isDragging.value && !ui.isAnimating.value && hasSelectedOnce.value
81
+ () => dom.isReady.value && !selection.isMultiSelecting.value && !selection.editableActive.value && !selection.isDragging.value && !ui.isAnimating.value && hasSelectedOnce.value
128
82
  );
129
83
  const findMostVisibleBlock = () => {
130
84
  const viewport = ui.visibleViewportPadded.value;
@@ -310,6 +264,39 @@ onBlokkliEvent("keyPressed", (e) => {
310
264
  selectAllBlocks();
311
265
  }
312
266
  });
267
+ defineItemDropdownAction(() => {
268
+ if (selectedBundle.value) {
269
+ const label = types.getBlockBundleDefinition(selectedBundle.value)?.label ?? selectedBundle.value;
270
+ return {
271
+ id: "selection-select-all-of-bundle",
272
+ label: $t("selectAllOfBundle", 'Select all "@bundle" blocks').replace(
273
+ "@bundle",
274
+ label
275
+ ),
276
+ icon: "selection",
277
+ group: "selection",
278
+ weight: 200,
279
+ callback: () => {
280
+ if (selectedBundle.value) {
281
+ const uuids = state.getAllUuids(selectedBundle.value);
282
+ eventBus.emit("select", uuids);
283
+ }
284
+ }
285
+ };
286
+ }
287
+ });
288
+ defineItemDropdownAction(() => {
289
+ if (selection.hasHostSelected.value) {
290
+ return {
291
+ id: "selection-select-all-blocks",
292
+ label: $t("selectAllBlocks", "Select all blocks"),
293
+ icon: "selection",
294
+ group: "selection",
295
+ weight: 200,
296
+ callback: selectAllBlocks
297
+ };
298
+ }
299
+ });
313
300
  </script>
314
301
 
315
302
  <script>
@@ -38,14 +38,14 @@
38
38
  }"
39
39
  @click.prevent="onClickPreview"
40
40
  >
41
- {{ $t("transformDialogButtonPreview", "Preview") }}
41
+ {{ $t("transformDialogButtonPreview", "New suggestion") }}
42
42
  </button>
43
43
  <button
44
44
  class="bk-button bk-is-orange"
45
45
  :disabled
46
46
  @click.prevent="onClickSubmit"
47
47
  >
48
- {{ $t("transformDialogButtonApply", "Apply") }}
48
+ {{ $t("transformDialogButtonApply", "Apply changes") }}
49
49
  </button>
50
50
  </footer>
51
51
  </div>
@@ -183,10 +183,10 @@ onMounted(async () => {
183
183
  ui.hasTransformOverlayOpen.value = true;
184
184
  selection.lockSelection("transform-dialog");
185
185
  if (hasSeedInput.value && supportsPreview.value) {
186
- const hasOnlySeedInputs = props.plugin.configInputs?.every(
187
- (v) => v.type === "seed"
186
+ const hasNoRequiredInput = props.plugin.configInputs?.every(
187
+ (v) => v.type === "seed" || !v.required
188
188
  );
189
- if (hasOnlySeedInputs === true) {
189
+ if (hasNoRequiredInput === true) {
190
190
  await onClickPreview();
191
191
  }
192
192
  }
@@ -1,25 +1,4 @@
1
1
  <template>
2
- <PluginItemDropdown
3
- id="transform"
4
- :title="$t('transformTo', 'Actions')"
5
- :enabled="!!possibleTransforms.length"
6
- :items="possibleTransforms"
7
- icon="script"
8
- weight="100"
9
- @select="onSelectBlockTransformPlugin($event, selection.uuids.value)"
10
- />
11
-
12
- <PluginItemDropdown
13
- v-if="hostPlugins.length"
14
- id="transform-host"
15
- :title="$t('transformTo', 'Actions')"
16
- :enabled="selection.hasHostSelected.value"
17
- :items="hostPlugins"
18
- icon="script"
19
- weight="100"
20
- @select="onSelectHostTransformPlugin($event)"
21
- />
22
-
23
2
  <Teleport to="body">
24
3
  <BlokkliTransition name="transform-overlay">
25
4
  <TransformDialog
@@ -42,10 +21,10 @@ import {
42
21
  defineBlokkliFeature,
43
22
  useLazyAsyncData
44
23
  } from "#imports";
45
- import { PluginItemDropdown } from "#blokkli/plugins";
46
24
  import { BlokkliTransition } from "#blokkli/components";
47
25
  import { filterTransforms } from "#blokkli/helpers/transform";
48
26
  import defineCommands from "#blokkli/helpers/composables/defineCommands";
27
+ import defineItemDropdownAction from "#blokkli/helpers/composables/defineItemDropdownAction";
49
28
  import TransformDialog from "./Dialog/index.vue";
50
29
  const { adapter } = defineBlokkliFeature({
51
30
  id: "transform",
@@ -218,6 +197,34 @@ defineCommands(
218
197
  }
219
198
  }))
220
199
  );
200
+ defineItemDropdownAction(() => {
201
+ if (possibleTransforms.value.length) {
202
+ return possibleTransforms.value.map((transform) => ({
203
+ id: "transform-block-" + transform.id,
204
+ label: transform.label,
205
+ icon: "script",
206
+ group: "transform",
207
+ weight: 100,
208
+ callback: () => {
209
+ onSelectBlockTransformPlugin(transform, selection.uuids.value);
210
+ }
211
+ }));
212
+ }
213
+ });
214
+ defineItemDropdownAction(() => {
215
+ if (selection.hasHostSelected.value && hostPlugins.value && hostPlugins.value.length) {
216
+ return hostPlugins.value.map((plugin) => ({
217
+ id: "transform-host-" + plugin.id,
218
+ label: plugin.label,
219
+ icon: "script",
220
+ group: "transform",
221
+ weight: 100,
222
+ callback: () => {
223
+ onSelectHostTransformPlugin(plugin);
224
+ }
225
+ }));
226
+ }
227
+ });
221
228
  </script>
222
229
 
223
230
  <script>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div>
3
+ <div class="bk-form-label">
4
+ {{ label }}<span v-if="required" class="bk-required-indicator">*</span>
5
+ </div>
6
+ <div>
7
+ <label v-for="option in options" :key="option.value" class="bk-checkbox">
8
+ <input
9
+ :checked="isChecked(option.value)"
10
+ type="checkbox"
11
+ :value="option.value"
12
+ :required
13
+ :disabled
14
+ @change="toggleValue(option.value)"
15
+ />
16
+ <span>{{ option.label }}</span>
17
+ </label>
18
+ </div>
19
+ <div v-if="description" class="bk-form-description">{{ description }}</div>
20
+ </div>
21
+ </template>
22
+
23
+ <script setup>
24
+ defineProps({
25
+ id: { type: String, required: true },
26
+ label: { type: String, required: true },
27
+ options: { type: Array, required: true },
28
+ required: { type: Boolean, required: false },
29
+ disabled: { type: Boolean, required: false },
30
+ description: { type: String, required: false }
31
+ });
32
+ const value = defineModel({ type: Array, ...{ default: [] } });
33
+ function isChecked(optionValue) {
34
+ return value.value.includes(optionValue);
35
+ }
36
+ function toggleValue(optionValue) {
37
+ if (value.value.includes(optionValue)) {
38
+ value.value = value.value.filter((v) => v !== optionValue);
39
+ } else {
40
+ value.value = [...value.value, optionValue];
41
+ }
42
+ }
43
+ </script>
@@ -0,0 +1,20 @@
1
+ type __VLS_Props = {
2
+ id: string;
3
+ label: string;
4
+ options: {
5
+ value: string;
6
+ label: string;
7
+ }[];
8
+ required?: boolean;
9
+ disabled?: boolean;
10
+ description?: string;
11
+ };
12
+ type __VLS_PublicProps = __VLS_Props & {
13
+ modelValue?: string[];
14
+ };
15
+ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
+ "update:modelValue": (value: string[]) => any;
17
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
+ "onUpdate:modelValue"?: ((value: string[]) => any) | undefined;
19
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
20
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  type __VLS_Props = {
2
- type: 'success' | 'error';
2
+ type: 'success' | 'error' | 'warning';
3
3
  message: string;
4
4
  additional?: string | Error | unknown;
5
5
  };
@@ -124,7 +124,7 @@ const onWheel = (e) => {
124
124
  };
125
125
  const isInIframe = () => window.parent !== window;
126
126
  const onFocusItem = (uuid) => {
127
- const el = document.querySelector(`[data-uuid="${uuid}"]`);
127
+ const el = document.querySelector(`[data-bk-uuid="${uuid}"]`);
128
128
  if (el) {
129
129
  const elRect = el.getBoundingClientRect();
130
130
  if (!intersects(elRect, {
@@ -10,14 +10,11 @@
10
10
 
11
11
  <script setup>
12
12
  import { useBlokkli } from "#imports";
13
- import {
14
- buildDraggableItem,
15
- getDistance,
16
- getInteractionCoordinates
17
- } from "#blokkli/helpers";
13
+ import { getDistance, getInteractionCoordinates } from "#blokkli/helpers";
18
14
  const { eventBus } = useBlokkli();
19
15
  const props = defineProps({
20
- getDragItems: { type: Function, required: false }
16
+ getDragItems: { type: Function, required: false },
17
+ buildItem: { type: Function, required: true }
21
18
  });
22
19
  let pointerStartCoords = null;
23
20
  let activeItem = null;
@@ -31,10 +28,10 @@ function onPointerDown(e) {
31
28
  }
32
29
  pointerStartCoords = getInteractionCoordinates(e);
33
30
  const sortliItem = e.target.closest("[data-sortli-id]");
34
- if (!sortliItem) {
31
+ if (!(sortliItem instanceof HTMLElement)) {
35
32
  return;
36
33
  }
37
- const item = buildDraggableItem(sortliItem);
34
+ const item = props.buildItem(sortliItem);
38
35
  if (!item) {
39
36
  return;
40
37
  }
@@ -1,8 +1,10 @@
1
1
  import type { DraggableItem } from '#blokkli/types';
2
2
  declare const _default: __VLS_WithSlots<import("vue").DefineComponent<{
3
3
  getDragItems?: (activeItem?: DraggableItem) => DraggableItem[] | null;
4
+ buildItem: (el: HTMLElement) => DraggableItem | null | undefined;
4
5
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
5
6
  getDragItems?: (activeItem?: DraggableItem) => DraggableItem[] | null;
7
+ buildItem: (el: HTMLElement) => DraggableItem | null | undefined;
6
8
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
7
9
  default?: (props: {}) => any;
8
10
  }>;