UNPKG

@prisma-cms/front-editor

Version:
70 lines 2.97 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RichText = void 0; const react_1 = __importDefault(require("react")); const editor_1 = __importDefault(require("@prisma-cms/editor")); const EditorComponent_1 = __importDefault(require("../../EditorComponent")); class RichText extends EditorComponent_1.default { constructor(props) { super(props); this.onChangeEditor = this.onChangeEditor.bind(this); } renderPanelView(content) { return super.renderPanelView(content || react_1.default.createElement("div", { className: "editor-component--panel-icon" }, "RichText")); } canBeChild() { return false; } onChangeEditor(value) { // const { // inEditMode, // } = this.getEditorContext(); this.updateComponentProps({ content: value, }); } isEditorReadOnly() { // let { // props: { // readOnly, // }, // } = this.getObjectWithMutations(); var _a; let readOnly = (_a = this.getObjectWithMutations()) === null || _a === void 0 ? void 0 : _a.props.readOnly; if (readOnly === undefined) { const { inEditMode } = this.getEditorContext(); readOnly = !inEditMode; } return readOnly; } renderChildren() { const _a = this.getComponentProps(this), { editorKey = 'richtext', content, components, contentEditable, data, hide_wrapper_in_default_mode, lang, object, props } = _a, // style, other = __rest(_a, ["editorKey", "content", "components", "contentEditable", "data", "hide_wrapper_in_default_mode", "lang", "object", "props"]); // const { // activeItem, // inEditMode, // } = this.getEditorContext(); const readOnly = this.isEditorReadOnly(); return (react_1.default.createElement(editor_1.default, Object.assign({ editorKey: editorKey, key: "editor", value: content, readOnly: readOnly, onChange: this.onChangeEditor }, other))); } } exports.RichText = RichText; RichText.Name = 'RichText'; RichText.defaultProps = Object.assign(Object.assign({}, EditorComponent_1.default.defaultProps), { hide_wrapper_in_default_mode: true }); exports.default = RichText; //# sourceMappingURL=index.js.map