@atlaskit/editor-common 112.4.3 → 112.4.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,14 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 112.4.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b6830be30e686`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b6830be30e686) -
8
+ Cleaned up selection toolbar positioning code behind platform_editor_sel_toolbar_fix and
9
+ platform_editor_sel_toolbar_scroll_pos_fix_exp experiments
10
+ - Updated dependencies
11
+
3
12
  ## 112.4.3
4
13
 
5
14
  ### Patch Changes
@@ -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 = "112.4.2";
22
+ var packageVersion = "112.4.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 = "112.4.2";
27
+ var packageVersion = "112.4.3";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -3,10 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.calculateToolbarPositionTrackHeadOld = exports.calculateToolbarPositionTrackHeadNew = exports.calculateToolbarPositionTrackHead = exports.calculateToolbarPositionOnCellSelection = exports.calculateToolbarPositionAboveSelection = void 0;
6
+ 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
- var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
9
  var MAXIMUM_BROWSER_SCROLLBAR_WIDTH = 20;
11
10
 
12
11
  /*
@@ -85,82 +84,7 @@ var calculateToolbarPositionAboveSelection = exports.calculateToolbarPositionAbo
85
84
  };
86
85
  };
87
86
  };
88
- var findContainingElement = function findContainingElement(editorView) {
89
- if ((0, _expValEquals.expValEquals)('platform_editor_sel_toolbar_scroll_pos_fix_exp', 'isEnabled', true)) {
90
- // Traverse DOM Tree upwards looking for scroll parents with "overflow: scroll"
91
- // or fixed/absolute positioned containers.
92
- var parent = editorView.dom;
93
-
94
- // Ignored via go/ees005
95
- // eslint-disable-next-line no-cond-assign
96
- while (parent = parent.parentElement) {
97
- var style = window.getComputedStyle(parent);
98
-
99
- // Check for explicit scroll parent class
100
- if (parent.classList.contains('fabric-editor-popup-scroll-parent')) {
101
- return {
102
- container: parent,
103
- isFixed: false
104
- };
105
- }
106
-
107
- // Check for overflow scroll containers
108
- if (style.overflow === 'scroll' || style.overflowX === 'scroll' || style.overflowY === 'scroll' || style.overflow === 'auto' || style.overflowX === 'auto' || style.overflowY === 'auto') {
109
- return {
110
- container: parent,
111
- isFixed: false
112
- };
113
- }
114
-
115
- // Check for fixed or absolute positioned containers (modal wrappers, sidebars)
116
- if (style.position === 'fixed' || style.position === 'absolute') {
117
- return {
118
- container: parent,
119
- isFixed: style.position === 'fixed'
120
- };
121
- }
122
-
123
- // Stop at body
124
- if (parent === document.body) {
125
- break;
126
- }
127
- }
128
-
129
- // Fall back to document.body if no suitable container found
130
- return {
131
- container: document.body,
132
- isFixed: false
133
- };
134
- }
135
-
136
- // Original logic
137
- var scrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
138
- if (scrollParent) {
139
- return {
140
- container: scrollParent,
141
- isFixed: false
142
- };
143
- } else {
144
- var fixedParent = editorView.dom.parentElement;
145
- while (fixedParent && fixedParent !== document.body) {
146
- var computedStyle = window.getComputedStyle(fixedParent);
147
- if (computedStyle.position === 'fixed') {
148
- return {
149
- container: fixedParent,
150
- isFixed: true
151
- };
152
- }
153
- fixedParent = fixedParent.parentElement;
154
- }
155
- }
156
-
157
- // Fall back to document.body if no fixed parent found
158
- return {
159
- container: document.body,
160
- isFixed: false
161
- };
162
- };
163
- var calculateToolbarPositionTrackHeadOld = exports.calculateToolbarPositionTrackHeadOld = function calculateToolbarPositionTrackHeadOld(toolbarTitle) {
87
+ var calculateToolbarPositionTrackHead = exports.calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
164
88
  return function (editorView, nextPos) {
165
89
  var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
166
90
  if (!toolbar) {
@@ -230,122 +154,6 @@ var calculateToolbarPositionTrackHeadOld = exports.calculateToolbarPositionTrack
230
154
  };
231
155
  };
232
156
 
233
- /**
234
- * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
235
- * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
236
- * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
237
- */
238
- var calculateToolbarPositionTrackHeadNew = exports.calculateToolbarPositionTrackHeadNew = function calculateToolbarPositionTrackHeadNew(toolbarTitle) {
239
- // Cache the container to avoid repeated DOM traversal and getComputedStyle calls
240
- var cachedContainer = null;
241
- var isFixedContainer = false;
242
- var cachedEditorDom = null;
243
- return function (editorView, nextPos) {
244
- var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
245
- if (!toolbar) {
246
- return nextPos;
247
- }
248
-
249
- // Find and cache the container (only recalculates if editor DOM changed)
250
- if (cachedEditorDom !== editorView.dom) {
251
- cachedEditorDom = editorView.dom;
252
- var _findContainingElemen = findContainingElement(editorView),
253
- _container = _findContainingElemen.container,
254
- isFixed = _findContainingElemen.isFixed;
255
- cachedContainer = _container;
256
- isFixedContainer = isFixed;
257
- }
258
- if (!cachedContainer) {
259
- return nextPos;
260
- }
261
- var container = cachedContainer;
262
- var containerBounds = container.getBoundingClientRect();
263
- var selection = window && window.getSelection();
264
- var moreRovoOptionsButton = document.querySelector('button[aria-label="More Rovo options"], [aria-label="More Rovo options"]');
265
- var isMoreRovoOptionsButtonVisible = !!moreRovoOptionsButton && moreRovoOptionsButton instanceof HTMLElement && !!moreRovoOptionsButton.offsetParent;
266
- var range = null;
267
- if (isMoreRovoOptionsButtonVisible) {
268
- if (selection && selection.getRangeAt && selection.rangeCount > 0) {
269
- var maybeRange = selection.getRangeAt(0);
270
- if (maybeRange instanceof Range) {
271
- range = maybeRange;
272
- }
273
- }
274
- } else {
275
- if (selection && !selection.isCollapsed && selection.getRangeAt && selection.rangeCount > 0) {
276
- var _maybeRange2 = selection.getRangeAt(0);
277
- if (_maybeRange2 instanceof Range) {
278
- range = _maybeRange2;
279
- }
280
- }
281
- }
282
- if (!range) {
283
- return nextPos;
284
- }
285
- var toolbarRect = toolbar.getBoundingClientRect();
286
- var _editorView$state$sel3 = editorView.state.selection,
287
- head = _editorView$state$sel3.head,
288
- anchor = _editorView$state$sel3.anchor;
289
- var top;
290
- var left;
291
- var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
292
- var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
293
- // If not the same line AND we are selecting downwards, display toolbar below.
294
- if (head > anchor && topCoords.top !== bottomCoords.top) {
295
- // We are taking the previous pos to the maxium, so avoid end of line positions
296
- // returning the next line's rect.
297
- top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
298
- } else {
299
- top = (topCoords.top || 0) - toolbarRect.height * 1.5;
300
- }
301
- left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
302
-
303
- // Place toolbar below selection if not sufficient space above
304
- if (top < containerBounds.top) {
305
- var _getCoordsBelowSelect3 = getCoordsBelowSelection(bottomCoords, toolbarRect);
306
- top = _getCoordsBelowSelect3.top;
307
- left = _getCoordsBelowSelect3.left;
308
- }
309
- var leftCoord = Math.max(0, left - containerBounds.left);
310
- if (leftCoord + toolbarRect.width > containerBounds.width) {
311
- var _scrollbarWidth2 = MAXIMUM_BROWSER_SCROLLBAR_WIDTH;
312
- leftCoord = Math.max(0, containerBounds.width - (toolbarRect.width + _scrollbarWidth2));
313
- }
314
-
315
- // Apply scroll offset only for non-fixed containers
316
- // Fixed positioned elements don't scroll with the page
317
- var scrollOffset = isFixedContainer ? 0 : container.scrollTop;
318
- return {
319
- top: top - containerBounds.top + scrollOffset,
320
- left: leftCoord
321
- };
322
- };
323
- };
324
-
325
- /*
326
- Calculates the position of the floating toolbar relative to the selection.
327
- This implementation works in multiple scenarios:
328
- - Standard scrollable containers with .fabric-editor-popup-scroll-parent
329
- - Fixed positioned parent containers
330
- - Falls back to document.body
331
-
332
- The function automatically detects the container type and applies the appropriate
333
- positioning logic and scroll offset handling.
334
-
335
- Things to consider:
336
- - stick as close to the head X release coordinates as possible
337
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport
338
- - popup may appear in '.fabric-editor-popup-scroll-parent', fixed parent, or body
339
- - we use the toolbarRect to center align toolbar
340
- - use container bounds to clamp values
341
- - for fixed positioning, no scroll offsets are applied
342
- - for scrollable containers, scroll offsets are included
343
- */
344
- var calculateToolbarPositionTrackHead = exports.calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
345
- var isSelToolbarFixEnabled = (0, _expValEquals.expValEquals)('platform_editor_sel_toolbar_fix', 'isEnabled', true);
346
- return isSelToolbarFixEnabled ? calculateToolbarPositionTrackHeadNew(toolbarTitle) : calculateToolbarPositionTrackHeadOld(toolbarTitle);
347
- };
348
-
349
157
  /**
350
158
  * Returns the coordintes at the bottom the selection.
351
159
  */
@@ -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 = "112.4.2";
7
+ const packageVersion = "112.4.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 = "112.4.2";
17
+ const packageVersion = "112.4.3";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -1,6 +1,5 @@
1
1
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
3
  const MAXIMUM_BROWSER_SCROLLBAR_WIDTH = 20;
5
4
 
6
5
  /*
@@ -79,82 +78,7 @@ export const calculateToolbarPositionAboveSelection = toolbarTitle => (editorVie
79
78
  left: Math.max(0, left - wrapperBounds.left)
80
79
  };
81
80
  };
82
- const findContainingElement = editorView => {
83
- if (expValEquals('platform_editor_sel_toolbar_scroll_pos_fix_exp', 'isEnabled', true)) {
84
- // Traverse DOM Tree upwards looking for scroll parents with "overflow: scroll"
85
- // or fixed/absolute positioned containers.
86
- let parent = editorView.dom;
87
-
88
- // Ignored via go/ees005
89
- // eslint-disable-next-line no-cond-assign
90
- while (parent = parent.parentElement) {
91
- const style = window.getComputedStyle(parent);
92
-
93
- // Check for explicit scroll parent class
94
- if (parent.classList.contains('fabric-editor-popup-scroll-parent')) {
95
- return {
96
- container: parent,
97
- isFixed: false
98
- };
99
- }
100
-
101
- // Check for overflow scroll containers
102
- if (style.overflow === 'scroll' || style.overflowX === 'scroll' || style.overflowY === 'scroll' || style.overflow === 'auto' || style.overflowX === 'auto' || style.overflowY === 'auto') {
103
- return {
104
- container: parent,
105
- isFixed: false
106
- };
107
- }
108
-
109
- // Check for fixed or absolute positioned containers (modal wrappers, sidebars)
110
- if (style.position === 'fixed' || style.position === 'absolute') {
111
- return {
112
- container: parent,
113
- isFixed: style.position === 'fixed'
114
- };
115
- }
116
-
117
- // Stop at body
118
- if (parent === document.body) {
119
- break;
120
- }
121
- }
122
-
123
- // Fall back to document.body if no suitable container found
124
- return {
125
- container: document.body,
126
- isFixed: false
127
- };
128
- }
129
-
130
- // Original logic
131
- const scrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
132
- if (scrollParent) {
133
- return {
134
- container: scrollParent,
135
- isFixed: false
136
- };
137
- } else {
138
- let fixedParent = editorView.dom.parentElement;
139
- while (fixedParent && fixedParent !== document.body) {
140
- const computedStyle = window.getComputedStyle(fixedParent);
141
- if (computedStyle.position === 'fixed') {
142
- return {
143
- container: fixedParent,
144
- isFixed: true
145
- };
146
- }
147
- fixedParent = fixedParent.parentElement;
148
- }
149
- }
150
-
151
- // Fall back to document.body if no fixed parent found
152
- return {
153
- container: document.body,
154
- isFixed: false
155
- };
156
- };
157
- export const calculateToolbarPositionTrackHeadOld = toolbarTitle => (editorView, nextPos) => {
81
+ export const calculateToolbarPositionTrackHead = toolbarTitle => (editorView, nextPos) => {
158
82
  const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
159
83
  if (!toolbar) {
160
84
  return nextPos;
@@ -224,125 +148,6 @@ export const calculateToolbarPositionTrackHeadOld = toolbarTitle => (editorView,
224
148
  };
225
149
  };
226
150
 
227
- /**
228
- * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
229
- * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
230
- * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
231
- */
232
- export const calculateToolbarPositionTrackHeadNew = toolbarTitle => {
233
- // Cache the container to avoid repeated DOM traversal and getComputedStyle calls
234
- let cachedContainer = null;
235
- let isFixedContainer = false;
236
- let cachedEditorDom = null;
237
- return (editorView, nextPos) => {
238
- const toolbar = document.querySelector(`div[aria-label="${toolbarTitle}"]`);
239
- if (!toolbar) {
240
- return nextPos;
241
- }
242
-
243
- // Find and cache the container (only recalculates if editor DOM changed)
244
- if (cachedEditorDom !== editorView.dom) {
245
- cachedEditorDom = editorView.dom;
246
- const {
247
- container,
248
- isFixed
249
- } = findContainingElement(editorView);
250
- cachedContainer = container;
251
- isFixedContainer = isFixed;
252
- }
253
- if (!cachedContainer) {
254
- return nextPos;
255
- }
256
- const container = cachedContainer;
257
- const containerBounds = container.getBoundingClientRect();
258
- const selection = window && window.getSelection();
259
- const moreRovoOptionsButton = document.querySelector('button[aria-label="More Rovo options"], [aria-label="More Rovo options"]');
260
- const isMoreRovoOptionsButtonVisible = !!moreRovoOptionsButton && moreRovoOptionsButton instanceof HTMLElement && !!moreRovoOptionsButton.offsetParent;
261
- let range = null;
262
- if (isMoreRovoOptionsButtonVisible) {
263
- if (selection && selection.getRangeAt && selection.rangeCount > 0) {
264
- const maybeRange = selection.getRangeAt(0);
265
- if (maybeRange instanceof Range) {
266
- range = maybeRange;
267
- }
268
- }
269
- } else {
270
- if (selection && !selection.isCollapsed && selection.getRangeAt && selection.rangeCount > 0) {
271
- const maybeRange = selection.getRangeAt(0);
272
- if (maybeRange instanceof Range) {
273
- range = maybeRange;
274
- }
275
- }
276
- }
277
- if (!range) {
278
- return nextPos;
279
- }
280
- const toolbarRect = toolbar.getBoundingClientRect();
281
- const {
282
- head,
283
- anchor
284
- } = editorView.state.selection;
285
- let top;
286
- let left;
287
- const topCoords = editorView.coordsAtPos(Math.min(head, anchor));
288
- const bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
289
- // If not the same line AND we are selecting downwards, display toolbar below.
290
- if (head > anchor && topCoords.top !== bottomCoords.top) {
291
- // We are taking the previous pos to the maxium, so avoid end of line positions
292
- // returning the next line's rect.
293
- top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
294
- } else {
295
- top = (topCoords.top || 0) - toolbarRect.height * 1.5;
296
- }
297
- left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
298
-
299
- // Place toolbar below selection if not sufficient space above
300
- if (top < containerBounds.top) {
301
- ({
302
- top,
303
- left
304
- } = getCoordsBelowSelection(bottomCoords, toolbarRect));
305
- }
306
- let leftCoord = Math.max(0, left - containerBounds.left);
307
- if (leftCoord + toolbarRect.width > containerBounds.width) {
308
- const scrollbarWidth = MAXIMUM_BROWSER_SCROLLBAR_WIDTH;
309
- leftCoord = Math.max(0, containerBounds.width - (toolbarRect.width + scrollbarWidth));
310
- }
311
-
312
- // Apply scroll offset only for non-fixed containers
313
- // Fixed positioned elements don't scroll with the page
314
- const scrollOffset = isFixedContainer ? 0 : container.scrollTop;
315
- return {
316
- top: top - containerBounds.top + scrollOffset,
317
- left: leftCoord
318
- };
319
- };
320
- };
321
-
322
- /*
323
- Calculates the position of the floating toolbar relative to the selection.
324
- This implementation works in multiple scenarios:
325
- - Standard scrollable containers with .fabric-editor-popup-scroll-parent
326
- - Fixed positioned parent containers
327
- - Falls back to document.body
328
-
329
- The function automatically detects the container type and applies the appropriate
330
- positioning logic and scroll offset handling.
331
-
332
- Things to consider:
333
- - stick as close to the head X release coordinates as possible
334
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport
335
- - popup may appear in '.fabric-editor-popup-scroll-parent', fixed parent, or body
336
- - we use the toolbarRect to center align toolbar
337
- - use container bounds to clamp values
338
- - for fixed positioning, no scroll offsets are applied
339
- - for scrollable containers, scroll offsets are included
340
- */
341
- export const calculateToolbarPositionTrackHead = toolbarTitle => {
342
- const isSelToolbarFixEnabled = expValEquals('platform_editor_sel_toolbar_fix', 'isEnabled', true);
343
- return isSelToolbarFixEnabled ? calculateToolbarPositionTrackHeadNew(toolbarTitle) : calculateToolbarPositionTrackHeadOld(toolbarTitle);
344
- };
345
-
346
151
  /**
347
152
  * Returns the coordintes at the bottom the selection.
348
153
  */
@@ -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 = "112.4.2";
13
+ var packageVersion = "112.4.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 = "112.4.2";
24
+ var packageVersion = "112.4.3";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -1,6 +1,5 @@
1
1
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
2
2
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
3
- import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
3
  var MAXIMUM_BROWSER_SCROLLBAR_WIDTH = 20;
5
4
 
6
5
  /*
@@ -79,82 +78,7 @@ export var calculateToolbarPositionAboveSelection = function calculateToolbarPos
79
78
  };
80
79
  };
81
80
  };
82
- var findContainingElement = function findContainingElement(editorView) {
83
- if (expValEquals('platform_editor_sel_toolbar_scroll_pos_fix_exp', 'isEnabled', true)) {
84
- // Traverse DOM Tree upwards looking for scroll parents with "overflow: scroll"
85
- // or fixed/absolute positioned containers.
86
- var parent = editorView.dom;
87
-
88
- // Ignored via go/ees005
89
- // eslint-disable-next-line no-cond-assign
90
- while (parent = parent.parentElement) {
91
- var style = window.getComputedStyle(parent);
92
-
93
- // Check for explicit scroll parent class
94
- if (parent.classList.contains('fabric-editor-popup-scroll-parent')) {
95
- return {
96
- container: parent,
97
- isFixed: false
98
- };
99
- }
100
-
101
- // Check for overflow scroll containers
102
- if (style.overflow === 'scroll' || style.overflowX === 'scroll' || style.overflowY === 'scroll' || style.overflow === 'auto' || style.overflowX === 'auto' || style.overflowY === 'auto') {
103
- return {
104
- container: parent,
105
- isFixed: false
106
- };
107
- }
108
-
109
- // Check for fixed or absolute positioned containers (modal wrappers, sidebars)
110
- if (style.position === 'fixed' || style.position === 'absolute') {
111
- return {
112
- container: parent,
113
- isFixed: style.position === 'fixed'
114
- };
115
- }
116
-
117
- // Stop at body
118
- if (parent === document.body) {
119
- break;
120
- }
121
- }
122
-
123
- // Fall back to document.body if no suitable container found
124
- return {
125
- container: document.body,
126
- isFixed: false
127
- };
128
- }
129
-
130
- // Original logic
131
- var scrollParent = editorView.dom.closest('.fabric-editor-popup-scroll-parent');
132
- if (scrollParent) {
133
- return {
134
- container: scrollParent,
135
- isFixed: false
136
- };
137
- } else {
138
- var fixedParent = editorView.dom.parentElement;
139
- while (fixedParent && fixedParent !== document.body) {
140
- var computedStyle = window.getComputedStyle(fixedParent);
141
- if (computedStyle.position === 'fixed') {
142
- return {
143
- container: fixedParent,
144
- isFixed: true
145
- };
146
- }
147
- fixedParent = fixedParent.parentElement;
148
- }
149
- }
150
-
151
- // Fall back to document.body if no fixed parent found
152
- return {
153
- container: document.body,
154
- isFixed: false
155
- };
156
- };
157
- export var calculateToolbarPositionTrackHeadOld = function calculateToolbarPositionTrackHeadOld(toolbarTitle) {
81
+ export var calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
158
82
  return function (editorView, nextPos) {
159
83
  var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
160
84
  if (!toolbar) {
@@ -224,122 +148,6 @@ export var calculateToolbarPositionTrackHeadOld = function calculateToolbarPosit
224
148
  };
225
149
  };
226
150
 
227
- /**
228
- * Same logic as calculateToolbarPositionTrackHeadOld, but with the following changes:
229
- * - Uses a cached container to avoid repeated DOM traversal and getComputedStyle calls
230
- * - Works when editor is nested within a fixed positioned parent, such as within a modal or sidebar
231
- */
232
- export var calculateToolbarPositionTrackHeadNew = function calculateToolbarPositionTrackHeadNew(toolbarTitle) {
233
- // Cache the container to avoid repeated DOM traversal and getComputedStyle calls
234
- var cachedContainer = null;
235
- var isFixedContainer = false;
236
- var cachedEditorDom = null;
237
- return function (editorView, nextPos) {
238
- var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
239
- if (!toolbar) {
240
- return nextPos;
241
- }
242
-
243
- // Find and cache the container (only recalculates if editor DOM changed)
244
- if (cachedEditorDom !== editorView.dom) {
245
- cachedEditorDom = editorView.dom;
246
- var _findContainingElemen = findContainingElement(editorView),
247
- _container = _findContainingElemen.container,
248
- isFixed = _findContainingElemen.isFixed;
249
- cachedContainer = _container;
250
- isFixedContainer = isFixed;
251
- }
252
- if (!cachedContainer) {
253
- return nextPos;
254
- }
255
- var container = cachedContainer;
256
- var containerBounds = container.getBoundingClientRect();
257
- var selection = window && window.getSelection();
258
- var moreRovoOptionsButton = document.querySelector('button[aria-label="More Rovo options"], [aria-label="More Rovo options"]');
259
- var isMoreRovoOptionsButtonVisible = !!moreRovoOptionsButton && moreRovoOptionsButton instanceof HTMLElement && !!moreRovoOptionsButton.offsetParent;
260
- var range = null;
261
- if (isMoreRovoOptionsButtonVisible) {
262
- if (selection && selection.getRangeAt && selection.rangeCount > 0) {
263
- var maybeRange = selection.getRangeAt(0);
264
- if (maybeRange instanceof Range) {
265
- range = maybeRange;
266
- }
267
- }
268
- } else {
269
- if (selection && !selection.isCollapsed && selection.getRangeAt && selection.rangeCount > 0) {
270
- var _maybeRange2 = selection.getRangeAt(0);
271
- if (_maybeRange2 instanceof Range) {
272
- range = _maybeRange2;
273
- }
274
- }
275
- }
276
- if (!range) {
277
- return nextPos;
278
- }
279
- var toolbarRect = toolbar.getBoundingClientRect();
280
- var _editorView$state$sel3 = editorView.state.selection,
281
- head = _editorView$state$sel3.head,
282
- anchor = _editorView$state$sel3.anchor;
283
- var top;
284
- var left;
285
- var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
286
- var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
287
- // If not the same line AND we are selecting downwards, display toolbar below.
288
- if (head > anchor && topCoords.top !== bottomCoords.top) {
289
- // We are taking the previous pos to the maxium, so avoid end of line positions
290
- // returning the next line's rect.
291
- top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
292
- } else {
293
- top = (topCoords.top || 0) - toolbarRect.height * 1.5;
294
- }
295
- left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
296
-
297
- // Place toolbar below selection if not sufficient space above
298
- if (top < containerBounds.top) {
299
- var _getCoordsBelowSelect3 = getCoordsBelowSelection(bottomCoords, toolbarRect);
300
- top = _getCoordsBelowSelect3.top;
301
- left = _getCoordsBelowSelect3.left;
302
- }
303
- var leftCoord = Math.max(0, left - containerBounds.left);
304
- if (leftCoord + toolbarRect.width > containerBounds.width) {
305
- var _scrollbarWidth2 = MAXIMUM_BROWSER_SCROLLBAR_WIDTH;
306
- leftCoord = Math.max(0, containerBounds.width - (toolbarRect.width + _scrollbarWidth2));
307
- }
308
-
309
- // Apply scroll offset only for non-fixed containers
310
- // Fixed positioned elements don't scroll with the page
311
- var scrollOffset = isFixedContainer ? 0 : container.scrollTop;
312
- return {
313
- top: top - containerBounds.top + scrollOffset,
314
- left: leftCoord
315
- };
316
- };
317
- };
318
-
319
- /*
320
- Calculates the position of the floating toolbar relative to the selection.
321
- This implementation works in multiple scenarios:
322
- - Standard scrollable containers with .fabric-editor-popup-scroll-parent
323
- - Fixed positioned parent containers
324
- - Falls back to document.body
325
-
326
- The function automatically detects the container type and applies the appropriate
327
- positioning logic and scroll offset handling.
328
-
329
- Things to consider:
330
- - stick as close to the head X release coordinates as possible
331
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport
332
- - popup may appear in '.fabric-editor-popup-scroll-parent', fixed parent, or body
333
- - we use the toolbarRect to center align toolbar
334
- - use container bounds to clamp values
335
- - for fixed positioning, no scroll offsets are applied
336
- - for scrollable containers, scroll offsets are included
337
- */
338
- export var calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
339
- var isSelToolbarFixEnabled = expValEquals('platform_editor_sel_toolbar_fix', 'isEnabled', true);
340
- return isSelToolbarFixEnabled ? calculateToolbarPositionTrackHeadNew(toolbarTitle) : calculateToolbarPositionTrackHeadOld(toolbarTitle);
341
- };
342
-
343
151
  /**
344
152
  * Returns the coordintes at the bottom the selection.
345
153
  */
@@ -1,13 +1,6 @@
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;
11
4
  export declare const calculateToolbarPositionTrackHead: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
12
5
  export type CoordsAtPos = {
13
6
  bottom: number;
@@ -1,13 +1,6 @@
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;
11
4
  export declare const calculateToolbarPositionTrackHead: (toolbarTitle: string) => (editorView: EditorView, nextPos: Position) => Position;
12
5
  export type CoordsAtPos = {
13
6
  bottom: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "112.4.3",
3
+ "version": "112.4.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/"
@@ -82,7 +82,7 @@
82
82
  "@atlaskit/task-decision": "^19.3.0",
83
83
  "@atlaskit/textfield": "^8.2.0",
84
84
  "@atlaskit/theme": "^22.0.0",
85
- "@atlaskit/tmp-editor-statsig": "^40.2.0",
85
+ "@atlaskit/tmp-editor-statsig": "^40.3.0",
86
86
  "@atlaskit/tokens": "^11.1.0",
87
87
  "@atlaskit/tooltip": "^20.14.0",
88
88
  "@atlaskit/width-detector": "^5.0.0",