redoc/lib/components/JsonSchemaView/json-schema-view.js

31 lines
835 B
JavaScript
Raw Normal View History

2015-10-17 21:03:08 +03:00
'use strict';
import {RedocComponent, BaseComponent} from '../base';
/* temporarily this component uses json-schema-view-js lib */
import 'json-formatter-js/src/index';
import 'json-formatter-js/dist/style.css!';
import JSONSchemaView from 'json-schema-view-js/src/index';
import 'json-schema-view-js/dist/style.css!';
import {ElementRef} from 'angular2/angular2';
@RedocComponent({
selector: 'schema',
2015-10-18 12:28:48 +03:00
template: ''
2015-10-17 21:03:08 +03:00
})
2015-10-27 20:44:08 +03:00
export default class JsonSchemaView extends BaseComponent {
2015-10-17 21:03:08 +03:00
constructor(schemaMgr, elementRef) {
super(schemaMgr);
this.element = elementRef.nativeElement;
}
init() {
this.dereference();
2015-10-17 23:31:01 +03:00
const formatter = new JSONSchemaView(this.componentSchema, 1);
2015-10-17 21:03:08 +03:00
this.element.appendChild(formatter.render());
}
}
JsonSchemaView.parameters = JsonSchemaView.parameters.concat([[ElementRef]]);