Content modelingMarks and inline editing

Marks and inline editing

Marks are the attributes a section spreads on the elements that render its fields. They tell the canvas which field an editor clicked, so text edits in place and everything else opens in the inspector.

View as Markdown

What a mark is

smoodly.marks(heroSchema) returns typed helpers for one schema. m.field("heading") is an object with one data- attribute naming the field; spread it on the element that renders the heading. The section root, rendered by Smoodly's section wrapper, carries the section's own id. From a click the canvas walks up from the marked element to that root and knows which field of which section was meant.

Outside the admin the marks are plain data attributes and do nothing. The typed helpers exist so a renamed field is a type error rather than a dead click.

Marking a field

Put the mark on the element that shows the value as stored:

src/sections/hero.astro
---
// …
const m = smoodly.marks(heroSchema);
---
// …
      {kicker && <p class="kicker" {...m.field("kicker")}>{kicker}</p>}
      <h1 class="hero__heading" {...m.field("heading")}>{heading}</h1>
      <p class="hero__text" {...m.field("text")}>{text}</p>
      // …
    {image && <Image image={image} class="hero__image" sizes="(min-width: 900px) 40vw, 100vw" priority {...m.field("image")} />}

Hovering a marked element outlines it in the canvas. What a click does depends on the field:

FieldOn click
f.text()Edits in place. The element becomes editable, and each keystroke updates the draft. Escape or a click elsewhere ends it.
f.richtext()Edits in place, with the richtext toolbar floating above the selection.
Everything elseOpens the inspector on that field: the media picker for an image, the repeater for a list, the pills for a choice.

In-place text editing needs an element with nothing but text inside. A mark on an element with child elements, such as a paragraph holding a link, falls through to the inspector. So does a mark on an element that shows the value transformed, in effect: the canvas would write the stored value over the formatted one. Leave a formatted date unmarked, or mark its container.

The image component passes data attributes to its wrapper, so a mark on it selects the image box.

Lists and objects

A list item or an object field is a scope of its own. m.item("buttons", i) returns a helper for one item: spread its attrs on the item's root element and use its field() for the fields inside. The starter's Hero buttons put both on the same anchor:

src/sections/hero.astro
          {buttons.map((b, i) => {
            const button = m.item("buttons", i);
            return <a class={i === 0 ? "button" : "button button--outline"} href={safeHref(b.href)} {...button.attrs} {...button.field("label")}>{b.label}</a>;
          })}

m.object("link") works the same way for an object field. A scope nests: m.item("points", i).object("author") reaches a field inside an object inside a list item.

A mark for the whole list, such as m.field("people") on the grid that renders a reference list, opens the list in the inspector.

What the canvas checks

A click on a mark that names a field the schema does not have logs a warning in development, naming the section and the path, and then does nothing. Check the data-smd-field and data-smd-item attributes it names.

Globals in the canvas, such as the starter's header, footer and quote, are marked the same way. Selecting one shows its own fields in the inspector, tagged global, with its own Publish, because publishing a footer to every page is a deliberate click. Globals has the details.

Next, the Fields group lists every field type and what editors see for each.

Edit this page on GitHubLast updated 6 Oct 2026