Extend this class to show a custom modal to the user, whose contents are displayed in a sandboxed
iframe controlled by your extension.
To pass a message to a script running in the modal, call sendMessage. The data you pass in will be
sent to the iframe with window.postMessage.
To pass messages back from the modal to this class, call parent.postMessage from within the iframe.
The data sent will be passed along to the messageFromFrame implementation on your Modal class.
Extends
Constructors
new Modal()
new Modal(client, config): Modal
Parameters
Parameter | Type |
---|---|
client | EditorClient |
config | ModalConfig |
Returns
Overrides
Properties
client
protected readonly client: EditorClient;
Inherited from
framePosition
protected framePosition: object;
The location of this frame within the top-level browser window. This is always updated immediately before
messageFromFrame
is called.
h
h: number = 1;
w
w: number = 1;
x
x: number = 0;
y
y: number = 0;
Inherited from
loaded
protected loaded: boolean = false;
True after the iframe has fired an onload event (not all scripts are necessarily finished executing)
Inherited from
messageActionName
protected messageActionName: string;
Inherited from
Methods
frameClosed()
protected frameClosed(): void
Called when the iframe has been removed from the DOM
Returns
void
Overrides
frameLoaded()
protected frameLoaded(): void
Called when the iframe has been constructed, its srcdoc set, and the window loaded event has fired
Returns
void
Inherited from
hide()
hide(): void
If this modal is currently visible, close it, destroying the iframe.
Returns
void
hookMessages()
protected hookMessages(): void
Subclasses must call hookMessages some time before the UI is displayed. A Modal
will call this when the open() method is called, where a Panel will need to do
this in the constructor to watch for the user opening the panel.
Returns
void
Inherited from
messageFromFrame()
protected messageFromFrame(message): void
Receives messages sent from the iframe via parent.postMessage(, '*')
Parameters
Parameter | Type | Description |
---|---|---|
message | any | data sent from the iframe |
Returns
void
Inherited from
sendMessage()
sendMessage(data): Promise<void>
Send a message to this UI component's iframe via window.postMessage.
Parameters
Parameter | Type | Description |
---|---|---|
data | JsonSerializable | Data to send to the iframe |
Returns
Promise
<void
>
Inherited from
show()
show(): Promise<void>
Returns
Promise
<void
>
unhookMessages()
protected unhookMessages(): void
Subclasses must call unhookMessages to allow them to be garbage collected.
Returns
void