Skip to main content
EmbedEditor renders the editor in a React app.

Props

EmbedEditor takes every prop of EmbedEditorProps. Every prop is optional and applies live unless it says otherwise.

Props

Every prop, its type and its default.

EditState

What state takes and onProcess hands back.

Attributes

data-* and aria-* attributes go to the component’s host element, which helps with tests and analytics. Anything else that isn’t a prop is invalid, and the editor reports it as INVALID_PROPS.

Ref

EmbedEditor forwards its ref to the editor’s handle, EmbedEditorHandle: its commands, reads and events. The handle is made once, and stays the same through every new set of props. Once the component unmounts, its commands reject with NOT_AVAILABLE.
See Commands.

Behavior

  • Size. In the default layout='inline', the editor fills the box its parent gives it, so give the parent a height, and at least 320 px of width. With layout='page', it covers the whole viewport.
  • Read at open. src and state are read when the editor opens. Once an image is on screen, give the editor a new key to open another one.
  • Stable source. Memoize src. A new object on every render, such as URL.createObjectURL(file) written inline, restarts the load each time the host renders while the image loads.
  • Next.js. The entry starts with 'use client', so a server component can render EmbedEditor directly. Callbacks such as onProcess need a client component around it.

Example

PhotoEditor.tsx