@atlaskit/editor-plugin-block-controls 18.2.4 → 18.2.7

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-block-controls
2
2
 
3
+ ## 18.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`e8d06b88688a5`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e8d06b88688a5) -
8
+ Use the React root API when `platform_editor_react19_migration` is enabled or the legacy ReactDOM
9
+ API is unavailable.
10
+ - Updated dependencies
11
+
12
+ ## 18.2.6
13
+
14
+ ### Patch Changes
15
+
16
+ - [`80f8db8984c15`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/80f8db8984c15) -
17
+ Fix collapsible headings causing invalid css anchors
18
+ - Updated dependencies
19
+
20
+ ## 18.2.5
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 18.2.4
4
27
 
5
28
  ### Patch Changes
@@ -27,10 +27,12 @@ var reactRoots = new WeakMap();
27
27
  * on (focus management, anchor positioning, block-menu visibility all read
28
28
  * the rendered DOM immediately after the callback returns).
29
29
  *
30
- * Otherwise, falls back to the legacy `ReactDOM.render` path.
30
+ * Otherwise, falls back to the legacy `ReactDOM.render` path. The API is not
31
+ * available in React 19, so the root path is also selected when the legacy
32
+ * method has been removed.
31
33
  */
32
34
  var renderToMountPoint = exports.renderToMountPoint = function renderToMountPoint(element, mountPoint) {
33
- if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration')) {
35
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration') || typeof _reactDom.default.render !== 'function') {
34
36
  var root = reactRoots.get(mountPoint);
35
37
  if (!root) {
36
38
  root = (0, _client.createRoot)(mountPoint);
@@ -57,7 +59,7 @@ var renderToMountPoint = exports.renderToMountPoint = function renderToMountPoin
57
59
  * Otherwise, falls back to `ReactDOM.unmountComponentAtNode`.
58
60
  */
59
61
  var unmountFromMountPoint = exports.unmountFromMountPoint = function unmountFromMountPoint(mountPoint) {
60
- if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration')) {
62
+ if ((0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_react19_migration') || typeof _reactDom.default.render !== 'function') {
61
63
  var root = reactRoots.get(mountPoint);
62
64
  if (root) {
63
65
  root.unmount();
@@ -1,4 +1,4 @@
1
- /* block-controls-left-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-left-surface.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* block-controls-right-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-right-surface.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -1,4 +1,4 @@
1
- /* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  "use strict";
3
3
 
4
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -90,6 +90,19 @@ var toMeasuredSurfaceWrapperPlacement = exports.toMeasuredSurfaceWrapperPlacemen
90
90
  }
91
91
  };
92
92
  };
93
+
94
+ /**
95
+ * Where a surface goes when its anchor stops resolving, as the fallback argument to the block-axis
96
+ * `anchor()` calls below.
97
+ *
98
+ * An anchor is invalid once its element stops generating a box e.g. (`display: none`) / removed node
99
+ * Currently, anchor fallback is not unstable with some of the position-visibility options, so here
100
+ * we manually set a fallback of -9999 so that it will render offscreen out of the viewport
101
+ * without causing extra overflows
102
+ */
103
+ var INVALID_ANCHOR_OFFSCREEN_PX = 9999;
104
+ var INVALID_ANCHOR_FALLBACK_TOP = "-".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
105
+ var INVALID_ANCHOR_FALLBACK_BOTTOM = "".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
93
106
  var getAnchoredSurfacePlacement = exports.getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_ref3) {
94
107
  var anchorName = _ref3.anchorName,
95
108
  nodeType = _ref3.nodeType,
@@ -104,7 +117,7 @@ var getAnchoredSurfacePlacement = exports.getAnchoredSurfacePlacement = function
104
117
  style: {
105
118
  left: "calc((anchor(".concat(anchorName, " left) + anchor(").concat(anchorName, " right)) / 2)"),
106
119
  positionAnchor: anchorName,
107
- top: "anchor(".concat(anchorName, " top)"),
120
+ top: "anchor(".concat(anchorName, " top, ").concat(INVALID_ANCHOR_FALLBACK_TOP, ")"),
108
121
  transform: 'translate(-50%, -50%)'
109
122
  }
110
123
  };
@@ -114,11 +127,11 @@ var getAnchoredSurfacePlacement = exports.getAnchoredSurfacePlacement = function
114
127
  return {
115
128
  isSticky: isSticky,
116
129
  style: _objectSpread(_objectSpread({}, isSticky ? {
117
- bottom: "anchor(".concat(anchorName, " bottom)")
130
+ bottom: "anchor(".concat(anchorName, " bottom, ").concat(INVALID_ANCHOR_FALLBACK_BOTTOM, ")")
118
131
  } : {}), {}, {
119
132
  left: side === 'right' ? "calc(anchor(".concat(anchorName, " right) + ").concat(gap, "px)") : "anchor(".concat(anchorName, " left)"),
120
133
  positionAnchor: anchorName,
121
- top: "calc(anchor(".concat(anchorName, " top) + ").concat((0, _consts.topPositionAdjustment)(nodeTypeWithLevel), "px)"),
134
+ top: "calc(anchor(".concat(anchorName, " top, ").concat(INVALID_ANCHOR_FALLBACK_TOP, ") + ").concat((0, _consts.topPositionAdjustment)(nodeTypeWithLevel), "px)"),
122
135
  // The left side grows away from the node without knowing its own width, so it pulls itself
123
136
  // back past its own box and the gap. The right side grows into the margin, so the gap is
124
137
  // already folded into `left` above.
@@ -20,10 +20,12 @@ const reactRoots = new WeakMap();
20
20
  * on (focus management, anchor positioning, block-menu visibility all read
21
21
  * the rendered DOM immediately after the callback returns).
22
22
  *
23
- * Otherwise, falls back to the legacy `ReactDOM.render` path.
23
+ * Otherwise, falls back to the legacy `ReactDOM.render` path. The API is not
24
+ * available in React 19, so the root path is also selected when the legacy
25
+ * method has been removed.
24
26
  */
25
27
  export const renderToMountPoint = (element, mountPoint) => {
26
- if (isExperimentEnabled('platform_editor_react19_migration')) {
28
+ if (isExperimentEnabled('platform_editor_react19_migration') || typeof ReactDOM.render !== 'function') {
27
29
  let root = reactRoots.get(mountPoint);
28
30
  if (!root) {
29
31
  root = createRoot(mountPoint);
@@ -48,7 +50,7 @@ export const renderToMountPoint = (element, mountPoint) => {
48
50
  * Otherwise, falls back to `ReactDOM.unmountComponentAtNode`.
49
51
  */
50
52
  export const unmountFromMountPoint = mountPoint => {
51
- if (isExperimentEnabled('platform_editor_react19_migration')) {
53
+ if (isExperimentEnabled('platform_editor_react19_migration') || typeof ReactDOM.render !== 'function') {
52
54
  const root = reactRoots.get(mountPoint);
53
55
  if (root) {
54
56
  root.unmount();
@@ -1,4 +1,4 @@
1
- /* block-controls-left-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-left-surface.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./block-controls-left-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
4
4
  import { bind } from 'bind-event-listener';
@@ -1,4 +1,4 @@
1
- /* block-controls-right-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-right-surface.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./block-controls-right-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import { ax, ix } from "@compiled/react/runtime";
3
3
  import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
4
4
  import { bind } from 'bind-event-listener';
@@ -1,4 +1,4 @@
1
- /* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./block-controls-surface-drag-handle.compiled.css";
3
3
  import * as React from 'react';
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -81,6 +81,19 @@ export const toMeasuredSurfaceWrapperPlacement = placement => ({
81
81
  transform: placement.transform
82
82
  }
83
83
  });
84
+
85
+ /**
86
+ * Where a surface goes when its anchor stops resolving, as the fallback argument to the block-axis
87
+ * `anchor()` calls below.
88
+ *
89
+ * An anchor is invalid once its element stops generating a box e.g. (`display: none`) / removed node
90
+ * Currently, anchor fallback is not unstable with some of the position-visibility options, so here
91
+ * we manually set a fallback of -9999 so that it will render offscreen out of the viewport
92
+ * without causing extra overflows
93
+ */
94
+ const INVALID_ANCHOR_OFFSCREEN_PX = 9999;
95
+ const INVALID_ANCHOR_FALLBACK_TOP = `-${INVALID_ANCHOR_OFFSCREEN_PX}px`;
96
+ const INVALID_ANCHOR_FALLBACK_BOTTOM = `${INVALID_ANCHOR_OFFSCREEN_PX}px`;
84
97
  export const getAnchoredSurfacePlacement = ({
85
98
  anchorName,
86
99
  nodeType,
@@ -96,7 +109,7 @@ export const getAnchoredSurfacePlacement = ({
96
109
  style: {
97
110
  left: `calc((anchor(${anchorName} left) + anchor(${anchorName} right)) / 2)`,
98
111
  positionAnchor: anchorName,
99
- top: `anchor(${anchorName} top)`,
112
+ top: `anchor(${anchorName} top, ${INVALID_ANCHOR_FALLBACK_TOP})`,
100
113
  transform: 'translate(-50%, -50%)'
101
114
  }
102
115
  };
@@ -110,11 +123,11 @@ export const getAnchoredSurfacePlacement = ({
110
123
  // with the adjusted `top` keeps the box ending exactly where the node does, however far
111
124
  // the top adjustment pushed the start down and however much the node later grows.
112
125
  ...(isSticky ? {
113
- bottom: `anchor(${anchorName} bottom)`
126
+ bottom: `anchor(${anchorName} bottom, ${INVALID_ANCHOR_FALLBACK_BOTTOM})`
114
127
  } : {}),
115
128
  left: side === 'right' ? `calc(anchor(${anchorName} right) + ${gap}px)` : `anchor(${anchorName} left)`,
116
129
  positionAnchor: anchorName,
117
- top: `calc(anchor(${anchorName} top) + ${topPositionAdjustment(nodeTypeWithLevel)}px)`,
130
+ top: `calc(anchor(${anchorName} top, ${INVALID_ANCHOR_FALLBACK_TOP}) + ${topPositionAdjustment(nodeTypeWithLevel)}px)`,
118
131
  // The left side grows away from the node without knowing its own width, so it pulls itself
119
132
  // back past its own box and the gap. The right side grows into the margin, so the gap is
120
133
  // already folded into `left` above.
@@ -20,10 +20,12 @@ var reactRoots = new WeakMap();
20
20
  * on (focus management, anchor positioning, block-menu visibility all read
21
21
  * the rendered DOM immediately after the callback returns).
22
22
  *
23
- * Otherwise, falls back to the legacy `ReactDOM.render` path.
23
+ * Otherwise, falls back to the legacy `ReactDOM.render` path. The API is not
24
+ * available in React 19, so the root path is also selected when the legacy
25
+ * method has been removed.
24
26
  */
25
27
  export var renderToMountPoint = function renderToMountPoint(element, mountPoint) {
26
- if (isExperimentEnabled('platform_editor_react19_migration')) {
28
+ if (isExperimentEnabled('platform_editor_react19_migration') || typeof ReactDOM.render !== 'function') {
27
29
  var root = reactRoots.get(mountPoint);
28
30
  if (!root) {
29
31
  root = createRoot(mountPoint);
@@ -50,7 +52,7 @@ export var renderToMountPoint = function renderToMountPoint(element, mountPoint)
50
52
  * Otherwise, falls back to `ReactDOM.unmountComponentAtNode`.
51
53
  */
52
54
  export var unmountFromMountPoint = function unmountFromMountPoint(mountPoint) {
53
- if (isExperimentEnabled('platform_editor_react19_migration')) {
55
+ if (isExperimentEnabled('platform_editor_react19_migration') || typeof ReactDOM.render !== 'function') {
54
56
  var root = reactRoots.get(mountPoint);
55
57
  if (root) {
56
58
  root.unmount();
@@ -1,4 +1,4 @@
1
- /* block-controls-left-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-left-surface.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./block-controls-left-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-left-surfaces.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* block-controls-right-surface.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-right-surface.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import "./block-controls-right-surface.compiled.css";
3
3
  import { ax, ix } from "@compiled/react/runtime";
4
4
  import React from 'react';
@@ -1,4 +1,4 @@
1
- /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-right-surfaces.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { ax, ix } from "@compiled/react/runtime";
@@ -1,4 +1,4 @@
1
- /* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v2.0.0 */
1
+ /* block-controls-surface-drag-handle.tsx generated by @compiled/babel-plugin v3.0.1 */
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import "./block-controls-surface-drag-handle.compiled.css";
4
4
  import * as React from 'react';
@@ -83,6 +83,19 @@ export var toMeasuredSurfaceWrapperPlacement = function toMeasuredSurfaceWrapper
83
83
  }
84
84
  };
85
85
  };
86
+
87
+ /**
88
+ * Where a surface goes when its anchor stops resolving, as the fallback argument to the block-axis
89
+ * `anchor()` calls below.
90
+ *
91
+ * An anchor is invalid once its element stops generating a box e.g. (`display: none`) / removed node
92
+ * Currently, anchor fallback is not unstable with some of the position-visibility options, so here
93
+ * we manually set a fallback of -9999 so that it will render offscreen out of the viewport
94
+ * without causing extra overflows
95
+ */
96
+ var INVALID_ANCHOR_OFFSCREEN_PX = 9999;
97
+ var INVALID_ANCHOR_FALLBACK_TOP = "-".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
98
+ var INVALID_ANCHOR_FALLBACK_BOTTOM = "".concat(INVALID_ANCHOR_OFFSCREEN_PX, "px");
86
99
  export var getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_ref3) {
87
100
  var anchorName = _ref3.anchorName,
88
101
  nodeType = _ref3.nodeType,
@@ -97,7 +110,7 @@ export var getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_r
97
110
  style: {
98
111
  left: "calc((anchor(".concat(anchorName, " left) + anchor(").concat(anchorName, " right)) / 2)"),
99
112
  positionAnchor: anchorName,
100
- top: "anchor(".concat(anchorName, " top)"),
113
+ top: "anchor(".concat(anchorName, " top, ").concat(INVALID_ANCHOR_FALLBACK_TOP, ")"),
101
114
  transform: 'translate(-50%, -50%)'
102
115
  }
103
116
  };
@@ -107,11 +120,11 @@ export var getAnchoredSurfacePlacement = function getAnchoredSurfacePlacement(_r
107
120
  return {
108
121
  isSticky: isSticky,
109
122
  style: _objectSpread(_objectSpread({}, isSticky ? {
110
- bottom: "anchor(".concat(anchorName, " bottom)")
123
+ bottom: "anchor(".concat(anchorName, " bottom, ").concat(INVALID_ANCHOR_FALLBACK_BOTTOM, ")")
111
124
  } : {}), {}, {
112
125
  left: side === 'right' ? "calc(anchor(".concat(anchorName, " right) + ").concat(gap, "px)") : "anchor(".concat(anchorName, " left)"),
113
126
  positionAnchor: anchorName,
114
- top: "calc(anchor(".concat(anchorName, " top) + ").concat(topPositionAdjustment(nodeTypeWithLevel), "px)"),
127
+ top: "calc(anchor(".concat(anchorName, " top, ").concat(INVALID_ANCHOR_FALLBACK_TOP, ") + ").concat(topPositionAdjustment(nodeTypeWithLevel), "px)"),
115
128
  // The left side grows away from the node without knowing its own width, so it pulls itself
116
129
  // back past its own box and the gap. The right side grows into the margin, so the gap is
117
130
  // already folded into `left` above.
@@ -8,7 +8,9 @@ import type { ReactElement } from 'react';
8
8
  * on (focus management, anchor positioning, block-menu visibility all read
9
9
  * the rendered DOM immediately after the callback returns).
10
10
  *
11
- * Otherwise, falls back to the legacy `ReactDOM.render` path.
11
+ * Otherwise, falls back to the legacy `ReactDOM.render` path. The API is not
12
+ * available in React 19, so the root path is also selected when the legacy
13
+ * method has been removed.
12
14
  */
13
15
  export declare const renderToMountPoint: (element: ReactElement, mountPoint: Element) => void;
14
16
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-block-controls",
3
- "version": "18.2.4",
3
+ "version": "18.2.7",
4
4
  "description": "Block controls plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/editor-plugin-width": "^18.0.0",
44
44
  "@atlaskit/editor-prosemirror": "^8.0.0",
45
45
  "@atlaskit/editor-shared-styles": "^4.1.0",
46
- "@atlaskit/editor-tables": "^3.1.0",
46
+ "@atlaskit/editor-tables": "^3.2.0",
47
47
  "@atlaskit/editor-ui-control-model": "^2.9.0",
48
48
  "@atlaskit/icon": "^37.6.0",
49
49
  "@atlaskit/icon-lab": "^7.8.0",
@@ -56,7 +56,7 @@
56
56
  "@atlaskit/primitives": "^22.5.0",
57
57
  "@atlaskit/section-message": "^10.2.0",
58
58
  "@atlaskit/theme": "^28.2.0",
59
- "@atlaskit/tmp-editor-statsig": "^183.0.0",
59
+ "@atlaskit/tmp-editor-statsig": "^185.0.0",
60
60
  "@atlaskit/tokens": "^16.11.0",
61
61
  "@atlaskit/tooltip": "^24.3.0",
62
62
  "@babel/runtime": "^7.0.0",
@@ -68,7 +68,7 @@
68
68
  "uuid": "^11.1.1"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^121.2.0",
71
+ "@atlaskit/editor-common": "^121.3.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -109,6 +109,7 @@
109
109
  },
110
110
  "devDependencies": {
111
111
  "@atlassian/structured-docs-types": "workspace:^",
112
+ "@atlassian/workbench": "workspace:*",
112
113
  "react": "^19.2.0",
113
114
  "react-dom": "^19.2.0",
114
115
  "react-intl": "^7.0.0"