@atlaskit/editor-common 111.30.2 → 111.30.3

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/experiences/ExperienceCheckDomMutation.js +27 -5
  3. package/dist/cjs/experiences/experience-utils.js +41 -1
  4. package/dist/cjs/experiences/index.js +6 -0
  5. package/dist/cjs/extensibility/Extension/Extension/index.js +1 -2
  6. package/dist/cjs/monitoring/error.js +1 -1
  7. package/dist/cjs/preset/core-plugin/requestDocument.js +2 -5
  8. package/dist/cjs/ui/DropList/index.js +1 -1
  9. package/dist/es2019/experiences/ExperienceCheckDomMutation.js +15 -7
  10. package/dist/es2019/experiences/experience-utils.js +43 -0
  11. package/dist/es2019/experiences/index.js +1 -1
  12. package/dist/es2019/extensibility/Extension/Extension/index.js +1 -2
  13. package/dist/es2019/monitoring/error.js +1 -1
  14. package/dist/es2019/preset/core-plugin/requestDocument.js +2 -5
  15. package/dist/es2019/ui/DropList/index.js +1 -1
  16. package/dist/esm/experiences/ExperienceCheckDomMutation.js +27 -5
  17. package/dist/esm/experiences/experience-utils.js +40 -0
  18. package/dist/esm/experiences/index.js +1 -1
  19. package/dist/esm/extensibility/Extension/Extension/index.js +1 -2
  20. package/dist/esm/monitoring/error.js +1 -1
  21. package/dist/esm/preset/core-plugin/requestDocument.js +2 -5
  22. package/dist/esm/ui/DropList/index.js +1 -1
  23. package/dist/types/experiences/ExperienceCheckDomMutation.d.ts +11 -5
  24. package/dist/types/experiences/experience-utils.d.ts +15 -0
  25. package/dist/types/experiences/index.d.ts +1 -1
  26. package/dist/types-ts4.5/experiences/ExperienceCheckDomMutation.d.ts +11 -5
  27. package/dist/types-ts4.5/experiences/experience-utils.d.ts +15 -0
  28. package/dist/types-ts4.5/experiences/index.d.ts +1 -1
  29. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 111.30.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1eccf8acebd58`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1eccf8acebd58) -
8
+ ED-5052 Remove unnecessary eslint-disable comments for no-unused-vars violations in
9
+ requestDocument.ts and Extension/index.tsx.
10
+
3
11
  ## 111.30.2
4
12
 
5
13
  ### Patch Changes
@@ -8,6 +8,9 @@ exports.ExperienceCheckDomMutation = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _consts = require("./consts");
11
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
12
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
14
  /**
12
15
  * Check for the completion of an experience based on DOM mutations
13
16
  *
@@ -29,8 +32,12 @@ var ExperienceCheckDomMutation = exports.ExperienceCheckDomMutation = /*#__PURE_
29
32
  value: function start(callback) {
30
33
  var _this = this;
31
34
  this.stop();
32
- var config = this.observeConfig();
33
- if (!(config !== null && config !== void 0 && config.target)) {
35
+ var configResult = this.observeConfig();
36
+ var configs = Array.isArray(configResult) ? configResult : [configResult];
37
+ var validConfigs = configs.filter(function (config) {
38
+ return !!(config !== null && config !== void 0 && config.target);
39
+ });
40
+ if (validConfigs.length === 0) {
34
41
  callback({
35
42
  status: 'failure',
36
43
  reason: _consts.EXPERIENCE_FAILURE_REASON.DOM_MUTATION_TARGET_NOT_FOUND
@@ -52,9 +59,24 @@ var ExperienceCheckDomMutation = exports.ExperienceCheckDomMutation = /*#__PURE_
52
59
  });
53
60
  }
54
61
  });
55
- var target = config.target,
56
- options = config.options;
57
- this.mutationObserver.observe(target, options);
62
+ var _iterator = _createForOfIteratorHelper(validConfigs),
63
+ _step;
64
+ try {
65
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
66
+ var config = _step.value;
67
+ var target = config.target,
68
+ options = config.options;
69
+ if (target) {
70
+ this.mutationObserver.observe(target, options !== null && options !== void 0 ? options : {
71
+ childList: true
72
+ });
73
+ }
74
+ }
75
+ } catch (err) {
76
+ _iterator.e(err);
77
+ } finally {
78
+ _iterator.f();
79
+ }
58
80
  }
59
81
  }, {
60
82
  key: "stop",
@@ -3,7 +3,47 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.popupWithNestedElement = exports.getPopupContainerFromEditorView = exports.getNodeQuery = exports.containsPopupWithNestedElement = void 0;
6
+ exports.popupWithNestedElement = exports.getSelectionAncestorDOM = exports.getPopupContainerFromEditorView = exports.getNodeQuery = exports.containsPopupWithNestedElement = void 0;
7
+ /**
8
+ * Finds the direct child of the ProseMirror root element that contains the current selection.
9
+ *
10
+ * Starting from the DOM node at the selection position, this function walks up the DOM tree
11
+ * until it reaches the ProseMirror root, then returns the last element before the root
12
+ * (i.e., the second top-level ancestor).
13
+ *
14
+ * This is useful for attaching MutationObservers to the narrowest subtree that contains
15
+ * the selection, while still capturing all relevant mutations within that branch.
16
+ *
17
+ * @param editorView - The ProseMirror EditorView instance
18
+ * @returns The direct child of PM root containing the selection, or null if not found
19
+ */
20
+ var getSelectionAncestorDOM = exports.getSelectionAncestorDOM = function getSelectionAncestorDOM(editorView) {
21
+ if (!editorView) {
22
+ return null;
23
+ }
24
+ var pmDom = editorView.dom;
25
+ var selection = editorView.state.selection;
26
+
27
+ // nodeDOM can return null when editor loses focus (e.g. toolbar click) or for certain positions.
28
+ // Fall back to domAtPos which resolves the DOM node at the given position.
29
+ var currentNode = editorView.nodeDOM(selection.from);
30
+ if (!currentNode) {
31
+ try {
32
+ var _editorView$domAtPos = editorView.domAtPos(selection.from),
33
+ node = _editorView$domAtPos.node;
34
+ currentNode = node instanceof HTMLElement ? node : node.parentElement;
35
+ } catch (_unused) {
36
+ return null;
37
+ }
38
+ }
39
+ var lastValidAncestor = currentNode;
40
+ while (currentNode instanceof HTMLElement && currentNode !== pmDom) {
41
+ lastValidAncestor = currentNode;
42
+ currentNode = currentNode.parentElement;
43
+ }
44
+ return lastValidAncestor instanceof HTMLElement ? lastValidAncestor : null;
45
+ };
46
+
7
47
  /**
8
48
  * Checks if a given node contains a popup with a nested element identified by a specific test ID.
9
49
  *
@@ -69,6 +69,12 @@ Object.defineProperty(exports, "getPopupContainerFromEditorView", {
69
69
  return _experienceUtils.getPopupContainerFromEditorView;
70
70
  }
71
71
  });
72
+ Object.defineProperty(exports, "getSelectionAncestorDOM", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _experienceUtils.getSelectionAncestorDOM;
76
+ }
77
+ });
72
78
  Object.defineProperty(exports, "popupWithNestedElement", {
73
79
  enumerable: true,
74
80
  get: function get() {
@@ -129,13 +129,12 @@ function ExtensionWithPluginState(props) {
129
129
  var newContentStyles = {};
130
130
  if (shouldBreakout) {
131
131
  // type is destructured so that breakout styles does not include it
132
- // eslint-disable-next-line no-unused-vars
133
132
  var _calculateBreakoutSty = (0, _utils.calculateBreakoutStyles)({
134
133
  mode: node.attrs.layout,
135
134
  widthStateWidth: widthState.width,
136
135
  widthStateLineLength: widthState.lineLength
137
136
  }),
138
- type = _calculateBreakoutSty.type,
137
+ _type = _calculateBreakoutSty.type,
139
138
  breakoutStyles = (0, _objectWithoutProperties2.default)(_calculateBreakoutSty, _excluded);
140
139
  newContentStyles = _objectSpread({}, breakoutStyles);
141
140
  customContainerStyles = breakoutStyles;
@@ -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.30.1";
22
+ var packageVersion = "111.30.2";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -65,9 +65,7 @@ function createThrottleSchedule(callback) {
65
65
  }
66
66
 
67
67
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
- function returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent,
69
- // eslint-disable-next-line no-unused-vars
70
- _alwaysFire) {
68
+ function returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire) {
71
69
  var _editorView$state;
72
70
  var _ref = (_editorView$state = editorView === null || editorView === void 0 ? void 0 : editorView.state) !== null && _editorView$state !== void 0 ? _editorView$state : {},
73
71
  doc = _ref.doc,
@@ -100,8 +98,7 @@ _alwaysFire) {
100
98
  function returnDocumentRequestNoThrowError(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire) {
101
99
  try {
102
100
  return returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire);
103
- // eslint-disable-next-line no-unused-vars
104
- } catch (_) {
101
+ } catch (_unused) {
105
102
  callback(undefined);
106
103
  }
107
104
  }
@@ -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.30.1";
27
+ var packageVersion = "111.30.2";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -17,8 +17,10 @@ export class ExperienceCheckDomMutation {
17
17
  }
18
18
  start(callback) {
19
19
  this.stop();
20
- const config = this.observeConfig();
21
- if (!(config !== null && config !== void 0 && config.target)) {
20
+ const configResult = this.observeConfig();
21
+ const configs = Array.isArray(configResult) ? configResult : [configResult];
22
+ const validConfigs = configs.filter(config => !!(config !== null && config !== void 0 && config.target));
23
+ if (validConfigs.length === 0) {
22
24
  callback({
23
25
  status: 'failure',
24
26
  reason: EXPERIENCE_FAILURE_REASON.DOM_MUTATION_TARGET_NOT_FOUND
@@ -40,11 +42,17 @@ export class ExperienceCheckDomMutation {
40
42
  });
41
43
  }
42
44
  });
43
- const {
44
- target,
45
- options
46
- } = config;
47
- this.mutationObserver.observe(target, options);
45
+ for (const config of validConfigs) {
46
+ const {
47
+ target,
48
+ options
49
+ } = config;
50
+ if (target) {
51
+ this.mutationObserver.observe(target, options !== null && options !== void 0 ? options : {
52
+ childList: true
53
+ });
54
+ }
55
+ }
48
56
  }
49
57
  stop() {
50
58
  if (this.mutationObserver) {
@@ -1,3 +1,46 @@
1
+ /**
2
+ * Finds the direct child of the ProseMirror root element that contains the current selection.
3
+ *
4
+ * Starting from the DOM node at the selection position, this function walks up the DOM tree
5
+ * until it reaches the ProseMirror root, then returns the last element before the root
6
+ * (i.e., the second top-level ancestor).
7
+ *
8
+ * This is useful for attaching MutationObservers to the narrowest subtree that contains
9
+ * the selection, while still capturing all relevant mutations within that branch.
10
+ *
11
+ * @param editorView - The ProseMirror EditorView instance
12
+ * @returns The direct child of PM root containing the selection, or null if not found
13
+ */
14
+ export const getSelectionAncestorDOM = editorView => {
15
+ if (!editorView) {
16
+ return null;
17
+ }
18
+ const pmDom = editorView.dom;
19
+ const {
20
+ selection
21
+ } = editorView.state;
22
+
23
+ // nodeDOM can return null when editor loses focus (e.g. toolbar click) or for certain positions.
24
+ // Fall back to domAtPos which resolves the DOM node at the given position.
25
+ let currentNode = editorView.nodeDOM(selection.from);
26
+ if (!currentNode) {
27
+ try {
28
+ const {
29
+ node
30
+ } = editorView.domAtPos(selection.from);
31
+ currentNode = node instanceof HTMLElement ? node : node.parentElement;
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+ let lastValidAncestor = currentNode;
37
+ while (currentNode instanceof HTMLElement && currentNode !== pmDom) {
38
+ lastValidAncestor = currentNode;
39
+ currentNode = currentNode.parentElement;
40
+ }
41
+ return lastValidAncestor instanceof HTMLElement ? lastValidAncestor : null;
42
+ };
43
+
1
44
  /**
2
45
  * Checks if a given node contains a popup with a nested element identified by a specific test ID.
3
46
  *
@@ -7,4 +7,4 @@ export { ExperienceCheckComposite } from './ExperienceCheckComposite';
7
7
  export { ExperienceCheckDomMutation } from './ExperienceCheckDomMutation';
8
8
  export { ExperienceCheckPopupMutation } from './ExperienceCheckPopupMutation';
9
9
  export { ExperienceCheckTimeout } from './ExperienceCheckTimeout';
10
- export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery } from './experience-utils';
10
+ export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery, getSelectionAncestorDOM } from './experience-utils';
@@ -123,9 +123,8 @@ function ExtensionWithPluginState(props) {
123
123
  let newContentStyles = {};
124
124
  if (shouldBreakout) {
125
125
  // type is destructured so that breakout styles does not include it
126
- // eslint-disable-next-line no-unused-vars
127
126
  const {
128
- type,
127
+ type: _type,
129
128
  ...breakoutStyles
130
129
  } = calculateBreakoutStyles({
131
130
  mode: node.attrs.layout,
@@ -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.30.1";
7
+ const packageVersion = "111.30.2";
8
8
  const sanitiseSentryEvents = (data, _hint) => {
9
9
  // Remove URL as it has UGC
10
10
  // Ignored via go/ees007
@@ -45,9 +45,7 @@ export function createThrottleSchedule(callback) {
45
45
  }
46
46
 
47
47
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
- export function returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent,
49
- // eslint-disable-next-line no-unused-vars
50
- _alwaysFire) {
48
+ export function returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire) {
51
49
  var _editorView$state;
52
50
  const {
53
51
  doc,
@@ -81,8 +79,7 @@ _alwaysFire) {
81
79
  export function returnDocumentRequestNoThrowError(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire) {
82
80
  try {
83
81
  return returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire);
84
- // eslint-disable-next-line no-unused-vars
85
- } catch (_) {
82
+ } catch {
86
83
  callback(undefined);
87
84
  }
88
85
  }
@@ -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.30.1";
17
+ const packageVersion = "111.30.2";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -1,5 +1,8 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
4
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
3
6
  import { EXPERIENCE_FAILURE_REASON } from './consts';
4
7
  /**
5
8
  * Check for the completion of an experience based on DOM mutations
@@ -22,8 +25,12 @@ export var ExperienceCheckDomMutation = /*#__PURE__*/function () {
22
25
  value: function start(callback) {
23
26
  var _this = this;
24
27
  this.stop();
25
- var config = this.observeConfig();
26
- if (!(config !== null && config !== void 0 && config.target)) {
28
+ var configResult = this.observeConfig();
29
+ var configs = Array.isArray(configResult) ? configResult : [configResult];
30
+ var validConfigs = configs.filter(function (config) {
31
+ return !!(config !== null && config !== void 0 && config.target);
32
+ });
33
+ if (validConfigs.length === 0) {
27
34
  callback({
28
35
  status: 'failure',
29
36
  reason: EXPERIENCE_FAILURE_REASON.DOM_MUTATION_TARGET_NOT_FOUND
@@ -45,9 +52,24 @@ export var ExperienceCheckDomMutation = /*#__PURE__*/function () {
45
52
  });
46
53
  }
47
54
  });
48
- var target = config.target,
49
- options = config.options;
50
- this.mutationObserver.observe(target, options);
55
+ var _iterator = _createForOfIteratorHelper(validConfigs),
56
+ _step;
57
+ try {
58
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
59
+ var config = _step.value;
60
+ var target = config.target,
61
+ options = config.options;
62
+ if (target) {
63
+ this.mutationObserver.observe(target, options !== null && options !== void 0 ? options : {
64
+ childList: true
65
+ });
66
+ }
67
+ }
68
+ } catch (err) {
69
+ _iterator.e(err);
70
+ } finally {
71
+ _iterator.f();
72
+ }
51
73
  }
52
74
  }, {
53
75
  key: "stop",
@@ -1,3 +1,43 @@
1
+ /**
2
+ * Finds the direct child of the ProseMirror root element that contains the current selection.
3
+ *
4
+ * Starting from the DOM node at the selection position, this function walks up the DOM tree
5
+ * until it reaches the ProseMirror root, then returns the last element before the root
6
+ * (i.e., the second top-level ancestor).
7
+ *
8
+ * This is useful for attaching MutationObservers to the narrowest subtree that contains
9
+ * the selection, while still capturing all relevant mutations within that branch.
10
+ *
11
+ * @param editorView - The ProseMirror EditorView instance
12
+ * @returns The direct child of PM root containing the selection, or null if not found
13
+ */
14
+ export var getSelectionAncestorDOM = function getSelectionAncestorDOM(editorView) {
15
+ if (!editorView) {
16
+ return null;
17
+ }
18
+ var pmDom = editorView.dom;
19
+ var selection = editorView.state.selection;
20
+
21
+ // nodeDOM can return null when editor loses focus (e.g. toolbar click) or for certain positions.
22
+ // Fall back to domAtPos which resolves the DOM node at the given position.
23
+ var currentNode = editorView.nodeDOM(selection.from);
24
+ if (!currentNode) {
25
+ try {
26
+ var _editorView$domAtPos = editorView.domAtPos(selection.from),
27
+ node = _editorView$domAtPos.node;
28
+ currentNode = node instanceof HTMLElement ? node : node.parentElement;
29
+ } catch (_unused) {
30
+ return null;
31
+ }
32
+ }
33
+ var lastValidAncestor = currentNode;
34
+ while (currentNode instanceof HTMLElement && currentNode !== pmDom) {
35
+ lastValidAncestor = currentNode;
36
+ currentNode = currentNode.parentElement;
37
+ }
38
+ return lastValidAncestor instanceof HTMLElement ? lastValidAncestor : null;
39
+ };
40
+
1
41
  /**
2
42
  * Checks if a given node contains a popup with a nested element identified by a specific test ID.
3
43
  *
@@ -7,4 +7,4 @@ export { ExperienceCheckComposite } from './ExperienceCheckComposite';
7
7
  export { ExperienceCheckDomMutation } from './ExperienceCheckDomMutation';
8
8
  export { ExperienceCheckPopupMutation } from './ExperienceCheckPopupMutation';
9
9
  export { ExperienceCheckTimeout } from './ExperienceCheckTimeout';
10
- export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery } from './experience-utils';
10
+ export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery, getSelectionAncestorDOM } from './experience-utils';
@@ -122,13 +122,12 @@ function ExtensionWithPluginState(props) {
122
122
  var newContentStyles = {};
123
123
  if (shouldBreakout) {
124
124
  // type is destructured so that breakout styles does not include it
125
- // eslint-disable-next-line no-unused-vars
126
125
  var _calculateBreakoutSty = calculateBreakoutStyles({
127
126
  mode: node.attrs.layout,
128
127
  widthStateWidth: widthState.width,
129
128
  widthStateLineLength: widthState.lineLength
130
129
  }),
131
- type = _calculateBreakoutSty.type,
130
+ _type = _calculateBreakoutSty.type,
132
131
  breakoutStyles = _objectWithoutProperties(_calculateBreakoutSty, _excluded);
133
132
  newContentStyles = _objectSpread({}, breakoutStyles);
134
133
  customContainerStyles = breakoutStyles;
@@ -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.30.1";
13
+ var packageVersion = "111.30.2";
14
14
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
15
15
  // Remove URL as it has UGC
16
16
  // Ignored via go/ees007
@@ -55,9 +55,7 @@ export function createThrottleSchedule(callback) {
55
55
  }
56
56
 
57
57
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
- export function returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent,
59
- // eslint-disable-next-line no-unused-vars
60
- _alwaysFire) {
58
+ export function returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire) {
61
59
  var _editorView$state;
62
60
  var _ref = (_editorView$state = editorView === null || editorView === void 0 ? void 0 : editorView.state) !== null && _editorView$state !== void 0 ? _editorView$state : {},
63
61
  doc = _ref.doc,
@@ -90,8 +88,7 @@ _alwaysFire) {
90
88
  export function returnDocumentRequestNoThrowError(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire) {
91
89
  try {
92
90
  return returnDocumentRequest(editorView, callback, transformer, fireAnalyticsEvent, _alwaysFire);
93
- // eslint-disable-next-line no-unused-vars
94
- } catch (_) {
91
+ } catch (_unused) {
95
92
  callback(undefined);
96
93
  }
97
94
  }
@@ -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.30.1";
24
+ var packageVersion = "111.30.2";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -14,12 +14,13 @@ export type ExperienceCheckDomMutationObserveConfig = {
14
14
  *
15
15
  * These include:
16
16
  * - childList: adding/removing child nodes directly under the target node
17
+ * - subtree: extends observation to the entire subtree of nodes rooted at target
17
18
  * - attributes: changes to attributes on the target node
18
19
  * - attributeFilter: defines the specific attributes to monitor for changes
19
20
  *
20
21
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe
21
22
  */
22
- options?: Pick<MutationObserverInit, 'childList' | 'attributes' | 'attributeFilter'>;
23
+ options?: Pick<MutationObserverInit, 'childList' | 'subtree' | 'attributes' | 'attributeFilter'>;
23
24
  /**
24
25
  * Target element to observe for mutations
25
26
  *
@@ -29,17 +30,22 @@ export type ExperienceCheckDomMutationObserveConfig = {
29
30
  };
30
31
  export type ExperienceCheckDomMutationConfig = {
31
32
  /**
32
- * Callback that returns the MutationObserver configuration
33
+ * Callback that returns one or more MutationObserver configurations.
34
+ *
35
+ * Can return:
36
+ * - A single config for one target to observe
37
+ * - An array of configs to observe multiple targets with one MutationObserver
38
+ * - null if no valid target is available (e.g., when selection node is not found)
33
39
  *
34
40
  * This is a callback to ensure consumers make explicit, conscious decisions about:
35
- * - What element to observe (performance: smaller scope = better performance)
41
+ * - What elements to observe (performance: smaller scope = better performance)
36
42
  * - What mutations to monitor (performance: fewer types = better performance)
37
43
  *
38
44
  * !!IMPORTANT!!
39
45
  * Return null if the target element cannot be found.
40
46
  * This will immediately fail the experience with experienceFailureReason 'domMutationTargetNotFound'.
41
- */
42
- observeConfig: () => ExperienceCheckDomMutationObserveConfig | null;
47
+ */
48
+ observeConfig: () => (ExperienceCheckDomMutationObserveConfig | ExperienceCheckDomMutationObserveConfig[] | null);
43
49
  /**
44
50
  * Callback invoked when DOM mutations are detected
45
51
  *
@@ -1,3 +1,18 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ /**
3
+ * Finds the direct child of the ProseMirror root element that contains the current selection.
4
+ *
5
+ * Starting from the DOM node at the selection position, this function walks up the DOM tree
6
+ * until it reaches the ProseMirror root, then returns the last element before the root
7
+ * (i.e., the second top-level ancestor).
8
+ *
9
+ * This is useful for attaching MutationObservers to the narrowest subtree that contains
10
+ * the selection, while still capturing all relevant mutations within that branch.
11
+ *
12
+ * @param editorView - The ProseMirror EditorView instance
13
+ * @returns The direct child of PM root containing the selection, or null if not found
14
+ */
15
+ export declare const getSelectionAncestorDOM: (editorView?: EditorView) => HTMLElement | null;
1
16
  /**
2
17
  * Checks if a given node contains a popup with a nested element identified by a specific test ID.
3
18
  *
@@ -7,4 +7,4 @@ export { ExperienceCheckTimeout } from './ExperienceCheckTimeout';
7
7
  export type { ExperienceCheckPopupMutationConfig, PopupCheckType, } from './ExperienceCheckPopupMutation';
8
8
  export type { ExperienceCheck, ExperienceCheckCallback, ExperienceCheckResult, } from './ExperienceCheck';
9
9
  export type { ExperienceCheckDomMutationConfig, ExperienceCheckDomMutationObserveConfig, ExperienceDomMutationCheckOptions, } from './ExperienceCheckDomMutation';
10
- export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery, } from './experience-utils';
10
+ export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery, getSelectionAncestorDOM, } from './experience-utils';
@@ -14,12 +14,13 @@ export type ExperienceCheckDomMutationObserveConfig = {
14
14
  *
15
15
  * These include:
16
16
  * - childList: adding/removing child nodes directly under the target node
17
+ * - subtree: extends observation to the entire subtree of nodes rooted at target
17
18
  * - attributes: changes to attributes on the target node
18
19
  * - attributeFilter: defines the specific attributes to monitor for changes
19
20
  *
20
21
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe
21
22
  */
22
- options?: Pick<MutationObserverInit, 'childList' | 'attributes' | 'attributeFilter'>;
23
+ options?: Pick<MutationObserverInit, 'childList' | 'subtree' | 'attributes' | 'attributeFilter'>;
23
24
  /**
24
25
  * Target element to observe for mutations
25
26
  *
@@ -29,17 +30,22 @@ export type ExperienceCheckDomMutationObserveConfig = {
29
30
  };
30
31
  export type ExperienceCheckDomMutationConfig = {
31
32
  /**
32
- * Callback that returns the MutationObserver configuration
33
+ * Callback that returns one or more MutationObserver configurations.
34
+ *
35
+ * Can return:
36
+ * - A single config for one target to observe
37
+ * - An array of configs to observe multiple targets with one MutationObserver
38
+ * - null if no valid target is available (e.g., when selection node is not found)
33
39
  *
34
40
  * This is a callback to ensure consumers make explicit, conscious decisions about:
35
- * - What element to observe (performance: smaller scope = better performance)
41
+ * - What elements to observe (performance: smaller scope = better performance)
36
42
  * - What mutations to monitor (performance: fewer types = better performance)
37
43
  *
38
44
  * !!IMPORTANT!!
39
45
  * Return null if the target element cannot be found.
40
46
  * This will immediately fail the experience with experienceFailureReason 'domMutationTargetNotFound'.
41
- */
42
- observeConfig: () => ExperienceCheckDomMutationObserveConfig | null;
47
+ */
48
+ observeConfig: () => (ExperienceCheckDomMutationObserveConfig | ExperienceCheckDomMutationObserveConfig[] | null);
43
49
  /**
44
50
  * Callback invoked when DOM mutations are detected
45
51
  *
@@ -1,3 +1,18 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+ /**
3
+ * Finds the direct child of the ProseMirror root element that contains the current selection.
4
+ *
5
+ * Starting from the DOM node at the selection position, this function walks up the DOM tree
6
+ * until it reaches the ProseMirror root, then returns the last element before the root
7
+ * (i.e., the second top-level ancestor).
8
+ *
9
+ * This is useful for attaching MutationObservers to the narrowest subtree that contains
10
+ * the selection, while still capturing all relevant mutations within that branch.
11
+ *
12
+ * @param editorView - The ProseMirror EditorView instance
13
+ * @returns The direct child of PM root containing the selection, or null if not found
14
+ */
15
+ export declare const getSelectionAncestorDOM: (editorView?: EditorView) => HTMLElement | null;
1
16
  /**
2
17
  * Checks if a given node contains a popup with a nested element identified by a specific test ID.
3
18
  *
@@ -7,4 +7,4 @@ export { ExperienceCheckTimeout } from './ExperienceCheckTimeout';
7
7
  export type { ExperienceCheckPopupMutationConfig, PopupCheckType, } from './ExperienceCheckPopupMutation';
8
8
  export type { ExperienceCheck, ExperienceCheckCallback, ExperienceCheckResult, } from './ExperienceCheck';
9
9
  export type { ExperienceCheckDomMutationConfig, ExperienceCheckDomMutationObserveConfig, ExperienceDomMutationCheckOptions, } from './ExperienceCheckDomMutation';
10
- export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery, } from './experience-utils';
10
+ export { containsPopupWithNestedElement, popupWithNestedElement, getPopupContainerFromEditorView, getNodeQuery, getSelectionAncestorDOM, } from './experience-utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "111.30.2",
3
+ "version": "111.30.3",
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/"
@@ -71,7 +71,7 @@
71
71
  "@atlaskit/platform-feature-flags-react": "^0.4.0",
72
72
  "@atlaskit/popper": "^7.1.0",
73
73
  "@atlaskit/primitives": "^18.0.0",
74
- "@atlaskit/profilecard": "^24.41.0",
74
+ "@atlaskit/profilecard": "^24.42.0",
75
75
  "@atlaskit/prosemirror-history": "^0.2.0",
76
76
  "@atlaskit/react-ufo": "^5.4.0",
77
77
  "@atlaskit/section-message": "^8.12.0",
@@ -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": "^35.1.0",
85
+ "@atlaskit/tmp-editor-statsig": "^35.3.0",
86
86
  "@atlaskit/tokens": "^11.0.0",
87
87
  "@atlaskit/tooltip": "^20.14.0",
88
88
  "@atlaskit/width-detector": "^5.0.0",