cirandas.net

ref: master

plugins/web_odf/public/wodotexteditor-0.5.9/docs/symbols/src/wodotexteditor.js.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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * Copyright (C) 2014 KO GmbH &lt;copyright@kogmbh.com>
<span class='line'>  3</span>  *
<span class='line'>  4</span>  * @licstart
<span class='line'>  5</span>  * This file is part of WebODF.
<span class='line'>  6</span>  *
<span class='line'>  7</span>  * WebODF is free software: you can redistribute it and/or modify it
<span class='line'>  8</span>  * under the terms of the GNU Affero General Public License (GNU AGPL)
<span class='line'>  9</span>  * as published by the Free Software Foundation, either version 3 of
<span class='line'> 10</span>  * the License, or (at your option) any later version.
<span class='line'> 11</span>  *
<span class='line'> 12</span>  * WebODF is distributed in the hope that it will be useful, but
<span class='line'> 13</span>  * WITHOUT ANY WARRANTY; without even the implied warranty of
<span class='line'> 14</span>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<span class='line'> 15</span>  * GNU Affero General Public License for more details.
<span class='line'> 16</span>  *
<span class='line'> 17</span>  * You should have received a copy of the GNU Affero General Public License
<span class='line'> 18</span>  * along with WebODF.  If not, see &lt;http://www.gnu.org/licenses/>.
<span class='line'> 19</span>  * @licend
<span class='line'> 20</span>  *
<span class='line'> 21</span>  * @source: http://www.webodf.org/
<span class='line'> 22</span>  * @source: https://github.com/kogmbh/WebODF/
<span class='line'> 23</span>  */</span><span class="WHIT">
<span class='line'> 24</span> 
<span class='line'> 25</span> </span><span class="COMM">/*global window, document, alert, navigator, require, dojo, runtime, core, gui, ops, odf, WodoFromSource*/</span><span class="WHIT">
<span class='line'> 26</span> 
<span class='line'> 27</span> </span><span class="COMM">/**
<span class='line'> 28</span>  * Namespace of the Wodo.TextEditor
<span class='line'> 29</span>  * @namespace
<span class='line'> 30</span>  * @name Wodo
<span class='line'> 31</span>  */</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="NAME">window.Wodo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.Wodo</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">    </span><span class="STRN">"use strict"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getInstallationPath</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 37</span>          * Sees to get the url of this script on top of the stack trace.
<span class='line'> 38</span>          * @param {!string|undefined} stack
<span class='line'> 39</span>          * @return {!string|undefined}
<span class='line'> 40</span>          */</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getScriptUrlFromStack</span><span class="PUNC">(</span><span class="NAME">stack</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">matches</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> 
<span class='line'> 44</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">stack</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="WHIT">                </span><span class="COMM">/*jslint regexp: true*/</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">                </span><span class="NAME">matches</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">stack.match</span><span class="PUNC">(</span><span class="REGX">/((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT">                </span><span class="COMM">/*jslint regexp: false*/</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="WHIT">                </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">matches</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">matches</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">url</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"string"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 55</span> 
<span class='line'> 56</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'> 57</span>          * Tries by various tricks to get the url of this script.
<span class='line'> 58</span>          * To be called if document.currentScript is not supported
<span class='line'> 59</span>          * @return {!string|undefined}
<span class='line'> 60</span>          */</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getCurrentScriptElementSrcByTricks</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">scriptElements</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">"script"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> </span><span class="WHIT">            </span><span class="COMM">// if there is only one script, it must be this</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">scriptElements.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">scriptElements</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">src</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 68</span> 
<span class='line'> 69</span> </span><span class="WHIT">            </span><span class="COMM">// otherwise get it from the stacktrace</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">                </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">getScriptUrlFromStack</span><span class="PUNC">(</span><span class="NAME">err.stack</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 76</span> 
<span class='line'> 77</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"."</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">scriptElementSrc</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">            </span><span class="NAME">a</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pathname</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 79</span> 
<span class='line'> 80</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">document.currentScript</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">document.currentScript.src</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">            </span><span class="NAME">scriptElementSrc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.currentScript.src</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">            </span><span class="NAME">scriptElementSrc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getCurrentScriptElementSrcByTricks</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 85</span> 
<span class='line'> 86</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">scriptElementSrc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">            </span><span class="NAME">a</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">'a'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">            </span><span class="NAME">a.href</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">scriptElementSrc</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">            </span><span class="NAME">pathname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.pathname</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pathname.charAt</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">                </span><span class="COMM">// Various versions of Internet Explorer seems to neglect the leading slash under some conditions</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">                </span><span class="COMM">// (not when watching it with the dev tools of course!). This was confirmed in IE10 + IE11</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">                </span><span class="NAME">pathname</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"/"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">pathname</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 95</span> 
<span class='line'> 96</span> </span><span class="WHIT">            </span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pathname.lastIndexOf</span><span class="PUNC">(</span><span class="STRN">"/"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pos</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">                </span><span class="NAME">path</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pathname.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pos</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">            </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">"Could not estimate installation path of the Wodo.TextEditor."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">path</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>105</span> 
<span class='line'>106</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="COMM">/** @inner @const
<span class='line'>107</span>             @type{!string} */</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">        </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getInstallationPath</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @type{!boolean} */</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">        </span><span class="NAME">isInitalized</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @type{!Array.&lt;!function():undefined>} */</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">        </span><span class="NAME">pendingInstanceCreationCalls</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @type{!number} */</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">        </span><span class="NAME">instanceCounter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">        </span><span class="COMM">// TODO: avatar image url needs base-url setting.</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">        </span><span class="COMM">// so far Wodo itself does not have a setup call,</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">        </span><span class="COMM">// but then the avatar is also not used yet here</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">        </span><span class="NAME">defaultUserData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">            </span><span class="NAME">fullName</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">            </span><span class="NAME">color</span><span class="PUNC">:</span><span class="WHIT">    </span><span class="STRN">"black"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">            </span><span class="NAME">imageUrl</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"avatar-joe.png"</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>124</span>             @type{!Array.&lt;!string>} */</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">        </span><span class="NAME">userDataFieldNames</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">"fullName"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"color"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"imageUrl"</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>127</span>             @type{!string} */</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">        </span><span class="NAME">memberId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"localuser"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">        </span><span class="COMM">// constructors</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">        </span><span class="NAME">BorderContainer</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ContentPane</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">FullWindowZoomHelper</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">EditorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Tools</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>132</span>             @type{!string} */</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">        </span><span class="NAME">MODUS_FULLEDITING</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"fullediting"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>135</span>             @type{!string} */</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">        </span><span class="NAME">MODUS_REVIEW</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"review"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>138</span>             @type{!string} */</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">        </span><span class="NAME">EVENT_UNKNOWNERROR</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"unknownError"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>141</span>             @type {!string} */</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">        </span><span class="NAME">EVENT_DOCUMENTMODIFIEDCHANGED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"documentModifiedChanged"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">        </span><span class="COMM">/** @inner @const
<span class='line'>144</span>             @type {!string} */</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">        </span><span class="NAME">EVENT_METADATACHANGED</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"metadataChanged"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> 
<span class='line'>147</span> </span><span class="WHIT">    </span><span class="NAME">window.dojoConfig</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">WebODFEditorDojoLocale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"C"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>149</span> 
<span class='line'>150</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">navigator</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">navigator.language</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">navigator.language.match</span><span class="PUNC">(</span><span class="REGX">/^(de)/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">            </span><span class="NAME">WebODFEditorDojoLocale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">navigator.language.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>153</span> 
<span class='line'>154</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">            </span><span class="NAME">locale</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">WebODFEditorDojoLocale</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">            </span><span class="NAME">paths</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">                </span><span class="STRN">"webodf/editor"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">installationPath</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">                </span><span class="STRN">"dijit"</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/dijit"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">                </span><span class="STRN">"dojox"</span><span class="PUNC">:</span><span class="WHIT">         </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/dojox"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">                </span><span class="STRN">"dojo"</span><span class="PUNC">:</span><span class="WHIT">          </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/dojo"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">                </span><span class="STRN">"resources"</span><span class="PUNC">:</span><span class="WHIT">     </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/resources"</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>165</span> 
<span class='line'>166</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>167</span>      * @return {undefined}
<span class='line'>168</span>      */</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">initTextEditor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">        </span><span class="NAME">require</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">            </span><span class="STRN">"dijit/layout/BorderContainer"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">            </span><span class="STRN">"dijit/layout/ContentPane"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">            </span><span class="STRN">"webodf/editor/FullWindowZoomHelper"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">            </span><span class="STRN">"webodf/editor/EditorSession"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">            </span><span class="STRN">"webodf/editor/Tools"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">            </span><span class="STRN">"webodf/editor/Translator"</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">            </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">BC</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">CP</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">FWZH</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ES</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">T</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">Translator</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">locale</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">navigator.language</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">"en-US"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">                    </span><span class="NAME">editorBase</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dojo.config</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">dojo.config.paths</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">dojo.config.paths</span><span class="PUNC">[</span><span class="STRN">"webodf/editor"</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">                    </span><span class="NAME">translationsDir</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">editorBase</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'/translations'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">                    </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> 
<span class='line'>183</span> </span><span class="WHIT">                </span><span class="NAME">BorderContainer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">BC</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">                </span><span class="NAME">ContentPane</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">CP</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">                </span><span class="NAME">FullWindowZoomHelper</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FWZH</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">                </span><span class="NAME">EditorSession</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ES</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">                </span><span class="NAME">Tools</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">T</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>188</span> 
<span class='line'>189</span> </span><span class="WHIT">                </span><span class="COMM">// TODO: locale cannot be set by the user, also different for different editors</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">                </span><span class="NAME">t</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Translator</span><span class="PUNC">(</span><span class="NAME">translationsDir</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">locale</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">editorTranslator</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">                    </span><span class="NAME">runtime.setTranslator</span><span class="PUNC">(</span><span class="NAME">editorTranslator.translate</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">                    </span><span class="COMM">// Extend runtime with a convenient translation function</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">                    </span><span class="NAME">runtime.translateContent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">                        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">                            </span><span class="NAME">element</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">                            </span><span class="NAME">tag</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">                            </span><span class="NAME">placeholder</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">                            </span><span class="NAME">translatable</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">node.querySelectorAll</span><span class="PUNC">(</span><span class="STRN">"*[text-i18n]"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>199</span> 
<span class='line'>200</span> </span><span class="WHIT">                        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">translatable.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">                            </span><span class="NAME">element</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">translatable</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">                            </span><span class="NAME">tag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">element.localName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">                            </span><span class="NAME">placeholder</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">element.getAttribute</span><span class="PUNC">(</span><span class="STRN">'text-i18n'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">                            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">tag</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"label"</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">                                    </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">tag</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"span"</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">                                    </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="REGX">/h\d/i</span><span class="PUNC">.</span><span class="NAME">test</span><span class="PUNC">(</span><span class="NAME">tag</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">                                </span><span class="NAME">element.textContent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">runtime.tr</span><span class="PUNC">(</span><span class="NAME">placeholder</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">                            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>209</span> </span><span class="WHIT">                        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>210</span> </span><span class="WHIT">                    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>211</span> 
<span class='line'>212</span> </span><span class="WHIT">                    </span><span class="NAME">defaultUserData.fullName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">runtime.tr</span><span class="PUNC">(</span><span class="STRN">"Unknown Author"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> 
<span class='line'>214</span> </span><span class="WHIT">                    </span><span class="NAME">isInitalized</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT">                    </span><span class="NAME">pendingInstanceCreationCalls.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">create</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">create</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span> 
<span class='line'>218</span> </span><span class="WHIT">                </span><span class="COMM">// only done to make jslint see the var used</span><span class="WHIT">
<span class='line'>219</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">t</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>220</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">        </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>223</span> 
<span class='line'>224</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>225</span>      * Creates a new record with userdata, and for all official fields
<span class='line'>226</span>      * copies over the value from the original or, if not present there,
<span class='line'>227</span>      * sets it to the default value.
<span class='line'>228</span>      * @param {?Object.&lt;!string,!string>|undefined} original, defaults to {}
<span class='line'>229</span>      * @return {!Object.&lt;!string,!string>}
<span class='line'>230</span>      */</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">cloneUserData</span><span class="PUNC">(</span><span class="NAME">original</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> 
<span class='line'>234</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">original</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">            </span><span class="NAME">original</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>237</span> 
<span class='line'>238</span> </span><span class="WHIT">        </span><span class="NAME">userDataFieldNames.forEach</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">fieldName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>239</span> </span><span class="WHIT">            </span><span class="NAME">result</span><span class="PUNC">[</span><span class="NAME">fieldName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">original</span><span class="PUNC">[</span><span class="NAME">fieldName</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">defaultUserData</span><span class="PUNC">[</span><span class="NAME">fieldName</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>240</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>241</span> 
<span class='line'>242</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>243</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>244</span> 
<span class='line'>245</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>246</span>      * @name TextEditor
<span class='line'>247</span>      * @constructor
<span class='line'>248</span>      * @param {!string} mainContainerElementId
<span class='line'>249</span>      * @param {!Object.&lt;!string,!*>} editorOptions
<span class='line'>250</span>      */</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">TextEditor</span><span class="PUNC">(</span><span class="NAME">mainContainerElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editorOptions</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">        </span><span class="NAME">instanceCounter</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">instanceCounter</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>253</span> 
<span class='line'>254</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>255</span>         * Returns true if either all features are wanted and this one is not explicitely disabled
<span class='line'>256</span>         * or if not all features are wanted by default and it is explicitely enabled
<span class='line'>257</span>         * @param {?boolean|undefined} isFeatureEnabled explicit flag which enables a feature
<span class='line'>258</span>         * @return {!boolean}
<span class='line'>259</span>         */</span><span class="WHIT">
<span class='line'>260</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">isFeatureEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>261</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">editorOptions.allFeaturesEnabled</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isFeatureEnabled</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">isFeatureEnabled</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>262</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>263</span> 
<span class='line'>264</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">userData</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>265</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT">            </span><span class="NAME">mainContainerElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementById</span><span class="PUNC">(</span><span class="NAME">mainContainerElementId</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT">            </span><span class="NAME">canvasElement</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">            </span><span class="NAME">canvasContainerElement</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">            </span><span class="NAME">toolbarElement</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">            </span><span class="NAME">toolbarContainerElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="COMM">// needed because dijit toolbar overwrites direct classList</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">            </span><span class="NAME">editorElement</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">            </span><span class="COMM">/** @inner @const
<span class='line'>273</span>                 @type{!string} */</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">            </span><span class="NAME">canvasElementId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-canvas"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">instanceCounter</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">            </span><span class="COMM">/** @inner @const
<span class='line'>276</span>                 @type{!string} */</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">            </span><span class="NAME">canvasContainerElementId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-canvascontainer"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">instanceCounter</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">            </span><span class="COMM">/** @inner @const
<span class='line'>279</span>                 @type{!string} */</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">            </span><span class="NAME">toolbarElementId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-toolbar"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">instanceCounter</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT">            </span><span class="COMM">/** @inner @const
<span class='line'>282</span>                 @type{!string} */</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT">            </span><span class="NAME">editorElementId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-editor"</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">instanceCounter</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT">            </span><span class="NAME">fullWindowZoomHelper</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT">            </span><span class="NAME">mainContainer</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT">            </span><span class="NAME">tools</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">            </span><span class="NAME">odfCanvas</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">            </span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">            </span><span class="NAME">session</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">            </span><span class="NAME">loadOdtFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">editorOptions.loadCallback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">            </span><span class="NAME">saveOdtFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">editorOptions.saveCallback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">            </span><span class="NAME">saveAsOdtFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">editorOptions.saveAsCallback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">            </span><span class="NAME">downloadOdtFile</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">editorOptions.downloadCallback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">            </span><span class="NAME">close</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">       </span><span class="NAME">editorOptions.closeCallback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">            </span><span class="NAME">reviewModeEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">editorOptions.modus</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NAME">MODUS_REVIEW</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">            </span><span class="NAME">directTextStylingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.directTextStylingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT">            </span><span class="NAME">directParagraphStylingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.directParagraphStylingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT">            </span><span class="NAME">paragraphStyleSelectingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">reviewModeEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.paragraphStyleSelectingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">            </span><span class="NAME">paragraphStyleEditingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">   </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">reviewModeEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.paragraphStyleEditingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT">            </span><span class="NAME">imageEditingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">            </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">reviewModeEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.imageEditingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT">            </span><span class="NAME">hyperlinkEditingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.hyperlinkEditingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT">            </span><span class="NAME">annotationsEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">reviewModeEnabled</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.annotationsEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT">            </span><span class="NAME">undoRedoEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.undoRedoEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT">            </span><span class="NAME">zoomingEnabled</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">isEnabled</span><span class="PUNC">(</span><span class="NAME">editorOptions.zoomingEnabled</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT">            </span><span class="NAME">pendingMemberId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">            </span><span class="NAME">pendingEditorReadyCallback</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">            </span><span class="COMM">//</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">            </span><span class="NAME">eventNotifier</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">core.EventNotifier</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>315</span> </span><span class="WHIT">                </span><span class="NAME">EVENT_UNKNOWNERROR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>316</span> </span><span class="WHIT">                </span><span class="NAME">EVENT_DOCUMENTMODIFIEDCHANGED</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">                </span><span class="NAME">EVENT_METADATACHANGED</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">            </span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>319</span> 
<span class='line'>320</span> </span><span class="WHIT">        </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">Boolean</span><span class="PUNC">(</span><span class="NAME">mainContainerElement</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"No id of an existing element passed to Wodo.createTextEditor(): "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">mainContainerElementId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> 
<span class='line'>322</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>323</span>          * @param {!Object} changes
<span class='line'>324</span>          * @return {undefined}
<span class='line'>325</span>          */</span><span class="WHIT">
<span class='line'>326</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">relayMetadataSignal</span><span class="PUNC">(</span><span class="NAME">changes</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>327</span> </span><span class="WHIT">            </span><span class="NAME">eventNotifier.emit</span><span class="PUNC">(</span><span class="NAME">EVENT_METADATACHANGED</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">changes</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>329</span> 
<span class='line'>330</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>331</span>          * @param {!Object} changes
<span class='line'>332</span>          * @return {undefined}
<span class='line'>333</span>          */</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">relayModifiedSignal</span><span class="PUNC">(</span><span class="NAME">modified</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">            </span><span class="NAME">eventNotifier.emit</span><span class="PUNC">(</span><span class="NAME">EVENT_DOCUMENTMODIFIEDCHANGED</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">modified</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>337</span> 
<span class='line'>338</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>339</span>          * @return {undefined}
<span class='line'>340</span>          */</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">createSession</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">viewOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">                    </span><span class="NAME">editInfoMarkersInitiallyVisible</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>344</span> </span><span class="WHIT">                    </span><span class="NAME">caretAvatarsInitiallyVisible</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>345</span> </span><span class="WHIT">                    </span><span class="NAME">caretBlinksOnRangeSelect</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>347</span> 
<span class='line'>348</span> </span><span class="WHIT">            </span><span class="COMM">// create session around loaded document</span><span class="WHIT">
<span class='line'>349</span> </span><span class="WHIT">            </span><span class="NAME">session</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ops.Session</span><span class="PUNC">(</span><span class="NAME">odfCanvas</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>350</span> </span><span class="WHIT">            </span><span class="NAME">editorSession</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">EditorSession</span><span class="PUNC">(</span><span class="NAME">session</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pendingMemberId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>351</span> </span><span class="WHIT">                </span><span class="NAME">viewOptions</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">viewOptions</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>352</span> </span><span class="WHIT">                </span><span class="NAME">directTextStylingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">directTextStylingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>353</span> </span><span class="WHIT">                </span><span class="NAME">directParagraphStylingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">directParagraphStylingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">                </span><span class="NAME">paragraphStyleSelectingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">paragraphStyleSelectingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">                </span><span class="NAME">paragraphStyleEditingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">paragraphStyleEditingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">                </span><span class="NAME">imageEditingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">imageEditingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">                </span><span class="NAME">hyperlinkEditingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hyperlinkEditingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">                </span><span class="NAME">annotationsEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">annotationsEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">                </span><span class="NAME">zoomingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">zoomingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">                </span><span class="NAME">reviewModeEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">reviewModeEnabled</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undoRedoEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">                </span><span class="NAME">editorSession.sessionController.setUndoManager</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">gui.TrivialUndoManager</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">                </span><span class="NAME">editorSession.sessionController.getUndoManager</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">subscribe</span><span class="PUNC">(</span><span class="NAME">gui.UndoManager.signalDocumentModifiedChanged</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">relayModifiedSignal</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>365</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>366</span> 
<span class='line'>367</span> </span><span class="WHIT">            </span><span class="COMM">// Relay any metadata changes to the Editor's consumer as an event</span><span class="WHIT">
<span class='line'>368</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.getMetadataController</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">subscribe</span><span class="PUNC">(</span><span class="NAME">gui.MetadataController.signalMetadataChanged</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">relayMetadataSignal</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>369</span> 
<span class='line'>370</span> </span><span class="WHIT">            </span><span class="COMM">// and report back to caller</span><span class="WHIT">
<span class='line'>371</span> </span><span class="WHIT">            </span><span class="NAME">pendingEditorReadyCallback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>372</span> </span><span class="WHIT">            </span><span class="COMM">// reset</span><span class="WHIT">
<span class='line'>373</span> </span><span class="WHIT">            </span><span class="NAME">pendingEditorReadyCallback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">            </span><span class="NAME">pendingMemberId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>376</span> 
<span class='line'>377</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>378</span>          * @return {undefined}
<span class='line'>379</span>          */</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">startEditing</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> 
<span class='line'>383</span> </span><span class="WHIT">            </span><span class="NAME">tools.setEditorSession</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>384</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.insertLocalCursor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.startEditing</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>386</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>387</span> 
<span class='line'>388</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>389</span>          * @return {undefined}
<span class='line'>390</span>          */</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">endEditing</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> 
<span class='line'>394</span> </span><span class="WHIT">            </span><span class="NAME">tools.setEditorSession</span><span class="PUNC">(</span><span class="NAME">undefined</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.endEditing</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.removeLocalCursor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>398</span> 
<span class='line'>399</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>400</span>          * Loads an ODT document into the editor.
<span class='line'>401</span>          * @name TextEditor#openDocumentFromUrl
<span class='line'>402</span>          * @function
<span class='line'>403</span>          * @param {!string} docUrl url from which the ODT document can be loaded
<span class='line'>404</span>          * @param {!function(!Error=):undefined} callback Called once the document has been opened, passes an error object in case of error
<span class='line'>405</span>          * @return {undefined}
<span class='line'>406</span>          */</span><span class="WHIT">
<span class='line'>407</span> </span><span class="WHIT">        </span><span class="NAME">this.openDocumentFromUrl</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">docUrl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editorReadyCallback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>408</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">docUrl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"document should be defined here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">pendingEditorReadyCallback</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"pendingEditorReadyCallback should not exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should not exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>411</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">session</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"session should not exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>412</span> 
<span class='line'>413</span> </span><span class="WHIT">            </span><span class="NAME">pendingMemberId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">memberId</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>414</span> </span><span class="WHIT">            </span><span class="NAME">pendingEditorReadyCallback</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ops.OpAddMember</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>416</span> </span><span class="WHIT">                </span><span class="NAME">op.init</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>417</span> </span><span class="WHIT">                    </span><span class="NAME">memberid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">memberId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">                    </span><span class="NAME">setProperties</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">userData</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>420</span> </span><span class="WHIT">                </span><span class="NAME">session.enqueue</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">op</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>421</span> </span><span class="WHIT">                </span><span class="NAME">startEditing</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">editorReadyCallback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">                    </span><span class="NAME">editorReadyCallback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>425</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>426</span> 
<span class='line'>427</span> </span><span class="WHIT">            </span><span class="NAME">odfCanvas.load</span><span class="PUNC">(</span><span class="NAME">docUrl</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>429</span> 
<span class='line'>430</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>431</span>          * Closes the document, and does cleanup.
<span class='line'>432</span>          * @name TextEditor#closeDocument
<span class='line'>433</span>          * @function
<span class='line'>434</span>          * @param {!function(!Error=):undefined} callback  Called once the document has been closed, passes an error object in case of error
<span class='line'>435</span>          * @return {undefined}
<span class='line'>436</span>          */</span><span class="WHIT">
<span class='line'>437</span> </span><span class="WHIT">        </span><span class="NAME">this.closeDocument</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>438</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">session</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"session should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>439</span> 
<span class='line'>440</span> </span><span class="WHIT">            </span><span class="NAME">endEditing</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>441</span> 
<span class='line'>442</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">op</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ops.OpRemoveMember</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>443</span> </span><span class="WHIT">            </span><span class="NAME">op.init</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>444</span> </span><span class="WHIT">                </span><span class="NAME">memberid</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">memberId</span><span class="WHIT">
<span class='line'>445</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>446</span> </span><span class="WHIT">            </span><span class="NAME">session.enqueue</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">op</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>447</span> 
<span class='line'>448</span> </span><span class="WHIT">            </span><span class="NAME">session.close</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>449</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>450</span> </span><span class="WHIT">                    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>452</span> </span><span class="WHIT">                    </span><span class="NAME">editorSession.sessionController.getMetadataController</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">unsubscribe</span><span class="PUNC">(</span><span class="NAME">gui.MetadataController.signalMetadataChanged</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">relayMetadataSignal</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>453</span> </span><span class="WHIT">                    </span><span class="NAME">editorSession.destroy</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">                        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>455</span> </span><span class="WHIT">                            </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>456</span> </span><span class="WHIT">                        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT">                            </span><span class="NAME">editorSession</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">                            </span><span class="NAME">session.destroy</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">                                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>460</span> </span><span class="WHIT">                                    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">err</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>461</span> </span><span class="WHIT">                                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">                                    </span><span class="NAME">session</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">                                    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> </span><span class="WHIT">                                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>465</span> </span><span class="WHIT">                            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">                        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">                    </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>471</span> 
<span class='line'>472</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>473</span>          * @name TextEditor#getDocumentAsByteArray
<span class='line'>474</span>          * @function
<span class='line'>475</span>          * @param {!function(err:?Error, file:!Uint8Array=):undefined} callback Called with the current document as ODT file as bytearray, passes an error object in case of error
<span class='line'>476</span>          * @return {undefined}
<span class='line'>477</span>          */</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">        </span><span class="NAME">this.getDocumentAsByteArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">odfContainer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">odfCanvas.odfContainer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>480</span> 
<span class='line'>481</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">odfContainer</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">                </span><span class="NAME">odfContainer.createByteArray</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ba</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>483</span> </span><span class="WHIT">                    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ba</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>484</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">errorString</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>485</span> </span><span class="WHIT">                    </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">errorString</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">"Could not create bytearray from OdfContainer."</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>486</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>487</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>488</span> </span><span class="WHIT">                </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">"No odfContainer set!"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>489</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>491</span> 
<span class='line'>492</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>493</span>          * Sets the metadata fields from the given properties map.
<span class='line'>494</span>          * Avoid setting certain fields since they are automatically set:
<span class='line'>495</span>          *    dc:creator
<span class='line'>496</span>          *    dc:date
<span class='line'>497</span>          *    meta:editing-cycles
<span class='line'>498</span>          *
<span class='line'>499</span>          * The following properties are never used and will be removed for semantic
<span class='line'>500</span>          * consistency from the document:
<span class='line'>501</span>          *     meta:editing-duration
<span class='line'>502</span>          *     meta:document-statistic
<span class='line'>503</span>          *
<span class='line'>504</span>          * Setting any of the above mentioned fields using this method will have no effect.
<span class='line'>505</span>          *
<span class='line'>506</span>          * @name TextEditor#setMetadata
<span class='line'>507</span>          * @function
<span class='line'>508</span>          * @param {?Object.&lt;!string, !string>} setProperties A flat object that is a string->string map of field name -> value.
<span class='line'>509</span>          * @param {?Array.&lt;!string>} removedProperties An array of metadata field names (prefixed).
<span class='line'>510</span>          * @return {undefined}
<span class='line'>511</span>          */</span><span class="WHIT">
<span class='line'>512</span> </span><span class="WHIT">        </span><span class="NAME">this.setMetadata</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">setProperties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">removedProperties</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>513</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>514</span> 
<span class='line'>515</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.getMetadataController</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">setMetadata</span><span class="PUNC">(</span><span class="NAME">setProperties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">removedProperties</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>517</span> 
<span class='line'>518</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>519</span>          * Returns the value of the requested document metadata field.
<span class='line'>520</span>          * @name TextEditor#getMetadata
<span class='line'>521</span>          * @function
<span class='line'>522</span>          * @param {!string} property A namespace-prefixed field name, for example
<span class='line'>523</span>          * dc:creator
<span class='line'>524</span>          * @return {?string}
<span class='line'>525</span>          */</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">        </span><span class="NAME">this.getMetadata</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">property</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>528</span> 
<span class='line'>529</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">editorSession.sessionController.getMetadataController</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getMetadata</span><span class="PUNC">(</span><span class="NAME">property</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>530</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>531</span> 
<span class='line'>532</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>533</span>          * Sets the data for the person that is editing the document.
<span class='line'>534</span>          * The supported fields are:
<span class='line'>535</span>          *     "fullName": the full name of the editing person
<span class='line'>536</span>          *     "color": color to use for the user specific UI elements
<span class='line'>537</span>          * @name TextEditor#setUserData
<span class='line'>538</span>          * @function
<span class='line'>539</span>          * @param {?Object.&lt;!string,!string>|undefined} data
<span class='line'>540</span>          * @return {undefined}
<span class='line'>541</span>          */</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">setUserData</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>543</span> </span><span class="WHIT">            </span><span class="NAME">userData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">cloneUserData</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>544</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">        </span><span class="NAME">this.setUserData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">setUserData</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>546</span> 
<span class='line'>547</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>548</span>          * Returns the data set for the person that is editing the document.
<span class='line'>549</span>          * @name TextEditor#getUserData
<span class='line'>550</span>          * @function
<span class='line'>551</span>          * @return {!Object.&lt;!string,!string>}
<span class='line'>552</span>          */</span><span class="WHIT">
<span class='line'>553</span> </span><span class="WHIT">        </span><span class="NAME">this.getUserData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>554</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">cloneUserData</span><span class="PUNC">(</span><span class="NAME">userData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>555</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>556</span> 
<span class='line'>557</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>558</span>          * Sets the current state of the document to be either the unmodified state
<span class='line'>559</span>          * or a modified state.
<span class='line'>560</span>          * If @p modified is @true and the current state was already a modified state,
<span class='line'>561</span>          * this call has no effect and also does not remove the unmodified flag
<span class='line'>562</span>          * from the state which has it set.
<span class='line'>563</span>          *
<span class='line'>564</span>          * @name TextEditor#setDocumentModified
<span class='line'>565</span>          * @function
<span class='line'>566</span>          * @param {!boolean} modified
<span class='line'>567</span>          * @return {undefined}
<span class='line'>568</span>          */</span><span class="WHIT">
<span class='line'>569</span> </span><span class="WHIT">        </span><span class="NAME">this.setDocumentModified</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">modified</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>570</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>571</span> 
<span class='line'>572</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undoRedoEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>573</span> </span><span class="WHIT">                </span><span class="NAME">editorSession.sessionController.getUndoManager</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">setDocumentModified</span><span class="PUNC">(</span><span class="NAME">modified</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>574</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>575</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>576</span> 
<span class='line'>577</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>578</span>          * Returns if the current state of the document matches the unmodified state.
<span class='line'>579</span>          * @name TextEditor#isDocumentModified
<span class='line'>580</span>          * @function
<span class='line'>581</span>          * @return {!boolean}
<span class='line'>582</span>          */</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT">        </span><span class="NAME">this.isDocumentModified</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>584</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="NAME">editorSession</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"editorSession should exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>585</span> 
<span class='line'>586</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">undoRedoEnabled</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>587</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">editorSession.sessionController.getUndoManager</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">isDocumentModified</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>588</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>589</span> 
<span class='line'>590</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>591</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>592</span> 
<span class='line'>593</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>594</span>          * @return {undefined}
<span class='line'>595</span>          */</span><span class="WHIT">
<span class='line'>596</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">setFocusToOdfCanvas</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT">            </span><span class="NAME">editorSession.sessionController.getEventManager</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">focus</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>598</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>599</span> 
<span class='line'>600</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>601</span>          * @param {!function(!Error=):undefined} callback passes an error object in case of error
<span class='line'>602</span>          * @return {undefined}
<span class='line'>603</span>          */</span><span class="WHIT">
<span class='line'>604</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">destroyInternal</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>605</span> </span><span class="WHIT">            </span><span class="NAME">mainContainerElement.removeChild</span><span class="PUNC">(</span><span class="NAME">editorElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>606</span> 
<span class='line'>607</span> </span><span class="WHIT">            </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>608</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>609</span> 
<span class='line'>610</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>611</span>          * Destructs the editor object completely.
<span class='line'>612</span>          * @name TextEditor#destroy
<span class='line'>613</span>          * @function
<span class='line'>614</span>          * @param {!function(!Error=):undefined} callback Called once the destruction has been completed, passes an error object in case of error
<span class='line'>615</span>          * @return {undefined}
<span class='line'>616</span>          */</span><span class="WHIT">
<span class='line'>617</span> </span><span class="WHIT">        </span><span class="NAME">this.destroy</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>618</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">destroyCallbacks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>619</span> 
<span class='line'>620</span> </span><span class="WHIT">            </span><span class="COMM">// TODO: decide if some forced close should be done here instead of enforcing proper API usage</span><span class="WHIT">
<span class='line'>621</span> </span><span class="WHIT">            </span><span class="NAME">runtime.assert</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">session</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"session should not exist here."</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>622</span> 
<span class='line'>623</span> </span><span class="WHIT">            </span><span class="COMM">// TODO: investigate what else needs to be done</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT">            </span><span class="NAME">mainContainer.destroyRecursive</span><span class="PUNC">(</span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>625</span> 
<span class='line'>626</span> </span><span class="WHIT">            </span><span class="NAME">destroyCallbacks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">destroyCallbacks.concat</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT">                </span><span class="NAME">fullWindowZoomHelper.destroy</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT">                </span><span class="NAME">tools.destroy</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT">                </span><span class="NAME">odfCanvas.destroy</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>630</span> </span><span class="WHIT">                </span><span class="NAME">destroyInternal</span><span class="WHIT">
<span class='line'>631</span> </span><span class="WHIT">            </span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>632</span> 
<span class='line'>633</span> </span><span class="WHIT">            </span><span class="NAME">core.Async.destroyAll</span><span class="PUNC">(</span><span class="NAME">destroyCallbacks</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>634</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>635</span> 
<span class='line'>636</span> </span><span class="WHIT">        </span><span class="COMM">// TODO:</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT">        </span><span class="COMM">// this.openDocumentFromByteArray = openDocumentFromByteArray; see also https://github.com/kogmbh/WebODF/issues/375</span><span class="WHIT">
<span class='line'>638</span> </span><span class="WHIT">        </span><span class="COMM">// setReadOnly: setReadOnly,</span><span class="WHIT">
<span class='line'>639</span> 
<span class='line'>640</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>641</span>          * Registers a callback which should be called if the given event happens.
<span class='line'>642</span>          * @name TextEditor#addEventListener
<span class='line'>643</span>          * @function
<span class='line'>644</span>          * @param {!string} eventId
<span class='line'>645</span>          * @param {!Function} callback
<span class='line'>646</span>          * @return {undefined}
<span class='line'>647</span>          */</span><span class="WHIT">
<span class='line'>648</span> </span><span class="WHIT">        </span><span class="NAME">this.addEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventNotifier.subscribe</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>649</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>650</span>          * Unregisters a callback for the given event.
<span class='line'>651</span>          * @name TextEditor#removeEventListener
<span class='line'>652</span>          * @function
<span class='line'>653</span>          * @param {!string} eventId
<span class='line'>654</span>          * @param {!Function} callback
<span class='line'>655</span>          * @return {undefined}
<span class='line'>656</span>          */</span><span class="WHIT">
<span class='line'>657</span> </span><span class="WHIT">        </span><span class="NAME">this.removeEventListener</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">eventNotifier.unsubscribe</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>658</span> 
<span class='line'>659</span> 
<span class='line'>660</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>661</span>          * @return {undefined}
<span class='line'>662</span>          */</span><span class="WHIT">
<span class='line'>663</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">init</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>664</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">editorPane</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>665</span> </span><span class="WHIT">                </span><span class="COMM">/** @inner @const
<span class='line'>666</span>                     @type{!string} */</span><span class="WHIT">
<span class='line'>667</span> </span><span class="WHIT">                </span><span class="NAME">documentns</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.documentElement.namespaceURI</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>668</span> 
<span class='line'>669</span> </span><span class="WHIT">            </span><span class="COMM">/**
<span class='line'>670</span>              * @param {!string} tagLocalName
<span class='line'>671</span>              * @param {!string|undefined} id
<span class='line'>672</span>              * @param {!string} className
<span class='line'>673</span>              * @return {!Element}
<span class='line'>674</span>              */</span><span class="WHIT">
<span class='line'>675</span> </span><span class="WHIT">            </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="NAME">tagLocalName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">className</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>676</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">element</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>677</span> </span><span class="WHIT">                </span><span class="NAME">element</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElementNS</span><span class="PUNC">(</span><span class="NAME">documentns</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tagLocalName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>678</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">id</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>679</span> </span><span class="WHIT">                    </span><span class="NAME">element.id</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">id</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>680</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>681</span> </span><span class="WHIT">                </span><span class="NAME">element.classList.add</span><span class="PUNC">(</span><span class="NAME">className</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>682</span> </span><span class="WHIT">                </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">element</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>683</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>684</span> 
<span class='line'>685</span> </span><span class="WHIT">            </span><span class="COMM">// create needed tree structure</span><span class="WHIT">
<span class='line'>686</span> </span><span class="WHIT">            </span><span class="NAME">canvasElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">canvasElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-canvas"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>687</span> </span><span class="WHIT">            </span><span class="NAME">canvasContainerElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">canvasContainerElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-canvascontainer"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT">            </span><span class="NAME">toolbarElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'span'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">toolbarElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-toolbar"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT">            </span><span class="NAME">toolbarContainerElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'span'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">undefined</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-toolbarcontainer"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>690</span> </span><span class="WHIT">            </span><span class="NAME">editorElement</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">createElement</span><span class="PUNC">(</span><span class="STRN">'div'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editorElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"webodfeditor-editor"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>691</span> 
<span class='line'>692</span> </span><span class="WHIT">            </span><span class="COMM">// put into tree</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT">            </span><span class="NAME">canvasContainerElement.appendChild</span><span class="PUNC">(</span><span class="NAME">canvasElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>694</span> </span><span class="WHIT">            </span><span class="NAME">toolbarContainerElement.appendChild</span><span class="PUNC">(</span><span class="NAME">toolbarElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>695</span> </span><span class="WHIT">            </span><span class="NAME">editorElement.appendChild</span><span class="PUNC">(</span><span class="NAME">toolbarContainerElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>696</span> </span><span class="WHIT">            </span><span class="NAME">editorElement.appendChild</span><span class="PUNC">(</span><span class="NAME">canvasContainerElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>697</span> </span><span class="WHIT">            </span><span class="NAME">mainContainerElement.appendChild</span><span class="PUNC">(</span><span class="NAME">editorElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>698</span> 
<span class='line'>699</span> </span><span class="WHIT">            </span><span class="COMM">// style all elements with Dojo's claro.</span><span class="WHIT">
<span class='line'>700</span> </span><span class="WHIT">            </span><span class="COMM">// Not nice to do this on body, but then there is no other way known</span><span class="WHIT">
<span class='line'>701</span> </span><span class="WHIT">            </span><span class="COMM">// to style also all dialogs, which are attached directly to body</span><span class="WHIT">
<span class='line'>702</span> </span><span class="WHIT">            </span><span class="NAME">document.body.classList.add</span><span class="PUNC">(</span><span class="STRN">"claro"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>703</span> 
<span class='line'>704</span> </span><span class="WHIT">            </span><span class="COMM">// prevent browser translation service messing up internal address system</span><span class="WHIT">
<span class='line'>705</span> </span><span class="WHIT">            </span><span class="COMM">// TODO: this should be done more centrally, but where exactly?</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT">            </span><span class="NAME">canvasElement.setAttribute</span><span class="PUNC">(</span><span class="STRN">"translate"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"no"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>707</span> </span><span class="WHIT">            </span><span class="NAME">canvasElement.classList.add</span><span class="PUNC">(</span><span class="STRN">"notranslate"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>708</span> 
<span class='line'>709</span> </span><span class="WHIT">            </span><span class="COMM">// create widgets</span><span class="WHIT">
<span class='line'>710</span> </span><span class="WHIT">            </span><span class="NAME">mainContainer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">BorderContainer</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">mainContainerElementId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>711</span> 
<span class='line'>712</span> </span><span class="WHIT">            </span><span class="NAME">editorPane</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ContentPane</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>713</span> </span><span class="WHIT">                </span><span class="NAME">region</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'center'</span><span class="WHIT">
<span class='line'>714</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editorElementId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>715</span> </span><span class="WHIT">            </span><span class="NAME">mainContainer.addChild</span><span class="PUNC">(</span><span class="NAME">editorPane</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>716</span> 
<span class='line'>717</span> </span><span class="WHIT">            </span><span class="NAME">mainContainer.startup</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>718</span> 
<span class='line'>719</span> </span><span class="WHIT">            </span><span class="NAME">tools</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Tools</span><span class="PUNC">(</span><span class="NAME">toolbarElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>720</span> </span><span class="WHIT">                </span><span class="NAME">onToolDone</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">setFocusToOdfCanvas</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">                </span><span class="NAME">loadOdtFile</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">loadOdtFile</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">                </span><span class="NAME">saveOdtFile</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">saveOdtFile</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT">                </span><span class="NAME">saveAsOdtFile</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">saveAsOdtFile</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT">                </span><span class="NAME">downloadOdtFile</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">downloadOdtFile</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT">                </span><span class="NAME">close</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">close</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT">                </span><span class="NAME">directTextStylingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">directTextStylingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT">                </span><span class="NAME">directParagraphStylingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">directParagraphStylingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT">                </span><span class="NAME">paragraphStyleSelectingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">paragraphStyleSelectingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>729</span> </span><span class="WHIT">                </span><span class="NAME">paragraphStyleEditingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">paragraphStyleEditingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT">                </span><span class="NAME">imageInsertingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">imageEditingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT">                </span><span class="NAME">hyperlinkEditingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">hyperlinkEditingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT">                </span><span class="NAME">annotationsEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">annotationsEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">                </span><span class="NAME">undoRedoEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">undoRedoEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT">                </span><span class="NAME">zoomingEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">zoomingEnabled</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT">                </span><span class="NAME">aboutEnabled</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>737</span> 
<span class='line'>738</span> </span><span class="WHIT">            </span><span class="NAME">odfCanvas</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">odf.OdfCanvas</span><span class="PUNC">(</span><span class="NAME">canvasElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT">            </span><span class="NAME">odfCanvas.enableAnnotations</span><span class="PUNC">(</span><span class="NAME">annotationsEnabled</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> 
<span class='line'>741</span> </span><span class="WHIT">            </span><span class="NAME">odfCanvas.addListener</span><span class="PUNC">(</span><span class="STRN">"statereadychange"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">createSession</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>742</span> 
<span class='line'>743</span> </span><span class="WHIT">            </span><span class="NAME">fullWindowZoomHelper</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">FullWindowZoomHelper</span><span class="PUNC">(</span><span class="NAME">toolbarContainerElement</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">canvasContainerElement</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>744</span> 
<span class='line'>745</span> </span><span class="WHIT">            </span><span class="NAME">setUserData</span><span class="PUNC">(</span><span class="NAME">editorOptions.userData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>746</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>747</span> 
<span class='line'>748</span> </span><span class="WHIT">        </span><span class="NAME">init</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>749</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>750</span> 
<span class='line'>751</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">loadDojoAndStuff</span><span class="PUNC">(</span><span class="NAME">callback</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>752</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">head</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">"head"</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>753</span> </span><span class="WHIT">            </span><span class="NAME">frag</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createDocumentFragment</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>754</span> </span><span class="WHIT">            </span><span class="NAME">link</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>755</span> </span><span class="WHIT">            </span><span class="NAME">script</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>756</span> 
<span class='line'>757</span> </span><span class="WHIT">        </span><span class="COMM">// append two link and two script elements to the header</span><span class="WHIT">
<span class='line'>758</span> </span><span class="WHIT">        </span><span class="NAME">link</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"link"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>759</span> </span><span class="WHIT">        </span><span class="NAME">link.rel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"stylesheet"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>760</span> </span><span class="WHIT">        </span><span class="NAME">link.href</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/app/resources/app.css"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>761</span> </span><span class="WHIT">        </span><span class="NAME">link.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"text/css"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>762</span> </span><span class="WHIT">        </span><span class="NAME">link.async</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT">        </span><span class="NAME">frag.appendChild</span><span class="PUNC">(</span><span class="NAME">link</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT">        </span><span class="NAME">link</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"link"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>765</span> </span><span class="WHIT">        </span><span class="NAME">link.rel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"stylesheet"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>766</span> </span><span class="WHIT">        </span><span class="NAME">link.href</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/wodotexteditor.css"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>767</span> </span><span class="WHIT">        </span><span class="NAME">link.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"text/css"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>768</span> </span><span class="WHIT">        </span><span class="NAME">link.async</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>769</span> </span><span class="WHIT">        </span><span class="NAME">frag.appendChild</span><span class="PUNC">(</span><span class="NAME">link</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>770</span> </span><span class="WHIT">        </span><span class="NAME">script</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"script"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">        </span><span class="NAME">script.src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/dojo-amalgamation.js"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">        </span><span class="NAME">script</span><span class="PUNC">[</span><span class="STRN">"data-dojo-config"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"async: true"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT">        </span><span class="NAME">script.charset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"utf-8"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>774</span> </span><span class="WHIT">        </span><span class="NAME">script.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"text/javascript"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>775</span> </span><span class="WHIT">        </span><span class="NAME">script.async</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>776</span> </span><span class="WHIT">        </span><span class="NAME">frag.appendChild</span><span class="PUNC">(</span><span class="NAME">script</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>777</span> </span><span class="WHIT">        </span><span class="NAME">script</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="STRN">"script"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>778</span> </span><span class="WHIT">        </span><span class="NAME">script.src</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">installationPath</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"/webodf.js"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>779</span> </span><span class="WHIT">        </span><span class="NAME">script.charset</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"utf-8"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT">        </span><span class="NAME">script.type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"text/javascript"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT">        </span><span class="NAME">script.async</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT">        </span><span class="NAME">script.onload</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>783</span> </span><span class="WHIT">        </span><span class="NAME">frag.appendChild</span><span class="PUNC">(</span><span class="NAME">script</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>784</span> </span><span class="WHIT">        </span><span class="NAME">head.appendChild</span><span class="PUNC">(</span><span class="NAME">frag</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>785</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>786</span> 
<span class='line'>787</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>788</span>      * Creates a text editor object and returns it on success in the passed callback.
<span class='line'>789</span>      * @name Wodo#createTextEditor
<span class='line'>790</span>      * @function
<span class='line'>791</span>      * @param {!string} editorContainerElementId id of the existing div element which will contain the editor (should be empty before)
<span class='line'>792</span>      * @param editorOptions options to configure the features of the editor. All entries are optional
<span class='line'>793</span>      * @param [editorOptions.modus=Wodo.MODUS_FULLEDITING] set the editing modus. Current options: Wodo.MODUS_FULLEDITING, Wodo.MODUS_REVIEW
<span class='line'>794</span>      * @param [editorOptions.loadCallback] parameter-less callback method, adds a "Load" button to the toolbar which triggers this method
<span class='line'>795</span>      * @param [editorOptions.saveCallback] parameter-less callback method, adds a "Save" button to the toolbar which triggers this method
<span class='line'>796</span>      * @param [editorOptions.saveAsCallback] parameter-less callback method, adds a "Save as" button to the toolbar which triggers this method
<span class='line'>797</span>      * @param [editorOptions.downloadCallback] parameter-less callback method, adds a "Download" button to the right of the toolbar which triggers this method
<span class='line'>798</span>      * @param [editorOptions.closeCallback] parameter-less callback method, adds a "Save" button to the toolbar which triggers this method
<span class='line'>799</span>      * @param [editorOptions.allFeaturesEnabled=false] if set to 'true', switches the default for all features from 'false' to 'true'
<span class='line'>800</span>      * @param [editorOptions.directTextStylingEnabled=false] if set to 'true', enables the direct styling of text (e.g. bold/italic or font)
<span class='line'>801</span>      * @param [editorOptions.directParagraphStylingEnabled=false] if set to 'true', enables the direct styling of paragraphs (e.g. indentation or alignement)
<span class='line'>802</span>      * @param [editorOptions.paragraphStyleSelectingEnabled=false] if set to 'true', enables setting of defined paragraph styles to paragraphs
<span class='line'>803</span>      * @param [editorOptions.paragraphStyleEditingEnabled=false] if set to 'true', enables the editing of defined paragraph styles
<span class='line'>804</span>      * @param [editorOptions.imageEditingEnabled=false] if set to 'true', enables the insertion of images
<span class='line'>805</span>      * @param [editorOptions.hyperlinkEditingEnabled=false] if set to 'true', enables the editing of hyperlinks
<span class='line'>806</span>      * @param [editorOptions.annotationsEnabled=false] if set to 'true', enables the display and the editing of annotations
<span class='line'>807</span>      * @param [editorOptions.undoRedoEnabled=false] if set to 'true', enables the Undo and Redo of editing actions
<span class='line'>808</span>      * @param [editorOptions.zoomingEnabled=false] if set to 'true', enables the zooming tool
<span class='line'>809</span>      * @param [editorOptions.userData] data about the user editing the document
<span class='line'>810</span>      * @param [editorOptions.userData.fullName] full name of the user, used for annotations and in the metadata of the document
<span class='line'>811</span>      * @param [editorOptions.userData.color="black"] color to use for any user related indicators like cursor or annotations
<span class='line'>812</span>      * @param {!function(err:?Error, editor:!TextEditor=):undefined} onEditorCreated
<span class='line'>813</span>      * @return {undefined}
<span class='line'>814</span>      */</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">    </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">createTextEditor</span><span class="PUNC">(</span><span class="NAME">editorContainerElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editorOptions</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">onEditorCreated</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>816</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>817</span>          * @return {undefined}
<span class='line'>818</span>          */</span><span class="WHIT">
<span class='line'>819</span> </span><span class="WHIT">        </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">create</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>820</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">editor</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TextEditor</span><span class="PUNC">(</span><span class="NAME">editorContainerElementId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editorOptions</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>821</span> </span><span class="WHIT">            </span><span class="NAME">onEditorCreated</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">editor</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>822</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>823</span> 
<span class='line'>824</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">isInitalized</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT">            </span><span class="NAME">pendingInstanceCreationCalls.push</span><span class="PUNC">(</span><span class="NAME">create</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span> </span><span class="WHIT">            </span><span class="COMM">// first request?</span><span class="WHIT">
<span class='line'>827</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">pendingInstanceCreationCalls.length</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>828</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">String</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WodoFromSource</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>829</span> </span><span class="WHIT">                    </span><span class="NAME">loadDojoAndStuff</span><span class="PUNC">(</span><span class="NAME">initTextEditor</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>830</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>831</span> </span><span class="WHIT">                    </span><span class="NAME">initTextEditor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>832</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>833</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>834</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>835</span> </span><span class="WHIT">            </span><span class="NAME">create</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>836</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>837</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>838</span> 
<span class='line'>839</span> 
<span class='line'>840</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>841</span>      * @lends Wodo#
<span class='line'>842</span>      */</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">        </span><span class="NAME">createTextEditor</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">createTextEditor</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>845</span> </span><span class="WHIT">        </span><span class="COMM">// flags</span><span class="WHIT">
<span class='line'>846</span> </span><span class="WHIT">        </span><span class="COMM">/** Id of full editing modus */</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">        </span><span class="NAME">MODUS_FULLEDITING</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">MODUS_FULLEDITING</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>848</span> </span><span class="WHIT">        </span><span class="COMM">/** Id of review modus */</span><span class="WHIT">
<span class='line'>849</span> </span><span class="WHIT">        </span><span class="NAME">MODUS_REVIEW</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">MODUS_REVIEW</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>850</span> </span><span class="WHIT">        </span><span class="COMM">/** Id of event for an unkown error */</span><span class="WHIT">
<span class='line'>851</span> </span><span class="WHIT">        </span><span class="NAME">EVENT_UNKNOWNERROR</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">EVENT_UNKNOWNERROR</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>852</span> </span><span class="WHIT">        </span><span class="COMM">/** Id of event if documentModified state changes */</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT">        </span><span class="NAME">EVENT_DOCUMENTMODIFIEDCHANGED</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">EVENT_DOCUMENTMODIFIEDCHANGED</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>854</span> </span><span class="WHIT">        </span><span class="COMM">/** Id of event if metadata changes */</span><span class="WHIT">
<span class='line'>855</span> </span><span class="WHIT">        </span><span class="NAME">EVENT_METADATACHANGED</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">EVENT_METADATACHANGED</span><span class="WHIT">
<span class='line'>856</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>857</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>858</span> </span></pre></body></html>