forked from miroapp/app-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miro.d.ts
2057 lines (1919 loc) · 53.4 KB
/
miro.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Start here
*/
declare const miro: SDK.Root
/**
* Here you will find a full reference to all publicly available methods in
* the Miro SDK for web plugins development.
*
* The [[Root]] interface contains the SDK main commands and is a good starting point.
*
*/
declare namespace SDK {
/**
* This is the same **`window.miro`** Object and will be your main entry point to the SDK methods.
*
* @meta-title The `window.miro` Object
* @category General
*/
interface Root {
/**
* Callback executed when everything is loaded and ready to use SDK methods.
* @param callback Function to be executed
* @returns
*
* **Example**
* ```javascript
* miro.onReady(() => {
* console.log("Ready to call SDK methods")
* }
* ```
*/
onReady(callback: () => void): void
/**
* Accepts a configuration to initialize the plugin.
*
* Available only on a board. Not available in iframes from [Container Entry points](https://developers.miro.com/docs/extension-points-for-miro-apps)
*
* **Example**
* ```javascript
* miro.onReady(() => {
* miro.initialize({
* //plugin configuration
* });
* }
* ```
*/
initialize(config?: IPluginConfig): Promise<void>
/**
* Accepts a configuration to initialize the plugin in the settings page.
* Available only in the setting page.
*
* **Example**
* ```javascript
* miro.onReady(() => {
* miro.initializeSettings({
* //plugin configuration
* });
* }
* ```
*
*/
initializeSettings(config?: IPluginSettingsConfig): Promise<void>
/**
* The current board the user is watching.
* Contains commands (functions) to access to the board information.
*
* Available only when the Web-plugin runs in a board
*
*/
board: IBoardCommands
/**
* Contains commands (functions) to access to the Account (Team)
* where the Web-plugin was installed
*
* *Note*: this is not the current user
*/
account: IAccountCommands
/**
* The current user.
* Contains commands (functions) to access to the current user information.
*/
currentUser: ICurrentUserCommands
/**
* Contains constants like events and style that can be used with other SDK methods
*/
enums: IEnums
/**
* Subscribe to an event in the board.
* Go to [[EventType]] to see a list of possible events.
*
* *Note*: Available only when the Web plugin runs on a board page.
* @param event A string with an event as defined in [[EventType]]
* @param listener A function to handle the [[Event]]
* @return void
*
* **Example**
* ```javascript
* function handleSelectionUpdated(event) {
* // Your event handler
* }
* miro.addListener('SELECTION_UPDATED', handleSelectionUpdated)
* ```
* *Related: See [[removeListener]] to remove a listener*
*/
addListener(event: EventType, listener: (e: Event) => void): void
/**
* Unsubscribe from an event in the board.
* Go to [[EventType]] to see a list of possible events.
*
* *Note*: Available only when the Web plugin runs on a board page.
* @param event A string with an event as defined in [[EventType]]
* @param listener The function originally passed in [[addListener]] to handle the event
* @return void
*
*
* **Example**
*
* ```javascript
* miro.removeListener('SELECTION_UPDATED', handleSelectionUpdated)
* ```
* *Related: See [[addListener]] to add a listener*
*/
removeListener(event: EventType, listener: (e: Event) => void): void
/**
* Broadcast some data to iframes from your plugin in [Container Entry Points](https://developers.miro.com/docs/extension-points-for-miro-apps)
*
* You can subscribe to the `DATA_BROADCASTED` event to receive this data.
* See [[addListener]] and [[EventType]]
*
* @param data The payload you wish to broadcast
* @returns void
*
* **Example**
* ```javascript
* miro.broadcastData({
* value: 1
* })
* ```
*/
broadcastData(data: any): void
/**
* Shows a notification to the user
* @param text The text to show in the notification
* @returns A Promise, fulfilled when the notification is displayed to the user
*
* **Example**
* ```javascript
* miro.showNotification('Hello world')
* ```
*/
showNotification(text: string): Promise<void>
/**
* Similar to [[showNotification]] with additional style to indicate error
* @param text The text to show in the notification
* @returns A Promise, fulfilled when the notification is displayed to the user
* **Example**
* ```javascript
* miro.showErrorNotification('This is an error notification')
* ```
*/
showErrorNotification(text: string): Promise<void>
/**
* Check if the current user has authorized the Web-plugin to make API requests
* on their behalf
* @returns True if the web plugin is authorized, false when not.
*
* **Example**
*
* ```javascript
* miro.isAuthorized().then( (isAuthorized) => {
* if (isAuthorized) {
* console.log('Web plugin authorized');
* } else {
* console.log('Unauthorized');
* }
* })
* ```
*/
isAuthorized(): Promise<boolean>
/**
* The `getIdToken()` method returns a [JSON Web Token (JWT)](http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-11), an encoded form of JSON data, signed by the application secret. You can use JWTs to authenticate requests from your Miro web-plugin to your backend services. You can use an existing [JWT library to decode](https://jwt.io/) the token and establish the communication between your Miro web-plugin and your backend services.
* If you are migrating from `getToken()` to `getIdToken()`, [see the migration guide.](https://developers.miro.com/docs/gettoken-migration-guide)
*
* @returns a JWT token
*
* **Example**
* ```javascript
* miro.getIdToken().then((jwt) =>{
* console.log('jwt token', jwt);
* })
* ```
*/
getIdToken(): Promise<string>
/**
* Opens a modal to follow the authorization process for your App.
*
* @param options Options for the authorization process. See [[AuthorizationOptions]]
* @returns A promise fulfilled if the app has been authorized.
*
*/
requestAuthorization(options?: AuthorizationOptions): Promise<void>
/**
* Returns the clientId from the web plugin.
* This is the same clientId from the App settings dashboard.
* @returns The web plugin clientId.
*/
getClientId(): string
/**
* Saves a state (any) that can will be accessible across all
* the container extension points (iframes) from your plugin.
*
* You can retrieve this state with [[__getRuntimeState]]
*
* *Note: This state is not persisted between boards or page reloads.*
*
* @experimental
*
* @returns A promise resolving into the previously saved state. Defaults to an empty object.
*
*/
__setRuntimeState<T = any>(data: T): Promise<T>
/**
* Gets a previously set state from any container extension point (iframe) from your plugin.
*
* You can set this state with [[__setRuntimeState]]
*
* *Note: This state is not persisted between boards or page reloads.*
*
* @experimental
*
* @returns A promise resolving into the stored state.
*/
__getRuntimeState<T = any>(): Promise<T>
}
/**
* Constant defining different events that can be triggered by the main application.
*
* The following events are experimental and can be unstable:
*
* * ESC_PRESSED
* * ALL_WIDGETS_LOADED
* * COMMENT_CREATED
* * CANVAS_CLICKED
* * DATA_BROADCASTED
* * RUNTIME_STATE_UPDATED
* * METADATA_CHANGED
* * ONLINE_USERS_CHANGED
* @category General
*/
type EventType =
| 'SELECTION_UPDATED'
| 'WIDGETS_CREATED'
| 'WIDGETS_DELETED'
| 'WIDGETS_TRANSFORMATION_UPDATED'
| 'ESC_PRESSED' //Experimental event
| 'ALL_WIDGETS_LOADED' //Experimental event
| 'COMMENT_CREATED' //Experimental event
| 'CANVAS_CLICKED' //Experimental event
| 'DATA_BROADCASTED' //Experimental event
| 'RUNTIME_STATE_UPDATED' //Experimental event
| 'METADATA_CHANGED' //Experimental event
| 'ONLINE_USERS_CHANGED' //Experimental event
/**
* An Event generated by the main application.
*
* You can subscribe to events using [[addListener]]
* @category General
*/
interface Event {
/**
* The type of event as in [[EventIBoardCommentsCommandspe]]
*/
type: string | EventType
/**
* Payload with data related to the event
*/
data: any
}
/**
* Authorization options for the [authorization flow](https://developers.miro.com/docs/webplugin_authorization).
* See [[requestAuthorization]]
* @category Account and User
*/
interface AuthorizationOptions {
/**
* The url the user will be redirected after the authorization.
* This url must be registered in your app "Redirect URLs" list.
*/
redirect_uri?: string
/**
* oAuth state parameter. It will be send back to the defined `redirect_uri`.
*/
state?: string
}
/**
* Options to initialize the plugin in the settings page.
* @category General
*
*/
interface IPluginSettingsConfig {
/**
* Height for your plugin iframe
*/
iframeHeight: number
}
/**
* Defines the configuration to initialize the web plugin
* See [`IPluginConfigExtensionPoints`] for further information.
* @category General
*/
interface IPluginConfig {
/**
* Configuration options
* @inline
*/
extensionPoints: IPluginConfigExtensionPoints
}
/**
* Extensions points allow you to enhance the user interface with buttons.
*
* You can define your own buttons using these extensions points, each extension
* points accepts a specific configuration and has its own limitations.
*
* Some extensions points only allow you to add up to one button.
*
*
* Read more about [Extension Points](https://developers.miro.com/docs/extension-points-for-miro-apps)
* @category Extension Points
*/
interface IPluginConfigExtensionPoints {
/**
* The toolbar seen on the left side of the board
*
* You can directly define a [[ToolbarButton]] or a function returning a
* promise that resolves on one.
*
* **Example**
* ```javascript
* miro.onReady(() => {
* miro.initialize({
* extensionPoints: {
* toolbar: {
* title: "The button title",
* librarySvgIcon:
* '<circle cx="12" cy="12" r="9" fill="blue" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* toolbarSvgIcon:
* '<circle cx="12" cy="12" r="9" fill="red" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* miro.showNotification("You clicked a toolbar item!");
* },
* },
* },
* });
* });
*
* ```
*/
toolbar?: ButtonExtensionPoint<ToolbarButton>
/**
* The toolbar seen on the bottom left side of the board
*
* You can directly define a [[BottomBarButton]] or a function returning a
* promise that resolves on one.
*
* **Example**
* ```javascript
* miro.onReady(() => {
* miro.initialize({
* extensionPoints: {
* bottomBar: {
* title: "The button title",
* svgIcon:
* '<circle cx="12" cy="12" r="9" fill="blue" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* miro.showNotification("You clicked a bottom bar item!");
* },
* },
* },
* });
* });
* ```
*/
bottomBar?: ButtonExtensionPoint<BottomBarButton>
/**
* The toolbar seen when the user opens the export menu.
*
* You can directly define a [[ExportMenuButton]] or a function returning a
* promise that resolves on one.
*
* **Example**
* ```javascript
* miro.onReady(() => {
* miro.initialize({
* extensionPoints: {
* exportMenu: {
* title: "The button title",
* svgIcon:
* '<circle cx="12" cy="12" r="9" fill="red" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* miro.showNotification("You clicked a export menu item!");
* },
* },
* },
* });
* });
*
* ```
*
*/
exportMenu?: ButtonExtensionPoint<ExportMenuButton>
/**
*
* **Deprecated**
* This method is deprecated.
*
* @deprecated
*/
getWidgetMenuItems?: (widgets: IWidget[], editMode: boolean) => Promise<IWidgetMenuItem | IWidgetMenuItem[]>
}
/**
* @category Extension Points
*/
type ButtonExtensionPoint<T> = T | (() => Promise<T | void>)
/**
* Defines a button in the toolbar extension point.
* The toolbar is displayed on the left side of the board.
*
* By default your icon will be only displayed on the library.
*
* See [[IPluginConfigExtensionPoints]] for examples.
*
* Read more about [Extension Points](https://developers.miro.com/docs/extension-points-for-miro-apps)
*
* @category Extension Points
*/
interface ToolbarButton {
/**
* The title of the button, It will be displayed on mouse over.
*/
title: string
/**
* The icon that will be displayed on the library (when clicking the dots `...` icon
* in the toolbar).
* Must be an [SVGElement](https://developer.mozilla.org/en-US/docs/Web/SVG/Element)
*
* By default your button will be displayed here.
* The user must drag and drop you plugin icon from the library into the toolbar to display it directly in
* the toolbar.
*/
librarySvgIcon: string
/**
* The icon that will be displayed in the toolbar after the user drag it from the library.
* Must be an [SVG Element](https://developer.mozilla.org/en-US/docs/Web/SVG/Element)
*/
toolbarSvgIcon: string
/**
* A handler to be executed when the user clicks the button
*/
onClick: () => void
}
/**
* Defines a button in the bottom bar extension point.
* The bottom bar is displayed on the bottom left side of the board.
*
* See [[IPluginConfigExtensionPoints]] for examples.
*
* Read more about [Extension Points](https://developers.miro.com/docs/extension-points-for-miro-apps)
* @category Extension Points
*/
interface BottomBarButton {
/**
* The title of the button, It will be displayed on mouse over.
*/
title: string
/**
* The icon that will be displayed.
* Must be an [SVGElement](https://developer.mozilla.org/en-US/docs/Web/SVG/Element)
*/
svgIcon: string
/**
* A handler to be executed when the user clicks the button
*/
onClick: () => void
}
/**
* Defines a button in the export menu extension point.
* The export buttons appears after the user click the "export" button in a board.
*
* See [[IPluginConfigExtensionPoints]] for examples.
*
* Read more about [Extension Points](https://developers.miro.com/docs/extension-points-for-miro-apps)
* @category Extension Points
*/
interface ExportMenuButton {
/**
* The title of the button., It will be displayed on mouse over.
*
* See [[IPluginConfigExtensionPoints]] for examples.
*
*/
title: string
/**
* The icon that will be displayed.
* Must be an [SVGElement](https://developer.mozilla.org/en-US/docs/Web/SVG/Element)
*/
svgIcon: string
/**
* A handler to be executed when the user clicks the button
*/
onClick: () => void
}
/**
* **Deprecated**
* This method is deprecated.
* @deprecated
*/
interface IWidgetMenuItem {
tooltip: string
svgIcon: string
onClick: () => void
}
/**
* Possible functions (commands) that you can execute
* on the current board.
*
* The specific commands and examples are defined on its own section.
* @category Board Manipulation
*/
interface IBoardCommands {
/**
* Command related to the board information
*/
info: IBoardInfoCommands
/**
* Commands related to widgets like create, update, delete and metadata.
*/
widgets: IBoardWidgetsCommands
/**
* Commands related to tags
*/
tags: IBoardTagsCommands
/**
* Commands related to the user interface control
*/
ui: IBoardUICommands
/**
* Commands related to the board viewport
*/
viewport: IBoardViewportCommands
/**
* Commands related to the selection of widgets in the board
*/
selection: IBoardSelectionCommands
/**
* Utilities to work with the board
*/
utils: IBoardUtils
/**
* Returns the deserialized parameters contained in the `miro_sdk` address (location.href) query parameter.
* @returns A promise resolving into the deserialized data in the `miro_sdk` query parameter.
* @experimental
*/
__getParamsFromURL(): Promise<any>
/**
* Enables the usage of the mouse left button on the board.
* It has no effect if the left button was not previously disabled.
* @experimental
*/
__enableLeftClickOnCanvas(): void
/**
* Disable the usage of the mouse left button on the board.
* @experimental
*/
__disableLeftClickOnCanvas(): void
}
/**
* Options to define the conditions and behavior of draggable items
* @category Extension Points
*/
interface DraggableItemsContainerOptions {
/**
* Allows to block the device (e.g. a tablet or smartphone) scrolling while the dragging takes place.
* This option will have no effect on mouse-enabled devices like a desktop PC.
*
* Possible values: `horizontal` and `vertical`
* Defaults to `horizontal`
*/
dragDirection?: string
/**
* A CSS selector. HTMLElement inside the container matching this selector will be draggable.
*/
draggableItemSelector: string
/**
* A callback executed when the user starts dragging.
*/
getDraggableItemPreview: (targetElement: HTMLElement) => {
/**
* defaults to 100
*/
width?: number
/**
* defaults to 100
*/
height?: number
/**
* An image following the cursor while the dragging takes place.
* Supported schemas: 'https://', 'data:image/svg+xml', 'data:image/png;base64'
*/
url: string
}
/**
* A callback executed when a draggable item is clicked.
* This callback will be executed regardless of the item being dragged or not.
*/
onClick?: (targetElement: HTMLElement) => void
/**
* A callback executed when an item was dropped in the board canvas.
* targetElement is the dragged and dropped item.
*/
onDrop: (canvasX: number, canvasY: number, targetElement: HTMLElement) => void
/**
* A callback executed when an item was dragged but not dropped in the board canvas.
*/
onCancel?: () => void
}
/**
* Commands related to the account (team) on which the plugin
* was installed.
*
* *Note*: this is not the current user.
* @category Account and User
*/
interface IAccountCommands {
/**
* Get information [[IAccountInfo]] about the account.
* @returns a promise that resolves into the account information.
*
* Requires scope: `TEAM:READ`
*/
get(): Promise<IAccountInfo>
}
/**
* Commands related to the current user
* @category Account and User
*/
interface ICurrentUserCommands {
/**
* Gets the user id
* @returns a promise resolving in the current user id
*
*/
getId(): Promise<string>
/**
* Returns if the user is logged in.
*
* @returns a promise resolved into the login status of the current user (true or false)
*/
isSignedIn(): Promise<boolean>
/**
* Gets the current scopes the user has authorized the plugin
* @returns a promise resolving into an array of scopes (strings) the user has authorized the plugin.
*/
getScopes(): Promise<string[]>
/**
* Gets the permissions of the current user over the current board.
*
* Requires scope: `IDENTITY:READ`
*
* @returns a promise resolving into an array of [[BoardPermission]](strings)
*/
getCurrentBoardPermissions(): Promise<BoardPermission[]>
/**
* Gets the permissions of the current user over the account (team).
*
* Requires scope: `IDENTITY:READ`
*
* @returns a promise resolving into an array of [[AccountPermission]](strings)
*/
getCurrentAccountPermissions(): Promise<AccountPermission[]>
/**
* Returns if the current user is a member of the account (team) owner of the board
*
* Requires scope: IDENTITY:READ
*
* @returns a promise resolving into the membership status of the current user (boolean)
*
*/
isMemberOfCurrentAccount(): Promise<boolean>
}
/**
* Representation of one widget by id
* @category Widgets Manipulation
*/
type InputWidget = string | {id: string}
/**
* Representation of one or multiple widgets by id
* @category Widgets Manipulation
*/
type InputWidgets = string | string[] | {id: string} | {id: string}[]
/**
* Commands to get information about the board
* @category Board Manipulation
*/
interface IBoardInfoCommands {
/**
* @returns a promise resolving into information ([[IBoardInfo]]) about the board
*/
get(): Promise<IBoardInfo>
}
/**
* Commands to manipulate the user interface of the current board and make use of
* container extension points.
*
* When a container extension point is opened (e.g. the sidebar) an iframe will be created
* and loaded based on the options you use to open it. There are different mechanism to communicate
* between these iframes, such events and states.
*
* Read more about [Extension Points](https://developers.miro.com/docs/extension-points-for-miro-apps)
* @category Extension Points
*/
interface IBoardUICommands {
/**
* Opens the left sidebar and loads an iframe with the `iframeURL`.
*
* You can communicate with this iframe by using the [[broadcastData]] method.
*
* @param iframeURL the url that will be open in the iframe. If a relative url is used, it will be relative
* to the defined web plugin url.
* @returns A promise that will be resolved once the left sidebar is closed.
*
* **Example**
* ```javascript
* miro.onReady(async () => {
* miro.initialize({
* extensionPoints: {
* // create a button on the bottom bar
* bottomBar: {
* title: "Open a sidebar",
* svgIcon:
* '<circle cx="12" cy="12" r="9" fill="blue" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* // open the sidebar when clicked
* // `/sidebar.html` will be relative to the plugin url
* miro.board.ui.openLeftSidebar("/sidebar.html");
*
* // send a message to the sidebar after 5 seconds
* setTimeout(() => {
* miro.broadcastData("Hello from the bottom bar");
* }, 5000);
* },
* },
* },
* });
* });
* ```
*/
openLeftSidebar(iframeURL: string): Promise<any>
/**
* Opens the library extension point and loads an iframe with the `iframeURL`.
*
* You can communicate with this iframe by using the [[broadcastData]] method.
*
* @param iframeURL the url that will be open in the iframe. If a relative url is used, it will be relative
* to the defined web plugin url.
* @param options Options for the library. Current only `title` is available.
* @returns A promise that will be resolved once the library is closed.
*
* **Example**
* ```javascript
* miro.onReady(async () => {
* miro.initialize({
* extensionPoints: {
* // create a button on the bottom bar
* bottomBar: {
* title: "Open the library",
* svgIcon:
* '<circle cx="12" cy="12" r="9" fill="blue" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* // `/library.html` will be relative to the plugin url
* miro.board.ui.openLibrary("/library.html", { title: "The library!" });
* },
* },
* },
* });
* });
* ```
*/
openLibrary(iframeURL: string, options: {title: string}): Promise<any>
/**
* Opens the modal extension point and loads an iframe with the `iframeURL`.
*
* You can communicate with this iframe by using the [[broadcastData]] method.
*
* @param iframeURL the url that will be open in the iframe. If a relative url is used, it will be relative
* to the defined web plugin url.
* @param options Options for the modal. You can define specific dimensions or make it fullscreen.
* @returns A promise that will be resolved once the modal is closed.
*
* **Example**
* ```javascript
* miro.onReady(async () => {
* miro.initialize({
* extensionPoints: {
* // create a button on the bottom bar
* bottomBar: {
* title: "Open a modal",
* svgIcon:
* '<circle cx="12" cy="12" r="9" fill="blue" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* miro.board.ui.openModal("/modal.html", { width: 400, height: 400 }).then(() => {
* miro.showNotification("modal closed");
* });
* },
* },
* },
* });
* });
* ```
*/
openModal(iframeURL: string, options?: {width?: number; height?: number} | {fullscreen: boolean}): Promise<any>
/**
* Opens the bottom panel extension point and loads an iframe with the `iframeURL`.
*
* You can communicate with this iframe by using the [[broadcastData]] method.
*
* @param iframeURL the url that will be open in the iframe. If a relative url is used, it will be relative
* to the defined web plugin url.
* @param options Options for the bottomPanel.
*
* options.width: default 120px, min value: 80px; max: value 320px
*
* options.height: default 48px, min value: 48px; max: value 200px
*
* @returns A promise that will be resolved once the bottomPanel is closed.
*
* **Example**
* ```javascript
* miro.onReady(async () => {
* miro.initialize({
* extensionPoints: {
* // create a button on the bottom bar
* bottomBar: {
* title: "Open a modal",
* svgIcon:
* '<circle cx="12" cy="12" r="9" fill="blue" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
* onClick: () => {
* miro.board.ui.openBottomPanel("/sidebar.html", {
* width: 200,
* height: 200,
* });
* },
* },
* },
* });
* });
* ```
*
*/
openBottomPanel(iframeURL: string, options?: {width?: number; height?: number}): Promise<any>
/**
* Closes the left sidebar.
* Throws error if the sidebar was not opened by the plugin
*
* @param data Ignored for now.
*/
closeLeftSidebar(data?: any): void
/**
* Closes the library.
* Throws error if the library was not opened by the plugin
* @param data Ignored for now.
*/
closeLibrary(data?: any): void
/**
* Closes the modal.
* Throws error if the modal was not opened by the plugin
* @param data Ignored for now.
*/
closeModal(data?: any): void
/**
* Closes the bottom panel.
* Throws error if the bottom panel was not opened by the plugin
* @param data Ignored for now.
*/
closeBottomPanel(data?: any): void
/**
* Resizes the current iframe inside the bottom-panel.
* @TODO this method does not exist
* resizeToInner does exist
*
* The left sidebar and the modal are not yet supported.
*/
resizeTo(value: HTMLElement | string | {width?: number; height?: number}): void
/**
* Enables a container (HTMLElement) to have draggable elements (items).
*
* *Note: Not all items inside the container will be draggable.
* See [[DraggableItemsContainerOptions]] to know how to define them.*
*
* Items dynamically added to the container will be draggable if matching the conditions defined in [[DraggableItemsContainerOptions]]
* @TODO add link to a guide with a full working example
*
* @param container An HTMLElement containing the draggable items.
* @param options Define the conditions and behavior of the draggable items.
* @returns
*
* **Example**
* ```javascript
* //This example code should run in a container extension point like the left sidebar or the library.
* miro.onReady(() => {
* // Contains the draggable elements
* const draggable = document.getElementById("draggables-container");
* miro.board.ui.initDraggableItemsContainer(draggable, {
* // matching elements will be draggable
* draggableItemSelector: ".drag-me",
* getDraggableItemPreview: function () {
* return {
* url: "https://dummyimage.com/600x400/000000/ffffff&text=Drag+Me",
* };
* },
* onDrop: function () {
* miro.showNotification("You dropped something");
* },
* });
* });
* ```
*
*/
initDraggableItemsContainer(container: HTMLElement, options: DraggableItemsContainerOptions): void
/**
* Selects the board default tool
* @experimental
*/
__selectDefaultTool(): void
/**
* Hides interface panels [[UIPanel]]
* @experimental
*/
__hideButtonsPanels(panels: 'all' | UIPanel | UIPanel[]): void
/**
* Shows interface panels [[UIPanel]]
*/
__showButtonsPanels(panels: 'all' | UIPanel | UIPanel[]): void
/**