-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.html
More file actions
223 lines (203 loc) · 7.22 KB
/
content.html
File metadata and controls
223 lines (203 loc) · 7.22 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<script type="text/javascript" src="https://miro.com/app/static/sdk.1.1.js"></script>
</head>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#container {
height: 100%;
overflow-y: auto;
overflow-x: hidden;
display: flex;
flex-wrap: wrap;
flex-direction: row;
align-items: center;
padding-top: 32px;
box-sizing: border-box;
}
.row {
display: flex;
flex-direction: row;
padding-left: 32px;
margin-bottom: 32px;
}
.draggable-item {
margin-left: 32px;
margin-bottom: 32px;
width: 112px;
height: 112px;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 18px;
font-family: sans-serif;
}
.draggable-item.red {
background-color: #f24726;
}
.draggable-item.green {
background-color: #0ca788;
}
.image-box img {
max-width: 112px;
max-height: 112px;
cursor: pointer;
}
</style>
<body>
<div id="container">
</div>
<script>
const images = [
{src: 'img/018_Kollaboratives-Engineering.svg', width: 476, height: 627},
{src: 'img/019_Social-Media.svg', width: 476, height: 627},
{src: 'img/019_Social Media-1.svg', width: 476, height: 627},
{src: 'img/019_Social Media-2.svg', width: 476, height: 627},
{src: 'img/drawing.svg', width: 476, height: 627},
{src: 'img/drawing-sold.svg', width: 476, height: 627},
{src: 'img/drawing-png.png', width: 476, height: 627},
{src: 'img/drawing-xml.svg', width: 476, height: 627},
{src: 'img/Asset_1.svg', width: 267.02, height: 218.31},
{src: 'img/Asset_11.svg', width: 204.36, height: 375.54},
{src: 'img/Asset_12.svg', width: 252.37, height: 254.81},
{src: 'img/Asset_13.svg', width: 262.87, height: 364.2},
{src: 'img/Asset_14.svg', width: 256.19, height: 365.41},
{src: 'img/Asset_15.svg', width: 259.2, height: 181.74},
{src: 'img/Asset_17.svg', width: 255, height: 175.65},
{src: 'img/Asset_18.svg', width: 249.34, height: 225.69},
{src: 'img/Asset_19.svg', width: 257.34, height: 305.2},
{src: 'img/Asset_20.svg', width: 245.67, height: 174.88},
{src: 'img/Asset_21.svg', width: 263.63, height: 246.18},
{src: 'img/Asset_22.svg', width: 254.62, height: 334.65},
{src: 'img/Asset_23.svg', width: 251.08, height: 234.84},
{src: 'img/Asset_24.svg', width: 251.44, height: 270.31},
{src: 'img/Asset_25.svg', width: 246.51, height: 278.04},
{src: 'img/Asset_26.svg', width: 125.58, height: 123.66},
{src: 'img/Asset_27.svg', width: 109.91, height: 213.59},
{src: 'img/Asset_28.svg', width: 215.6, height: 156.79},
{src: 'img/Asset_29.svg', width: 193.6, height: 195.33},
{src: 'img/Asset_3.svg', width: 239.27, height: 281.26},
{src: 'img/Asset_32.svg', width: 139.77, height: 150.23},
{src: 'img/Asset_33.svg', width: 127.36, height: 162.64},
{src: 'img/Asset_34.svg', width: 163.54, height: 211.2},
{src: 'img/Asset_35.svg', width: 212.54, height: 93.78},
{src: 'img/Asset_36.svg', width: 160.19, height: 110.65},
{src: 'img/Asset_37.svg', width: 188.59, height: 127.25},
{src: 'img/Asset_38.svg', width: 247.68, height: 473.78},
{src: 'img/Asset_39.svg', width: 282.79, height: 213.35},
{src: 'img/Asset_40.svg', width: 228.45, height: 139.07},
{src: 'img/Asset_41.svg', width: 213.14, height: 168.79},
{src: 'img/Asset_42.svg', width: 239.71, height: 196.94},
{src: 'img/Asset_43.svg', width: 174.07, height: 262.56},
{src: 'img/Asset_45.svg', width: 134.8, height: 118.42},
{src: 'img/Asset_46.svg', width: 220.27, height: 159.99},
{src: 'img/Asset_47.svg', width: 137.35, height: 113.94},
{src: 'img/Asset_48.svg', width: 233.98, height: 277.4},
{src: 'img/Asset_49.svg', width: 103.23, height: 109.1},
{src: 'img/Asset_50.svg', width: 234.95, height: 265.47},
{src: 'img/Asset_51.svg', width: 155.91, height: 133.13},
{src: 'img/Asset_52.svg', width: 199.46, height: 163.54},
{src: 'img/Asset_53.svg', width: 224.52, height: 222.51},
{src: 'img/Asset_54.svg', width: 315.1, height: 278.03},
{src: 'img/Asset_55.svg', width: 197, height: 85.03},
{src: 'img/Asset_56.svg', width: 70.92, height: 108.35},
{src: 'img/Asset_6.svg', width: 265, height: 177.19},
{src: 'img/Asset_7.svg', width: 215.65, height: 138.67},
{src: 'img/Asset_8.svg', width: 251.67, height: 266.92},
{src: 'img/Asset_9.svg', width: 211.51, height: 246.24},
]
function getImage(img) {
return `<div class="draggable-item image-box">
<img src="${img.src}" data-image-url="${img.src}">
</div>`
}
function addShapes(container) {
container.innerHTML += '<div class="shape draggable-item green" data-color="0ca788">I am shape</div>' +
'<div class="shape draggable-item red" data-color="f24726">Me too</div>'
}
function addImages(container) {
container.innerHTML += images.map(i => getImage(i)).join('')
}
function createImage(canvasX, canvasY, url) {
console.log(url)
return miro.board.widgets.create({
type: 'image',
url: url,
x: canvasX,
y: canvasY,
})
}
function createShape(canvasX, canvasY, color, text) {
return miro.board.widgets.create({
type: 'shape',
text: text,
x: canvasX,
y: canvasY,
style: {
textColor: '#fff',
backgroundColor: '#' + color,
borderColor: 'transparent'
}
})
}
function bootstrap() {
const container = document.getElementById('container')
addShapes(container)
addImages(container)
let currentImageUrl
const imageOptions = {
draggableItemSelector: 'img',
onClick: async (targetElement) => {
const url = targetElement.getAttribute('data-image-url')
const widget = (await createImage(0, 0, url))[0]
miro.board.viewport.zoomToObject(widget)
},
getDraggableItemPreview: (targetElement) => { //drag-started
currentImageUrl = targetElement.getAttribute('data-image-url')
return {
width: 100,
height: 100,
url: currentImageUrl
}
},
onDrop: (canvasX, canvasY) => {
console.log('onDrop 1')
createImage(canvasX, canvasY, currentImageUrl)
}
}
miro.board.ui.initDraggableItemsContainer(container, imageOptions)
let currentShapeColor
let currentShapeText
const shapeOptions = {
draggableItemSelector: '.shape',
onClick: async (targetElement) => {
const color = targetElement.getAttribute('data-color')
const text = targetElement.innerText
const widget = (await createShape(0, 0, color, text))[0]
miro.board.viewport.zoomToObject(widget)
},
getDraggableItemPreview: (targetElement) => {
currentShapeColor = targetElement.getAttribute('data-color')
currentShapeText = targetElement.innerText
return {
url: `data:image/svg+xml,%3Csvg width='140' height='140' xmlns='http://www.w3.org/2000/svg'%3E%3Cg%3E%3Crect stroke='null' x='0' y='0' fill='%23${currentShapeColor}' height='140' width='140'/%3E%3C/g%3E%3C/svg%3E`
}
},
onDrop: (canvasX, canvasY) => {
console.log('onDrop 2')
createShape(canvasX, canvasY, currentShapeColor, currentShapeText)
}
}
miro.board.ui.initDraggableItemsContainer(container, shapeOptions)
}
miro.onReady(bootstrap)
</script>
</body>
</html>