UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

77 lines (74 loc) 3.24 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; import _createClass from "@babel/runtime/helpers/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/inherits"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; var _excluded = ["Editor"]; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } import React from 'react'; // Ignored via go/ees005 // eslint-disable-next-line import/no-namespace import ChromeCollapsed from '../ui/ChromeCollapsed'; // eslint-disable-next-line @typescript-eslint/no-explicit-any // Ignored via go/ees005 // eslint-disable-next-line @repo/internal/react/no-class-components var CollapsedEditor = /*#__PURE__*/function (_React$Component) { function CollapsedEditor() { var _this; _classCallCheck(this, CollapsedEditor); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _callSuper(this, CollapsedEditor, [].concat(args)); _defineProperty(_this, "state", { editorModules: CollapsedEditor.editorModules }); return _this; } _inherits(CollapsedEditor, _React$Component); return _createClass(CollapsedEditor, [{ key: "componentDidMount", value: function componentDidMount() { if (!this.state.editorModules) { this.loadEditorModules(); } } }, { key: "loadEditorModules", value: function loadEditorModules() { var _this2 = this; import( /* webpackChunkName:"@atlaskit-internal_editor-core-async" */'../').then(function (modules) { CollapsedEditor.editorModules = modules; _this2.setState({ editorModules: modules }); }); } }, { key: "render", value: function render() { if (!this.props.isExpanded) { return /*#__PURE__*/React.createElement(ChromeCollapsed, { onFocus: this.props.onClickToExpand, text: this.props.placeholder }); } if (!this.state.editorModules) { // Ignored via go/ees007 // eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format // TODO: Proper loading state return /*#__PURE__*/React.createElement(ChromeCollapsed, { text: "Loading..." }); } var _this$state$editorMod = this.state.editorModules, Editor = _this$state$editorMod.Editor, rest = _objectWithoutProperties(_this$state$editorMod, _excluded); return this.props.renderEditor(Editor, rest); } }]); }(React.Component); export { CollapsedEditor as default };