r105710 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105709‎ | r105710 | r105711 >
Date:20:40, 9 December 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added support for loading multiple documents in the demo/sandbox
Modified paths:
  • /trunk/extensions/VisualEditor/SpecialVisualEditorSandbox.php (modified) (history)
  • /trunk/extensions/VisualEditor/demo/index.html (modified) (history)
  • /trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/sandbox/sandbox.css (modified) (history)
  • /trunk/extensions/VisualEditor/modules/sandbox/sandbox.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/SpecialVisualEditorSandbox.php
@@ -23,6 +23,10 @@
2424
2525 $out = <<<HTML
2626 <!-- VisualEditor Sandbox -->
 27+<div id="es-docs">
 28+ <div id="es-docs-label">Example documents:</div>
 29+ <ul id="es-docs-list" ></ul>
 30+</div>
2731 <div id="es-base">
2832 <div id="es-toolbar" class="es-toolbar">
2933 <div id="es-modes" class="es-modes">
Index: trunk/extensions/VisualEditor/demo/index.html
@@ -23,6 +23,7 @@
2424 }
2525 #es-base {
2626 margin: 2em;
 27+ margin-top: 0em;
2728 -webkit-box-shadow: 0 0.25em 1.5em 0 #dddddd;
2829 -moz-box-shadow: 0 0.25em 1.5em 0 #dddddd;
2930 box-shadow: 0 0.25em 1.5em 0 #dddddd;
@@ -58,9 +59,16 @@
5960 right: 2em;
6061 top: 0;
6162 }
 63+ #es-docs {
 64+ margin-left: 2.5em;
 65+ }
6266 </style>
6367 </head>
6468 <body>
 69+ <div id="es-docs">
 70+ <div id="es-docs-label">Example documents:</div>
 71+ <ul id="es-docs-list" ></ul>
 72+ </div>
6573 <div id="es-base">
6674 <div id="es-toolbar" class="es-toolbar">
6775 <div id="es-modes" class="es-modes">
Index: trunk/extensions/VisualEditor/modules/es/models/es.SurfaceModel.js
@@ -28,6 +28,12 @@
2929
3030 /* Methods */
3131
 32+es.SurfaceModel.prototype.purgeHistory = function() {
 33+ this.selection = null;
 34+ this.history = [];
 35+ this.historyIndex = 0;
 36+ this.currentLengthDifference = 0;
 37+};
3238
3339 /**
3440 * Gets the document model of the surface.
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.css
@@ -180,4 +180,26 @@
181181 #es-panel-history div.es-panel-history-active {
182182 color: #000000;
183183 background-color: white;
184 -}
\ No newline at end of file
 184+}
 185+
 186+#es-docs {
 187+ margin-bottom: 1em;
 188+}
 189+
 190+#es-docs-label {
 191+ display: inline-block;
 192+}
 193+
 194+#es-docs-list {
 195+ list-style: none;
 196+ margin: 0;
 197+ padding: 0;
 198+ display: inline-block;
 199+}
 200+
 201+.es-docs-listItem {
 202+ list-style: none;
 203+ margin: 0 0.75em 0 0;
 204+ padding: 0;
 205+ display: inline-block;
 206+}
Index: trunk/extensions/VisualEditor/modules/sandbox/sandbox.js
@@ -1,449 +1,501 @@
22 $(document).ready( function() {
3 - window.wikiDom = {
4 - 'type': 'document',
5 - 'children': [
6 - {
7 - 'type': 'heading',
8 - 'attributes': { 'level': 1 },
9 - 'content': { 'text': 'Direct manipulation interface' }
10 - },
11 - {
12 - 'type': 'paragraph',
13 - 'content': {
14 - 'text': 'In computer science, direct manipulation is a human-computer interaction style which involves continuous representation of objects of interest, and rapid, reversible, incremental actions and feedback. The intention is to allow a user to directly manipulate objects presented to them, using actions that correspond at least loosely to the physical world. An example of direct-manipulation is resizing a graphical shape, such as a rectangle, by dragging its corners or edges with a mouse.',
15 - 'annotations': [
16 - {
17 - 'type': 'link/internal',
18 - 'data': {
19 - 'title': 'Computer_science'
 3+ var wikidoms = {
 4+ 'Direct manipulation interface': {
 5+ 'type': 'document',
 6+ 'children': [
 7+ {
 8+ 'type': 'heading',
 9+ 'attributes': { 'level': 1 },
 10+ 'content': { 'text': 'Direct manipulation interface' }
 11+ },
 12+ {
 13+ 'type': 'paragraph',
 14+ 'content': {
 15+ 'text': 'In computer science, direct manipulation is a human-computer interaction style which involves continuous representation of objects of interest, and rapid, reversible, incremental actions and feedback. The intention is to allow a user to directly manipulate objects presented to them, using actions that correspond at least loosely to the physical world. An example of direct-manipulation is resizing a graphical shape, such as a rectangle, by dragging its corners or edges with a mouse.',
 16+ 'annotations': [
 17+ {
 18+ 'type': 'link/internal',
 19+ 'data': {
 20+ 'title': 'Computer_science'
 21+ },
 22+ 'range': {
 23+ 'start': 3,
 24+ 'end': 19
 25+ }
2026 },
21 - 'range': {
22 - 'start': 3,
23 - 'end': 19
 27+ {
 28+ 'type': 'link/internal',
 29+ 'data': {
 30+ 'title': 'Human-computer interaction'
 31+ },
 32+ 'range': {
 33+ 'start': 46,
 34+ 'end': 72
 35+ }
2436 }
25 - },
26 - {
27 - 'type': 'link/internal',
28 - 'data': {
29 - 'title': 'Human-computer interaction'
 37+ ]
 38+ }
 39+ },
 40+ {
 41+ 'type': 'paragraph',
 42+ 'content': { 'text': 'Having real-world metaphors for objects and actions can make it easier for a user to learn and use an interface (some might say that the interface is more natural or intuitive), and rapid, incremental feedback allows a user to make fewer errors and complete tasks in less time, because they can see the results of an action before completing the action, thus evaluating the output and compensating for mistakes.' }
 43+ },
 44+ {
 45+ 'type': 'paragraph',
 46+ 'content': {
 47+ 'text': 'The term was introduced by Ben Shneiderman in 1983 within the context of office applications and the desktop metaphor. Individuals in academia and computer scientists doing research on future user interfaces often put as much or even more stress on tactile control and feedback, or sonic control and feedback than on the visual feedback given by most GUIs. As a result the term direct manipulation interface has been more widespread in these environments. ',
 48+ 'annotations': [
 49+ {
 50+ 'type': 'link/internal',
 51+ 'data': {
 52+ 'title': 'Ben_Shneiderman'
 53+ },
 54+ 'range': {
 55+ 'start': 27,
 56+ 'end': 42
 57+ }
3058 },
31 - 'range': {
32 - 'start': 46,
33 - 'end': 72
34 - }
35 - }
36 - ]
37 - }
38 - },
39 - {
40 - 'type': 'paragraph',
41 - 'content': { 'text': 'Having real-world metaphors for objects and actions can make it easier for a user to learn and use an interface (some might say that the interface is more natural or intuitive), and rapid, incremental feedback allows a user to make fewer errors and complete tasks in less time, because they can see the results of an action before completing the action, thus evaluating the output and compensating for mistakes.' }
42 - },
43 - {
44 - 'type': 'paragraph',
45 - 'content': {
46 - 'text': 'The term was introduced by Ben Shneiderman in 1983 within the context of office applications and the desktop metaphor. Individuals in academia and computer scientists doing research on future user interfaces often put as much or even more stress on tactile control and feedback, or sonic control and feedback than on the visual feedback given by most GUIs. As a result the term direct manipulation interface has been more widespread in these environments. ',
47 - 'annotations': [
48 - {
49 - 'type': 'link/internal',
50 - 'data': {
51 - 'title': 'Ben_Shneiderman'
 59+ {
 60+ 'type': 'link/internal',
 61+ 'data': {
 62+ 'title': 'GUI'
 63+ },
 64+ 'range': {
 65+ 'start': 352,
 66+ 'end': 356
 67+ }
5268 },
53 - 'range': {
54 - 'start': 27,
55 - 'end': 42
56 - }
57 - },
58 - {
59 - 'type': 'link/internal',
60 - 'data': {
61 - 'title': 'GUI'
 69+ {
 70+ 'type': 'object/hook',
 71+ 'data': {
 72+ 'html': '<sup><small><a href="#">[1]</a></small></sup>'
 73+ },
 74+ 'range': {
 75+ 'start': 118,
 76+ 'end': 119
 77+ }
6278 },
63 - 'range': {
64 - 'start': 352,
65 - 'end': 356
66 - }
67 - },
68 - {
69 - 'type': 'object/hook',
70 - 'data': {
71 - 'html': '<sup><small><a href="#">[1]</a></small></sup>'
72 - },
73 - 'range': {
74 - 'start': 118,
75 - 'end': 119
76 - }
77 - },
78 - {
79 - 'type': 'object/template',
80 - 'data': {
81 - 'html': '<sup><small>[<a href="#">citation needed</a>]</small></sup>'
82 - },
83 - 'range': {
84 - 'start': 456,
85 - 'end': 457
86 - }
87 - }
88 - ]
89 - }
90 - },
91 - {
92 - 'type': 'heading',
93 - 'attributes': { 'level': 2 },
94 - 'content': { 'text': 'In contrast to WIMP/GUI interfaces' }
95 - },
96 - {
97 - 'type': 'paragraph',
98 - 'content': {
99 - 'text': 'Direct manipulation is closely associated with interfaces that use windows, icons, menus, and a pointing device (WIMP GUI) as these almost always incorporate direct manipulation to at least some degree. However, direct manipulation should not be confused with these other terms, as it does not imply the use of windows or even graphical output. For example, direct manipulation concepts can be applied to interfaces for blind or vision-impaired users, using a combination of tactile and sonic devices and software.',
100 - 'annotations': [
101 - {
102 - 'type': 'link/internal',
103 - 'data': {
104 - 'title': 'WIMP_(computing)'
105 - },
106 - 'range': {
107 - 'start': 113,
108 - 'end': 117
109 - }
110 - }
111 - ]
112 - }
113 - },
114 - {
115 - 'type': 'paragraph',
116 - 'content': {
117 - 'text': 'It is also possible to design a WIMP interface that intentionally does not make use of direct manipulation. For example, most versions of windowing interfaces (e.g. Microsoft Windows) allowed users to reposition a window by dragging it with the mouse, but would not continually redraw the complete window at intermediate positions during the drag. Instead, for example, a rectangular outline of the window might be drawn during the drag, with the complete window contents being redrawn only once the user had released the mouse button. This was necessary on older computers that lacked the memory and/or CPU power to quickly redraw data behind a window that was being dragged.',
118 - 'annotations': [
119 - {
120 - 'type': 'link/internal',
121 - 'data': {
122 - 'title': 'Microsoft_Windows'
123 - },
124 - 'range': {
125 - 'start': 165,
126 - 'end': 182
127 - }
128 - }
129 - ]
130 - }
131 - },
132 - {
133 - 'type': 'heading',
134 - 'attributes': { 'level': 1 },
135 - 'content': {
136 - 'text': 'This is a heading (level 1)',
137 - 'annotations': [
138 - {
139 - 'type': 'textStyle/italic',
140 - 'range': {
141 - 'start': 10,
142 - 'end': 17
143 - }
144 - }
145 - ]
146 - }
147 - },
148 - {
149 - 'type': 'paragraph',
150 - 'content': { 'text': 'Paragraph' }
151 - },
152 - {
153 - 'type': 'heading',
154 - 'attributes': { 'level': 2 },
155 - 'content': {
156 - 'text': 'This is a heading (level 2)',
157 - 'annotations': [
158 - {
159 - 'type': 'textStyle/italic',
160 - 'range': {
161 - 'start': 10,
162 - 'end': 17
163 - }
164 - }
165 - ]
166 - }
167 - },
168 - {
169 - 'type': 'paragraph',
170 - 'content': { 'text': 'Paragraph' }
171 - },
172 - {
173 - 'type': 'heading',
174 - 'attributes': { 'level': 3 },
175 - 'content': {
176 - 'text': 'This is a heading (level 3)',
177 - 'annotations': [
178 - {
179 - 'type': 'textStyle/italic',
180 - 'range': {
181 - 'start': 10,
182 - 'end': 17
183 - }
184 - }
185 - ]
186 - }
187 - },
188 - {
189 - 'type': 'paragraph',
190 - 'content': { 'text': 'Paragraph' }
191 - },
192 - {
193 - 'type': 'heading',
194 - 'attributes': { 'level': 4 },
195 - 'content': {
196 - 'text': 'This is a heading (level 4)',
197 - 'annotations': [
198 - {
199 - 'type': 'textStyle/italic',
200 - 'range': {
201 - 'start': 10,
202 - 'end': 17
203 - }
204 - }
205 - ]
206 - }
207 - },
208 - {
209 - 'type': 'paragraph',
210 - 'content': { 'text': 'Paragraph' }
211 - },
212 - {
213 - 'type': 'heading',
214 - 'attributes': { 'level': 5 },
215 - 'content': {
216 - 'text': 'This is a heading (level 5)',
217 - 'annotations': [
218 - {
219 - 'type': 'textStyle/italic',
220 - 'range': {
221 - 'start': 10,
222 - 'end': 17
223 - }
224 - }
225 - ]
226 - }
227 - },
228 - {
229 - 'type': 'paragraph',
230 - 'content': { 'text': 'Paragraph' }
231 - },
232 - {
233 - 'type': 'heading',
234 - 'attributes': { 'level': 6 },
235 - 'content': {
236 - 'text': 'This is a heading (level 6)',
237 - 'annotations': [
238 - {
239 - 'type': 'textStyle/italic',
240 - 'range': {
241 - 'start': 10,
242 - 'end': 17
243 - }
244 - }
245 - ]
246 - }
247 - },
248 - {
249 - 'type': 'paragraph',
250 - 'content': { 'text': 'Paragraph' }
251 - },
252 - {
253 - 'type': 'list',
254 - 'children': [
255 - {
256 - 'type': 'listItem',
257 - 'attributes': {
258 - 'styles': ['bullet']
259 - },
260 - 'children' : [
26179 {
262 - 'type': 'paragraph',
263 - 'content': { 'text': 'Bullet' }
 80+ 'type': 'object/template',
 81+ 'data': {
 82+ 'html': '<sup><small>[<a href="#">citation needed</a>]</small></sup>'
 83+ },
 84+ 'range': {
 85+ 'start': 456,
 86+ 'end': 457
 87+ }
26488 }
26589 ]
26690 }
267 - ]
268 - },
269 - {
270 - 'type': 'paragraph',
271 - 'content': { 'text': 'Paragraph' }
272 - },
273 - {
274 - 'type': 'list',
275 - 'children': [
276 - {
277 - 'type': 'listItem',
278 - 'attributes': {
279 - 'styles': ['bullet']
280 - },
281 - 'children' : [
 91+ },
 92+ {
 93+ 'type': 'heading',
 94+ 'attributes': { 'level': 2 },
 95+ 'content': { 'text': 'In contrast to WIMP/GUI interfaces' }
 96+ },
 97+ {
 98+ 'type': 'paragraph',
 99+ 'content': {
 100+ 'text': 'Direct manipulation is closely associated with interfaces that use windows, icons, menus, and a pointing device (WIMP GUI) as these almost always incorporate direct manipulation to at least some degree. However, direct manipulation should not be confused with these other terms, as it does not imply the use of windows or even graphical output. For example, direct manipulation concepts can be applied to interfaces for blind or vision-impaired users, using a combination of tactile and sonic devices and software.',
 101+ 'annotations': [
282102 {
283 - 'type': 'paragraph',
284 - 'content': { 'text': 'Bullet' }
 103+ 'type': 'link/internal',
 104+ 'data': {
 105+ 'title': 'WIMP_(computing)'
 106+ },
 107+ 'range': {
 108+ 'start': 113,
 109+ 'end': 117
 110+ }
285111 }
286112 ]
287 - },
288 - {
289 - 'type': 'listItem',
290 - 'attributes': {
291 - 'styles': ['bullet', 'bullet']
292 - },
293 - 'children' : [
 113+ }
 114+ },
 115+ {
 116+ 'type': 'paragraph',
 117+ 'content': {
 118+ 'text': 'It is also possible to design a WIMP interface that intentionally does not make use of direct manipulation. For example, most versions of windowing interfaces (e.g. Microsoft Windows) allowed users to reposition a window by dragging it with the mouse, but would not continually redraw the complete window at intermediate positions during the drag. Instead, for example, a rectangular outline of the window might be drawn during the drag, with the complete window contents being redrawn only once the user had released the mouse button. This was necessary on older computers that lacked the memory and/or CPU power to quickly redraw data behind a window that was being dragged.',
 119+ 'annotations': [
294120 {
295 - 'type': 'paragraph',
296 - 'content': { 'text': 'Bullet bullet' }
 121+ 'type': 'link/internal',
 122+ 'data': {
 123+ 'title': 'Microsoft_Windows'
 124+ },
 125+ 'range': {
 126+ 'start': 165,
 127+ 'end': 182
 128+ }
297129 }
298130 ]
299 - },
300 - {
301 - 'type': 'listItem',
302 - 'attributes': {
303 - 'styles': ['bullet', 'bullet', 'bullet']
304 - },
305 - 'children' : [
 131+ }
 132+ }
 133+ ]
 134+ },
 135+ 'Headings and paragraphs': {
 136+ 'type': 'document',
 137+ 'children': [
 138+ {
 139+ 'type': 'heading',
 140+ 'attributes': { 'level': 1 },
 141+ 'content': {
 142+ 'text': 'This is a heading (level 1)',
 143+ 'annotations': [
306144 {
307 - 'type': 'paragraph',
308 - 'content': { 'text': 'Bullet bullet bullet' }
 145+ 'type': 'textStyle/italic',
 146+ 'range': {
 147+ 'start': 10,
 148+ 'end': 17
 149+ }
309150 }
310 - ]
311 - },
312 - {
313 - 'type': 'listItem',
314 - 'attributes': {
315 - 'styles': ['number']
316 - },
317 - 'children' : [
 151+ ]
 152+ }
 153+ },
 154+ {
 155+ 'type': 'paragraph',
 156+ 'content': { 'text': 'Paragraph' }
 157+ },
 158+ {
 159+ 'type': 'heading',
 160+ 'attributes': { 'level': 2 },
 161+ 'content': {
 162+ 'text': 'This is a heading (level 2)',
 163+ 'annotations': [
318164 {
319 - 'type': 'paragraph',
320 - 'content': { 'text': 'Number' }
 165+ 'type': 'textStyle/italic',
 166+ 'range': {
 167+ 'start': 10,
 168+ 'end': 17
 169+ }
321170 }
322 - ]
323 - },
324 - {
325 - 'type': 'listItem',
326 - 'attributes': {
327 - 'styles': ['number', 'number']
328 - },
329 - 'children' : [
 171+ ]
 172+ }
 173+ },
 174+ {
 175+ 'type': 'paragraph',
 176+ 'content': { 'text': 'Paragraph' }
 177+ },
 178+ {
 179+ 'type': 'heading',
 180+ 'attributes': { 'level': 3 },
 181+ 'content': {
 182+ 'text': 'This is a heading (level 3)',
 183+ 'annotations': [
330184 {
331 - 'type': 'paragraph',
332 - 'content': { 'text': 'Number number' }
 185+ 'type': 'textStyle/italic',
 186+ 'range': {
 187+ 'start': 10,
 188+ 'end': 17
 189+ }
333190 }
334 - ]
335 - },
336 - {
337 - 'type': 'listItem',
338 - 'attributes': {
339 - 'styles': ['term']
340 - },
341 - 'children' : [
 191+ ]
 192+ }
 193+ },
 194+ {
 195+ 'type': 'paragraph',
 196+ 'content': { 'text': 'Paragraph' }
 197+ },
 198+ {
 199+ 'type': 'heading',
 200+ 'attributes': { 'level': 4 },
 201+ 'content': {
 202+ 'text': 'This is a heading (level 4)',
 203+ 'annotations': [
342204 {
343 - 'type': 'paragraph',
344 - 'content': { 'text': 'Term' }
 205+ 'type': 'textStyle/italic',
 206+ 'range': {
 207+ 'start': 10,
 208+ 'end': 17
 209+ }
345210 }
346 - ]
347 - },
348 - {
349 - 'type': 'listItem',
350 - 'attributes': {
351 - 'styles': ['definition']
352 - },
353 - 'children' : [
 211+ ]
 212+ }
 213+ },
 214+ {
 215+ 'type': 'paragraph',
 216+ 'content': { 'text': 'Paragraph' }
 217+ },
 218+ {
 219+ 'type': 'heading',
 220+ 'attributes': { 'level': 5 },
 221+ 'content': {
 222+ 'text': 'This is a heading (level 5)',
 223+ 'annotations': [
354224 {
355 - 'type': 'paragraph',
356 - 'content': { 'text': 'Definition' }
 225+ 'type': 'textStyle/italic',
 226+ 'range': {
 227+ 'start': 10,
 228+ 'end': 17
 229+ }
357230 }
358 - ]
 231+ ]
359232 }
360 - ]
361 - },
362 - {
 233+ },
 234+ {
 235+ 'type': 'paragraph',
 236+ 'content': { 'text': 'Paragraph' }
 237+ },
 238+ {
 239+ 'type': 'heading',
 240+ 'attributes': { 'level': 6 },
 241+ 'content': {
 242+ 'text': 'This is a heading (level 6)',
 243+ 'annotations': [
 244+ {
 245+ 'type': 'textStyle/italic',
 246+ 'range': {
 247+ 'start': 10,
 248+ 'end': 17
 249+ }
 250+ }
 251+ ]
 252+ }
 253+ },
 254+ {
 255+ 'type': 'paragraph',
 256+ 'content': { 'text': 'Paragraph' }
 257+ },
 258+ {
363259 'type': 'pre',
364260 'content': { 'text': 'A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps.. A lot of text goes here... and at some point it wraps..' }
365 - }/*,
366 - {
367 - 'type': 'table',
368 - 'attributes': { 'html/style': 'width: 600px; border: solid 1px;' },
369 - 'children': [
370 - {
371 - 'type': 'tableRow',
372 - 'children': [
373 - {
374 - 'type': 'tableCell',
375 - 'attributes': { 'html/style': 'border: solid 1px;' },
376 - 'children': [
377 - {
378 - 'type': 'paragraph',
379 - 'content': { 'text': 'row 1 & cell 1' }
380 - },
381 - {
382 - 'type': 'list',
383 - 'children': [
384 - {
385 - 'type': 'listItem',
386 - 'attributes': {
387 - 'styles': ['bullet']
 261+ }
 262+ ]
 263+ },
 264+ 'Lists': {
 265+ 'type': 'document',
 266+ 'children': [
 267+ {
 268+ 'type': 'heading',
 269+ 'attributes': { 'level': 1 },
 270+ 'content': { 'text': 'Lists' }
 271+ },
 272+ {
 273+ 'type': 'list',
 274+ 'children': [
 275+ {
 276+ 'type': 'listItem',
 277+ 'attributes': {
 278+ 'styles': ['bullet']
 279+ },
 280+ 'children' : [
 281+ {
 282+ 'type': 'paragraph',
 283+ 'content': { 'text': 'Bullet' }
 284+ }
 285+ ]
 286+ }
 287+ ]
 288+ },
 289+ {
 290+ 'type': 'paragraph',
 291+ 'content': { 'text': 'Paragraph' }
 292+ },
 293+ {
 294+ 'type': 'list',
 295+ 'children': [
 296+ {
 297+ 'type': 'listItem',
 298+ 'attributes': {
 299+ 'styles': ['bullet']
 300+ },
 301+ 'children' : [
 302+ {
 303+ 'type': 'paragraph',
 304+ 'content': { 'text': 'Bullet' }
 305+ }
 306+ ]
 307+ },
 308+ {
 309+ 'type': 'listItem',
 310+ 'attributes': {
 311+ 'styles': ['bullet', 'bullet']
 312+ },
 313+ 'children' : [
 314+ {
 315+ 'type': 'paragraph',
 316+ 'content': { 'text': 'Bullet bullet' }
 317+ }
 318+ ]
 319+ },
 320+ {
 321+ 'type': 'listItem',
 322+ 'attributes': {
 323+ 'styles': ['bullet', 'bullet', 'bullet']
 324+ },
 325+ 'children' : [
 326+ {
 327+ 'type': 'paragraph',
 328+ 'content': { 'text': 'Bullet bullet bullet' }
 329+ }
 330+ ]
 331+ },
 332+ {
 333+ 'type': 'listItem',
 334+ 'attributes': {
 335+ 'styles': ['number']
 336+ },
 337+ 'children' : [
 338+ {
 339+ 'type': 'paragraph',
 340+ 'content': { 'text': 'Number' }
 341+ }
 342+ ]
 343+ },
 344+ {
 345+ 'type': 'listItem',
 346+ 'attributes': {
 347+ 'styles': ['number', 'number']
 348+ },
 349+ 'children' : [
 350+ {
 351+ 'type': 'paragraph',
 352+ 'content': { 'text': 'Number number' }
 353+ }
 354+ ]
 355+ },
 356+ {
 357+ 'type': 'listItem',
 358+ 'attributes': {
 359+ 'styles': ['term']
 360+ },
 361+ 'children' : [
 362+ {
 363+ 'type': 'paragraph',
 364+ 'content': { 'text': 'Term' }
 365+ }
 366+ ]
 367+ },
 368+ {
 369+ 'type': 'listItem',
 370+ 'attributes': {
 371+ 'styles': ['definition']
 372+ },
 373+ 'children' : [
 374+ {
 375+ 'type': 'paragraph',
 376+ 'content': { 'text': 'Definition' }
 377+ }
 378+ ]
 379+ }
 380+ ]
 381+ }
 382+ ]
 383+ },
 384+ 'Tables': {
 385+ 'type': 'document',
 386+ 'children': [
 387+ {
 388+ 'type': 'heading',
 389+ 'attributes': { 'level': 1 },
 390+ 'content': { 'text': 'Tables' }
 391+ },
 392+ {
 393+ 'type': 'table',
 394+ 'attributes': { 'html/style': 'width: 600px; border: solid 1px;' },
 395+ 'children': [
 396+ {
 397+ 'type': 'tableRow',
 398+ 'children': [
 399+ {
 400+ 'type': 'tableCell',
 401+ 'attributes': { 'html/style': 'border: solid 1px;' },
 402+ 'children': [
 403+ {
 404+ 'type': 'paragraph',
 405+ 'content': { 'text': 'row 1 & cell 1' }
 406+ },
 407+ {
 408+ 'type': 'list',
 409+ 'children': [
 410+ {
 411+ 'type': 'listItem',
 412+ 'attributes': {
 413+ 'styles': ['bullet']
 414+ },
 415+ 'children' : [
 416+ {
 417+ 'type': 'paragraph',
 418+ 'content': { 'text': 'Test 4444' }
 419+ }
 420+ ]
388421 },
389 - 'children' : [
390 - {
391 - 'type': 'paragraph',
392 - 'content': { 'text': 'Test 4444' }
393 - }
394 - ]
395 - },
396 - {
397 - 'type': 'listItem',
398 - 'attributes': {
399 - 'styles': ['bullet', 'bullet']
 422+ {
 423+ 'type': 'listItem',
 424+ 'attributes': {
 425+ 'styles': ['bullet', 'bullet']
 426+ },
 427+ 'children' : [
 428+ {
 429+ 'type': 'paragraph',
 430+ 'content': { 'text': 'Test 55555' }
 431+ }
 432+ ]
400433 },
401 - 'children' : [
402 - {
403 - 'type': 'paragraph',
404 - 'content': { 'text': 'Test 55555' }
405 - }
406 - ]
407 - },
408 - {
409 - 'type': 'listItem',
410 - 'attributes': {
411 - 'styles': ['number']
412 - },
413 - 'children' : [
414 - {
415 - 'type': 'paragraph',
416 - 'content': { 'text': 'Test 666666' }
417 - }
418 - ]
419 - }
420 - ]
421 - }
422 - ]
423 - },
424 - {
425 - 'type': 'tableCell',
426 - 'attributes': { 'html/style': 'border: solid 1px;' },
427 - 'children': [
428 - {
429 - 'type': 'paragraph',
430 - 'content': { 'text': 'row 1 & cell 2' }
431 - }
432 - ]
433 - }
434 - ]
435 - }
436 - ]
437 - }
438 - */
439 - ]
 434+ {
 435+ 'type': 'listItem',
 436+ 'attributes': {
 437+ 'styles': ['number']
 438+ },
 439+ 'children' : [
 440+ {
 441+ 'type': 'paragraph',
 442+ 'content': { 'text': 'Test 666666' }
 443+ }
 444+ ]
 445+ }
 446+ ]
 447+ }
 448+ ]
 449+ },
 450+ {
 451+ 'type': 'tableCell',
 452+ 'attributes': { 'html/style': 'border: solid 1px;' },
 453+ 'children': [
 454+ {
 455+ 'type': 'paragraph',
 456+ 'content': { 'text': 'row 1 & cell 2' }
 457+ }
 458+ ]
 459+ }
 460+ ]
 461+ }
 462+ ]
 463+ }
 464+ ]
 465+ }
440466 };
441 - window.doc = es.DocumentModel.newFromPlainObject( window.wikiDom );
442 - window.surfaceModel = new es.SurfaceModel( window.doc );
 467+ window.documentModel = es.DocumentModel.newFromPlainObject(
 468+ wikidoms['Direct manipulation interface']
 469+ );
 470+ window.surfaceModel = new es.SurfaceModel( window.documentModel );
443471 window.surfaceView = new es.SurfaceView( $( '#es-editor' ), window.surfaceModel );
444472 window.toolbarView = new es.ToolbarView( $( '#es-toolbar' ), window.surfaceView );
445473 window.contextView = new es.ContextView( window.surfaceView );
446474 window.surfaceModel.select( new es.Range( 1, 1 ) );
447475
 476+ var $docsList = $( '#es-docs-list' );
 477+ $.each( wikidoms, function( title, wikidom ) {
 478+ $docsList.append(
 479+ $( '<li class="es-docs-listItem"></li>' )
 480+ .append(
 481+ $( '<a href="#"></a>' )
 482+ .text( title )
 483+ .click( function() {
 484+ var newDocumentModel = es.DocumentModel.newFromPlainObject( wikidom );
 485+ documentModel.data.splice( 0, documentModel.data.length );
 486+ es.insertIntoArray( documentModel.data, 0, newDocumentModel.data );
 487+ surfaceModel.select( new es.Range( 1, 1 ) );
 488+ documentModel.splice.apply(
 489+ documentModel,
 490+ [0, documentModel.getChildren().length]
 491+ .concat( newDocumentModel.getChildren() )
 492+ );
 493+ surfaceModel.purgeHistory();
 494+ return false;
 495+ } )
 496+ )
 497+ );
 498+ } );
 499+
448500 var $modeButtons = $( '.es-modes-button' ),
449501 $panels = $( '.es-panel' ),
450502 $base = $( '#es-base' ),
@@ -454,14 +506,16 @@
455507 '$': $( '#es-mode-wikitext' ),
456508 '$panel': $( '#es-panel-wikitext' ),
457509 'update': function() {
458 - this.$panel.text( es.WikitextSerializer.stringify( doc.getPlainObject() ) );
 510+ this.$panel.text(
 511+ es.WikitextSerializer.stringify( documentModel.getPlainObject() )
 512+ );
459513 }
460514 },
461515 'json': {
462516 '$': $( '#es-mode-json' ),
463517 '$panel': $( '#es-panel-json' ),
464518 'update': function() {
465 - this.$panel.text( es.JsonSerializer.stringify( doc.getPlainObject(), {
 519+ this.$panel.text( es.JsonSerializer.stringify( documentModel.getPlainObject(), {
466520 'indentWith': ' '
467521 } ) );
468522 }
@@ -470,14 +524,18 @@
471525 '$': $( '#es-mode-html' ),
472526 '$panel': $( '#es-panel-html' ),
473527 'update': function() {
474 - this.$panel.text( es.HtmlSerializer.stringify( doc.getPlainObject() ) );
 528+ this.$panel.text(
 529+ es.HtmlSerializer.stringify( documentModel.getPlainObject() )
 530+ );
475531 }
476532 },
477533 'render': {
478534 '$': $( '#es-mode-render' ),
479535 '$panel': $( '#es-panel-render' ),
480536 'update': function() {
481 - this.$panel.html( es.HtmlSerializer.stringify( doc.getPlainObject() ) );
 537+ this.$panel.html(
 538+ es.HtmlSerializer.stringify( documentModel.getPlainObject() )
 539+ );
482540 }
483541 },
484542 'history': {

Status & tagging log