@atlaskit/editor-plugin-media 24.0.4 → 24.0.6

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,28 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 24.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e88ec21b2ee73`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e88ec21b2ee73) -
8
+ Re-land of EDITOR-9164. Behind the shared `platform_editor_reduce_forced_layout` experiment, the
9
+ media single node view no longer reads `offsetLeft` from `ignoreMutation` when nothing can consume
10
+ the result — that is, when pixel resizing is enabled (the resizer used in that mode never reads
11
+ it) or when resizing is disabled. The read forced a synchronous layout recalculation on every DOM
12
+ mutation and every caret move inside a media single. Percentage-based resizing is unaffected.
13
+
14
+ The skip decision is now resolved lazily on the first `ignoreMutation` call instead of in a
15
+ class-field initializer, avoiding the optional chaining in a class field that caused
16
+ `jsx is not defined` in the Help Center build.
17
+
18
+ - Updated dependencies
19
+
20
+ ## 24.0.5
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 24.0.4
4
27
 
5
28
  ### Patch Changes
@@ -20,6 +20,7 @@ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/rea
20
20
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
21
21
  var _utils = require("@atlaskit/editor-common/utils");
22
22
  var _contentVisibility = require("@atlaskit/editor-common/utils/content-visibility");
23
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
23
24
  var _main = require("../pm-plugins/main");
24
25
  var _MediaSSRReactContextsProvider = require("../ui/MediaSSRReactContextsProvider");
25
26
  var _mediaSingleNext = require("./mediaSingleNext");
@@ -96,6 +97,19 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref) {
96
97
  editorAppearance: editorAppearance
97
98
  });
98
99
  };
100
+
101
+ /**
102
+ * Only the percentage-based `ResizableMediaSingle` reads `offsetLeft`, to offset the resize grid
103
+ * for an image indented in a list. Pixel resizing and no-resizer configurations never consume it,
104
+ * so `ignoreMutation` can skip the forced layout read for them.
105
+ *
106
+ * We can remove this and always return true from ignoreMutation once the legacy media resizer is removed.
107
+ */
108
+ var shouldSkipOffsetLeftRead = function shouldSkipOffsetLeftRead(mediaOptions) {
109
+ var allowPixelResizing = Boolean(mediaOptions && mediaOptions.allowPixelResizing);
110
+ var allowResizing = Boolean(mediaOptions && mediaOptions.allowResizing);
111
+ return (allowPixelResizing || !allowResizing) && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_reduce_forced_layout');
112
+ };
99
113
  var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
100
114
  function MediaSingleNodeView() {
101
115
  var _this;
@@ -108,6 +122,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
108
122
  (0, _defineProperty2.default)(_this, "forceViewUpdate", false);
109
123
  (0, _defineProperty2.default)(_this, "selectionType", null);
110
124
  (0, _defineProperty2.default)(_this, "hasResized", false);
125
+ (0, _defineProperty2.default)(_this, "skipsOffsetLeftRead", null);
111
126
  (0, _defineProperty2.default)(_this, "checkAndUpdateSelectionType", function () {
112
127
  var getPos = _this.getPos;
113
128
  var selection = _this.view.state.selection;
@@ -320,6 +335,13 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
320
335
  }, {
321
336
  key: "ignoreMutation",
322
337
  value: function ignoreMutation() {
338
+ if (this.skipsOffsetLeftRead === null) {
339
+ this.skipsOffsetLeftRead = shouldSkipOffsetLeftRead(this.reactComponentProps.mediaOptions);
340
+ }
341
+ if (this.skipsOffsetLeftRead) {
342
+ return true;
343
+ }
344
+
323
345
  // DOM has changed; recalculate if we need to re-render
324
346
  if (this.dom) {
325
347
  // Ignored via go/ees005
@@ -15,6 +15,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
15
15
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
16
16
  import { isNodeSelectedOrInRange } from '@atlaskit/editor-common/utils';
17
17
  import { applyContentVisibility, estimateMediaSingleIntrinsicSize } from '@atlaskit/editor-common/utils/content-visibility';
18
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
18
19
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
19
20
  import { MediaSSRReactContextsProvider } from '../ui/MediaSSRReactContextsProvider';
20
21
  import { MediaSingleNodeNext } from './mediaSingleNext';
@@ -81,6 +82,19 @@ const MediaSingleNodeWrapper = ({
81
82
  editorAppearance: editorAppearance
82
83
  });
83
84
  };
85
+
86
+ /**
87
+ * Only the percentage-based `ResizableMediaSingle` reads `offsetLeft`, to offset the resize grid
88
+ * for an image indented in a list. Pixel resizing and no-resizer configurations never consume it,
89
+ * so `ignoreMutation` can skip the forced layout read for them.
90
+ *
91
+ * We can remove this and always return true from ignoreMutation once the legacy media resizer is removed.
92
+ */
93
+ const shouldSkipOffsetLeftRead = mediaOptions => {
94
+ const allowPixelResizing = Boolean(mediaOptions && mediaOptions.allowPixelResizing);
95
+ const allowResizing = Boolean(mediaOptions && mediaOptions.allowResizing);
96
+ return (allowPixelResizing || !allowResizing) && isExperimentEnabled('platform_editor_reduce_forced_layout');
97
+ };
84
98
  class MediaSingleNodeView extends ReactNodeView {
85
99
  constructor(...args) {
86
100
  super(...args);
@@ -88,6 +102,7 @@ class MediaSingleNodeView extends ReactNodeView {
88
102
  _defineProperty(this, "forceViewUpdate", false);
89
103
  _defineProperty(this, "selectionType", null);
90
104
  _defineProperty(this, "hasResized", false);
105
+ _defineProperty(this, "skipsOffsetLeftRead", null);
91
106
  _defineProperty(this, "checkAndUpdateSelectionType", () => {
92
107
  const getPos = this.getPos;
93
108
  const {
@@ -274,6 +289,13 @@ class MediaSingleNodeView extends ReactNodeView {
274
289
  }));
275
290
  }
276
291
  ignoreMutation() {
292
+ if (this.skipsOffsetLeftRead === null) {
293
+ this.skipsOffsetLeftRead = shouldSkipOffsetLeftRead(this.reactComponentProps.mediaOptions);
294
+ }
295
+ if (this.skipsOffsetLeftRead) {
296
+ return true;
297
+ }
298
+
277
299
  // DOM has changed; recalculate if we need to re-render
278
300
  if (this.dom) {
279
301
  // Ignored via go/ees005
@@ -24,6 +24,7 @@ import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared
24
24
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
25
25
  import { isNodeSelectedOrInRange } from '@atlaskit/editor-common/utils';
26
26
  import { applyContentVisibility, estimateMediaSingleIntrinsicSize } from '@atlaskit/editor-common/utils/content-visibility';
27
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
27
28
  import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
28
29
  import { MediaSSRReactContextsProvider } from '../ui/MediaSSRReactContextsProvider';
29
30
  import { MediaSingleNodeNext } from './mediaSingleNext';
@@ -92,6 +93,19 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref) {
92
93
  editorAppearance: editorAppearance
93
94
  });
94
95
  };
96
+
97
+ /**
98
+ * Only the percentage-based `ResizableMediaSingle` reads `offsetLeft`, to offset the resize grid
99
+ * for an image indented in a list. Pixel resizing and no-resizer configurations never consume it,
100
+ * so `ignoreMutation` can skip the forced layout read for them.
101
+ *
102
+ * We can remove this and always return true from ignoreMutation once the legacy media resizer is removed.
103
+ */
104
+ var shouldSkipOffsetLeftRead = function shouldSkipOffsetLeftRead(mediaOptions) {
105
+ var allowPixelResizing = Boolean(mediaOptions && mediaOptions.allowPixelResizing);
106
+ var allowResizing = Boolean(mediaOptions && mediaOptions.allowResizing);
107
+ return (allowPixelResizing || !allowResizing) && isExperimentEnabled('platform_editor_reduce_forced_layout');
108
+ };
95
109
  var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
96
110
  function MediaSingleNodeView() {
97
111
  var _this;
@@ -104,6 +118,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
104
118
  _defineProperty(_this, "forceViewUpdate", false);
105
119
  _defineProperty(_this, "selectionType", null);
106
120
  _defineProperty(_this, "hasResized", false);
121
+ _defineProperty(_this, "skipsOffsetLeftRead", null);
107
122
  _defineProperty(_this, "checkAndUpdateSelectionType", function () {
108
123
  var getPos = _this.getPos;
109
124
  var selection = _this.view.state.selection;
@@ -316,6 +331,13 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
316
331
  }, {
317
332
  key: "ignoreMutation",
318
333
  value: function ignoreMutation() {
334
+ if (this.skipsOffsetLeftRead === null) {
335
+ this.skipsOffsetLeftRead = shouldSkipOffsetLeftRead(this.reactComponentProps.mediaOptions);
336
+ }
337
+ if (this.skipsOffsetLeftRead) {
338
+ return true;
339
+ }
340
+
319
341
  // DOM has changed; recalculate if we need to re-render
320
342
  if (this.dom) {
321
343
  // Ignored via go/ees005
@@ -18,6 +18,7 @@ declare class MediaSingleNodeView extends ReactNodeView<MediaSingleNodeViewProps
18
18
  selectionType: number | null;
19
19
  unsubscribeToViewModeChange: (() => void) | undefined;
20
20
  hasResized: boolean;
21
+ skipsOffsetLeftRead: boolean | null;
21
22
  createDomRef(): HTMLElement;
22
23
  getContentDOM(): {
23
24
  dom: HTMLDivElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "24.0.4",
3
+ "version": "24.0.6",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -61,7 +61,7 @@
61
61
  "@atlaskit/platform-feature-flags": "^2.2.0",
62
62
  "@atlaskit/primitives": "^22.5.0",
63
63
  "@atlaskit/textfield": "^10.2.0",
64
- "@atlaskit/tmp-editor-statsig": "^213.0.0",
64
+ "@atlaskit/tmp-editor-statsig": "^215.0.0",
65
65
  "@atlaskit/tokens": "^20.1.0",
66
66
  "@atlaskit/tooltip": "^24.3.0",
67
67
  "@babel/runtime": "^7.0.0",
@@ -74,7 +74,7 @@
74
74
  "uuid": "^11.1.1"
75
75
  },
76
76
  "peerDependencies": {
77
- "@atlaskit/editor-common": "^126.2.0",
77
+ "@atlaskit/editor-common": "^126.3.0",
78
78
  "@atlaskit/media-core": "^39.0.0",
79
79
  "react": "^18.2.0 || ^19.2.0",
80
80
  "react-dom": "^18.2.0 || ^19.2.0",