mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 01:05:53 -04:00
More Riot -> Element
This commit is contained in:
parent
76903e8c8c
commit
db2298172f
@ -1,12 +1,12 @@
|
||||
# Riot's Widget API
|
||||
# Element's Widget API
|
||||
|
||||
Widgets and Riot communicate using cross-origin messages in a defined format (described in this document). Widgets have access to the entire Scalar Client API, but generally do not need any of the endpoints there. Riot provides additional APIs available to particular widgets for which the integrations manager can not access. The full source for the widget messaging layer in Riot can be seen [here](https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/WidgetMessaging.js). The API is restricted to ensure rogue widgets cannot take over the Riot instance.
|
||||
Widgets and Element communicate using cross-origin messages in a defined format (described in this document). Widgets have access to the entire Scalar Client API, but generally do not need any of the endpoints there. Element provides additional APIs available to particular widgets for which the integrations manager can not access. The full source for the widget messaging layer in Element can be seen [here](https://github.com/matrix-org/matrix-react-sdk/blob/develop/src/WidgetMessaging.js). The API is restricted to ensure rogue widgets cannot take over the Element instance.
|
||||
|
||||
**Note**: This is largely out of date and better documented in the Matrix spec nowadays. See https://github.com/matrix-org/matrix-doc/issues/1236 for more information.
|
||||
|
||||
## Setting up communications
|
||||
|
||||
Riot will automatically open a channel for receiving messages. The widget needs to do the same so it can speak to Riot. Here's some sample JavaScript that will do this for us:
|
||||
Element will automatically open a channel for receiving messages. The widget needs to do the same so it can speak to Element. Here's some sample JavaScript that will do this for us:
|
||||
|
||||
```
|
||||
window.addEventListener("message", function(event) {
|
||||
@ -18,7 +18,7 @@ window.addEventListener("message", function(event) {
|
||||
|
||||
function sendMessage(action, widgetId, otherFields) {
|
||||
if (!otherFields) otherFields = {};
|
||||
|
||||
|
||||
var request = otherFields;
|
||||
request["widgetId"] = widgetId;
|
||||
request["action"] = action;
|
||||
@ -64,7 +64,7 @@ An error response will always have the following structure under `response`:
|
||||
|
||||
### Versions / Changelog
|
||||
|
||||
All versions use a semantic versioning scheme. The actions recorded in this document include which version they were implemented in. The changelog here is for convience.
|
||||
All versions use a semantic versioning scheme. The actions recorded in this document include which version they were implemented in. The changelog here is for convience.
|
||||
|
||||
**v0.0.1**
|
||||
* Initial release
|
||||
|
Loading…
Reference in New Issue
Block a user