@atlaskit/editor-core 198.6.3 → 198.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 198.6.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#151676](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/151676)
8
+ [`ed6d01983b0da`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ed6d01983b0da) -
9
+ ED-25183: Remediate WithEditorActions, WithPluginState & LegacyEditorContext context type
10
+
3
11
  ## 198.6.3
4
12
 
5
13
  ### Patch Changes
@@ -4,35 +4,70 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useEditorContext = exports.default = void 0;
7
+ exports.useEditorContext = exports.default = exports.LegacyEditorContext = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
11
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
11
12
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
12
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _propTypes = _interopRequireDefault(require("prop-types"));
16
+ var _UNSAFE_do_not_use_editor_context = require("@atlaskit/editor-common/UNSAFE_do_not_use_editor_context");
16
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
18
  var _actions = _interopRequireDefault(require("../../actions"));
18
19
  var _context = require("../../presets/context");
19
20
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
20
21
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
- var EditorContext = /*#__PURE__*/_react.default.createContext({});
22
22
  var useEditorContext = exports.useEditorContext = function useEditorContext() {
23
- return _react.default.useContext(EditorContext);
23
+ return _react.default.useContext(_UNSAFE_do_not_use_editor_context.EditorContext);
24
24
  };
25
- var LegacyEditorContext = exports.default = /*#__PURE__*/function (_React$Component) {
25
+ var LegacyEditorContext = exports.LegacyEditorContext = /*#__PURE__*/function (_React$Component) {
26
26
  (0, _inherits2.default)(LegacyEditorContext, _React$Component);
27
27
  var _super = _createSuper(LegacyEditorContext);
28
28
  function LegacyEditorContext(props) {
29
- var _this;
30
29
  (0, _classCallCheck2.default)(this, LegacyEditorContext);
31
- _this = _super.call(this, props);
30
+ return _super.call(this, props);
31
+ }
32
+ (0, _createClass2.default)(LegacyEditorContext, [{
33
+ key: "render",
34
+ value: function render() {
35
+ if ((0, _platformFeatureFlags.fg)('platform_editor_react18_phase2')) {
36
+ return /*#__PURE__*/_react.default.createElement(LegacyEditorContextNew, this.props, this.props.children);
37
+ }
38
+ return /*#__PURE__*/_react.default.createElement(LegacyEditorContextOld, this.props, this.props.children);
39
+ }
40
+ }]);
41
+ return LegacyEditorContext;
42
+ }(_react.default.Component);
43
+ function LegacyEditorContextNew(_ref) {
44
+ var children = _ref.children,
45
+ editorActions = _ref.editorActions;
46
+ if ((0, _platformFeatureFlags.fg)('platform_editor_remove_use_preset_context')) {
47
+ return /*#__PURE__*/_react.default.createElement(_UNSAFE_do_not_use_editor_context.EditorContext.Provider, {
48
+ value: {
49
+ editorActions: editorActions !== null && editorActions !== void 0 ? editorActions : new _actions.default()
50
+ }
51
+ }, children);
52
+ } else {
53
+ return /*#__PURE__*/_react.default.createElement(_UNSAFE_do_not_use_editor_context.EditorContext.Provider, {
54
+ value: {
55
+ editorActions: editorActions !== null && editorActions !== void 0 ? editorActions : new _actions.default()
56
+ }
57
+ }, /*#__PURE__*/_react.default.createElement(_context.PresetContextProvider, null, children));
58
+ }
59
+ }
60
+ var LegacyEditorContextOld = exports.default = /*#__PURE__*/function (_React$Component2) {
61
+ (0, _inherits2.default)(LegacyEditorContextOld, _React$Component2);
62
+ var _super2 = _createSuper(LegacyEditorContextOld);
63
+ function LegacyEditorContextOld(props) {
64
+ var _this;
65
+ (0, _classCallCheck2.default)(this, LegacyEditorContextOld);
66
+ _this = _super2.call(this, props);
32
67
  _this.editorActions = props.editorActions || new _actions.default();
33
68
  return _this;
34
69
  }
35
- (0, _createClass2.default)(LegacyEditorContext, [{
70
+ (0, _createClass2.default)(LegacyEditorContextOld, [{
36
71
  key: "getChildContext",
37
72
  value: function getChildContext() {
38
73
  return {
@@ -43,18 +78,18 @@ var LegacyEditorContext = exports.default = /*#__PURE__*/function (_React$Compon
43
78
  key: "render",
44
79
  value: function render() {
45
80
  if ((0, _platformFeatureFlags.fg)('platform_editor_remove_use_preset_context')) {
46
- return /*#__PURE__*/_react.default.createElement(EditorContext.Provider, {
81
+ return /*#__PURE__*/_react.default.createElement(_UNSAFE_do_not_use_editor_context.EditorContext.Provider, {
47
82
  value: this.getChildContext()
48
83
  }, this.props.children);
49
84
  } else {
50
- return /*#__PURE__*/_react.default.createElement(EditorContext.Provider, {
85
+ return /*#__PURE__*/_react.default.createElement(_UNSAFE_do_not_use_editor_context.EditorContext.Provider, {
51
86
  value: this.getChildContext()
52
87
  }, /*#__PURE__*/_react.default.createElement(_context.PresetContextProvider, null, this.props.children));
53
88
  }
54
89
  }
55
90
  }]);
56
- return LegacyEditorContext;
91
+ return LegacyEditorContextOld;
57
92
  }(_react.default.Component);
58
- (0, _defineProperty2.default)(LegacyEditorContext, "childContextTypes", {
93
+ (0, _defineProperty2.default)(LegacyEditorContextOld, "childContextTypes", {
59
94
  editorActions: _propTypes.default.object
60
95
  });
@@ -5,34 +5,93 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
12
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
13
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
14
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _react = _interopRequireDefault(require("react"));
16
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
+ var _UNSAFE_do_not_use_editor_context = require("@atlaskit/editor-common/UNSAFE_do_not_use_editor_context");
18
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
19
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = (0, _getPrototypeOf2.default)(t); if (r) { var s = (0, _getPrototypeOf2.default)(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return (0, _possibleConstructorReturn2.default)(this, e); }; }
18
20
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
19
21
  var WithEditorActions = exports.default = /*#__PURE__*/function (_React$Component) {
20
22
  (0, _inherits2.default)(WithEditorActions, _React$Component);
21
23
  var _super = _createSuper(WithEditorActions);
22
- function WithEditorActions() {
23
- var _this;
24
+ function WithEditorActions(props) {
24
25
  (0, _classCallCheck2.default)(this, WithEditorActions);
26
+ return _super.call(this, props);
27
+ }
28
+ (0, _createClass2.default)(WithEditorActions, [{
29
+ key: "render",
30
+ value: function render() {
31
+ if ((0, _platformFeatureFlags.fg)('platform_editor_react18_phase2')) {
32
+ return /*#__PURE__*/_react.default.createElement(WithEditorActionsNew, this.props);
33
+ }
34
+ return /*#__PURE__*/_react.default.createElement(WithEditorActionsOld, this.props);
35
+ }
36
+ }]);
37
+ return WithEditorActions;
38
+ }(_react.default.Component);
39
+ function WithEditorActionsNew(props) {
40
+ var render = props.render;
41
+ var context = _react.default.useContext(_UNSAFE_do_not_use_editor_context.EditorContext);
42
+ return /*#__PURE__*/_react.default.createElement(WithEditorActionsInner, {
43
+ render: render,
44
+ editorActions: context === null || context === void 0 ? void 0 : context.editorActions
45
+ });
46
+ }
47
+ var WithEditorActionsInner = /*#__PURE__*/function (_React$Component2) {
48
+ (0, _inherits2.default)(WithEditorActionsInner, _React$Component2);
49
+ var _super2 = _createSuper(WithEditorActionsInner);
50
+ function WithEditorActionsInner() {
51
+ (0, _classCallCheck2.default)(this, WithEditorActionsInner);
52
+ return _super2.apply(this, arguments);
53
+ }
54
+ (0, _createClass2.default)(WithEditorActionsInner, [{
55
+ key: "componentDidMount",
56
+ value: function componentDidMount() {
57
+ var _this = this;
58
+ this.props.editorActions._privateSubscribe(function () {
59
+ return _this.forceUpdate();
60
+ });
61
+ }
62
+ }, {
63
+ key: "componentWillUnmount",
64
+ value: function componentWillUnmount() {
65
+ var _this2 = this;
66
+ this.props.editorActions._privateUnsubscribe(function () {
67
+ return _this2.forceUpdate();
68
+ });
69
+ }
70
+ }, {
71
+ key: "render",
72
+ value: function render() {
73
+ return this.props.render(this.props.editorActions);
74
+ }
75
+ }]);
76
+ return WithEditorActionsInner;
77
+ }(_react.default.Component);
78
+ var WithEditorActionsOld = /*#__PURE__*/function (_React$Component3) {
79
+ (0, _inherits2.default)(WithEditorActionsOld, _React$Component3);
80
+ var _super3 = _createSuper(WithEditorActionsOld);
81
+ function WithEditorActionsOld() {
82
+ var _this3;
83
+ (0, _classCallCheck2.default)(this, WithEditorActionsOld);
25
84
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
85
  args[_key] = arguments[_key];
27
86
  }
28
- _this = _super.call.apply(_super, [this].concat(args));
29
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onContextUpdate", function () {
87
+ _this3 = _super3.call.apply(_super3, [this].concat(args));
88
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this3), "onContextUpdate", function () {
30
89
  // Re-render actions when editorActions changes...
31
- _this.forceUpdate();
90
+ _this3.forceUpdate();
32
91
  });
33
- return _this;
92
+ return _this3;
34
93
  }
35
- (0, _createClass2.default)(WithEditorActions, [{
94
+ (0, _createClass2.default)(WithEditorActionsOld, [{
36
95
  key: "componentDidMount",
37
96
  value: function componentDidMount() {
38
97
  this.context.editorActions._privateSubscribe(this.onContextUpdate);
@@ -48,8 +107,8 @@ var WithEditorActions = exports.default = /*#__PURE__*/function (_React$Componen
48
107
  return this.props.render(this.context.editorActions);
49
108
  }
50
109
  }]);
51
- return WithEditorActions;
110
+ return WithEditorActionsOld;
52
111
  }(_react.default.Component);
53
- (0, _defineProperty2.default)(WithEditorActions, "contextTypes", {
112
+ (0, _defineProperty2.default)(WithEditorActionsOld, "contextTypes", {
54
113
  editorActions: _propTypes.default.object.isRequired
55
114
  });
@@ -5,4 +5,4 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "198.6.3";
8
+ var version = exports.version = "198.6.4";
@@ -1,12 +1,41 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
+ import { EditorContext } from '@atlaskit/editor-common/UNSAFE_do_not_use_editor_context';
4
5
  import { fg } from '@atlaskit/platform-feature-flags';
5
6
  import EditorActions from '../../actions';
6
7
  import { PresetContextProvider } from '../../presets/context';
7
- const EditorContext = /*#__PURE__*/React.createContext({});
8
8
  export const useEditorContext = () => React.useContext(EditorContext);
9
- export default class LegacyEditorContext extends React.Component {
9
+ export class LegacyEditorContext extends React.Component {
10
+ constructor(props) {
11
+ super(props);
12
+ }
13
+ render() {
14
+ if (fg('platform_editor_react18_phase2')) {
15
+ return /*#__PURE__*/React.createElement(LegacyEditorContextNew, this.props, this.props.children);
16
+ }
17
+ return /*#__PURE__*/React.createElement(LegacyEditorContextOld, this.props, this.props.children);
18
+ }
19
+ }
20
+ function LegacyEditorContextNew({
21
+ children,
22
+ editorActions
23
+ }) {
24
+ if (fg('platform_editor_remove_use_preset_context')) {
25
+ return /*#__PURE__*/React.createElement(EditorContext.Provider, {
26
+ value: {
27
+ editorActions: editorActions !== null && editorActions !== void 0 ? editorActions : new EditorActions()
28
+ }
29
+ }, children);
30
+ } else {
31
+ return /*#__PURE__*/React.createElement(EditorContext.Provider, {
32
+ value: {
33
+ editorActions: editorActions !== null && editorActions !== void 0 ? editorActions : new EditorActions()
34
+ }
35
+ }, /*#__PURE__*/React.createElement(PresetContextProvider, null, children));
36
+ }
37
+ }
38
+ export default class LegacyEditorContextOld extends React.Component {
10
39
  constructor(props) {
11
40
  super(props);
12
41
  this.editorActions = props.editorActions || new EditorActions();
@@ -28,6 +57,6 @@ export default class LegacyEditorContext extends React.Component {
28
57
  }
29
58
  }
30
59
  }
31
- _defineProperty(LegacyEditorContext, "childContextTypes", {
60
+ _defineProperty(LegacyEditorContextOld, "childContextTypes", {
32
61
  editorActions: PropTypes.object
33
62
  });
@@ -1,7 +1,41 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
+ import { EditorContext } from '@atlaskit/editor-common/UNSAFE_do_not_use_editor_context';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
4
6
  export default class WithEditorActions extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ }
10
+ render() {
11
+ if (fg('platform_editor_react18_phase2')) {
12
+ return /*#__PURE__*/React.createElement(WithEditorActionsNew, this.props);
13
+ }
14
+ return /*#__PURE__*/React.createElement(WithEditorActionsOld, this.props);
15
+ }
16
+ }
17
+ function WithEditorActionsNew(props) {
18
+ const {
19
+ render
20
+ } = props;
21
+ const context = React.useContext(EditorContext);
22
+ return /*#__PURE__*/React.createElement(WithEditorActionsInner, {
23
+ render: render,
24
+ editorActions: context === null || context === void 0 ? void 0 : context.editorActions
25
+ });
26
+ }
27
+ class WithEditorActionsInner extends React.Component {
28
+ componentDidMount() {
29
+ this.props.editorActions._privateSubscribe(() => this.forceUpdate());
30
+ }
31
+ componentWillUnmount() {
32
+ this.props.editorActions._privateUnsubscribe(() => this.forceUpdate());
33
+ }
34
+ render() {
35
+ return this.props.render(this.props.editorActions);
36
+ }
37
+ }
38
+ class WithEditorActionsOld extends React.Component {
5
39
  constructor(...args) {
6
40
  super(...args);
7
41
  _defineProperty(this, "onContextUpdate", () => {
@@ -19,6 +53,6 @@ export default class WithEditorActions extends React.Component {
19
53
  return this.props.render(this.context.editorActions);
20
54
  }
21
55
  }
22
- _defineProperty(WithEditorActions, "contextTypes", {
56
+ _defineProperty(WithEditorActionsOld, "contextTypes", {
23
57
  editorActions: PropTypes.object.isRequired
24
58
  });
@@ -1,2 +1,2 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "198.6.3";
2
+ export const version = "198.6.4";
@@ -1,31 +1,66 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
3
  import _createClass from "@babel/runtime/helpers/createClass";
3
4
  import _inherits from "@babel/runtime/helpers/inherits";
4
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
7
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
8
8
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
9
  import React from 'react';
10
10
  import PropTypes from 'prop-types';
11
+ import { EditorContext } from '@atlaskit/editor-common/UNSAFE_do_not_use_editor_context';
11
12
  import { fg } from '@atlaskit/platform-feature-flags';
12
13
  import EditorActions from '../../actions';
13
14
  import { PresetContextProvider } from '../../presets/context';
14
- var EditorContext = /*#__PURE__*/React.createContext({});
15
15
  export var useEditorContext = function useEditorContext() {
16
16
  return React.useContext(EditorContext);
17
17
  };
18
- var LegacyEditorContext = /*#__PURE__*/function (_React$Component) {
18
+ export var LegacyEditorContext = /*#__PURE__*/function (_React$Component) {
19
19
  _inherits(LegacyEditorContext, _React$Component);
20
20
  var _super = _createSuper(LegacyEditorContext);
21
21
  function LegacyEditorContext(props) {
22
- var _this;
23
22
  _classCallCheck(this, LegacyEditorContext);
24
- _this = _super.call(this, props);
23
+ return _super.call(this, props);
24
+ }
25
+ _createClass(LegacyEditorContext, [{
26
+ key: "render",
27
+ value: function render() {
28
+ if (fg('platform_editor_react18_phase2')) {
29
+ return /*#__PURE__*/React.createElement(LegacyEditorContextNew, this.props, this.props.children);
30
+ }
31
+ return /*#__PURE__*/React.createElement(LegacyEditorContextOld, this.props, this.props.children);
32
+ }
33
+ }]);
34
+ return LegacyEditorContext;
35
+ }(React.Component);
36
+ function LegacyEditorContextNew(_ref) {
37
+ var children = _ref.children,
38
+ editorActions = _ref.editorActions;
39
+ if (fg('platform_editor_remove_use_preset_context')) {
40
+ return /*#__PURE__*/React.createElement(EditorContext.Provider, {
41
+ value: {
42
+ editorActions: editorActions !== null && editorActions !== void 0 ? editorActions : new EditorActions()
43
+ }
44
+ }, children);
45
+ } else {
46
+ return /*#__PURE__*/React.createElement(EditorContext.Provider, {
47
+ value: {
48
+ editorActions: editorActions !== null && editorActions !== void 0 ? editorActions : new EditorActions()
49
+ }
50
+ }, /*#__PURE__*/React.createElement(PresetContextProvider, null, children));
51
+ }
52
+ }
53
+ var LegacyEditorContextOld = /*#__PURE__*/function (_React$Component2) {
54
+ _inherits(LegacyEditorContextOld, _React$Component2);
55
+ var _super2 = _createSuper(LegacyEditorContextOld);
56
+ function LegacyEditorContextOld(props) {
57
+ var _this;
58
+ _classCallCheck(this, LegacyEditorContextOld);
59
+ _this = _super2.call(this, props);
25
60
  _this.editorActions = props.editorActions || new EditorActions();
26
61
  return _this;
27
62
  }
28
- _createClass(LegacyEditorContext, [{
63
+ _createClass(LegacyEditorContextOld, [{
29
64
  key: "getChildContext",
30
65
  value: function getChildContext() {
31
66
  return {
@@ -46,9 +81,9 @@ var LegacyEditorContext = /*#__PURE__*/function (_React$Component) {
46
81
  }
47
82
  }
48
83
  }]);
49
- return LegacyEditorContext;
84
+ return LegacyEditorContextOld;
50
85
  }(React.Component);
51
- _defineProperty(LegacyEditorContext, "childContextTypes", {
86
+ _defineProperty(LegacyEditorContextOld, "childContextTypes", {
52
87
  editorActions: PropTypes.object
53
88
  });
54
- export { LegacyEditorContext as default };
89
+ export { LegacyEditorContextOld as default };
@@ -1,31 +1,91 @@
1
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
4
  import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
5
  import _inherits from "@babel/runtime/helpers/inherits";
5
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
9
9
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
10
  import React from 'react';
11
11
  import PropTypes from 'prop-types';
12
+ import { EditorContext } from '@atlaskit/editor-common/UNSAFE_do_not_use_editor_context';
13
+ import { fg } from '@atlaskit/platform-feature-flags';
12
14
  var WithEditorActions = /*#__PURE__*/function (_React$Component) {
13
15
  _inherits(WithEditorActions, _React$Component);
14
16
  var _super = _createSuper(WithEditorActions);
15
- function WithEditorActions() {
16
- var _this;
17
+ function WithEditorActions(props) {
17
18
  _classCallCheck(this, WithEditorActions);
19
+ return _super.call(this, props);
20
+ }
21
+ _createClass(WithEditorActions, [{
22
+ key: "render",
23
+ value: function render() {
24
+ if (fg('platform_editor_react18_phase2')) {
25
+ return /*#__PURE__*/React.createElement(WithEditorActionsNew, this.props);
26
+ }
27
+ return /*#__PURE__*/React.createElement(WithEditorActionsOld, this.props);
28
+ }
29
+ }]);
30
+ return WithEditorActions;
31
+ }(React.Component);
32
+ export { WithEditorActions as default };
33
+ function WithEditorActionsNew(props) {
34
+ var render = props.render;
35
+ var context = React.useContext(EditorContext);
36
+ return /*#__PURE__*/React.createElement(WithEditorActionsInner, {
37
+ render: render,
38
+ editorActions: context === null || context === void 0 ? void 0 : context.editorActions
39
+ });
40
+ }
41
+ var WithEditorActionsInner = /*#__PURE__*/function (_React$Component2) {
42
+ _inherits(WithEditorActionsInner, _React$Component2);
43
+ var _super2 = _createSuper(WithEditorActionsInner);
44
+ function WithEditorActionsInner() {
45
+ _classCallCheck(this, WithEditorActionsInner);
46
+ return _super2.apply(this, arguments);
47
+ }
48
+ _createClass(WithEditorActionsInner, [{
49
+ key: "componentDidMount",
50
+ value: function componentDidMount() {
51
+ var _this = this;
52
+ this.props.editorActions._privateSubscribe(function () {
53
+ return _this.forceUpdate();
54
+ });
55
+ }
56
+ }, {
57
+ key: "componentWillUnmount",
58
+ value: function componentWillUnmount() {
59
+ var _this2 = this;
60
+ this.props.editorActions._privateUnsubscribe(function () {
61
+ return _this2.forceUpdate();
62
+ });
63
+ }
64
+ }, {
65
+ key: "render",
66
+ value: function render() {
67
+ return this.props.render(this.props.editorActions);
68
+ }
69
+ }]);
70
+ return WithEditorActionsInner;
71
+ }(React.Component);
72
+ var WithEditorActionsOld = /*#__PURE__*/function (_React$Component3) {
73
+ _inherits(WithEditorActionsOld, _React$Component3);
74
+ var _super3 = _createSuper(WithEditorActionsOld);
75
+ function WithEditorActionsOld() {
76
+ var _this3;
77
+ _classCallCheck(this, WithEditorActionsOld);
18
78
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
19
79
  args[_key] = arguments[_key];
20
80
  }
21
- _this = _super.call.apply(_super, [this].concat(args));
22
- _defineProperty(_assertThisInitialized(_this), "onContextUpdate", function () {
81
+ _this3 = _super3.call.apply(_super3, [this].concat(args));
82
+ _defineProperty(_assertThisInitialized(_this3), "onContextUpdate", function () {
23
83
  // Re-render actions when editorActions changes...
24
- _this.forceUpdate();
84
+ _this3.forceUpdate();
25
85
  });
26
- return _this;
86
+ return _this3;
27
87
  }
28
- _createClass(WithEditorActions, [{
88
+ _createClass(WithEditorActionsOld, [{
29
89
  key: "componentDidMount",
30
90
  value: function componentDidMount() {
31
91
  this.context.editorActions._privateSubscribe(this.onContextUpdate);
@@ -41,9 +101,8 @@ var WithEditorActions = /*#__PURE__*/function (_React$Component) {
41
101
  return this.props.render(this.context.editorActions);
42
102
  }
43
103
  }]);
44
- return WithEditorActions;
104
+ return WithEditorActionsOld;
45
105
  }(React.Component);
46
- _defineProperty(WithEditorActions, "contextTypes", {
106
+ _defineProperty(WithEditorActionsOld, "contextTypes", {
47
107
  editorActions: PropTypes.object.isRequired
48
- });
49
- export { WithEditorActions as default };
108
+ });
@@ -1,2 +1,2 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "198.6.3";
2
+ export var version = "198.6.4";
@@ -1,11 +1,16 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import EditorActions from '../../actions';
4
- export type EditorContextProps = React.PropsWithChildren<{
4
+ type EditorContextInternal = {
5
5
  editorActions?: EditorActions;
6
- }>;
6
+ };
7
+ export type EditorContextProps = React.PropsWithChildren<EditorContextInternal>;
7
8
  export declare const useEditorContext: () => EditorContextProps;
8
- export default class LegacyEditorContext extends React.Component<EditorContextProps, {}> {
9
+ export declare class LegacyEditorContext extends React.Component<EditorContextProps, {}> {
10
+ constructor(props: EditorContextProps);
11
+ render(): JSX.Element;
12
+ }
13
+ export default class LegacyEditorContextOld extends React.Component<EditorContextProps, {}> {
9
14
  static childContextTypes: {
10
15
  editorActions: PropTypes.Requireable<object>;
11
16
  };
@@ -16,3 +21,4 @@ export default class LegacyEditorContext extends React.Component<EditorContextPr
16
21
  };
17
22
  render(): JSX.Element;
18
23
  }
24
+ export {};
@@ -1,18 +1,9 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type EditorActions from '../../actions';
4
3
  export interface WithEditorActionsProps {
5
4
  render(actions: EditorActions): React.ReactElement | null;
6
5
  }
7
- export default class WithEditorActions extends React.Component<WithEditorActionsProps> {
8
- static contextTypes: {
9
- editorActions: PropTypes.Validator<object>;
10
- };
11
- context: {
12
- editorActions: EditorActions;
13
- };
14
- componentDidMount(): void;
15
- componentWillUnmount(): void;
16
- private onContextUpdate;
17
- render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
6
+ export default class WithEditorActions extends React.Component<WithEditorActionsProps, {}> {
7
+ constructor(props: WithEditorActionsProps);
8
+ render(): JSX.Element;
18
9
  }
@@ -1,11 +1,16 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import EditorActions from '../../actions';
4
- export type EditorContextProps = React.PropsWithChildren<{
4
+ type EditorContextInternal = {
5
5
  editorActions?: EditorActions;
6
- }>;
6
+ };
7
+ export type EditorContextProps = React.PropsWithChildren<EditorContextInternal>;
7
8
  export declare const useEditorContext: () => EditorContextProps;
8
- export default class LegacyEditorContext extends React.Component<EditorContextProps, {}> {
9
+ export declare class LegacyEditorContext extends React.Component<EditorContextProps, {}> {
10
+ constructor(props: EditorContextProps);
11
+ render(): JSX.Element;
12
+ }
13
+ export default class LegacyEditorContextOld extends React.Component<EditorContextProps, {}> {
9
14
  static childContextTypes: {
10
15
  editorActions: PropTypes.Requireable<object>;
11
16
  };
@@ -16,3 +21,4 @@ export default class LegacyEditorContext extends React.Component<EditorContextPr
16
21
  };
17
22
  render(): JSX.Element;
18
23
  }
24
+ export {};
@@ -1,18 +1,9 @@
1
1
  import React from 'react';
2
- import PropTypes from 'prop-types';
3
2
  import type EditorActions from '../../actions';
4
3
  export interface WithEditorActionsProps {
5
4
  render(actions: EditorActions): React.ReactElement | null;
6
5
  }
7
- export default class WithEditorActions extends React.Component<WithEditorActionsProps> {
8
- static contextTypes: {
9
- editorActions: PropTypes.Validator<object>;
10
- };
11
- context: {
12
- editorActions: EditorActions;
13
- };
14
- componentDidMount(): void;
15
- componentWillUnmount(): void;
16
- private onContextUpdate;
17
- render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
6
+ export default class WithEditorActions extends React.Component<WithEditorActionsProps, {}> {
7
+ constructor(props: WithEditorActionsProps);
8
+ render(): JSX.Element;
18
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "198.6.3",
3
+ "version": "198.6.4",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -103,7 +103,7 @@
103
103
  "@atlaskit/visual-regression": "*",
104
104
  "@atlassian/adf-schema-json": "^1.22.0",
105
105
  "@atlassian/feature-flags-test-utils": "*",
106
- "@atlassian/search-provider": "2.4.147",
106
+ "@atlassian/search-provider": "2.4.148",
107
107
  "@emotion/jest": "^11.8.0",
108
108
  "@storybook/addon-knobs": "^5.3.18",
109
109
  "@testing-library/react": "^12.1.5",
@@ -267,6 +267,10 @@
267
267
  "type": "boolean",
268
268
  "referenceOnly": true
269
269
  },
270
+ "platform_editor_react18_phase2": {
271
+ "type": "boolean",
272
+ "referenceOnly": true
273
+ },
270
274
  "platform_editor_react18_extension_component": {
271
275
  "type": "boolean"
272
276
  },
@@ -289,10 +293,6 @@
289
293
  "type": "boolean",
290
294
  "referenceOnly": true
291
295
  },
292
- "platform_editor_react18_phase2": {
293
- "type": "boolean",
294
- "referenceOnly": true
295
- },
296
296
  "platform_editor_element_dnd_nested_fix_patch_2": {
297
297
  "type": "boolean",
298
298
  "referenceOnly": true