@atlaskit/editor-plugin-table 5.3.14 → 5.3.16

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 (144) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/plugins/table/event-handlers.js +4 -3
  3. package/dist/cjs/plugins/table/index.js +2 -1
  4. package/dist/cjs/plugins/table/pm-plugins/drag-and-drop/plugin.js +1 -0
  5. package/dist/cjs/plugins/table/types.js +5 -3
  6. package/dist/cjs/plugins/table/ui/FloatingDragMenu/DragMenu.js +49 -11
  7. package/dist/cjs/plugins/table/ui/FloatingDragMenu/index.js +5 -2
  8. package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +5 -0
  9. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
  10. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
  11. package/dist/cjs/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
  12. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +114 -0
  13. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +60 -0
  14. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +11 -112
  15. package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/types.js +5 -0
  16. package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
  17. package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +7 -2
  18. package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
  19. package/dist/cjs/plugins/table/ui/icons/AddColLeftIcon.js +44 -0
  20. package/dist/cjs/plugins/table/ui/icons/AddColRightIcon.js +44 -0
  21. package/dist/cjs/plugins/table/ui/icons/AddRowAboveIcon.js +45 -0
  22. package/dist/cjs/plugins/table/ui/icons/AddRowBelowIcon.js +40 -0
  23. package/dist/cjs/plugins/table/ui/icons/index.js +29 -1
  24. package/dist/cjs/plugins/table/ui/messages.js +5 -0
  25. package/dist/cjs/plugins/table/ui/ui-styles.js +28 -25
  26. package/dist/cjs/plugins/table/utils/dom.js +16 -7
  27. package/dist/cjs/plugins/table/utils/drag-menu.js +122 -10
  28. package/dist/cjs/plugins/table/utils/index.js +12 -6
  29. package/dist/es2019/plugins/table/event-handlers.js +5 -4
  30. package/dist/es2019/plugins/table/index.js +2 -1
  31. package/dist/es2019/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
  32. package/dist/es2019/plugins/table/types.js +5 -3
  33. package/dist/es2019/plugins/table/ui/FloatingDragMenu/DragMenu.js +52 -8
  34. package/dist/es2019/plugins/table/ui/FloatingDragMenu/index.js +5 -2
  35. package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +5 -0
  36. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
  37. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
  38. package/dist/es2019/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
  39. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +93 -0
  40. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +61 -0
  41. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -99
  42. package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
  43. package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
  44. package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +8 -3
  45. package/dist/es2019/plugins/table/ui/common-styles.js +8 -6
  46. package/dist/es2019/plugins/table/ui/icons/AddColLeftIcon.js +35 -0
  47. package/dist/es2019/plugins/table/ui/icons/AddColRightIcon.js +35 -0
  48. package/dist/es2019/plugins/table/ui/icons/AddRowAboveIcon.js +36 -0
  49. package/dist/es2019/plugins/table/ui/icons/AddRowBelowIcon.js +31 -0
  50. package/dist/es2019/plugins/table/ui/icons/index.js +5 -1
  51. package/dist/es2019/plugins/table/ui/messages.js +5 -0
  52. package/dist/es2019/plugins/table/ui/ui-styles.js +44 -3
  53. package/dist/es2019/plugins/table/utils/dom.js +13 -6
  54. package/dist/es2019/plugins/table/utils/drag-menu.js +118 -8
  55. package/dist/es2019/plugins/table/utils/index.js +1 -1
  56. package/dist/esm/plugins/table/event-handlers.js +5 -4
  57. package/dist/esm/plugins/table/index.js +2 -1
  58. package/dist/esm/plugins/table/pm-plugins/drag-and-drop/plugin.js +2 -1
  59. package/dist/esm/plugins/table/types.js +5 -3
  60. package/dist/esm/plugins/table/ui/FloatingDragMenu/DragMenu.js +46 -8
  61. package/dist/esm/plugins/table/ui/FloatingDragMenu/index.js +5 -2
  62. package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +5 -0
  63. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.js +3 -11
  64. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
  65. package/dist/esm/plugins/table/ui/TableFloatingColumnControls/index.js +1 -1
  66. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +104 -0
  67. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.js +50 -0
  68. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -110
  69. package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/types.js +1 -0
  70. package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/DragControls.js +1 -7
  71. package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +8 -3
  72. package/dist/esm/plugins/table/ui/common-styles.js +2 -2
  73. package/dist/esm/plugins/table/ui/icons/AddColLeftIcon.js +37 -0
  74. package/dist/esm/plugins/table/ui/icons/AddColRightIcon.js +37 -0
  75. package/dist/esm/plugins/table/ui/icons/AddRowAboveIcon.js +38 -0
  76. package/dist/esm/plugins/table/ui/icons/AddRowBelowIcon.js +33 -0
  77. package/dist/esm/plugins/table/ui/icons/index.js +5 -1
  78. package/dist/esm/plugins/table/ui/messages.js +5 -0
  79. package/dist/esm/plugins/table/ui/ui-styles.js +27 -24
  80. package/dist/esm/plugins/table/utils/dom.js +15 -6
  81. package/dist/esm/plugins/table/utils/drag-menu.js +120 -8
  82. package/dist/esm/plugins/table/utils/index.js +1 -1
  83. package/dist/types/plugins/table/types.d.ts +5 -3
  84. package/dist/types/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
  85. package/dist/types/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
  86. package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
  87. package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
  88. package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
  89. package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -0
  90. package/dist/types/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
  91. package/dist/types/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
  92. package/dist/types/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
  93. package/dist/types/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
  94. package/dist/types/plugins/table/ui/icons/index.d.ts +4 -0
  95. package/dist/types/plugins/table/ui/messages.d.ts +5 -0
  96. package/dist/types/plugins/table/ui/ui-styles.d.ts +1 -0
  97. package/dist/types/plugins/table/utils/dom.d.ts +3 -2
  98. package/dist/types/plugins/table/utils/drag-menu.d.ts +6 -3
  99. package/dist/types/plugins/table/utils/index.d.ts +1 -1
  100. package/dist/types-ts4.5/plugins/table/types.d.ts +5 -3
  101. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/DragMenu.d.ts +5 -2
  102. package/dist/types-ts4.5/plugins/table/ui/FloatingDragMenu/index.d.ts +3 -1
  103. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.d.ts +6 -0
  104. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.d.ts +6 -0
  105. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +2 -16
  106. package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/types.d.ts +11 -0
  107. package/dist/types-ts4.5/plugins/table/ui/icons/AddColLeftIcon.d.ts +2 -0
  108. package/dist/types-ts4.5/plugins/table/ui/icons/AddColRightIcon.d.ts +2 -0
  109. package/dist/types-ts4.5/plugins/table/ui/icons/AddRowAboveIcon.d.ts +2 -0
  110. package/dist/types-ts4.5/plugins/table/ui/icons/AddRowBelowIcon.d.ts +2 -0
  111. package/dist/types-ts4.5/plugins/table/ui/icons/index.d.ts +4 -0
  112. package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +5 -0
  113. package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +1 -0
  114. package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +3 -2
  115. package/dist/types-ts4.5/plugins/table/utils/drag-menu.d.ts +6 -3
  116. package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
  117. package/package.json +2 -2
  118. package/src/plugins/table/event-handlers.ts +7 -2
  119. package/src/plugins/table/index.tsx +1 -0
  120. package/src/plugins/table/pm-plugins/drag-and-drop/plugin.ts +7 -1
  121. package/src/plugins/table/types.ts +7 -4
  122. package/src/plugins/table/ui/FloatingDragMenu/DragMenu.tsx +73 -6
  123. package/src/plugins/table/ui/FloatingDragMenu/index.tsx +5 -0
  124. package/src/plugins/table/ui/FloatingInsertButton/index.tsx +8 -0
  125. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnControls/index.tsx +5 -7
  126. package/src/plugins/table/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
  127. package/src/plugins/table/ui/TableFloatingColumnControls/index.tsx +1 -1
  128. package/src/plugins/table/ui/TableFloatingControls/CornerControls/ClassicCornerControls.tsx +107 -0
  129. package/src/plugins/table/ui/TableFloatingControls/CornerControls/DragCornerControls.tsx +66 -0
  130. package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +2 -125
  131. package/src/plugins/table/ui/TableFloatingControls/CornerControls/types.ts +12 -0
  132. package/src/plugins/table/ui/TableFloatingControls/RowControls/DragControls.tsx +3 -3
  133. package/src/plugins/table/ui/TableFloatingControls/index.tsx +22 -14
  134. package/src/plugins/table/ui/common-styles.ts +8 -5
  135. package/src/plugins/table/ui/icons/AddColLeftIcon.tsx +43 -0
  136. package/src/plugins/table/ui/icons/AddColRightIcon.tsx +43 -0
  137. package/src/plugins/table/ui/icons/AddRowAboveIcon.tsx +42 -0
  138. package/src/plugins/table/ui/icons/AddRowBelowIcon.tsx +36 -0
  139. package/src/plugins/table/ui/icons/index.ts +4 -0
  140. package/src/plugins/table/ui/messages.ts +6 -0
  141. package/src/plugins/table/ui/ui-styles.ts +45 -3
  142. package/src/plugins/table/utils/dom.ts +16 -4
  143. package/src/plugins/table/utils/drag-menu.ts +158 -5
  144. package/src/plugins/table/utils/index.ts +2 -1
@@ -35,11 +35,11 @@ export const ColumnDropTargets: React.FC<Props> = ({
35
35
 
36
36
  return (
37
37
  <div
38
- className={ClassName.COLUMN_DROP_TARGET_CONTROLS}
38
+ className={ClassName.DRAG_COLUMN_DROP_TARGET_CONTROLS}
39
39
  contentEditable={false}
40
40
  >
41
41
  <div
42
- className={ClassName.COLUMN_CONTROLS_INNER}
42
+ className={ClassName.DRAG_COLUMN_CONTROLS_INNER}
43
43
  data-testid="table-floating-column-controls-drop-targets"
44
44
  >
45
45
  {colWidths?.map((width, index) => {
@@ -129,7 +129,7 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
129
129
 
130
130
  return ReactDOM.createPortal(
131
131
  <div
132
- className={ClassName.COLUMN_CONTROLS_WRAPPER}
132
+ className={ClassName.DRAG_COLUMN_CONTROLS_WRAPPER}
133
133
  data-testid="table-floating-column-controls-wrapper"
134
134
  >
135
135
  <ColumnControls
@@ -0,0 +1,107 @@
1
+ import React, { Component } from 'react';
2
+
3
+ import classnames from 'classnames';
4
+ import type { WrappedComponentProps } from 'react-intl-next';
5
+ import { injectIntl } from 'react-intl-next';
6
+
7
+ import { TableMap } from '@atlaskit/editor-tables/table-map';
8
+ import {
9
+ findTable,
10
+ isTableSelected,
11
+ selectTable,
12
+ } from '@atlaskit/editor-tables/utils';
13
+
14
+ import { clearHoverSelection, hoverTable } from '../../../commands';
15
+ import { TableCssClassName as ClassName } from '../../../types';
16
+ import messages from '../../messages';
17
+
18
+ import type { CornerControlProps } from './types';
19
+
20
+ class CornerControlComponent extends Component<
21
+ CornerControlProps & WrappedComponentProps,
22
+ any
23
+ > {
24
+ render() {
25
+ const {
26
+ isInDanger,
27
+ tableRef,
28
+ isHeaderColumnEnabled,
29
+ isHeaderRowEnabled,
30
+ intl: { formatMessage },
31
+ } = this.props;
32
+ if (!tableRef) {
33
+ return null;
34
+ }
35
+ const isActive = this.isActive();
36
+
37
+ return (
38
+ <div
39
+ className={classnames(ClassName.CORNER_CONTROLS, {
40
+ active: isActive,
41
+ sticky: this.props.stickyTop !== undefined,
42
+ })}
43
+ style={{
44
+ top:
45
+ this.props.stickyTop !== undefined
46
+ ? `${this.props.stickyTop}px`
47
+ : undefined,
48
+ }}
49
+ contentEditable={false}
50
+ >
51
+ <button
52
+ aria-label={formatMessage(messages.cornerControl)}
53
+ type="button"
54
+ className={classnames(ClassName.CONTROLS_CORNER_BUTTON, {
55
+ danger: isActive && isInDanger,
56
+ })}
57
+ onClick={this.selectTable}
58
+ onMouseOver={this.hoverTable}
59
+ onMouseOut={this.clearHoverSelection}
60
+ />
61
+
62
+ {!isHeaderRowEnabled && (
63
+ <div className={ClassName.CORNER_CONTROLS_INSERT_ROW_MARKER}>
64
+ <div className={ClassName.CONTROLS_INSERT_MARKER} />
65
+ </div>
66
+ )}
67
+ {!isHeaderColumnEnabled && (
68
+ <div className={ClassName.CORNER_CONTROLS_INSERT_COLUMN_MARKER}>
69
+ <div className={ClassName.CONTROLS_INSERT_MARKER} />
70
+ </div>
71
+ )}
72
+ </div>
73
+ );
74
+ }
75
+
76
+ private isActive = () => {
77
+ const { editorView, hoveredRows, isResizing } = this.props;
78
+ const { selection } = editorView.state;
79
+ const table = findTable(selection);
80
+ if (!table) {
81
+ return false;
82
+ }
83
+ return (
84
+ isTableSelected(selection) ||
85
+ (hoveredRows &&
86
+ hoveredRows.length === TableMap.get(table.node).height &&
87
+ !isResizing)
88
+ );
89
+ };
90
+
91
+ private clearHoverSelection = () => {
92
+ const { state, dispatch } = this.props.editorView;
93
+ clearHoverSelection()(state, dispatch);
94
+ };
95
+
96
+ private selectTable = () => {
97
+ const { state, dispatch } = this.props.editorView;
98
+ dispatch(selectTable(state.tr).setMeta('addToHistory', false));
99
+ };
100
+
101
+ private hoverTable = () => {
102
+ const { state, dispatch } = this.props.editorView;
103
+ hoverTable()(state, dispatch);
104
+ };
105
+ }
106
+
107
+ export const CornerControls = injectIntl(CornerControlComponent);
@@ -0,0 +1,66 @@
1
+ import React, { useMemo } from 'react';
2
+
3
+ import classnames from 'classnames';
4
+ import type { WrappedComponentProps } from 'react-intl-next';
5
+ import { injectIntl } from 'react-intl-next';
6
+
7
+ import {
8
+ findTable,
9
+ isTableSelected,
10
+ selectTable,
11
+ } from '@atlaskit/editor-tables/utils';
12
+
13
+ import { clearHoverSelection, hoverTable } from '../../../commands';
14
+ import { TableCssClassName as ClassName } from '../../../types';
15
+ import messages from '../../messages';
16
+
17
+ import type { CornerControlProps } from './types';
18
+
19
+ const DragCornerControlsComponent = ({
20
+ editorView,
21
+ isInDanger,
22
+ intl: { formatMessage },
23
+ }: CornerControlProps & WrappedComponentProps) => {
24
+ const handleOnClick = () => {
25
+ const { state, dispatch } = editorView;
26
+ dispatch(selectTable(state.tr).setMeta('addToHistory', false));
27
+ };
28
+
29
+ const handleMouseOver = () => {
30
+ const { state, dispatch } = editorView;
31
+ hoverTable()(state, dispatch);
32
+ };
33
+
34
+ const handleMouseOut = () => {
35
+ const { state, dispatch } = editorView;
36
+ clearHoverSelection()(state, dispatch);
37
+ };
38
+
39
+ const isActive = useMemo(() => {
40
+ const { selection } = editorView.state;
41
+ const table = findTable(selection);
42
+ if (!table) {
43
+ return false;
44
+ }
45
+ return isTableSelected(selection);
46
+ }, [editorView.state]);
47
+
48
+ return (
49
+ <button
50
+ className={classnames(ClassName.DRAG_CORNER_BUTTON, {
51
+ active: isActive,
52
+ danger: isActive && isInDanger,
53
+ })}
54
+ aria-label={formatMessage(messages.cornerControl)}
55
+ type="button"
56
+ onClick={handleOnClick}
57
+ onMouseOver={handleMouseOver}
58
+ onMouseOut={handleMouseOut}
59
+ contentEditable={false}
60
+ >
61
+ <div className={ClassName.DRAG_CORNER_BUTTON_INNER} />
62
+ </button>
63
+ );
64
+ };
65
+
66
+ export const DragCornerControls = injectIntl(DragCornerControlsComponent);
@@ -1,125 +1,2 @@
1
- import React, { Component } from 'react';
2
-
3
- import classnames from 'classnames';
4
- import type { WrappedComponentProps } from 'react-intl-next';
5
- import { defineMessages, injectIntl } from 'react-intl-next';
6
-
7
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
8
- import { TableMap } from '@atlaskit/editor-tables/table-map';
9
- import {
10
- findTable,
11
- isTableSelected,
12
- selectTable,
13
- } from '@atlaskit/editor-tables/utils';
14
-
15
- import { clearHoverSelection, hoverTable } from '../../../commands';
16
- import { TableCssClassName as ClassName } from '../../../types';
17
-
18
- const messages = defineMessages({
19
- cornerControl: {
20
- id: 'fabric.editor.cornerControl',
21
- defaultMessage: 'Highlight table',
22
- description:
23
- 'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.',
24
- },
25
- });
26
-
27
- export interface Props {
28
- editorView: EditorView;
29
- tableRef?: HTMLTableElement;
30
- isInDanger?: boolean;
31
- isResizing?: boolean;
32
- hoveredRows?: number[];
33
- isHeaderColumnEnabled?: boolean;
34
- isHeaderRowEnabled?: boolean;
35
- stickyTop?: number;
36
- }
37
-
38
- class CornerControlComponent extends Component<
39
- Props & WrappedComponentProps,
40
- any
41
- > {
42
- render() {
43
- const {
44
- isInDanger,
45
- tableRef,
46
- isHeaderColumnEnabled,
47
- isHeaderRowEnabled,
48
- intl: { formatMessage },
49
- } = this.props;
50
- if (!tableRef) {
51
- return null;
52
- }
53
- const isActive = this.isActive();
54
-
55
- return (
56
- <div
57
- className={classnames(ClassName.CORNER_CONTROLS, {
58
- active: isActive,
59
- sticky: this.props.stickyTop !== undefined,
60
- })}
61
- style={{
62
- top:
63
- this.props.stickyTop !== undefined
64
- ? `${this.props.stickyTop}px`
65
- : undefined,
66
- }}
67
- contentEditable={false}
68
- >
69
- <button
70
- aria-label={formatMessage(messages.cornerControl)}
71
- type="button"
72
- className={classnames(ClassName.CONTROLS_CORNER_BUTTON, {
73
- danger: isActive && isInDanger,
74
- })}
75
- onClick={this.selectTable}
76
- onMouseOver={this.hoverTable}
77
- onMouseOut={this.clearHoverSelection}
78
- />
79
-
80
- {!isHeaderRowEnabled && (
81
- <div className={ClassName.CORNER_CONTROLS_INSERT_ROW_MARKER}>
82
- <div className={ClassName.CONTROLS_INSERT_MARKER} />
83
- </div>
84
- )}
85
- {!isHeaderColumnEnabled && (
86
- <div className={ClassName.CORNER_CONTROLS_INSERT_COLUMN_MARKER}>
87
- <div className={ClassName.CONTROLS_INSERT_MARKER} />
88
- </div>
89
- )}
90
- </div>
91
- );
92
- }
93
-
94
- private isActive = () => {
95
- const { editorView, hoveredRows, isResizing } = this.props;
96
- const { selection } = editorView.state;
97
- const table = findTable(selection);
98
- if (!table) {
99
- return false;
100
- }
101
- return (
102
- isTableSelected(selection) ||
103
- (hoveredRows &&
104
- hoveredRows.length === TableMap.get(table.node).height &&
105
- !isResizing)
106
- );
107
- };
108
-
109
- private clearHoverSelection = () => {
110
- const { state, dispatch } = this.props.editorView;
111
- clearHoverSelection()(state, dispatch);
112
- };
113
-
114
- private selectTable = () => {
115
- const { state, dispatch } = this.props.editorView;
116
- dispatch(selectTable(state.tr).setMeta('addToHistory', false));
117
- };
118
-
119
- private hoverTable = () => {
120
- const { state, dispatch } = this.props.editorView;
121
- hoverTable()(state, dispatch);
122
- };
123
- }
124
-
125
- export const CornerControls = injectIntl(CornerControlComponent);
1
+ export { CornerControls } from './ClassicCornerControls';
2
+ export { DragCornerControls } from './DragCornerControls';
@@ -0,0 +1,12 @@
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
+
3
+ export type CornerControlProps = {
4
+ editorView: EditorView;
5
+ tableRef?: HTMLTableElement;
6
+ isInDanger?: boolean;
7
+ isResizing?: boolean;
8
+ hoveredRows?: number[];
9
+ isHeaderColumnEnabled?: boolean;
10
+ isHeaderRowEnabled?: boolean;
11
+ stickyTop?: number;
12
+ };
@@ -9,7 +9,6 @@ import type { Selection } from '@atlaskit/editor-prosemirror/state';
9
9
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
10
10
  import { CellSelection } from '@atlaskit/editor-tables';
11
11
  import { getSelectionRect } from '@atlaskit/editor-tables/utils';
12
- import { token } from '@atlaskit/tokens';
13
12
 
14
13
  import { clearHoverSelection } from '../../../commands';
15
14
  import { toggleDragMenu } from '../../../pm-plugins/drag-and-drop/commands';
@@ -141,7 +140,8 @@ const DragControlsComponent = ({
141
140
  contentEditable={false}
142
141
  key={index}
143
142
  >
144
- {!hasHeaderRow && index === 0 && (
143
+ {/* TODO: Disabling first column insert button https://atlassian.slack.com/archives/C05U8HRQM50/p1698363744682219?thread_ts=1698209039.104909&cid=C05U8HRQM50 */}
144
+ {/* {!hasHeaderRow && index === 0 && (
145
145
  <div
146
146
  style={{
147
147
  top: '0px',
@@ -149,7 +149,7 @@ const DragControlsComponent = ({
149
149
  }}
150
150
  className={ClassName.DRAG_ROW_FLOATING_INSERT_DOT}
151
151
  />
152
- )}
152
+ )} */}
153
153
  <div className={ClassName.DRAG_ROW_FLOATING_INSERT_DOT} />
154
154
  </div>
155
155
  ))}
@@ -12,7 +12,7 @@ import type { RowStickyState } from '../../pm-plugins/sticky-headers';
12
12
  import type { CellHoverMeta } from '../../types';
13
13
  import { isSelectionUpdated } from '../../utils';
14
14
 
15
- import { CornerControls } from './CornerControls';
15
+ import { CornerControls, DragCornerControls } from './CornerControls';
16
16
  import NumberColumn from './NumberColumn';
17
17
  import { DragControls, RowControls } from './RowControls';
18
18
 
@@ -159,19 +159,27 @@ export default class TableFloatingControls extends Component<Props, State> {
159
159
  {tableActive && (
160
160
  <>
161
161
  {isDragAndDropEnabled ? (
162
- <DragControls
163
- tableRef={tableRef}
164
- tableNode={tableNode}
165
- hoveredCell={hoveredCell}
166
- editorView={editorView}
167
- tableActive={tableActive}
168
- isInDanger={isInDanger}
169
- isResizing={isResizing}
170
- hasHeaderRow={hasHeaderRow}
171
- hoverRows={this.hoverRows}
172
- selectRow={this.selectRow}
173
- updateCellHoverLocation={this.updateCellHoverLocation}
174
- />
162
+ <>
163
+ <DragCornerControls
164
+ editorView={editorView}
165
+ tableRef={tableRef}
166
+ isInDanger={isInDanger}
167
+ isResizing={isResizing}
168
+ />
169
+ <DragControls
170
+ tableRef={tableRef}
171
+ tableNode={tableNode}
172
+ hoveredCell={hoveredCell}
173
+ editorView={editorView}
174
+ tableActive={tableActive}
175
+ isInDanger={isInDanger}
176
+ isResizing={isResizing}
177
+ hasHeaderRow={hasHeaderRow}
178
+ hoverRows={this.hoverRows}
179
+ selectRow={this.selectRow}
180
+ updateCellHoverLocation={this.updateCellHoverLocation}
181
+ />
182
+ </>
175
183
  ) : (
176
184
  <>
177
185
  <CornerControls
@@ -56,6 +56,7 @@ import {
56
56
  columnControlsDecoration,
57
57
  columnControlsLineMarker,
58
58
  DeleteButton,
59
+ dragCornerControlButton,
59
60
  dragInsertButtonWrapper,
60
61
  floatingColumnControls,
61
62
  HeaderButton,
@@ -360,6 +361,8 @@ export const tableStyles = (
360
361
 
361
362
  ${dragInsertButtonWrapper(props)}
362
363
 
364
+ ${dragCornerControlButton(props)}
365
+
363
366
  /* Delete button */
364
367
  ${DeleteButton(props)}
365
368
  /* Ends Delete button */
@@ -543,7 +546,7 @@ export const tableStyles = (
543
546
  }
544
547
  }
545
548
 
546
- .${ClassName.COLUMN_CONTROLS_WRAPPER} {
549
+ .${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
547
550
  padding: 0 ${tablePadding}px;
548
551
  }
549
552
 
@@ -732,11 +735,11 @@ export const tableStyles = (
732
735
  }
733
736
 
734
737
  .${ClassName.DRAG_COLUMN_CONTROLS} {
735
- .${ClassName.COLUMN_CONTROLS_INNER} {
738
+ .${ClassName.DRAG_COLUMN_CONTROLS_INNER} {
736
739
  height: 24px;
737
740
  position: absolute;
738
741
  top: ${token('space.negative.150', '-12px')};
739
- z-index: ${akEditorUnitZIndex};
742
+ z-index: ${akEditorUnitZIndex * 13};
740
743
  }
741
744
 
742
745
  .${ClassName.DRAG_COLUMN_FLOATING_INSERT_DOT_WRAPPER} {
@@ -1031,9 +1034,9 @@ export const tableStyles = (
1031
1034
  z-index: ${akEditorUnitZIndex};
1032
1035
  }
1033
1036
 
1034
- .${ClassName.COLUMN_CONTROLS_WRAPPER} {
1037
+ .${ClassName.DRAG_COLUMN_CONTROLS_WRAPPER} {
1035
1038
  position: absolute;
1036
- top: ${tableMarginTop + 1}px;
1039
+ top: ${tableMarginTop}px;
1037
1040
  }
1038
1041
 
1039
1042
  ${tableWrapperStyles()}
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+
3
+ export const AddColLeftIcon = () => (
4
+ <svg
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="currentColor"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ >
11
+ <rect
12
+ width="24"
13
+ height="24"
14
+ transform="matrix(0 -1 1 0 0 24)"
15
+ fill="none"
16
+ fillOpacity="0.01"
17
+ />
18
+ <rect
19
+ x="12"
20
+ y="18"
21
+ width="12"
22
+ height="3"
23
+ rx="0.5"
24
+ transform="rotate(-90 12 18)"
25
+ fill="currentColor"
26
+ />
27
+ <rect
28
+ x="16"
29
+ y="18"
30
+ width="12"
31
+ height="3"
32
+ rx="0.5"
33
+ transform="rotate(-90 16 18)"
34
+ fill="currentColor"
35
+ />
36
+ <path
37
+ fillRule="evenodd"
38
+ clipRule="evenodd"
39
+ d="M7 11H5.99C5.72652 11.0026 5.47473 11.1092 5.28935 11.2964C5.10397 11.4837 4.99999 11.7365 5 12C5 12.556 5.444 13 5.99 13H7V14C7 14.2652 7.10536 14.5196 7.29289 14.7071C7.48043 14.8946 7.73478 15 8 15C8.26522 15 8.51957 14.8946 8.70711 14.7071C8.89464 14.5196 9 14.2652 9 14V13H10.01C10.2735 12.9974 10.5253 12.8908 10.7107 12.7036C10.896 12.5163 11 12.2635 11 12C11 11.444 10.556 11 10.01 11H9V10C9 9.73478 8.89464 9.48043 8.70711 9.29289C8.51957 9.10536 8.26522 9 8 9C7.73478 9 7.48043 9.10536 7.29289 9.29289C7.10536 9.48043 7 9.73478 7 10V11Z"
40
+ fill="currentColor"
41
+ />
42
+ </svg>
43
+ );
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+
3
+ export const AddColRightIcon = () => (
4
+ <svg
5
+ width="24"
6
+ height="24"
7
+ viewBox="0 0 24 24"
8
+ fill="none"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ >
11
+ <rect
12
+ width="24"
13
+ height="24"
14
+ transform="translate(0 24) rotate(-90)"
15
+ fill="none"
16
+ fillOpacity="0.01"
17
+ />
18
+ <rect
19
+ x="9"
20
+ y="18"
21
+ width="12"
22
+ height="3"
23
+ rx="0.5"
24
+ transform="rotate(-90 9 18)"
25
+ fill="currentColor"
26
+ />
27
+ <rect
28
+ x="5"
29
+ y="18"
30
+ width="12"
31
+ height="3"
32
+ rx="0.5"
33
+ transform="rotate(-90 5 18)"
34
+ fill="currentColor"
35
+ />
36
+ <path
37
+ fillRule="evenodd"
38
+ clipRule="evenodd"
39
+ d="M15 11L13.99 11C13.7265 11.0026 13.4747 11.1092 13.2893 11.2964C13.104 11.4837 13 11.7365 13 12C13 12.556 13.444 13 13.99 13L15 13L15 14C15 14.2652 15.1054 14.5196 15.2929 14.7071C15.4804 14.8946 15.7348 15 16 15C16.2652 15 16.5196 14.8946 16.7071 14.7071C16.8946 14.5196 17 14.2652 17 14L17 13L18.01 13C18.2735 12.9974 18.5253 12.8908 18.7107 12.7036C18.896 12.5163 19 12.2635 19 12C19 11.444 18.556 11 18.01 11L17 11L17 10C17 9.73478 16.8946 9.48043 16.7071 9.29289C16.5196 9.10536 16.2652 9 16 9C15.7348 9 15.4804 9.10536 15.2929 9.29289C15.1054 9.48043 15 9.73478 15 10L15 11Z"
40
+ fill="currentColor"
41
+ />
42
+ </svg>
43
+ );
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+
3
+ import { token } from '@atlaskit/tokens';
4
+
5
+ export const AddRowAboveIcon = () => (
6
+ <svg
7
+ width="24"
8
+ height="24"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ >
13
+ <rect
14
+ width="24"
15
+ height="24"
16
+ fill={token('color.border.inverse', '#FFFFFF')}
17
+ fillOpacity="0.01"
18
+ />
19
+ <mask
20
+ id="path-1-inside-1_896_17822"
21
+ fill={token('color.border.inverse', '#FFFFFF')}
22
+ >
23
+ <rect x="6" y="12" width="12" height="8" rx="0.5" />
24
+ </mask>
25
+ <rect
26
+ x="6"
27
+ y="12"
28
+ width="12"
29
+ height="8"
30
+ rx="0.5"
31
+ stroke="currentColor"
32
+ strokeWidth="4"
33
+ mask="url(#path-1-inside-1_896_17822)"
34
+ />
35
+ <path
36
+ fillRule="evenodd"
37
+ clipRule="evenodd"
38
+ d="M13 7V5.99C12.9974 5.72652 12.8908 5.47473 12.7036 5.28935C12.5163 5.10397 12.2635 4.99999 12 5C11.444 5 11 5.444 11 5.99V7H10C9.73478 7 9.48043 7.10536 9.29289 7.29289C9.10536 7.48043 9 7.73478 9 8C9 8.26522 9.10536 8.51957 9.29289 8.70711C9.48043 8.89464 9.73478 9 10 9H11V10.01C11.0026 10.2735 11.1092 10.5253 11.2964 10.7107C11.4837 10.896 11.7365 11 12 11C12.556 11 13 10.556 13 10.01V9H14C14.2652 9 14.5196 8.89464 14.7071 8.70711C14.8946 8.51957 15 8.26522 15 8C15 7.73478 14.8946 7.48043 14.7071 7.29289C14.5196 7.10536 14.2652 7 14 7H13Z"
39
+ fill="currentColor"
40
+ />
41
+ </svg>
42
+ );
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+
3
+ import { token } from '@atlaskit/tokens';
4
+
5
+ export const AddRowBelowIcon = () => (
6
+ <svg
7
+ width="24"
8
+ height="24"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ >
13
+ <mask
14
+ id="path-1-inside-1_920_47112"
15
+ fill={token('color.border.inverse', '#FFFFFF')}
16
+ >
17
+ <rect x="6" y="4" width="12" height="8" rx="0.5" />
18
+ </mask>
19
+ <rect
20
+ x="6"
21
+ y="4"
22
+ width="12"
23
+ height="8"
24
+ rx="0.5"
25
+ stroke="currentColor"
26
+ strokeWidth="4"
27
+ mask="url(#path-1-inside-1_920_47112)"
28
+ />
29
+ <path
30
+ fillRule="evenodd"
31
+ clipRule="evenodd"
32
+ d="M13 15V13.99C12.9974 13.7265 12.8908 13.4747 12.7036 13.2893C12.5163 13.104 12.2635 13 12 13C11.444 13 11 13.444 11 13.99V15H10C9.73478 15 9.48043 15.1054 9.29289 15.2929C9.10536 15.4804 9 15.7348 9 16C9 16.2652 9.10536 16.5196 9.29289 16.7071C9.48043 16.8946 9.73478 17 10 17H11V18.01C11.0026 18.2735 11.1092 18.5253 11.2964 18.7107C11.4837 18.896 11.7365 19 12 19C12.556 19 13 18.556 13 18.01V17H14C14.2652 17 14.5196 16.8946 14.7071 16.7071C14.8946 16.5196 15 16.2652 15 16C15 15.7348 14.8946 15.4804 14.7071 15.2929C14.5196 15.1054 14.2652 15 14 15H13Z"
33
+ fill="currentColor"
34
+ />
35
+ </svg>
36
+ );
@@ -1,2 +1,6 @@
1
1
  export { DragHandleIcon } from './DragHandleIcon';
2
2
  export { DragInMotionIcon } from './DragInMotionIcon';
3
+ export { AddRowAboveIcon } from './AddRowAboveIcon';
4
+ export { AddRowBelowIcon } from './AddRowBelowIcon';
5
+ export { AddColLeftIcon } from './AddColLeftIcon';
6
+ export { AddColRightIcon } from './AddColRightIcon';
@@ -65,4 +65,10 @@ export default defineMessages({
65
65
  defaultMessage: 'Adjust column',
66
66
  description: 'Tooltip displayed on table column resize handle',
67
67
  },
68
+ cornerControl: {
69
+ id: 'fabric.editor.cornerControl',
70
+ defaultMessage: 'Highlight table',
71
+ description:
72
+ 'A button on the upper left corner of the table that shows up when the table is in focus. Clicking on it will select the entire table.',
73
+ },
68
74
  });