forked from miroapp/app-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
41 lines (36 loc) · 994 Bytes
/
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
38
39
40
41
const icon = '<circle cx="12" cy="12" r="9" fill="none" fill-rule="evenodd" stroke="currentColor" stroke-width="2"></circle>'
miro.onReady(() => {
miro.initialize({
extensionPoints: {
bottomBar: {
title: 'Board cleaner',
svgIcon: icon,
onClick: async () => {
const authorized = await miro.isAuthorized()
if (authorized) {
clearAllContent()
} else {
miro.board.ui.openModal('not-authorized.html')
.then(res => {
if (res === 'success') {
clearAllContent()
}
})
}
}
}
}
})
})
async function clearAllContent() {
// Show modal and wait for user choice
let needToClear = confirm('Do you want delete all board content?')
if (needToClear) {
// Get all board objects
let objects = await miro.board.widgets.get()
// Delete all board objects
await miro.board.widgets.deleteById(objects.map(object => object.id))
// Display success
miro.showNotification('Content has been deleted')
}
}