@@ -191,6 +191,122 @@ window.lumapps.customize(({ targets, components, render, placement, constants })
191
191
});
192
192
```
193
193
194
+ ## Add new button on the rich text editor toolbar (widget RTE, article or event)
195
+
196
+ ![ Use case wrex button] ( ./assets/use-case-wrex-toolbar-item.png " Use case wrex button ")
197
+
198
+ In this use case, you'll probably want to have a new button on the rich text editor toolbar allowing you to insert specific elements from an external provider.
199
+
200
+ ``` js
201
+ window .lumapps .customize (({
202
+ targets,
203
+ components,
204
+ render,
205
+ placement
206
+ }) => {
207
+ const { DropdownSection , DropdownItem } = components;
208
+
209
+ const onVideoButtonClick = async (context ) => {
210
+ // It will open a dialog with the specified html in it
211
+ context .setWrexElementConfiguration ({
212
+ content: ' <p>My HTML for my iframe configuration</p>'
213
+ });
214
+
215
+ // Set the element attributes to be inserted on dialog confirmation button click
216
+ context .setWrexIframeAttributes ({
217
+ src: ' https://lumapps.com' ,
218
+ title: ' Lumapps' ,
219
+ provider: ' my-website' ,
220
+ });
221
+ };
222
+
223
+ const onImageButtonClick = async (context ) => {
224
+ context .setWrexElementConfiguration ({
225
+ content: ' <p>My HTML for my image configuration</p>'
226
+ });
227
+
228
+ context .setWrexImageAttributes ({
229
+ images: [{
230
+ id: ' 1234' ,
231
+ src: ' https://picsum.photos/id/17/367/267' ,
232
+ width: 367 ,
233
+ height: 267 ,
234
+ alt: ' Some alt text' ,
235
+ }, ],
236
+ });
237
+ };
238
+
239
+ render ({
240
+ placement: placement .UNDER ,
241
+ target: targets .WREX_TOOLBAR ,
242
+ toRenderWithContext : (context ) => {
243
+ return DropdownSection ({
244
+ children: [
245
+ DropdownItem ({
246
+ title: ' My videos' ,
247
+ icon: ' video-account' ,
248
+ onClick : () => onVideoButtonClick (context),
249
+ }),
250
+ DropdownItem ({
251
+ title: ' My images' ,
252
+ icon: ' image-area' ,
253
+ onClick : () => onImageButtonClick (context),
254
+ }),
255
+ ],
256
+ });
257
+ },
258
+ });
259
+ });
260
+ ```
261
+ ### Use case information
262
+
263
+ ** setWrexElementConfiguration** Function
264
+
265
+ Allows you to define the configuration of your rich text element.
266
+
267
+ * Note: calling this function will open a dialog where your defined content is displayed*
268
+
269
+ | Parameter | Description | Is required? | Option type | Default Value |
270
+ | -----------| ------| ----------| ---------| -------------|
271
+ | ` configuration ` | Configuration options | Yes | object | ` {} ` |
272
+ | ` configuration.content ` | The html content of the dialog | Yes | string | ` '' ` |
273
+ | ` configuration.isLoading ` | Whether the dialog should be in a loading state | No | boolean | ` false ` |
274
+
275
+ ** setWrexIframeAttributes** Function
276
+
277
+ Allows you to define the data of the iframe to insert
278
+
279
+ * Note: calling this function will not insert an iframe, the insertion is done through the configuration dialog*
280
+
281
+ | Parameter | Description | Is required? | Option type | Default Value |
282
+ | -----------| ------| ----------| ---------| -------------|
283
+ | ` attributes ` | Configuration options | Yes | object | ` {} ` |
284
+ | ` attributes.src ` | The url of the page to embed | Yes | string | ` undefined ` |
285
+ | ` attributes.srcDoc ` | The html content of the iframe | No | string | ` undefined ` |
286
+ | ` attributes.title ` | The title of the iframe, used for accessibility | No | string | ` undefined ` |
287
+ | ` attributes.provider ` | The name of the provider of the iframe, used to identify an iframe | No | string | ` undefined ` |
288
+
289
+ ** setWrexImageAttributes** Function
290
+
291
+ Allows you to define the data of the image to insert
292
+
293
+ * Note: calling this function will not insert an image, the insertion is done through the configuration dialog*
294
+
295
+ | Parameter | Description | Is required? | Option type | Default Value |
296
+ | -----------| ------| ----------| ---------| -------------|
297
+ | ` attributes ` | Configuration options | Yes | object | ` {} ` |
298
+ | ` attributes.title ` | The caption of the image group | No | string | ` undefined ` |
299
+ | ` attributes.images ` | The image(s) to display | Yes | Image[ ] | ` [] ` |
300
+
301
+ ** Image object**
302
+
303
+ | Parameter | Description | Is required? | Option type | Default Value |
304
+ | -----------| ------| ----------| ---------| -------------|
305
+ | ` src ` | The image url | Yes | string | ` '' ` |
306
+ | ` alt ` | The image alt text, should describe the image for accessibility purpose | No | string | ` '' ` |
307
+ | ` height ` | The image height (in px) | No | integer | ` undefined ` |
308
+ | ` width ` | The image width (in px) | No | integer | ` undefined ` |
309
+
194
310
## Disabling bookmarks
195
311
196
312
Bookmarks can be disabled in order to avoid them to be displayed by adding the following line of JavaScript to your site.
0 commit comments