react-schema-based-json-editor
Version:
A reactjs component of schema based json editor.
34 lines (33 loc) • 1.74 kB
JavaScript
import { __extends } from "tslib";
import * as React from 'react';
import * as common from 'schema-based-json-editor';
export * from 'schema-based-json-editor';
import { Editor } from './editor';
/**
* @public
*/
var JSONEditor = /** @class */ (function (_super) {
__extends(JSONEditor, _super);
function JSONEditor(props) {
var _this = _super.call(this, props) || this;
_this.getReference = function (name) {
if (_this.props.schema.definitions) {
return _this.props.schema.definitions[name.substring('#/definitions/'.length)];
}
return undefined;
};
_this.updateValue = function (value, isValid) {
_this.props.updateValue(value, isValid);
};
_this.md = common.initializeMarkdown(_this.props.markdownit, _this.props.hljs, _this.props.forceHttps);
return _this;
}
JSONEditor.prototype.render = function () {
var theme = common.getTheme(this.props.theme);
var locale = common.getLocale(this.props.locale);
var icon = common.getIcon(this.props.icon, locale);
return React.createElement(Editor, { schema: this.props.schema, initialValue: this.props.initialValue, updateValue: this.updateValue, getReference: this.getReference, readonly: this.props.readonly, theme: theme, locale: locale, icon: icon, required: true, dragula: this.props.dragula, md: this.md, hljs: this.props.hljs, forceHttps: this.props.forceHttps, disableCollapse: this.props.disableCollapse, noSelect2: this.props.noSelect2, minItemCountIfNeedFilter: this.props.minItemCountIfNeedFilter, monacoEditor: this.props.monacoEditor });
};
return JSONEditor;
}(React.Component));
export { JSONEditor };