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.
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. Withlayout='page', it covers the whole viewport. - Read at open.
srcandstateare read when the editor opens. Once an image is on screen, give the editor a newkeyto open another one. - Stable source. Memoize
src. A new object on every render, such asURL.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 renderEmbedEditordirectly. Callbacks such asonProcessneed a client component around it.
Example
PhotoEditor.tsx