@atlaskit/editor-core 185.8.0 → 185.8.2

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,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 185.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5f6168797f7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f6168797f7) - Improve run-time performance of editor on scroll/resizing by using newer APIs for toolbar keyline.
8
+
3
9
  ## 185.8.0
4
10
 
5
11
  ### Minor Changes
@@ -1,144 +1,102 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FullPageEditor = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
12
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
13
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _react = _interopRequireDefault(require("react"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = _interopRequireWildcard(require("react"));
16
11
  var _react2 = require("@emotion/react");
17
- var _rafSchd = _interopRequireDefault(require("raf-schd"));
18
- var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
19
12
  var _StyledComponents = require("./StyledComponents");
20
13
  var _ui = require("@atlaskit/editor-common/ui");
21
14
  var _FullPageContentArea = require("./FullPageContentArea");
22
15
  var _FullPageToolbar = require("./FullPageToolbar");
23
- 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); }; }
24
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
25
- var FullPageEditor = /*#__PURE__*/function (_React$Component) {
26
- (0, _inherits2.default)(FullPageEditor, _React$Component);
27
- var _super = _createSuper(FullPageEditor);
28
- function FullPageEditor(props) {
29
- var _this;
30
- (0, _classCallCheck2.default)(this, FullPageEditor);
31
- _this = _super.call(this, props);
32
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
33
- showKeyline: false
34
- });
35
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "scrollContainer", null);
36
- // Wrapper container for toolbar and content area
37
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "wrapperElementRef", /*#__PURE__*/_react.default.createRef());
38
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "contentAreaRef", function (contentArea) {
39
- _this.contentArea = contentArea;
40
- });
41
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "scrollContainerRef", function (ref) {
42
- var previousScrollContainer = _this.scrollContainer;
16
+ var _utils = require("@atlaskit/editor-common/utils");
17
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
+ /** @jsx jsx */
43
20
 
44
- // remove existing handler
45
- if (previousScrollContainer) {
46
- previousScrollContainer.removeEventListener('scroll', _this.updateToolbarKeyline);
47
- }
48
- _this.scrollContainer = ref ? ref : null;
49
- if (_this.scrollContainer) {
50
- _this.scrollContainer.addEventListener('scroll', _this.updateToolbarKeyline, false);
51
- _this.updateToolbarKeyline();
52
- }
53
- });
54
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateToolbarKeyline", (0, _rafSchd.default)(function () {
55
- if (!_this.scrollContainer) {
56
- return false;
57
- }
58
- var scrollTop = _this.scrollContainer.scrollTop;
59
- var showKeyline = scrollTop > _editorSharedStyles.akEditorToolbarKeylineHeight;
60
- if (showKeyline !== _this.state.showKeyline) {
61
- _this.setState({
62
- showKeyline: showKeyline
63
- });
64
- }
65
- return false;
66
- }));
67
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResize", function () {
68
- _this.updateToolbarKeyline();
69
- });
70
- _this.featureFlags = props.featureFlags;
71
- if (props.innerRef) {
72
- _this.wrapperElementRef = props.innerRef;
21
+ var useShowKeyline = function useShowKeyline(contentAreaRef) {
22
+ var _useState = (0, _react.useState)(false),
23
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
24
+ showKeyline = _useState2[0],
25
+ setShowKeyline = _useState2[1];
26
+ (0, _react.useEffect)(function () {
27
+ var _contentAreaRef$curre;
28
+ if (!((_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 && _contentAreaRef$curre.contentArea)) {
29
+ return;
73
30
  }
74
- return _this;
75
- }
76
- (0, _createClass2.default)(FullPageEditor, [{
77
- key: "componentDidMount",
78
- value: function componentDidMount() {
79
- window.addEventListener('resize', this.handleResize, false);
80
- }
81
- }, {
82
- key: "componentWillUnmount",
83
- value: function componentWillUnmount() {
84
- window.removeEventListener('resize', this.handleResize);
85
- this.updateToolbarKeyline.cancel();
86
- }
87
- }, {
88
- key: "render",
89
- value: function render() {
90
- var props = this.props;
91
- var showKeyline = this.state.showKeyline;
92
- return (0, _react2.jsx)(_ui.ContextPanelWidthProvider, null, (0, _react2.jsx)("div", {
93
- css: _StyledComponents.fullPageEditorWrapper,
94
- className: "akEditor",
95
- ref: this.wrapperElementRef
96
- }, (0, _react2.jsx)(_FullPageToolbar.FullPageToolbar, {
97
- appearance: props.appearance,
98
- beforeIcon: props.primaryToolbarIconBefore,
99
- collabEdit: props.collabEdit,
100
- containerElement: this.scrollContainer,
101
- customPrimaryToolbarComponents: props.customPrimaryToolbarComponents,
102
- disabled: !!props.disabled,
103
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
104
- editorActions: props.editorActions,
105
- editorDOMElement: props.editorDOMElement,
106
- editorView: props.editorView,
107
- eventDispatcher: props.eventDispatcher,
108
- hasMinWidth: props.enableToolbarMinWidth,
109
- popupsBoundariesElement: props.popupsBoundariesElement,
110
- popupsMountPoint: props.popupsMountPoint,
111
- popupsScrollableElement: props.popupsScrollableElement,
112
- primaryToolbarComponents: props.primaryToolbarComponents,
113
- providerFactory: props.providerFactory,
114
- showKeyline: showKeyline,
115
- featureFlags: this.featureFlags
116
- }), (0, _react2.jsx)(_FullPageContentArea.FullPageContentArea, {
117
- appearance: props.appearance,
118
- contentArea: this.contentArea,
119
- contentAreaRef: this.contentAreaRef,
120
- contentComponents: props.contentComponents,
121
- contextPanel: props.contextPanel,
122
- customContentComponents: props.customContentComponents,
123
- disabled: props.disabled,
124
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
125
- editorActions: props.editorActions,
126
- editorDOMElement: props.editorDOMElement,
127
- editorView: props.editorView,
128
- eventDispatcher: props.eventDispatcher,
129
- popupsBoundariesElement: props.popupsBoundariesElement,
130
- popupsMountPoint: props.popupsMountPoint,
131
- popupsScrollableElement: props.popupsScrollableElement,
132
- providerFactory: props.providerFactory,
133
- scrollContainer: this.scrollContainer,
134
- scrollContainerRef: this.scrollContainerRef,
135
- wrapperElement: this.wrapperElementRef.current,
136
- pluginHooks: props.pluginHooks,
137
- featureFlags: this.featureFlags
138
- })));
139
- }
140
- }]);
141
- return FullPageEditor;
142
- }(_react.default.Component);
143
- exports.FullPageEditor = FullPageEditor;
144
- (0, _defineProperty2.default)(FullPageEditor, "displayName", 'FullPageEditor');
31
+ var intersection = new IntersectionObserver(function (_ref) {
32
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 1),
33
+ entry = _ref2[0];
34
+ setShowKeyline(!entry.isIntersecting && entry.boundingClientRect.top < entry.intersectionRect.top);
35
+ }, {
36
+ root: undefined,
37
+ // Safari seems to miss events (on fast scroll) sometimes due
38
+ // to differences in IntersectionObserver behaviour between browsers.
39
+ // By lowering the threshold a little it gives Safari more
40
+ // time to catch these events.
41
+ threshold: _utils.browser.safari ? 0.98 : 1
42
+ });
43
+ intersection.observe(contentAreaRef.current.contentArea);
44
+ return function () {
45
+ intersection.disconnect();
46
+ };
47
+ }, [contentAreaRef]);
48
+ return showKeyline;
49
+ };
50
+ var FullPageEditor = function FullPageEditor(props) {
51
+ var _scrollContentContain, _scrollContentContain2, _wrapperElementRef$cu;
52
+ var wrapperElementRef = (0, _react.useMemo)(function () {
53
+ return props.innerRef;
54
+ }, [props.innerRef]);
55
+ var scrollContentContainerRef = (0, _react.useRef)(null);
56
+ var showKeyline = useShowKeyline(scrollContentContainerRef);
57
+ return (0, _react2.jsx)(_ui.ContextPanelWidthProvider, null, (0, _react2.jsx)("div", {
58
+ css: _StyledComponents.fullPageEditorWrapper,
59
+ className: "akEditor",
60
+ ref: wrapperElementRef
61
+ }, (0, _react2.jsx)(_FullPageToolbar.FullPageToolbar, {
62
+ appearance: props.appearance,
63
+ beforeIcon: props.primaryToolbarIconBefore,
64
+ collabEdit: props.collabEdit,
65
+ containerElement: (_scrollContentContain = (_scrollContentContain2 = scrollContentContainerRef.current) === null || _scrollContentContain2 === void 0 ? void 0 : _scrollContentContain2.scrollContainer) !== null && _scrollContentContain !== void 0 ? _scrollContentContain : null,
66
+ customPrimaryToolbarComponents: props.customPrimaryToolbarComponents,
67
+ disabled: !!props.disabled,
68
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
69
+ editorActions: props.editorActions,
70
+ editorDOMElement: props.editorDOMElement,
71
+ editorView: props.editorView,
72
+ eventDispatcher: props.eventDispatcher,
73
+ hasMinWidth: props.enableToolbarMinWidth,
74
+ popupsBoundariesElement: props.popupsBoundariesElement,
75
+ popupsMountPoint: props.popupsMountPoint,
76
+ popupsScrollableElement: props.popupsScrollableElement,
77
+ primaryToolbarComponents: props.primaryToolbarComponents,
78
+ providerFactory: props.providerFactory,
79
+ showKeyline: showKeyline,
80
+ featureFlags: props.featureFlags
81
+ }), (0, _react2.jsx)(_FullPageContentArea.FullPageContentArea, {
82
+ ref: scrollContentContainerRef,
83
+ appearance: props.appearance,
84
+ contentComponents: props.contentComponents,
85
+ contextPanel: props.contextPanel,
86
+ customContentComponents: props.customContentComponents,
87
+ disabled: props.disabled,
88
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
89
+ editorActions: props.editorActions,
90
+ editorDOMElement: props.editorDOMElement,
91
+ editorView: props.editorView,
92
+ eventDispatcher: props.eventDispatcher,
93
+ popupsBoundariesElement: props.popupsBoundariesElement,
94
+ popupsMountPoint: props.popupsMountPoint,
95
+ popupsScrollableElement: props.popupsScrollableElement,
96
+ providerFactory: props.providerFactory,
97
+ wrapperElement: (_wrapperElementRef$cu = wrapperElementRef === null || wrapperElementRef === void 0 ? void 0 : wrapperElementRef.current) !== null && _wrapperElementRef$cu !== void 0 ? _wrapperElementRef$cu : null,
98
+ pluginHooks: props.pluginHooks,
99
+ featureFlags: props.featureFlags
100
+ })));
101
+ };
102
+ exports.FullPageEditor = FullPageEditor;
@@ -1,37 +1,53 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.FullPageContentArea = exports.CONTENT_AREA_TEST_ID = void 0;
8
9
  var _react = require("@emotion/react");
9
10
  var _ui = require("@atlaskit/editor-common/ui");
10
- var _react2 = _interopRequireDefault(require("react"));
11
+ var _react2 = _interopRequireWildcard(require("react"));
11
12
  var _reactIntlNext = require("react-intl-next");
12
13
  var _Addon = require("../../Addon");
13
14
  var _ContextPanel = _interopRequireDefault(require("../../ContextPanel"));
14
15
  var _PluginSlot = _interopRequireDefault(require("../../PluginSlot"));
15
16
  var _StyledComponents = require("./StyledComponents");
16
17
  var _messages = _interopRequireDefault(require("./messages"));
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
20
  /** @jsx jsx */
18
21
 
19
22
  var CONTENT_AREA_TEST_ID = 'ak-editor-fp-content-area';
20
23
  exports.CONTENT_AREA_TEST_ID = CONTENT_AREA_TEST_ID;
21
- var Content = /*#__PURE__*/_react2.default.memo(function (props) {
24
+ var Content = /*#__PURE__*/_react2.default.forwardRef(function (props, ref) {
22
25
  var theme = (0, _react.useTheme)();
23
26
  var fullWidthMode = props.appearance === 'full-width';
27
+ var scrollContainerRef = (0, _react2.useRef)(null);
28
+ var contentAreaRef = (0, _react2.useRef)(null);
29
+ (0, _react2.useImperativeHandle)(ref, function () {
30
+ return {
31
+ get scrollContainer() {
32
+ return scrollContainerRef.current;
33
+ },
34
+ get contentArea() {
35
+ return contentAreaRef.current;
36
+ }
37
+ };
38
+ }, []);
24
39
  return (0, _react.jsx)(_ui.WidthConsumer, null, function (_ref) {
25
40
  var width = _ref.width;
26
41
  return (0, _react.jsx)(_ui.ContextPanelConsumer, null, function (_ref2) {
42
+ var _contentAreaRef$curre;
27
43
  var positionedOverEditor = _ref2.positionedOverEditor;
28
44
  return (0, _react.jsx)("div", {
29
45
  css: [_StyledComponents.contentArea, positionedOverEditor && _StyledComponents.positionedOverEditorStyle],
30
46
  "data-testid": CONTENT_AREA_TEST_ID
31
47
  }, (0, _react.jsx)(_StyledComponents.ScrollContainer, {
32
- ref: props.scrollContainerRef,
33
48
  className: "fabric-editor-popup-scroll-parent",
34
- featureFlags: props.featureFlags
49
+ featureFlags: props.featureFlags,
50
+ ref: scrollContainerRef
35
51
  }, (0, _react.jsx)(_Addon.ClickAreaBlock, {
36
52
  editorView: props.editorView,
37
53
  editorDisabled: props.disabled
@@ -43,10 +59,11 @@ var Content = /*#__PURE__*/_react2.default.memo(function (props) {
43
59
  }),
44
60
  role: "region",
45
61
  "aria-label": props.intl.formatMessage(_messages.default.editableContentLabel),
46
- ref: props.contentAreaRef
62
+ ref: contentAreaRef
47
63
  }, (0, _react.jsx)("div", {
48
64
  css: _StyledComponents.editorContentGutterStyle,
49
- className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' ')
65
+ className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' '),
66
+ ref: contentAreaRef
50
67
  }, props.customContentComponents, (0, _react.jsx)(_PluginSlot.default, {
51
68
  editorView: props.editorView,
52
69
  editorActions: props.editorActions,
@@ -55,12 +72,12 @@ var Content = /*#__PURE__*/_react2.default.memo(function (props) {
55
72
  appearance: props.appearance,
56
73
  items: props.contentComponents,
57
74
  pluginHooks: props.pluginHooks,
58
- contentArea: props.contentArea,
75
+ contentArea: (_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 ? _contentAreaRef$curre : undefined,
59
76
  popupsMountPoint: props.popupsMountPoint,
60
77
  popupsBoundariesElement: props.popupsBoundariesElement,
61
78
  popupsScrollableElement: props.popupsScrollableElement,
62
79
  disabled: !!props.disabled,
63
- containerElement: props.scrollContainer,
80
+ containerElement: scrollContainerRef.current,
64
81
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
65
82
  wrapperElement: props.wrapperElement
66
83
  }), props.editorDOMElement)))), (0, _react.jsx)("div", {
@@ -71,5 +88,7 @@ var Content = /*#__PURE__*/_react2.default.memo(function (props) {
71
88
  });
72
89
  });
73
90
  });
74
- var FullPageContentArea = (0, _reactIntlNext.injectIntl)(Content);
91
+ var FullPageContentArea = (0, _reactIntlNext.injectIntl)(Content, {
92
+ forwardRef: true
93
+ });
75
94
  exports.FullPageContentArea = FullPageContentArea;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "185.8.0";
9
+ var version = "185.8.2";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.8.0",
3
+ "version": "185.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,122 +1,82 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  /** @jsx jsx */
3
- import React from 'react';
2
+ import React, { useEffect, useState, useRef, useMemo } from 'react';
4
3
  import { jsx } from '@emotion/react';
5
- import rafSchedule from 'raf-schd';
6
- import { akEditorToolbarKeylineHeight } from '@atlaskit/editor-shared-styles';
7
4
  import { fullPageEditorWrapper } from './StyledComponents';
8
5
  import { ContextPanelWidthProvider } from '@atlaskit/editor-common/ui';
9
6
  import { FullPageContentArea } from './FullPageContentArea';
10
7
  import { FullPageToolbar } from './FullPageToolbar';
11
- export class FullPageEditor extends React.Component {
12
- constructor(props) {
13
- super(props);
14
- _defineProperty(this, "state", {
15
- showKeyline: false
16
- });
17
- _defineProperty(this, "scrollContainer", null);
18
- // Wrapper container for toolbar and content area
19
- _defineProperty(this, "wrapperElementRef", /*#__PURE__*/React.createRef());
20
- _defineProperty(this, "contentAreaRef", contentArea => {
21
- this.contentArea = contentArea;
22
- });
23
- _defineProperty(this, "scrollContainerRef", ref => {
24
- const previousScrollContainer = this.scrollContainer;
25
-
26
- // remove existing handler
27
- if (previousScrollContainer) {
28
- previousScrollContainer.removeEventListener('scroll', this.updateToolbarKeyline);
29
- }
30
- this.scrollContainer = ref ? ref : null;
31
- if (this.scrollContainer) {
32
- this.scrollContainer.addEventListener('scroll', this.updateToolbarKeyline, false);
33
- this.updateToolbarKeyline();
34
- }
35
- });
36
- _defineProperty(this, "updateToolbarKeyline", rafSchedule(() => {
37
- if (!this.scrollContainer) {
38
- return false;
39
- }
40
- const {
41
- scrollTop
42
- } = this.scrollContainer;
43
- const showKeyline = scrollTop > akEditorToolbarKeylineHeight;
44
- if (showKeyline !== this.state.showKeyline) {
45
- this.setState({
46
- showKeyline
47
- });
48
- }
49
- return false;
50
- }));
51
- _defineProperty(this, "handleResize", () => {
52
- this.updateToolbarKeyline();
53
- });
54
- this.featureFlags = props.featureFlags;
55
- if (props.innerRef) {
56
- this.wrapperElementRef = props.innerRef;
8
+ import { browser } from '@atlaskit/editor-common/utils';
9
+ const useShowKeyline = contentAreaRef => {
10
+ const [showKeyline, setShowKeyline] = useState(false);
11
+ useEffect(() => {
12
+ var _contentAreaRef$curre;
13
+ if (!((_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 && _contentAreaRef$curre.contentArea)) {
14
+ return;
57
15
  }
58
- }
59
- componentDidMount() {
60
- window.addEventListener('resize', this.handleResize, false);
61
- }
62
- componentWillUnmount() {
63
- window.removeEventListener('resize', this.handleResize);
64
- this.updateToolbarKeyline.cancel();
65
- }
66
- render() {
67
- const {
68
- props
69
- } = this;
70
- const {
71
- showKeyline
72
- } = this.state;
73
- return jsx(ContextPanelWidthProvider, null, jsx("div", {
74
- css: fullPageEditorWrapper,
75
- className: "akEditor",
76
- ref: this.wrapperElementRef
77
- }, jsx(FullPageToolbar, {
78
- appearance: props.appearance,
79
- beforeIcon: props.primaryToolbarIconBefore,
80
- collabEdit: props.collabEdit,
81
- containerElement: this.scrollContainer,
82
- customPrimaryToolbarComponents: props.customPrimaryToolbarComponents,
83
- disabled: !!props.disabled,
84
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
85
- editorActions: props.editorActions,
86
- editorDOMElement: props.editorDOMElement,
87
- editorView: props.editorView,
88
- eventDispatcher: props.eventDispatcher,
89
- hasMinWidth: props.enableToolbarMinWidth,
90
- popupsBoundariesElement: props.popupsBoundariesElement,
91
- popupsMountPoint: props.popupsMountPoint,
92
- popupsScrollableElement: props.popupsScrollableElement,
93
- primaryToolbarComponents: props.primaryToolbarComponents,
94
- providerFactory: props.providerFactory,
95
- showKeyline: showKeyline,
96
- featureFlags: this.featureFlags
97
- }), jsx(FullPageContentArea, {
98
- appearance: props.appearance,
99
- contentArea: this.contentArea,
100
- contentAreaRef: this.contentAreaRef,
101
- contentComponents: props.contentComponents,
102
- contextPanel: props.contextPanel,
103
- customContentComponents: props.customContentComponents,
104
- disabled: props.disabled,
105
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
106
- editorActions: props.editorActions,
107
- editorDOMElement: props.editorDOMElement,
108
- editorView: props.editorView,
109
- eventDispatcher: props.eventDispatcher,
110
- popupsBoundariesElement: props.popupsBoundariesElement,
111
- popupsMountPoint: props.popupsMountPoint,
112
- popupsScrollableElement: props.popupsScrollableElement,
113
- providerFactory: props.providerFactory,
114
- scrollContainer: this.scrollContainer,
115
- scrollContainerRef: this.scrollContainerRef,
116
- wrapperElement: this.wrapperElementRef.current,
117
- pluginHooks: props.pluginHooks,
118
- featureFlags: this.featureFlags
119
- })));
120
- }
121
- }
122
- _defineProperty(FullPageEditor, "displayName", 'FullPageEditor');
16
+ const intersection = new IntersectionObserver(([entry]) => {
17
+ setShowKeyline(!entry.isIntersecting && entry.boundingClientRect.top < entry.intersectionRect.top);
18
+ }, {
19
+ root: undefined,
20
+ // Safari seems to miss events (on fast scroll) sometimes due
21
+ // to differences in IntersectionObserver behaviour between browsers.
22
+ // By lowering the threshold a little it gives Safari more
23
+ // time to catch these events.
24
+ threshold: browser.safari ? 0.98 : 1
25
+ });
26
+ intersection.observe(contentAreaRef.current.contentArea);
27
+ return () => {
28
+ intersection.disconnect();
29
+ };
30
+ }, [contentAreaRef]);
31
+ return showKeyline;
32
+ };
33
+ export const FullPageEditor = props => {
34
+ var _scrollContentContain, _scrollContentContain2, _wrapperElementRef$cu;
35
+ const wrapperElementRef = useMemo(() => props.innerRef, [props.innerRef]);
36
+ const scrollContentContainerRef = useRef(null);
37
+ const showKeyline = useShowKeyline(scrollContentContainerRef);
38
+ return jsx(ContextPanelWidthProvider, null, jsx("div", {
39
+ css: fullPageEditorWrapper,
40
+ className: "akEditor",
41
+ ref: wrapperElementRef
42
+ }, jsx(FullPageToolbar, {
43
+ appearance: props.appearance,
44
+ beforeIcon: props.primaryToolbarIconBefore,
45
+ collabEdit: props.collabEdit,
46
+ containerElement: (_scrollContentContain = (_scrollContentContain2 = scrollContentContainerRef.current) === null || _scrollContentContain2 === void 0 ? void 0 : _scrollContentContain2.scrollContainer) !== null && _scrollContentContain !== void 0 ? _scrollContentContain : null,
47
+ customPrimaryToolbarComponents: props.customPrimaryToolbarComponents,
48
+ disabled: !!props.disabled,
49
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
50
+ editorActions: props.editorActions,
51
+ editorDOMElement: props.editorDOMElement,
52
+ editorView: props.editorView,
53
+ eventDispatcher: props.eventDispatcher,
54
+ hasMinWidth: props.enableToolbarMinWidth,
55
+ popupsBoundariesElement: props.popupsBoundariesElement,
56
+ popupsMountPoint: props.popupsMountPoint,
57
+ popupsScrollableElement: props.popupsScrollableElement,
58
+ primaryToolbarComponents: props.primaryToolbarComponents,
59
+ providerFactory: props.providerFactory,
60
+ showKeyline: showKeyline,
61
+ featureFlags: props.featureFlags
62
+ }), jsx(FullPageContentArea, {
63
+ ref: scrollContentContainerRef,
64
+ appearance: props.appearance,
65
+ contentComponents: props.contentComponents,
66
+ contextPanel: props.contextPanel,
67
+ customContentComponents: props.customContentComponents,
68
+ disabled: props.disabled,
69
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
70
+ editorActions: props.editorActions,
71
+ editorDOMElement: props.editorDOMElement,
72
+ editorView: props.editorView,
73
+ eventDispatcher: props.eventDispatcher,
74
+ popupsBoundariesElement: props.popupsBoundariesElement,
75
+ popupsMountPoint: props.popupsMountPoint,
76
+ popupsScrollableElement: props.popupsScrollableElement,
77
+ providerFactory: props.providerFactory,
78
+ wrapperElement: (_wrapperElementRef$cu = wrapperElementRef === null || wrapperElementRef === void 0 ? void 0 : wrapperElementRef.current) !== null && _wrapperElementRef$cu !== void 0 ? _wrapperElementRef$cu : null,
79
+ pluginHooks: props.pluginHooks,
80
+ featureFlags: props.featureFlags
81
+ })));
82
+ };
@@ -2,7 +2,7 @@
2
2
  import { jsx, useTheme } from '@emotion/react';
3
3
  import { WidthConsumer } from '@atlaskit/editor-common/ui';
4
4
  import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
5
- import React from 'react';
5
+ import React, { useImperativeHandle, useRef } from 'react';
6
6
  import { injectIntl } from 'react-intl-next';
7
7
  import { ClickAreaBlock } from '../../Addon';
8
8
  import ContextPanel from '../../ContextPanel';
@@ -10,55 +10,71 @@ import PluginSlot from '../../PluginSlot';
10
10
  import { contentArea, editorContentAreaStyle, sidebarArea, ScrollContainer, editorContentGutterStyle, positionedOverEditorStyle } from './StyledComponents';
11
11
  import messages from './messages';
12
12
  export const CONTENT_AREA_TEST_ID = 'ak-editor-fp-content-area';
13
- const Content = /*#__PURE__*/React.memo(props => {
13
+ const Content = /*#__PURE__*/React.forwardRef((props, ref) => {
14
14
  const theme = useTheme();
15
15
  const fullWidthMode = props.appearance === 'full-width';
16
+ const scrollContainerRef = useRef(null);
17
+ const contentAreaRef = useRef(null);
18
+ useImperativeHandle(ref, () => ({
19
+ get scrollContainer() {
20
+ return scrollContainerRef.current;
21
+ },
22
+ get contentArea() {
23
+ return contentAreaRef.current;
24
+ }
25
+ }), []);
16
26
  return jsx(WidthConsumer, null, ({
17
27
  width
18
28
  }) => jsx(ContextPanelConsumer, null, ({
19
29
  positionedOverEditor
20
- }) => jsx("div", {
21
- css: [contentArea, positionedOverEditor && positionedOverEditorStyle],
22
- "data-testid": CONTENT_AREA_TEST_ID
23
- }, jsx(ScrollContainer, {
24
- ref: props.scrollContainerRef,
25
- className: "fabric-editor-popup-scroll-parent",
26
- featureFlags: props.featureFlags
27
- }, jsx(ClickAreaBlock, {
28
- editorView: props.editorView,
29
- editorDisabled: props.disabled
30
- }, jsx("div", {
31
- css: editorContentAreaStyle({
32
- fullWidthMode,
33
- layoutMaxWidth: theme.layoutMaxWidth,
34
- containerWidth: width
35
- }),
36
- role: "region",
37
- "aria-label": props.intl.formatMessage(messages.editableContentLabel),
38
- ref: props.contentAreaRef
39
- }, jsx("div", {
40
- css: editorContentGutterStyle,
41
- className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' ')
42
- }, props.customContentComponents, jsx(PluginSlot, {
43
- editorView: props.editorView,
44
- editorActions: props.editorActions,
45
- eventDispatcher: props.eventDispatcher,
46
- providerFactory: props.providerFactory,
47
- appearance: props.appearance,
48
- items: props.contentComponents,
49
- pluginHooks: props.pluginHooks,
50
- contentArea: props.contentArea,
51
- popupsMountPoint: props.popupsMountPoint,
52
- popupsBoundariesElement: props.popupsBoundariesElement,
53
- popupsScrollableElement: props.popupsScrollableElement,
54
- disabled: !!props.disabled,
55
- containerElement: props.scrollContainer,
56
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
57
- wrapperElement: props.wrapperElement
58
- }), props.editorDOMElement)))), jsx("div", {
59
- css: sidebarArea
60
- }, props.contextPanel || jsx(ContextPanel, {
61
- visible: false
62
- })))));
30
+ }) => {
31
+ var _contentAreaRef$curre;
32
+ return jsx("div", {
33
+ css: [contentArea, positionedOverEditor && positionedOverEditorStyle],
34
+ "data-testid": CONTENT_AREA_TEST_ID
35
+ }, jsx(ScrollContainer, {
36
+ className: "fabric-editor-popup-scroll-parent",
37
+ featureFlags: props.featureFlags,
38
+ ref: scrollContainerRef
39
+ }, jsx(ClickAreaBlock, {
40
+ editorView: props.editorView,
41
+ editorDisabled: props.disabled
42
+ }, jsx("div", {
43
+ css: editorContentAreaStyle({
44
+ fullWidthMode,
45
+ layoutMaxWidth: theme.layoutMaxWidth,
46
+ containerWidth: width
47
+ }),
48
+ role: "region",
49
+ "aria-label": props.intl.formatMessage(messages.editableContentLabel),
50
+ ref: contentAreaRef
51
+ }, jsx("div", {
52
+ css: editorContentGutterStyle,
53
+ className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' '),
54
+ ref: contentAreaRef
55
+ }, props.customContentComponents, jsx(PluginSlot, {
56
+ editorView: props.editorView,
57
+ editorActions: props.editorActions,
58
+ eventDispatcher: props.eventDispatcher,
59
+ providerFactory: props.providerFactory,
60
+ appearance: props.appearance,
61
+ items: props.contentComponents,
62
+ pluginHooks: props.pluginHooks,
63
+ contentArea: (_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 ? _contentAreaRef$curre : undefined,
64
+ popupsMountPoint: props.popupsMountPoint,
65
+ popupsBoundariesElement: props.popupsBoundariesElement,
66
+ popupsScrollableElement: props.popupsScrollableElement,
67
+ disabled: !!props.disabled,
68
+ containerElement: scrollContainerRef.current,
69
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
70
+ wrapperElement: props.wrapperElement
71
+ }), props.editorDOMElement)))), jsx("div", {
72
+ css: sidebarArea
73
+ }, props.contextPanel || jsx(ContextPanel, {
74
+ visible: false
75
+ })));
76
+ }));
63
77
  });
64
- export const FullPageContentArea = injectIntl(Content);
78
+ export const FullPageContentArea = injectIntl(Content, {
79
+ forwardRef: true
80
+ });
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "185.8.0";
2
+ export const version = "185.8.2";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.8.0",
3
+ "version": "185.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,137 +1,90 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
10
2
  /** @jsx jsx */
11
- import React from 'react';
3
+ import React, { useEffect, useState, useRef, useMemo } from 'react';
12
4
  import { jsx } from '@emotion/react';
13
- import rafSchedule from 'raf-schd';
14
- import { akEditorToolbarKeylineHeight } from '@atlaskit/editor-shared-styles';
15
5
  import { fullPageEditorWrapper } from './StyledComponents';
16
6
  import { ContextPanelWidthProvider } from '@atlaskit/editor-common/ui';
17
7
  import { FullPageContentArea } from './FullPageContentArea';
18
8
  import { FullPageToolbar } from './FullPageToolbar';
19
- export var FullPageEditor = /*#__PURE__*/function (_React$Component) {
20
- _inherits(FullPageEditor, _React$Component);
21
- var _super = _createSuper(FullPageEditor);
22
- function FullPageEditor(props) {
23
- var _this;
24
- _classCallCheck(this, FullPageEditor);
25
- _this = _super.call(this, props);
26
- _defineProperty(_assertThisInitialized(_this), "state", {
27
- showKeyline: false
28
- });
29
- _defineProperty(_assertThisInitialized(_this), "scrollContainer", null);
30
- // Wrapper container for toolbar and content area
31
- _defineProperty(_assertThisInitialized(_this), "wrapperElementRef", /*#__PURE__*/React.createRef());
32
- _defineProperty(_assertThisInitialized(_this), "contentAreaRef", function (contentArea) {
33
- _this.contentArea = contentArea;
34
- });
35
- _defineProperty(_assertThisInitialized(_this), "scrollContainerRef", function (ref) {
36
- var previousScrollContainer = _this.scrollContainer;
37
-
38
- // remove existing handler
39
- if (previousScrollContainer) {
40
- previousScrollContainer.removeEventListener('scroll', _this.updateToolbarKeyline);
41
- }
42
- _this.scrollContainer = ref ? ref : null;
43
- if (_this.scrollContainer) {
44
- _this.scrollContainer.addEventListener('scroll', _this.updateToolbarKeyline, false);
45
- _this.updateToolbarKeyline();
46
- }
47
- });
48
- _defineProperty(_assertThisInitialized(_this), "updateToolbarKeyline", rafSchedule(function () {
49
- if (!_this.scrollContainer) {
50
- return false;
51
- }
52
- var scrollTop = _this.scrollContainer.scrollTop;
53
- var showKeyline = scrollTop > akEditorToolbarKeylineHeight;
54
- if (showKeyline !== _this.state.showKeyline) {
55
- _this.setState({
56
- showKeyline: showKeyline
57
- });
58
- }
59
- return false;
60
- }));
61
- _defineProperty(_assertThisInitialized(_this), "handleResize", function () {
62
- _this.updateToolbarKeyline();
63
- });
64
- _this.featureFlags = props.featureFlags;
65
- if (props.innerRef) {
66
- _this.wrapperElementRef = props.innerRef;
9
+ import { browser } from '@atlaskit/editor-common/utils';
10
+ var useShowKeyline = function useShowKeyline(contentAreaRef) {
11
+ var _useState = useState(false),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ showKeyline = _useState2[0],
14
+ setShowKeyline = _useState2[1];
15
+ useEffect(function () {
16
+ var _contentAreaRef$curre;
17
+ if (!((_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 && _contentAreaRef$curre.contentArea)) {
18
+ return;
67
19
  }
68
- return _this;
69
- }
70
- _createClass(FullPageEditor, [{
71
- key: "componentDidMount",
72
- value: function componentDidMount() {
73
- window.addEventListener('resize', this.handleResize, false);
74
- }
75
- }, {
76
- key: "componentWillUnmount",
77
- value: function componentWillUnmount() {
78
- window.removeEventListener('resize', this.handleResize);
79
- this.updateToolbarKeyline.cancel();
80
- }
81
- }, {
82
- key: "render",
83
- value: function render() {
84
- var props = this.props;
85
- var showKeyline = this.state.showKeyline;
86
- return jsx(ContextPanelWidthProvider, null, jsx("div", {
87
- css: fullPageEditorWrapper,
88
- className: "akEditor",
89
- ref: this.wrapperElementRef
90
- }, jsx(FullPageToolbar, {
91
- appearance: props.appearance,
92
- beforeIcon: props.primaryToolbarIconBefore,
93
- collabEdit: props.collabEdit,
94
- containerElement: this.scrollContainer,
95
- customPrimaryToolbarComponents: props.customPrimaryToolbarComponents,
96
- disabled: !!props.disabled,
97
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
98
- editorActions: props.editorActions,
99
- editorDOMElement: props.editorDOMElement,
100
- editorView: props.editorView,
101
- eventDispatcher: props.eventDispatcher,
102
- hasMinWidth: props.enableToolbarMinWidth,
103
- popupsBoundariesElement: props.popupsBoundariesElement,
104
- popupsMountPoint: props.popupsMountPoint,
105
- popupsScrollableElement: props.popupsScrollableElement,
106
- primaryToolbarComponents: props.primaryToolbarComponents,
107
- providerFactory: props.providerFactory,
108
- showKeyline: showKeyline,
109
- featureFlags: this.featureFlags
110
- }), jsx(FullPageContentArea, {
111
- appearance: props.appearance,
112
- contentArea: this.contentArea,
113
- contentAreaRef: this.contentAreaRef,
114
- contentComponents: props.contentComponents,
115
- contextPanel: props.contextPanel,
116
- customContentComponents: props.customContentComponents,
117
- disabled: props.disabled,
118
- dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
119
- editorActions: props.editorActions,
120
- editorDOMElement: props.editorDOMElement,
121
- editorView: props.editorView,
122
- eventDispatcher: props.eventDispatcher,
123
- popupsBoundariesElement: props.popupsBoundariesElement,
124
- popupsMountPoint: props.popupsMountPoint,
125
- popupsScrollableElement: props.popupsScrollableElement,
126
- providerFactory: props.providerFactory,
127
- scrollContainer: this.scrollContainer,
128
- scrollContainerRef: this.scrollContainerRef,
129
- wrapperElement: this.wrapperElementRef.current,
130
- pluginHooks: props.pluginHooks,
131
- featureFlags: this.featureFlags
132
- })));
133
- }
134
- }]);
135
- return FullPageEditor;
136
- }(React.Component);
137
- _defineProperty(FullPageEditor, "displayName", 'FullPageEditor');
20
+ var intersection = new IntersectionObserver(function (_ref) {
21
+ var _ref2 = _slicedToArray(_ref, 1),
22
+ entry = _ref2[0];
23
+ setShowKeyline(!entry.isIntersecting && entry.boundingClientRect.top < entry.intersectionRect.top);
24
+ }, {
25
+ root: undefined,
26
+ // Safari seems to miss events (on fast scroll) sometimes due
27
+ // to differences in IntersectionObserver behaviour between browsers.
28
+ // By lowering the threshold a little it gives Safari more
29
+ // time to catch these events.
30
+ threshold: browser.safari ? 0.98 : 1
31
+ });
32
+ intersection.observe(contentAreaRef.current.contentArea);
33
+ return function () {
34
+ intersection.disconnect();
35
+ };
36
+ }, [contentAreaRef]);
37
+ return showKeyline;
38
+ };
39
+ export var FullPageEditor = function FullPageEditor(props) {
40
+ var _scrollContentContain, _scrollContentContain2, _wrapperElementRef$cu;
41
+ var wrapperElementRef = useMemo(function () {
42
+ return props.innerRef;
43
+ }, [props.innerRef]);
44
+ var scrollContentContainerRef = useRef(null);
45
+ var showKeyline = useShowKeyline(scrollContentContainerRef);
46
+ return jsx(ContextPanelWidthProvider, null, jsx("div", {
47
+ css: fullPageEditorWrapper,
48
+ className: "akEditor",
49
+ ref: wrapperElementRef
50
+ }, jsx(FullPageToolbar, {
51
+ appearance: props.appearance,
52
+ beforeIcon: props.primaryToolbarIconBefore,
53
+ collabEdit: props.collabEdit,
54
+ containerElement: (_scrollContentContain = (_scrollContentContain2 = scrollContentContainerRef.current) === null || _scrollContentContain2 === void 0 ? void 0 : _scrollContentContain2.scrollContainer) !== null && _scrollContentContain !== void 0 ? _scrollContentContain : null,
55
+ customPrimaryToolbarComponents: props.customPrimaryToolbarComponents,
56
+ disabled: !!props.disabled,
57
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
58
+ editorActions: props.editorActions,
59
+ editorDOMElement: props.editorDOMElement,
60
+ editorView: props.editorView,
61
+ eventDispatcher: props.eventDispatcher,
62
+ hasMinWidth: props.enableToolbarMinWidth,
63
+ popupsBoundariesElement: props.popupsBoundariesElement,
64
+ popupsMountPoint: props.popupsMountPoint,
65
+ popupsScrollableElement: props.popupsScrollableElement,
66
+ primaryToolbarComponents: props.primaryToolbarComponents,
67
+ providerFactory: props.providerFactory,
68
+ showKeyline: showKeyline,
69
+ featureFlags: props.featureFlags
70
+ }), jsx(FullPageContentArea, {
71
+ ref: scrollContentContainerRef,
72
+ appearance: props.appearance,
73
+ contentComponents: props.contentComponents,
74
+ contextPanel: props.contextPanel,
75
+ customContentComponents: props.customContentComponents,
76
+ disabled: props.disabled,
77
+ dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
78
+ editorActions: props.editorActions,
79
+ editorDOMElement: props.editorDOMElement,
80
+ editorView: props.editorView,
81
+ eventDispatcher: props.eventDispatcher,
82
+ popupsBoundariesElement: props.popupsBoundariesElement,
83
+ popupsMountPoint: props.popupsMountPoint,
84
+ popupsScrollableElement: props.popupsScrollableElement,
85
+ providerFactory: props.providerFactory,
86
+ wrapperElement: (_wrapperElementRef$cu = wrapperElementRef === null || wrapperElementRef === void 0 ? void 0 : wrapperElementRef.current) !== null && _wrapperElementRef$cu !== void 0 ? _wrapperElementRef$cu : null,
87
+ pluginHooks: props.pluginHooks,
88
+ featureFlags: props.featureFlags
89
+ })));
90
+ };
@@ -2,7 +2,7 @@
2
2
  import { jsx, useTheme } from '@emotion/react';
3
3
  import { WidthConsumer } from '@atlaskit/editor-common/ui';
4
4
  import { ContextPanelConsumer } from '@atlaskit/editor-common/ui';
5
- import React from 'react';
5
+ import React, { useImperativeHandle, useRef } from 'react';
6
6
  import { injectIntl } from 'react-intl-next';
7
7
  import { ClickAreaBlock } from '../../Addon';
8
8
  import ContextPanel from '../../ContextPanel';
@@ -10,20 +10,33 @@ import PluginSlot from '../../PluginSlot';
10
10
  import { contentArea, editorContentAreaStyle, sidebarArea, ScrollContainer, editorContentGutterStyle, positionedOverEditorStyle } from './StyledComponents';
11
11
  import messages from './messages';
12
12
  export var CONTENT_AREA_TEST_ID = 'ak-editor-fp-content-area';
13
- var Content = /*#__PURE__*/React.memo(function (props) {
13
+ var Content = /*#__PURE__*/React.forwardRef(function (props, ref) {
14
14
  var theme = useTheme();
15
15
  var fullWidthMode = props.appearance === 'full-width';
16
+ var scrollContainerRef = useRef(null);
17
+ var contentAreaRef = useRef(null);
18
+ useImperativeHandle(ref, function () {
19
+ return {
20
+ get scrollContainer() {
21
+ return scrollContainerRef.current;
22
+ },
23
+ get contentArea() {
24
+ return contentAreaRef.current;
25
+ }
26
+ };
27
+ }, []);
16
28
  return jsx(WidthConsumer, null, function (_ref) {
17
29
  var width = _ref.width;
18
30
  return jsx(ContextPanelConsumer, null, function (_ref2) {
31
+ var _contentAreaRef$curre;
19
32
  var positionedOverEditor = _ref2.positionedOverEditor;
20
33
  return jsx("div", {
21
34
  css: [contentArea, positionedOverEditor && positionedOverEditorStyle],
22
35
  "data-testid": CONTENT_AREA_TEST_ID
23
36
  }, jsx(ScrollContainer, {
24
- ref: props.scrollContainerRef,
25
37
  className: "fabric-editor-popup-scroll-parent",
26
- featureFlags: props.featureFlags
38
+ featureFlags: props.featureFlags,
39
+ ref: scrollContainerRef
27
40
  }, jsx(ClickAreaBlock, {
28
41
  editorView: props.editorView,
29
42
  editorDisabled: props.disabled
@@ -35,10 +48,11 @@ var Content = /*#__PURE__*/React.memo(function (props) {
35
48
  }),
36
49
  role: "region",
37
50
  "aria-label": props.intl.formatMessage(messages.editableContentLabel),
38
- ref: props.contentAreaRef
51
+ ref: contentAreaRef
39
52
  }, jsx("div", {
40
53
  css: editorContentGutterStyle,
41
- className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' ')
54
+ className: ['ak-editor-content-area', fullWidthMode ? 'fabric-editor--full-width-mode' : ''].join(' '),
55
+ ref: contentAreaRef
42
56
  }, props.customContentComponents, jsx(PluginSlot, {
43
57
  editorView: props.editorView,
44
58
  editorActions: props.editorActions,
@@ -47,12 +61,12 @@ var Content = /*#__PURE__*/React.memo(function (props) {
47
61
  appearance: props.appearance,
48
62
  items: props.contentComponents,
49
63
  pluginHooks: props.pluginHooks,
50
- contentArea: props.contentArea,
64
+ contentArea: (_contentAreaRef$curre = contentAreaRef.current) !== null && _contentAreaRef$curre !== void 0 ? _contentAreaRef$curre : undefined,
51
65
  popupsMountPoint: props.popupsMountPoint,
52
66
  popupsBoundariesElement: props.popupsBoundariesElement,
53
67
  popupsScrollableElement: props.popupsScrollableElement,
54
68
  disabled: !!props.disabled,
55
- containerElement: props.scrollContainer,
69
+ containerElement: scrollContainerRef.current,
56
70
  dispatchAnalyticsEvent: props.dispatchAnalyticsEvent,
57
71
  wrapperElement: props.wrapperElement
58
72
  }), props.editorDOMElement)))), jsx("div", {
@@ -63,4 +77,6 @@ var Content = /*#__PURE__*/React.memo(function (props) {
63
77
  });
64
78
  });
65
79
  });
66
- export var FullPageContentArea = injectIntl(Content);
80
+ export var FullPageContentArea = injectIntl(Content, {
81
+ forwardRef: true
82
+ });
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "185.8.0";
2
+ export var version = "185.8.2";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.8.0",
3
+ "version": "185.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,25 +1,3 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
1
  import { jsx } from '@emotion/react';
4
2
  import { EditorAppearanceComponentProps } from '../../../types';
5
- import { FeatureFlags } from '@atlaskit/editor-common/types';
6
- interface FullPageEditorState {
7
- showKeyline: boolean;
8
- }
9
- export declare class FullPageEditor extends React.Component<EditorAppearanceComponentProps, FullPageEditorState> {
10
- state: FullPageEditorState;
11
- featureFlags: FeatureFlags;
12
- static displayName: string;
13
- private scrollContainer;
14
- private contentArea;
15
- private wrapperElementRef;
16
- constructor(props: any);
17
- private contentAreaRef;
18
- private scrollContainerRef;
19
- private updateToolbarKeyline;
20
- private handleResize;
21
- componentDidMount(): void;
22
- componentWillUnmount(): void;
23
- render(): jsx.JSX.Element;
24
- }
25
- export {};
3
+ export declare const FullPageEditor: (props: EditorAppearanceComponentProps) => jsx.JSX.Element;
@@ -10,7 +10,6 @@ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
10
10
  import type { FeatureFlags } from '../../../types/feature-flags';
11
11
  interface FullPageEditorContentAreaProps {
12
12
  appearance: EditorAppearance | undefined;
13
- contentArea: HTMLElement | undefined;
14
13
  contentComponents: UIComponentFactory[] | undefined;
15
14
  pluginHooks: ReactHookFactory[] | undefined;
16
15
  contextPanel: ReactComponents | undefined;
@@ -25,14 +24,15 @@ interface FullPageEditorContentAreaProps {
25
24
  popupsBoundariesElement: HTMLElement | undefined;
26
25
  popupsScrollableElement: HTMLElement | undefined;
27
26
  providerFactory: ProviderFactory;
28
- scrollContainer: HTMLElement | null;
29
- contentAreaRef(ref: HTMLElement | null): void;
30
- scrollContainerRef(ref: HTMLElement | null): void;
31
27
  wrapperElement: HTMLElement | null;
32
28
  featureFlags?: FeatureFlags;
33
29
  }
34
30
  export declare const CONTENT_AREA_TEST_ID = "ak-editor-fp-content-area";
35
- export declare const FullPageContentArea: React.FC<import("react-intl-next").WithIntlProps<FullPageEditorContentAreaProps & WrappedComponentProps<"intl">>> & {
36
- WrappedComponent: React.ComponentType<FullPageEditorContentAreaProps & WrappedComponentProps<"intl">>;
31
+ type ScrollContainerRefs = {
32
+ scrollContainer: HTMLDivElement | null;
33
+ contentArea: HTMLDivElement | null;
34
+ };
35
+ export declare const FullPageContentArea: React.ForwardRefExoticComponent<Pick<import("react-intl-next").WithIntlProps<React.PropsWithChildren<FullPageEditorContentAreaProps & WrappedComponentProps<"intl"> & React.RefAttributes<ScrollContainerRefs>>>, "children" | "key" | "forwardedRef" | keyof FullPageEditorContentAreaProps> & React.RefAttributes<any>> & {
36
+ WrappedComponent: React.ComponentType<FullPageEditorContentAreaProps & WrappedComponentProps<"intl"> & React.RefAttributes<ScrollContainerRefs>>;
37
37
  };
38
38
  export {};
@@ -1,5 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import React, { ReactElement } from 'react';
3
+ import { jsx } from '@emotion/react';
3
4
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
5
  import { EditorView } from 'prosemirror-view';
5
6
  import { WrappedComponentProps } from 'react-intl-next';
@@ -30,7 +31,7 @@ export interface FullPageToolbarProps {
30
31
  hasMinWidth?: boolean;
31
32
  featureFlags?: FeatureFlags;
32
33
  }
33
- export declare const EditorToolbar: React.FunctionComponent<FullPageToolbarProps & WrappedComponentProps>;
34
+ export declare const EditorToolbar: React.MemoExoticComponent<(props: FullPageToolbarProps & WrappedComponentProps) => jsx.JSX.Element>;
34
35
  export declare const FullPageToolbar: React.FC<import("react-intl-next").WithIntlProps<FullPageToolbarProps & WrappedComponentProps<"intl">>> & {
35
36
  WrappedComponent: React.ComponentType<FullPageToolbarProps & WrappedComponentProps<"intl">>;
36
37
  };
@@ -1,25 +1,3 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
1
  import { jsx } from '@emotion/react';
4
2
  import { EditorAppearanceComponentProps } from '../../../types';
5
- import { FeatureFlags } from '@atlaskit/editor-common/types';
6
- interface FullPageEditorState {
7
- showKeyline: boolean;
8
- }
9
- export declare class FullPageEditor extends React.Component<EditorAppearanceComponentProps, FullPageEditorState> {
10
- state: FullPageEditorState;
11
- featureFlags: FeatureFlags;
12
- static displayName: string;
13
- private scrollContainer;
14
- private contentArea;
15
- private wrapperElementRef;
16
- constructor(props: any);
17
- private contentAreaRef;
18
- private scrollContainerRef;
19
- private updateToolbarKeyline;
20
- private handleResize;
21
- componentDidMount(): void;
22
- componentWillUnmount(): void;
23
- render(): jsx.JSX.Element;
24
- }
25
- export {};
3
+ export declare const FullPageEditor: (props: EditorAppearanceComponentProps) => jsx.JSX.Element;
@@ -10,7 +10,6 @@ import type { ReactHookFactory } from '@atlaskit/editor-common/types';
10
10
  import type { FeatureFlags } from '../../../types/feature-flags';
11
11
  interface FullPageEditorContentAreaProps {
12
12
  appearance: EditorAppearance | undefined;
13
- contentArea: HTMLElement | undefined;
14
13
  contentComponents: UIComponentFactory[] | undefined;
15
14
  pluginHooks: ReactHookFactory[] | undefined;
16
15
  contextPanel: ReactComponents | undefined;
@@ -25,14 +24,15 @@ interface FullPageEditorContentAreaProps {
25
24
  popupsBoundariesElement: HTMLElement | undefined;
26
25
  popupsScrollableElement: HTMLElement | undefined;
27
26
  providerFactory: ProviderFactory;
28
- scrollContainer: HTMLElement | null;
29
- contentAreaRef(ref: HTMLElement | null): void;
30
- scrollContainerRef(ref: HTMLElement | null): void;
31
27
  wrapperElement: HTMLElement | null;
32
28
  featureFlags?: FeatureFlags;
33
29
  }
34
30
  export declare const CONTENT_AREA_TEST_ID = "ak-editor-fp-content-area";
35
- export declare const FullPageContentArea: React.FC<import("react-intl-next").WithIntlProps<FullPageEditorContentAreaProps & WrappedComponentProps<"intl">>> & {
36
- WrappedComponent: React.ComponentType<FullPageEditorContentAreaProps & WrappedComponentProps<"intl">>;
31
+ type ScrollContainerRefs = {
32
+ scrollContainer: HTMLDivElement | null;
33
+ contentArea: HTMLDivElement | null;
34
+ };
35
+ export declare const FullPageContentArea: React.ForwardRefExoticComponent<Pick<import("react-intl-next").WithIntlProps<React.PropsWithChildren<FullPageEditorContentAreaProps & WrappedComponentProps<"intl"> & React.RefAttributes<ScrollContainerRefs>>>, "children" | "key" | "forwardedRef" | keyof FullPageEditorContentAreaProps> & React.RefAttributes<any>> & {
36
+ WrappedComponent: React.ComponentType<FullPageEditorContentAreaProps & WrappedComponentProps<"intl"> & React.RefAttributes<ScrollContainerRefs>>;
37
37
  };
38
38
  export {};
@@ -1,5 +1,6 @@
1
1
  /** @jsx jsx */
2
2
  import React, { ReactElement } from 'react';
3
+ import { jsx } from '@emotion/react';
3
4
  import { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
4
5
  import { EditorView } from 'prosemirror-view';
5
6
  import { WrappedComponentProps } from 'react-intl-next';
@@ -30,7 +31,7 @@ export interface FullPageToolbarProps {
30
31
  hasMinWidth?: boolean;
31
32
  featureFlags?: FeatureFlags;
32
33
  }
33
- export declare const EditorToolbar: React.FunctionComponent<FullPageToolbarProps & WrappedComponentProps>;
34
+ export declare const EditorToolbar: React.MemoExoticComponent<(props: FullPageToolbarProps & WrappedComponentProps) => jsx.JSX.Element>;
34
35
  export declare const FullPageToolbar: React.FC<import("react-intl-next").WithIntlProps<FullPageToolbarProps & WrappedComponentProps<"intl">>> & {
35
36
  WrappedComponent: React.ComponentType<FullPageToolbarProps & WrappedComponentProps<"intl">>;
36
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "185.8.0",
3
+ "version": "185.8.2",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -69,7 +69,7 @@
69
69
  "@atlaskit/form": "^8.11.0",
70
70
  "@atlaskit/icon": "^21.12.0",
71
71
  "@atlaskit/icon-object": "^6.3.0",
72
- "@atlaskit/link-analytics": "^8.1.0",
72
+ "@atlaskit/link-analytics": "^8.2.0",
73
73
  "@atlaskit/link-datasource": "^0.27.0",
74
74
  "@atlaskit/link-picker": "^1.25.0",
75
75
  "@atlaskit/locale": "^2.5.0",
@@ -97,7 +97,7 @@
97
97
  "@atlaskit/tabs": "^13.4.0",
98
98
  "@atlaskit/task-decision": "^17.6.0",
99
99
  "@atlaskit/textarea": "^4.7.0",
100
- "@atlaskit/textfield": "^5.5.0",
100
+ "@atlaskit/textfield": "^5.6.0",
101
101
  "@atlaskit/theme": "^12.5.0",
102
102
  "@atlaskit/toggle": "^12.6.0",
103
103
  "@atlaskit/tokens": "^1.11.0",
@@ -149,31 +149,22 @@
149
149
  "devDependencies": {
150
150
  "@af/editor-libra": "*",
151
151
  "@af/integration-testing": "*",
152
- "@atlaskit/atlassian-navigation": "^2.6.0",
153
- "@atlaskit/breadcrumbs": "11.10.4",
154
152
  "@atlaskit/code": "^14.6.0",
155
153
  "@atlaskit/collab-provider": "9.5.1",
156
- "@atlaskit/docs": "*",
157
- "@atlaskit/drawer": "^7.5.0",
158
154
  "@atlaskit/dropdown-menu": "^11.10.0",
159
- "@atlaskit/editor-card-provider": "^3.1.0",
160
155
  "@atlaskit/editor-extension-dropbox": "^0.4.0",
161
156
  "@atlaskit/editor-plugin-table": "^1.7.0",
162
157
  "@atlaskit/editor-test-helpers": "^18.8.0",
163
158
  "@atlaskit/flag": "^15.2.0",
164
- "@atlaskit/inline-dialog": "^13.6.0",
165
159
  "@atlaskit/link-provider": "^1.6.0",
166
160
  "@atlaskit/link-test-helpers": "^4.1.0",
167
- "@atlaskit/lozenge": "^11.4.0",
168
161
  "@atlaskit/media-core": "^34.1.0",
169
162
  "@atlaskit/media-integration-test-helpers": "^3.0.0",
170
163
  "@atlaskit/media-test-helpers": "^33.0.0",
171
164
  "@atlaskit/menu": "^1.9.0",
172
- "@atlaskit/page-layout": "^1.7.0",
173
165
  "@atlaskit/platform-feature-flags": "^0.2.0",
174
166
  "@atlaskit/renderer": "^108.6.0",
175
167
  "@atlaskit/section-message": "^6.4.0",
176
- "@atlaskit/share": "*",
177
168
  "@atlaskit/smart-user-picker": "^6.1.0",
178
169
  "@atlaskit/synchrony-test-helpers": "^2.3.0",
179
170
  "@atlaskit/textarea": "^4.7.0",