Skip to content

Instantly share code, notes, and snippets.

@weeksdev
Last active August 3, 2022 00:10
Show Gist options
  • Select an option

  • Save weeksdev/f295e753a406e22c82df to your computer and use it in GitHub Desktop.

Select an option

Save weeksdev/f295e753a406e22c82df to your computer and use it in GitHub Desktop.
CodeMirror ExtJs
{
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