@atlaskit/editor-common 120.6.2 → 120.7.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,37 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 120.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d6fdb2e0f375c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d6fdb2e0f375c) -
8
+ Make `limitedModePlugin` the single source of truth for whether limited (performance) mode is on.
9
+
10
+ `NodeAnchorProvider` used to run the document-size / node-count / legacy-content-macro heuristic
11
+ itself, ignoring the plugin. Since the plugin is optional, removing it from a preset — or setting
12
+ `killSwitchEnabled: true` — did not actually disable limited mode: node anchors were still
13
+ suppressed, so no `data-node-anchor` attributes were written and block controls lost its drag
14
+ handles entirely.
15
+
16
+ Behind the `platform_editor_fix_limited_mode_leaking` feature gate, `getNodeIdProvider` now reads
17
+ the limited-mode plugin's state instead. No public API changes: `limitedModePluginKey` stays owned
18
+ by and exported from `@atlaskit/editor-plugin-limited-mode`, and `editor-common` reads the
19
+ plugin's state off `EditorState` by property name so it does not have to depend on a plugin
20
+ package. With the gate off the old document heuristic runs unchanged.
21
+
22
+ **Behaviour change once the gate is on.** With the plugin absent, limited mode is off: presets
23
+ that do not register it, and any product setting `killSwitchEnabled: true`, lose limited mode's
24
+ protection on very large documents and on documents containing a legacy content macro. Presets
25
+ that do register the plugin are unaffected.
26
+
27
+ `NodeAnchorProvider`'s limited-mode flag remains one-way — `documentSizeBreachesThreshold` can
28
+ return to `false` on a `replaceDocument` transaction, but the provider stays latched on, because
29
+ recovering would require re-rendering every nodeview to restore its anchor attribute.
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies
34
+
3
35
  ## 120.6.2
4
36
 
5
37
  ### Patch Changes
@@ -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 = "120.6.1";
31
+ var packageVersion = "120.6.2";
32
32
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
33
33
  // Remove URL as it has UGC
34
34
  // Ignored via go/ees007
@@ -8,9 +8,26 @@ exports.getNodeIdProvider = exports.NodeAnchorProvider = 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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
11
12
  var _utils = require("../utils");
12
13
  var _dynamicBitArray = require("./dynamic-bit-array");
13
14
  var _shouldEnableLimitedMode = require("./should-enable-limited-mode");
15
+ // The slice of `@atlaskit/editor-plugin-limited-mode`'s state read below. Declared
16
+ // structurally because `editor-common` must not depend on a plugin package.
17
+
18
+ // The real key stays in `@atlaskit/editor-plugin-limited-mode`; importing it would make
19
+ // `editor-common` depend on a plugin package, so match the state property by name.
20
+ // `'limitedModePlugin$'` is what ProseMirror derives for `new PluginKey('limitedModePlugin')`,
21
+ // and editor-plugin-limited-mode-tests asserts that literal to catch it shifting to `$1`.
22
+ // Please, do not copy or use this kind of code below
23
+ // @ts-ignore
24
+ var limitedModePluginKey = {
25
+ key: 'limitedModePlugin$',
26
+ getState: function getState(state) {
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ return state['limitedModePlugin$'];
29
+ }
30
+ };
14
31
  var NodeAnchorProvider = exports.NodeAnchorProvider = /*#__PURE__*/function () {
15
32
  function NodeAnchorProvider() {
16
33
  var limitedMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -81,6 +98,9 @@ var NodeAnchorProvider = exports.NodeAnchorProvider = /*#__PURE__*/function () {
81
98
  // After set to limited mode, we clear the cache to free up memory
82
99
  // and prevent further ids from being generated
83
100
  // Once in limited mode, we won't exit it
101
+ //
102
+ // One-way by design, so this can stay latched on after the plugin flips back to
103
+ // off: recovering would mean re-rendering every nodeview to restore its anchor.
84
104
  }, {
85
105
  key: "setLimitedMode",
86
106
  value: function setLimitedMode() {
@@ -94,12 +114,16 @@ var NodeAnchorProvider = exports.NodeAnchorProvider = /*#__PURE__*/function () {
94
114
  var nodeIdProviderMap = new WeakMap();
95
115
 
96
116
  /**
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.
117
+ * Reads the limited-mode plugin's state and nothing else, so a preset without the plugin no longer
118
+ * gets anchor suppression (and with it, no drag handles). No plugin means limited mode is off.
119
+ *
120
+ * Read off the state rather than the plugin injection API because plugin `state.init` is the only
121
+ * thing that has run by the time the `EditorView` constructor builds its first nodeview and calls
122
+ * `getNodeIdProvider`. Plugin views and `usePluginHook` both run later.
100
123
  */
101
124
  var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
102
- return (0, _shouldEnableLimitedMode.shouldEnableLimitedModeForDocument)(editorView.state.doc);
125
+ var _limitedModePluginKey, _limitedModePluginKey2;
126
+ return (0, _fg.fg)('platform_editor_fix_limited_mode_leaking') ? (_limitedModePluginKey = (_limitedModePluginKey2 = limitedModePluginKey.getState(editorView.state)) === null || _limitedModePluginKey2 === void 0 ? void 0 : _limitedModePluginKey2.documentSizeBreachesThreshold) !== null && _limitedModePluginKey !== void 0 ? _limitedModePluginKey : false : (0, _shouldEnableLimitedMode.shouldEnableLimitedModeForDocument)(editorView.state.doc);
103
127
  };
104
128
 
105
129
  // Get the NodeIdProvider for a specific EditorView instance.
@@ -107,8 +131,6 @@ var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
107
131
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
108
132
  var getNodeIdProvider = exports.getNodeIdProvider = function getNodeIdProvider(editorView) {
109
133
  if (!nodeIdProviderMap.has(editorView)) {
110
- // if the limited mode flag is on, enable limited mode based on the threshold
111
- // only for the first time
112
134
  var limitedMode = isLimitedModeEnabled(editorView);
113
135
  var isEmptyDoc = (0, _utils.isEmptyDocument)(editorView.state.doc);
114
136
  var provider = new NodeAnchorProvider(limitedMode, isEmptyDoc);
@@ -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 = "120.6.1";
27
+ var packageVersion = "120.6.2";
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 = "120.6.1";
17
+ const packageVersion = "120.6.2";
18
18
  const sanitiseSentryEvents = (data, _hint) => {
19
19
  // Remove URL as it has UGC
20
20
  // Ignored via go/ees007
@@ -1,7 +1,25 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
2
3
  import { isEmptyDocument } from '../utils';
3
4
  import { DynamicBitArray } from './dynamic-bit-array';
4
5
  import { shouldEnableLimitedModeForDocument } from './should-enable-limited-mode';
6
+
7
+ // The slice of `@atlaskit/editor-plugin-limited-mode`'s state read below. Declared
8
+ // structurally because `editor-common` must not depend on a plugin package.
9
+
10
+ // The real key stays in `@atlaskit/editor-plugin-limited-mode`; importing it would make
11
+ // `editor-common` depend on a plugin package, so match the state property by name.
12
+ // `'limitedModePlugin$'` is what ProseMirror derives for `new PluginKey('limitedModePlugin')`,
13
+ // and editor-plugin-limited-mode-tests asserts that literal to catch it shifting to `$1`.
14
+ // Please, do not copy or use this kind of code below
15
+ // @ts-ignore
16
+ const limitedModePluginKey = {
17
+ key: 'limitedModePlugin$',
18
+ getState: state => {
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ return state['limitedModePlugin$'];
21
+ }
22
+ };
5
23
  export class NodeAnchorProvider {
6
24
  constructor(limitedMode = false, emptyDoc = false) {
7
25
  _defineProperty(this, "cache", new WeakMap());
@@ -57,6 +75,9 @@ export class NodeAnchorProvider {
57
75
  // After set to limited mode, we clear the cache to free up memory
58
76
  // and prevent further ids from being generated
59
77
  // Once in limited mode, we won't exit it
78
+ //
79
+ // One-way by design, so this can stay latched on after the plugin flips back to
80
+ // off: recovering would mean re-rendering every nodeview to restore its anchor.
60
81
  setLimitedMode() {
61
82
  this.limitedMode = true;
62
83
  this.cache = new WeakMap();
@@ -67,19 +88,23 @@ export class NodeAnchorProvider {
67
88
  const nodeIdProviderMap = new WeakMap();
68
89
 
69
90
  /**
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.
91
+ * Reads the limited-mode plugin's state and nothing else, so a preset without the plugin no longer
92
+ * gets anchor suppression (and with it, no drag handles). No plugin means limited mode is off.
93
+ *
94
+ * Read off the state rather than the plugin injection API because plugin `state.init` is the only
95
+ * thing that has run by the time the `EditorView` constructor builds its first nodeview and calls
96
+ * `getNodeIdProvider`. Plugin views and `usePluginHook` both run later.
73
97
  */
74
- const isLimitedModeEnabled = editorView => shouldEnableLimitedModeForDocument(editorView.state.doc);
98
+ const isLimitedModeEnabled = editorView => {
99
+ var _limitedModePluginKey, _limitedModePluginKey2;
100
+ return fg('platform_editor_fix_limited_mode_leaking') ? (_limitedModePluginKey = (_limitedModePluginKey2 = limitedModePluginKey.getState(editorView.state)) === null || _limitedModePluginKey2 === void 0 ? void 0 : _limitedModePluginKey2.documentSizeBreachesThreshold) !== null && _limitedModePluginKey !== void 0 ? _limitedModePluginKey : false : shouldEnableLimitedModeForDocument(editorView.state.doc);
101
+ };
75
102
 
76
103
  // Get the NodeIdProvider for a specific EditorView instance.
77
104
  // This allows access to the node ids anywhere.
78
105
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
79
106
  export const getNodeIdProvider = editorView => {
80
107
  if (!nodeIdProviderMap.has(editorView)) {
81
- // if the limited mode flag is on, enable limited mode based on the threshold
82
- // only for the first time
83
108
  const limitedMode = isLimitedModeEnabled(editorView);
84
109
  const isEmptyDoc = isEmptyDocument(editorView.state.doc);
85
110
  const provider = new NodeAnchorProvider(limitedMode, isEmptyDoc);
@@ -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 = "120.6.1";
17
+ const packageVersion = "120.6.2";
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 = "120.6.1";
23
+ var packageVersion = "120.6.2";
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,27 @@
1
1
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
2
  import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
4
5
  import { isEmptyDocument } from '../utils';
5
6
  import { DynamicBitArray } from './dynamic-bit-array';
6
7
  import { shouldEnableLimitedModeForDocument } from './should-enable-limited-mode';
8
+
9
+ // The slice of `@atlaskit/editor-plugin-limited-mode`'s state read below. Declared
10
+ // structurally because `editor-common` must not depend on a plugin package.
11
+
12
+ // The real key stays in `@atlaskit/editor-plugin-limited-mode`; importing it would make
13
+ // `editor-common` depend on a plugin package, so match the state property by name.
14
+ // `'limitedModePlugin$'` is what ProseMirror derives for `new PluginKey('limitedModePlugin')`,
15
+ // and editor-plugin-limited-mode-tests asserts that literal to catch it shifting to `$1`.
16
+ // Please, do not copy or use this kind of code below
17
+ // @ts-ignore
18
+ var limitedModePluginKey = {
19
+ key: 'limitedModePlugin$',
20
+ getState: function getState(state) {
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ return state['limitedModePlugin$'];
23
+ }
24
+ };
7
25
  export var NodeAnchorProvider = /*#__PURE__*/function () {
8
26
  function NodeAnchorProvider() {
9
27
  var limitedMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -74,6 +92,9 @@ export var NodeAnchorProvider = /*#__PURE__*/function () {
74
92
  // After set to limited mode, we clear the cache to free up memory
75
93
  // and prevent further ids from being generated
76
94
  // Once in limited mode, we won't exit it
95
+ //
96
+ // One-way by design, so this can stay latched on after the plugin flips back to
97
+ // off: recovering would mean re-rendering every nodeview to restore its anchor.
77
98
  }, {
78
99
  key: "setLimitedMode",
79
100
  value: function setLimitedMode() {
@@ -87,12 +108,16 @@ export var NodeAnchorProvider = /*#__PURE__*/function () {
87
108
  var nodeIdProviderMap = new WeakMap();
88
109
 
89
110
  /**
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.
111
+ * Reads the limited-mode plugin's state and nothing else, so a preset without the plugin no longer
112
+ * gets anchor suppression (and with it, no drag handles). No plugin means limited mode is off.
113
+ *
114
+ * Read off the state rather than the plugin injection API because plugin `state.init` is the only
115
+ * thing that has run by the time the `EditorView` constructor builds its first nodeview and calls
116
+ * `getNodeIdProvider`. Plugin views and `usePluginHook` both run later.
93
117
  */
94
118
  var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
95
- return shouldEnableLimitedModeForDocument(editorView.state.doc);
119
+ var _limitedModePluginKey, _limitedModePluginKey2;
120
+ return fg('platform_editor_fix_limited_mode_leaking') ? (_limitedModePluginKey = (_limitedModePluginKey2 = limitedModePluginKey.getState(editorView.state)) === null || _limitedModePluginKey2 === void 0 ? void 0 : _limitedModePluginKey2.documentSizeBreachesThreshold) !== null && _limitedModePluginKey !== void 0 ? _limitedModePluginKey : false : shouldEnableLimitedModeForDocument(editorView.state.doc);
96
121
  };
97
122
 
98
123
  // Get the NodeIdProvider for a specific EditorView instance.
@@ -100,8 +125,6 @@ var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
100
125
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
101
126
  export var getNodeIdProvider = function getNodeIdProvider(editorView) {
102
127
  if (!nodeIdProviderMap.has(editorView)) {
103
- // if the limited mode flag is on, enable limited mode based on the threshold
104
- // only for the first time
105
128
  var limitedMode = isLimitedModeEnabled(editorView);
106
129
  var isEmptyDoc = isEmptyDocument(editorView.state.doc);
107
130
  var provider = new NodeAnchorProvider(limitedMode, isEmptyDoc);
@@ -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 = "120.6.1";
24
+ var packageVersion = "120.6.2";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "120.6.2",
3
+ "version": "120.7.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/"
@@ -84,8 +84,8 @@
84
84
  "@atlaskit/task-decision": "^21.8.0",
85
85
  "@atlaskit/teams-app-config": "^3.0.0",
86
86
  "@atlaskit/textfield": "^10.1.0",
87
- "@atlaskit/tmp-editor-statsig": "^166.0.0",
88
- "@atlaskit/tokens": "^16.8.0",
87
+ "@atlaskit/tmp-editor-statsig": "^167.0.0",
88
+ "@atlaskit/tokens": "^16.9.0",
89
89
  "@atlaskit/tooltip": "^24.2.0",
90
90
  "@atlaskit/width-detector": "^7.1.0",
91
91
  "@babel/runtime": "^7.0.0",
@@ -208,6 +208,9 @@
208
208
  "platform_editor_inline_node_virt_threshold_override": {
209
209
  "type": "boolean"
210
210
  },
211
+ "platform_editor_fix_limited_mode_leaking": {
212
+ "type": "boolean"
213
+ },
211
214
  "confluence-issue-terminology-refresh": {
212
215
  "type": "boolean"
213
216
  },