@withalleo/ewidget-utils 1.0.12 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -40
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
# @withalleo/ewidget-utils
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm i @withalleo/ewidget-utils
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Demo (plain HTML)
|
|
10
|
-
|
|
11
|
-
This package ships a browser bundle at `@withalleo/ewidget-utils/browser` (UMD). You can drop it into a plain HTML page and call `demo()`.
|
|
12
|
-
|
|
13
|
-
> Note: The CDN URL below is an example. Prefer pinning an exact version.
|
|
3
|
+
This package ships a browser bundle at `@withalleo/ewidget-utils`.
|
|
14
4
|
|
|
15
5
|
```html
|
|
16
6
|
<!doctype html>
|
|
@@ -46,13 +36,13 @@ This package ships a browser bundle at `@withalleo/ewidget-utils/browser` (UMD).
|
|
|
46
36
|
**Outgoing examples**
|
|
47
37
|
|
|
48
38
|
```js
|
|
49
|
-
|
|
39
|
+
alleo.triggerAction('demo', {
|
|
50
40
|
'demo-param': 'Hello from iframe',
|
|
51
41
|
})
|
|
52
42
|
```
|
|
53
43
|
|
|
54
44
|
```js
|
|
55
|
-
|
|
45
|
+
alleo.addContent({
|
|
56
46
|
type: 'notepad',
|
|
57
47
|
textFormat: 'markdown',
|
|
58
48
|
text: '# Status\n\nAll systems go.',
|
|
@@ -60,11 +50,11 @@ messenger.addContent({
|
|
|
60
50
|
```
|
|
61
51
|
|
|
62
52
|
```js
|
|
63
|
-
|
|
53
|
+
alleo.requestSyncedStatus()
|
|
64
54
|
```
|
|
65
55
|
|
|
66
56
|
```js
|
|
67
|
-
|
|
57
|
+
alleo.setSyncedStatus({
|
|
68
58
|
color: '#FFAA33',
|
|
69
59
|
})
|
|
70
60
|
```
|
|
@@ -83,13 +73,13 @@ messenger.setSyncedStatus({
|
|
|
83
73
|
**Incoming examples (one per event)**
|
|
84
74
|
|
|
85
75
|
```js
|
|
86
|
-
|
|
76
|
+
alleo.onSyncedStatusUpdate((status) => {
|
|
87
77
|
console.log('synced status', status)
|
|
88
78
|
})
|
|
89
79
|
```
|
|
90
80
|
|
|
91
81
|
```js
|
|
92
|
-
|
|
82
|
+
alleo.onIncomingAction(({ actionId, data }) => {
|
|
93
83
|
console.log('incoming action', actionId, data)
|
|
94
84
|
})
|
|
95
85
|
```
|
|
@@ -249,20 +239,17 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
249
239
|
> logEl.textContent = `${line}\n${logEl.textContent}`
|
|
250
240
|
> }
|
|
251
241
|
>
|
|
252
|
-
> const
|
|
253
|
-
> targetOrigin: '*',
|
|
254
|
-
> debug: true,
|
|
255
|
-
> })
|
|
242
|
+
> const alleo = new AlleoEWidget.getEmbedWidgetMessenger()
|
|
256
243
|
>
|
|
257
|
-
>
|
|
244
|
+
> alleo.onSyncedStatusUpdate((status) => {
|
|
258
245
|
> log('syncedStatusUpdate:', status)
|
|
259
246
|
> })
|
|
260
247
|
>
|
|
261
|
-
>
|
|
248
|
+
> alleo.onIncomingAction(({ actionId, data }) => {
|
|
262
249
|
> log(`incomingAction: ${actionId}`, data)
|
|
263
250
|
> })
|
|
264
251
|
>
|
|
265
|
-
>
|
|
252
|
+
> alleo.getElementById('trigger').addEventListener('click', () => {
|
|
266
253
|
> messenger.triggerAction('demo', {
|
|
267
254
|
> 'demo-param': 'Hello from iframe',
|
|
268
255
|
> })
|
|
@@ -270,7 +257,7 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
270
257
|
> })
|
|
271
258
|
>
|
|
272
259
|
> document.getElementById('request').addEventListener('click', () => {
|
|
273
|
-
>
|
|
260
|
+
> alleo.requestSyncedStatus()
|
|
274
261
|
> log('requestSyncedStatus sent')
|
|
275
262
|
> })
|
|
276
263
|
> </script>
|
|
@@ -309,13 +296,9 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
309
296
|
>
|
|
310
297
|
> <script src="https://unpkg.com/@withalleo/ewidget-utils/dist/ewidget-utils.umd.cjs"></script>
|
|
311
298
|
> <script>
|
|
312
|
-
> const
|
|
313
|
-
> targetOrigin: '*',
|
|
314
|
-
> debug: true,
|
|
315
|
-
> })
|
|
316
|
-
>
|
|
299
|
+
> const alleo = new AlleoEWidget.getEmbedWidgetMessenger()
|
|
317
300
|
> document.getElementById('add-notepad').addEventListener('click', () => {
|
|
318
|
-
>
|
|
301
|
+
> alleo.addContent({
|
|
319
302
|
> type: 'notepad',
|
|
320
303
|
> textFormat: 'markdown',
|
|
321
304
|
> text: '# New note\n\nAdded from iframe.',
|
|
@@ -323,7 +306,7 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
323
306
|
> })
|
|
324
307
|
>
|
|
325
308
|
> document.getElementById('add-sticky').addEventListener('click', () => {
|
|
326
|
-
>
|
|
309
|
+
> alleo.addContent({
|
|
327
310
|
> type: 'sticky-note',
|
|
328
311
|
> text: 'Remember to review the draft',
|
|
329
312
|
> color: '#FFE680',
|
|
@@ -333,7 +316,7 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
333
316
|
> })
|
|
334
317
|
>
|
|
335
318
|
> document.getElementById('add-html').addEventListener('click', () => {
|
|
336
|
-
>
|
|
319
|
+
> alleo.addContent({
|
|
337
320
|
> type: 'html',
|
|
338
321
|
> html: '<!doctype html><html><body><h2>Hello from iframe</h2></body></html>',
|
|
339
322
|
> })
|
|
@@ -374,17 +357,14 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
374
357
|
> <script>
|
|
375
358
|
> const button = document.getElementById('color')
|
|
376
359
|
>
|
|
377
|
-
> const
|
|
378
|
-
> targetOrigin: '*',
|
|
379
|
-
> debug: true,
|
|
380
|
-
> })
|
|
360
|
+
> const alleo = new AlleoEWidget.getEmbedWidgetMessenger()
|
|
381
361
|
>
|
|
382
362
|
> const applyColor = (status) => {
|
|
383
363
|
> if (!status || !status.color) return
|
|
384
364
|
> button.style.backgroundColor = status.color
|
|
385
365
|
> }
|
|
386
366
|
>
|
|
387
|
-
>
|
|
367
|
+
> alleo.onSyncedStatusUpdate((status) => {
|
|
388
368
|
> applyColor(status)
|
|
389
369
|
> })
|
|
390
370
|
>
|
|
@@ -392,10 +372,10 @@ Below are the exact sample files from `samples/`, included verbatim as quoted bl
|
|
|
392
372
|
> const color = `#${Math.floor(Math.random() * 0xffffff)
|
|
393
373
|
> .toString(16)
|
|
394
374
|
> .padStart(6, '0')}`
|
|
395
|
-
>
|
|
375
|
+
> alleo.setSyncedStatus({ color })
|
|
396
376
|
> })
|
|
397
377
|
>
|
|
398
|
-
>
|
|
378
|
+
> alleo.requestSyncedStatus()
|
|
399
379
|
> </script>
|
|
400
380
|
> </body>
|
|
401
381
|
> </html>
|