open-vault/ui/app/components/json-editor.js
madalynrose 2b41283a91
UI console (#4631)
* adding columnify and ember-cli-cjs-transform

* add yargs-parser

* remove vendored yargs-parser tokenizer and use cjs transform to import it from actual yargs-parser

* add clear command that clears the log, but maintains history

* make codemirror have no gutter and be auto-height when rendered in the console output log

* add fullscreen command and hook up fullscreen toggle button

* hook up copy button
2018-05-25 16:33:22 -04:00

33 lines
917 B
JavaScript

import IvyCodemirrorComponent from './ivy-codemirror';
import Ember from 'ember';
const { assign } = Ember;
const JSON_EDITOR_DEFAULTS = {
// IMPORTANT: `gutters` must come before `lint` since the presence of
// `gutters` is cached internally when `lint` is toggled
gutters: ['CodeMirror-lint-markers'],
tabSize: 2,
mode: 'application/json',
lineNumbers: true,
lint: { lintOnChange: false },
theme: 'hashi',
readOnly: false,
};
export default IvyCodemirrorComponent.extend({
'data-test-component': 'json-editor',
updateCodeMirrorOptions() {
const options = assign({}, JSON_EDITOR_DEFAULTS, this.get('options'));
if (options.autoHeight) {
options.viewportMargin = Infinity;
delete options.autoHeight;
}
if (options) {
Object.keys(options).forEach(function(option) {
this.updateCodeMirrorOption(option, options[option]);
}, this);
}
},
});