@atlaskit/editor-core 185.7.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,21 @@
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
+
9
+ ## 185.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`68ef7e6146c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/68ef7e6146c) - Added feature flag for the new media resize experience.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 185.7.0
4
20
 
5
21
  ### Minor Changes
@@ -35,6 +35,7 @@ var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
35
35
  var _mediaNodeView = require("./nodeviews/mediaNodeView");
36
36
  var _mediaInline = require("./nodeviews/mediaInline");
37
37
  var _pluginKey = require("./pm-plugins/plugin-key");
38
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
38
39
  var _mediaSingle2 = require("./utils/media-single");
39
40
  var mediaPlugin = function mediaPlugin() {
40
41
  var _api$dependencies, _api$dependencies$fea;
@@ -58,7 +59,14 @@ var mediaPlugin = function mediaPlugin() {
58
59
  mediaFeatureFlags = _ref.featureFlags;
59
60
  var captions = (0, _mediaCommon.getMediaFeatureFlag)('captions', mediaFeatureFlags);
60
61
  var allowMediaInline = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags);
61
- var mediaSingleNode = captions ? _adfSchema.mediaSingleWithCaption : _adfSchema.mediaSingle;
62
+ var mediaSingleOption = (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? {
63
+ withCaption: captions,
64
+ withExtendedWidthTypes: true
65
+ } : {
66
+ withCaption: captions,
67
+ withExtendedWidthTypes: false
68
+ };
69
+ var mediaSingleNode = (0, _adfSchema.mediaSingleSpec)(mediaSingleOption);
62
70
  return [{
63
71
  name: 'mediaGroup',
64
72
  node: _adfSchema.mediaGroup
@@ -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.7.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.7.0",
3
+ "version": "185.8.2",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { PluginKey, NodeSelection } from 'prosemirror-state';
3
3
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
4
- import { media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaInline } from '@atlaskit/adf-schema';
4
+ import { media, mediaGroup, mediaInline, mediaSingleSpec } from '@atlaskit/adf-schema';
5
5
  import { stateKey as pluginKey, createPlugin } from './pm-plugins/main';
6
6
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
7
7
  import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
@@ -22,6 +22,7 @@ import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
22
22
  import { ReactMediaNode } from './nodeviews/mediaNodeView';
23
23
  import { ReactMediaInlineNode } from './nodeviews/mediaInline';
24
24
  import { stateKey } from './pm-plugins/plugin-key';
25
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
25
26
  export { insertMediaSingleNode } from './utils/media-single';
26
27
  const mediaPlugin = (options = {}, api) => {
27
28
  var _api$dependencies, _api$dependencies$fea;
@@ -42,7 +43,14 @@ const mediaPlugin = (options = {}, api) => {
42
43
  } = options || {};
43
44
  const captions = getMediaFeatureFlag('captions', mediaFeatureFlags);
44
45
  const allowMediaInline = getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
45
- const mediaSingleNode = captions ? mediaSingleWithCaption : mediaSingle;
46
+ const mediaSingleOption = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
47
+ withCaption: captions,
48
+ withExtendedWidthTypes: true
49
+ } : {
50
+ withCaption: captions,
51
+ withExtendedWidthTypes: false
52
+ };
53
+ const mediaSingleNode = mediaSingleSpec(mediaSingleOption);
46
54
  return [{
47
55
  name: 'mediaGroup',
48
56
  node: mediaGroup
@@ -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
+ };