Registers a callback that runs when the specified type of content is selected.
This callback fires immediately if content is already selected when the callback is registered.
Parameters
opts
object
Options for configuring the content selection callback.
Properties of opts
scope
Scope
The type of content that triggers a selection change event.
The available options include:
"plaintext"
"image"
"video"
"richtext"
onChange
function
The callback to run when the selected content changes.
Parameters
event
SelectionEvent<Scope>
Information about the selection change event.
Properties of event
scope
Scope
The type of content that's selected.
The available options include:
"plaintext"
"image"
"video"
"richtext"
count
number
The number of selected elements.
read
function
Returns a snapshot of the content in the user's selection.
The snapshot is known as the draft.
Returns
A snapshot of content from a user's design. This is a Promise
that resolves with the following object:
contents
T[]
The individual content items that exist within the snapshot.
Any changes made to this array won't be reflected in the user's design until the save
method is called.
save
function
Saves changes made to the content items in the contents
array.
Once this method is called:
- Any changes the app has made to to the content will be reflected in the user's design.
- Any changes the user has made to the content since the snapshot was created may be overwritten.
- Only properties that are different from the original state will be written to the design.
Returns
Promise<void>
Returns
void
Returns
() => void