-
Notifications
You must be signed in to change notification settings - Fork 0
/
contenteditable.html
77 lines (71 loc) · 1.44 KB
/
contenteditable.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
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>contenteditable Test</title>
<style type="text/css">
.editable {
font-size: 1.0em;
line-height: 1.2em;
font-family: inherit;
white-space: pre-wrap;
max-height: 80%;
overflow: auto;
border: 1px solid #808080;
}
.left-pane, .right-pane {
width: 50%;
margin: 0;
padding: 0;
}
.left-pane {
float: left;
min-height: 10em;
}
.right-pane {
float: right;
min-height: 10em;
background: hsl(300, 100%, 95%);
}
.right-pane #dom {
white-space: pre-wrap;
margin: 0; padding: 0;
width: 100%;
border: none;
height: 80%;
display: block;
-webkit-box-shadow: 0 0 2px #08f;
}
</style>
<script type="text/javascript" src="jquery-1.4.js"></script>
<script type="text/javascript">
$(function(){
$('.editable').attr('contenteditable', true);
$('.editable a').click(function(){
alert('(stub - would open link in new window…)');
});
var ourDom = $('#dom');
var ourContent = $('#editableContent');
function copyDom(){
ourDom.text(ourContent.html());
window.setTimeout(copyDom, 250);
}
window.setTimeout(copyDom, 250);
});
</script>
</head>
<body>
<h1>contenteditable Test</h1>
<div class="left-pane">
<div class="editable" id="editableContent">The contents of this div
are editable by the user. <a href="//alanhogan.com">Link to alanhogan.com</a>.
Some other stuff.
<ul><li>Item 1
<li>Item 2</ul>
</div>
</div><!--left pane-->
<div class="right-pane">
<div id="dom"></div>
</div>
</body>
</html>