selection.registerOnChange
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
RequiredOptions for configuring the content selection callback.
scope
Scope
RequiredThe type of content that triggers a selection change event.
Available values:
"plaintext"
"image"
"video"
"richtext"
onChange
function
RequiredThe callback to run when the selected content changes.
Parameters
event
SelectionEvent<Scope>
RequiredInformation about the selection change event.
scope
Scope
RequiredThe type of content that's selected.
Available values:
"plaintext"
"image"
"video"
"richtext"
count
number
RequiredThe number of selected elements.
read
function
RequiredReturns 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