-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext2stickies.js
More file actions
44 lines (40 loc) · 1.46 KB
/
text2stickies.js
File metadata and controls
44 lines (40 loc) · 1.46 KB
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
async function createStickiesFromInput() {
try {
const inputData = prompt("Enter your text (one sticky note per line):");
if (!inputData) {
console.log("No input provided. Aborting.");
return;
}
const lines = inputData.split('\n');
const viewport = await miro.board.viewport.get();
const startX = viewport.x + viewport.width / 4;
const startY = viewport.y + viewport.height / 4;
const width = 200;
const padding = 10;
for (let i = 0; i < lines.length; i++) {
const line = lines[i].trim();
if (line) {
const sticky = await miro.board.createStickyNote({
content: line,
x: startX + (i % 5) * (width + padding),
y: startY + Math.floor(i / 5) * (width + padding),
width: width,
shape: 'rectangle',
style: {
fillColor: 'light_yellow',
textAlign: 'center',
textAlignVertical: 'middle',
},
});
}
}
console.log('Sticky notes successfully created');
} catch (error) {
console.error('Error creating sticky notes:', error);
}
}
if (typeof miro !== 'undefined') {
createStickiesFromInput();
} else {
console.error('Miro SDK not found. Make sure you are on a Miro board.');
}