@juo/orion-core 0.12.0 → 0.14.0
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.
- package/dist/{ExtensionRoot-BuoY5H2A.js → ExtensionRoot-BFk-vt2J.js} +44 -16
- package/dist/block.d.ts +15 -3
- package/dist/bridge-fHXg0b-e.js +421 -0
- package/dist/core.js +270 -9
- package/dist/editor/bridge.d.ts +17 -0
- package/dist/editor/bridge.test.d.ts +1 -0
- package/dist/editor/components.d.ts +6 -0
- package/dist/editor/handler.d.ts +2 -3
- package/dist/editor/main.d.ts +7 -4
- package/dist/editor/messages.d.ts +86 -6
- package/dist/editor.js +299 -59
- package/dist/flows/MockWorkflowApiAdapter.d.ts +12 -0
- package/dist/flows/WorkflowService.d.ts +156 -0
- package/dist/flows/__tests__/WorkflowService.test.d.ts +1 -0
- package/dist/flows/__tests__/defaults.test.d.ts +1 -0
- package/dist/flows/__tests__/juo-workflow.test.d.ts +1 -0
- package/dist/flows/__tests__/overlay-behavior.test.d.ts +1 -0
- package/dist/flows/__tests__/theme-state-surfaces.test.d.ts +1 -0
- package/dist/flows/defaults.d.ts +14 -0
- package/dist/flows/index.d.ts +3 -0
- package/dist/flows/juo-workflow.d.ts +47 -0
- package/dist/juo-workflow-CoWvwYTn.js +545 -0
- package/dist/main.d.ts +5 -3
- package/dist/preact.js +1 -1
- package/dist/react.js +1 -1
- package/dist/{block-CFJIpH_9.js → theme-state-TW-9hD7e.js} +209 -7
- package/dist/theme-state.d.ts +84 -0
- package/dist/theme-state.locales.test.d.ts +1 -0
- package/dist/translation.d.ts +13 -0
- package/dist/translation.test.d.ts +1 -0
- package/dist/vue/context.d.ts +2 -0
- package/dist/vue.js +8 -1
- package/dist/web-components/ExtensionRoot.d.ts +12 -1
- package/dist/web-components/editor/InlineText.d.ts +4 -0
- package/dist/web-components/runtime/InlineText.d.ts +2 -1
- package/dist/web-components-editor.js +70 -21
- package/dist/web-components-runtime.js +39 -3
- package/package.json +1 -1
- package/dist/bridge-BPfBHSPI.js +0 -245
- package/dist/page-DFFhF7j8.js +0 -12
- package/dist/page.d.ts +0 -9
package/dist/editor.js
CHANGED
|
@@ -4,23 +4,97 @@ var __publicField = (obj, key, value) => {
|
|
|
4
4
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
return value;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { getDefinedBlocks } from "@juo/orion-core";
|
|
8
|
+
import { c as createEditorBridge, d as createRemoveBlockMessage, e as createRegisterBlocksMessage, f as createRegisterRoutesMessage } from "./bridge-fHXg0b-e.js";
|
|
9
|
+
import { o, a, p, u, h, l, t, j, k, m, q, s, r, n, b, v, i, g } from "./bridge-fHXg0b-e.js";
|
|
10
|
+
import { e as createBlockInstanceFromObject, m as indexOverrides, x as onRegisterBlock } from "./theme-state-TW-9hD7e.js";
|
|
10
11
|
function createEditorHandler(options) {
|
|
11
|
-
const {
|
|
12
|
+
const { themeState, onBlockSelection } = options;
|
|
13
|
+
const blockSurfaceIndex = /* @__PURE__ */ new Map();
|
|
14
|
+
function getBlocks(surface) {
|
|
15
|
+
return surface === "overlay" ? themeState.overlay.blocks : themeState.page.blocks;
|
|
16
|
+
}
|
|
17
|
+
function indexSurface(surface, blocks) {
|
|
18
|
+
for (const [id, value] of blockSurfaceIndex) {
|
|
19
|
+
if (value === surface) {
|
|
20
|
+
blockSurfaceIndex.delete(id);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const visit = (block) => {
|
|
24
|
+
if (!(block == null ? void 0 : block.id))
|
|
25
|
+
return;
|
|
26
|
+
blockSurfaceIndex.set(block.id, surface);
|
|
27
|
+
for (const slotBlocks of Object.values(block.slots || {})) {
|
|
28
|
+
const slotArray = Array.isArray(slotBlocks) ? slotBlocks : [slotBlocks];
|
|
29
|
+
for (const child of slotArray) {
|
|
30
|
+
if (typeof child !== "string") {
|
|
31
|
+
visit(child);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
for (const block of blocks) {
|
|
37
|
+
visit(block);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function resolveSurfaceForMessage(message) {
|
|
41
|
+
const lookup = (id) => id ? blockSurfaceIndex.get(id) : void 0;
|
|
42
|
+
if (message.type === "UPDATE_BLOCK_PROPS") {
|
|
43
|
+
return lookup(message.payload.blockId) ?? "page";
|
|
44
|
+
}
|
|
45
|
+
if (message.type === "REMOVE_BLOCK") {
|
|
46
|
+
return lookup(message.payload.blockId) ?? lookup(message.payload.location.parentId) ?? "page";
|
|
47
|
+
}
|
|
48
|
+
if (message.type === "MOVE_BLOCK") {
|
|
49
|
+
return lookup(message.payload.blockId) ?? lookup(message.payload.location.parentId) ?? "page";
|
|
50
|
+
}
|
|
51
|
+
if (message.type === "ADD_BLOCK") {
|
|
52
|
+
const location = message.payload.location;
|
|
53
|
+
if (location.type === "append") {
|
|
54
|
+
return lookup(location.parentId) ?? "page";
|
|
55
|
+
}
|
|
56
|
+
return lookup(location.targetId) ?? "page";
|
|
57
|
+
}
|
|
58
|
+
return "page";
|
|
59
|
+
}
|
|
12
60
|
function handleMessage(message) {
|
|
13
|
-
var _a;
|
|
14
|
-
if (message.type === "
|
|
15
|
-
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (message.type === "SET_GLOBAL_STYLES") {
|
|
63
|
+
themeState.setGlobalStyles(message.payload.styles);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (message.type === "PROVIDE_THEME_STATE") {
|
|
67
|
+
const surface = message.payload.surface ?? "page";
|
|
68
|
+
const blocks = ((_a = message.payload.blocks) == null ? void 0 : _a.map(
|
|
16
69
|
(block) => createBlockInstanceFromObject(block)
|
|
17
|
-
) || [];
|
|
18
|
-
|
|
70
|
+
)) || [];
|
|
71
|
+
const target = getBlocks(surface);
|
|
72
|
+
target.value = blocks;
|
|
73
|
+
indexSurface(surface, target.value);
|
|
19
74
|
} else if (message.type === "SELECT_BLOCK") {
|
|
20
75
|
const blockId = message.payload.blockId;
|
|
21
76
|
if (onBlockSelection) {
|
|
22
77
|
onBlockSelection(blockId);
|
|
23
78
|
}
|
|
79
|
+
} else if (message.type === "PROVIDE_TRANSLATION_OVERRIDES" && message.payload.requestId == null) {
|
|
80
|
+
const catalogs = themeState.locales.catalogs;
|
|
81
|
+
const current = catalogs.value;
|
|
82
|
+
if (current == null)
|
|
83
|
+
return;
|
|
84
|
+
const indexed = indexOverrides(message.payload.overrides);
|
|
85
|
+
catalogs.value = {
|
|
86
|
+
...current,
|
|
87
|
+
theme: {
|
|
88
|
+
...current.theme,
|
|
89
|
+
overrides: indexed.theme
|
|
90
|
+
},
|
|
91
|
+
blocks: {
|
|
92
|
+
...current.blocks,
|
|
93
|
+
overrides: indexed.blocks
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
} else if (message.type === "SET_LOCALE") {
|
|
97
|
+
void themeState.locales.setLocale(message.payload.locale);
|
|
24
98
|
} else if (message.type === "UPDATE_BLOCK_PROPS") {
|
|
25
99
|
let findAndUpdateBlock = function(blocks, blockId, props) {
|
|
26
100
|
for (const block of blocks) {
|
|
@@ -41,13 +115,18 @@ function createEditorHandler(options) {
|
|
|
41
115
|
}
|
|
42
116
|
return false;
|
|
43
117
|
};
|
|
118
|
+
const surface = resolveSurfaceForMessage(message);
|
|
119
|
+
const target = getBlocks(surface);
|
|
44
120
|
findAndUpdateBlock(
|
|
45
|
-
|
|
121
|
+
target.value,
|
|
46
122
|
message.payload.blockId,
|
|
47
123
|
message.payload.props
|
|
48
124
|
);
|
|
49
|
-
|
|
125
|
+
target.value = [...target.value];
|
|
126
|
+
indexSurface(surface, target.value);
|
|
50
127
|
} else if (message.type === "ADD_BLOCK") {
|
|
128
|
+
const surface = resolveSurfaceForMessage(message);
|
|
129
|
+
const target = getBlocks(surface);
|
|
51
130
|
const { block: blockData, location } = message.payload;
|
|
52
131
|
const newBlock = createBlockInstanceFromObject(blockData);
|
|
53
132
|
if (location.type === "before" || location.type === "after") {
|
|
@@ -81,7 +160,7 @@ function createEditorHandler(options) {
|
|
|
81
160
|
return false;
|
|
82
161
|
};
|
|
83
162
|
findAndInsertBlock(
|
|
84
|
-
|
|
163
|
+
target.value,
|
|
85
164
|
location.targetId,
|
|
86
165
|
newBlock,
|
|
87
166
|
location.type
|
|
@@ -115,13 +194,14 @@ function createEditorHandler(options) {
|
|
|
115
194
|
return false;
|
|
116
195
|
};
|
|
117
196
|
findAndAppendBlock(
|
|
118
|
-
|
|
197
|
+
target.value,
|
|
119
198
|
location.parentId,
|
|
120
199
|
location.slot,
|
|
121
200
|
newBlock
|
|
122
201
|
);
|
|
123
202
|
}
|
|
124
|
-
|
|
203
|
+
target.value = [...target.value];
|
|
204
|
+
indexSurface(surface, target.value);
|
|
125
205
|
} else if (message.type === "REMOVE_BLOCK") {
|
|
126
206
|
let findAndRemoveBlock = function(blocks, blockId, slot, parentId) {
|
|
127
207
|
var _a2;
|
|
@@ -130,7 +210,7 @@ function createEditorHandler(options) {
|
|
|
130
210
|
const slotBlocks = blocks[i2].slots[slot];
|
|
131
211
|
const slotArray = Array.isArray(slotBlocks) ? slotBlocks : [slotBlocks];
|
|
132
212
|
const index = slotArray.findIndex(
|
|
133
|
-
(
|
|
213
|
+
(b2) => typeof b2 !== "string" && (b2 == null ? void 0 : b2.id) === blockId
|
|
134
214
|
);
|
|
135
215
|
if (index !== -1) {
|
|
136
216
|
slotArray.splice(index, 1);
|
|
@@ -152,17 +232,20 @@ function createEditorHandler(options) {
|
|
|
152
232
|
}
|
|
153
233
|
return false;
|
|
154
234
|
};
|
|
235
|
+
const surface = resolveSurfaceForMessage(message);
|
|
236
|
+
const target = getBlocks(surface);
|
|
155
237
|
let resolvedParentId = message.payload.location.parentId;
|
|
156
238
|
if (resolvedParentId === "root") {
|
|
157
|
-
resolvedParentId = ((
|
|
239
|
+
resolvedParentId = ((_b = target.value[0]) == null ? void 0 : _b.id) ?? "root";
|
|
158
240
|
}
|
|
159
241
|
findAndRemoveBlock(
|
|
160
|
-
|
|
242
|
+
target.value,
|
|
161
243
|
message.payload.blockId,
|
|
162
244
|
message.payload.location.slot,
|
|
163
245
|
resolvedParentId
|
|
164
246
|
);
|
|
165
|
-
|
|
247
|
+
target.value = [...target.value];
|
|
248
|
+
indexSurface(surface, target.value);
|
|
166
249
|
} else if (message.type === "MOVE_BLOCK") {
|
|
167
250
|
let findAndMoveBlock = function(blocks, blockId, slot, parentId, newIndex) {
|
|
168
251
|
var _a2;
|
|
@@ -171,7 +254,7 @@ function createEditorHandler(options) {
|
|
|
171
254
|
const slotBlocks = block.slots[slot];
|
|
172
255
|
const slotArray = Array.isArray(slotBlocks) ? slotBlocks : [slotBlocks];
|
|
173
256
|
const oldIndex = slotArray.findIndex(
|
|
174
|
-
(
|
|
257
|
+
(b2) => typeof b2 !== "string" && (b2 == null ? void 0 : b2.id) === blockId
|
|
175
258
|
);
|
|
176
259
|
if (oldIndex !== -1) {
|
|
177
260
|
const [moved] = slotArray.splice(oldIndex, 1);
|
|
@@ -194,16 +277,21 @@ function createEditorHandler(options) {
|
|
|
194
277
|
}
|
|
195
278
|
return false;
|
|
196
279
|
};
|
|
280
|
+
const surface = resolveSurfaceForMessage(message);
|
|
281
|
+
const target = getBlocks(surface);
|
|
197
282
|
findAndMoveBlock(
|
|
198
|
-
|
|
283
|
+
target.value,
|
|
199
284
|
message.payload.blockId,
|
|
200
285
|
message.payload.location.slot,
|
|
201
286
|
message.payload.location.parentId,
|
|
202
287
|
message.payload.location.index
|
|
203
288
|
);
|
|
204
|
-
|
|
289
|
+
target.value = [...target.value];
|
|
290
|
+
indexSurface(surface, target.value);
|
|
205
291
|
}
|
|
206
292
|
}
|
|
293
|
+
indexSurface("page", themeState.page.blocks.value);
|
|
294
|
+
indexSurface("overlay", themeState.overlay.blocks.value);
|
|
207
295
|
return {
|
|
208
296
|
handleMessage
|
|
209
297
|
};
|
|
@@ -211,6 +299,7 @@ function createEditorHandler(options) {
|
|
|
211
299
|
const styles = `
|
|
212
300
|
<style>
|
|
213
301
|
.block-wrapper {
|
|
302
|
+
position: relative;
|
|
214
303
|
padding: 12px;
|
|
215
304
|
background-color: white;
|
|
216
305
|
border: 1px solid #B5B5B5;
|
|
@@ -225,6 +314,7 @@ const styles = `
|
|
|
225
314
|
}
|
|
226
315
|
|
|
227
316
|
.block-wrapper__name {
|
|
317
|
+
position: relative;
|
|
228
318
|
display: flex;
|
|
229
319
|
justify-content: space-between;
|
|
230
320
|
align-items: center;
|
|
@@ -259,10 +349,66 @@ const styles = `
|
|
|
259
349
|
cursor: pointer;
|
|
260
350
|
}
|
|
261
351
|
|
|
352
|
+
.block-wrapper__actions button:hover {
|
|
353
|
+
color: #8A8A8A;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
.block-wrapper__menu {
|
|
358
|
+
display: none;
|
|
359
|
+
position: absolute;
|
|
360
|
+
top: calc(100% + 4px);
|
|
361
|
+
right: 0;
|
|
362
|
+
z-index: 1000;
|
|
363
|
+
background: white;
|
|
364
|
+
border: 1px solid #e9e9e9;
|
|
365
|
+
border-radius: 6px;
|
|
366
|
+
box-shadow: 0px 0px 30px 0px rgba(0, 0, 0, 0.04);
|
|
367
|
+
padding: 4px 0;
|
|
368
|
+
min-width: 148px;
|
|
369
|
+
flex-direction: column;
|
|
370
|
+
gap: 4px;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.block-wrapper__menu.open {
|
|
374
|
+
display: flex;
|
|
375
|
+
}
|
|
262
376
|
|
|
263
|
-
.block-
|
|
264
|
-
|
|
265
|
-
|
|
377
|
+
.block-wrapper__menu-section {
|
|
378
|
+
padding: 0 4px;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.block-wrapper__menu-item {
|
|
382
|
+
display: flex;
|
|
383
|
+
align-items: center;
|
|
384
|
+
gap: 6px;
|
|
385
|
+
height: 24px;
|
|
386
|
+
padding: 0 8px;
|
|
387
|
+
cursor: pointer;
|
|
388
|
+
font-size: 12px;
|
|
389
|
+
font-weight: 500;
|
|
390
|
+
font-family: inherit;
|
|
391
|
+
border-radius: 4px;
|
|
392
|
+
border: none;
|
|
393
|
+
background: none;
|
|
394
|
+
width: 100%;
|
|
395
|
+
text-align: left;
|
|
396
|
+
color: #111;
|
|
397
|
+
box-sizing: border-box;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.block-wrapper__menu-item:hover {
|
|
401
|
+
background: #f5f5f5;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.block-wrapper__menu-item--danger {
|
|
405
|
+
color: #f12323;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.block-wrapper__menu-divider {
|
|
409
|
+
height: 1px;
|
|
410
|
+
background: #e9e9e9;
|
|
411
|
+
flex-shrink: 0;
|
|
266
412
|
}
|
|
267
413
|
</style>
|
|
268
414
|
`;
|
|
@@ -272,11 +418,20 @@ const blockIconSvg = `
|
|
|
272
418
|
</svg>
|
|
273
419
|
|
|
274
420
|
`;
|
|
275
|
-
const
|
|
421
|
+
const moreIconSvg = `
|
|
276
422
|
<svg width="13" height="3" viewBox="0 0 13 3" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
277
423
|
<path d="M1.5 0C2.32843 2.0934e-07 3 0.671573 3 1.5C3 2.32843 2.32843 3 1.5 3C0.671573 3 3.62117e-08 2.32843 0 1.5C6.04266e-08 0.671573 0.671573 3.62117e-08 1.5 0ZM6.5 0C7.32843 2.0934e-07 8 0.671573 8 1.5C8 2.32843 7.32843 3 6.5 3C5.67157 3 5 2.32843 5 1.5C5 0.671573 5.67157 3.62117e-08 6.5 0ZM11.5 0C12.3284 2.0934e-07 13 0.671573 13 1.5C13 2.32843 12.3284 3 11.5 3C10.6716 3 10 2.32843 10 1.5C10 0.671573 10.6716 3.62117e-08 11.5 0Z" fill="currentColor"/>
|
|
278
424
|
</svg>
|
|
279
|
-
|
|
425
|
+
`;
|
|
426
|
+
const trashIconSvg = `
|
|
427
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
428
|
+
<path d="M2 4H12" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
429
|
+
<path d="M5 4V2.5C5 2.22386 5.22386 2 5.5 2H8.5C8.77614 2 9 2.22386 9 2.5V4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
430
|
+
<path d="M10.5 4L10 11.5C10 11.7761 9.77614 12 9.5 12H4.5C4.22386 12 4 11.7761 4 11.5L3.5 4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
431
|
+
<line x1="7" y1="6.5" x2="7" y2="9.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
432
|
+
<line x1="5.5" y1="6.5" x2="5.5" y2="9.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
433
|
+
<line x1="8.5" y1="6.5" x2="8.5" y2="9.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
|
|
434
|
+
</svg>
|
|
280
435
|
`;
|
|
281
436
|
class BlockWrapper extends HTMLElement {
|
|
282
437
|
constructor() {
|
|
@@ -284,6 +439,9 @@ class BlockWrapper extends HTMLElement {
|
|
|
284
439
|
__publicField(this, "block", null);
|
|
285
440
|
__publicField(this, "editorBridge", createEditorBridge());
|
|
286
441
|
__publicField(this, "nameElement", null);
|
|
442
|
+
__publicField(this, "menuElement", null);
|
|
443
|
+
__publicField(this, "isMenuOpen", false);
|
|
444
|
+
__publicField(this, "closeMenuOnOutsideClick", null);
|
|
287
445
|
this.attachShadow({ mode: "open" });
|
|
288
446
|
this.setupStyles();
|
|
289
447
|
this.setupTemplate();
|
|
@@ -309,22 +467,44 @@ class BlockWrapper extends HTMLElement {
|
|
|
309
467
|
nameSpan.textContent = "";
|
|
310
468
|
const actionsDiv = document.createElement("div");
|
|
311
469
|
actionsDiv.className = "block-wrapper__actions";
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
470
|
+
const moreBtn = document.createElement("button");
|
|
471
|
+
moreBtn.type = "button";
|
|
472
|
+
moreBtn.innerHTML = moreIconSvg;
|
|
473
|
+
moreBtn.addEventListener("click", (e) => {
|
|
474
|
+
e.stopPropagation();
|
|
475
|
+
this.toggleMenu();
|
|
476
|
+
});
|
|
477
|
+
const menuEl = document.createElement("div");
|
|
478
|
+
menuEl.className = "block-wrapper__menu";
|
|
479
|
+
menuEl.setAttribute("role", "menu");
|
|
480
|
+
const divider = document.createElement("div");
|
|
481
|
+
divider.className = "block-wrapper__menu-divider";
|
|
482
|
+
divider.setAttribute("role", "separator");
|
|
483
|
+
const deleteSection = document.createElement("div");
|
|
484
|
+
deleteSection.className = "block-wrapper__menu-section";
|
|
485
|
+
const deleteBtn = document.createElement("button");
|
|
486
|
+
deleteBtn.type = "button";
|
|
487
|
+
deleteBtn.className = "block-wrapper__menu-item block-wrapper__menu-item--danger";
|
|
488
|
+
deleteBtn.setAttribute("role", "menuitem");
|
|
489
|
+
deleteBtn.innerHTML = `${trashIconSvg}<span>Delete</span>`;
|
|
490
|
+
deleteBtn.addEventListener("click", (e) => {
|
|
316
491
|
e.stopPropagation();
|
|
492
|
+
this.closeMenu();
|
|
317
493
|
this.handleRemoveBlock();
|
|
318
494
|
});
|
|
319
|
-
|
|
495
|
+
deleteSection.appendChild(deleteBtn);
|
|
496
|
+
menuEl.appendChild(deleteSection);
|
|
497
|
+
actionsDiv.appendChild(moreBtn);
|
|
320
498
|
nameDiv.appendChild(iconContainer);
|
|
321
499
|
nameDiv.appendChild(nameSpan);
|
|
322
500
|
nameDiv.appendChild(actionsDiv);
|
|
501
|
+
nameDiv.appendChild(menuEl);
|
|
323
502
|
wrapper.appendChild(nameDiv);
|
|
324
503
|
const slot = document.createElement("slot");
|
|
325
504
|
wrapper.appendChild(slot);
|
|
326
505
|
this.shadowRoot.appendChild(wrapper);
|
|
327
506
|
this.nameElement = nameSpan;
|
|
507
|
+
this.menuElement = menuEl;
|
|
328
508
|
this.editorBridge.onMessage((message) => {
|
|
329
509
|
var _a;
|
|
330
510
|
if (message.type === "SELECT_BLOCK") {
|
|
@@ -333,8 +513,46 @@ class BlockWrapper extends HTMLElement {
|
|
|
333
513
|
});
|
|
334
514
|
}
|
|
335
515
|
connectedCallback() {
|
|
516
|
+
const isInOverlay = this.closest('juo-extension-root[surface="overlay"]') !== null;
|
|
517
|
+
if (isInOverlay) {
|
|
518
|
+
const actions = this.shadowRoot.querySelector(
|
|
519
|
+
".block-wrapper__actions"
|
|
520
|
+
);
|
|
521
|
+
if (actions)
|
|
522
|
+
actions.style.visibility = "hidden";
|
|
523
|
+
}
|
|
336
524
|
}
|
|
337
525
|
disconnectedCallback() {
|
|
526
|
+
this.closeMenu();
|
|
527
|
+
}
|
|
528
|
+
toggleMenu() {
|
|
529
|
+
if (this.isMenuOpen) {
|
|
530
|
+
this.closeMenu();
|
|
531
|
+
} else {
|
|
532
|
+
this.openMenu();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
openMenu() {
|
|
536
|
+
if (!this.menuElement)
|
|
537
|
+
return;
|
|
538
|
+
this.menuElement.classList.add("open");
|
|
539
|
+
this.isMenuOpen = true;
|
|
540
|
+
this.closeMenuOnOutsideClick = (e) => {
|
|
541
|
+
if (!this.shadowRoot.contains(e.composedPath()[0])) {
|
|
542
|
+
this.closeMenu();
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
document.addEventListener("click", this.closeMenuOnOutsideClick);
|
|
546
|
+
}
|
|
547
|
+
closeMenu() {
|
|
548
|
+
if (!this.menuElement)
|
|
549
|
+
return;
|
|
550
|
+
this.menuElement.classList.remove("open");
|
|
551
|
+
this.isMenuOpen = false;
|
|
552
|
+
if (this.closeMenuOnOutsideClick) {
|
|
553
|
+
document.removeEventListener("click", this.closeMenuOnOutsideClick);
|
|
554
|
+
this.closeMenuOnOutsideClick = null;
|
|
555
|
+
}
|
|
338
556
|
}
|
|
339
557
|
setBlock(block) {
|
|
340
558
|
this.block = block;
|
|
@@ -403,48 +621,70 @@ class BlockWrapper extends HTMLElement {
|
|
|
403
621
|
if (customElements.get("juo-editor-block-wrapper") == null) {
|
|
404
622
|
customElements.define("juo-editor-block-wrapper", BlockWrapper);
|
|
405
623
|
}
|
|
406
|
-
|
|
624
|
+
function serializeBlock(block) {
|
|
625
|
+
let initialValue = block.initialValue;
|
|
626
|
+
if (typeof initialValue === "function") {
|
|
627
|
+
try {
|
|
628
|
+
initialValue = initialValue();
|
|
629
|
+
} catch {
|
|
630
|
+
initialValue = void 0;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
name: block.name,
|
|
635
|
+
group: block.group,
|
|
636
|
+
schema: block.schema,
|
|
637
|
+
initialValue,
|
|
638
|
+
presets: block.presets
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
async function setupEditorMode(routes, themeState) {
|
|
407
642
|
const editor = createEditorBridge();
|
|
408
643
|
const handler = createEditorHandler({
|
|
409
|
-
|
|
644
|
+
themeState
|
|
410
645
|
});
|
|
411
|
-
editor.onMessage((message) => {
|
|
646
|
+
const { unsubscribe } = editor.onMessage((message) => {
|
|
412
647
|
handler.handleMessage(message);
|
|
413
648
|
});
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
if (typeof initialValue === "function") {
|
|
417
|
-
try {
|
|
418
|
-
initialValue = initialValue();
|
|
419
|
-
} catch {
|
|
420
|
-
initialValue = void 0;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
return {
|
|
424
|
-
name: block.name,
|
|
425
|
-
group: block.group,
|
|
426
|
-
schema: block.schema,
|
|
427
|
-
initialValue,
|
|
428
|
-
presets: block.presets
|
|
429
|
-
};
|
|
430
|
-
});
|
|
431
|
-
editor.sendMessage(createRegisterBlocksMessage({ blocks: blocksArray }));
|
|
649
|
+
const blocks = getDefinedBlocks().map(serializeBlock);
|
|
650
|
+
editor.sendMessage(createRegisterBlocksMessage({ blocks }));
|
|
432
651
|
editor.sendMessage(createRegisterRoutesMessage({ routes }));
|
|
652
|
+
onRegisterBlock(
|
|
653
|
+
(_, block) => editor.sendMessage(
|
|
654
|
+
createRegisterBlocksMessage({
|
|
655
|
+
blocks: [serializeBlock(block)]
|
|
656
|
+
})
|
|
657
|
+
)
|
|
658
|
+
);
|
|
659
|
+
return () => {
|
|
660
|
+
unsubscribe();
|
|
661
|
+
editor.destroy();
|
|
662
|
+
};
|
|
433
663
|
}
|
|
434
664
|
export {
|
|
435
665
|
BlockWrapper,
|
|
436
|
-
|
|
666
|
+
o as createAddBlockMessage,
|
|
437
667
|
createEditorBridge,
|
|
438
668
|
createEditorHandler,
|
|
439
|
-
|
|
669
|
+
a as createFocusInlineTextMessage,
|
|
670
|
+
p as createMoveBlockMessage,
|
|
671
|
+
u as createProvideGlobalStylesMessage,
|
|
672
|
+
h as createProvideThemeStateMessage,
|
|
673
|
+
l as createProvideTranslationOverridesMessage,
|
|
440
674
|
createRegisterBlocksMessage,
|
|
441
675
|
createRegisterRoutesMessage,
|
|
442
676
|
createRemoveBlockMessage,
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
677
|
+
t as createRequestGlobalStylesMessage,
|
|
678
|
+
j as createRequestThemeStateMessage,
|
|
679
|
+
k as createRequestTranslationOverridesMessage,
|
|
680
|
+
m as createSelectBlockMessage,
|
|
681
|
+
q as createSetBlockPresetMessage,
|
|
682
|
+
s as createSetGlobalStylesMessage,
|
|
683
|
+
r as createSetLocaleMessage,
|
|
684
|
+
n as createUpdateBlockPropsMessage,
|
|
685
|
+
b as createUpdateBlockTranslationMessage,
|
|
686
|
+
v as getEditorBridge,
|
|
447
687
|
i as isEditorMessage,
|
|
448
|
-
|
|
688
|
+
g as isIframeMessage,
|
|
449
689
|
setupEditorMode
|
|
450
690
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WorkflowApiAdapter } from './WorkflowService';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a mock WorkflowApiAdapter that simulates the full workflow lifecycle.
|
|
4
|
+
*
|
|
5
|
+
* - `start()` begins a flow using predefined step sequences
|
|
6
|
+
* - `respond()` advances to the next step or completes the flow
|
|
7
|
+
* - `cancel()` cancels the flow
|
|
8
|
+
* - `getState()` returns the current state
|
|
9
|
+
*
|
|
10
|
+
* Useful for development/testing when Stream 4 (backend) is not yet implemented.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createMockWorkflowApiAdapter(): WorkflowApiAdapter;
|