-
Notifications
You must be signed in to change notification settings - Fork 5
/
copyspan.html
41 lines (41 loc) · 1.1 KB
/
copyspan.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
span {
display: inline-block;
}
</style>
<script>
addEventListener('copy', (event) => {
const selection = window.getSelection();
const str = selection.toString().replace(/\n%%BR%%\n/g, '');
event.clipboardData.setData('text/plain', str)
event.preventDefault()
});
</script>
<style>
.flex-br, .flex-nobr {
width: 0;
font-size: 0;
line-height: 0;
height: 0;
}
</style>
</head>
<body>
<div class="test" style="display: flex;user-select: auto;">
<span>abc</span><span class="flex-nobr">%%BR%%</span><span>111</span>
</div>
<div class="test" style="display: flex">
<span>sssss</span><span class="flex-nobr">%%BR%%</span><span>222</span>
</div>
<div class="test1123123" style="display: flex">
<span>abc</span><span class="flex-nobr">%%BR%%</span><span>111</span>
</div>
</body>
</html>