@atlaskit/editor-plugin-table 1.4.1 → 1.5.1

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/cjs/i18n/cs.js +2 -2
  3. package/dist/cjs/i18n/en_ZZ.js +43 -0
  4. package/dist/cjs/i18n/ja.js +4 -4
  5. package/dist/cjs/i18n/ko.js +1 -1
  6. package/dist/cjs/i18n/sv.js +1 -1
  7. package/dist/cjs/i18n/vi.js +2 -2
  8. package/dist/cjs/i18n/zh.js +3 -3
  9. package/dist/cjs/plugins/table/index.js +3 -1
  10. package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -0
  11. package/dist/cjs/plugins/table/nodeviews/table.js +2 -1
  12. package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +10 -0
  13. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  14. package/dist/cjs/plugins/table/ui/consts.js +8 -3
  15. package/dist/cjs/plugins/table/ui/ui-styles.js +2 -2
  16. package/dist/cjs/version.json +1 -1
  17. package/dist/es2019/i18n/cs.js +2 -2
  18. package/dist/es2019/i18n/en_ZZ.js +36 -0
  19. package/dist/es2019/i18n/ja.js +4 -4
  20. package/dist/es2019/i18n/ko.js +1 -1
  21. package/dist/es2019/i18n/sv.js +1 -1
  22. package/dist/es2019/i18n/vi.js +2 -2
  23. package/dist/es2019/i18n/zh.js +3 -3
  24. package/dist/es2019/plugins/table/index.js +4 -2
  25. package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -0
  26. package/dist/es2019/plugins/table/nodeviews/table.js +2 -1
  27. package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +10 -0
  28. package/dist/es2019/plugins/table/ui/common-styles.js +3 -3
  29. package/dist/es2019/plugins/table/ui/consts.js +6 -2
  30. package/dist/es2019/plugins/table/ui/ui-styles.js +3 -3
  31. package/dist/es2019/version.json +1 -1
  32. package/dist/esm/i18n/cs.js +2 -2
  33. package/dist/esm/i18n/en_ZZ.js +36 -0
  34. package/dist/esm/i18n/ja.js +4 -4
  35. package/dist/esm/i18n/ko.js +1 -1
  36. package/dist/esm/i18n/sv.js +1 -1
  37. package/dist/esm/i18n/vi.js +2 -2
  38. package/dist/esm/i18n/zh.js +3 -3
  39. package/dist/esm/plugins/table/index.js +4 -2
  40. package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -0
  41. package/dist/esm/plugins/table/nodeviews/table.js +2 -1
  42. package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +10 -0
  43. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  44. package/dist/esm/plugins/table/ui/consts.js +6 -2
  45. package/dist/esm/plugins/table/ui/ui-styles.js +3 -3
  46. package/dist/esm/version.json +1 -1
  47. package/dist/types/i18n/en_ZZ.d.ts +35 -0
  48. package/dist/types/plugins/table/ui/consts.d.ts +2 -1
  49. package/dist/types-ts4.5/i18n/en_ZZ.d.ts +35 -0
  50. package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -1
  51. package/examples/99-testing.tsx +1 -4
  52. package/package.json +16 -7
  53. package/src/__tests__/integration/auto-size.ts +6 -2
  54. package/src/__tests__/integration/sticky-header.ts +6 -5
  55. package/src/__tests__/unit/collab.ts +1 -1
  56. package/src/__tests__/unit/color-picker.ts +4 -0
  57. package/src/__tests__/unit/commands/insert.ts +1 -1
  58. package/src/__tests__/unit/commands/misc.ts +2 -0
  59. package/src/__tests__/unit/commands.ts +4 -2
  60. package/src/__tests__/unit/event-handlers.ts +4 -2
  61. package/src/__tests__/unit/get-toolbar-config.ts +4 -0
  62. package/src/__tests__/unit/index.ts +4 -2
  63. package/src/__tests__/unit/keymap.ts +4 -2
  64. package/src/__tests__/unit/layout.ts +4 -0
  65. package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +4 -0
  66. package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +3 -1
  67. package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +2 -0
  68. package/src/__tests__/unit/undo-redo.ts +1 -1
  69. package/src/__tests__/unit/utils/collapse.ts +4 -1
  70. package/src/i18n/cs.ts +2 -2
  71. package/src/i18n/en_ZZ.ts +41 -0
  72. package/src/i18n/ja.ts +4 -4
  73. package/src/i18n/ko.ts +1 -1
  74. package/src/i18n/sv.ts +1 -1
  75. package/src/i18n/vi.ts +2 -2
  76. package/src/i18n/zh.ts +3 -3
  77. package/src/plugins/table/index.tsx +13 -2
  78. package/src/plugins/table/nodeviews/TableComponent.tsx +6 -0
  79. package/src/plugins/table/nodeviews/table.tsx +1 -0
  80. package/src/plugins/table/pm-plugins/table-resizing/utils/resize-state.ts +11 -0
  81. package/src/plugins/table/ui/common-styles.ts +3 -3
  82. package/src/plugins/table/ui/consts.ts +6 -2
  83. package/src/plugins/table/ui/ui-styles.ts +3 -3
package/src/i18n/vi.ts CHANGED
@@ -12,7 +12,7 @@ export default {
12
12
  'fabric.editor.cellOptions': 'Tùy chọn ô',
13
13
  'fabric.editor.clearCells': '{0, plural, other {Xóa ô}}',
14
14
  'fabric.editor.collapseTable': 'Thu gọn bảng',
15
- 'fabric.editor.cornerControl': 'Bảng nổi bật',
15
+ 'fabric.editor.cornerControl': 'Làm nổi bật bảng',
16
16
  'fabric.editor.distributeColumns': 'Phân phối cột',
17
17
  'fabric.editor.extension.deleteElementTitle': 'Xóa thành phần',
18
18
  'fabric.editor.floatingToolbar.confirmModalCheckboxLabel': 'Đồng thời xóa các thành phần được kết nối',
@@ -24,7 +24,7 @@ export default {
24
24
  'fabric.editor.numberedColumn': 'Cột được đánh số',
25
25
  'fabric.editor.removeColumns': '{0, plural, other {Xóa cột}}',
26
26
  'fabric.editor.removeRows': '{0, plural, other {Xóa hàng}}',
27
- 'fabric.editor.rowControl': 'Hàng nổi bật',
27
+ 'fabric.editor.rowControl': 'Làm nổi bật hàng',
28
28
  'fabric.editor.sortColumnASC': 'Sắp xếp cột A → Z',
29
29
  'fabric.editor.sortColumnDESC': 'Sắp xếp cột Z → A',
30
30
  'fabric.editor.splitCell': 'Tách ô',
package/src/i18n/zh.ts CHANGED
@@ -18,8 +18,8 @@ export default {
18
18
  'fabric.editor.extension.deleteElementTitle': '删除元素',
19
19
  'fabric.editor.extension.sourceNoTitledName': '此元素',
20
20
  'fabric.editor.floatingToolbar.confirmModalCheckboxLabel': '同时删除已连接的元素',
21
- 'fabric.editor.headerColumn': '标头列',
22
- 'fabric.editor.headerRow': '表头行',
21
+ 'fabric.editor.headerColumn': '标题列',
22
+ 'fabric.editor.headerRow': '标题行',
23
23
  'fabric.editor.insertColumn': '在右侧插入列',
24
24
  'fabric.editor.insertRow': '在下方插入行',
25
25
  'fabric.editor.mergeCells': '合并单元格',
@@ -29,7 +29,7 @@ export default {
29
29
  'fabric.editor.rowControl': '突出显示行',
30
30
  'fabric.editor.sortColumnASC': '对列 A → Z 进行排序',
31
31
  'fabric.editor.sortColumnDESC': '对列 Z → A 进行排序',
32
- 'fabric.editor.splitCell': '分离单元格',
32
+ 'fabric.editor.splitCell': '拆分单元格',
33
33
  'fabric.editor.tableOptions': '表格选项',
34
34
  'fabric.editor.tables.confirmDeleteLinkedModalMessage': '删除 {nodeName} 将断开与其连接的所有内容。',
35
35
  'fabric.editor.tables.confirmDeleteLinkedModalOKButton': '删除',
@@ -7,7 +7,13 @@ import { browser } from '@atlaskit/editor-common/utils';
7
7
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
8
8
  import { createTable } from '@atlaskit/editor-tables/utils';
9
9
 
10
- import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
10
+ import {
11
+ table,
12
+ tableCell,
13
+ tableHeader,
14
+ tableRow,
15
+ tableWithCustomWidth,
16
+ } from '@atlaskit/adf-schema';
11
17
 
12
18
  import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
13
19
 
@@ -63,6 +69,7 @@ import type {
63
69
  import { EditorState, Transaction } from 'prosemirror-state';
64
70
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
65
71
  import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
72
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
66
73
 
67
74
  interface TablePluginOptions {
68
75
  tableOptions: PluginConfig;
@@ -135,8 +142,12 @@ const tablesPlugin: NextEditorPlugin<
135
142
  },
136
143
 
137
144
  nodes() {
145
+ const tableNode = getBooleanFF('platform.editor.custom-table-width')
146
+ ? tableWithCustomWidth
147
+ : table;
148
+
138
149
  return [
139
- { name: 'table', node: table },
150
+ { name: 'table', node: tableNode },
140
151
  { name: 'tableHeader', node: tableHeader },
141
152
  { name: 'tableRow', node: tableRow },
142
153
  { name: 'tableCell', node: tableCell },
@@ -5,6 +5,7 @@ import { isTableSelected } from '@atlaskit/editor-tables/utils';
5
5
  import { EditorView } from 'prosemirror-view';
6
6
  import rafSchedule from 'raf-schd';
7
7
  import { findTable } from '@atlaskit/editor-tables/utils';
8
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
 
9
10
  import {
10
11
  calcTableWidth,
@@ -393,6 +394,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
393
394
  )
394
395
  : NOOP;
395
396
 
397
+ if (getBooleanFF('platform.editor.custom-table-width')) {
398
+ // new table experience code goes here
399
+ // return <Resizer>...
400
+ }
401
+
396
402
  return (
397
403
  <div
398
404
  style={{
@@ -38,6 +38,7 @@ const tableAttributes = (node: PmNode) => {
38
38
  'data-layout': node.attrs.layout,
39
39
  'data-autosize': node.attrs.__autoSize,
40
40
  'data-table-local-id': node.attrs.localId || '',
41
+ 'data-table-width': node.attrs.width,
41
42
  };
42
43
  };
43
44
 
@@ -289,6 +289,12 @@ export const getNewResizeStateFromSelectedColumns = (
289
289
  domAtPos: (pos: number) => { node: Node; offset: number },
290
290
  getEditorContainerWidth: GetEditorContainerWidth,
291
291
  ): ResizeStateWithAnalytics | undefined => {
292
+ // Fail early so that we don't do complex calculations for no reason
293
+ const numColumnsSelected = rect.right - rect.left;
294
+ if (numColumnsSelected <= 1) {
295
+ return;
296
+ }
297
+
292
298
  const { totalRowCount, totalColumnCount, table } = getSelectedTableInfo(
293
299
  state.selection,
294
300
  );
@@ -297,6 +303,11 @@ export const getNewResizeStateFromSelectedColumns = (
297
303
  return;
298
304
  }
299
305
 
306
+ // Fail early so that we don't do complex calculations for no reason
307
+ if (!hasTableBeenResized(table.node)) {
308
+ return;
309
+ }
310
+
300
311
  const maybeTable = domAtPos(table.start).node as HTMLElement;
301
312
  const tableRef = maybeTable.closest('table');
302
313
 
@@ -24,7 +24,7 @@ import { TableCssClassName as ClassName } from '../types';
24
24
 
25
25
  import {
26
26
  tableCellBackgroundColor,
27
- tableToolbarColor,
27
+ tableHeaderCellBackgroundColor,
28
28
  tableBorderColor,
29
29
  tableCellSelectedColor,
30
30
  tableToolbarSelectedColor,
@@ -481,7 +481,7 @@ export const tableStyles = (
481
481
  border: 1px solid ${tableBorderColor(props)};
482
482
  border-radius: 0;
483
483
  border-top-left-radius: ${tableBorderRadiusSize}px;
484
- background: ${tableToolbarColor(props)};
484
+ background: ${tableHeaderCellBackgroundColor(props)};
485
485
  box-sizing: border-box;
486
486
  padding: 0;
487
487
  :focus {
@@ -598,7 +598,7 @@ export const tableStyles = (
598
598
  padding: 10px 2px;
599
599
  text-align: center;
600
600
  font-size: ${relativeFontSizeToBase16(fontSize())};
601
- background-color: ${tableToolbarColor(props)};
601
+ background-color: ${tableHeaderCellBackgroundColor(props)};
602
602
  color: ${tableTextColor(props)};
603
603
  border-color: ${tableBorderColor(props)};
604
604
 
@@ -38,6 +38,10 @@ export const tableCellBackgroundColor = themed({
38
38
  light: token('elevation.surface', N0),
39
39
  dark: token('elevation.surface', DN30),
40
40
  });
41
+ export const tableHeaderCellBackgroundColor = themed({
42
+ light: token('color.background.neutral', akEditorTableToolbar),
43
+ dark: token('color.background.neutral', akEditorTableToolbarDark),
44
+ });
41
45
  export const tableToolbarColor = themed({
42
46
  light: token('color.background.neutral.subtle', akEditorTableToolbar),
43
47
  dark: token('color.background.neutral.subtle', akEditorTableToolbarDark),
@@ -47,8 +51,8 @@ export const tableTextColor = themed({
47
51
  dark: token('color.text.subtlest', DN400),
48
52
  });
49
53
  export const tableBorderColor = themed({
50
- light: token('color.border', akEditorTableBorder),
51
- dark: token('color.border', akEditorTableBorderDark),
54
+ light: token('color.background.accent.gray.subtler', akEditorTableBorder),
55
+ dark: token('color.background.accent.gray.subtler', akEditorTableBorderDark),
52
56
  });
53
57
  export const tableFloatingControlsColor = token(
54
58
  'color.background.neutral',
@@ -21,9 +21,9 @@ import {
21
21
  Y200,
22
22
  } from '@atlaskit/theme/colors';
23
23
  import {
24
- tableToolbarColor,
25
24
  tableBorderColor,
26
25
  tableToolbarSelectedColor,
26
+ tableHeaderCellBackgroundColor,
27
27
  tableBorderSelectedColor,
28
28
  tableCellDeleteColor,
29
29
  tableBorderDeleteColor,
@@ -95,7 +95,7 @@ const Button = (cssString?: string) => css`
95
95
 
96
96
  export const HeaderButton = (props: ThemeProps, cssString?: string) => css`
97
97
  .${ClassName.CONTROLS_BUTTON} {
98
- background: ${tableToolbarColor(props)};
98
+ background: ${tableHeaderCellBackgroundColor(props)};
99
99
  border: 1px solid ${tableBorderColor(props)};
100
100
  display: block;
101
101
  box-sizing: border-box;
@@ -297,7 +297,7 @@ export const OverflowShadow = (props: ThemeProps) => css`
297
297
  `;
298
298
 
299
299
  const columnHeaderButton = (props: ThemeProps, cssString?: string) => css`
300
- background: ${tableToolbarColor(props)};
300
+ background: ${tableHeaderCellBackgroundColor(props)};
301
301
  border: 1px solid ${tableBorderColor(props)};
302
302
  display: block;
303
303
  box-sizing: border-box;