mirror of https://github.com/hashicorp/consul
Backport of [ui] Prettify ember-cli-build into release/1.19.x (#21733)
[ui] Prettify ember-cli-build (#21731) * Missed prettification at a pre-merge step earlier * Missed lint-removal Co-authored-by: Phil Renaud <phil.renaud@hashicorp.com>pull/21734/head^2
parent
b6784bff7f
commit
4203ba6474
|
@ -49,7 +49,6 @@ export default Component.extend({
|
||||||
|
|
||||||
const editor = this.editor;
|
const editor = this.editor;
|
||||||
editor.setOption('mode', mode.mime);
|
editor.setOption('mode', mode.mime);
|
||||||
this.helper.lint(editor, mode.mode);
|
|
||||||
set(this, 'mode', mode);
|
set(this, 'mode', mode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Service, { inject as service } from '@ember/service';
|
import Service, { inject as service } from '@ember/service';
|
||||||
import lint from 'consul-ui/utils/editor/lint';
|
|
||||||
const MODES = [
|
const MODES = [
|
||||||
{
|
{
|
||||||
name: 'JSON',
|
name: 'JSON',
|
||||||
|
@ -41,10 +40,6 @@ export default class LinterService extends Service {
|
||||||
return MODES;
|
return MODES;
|
||||||
}
|
}
|
||||||
|
|
||||||
lint() {
|
|
||||||
return lint(...arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
getEditor(element) {
|
getEditor(element) {
|
||||||
return this.dom.element('textarea + div', element).CodeMirror;
|
return this.dom.element('textarea + div', element).CodeMirror;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) HashiCorp, Inc.
|
|
||||||
* SPDX-License-Identifier: BUSL-1.1
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*global CodeMirror*/
|
|
||||||
|
|
||||||
// CodeMirror doesn't seem to have anyway to hook into whether a mode
|
|
||||||
// has already loaded, or when a mode has finished loading
|
|
||||||
// follow more or less what CodeMirror does but doesn't expose
|
|
||||||
// see codemirror/addon/mode/loadmode.js
|
|
||||||
|
|
||||||
export const createLoader = function (
|
|
||||||
$$ = document.getElementsByTagName.bind(document),
|
|
||||||
CM = CodeMirror
|
|
||||||
) {
|
|
||||||
CM.registerHelper('lint', 'ruby', function (text) {
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
return function (editor, mode, cb) {
|
|
||||||
let scripts = [...$$('script')];
|
|
||||||
const loaded = scripts.find(function (item) {
|
|
||||||
return item.src.indexOf(`/codemirror/mode/${mode}/${mode}.js`) !== -1;
|
|
||||||
});
|
|
||||||
CM.autoLoadMode(editor, mode);
|
|
||||||
if (loaded) {
|
|
||||||
cb();
|
|
||||||
} else {
|
|
||||||
scripts = [...$$('script')];
|
|
||||||
CM.on(scripts[0], 'load', function () {
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
const load = createLoader();
|
|
||||||
export default function (editor, mode) {
|
|
||||||
load(editor, mode, function () {
|
|
||||||
if (editor.getValue().trim().length) {
|
|
||||||
editor.performLint();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
|
@ -206,11 +206,7 @@ module.exports = function (defaults, $ = process.env) {
|
||||||
},
|
},
|
||||||
codemirror: {
|
codemirror: {
|
||||||
keyMaps: ['sublime'],
|
keyMaps: ['sublime'],
|
||||||
addonFiles: [
|
addonFiles: ['lint/lint.css', 'lint/yaml-lint.js', 'mode/loadmode.js'],
|
||||||
'lint/lint.css',
|
|
||||||
'lint/yaml-lint.js',
|
|
||||||
'mode/loadmode.js',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
sassOptions: {
|
sassOptions: {
|
||||||
implementation: require('sass'),
|
implementation: require('sass'),
|
||||||
|
|
Loading…
Reference in New Issue