@atlaskit/editor-common 111.7.3 → 111.7.4

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,17 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 111.7.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`db121516e200b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/db121516e200b) -
8
+ [ux] Update hub extention titles and radius slider style
9
+ - [`ba05557f777bf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ba05557f777bf) -
10
+ Add support to render selection toolbar in editors which have an ancestor elemenent which has
11
+ position fixed, most common use case is for the chromeless appearance when rendered inside modals,
12
+ popups etc.
13
+ - Updated dependencies
14
+
3
15
  ## 111.7.3
4
16
 
5
17
  ### Patch Changes
@@ -18,7 +18,7 @@ var textColorMessages = exports.textColorMessages = (0, _reactIntlNext.defineMes
18
18
  },
19
19
  textColorHighlightTooltip: {
20
20
  id: 'fabric.editor.textColorHighlightTooltip',
21
- defaultMessage: 'Text and Highlight color',
21
+ defaultMessage: 'Text and highlight color',
22
22
  description: 'Tooltip of menu that provides access to various colors of highlight.'
23
23
  }
24
24
  });
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "111.7.2";
22
+ var packageVersion = "111.7.3";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "111.7.2";
27
+ var packageVersion = "111.7.3";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.calculateToolbarPositionTrackHead = exports.calculateToolbarPositionOnCellSelection = exports.calculateToolbarPositionAboveSelection = void 0;
6
+ exports.calculateToolbarPositionTrackHeadOld = exports.calculateToolbarPositionTrackHeadNew = exports.calculateToolbarPositionTrackHead = exports.calculateToolbarPositionOnCellSelection = exports.calculateToolbarPositionAboveSelection = void 0;
7
7
  var _utils = require("@atlaskit/editor-prosemirror/utils");
8
8
  var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
9
9
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
11
  var MAXIMUM_BROWSER_SCROLLBAR_WIDTH = 20;
11
12
 
12
13
  /*
@@ -85,19 +86,36 @@ var calculateToolbarPositionAboveSelection = exports.calculateToolbarPositionAbo
85
86
  };
86
87
  };
87
88
  };
88
- /*
89
- Calculates the position of the floating toolbar relative to the selection.
90
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
91
- The main difference is the popup is always above the selection.
92
- Things to consider:
93
- - stick as close to the head X release coordinates as possible
94
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
95
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
96
- - we use the toolbarRect to center align toolbar
97
- - use wrapperBounds to clamp values
98
- - editorView.dom bounds differ to wrapperBounds, convert at the end
99
- */
100
- var calculateToolbarPositionTrackHead = exports.calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
89
+ var findContainingElement = function findContainingElement(editorView) {
90
+ // First, try to find .fabric-editor-popup-scroll-parent
91
+ var scrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
92
+ if (scrollParent) {
93
+ return {
94
+ container: scrollParent,
95
+ isFixed: false
96
+ };
97
+ } else {
98
+ // If no scroll parent, look for a fixed positioned parent
99
+ var fixedParent = editorView.dom.parentElement;
100
+ while (fixedParent && fixedParent !== document.body) {
101
+ var computedStyle = window.getComputedStyle(fixedParent);
102
+ if (computedStyle.position === 'fixed') {
103
+ return {
104
+ container: fixedParent,
105
+ isFixed: true
106
+ };
107
+ }
108
+ fixedParent = fixedParent.parentElement;
109
+ }
110
+ }
111
+
112
+ // Fall back to document.body if no fixed parent found
113
+ return {
114
+ container: document.body,
115
+ isFixed: false
116
+ };
117
+ };
118
+ var calculateToolbarPositionTrackHeadOld = exports.calculateToolbarPositionTrackHeadOld = function calculateToolbarPositionTrackHeadOld(toolbarTitle) {
101
119
  return function (editorView, nextPos) {
102
120
  var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
103
121
  if (!toolbar) {
@@ -167,6 +185,121 @@ var calculateToolbarPositionTrackHead = exports.calculateToolbarPositionTrackHea
167
185
  };
168
186
  };
169
187
 
188
+ /**
189
+ * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
190
+ * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
191
+ * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
192
+ */
193
+ var calculateToolbarPositionTrackHeadNew = exports.calculateToolbarPositionTrackHeadNew = function calculateToolbarPositionTrackHeadNew(toolbarTitle) {
194
+ // Cache the container to avoid repeated DOM traversal and getComputedStyle calls
195
+ var cachedContainer = null;
196
+ var isFixedContainer = false;
197
+ var cachedEditorDom = null;
198
+ return function (editorView, nextPos) {
199
+ var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
200
+ if (!toolbar) {
201
+ return nextPos;
202
+ }
203
+
204
+ // Find and cache the container (only recalculates if editor DOM changed)
205
+ if (cachedEditorDom !== editorView.dom) {
206
+ cachedEditorDom = editorView.dom;
207
+ var _findContainingElemen = findContainingElement(editorView),
208
+ _container = _findContainingElemen.container,
209
+ isFixed = _findContainingElemen.isFixed;
210
+ cachedContainer = _container;
211
+ isFixedContainer = isFixed;
212
+ }
213
+ if (!cachedContainer) {
214
+ return nextPos;
215
+ }
216
+ var container = cachedContainer;
217
+ var containerBounds = container.getBoundingClientRect();
218
+ var selection = window && window.getSelection();
219
+ var moreRovoOptionsButton = document.querySelector('button[aria-label="More Rovo options"], [aria-label="More Rovo options"]');
220
+ var isMoreRovoOptionsButtonVisible = !!moreRovoOptionsButton && moreRovoOptionsButton instanceof HTMLElement && !!moreRovoOptionsButton.offsetParent;
221
+ var range = null;
222
+ if (isMoreRovoOptionsButtonVisible && (0, _platformFeatureFlags.fg)('platform_editor_ai_generic_prep_for_aifc')) {
223
+ if (selection && selection.getRangeAt && selection.rangeCount > 0) {
224
+ var maybeRange = selection.getRangeAt(0);
225
+ if (maybeRange instanceof Range) {
226
+ range = maybeRange;
227
+ }
228
+ }
229
+ } else {
230
+ if (selection && !selection.isCollapsed && selection.getRangeAt && selection.rangeCount > 0) {
231
+ var _maybeRange2 = selection.getRangeAt(0);
232
+ if (_maybeRange2 instanceof Range) {
233
+ range = _maybeRange2;
234
+ }
235
+ }
236
+ }
237
+ if (!range) {
238
+ return nextPos;
239
+ }
240
+ var toolbarRect = toolbar.getBoundingClientRect();
241
+ var _editorView$state$sel3 = editorView.state.selection,
242
+ head = _editorView$state$sel3.head,
243
+ anchor = _editorView$state$sel3.anchor;
244
+ var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
245
+ var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
246
+ var top;
247
+ // If not the same line AND we are selecting downwards, display toolbar below.
248
+ if (head > anchor && topCoords.top !== bottomCoords.top) {
249
+ // We are taking the previous pos to the maxium, so avoid end of line positions
250
+ // returning the next line's rect.
251
+ top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
252
+ } else {
253
+ top = (topCoords.top || 0) - toolbarRect.height * 1.5;
254
+ }
255
+ var left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
256
+
257
+ // Place toolbar below selection if not sufficient space above
258
+ if (top < containerBounds.top) {
259
+ var _getCoordsBelowSelect3 = getCoordsBelowSelection(bottomCoords, toolbarRect);
260
+ top = _getCoordsBelowSelect3.top;
261
+ left = _getCoordsBelowSelect3.left;
262
+ }
263
+ var leftCoord = Math.max(0, left - containerBounds.left);
264
+ if (leftCoord + toolbarRect.width > containerBounds.width) {
265
+ var _scrollbarWidth2 = MAXIMUM_BROWSER_SCROLLBAR_WIDTH;
266
+ leftCoord = Math.max(0, containerBounds.width - (toolbarRect.width + _scrollbarWidth2));
267
+ }
268
+
269
+ // Apply scroll offset only for non-fixed containers
270
+ // Fixed positioned elements don't scroll with the page
271
+ var scrollOffset = isFixedContainer ? 0 : container.scrollTop;
272
+ return {
273
+ top: top - containerBounds.top + scrollOffset,
274
+ left: leftCoord
275
+ };
276
+ };
277
+ };
278
+
279
+ /*
280
+ Calculates the position of the floating toolbar relative to the selection.
281
+ This implementation works in multiple scenarios:
282
+ - Standard scrollable containers with .fabric-editor-popup-scroll-parent
283
+ - Fixed positioned parent containers
284
+ - Falls back to document.body
285
+
286
+ The function automatically detects the container type and applies the appropriate
287
+ positioning logic and scroll offset handling.
288
+
289
+ Things to consider:
290
+ - stick as close to the head X release coordinates as possible
291
+ - coordinates of head X and getBoundingClientRect() are absolute in client viewport
292
+ - popup may appear in '.fabric-editor-popup-scroll-parent', fixed parent, or body
293
+ - we use the toolbarRect to center align toolbar
294
+ - use container bounds to clamp values
295
+ - for fixed positioning, no scroll offsets are applied
296
+ - for scrollable containers, scroll offsets are included
297
+ */
298
+ var calculateToolbarPositionTrackHead = exports.calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
299
+ var isSelToolbarFixEnabled = (0, _expValEquals.expValEquals)('platform_editor_sel_toolbar_fix', 'isEnabled', true);
300
+ return isSelToolbarFixEnabled ? calculateToolbarPositionTrackHeadNew(toolbarTitle) : calculateToolbarPositionTrackHeadOld(toolbarTitle);
301
+ };
302
+
170
303
  /**
171
304
  * Returns the coordintes at the bottom the selection.
172
305
  */
@@ -12,7 +12,7 @@ export const textColorMessages = defineMessages({
12
12
  },
13
13
  textColorHighlightTooltip: {
14
14
  id: 'fabric.editor.textColorHighlightTooltip',
15
- defaultMessage: 'Text and Highlight color',
15
+ defaultMessage: 'Text and highlight color',
16
16
  description: 'Tooltip of menu that provides access to various colors of highlight.'
17
17
  }
18
18
  });
@@ -4,7 +4,7 @@ import { isFedRamp } from './environment';
4
4
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
5
5
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
6
6
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
7
- const packageVersion = "111.7.2";
7
+ const packageVersion = "111.7.3";
8
8
  const sanitiseSentryEvents = (data, _hint) => {
9
9
  // Remove URL as it has UGC
10
10
  // Ignored via go/ees007
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "111.7.2";
17
+ const packageVersion = "111.7.3";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -1,6 +1,7 @@
1
1
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  const MAXIMUM_BROWSER_SCROLLBAR_WIDTH = 20;
5
6
 
6
7
  /*
@@ -79,19 +80,36 @@ export const calculateToolbarPositionAboveSelection = toolbarTitle => (editorVie
79
80
  left: Math.max(0, left - wrapperBounds.left)
80
81
  };
81
82
  };
82
- /*
83
- Calculates the position of the floating toolbar relative to the selection.
84
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
85
- The main difference is the popup is always above the selection.
86
- Things to consider:
87
- - stick as close to the head X release coordinates as possible
88
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
89
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
90
- - we use the toolbarRect to center align toolbar
91
- - use wrapperBounds to clamp values
92
- - editorView.dom bounds differ to wrapperBounds, convert at the end
93
- */
94
- export const calculateToolbarPositionTrackHead = toolbarTitle => (editorView, nextPos) => {
83
+ const findContainingElement = editorView => {
84
+ // First, try to find .fabric-editor-popup-scroll-parent
85
+ const scrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
86
+ if (scrollParent) {
87
+ return {
88
+ container: scrollParent,
89
+ isFixed: false
90
+ };
91
+ } else {
92
+ // If no scroll parent, look for a fixed positioned parent
93
+ let fixedParent = editorView.dom.parentElement;
94
+ while (fixedParent && fixedParent !== document.body) {
95
+ const computedStyle = window.getComputedStyle(fixedParent);
96
+ if (computedStyle.position === 'fixed') {
97
+ return {
98
+ container: fixedParent,
99
+ isFixed: true
100
+ };
101
+ }
102
+ fixedParent = fixedParent.parentElement;
103
+ }
104
+ }
105
+
106
+ // Fall back to document.body if no fixed parent found
107
+ return {
108
+ container: document.body,
109
+ isFixed: false
110
+ };
111
+ };
112
+ export const calculateToolbarPositionTrackHeadOld = toolbarTitle => (editorView, nextPos) => {
95
113
  const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
96
114
  if (!toolbar) {
97
115
  return nextPos;
@@ -161,6 +179,124 @@ export const calculateToolbarPositionTrackHead = toolbarTitle => (editorView, ne
161
179
  };
162
180
  };
163
181
 
182
+ /**
183
+ * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
184
+ * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
185
+ * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
186
+ */
187
+ export const calculateToolbarPositionTrackHeadNew = toolbarTitle => {
188
+ // Cache the container to avoid repeated DOM traversal and getComputedStyle calls
189
+ let cachedContainer = null;
190
+ let isFixedContainer = false;
191
+ let cachedEditorDom = null;
192
+ return (editorView, nextPos) => {
193
+ const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
194
+ if (!toolbar) {
195
+ return nextPos;
196
+ }
197
+
198
+ // Find and cache the container (only recalculates if editor DOM changed)
199
+ if (cachedEditorDom !== editorView.dom) {
200
+ cachedEditorDom = editorView.dom;
201
+ const {
202
+ container,
203
+ isFixed
204
+ } = findContainingElement(editorView);
205
+ cachedContainer = container;
206
+ isFixedContainer = isFixed;
207
+ }
208
+ if (!cachedContainer) {
209
+ return nextPos;
210
+ }
211
+ const container = cachedContainer;
212
+ const containerBounds = container.getBoundingClientRect();
213
+ const selection = window && window.getSelection();
214
+ const moreRovoOptionsButton = document.querySelector('button[aria-label="More Rovo options"], [aria-label="More Rovo options"]');
215
+ const isMoreRovoOptionsButtonVisible = !!moreRovoOptionsButton && moreRovoOptionsButton instanceof HTMLElement && !!moreRovoOptionsButton.offsetParent;
216
+ let range = null;
217
+ if (isMoreRovoOptionsButtonVisible && fg('platform_editor_ai_generic_prep_for_aifc')) {
218
+ if (selection && selection.getRangeAt && selection.rangeCount > 0) {
219
+ const maybeRange = selection.getRangeAt(0);
220
+ if (maybeRange instanceof Range) {
221
+ range = maybeRange;
222
+ }
223
+ }
224
+ } else {
225
+ if (selection && !selection.isCollapsed && selection.getRangeAt && selection.rangeCount > 0) {
226
+ const maybeRange = selection.getRangeAt(0);
227
+ if (maybeRange instanceof Range) {
228
+ range = maybeRange;
229
+ }
230
+ }
231
+ }
232
+ if (!range) {
233
+ return nextPos;
234
+ }
235
+ const toolbarRect = toolbar.getBoundingClientRect();
236
+ const {
237
+ head,
238
+ anchor
239
+ } = editorView.state.selection;
240
+ const topCoords = editorView.coordsAtPos(Math.min(head, anchor));
241
+ const bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
242
+ let top;
243
+ // If not the same line AND we are selecting downwards, display toolbar below.
244
+ if (head > anchor && topCoords.top !== bottomCoords.top) {
245
+ // We are taking the previous pos to the maxium, so avoid end of line positions
246
+ // returning the next line's rect.
247
+ top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
248
+ } else {
249
+ top = (topCoords.top || 0) - toolbarRect.height * 1.5;
250
+ }
251
+ let left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
252
+
253
+ // Place toolbar below selection if not sufficient space above
254
+ if (top < containerBounds.top) {
255
+ ({
256
+ top,
257
+ left
258
+ } = getCoordsBelowSelection(bottomCoords, toolbarRect));
259
+ }
260
+ let leftCoord = Math.max(0, left - containerBounds.left);
261
+ if (leftCoord + toolbarRect.width > containerBounds.width) {
262
+ const scrollbarWidth = MAXIMUM_BROWSER_SCROLLBAR_WIDTH;
263
+ leftCoord = Math.max(0, containerBounds.width - (toolbarRect.width + scrollbarWidth));
264
+ }
265
+
266
+ // Apply scroll offset only for non-fixed containers
267
+ // Fixed positioned elements don't scroll with the page
268
+ const scrollOffset = isFixedContainer ? 0 : container.scrollTop;
269
+ return {
270
+ top: top - containerBounds.top + scrollOffset,
271
+ left: leftCoord
272
+ };
273
+ };
274
+ };
275
+
276
+ /*
277
+ Calculates the position of the floating toolbar relative to the selection.
278
+ This implementation works in multiple scenarios:
279
+ - Standard scrollable containers with .fabric-editor-popup-scroll-parent
280
+ - Fixed positioned parent containers
281
+ - Falls back to document.body
282
+
283
+ The function automatically detects the container type and applies the appropriate
284
+ positioning logic and scroll offset handling.
285
+
286
+ Things to consider:
287
+ - stick as close to the head X release coordinates as possible
288
+ - coordinates of head X and getBoundingClientRect() are absolute in client viewport
289
+ - popup may appear in '.fabric-editor-popup-scroll-parent', fixed parent, or body
290
+ - we use the toolbarRect to center align toolbar
291
+ - use container bounds to clamp values
292
+ - for fixed positioning, no scroll offsets are applied
293
+ - for scrollable containers, scroll offsets are included
294
+ */
295
+ export const calculateToolbarPositionTrackHead = toolbarTitle => {
296
+ const isSelToolbarFixEnabled = expValEquals('platform_editor_sel_toolbar_fix', 'isEnabled', true);
297
+ return isSelToolbarFixEnabled ? calculateToolbarPositionTrackHeadNew(toolbarTitle) : calculateToolbarPositionTrackHeadOld(toolbarTitle);
298
+ };
299
+
164
300
  /**
165
301
  * Returns the coordintes at the bottom the selection.
166
302
  */
@@ -12,7 +12,7 @@ export var textColorMessages = defineMessages({
12
12
  },
13
13
  textColorHighlightTooltip: {
14
14
  id: 'fabric.editor.textColorHighlightTooltip',
15
- defaultMessage: 'Text and Highlight color',
15
+ defaultMessage: 'Text and highlight color',
16
16
  description: 'Tooltip of menu that provides access to various colors of highlight.'
17
17
  }
18
18
  });
@@ -10,7 +10,7 @@ import { isFedRamp } from './environment';
10
10
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
11
11
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
12
12
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
13
- var packageVersion = "111.7.2";
13
+ var packageVersion = "111.7.3";
14
14
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
15
15
  // Remove URL as it has UGC
16
16
  // Ignored via go/ees007
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "111.7.2";
24
+ var packageVersion = "111.7.3";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -1,6 +1,7 @@
1
1
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
3
  import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  var MAXIMUM_BROWSER_SCROLLBAR_WIDTH = 20;
5
6
 
6
7
  /*
@@ -79,19 +80,36 @@ export var calculateToolbarPositionAboveSelection = function calculateToolbarPos
79
80
  };
80
81
  };
81
82
  };
82
- /*
83
- Calculates the position of the floating toolbar relative to the selection.
84
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
85
- The main difference is the popup is always above the selection.
86
- Things to consider:
87
- - stick as close to the head X release coordinates as possible
88
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
89
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
90
- - we use the toolbarRect to center align toolbar
91
- - use wrapperBounds to clamp values
92
- - editorView.dom bounds differ to wrapperBounds, convert at the end
93
- */
94
- export var calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
83
+ var findContainingElement = function findContainingElement(editorView) {
84
+ // First, try to find .fabric-editor-popup-scroll-parent
85
+ var scrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
86
+ if (scrollParent) {
87
+ return {
88
+ container: scrollParent,
89
+ isFixed: false
90
+ };
91
+ } else {
92
+ // If no scroll parent, look for a fixed positioned parent
93
+ var fixedParent = editorView.dom.parentElement;
94
+ while (fixedParent && fixedParent !== document.body) {
95
+ var computedStyle = window.getComputedStyle(fixedParent);
96
+ if (computedStyle.position === 'fixed') {
97
+ return {
98
+ container: fixedParent,
99
+ isFixed: true
100
+ };
101
+ }
102
+ fixedParent = fixedParent.parentElement;
103
+ }
104
+ }
105
+
106
+ // Fall back to document.body if no fixed parent found
107
+ return {
108
+ container: document.body,
109
+ isFixed: false
110
+ };
111
+ };
112
+ export var calculateToolbarPositionTrackHeadOld = function calculateToolbarPositionTrackHeadOld(toolbarTitle) {
95
113
  return function (editorView, nextPos) {
96
114
  var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
97
115
  if (!toolbar) {
@@ -161,6 +179,121 @@ export var calculateToolbarPositionTrackHead = function calculateToolbarPosition
161
179
  };
162
180
  };
163
181
 
182
+ /**
183
+ * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
184
+ * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
185
+ * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
186
+ */
187
+ export var calculateToolbarPositionTrackHeadNew = function calculateToolbarPositionTrackHeadNew(toolbarTitle) {
188
+ // Cache the container to avoid repeated DOM traversal and getComputedStyle calls
189
+ var cachedContainer = null;
190
+ var isFixedContainer = false;
191
+ var cachedEditorDom = null;
192
+ return function (editorView, nextPos) {
193
+ var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
194
+ if (!toolbar) {
195
+ return nextPos;
196
+ }
197
+
198
+ // Find and cache the container (only recalculates if editor DOM changed)
199
+ if (cachedEditorDom !== editorView.dom) {
200
+ cachedEditorDom = editorView.dom;
201
+ var _findContainingElemen = findContainingElement(editorView),
202
+ _container = _findContainingElemen.container,
203
+ isFixed = _findContainingElemen.isFixed;
204
+ cachedContainer = _container;
205
+ isFixedContainer = isFixed;
206
+ }
207
+ if (!cachedContainer) {
208
+ return nextPos;
209
+ }
210
+ var container = cachedContainer;
211
+ var containerBounds = container.getBoundingClientRect();
212
+ var selection = window && window.getSelection();
213
+ var moreRovoOptionsButton = document.querySelector('button[aria-label="More Rovo options"], [aria-label="More Rovo options"]');
214
+ var isMoreRovoOptionsButtonVisible = !!moreRovoOptionsButton && moreRovoOptionsButton instanceof HTMLElement && !!moreRovoOptionsButton.offsetParent;
215
+ var range = null;
216
+ if (isMoreRovoOptionsButtonVisible && fg('platform_editor_ai_generic_prep_for_aifc')) {
217
+ if (selection && selection.getRangeAt && selection.rangeCount > 0) {
218
+ var maybeRange = selection.getRangeAt(0);
219
+ if (maybeRange instanceof Range) {
220
+ range = maybeRange;
221
+ }
222
+ }
223
+ } else {
224
+ if (selection && !selection.isCollapsed && selection.getRangeAt && selection.rangeCount > 0) {
225
+ var _maybeRange2 = selection.getRangeAt(0);
226
+ if (_maybeRange2 instanceof Range) {
227
+ range = _maybeRange2;
228
+ }
229
+ }
230
+ }
231
+ if (!range) {
232
+ return nextPos;
233
+ }
234
+ var toolbarRect = toolbar.getBoundingClientRect();
235
+ var _editorView$state$sel3 = editorView.state.selection,
236
+ head = _editorView$state$sel3.head,
237
+ anchor = _editorView$state$sel3.anchor;
238
+ var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
239
+ var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
240
+ var top;
241
+ // If not the same line AND we are selecting downwards, display toolbar below.
242
+ if (head > anchor && topCoords.top !== bottomCoords.top) {
243
+ // We are taking the previous pos to the maxium, so avoid end of line positions
244
+ // returning the next line's rect.
245
+ top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
246
+ } else {
247
+ top = (topCoords.top || 0) - toolbarRect.height * 1.5;
248
+ }
249
+ var left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
250
+
251
+ // Place toolbar below selection if not sufficient space above
252
+ if (top < containerBounds.top) {
253
+ var _getCoordsBelowSelect3 = getCoordsBelowSelection(bottomCoords, toolbarRect);
254
+ top = _getCoordsBelowSelect3.top;
255
+ left = _getCoordsBelowSelect3.left;
256
+ }
257
+ var leftCoord = Math.max(0, left - containerBounds.left);
258
+ if (leftCoord + toolbarRect.width > containerBounds.width) {
259
+ var _scrollbarWidth2 = MAXIMUM_BROWSER_SCROLLBAR_WIDTH;
260
+ leftCoord = Math.max(0, containerBounds.width - (toolbarRect.width + _scrollbarWidth2));
261
+ }
262
+
263
+ // Apply scroll offset only for non-fixed containers
264
+ // Fixed positioned elements don't scroll with the page
265
+ var scrollOffset = isFixedContainer ? 0 : container.scrollTop;
266
+ return {
267
+ top: top - containerBounds.top + scrollOffset,
268
+ left: leftCoord
269
+ };
270
+ };
271
+ };
272
+
273
+ /*
274
+ Calculates the position of the floating toolbar relative to the selection.
275
+ This implementation works in multiple scenarios:
276
+ - Standard scrollable containers with .fabric-editor-popup-scroll-parent
277
+ - Fixed positioned parent containers
278
+ - Falls back to document.body
279
+
280
+ The function automatically detects the container type and applies the appropriate
281
+ positioning logic and scroll offset handling.
282
+
283
+ Things to consider:
284
+ - stick as close to the head X release coordinates as possible
285
+ - coordinates of head X and getBoundingClientRect() are absolute in client viewport
286
+ - popup may appear in '.fabric-editor-popup-scroll-parent', fixed parent, or body
287
+ - we use the toolbarRect to center align toolbar
288
+ - use container bounds to clamp values
289
+ - for fixed positioning, no scroll offsets are applied
290
+ - for scrollable containers, scroll offsets are included
291
+ */
292
+ export var calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
293
+ var isSelToolbarFixEnabled = expValEquals('platform_editor_sel_toolbar_fix', 'isEnabled', true);
294
+ return isSelToolbarFixEnabled ? calculateToolbarPositionTrackHeadNew(toolbarTitle) : calculateToolbarPositionTrackHeadOld(toolbarTitle);
295
+ };
296
+
164
297
  /**
165
298
  * Returns the coordintes at the bottom the selection.
166
299
  */
@@ -1,6 +1,13 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  import type { PopupPosition as Position } from '../ui';
3
3
  export declare const calculateToolbarPositionAboveSelection: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
4
+ export declare const calculateToolbarPositionTrackHeadOld: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
5
+ /**
6
+ * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
7
+ * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
8
+ * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
9
+ */
10
+ export declare const calculateToolbarPositionTrackHeadNew: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
4
11
  export declare const calculateToolbarPositionTrackHead: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
5
12
  export type CoordsAtPos = {
6
13
  bottom: number;
@@ -1,6 +1,13 @@
1
1
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  import type { PopupPosition as Position } from '../ui';
3
3
  export declare const calculateToolbarPositionAboveSelection: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
4
+ export declare const calculateToolbarPositionTrackHeadOld: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
5
+ /**
6
+ * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
7
+ * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
8
+ * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
9
+ */
10
+ export declare const calculateToolbarPositionTrackHeadNew: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
4
11
  export declare const calculateToolbarPositionTrackHead: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
5
12
  export type CoordsAtPos = {
6
13
  bottom: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "111.7.3",
3
+ "version": "111.7.4",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -70,7 +70,7 @@
70
70
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
71
71
  "@atlaskit/popper": "^7.1.0",
72
72
  "@atlaskit/primitives": "^17.0.0",
73
- "@atlaskit/profilecard": "^24.29.0",
73
+ "@atlaskit/profilecard": "^24.30.0",
74
74
  "@atlaskit/prosemirror-history": "^0.2.0",
75
75
  "@atlaskit/react-ufo": "^4.17.0",
76
76
  "@atlaskit/section-message": "^8.12.0",
@@ -81,9 +81,9 @@
81
81
  "@atlaskit/task-decision": "^19.2.0",
82
82
  "@atlaskit/textfield": "^8.2.0",
83
83
  "@atlaskit/theme": "^21.0.0",
84
- "@atlaskit/tmp-editor-statsig": "^16.15.0",
84
+ "@atlaskit/tmp-editor-statsig": "^16.18.0",
85
85
  "@atlaskit/tokens": "^9.1.0",
86
- "@atlaskit/tooltip": "^20.13.0",
86
+ "@atlaskit/tooltip": "^20.14.0",
87
87
  "@atlaskit/width-detector": "^5.0.0",
88
88
  "@babel/runtime": "^7.0.0",
89
89
  "@compiled/react": "^0.18.6",