36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import Component from '@ember/component';
|
|
import { htmlSafe } from '@ember/template';
|
|
|
|
const C = Component.extend({
|
|
tagName: 'pre',
|
|
keyColor: '#E6DB74',
|
|
numberColor: '#AE81FF',
|
|
stringColor: '#E6DB74',
|
|
trueColor: '#00CC00',
|
|
falseColor: '#FF8080',
|
|
nullColor: 'cornflowerblue',
|
|
style: 'color: #F8F8F1; background-color: #272822;',
|
|
attributeBindings: ['style'],
|
|
didReceiveAttrs() {
|
|
const me = this;
|
|
me._super(...arguments);
|
|
const content = me.get('content');
|
|
if (content) {
|
|
me.set('contentHtml', htmlSafe(jsonFormatHighlight(
|
|
JSON.stringify(JSON.parse(content), null, 4), {
|
|
keyColor: me.get('keyColor'),
|
|
numberColor: me.get('numberColor'),
|
|
stringColor: me.get('stringColor'),
|
|
trueColor: me.get('trueColor'),
|
|
falseColor: me.get('falseColor'),
|
|
nullColor: me.get('nullColor')
|
|
})));
|
|
}
|
|
}
|
|
});
|
|
|
|
C.reopenClass({
|
|
positionalParams: ['content']
|
|
});
|
|
|
|
export default C; |