annotate index.xhtml @ 0:891d16fda2e2

initial push
author Sonny Piers <sonny.piers@gmail.com>
date Sun, 18 Dec 2011 16:28:54 +0100
parents
children eb3679d92996
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
1 <?xml version="1.0" encoding="UTF-8"?>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
2 <!DOCTYPE html>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
3 <html xmlns="http://www.w3.org/1999/xhtml">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
4 <head>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
5 <meta charset="UTF-8" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
6 <title> contentEditable </title>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
7 <script type="text/javascript">//<![CDATA[
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
8 var
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
9 gActiveEditor = null, // active editing host
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
10 gCommandDump = null; // command dump field
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
11 function ExecCommand(toolbarElement) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
12 var argVal, argStr,
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
13 type = toolbarElement.getAttribute("type"),
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
14 command = toolbarElement.getAttribute("data-command");
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
15 switch (type) { // get the execCommand argument according to the button type
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
16 case "button": // toolbar button: no argument
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
17 argVal = argStr = false;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
18 break;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
19 case "checkbox": // styleWithCSS: boolean argument
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
20 argVal = argStr = "" + toolbarElement.checked + "";
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
21 break;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
22 default: // <select> menu: string argument
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
23 if (!toolbarElement.selectedIndex) return;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
24 argVal = toolbarElement.value;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
25 argStr = "'" + argVal.replace("<", "&lt;").replace(">", "&gt;") + "'";
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
26 toolbarElement.selectedIndex = 0; // reset drop-down list
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
27 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
28 document.execCommand(command, false, argVal); // send requested action
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
29 if (gActiveEditor) gActiveEditor.focus(); // re-focus the editable element
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
30 gCommandDump.innerHTML = "document.execCommand('" + command + "', false, '" + argStr + "');";
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
31 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
32 window.addEventListener("DOMContentLoaded", function() {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
33 var i,
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
34 buttons = document.querySelectorAll("*[data-command]"),
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
35 editors = document.querySelectorAll("*[contenteditable]");
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
36 for (i = 0; i < buttons.length; i++) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
37 buttons[i].onclick = function() { ExecCommand(this); };
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
38 buttons[i].onchange = function() { ExecCommand(this); };
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
39 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
40 for (i = 0; i < editors.length; i++)
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
41 editors[i].onfocus = function() { gActiveEditor = this; };
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
42 gCommandDump = document.querySelector("#execCommand");
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
43 ExecCommand(document.querySelector("#useCSS"));
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
44 }, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
45 //]]></script>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
46 <style type="text/css">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
47 html {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
48 background: #111;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
49 color: #eee;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
50 font-family: sans-serif;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
51 font-size: 12px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
52 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
53 body {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
54 margin: 1em auto;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
55 padding: 5px 20px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
56 width: 600px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
57 background: #eee;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
58 color: #111;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
59 border: 2px solid #eee;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
60 overflow: auto;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
61 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
62 *[contenteditable] {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
63 margin: 1em 0;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
64 padding: 10px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
65 background: #fff;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
66 color: #111;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
67 border: 1px solid #ddd;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
68 outline: none;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
69 resize: both;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
70 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
71 #execCommand {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
72 padding-left: 5em;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
73 min-height: 1em;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
74 line-height: 1em;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
75 color: #555;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
76 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
77 footer {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
78 border-top: 1px solid #ccc;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
79 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
80 #toolbar {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
81 border-bottom: 1px solid #ccc;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
82 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
83 #toolbar dt {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
84 float: left;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
85 clear: both;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
86 width: 5em;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
87 line-height: 24px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
88 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
89 #toolbar dd {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
90 line-height: 24px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
91 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
92 #toolbar input {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
93 /* toolbar images taken from CKEditor */
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
94 background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAUPCAMAAACIlZC6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAMAUExURQAAAB5DQ///AANNxxU+PpiYmPeRKwMwMFPsYh0fojMzMw04OKQKABk3LLAOABwipq/V89jY2SgroVRXqSczrvGxU5WxHyVGRvz8/P9nAe3XW+yUJNQ6ARxCQstVBpWYyLkWAARY9FGP7Pt9DscmAmmd7uDcr2turz9Cpd53CHHI6YWIvN/e7A+bA42ANXuq8WdeNHGVDvfHCydFxRE7O/GRHP8AAJHU7vDw8tK5nxg/QPz//09xBgQYhu/oyMKBcNpoDaOkpPdeK4okAE9lx+LHwhY+Phhp7s/n5rrLeBJOzy5KSlTuYNx2GPCKV09SQ7uveB9l3LpXROrq7Q1Fy/f397/b2aeorMBIOAAzzP79Avz8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64715n4th1hZg9+lxJ0HfKR+TihE9x8+bCeOeI3iE//3Fh69kEzHxzLKJKefUuna9lneJBMVJP1ea3f2aCO02bTn1EDJYfK/hiYDZiyjj85ZXtyzIQsj5JdWzvytYfKVz5MB8h8asyZD6aQ8mHCHOejuaGp6dAu4a5vbn79cP/RQ489xsCex5qvNDU1Hdx1iN7gcGV9c3+ov7+/6fAhKuk/crB+PNTU9KvDzc2vAwCMj49fuXKlvz9Uv6/5pwAAe/f2n2pubj4Y6m86fBAAYPzD8T3NjXuunAj1hwAAYHzv3l80Nu/pH+9f9Sta7Yd7+xtP9Y+Pj/fzlo3vbd7z4fj4uGjqpxfGL4yPX/glc1/baQQHT548EDSCr3DJa7tf3b17924AgP8bADsP4s1ClpYJAAAAAElFTkSuQmCC);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
95 height: 20px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
96 width: 20px;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
97 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
98 #toolbar *[disabled] {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
99 opacity: 0.5;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
100 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
101 #toolbar *[data-command="increaseFontSize"],
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
102 #toolbar *[data-command="decreaseFontSize"] {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
103 background-image: none;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
104 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
105 #toolbar *[type="checkbox"] {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
106 margin: 0;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
107 padding: 0;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
108 vertical-align: middle;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
109 background-image: none;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
110 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
111 *[data-command="cut"] { background-position: 0 -96px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
112 *[data-command="copy"] { background-position: 0 -112px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
113 *[data-command="paste"] { background-position: 0 -128px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
114 *[data-command="undo"] { background-position: 0 -208px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
115 *[data-command="redo"] { background-position: 0 -224px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
116 *[data-command="bold"] { background-position: 0 -304px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
117 *[data-command="italic"] { background-position: 0 -320px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
118 *[data-command="underline"] { background-position: 0 -336px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
119 *[data-command="strikeThrough"] { background-position: 0 -352px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
120 *[data-command="subscript"] { background-position: 0 -368px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
121 *[data-command="superscript"] { background-position: 0 -384px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
122 *[data-command="insertOrderedList"] { background-position: 0 -400px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
123 *[data-command="insertUnorderedList"] { background-position: 0 -416px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
124 *[data-command="outdent"] { background-position: 0 -432px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
125 *[data-command="indent"] { background-position: 0 -448px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
126 *[data-command="justifyLeft"] { background-position: 0 -464px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
127 *[data-command="justifyCenter"] { background-position: 0 -480px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
128 *[data-command="justifyRight"] { background-position: 0 -496px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
129 *[data-command="justifyFull"] { background-position: 0 -512px; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
130 </style>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
131 <!--
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
132 - Mutation Events:
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
133 - https://developer.mozilla.org/en/XUL/Events#Mutation_DOM_events
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
134 -->
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
135 <script type="text/javascript">//<![CDATA[
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
136 var gBreadCrumb = null;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
137 function updateBreadCrumb(node, action) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
138 if (!gBreadCrumb || !node || (node == document.body)) return;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
139 var
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
140 body = document.body,
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
141 text = node.nodeName,
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
142 tmp = node.parentNode;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
143 while (tmp && tmp != body) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
144 text = tmp.nodeName + " > " + text;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
145 tmp = tmp.parentNode;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
146 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
147 text = action + ": " + text;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
148 gBreadCrumb.innerHTML = text;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
149 console.log(text);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
150 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
151
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
152 // retrieve the startContainer of the current selection
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
153 var gLastFocusNode = null;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
154 function getSelectionStart() {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
155 var node = document.getSelection().anchorNode;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
156 return (node.nodeName == "#text" ? node.parentNode : node);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
157 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
158 function onCaretMove(event, action) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
159 var selection = document.getSelection();
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
160 var node = selection.isCollapsed ? selection.focusNode
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
161 : selection.getRangeAt(0).commonAncestorContainer;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
162 if (node != gLastFocusNode) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
163 updateBreadCrumb(node, action);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
164 gLastFocusNode = node;
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
165 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
166 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
167
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
168 window.addEventListener("DOMContentLoaded", function() {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
169 gBreadCrumb = document.querySelector("#breadcrumb");
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
170
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
171 function onAttrModified(event) { updateBreadCrumb(event.target, "keypress"); }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
172 function onNodeInserted(event) { updateBreadCrumb(event.target, "inserted"); }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
173 function onNodeRemoved(event) { updateBreadCrumb(event.target, "removed "); }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
174
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
175 function onKeyUp(event) { onCaretMove(event, "keyup"); }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
176 function onClick(event) { onCaretMove(event, "click"); }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
177
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
178 // listening to mutation events on 'document' freezes Firefox :-/
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
179 var i, editors = document.querySelectorAll("*[contenteditable]");
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
180 for (i = 0; i < editors.length; i++) {
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
181 // mutation events -- do we really need them?
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
182 editors[i].addEventListener("DOMAttrModified", onAttrModified, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
183 editors[i].addEventListener("DOMNodeInserted", onNodeInserted, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
184 editors[i].addEventListener("DOMNodeRemoved", onNodeRemoved, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
185 // caret movements
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
186 //editors[i].addEventListener("textinput", onKeyUp, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
187 editors[i].addEventListener("keyup", onKeyUp, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
188 editors[i].addEventListener("mouseup", onClick, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
189 }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
190 }, false);
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
191 //]]></script>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
192 <style type="text/css">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
193 .attrModified { border: 1px dashed red; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
194 .nodeModified { border: 1px dashed navy; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
195 .nodeInserted { border: 1px dotted brown; }
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
196 </style>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
197 </head>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
198 <body>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
199 <form id="toolbar">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
200 <dl>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
201 <dt> edit: </dt>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
202 <dd>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
203 <input type="button" value=" " data-command="undo" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
204 <input type="button" value=" " data-command="redo" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
205 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
206 <input type="button" value=" " data-command="cut" disabled="" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
207 <input type="button" value=" " data-command="copy" disabled="" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
208 <input type="button" value=" " data-command="paste" disabled="" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
209 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
210 <input type="checkbox" id="useCSS" data-command="styleWithCSS" checked="" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
211 <label for="useCSS">style with CSS</label>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
212 </dd>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
213 <dt> inline: </dt>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
214 <dd>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
215 <select data-command="fontName">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
216 <option value="" disabled="" selected=""> Font </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
217 <option value="serif"> serif </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
218 <option value="sans-serif"> sans-serif </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
219 <option value="monospace"> monospace </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
220 <option value=" " disabled=""> - </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
221 <option value="Arial"> Arial </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
222 <option value="Courier New"> Courier New </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
223 <option value="Times New Roman"> Times New Roman </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
224 <option value="Verdana"> Verdana </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
225 </select>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
226 <select data-command="fontSize">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
227 <option value="" disabled="" selected=""> Size </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
228 <option value="1"> 1 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
229 <option value="2"> 2 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
230 <option value="3"> 3 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
231 <option value="4"> 4 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
232 <option value="5"> 5 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
233 <option value="6"> 6 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
234 <option value="7"> 7 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
235 </select>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
236 <input type="button" value="-" data-command="decreaseFontSize" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
237 <input type="button" value="+" data-command="increaseFontSize" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
238 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
239 <input type="button" value=" " data-command="bold" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
240 <input type="button" value=" " data-command="italic" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
241 <input type="button" value=" " data-command="underline" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
242 <input type="button" value=" " data-command="strikeThrough" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
243 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
244 <input type="button" value=" " data-command="subscript" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
245 <input type="button" value=" " data-command="superscript" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
246 </dd>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
247 <dt> block: </dt>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
248 <dd>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
249 <select data-command="formatBlock">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
250 <option value="" disabled="" selected=""> Format </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
251 <option value="&lt;p&gt;"> paragraph </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
252 <option value="&lt;h1&gt;"> heading 1 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
253 <option value="&lt;h2&gt;"> heading 2 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
254 <option value="&lt;h3&gt;"> heading 3 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
255 <option value="&lt;h4&gt;"> heading 4 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
256 <option value="&lt;h5&gt;"> heading 5 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
257 <option value="&lt;h6&gt;"> heading 6 </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
258 <option value="&lt;address&gt;"> address </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
259 <option value="&lt;pre&gt;"> preformatted </option>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
260 </select>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
261 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
262 <input type="button" value=" " data-command="justifyLeft" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
263 <input type="button" value=" " data-command="justifyCenter" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
264 <input type="button" value=" " data-command="justifyRight" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
265 <input type="button" value=" " data-command="justifyFull" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
266 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
267 <input type="button" value=" " data-command="outdent" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
268 <input type="button" value=" " data-command="indent" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
269 |
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
270 <input type="button" value=" " data-command="insertOrderedList" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
271 <input type="button" value=" " data-command="insertUnorderedList" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
272 </dd>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
273 </dl>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
274 <pre id="execCommand" />
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
275 </form>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
276 <pre id="breadcrumb"> </pre>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
277
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
278 <section contenteditable="true">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
279 <h2> Go ahead, edit away! </h2>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
280 <p> Here's a typical paragraph element </p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
281 <ol><li> and now a list </li><li> with only </li><li> three items </li></ol>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
282 </section>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
283
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
284 <footer contenteditable="true">
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
285 <p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
286 This HTML content editor is not intended to compete with <a
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
287 href="http://ckeditor.com/">CKEditor</a> or <a
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
288 href="http://tinymce.com/">TinyMCE</a>: it is designed to
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
289 <strong>test</strong> the various implementations of
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
290 <code>contentEditable</code> and <code>execCommand</code>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
291 in modern browsers.
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
292 </p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
293 <p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
294 This is a standalone file: the JavaScript code (&lt;40 lines!), CSS markup and
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
295 images are embedded. Feel free to download it to try it offline.
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
296 </p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
297 <p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
298 Useful links:
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
299 <a href="https://developer.mozilla.org/en/Rich-Text_Editing_in_Mozilla">Mozilla Developer Network</a>,
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
300 <a href="http://html5demos.com/contenteditable/">html5demos.com</a>,
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
301 <a href="http://www.browserscope.org/richtext2/test">Browserscope.org</a>.
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
302 </p>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
303 </footer>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
304 </body>
891d16fda2e2 initial push
Sonny Piers <sonny.piers@gmail.com>
parents:
diff changeset
305 </html>