Last active
August 3, 2022 00:10
-
-
Save weeksdev/f295e753a406e22c82df to your computer and use it in GitHub Desktop.
CodeMirror ExtJs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| fieldLabel: 'Code Instance', | |
| itemId: 'parentFld', | |
| border: 1, | |
| html: '<textarea></textarea>', | |
| /* Overriding getValue function of the field to pull value from the codemirror text area*/ | |
| getValue: function (value) { | |
| return this.getCodeMirror().getValue(); | |
| }, | |
| /*Overriding setValue function of the field to put the value in the code mirror window*/ | |
| setValue: function (value) { | |
| this.getCodeMirror().setValue(value); | |
| }, | |
| getCodeMirror: function () { | |
| return this.getEl().query('.CodeMirror')[0].CodeMirror; | |
| }, | |
| listeners: { | |
| //on render of the component convert the textarea into a codemirror. make codeMirror a global variable while we are at it ;) | |
| render: function () { | |
| var codeMirror = CodeMirror.fromTextArea(this.getEl().down('textarea').dom, { | |
| mode: { | |
| name: "text/x-sql", globalVars: true | |
| }, | |
| //theme: theme, | |
| lineNumbers: true, | |
| readOnly: false, | |
| extraKeys: {"Ctrl-Space":"autocomplete"} | |
| }); | |
| codeMirror.setSize(700, 370); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment