Skip to content

Introduce contentRole on blocks - #44

Merged
janglad merged 1 commit into
mainfrom
fix/web-4017-composer-placeholder-not-there-until-you-tab-into-body
Sep 16, 2026
Merged

janglad merged 1 commit into
mainfrom
fix/web-4017-composer-placeholder-not-there-until-you-tab-into-body

Conversation

@janglad

@janglad janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member

Pen decides whether to show the document placeholder based on whether the document is
empty, which previously worked by counting root blocks. That is too limiting: some blocks
(an email signature) are chrome the host puts in the document, and
should not count toward the document having content. With one present, the placeholder
never painted — and since the same boolean decides where a click below the blocks lands,
the caret went into the chrome too.e

Pen cannot infer this from what schemas already declare: divider carries the same
fieldEditor: "none", selectionRole: "structural", and flowCapability: "flow-structural"
as a signature block, and [empty paragraph, divider] is a document with content in it.

Fixed by introducing authoring.contentRole on the block schema, letting a host say
whether a block type counts toward a filled document. Defaults to "content", so nothing
changes for a host that does not set it. documentState.isEmpty and data-empty are
untouched. Specified as RI8 in spec/rules/dom.md (document placeholder visibility had no
rule before), evidence in ri8DocumentPlaceholder.test.ts, patch changeset.


Note

Medium Risk
Touches placeholder eligibility, pointer click-below caret placement, and a new public schema field across DOM and framework bindings; behavior change is opt-in via explicit contentRole: "chrome".

Overview
Adds authoring.contentRole ("content" | "chrome") so hosts can mark furniture (e.g. signatures) that should not count as user-facing document content. getBlockContentRole in @input/pen-core reads it and defaults to "content".

Document empty-state handling shifts from counting root blocks to naming a target block: getDocumentPlaceholderTargetBlockId (@input/pen-dom) replaces computeDocumentPlaceholderVisible. Eligibility ignores chrome, requires exactly one empty inline editable content block, and returns that block’s id (or null). resolveInlinePlaceholderVisibility now takes isDocumentPlaceholderTarget instead of isFirstBlock + isDocumentEmpty.

React and Vue paint emptyPlaceholder on the target block (not blockOrder[0]). Click-below-block gestures activate the target via the same helper. documentState.isEmpty / data-empty are unchanged. RI8 is documented; patch changeset across pen-types, core, dom, react, and vue.

Reviewed by Cursor Bugbot for commit 4ea7542. Bugbot is set up for automated code reviews on this repo. Configure here.

This update introduces a new mechanism for determining document placeholder eligibility by counting content blocks instead of root blocks. A block schema can now specify `authoring.contentRole: "chrome"` for elements like email signatures, which will not suppress the empty-document placeholder. The `getBlockContentRole` function has been added to handle this logic, defaulting to `"content"` for existing hosts. Additionally, the `getDocumentPlaceholderTargetBlockId` function identifies the appropriate block for the placeholder, ensuring that the hint is displayed correctly in documents that start with chrome elements.

Changes include:
- New `getBlockContentRole` function in `@input/pen-core`.
- Updated placeholder visibility logic in React and Vue bindings.
- Tests added to verify the new behavior regarding document placeholders.

This change enhances the user experience by providing clearer visual cues in the editor.
@janglad

janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor

cursor Bot commented Sep 16, 2026

Copy link
Copy Markdown

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

@janglad

janglad commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4ea7542. Configure here.

@janglad
janglad merged commit ef13945 into main Sep 16, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants