forked from xwiki-contrib/wiki-editor-devtools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SyntaxHighlighting.xml
597 lines (536 loc) · 23.8 KB
/
SyntaxHighlighting.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<xwikidoc reference="SyntaxHighlighting.SyntaxHighlighting" locale="">
<web>SyntaxHighlighting</web>
<name>SyntaxHighlighting</name>
<language/>
<defaultLanguage/>
<translation>0</translation>
<parent>SyntaxHighlighting.EnableSyntaxHighlighting</parent>
<creator>xwiki:XWiki.Admin</creator>
<author>xwiki:XWiki.Admin</author>
<customClass/>
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
<creationDate>1450093299000</creationDate>
<date>1450188859000</date>
<contentUpdateDate>1450108212000</contentUpdateDate>
<version>1.1</version>
<title>SyntaxHighlighting</title>
<defaultTemplate/>
<validationScript/>
<comment/>
<minorEdit>false</minorEdit>
<syntaxId>xwiki/2.1</syntaxId>
<hidden>true</hidden>
<object>
<class>
<name>XWiki.JavaScriptExtension</name>
<customClass/>
<customMapping/>
<defaultViewSheet/>
<defaultEditSheet/>
<defaultWeb/>
<nameField/>
<validationScript/>
<cache>
<cache>0</cache>
<disabled>0</disabled>
<displayType>select</displayType>
<multiSelect>0</multiSelect>
<name>cache</name>
<number>5</number>
<prettyName>Caching policy</prettyName>
<relationalStorage>0</relationalStorage>
<separator> </separator>
<separators>|, </separators>
<size>1</size>
<unmodifiable>0</unmodifiable>
<values>long|short|default|forbid</values>
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
</cache>
<code>
<disabled>0</disabled>
<name>code</name>
<number>2</number>
<prettyName>Code</prettyName>
<rows>20</rows>
<size>50</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.TextAreaClass</classType>
</code>
<name>
<disabled>0</disabled>
<name>name</name>
<number>1</number>
<prettyName>Name</prettyName>
<size>30</size>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
</name>
<parse>
<disabled>0</disabled>
<displayFormType>select</displayFormType>
<displayType>yesno</displayType>
<name>parse</name>
<number>4</number>
<prettyName>Parse content</prettyName>
<unmodifiable>0</unmodifiable>
<classType>com.xpn.xwiki.objects.classes.BooleanClass</classType>
</parse>
<use>
<cache>0</cache>
<disabled>0</disabled>
<displayType>select</displayType>
<multiSelect>0</multiSelect>
<name>use</name>
<number>3</number>
<prettyName>Use this extension</prettyName>
<relationalStorage>0</relationalStorage>
<separator> </separator>
<separators>|, </separators>
<size>1</size>
<unmodifiable>0</unmodifiable>
<values>currentPage|onDemand|always</values>
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
</use>
</class>
<name>SyntaxHighlighting.SyntaxHighlighting</name>
<number>0</number>
<className>XWiki.JavaScriptExtension</className>
<guid>ae324f77-9a39-4a22-b789-fb02e302d54f</guid>
<property>
<cache>default</cache>
</property>
<property>
<code>#includeMacros('Macros')
## Only do work if the extension is enabled.
#if ($configuration.getValue('enabled') == 1)
define(['jquery'], function ($) {
var codeMirrors = [];
/* Initialize the CodeMirror library and then start registering the extra modules. */
var initCodeMirrorInternals = function() {
initCodeMirrors();
// Override the insertTags method for the wiki syntax editor so that we can intercept commands from
// the attached toolbar and execute them on the CodeMirror instance instead of the simple textarea
if (XWiki.editor == 'wiki' && insertTags) {
insertTags = function(tagOpen, tagClose, sampleText) {
var codeMirror = codeMirrors[0];
if (!codeMirror) {
return;
}
codeMirror.replaceSelection(tagOpen + (codeMirror.doc.getSelection() || sampleText) + tagClose, 'end');
}
}
}
/* Initialize all possible CodeMirror instances. */
var initCodeMirrors = function () {
if (XWiki.editor == 'object' || XWiki.editor == 'inline') {
// Object editor highlighting support
initCodeMirror("textarea[id^='XWiki.StyleSheetExtension_'][id$='_code']", 'css');
initCodeMirror("textarea[id^='XWiki.JavaScriptExtension_'][id$='_code']", 'javascript');
initCodeMirror("textarea[id^='XWiki.XWikiSkins_'][id$='.css']", 'css');
initCodeMirror("textarea[id^='XWiki.XWikiSkins_'][id$='.js']", 'javascript');
initCodeMirror("textarea[id^='XWiki.XWikiSkins_'][id$='.vm']", 'velocity');
initCodeMirror("textarea[id^='XWiki.WikiMacroClass_'][id$='_code']", XWiki.docsyntax);
} else if (XWiki.editor == 'wiki') {
// Document content editor highlighting support using the document's syntax.
initCodeMirror("textarea[id='content']", XWiki.docsyntax);
}
}
/**
* Initialize a CodeMirror instance and add it to the list of instances.
* @param propertyPattern : the CSS selector for the textarea to wrap with a CodeMirror instance.
* @param codeMirrorMode : the mode that will be used by this CodeMirror instance ('css', 'javascript', etc.)
*/
var initCodeMirror = function (propertyPattern, codeMirrorMode) {
//
// Attach codeMirrors to all the elements matched with the propertyPattern.
//
var codeMirrorState = window.localStorage['XWiki.extension.SyntaxHighlighting.disable'] || 0;
var textareas = $$(propertyPattern);
for (var i = 0; i<textareas.length; ++i) {
var textarea = textareas[i];
// If the textarea is not visible, like the object editor's textareas are when they are not expanded, delay the initialization
if (textarea.offsetWidth > 0 || textarea.offsetHeight > 0) {
if(codeMirrorState === '1') {
displayEnableCheckbox(textarea, codeMirrorMode);
}
else {
initSingleCodeMirror(textarea, codeMirrorMode);
}
} else {
var objectDiv = textarea.up('.xobject');
if (!objectDiv) {
// We only know how to handle hidden text areas in the object editor.
return;
}
// Hack: since we are not using a static listener, but a custom one for each instance (through the bind method by curry-ing parameter values to it),
// we`re currying the "this" (first) parameter to a dummy object that is empty at curry time, but which is then made the container of the generated
// listener. This way, the listener will be able to have access to itself, in it's curryed form (so that it can unregister itself once it executes);
var dummy = {};
var listener = lazyInitObjectEditorCodeMirrors.bindAsEventListener(dummy, objectDiv, textarea, codeMirrorMode);
dummy.listener = listener;
objectDiv.observe('click', listener);
}
}
}
// Add a checkbox to enable CodeMirror for the user
var displayEnableCheckbox = function (textarea, codeMirrorMode) {
var openInstances = $('.enableCodeMirror').length;
$('<div class="meta-versionSummary enableCodeMirror"><input type="checkbox" class="SHcheckbox" id="enableCodeMirror'+openInstances+'"/> <label for="enableCodeMirror'+openInstances+'">Allow Syntax Highlighting</label></div>').insertAfter(textarea).on('click',function() {
initSingleCodeMirror(textarea, codeMirrorMode);
$(this).remove();
window.localStorage['XWiki.extension.SyntaxHighlighting.disable'] = 0;
});
}
var initSingleCodeMirror = function (textarea, codeMirrorMode) {
// FIXME: Until a better way comes up, we`ll just reuse the xwiki 2.1 syntax mode for 2.0 as well.
if (codeMirrorMode == 'xwiki/2.0') {
codeMirrorMode = 'xwiki/2.1';
}
var modeDependency = configureRequireJsPaths(codeMirrorMode);
// Load any configured theme.
var theme = "$!{configuration.getValue('theme')}";
if (!theme) theme = 'default';
if (theme != 'default') {
#set ($themeCSS = "theme/${configuration.theme}.css")
var themeURL = "${codeMirrorBaseURL}${themeCSS}";
loadCSS(themeURL);
}
// TODO: Make all these addons requirements configurable and read the global or user configuration when
// including them in the list of dependencies. i.e. if the user/admin does not need them, do not require them.
require(['SyntaxHighlighting_cm/lib/codemirror',
/** Modes **/
modeDependency,
/** Addons **/
// Match highlighting
'SyntaxHighlighting_cm/addon/search/match-highlighter',
// Enable brackets matching
'SyntaxHighlighting_cm/addon/edit/matchbrackets',
// Active line highlighting
'SyntaxHighlighting_cm/addon/selection/active-line',
// Continue C-like block comments on a new line
'SyntaxHighlighting_cm/addon/comment/continuecomment',
// Auto-close brackets and quotes
'SyntaxHighlighting_cm/addon/edit/closebrackets',
// Show trailing empty whitespaces
'SyntaxHighlighting_cm/addon/edit/trailingspace',
// Search support
'SyntaxHighlighting_cm/addon/search/search',
// Displays search result locations on the scrollbar
'SyntaxHighlighting_cm/addon/search/matchesonscrollbar'
], function (CodeMirror) {
// console.log('Initializing CodeMirror instance...');
// Enable optional autocomplete support.
var autocompleteSupportModule = new XWiki.Document('Autocomplete', 'SyntaxHighlighting').getURL('jsx');
// console.log('Loading autocomplete support to module: ' + autocompleteSupportModule);
require([autocompleteSupportModule], function () {
// console.log('Autocomplete support module loaded: ' + autocompleteSupportModule);
}, function (err) {
var failedId = err.requireModules && err.requireModules[0];
if (failedId === autocompleteSupportModule) {
// console.log('Failed to load autocomplete support module: ' + failedId);
requirejs.undef(failedId);
} else {
// Some other error. Maybe show message to the user.
new XWiki.widgets.Notification('Autocompletion failed to load.', 'error');
console.log(err);
}
});
// Compute and remember the wrapped textarea's width in percentages.
var textareaWidthPercentage = textarea.getWidth() * 100 / textarea.parentNode.getWidth();
var textareaHeight = textarea.getHeight();
// Initialize the CodeMirror instance.
var codeMirror = CodeMirror.fromTextArea(textarea, {
'mode' : codeMirrorMode,
'theme' : theme,
'lineNumbers' : true,
'matchBrackets' : true,
// Active line highlighting
'styleActiveLine' : true,
// Automatically highlight matching words on click.
'highlightSelectionMatches': {showToken: /\w+/},
// Continue C-like block comments on a new line.
'continueComments' : true,
// Auto-close brackets and quotes
'autoCloseBrackets' : true,
// Show trailing empty whitespaces
'showTrailingSpace' : true,
extraKeys : {
// Autocomplete support
'Ctrl-Space' : 'autocomplete',
// Mac friendly autocomplete binding
'Shift-Ctrl-Space' : 'autocomplete',
// Use whitespaces instead of tabs.
'Tab' : whitespaceIndentation,
// Fix for findNext because Ctrl-G is not available (already taken by the go to page feature).
'F3' : 'findNext',
// Fullscreen on
'F11' : function(cm) {
var editorDiv = cm.getWrapperElement();
if (!editorDiv.hasClassName('CodeMirror-fullscreen')) {
var fullScreenActivatorElement = editorDiv.up().select('.fullScreenEditButton', '.fullScreenEditLink')[0];
fullScreenActivatorElement.click();
}
},
// Fullscreen off
'Esc' : function(cm) {
var editorDiv = cm.getWrapperElement();
if (editorDiv.hasClassName('CodeMirror-fullscreen')) {
var fullScreenDeactivatorElement = $$('.bottombuttons')[0].down('.button');
fullScreenDeactivatorElement.click();
}
},
// Enable persistent search
'Alt-F': 'findPersistent',
}
});
if(Object.keys(shortcut.all_shortcuts).indexOf('ctrl+g') > 0) {
var callback = shortcut.all_shortcuts['ctrl+g'].callback;
shortcut.remove('ctrl+g');
shortcut.add('ctrl+g', callback, {
'disable_in_input' : true
});
}
// Trigger autocomplete while typing, without having to press Ctrl+Space
codeMirror.on('keyup', function(editor , event) {
if (event.key == '.' || event.key == '$') {
editor.execCommand('autocomplete');
}
}),
// Set the width of the codemirror editor equal to the one of the wrapped textarea. Value is computed before
// attaching the codemirror instance, otherwise it will not report it correctly since the textarea will be hidden.
codeMirror.setSize(textareaWidthPercentage + "%", textareaHeight);
// console.log('CodeMirror instance initialized for mode: ' + codeMirrorMode);
// Add a checkbox to disable CodeMirror for the user
var openInstances = jQuery('.disableCodeMirror').length;
var codeMirrorDiv = jQuery(textarea).siblings('.CodeMirror');
jQuery('<div class="meta-versionSummary disableCodeMirror"><input type="checkbox" checked="checked" class="SHcheckbox" id="disableCodeMirror'+openInstances+'"/> <label for="disableCodeMirror'+openInstances+'" >Allow Syntax Highlighting</label></div>').insertAfter(codeMirrorDiv).on('click',function() {
codeMirror.toTextArea();
displayEnableCheckbox(textarea, codeMirrorMode);
$(this).remove();
window.localStorage['XWiki.extension.SyntaxHighlighting.disable'] = 1;
});
// Track this new instance by adding it to the list of instances.
codeMirrors.push(codeMirror);
}, function (err) {
// Some other error. Log it and notify the user.
console.log(err);
new XWiki.widgets.Notification('Syntax Highlighting and/or Autocompletion failed to load.', 'error');
});
}
/**
* Handles all the wiring needed by requirejs to properly locate codemirror's library, modules and the dependencies of those modules.
*
* For codeMirror modes, we will be checking 2 locations: the codeMirror directory and wiki pages named by the pattern "SyntaxHighlighting.HighlightingMode<capitalizedModeName>"
*
* @param codeMirrorMode the mode to configure
* @returns the configured mode dependency path to use wih requirejs to load the specified codeMirror mode
*/
var configureRequireJsPaths = function(codeMirrorMode) {
var codeMirrorWebjarHome = "$codeMirrorBaseURL";
// The general path to be used in our modules.
var pathsConfig = {
SyntaxHighlighting_cm : codeMirrorWebjarHome
};
// The location of a mode implementaion in the codemirror package is "/mode/<modeName>/<modeName>.js"
var modeDependency = 'SyntaxHighlighting_cm/mode/' + codeMirrorMode + '/' + codeMirrorMode;
// console.log("Mode dependency: " + modeDependency);
// Compute a fallback for custom modes defined by us in wiki pages.
var capitalizedModeName = codeMirrorMode.charAt(0).toUpperCase() + codeMirrorMode.substring(1);
var modeDocName = 'HighlightingMode' + capitalizedModeName;
// Note: the 'discard' query parameter is there just to make sure requirejs does not add any .js suffix to the module's path
var modeDependencyFallback = new XWiki.Document(modeDocName, 'SyntaxHighlighting').getURL('jsx', 'discard');
/*
* Configure a path for the current mode.
*/
// Start by adding the fallback.
pathsConfig[modeDependency] = [modeDependencyFallback];
// This is a hack to improve performance and avoid useless failures for the xwiki mode, which we will be using a lot.
// Basically, the XWiki mode is defined in the fallback location (wiki page) so no need to look in the codemirror directory.
if (codeMirrorMode != 'xwiki/2.1') {
// Any other mode has to go through a fallback mechanism.
var codeMirrorModeDependency = codeMirrorWebjarHome + 'mode/' + codeMirrorMode + '/' + codeMirrorMode;
// We have already added the fallback, now we are prepeding the list of lookup locations with the codeMirror directory, since it should be checked first.
pathsConfig[modeDependency].unshift(codeMirrorModeDependency);
}
// Set the configured paths.
require.config({
paths: pathsConfig,
// At least until http://jira.xwiki.org/browse/WIKIEDITOR-21 is fixed, a greater wait time should avoid timeouts.
waitSeconds: 60
});
return modeDependency;
}
/* Inject an extra stylesheet into the current DOM using the given location. */
var loadCSS = function(url) {
// Stop here if the stylesheet is already loaded
if ($$("head link[href='" + url + "']").length != 0) {
return;
}
var link = document.createElement('link');
link.type = "text/css";
link.rel = "stylesheet";
link.href = url;
document.getElementsByTagName('head')[0].appendChild(link);
}
/*
* Listener that initializes a CodeMirror instance only once and then unregistes itself.
*/
var lazyInitObjectEditorCodeMirrors = function (event, observedElement, textarea, codeMirrorMode) {
initSingleCodeMirror(textarea, codeMirrorMode);
/* Remove the listener so that it is triggered only once */
observedElement.stopObserving('click', this.listener);
}
/* Uses whitespaces instead of tabs for indentation. */
// See https://github.com/codemirror/CodeMirror/issues/988#issuecomment-14921785
// TODO: see if there is a better way to do this in the new 5.1 version since this solution is old (3.14).
var whitespaceIndentation = function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection("add");
} else {
cm.replaceSelection(cm.getOption("indentWithTabs") ? "\t" : Array(cm.getOption("indentUnit") + 1).join(" "), "end", "+input");
}
}
/* Synchronize the original textareas' contents with the codemirrors' contents just before saving the page. */
document.observe('xwiki:actions:save', function(event){
for (var i=0; i < codeMirrors.length; ++i) {
codeMirrors[i].save();
}
});
/*
* Fullscreen handling
*/
/* Before going into fullscreen editing, record the element's original dimensions. */
document.observe('xwiki:fullscreen:enter', function(event) {
var codeMirror = getCodeMirrorFromFullScreenEvent(event);
if (!codeMirror) {
// Something else is entering fullscreen.
return;
}
var editorDiv = codeMirror.getWrapperElement();
// Height as an integer (pixels), Width as percent string
toggleFullscreenEditing.dimensionsBeforeFullscreen = {
// px
height: editorDiv.clientHeight,
// x%
width: editorDiv.style.width
};
toggleFullscreenEditing.scrollBeforeFullscreen = document.viewport.getScrollOffsets();
});
/* Full screen editing when pressing the maximize button/link. */
document.observe('xwiki:fullscreen:entered', function(event) {
var codeMirror = getCodeMirrorFromFullScreenEvent(event);
if (!codeMirror) {
// Something else entered fullscreen.
return;
}
toggleFullscreenEditing(codeMirror, true);
});
/* Fullscreen left by pressing the bottom button. */
document.observe('xwiki:fullscreen:exited', function(event) {
var codeMirror = getCodeMirrorFromFullScreenEvent(event);
if (!codeMirror) {
// Something else exited fullscreen.
return;
}
toggleFullscreenEditing(codeMirror, false);
});
var getCodeMirrorFromFullScreenEvent = function(event) {
var originalTextArea = event.memo.target;
var codeMirrorTextArea = originalTextArea.up().down('.CodeMirror textarea');
var codeMirror = getCodeMirrorFromInternalTextArea(codeMirrorTextArea, codeMirrors);
return codeMirror;
}
var getCodeMirrorFromInternalTextArea = function(textArea, codeMirrors) {
for(var j=0; j<codeMirrors.length; ++j) {
var codeMirror = codeMirrors[j];
var codeMirrorTextArea = codeMirror.getInputField();
if (textArea == codeMirrorTextArea) {
return codeMirror;
}
}
}
/* Display the given codeMirror instance in full screen. */
var toggleFullscreenEditing = function (codeMirror, enabled) {
var editorDiv = codeMirror.getWrapperElement();
if (enabled) {
editorDiv.addClassName('CodeMirror-fullscreen');
// Set proper dimensions
editorDiv.style.height = getNewCodeMirrorHeightInFullscreen() + 'px';
editorDiv.style.width ='100%';
} else {
editorDiv.removeClassName('CodeMirror-fullscreen');
// Restore the editor's dimensions
editorDiv.style.height = toggleFullscreenEditing.dimensionsBeforeFullscreen.height + 'px';
// Set the editor's width (percent string)
editorDiv.style.width = toggleFullscreenEditing.dimensionsBeforeFullscreen.width;
// Restore the window's scrolling position
window.scrollTo(toggleFullscreenEditing.scrollBeforeFullscreen.left, toggleFullscreenEditing.scrollBeforeFullscreen.top);
}
codeMirror.refresh();
codeMirror.focus();
}
var getNewCodeMirrorHeightInFullscreen = function() {
// Should always exist.
var bottomButtonsHeight = $$('.bottombuttons')[0].getHeight();
// May not always exist (like in the object editor)
var toolbarElement = $$('.leftmenu2')[0];
var toolbarHeight = 0;
if (toolbarElement) {
toolbarHeight = toolbarElement.getHeight();
}
var result = getWindowHeight() - bottomButtonsHeight - toolbarHeight;
return result;
}
var getWindowHeight = function() {
return window.innerHeight || (document.documentElement || document.body).clientHeight;
}
/* Fullscreen: Resize the editor while in fullscreen and the window gets resized */
Event.observe(window, 'resize', function(event) {
var editorDiv = $$('.CodeMirror-fullscreen')[0];
// If not in fullscreen mode, ignore the resize event.
if (!editorDiv) {
return;
}
// Recompute and set the height; the width is already set to 100% so we don`t worry about that.
editorDiv.style.height = getNewCodeMirrorHeightInFullscreen() + 'px';
editorDiv.CodeMirror.refresh();
});
return {
initCodeMirrorInternals : initCodeMirrorInternals,
initCodeMirror : initCodeMirror
}
});
#end ## enabled check</code>
</property>
<property>
<name>CodeMirror API</name>
</property>
<property>
<parse>1</parse>
</property>
<property>
<use>currentPage</use>
</property>
</object>
<content/>
</xwikidoc>