@atlaskit/editor-plugin-table 2.10.3 → 2.10.4

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,11 @@
1
1
  # @atlaskit/editor-plugin-table
2
2
 
3
+ ## 2.10.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`eefbc3c6065`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eefbc3c6065) - [ED-19510] Applies performance tweaks for table
8
+
3
9
  ## 2.10.3
4
10
 
5
11
  ### Patch Changes
@@ -13,6 +13,7 @@ var _transforms = require("@atlaskit/editor-common/transforms");
13
13
  var _utils = require("@atlaskit/editor-common/utils");
14
14
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
15
  var _utils3 = require("@atlaskit/editor-tables/utils");
16
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
16
17
  var _commands = require("../commands");
17
18
  var _misc = require("../commands/misc");
18
19
  var _eventHandlers = require("../event-handlers");
@@ -132,8 +133,12 @@ var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, porta
132
133
  if (pluginState.tableRef !== tableRef) {
133
134
  (0, _commands.setTableRef)(tableRef)(state, dispatch);
134
135
  }
135
- if (pluginState.tableNode !== tableNode) {
136
- (0, _utils4.updateResizeHandles)(tableRef);
136
+
137
+ // Removes updateResizeHandles
138
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
139
+ if (pluginState.tableNode !== tableNode) {
140
+ (0, _utils4.updateResizeHandles)(tableRef);
141
+ }
137
142
  }
138
143
  if (pluginState.editorHasFocus && pluginState.tableRef) {
139
144
  var _ref = state.selection,
@@ -140,7 +140,10 @@ var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos
140
140
  var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
141
141
  (0, _utils3.resizeColumn)(resizeState, colIndex, clientX - dragging.startX, dom);
142
142
  (0, _utils3.updateControls)()(state);
143
- (0, _utils2.updateResizeHandles)(dom);
143
+ // Remove updateResizeHandles
144
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
145
+ (0, _utils2.updateResizeHandles)(dom);
146
+ }
144
147
  }
145
148
  window.addEventListener('mouseup', finish);
146
149
  window.addEventListener('mousemove', move);
@@ -93,6 +93,7 @@ var TableCssClassName = _objectSpread(_objectSpread({}, _styles.TableSharedCssCl
93
93
  RESIZING_PLUGIN: "".concat(_adfSchema.tablePrefixSelector, "-resizing-plugin"),
94
94
  RESIZE_CURSOR: "".concat(_adfSchema.tablePrefixSelector, "-resize-cursor"),
95
95
  IS_RESIZING: "".concat(_adfSchema.tablePrefixSelector, "-is-resizing"),
96
+ // Resize handle is going to be removed together with updateResizeHandles - table's utility function
96
97
  RESIZE_HANDLE: "".concat(_adfSchema.tablePrefixSelector, "-resize-handle"),
97
98
  RESIZE_HANDLE_DECORATION: "".concat(_adfSchema.tablePrefixSelector, "-resize-decoration"),
98
99
  CONTEXTUAL_SUBMENU: "".concat(_adfSchema.tablePrefixSelector, "-contextual-submenu"),
@@ -135,17 +135,20 @@ var getMousePositionVerticalRelativeByElement = function getMousePositionVertica
135
135
  }
136
136
  return null;
137
137
  };
138
+
139
+ // This function is deprecated
138
140
  exports.getMousePositionVerticalRelativeByElement = getMousePositionVerticalRelativeByElement;
139
141
  var updateResizeHandles = function updateResizeHandles(tableRef) {
140
142
  if (!tableRef) {
141
143
  return;
142
144
  }
143
- var height = tableRef.offsetHeight + _consts.tableToolbarSize;
145
+
144
146
  // see ED-7600
145
147
  var nodes = Array.from(tableRef.querySelectorAll(".".concat(_types.TableCssClassName.RESIZE_HANDLE)));
146
148
  if (!nodes || !nodes.length) {
147
149
  return;
148
150
  }
151
+ var height = tableRef.offsetHeight + _consts.tableToolbarSize;
149
152
  nodes.forEach(function (node) {
150
153
  node.style.height = "".concat(height, "px");
151
154
  });
@@ -5,6 +5,7 @@ import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenEx
5
5
  import { browser, closestElement } from '@atlaskit/editor-common/utils';
6
6
  import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { findTable } from '@atlaskit/editor-tables/utils';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
9
10
  import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
10
11
  import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
@@ -117,8 +118,12 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
117
118
  if (pluginState.tableRef !== tableRef) {
118
119
  setTableRef(tableRef)(state, dispatch);
119
120
  }
120
- if (pluginState.tableNode !== tableNode) {
121
- updateResizeHandles(tableRef);
121
+
122
+ // Removes updateResizeHandles
123
+ if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
124
+ if (pluginState.tableNode !== tableNode) {
125
+ updateResizeHandles(tableRef);
126
+ }
122
127
  }
123
128
  if (pluginState.editorHasFocus && pluginState.tableRef) {
124
129
  const {
@@ -150,7 +150,10 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
150
150
  const colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
151
151
  resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
152
152
  updateControls()(state);
153
- updateResizeHandles(dom);
153
+ // Remove updateResizeHandles
154
+ if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
155
+ updateResizeHandles(dom);
156
+ }
154
157
  }
155
158
  window.addEventListener('mouseup', finish);
156
159
  window.addEventListener('mousemove', move);
@@ -83,6 +83,7 @@ export const TableCssClassName = {
83
83
  RESIZING_PLUGIN: `${tablePrefixSelector}-resizing-plugin`,
84
84
  RESIZE_CURSOR: `${tablePrefixSelector}-resize-cursor`,
85
85
  IS_RESIZING: `${tablePrefixSelector}-is-resizing`,
86
+ // Resize handle is going to be removed together with updateResizeHandles - table's utility function
86
87
  RESIZE_HANDLE: `${tablePrefixSelector}-resize-handle`,
87
88
  RESIZE_HANDLE_DECORATION: `${tablePrefixSelector}-resize-decoration`,
88
89
  CONTEXTUAL_SUBMENU: `${tablePrefixSelector}-contextual-submenu`,
@@ -104,16 +104,19 @@ export const getMousePositionVerticalRelativeByElement = mouseEvent => {
104
104
  }
105
105
  return null;
106
106
  };
107
+
108
+ // This function is deprecated
107
109
  export const updateResizeHandles = tableRef => {
108
110
  if (!tableRef) {
109
111
  return;
110
112
  }
111
- const height = tableRef.offsetHeight + tableToolbarSize;
113
+
112
114
  // see ED-7600
113
115
  const nodes = Array.from(tableRef.querySelectorAll(`.${ClassName.RESIZE_HANDLE}`));
114
116
  if (!nodes || !nodes.length) {
115
117
  return;
116
118
  }
119
+ const height = tableRef.offsetHeight + tableToolbarSize;
117
120
  nodes.forEach(node => {
118
121
  node.style.height = `${height}px`;
119
122
  });
@@ -8,6 +8,7 @@ import { transformSliceToRemoveOpenBodiedExtension, transformSliceToRemoveOpenEx
8
8
  import { browser, closestElement } from '@atlaskit/editor-common/utils';
9
9
  import { findParentDomRefOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { findTable } from '@atlaskit/editor-tables/utils';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
11
12
  import { addBoldInEmptyHeaderCells, clearHoverSelection, setTableRef } from '../commands';
12
13
  import { transformSliceRemoveCellBackgroundColor, transformSliceToAddTableHeaders, transformSliceToRemoveColumnsWidths } from '../commands/misc';
13
14
  import { handleBlur, handleClick, handleCut, handleFocus, handleMouseDown, handleMouseLeave, handleMouseMove, handleMouseOut, handleMouseOver, handleTripleClick, whenTableInFocus } from '../event-handlers';
@@ -125,8 +126,12 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
125
126
  if (pluginState.tableRef !== tableRef) {
126
127
  setTableRef(tableRef)(state, dispatch);
127
128
  }
128
- if (pluginState.tableNode !== tableNode) {
129
- updateResizeHandles(tableRef);
129
+
130
+ // Removes updateResizeHandles
131
+ if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
132
+ if (pluginState.tableNode !== tableNode) {
133
+ updateResizeHandles(tableRef);
134
+ }
130
135
  }
131
136
  if (pluginState.editorHasFocus && pluginState.tableRef) {
132
137
  var _ref = state.selection,
@@ -134,7 +134,10 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
134
134
  var colIndex = map.colCount($cell.pos - $cell.start(-1)) + $cell.nodeAfter.attrs.colspan - 1;
135
135
  resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
136
136
  updateControls()(state);
137
- updateResizeHandles(dom);
137
+ // Remove updateResizeHandles
138
+ if (getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')) {} else {
139
+ updateResizeHandles(dom);
140
+ }
138
141
  }
139
142
  window.addEventListener('mouseup', finish);
140
143
  window.addEventListener('mousemove', move);
@@ -85,6 +85,7 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
85
85
  RESIZING_PLUGIN: "".concat(tablePrefixSelector, "-resizing-plugin"),
86
86
  RESIZE_CURSOR: "".concat(tablePrefixSelector, "-resize-cursor"),
87
87
  IS_RESIZING: "".concat(tablePrefixSelector, "-is-resizing"),
88
+ // Resize handle is going to be removed together with updateResizeHandles - table's utility function
88
89
  RESIZE_HANDLE: "".concat(tablePrefixSelector, "-resize-handle"),
89
90
  RESIZE_HANDLE_DECORATION: "".concat(tablePrefixSelector, "-resize-decoration"),
90
91
  CONTEXTUAL_SUBMENU: "".concat(tablePrefixSelector, "-contextual-submenu"),
@@ -120,16 +120,19 @@ export var getMousePositionVerticalRelativeByElement = function getMousePosition
120
120
  }
121
121
  return null;
122
122
  };
123
+
124
+ // This function is deprecated
123
125
  export var updateResizeHandles = function updateResizeHandles(tableRef) {
124
126
  if (!tableRef) {
125
127
  return;
126
128
  }
127
- var height = tableRef.offsetHeight + tableToolbarSize;
129
+
128
130
  // see ED-7600
129
131
  var nodes = Array.from(tableRef.querySelectorAll(".".concat(ClassName.RESIZE_HANDLE)));
130
132
  if (!nodes || !nodes.length) {
131
133
  return;
132
134
  }
135
+ var height = tableRef.offsetHeight + tableToolbarSize;
133
136
  nodes.forEach(function (node) {
134
137
  node.style.height = "".concat(height, "px");
135
138
  });
@@ -3,5 +3,5 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
6
- import { PluginConfig, PluginInjectionAPI } from '../types';
6
+ import type { PluginConfig, PluginInjectionAPI } from '../types';
7
7
  export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
@@ -1,5 +1,5 @@
1
1
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
2
- import { ThemeProps } from '@atlaskit/theme/types';
2
+ import type { ThemeProps } from '@atlaskit/theme/types';
3
3
  export declare const insertColumnButtonOffset: number;
4
4
  export declare const tableStyles: (props: ThemeProps & {
5
5
  featureFlags?: FeatureFlags;
@@ -1,4 +1,4 @@
1
- import { ElementContentRects } from '../types';
1
+ import type { ElementContentRects } from '../types';
2
2
  export declare const isCell: (node: HTMLElement | null) => boolean;
3
3
  export declare const isCornerButton: (node: HTMLElement | null) => boolean;
4
4
  export declare const isInsertRowButton: (node: HTMLElement | null) => boolean | HTMLElement | null;
@@ -3,5 +3,5 @@ import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-di
3
3
  import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
5
  import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
6
- import { PluginConfig, PluginInjectionAPI } from '../types';
6
+ import type { PluginConfig, PluginInjectionAPI } from '../types';
7
7
  export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, tableResizingEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
@@ -1,5 +1,5 @@
1
1
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
2
- import { ThemeProps } from '@atlaskit/theme/types';
2
+ import type { ThemeProps } from '@atlaskit/theme/types';
3
3
  export declare const insertColumnButtonOffset: number;
4
4
  export declare const tableStyles: (props: ThemeProps & {
5
5
  featureFlags?: FeatureFlags;
@@ -1,4 +1,4 @@
1
- import { ElementContentRects } from '../types';
1
+ import type { ElementContentRects } from '../types';
2
2
  export declare const isCell: (node: HTMLElement | null) => boolean;
3
3
  export declare const isCornerButton: (node: HTMLElement | null) => boolean;
4
4
  export declare const isInsertRowButton: (node: HTMLElement | null) => boolean | HTMLElement | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "2.10.3",
3
+ "version": "2.10.4",
4
4
  "description": "Table plugin for the @atlaskit/editor",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@atlaskit/adf-schema": "^28.1.0",
31
- "@atlaskit/editor-common": "^74.49.0",
31
+ "@atlaskit/editor-common": "^74.50.0",
32
32
  "@atlaskit/editor-palette": "1.5.1",
33
33
  "@atlaskit/editor-plugin-analytics": "^0.1.0",
34
34
  "@atlaskit/editor-plugin-content-insertion": "^0.0.8",
@@ -105,6 +105,9 @@
105
105
  },
106
106
  "platform.editor.update-table-cell-width-via-step": {
107
107
  "type": "boolean"
108
+ },
109
+ "platform.editor.table-remove-update-resize-handles_djvab": {
110
+ "type": "boolean"
108
111
  }
109
112
  }
110
113
  }
@@ -26,8 +26,8 @@ import type {
26
26
  getPosHandler,
27
27
  } from '@atlaskit/editor-common/types';
28
28
  import { browser, closestElement } from '@atlaskit/editor-common/utils';
29
- import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
30
- import {
29
+ import type { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
30
+ import type {
31
31
  EditorState,
32
32
  TextSelection,
33
33
  Transaction,
@@ -36,8 +36,9 @@ import {
36
36
  findParentDomRefOfType,
37
37
  findParentNodeOfType,
38
38
  } from '@atlaskit/editor-prosemirror/utils';
39
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
39
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
40
40
  import { findTable } from '@atlaskit/editor-tables/utils';
41
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
41
42
 
42
43
  import {
43
44
  addBoldInEmptyHeaderCells,
@@ -66,13 +67,13 @@ import { createTableView } from '../nodeviews/table';
66
67
  import TableCellNodeView from '../nodeviews/tableCell';
67
68
  import { pluginKey as decorationsPluginKey } from '../pm-plugins/decorations/plugin';
68
69
  import { fixTables, replaceSelectedTable } from '../transforms';
69
- import {
70
- TableCssClassName as ClassName,
70
+ import type {
71
71
  ElementContentRects,
72
72
  InvalidNodeAttr,
73
73
  PluginConfig,
74
74
  PluginInjectionAPI,
75
75
  } from '../types';
76
+ import { TableCssClassName as ClassName } from '../types';
76
77
  import {
77
78
  findControlsHoverDecoration,
78
79
  transformSliceToCorrectEmptyTableCells,
@@ -230,8 +231,16 @@ export const createPlugin = (
230
231
  setTableRef(tableRef)(state, dispatch);
231
232
  }
232
233
 
233
- if (pluginState.tableNode !== tableNode) {
234
- updateResizeHandles(tableRef);
234
+ // Removes updateResizeHandles
235
+ if (
236
+ getBooleanFF(
237
+ 'platform.editor.table-remove-update-resize-handles_djvab',
238
+ )
239
+ ) {
240
+ } else {
241
+ if (pluginState.tableNode !== tableNode) {
242
+ updateResizeHandles(tableRef);
243
+ }
235
244
  }
236
245
 
237
246
  if (pluginState.editorHasFocus && pluginState.tableRef) {
@@ -215,7 +215,13 @@ export const handleMouseDown = (
215
215
  resizeColumn(resizeState, colIndex, clientX - dragging.startX, dom);
216
216
 
217
217
  updateControls()(state);
218
- updateResizeHandles(dom);
218
+ // Remove updateResizeHandles
219
+ if (
220
+ getBooleanFF('platform.editor.table-remove-update-resize-handles_djvab')
221
+ ) {
222
+ } else {
223
+ updateResizeHandles(dom);
224
+ }
219
225
  }
220
226
 
221
227
  window.addEventListener('mouseup', finish);
@@ -282,6 +282,7 @@ export const TableCssClassName = {
282
282
  RESIZE_CURSOR: `${tablePrefixSelector}-resize-cursor`,
283
283
  IS_RESIZING: `${tablePrefixSelector}-is-resizing`,
284
284
 
285
+ // Resize handle is going to be removed together with updateResizeHandles - table's utility function
285
286
  RESIZE_HANDLE: `${tablePrefixSelector}-resize-handle`,
286
287
  RESIZE_HANDLE_DECORATION: `${tablePrefixSelector}-resize-decoration`,
287
288
 
@@ -21,7 +21,7 @@ import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
21
21
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
22
22
  import { B300, N0, N20A, N300, N40A, R500 } from '@atlaskit/theme/colors';
23
23
  import { fontSize } from '@atlaskit/theme/constants';
24
- import { ThemeProps } from '@atlaskit/theme/types';
24
+ import type { ThemeProps } from '@atlaskit/theme/types';
25
25
  import { token } from '@atlaskit/tokens';
26
26
 
27
27
  import { TableCssClassName as ClassName } from '../types';
@@ -3,7 +3,8 @@ import {
3
3
  containsClassName,
4
4
  } from '@atlaskit/editor-common/utils';
5
5
 
6
- import { TableCssClassName as ClassName, ElementContentRects } from '../types';
6
+ import { TableCssClassName as ClassName } from '../types';
7
+ import type { ElementContentRects } from '../types';
7
8
  import { tableToolbarSize } from '../ui/consts';
8
9
 
9
10
  const SELECTOR_TABLE_LEAFS = `.${ClassName.TABLE_CELL}, .${ClassName.TABLE_HEADER_CELL}`;
@@ -154,11 +155,12 @@ export const getMousePositionVerticalRelativeByElement = (
154
155
  return null;
155
156
  };
156
157
 
158
+ // This function is deprecated
157
159
  export const updateResizeHandles = (tableRef?: HTMLElement) => {
158
160
  if (!tableRef) {
159
161
  return;
160
162
  }
161
- const height = tableRef.offsetHeight + tableToolbarSize;
163
+
162
164
  // see ED-7600
163
165
  const nodes = Array.from(
164
166
  tableRef.querySelectorAll(
@@ -169,6 +171,7 @@ export const updateResizeHandles = (tableRef?: HTMLElement) => {
169
171
  return;
170
172
  }
171
173
 
174
+ const height = tableRef.offsetHeight + tableToolbarSize;
172
175
  nodes.forEach((node) => {
173
176
  node.style.height = `${height}px`;
174
177
  });