@atlaskit/editor-plugin-table 26.0.10 → 26.1.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,21 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 26.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`2d23b40eed4f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2d23b40eed4f0) -
8
+ Add gated content-visibility:auto to tables, expands and media singles to improve editor rendering
9
+ performance on large documents. Applied only to nodes whose rendered size can be estimated closely
10
+ — structurally (row/child counts) for tables and expands, and from the media's own dimensions and
11
+ the renderer's width calculation for media singles. Behind the
12
+ cc_editor_limited_mode_perf_improvements experiment and only active when limited mode is enabled
13
+ for the document (shared large-document detection with the limited-mode plugin).
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 26.0.10
4
20
 
5
21
  ### Patch Changes
@@ -18,6 +18,7 @@ var _coreUtils = require("@atlaskit/editor-common/core-utils");
18
18
  var _nodeWidth = require("@atlaskit/editor-common/node-width");
19
19
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
20
20
  var _table = require("@atlaskit/editor-common/table");
21
+ var _contentVisibility = require("@atlaskit/editor-common/utils/content-visibility");
21
22
  var _model = require("@atlaskit/editor-prosemirror/model");
22
23
  var _state = require("@atlaskit/editor-prosemirror/state");
23
24
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
@@ -74,6 +75,7 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
74
75
  _this = _callSuper(this, TableView, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined,
75
76
  // @portal-render-immediately
76
77
  true]);
78
+ (0, _defineProperty2.default)(_this, "isNestedTable", false);
77
79
  (0, _defineProperty2.default)(_this, "getNode", function () {
78
80
  return _this.node;
79
81
  });
@@ -115,6 +117,8 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
115
117
  var tableElement = rendered.dom.querySelector('table');
116
118
  this.table = tableElement ? tableElement : rendered.dom;
117
119
  this.renderedDOM = rendered.dom;
120
+ this.isNestedTable = isNested;
121
+ this.updateContentVisibility();
118
122
  var allowFixedColumnWidthOption = ((_this$reactComponentP5 = this.reactComponentProps) === null || _this$reactComponentP5 === void 0 ? void 0 : _this$reactComponentP5.allowFixedColumnWidthOption) || false;
119
123
  if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled && allowFixedColumnWidthOption && this.node.attrs.displayMode === 'fixed') {
120
124
  var tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos(), this.reactComponentProps.allowTableResizing);
@@ -264,6 +268,35 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
264
268
  }
265
269
  }
266
270
  }
271
+ }, {
272
+ key: "updateContentVisibility",
273
+ value: function updateContentVisibility() {
274
+ var _this$reactComponentP9,
275
+ _limitedMode$sharedSt,
276
+ _this4 = this;
277
+ if (this.isNestedTable || !this.table) {
278
+ return;
279
+ }
280
+ // Read limited mode from the nodeView's own `this.view.state` via the plugin key exposed on
281
+ // the (already-typed) shared state, NOT `currentState().enabled`: during initial EditorView
282
+ // construction the injection API's editor state is undefined, so `.enabled` reads a stale false.
283
+ var limitedMode = (_this$reactComponentP9 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP9 === void 0 ? void 0 : _this$reactComponentP9.limitedMode;
284
+ var enabled = Boolean(limitedMode === null || limitedMode === void 0 || (_limitedMode$sharedSt = limitedMode.sharedState.currentState()) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.limitedModePluginKey) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.getState(this.view.state)) === null || _limitedMode$sharedSt === void 0 ? void 0 : _limitedMode$sharedSt.documentSizeBreachesThreshold);
285
+ var applied = (0, _contentVisibility.applyContentVisibility)(this.table, enabled, function () {
286
+ return {
287
+ // The `<table>` is content-sized (`display: table`), so it needs an explicit intrinsic
288
+ // width or it collapses to 0 wide while contained. `getTableContainerWidth` covers
289
+ // wide/full-width tables; explicit inline widths (resizable tables) simply override it.
290
+ width: (0, _nodeWidth.getTableContainerWidth)(_this4.node),
291
+ height: (0, _contentVisibility.estimateTableIntrinsicHeight)(_this4.node)
292
+ };
293
+ });
294
+ // Marker for the shared table CSS: when content-visibility (→ contain: paint) is actually
295
+ // applied, it pulls the `::after` outer-border overlay from `inset: -0.5px` to `inset: 0` so
296
+ // paint clipping doesn't shave the border. Keyed off the real applied style so it stays in
297
+ // sync with the gate inside applyContentVisibility.
298
+ this.table.toggleAttribute('data-content-visibility', applied);
299
+ }
267
300
  }, {
268
301
  key: "update",
269
302
  value: function update(node, decorations, innerDecorations, validUpdate) {
@@ -272,6 +305,9 @@ var TableView = exports.default = /*#__PURE__*/function (_ReactNodeView) {
272
305
  // Keep the rounded-corner edge attrs in sync with structural changes (rows/columns
273
306
  // added, removed, merged, or reordered via drag-and-drop) that the cells themselves
274
307
  // can miss.
308
+ if (didUpdate) {
309
+ this.updateContentVisibility();
310
+ }
275
311
  if (didUpdate && (0, _expValEquals.expValEquals)('platform_editor_table_q4_loveability', 'isEnabled', true)) {
276
312
  var _this$roundedTableEdg;
277
313
  (_this$roundedTableEdg = this.roundedTableEdges) === null || _this$roundedTableEdg === void 0 || _this$roundedTableEdg.handleUpdate(node);
@@ -4,6 +4,7 @@ import { isSSRStreaming } from '@atlaskit/editor-common/core-utils';
4
4
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
5
5
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
6
6
  import { isTableInContentMode } from '@atlaskit/editor-common/table';
7
+ import { applyContentVisibility, estimateTableIntrinsicHeight } from '@atlaskit/editor-common/utils/content-visibility';
7
8
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
8
9
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
9
10
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
@@ -55,6 +56,7 @@ export default class TableView extends ReactNodeView {
55
56
  super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined,
56
57
  // @portal-render-immediately
57
58
  true);
59
+ _defineProperty(this, "isNestedTable", false);
58
60
  _defineProperty(this, "getNode", () => {
59
61
  return this.node;
60
62
  });
@@ -88,6 +90,8 @@ export default class TableView extends ReactNodeView {
88
90
  const tableElement = rendered.dom.querySelector('table');
89
91
  this.table = tableElement ? tableElement : rendered.dom;
90
92
  this.renderedDOM = rendered.dom;
93
+ this.isNestedTable = isNested;
94
+ this.updateContentVisibility();
91
95
  const allowFixedColumnWidthOption = ((_this$reactComponentP5 = this.reactComponentProps) === null || _this$reactComponentP5 === void 0 ? void 0 : _this$reactComponentP5.allowFixedColumnWidthOption) || false;
92
96
  if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled && allowFixedColumnWidthOption && this.node.attrs.displayMode === 'fixed') {
93
97
  const tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos(), this.reactComponentProps.allowTableResizing);
@@ -229,12 +233,38 @@ export default class TableView extends ReactNodeView {
229
233
  }
230
234
  }
231
235
  }
236
+ updateContentVisibility() {
237
+ var _this$reactComponentP9, _limitedMode$sharedSt, _limitedMode$sharedSt2, _limitedMode$sharedSt3;
238
+ if (this.isNestedTable || !this.table) {
239
+ return;
240
+ }
241
+ // Read limited mode from the nodeView's own `this.view.state` via the plugin key exposed on
242
+ // the (already-typed) shared state, NOT `currentState().enabled`: during initial EditorView
243
+ // construction the injection API's editor state is undefined, so `.enabled` reads a stale false.
244
+ const limitedMode = (_this$reactComponentP9 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP9 === void 0 ? void 0 : _this$reactComponentP9.limitedMode;
245
+ const enabled = Boolean(limitedMode === null || limitedMode === void 0 ? void 0 : (_limitedMode$sharedSt = limitedMode.sharedState.currentState()) === null || _limitedMode$sharedSt === void 0 ? void 0 : (_limitedMode$sharedSt2 = _limitedMode$sharedSt.limitedModePluginKey) === null || _limitedMode$sharedSt2 === void 0 ? void 0 : (_limitedMode$sharedSt3 = _limitedMode$sharedSt2.getState(this.view.state)) === null || _limitedMode$sharedSt3 === void 0 ? void 0 : _limitedMode$sharedSt3.documentSizeBreachesThreshold);
246
+ const applied = applyContentVisibility(this.table, enabled, () => ({
247
+ // The `<table>` is content-sized (`display: table`), so it needs an explicit intrinsic
248
+ // width or it collapses to 0 wide while contained. `getTableContainerWidth` covers
249
+ // wide/full-width tables; explicit inline widths (resizable tables) simply override it.
250
+ width: getTableContainerWidth(this.node),
251
+ height: estimateTableIntrinsicHeight(this.node)
252
+ }));
253
+ // Marker for the shared table CSS: when content-visibility (→ contain: paint) is actually
254
+ // applied, it pulls the `::after` outer-border overlay from `inset: -0.5px` to `inset: 0` so
255
+ // paint clipping doesn't shave the border. Keyed off the real applied style so it stays in
256
+ // sync with the gate inside applyContentVisibility.
257
+ this.table.toggleAttribute('data-content-visibility', applied);
258
+ }
232
259
  update(node, decorations, innerDecorations, validUpdate) {
233
260
  const didUpdate = super.update(node, decorations, innerDecorations, validUpdate);
234
261
 
235
262
  // Keep the rounded-corner edge attrs in sync with structural changes (rows/columns
236
263
  // added, removed, merged, or reordered via drag-and-drop) that the cells themselves
237
264
  // can miss.
265
+ if (didUpdate) {
266
+ this.updateContentVisibility();
267
+ }
238
268
  if (didUpdate && expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
239
269
  var _this$roundedTableEdg;
240
270
  (_this$roundedTableEdg = this.roundedTableEdges) === null || _this$roundedTableEdg === void 0 ? void 0 : _this$roundedTableEdg.handleUpdate(node);
@@ -14,6 +14,7 @@ import { isSSRStreaming } from '@atlaskit/editor-common/core-utils';
14
14
  import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
15
15
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
16
16
  import { isTableInContentMode } from '@atlaskit/editor-common/table';
17
+ import { applyContentVisibility, estimateTableIntrinsicHeight } from '@atlaskit/editor-common/utils/content-visibility';
17
18
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
18
19
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
19
20
  import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
@@ -67,6 +68,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
67
68
  _this = _callSuper(this, TableView, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props, undefined, undefined,
68
69
  // @portal-render-immediately
69
70
  true]);
71
+ _defineProperty(_this, "isNestedTable", false);
70
72
  _defineProperty(_this, "getNode", function () {
71
73
  return _this.node;
72
74
  });
@@ -108,6 +110,8 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
108
110
  var tableElement = rendered.dom.querySelector('table');
109
111
  this.table = tableElement ? tableElement : rendered.dom;
110
112
  this.renderedDOM = rendered.dom;
113
+ this.isNestedTable = isNested;
114
+ this.updateContentVisibility();
111
115
  var allowFixedColumnWidthOption = ((_this$reactComponentP5 = this.reactComponentProps) === null || _this$reactComponentP5 === void 0 ? void 0 : _this$reactComponentP5.allowFixedColumnWidthOption) || false;
112
116
  if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.isTableScalingEnabled) || (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.isTableScalingEnabled && allowFixedColumnWidthOption && this.node.attrs.displayMode === 'fixed') {
113
117
  var tableInlineWidth = getInlineWidth(this.node, this.reactComponentProps.options, this.reactComponentProps.view.state, this.reactComponentProps.getPos(), this.reactComponentProps.allowTableResizing);
@@ -257,6 +261,35 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
257
261
  }
258
262
  }
259
263
  }
264
+ }, {
265
+ key: "updateContentVisibility",
266
+ value: function updateContentVisibility() {
267
+ var _this$reactComponentP9,
268
+ _limitedMode$sharedSt,
269
+ _this4 = this;
270
+ if (this.isNestedTable || !this.table) {
271
+ return;
272
+ }
273
+ // Read limited mode from the nodeView's own `this.view.state` via the plugin key exposed on
274
+ // the (already-typed) shared state, NOT `currentState().enabled`: during initial EditorView
275
+ // construction the injection API's editor state is undefined, so `.enabled` reads a stale false.
276
+ var limitedMode = (_this$reactComponentP9 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP9 === void 0 ? void 0 : _this$reactComponentP9.limitedMode;
277
+ var enabled = Boolean(limitedMode === null || limitedMode === void 0 || (_limitedMode$sharedSt = limitedMode.sharedState.currentState()) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.limitedModePluginKey) === null || _limitedMode$sharedSt === void 0 || (_limitedMode$sharedSt = _limitedMode$sharedSt.getState(this.view.state)) === null || _limitedMode$sharedSt === void 0 ? void 0 : _limitedMode$sharedSt.documentSizeBreachesThreshold);
278
+ var applied = applyContentVisibility(this.table, enabled, function () {
279
+ return {
280
+ // The `<table>` is content-sized (`display: table`), so it needs an explicit intrinsic
281
+ // width or it collapses to 0 wide while contained. `getTableContainerWidth` covers
282
+ // wide/full-width tables; explicit inline widths (resizable tables) simply override it.
283
+ width: getTableContainerWidth(_this4.node),
284
+ height: estimateTableIntrinsicHeight(_this4.node)
285
+ };
286
+ });
287
+ // Marker for the shared table CSS: when content-visibility (→ contain: paint) is actually
288
+ // applied, it pulls the `::after` outer-border overlay from `inset: -0.5px` to `inset: 0` so
289
+ // paint clipping doesn't shave the border. Keyed off the real applied style so it stays in
290
+ // sync with the gate inside applyContentVisibility.
291
+ this.table.toggleAttribute('data-content-visibility', applied);
292
+ }
260
293
  }, {
261
294
  key: "update",
262
295
  value: function update(node, decorations, innerDecorations, validUpdate) {
@@ -265,6 +298,9 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
265
298
  // Keep the rounded-corner edge attrs in sync with structural changes (rows/columns
266
299
  // added, removed, merged, or reordered via drag-and-drop) that the cells themselves
267
300
  // can miss.
301
+ if (didUpdate) {
302
+ this.updateContentVisibility();
303
+ }
268
304
  if (didUpdate && expValEquals('platform_editor_table_q4_loveability', 'isEnabled', true)) {
269
305
  var _this$roundedTableEdg;
270
306
  (_this$roundedTableEdg = this.roundedTableEdges) === null || _this$roundedTableEdg === void 0 || _this$roundedTableEdg.handleUpdate(node);
@@ -16,6 +16,7 @@ export default class TableView extends ReactNodeView<Props> {
16
16
  private resizeObserver?;
17
17
  private roundedTableEdges;
18
18
  private intl?;
19
+ private isNestedTable;
19
20
  eventDispatcher?: EventDispatcher;
20
21
  getPos: getPosHandlerNode;
21
22
  options: TableOptions | undefined;
@@ -35,6 +36,7 @@ export default class TableView extends ReactNodeView<Props> {
35
36
  private _handleTableRef;
36
37
  setDomAttrs(node: PmNode): void;
37
38
  getNode: () => PmNode;
39
+ private updateContentVisibility;
38
40
  update(node: PmNode, decorations: ReadonlyArray<Decoration>, innerDecorations?: DecorationSource, validUpdate?: (currentNode: PmNode, newNode: PmNode) => boolean): boolean;
39
41
  render(props: Props, forwardRef: ForwardRef): React.JSX.Element;
40
42
  private hasHoveredRows;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "26.0.10",
3
+ "version": "26.1.0",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -68,7 +68,7 @@
68
68
  "uuid": "^3.1.0"
69
69
  },
70
70
  "peerDependencies": {
71
- "@atlaskit/editor-common": "^118.10.0",
71
+ "@atlaskit/editor-common": "^118.11.0",
72
72
  "react": "^18.2.0 || ^19.2.0",
73
73
  "react-dom": "^18.2.0 || ^19.2.0",
74
74
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"