@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
@@ -1,240 +0,0 @@
1
- <template>
2
- <PluginSidebar id="debug" title="Debug" icon="bug" weight="200">
3
- <div class="bk bk-debug">
4
- <section>
5
- <h2>Keyboard</h2>
6
- <div class="bk-debug-list">
7
- <div>
8
- <div>Space</div>
9
- <div>{{ keyboard.isPressingSpace.value }}</div>
10
- </div>
11
- <div>
12
- <div>Control</div>
13
- <div>{{ keyboard.isPressingControl.value }}</div>
14
- </div>
15
- </div>
16
- </section>
17
-
18
- <section>
19
- <h2>Selection</h2>
20
- <div class="bk-debug-list">
21
- <div>
22
- <div>Count</div>
23
- <div>{{ selection.uuids.value.length }}</div>
24
- </div>
25
- <div>
26
- <div>isDragging</div>
27
- <div>{{ selection.isDragging.value }}</div>
28
- </div>
29
- <div>
30
- <div>isDraggingExisting</div>
31
- <div>{{ selection.isDraggingExisting.value }}</div>
32
- </div>
33
- <div>
34
- <div>Is multiselecting</div>
35
- <div>{{ selection.isMultiSelecting.value }}</div>
36
- </div>
37
- </div>
38
- </section>
39
-
40
- <section>
41
- <h2>Rendering</h2>
42
- <div class="bk-debug-list">
43
- <div>
44
- <div>DPI</div>
45
- <div>{{ animation.dpi.value }}</div>
46
- </div>
47
- <div v-for="overlay in debug.overlays.value" :key="overlay.id">
48
- <FormToggle
49
- :label="overlay.label"
50
- :model-value="overlay.active"
51
- @update:model-value="debug.toggleOverlay(overlay.id)"
52
- />
53
- </div>
54
- <div>
55
- <FormToggle
56
- label="Set transforming"
57
- :model-value="ui.isTransforming.value"
58
- @update:model-value="toggleTransforming"
59
- />
60
- </div>
61
-
62
- <div>
63
- <FormToggle
64
- label="Enable WebGL"
65
- :model-value="animation.webglEnabled.value"
66
- @update:model-value="toggleWebgl"
67
- />
68
- </div>
69
- <div>
70
- <button
71
- class="bk-button bk-is-small"
72
- @click.prevent="() => dom.updateVisibleRects()"
73
- >
74
- Refresh Rects
75
- </button>
76
- </div>
77
- </div>
78
- </section>
79
-
80
- <section>
81
- <h2>Logging</h2>
82
- <div class="bk-debug-list">
83
- <div>
84
- <div>
85
- <FormToggle v-model="logEvents" label="Log Events" />
86
- </div>
87
- <div>
88
- <button
89
- class="bk-button bk-is-small"
90
- @click.prevent="() => console.log(dom.getDebugData())"
91
- >
92
- Log DOM state
93
- </button>
94
- </div>
95
- </div>
96
- </div>
97
- </section>
98
-
99
- <section>
100
- <h2>Icons</h2>
101
- <div class="bk-debug-icons">
102
- <div v-for="icon in iconItems" :key="icon">
103
- <Icon :name="icon" />
104
- <p>{{ icon }}</p>
105
- </div>
106
- </div>
107
- </section>
108
-
109
- <section>
110
- <h2>Features</h2>
111
- <div class="bk-debug-features">
112
- <div v-for="feature in featuresList" :key="feature.id">
113
- <div>
114
- <span
115
- class="bk-status-indicator"
116
- :class="feature.mounted ? 'bk-is-success' : 'bk-is-danger'"
117
- />
118
- </div>
119
- <div>
120
- <h3>{{ feature.label }}</h3>
121
- <div>{{ feature.id }}</div>
122
- <p>{{ feature.description }}</p>
123
- </div>
124
- </div>
125
- </div>
126
- </section>
127
- </div>
128
- </PluginSidebar>
129
-
130
- <PluginDebugOverlay id="viewport" title="Show viewport overlay">
131
- <DebugViewport />
132
- </PluginDebugOverlay>
133
-
134
- <PluginDebugOverlay id="rects" title="Show field and block rects">
135
- <DebugRects />
136
- </PluginDebugOverlay>
137
-
138
- <PluginItemDropdown
139
- v-if="itemDropdownItems.length"
140
- id="selection"
141
- :title="$t('selectionActionGroupTitle', 'Selection')"
142
- enabled
143
- :items="itemDropdownItems"
144
- icon="bug"
145
- weight="200"
146
- @select="onSelectDropdownItem"
147
- />
148
- </template>
149
-
150
- <script setup>
151
- import { useBlokkli, onMounted, onBeforeUnmount, computed } from "#imports";
152
- import {
153
- PluginSidebar,
154
- PluginDebugOverlay,
155
- PluginItemDropdown
156
- } from "#blokkli/plugins";
157
- import { Icon, FormToggle } from "#blokkli/components";
158
- import { icons } from "#blokkli-build/icons";
159
- import DebugViewport from "./Viewport/index.vue";
160
- import DebugRects from "./Rects/index.vue";
161
- const { logger } = defineProps({
162
- logger: { type: Object, required: true }
163
- });
164
- const {
165
- keyboard,
166
- selection,
167
- eventBus,
168
- features,
169
- debug,
170
- ui,
171
- animation,
172
- dom,
173
- storage,
174
- $t
175
- } = useBlokkli();
176
- const logEvents = storage.use("debug:log-events", true);
177
- const iconItems = computed(() => Object.keys(icons));
178
- const featuresList = computed(() => {
179
- return features.features.value.map((v) => {
180
- const feature = features.mountedFeatures.value.find((f) => f.id === v.id);
181
- return {
182
- id: v.id,
183
- label: v.label,
184
- description: v.description,
185
- dependencies: v.dependencies?.join(", "),
186
- mounted: !!feature
187
- };
188
- });
189
- });
190
- const onEvent = (name, data) => {
191
- if (!logEvents.value) {
192
- return;
193
- }
194
- if (name === "animationFrame" || name === "animationFrame:before" || name === "animationFrame:after" || name === "canvas:draw") {
195
- return;
196
- }
197
- logger.log("Event: " + String(name), data);
198
- };
199
- function toggleTransforming() {
200
- if (ui.isTransforming.value) {
201
- ui.setTransform();
202
- } else {
203
- ui.setTransform("Transform plugin label");
204
- }
205
- }
206
- function toggleWebgl() {
207
- if (animation.webglEnabled.value) {
208
- animation.webglEnabled.value = false;
209
- } else {
210
- animation.webglEnabled.value = true;
211
- }
212
- }
213
- onMounted(() => {
214
- eventBus.on("*", onEvent);
215
- });
216
- onBeforeUnmount(() => {
217
- eventBus.off("*", onEvent);
218
- });
219
- const itemDropdownItems = computed(() => {
220
- if (selection.uuids.value.length === 1) {
221
- return [
222
- {
223
- id: "copy-uuid",
224
- label: "Copy UUID"
225
- }
226
- ];
227
- }
228
- return [];
229
- });
230
- async function onSelectDropdownItem(item) {
231
- if (item.id === "copy-uuid") {
232
- const type = "text/plain";
233
- const clipboardItemData = {
234
- [type]: selection.uuids.value.at(0) ?? ""
235
- };
236
- const clipboardItem = new ClipboardItem(clipboardItemData);
237
- await navigator.clipboard.write([clipboardItem]);
238
- }
239
- }
240
- </script>
@@ -1,96 +0,0 @@
1
- precision highp float;
2
-
3
- varying float v_intersecting;
4
- varying float v_is_hover_area;
5
- varying vec4 v_quad;
6
- varying vec3 v_color;
7
-
8
- uniform float u_scale;
9
- uniform float u_dpi;
10
- uniform vec2 u_resolution;
11
- uniform float u_active_hover_nesting_level;
12
-
13
- float roundedBoxSDF(vec2 CenterPosition, vec2 Size, float Radius) {
14
- return length(max(abs(CenterPosition) - Size + Radius, 0.0)) - Radius;
15
- }
16
-
17
- void main() {
18
- bool isHoverArea = v_is_hover_area >= 1.0;
19
- float stroke = isHoverArea ? 0.75 : 2.0;
20
- float radiusBase = stroke * u_scale;
21
-
22
- float thickness = max(min(1.0 * u_scale, 3.0), 0.5);
23
-
24
- // Calculate the resulting inset so that we draw the rounded box and border *inside* the quad (vs. that it would bleed outside the quad).
25
- float inset = max(min(2.0 * u_scale, 1.0), 3.0) * thickness + stroke;
26
-
27
- // Rectangle dimensions with inset.
28
- float u_rect_x = v_quad.x + inset;
29
- float u_rect_y = v_quad.y + inset;
30
- float u_rectWidth = v_quad.z - 2.0 * inset;
31
- float u_rectHeight = v_quad.w - 2.0 * inset;
32
-
33
- vec2 size = vec2(u_rectWidth, u_rectHeight);
34
-
35
- // Center position of the rectangle.
36
- vec2 offsetPosition = vec2(u_rect_x + size.x / 2.0, u_rect_y + size.y / 2.0);
37
- vec2 location = offsetPosition;
38
-
39
- // Make sure the edges of the border are not too harsh.
40
- float edgeSoftness = 0.5 * u_dpi;
41
-
42
- float borderWidth = stroke * u_scale * u_dpi;
43
-
44
- // Different radius for inner and outer.
45
- float radiusOutside =
46
- min(radiusBase * u_dpi, min(size.x, size.y)) + thickness;
47
- float radiusInside = radiusOutside - borderWidth;
48
-
49
- vec2 sizeInner = size - 2.0 * borderWidth;
50
-
51
- // Compute different distance for inside and outside.
52
- float distanceOuter = roundedBoxSDF(
53
- location - gl_FragCoord.xy,
54
- size / 2.0,
55
- radiusOutside
56
- );
57
- float distanceInner = roundedBoxSDF(
58
- location - gl_FragCoord.xy,
59
- sizeInner / 2.0,
60
- radiusInside
61
- );
62
-
63
- float alphaOuter =
64
- 1.0 - smoothstep(-edgeSoftness, edgeSoftness, distanceOuter - thickness);
65
- float alphaInner =
66
- 1.0 - smoothstep(-edgeSoftness, edgeSoftness, distanceInner - thickness);
67
-
68
- // Alpha value for the border.
69
- float alphaBorder = clamp(alphaOuter - alphaInner, 0.0, 1.0);
70
-
71
- // Adjust alphas based on intersection.
72
- float adjustedAlphaFill =
73
- v_intersecting >= 0.5
74
- ? alphaInner * 0.95
75
- : alphaInner * 0.2;
76
-
77
- if (v_is_hover_area >= 1.0) {
78
- // If nesting level is 0, don't render the fill (border only)
79
- if (u_active_hover_nesting_level < 0.5) {
80
- adjustedAlphaFill = 0.0;
81
- } else {
82
- adjustedAlphaFill *= 0.5;
83
- }
84
- }
85
-
86
- if (alphaBorder > 0.0) {
87
- float a = isHoverArea ? 0.6 : 1.0;
88
- gl_FragColor = vec4(v_color, a);
89
- return;
90
- } else if (adjustedAlphaFill > 0.0) {
91
- gl_FragColor = vec4(v_color, adjustedAlphaFill);
92
- return;
93
- }
94
-
95
- discard;
96
- }
@@ -1,139 +0,0 @@
1
- precision highp float;
2
-
3
- varying vec4 v_quad;
4
- varying vec4 v_rect_radius;
5
- varying vec2 v_rect_size;
6
- varying vec2 v_rect_center;
7
- varying float v_rect_type;
8
- varying vec2 v_quad_artboard_pos;
9
-
10
- uniform float u_dpi;
11
- uniform float u_scale;
12
- uniform float u_offset_x;
13
- uniform float u_offset_y;
14
- uniform vec2 u_resolution;
15
- uniform vec3 u_color_mono;
16
- uniform vec3 u_color_accent;
17
- uniform vec3 u_color_teal;
18
- uniform vec3 u_color_white;
19
- uniform vec3 u_color_lime;
20
-
21
- int pseudoQuadrant(vec2 p) {
22
- return int(floor(step(0.0, p.x) + 2.0 * step(0.0, -p.y)));
23
- }
24
-
25
- float sdRoundBox(vec2 p, vec2 b, vec4 radii) {
26
- int idx = pseudoQuadrant(p);
27
- float cr;
28
- if (idx == 0) cr = radii[0];
29
- else if (idx == 1) cr = radii[1];
30
- else if (idx == 2) cr = radii[3];
31
- else cr = radii[2];
32
- vec2 q = abs(p) - b + cr;
33
- return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - cr;
34
- }
35
-
36
- void main() {
37
- vec2 size = v_rect_size;
38
- vec4 u_cornerRadii = min(v_rect_radius, min(size.x, size.y) / 2.0);
39
- vec4 r = u_cornerRadii;
40
-
41
- vec2 posRelativeToQuad = gl_FragCoord.xy - v_rect_center;
42
-
43
- float mainDist = sdRoundBox(posRelativeToQuad, size / 2.0, r);
44
-
45
- // For editable fields (type 2), render both fill and solid border
46
- if (v_rect_type > 1.5 && v_rect_type < 2.5) {
47
- float u_edgeSoftness = 1.0;
48
- float borderThickness = 1.5 * u_dpi;
49
- float u_borderSoftness = 1.0;
50
-
51
- // Render fill
52
- float fillAlpha = 1.0 - smoothstep(-u_edgeSoftness, 0.0, mainDist);
53
- vec4 fillColor = vec4(u_color_teal, 0.2);
54
-
55
- // Render solid border (non-dashed)
56
- float borderAlpha =
57
- 1.0 - smoothstep(-u_borderSoftness, 0.0, abs(mainDist) - borderThickness);
58
- vec4 borderColor = vec4(u_color_teal, 1.0);
59
-
60
- // Combine fill and border
61
- vec4 combined = mix(
62
- vec4(fillColor.rgb, fillAlpha * fillColor.a),
63
- borderColor,
64
- borderAlpha * borderColor.a
65
- );
66
-
67
- gl_FragColor = combined;
68
- return;
69
- }
70
-
71
- // For blocks (type 0, 1, and 3), render border
72
- float borderThickness = 1.5 * u_dpi;
73
- float u_borderSoftness = 1.0;
74
-
75
- float borderAlpha =
76
- 1.0 - smoothstep(-u_borderSoftness, 0.0, abs(mainDist) - borderThickness);
77
-
78
- // Select color based on type: 0 = mono, 1 = accent, 3 = white (inverted), 4 = lime (library)
79
- vec3 color = u_color_mono;
80
- if (v_rect_type > 3.5) {
81
- color = u_color_lime;
82
- } else if (v_rect_type > 2.5) {
83
- color = u_color_white;
84
- } else if (v_rect_type > 0.5) {
85
- color = u_color_accent;
86
- }
87
-
88
- // Apply dashed pattern for all blocks
89
- // Calculate actual perimeter distance for proper dashing
90
- vec2 halfSize = size / 2.0;
91
- vec2 p = posRelativeToQuad;
92
- vec2 absP = abs(p);
93
-
94
- // Determine which edge/corner we're on and calculate perimeter distance
95
- float perimeterDistance = 0.0;
96
-
97
- // Check which edge we're closest to
98
- float dx = absP.x - halfSize.x;
99
- float dy = absP.y - halfSize.y;
100
-
101
- if (dy > dx) {
102
- // Top or bottom edge
103
- if (p.y > 0.0) {
104
- // Bottom edge: start at bottom-left, go right
105
- perimeterDistance = size.x + size.y + (p.x + halfSize.x);
106
- } else {
107
- // Top edge: start at top-right, go left
108
- perimeterDistance = size.x + (halfSize.x - p.x);
109
- }
110
- } else {
111
- // Left or right edge
112
- if (p.x > 0.0) {
113
- // Right edge: start at top-right, go down
114
- perimeterDistance = p.y + halfSize.y;
115
- } else {
116
- // Left edge: start at bottom-left, go up
117
- perimeterDistance = size.x + size.y + size.x + (halfSize.y - p.y);
118
- }
119
- }
120
-
121
- float dashWidth = 7.0 * u_dpi;
122
- float dashGap = 7.0 * u_dpi;
123
- float dashCycle = dashWidth + dashGap;
124
-
125
- float dashPosition = mod(perimeterDistance, dashCycle);
126
- float dashFactor = step(dashPosition, dashWidth);
127
-
128
- // Only show dashes
129
- borderAlpha *= dashFactor;
130
-
131
- vec4 borderColor = vec4(color, 1.0);
132
- vec4 finalColor = mix(
133
- vec4(0.0, 0.0, 0.0, 0.0),
134
- borderColor,
135
- borderAlpha * borderColor.a
136
- );
137
-
138
- gl_FragColor = finalColor;
139
- }
@@ -1,42 +0,0 @@
1
- <template>
2
- <Teleport :to="artboard">
3
- <div class="bk bk-selection-overlay-fallback">
4
- <div
5
- v-for="item in items"
6
- :key="item.uuid"
7
- :style="{
8
- top: item.rect.y + 'px',
9
- left: item.rect.x + 'px',
10
- width: item.rect.width + 'px',
11
- height: item.rect.height + 'px'
12
- }"
13
- />
14
- </div>
15
- </Teleport>
16
- </template>
17
-
18
- <script setup>
19
- import { falsy } from "#blokkli/helpers";
20
- import onBlokkliEvent from "#blokkli/helpers/composables/onBlokkliEvent";
21
- import { useBlokkli, computed } from "#imports";
22
- const props = defineProps({
23
- uuids: { type: Array, required: true }
24
- });
25
- const { ui, dom, blocks } = useBlokkli();
26
- const artboard = ui.artboardElement();
27
- const items = computed(() => {
28
- return props.uuids.map((uuid) => {
29
- const block = blocks.getBlock(uuid);
30
- if (!block) {
31
- return null;
32
- }
33
- const rect = dom.getBlockRect(uuid);
34
- if (!rect) {
35
- return null;
36
- }
37
- return { uuid, rect };
38
- }).filter(falsy);
39
- });
40
- onBlokkliEvent("animationFrame", function() {
41
- });
42
- </script>