@jxsuite/studio 0.37.1 → 1.1.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 (113) hide show
  1. package/dist/iframe-entry.js +622 -49
  2. package/dist/iframe-entry.js.map +15 -12
  3. package/dist/studio.css +1333 -0
  4. package/dist/studio.js +103709 -81001
  5. package/dist/studio.js.map +201 -157
  6. package/package.json +47 -45
  7. package/src/account-status.ts +39 -0
  8. package/src/browse/browse.ts +10 -14
  9. package/src/canvas/canvas-live-render.ts +21 -2
  10. package/src/canvas/canvas-render.ts +35 -16
  11. package/src/canvas/canvas-utils.ts +118 -72
  12. package/src/canvas/iframe-entry.ts +20 -0
  13. package/src/canvas/iframe-eval.ts +155 -0
  14. package/src/canvas/iframe-host.ts +132 -6
  15. package/src/canvas/iframe-inline-edit.ts +107 -1
  16. package/src/canvas/iframe-protocol.ts +43 -3
  17. package/src/canvas/iframe-render.ts +18 -0
  18. package/src/collab/collab-session.ts +23 -8
  19. package/src/collab/collab-state.ts +6 -3
  20. package/src/component-props.ts +104 -0
  21. package/src/editor/context-menu.ts +1 -1
  22. package/src/editor/inline-edit-apply.ts +36 -1
  23. package/src/editor/inline-edit.ts +58 -1
  24. package/src/editor/repeater-scope.ts +8 -13
  25. package/src/editor/shortcuts.ts +41 -12
  26. package/src/files/file-ops.ts +14 -0
  27. package/src/files/files.ts +56 -1
  28. package/src/format/format-host.ts +63 -1
  29. package/src/grid/cell-editors.ts +288 -0
  30. package/src/grid/cell-popovers.ts +108 -0
  31. package/src/grid/csv-codec.ts +122 -0
  32. package/src/grid/edit-buffer.ts +490 -0
  33. package/src/grid/grid-controller.ts +417 -0
  34. package/src/grid/grid-layout.ts +83 -0
  35. package/src/grid/grid-open.ts +167 -0
  36. package/src/grid/grid-panel.ts +302 -0
  37. package/src/grid/grid-source.ts +210 -0
  38. package/src/grid/grid-view.ts +367 -0
  39. package/src/grid/schema-columns.ts +261 -0
  40. package/src/grid/sources/connector-source.ts +217 -0
  41. package/src/grid/sources/content-source.ts +542 -0
  42. package/src/grid/sources/csv-file-source.ts +247 -0
  43. package/src/grid/tabulator-tables.d.ts +120 -0
  44. package/src/new-project/add-repo-modal.ts +183 -0
  45. package/src/new-project/new-project-modal.ts +22 -3
  46. package/src/page-params.ts +34 -8
  47. package/src/panels/ai-chat/chat-markdown.ts +2 -2
  48. package/src/panels/ai-panel.ts +61 -4
  49. package/src/panels/block-action-bar.ts +8 -3
  50. package/src/panels/chat-panel.ts +98 -0
  51. package/src/panels/data-grid.ts +241 -0
  52. package/src/panels/editors.ts +43 -17
  53. package/src/panels/events-panel.ts +137 -44
  54. package/src/panels/formula-workspace.ts +379 -0
  55. package/src/panels/frontmatter-fields.ts +231 -0
  56. package/src/panels/frontmatter-panel.ts +132 -0
  57. package/src/panels/git-panel.ts +1 -1
  58. package/src/panels/head-panel.ts +11 -175
  59. package/src/panels/properties-panel.ts +154 -144
  60. package/src/panels/right-panel.ts +9 -47
  61. package/src/panels/signals-panel.ts +217 -460
  62. package/src/panels/statement-editor.ts +710 -0
  63. package/src/panels/statusbar.ts +1 -1
  64. package/src/panels/style-panel.ts +25 -1
  65. package/src/panels/stylebook-panel.ts +0 -2
  66. package/src/panels/tab-bar.ts +175 -6
  67. package/src/panels/tab-strip.ts +62 -6
  68. package/src/panels/toolbar.ts +37 -3
  69. package/src/panels/welcome-screen.ts +50 -0
  70. package/src/platform-errors.ts +30 -0
  71. package/src/platforms/cloud.ts +172 -89
  72. package/src/platforms/devserver.ts +172 -0
  73. package/src/services/ai-project-tools.ts +541 -0
  74. package/src/services/ai-session-store.ts +28 -0
  75. package/src/services/ai-system-prompt.ts +194 -24
  76. package/src/services/ai-tools.ts +88 -21
  77. package/src/services/automation.ts +16 -0
  78. package/src/services/context-resolver.ts +73 -0
  79. package/src/services/data-service.ts +155 -0
  80. package/src/services/document-assistant.ts +81 -11
  81. package/src/services/gated-registry.ts +72 -0
  82. package/src/services/live-preview.ts +0 -0
  83. package/src/services/monaco-setup.ts +75 -26
  84. package/src/services/preview-eval.ts +68 -0
  85. package/src/services/project-adoption.ts +31 -0
  86. package/src/settings/contributed-section.ts +406 -0
  87. package/src/settings/extension-sections.ts +145 -0
  88. package/src/settings/schema-field-ui.ts +4 -2
  89. package/src/settings/settings-modal.ts +101 -42
  90. package/src/site-context.ts +12 -1
  91. package/src/store.ts +4 -0
  92. package/src/studio.ts +107 -52
  93. package/src/tabs/patch-ops.ts +25 -0
  94. package/src/tabs/tab.ts +39 -1
  95. package/src/tabs/transact.ts +61 -14
  96. package/src/types.ts +132 -1
  97. package/src/ui/dynamic-slot.ts +272 -0
  98. package/src/ui/expression-editor.ts +423 -125
  99. package/src/ui/field-row.ts +5 -0
  100. package/src/ui/form-controls.ts +322 -0
  101. package/src/ui/formula-catalog.ts +557 -0
  102. package/src/ui/formula-chips.ts +216 -0
  103. package/src/ui/formula-palette.ts +211 -0
  104. package/src/ui/layers.ts +40 -0
  105. package/src/ui/media-picker.ts +1 -1
  106. package/src/ui/panel-resize.ts +15 -1
  107. package/src/ui/progress-modal.ts +2 -2
  108. package/src/ui/schema-form.ts +524 -0
  109. package/src/utils/preview-format.ts +26 -0
  110. package/src/utils/studio-utils.ts +4 -3
  111. package/src/view.ts +4 -4
  112. package/src/workspace/workspace.ts +14 -0
  113. package/src/settings/content-types-editor.ts +0 -599
@@ -21,6 +21,7 @@ import { startIframeSlashBridge } from "./iframe-slash";
21
21
  import { startKeyForwarding } from "./iframe-keys";
22
22
  import { applyIframePatch } from "./iframe-patch";
23
23
  import { disposeAllSubtrees } from "./iframe-subtree";
24
+ import { evaluateLiveExprs } from "./iframe-eval";
24
25
  import { serializeDataScope } from "./serialize-scope";
25
26
  import { getActivePath, isEditing, stopEditing } from "../editor/inline-edit";
26
27
  import { isAncestor } from "../state";
@@ -226,8 +227,11 @@ export function startCanvasIframe(opts: {
226
227
  // Document, so without this they'd be swallowed whenever focus is inside the canvas iframe.
227
228
  const stopKeyForwarding = startKeyForwarding(channel, container.ownerDocument);
228
229
  // Run inline editing (contenteditable) here, posting committed/split/insert results to the parent.
230
+ // The shadow-doc accessor gates prop-bound sessions on the RAW instance prop value (template/$ref
231
+ // Valued props render display sugar and must not be plain-text edited).
229
232
  const stopInlineEdit = startIframeInlineEdit(channel, container, {
230
233
  getMode: () => currentMode,
234
+ getShadowDoc: () => shadowDoc,
231
235
  });
232
236
  // Bridge the engine's slash menu to the parent's Spectrum menu (show/nav/select over the channel).
233
237
  const stopSlashBridge = startIframeSlashBridge(channel, container.ownerDocument);
@@ -365,6 +369,22 @@ export function startCanvasIframe(opts: {
365
369
  });
366
370
  return;
367
371
  }
372
+ if (msg.kind === "evalExpr") {
373
+ // Live expression preview (M6): evaluate against the LIVE render's resolved scope — but only
374
+ // The render the request targeted. A stale/ahead gen gets an empty reply (never values from
375
+ // The wrong scope); the parent additionally gen-gates the reply against its own state.
376
+ const results =
377
+ msg.gen === renderedGen && renderCtx && shadowDoc
378
+ ? evaluateLiveExprs(
379
+ msg.exprs,
380
+ renderCtx.defs as Record<string, unknown>,
381
+ shadowDoc,
382
+ msg.contextPath,
383
+ )
384
+ : [];
385
+ channel.post({ gen: msg.gen, kind: "evalResult", reqId: msg.reqId, results });
386
+ return;
387
+ }
368
388
  if (msg.kind === "patch") {
369
389
  const { gen } = msg;
370
390
  if (gen < renderedGen) {
@@ -0,0 +1,155 @@
1
+ /**
2
+ * In-iframe live expression evaluation (M6) — answers the parent's `evalExpr` requests against the
3
+ * LIVE resolved scope of the current render (buildScope's `$defs`), so previews see real repeater
4
+ * items, real `window#/` globals, and uncapped data values instead of the parent's serialized
5
+ * snapshot.
6
+ *
7
+ * Safety: every expression evaluates against a fresh plain-data clone of the scope (a per-key JSON
8
+ * round-trip, the serialize-scope idiom — it reads through the runtime's reactive proxies), so
9
+ * mutating operators write into the clone and never touch the live canvas. Named-formula callables
10
+ * (pure `$expression` entries with parameters) are kept BY REFERENCE so `call` nodes work; every
11
+ * other function (side-effecting handlers, server fns) is dropped so a preview can never run one.
12
+ */
13
+
14
+ import { evaluateExpression } from "@jxsuite/runtime/expression";
15
+ import { resolveRef } from "@jxsuite/runtime";
16
+ import { formatPreviewValue } from "../utils/preview-format";
17
+
18
+ import type { ExpressionNode } from "@jxsuite/runtime/expression";
19
+ import type { EvalExprResult } from "./iframe-protocol";
20
+
21
+ type Scope = Record<string, unknown>;
22
+
23
+ /** Whether the raw (document) state entry is a pure named-formula (`$expression` + parameters). */
24
+ function isNamedFormulaEntry(entry: unknown): boolean {
25
+ return (
26
+ typeof entry === "object" &&
27
+ entry !== null &&
28
+ !Array.isArray(entry) &&
29
+ "$expression" in entry &&
30
+ Array.isArray((entry as { parameters?: unknown }).parameters)
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Clone the live `$defs` scope into a plain object safe to evaluate (and mutate) against. Data
36
+ * values are JSON round-tripped per key (reads through reactive proxies, unwraps top-level refs);
37
+ * functions survive only when their raw state entry is a pure named formula — anything else
38
+ * callable (event handlers, structured-body functions, server fns) is dropped so a stray `call`
39
+ * can't run a side effect against the live canvas.
40
+ */
41
+ export function cloneLiveScope(defs: Scope, rawState: Record<string, unknown> | null): Scope {
42
+ const out: Scope = {};
43
+ for (const key of Object.keys(defs)) {
44
+ try {
45
+ // Reading through the reactive proxy auto-unwraps a top-level ref/computed — and can throw (a
46
+ // Computed getter that throws), which maps the key to null instead of aborting the clone.
47
+ const value = defs[key];
48
+ if (typeof value === "function") {
49
+ if (isNamedFormulaEntry(rawState?.[key])) {
50
+ out[key] = value; // A pure formula callable — safe (and needed) for `call` nodes.
51
+ }
52
+ continue;
53
+ }
54
+ const json = JSON.stringify(value);
55
+ out[key] = json === undefined ? null : (JSON.parse(json) as unknown);
56
+ } catch {
57
+ out[key] = null;
58
+ }
59
+ }
60
+ return out;
61
+ }
62
+
63
+ /**
64
+ * Bind repeater `$map` contexts for a node at `contextPath`: walk the shadow doc along the path
65
+ * and, at every repeater crossing (a `$prototype: "Array"` node entered through its `map`
66
+ * template), resolve the repeater's `items` against the scope built so far and layer the FIRST
67
+ * item's `$map` context (item + index 0) over it — the same shape `renderMappedArrayInto` gives
68
+ * rendered items, so `$map/item` / `$map/index` refs preview against real data. Nested repeaters
69
+ * chain naturally (an inner `items` ref may read the outer `$map/item`).
70
+ */
71
+ export function bindRepeaterContext(
72
+ scope: Scope,
73
+ shadowDoc: unknown,
74
+ contextPath: (string | number)[] | null,
75
+ ): Scope {
76
+ if (!contextPath || contextPath.length === 0) {
77
+ return scope;
78
+ }
79
+ let node: unknown = shadowDoc;
80
+ let bound = scope;
81
+ for (const seg of contextPath) {
82
+ if (!node || typeof node !== "object") {
83
+ break;
84
+ }
85
+ const rec = node as Record<string, unknown>;
86
+ if (rec.$prototype === "Array" && seg === "map") {
87
+ // Entering the repeater's template — bind the first item's context before descending.
88
+ const itemsDef = rec.items;
89
+ const items: unknown =
90
+ itemsDef && typeof itemsDef === "object" && "$ref" in itemsDef
91
+ ? resolveRef((itemsDef as { $ref: string }).$ref, bound)
92
+ : itemsDef;
93
+ if (Array.isArray(items) && items.length > 0) {
94
+ let item: unknown;
95
+ try {
96
+ // Items resolved from the shadow doc (a literal array) must not be mutable through the
97
+ // Preview scope — clone; scope-resolved items are already clone data, so this is free.
98
+ item = structuredClone(items[0]);
99
+ } catch {
100
+ item = null;
101
+ }
102
+ const child = Object.create(bound) as Scope;
103
+ child.$map = { index: 0, item };
104
+ child["$map/item"] = item;
105
+ child["$map/index"] = 0;
106
+ bound = child;
107
+ }
108
+ }
109
+ node = rec[seg as keyof typeof rec];
110
+ }
111
+ return bound;
112
+ }
113
+
114
+ /**
115
+ * Evaluate each requested expression against a fresh clone of the live scope (with the repeater
116
+ * context for `contextPath` bound), reporting every sub-node's value through the engine's trace
117
+ * hook as pre-formatted display strings. Exceptions are guarded per expression into `error`.
118
+ */
119
+ export function evaluateLiveExprs(
120
+ exprs: { id: string; node: unknown }[],
121
+ defs: Scope,
122
+ shadowDoc: unknown,
123
+ contextPath: (string | number)[] | null,
124
+ ): EvalExprResult[] {
125
+ const rawState =
126
+ shadowDoc && typeof shadowDoc === "object"
127
+ ? ((shadowDoc as { state?: Record<string, unknown> }).state ?? null)
128
+ : null;
129
+ return exprs.map(({ id, node }) => {
130
+ const values = new Map<string, string>();
131
+ // A fresh scope per expression: a mutating operator writes into this clone only, and can never
132
+ // Leak into the next expression's evaluation (or the live canvas).
133
+ let scope: Scope;
134
+ try {
135
+ scope = bindRepeaterContext(cloneLiveScope(defs, rawState), shadowDoc, contextPath);
136
+ } catch (error) {
137
+ return { error: error instanceof Error ? error.message : String(error), id, values: [] };
138
+ }
139
+ try {
140
+ if (!node || typeof node !== "object" || !("operator" in node)) {
141
+ throw new Error("not an expression node");
142
+ }
143
+ evaluateExpression(node as ExpressionNode, scope, null, undefined, {
144
+ report: (path, value) => values.set(path.join("/"), formatPreviewValue(value)),
145
+ });
146
+ return { id, values: [...values.entries()] };
147
+ } catch (error) {
148
+ return {
149
+ error: error instanceof Error ? error.message : String(error),
150
+ id,
151
+ values: [...values.entries()],
152
+ };
153
+ }
154
+ });
155
+ }
@@ -12,6 +12,7 @@ import { canvasBaseOrigin } from "./canvas-origin";
12
12
  import { resolveCanvasDocument } from "./canvas-live-render";
13
13
  import {
14
14
  applyInlineCommit,
15
+ applyInlinePropCommit,
15
16
  applyInlineInsert,
16
17
  applyInlineSplit,
17
18
  } from "../editor/inline-edit-apply";
@@ -31,6 +32,7 @@ import type {
31
32
  ApplyFormatIntent,
32
33
  CanvasMode,
33
34
  DragSrcKind,
35
+ EvalExprResult,
34
36
  IframeToParent,
35
37
  InsertZone,
36
38
  NodeHit,
@@ -43,13 +45,15 @@ import type { IframeChannel } from "./iframe-channel";
43
45
  import type { OverlayLayer, OverlayPlacement } from "./iframe-overlay";
44
46
  import type { SlashCommand } from "../editor/inline-edit";
45
47
  import type { Tab } from "../tabs/tab";
46
- import type { JxMutableNode } from "@jxsuite/schema/types";
48
+ import type { JxExpressionNode, JxMutableNode } from "@jxsuite/schema/types";
47
49
 
48
50
  /** A rect in PARENT coordinates (overlay-local from {@link canvasRectToParent}, same field shape). */
49
51
  type ParentRect = OverlayPlacement;
50
52
 
51
53
  interface HostState {
52
54
  iframe: HTMLIFrameElement;
55
+ /** The `.canvas-panel-canvas` element hosting the iframe + overlay (the WeakMap key). */
56
+ canvasEl: HTMLElement;
53
57
  channel: IframeChannel<ParentToIframe, IframeToParent>;
54
58
  /**
55
59
  * The resolved canvasUrl this iframe was built with — so a host built early with the default URL
@@ -70,6 +74,8 @@ interface HostState {
70
74
  presenceMeta: Map<string, { color: string; label: string }>;
71
75
  /** Whether an inline-edit session is live in this host's iframe (drives the format toolbar). */
72
76
  editing: boolean;
77
+ /** The prop a live plain session edits (prop-bound text) — null for rich sessions/none. */
78
+ editingProp: string | null;
73
79
  /** The latest selection snapshot from this host's iframe (active tags + caret rect + link). */
74
80
  snapshot: SelectionSnapshot | null;
75
81
  /** Highest snapshot `seq` seen, so stale (re-ordered) snapshots are dropped. */
@@ -176,6 +182,72 @@ export function sawIframeDragOver(seq: number): boolean {
176
182
  );
177
183
  }
178
184
 
185
+ // ─── Live expression preview (M6) ───────────────────────────────────────────────
186
+ // The parent asks a live iframe to evaluate expression nodes against its LIVE resolved scope and
187
+ // Correlates the `evalResult` reply by reqId (the measure/geometry precedent), gen-gating it so a
188
+ // Reply computed against a superseded render never paints badges.
189
+
190
+ /** Monotonic eval request id (shared across hosts; stale replies carry an older/unknown id). */
191
+ let evalReqId = 0;
192
+
193
+ /** Pending eval resolvers keyed by reqId; a timeout or stale reply resolves null. */
194
+ const pendingEvals = new Map<number, (results: EvalExprResult[] | null) => void>();
195
+
196
+ /** How long (ms) the parent waits for an `evalResult` before falling back to the snapshot. */
197
+ export const EVAL_TIMEOUT_MS = 300;
198
+
199
+ /**
200
+ * Post an `evalExpr` request to the live, ready iframe host rendering `tabId`'s document and
201
+ * resolve with its results. Resolves `null` when no such host exists (caller falls back to the
202
+ * snapshot evaluator immediately), when no reply lands within `timeoutMs`, or when the reply's gen
203
+ * shows it was computed against a superseded render.
204
+ */
205
+ export function requestCanvasEval(
206
+ tabId: string | null,
207
+ exprs: { id: string; node: unknown }[],
208
+ contextPath: (string | number)[] | null,
209
+ timeoutMs: number = EVAL_TIMEOUT_MS,
210
+ ): Promise<EvalExprResult[] | null> {
211
+ let target: HostState | null = null;
212
+ for (const host of liveHosts) {
213
+ if (!host.iframe.isConnected) {
214
+ liveHosts.delete(host);
215
+ continue;
216
+ }
217
+ // Only a document host can answer (never a stylebook specimen catalog or a null-tab override
218
+ // Doc like git-diff), and only the one whose iframe DOM reflects this tab's document.
219
+ if (host.ready && !host.stylebook && tabId !== null && host.tabId === tabId) {
220
+ target = host;
221
+ break;
222
+ }
223
+ }
224
+ if (!target) {
225
+ return Promise.resolve(null);
226
+ }
227
+ evalReqId += 1;
228
+ const reqId = evalReqId;
229
+ // Expression nodes come off the reactive document — only plain values may cross postMessage.
230
+ // oxlint-disable-next-line unicorn/prefer-structured-clone
231
+ const wireExprs = JSON.parse(JSON.stringify(exprs)) as { id: string; node: JxExpressionNode }[];
232
+ target.channel.post({
233
+ contextPath: contextPath ? [...contextPath] : null,
234
+ exprs: wireExprs,
235
+ gen: target.lastRenderedGen,
236
+ kind: "evalExpr",
237
+ reqId,
238
+ });
239
+ return new Promise((resolve) => {
240
+ const timer = setTimeout(() => {
241
+ pendingEvals.delete(reqId);
242
+ resolve(null);
243
+ }, timeoutMs);
244
+ pendingEvals.set(reqId, (results) => {
245
+ clearTimeout(timer);
246
+ resolve(results);
247
+ });
248
+ });
249
+ }
250
+
179
251
  /** The host backing a given canvas element (or null), for the coordinator's host resolution. */
180
252
  export function hostForCanvas(canvasEl: HTMLElement): HostState | null {
181
253
  return hosts.get(canvasEl) ?? null;
@@ -263,6 +335,25 @@ export function hostDragGeometry(host: HostState): {
263
335
  return { rect, scale };
264
336
  }
265
337
 
338
+ /**
339
+ * Pin the `.canvas-panel-viewport` (the white "page" surface, the canvas element's parent) to the
340
+ * SCALED content height when edit-mode content zoom is active. A `transform: scale()` on the canvas
341
+ * element rescales its painted box but never its ancestor's auto-height, so without this write the
342
+ * viewport background would stay sized to the UN-zoomed iframe height. The scale is read from the
343
+ * canvas element's own inline transform (written only by `applyEditZoom`) — NOT from
344
+ * {@link hostDragGeometry}, whose empirical ratio also reflects design mode's panzoom-wrap
345
+ * transform, where the viewport must keep its unscaled auto height.
346
+ */
347
+ function syncEditZoomViewportHeight(state: HostState): void {
348
+ const viewport = state.canvasEl.parentElement;
349
+ if (!viewport) {
350
+ return;
351
+ }
352
+ const match = /scale\(([\d.]+)\)/.exec(state.canvasEl.style.transform);
353
+ const scale = match ? Number(match[1]!) : 1;
354
+ viewport.style.height = scale === 1 ? "" : `${state.iframe.offsetHeight * scale}px`;
355
+ }
356
+
266
357
  /** Post a parent→iframe drag message to `host`'s channel (the coordinator builds it purely). */
267
358
  export function postDragMessage(host: HostState, msg: ParentToIframe): void {
268
359
  if (!host.iframe.isConnected) {
@@ -662,9 +753,11 @@ function ensureHost(canvasEl: HTMLElement): HostState {
662
753
  });
663
754
 
664
755
  const state: HostState = {
756
+ canvasEl,
665
757
  canvasUrl,
666
758
  channel,
667
759
  editing: false,
760
+ editingProp: null,
668
761
  iframe,
669
762
  insertHideTimer: null,
670
763
  insertZone: null,
@@ -875,6 +968,18 @@ function handleMessage(state: HostState, msg: IframeToParent): void {
875
968
  }
876
969
  return;
877
970
  }
971
+ case "evalResult": {
972
+ // A live expression-preview reply (M6). Resolve the pending request by reqId (unknown ids —
973
+ // Already timed out or from a torn-down request — are dropped), gen-gating it so values
974
+ // Computed against a superseded render resolve null (the caller keeps the snapshot preview).
975
+ const resolve = pendingEvals.get(msg.reqId);
976
+ if (!resolve) {
977
+ return;
978
+ }
979
+ pendingEvals.delete(msg.reqId);
980
+ resolve(msg.gen === state.lastRenderedGen ? msg.results : null);
981
+ return;
982
+ }
878
983
  case "renderComplete": {
879
984
  // Adopt the tab identity this render was mounted with. host.tabId flips ONLY here — after any
880
985
  // Edit-session commit the iframe posted ahead of this ack on the FIFO channel — so a commit
@@ -922,6 +1027,7 @@ function handleMessage(state: HostState, msg: IframeToParent): void {
922
1027
  // Component leaves dead space below — pages keep the floor and stay tall via #jx-canvas-root).
923
1028
  state.iframe.style.height = `${msg.height}px`;
924
1029
  state.iframe.style.minHeight = msg.fragment ? "0px" : "480px";
1030
+ syncEditZoomViewportHeight(state);
925
1031
  return;
926
1032
  }
927
1033
  case "dragOver": {
@@ -1025,10 +1131,12 @@ function handleMessage(state: HostState, msg: IframeToParent): void {
1025
1131
  // Tear down any other host's editing state and make this the single active edit host.
1026
1132
  if (activeEditHost && activeEditHost !== state) {
1027
1133
  activeEditHost.editing = false;
1134
+ activeEditHost.editingProp = null;
1028
1135
  activeEditHost.snapshot = null;
1029
1136
  }
1030
1137
  activeEditHost = state;
1031
1138
  state.editing = true;
1139
+ state.editingProp = msg.prop ?? null;
1032
1140
  state.snapshot = null;
1033
1141
  state.lastSnapshotSeq = 0;
1034
1142
  toolbarRefresh?.();
@@ -1050,6 +1158,12 @@ function handleMessage(state: HostState, msg: IframeToParent): void {
1050
1158
  applyInlineCommit(hostTab(state), msg.path, msg.children, msg.textContent);
1051
1159
  return;
1052
1160
  }
1161
+ case "editCommitProp": {
1162
+ // A prop-bound plain session committed: persist into the instance's $props (same host-tab
1163
+ // Routing as editCommit; the unchanged-value no-op lives in the apply).
1164
+ applyInlinePropCommit(hostTab(state), msg.path, msg.prop, msg.value);
1165
+ return;
1166
+ }
1053
1167
  case "editSplit": {
1054
1168
  // The mutation lands now (surgical patch or escalated render); re-entry on the new paragraph
1055
1169
  // Is deferred until this host acks the DOM that contains it (see deferEnterEdit).
@@ -1109,12 +1223,13 @@ function handleMessage(state: HostState, msg: IframeToParent): void {
1109
1223
  return;
1110
1224
  }
1111
1225
  state.editing = false;
1226
+ state.editingProp = null;
1112
1227
  state.snapshot = null;
1113
1228
  if (activeEditHost === state) {
1114
1229
  activeEditHost = null;
1115
1230
  }
1116
1231
  toolbarRefresh?.();
1117
- return;
1232
+ break;
1118
1233
  }
1119
1234
  default: {
1120
1235
  break;
@@ -1381,11 +1496,19 @@ export function getActiveEditHost(): HostState | null {
1381
1496
  }
1382
1497
 
1383
1498
  /** The current edit session's editing flag + latest selection snapshot, for the parent toolbar. */
1384
- export function getEditSnapshot(): { editing: boolean; snapshot: SelectionSnapshot | null } {
1499
+ export function getEditSnapshot(): {
1500
+ editing: boolean;
1501
+ editingProp: string | null;
1502
+ snapshot: SelectionSnapshot | null;
1503
+ } {
1385
1504
  if (!activeEditHost) {
1386
- return { editing: false, snapshot: null };
1505
+ return { editing: false, editingProp: null, snapshot: null };
1387
1506
  }
1388
- return { editing: activeEditHost.editing, snapshot: activeEditHost.snapshot };
1507
+ return {
1508
+ editing: activeEditHost.editing,
1509
+ editingProp: activeEditHost.editingProp,
1510
+ snapshot: activeEditHost.snapshot,
1511
+ };
1389
1512
  }
1390
1513
 
1391
1514
  /** Post an `applyFormat` intent to the active edit host's iframe (no-op when none/not ready). */
@@ -1423,7 +1546,10 @@ function hostForActivePanel(): HostState | null {
1423
1546
  * UNSCALED iframe-viewport px (D-2: the overlay draws them inside the scaled panzoom-wrap, so the
1424
1547
  * browser applies the zoom there); the fixed bar gets no such free ride, so scale by the live
1425
1548
  * empirical zoom ({@link hostDragGeometry}) and add the iframe's on-screen offset, whose GBCR
1426
- * already bakes in pan + zoom + ancestor scroll. Edit mode has no transform scale is 1.
1549
+ * already bakes in pan + zoom + ancestor scroll. The empirical ratio covers BOTH scale sources:
1550
+ * design mode's panzoom-wrap transform and edit mode's content-zoom counter-scale (where it
1551
+ * evaluates to exactly `editZoom` — the iframe's layout width is `renderWidth / editZoom` while its
1552
+ * rendered width is `renderWidth`).
1427
1553
  */
1428
1554
  export function getEditBarAnchorRect(): ParentRect | null {
1429
1555
  // The format toolbar follows the live caret/selection snapshot of the active edit session; the
@@ -33,6 +33,7 @@ import { isTagActiveInSelection, toggleInlineFormat } from "../editor/inline-for
33
33
  import { applyLink, insertTemplateToken, linkStateForSelection } from "../editor/inline-link";
34
34
  import { restoreTemplateExpressions } from "../utils/edit-display";
35
35
  import { rectOfRange } from "../utils/geometry";
36
+ import { getNodeAtPath } from "../state";
36
37
  import { parseJxPath, serializeJxPath } from "./path-mapping";
37
38
  import type { IframeChannel } from "./iframe-channel";
38
39
  import type {
@@ -43,6 +44,7 @@ import type {
43
44
  SerializableRect,
44
45
  } from "./iframe-protocol";
45
46
  import type { JxPath } from "../state";
47
+ import type { JxMutableNode } from "@jxsuite/schema/types";
46
48
 
47
49
  /** Toolbar command → inline tag (mirrors the parent's old `cmdToTag`, now iframe-side). */
48
50
  const CMD_TO_TAG: Record<string, string> = {
@@ -74,6 +76,43 @@ function findEditableTarget(target: EventTarget | null): { el: HTMLElement; path
74
76
  return null;
75
77
  }
76
78
 
79
+ /**
80
+ * Walk up from an event target to the nearest element carrying `data-jx-bound-prop` (a component-
81
+ * internal element whose text is an invertible prop binding — stamped by the runtime, see
82
+ * setStampPropBindings). Component internals are unstamped, so hitting a `data-jx-path` element
83
+ * first means the target sits in page-level DOM (or slotted content) — not a prop-bound target.
84
+ */
85
+ function findPropBoundTarget(target: EventTarget | null): { el: HTMLElement; prop: string } | null {
86
+ let el = target instanceof Element ? target : null;
87
+ while (el) {
88
+ if (el instanceof HTMLElement) {
89
+ if (el.dataset.jxBoundProp) {
90
+ return { el, prop: el.dataset.jxBoundProp };
91
+ }
92
+ if (el.dataset.jxPath) {
93
+ return null;
94
+ }
95
+ }
96
+ el = el.parentElement;
97
+ }
98
+ return null;
99
+ }
100
+
101
+ /**
102
+ * The instance that owns a prop-bound element: its nearest custom-element ancestor (that element's
103
+ * connectedCallback rendered the marker with its state, so the walk can never skip the owner).
104
+ */
105
+ function ownerInstanceOf(el: HTMLElement): HTMLElement | null {
106
+ let cur = el.parentElement;
107
+ while (cur) {
108
+ if (cur.tagName.includes("-")) {
109
+ return cur;
110
+ }
111
+ cur = cur.parentElement;
112
+ }
113
+ return null;
114
+ }
115
+
77
116
  /** Locate the rendered element for a document path via its stamped `data-jx-path`. */
78
117
  function elementForPath(container: HTMLElement, path: JxPath): HTMLElement | null {
79
118
  const serialized = serializeJxPath(path);
@@ -95,7 +134,7 @@ function toSerializableRect(rect: DOMRect): SerializableRect {
95
134
  export function startIframeInlineEdit(
96
135
  channel: IframeChannel<IframeToParent, ParentToIframe>,
97
136
  container: HTMLElement,
98
- opts?: { getMode?: () => string },
137
+ opts?: { getMode?: () => string; getShadowDoc?: () => JxMutableNode | null },
99
138
  ): () => void {
100
139
  const doc = container.ownerDocument;
101
140
 
@@ -251,6 +290,56 @@ export function startIframeInlineEdit(
251
290
  onSelectionChange();
252
291
  };
253
292
 
293
+ /**
294
+ * Whether the instance's RAW `$props[prop]` value (from the pre-edit-display shadow doc) is
295
+ * plain-text editable. Template-valued (`"${...}"`) and `$ref`-valued props render display sugar,
296
+ * not the value — committing typed text would silently destroy the binding, so they're blocked.
297
+ * An absent getShadowDoc is permissive (tests, same contract as getMode).
298
+ */
299
+ const propEditableAt = (hostPath: JxPath, prop: string): boolean => {
300
+ const shadowDoc = opts?.getShadowDoc?.();
301
+ if (!shadowDoc) {
302
+ return true;
303
+ }
304
+ const node = getNodeAtPath(shadowDoc, hostPath) as JxMutableNode | undefined;
305
+ const raw = (node?.$props as Record<string, unknown> | undefined)?.[prop];
306
+ if (raw == null) {
307
+ return true; // Unset — editing ADDS the prop, overriding the definition default.
308
+ }
309
+ if (typeof raw === "object") {
310
+ return false;
311
+ }
312
+ return !(typeof raw === "string" && raw.includes("${"));
313
+ };
314
+
315
+ /**
316
+ * Enter a plain (plaintext-only) session on a prop-bound component-internal element. The session
317
+ * path is the INSTANCE path — the marker element has no path of its own, and an external `$props`
318
+ * patch at the host path must disturb (commit + end) this session before detaching its element.
319
+ */
320
+ const enterPropEditAt = (el: HTMLElement, hostPath: JxPath, prop: string) => {
321
+ channel.post({ kind: "editStart", path: hostPath, prop });
322
+ suspendBlurClose();
323
+ startEditing(
324
+ el,
325
+ hostPath,
326
+ {
327
+ onCommit: (p, _children, textContent) =>
328
+ channel.post({ kind: "editCommitProp", path: p, prop, value: textContent ?? "" }),
329
+ onEnd: () => {
330
+ resumeBlurClose();
331
+ clearHighlight();
332
+ lastNonEmptyRange = null;
333
+ channel.post({ kind: "editEnd" });
334
+ },
335
+ // Prop values are single plain strings — no split, no slash-insert.
336
+ onInsert: () => {},
337
+ onSplit: () => {},
338
+ },
339
+ { plainText: true },
340
+ );
341
+ };
342
+
254
343
  /** Apply a format/link/insert intent to the iframe's cached selection range. */
255
344
  const applyFormatIntent = (intent: ApplyFormatIntent) => {
256
345
  const el = getActiveElement();
@@ -290,6 +379,23 @@ export function startIframeInlineEdit(
290
379
  if (!editingAllowed()) {
291
380
  return;
292
381
  }
382
+ // Prop-bound targets win: they sit in unstamped component internals, deeper than any editable
383
+ // Page block, and once a marker is hit the event must NOT fall through to rich editing (an
384
+ // Instance nested inside a page-level editable would otherwise rich-edit that whole ancestor).
385
+ const propHit = findPropBoundTarget(e.target);
386
+ if (propHit) {
387
+ const host = ownerInstanceOf(propHit.el);
388
+ const hostPathRaw = host?.dataset.jxPath;
389
+ if (host && hostPathRaw) {
390
+ const hostPath = parseJxPath(hostPathRaw);
391
+ if (propEditableAt(hostPath, propHit.prop)) {
392
+ enterPropEditAt(propHit.el, hostPath, propHit.prop);
393
+ }
394
+ }
395
+ // A path-less host is itself internal to another definition — its $props live in a document
396
+ // Not open in this tab, so there is no write-back target: blocked.
397
+ return;
398
+ }
293
399
  const hit = findEditableTarget(e.target);
294
400
  if (hit) {
295
401
  enterEditAt(hit.el, hit.path);