@atlaskit/editor-common 119.16.4 → 119.17.0

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,24 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 119.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`df8065dfa9d59`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/df8065dfa9d59) -
8
+ [EDITOR-8302] Behind the `platform_editor_limited_threshold_tweaks` experiment, limited mode
9
+ retunes its document thresholds: the node-count threshold drops from 5,000 to 2,438 — the
10
+ production p99 — so the guard lands on the largest ~1% of documents, and the `doc.nodeSize`
11
+ threshold is raised from 30,000 to 750,000 so it acts as a backstop for pathologically huge
12
+ documents rather than tripping on ordinary long-text pages. Control behaviour is unchanged.
13
+
14
+ The decision now lives in a single shared `@atlaskit/editor-common/should-enable-limited-mode`
15
+ module, used by both the limited-mode plugin and the node-anchor provider, instead of two
16
+ hand-synced copies.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 119.16.4
4
23
 
5
24
  ### Patch Changes
@@ -15,7 +15,13 @@ const EXCLUDED_PACKAGE_JSON_PATHS = [
15
15
  'packages/editor/editor-core/package.json',
16
16
  'packages/editor/editor-plugin-ai-tests/package.json',
17
17
  'packages/editor/editor-plugin-extension-tests/package.json',
18
+ 'packages/editor/editor-plugin-synced-block-tests/package.json',
19
+ 'packages/editor/generative-ai-modal/package.json',
20
+ 'packages/editor/editor-plugin-show-diff-tests/package.json',
18
21
  'packages/editor/editor-plugin-table-tests/package.json',
22
+ 'packages/editor/editor-plugin-quick-insert-tests/package.json',
23
+ 'packages/editor/editor-referentiality/package.json',
24
+ 'packages/editor/editor-synced-block-renderer-tests/package.json',
19
25
  ];
20
26
 
21
27
  type DependencyName = 'react' | 'react-dom' | '@types/react' | '@types/react-dom';
@@ -28,7 +28,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
28
28
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
29
29
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
30
30
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
31
- var packageVersion = "119.16.3";
31
+ var packageVersion = "119.16.4";
32
32
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
33
33
  // Remove URL as it has UGC
34
34
  // Ignored via go/ees007
@@ -3,13 +3,51 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LIMITED_MODE_INCLUDE_LEGACY_CONTENT_IN_THRESHOLD = exports.LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = exports.LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = void 0;
6
+ exports.getLimitedModeThresholds = exports.LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD = exports.LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD = exports.LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = exports.LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = void 0;
7
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
7
8
  /** Fixed document thresholds for limited (performance) mode (previously Statsig-driven). */
8
9
  var LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = exports.LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = 5000;
9
10
 
10
11
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
11
12
  var LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = exports.LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = 30000;
12
13
 
13
- /** When true, any legacy-content macro triggers limited mode regardless of size/count. */
14
+ /**
15
+ * Treatment node-count threshold. Production node-count percentiles across all documents are
16
+ * p90 ≈ 206, p95 ≈ 576, p99 ≈ 2,438 — today's 5,000 sits beyond p99 and fires on only ~0.36% of
17
+ * documents. 2,500 is p99 rounded, i.e. limited mode becomes a guard on the largest ~1% of pages.
18
+ *
19
+ * Deliberately NOT lower: the worst-5%-by-INP cohort has a median document of ~25 nodes, so its
20
+ * slowness is device/extension/collab-bound and structurally invisible. No node-count value catches
21
+ * it without enabling limited mode for nearly everyone (300 nodes ⇒ 8% of all sessions for 34%
22
+ * recall). Chasing that cohort needs a runtime input-latency trigger, not a bigger document guard.
23
+ */
14
24
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
15
- var LIMITED_MODE_INCLUDE_LEGACY_CONTENT_IN_THRESHOLD = exports.LIMITED_MODE_INCLUDE_LEGACY_CONTENT_IN_THRESHOLD = true;
25
+ var LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD = exports.LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD = 2438;
26
+
27
+ /**
28
+ * Treatment `nodeSize` threshold — a backstop for pathologically huge documents, not a routine
29
+ * trigger. Input latency really does degrade at extreme document sizes: the 100k+ `nodeSize` bucket
30
+ * sits at p90 113.5ms / p99 899ms, against p90 25.6ms in the 6k–11k bucket. But that curve is smooth
31
+ * and only becomes severe far past the body of the distribution (production `nodeSize` p99 is
32
+ * ~91.8k), so this is set well beyond p99 rather than at the control's 30,000 — which fires around
33
+ * p95 and so degrades a large population of plain long-text pages that type perfectly well.
34
+ */
35
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
36
+ var LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD = exports.LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD = 750000;
37
+
38
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
39
+
40
+ /**
41
+ * The document thresholds currently in force. This is the only place the cohort is resolved — the
42
+ * limited-mode decision itself is identical either way, only these two numbers change.
43
+ */
44
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
45
+ var getLimitedModeThresholds = exports.getLimitedModeThresholds = function getLimitedModeThresholds() {
46
+ return (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_limited_threshold_tweaks') ? {
47
+ docSizeThreshold: LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD,
48
+ nodeCountThreshold: LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD
49
+ } : {
50
+ docSizeThreshold: LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD,
51
+ nodeCountThreshold: LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD
52
+ };
53
+ };
@@ -10,7 +10,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _utils = require("../utils");
12
12
  var _dynamicBitArray = require("./dynamic-bit-array");
13
- var _limitedModeDocumentThresholds = require("./limited-mode-document-thresholds");
13
+ var _shouldEnableLimitedMode = require("./should-enable-limited-mode");
14
14
  var NodeAnchorProvider = exports.NodeAnchorProvider = /*#__PURE__*/function () {
15
15
  function NodeAnchorProvider() {
16
16
  var limitedMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -94,53 +94,12 @@ var NodeAnchorProvider = exports.NodeAnchorProvider = /*#__PURE__*/function () {
94
94
  var nodeIdProviderMap = new WeakMap();
95
95
 
96
96
  /**
97
- * Determines whether limited mode should be enabled.
98
- * This logic mirrors the limited mode plugin implementation, but lives here to avoid a circular dependency.
99
- * If it changes, update the matching logic in `editor-plugin-limited-mode/src/pm-plugins/main.ts`.
100
- *
101
- * Limited mode is activated when ANY of the following conditions are met:
102
- * 1. Document size exceeds `LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD` — checked first as O(1)
103
- * 2. Node count exceeds `LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD`
104
- * 3. Document contains a legacy-content macro (LCM)
105
- *
106
- * Performance optimisations:
107
- * - Doc size is checked first (O(1)) - if it exceeds threshold, we skip traversal entirely.
108
- * - If we find an LCM during traversal, we exit early since limited mode will be enabled.
97
+ * Determines whether limited mode should be enabled for the given editor view.
98
+ * Delegates to the shared decision in `should-enable-limited-mode.ts` so the provider and the
99
+ * limited-mode plugin can never drift.
109
100
  */
110
101
  var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
111
- var doc = editorView.state.doc;
112
- var nodeCountThreshold = _limitedModeDocumentThresholds.LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD;
113
- var docSizeThreshold = _limitedModeDocumentThresholds.LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD;
114
-
115
- // Early exit: doc size exceeds threshold - O(1), no traversal needed
116
- if (doc.nodeSize > docSizeThreshold) {
117
- return true;
118
- }
119
-
120
- // Single traversal for node count and LCM detection
121
- var nodeCount = 0;
122
- var hasLcm = false;
123
- doc.descendants(function (node) {
124
- var _node$attrs;
125
- nodeCount += 1;
126
- if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
127
- hasLcm = true;
128
-
129
- // Early exit: LCM found — limited mode will be enabled
130
- return false;
131
- }
132
- });
133
-
134
- // LCM condition takes precedence (if we early exited traversal, this is why)
135
- if (hasLcm) {
136
- return true;
137
- }
138
-
139
- // Check node count threshold
140
- if (nodeCount > nodeCountThreshold) {
141
- return true;
142
- }
143
- return false;
102
+ return (0, _shouldEnableLimitedMode.shouldEnableLimitedModeForDocument)(editorView.state.doc);
144
103
  };
145
104
 
146
105
  // Get the NodeIdProvider for a specific EditorView instance.
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shouldEnableLimitedModeForDocument = void 0;
7
+ var _limitedModeDocumentThresholds = require("./limited-mode-document-thresholds");
8
+ var LEGACY_CONTENT_EXTENSION_KEY = 'legacy-content';
9
+
10
+ /**
11
+ * Single source of truth for the limited (performance) mode decision.
12
+ *
13
+ * Shared by the limited-mode plugin (`editor-plugin-limited-mode/src/pm-plugins/main.ts`) and the
14
+ * node-anchor provider (`node-anchor-provider.ts`) so the logic can no longer drift between two
15
+ * hand-synced copies. It lives in `editor-common` to avoid a circular dependency (the plugin already
16
+ * depends on `editor-common`; `editor-common` must not depend on the plugin).
17
+ *
18
+ * Limited mode is enabled when ANY of the following is true:
19
+ * 1. `doc.nodeSize` exceeds the doc-size threshold (checked first, O(1))
20
+ * 2. the document contains a legacy-content macro (LCM)
21
+ * 3. node count exceeds the node-count threshold
22
+ *
23
+ * The thresholds come from `getLimitedModeThresholds()`, which is where the
24
+ * `platform_editor_limited_threshold_tweaks` cohort is resolved — see
25
+ * `limited-mode-document-thresholds.ts` for the values and the data behind them.
26
+ *
27
+ * Performance: doc size is checked first so an oversized document skips the traversal entirely.
28
+ */
29
+ var shouldEnableLimitedModeForDocument = exports.shouldEnableLimitedModeForDocument = function shouldEnableLimitedModeForDocument(doc) {
30
+ var _getLimitedModeThresh = (0, _limitedModeDocumentThresholds.getLimitedModeThresholds)(),
31
+ docSizeThreshold = _getLimitedModeThresh.docSizeThreshold,
32
+ nodeCountThreshold = _getLimitedModeThresh.nodeCountThreshold;
33
+ if (doc.nodeSize > docSizeThreshold) {
34
+ return true;
35
+ }
36
+
37
+ // Single traversal for node count and LCM detection.
38
+ var nodeCount = 0;
39
+ var hasLcm = false;
40
+ doc.descendants(function (node) {
41
+ var _node$attrs;
42
+ nodeCount += 1;
43
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === LEGACY_CONTENT_EXTENSION_KEY) {
44
+ hasLcm = true;
45
+
46
+ // Early exit: LCM found — limited mode will be enabled
47
+ return false;
48
+ }
49
+ return true;
50
+ });
51
+ return hasLcm || nodeCount > nodeCountThreshold;
52
+ };
@@ -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 = "119.16.3";
27
+ var packageVersion = "119.16.4";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -14,7 +14,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
14
14
  const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
15
15
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
16
16
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
17
- const packageVersion = "119.16.3";
17
+ const packageVersion = "119.16.4";
18
18
  const sanitiseSentryEvents = (data, _hint) => {
19
19
  // Remove URL as it has UGC
20
20
  // Ignored via go/ees007
@@ -1,9 +1,46 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
2
+
1
3
  /** Fixed document thresholds for limited (performance) mode (previously Statsig-driven). */
2
4
  export const LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = 5000;
3
5
 
4
6
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
5
7
  export const LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = 30000;
6
8
 
7
- /** When true, any legacy-content macro triggers limited mode regardless of size/count. */
9
+ /**
10
+ * Treatment node-count threshold. Production node-count percentiles across all documents are
11
+ * p90 ≈ 206, p95 ≈ 576, p99 ≈ 2,438 — today's 5,000 sits beyond p99 and fires on only ~0.36% of
12
+ * documents. 2,500 is p99 rounded, i.e. limited mode becomes a guard on the largest ~1% of pages.
13
+ *
14
+ * Deliberately NOT lower: the worst-5%-by-INP cohort has a median document of ~25 nodes, so its
15
+ * slowness is device/extension/collab-bound and structurally invisible. No node-count value catches
16
+ * it without enabling limited mode for nearly everyone (300 nodes ⇒ 8% of all sessions for 34%
17
+ * recall). Chasing that cohort needs a runtime input-latency trigger, not a bigger document guard.
18
+ */
19
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
20
+ export const LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD = 2438;
21
+
22
+ /**
23
+ * Treatment `nodeSize` threshold — a backstop for pathologically huge documents, not a routine
24
+ * trigger. Input latency really does degrade at extreme document sizes: the 100k+ `nodeSize` bucket
25
+ * sits at p90 113.5ms / p99 899ms, against p90 25.6ms in the 6k–11k bucket. But that curve is smooth
26
+ * and only becomes severe far past the body of the distribution (production `nodeSize` p99 is
27
+ * ~91.8k), so this is set well beyond p99 rather than at the control's 30,000 — which fires around
28
+ * p95 and so degrades a large population of plain long-text pages that type perfectly well.
29
+ */
30
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
31
+ export const LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD = 750000;
32
+
33
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
34
+
35
+ /**
36
+ * The document thresholds currently in force. This is the only place the cohort is resolved — the
37
+ * limited-mode decision itself is identical either way, only these two numbers change.
38
+ */
8
39
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
9
- export const LIMITED_MODE_INCLUDE_LEGACY_CONTENT_IN_THRESHOLD = true;
40
+ export const getLimitedModeThresholds = () => isExperimentEnabled('platform_editor_limited_threshold_tweaks') ? {
41
+ docSizeThreshold: LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD,
42
+ nodeCountThreshold: LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD
43
+ } : {
44
+ docSizeThreshold: LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD,
45
+ nodeCountThreshold: LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD
46
+ };
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import { isEmptyDocument } from '../utils';
3
3
  import { DynamicBitArray } from './dynamic-bit-array';
4
- import { LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD, LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD } from './limited-mode-document-thresholds';
4
+ import { shouldEnableLimitedModeForDocument } from './should-enable-limited-mode';
5
5
  export class NodeAnchorProvider {
6
6
  constructor(limitedMode = false, emptyDoc = false) {
7
7
  _defineProperty(this, "cache", new WeakMap());
@@ -67,54 +67,11 @@ export class NodeAnchorProvider {
67
67
  const nodeIdProviderMap = new WeakMap();
68
68
 
69
69
  /**
70
- * Determines whether limited mode should be enabled.
71
- * This logic mirrors the limited mode plugin implementation, but lives here to avoid a circular dependency.
72
- * If it changes, update the matching logic in `editor-plugin-limited-mode/src/pm-plugins/main.ts`.
73
- *
74
- * Limited mode is activated when ANY of the following conditions are met:
75
- * 1. Document size exceeds `LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD` — checked first as O(1)
76
- * 2. Node count exceeds `LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD`
77
- * 3. Document contains a legacy-content macro (LCM)
78
- *
79
- * Performance optimisations:
80
- * - Doc size is checked first (O(1)) - if it exceeds threshold, we skip traversal entirely.
81
- * - If we find an LCM during traversal, we exit early since limited mode will be enabled.
70
+ * Determines whether limited mode should be enabled for the given editor view.
71
+ * Delegates to the shared decision in `should-enable-limited-mode.ts` so the provider and the
72
+ * limited-mode plugin can never drift.
82
73
  */
83
- const isLimitedModeEnabled = editorView => {
84
- const doc = editorView.state.doc;
85
- const nodeCountThreshold = LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD;
86
- const docSizeThreshold = LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD;
87
-
88
- // Early exit: doc size exceeds threshold - O(1), no traversal needed
89
- if (doc.nodeSize > docSizeThreshold) {
90
- return true;
91
- }
92
-
93
- // Single traversal for node count and LCM detection
94
- let nodeCount = 0;
95
- let hasLcm = false;
96
- doc.descendants(node => {
97
- var _node$attrs;
98
- nodeCount += 1;
99
- if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
100
- hasLcm = true;
101
-
102
- // Early exit: LCM found — limited mode will be enabled
103
- return false;
104
- }
105
- });
106
-
107
- // LCM condition takes precedence (if we early exited traversal, this is why)
108
- if (hasLcm) {
109
- return true;
110
- }
111
-
112
- // Check node count threshold
113
- if (nodeCount > nodeCountThreshold) {
114
- return true;
115
- }
116
- return false;
117
- };
74
+ const isLimitedModeEnabled = editorView => shouldEnableLimitedModeForDocument(editorView.state.doc);
118
75
 
119
76
  // Get the NodeIdProvider for a specific EditorView instance.
120
77
  // This allows access to the node ids anywhere.
@@ -0,0 +1,47 @@
1
+ import { getLimitedModeThresholds } from './limited-mode-document-thresholds';
2
+ const LEGACY_CONTENT_EXTENSION_KEY = 'legacy-content';
3
+
4
+ /**
5
+ * Single source of truth for the limited (performance) mode decision.
6
+ *
7
+ * Shared by the limited-mode plugin (`editor-plugin-limited-mode/src/pm-plugins/main.ts`) and the
8
+ * node-anchor provider (`node-anchor-provider.ts`) so the logic can no longer drift between two
9
+ * hand-synced copies. It lives in `editor-common` to avoid a circular dependency (the plugin already
10
+ * depends on `editor-common`; `editor-common` must not depend on the plugin).
11
+ *
12
+ * Limited mode is enabled when ANY of the following is true:
13
+ * 1. `doc.nodeSize` exceeds the doc-size threshold (checked first, O(1))
14
+ * 2. the document contains a legacy-content macro (LCM)
15
+ * 3. node count exceeds the node-count threshold
16
+ *
17
+ * The thresholds come from `getLimitedModeThresholds()`, which is where the
18
+ * `platform_editor_limited_threshold_tweaks` cohort is resolved — see
19
+ * `limited-mode-document-thresholds.ts` for the values and the data behind them.
20
+ *
21
+ * Performance: doc size is checked first so an oversized document skips the traversal entirely.
22
+ */
23
+ export const shouldEnableLimitedModeForDocument = doc => {
24
+ const {
25
+ docSizeThreshold,
26
+ nodeCountThreshold
27
+ } = getLimitedModeThresholds();
28
+ if (doc.nodeSize > docSizeThreshold) {
29
+ return true;
30
+ }
31
+
32
+ // Single traversal for node count and LCM detection.
33
+ let nodeCount = 0;
34
+ let hasLcm = false;
35
+ doc.descendants(node => {
36
+ var _node$attrs;
37
+ nodeCount += 1;
38
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === LEGACY_CONTENT_EXTENSION_KEY) {
39
+ hasLcm = true;
40
+
41
+ // Early exit: LCM found — limited mode will be enabled
42
+ return false;
43
+ }
44
+ return true;
45
+ });
46
+ return hasLcm || nodeCount > nodeCountThreshold;
47
+ };
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags/fg';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "119.16.3";
17
+ const packageVersion = "119.16.4";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -20,7 +20,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
20
20
  var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
21
21
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
22
22
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
23
- var packageVersion = "119.16.3";
23
+ var packageVersion = "119.16.4";
24
24
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
25
25
  // Remove URL as it has UGC
26
26
  // Ignored via go/ees007
@@ -1,9 +1,48 @@
1
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
2
+
1
3
  /** Fixed document thresholds for limited (performance) mode (previously Statsig-driven). */
2
4
  export var LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = 5000;
3
5
 
4
6
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
5
7
  export var LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = 30000;
6
8
 
7
- /** When true, any legacy-content macro triggers limited mode regardless of size/count. */
9
+ /**
10
+ * Treatment node-count threshold. Production node-count percentiles across all documents are
11
+ * p90 ≈ 206, p95 ≈ 576, p99 ≈ 2,438 — today's 5,000 sits beyond p99 and fires on only ~0.36% of
12
+ * documents. 2,500 is p99 rounded, i.e. limited mode becomes a guard on the largest ~1% of pages.
13
+ *
14
+ * Deliberately NOT lower: the worst-5%-by-INP cohort has a median document of ~25 nodes, so its
15
+ * slowness is device/extension/collab-bound and structurally invisible. No node-count value catches
16
+ * it without enabling limited mode for nearly everyone (300 nodes ⇒ 8% of all sessions for 34%
17
+ * recall). Chasing that cohort needs a runtime input-latency trigger, not a bigger document guard.
18
+ */
19
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
20
+ export var LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD = 2438;
21
+
22
+ /**
23
+ * Treatment `nodeSize` threshold — a backstop for pathologically huge documents, not a routine
24
+ * trigger. Input latency really does degrade at extreme document sizes: the 100k+ `nodeSize` bucket
25
+ * sits at p90 113.5ms / p99 899ms, against p90 25.6ms in the 6k–11k bucket. But that curve is smooth
26
+ * and only becomes severe far past the body of the distribution (production `nodeSize` p99 is
27
+ * ~91.8k), so this is set well beyond p99 rather than at the control's 30,000 — which fires around
28
+ * p95 and so degrades a large population of plain long-text pages that type perfectly well.
29
+ */
30
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
31
+ export var LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD = 750000;
32
+
33
+ // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
34
+
35
+ /**
36
+ * The document thresholds currently in force. This is the only place the cohort is resolved — the
37
+ * limited-mode decision itself is identical either way, only these two numbers change.
38
+ */
8
39
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
9
- export var LIMITED_MODE_INCLUDE_LEGACY_CONTENT_IN_THRESHOLD = true;
40
+ export var getLimitedModeThresholds = function getLimitedModeThresholds() {
41
+ return isExperimentEnabled('platform_editor_limited_threshold_tweaks') ? {
42
+ docSizeThreshold: LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD,
43
+ nodeCountThreshold: LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD
44
+ } : {
45
+ docSizeThreshold: LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD,
46
+ nodeCountThreshold: LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD
47
+ };
48
+ };
@@ -3,7 +3,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import { isEmptyDocument } from '../utils';
5
5
  import { DynamicBitArray } from './dynamic-bit-array';
6
- import { LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD, LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD } from './limited-mode-document-thresholds';
6
+ import { shouldEnableLimitedModeForDocument } from './should-enable-limited-mode';
7
7
  export var NodeAnchorProvider = /*#__PURE__*/function () {
8
8
  function NodeAnchorProvider() {
9
9
  var limitedMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -87,53 +87,12 @@ export var NodeAnchorProvider = /*#__PURE__*/function () {
87
87
  var nodeIdProviderMap = new WeakMap();
88
88
 
89
89
  /**
90
- * Determines whether limited mode should be enabled.
91
- * This logic mirrors the limited mode plugin implementation, but lives here to avoid a circular dependency.
92
- * If it changes, update the matching logic in `editor-plugin-limited-mode/src/pm-plugins/main.ts`.
93
- *
94
- * Limited mode is activated when ANY of the following conditions are met:
95
- * 1. Document size exceeds `LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD` — checked first as O(1)
96
- * 2. Node count exceeds `LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD`
97
- * 3. Document contains a legacy-content macro (LCM)
98
- *
99
- * Performance optimisations:
100
- * - Doc size is checked first (O(1)) - if it exceeds threshold, we skip traversal entirely.
101
- * - If we find an LCM during traversal, we exit early since limited mode will be enabled.
90
+ * Determines whether limited mode should be enabled for the given editor view.
91
+ * Delegates to the shared decision in `should-enable-limited-mode.ts` so the provider and the
92
+ * limited-mode plugin can never drift.
102
93
  */
103
94
  var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
104
- var doc = editorView.state.doc;
105
- var nodeCountThreshold = LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD;
106
- var docSizeThreshold = LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD;
107
-
108
- // Early exit: doc size exceeds threshold - O(1), no traversal needed
109
- if (doc.nodeSize > docSizeThreshold) {
110
- return true;
111
- }
112
-
113
- // Single traversal for node count and LCM detection
114
- var nodeCount = 0;
115
- var hasLcm = false;
116
- doc.descendants(function (node) {
117
- var _node$attrs;
118
- nodeCount += 1;
119
- if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
120
- hasLcm = true;
121
-
122
- // Early exit: LCM found — limited mode will be enabled
123
- return false;
124
- }
125
- });
126
-
127
- // LCM condition takes precedence (if we early exited traversal, this is why)
128
- if (hasLcm) {
129
- return true;
130
- }
131
-
132
- // Check node count threshold
133
- if (nodeCount > nodeCountThreshold) {
134
- return true;
135
- }
136
- return false;
95
+ return shouldEnableLimitedModeForDocument(editorView.state.doc);
137
96
  };
138
97
 
139
98
  // Get the NodeIdProvider for a specific EditorView instance.
@@ -0,0 +1,46 @@
1
+ import { getLimitedModeThresholds } from './limited-mode-document-thresholds';
2
+ var LEGACY_CONTENT_EXTENSION_KEY = 'legacy-content';
3
+
4
+ /**
5
+ * Single source of truth for the limited (performance) mode decision.
6
+ *
7
+ * Shared by the limited-mode plugin (`editor-plugin-limited-mode/src/pm-plugins/main.ts`) and the
8
+ * node-anchor provider (`node-anchor-provider.ts`) so the logic can no longer drift between two
9
+ * hand-synced copies. It lives in `editor-common` to avoid a circular dependency (the plugin already
10
+ * depends on `editor-common`; `editor-common` must not depend on the plugin).
11
+ *
12
+ * Limited mode is enabled when ANY of the following is true:
13
+ * 1. `doc.nodeSize` exceeds the doc-size threshold (checked first, O(1))
14
+ * 2. the document contains a legacy-content macro (LCM)
15
+ * 3. node count exceeds the node-count threshold
16
+ *
17
+ * The thresholds come from `getLimitedModeThresholds()`, which is where the
18
+ * `platform_editor_limited_threshold_tweaks` cohort is resolved — see
19
+ * `limited-mode-document-thresholds.ts` for the values and the data behind them.
20
+ *
21
+ * Performance: doc size is checked first so an oversized document skips the traversal entirely.
22
+ */
23
+ export var shouldEnableLimitedModeForDocument = function shouldEnableLimitedModeForDocument(doc) {
24
+ var _getLimitedModeThresh = getLimitedModeThresholds(),
25
+ docSizeThreshold = _getLimitedModeThresh.docSizeThreshold,
26
+ nodeCountThreshold = _getLimitedModeThresh.nodeCountThreshold;
27
+ if (doc.nodeSize > docSizeThreshold) {
28
+ return true;
29
+ }
30
+
31
+ // Single traversal for node count and LCM detection.
32
+ var nodeCount = 0;
33
+ var hasLcm = false;
34
+ doc.descendants(function (node) {
35
+ var _node$attrs;
36
+ nodeCount += 1;
37
+ if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === LEGACY_CONTENT_EXTENSION_KEY) {
38
+ hasLcm = true;
39
+
40
+ // Early exit: LCM found — limited mode will be enabled
41
+ return false;
42
+ }
43
+ return true;
44
+ });
45
+ return hasLcm || nodeCount > nodeCountThreshold;
46
+ };
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags/fg';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "119.16.3";
24
+ var packageVersion = "119.16.4";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -1,5 +1,32 @@
1
1
  /** Fixed document thresholds for limited (performance) mode (previously Statsig-driven). */
2
2
  export declare const LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD = 5000;
3
3
  export declare const LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD = 30000;
4
- /** When true, any legacy-content macro triggers limited mode regardless of size/count. */
5
- export declare const LIMITED_MODE_INCLUDE_LEGACY_CONTENT_IN_THRESHOLD = true;
4
+ /**
5
+ * Treatment node-count threshold. Production node-count percentiles across all documents are
6
+ * p90 ≈ 206, p95 ≈ 576, p99 ≈ 2,438 — today's 5,000 sits beyond p99 and fires on only ~0.36% of
7
+ * documents. 2,500 is p99 rounded, i.e. limited mode becomes a guard on the largest ~1% of pages.
8
+ *
9
+ * Deliberately NOT lower: the worst-5%-by-INP cohort has a median document of ~25 nodes, so its
10
+ * slowness is device/extension/collab-bound and structurally invisible. No node-count value catches
11
+ * it without enabling limited mode for nearly everyone (300 nodes ⇒ 8% of all sessions for 34%
12
+ * recall). Chasing that cohort needs a runtime input-latency trigger, not a bigger document guard.
13
+ */
14
+ export declare const LIMITED_MODE_TWEAKED_NODE_COUNT_THRESHOLD = 2438;
15
+ /**
16
+ * Treatment `nodeSize` threshold — a backstop for pathologically huge documents, not a routine
17
+ * trigger. Input latency really does degrade at extreme document sizes: the 100k+ `nodeSize` bucket
18
+ * sits at p90 113.5ms / p99 899ms, against p90 25.6ms in the 6k–11k bucket. But that curve is smooth
19
+ * and only becomes severe far past the body of the distribution (production `nodeSize` p99 is
20
+ * ~91.8k), so this is set well beyond p99 rather than at the control's 30,000 — which fires around
21
+ * p95 and so degrades a large population of plain long-text pages that type perfectly well.
22
+ */
23
+ export declare const LIMITED_MODE_TWEAKED_DOC_SIZE_THRESHOLD = 750000;
24
+ export type LimitedModeThresholds = {
25
+ docSizeThreshold: number;
26
+ nodeCountThreshold: number;
27
+ };
28
+ /**
29
+ * The document thresholds currently in force. This is the only place the cohort is resolved — the
30
+ * limited-mode decision itself is identical either way, only these two numbers change.
31
+ */
32
+ export declare const getLimitedModeThresholds: () => LimitedModeThresholds;
@@ -0,0 +1,21 @@
1
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ /**
3
+ * Single source of truth for the limited (performance) mode decision.
4
+ *
5
+ * Shared by the limited-mode plugin (`editor-plugin-limited-mode/src/pm-plugins/main.ts`) and the
6
+ * node-anchor provider (`node-anchor-provider.ts`) so the logic can no longer drift between two
7
+ * hand-synced copies. It lives in `editor-common` to avoid a circular dependency (the plugin already
8
+ * depends on `editor-common`; `editor-common` must not depend on the plugin).
9
+ *
10
+ * Limited mode is enabled when ANY of the following is true:
11
+ * 1. `doc.nodeSize` exceeds the doc-size threshold (checked first, O(1))
12
+ * 2. the document contains a legacy-content macro (LCM)
13
+ * 3. node count exceeds the node-count threshold
14
+ *
15
+ * The thresholds come from `getLimitedModeThresholds()`, which is where the
16
+ * `platform_editor_limited_threshold_tweaks` cohort is resolved — see
17
+ * `limited-mode-document-thresholds.ts` for the values and the data behind them.
18
+ *
19
+ * Performance: doc size is checked first so an oversized document skips the traversal entirely.
20
+ */
21
+ export declare const shouldEnableLimitedModeForDocument: (doc: PMNode) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "119.16.4",
3
+ "version": "119.17.0",
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/"
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@atlaskit/activity-provider": "^3.0.0",
32
- "@atlaskit/adf-schema": "^57.0.0",
32
+ "@atlaskit/adf-schema": "^57.1.0",
33
33
  "@atlaskit/adf-utils": "^20.7.0",
34
34
  "@atlaskit/afm-i18n-platform-editor-editor-common": "2.200.0",
35
35
  "@atlaskit/analytics-listeners": "^11.1.0",
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "@atlaskit/editor-common/should-enable-limited-mode",
3
+ "main": "../dist/cjs/node-anchor/should-enable-limited-mode.js",
4
+ "module": "../dist/esm/node-anchor/should-enable-limited-mode.js",
5
+ "module:es2019": "../dist/es2019/node-anchor/should-enable-limited-mode.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/node-anchor/should-enable-limited-mode.d.ts"
10
+ }