@atlaskit/editor-core 195.6.1 → 195.7.0

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cjs/create-editor/ReactEditorView.js +2 -10
  3. package/dist/cjs/create-editor/create-editor.js +0 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/ui/Appearance/FullPage/FullPage.js +1 -0
  6. package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea.js +64 -60
  7. package/dist/cjs/ui/ContextPanel/deprecated.js +283 -0
  8. package/dist/cjs/ui/ContextPanel/index.js +26 -133
  9. package/dist/cjs/version-wrapper.js +1 -1
  10. package/dist/es2019/create-editor/ReactEditorView.js +2 -6
  11. package/dist/es2019/create-editor/create-editor.js +0 -1
  12. package/dist/es2019/index.js +6 -1
  13. package/dist/es2019/ui/Appearance/FullPage/FullPage.js +1 -0
  14. package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea.js +4 -1
  15. package/dist/es2019/ui/ContextPanel/deprecated.js +258 -0
  16. package/dist/es2019/ui/ContextPanel/index.js +24 -133
  17. package/dist/es2019/version-wrapper.js +1 -1
  18. package/dist/esm/create-editor/ReactEditorView.js +2 -10
  19. package/dist/esm/create-editor/create-editor.js +0 -1
  20. package/dist/esm/index.js +6 -1
  21. package/dist/esm/ui/Appearance/FullPage/FullPage.js +1 -0
  22. package/dist/esm/ui/Appearance/FullPage/FullPageContentArea.js +64 -60
  23. package/dist/esm/ui/ContextPanel/deprecated.js +277 -0
  24. package/dist/esm/ui/ContextPanel/index.js +24 -132
  25. package/dist/esm/version-wrapper.js +1 -1
  26. package/dist/types/create-editor/ReactEditorView.d.ts +3 -5
  27. package/dist/types/create-editor/create-universal-preset.d.ts +78 -0
  28. package/dist/types/create-editor/get-plugins.d.ts +0 -2
  29. package/dist/types/index.d.ts +6 -1
  30. package/dist/types/presets/default.d.ts +66 -0
  31. package/dist/types/presets/universal.d.ts +78 -0
  32. package/dist/types/presets/useUniversalPreset.d.ts +78 -0
  33. package/dist/types/ui/Appearance/FullPage/FullPageContentArea.d.ts +3 -1
  34. package/dist/types/ui/ContextPanel/deprecated.d.ts +44 -0
  35. package/dist/types/ui/ContextPanel/index.d.ts +5 -9
  36. package/dist/types-ts4.5/create-editor/ReactEditorView.d.ts +3 -5
  37. package/dist/types-ts4.5/create-editor/create-universal-preset.d.ts +78 -0
  38. package/dist/types-ts4.5/create-editor/get-plugins.d.ts +0 -2
  39. package/dist/types-ts4.5/index.d.ts +6 -1
  40. package/dist/types-ts4.5/presets/default.d.ts +66 -0
  41. package/dist/types-ts4.5/presets/universal.d.ts +78 -0
  42. package/dist/types-ts4.5/presets/useUniversalPreset.d.ts +78 -0
  43. package/dist/types-ts4.5/ui/Appearance/FullPage/FullPageContentArea.d.ts +5 -1
  44. package/dist/types-ts4.5/ui/ContextPanel/deprecated.d.ts +44 -0
  45. package/dist/types-ts4.5/ui/ContextPanel/index.d.ts +7 -9
  46. package/package.json +10 -19
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 195.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#132259](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/132259)
8
+ [`f5e633e11af26`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f5e633e11af26) -
9
+ [ux] Expose the context panel state from the context panel plugin. Simplify and consolidate the
10
+ context panel logic such that it always opens in the same manner. Previously there was a small
11
+ number of cases in which the context panel overlaps.
12
+ - [#133191](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/133191)
13
+ [`78a1927084934`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/78a1927084934) -
14
+ [ux] Remove icon migration feature gate and migrate new icons on primary toolbar
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
20
+ ## 195.6.2
21
+
22
+ ### Patch Changes
23
+
24
+ - [#131378](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/131378)
25
+ [`04848ee5982e0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/04848ee5982e0) -
26
+ Remove `reactContext` from `PMPluginFactoryParams` type. This was an unused property and so
27
+ shouldn't have any upgrade friction.
28
+ - [#131548](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/131548)
29
+ [`1b9034d028442`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1b9034d028442) -
30
+ [ux] Fix extension label button text size and update VR tests
31
+ - Updated dependencies
32
+
3
33
  ## 195.6.1
4
34
 
5
35
  ### Patch Changes
@@ -86,11 +86,11 @@ function handleEditorFocus(view) {
86
86
  var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Component) {
87
87
  (0, _inherits2.default)(ReactEditorView, _React$Component);
88
88
  var _super = _createSuper(ReactEditorView);
89
- function ReactEditorView(props, context) {
89
+ function ReactEditorView(props) {
90
90
  var _props$setEditorApi, _props$editorProps;
91
91
  var _this;
92
92
  (0, _classCallCheck2.default)(this, ReactEditorView);
93
- _this = _super.call(this, props, context);
93
+ _this = _super.call(this, props);
94
94
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "editorRef", /*#__PURE__*/_react.default.createRef());
95
95
  // ProseMirror is instantiated prior to the initial React render cycle,
96
96
  // so we allow transactions by default, to avoid discarding the initial one.
@@ -135,7 +135,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
135
135
  _this.featureFlags = (0, _featureFlagsFromProps.createFeatureFlagsFromProps)(_this.props.editorProps);
136
136
  _this.editorState = _this.createEditorState({
137
137
  props: _this.props,
138
- context: _this.context,
139
138
  doc: doc,
140
139
  resetting: true,
141
140
  selectionAtStart: !shouldScrollToBottom
@@ -201,9 +200,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
201
200
  eventDispatcher: _this.eventDispatcher,
202
201
  providerFactory: options.props.providerFactory,
203
202
  portalProviderAPI: _this.props.portalProviderAPI,
204
- reactContext: function reactContext() {
205
- return options.context;
206
- },
207
203
  dispatchAnalyticsEvent: _this.dispatchAnalyticsEvent,
208
204
  performanceTracking: _this.props.editorProps.performanceTracking,
209
205
  transactionTracker: _this.transactionTracker,
@@ -582,7 +578,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
582
578
  _this.eventDispatcher.on('resetEditorState', _this.resetEditorState);
583
579
  _this.editorState = _this.createEditorState({
584
580
  props: props,
585
- context: context,
586
581
  doc: props.editorProps.defaultValue,
587
582
  // ED-4759: Don't set selection at end for full-page editor - should be at start.
588
583
  selectionAtStart: (0, _isFullPage.isFullPage)(props.editorProps.appearance)
@@ -697,9 +692,6 @@ var ReactEditorView = exports.ReactEditorView = /*#__PURE__*/function (_React$Co
697
692
  eventDispatcher: this.eventDispatcher,
698
693
  providerFactory: props.providerFactory,
699
694
  portalProviderAPI: props.portalProviderAPI,
700
- reactContext: function reactContext() {
701
- return _this2.context;
702
- },
703
695
  dispatchAnalyticsEvent: this.dispatchAnalyticsEvent,
704
696
  performanceTracking: props.editorProps.performanceTracking,
705
697
  transactionTracker: this.transactionTracker,
@@ -131,7 +131,6 @@ function createPMPlugins(config) {
131
131
  providerFactory: config.providerFactory,
132
132
  errorReporter: config.errorReporter,
133
133
  portalProviderAPI: config.portalProviderAPI,
134
- reactContext: config.reactContext,
135
134
  dispatchAnalyticsEvent: config.dispatchAnalyticsEvent,
136
135
  featureFlags: config.featureFlags || {},
137
136
  getIntl: config.getIntl
package/dist/cjs/index.js CHANGED
@@ -37,7 +37,7 @@ Object.defineProperty(exports, "CollapsedEditor", {
37
37
  Object.defineProperty(exports, "ContextPanel", {
38
38
  enumerable: true,
39
39
  get: function get() {
40
- return _ContextPanel.default;
40
+ return _deprecated.default;
41
41
  }
42
42
  });
43
43
  Object.defineProperty(exports, "EVENT_TYPE", {
@@ -156,7 +156,7 @@ var _WithHelpTrigger = _interopRequireDefault(require("./ui/WithHelpTrigger"));
156
156
  var _CollapsedEditor = _interopRequireDefault(require("./ui/CollapsedEditor"));
157
157
  var _ToolbarHelp = _interopRequireDefault(require("./ui/ToolbarHelp"));
158
158
  var _ToolbarFeedback = _interopRequireDefault(require("./ui/ToolbarFeedback"));
159
- var _ContextPanel = _interopRequireDefault(require("./ui/ContextPanel"));
159
+ var _deprecated = _interopRequireDefault(require("./ui/ContextPanel/deprecated"));
160
160
  var _resource = require("@atlaskit/emoji/resource");
161
161
  var _resource2 = require("@atlaskit/mention/resource");
162
162
  var _teamResource = require("@atlaskit/mention/team-resource");
@@ -108,6 +108,7 @@ var FullPageEditor = exports.FullPageEditor = function FullPageEditor(props) {
108
108
  featureFlags: props.featureFlags,
109
109
  hideAvatarGroup: props.hideAvatarGroup
110
110
  }), (0, _react2.jsx)(_FullPageContentArea.FullPageContentArea, {
111
+ editorAPI: editorAPI,
111
112
  ref: scrollContentContainerRef,
112
113
  appearance: props.appearance,
113
114
  contentComponents: props.contentComponents,
@@ -46,67 +46,71 @@ var Content = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
46
46
  }, []);
47
47
  return (0, _react2.jsx)(_ui.WidthConsumer, null, function (_ref) {
48
48
  var width = _ref.width;
49
- return (0, _react2.jsx)(_ui.ContextPanelConsumer, null, function (_ref2) {
50
- var _contentAreaRef$curre;
51
- var positionedOverEditor = _ref2.positionedOverEditor;
52
- return (0, _react2.jsx)("div", {
53
- css: [
54
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
55
- _StyledComponents.contentArea,
56
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
57
- props.isEditorToolbarHidden && _StyledComponents.contentAreaHeightNoToolbar,
58
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
59
- positionedOverEditor && _StyledComponents.positionedOverEditorStyle],
60
- "data-testid": CONTENT_AREA_TEST_ID,
61
- ref: containerRef
62
- }, (0, _react2.jsx)(_StyledComponents.ScrollContainer
63
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
64
- , {
65
- className: "fabric-editor-popup-scroll-parent",
66
- featureFlags: props.featureFlags,
67
- ref: scrollContainerRef
68
- }, (0, _react2.jsx)(_Addon.ClickAreaBlock, {
69
- editorView: props.editorView,
70
- editorDisabled: props.disabled
71
- }, (0, _react2.jsx)("div", {
72
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
73
- css: (0, _StyledComponents.editorContentAreaStyle)({
74
- fullWidthMode: fullWidthMode,
75
- layoutMaxWidth: theme.layoutMaxWidth,
76
- containerWidth: width
77
- }),
78
- role: "region",
79
- "aria-label": props.intl.formatMessage(_messages.fullPageMessages.editableContentLabel),
80
- ref: contentAreaRef
81
- }, (0, _react2.jsx)("div", {
82
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
83
- css: (0, _StyledComponents.editorContentGutterStyle)()
49
+ return (
50
+ // Cleaned up with: platform_editor_context-panel_simplify_behaviour
51
+ (0, _react2.jsx)(_ui.ContextPanelConsumer, null, function (_ref2) {
52
+ var _contentAreaRef$curre;
53
+ var positionedOverEditor = _ref2.positionedOverEditor;
54
+ return (0, _react2.jsx)("div", {
55
+ css: [
56
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
57
+ _StyledComponents.contentArea,
58
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
59
+ props.isEditorToolbarHidden && _StyledComponents.contentAreaHeightNoToolbar,
60
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
61
+ positionedOverEditor && _StyledComponents.positionedOverEditorStyle],
62
+ "data-testid": CONTENT_AREA_TEST_ID,
63
+ ref: containerRef
64
+ }, (0, _react2.jsx)(_StyledComponents.ScrollContainer
84
65
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
85
- ,
86
- className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' '),
87
- ref: contentAreaRef
88
- }, !!props.customContentComponents && 'before' in props.customContentComponents ? props.customContentComponents.before : props.customContentComponents, (0, _react2.jsx)(_PluginSlot.default, {
89
- editorView: props.editorView,
90
- editorActions: props.editorActions,
91
- eventDispatcher: props.eventDispatcher,
92
- providerFactory: props.providerFactory,
93
- appearance: props.appearance,
94
- items: props.contentComponents,
95
- pluginHooks: props.pluginHooks,
96
- contentArea: (_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 ? _contentAreaRef$curre : undefined,
97
- popupsMountPoint: props.popupsMountPoint,
98
- popupsBoundariesElement: props.popupsBoundariesElement,
99
- popupsScrollableElement: props.popupsScrollableElement,
100
- disabled: !!props.disabled,
101
- containerElement: scrollContainerRef.current,
102
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
103
- wrapperElement: props.wrapperElement
104
- }), props.editorDOMElement, !!props.customContentComponents && 'after' in props.customContentComponents ? props.customContentComponents.after : null)))), (0, _react2.jsx)("div", {
105
- css: _StyledComponents.sidebarArea
106
- }, props.contextPanel || (0, _react2.jsx)(_ContextPanel.default, {
107
- visible: false
108
- })));
109
- });
66
+ , {
67
+ className: "fabric-editor-popup-scroll-parent",
68
+ featureFlags: props.featureFlags,
69
+ ref: scrollContainerRef
70
+ }, (0, _react2.jsx)(_Addon.ClickAreaBlock, {
71
+ editorView: props.editorView,
72
+ editorDisabled: props.disabled
73
+ }, (0, _react2.jsx)("div", {
74
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
75
+ css: (0, _StyledComponents.editorContentAreaStyle)({
76
+ fullWidthMode: fullWidthMode,
77
+ layoutMaxWidth: theme.layoutMaxWidth,
78
+ containerWidth: width
79
+ }),
80
+ role: "region",
81
+ "aria-label": props.intl.formatMessage(_messages.fullPageMessages.editableContentLabel),
82
+ ref: contentAreaRef
83
+ }, (0, _react2.jsx)("div", {
84
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
85
+ css: (0, _StyledComponents.editorContentGutterStyle)()
86
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
87
+ ,
88
+ className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' '),
89
+ ref: contentAreaRef
90
+ }, !!props.customContentComponents && 'before' in props.customContentComponents ? props.customContentComponents.before : props.customContentComponents, (0, _react2.jsx)(_PluginSlot.default, {
91
+ editorView: props.editorView,
92
+ editorActions: props.editorActions,
93
+ eventDispatcher: props.eventDispatcher,
94
+ providerFactory: props.providerFactory,
95
+ appearance: props.appearance,
96
+ items: props.contentComponents,
97
+ pluginHooks: props.pluginHooks,
98
+ contentArea: (_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 ? _contentAreaRef$curre : undefined,
99
+ popupsMountPoint: props.popupsMountPoint,
100
+ popupsBoundariesElement: props.popupsBoundariesElement,
101
+ popupsScrollableElement: props.popupsScrollableElement,
102
+ disabled: !!props.disabled,
103
+ containerElement: scrollContainerRef.current,
104
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
105
+ wrapperElement: props.wrapperElement
106
+ }), props.editorDOMElement, !!props.customContentComponents && 'after' in props.customContentComponents ? props.customContentComponents.after : null)))), (0, _react2.jsx)("div", {
107
+ css: _StyledComponents.sidebarArea
108
+ }, props.contextPanel || (0, _react2.jsx)(_ContextPanel.default, {
109
+ editorAPI: props.editorAPI,
110
+ visible: false
111
+ })));
112
+ })
113
+ );
110
114
  });
111
115
  });
112
116
  var FullPageContentArea = exports.FullPageContentArea = (0, _reactIntlNext.injectIntl)(Content, {
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.content = exports.SwappableContentArea = void 0;
9
+ exports.default = ContextPanel;
10
+ exports.shouldPanelBePositionedOverEditor = exports.panel = void 0;
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
18
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
19
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
+ var _react = _interopRequireWildcard(require("react"));
21
+ var _react2 = require("@emotion/react");
22
+ var _Transition = _interopRequireDefault(require("react-transition-group/Transition"));
23
+ var _ui = require("@atlaskit/editor-common/ui");
24
+ var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
25
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
26
+ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
27
+ var _colors = require("@atlaskit/theme/colors");
28
+ var _document = require("../../utils/document");
29
+ var _WithEditorActions = _interopRequireDefault(require("../WithEditorActions"));
30
+ var _excluded = ["actions"];
31
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
32
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
33
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
34
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
35
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
36
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
37
+ * @jsxRuntime classic
38
+ * @jsx jsx
39
+ */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
40
+ var ANIM_SPEED_MS = 500;
41
+ var EDITOR_WIDTH = _editorSharedStyles.akEditorDefaultLayoutWidth + _editorSharedStyles.akEditorBreakoutPadding;
42
+ var WIDE_EDITOR_WIDTH = _editorSharedStyles.akEditorWideLayoutWidth + _editorSharedStyles.akEditorBreakoutPadding;
43
+ var FULLWIDTH_MODE = 'full-width';
44
+ var WIDE_MODE = 'wide';
45
+ var absolutePanelStyles = (0, _react2.css)({
46
+ position: 'absolute',
47
+ right: 0,
48
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
49
+ height: "calc(100% - ".concat((0, _editorSharedStyles.FULL_PAGE_EDITOR_TOOLBAR_HEIGHT)(), ")")
50
+ });
51
+ var checkTableExistsInDoc = function checkTableExistsInDoc(editorView) {
52
+ var tableNodeSchema = editorView.state.schema.nodes.table;
53
+ var findResult = (0, _utils.findChildrenByType)(editorView.state.doc, tableNodeSchema);
54
+ return findResult.length > 0;
55
+ };
56
+ var shouldPanelBePositionedOverEditor = exports.shouldPanelBePositionedOverEditor = function shouldPanelBePositionedOverEditor(editorWidth, panelWidth, editorView) {
57
+ var lineLength = editorWidth.lineLength,
58
+ _editorWidth$containe = editorWidth.containerWidth,
59
+ containerWidth = _editorWidth$containe === void 0 ? 0 : _editorWidth$containe,
60
+ contentBreakoutModes = editorWidth.contentBreakoutModes;
61
+ var editorNotFullWidth = !(lineLength && lineLength > _editorSharedStyles.akEditorDefaultLayoutWidth);
62
+ var hasSpaceForPanel = !contentBreakoutModes.length && containerWidth >= panelWidth * 2 + EDITOR_WIDTH;
63
+ var hasSpaceForWideBreakoutsAndPanel = !contentBreakoutModes.includes(FULLWIDTH_MODE) && contentBreakoutModes.includes(WIDE_MODE) && containerWidth >= panelWidth * 2 + WIDE_EDITOR_WIDTH;
64
+ if (!editorView) {
65
+ return editorNotFullWidth && (hasSpaceForPanel || hasSpaceForWideBreakoutsAndPanel);
66
+ } else {
67
+ // when custom table width feature flag is on,
68
+ // there are scenarios when a table has attr layout default, but width is in full-width or very wide
69
+ // but in this case we still want the shouldPanelBePositionedOverEditor return false
70
+ // previous logic is returning false when table layout default
71
+ // but when custom table width feature flag is one, we want to return false whenever there is a table in the doc
72
+ var isTableInDoc = checkTableExistsInDoc(editorView);
73
+ return editorNotFullWidth && (hasSpaceForPanel || hasSpaceForWideBreakoutsAndPanel) && !isTableInDoc;
74
+ }
75
+ };
76
+ var panelHidden = (0, _react2.css)({
77
+ width: 0
78
+ });
79
+
80
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
81
+ var panel = exports.panel = (0, _react2.css)({
82
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
83
+ width: "".concat(_editorSharedStyles.akEditorContextPanelWidth, "px"),
84
+ height: '100%',
85
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
86
+ transition: "width ".concat(ANIM_SPEED_MS, "ms ").concat(_editorSharedStyles.akEditorSwoopCubicBezier),
87
+ overflow: 'hidden',
88
+ boxShadow: "inset 2px 0 0 0 ".concat("var(--ds-border, ".concat(_colors.N30, ")"))
89
+ });
90
+
91
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
92
+ var content = exports.content = (0, _react2.css)({
93
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
94
+ transition: "width 600ms ".concat(_editorSharedStyles.akEditorSwoopCubicBezier),
95
+ boxSizing: 'border-box',
96
+ padding: "var(--ds-space-200, 16px)".concat(" ", "var(--ds-space-200, 16px)", " 0px"),
97
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
98
+ width: "".concat(_editorSharedStyles.akEditorContextPanelWidth, "px"),
99
+ height: '100%',
100
+ overflowY: 'auto'
101
+ });
102
+ var SwappableContentArea = exports.SwappableContentArea = /*#__PURE__*/function (_React$PureComponent) {
103
+ (0, _inherits2.default)(SwappableContentArea, _React$PureComponent);
104
+ var _super = _createSuper(SwappableContentArea);
105
+ function SwappableContentArea() {
106
+ var _this;
107
+ (0, _classCallCheck2.default)(this, SwappableContentArea);
108
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
109
+ args[_key] = arguments[_key];
110
+ }
111
+ _this = _super.call.apply(_super, [this].concat(args));
112
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
113
+ mounted: false,
114
+ currentPluginContent: undefined
115
+ });
116
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focusEditor", function () {
117
+ var editorView = _this.props.editorView;
118
+ if (editorView && !editorView.hasFocus()) {
119
+ var _editorView$focus;
120
+ (_editorView$focus = editorView.focus) === null || _editorView$focus === void 0 || _editorView$focus.call(editorView);
121
+ }
122
+ });
123
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "showPluginContent", function () {
124
+ var pluginContent = _this.props.pluginContent;
125
+ var currentPluginContent = _this.state.currentPluginContent;
126
+ if (!currentPluginContent) {
127
+ return;
128
+ }
129
+ return (0, _react2.jsx)(_Transition.default, {
130
+ timeout: _this.state.mounted ? ANIM_SPEED_MS : 0,
131
+ in: !!pluginContent,
132
+ mountOnEnter: true,
133
+ unmountOnExit: true,
134
+ onExited: function onExited() {
135
+ return _this.unsetPluginContent();
136
+ }
137
+ }, currentPluginContent);
138
+ });
139
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "showProvidedContent", function (isVisible) {
140
+ var children = _this.props.children;
141
+ if (!children) {
142
+ return;
143
+ }
144
+ return (0, _react2.jsx)(_Transition.default, {
145
+ timeout: _this.state.mounted ? ANIM_SPEED_MS : 0,
146
+ in: isVisible,
147
+ mountOnEnter: true,
148
+ unmountOnExit: true,
149
+ onExiting: _this.focusEditor
150
+ }, children);
151
+ });
152
+ return _this;
153
+ }
154
+ (0, _createClass2.default)(SwappableContentArea, [{
155
+ key: "unsetPluginContent",
156
+ value: function unsetPluginContent() {
157
+ this.setState({
158
+ currentPluginContent: undefined
159
+ });
160
+ }
161
+ }, {
162
+ key: "componentDidMount",
163
+ value: function componentDidMount() {
164
+ // use this to trigger an animation
165
+ this.setState({
166
+ mounted: true
167
+ });
168
+ }
169
+ }, {
170
+ key: "render",
171
+ value: function render() {
172
+ var _this2 = this;
173
+ var _this$props = this.props,
174
+ editorWidth = _this$props.editorWidth,
175
+ editorView = _this$props.editorView;
176
+ var width = _editorSharedStyles.akEditorContextPanelWidth;
177
+ var userVisible = !!this.props.visible;
178
+ var visible = userVisible || !!this.state.currentPluginContent;
179
+ return (0, _react2.jsx)(_ui.ContextPanelConsumer, null, function (_ref) {
180
+ var broadcastWidth = _ref.broadcastWidth,
181
+ broadcastPosition = _ref.broadcastPosition,
182
+ positionedOverEditor = _ref.positionedOverEditor;
183
+ var contextPanelWidth = visible ? width : 0;
184
+ var newPosition = editorWidth ? shouldPanelBePositionedOverEditor(editorWidth, width, editorView) : false;
185
+ broadcastWidth(contextPanelWidth);
186
+ (newPosition && visible) !== positionedOverEditor && broadcastPosition(newPosition && visible);
187
+ return (0, _react2.jsx)("div", {
188
+ css: [panel, !visible && panelHidden,
189
+ /**
190
+ * Only use absolute position for panel when screen size is wide enough
191
+ * to accommodate breakout content and editor is not in wide mode.
192
+ */
193
+ newPosition && absolutePanelStyles],
194
+ "data-testid": "context-panel-panel",
195
+ "aria-labelledby": "context-panel-title",
196
+ role: "dialog"
197
+ }, (0, _react2.jsx)("div", {
198
+ "data-testid": "context-panel-content",
199
+ css: [content, !visible && panelHidden]
200
+ }, _this2.showPluginContent() || _this2.showProvidedContent(userVisible)));
201
+ });
202
+ }
203
+ }], [{
204
+ key: "getDerivedStateFromProps",
205
+ value: function getDerivedStateFromProps(props, state) {
206
+ if (props.pluginContent !== state.currentPluginContent) {
207
+ return _objectSpread(_objectSpread({}, state), {}, {
208
+ currentPluginContent: props.pluginContent
209
+ });
210
+ }
211
+ return null;
212
+ }
213
+ }]);
214
+ return SwappableContentArea;
215
+ }(_react.default.PureComponent); // TODO: ED-17837 We have this workaround because we do
216
+ // not have access to the pluginInjectionApi at this location.
217
+ // It might be that we need to inject the pluginInjectionApi
218
+ // via context so that we can use it in this file (similar to
219
+ // WithEditorActions). To be investigated further.
220
+ // @ts-ignore
221
+ var widthPluginKey = {
222
+ key: 'widthPlugin$',
223
+ getState: function getState(state) {
224
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
225
+ return state['widthPlugin$'];
226
+ }
227
+ };
228
+
229
+ // @ts-ignore
230
+ var contextPanelPluginKey = {
231
+ key: 'contextPanelPluginKey$',
232
+ getState: function getState(state) {
233
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
234
+ return state['contextPanelPluginKey$'];
235
+ }
236
+ };
237
+ function ContextPanelWithActions(_ref2) {
238
+ var actions = _ref2.actions,
239
+ props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
240
+ var eventDispatcher = actions._privateGetEventDispatcher();
241
+ var editorView = actions._privateGetEditorView();
242
+ var _useContext = (0, _react.useContext)(_ui.WidthContext),
243
+ width = _useContext.width;
244
+ if (!eventDispatcher) {
245
+ return (0, _react2.jsx)(SwappableContentArea, (0, _extends2.default)({
246
+ editorView: editorView
247
+ }, props));
248
+ }
249
+ return (
250
+ // @ts-ignore - 'WithPluginState' cannot be used as a JSX component.
251
+ // This error was introduced after upgrading to TypeScript 5
252
+ (0, _react2.jsx)(_withPluginState.WithPluginState, {
253
+ eventDispatcher: eventDispatcher,
254
+ plugins: {
255
+ contextPanel: contextPanelPluginKey,
256
+ widthState: widthPluginKey
257
+ },
258
+ render: function render(_ref3) {
259
+ var contextPanel = _ref3.contextPanel,
260
+ widthState = _ref3.widthState;
261
+ var firstContent = contextPanel && contextPanel.contents.find(Boolean);
262
+ var editorWidth = _objectSpread(_objectSpread({}, widthState), {}, {
263
+ containerWidth: width,
264
+ contentBreakoutModes: editorView ? (0, _document.getChildBreakoutModes)(editorView.state.doc, editorView.state.schema) : []
265
+ });
266
+ return (0, _react2.jsx)(SwappableContentArea, (0, _extends2.default)({}, props, {
267
+ editorView: editorView,
268
+ pluginContent: firstContent,
269
+ editorWidth: editorWidth
270
+ }));
271
+ }
272
+ })
273
+ );
274
+ }
275
+ function ContextPanel(props) {
276
+ return (0, _react2.jsx)(_WithEditorActions.default, {
277
+ render: function render(actions) {
278
+ return (0, _react2.jsx)(ContextPanelWithActions, (0, _extends2.default)({
279
+ actions: actions
280
+ }, props));
281
+ }
282
+ });
283
+ }