@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
42 lines (41 loc) • 2.08 kB
JavaScript
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";
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';
import { EditorContext } from '@atlaskit/editor-common/UNSAFE_do_not_use_editor_context';
import EditorActions from '../../actions';
export var useEditorContext = function useEditorContext() {
return React.useContext(EditorContext);
};
// Ignored via go/ees005
// eslint-disable-next-line @repo/internal/react/no-class-components, react/prefer-stateless-function
export var LegacyEditorContext = /*#__PURE__*/function (_React$Component) {
function LegacyEditorContext(props) {
var _this;
_classCallCheck(this, LegacyEditorContext);
_this = _callSuper(this, LegacyEditorContext, [props]);
_this.editorActions = props.editorActions || new EditorActions();
_this.contextValue = {
editorActions: _this.editorActions
};
return _this;
}
_inherits(LegacyEditorContext, _React$Component);
return _createClass(LegacyEditorContext, [{
key: "render",
value: function render() {
return /*#__PURE__*/React.createElement(EditorContext.Provider, {
value: this.contextValue
}, this.props.children);
}
}]);
}(React.Component);
export default (function (props) {
return /*#__PURE__*/React.createElement(LegacyEditorContext, {
editorActions: props.editorActions
}, props.children);
});