@juo/blocks 1.13.0 → 1.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.
Files changed (132) hide show
  1. package/dist/ExtensionRoot-CRJx0Dtr.js +378 -0
  2. package/dist/block.d.ts.map +1 -1
  3. package/dist/{bridge-w5KQ-czl.js → bridge-D838SWmN.js} +146 -32
  4. package/dist/context.d.ts.map +1 -1
  5. package/dist/core.js +775 -35
  6. package/dist/{juo-workflow-BlG9CcAG.js → css-runtime-DWytAzZ5.js} +466 -611
  7. package/dist/editor/bridge.d.ts +8 -0
  8. package/dist/editor/bridge.d.ts.map +1 -1
  9. package/dist/editor/canvas-mode-signal.d.ts +22 -0
  10. package/dist/editor/canvas-mode-signal.d.ts.map +1 -0
  11. package/dist/editor/canvas-mode.d.ts +15 -0
  12. package/dist/editor/canvas-mode.d.ts.map +1 -0
  13. package/dist/editor/canvas-mode.test.d.ts +2 -0
  14. package/dist/editor/canvas-mode.test.d.ts.map +1 -0
  15. package/dist/editor/components.d.ts +113 -0
  16. package/dist/editor/components.d.ts.map +1 -1
  17. package/dist/editor/components.test.d.ts.map +1 -1
  18. package/dist/editor/handler.d.ts.map +1 -1
  19. package/dist/editor/handler.test.d.ts +2 -0
  20. package/dist/editor/handler.test.d.ts.map +1 -0
  21. package/dist/editor/layout-command-emitter.d.ts +31 -0
  22. package/dist/editor/layout-command-emitter.d.ts.map +1 -0
  23. package/dist/editor/layout-command-emitter.test.d.ts +2 -0
  24. package/dist/editor/layout-command-emitter.test.d.ts.map +1 -0
  25. package/dist/editor/layout-system-signal.d.ts +21 -0
  26. package/dist/editor/layout-system-signal.d.ts.map +1 -0
  27. package/dist/editor/main.d.ts +1 -0
  28. package/dist/editor/main.d.ts.map +1 -1
  29. package/dist/editor/messages.d.ts +90 -3
  30. package/dist/editor/messages.d.ts.map +1 -1
  31. package/dist/editor/messages.test.d.ts +2 -0
  32. package/dist/editor/messages.test.d.ts.map +1 -0
  33. package/dist/editor/surface-context.d.ts +7 -0
  34. package/dist/editor/surface-context.d.ts.map +1 -0
  35. package/dist/editor/surface-context.test.d.ts +2 -0
  36. package/dist/editor/surface-context.test.d.ts.map +1 -0
  37. package/dist/editor/wrapper-shared.d.ts +31 -0
  38. package/dist/editor/wrapper-shared.d.ts.map +1 -0
  39. package/dist/editor.js +863 -45
  40. package/dist/gridstack-adapter-DreG3XnB.js +5490 -0
  41. package/dist/layout/css-runtime.d.ts +41 -0
  42. package/dist/layout/css-runtime.d.ts.map +1 -0
  43. package/dist/layout/css-runtime.test.d.ts +2 -0
  44. package/dist/layout/css-runtime.test.d.ts.map +1 -0
  45. package/dist/layout/derive.d.ts +4 -0
  46. package/dist/layout/derive.d.ts.map +1 -0
  47. package/dist/layout/derive.test.d.ts +2 -0
  48. package/dist/layout/derive.test.d.ts.map +1 -0
  49. package/dist/layout/dividers.d.ts +34 -0
  50. package/dist/layout/dividers.d.ts.map +1 -0
  51. package/dist/layout/dividers.test.d.ts +2 -0
  52. package/dist/layout/dividers.test.d.ts.map +1 -0
  53. package/dist/layout/engine.d.ts +3 -0
  54. package/dist/layout/engine.d.ts.map +1 -0
  55. package/dist/layout/engine.test.d.ts +2 -0
  56. package/dist/layout/engine.test.d.ts.map +1 -0
  57. package/dist/layout/grid-utils.d.ts +57 -0
  58. package/dist/layout/grid-utils.d.ts.map +1 -0
  59. package/dist/layout/grid-utils.test.d.ts +2 -0
  60. package/dist/layout/grid-utils.test.d.ts.map +1 -0
  61. package/dist/layout/index.d.ts +12 -0
  62. package/dist/layout/index.d.ts.map +1 -0
  63. package/dist/layout/index.test.d.ts +2 -0
  64. package/dist/layout/index.test.d.ts.map +1 -0
  65. package/dist/layout/insert.d.ts +31 -0
  66. package/dist/layout/insert.d.ts.map +1 -0
  67. package/dist/layout/insert.test.d.ts +2 -0
  68. package/dist/layout/insert.test.d.ts.map +1 -0
  69. package/dist/layout/project-css.d.ts +6 -0
  70. package/dist/layout/project-css.d.ts.map +1 -0
  71. package/dist/layout/project-css.test.d.ts +2 -0
  72. package/dist/layout/project-css.test.d.ts.map +1 -0
  73. package/dist/layout/project-gridstack.d.ts +50 -0
  74. package/dist/layout/project-gridstack.d.ts.map +1 -0
  75. package/dist/layout/project-gridstack.test.d.ts +2 -0
  76. package/dist/layout/project-gridstack.test.d.ts.map +1 -0
  77. package/dist/layout/reconcile.d.ts +22 -0
  78. package/dist/layout/reconcile.d.ts.map +1 -0
  79. package/dist/layout/reconcile.test.d.ts +2 -0
  80. package/dist/layout/reconcile.test.d.ts.map +1 -0
  81. package/dist/layout/types.d.ts +118 -0
  82. package/dist/layout/types.d.ts.map +1 -0
  83. package/dist/layout-mode-adapter-BBd4JRQd.js +21 -0
  84. package/dist/main.d.ts +7 -1
  85. package/dist/main.d.ts.map +1 -1
  86. package/dist/morph-Dj-xvrwt.js +182 -0
  87. package/dist/preact.js +1 -1
  88. package/dist/project-gridstack-DYLMKSH1.js +52 -0
  89. package/dist/react.js +1 -1
  90. package/dist/theme-state.d.ts +16 -0
  91. package/dist/theme-state.d.ts.map +1 -1
  92. package/dist/theme-state.layout.test.d.ts +2 -0
  93. package/dist/theme-state.layout.test.d.ts.map +1 -0
  94. package/dist/theme-state.test.d.ts +2 -0
  95. package/dist/theme-state.test.d.ts.map +1 -0
  96. package/dist/vue.js +1 -1
  97. package/dist/web-components/ExtensionRoot.d.ts +50 -2
  98. package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
  99. package/dist/web-components/editor/ExtensionRoot.d.ts +11 -0
  100. package/dist/web-components/editor/ExtensionRoot.d.ts.map +1 -0
  101. package/dist/web-components/editor/ExtensionRoot.test.d.ts +2 -0
  102. package/dist/web-components/editor/ExtensionRoot.test.d.ts.map +1 -0
  103. package/dist/web-components/editor/InlineText.d.ts +1 -0
  104. package/dist/web-components/editor/InlineText.d.ts.map +1 -1
  105. package/dist/web-components/editor/editor-layout-controller.d.ts +28 -0
  106. package/dist/web-components/editor/editor-layout-controller.d.ts.map +1 -0
  107. package/dist/web-components/editor/gridstack-adapter.d.ts +3 -0
  108. package/dist/web-components/editor/gridstack-adapter.d.ts.map +1 -0
  109. package/dist/web-components/editor/gridstack-adapter.test.d.ts +2 -0
  110. package/dist/web-components/editor/gridstack-adapter.test.d.ts.map +1 -0
  111. package/dist/web-components/editor/morph.d.ts +32 -0
  112. package/dist/web-components/editor/morph.d.ts.map +1 -0
  113. package/dist/web-components/editor/morph.test.d.ts +2 -0
  114. package/dist/web-components/editor/morph.test.d.ts.map +1 -0
  115. package/dist/web-components/layout/layout-controller.d.ts +55 -0
  116. package/dist/web-components/layout/layout-controller.d.ts.map +1 -0
  117. package/dist/web-components/layout/view-layout-controller.d.ts +17 -0
  118. package/dist/web-components/layout/view-layout-controller.d.ts.map +1 -0
  119. package/dist/web-components/layout/view-layout-controller.test.d.ts +2 -0
  120. package/dist/web-components/layout/view-layout-controller.test.d.ts.map +1 -0
  121. package/dist/web-components/layout-grid.d.ts +47 -0
  122. package/dist/web-components/layout-grid.d.ts.map +1 -0
  123. package/dist/web-components/layout-grid.test.d.ts +2 -0
  124. package/dist/web-components/layout-grid.test.d.ts.map +1 -0
  125. package/dist/web-components/layout-mode-adapter.d.ts +51 -0
  126. package/dist/web-components/layout-mode-adapter.d.ts.map +1 -0
  127. package/dist/web-components/layout-mode-adapter.test.d.ts +2 -0
  128. package/dist/web-components/layout-mode-adapter.test.d.ts.map +1 -0
  129. package/dist/web-components-editor.js +125 -17
  130. package/dist/web-components-runtime.js +4 -3
  131. package/package.json +3 -2
  132. package/dist/ExtensionRoot-2xTGTu3K.js +0 -219
@@ -0,0 +1,378 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { signal, effect, createBlockInstance, layoutSystemEnabled, untracked } from "@juo/blocks";
5
+ import { reportBlockWarning, reportBlockError } from "./observability.js";
6
+ import { L as LAYOUT_SCOPE_ATTR, p as buildGridLayout, U as isStubDefinition, a5 as withWrapper, s as subscribeContext, T as ThemeStateContext, o as backfillInstanceDefaults, X as onRegisterBlock } from "./css-runtime-DWytAzZ5.js";
7
+ class Block extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ /** @description The block name to render */
11
+ __publicField(this, "name", signal(null));
12
+ __publicField(this, "disposeEffect");
13
+ }
14
+ static get observedAttributes() {
15
+ return ["name"];
16
+ }
17
+ connectedCallback() {
18
+ this.name.value = this.getAttribute("name") ?? null;
19
+ this.disposeEffect = effect(() => {
20
+ this.renderBlock(this.name.value);
21
+ });
22
+ }
23
+ attributeChangedCallback(name, oldValue, newValue) {
24
+ if (name === "name" && oldValue !== newValue) {
25
+ this.name.value = newValue ?? null;
26
+ }
27
+ }
28
+ disconnectedCallback() {
29
+ if (this.disposeEffect) {
30
+ this.disposeEffect();
31
+ this.disposeEffect = void 0;
32
+ }
33
+ }
34
+ renderBlock(name) {
35
+ if (name == null) {
36
+ reportBlockWarning("'name' attribute is required on <juo-block>", {
37
+ site: "web-components.Block.renderBlock"
38
+ });
39
+ this.replaceChildren();
40
+ return;
41
+ }
42
+ const props = Object.fromEntries(
43
+ Array.from(this.attributes).map((attr) => [attr.name, attr.value])
44
+ );
45
+ try {
46
+ const block = createBlockInstance(name, { props });
47
+ this.replaceChildren(block.definition.render(block));
48
+ } catch (error) {
49
+ reportBlockError(error, {
50
+ site: "web-components.Block.renderBlock",
51
+ block: { id: "(none)", type: name },
52
+ keys: { props: Object.keys(props) }
53
+ });
54
+ this.replaceChildren();
55
+ }
56
+ }
57
+ }
58
+ function tagGridItems(items, tags) {
59
+ const { dividerBlockIds, dividerRowBlockIds, fullWidthBlockIds } = tags;
60
+ for (const { blockId, element } of items) {
61
+ element.toggleAttribute(
62
+ "data-juo-divider",
63
+ (dividerBlockIds == null ? void 0 : dividerBlockIds.has(blockId)) ?? false
64
+ );
65
+ element.toggleAttribute(
66
+ "data-juo-divider-row",
67
+ (dividerRowBlockIds == null ? void 0 : dividerRowBlockIds.has(blockId)) ?? false
68
+ );
69
+ element.toggleAttribute(
70
+ "data-juo-grid-full-width",
71
+ (fullWidthBlockIds == null ? void 0 : fullWidthBlockIds.has(blockId)) ?? false
72
+ );
73
+ }
74
+ }
75
+ function applyGridLayout(host, inputs) {
76
+ host.style.containerType = "inline-size";
77
+ const styleEl = document.createElement("style");
78
+ styleEl.textContent = inputs.css;
79
+ const gridEl = document.createElement("div");
80
+ gridEl.setAttribute(LAYOUT_SCOPE_ATTR, inputs.scopeId);
81
+ for (const { blockId, element } of inputs.items) {
82
+ element.setAttribute("data-block-id", blockId);
83
+ gridEl.appendChild(element);
84
+ }
85
+ tagGridItems(inputs.items, inputs);
86
+ host.replaceChildren(styleEl, gridEl);
87
+ }
88
+ function clearGridLayout(host) {
89
+ host.style.removeProperty("container-type");
90
+ }
91
+ class ViewLayoutController {
92
+ readReactiveState() {
93
+ return { mode: false };
94
+ }
95
+ apply(host, inputs) {
96
+ const { extensionBlocks, children, layoutDoc, scopeId, layoutEngineEnabled } = inputs;
97
+ if (layoutEngineEnabled && host.hasAttribute("grid-layout") && layoutDoc != null) {
98
+ const blockIds = extensionBlocks.map((block) => block.id);
99
+ const runtime = buildGridLayout(layoutDoc, blockIds, scopeId);
100
+ applyGridLayout(host, {
101
+ scopeId,
102
+ css: runtime.css,
103
+ items: extensionBlocks.map((block, index) => ({
104
+ blockId: block.id,
105
+ element: children[index]
106
+ })),
107
+ dividerBlockIds: runtime.dividerBlockIds,
108
+ dividerRowBlockIds: runtime.dividerRowBlockIds,
109
+ fullWidthBlockIds: runtime.fullWidthBlockIds
110
+ });
111
+ return;
112
+ }
113
+ clearGridLayout(host);
114
+ host.replaceChildren(...children);
115
+ }
116
+ teardown(host) {
117
+ clearGridLayout(host);
118
+ }
119
+ }
120
+ const _ExtensionRoot = class _ExtensionRoot extends HTMLElement {
121
+ constructor() {
122
+ super();
123
+ __publicField(this, "state", signal(null));
124
+ __publicField(this, "themeState", null);
125
+ __publicField(this, "unsubscribeThemeContext");
126
+ __publicField(this, "disposeEffect");
127
+ __publicField(this, "__vueInstance", null);
128
+ /**
129
+ * Names of top-level slot children that resolved to a stub on the last
130
+ * render pass — i.e. blocks whose definition hasn't been registered yet.
131
+ * Rebuilt on each render and consulted from the registration listener so
132
+ * we only retrigger when a block we're actually waiting on lands.
133
+ *
134
+ * Only top-level children are tracked — nested stubs inside a registered
135
+ * parent's renderer aren't currently handled (rare in practice; revisit
136
+ * if it shows up).
137
+ */
138
+ __publicField(this, "unresolvedNames", /* @__PURE__ */ new Set());
139
+ __publicField(this, "unregisterListener");
140
+ __publicField(this, "scopeId", null);
141
+ /**
142
+ * Pluggable layout strategy. Runtime default renders the settled CSS-Grid/flex
143
+ * view; the editor subclass swaps in a controller that adds the drag/resize
144
+ * adapter path. ExtensionRoot owns block rendering — the controller owns all
145
+ * layout side-effects on this host.
146
+ */
147
+ __publicField(this, "layout", new ViewLayoutController());
148
+ /**
149
+ * Optional function to wrap each rendered block element.
150
+ * Called with the rendered block HTMLElement, must return an HTMLElement.
151
+ * When set, the wrapper sits between the editor wrapper (outer) and the actual block (inner).
152
+ * Must be set before blocks are first rendered; changing it afterwards has no effect
153
+ * on already-cached block wrappers.
154
+ */
155
+ __publicField(this, "blockWrapper", null);
156
+ /**
157
+ * Rendered top-level children cached by stable block id.
158
+ *
159
+ * Keying on id (not BlockInstance identity) is what keeps entering layout
160
+ * mode cheap: a PROVIDE_THEME_STATE that re-materialises the same blocks
161
+ * into fresh instance objects reuses the existing wrapper element instead of
162
+ * recreating the whole subtree — which would otherwise tear down and
163
+ * re-request context for every nested `juo-text` and rip GridStack's managed
164
+ * elements out from under it.
165
+ *
166
+ * `render` is the memoised withWrapper closure (owns a stable outer wrapper
167
+ * element). `signature` is a content hash of the last-rendered block; when
168
+ * it is unchanged (e.g. only `canvasMode`/layout changed) we return the
169
+ * cached element without re-rendering at all. Any real content change —
170
+ * props/slots edited in place, a stub upgrading to its real definition at
171
+ * any depth — flips the signature and forces a re-render.
172
+ */
173
+ __publicField(this, "childCache", /* @__PURE__ */ new Map());
174
+ /**
175
+ * The layout engine the cached wrappers were built under. `withWrapper`
176
+ * (block.ts) picks the wrapper *element* (legacy chrome vs. minimal layout
177
+ * wrapper) once, at creation, from `layoutSystemEnabled`. The child cache
178
+ * keys on block id and reuses that memoised closure, so a live engine switch
179
+ * would otherwise keep the stale wrapper tag until a full refresh. Tracking
180
+ * the engine here lets us drop the cache when it flips, forcing fresh
181
+ * closures (and thus the correct wrapper element) on the next render.
182
+ */
183
+ __publicField(this, "childCacheEngine", null);
184
+ }
185
+ getScopeId() {
186
+ if (this.scopeId == null) {
187
+ this.scopeId = `ext-${++_ExtensionRoot.scopeCounter}`;
188
+ }
189
+ return this.scopeId;
190
+ }
191
+ static get observedAttributes() {
192
+ return ["name", "surface", "grid-layout"];
193
+ }
194
+ /**
195
+ * Content hash of a block subtree: type, props, slot structure and the
196
+ * stub/real state of every node. Identity is deliberately excluded so a
197
+ * re-materialised-but-identical tree reuses its element; stub flags are
198
+ * included so a late-registered definition still re-renders even when its
199
+ * serialised props are unchanged.
200
+ */
201
+ static signatureOf(block) {
202
+ const stub = isStubDefinition(block.definition) ? "1" : "0";
203
+ const slots = Object.entries(block.slots ?? {}).map(([key, value]) => {
204
+ const children = Array.isArray(value) ? value : [value];
205
+ return `${key}:${children.map(
206
+ (child) => typeof child === "string" ? `s${child}` : _ExtensionRoot.signatureOf(child)
207
+ ).join(",")}`;
208
+ }).join("|");
209
+ return `${block.type}#${stub}#${JSON.stringify(block.props ?? {})}#{${slots}}`;
210
+ }
211
+ renderChild(block) {
212
+ const signature = _ExtensionRoot.signatureOf(block);
213
+ const cached = this.childCache.get(block.id);
214
+ if (cached != null && cached.signature === signature) {
215
+ return cached.element;
216
+ }
217
+ const render = (cached == null ? void 0 : cached.render) ?? withWrapper((inner) => {
218
+ const rendered = inner.definition.render({
219
+ ...inner,
220
+ __vueInstance: this.__vueInstance
221
+ });
222
+ return this.blockWrapper ? this.blockWrapper(rendered) : rendered;
223
+ });
224
+ const element = render(block);
225
+ this.childCache.set(block.id, { signature, render, element });
226
+ return element;
227
+ }
228
+ /** Drop cached children whose ids are no longer rendered to avoid leaks. */
229
+ pruneChildCache(activeIds) {
230
+ for (const id of this.childCache.keys()) {
231
+ if (!activeIds.has(id)) {
232
+ this.childCache.delete(id);
233
+ }
234
+ }
235
+ }
236
+ getSurface() {
237
+ return this.getAttribute("surface") === "overlay" ? "overlay" : "page";
238
+ }
239
+ setStateFromThemeState(themeState) {
240
+ const surface = this.getSurface();
241
+ this.state.value = surface === "overlay" ? themeState.overlay : themeState.page;
242
+ }
243
+ connectedCallback() {
244
+ this.state.value = null;
245
+ this.themeState = null;
246
+ this.style.display = "flex";
247
+ this.style.flexDirection = "column";
248
+ this.style.maxWidth = "100%";
249
+ this.unsubscribeThemeContext = subscribeContext(
250
+ this,
251
+ ThemeStateContext,
252
+ (contextValue) => {
253
+ this.themeState = contextValue;
254
+ this.setStateFromThemeState(contextValue);
255
+ }
256
+ );
257
+ this.disposeEffect = effect(() => {
258
+ var _a;
259
+ const state = this.state.value;
260
+ if (state == null) {
261
+ this.layout.teardown(this);
262
+ this.replaceChildren();
263
+ return;
264
+ }
265
+ const name = this.getAttribute("name");
266
+ if (name == null) {
267
+ console.error("'name' attribute is required");
268
+ this.layout.teardown(this);
269
+ this.replaceChildren();
270
+ return;
271
+ }
272
+ const blocks = state.blocks.value;
273
+ const layoutDoc = ((_a = state.layout) == null ? void 0 : _a.value) ?? null;
274
+ const reactive = this.layout.readReactiveState();
275
+ const layoutEngineEnabled = layoutSystemEnabled.value;
276
+ untracked(() => {
277
+ var _a2;
278
+ if (this.childCacheEngine !== layoutEngineEnabled) {
279
+ this.childCache.clear();
280
+ this.childCacheEngine = layoutEngineEnabled;
281
+ }
282
+ let extensionBlocks = [];
283
+ try {
284
+ extensionBlocks = (((_a2 = blocks.at(0)) == null ? void 0 : _a2.slots) ?? {})[name] ?? [];
285
+ for (const block of extensionBlocks) {
286
+ if (block != null && typeof block === "object") {
287
+ backfillInstanceDefaults(block);
288
+ }
289
+ }
290
+ const children = extensionBlocks.map(
291
+ (block) => this.renderChild(block)
292
+ );
293
+ this.pruneChildCache(
294
+ new Set(extensionBlocks.map((block) => block.id))
295
+ );
296
+ this.layout.apply(this, {
297
+ extensionBlocks,
298
+ children,
299
+ layoutDoc,
300
+ scopeId: this.getScopeId(),
301
+ reactive,
302
+ layoutEngineEnabled
303
+ });
304
+ } catch (error) {
305
+ reportBlockError(error, {
306
+ site: "web-components.ExtensionRoot.effect",
307
+ extra: {
308
+ surface: this.getSurface(),
309
+ name: this.getAttribute("name") ?? "(none)"
310
+ }
311
+ });
312
+ this.layout.teardown(this);
313
+ this.replaceChildren();
314
+ extensionBlocks = [];
315
+ }
316
+ this.unresolvedNames.clear();
317
+ for (const block of extensionBlocks) {
318
+ if (block != null && typeof block === "object" && isStubDefinition(block.definition)) {
319
+ this.unresolvedNames.add(block.type);
320
+ }
321
+ }
322
+ if (this.unresolvedNames.size > 0 && !this.unregisterListener) {
323
+ this.unregisterListener = onRegisterBlock((name2) => {
324
+ var _a3;
325
+ if (!this.unresolvedNames.has(name2)) return;
326
+ const stateRef = this.state.value;
327
+ if (stateRef == null) return;
328
+ const surfaceBlocks = stateRef.blocks.value;
329
+ const slotName = this.getAttribute("name");
330
+ if (slotName != null) {
331
+ const children = (((_a3 = surfaceBlocks.at(0)) == null ? void 0 : _a3.slots) ?? {})[slotName] ?? [];
332
+ for (const child of children) {
333
+ if (child != null && typeof child === "object" && child.type === name2) {
334
+ backfillInstanceDefaults(child);
335
+ }
336
+ }
337
+ }
338
+ this.state.value = { ...stateRef };
339
+ });
340
+ }
341
+ });
342
+ });
343
+ }
344
+ attributeChangedCallback(name, oldValue, newValue) {
345
+ if ((name === "name" || name === "surface" || name === "grid-layout") && oldValue !== newValue && this.state.value) {
346
+ if (name === "surface") {
347
+ if (this.themeState) {
348
+ this.setStateFromThemeState(this.themeState);
349
+ return;
350
+ }
351
+ }
352
+ this.state.value = { ...this.state.value };
353
+ }
354
+ }
355
+ disconnectedCallback() {
356
+ this.layout.teardown(this);
357
+ if (this.unsubscribeThemeContext) {
358
+ this.unsubscribeThemeContext();
359
+ this.unsubscribeThemeContext = void 0;
360
+ }
361
+ if (this.disposeEffect) {
362
+ this.disposeEffect();
363
+ this.disposeEffect = void 0;
364
+ }
365
+ if (this.unregisterListener) {
366
+ this.unregisterListener();
367
+ this.unregisterListener = void 0;
368
+ }
369
+ this.unresolvedNames.clear();
370
+ }
371
+ };
372
+ __publicField(_ExtensionRoot, "scopeCounter", 0);
373
+ let ExtensionRoot = _ExtensionRoot;
374
+ export {
375
+ Block as B,
376
+ ExtensionRoot as E,
377
+ ViewLayoutController as V
378
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAKpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAkB7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,EACjB,KAAK,CAAC,EAAE,UAAU,GACjB,MAAM,IAAI,CAmBZ;AAED,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,UAAU,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAErD,MAAM,WAAW,WAAW,CAC1B,MAAM,GAAG,OAAO,EAChB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElE,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,K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2
+ const LAYOUT_BLOCK_WRAPPER_TAG = "juo-editor-layout-block-wrapper";
3
+ const WRAPPER_TAG_NAMES = /* @__PURE__ */ new Set([
4
+ BLOCK_WRAPPER_TAG.toUpperCase(),
5
+ LAYOUT_BLOCK_WRAPPER_TAG.toUpperCase()
6
+ ]);
7
+ const WRAPPER_SELECTOR = `${BLOCK_WRAPPER_TAG}[data-block-id], ${LAYOUT_BLOCK_WRAPPER_TAG}[data-block-id]`;
8
+ function isBlockWrapperTag(tagName) {
9
+ return WRAPPER_TAG_NAMES.has(tagName.toUpperCase());
10
+ }
11
+ function getBlockLabel(block) {
12
+ return block.definition.displayName ?? block.definition.name;
13
+ }
14
+ function resolveOutlineTarget(slotted) {
15
+ const root = slotted.shadowRoot ?? slotted;
16
+ let el = root.firstElementChild;
17
+ while (el) {
18
+ if (el.tagName === "STYLE") {
19
+ el = el.nextElementSibling;
20
+ continue;
21
+ }
22
+ if (getComputedStyle(el).display === "contents") {
23
+ el = el.firstElementChild;
24
+ continue;
25
+ }
26
+ return el;
27
+ }
28
+ return slotted.shadowRoot ? null : slotted;
29
+ }
1
30
  function isEditorMessage(message) {
2
- return message.type === "PROVIDE_THEME_STATE" || message.type === "PROVIDE_TRANSLATION_OVERRIDES" || message.type === "SELECT_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "ADD_BLOCK" || message.type === "REMOVE_BLOCK" || message.type === "MOVE_BLOCK" || message.type === "SET_BLOCK_PRESET" || message.type === "SET_LOCALE" || message.type === "SET_GLOBAL_STYLES" || message.type === "PROVIDE_GLOBAL_STYLES" || message.type === "SCROLL_SYNC" || message.type === "REQUEST_CONTENT_HEIGHT" || message.type === "ADD_BLOCK_MENU_CLOSED";
31
+ return message.type === "PROVIDE_THEME_STATE" || message.type === "PROVIDE_TRANSLATION_OVERRIDES" || message.type === "SELECT_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "ADD_BLOCK" || message.type === "REMOVE_BLOCK" || message.type === "MOVE_BLOCK" || message.type === "SET_BLOCK_PRESET" || message.type === "SET_LOCALE" || message.type === "SET_GLOBAL_STYLES" || message.type === "PROVIDE_GLOBAL_STYLES" || message.type === "SCROLL_SYNC" || message.type === "REQUEST_CONTENT_HEIGHT" || message.type === "ADD_BLOCK_MENU_CLOSED" || message.type === "PROVIDE_LAYOUT" || message.type === "PROVIDE_LAYOUT_DOCUMENT" || message.type === "SET_LAYOUTING_MODE";
3
32
  }
4
33
  function isIframeMessage(message) {
5
- return message.type === "SELECT_BLOCK" || message.type === "IFRAME_READY" || message.type === "REGISTER_BLOCKS" || message.type === "REGISTER_ROUTES" || message.type === "REMOVE_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "REQUEST_THEME_STATE" || message.type === "UPSERT_THEME_STATE" || message.type === "REQUEST_TRANSLATION_OVERRIDES" || message.type === "UPDATE_BLOCK_TRANSLATION" || message.type === "REGISTER_BLOCK_TRANSLATION_KEYS" || message.type === "FOCUS_INLINE_TEXT" || message.type === "REQUEST_GLOBAL_STYLES" || message.type === "PROVIDE_INITIAL_GLOBAL_STYLES" || message.type === "REPORT_CONTENT_HEIGHT" || message.type === "SCROLL_SYNC" || message.type === "OPEN_ADD_BLOCK_MENU";
34
+ return message.type === "SELECT_BLOCK" || message.type === "IFRAME_READY" || message.type === "REGISTER_BLOCKS" || message.type === "REGISTER_ROUTES" || message.type === "REMOVE_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "REQUEST_THEME_STATE" || message.type === "UPSERT_THEME_STATE" || message.type === "REQUEST_TRANSLATION_OVERRIDES" || message.type === "UPDATE_BLOCK_TRANSLATION" || message.type === "REGISTER_BLOCK_TRANSLATION_KEYS" || message.type === "FOCUS_INLINE_TEXT" || message.type === "REQUEST_GLOBAL_STYLES" || message.type === "PROVIDE_INITIAL_GLOBAL_STYLES" || message.type === "REPORT_CONTENT_HEIGHT" || message.type === "SCROLL_SYNC" || message.type === "OPEN_ADD_BLOCK_MENU" || message.type === "REQUEST_CLOSE_ADD_BLOCK_MENU" || message.type === "LAYOUT_COMMAND" || message.type === "LAYOUTING_MODE_CHANGED" || message.type === "REPORT_BLOCK_CONTENT_SIZE";
6
35
  }
7
36
  function createProvideThemeStateMessage(payload) {
8
37
  return {
@@ -197,6 +226,55 @@ function createAddBlockMenuClosedMessage(payload) {
197
226
  timestamp: Date.now()
198
227
  };
199
228
  }
229
+ function createRequestCloseAddBlockMenuMessage() {
230
+ return {
231
+ type: "REQUEST_CLOSE_ADD_BLOCK_MENU",
232
+ payload: {},
233
+ timestamp: Date.now()
234
+ };
235
+ }
236
+ function createProvideLayoutMessage(payload) {
237
+ return {
238
+ type: "PROVIDE_LAYOUT",
239
+ payload,
240
+ timestamp: Date.now()
241
+ };
242
+ }
243
+ function createLayoutCommandMessage(payload) {
244
+ return {
245
+ type: "LAYOUT_COMMAND",
246
+ payload,
247
+ timestamp: Date.now()
248
+ };
249
+ }
250
+ function createProvideLayoutDocumentMessage(payload) {
251
+ return {
252
+ type: "PROVIDE_LAYOUT_DOCUMENT",
253
+ payload,
254
+ timestamp: Date.now()
255
+ };
256
+ }
257
+ function createSetLayoutingModeMessage(payload) {
258
+ return {
259
+ type: "SET_LAYOUTING_MODE",
260
+ payload,
261
+ timestamp: Date.now()
262
+ };
263
+ }
264
+ function createLayoutingModeChangedMessage(payload) {
265
+ return {
266
+ type: "LAYOUTING_MODE_CHANGED",
267
+ payload,
268
+ timestamp: Date.now()
269
+ };
270
+ }
271
+ function createReportBlockContentSizeMessage(payload) {
272
+ return {
273
+ type: "REPORT_BLOCK_CONTENT_SIZE",
274
+ payload,
275
+ timestamp: Date.now()
276
+ };
277
+ }
200
278
  let bridgeInstance = null;
201
279
  function getEditorBridge() {
202
280
  return bridgeInstance;
@@ -260,11 +338,13 @@ function createEditorBridge() {
260
338
  });
261
339
  const isAddBlockButton = path.some((node) => {
262
340
  if (!(node instanceof HTMLElement)) return false;
263
- return node.classList.contains("block-wrapper__add-btn") || node.classList.contains("block-wrapper__add-btn-inner") || node.classList.contains("block-wrapper__add-btn-surface") || node.classList.contains("block-wrapper__add-btn-plus") || node.classList.contains("block-wrapper__add-btn-text");
341
+ return node.classList.contains("block-wrapper__add-btn") || node.classList.contains("block-wrapper__add-btn-inner") || node.classList.contains("block-wrapper__add-btn-surface") || node.classList.contains("block-wrapper__add-btn-plus") || node.classList.contains("block-wrapper__add-btn-text") || // Grid layout toolbar's "add block below" button.
342
+ node.classList.contains("layout-block-wrapper__tool-btn--add");
264
343
  });
265
344
  if (isAddBlockButton) {
266
345
  return;
267
346
  }
347
+ sendMessage(createRequestCloseAddBlockMenuMessage());
268
348
  const isEditorUI = path.some((node) => {
269
349
  if (!(node instanceof HTMLElement)) return false;
270
350
  let current = node;
@@ -280,7 +360,7 @@ function createEditorBridge() {
280
360
  });
281
361
  let blockWrapper = null;
282
362
  for (const node of path) {
283
- if (node instanceof HTMLElement && node.tagName === "JUO-EDITOR-BLOCK-WRAPPER") {
363
+ if (node instanceof HTMLElement && isBlockWrapperTag(node.tagName)) {
284
364
  blockWrapper = node;
285
365
  break;
286
366
  }
@@ -392,7 +472,7 @@ function createEditorBridge() {
392
472
  clearTimeout(pending.timer);
393
473
  pendingRequests.delete(data.payload.requestId);
394
474
  pending.resolve(
395
- data.payload.blocks != null ? { blocks: data.payload.blocks } : null
475
+ data.payload.blocks != null ? { blocks: data.payload.blocks, layout: data.payload.layout ?? null } : null
396
476
  );
397
477
  }
398
478
  } else if (data.type === "PROVIDE_TRANSLATION_OVERRIDES" && data.payload.requestId) {
@@ -450,6 +530,7 @@ function createEditorBridge() {
450
530
  let ghostScrollStyleEl = null;
451
531
  let ghostScrollObserver = null;
452
532
  let suppressScrollReport = false;
533
+ let scrollPreserveActive = false;
453
534
  function reportContentHeight() {
454
535
  var _a;
455
536
  if (!isEditorMode) return;
@@ -460,12 +541,32 @@ function createEditorBridge() {
460
541
  sendMessage(createReportContentHeightMessage({ height }));
461
542
  }
462
543
  function handleScrollEvent() {
544
+ if (scrollPreserveActive) return;
463
545
  if (suppressScrollReport) {
464
546
  suppressScrollReport = false;
465
547
  return;
466
548
  }
467
549
  sendMessage(createScrollSyncMessage({ scrollY: window.scrollY }));
468
550
  }
551
+ function preserveScrollAcrossReflow() {
552
+ if (!isEditorMode) return;
553
+ const targetY = window.scrollY;
554
+ scrollPreserveActive = true;
555
+ const raf = typeof requestAnimationFrame === "function" ? (cb) => {
556
+ requestAnimationFrame(() => cb());
557
+ } : (cb) => {
558
+ setTimeout(cb, 0);
559
+ };
560
+ const restore = () => window.scrollTo(0, targetY);
561
+ raf(() => {
562
+ restore();
563
+ raf(() => {
564
+ restore();
565
+ scrollPreserveActive = false;
566
+ sendMessage(createScrollSyncMessage({ scrollY: targetY }));
567
+ });
568
+ });
569
+ }
469
570
  if (isEditorMode) {
470
571
  ghostScrollStyleEl = document.createElement("style");
471
572
  ghostScrollStyleEl.textContent = "html { scrollbar-width: none; } html::-webkit-scrollbar { display: none; }";
@@ -518,38 +619,51 @@ function createEditorBridge() {
518
619
  upsertThemeState,
519
620
  requestTranslationOverrides,
520
621
  requestGlobalStyles,
622
+ preserveScrollAcrossReflow,
521
623
  destroy
522
624
  };
523
625
  return bridgeInstance;
524
626
  }
525
627
  export {
526
- getEditorBridge as A,
527
- isEditorMessage as B,
528
- isIframeMessage as C,
529
- createEditorBridge as a,
530
- createFocusInlineTextMessage as b,
531
- createRegisterBlockTranslationKeysMessage as c,
532
- createUpdateBlockTranslationMessage as d,
533
- createSelectBlockMessage as e,
628
+ createRequestGlobalStylesMessage as A,
629
+ createRequestThemeStateMessage as B,
630
+ createRequestTranslationOverridesMessage as C,
631
+ createScrollSyncMessage as D,
632
+ createSetBlockPresetMessage as E,
633
+ createSetGlobalStylesMessage as F,
634
+ createSetLayoutingModeMessage as G,
635
+ createSetLocaleMessage as H,
636
+ createUpdateBlockPropsMessage as I,
637
+ createUpsertThemeStateMessage as J,
638
+ getEditorBridge as K,
639
+ LAYOUT_BLOCK_WRAPPER_TAG as L,
640
+ isEditorMessage as M,
641
+ isIframeMessage as N,
642
+ WRAPPER_SELECTOR as W,
643
+ createSelectBlockMessage as a,
644
+ createRegisterBlockTranslationKeysMessage as b,
645
+ createEditorBridge as c,
646
+ createFocusInlineTextMessage as d,
647
+ createUpdateBlockTranslationMessage as e,
534
648
  createOpenAddBlockMenuMessage as f,
535
649
  createRemoveBlockMessage as g,
536
- createRegisterBlocksMessage as h,
537
- createRegisterRoutesMessage as i,
538
- createAddBlockMenuClosedMessage as j,
539
- createAddBlockMessage as k,
540
- createMoveBlockMessage as l,
541
- createProvideGlobalStylesMessage as m,
542
- createProvideInitialGlobalStylesMessage as n,
543
- createProvideThemeStateMessage as o,
544
- createProvideTranslationOverridesMessage as p,
545
- createReportContentHeightMessage as q,
546
- createRequestGlobalStylesMessage as r,
547
- createRequestThemeStateMessage as s,
548
- createRequestTranslationOverridesMessage as t,
549
- createScrollSyncMessage as u,
550
- createSetBlockPresetMessage as v,
551
- createSetGlobalStylesMessage as w,
552
- createSetLocaleMessage as x,
553
- createUpdateBlockPropsMessage as y,
554
- createUpsertThemeStateMessage as z
650
+ getBlockLabel as h,
651
+ isBlockWrapperTag as i,
652
+ createLayoutCommandMessage as j,
653
+ createRegisterBlocksMessage as k,
654
+ createRegisterRoutesMessage as l,
655
+ createAddBlockMenuClosedMessage as m,
656
+ createAddBlockMessage as n,
657
+ createLayoutingModeChangedMessage as o,
658
+ createMoveBlockMessage as p,
659
+ createProvideGlobalStylesMessage as q,
660
+ resolveOutlineTarget as r,
661
+ createProvideInitialGlobalStylesMessage as s,
662
+ createProvideLayoutDocumentMessage as t,
663
+ createProvideLayoutMessage as u,
664
+ createProvideThemeStateMessage as v,
665
+ createProvideTranslationOverridesMessage as w,
666
+ createReportBlockContentSizeMessage as x,
667
+ createReportContentHeightMessage as y,
668
+ createRequestCloseAddBlockMenuMessage as z
555
669
  };
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mapp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