mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
code editor: set default mode
This commit is contained in:
parent
ed431e9895
commit
67866a54b3
2 changed files with 6 additions and 10 deletions
|
@ -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="', "");
|
||||
let startPos = cleanBody.indexOf('">');
|
||||
let syntax = {
|
||||
mode: "html",
|
||||
mode: "htmlmixed",
|
||||
name: "HTML"
|
||||
};
|
||||
|
||||
|
@ -53,10 +53,7 @@ export default Ember.Component.extend(TooltipMixin, {
|
|||
let opts = [];
|
||||
|
||||
_.each(_.sortBy(CodeMirror.modeInfo, 'name'), function(item) {
|
||||
let i = {
|
||||
mode: item.mode,
|
||||
name: item.name
|
||||
};
|
||||
let i = { mode: item.mode, name: item.name };
|
||||
opts.pushObject(i);
|
||||
|
||||
if (item.mode === syntax) {
|
||||
|
@ -68,7 +65,7 @@ export default Ember.Component.extend(TooltipMixin, {
|
|||
|
||||
// default check
|
||||
if (is.null(this.get("codeSyntax"))) {
|
||||
this.set("codeSyntax", opts.findBy("mode", "html"));
|
||||
this.set("codeSyntax", opts.findBy("mode", "htmlmixed"));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -34,13 +34,11 @@ export default Ember.Component.extend({
|
|||
}
|
||||
|
||||
_.each(_.sortBy(CodeMirror.modeInfo, 'name'), (item) => {
|
||||
let i = {
|
||||
mode: item.mode,
|
||||
name: item.name
|
||||
};
|
||||
let i = { mode: item.mode, name: item.name };
|
||||
|
||||
if (item.mode === this.get('codeSyntax')) {
|
||||
this.set('codeSyntax', i);
|
||||
console.log(this.get('codeSyntax'));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -69,6 +67,7 @@ export default Ember.Component.extend({
|
|||
|
||||
let syntax = this.get("codeSyntax");
|
||||
if (is.not.undefined(syntax)) {
|
||||
console.log(syntax);
|
||||
CodeMirror.autoLoadMode(editor, syntax.mode);
|
||||
editor.setOption("mode", syntax.mode);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue