@atlaskit/editor-plugin-table 10.10.6 → 10.11.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 +21 -0
- package/dist/cjs/nodeviews/TableComponent.js +49 -25
- package/dist/cjs/nodeviews/TableRow.js +29 -20
- package/dist/cjs/ui/common-styles.js +1 -1
- package/dist/es2019/nodeviews/TableComponent.js +23 -1
- package/dist/es2019/nodeviews/TableRow.js +24 -16
- package/dist/es2019/ui/common-styles.js +8 -8
- package/dist/esm/nodeviews/TableComponent.js +49 -25
- package/dist/esm/nodeviews/TableRow.js +29 -20
- package/dist/esm/ui/common-styles.js +1 -1
- package/dist/types/nodeviews/TableRow.d.ts +2 -0
- package/dist/types-ts4.5/nodeviews/TableRow.d.ts +2 -0
- package/package.json +6 -6
- package/src/nodeviews/TableComponent.tsx +29 -6
- package/src/nodeviews/TableRow.ts +27 -25
- package/src/ui/common-styles.ts +8 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.11.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -32,21 +32,21 @@
|
|
|
32
32
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
33
33
|
"@atlaskit/button": "^23.2.0",
|
|
34
34
|
"@atlaskit/custom-steps": "^0.11.0",
|
|
35
|
-
"@atlaskit/editor-common": "^105.
|
|
35
|
+
"@atlaskit/editor-common": "^105.10.0",
|
|
36
36
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-accessibility-utils": "^2.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^2.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-content-insertion": "^2.1.0",
|
|
41
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
42
|
-
"@atlaskit/editor-plugin-extension": "5.4.
|
|
41
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^4.0.0",
|
|
42
|
+
"@atlaskit/editor-plugin-extension": "5.4.2",
|
|
43
43
|
"@atlaskit/editor-plugin-guideline": "^2.0.0",
|
|
44
44
|
"@atlaskit/editor-plugin-selection": "^2.2.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^3.0.0",
|
|
46
46
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.4.0",
|
|
48
48
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
49
|
-
"@atlaskit/icon": "^26.
|
|
49
|
+
"@atlaskit/icon": "^26.3.0",
|
|
50
50
|
"@atlaskit/menu": "^8.0.0",
|
|
51
51
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
55
55
|
"@atlaskit/primitives": "^14.8.0",
|
|
56
56
|
"@atlaskit/theme": "^18.0.0",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^5.0.0",
|
|
58
58
|
"@atlaskit/toggle": "^15.0.0",
|
|
59
59
|
"@atlaskit/tokens": "^4.9.0",
|
|
60
60
|
"@atlaskit/tooltip": "^20.0.0",
|
|
@@ -13,6 +13,7 @@ import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
|
13
13
|
import { tintDirtyTransaction } from '@atlaskit/editor-common/collab';
|
|
14
14
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
15
15
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
16
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
16
17
|
import { getParentNodeWidth, getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
17
18
|
import { tableMarginSides } from '@atlaskit/editor-common/styles';
|
|
18
19
|
import type { EditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
@@ -28,6 +29,7 @@ import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
|
28
29
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
29
30
|
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
30
31
|
import type { CleanupFn } from '@atlaskit/pragmatic-drag-and-drop/types';
|
|
32
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
31
33
|
import { token } from '@atlaskit/tokens';
|
|
32
34
|
|
|
33
35
|
import { autoSizeTable, clearHoverSelection } from '../pm-plugins/commands';
|
|
@@ -180,6 +182,7 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
180
182
|
private updateColGroupFromFullWidthChange?: boolean;
|
|
181
183
|
|
|
182
184
|
private dragAndDropCleanupFn?: CleanupFn;
|
|
185
|
+
private nodeVisibilityObserverCleanupFn?: CleanupFn;
|
|
183
186
|
|
|
184
187
|
constructor(props: ComponentProps) {
|
|
185
188
|
super(props);
|
|
@@ -189,12 +192,11 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
189
192
|
|
|
190
193
|
const tablePos = props.getPos();
|
|
191
194
|
|
|
192
|
-
this.isNestedInTable =
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
: false;
|
|
195
|
+
this.isNestedInTable = tablePos
|
|
196
|
+
? getParentOfTypeCount(props.view.state.schema.nodes.table)(
|
|
197
|
+
props.view.state.doc.resolve(tablePos),
|
|
198
|
+
) > 0
|
|
199
|
+
: false;
|
|
198
200
|
|
|
199
201
|
this.isInitialOverflowSent = false;
|
|
200
202
|
|
|
@@ -250,6 +252,23 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
250
252
|
};
|
|
251
253
|
|
|
252
254
|
componentDidMount() {
|
|
255
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
256
|
+
this.initialiseEventListenersAfterMount();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const { observe } = nodeVisibilityManager(this.props.view.dom);
|
|
261
|
+
if (this.table) {
|
|
262
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
263
|
+
element: this.table,
|
|
264
|
+
onFirstVisible: () => {
|
|
265
|
+
this.initialiseEventListenersAfterMount();
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
initialiseEventListenersAfterMount() {
|
|
253
272
|
const {
|
|
254
273
|
allowColumnResizing,
|
|
255
274
|
allowTableResizing,
|
|
@@ -367,6 +386,10 @@ class TableComponent extends React.Component<ComponentProps, TableState> {
|
|
|
367
386
|
this.dragAndDropCleanupFn();
|
|
368
387
|
}
|
|
369
388
|
|
|
389
|
+
if (this.nodeVisibilityObserverCleanupFn) {
|
|
390
|
+
this.nodeVisibilityObserverCleanupFn();
|
|
391
|
+
}
|
|
392
|
+
|
|
370
393
|
this.resizeObserver?.disconnect();
|
|
371
394
|
this.wrapperReisizeObserver?.disconnect();
|
|
372
395
|
|
|
@@ -3,11 +3,13 @@ import throttle from 'lodash/throttle';
|
|
|
3
3
|
|
|
4
4
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
6
|
+
import { nodeVisibilityManager } from '@atlaskit/editor-common/node-visibility';
|
|
6
7
|
import { findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
7
8
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
10
|
import type { EditorView, NodeView } from '@atlaskit/editor-prosemirror/view';
|
|
10
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
11
13
|
|
|
12
14
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
13
15
|
import { pluginKey as tablePluginKey } from '../pm-plugins/plugin-key';
|
|
@@ -44,6 +46,8 @@ const HEADER_ROW_SCROLL_THROTTLE_TIMEOUT = 200;
|
|
|
44
46
|
const HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT = 400;
|
|
45
47
|
|
|
46
48
|
export default class TableRow extends TableNodeView<HTMLTableRowElement> implements NodeView {
|
|
49
|
+
private nodeVisibilityObserverCleanupFn?: () => void;
|
|
50
|
+
|
|
47
51
|
constructor(
|
|
48
52
|
node: PMNode,
|
|
49
53
|
view: EditorView,
|
|
@@ -66,13 +70,31 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
if (this.isHeaderRow) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
if (editorExperiment('platform_editor_nodevisibility', false)) {
|
|
74
|
+
this.subscribeWhenRowVisible();
|
|
75
|
+
} else {
|
|
76
|
+
const { observe } = nodeVisibilityManager(view.dom);
|
|
77
|
+
this.nodeVisibilityObserverCleanupFn = observe({
|
|
78
|
+
element: this.contentDOM,
|
|
79
|
+
onFirstVisible: () => {
|
|
80
|
+
this.subscribeWhenRowVisible();
|
|
81
|
+
},
|
|
82
|
+
});
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
}
|
|
75
86
|
|
|
87
|
+
subscribeWhenRowVisible() {
|
|
88
|
+
if (this.listening) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
this.dom.setAttribute('data-header-row', 'true');
|
|
93
|
+
if (this.isStickyHeaderEnabled) {
|
|
94
|
+
this.subscribe();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
76
98
|
/**
|
|
77
99
|
* Variables
|
|
78
100
|
*/
|
|
@@ -151,6 +173,8 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
151
173
|
if (this.isStickyHeaderEnabled) {
|
|
152
174
|
this.unsubscribe();
|
|
153
175
|
|
|
176
|
+
this.nodeVisibilityObserverCleanupFn && this.nodeVisibilityObserverCleanupFn();
|
|
177
|
+
|
|
154
178
|
const tree = getTree(this.dom);
|
|
155
179
|
if (tree) {
|
|
156
180
|
this.makeRowHeaderNotSticky(tree.table, true);
|
|
@@ -608,19 +632,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
608
632
|
const isTableInsideLayout =
|
|
609
633
|
parentContainer && parentContainer.getAttribute('data-layout-content');
|
|
610
634
|
|
|
611
|
-
const isNestedTable =
|
|
612
|
-
parentContainer &&
|
|
613
|
-
(parentContainer.className === 'pm-table-header-content-wrap' ||
|
|
614
|
-
parentContainer.className === 'pm-table-cell-content-wrap');
|
|
615
|
-
|
|
616
|
-
const isNestedDataTable =
|
|
617
|
-
parentContainer &&
|
|
618
|
-
parentContainer.getAttribute('data-mark-type') === 'fragment' &&
|
|
619
|
-
(parentContainer.parentElement?.className === 'pm-table-header-content-wrap' ||
|
|
620
|
-
parentContainer.parentElement?.className === 'pm-table-cell-content-wrap');
|
|
621
|
-
|
|
622
|
-
const isTableInsideTable = isNestedTable || isNestedDataTable;
|
|
623
|
-
|
|
624
635
|
if (tableContentWrapper) {
|
|
625
636
|
if (isCurrentTableSelected) {
|
|
626
637
|
this.colControlsOffset = tableControlsSpacing;
|
|
@@ -629,17 +640,11 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
629
640
|
// to provide spacing for table controls
|
|
630
641
|
if (isTableInsideLayout) {
|
|
631
642
|
tableContentWrapper.style.paddingLeft = '11px';
|
|
632
|
-
} else if (isTableInsideTable && !fg('nested_table_control_padding_with_css')) {
|
|
633
|
-
tableContentWrapper.style.paddingLeft = '15px';
|
|
634
|
-
tableContentWrapper.style.paddingRight = '4px';
|
|
635
643
|
}
|
|
636
644
|
} else {
|
|
637
645
|
this.colControlsOffset = 0;
|
|
638
646
|
if (isTableInsideLayout) {
|
|
639
647
|
tableContentWrapper.style.removeProperty('padding-left');
|
|
640
|
-
} else if (isTableInsideTable && !fg('nested_table_control_padding_with_css')) {
|
|
641
|
-
tableContentWrapper.style.removeProperty('padding-left');
|
|
642
|
-
tableContentWrapper.style.removeProperty('padding-right');
|
|
643
648
|
}
|
|
644
649
|
}
|
|
645
650
|
}
|
|
@@ -677,9 +682,6 @@ export default class TableRow extends TableNodeView<HTMLTableRowElement> impleme
|
|
|
677
682
|
|
|
678
683
|
private makeHeaderRowSticky(tree: TableDOMElements, scrollTop?: number) {
|
|
679
684
|
// If header row height is more than 50% of viewport height don't do this
|
|
680
|
-
// TODO: ED-26961 - When cleaning up 'nested_table_control_padding_with_css' FG
|
|
681
|
-
// move this check to the constructor of the TableRow so that we don't subscribe to
|
|
682
|
-
// clicks and scrolls for nested tables.
|
|
683
685
|
if (
|
|
684
686
|
this.isSticky ||
|
|
685
687
|
(this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) ||
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -475,17 +475,15 @@ export const baseTableStyles = (props: {
|
|
|
475
475
|
padding-bottom: ${tableToolbarSize}px;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
478
|
+
.tableView-content-wrap:has(.tableView-content-wrap):has(
|
|
479
|
+
.${ClassName.NESTED_TABLE_WITH_CONTROLS}
|
|
480
|
+
) {
|
|
481
|
+
padding-left: unset;
|
|
482
|
+
}
|
|
483
483
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
`
|
|
488
|
-
: ''}
|
|
484
|
+
.tableView-content-wrap:has(.${ClassName.NESTED_TABLE_WITH_CONTROLS}) {
|
|
485
|
+
padding-left: 15px;
|
|
486
|
+
}
|
|
489
487
|
|
|
490
488
|
tr.sticky th {
|
|
491
489
|
border-bottom: ${stickyHeaderBorderBottomWidth}px solid ${tableBorderColor};
|