@atlaskit/editor-plugin-limited-mode 12.0.13 → 13.0.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,28 @@
1
1
  # @atlaskit/editor-plugin-limited-mode
2
2
 
3
+ ## 13.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 12.0.14
10
+
11
+ ### Patch Changes
12
+
13
+ - [`df8065dfa9d59`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/df8065dfa9d59) -
14
+ [EDITOR-8302] Behind the `platform_editor_limited_threshold_tweaks` experiment, limited mode
15
+ retunes its document thresholds: the node-count threshold drops from 5,000 to 2,438 — the
16
+ production p99 — so the guard lands on the largest ~1% of documents, and the `doc.nodeSize`
17
+ threshold is raised from 30,000 to 750,000 so it acts as a backstop for pathologically huge
18
+ documents rather than tripping on ordinary long-text pages. Control behaviour is unchanged.
19
+
20
+ The decision now lives in a single shared `@atlaskit/editor-common/should-enable-limited-mode`
21
+ module, used by both the limited-mode plugin and the node-anchor provider, instead of two
22
+ hand-synced copies.
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 12.0.13
4
27
 
5
28
  ### Patch Changes
@@ -4,57 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.limitedModePluginKey = exports.createPlugin = void 0;
7
- var _limitedModeDocumentThresholds = require("@atlaskit/editor-common/limited-mode-document-thresholds");
8
7
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
8
+ var _shouldEnableLimitedMode = require("@atlaskit/editor-common/should-enable-limited-mode");
9
9
  var _state = require("@atlaskit/editor-prosemirror/state");
10
10
  var limitedModePluginKey = exports.limitedModePluginKey = new _state.PluginKey('limitedModePlugin');
11
- /**
12
- * Determines whether limited mode should be enabled for a document.
13
- * If this logic changes, update the duplicate in `editor-common/src/node-anchor/node-anchor-provider.ts` to avoid drift.
14
- *
15
- * Limited mode is activated when ANY of the following conditions are met:
16
- * 1. Document size exceeds `LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD`
17
- * 2. Node count exceeds `LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD`
18
- * 3. Document contains a legacy-content macro (LCM)
19
- *
20
- * Performance optimisations:
21
- * - Doc size is checked first (O(1)) - if it exceeds threshold, we skip traversal entirely.
22
- * - If we find an LCM during traversal, we exit early since limited mode will be enabled.
23
- */
24
- var shouldEnableLimitedModeForDocument = function shouldEnableLimitedModeForDocument(doc) {
25
- var nodeCountThreshold = _limitedModeDocumentThresholds.LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD;
26
- var docSizeThreshold = _limitedModeDocumentThresholds.LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD;
27
-
28
- // Early exit: doc size exceeds threshold - O(1), no traversal needed
29
- if (doc.nodeSize > docSizeThreshold) {
30
- return true;
31
- }
32
-
33
- // Single traversal for node count and LCM detection
34
- var nodeCount = 0;
35
- var hasLcm = false;
36
- doc.descendants(function (node) {
37
- var _node$attrs;
38
- nodeCount += 1;
39
- if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
40
- hasLcm = true;
41
-
42
- // Early exit: LCM found — limited mode will be enabled
43
- return false;
44
- }
45
- });
46
-
47
- // LCM condition takes precedence (if we early exited traversal, this is why)
48
- if (hasLcm) {
49
- return true;
50
- }
51
-
52
- // Check node count threshold
53
- if (nodeCount > nodeCountThreshold) {
54
- return true;
55
- }
56
- return false;
57
- };
58
11
  var createPlugin = exports.createPlugin = function createPlugin() {
59
12
  return new _safePlugin.SafePlugin({
60
13
  key: limitedModePluginKey,
@@ -64,7 +17,7 @@ var createPlugin = exports.createPlugin = function createPlugin() {
64
17
  state: {
65
18
  init: function init(_config, editorState) {
66
19
  return {
67
- documentSizeBreachesThreshold: shouldEnableLimitedModeForDocument(editorState.doc)
20
+ documentSizeBreachesThreshold: (0, _shouldEnableLimitedMode.shouldEnableLimitedModeForDocument)(editorState.doc)
68
21
  };
69
22
  },
70
23
  apply: function apply(tr, currentPluginState, _oldState, _newState) {
@@ -75,7 +28,7 @@ var createPlugin = exports.createPlugin = function createPlugin() {
75
28
  return currentPluginState;
76
29
  }
77
30
  return {
78
- documentSizeBreachesThreshold: shouldEnableLimitedModeForDocument(tr.doc)
31
+ documentSizeBreachesThreshold: (0, _shouldEnableLimitedMode.shouldEnableLimitedModeForDocument)(tr.doc)
79
32
  };
80
33
  }
81
34
  }
@@ -1,54 +1,7 @@
1
- import { LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD, LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD } from '@atlaskit/editor-common/limited-mode-document-thresholds';
2
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { shouldEnableLimitedModeForDocument } from '@atlaskit/editor-common/should-enable-limited-mode';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  export const limitedModePluginKey = new PluginKey('limitedModePlugin');
5
- /**
6
- * Determines whether limited mode should be enabled for a document.
7
- * If this logic changes, update the duplicate in `editor-common/src/node-anchor/node-anchor-provider.ts` to avoid drift.
8
- *
9
- * Limited mode is activated when ANY of the following conditions are met:
10
- * 1. Document size exceeds `LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD`
11
- * 2. Node count exceeds `LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD`
12
- * 3. Document contains a legacy-content macro (LCM)
13
- *
14
- * Performance optimisations:
15
- * - Doc size is checked first (O(1)) - if it exceeds threshold, we skip traversal entirely.
16
- * - If we find an LCM during traversal, we exit early since limited mode will be enabled.
17
- */
18
- const shouldEnableLimitedModeForDocument = doc => {
19
- const nodeCountThreshold = LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD;
20
- const docSizeThreshold = LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD;
21
-
22
- // Early exit: doc size exceeds threshold - O(1), no traversal needed
23
- if (doc.nodeSize > docSizeThreshold) {
24
- return true;
25
- }
26
-
27
- // Single traversal for node count and LCM detection
28
- let nodeCount = 0;
29
- let hasLcm = false;
30
- doc.descendants(node => {
31
- var _node$attrs;
32
- nodeCount += 1;
33
- if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
34
- hasLcm = true;
35
-
36
- // Early exit: LCM found — limited mode will be enabled
37
- return false;
38
- }
39
- });
40
-
41
- // LCM condition takes precedence (if we early exited traversal, this is why)
42
- if (hasLcm) {
43
- return true;
44
- }
45
-
46
- // Check node count threshold
47
- if (nodeCount > nodeCountThreshold) {
48
- return true;
49
- }
50
- return false;
51
- };
52
5
  export const createPlugin = () => {
53
6
  return new SafePlugin({
54
7
  key: limitedModePluginKey,
@@ -1,54 +1,7 @@
1
- import { LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD, LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD } from '@atlaskit/editor-common/limited-mode-document-thresholds';
2
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { shouldEnableLimitedModeForDocument } from '@atlaskit/editor-common/should-enable-limited-mode';
3
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
4
  export var limitedModePluginKey = new PluginKey('limitedModePlugin');
5
- /**
6
- * Determines whether limited mode should be enabled for a document.
7
- * If this logic changes, update the duplicate in `editor-common/src/node-anchor/node-anchor-provider.ts` to avoid drift.
8
- *
9
- * Limited mode is activated when ANY of the following conditions are met:
10
- * 1. Document size exceeds `LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD`
11
- * 2. Node count exceeds `LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD`
12
- * 3. Document contains a legacy-content macro (LCM)
13
- *
14
- * Performance optimisations:
15
- * - Doc size is checked first (O(1)) - if it exceeds threshold, we skip traversal entirely.
16
- * - If we find an LCM during traversal, we exit early since limited mode will be enabled.
17
- */
18
- var shouldEnableLimitedModeForDocument = function shouldEnableLimitedModeForDocument(doc) {
19
- var nodeCountThreshold = LIMITED_MODE_DEFAULT_NODE_COUNT_THRESHOLD;
20
- var docSizeThreshold = LIMITED_MODE_DEFAULT_DOC_SIZE_THRESHOLD;
21
-
22
- // Early exit: doc size exceeds threshold - O(1), no traversal needed
23
- if (doc.nodeSize > docSizeThreshold) {
24
- return true;
25
- }
26
-
27
- // Single traversal for node count and LCM detection
28
- var nodeCount = 0;
29
- var hasLcm = false;
30
- doc.descendants(function (node) {
31
- var _node$attrs;
32
- nodeCount += 1;
33
- if (((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.extensionKey) === 'legacy-content') {
34
- hasLcm = true;
35
-
36
- // Early exit: LCM found — limited mode will be enabled
37
- return false;
38
- }
39
- });
40
-
41
- // LCM condition takes precedence (if we early exited traversal, this is why)
42
- if (hasLcm) {
43
- return true;
44
- }
45
-
46
- // Check node count threshold
47
- if (nodeCount > nodeCountThreshold) {
48
- return true;
49
- }
50
- return false;
51
- };
52
5
  export var createPlugin = function createPlugin() {
53
6
  return new SafePlugin({
54
7
  key: limitedModePluginKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-limited-mode",
3
- "version": "12.0.13",
3
+ "version": "13.0.0",
4
4
  "description": "LimitedMode plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -27,7 +27,7 @@
27
27
  "bind-event-listener": "^3.0.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@atlaskit/editor-common": "^119.16.0",
30
+ "@atlaskit/editor-common": "^120.0.0",
31
31
  "react": "^18.2.0 || ^19.2.0",
32
32
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
33
33
  },