Skip to content

Allow trusted content-editor panels to read and patch the live draft #2866

Description

@diogoascarneiro

Description

In EmDash 0.35, a trusted plugin can add a React panel to the content editor, but the panel receives only the last saved entry, collection, and locale:

interface ContentEditorPanelContext {
  collection: string;
  entry: ContentItem;
  locale?: string;
}

It cannot read the editor's current form values or return changes to them. A field widget is not a substitute because it can access only its own field.

This blocks editor tools that need several current fields. For example, a translation plugin should be able to read eligible text fields from an existing target-locale draft, send them to its provider, and place the result back into the form for review.

Expected behavior:

  • A trusted content-editor panel can read the latest draft data and field definitions on demand.
  • The panel can request a patch to known editable fields without directly saving the entry.
  • EmDash validates the patch against the editor's collection schema, updates the visible form, and marks it dirty.
  • The patch includes the draft revision it was based on and is rejected if the form changed while asynchronous work was running.
  • Normal autosave, explicit save, server-side permissions, schema validation, and revision checks remain unchanged.
  • The API does not require panels to subscribe to every keystroke or cause every panel to rerender while typing.

An on-demand shape such as getDraft() plus patchDraft(patch, { expectedRevision }) would be sufficient. The exact API can
follow the existing panel conventions.

This is a narrower follow-up to #2227, which motivated full-document editor context. The panel shipped in 0.34 provides saved-entry context but not live draft access or write-back.

Documentation:

Steps to reproduce

  1. Configure EmDash i18n with at least two locales and create a collection with multiple text fields.
  2. Add a trusted plugin with a contentEditorPanels export.
  3. Use EmDash's existing Translate action to create and open a target-locale draft.
  4. Change one or more fields without saving.
  5. Inspect the panel context and try to update those fields from the panel.
  6. Observe that the panel sees only the last saved entry and has no supported API for reading or patching the live form.

Environment

  • emdash version: 0.35.0 (3c99225d80a38a9751ed0e4b56e3924e40308e70)
  • Node.js version: 22.22.3
  • Runtime: Node.js and Cloudflare Workers
  • OS: macOS; the missing admin API is platform-independent

Screenshots

Not applicable

Logs / error output

Not applicable. This is a missing plugin API rather than a runtime error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions