Skip to main content

Editable Syntax

Live Editor preserves source first. The property panel only offers an edit when it can identify the exact source span to replace without rebuilding or evaluating unrelated expressions. Unsupported syntax remains valid preview code and stays editable in Live.Editor; a rejected panel operation returns the original source unchanged.

Support matrix​

“Value” means changing one scalar or object property. Move, duplicate, and delete describe array items or JSX children; they do not apply to a scalar attribute.

Authored syntaxReadValue editMoveDuplicateDeleteFallback
String, number, boolean, and null literalsYesYes————
Object/array containing only supported literal valuesYesYesYes when it is a dense Items arrayYes when it is a dense Items arrayYes when it is a dense Items arrayCode editor for unsupported nested expressions
Object whose keys hold functions or other expressions (no spread, computed key or method)Yes, key by keyLiteral keys as values, function keys as source; other keys read-only———Code editor for the read-only keys
Static JSX element or fragment in a children bindingYesNested bindings onlyYesYes when static IDs can be regenerated safelyYes—
Conditional, logical, call, or .map() expression in childrenPreserved, not modeled as a childNo direct value controlNo direct controlNo direct controlNo direct controlCode editor
Dense array item containing an identifier, call, template, function, or JSXThe item source is preserved; unsupported values are shown as code-only (a function is edited as source, see below)Supported literal/property spans onlyYes, as raw sourceYes, unless identity is ambiguousYesCode editor for the value itself
Sparse array (holes)Visible expressions only; holes remain in sourceSupported visible values onlyNoNoNoCode editor; structural controls are disabled
Array spread (...items)Static siblings are visible; spread remains in sourceSupported static siblings onlyNoNoNoCode editor; structural controls are disabled
Parenthesized top-level array itemYesSupported inner values onlyNoNoNoCode editor
Function expression (() => {}, function () {}) or, with type: 'function', a reference (handleClick, actions.open) as an attribute value, an object key, an array item's property, or an array itemYes, as sourceYes, as source; a call is refused————
Variable or function call used instead of an array literalNo list modelNoNoNoNoCode editor
Variable, call, spread, hole, or computed property inside a partially modeled objectRaw source onlyNo; rebuilding could drop syntax———The value control is replaced with code-editor guidance
Dynamic or ambiguous key / data-idYesOther supported values remain editableYesNoYesMake the identity static before copying

The copy column is about children and array items. Copying a whole section works with a dynamic data-id inside it: the copy gets new values for the string data-ids, in either quote style, and keeps an expression such as data-id={`img-${index}`} as written. Panel edits only find elements by a string data-id, so the two sections can share it.

Array value edits and structure edits deliberately have different boundaries. For example, changing label in [, ...rows, { label: 'A' }] replaces only 'A'; the hole and spread remain unchanged. Moving or deleting that item is disabled because the visible panel indices do not represent every runtime array entry.

useDndItems() exposes this decision as canEditStructure. It is computed with the same dense-array check used again by every mutation helper, so custom panels can disable controls up front without weakening commit-time validation. Likewise, PanelBinding.canEditValue === false means a partial value editor would be lossy. The built-in Field replaces that control with the exact raw expression and code-editor guidance; custom panels should do the same. The AST mutation layer repeats the same literal-safety check and returns an unsupported-syntax failure if a stale or custom caller still attempts it.

Children and expressions​

A children binding models static JSX elements and fragments. Text, comments, and expressions between those nodes are source gaps: moving static children keeps those gaps in place, and copying a subtree keeps its inner expressions verbatim. An expression-only or otherwise unmodeled fragment is never reported as a successful structural edit. The AST update returns success: false, the original code remains intact, and the user can continue in the code editor.

Children commands also carry signatures of the extracted nodes. The mutation layer compares them with the latest source before writing, so a command created before an external edit or undo cannot overwrite newer code.

Why data-binding remains the contract​

data-binding keeps edit metadata beside the JSX source span it describes. That gives the editor a stable property name, value kind, validation hints, and optional nested render map without executing application code. It also lets the AST layer validate the current source immediately before a patch.

An external schema can be useful for forms or domain models, but it does not by itself identify which JSX span owns a value, how static data-id identities should be copied, or whether the current expression can be changed losslessly. Live Editor therefore does not replace data-binding with an external schema. A custom panel may use external metadata for presentation while still committing through the PanelBinding callbacks and the same source-preserving rules.

See Custom Palette and Panel for the public panel hooks and Editor Mode for the code-editor fallback.