forked from layerssss/paste.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
64 lines (56 loc) · 1.48 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Paste.js</title>
<style>
.example {
margin-bottom: 1em;
}
.example--simple,
.example--ce {
border: 1px dotted rgba(0,0,0,.3);
padding: 1em;
}
label {
cursor: pointer;
display: block;
}
#result {
margin-top: 1em;
}
</style>
</head>
<body>
<div class="example example--simple">
Вставляйте изображение сюда
</div>
<div class="example example--ce" contenteditable="true">
Или сюда
</div>
<div class="example-wrapper">
<label for="area">Или напрямую в текстовое поле</label>
<textarea class="example" name="area" id="area" cols="30" rows="10"></textarea>
</div>
<div id="result">
Тут будет появляться вставляемое
</div>
<script src="paste.js"></script>
<script>
[].forEach.call(Paste.init('.example'), function (example) {
example.addEventListener('pasteImage', function (e) {
var resultItem = document.createElement('div');
var i = document.createElement('img');
i.src = URL.createObjectURL(e.detail.blob);
resultItem.appendChild(i);
result.appendChild(resultItem);
});
example.addEventListener('pasteText', function (e) {
var resultItem = document.createElement('div');
resultItem.innerHTML = e.detail.text;
result.appendChild(resultItem);
});
});
</script>
</body>
</html>