mirror of https://github.com/hashicorp/consul
ui: Add XML syntax highlighting to key/value editor (#11785)
* ui: Add XML syntax highlighting to key/value editor * ui: Make explicit options that are specific to XML for claritypull/10894/head
parent
f8b336b9a0
commit
d1ac40e967
|
@ -31,11 +31,18 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setMode: function(mode) {
|
setMode: function(mode) {
|
||||||
set(this, 'options', {
|
let options = {
|
||||||
...DEFAULTS,
|
...DEFAULTS,
|
||||||
mode: mode.mime,
|
mode: mode.mime,
|
||||||
readOnly: this.readonly,
|
readOnly: this.readonly,
|
||||||
});
|
};
|
||||||
|
if (mode.name === 'XML') {
|
||||||
|
options.htmlMode = mode.htmlMode;
|
||||||
|
options.matchClosing = mode.matchClosing;
|
||||||
|
options.alignCDATA = mode.alignCDATA;
|
||||||
|
}
|
||||||
|
set(this, 'options', options);
|
||||||
|
|
||||||
const editor = this.editor;
|
const editor = this.editor;
|
||||||
editor.setOption('mode', mode.mime);
|
editor.setOption('mode', mode.mime);
|
||||||
this.helper.lint(editor, mode.mode);
|
this.helper.lint(editor, mode.mode);
|
||||||
|
|
|
@ -128,6 +128,10 @@ $syntax-dark-gray: #535f73;
|
||||||
color: var(--syntax-packer);
|
color: var(--syntax-packer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
span.cm-error {
|
||||||
|
color: var(--syntax-red);
|
||||||
|
}
|
||||||
|
|
||||||
span.cm-attribute {
|
span.cm-attribute {
|
||||||
color: #9fca56;
|
color: #9fca56;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ export function initialize(application) {
|
||||||
return fs.get(['codemirror', 'mode', 'ruby', 'ruby.js'].join('/'));
|
return fs.get(['codemirror', 'mode', 'ruby', 'ruby.js'].join('/'));
|
||||||
case 'yaml':
|
case 'yaml':
|
||||||
return fs.get(['codemirror', 'mode', 'yaml', 'yaml.js'].join('/'));
|
return fs.get(['codemirror', 'mode', 'yaml', 'yaml.js'].join('/'));
|
||||||
|
case 'xml':
|
||||||
|
return fs.get(['codemirror', 'mode', 'xml', 'xml.js'].join('/'));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,16 @@ const MODES = [
|
||||||
alias: ['jruby', 'macruby', 'rake', 'rb', 'rbx'],
|
alias: ['jruby', 'macruby', 'rake', 'rb', 'rbx'],
|
||||||
},
|
},
|
||||||
{ name: 'YAML', mime: 'text/x-yaml', mode: 'yaml', ext: ['yaml', 'yml'], alias: ['yml'] },
|
{ name: 'YAML', mime: 'text/x-yaml', mode: 'yaml', ext: ['yaml', 'yml'], alias: ['yml'] },
|
||||||
|
{
|
||||||
|
name: 'XML',
|
||||||
|
mime: 'application/xml',
|
||||||
|
mode: 'xml',
|
||||||
|
htmlMode: false,
|
||||||
|
matchClosing: true,
|
||||||
|
alignCDATA: false,
|
||||||
|
ext: ['xml'],
|
||||||
|
alias: ['xml'],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class LinterService extends Service {
|
export default class LinterService extends Service {
|
||||||
|
|
|
@ -206,6 +206,10 @@ module.exports = function(defaults, $ = process.env) {
|
||||||
app.import('node_modules/codemirror/mode/yaml/yaml.js', {
|
app.import('node_modules/codemirror/mode/yaml/yaml.js', {
|
||||||
outputFile: 'assets/codemirror/mode/yaml/yaml.js',
|
outputFile: 'assets/codemirror/mode/yaml/yaml.js',
|
||||||
});
|
});
|
||||||
|
// XML linting support. Possibly dynamically loaded via CodeMirror linting. See services/code-mirror/linter.js
|
||||||
|
app.import('node_modules/codemirror/mode/xml/xml.js', {
|
||||||
|
outputFile: 'assets/codemirror/mode/xml/xml.js',
|
||||||
|
});
|
||||||
// metrics-providers
|
// metrics-providers
|
||||||
app.import('vendor/metrics-providers/consul.js', {
|
app.import('vendor/metrics-providers/consul.js', {
|
||||||
outputFile: 'assets/metrics-providers/consul.js',
|
outputFile: 'assets/metrics-providers/consul.js',
|
||||||
|
|
|
@ -38,7 +38,8 @@ ${environment === 'production' ? `{{jsonEncode .}}` : JSON.stringify(config.oper
|
||||||
"css.escape/css.escape.js": "${rootURL}assets/css.escape.js",
|
"css.escape/css.escape.js": "${rootURL}assets/css.escape.js",
|
||||||
"codemirror/mode/javascript/javascript.js": "${rootURL}assets/codemirror/mode/javascript/javascript.js",
|
"codemirror/mode/javascript/javascript.js": "${rootURL}assets/codemirror/mode/javascript/javascript.js",
|
||||||
"codemirror/mode/ruby/ruby.js": "${rootURL}assets/codemirror/mode/ruby/ruby.js",
|
"codemirror/mode/ruby/ruby.js": "${rootURL}assets/codemirror/mode/ruby/ruby.js",
|
||||||
"codemirror/mode/yaml/yaml.js": "${rootURL}assets/codemirror/mode/yaml/yaml.js"
|
"codemirror/mode/yaml/yaml.js": "${rootURL}assets/codemirror/mode/yaml/yaml.js",
|
||||||
|
"codemirror/mode/xml/xml.js": "${rootURL}assets/codemirror/mode/xml/xml.js"
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script data-app-name="${appName}" data-${appName}-services src="${rootURL}assets/consul-ui/services.js"></script>
|
<script data-app-name="${appName}" data-${appName}-services src="${rootURL}assets/consul-ui/services.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue