1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-26 00:29:47 +02:00

code editor: set default mode

This commit is contained in:
Harvey Kandola 2017-03-10 11:55:34 +00:00
parent ed431e9895
commit 67866a54b3
2 changed files with 6 additions and 10 deletions

View file

@ -39,7 +39,7 @@ export default Ember.Component.extend(TooltipMixin, {
cleanBody = cleanBody.replace('<pre class="code-mirror cm-s-solarized cm-s-dark" data-lang="', ""); cleanBody = cleanBody.replace('<pre class="code-mirror cm-s-solarized cm-s-dark" data-lang="', "");
let startPos = cleanBody.indexOf('">'); let startPos = cleanBody.indexOf('">');
let syntax = { let syntax = {
mode: "html", mode: "htmlmixed",
name: "HTML" name: "HTML"
}; };
@ -53,10 +53,7 @@ export default Ember.Component.extend(TooltipMixin, {
let opts = []; let opts = [];
_.each(_.sortBy(CodeMirror.modeInfo, 'name'), function(item) { _.each(_.sortBy(CodeMirror.modeInfo, 'name'), function(item) {
let i = { let i = { mode: item.mode, name: item.name };
mode: item.mode,
name: item.name
};
opts.pushObject(i); opts.pushObject(i);
if (item.mode === syntax) { if (item.mode === syntax) {
@ -68,7 +65,7 @@ export default Ember.Component.extend(TooltipMixin, {
// default check // default check
if (is.null(this.get("codeSyntax"))) { if (is.null(this.get("codeSyntax"))) {
this.set("codeSyntax", opts.findBy("mode", "html")); this.set("codeSyntax", opts.findBy("mode", "htmlmixed"));
} }
}, },

View file

@ -34,13 +34,11 @@ export default Ember.Component.extend({
} }
_.each(_.sortBy(CodeMirror.modeInfo, 'name'), (item) => { _.each(_.sortBy(CodeMirror.modeInfo, 'name'), (item) => {
let i = { let i = { mode: item.mode, name: item.name };
mode: item.mode,
name: item.name
};
if (item.mode === this.get('codeSyntax')) { if (item.mode === this.get('codeSyntax')) {
this.set('codeSyntax', i); this.set('codeSyntax', i);
console.log(this.get('codeSyntax'));
} }
}); });
}, },
@ -69,6 +67,7 @@ export default Ember.Component.extend({
let syntax = this.get("codeSyntax"); let syntax = this.get("codeSyntax");
if (is.not.undefined(syntax)) { if (is.not.undefined(syntax)) {
console.log(syntax);
CodeMirror.autoLoadMode(editor, syntax.mode); CodeMirror.autoLoadMode(editor, syntax.mode);
editor.setOption("mode", syntax.mode); editor.setOption("mode", syntax.mode);
} }