Skip to content

Commit f41cfef

Browse files
SITES-26787: Document the Event Listener in Universal Editor (#109)
* SITES-26787: Document the Event Listener in Universal Editor * SITES-28468: Documentation for navigateTo API * SITES-28468: Documentation for navigateTo API
1 parent bc9b51e commit f41cfef

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

gatsby-config.js

+4
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ module.exports = {
306306
{
307307
title: "Retrieving Data from the Universal Editor",
308308
path: "/services/aem-universal-editor/api/data/"
309+
},
310+
{
311+
title: "Triggering Universal Editor actions from the extension",
312+
path: "/services/aem-universal-editor/api/actions/"
309313
}
310314
]
311315
},
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Universal Editor Extensibility
3+
description: Actions that can be performed from extensions
4+
contributors:
5+
- https://github.com/AdobeDocs/uix
6+
---
7+
8+
# Actions that can be performed from extensions
9+
10+
Understand the fundamentals required to develop an extension for the Universal Editor.
11+
12+
## List of actions:
13+
14+
### Navigate To
15+
16+
Universal Editor provides `navigateTo` action, enables switching the URL to the editor content page from the extension.
17+
To execute this action, an extension developer can call the navigateTo method on connection.host.editorActions and provide the new content URL as a parameter.
18+
19+
#### API
20+
Method: `navigateTo`
21+
22+
| Param | Type | Description |
23+
|------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
24+
| href | `string` | Path to the content page |
25+
26+
27+
Example:
28+
`guestConnection.host.editorActions.navigateTo(href: string);`
29+
30+
### Select Editables
31+
The `selectEditables` action allows an extension developer to select an editable block for editing. An editable block refers to the portion of content that can be modified within the Universal Editor.
32+
33+
Editable block example:
34+
![editable-block-example.png](editable-block-example.png)
35+
36+
The extension developer can retrieve the list of all editable blocks from the [editor state](https://developer.adobe.com/uix/docs/services/aem-universal-editor/api/data/#editor-state). This can be achieved by using `await guestConnection.host.editorState.get()` api.
37+
38+
#### API
39+
40+
Method: `selectEditables`
41+
42+
| Param | Type | Description |
43+
|------------|---------------------|---------------------------------|
44+
| editables | `Array` | The list of Editables to select |
45+
46+
Example: `guestConnection.host.editorActions.selectEditables(editables: Editable[]);`
47+
48+
### Update
49+
50+
The update action enables an extension developer to modify the data within a specific editable block.
51+
52+
At present, only a single field can be updated per call, and only the replace operation is supported. If the provided patch does not adhere to these rules, an error will be triggered.
53+
54+
55+
#### API
56+
57+
Method: `update`
58+
59+
| Param | Type | Description |
60+
|------------|----------|------------------------------------------------------|
61+
| target | `Object` | The editable to update |
62+
| patch | `Arrap` | The path to the specific edirable property to update |
63+
64+
Example:
65+
`guestConnection.host.editorActions.update({ target: Target, patch: JSONPatch });`
66+
67+
Example for updating a field with the name title:
68+
`update({ target: { editable }, patch: [{ op: "replace", path: "/title", value: "New title" }] })`
69+
70+

src/pages/services/aem-universal-editor/api/events/index.md

+30
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,33 @@ You can send events to the remote application using the `triggerEvent` method.
3737
| eventName | `string` | ✔️ | Name of the event |
3838
| selector | `string` | ✔️ | A valid CSS selector string|
3939
| payload | Serializable `object`| An object that, in addition of the properties defined in the Event Constructor |
40+
41+
42+
### Subscribing to events:
43+
To listen to events sent by the Universal Editor, you can subscribe to them using the next declaration:
44+
45+
```js
46+
function ExtensionRegistration() {
47+
const init = async () => {
48+
const guestConnection = await register({
49+
id: extensionId,
50+
methods: {
51+
events: {
52+
listen: (eventName, data) => {
53+
console.log(`Extension registered to listen to event: ${eventName}. The event data: ${JSON.stringify(data)}`);
54+
}
55+
},
56+
}
57+
});
58+
59+
};
60+
init().catch((error) => console.error(error));
61+
62+
return <Text>IFrame for integration with Host (AEM)...</Text>
63+
}
64+
65+
```
66+
67+
The extension has the capability to subscribe to a wide range of events offered by the Universal Editor, enabling seamless integration and enhanced functionality.
68+
69+
For a comprehensive list of all available events and the corresponding response interfaces, please refer to the [Universal Editor Events documentation](https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developing/universal-editor/events).

0 commit comments

Comments
 (0)