3 class CodeMirrorPerspective extends $.wiki.Perspective {
8 this.codemirror = CodeMirror.fromTextArea($(
9 '#codemirror_placeholder').get(0), {
13 readOnly: CurrentDocument.readonly || false,
17 $('#source-editor').keydown(function(event) {
22 var button = $("#source-editor button[data-ui-accesskey='"+c+"']");
23 if(button.length == 0)
25 button.get(0).click();
26 event.preventDefault();
29 $('#source-editor .toolbar').toolbarize({
30 actionContext: self.codemirror
33 // textarea is no longer needed
34 $('#codemirror_placeholder').remove();
37 onEnter(success, failure) {
39 this.codemirror.setValue(this.doc.text);
40 this.codemirror.scrollTo(0, this.config().position || 0);
42 if(success) success();
45 onExit(success, failure) {
47 this.config().position = this.codemirror.getScrollInfo().top;
48 this.doc.setText(this.codemirror.getValue());
50 $.wiki.exitTab('#SearchPerspective');
52 if(success) success();
56 $.wiki.CodeMirrorPerspective = CodeMirrorPerspective;