forked from miroapp/app-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
37 lines (33 loc) · 1.15 KB
/
main.js
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
miro.onReady(() => {
miro.initialize({
extensionPoints: {
bottomBar: {
title: 'Sticker to shapes',
svgIcon:
'<circle cx="12" cy="12" r="9" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-width="2"/>',
positionPriority: 1,
onClick: async () => {
// Get selected widgets
let selectedWidgets = await miro.board.selection.get()
// Filter stickers from selected widgets
let stickers = selectedWidgets.filter((widget) => widget.type === 'STICKER')
// Delete selected stickers
await miro.board.widgets.deleteById(stickers.map((sticker) => sticker.id))
// Create shapes from selected stickers
await miro.board.widgets.create(
stickers.map((sticker) => ({
type: 'shape',
text: sticker.text,
x: sticker.x,
y: sticker.y,
width: sticker.bounds.width,
height: sticker.bounds.height,
})),
)
// Show success message
miro.showNotification('Stickers has been converted')
},
},
},
})
})