@atlaskit/editor-plugin-table 24.4.18 → 24.4.20
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 +16 -0
- package/dist/cjs/nodeviews/TableRow.js +21 -4
- package/dist/cjs/nodeviews/TableRowNativeStickyWithFallback.js +14 -3
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/pm-plugins/utils/nodes.js +8 -2
- package/dist/cjs/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +6 -13
- package/dist/es2019/nodeviews/TableRow.js +20 -3
- package/dist/es2019/nodeviews/TableRowNativeStickyWithFallback.js +12 -1
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/pm-plugins/utils/nodes.js +8 -3
- package/dist/es2019/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +7 -14
- package/dist/esm/nodeviews/TableRow.js +21 -4
- package/dist/esm/nodeviews/TableRowNativeStickyWithFallback.js +14 -3
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/pm-plugins/utils/nodes.js +8 -2
- package/dist/esm/pm-plugins/utils/tableMode/apply-measured-width-to-all-tables.js +7 -14
- package/dist/types/pm-plugins/utils/nodes.d.ts +5 -2
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 24.4.20
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6f1a6a07b4be1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6f1a6a07b4be1) -
|
|
8
|
+
Fixes malfunctioning sticky header row when header columns are merged
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 24.4.19
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`f596f4ca80078`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f596f4ca80078) -
|
|
16
|
+
Clean up feature gate `platform_editor_table_auto_convert_fix`
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 24.4.18
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -90,7 +90,6 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
90
90
|
_this.headerRowMouseScrollEnd();
|
|
91
91
|
}
|
|
92
92
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
93
|
-
_this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node);
|
|
94
93
|
_this.isSticky = false;
|
|
95
94
|
var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
|
|
96
95
|
pluginConfig = _getPluginState.pluginConfig;
|
|
@@ -102,17 +101,24 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
102
101
|
}
|
|
103
102
|
var pos = _this.getPos();
|
|
104
103
|
_this.isInNestedTable = false;
|
|
104
|
+
var rowIndex = 0;
|
|
105
105
|
try {
|
|
106
106
|
// We cannot trust that the value from getPos will be defined
|
|
107
107
|
// https://discuss.prosemirror.net/t/getpos-is-undefined-in-nodeview-constructor/1246/4
|
|
108
108
|
// There are also scenarios where the value it brings back does not tally with the current doc
|
|
109
109
|
// E.g. when AI streaming brings in new content, this position brings back incorrect values that cannot be resolved
|
|
110
110
|
if (pos) {
|
|
111
|
-
|
|
111
|
+
var $pos = view.state.doc.resolve(pos);
|
|
112
|
+
_this.isInNestedTable = (0, _nesting.getParentOfTypeCount)(view.state.schema.nodes.table)($pos) > 1;
|
|
113
|
+
// Resolve rowIndex only when the flag is on — otherwise it's unused
|
|
114
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
115
|
+
rowIndex = $pos.index();
|
|
116
|
+
}
|
|
112
117
|
}
|
|
113
118
|
} catch (_unused) {
|
|
114
119
|
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
115
120
|
}
|
|
121
|
+
_this.isHeaderRow = (0, _nodes.supportedHeaderRow)(node, rowIndex);
|
|
116
122
|
if (_this.isHeaderRow) {
|
|
117
123
|
_this.dom.setAttribute('data-vc-nvs', 'true');
|
|
118
124
|
var _nodeVisibilityManage = (0, _nodeVisibility.nodeVisibilityManager)(view.dom),
|
|
@@ -158,7 +164,18 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
158
164
|
|
|
159
165
|
// see if we're changing into a header row or
|
|
160
166
|
// changing away from one
|
|
161
|
-
var
|
|
167
|
+
var rowIndex = 0;
|
|
168
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
169
|
+
try {
|
|
170
|
+
var pos = this.getPos();
|
|
171
|
+
if (pos) {
|
|
172
|
+
rowIndex = this.view.state.doc.resolve(pos).index();
|
|
173
|
+
}
|
|
174
|
+
} catch (_unused2) {
|
|
175
|
+
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
var newNodeIsHeaderRow = (0, _nodes.supportedHeaderRow)(node, rowIndex);
|
|
162
179
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
163
180
|
return false; // re-create nodeview
|
|
164
181
|
}
|
|
@@ -493,7 +510,7 @@ var TableRow = exports.default = /*#__PURE__*/function (_TableNodeView) {
|
|
|
493
510
|
return false;
|
|
494
511
|
}
|
|
495
512
|
}
|
|
496
|
-
} catch (
|
|
513
|
+
} catch (_unused3) {
|
|
497
514
|
// getPos can return stale positions during AI streaming — fall back to non-sticky
|
|
498
515
|
return false;
|
|
499
516
|
}
|
|
@@ -202,7 +202,18 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
202
202
|
|
|
203
203
|
// see if we're changing into a header row or
|
|
204
204
|
// changing away from one
|
|
205
|
-
var
|
|
205
|
+
var rowIndex = 0;
|
|
206
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
207
|
+
try {
|
|
208
|
+
var pos = this.getPos();
|
|
209
|
+
if (pos) {
|
|
210
|
+
rowIndex = this.view.state.doc.resolve(pos).index();
|
|
211
|
+
}
|
|
212
|
+
} catch (_unused2) {
|
|
213
|
+
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
var newNodeIsHeaderRow = (0, _nodes.supportedHeaderRow)(node, rowIndex);
|
|
206
217
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
207
218
|
if (!newNodeIsHeaderRow && this.isHeaderRow) {
|
|
208
219
|
var _this$dom$closest;
|
|
@@ -738,7 +749,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
738
749
|
return false;
|
|
739
750
|
}
|
|
740
751
|
}
|
|
741
|
-
} catch (
|
|
752
|
+
} catch (_unused3) {
|
|
742
753
|
// getPos can return stale positions during AI streaming — fall back to non-sticky
|
|
743
754
|
return false;
|
|
744
755
|
}
|
|
@@ -918,7 +929,7 @@ var TableRowNativeStickyWithFallback = exports.default = /*#__PURE__*/function (
|
|
|
918
929
|
return node.type === _this1.view.state.schema.nodes.table;
|
|
919
930
|
})) === null || _findParentNodeCloses3 === void 0 ? void 0 : _findParentNodeCloses3.node;
|
|
920
931
|
return (tableNode === null || tableNode === void 0 ? void 0 : tableNode.childCount) === 1;
|
|
921
|
-
} catch (
|
|
932
|
+
} catch (_unused4) {
|
|
922
933
|
// getPos can return stale positions during AI streaming. Preserve the original sticky
|
|
923
934
|
// header behaviour when the containing table cannot be determined.
|
|
924
935
|
return false;
|
|
@@ -146,7 +146,7 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
146
146
|
var contentModeSizeTableId = null;
|
|
147
147
|
var hasMeasuredContentModeTables = false;
|
|
148
148
|
var focusListenerBinding = null;
|
|
149
|
-
if (
|
|
149
|
+
if (!__livePage && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) !== 'view' && (0, _isContentModeSupported.isContentModeSupported)({
|
|
150
150
|
allowColumnResizing: !!pluginConfig.allowColumnResizing,
|
|
151
151
|
allowTableResizing: !!pluginConfig.allowTableResizing,
|
|
152
152
|
isFullPageEditor: !isChromelessEditor && !isCommentEditor
|
|
@@ -148,18 +148,24 @@ var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(nod
|
|
|
148
148
|
* - all children are tableHeader cells
|
|
149
149
|
* - no table cells have been merged with other table row cells (rowspan > 1)
|
|
150
150
|
* - no table cells have been merged with other table column cells (colspan > 1),
|
|
151
|
-
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction
|
|
151
|
+
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction,
|
|
152
|
+
* and only applied to non-first rows — the first/sticky header row is allowed
|
|
153
|
+
* to have merged columns within itself, gated behind platform_editor_fix_sticky_header_row)
|
|
152
154
|
*
|
|
153
155
|
* @param node ProseMirror node
|
|
156
|
+
* @param rowIndex index of this row within its parent (default 0 = first/sticky row)
|
|
154
157
|
* @returns boolean if it meets definition
|
|
155
158
|
*/
|
|
156
159
|
var supportedHeaderRow = exports.supportedHeaderRow = function supportedHeaderRow(node) {
|
|
160
|
+
var rowIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
157
161
|
var allHeaders = (0, _utils.mapChildren)(node, function (child) {
|
|
158
162
|
return child.type.name === 'tableHeader';
|
|
159
163
|
}).every(Boolean);
|
|
160
164
|
if ((0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_malfunction', 'isEnabled', true)) {
|
|
161
165
|
var someMergedAcrossRow = anyChildCellMergedAcrossRow(node);
|
|
162
|
-
|
|
166
|
+
// Only apply the colspan check to non-first rows (rowIndex > 0) when the fix is enabled.
|
|
167
|
+
var isFirstStickyRowExempt = (0, _expValEquals.expValEquals)('platform_editor_fix_sticky_header_row', 'isEnabled', true) && rowIndex === 0;
|
|
168
|
+
var someMergedAcrossColumn = isFirstStickyRowExempt ? false : anyChildCellMergedAcrossColumn(node);
|
|
163
169
|
return allHeaders && !someMergedAcrossRow && !someMergedAcrossColumn;
|
|
164
170
|
}
|
|
165
171
|
var someMerged = anyChildCellMergedAcrossRow(node);
|
|
@@ -7,7 +7,6 @@ exports.applyMeasuredWidthToAllTables = void 0;
|
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
8
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
9
9
|
var _table = require("@atlaskit/editor-common/table");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var _contentMode = require("../../transforms/content-mode");
|
|
12
11
|
/**
|
|
13
12
|
* Iterates all top-level tables in the document, and for those in content mode,
|
|
@@ -25,18 +24,12 @@ var applyMeasuredWidthToAllTables = exports.applyMeasuredWidthToAllTables = func
|
|
|
25
24
|
|
|
26
25
|
// modify only top-level tables
|
|
27
26
|
doc.forEach(function (node, offset) {
|
|
28
|
-
if ((0,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
if (node.type !== table || (0, _table.hasTableBeenResized)(node) && node.attrs.layout !== 'align-start') {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
27
|
+
if (node.type !== table || !(0, _table.isTableInContentMode)({
|
|
28
|
+
tableNode: node,
|
|
29
|
+
isSupported: true,
|
|
30
|
+
isTableNested: false
|
|
31
|
+
})) {
|
|
32
|
+
return;
|
|
40
33
|
}
|
|
41
34
|
var domNode = view.domAtPos(offset + 1).node;
|
|
42
35
|
var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(_styles.TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
|
|
@@ -74,7 +74,6 @@ export default class TableRow extends TableNodeView {
|
|
|
74
74
|
this.headerRowMouseScrollEnd();
|
|
75
75
|
}
|
|
76
76
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
77
|
-
this.isHeaderRow = supportedHeaderRow(node);
|
|
78
77
|
this.isSticky = false;
|
|
79
78
|
const {
|
|
80
79
|
pluginConfig
|
|
@@ -87,17 +86,24 @@ export default class TableRow extends TableNodeView {
|
|
|
87
86
|
}
|
|
88
87
|
const pos = this.getPos();
|
|
89
88
|
this.isInNestedTable = false;
|
|
89
|
+
let rowIndex = 0;
|
|
90
90
|
try {
|
|
91
91
|
// We cannot trust that the value from getPos will be defined
|
|
92
92
|
// https://discuss.prosemirror.net/t/getpos-is-undefined-in-nodeview-constructor/1246/4
|
|
93
93
|
// There are also scenarios where the value it brings back does not tally with the current doc
|
|
94
94
|
// E.g. when AI streaming brings in new content, this position brings back incorrect values that cannot be resolved
|
|
95
95
|
if (pos) {
|
|
96
|
-
|
|
96
|
+
const $pos = view.state.doc.resolve(pos);
|
|
97
|
+
this.isInNestedTable = getParentOfTypeCount(view.state.schema.nodes.table)($pos) > 1;
|
|
98
|
+
// Resolve rowIndex only when the flag is on — otherwise it's unused
|
|
99
|
+
if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
100
|
+
rowIndex = $pos.index();
|
|
101
|
+
}
|
|
97
102
|
}
|
|
98
103
|
} catch {
|
|
99
104
|
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
100
105
|
}
|
|
106
|
+
this.isHeaderRow = supportedHeaderRow(node, rowIndex);
|
|
101
107
|
if (this.isHeaderRow) {
|
|
102
108
|
this.dom.setAttribute('data-vc-nvs', 'true');
|
|
103
109
|
const {
|
|
@@ -138,7 +144,18 @@ export default class TableRow extends TableNodeView {
|
|
|
138
144
|
|
|
139
145
|
// see if we're changing into a header row or
|
|
140
146
|
// changing away from one
|
|
141
|
-
|
|
147
|
+
let rowIndex = 0;
|
|
148
|
+
if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
149
|
+
try {
|
|
150
|
+
const pos = this.getPos();
|
|
151
|
+
if (pos) {
|
|
152
|
+
rowIndex = this.view.state.doc.resolve(pos).index();
|
|
153
|
+
}
|
|
154
|
+
} catch {
|
|
155
|
+
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const newNodeIsHeaderRow = supportedHeaderRow(node, rowIndex);
|
|
142
159
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
143
160
|
return false; // re-create nodeview
|
|
144
161
|
}
|
|
@@ -183,7 +183,18 @@ export default class TableRowNativeStickyWithFallback extends TableNodeView {
|
|
|
183
183
|
|
|
184
184
|
// see if we're changing into a header row or
|
|
185
185
|
// changing away from one
|
|
186
|
-
|
|
186
|
+
let rowIndex = 0;
|
|
187
|
+
if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
188
|
+
try {
|
|
189
|
+
const pos = this.getPos();
|
|
190
|
+
if (pos) {
|
|
191
|
+
rowIndex = this.view.state.doc.resolve(pos).index();
|
|
192
|
+
}
|
|
193
|
+
} catch {
|
|
194
|
+
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
const newNodeIsHeaderRow = supportedHeaderRow(node, rowIndex);
|
|
187
198
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
188
199
|
if (!newNodeIsHeaderRow && this.isHeaderRow) {
|
|
189
200
|
var _this$dom$closest;
|
|
@@ -131,7 +131,7 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
131
131
|
let contentModeSizeTableId = null;
|
|
132
132
|
let hasMeasuredContentModeTables = false;
|
|
133
133
|
let focusListenerBinding = null;
|
|
134
|
-
if (
|
|
134
|
+
if (!__livePage && (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 ? void 0 : (_pluginInjectionApi$e2 = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.mode) !== 'view' && isContentModeSupported({
|
|
135
135
|
allowColumnResizing: !!pluginConfig.allowColumnResizing,
|
|
136
136
|
allowTableResizing: !!pluginConfig.allowTableResizing,
|
|
137
137
|
isFullPageEditor: !isChromelessEditor && !isCommentEditor
|
|
@@ -116,16 +116,21 @@ const anyChildCellMergedAcrossColumn = node => mapChildren(node, child => child.
|
|
|
116
116
|
* - all children are tableHeader cells
|
|
117
117
|
* - no table cells have been merged with other table row cells (rowspan > 1)
|
|
118
118
|
* - no table cells have been merged with other table column cells (colspan > 1),
|
|
119
|
-
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction
|
|
119
|
+
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction,
|
|
120
|
+
* and only applied to non-first rows — the first/sticky header row is allowed
|
|
121
|
+
* to have merged columns within itself, gated behind platform_editor_fix_sticky_header_row)
|
|
120
122
|
*
|
|
121
123
|
* @param node ProseMirror node
|
|
124
|
+
* @param rowIndex index of this row within its parent (default 0 = first/sticky row)
|
|
122
125
|
* @returns boolean if it meets definition
|
|
123
126
|
*/
|
|
124
|
-
export const supportedHeaderRow = node => {
|
|
127
|
+
export const supportedHeaderRow = (node, rowIndex = 0) => {
|
|
125
128
|
const allHeaders = mapChildren(node, child => child.type.name === 'tableHeader').every(Boolean);
|
|
126
129
|
if (expValEquals('platform_editor_fix_sticky_header_malfunction', 'isEnabled', true)) {
|
|
127
130
|
const someMergedAcrossRow = anyChildCellMergedAcrossRow(node);
|
|
128
|
-
|
|
131
|
+
// Only apply the colspan check to non-first rows (rowIndex > 0) when the fix is enabled.
|
|
132
|
+
const isFirstStickyRowExempt = expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true) && rowIndex === 0;
|
|
133
|
+
const someMergedAcrossColumn = isFirstStickyRowExempt ? false : anyChildCellMergedAcrossColumn(node);
|
|
129
134
|
return allHeaders && !someMergedAcrossRow && !someMergedAcrossColumn;
|
|
130
135
|
}
|
|
131
136
|
const someMerged = anyChildCellMergedAcrossRow(node);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import {
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { isTableInContentMode } from '@atlaskit/editor-common/table';
|
|
5
4
|
import { applyTableMeasurement, getTableMeasurement } from '../../transforms/content-mode';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -25,18 +24,12 @@ export const applyMeasuredWidthToAllTables = (view, pluginInjectionApi) => {
|
|
|
25
24
|
|
|
26
25
|
// modify only top-level tables
|
|
27
26
|
doc.forEach((node, offset) => {
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
27
|
+
if (node.type !== table || !isTableInContentMode({
|
|
28
|
+
tableNode: node,
|
|
29
|
+
isSupported: true,
|
|
30
|
+
isTableNested: false
|
|
31
|
+
})) {
|
|
32
|
+
return;
|
|
40
33
|
}
|
|
41
34
|
const domNode = view.domAtPos(offset + 1).node;
|
|
42
35
|
const tableWrapper = domNode instanceof HTMLElement ? domNode.closest(`.${TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP}`) : null;
|
|
@@ -83,7 +83,6 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
83
83
|
_this.headerRowMouseScrollEnd();
|
|
84
84
|
}
|
|
85
85
|
}, HEADER_ROW_SCROLL_THROTTLE_TIMEOUT));
|
|
86
|
-
_this.isHeaderRow = supportedHeaderRow(node);
|
|
87
86
|
_this.isSticky = false;
|
|
88
87
|
var _getPluginState = getPluginState(view.state),
|
|
89
88
|
pluginConfig = _getPluginState.pluginConfig;
|
|
@@ -95,17 +94,24 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
95
94
|
}
|
|
96
95
|
var pos = _this.getPos();
|
|
97
96
|
_this.isInNestedTable = false;
|
|
97
|
+
var rowIndex = 0;
|
|
98
98
|
try {
|
|
99
99
|
// We cannot trust that the value from getPos will be defined
|
|
100
100
|
// https://discuss.prosemirror.net/t/getpos-is-undefined-in-nodeview-constructor/1246/4
|
|
101
101
|
// There are also scenarios where the value it brings back does not tally with the current doc
|
|
102
102
|
// E.g. when AI streaming brings in new content, this position brings back incorrect values that cannot be resolved
|
|
103
103
|
if (pos) {
|
|
104
|
-
|
|
104
|
+
var $pos = view.state.doc.resolve(pos);
|
|
105
|
+
_this.isInNestedTable = getParentOfTypeCount(view.state.schema.nodes.table)($pos) > 1;
|
|
106
|
+
// Resolve rowIndex only when the flag is on — otherwise it's unused
|
|
107
|
+
if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
108
|
+
rowIndex = $pos.index();
|
|
109
|
+
}
|
|
105
110
|
}
|
|
106
111
|
} catch (_unused) {
|
|
107
112
|
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
108
113
|
}
|
|
114
|
+
_this.isHeaderRow = supportedHeaderRow(node, rowIndex);
|
|
109
115
|
if (_this.isHeaderRow) {
|
|
110
116
|
_this.dom.setAttribute('data-vc-nvs', 'true');
|
|
111
117
|
var _nodeVisibilityManage = nodeVisibilityManager(view.dom),
|
|
@@ -151,7 +157,18 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
151
157
|
|
|
152
158
|
// see if we're changing into a header row or
|
|
153
159
|
// changing away from one
|
|
154
|
-
var
|
|
160
|
+
var rowIndex = 0;
|
|
161
|
+
if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
162
|
+
try {
|
|
163
|
+
var pos = this.getPos();
|
|
164
|
+
if (pos) {
|
|
165
|
+
rowIndex = this.view.state.doc.resolve(pos).index();
|
|
166
|
+
}
|
|
167
|
+
} catch (_unused2) {
|
|
168
|
+
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
var newNodeIsHeaderRow = supportedHeaderRow(node, rowIndex);
|
|
155
172
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
156
173
|
return false; // re-create nodeview
|
|
157
174
|
}
|
|
@@ -486,7 +503,7 @@ var TableRow = /*#__PURE__*/function (_TableNodeView) {
|
|
|
486
503
|
return false;
|
|
487
504
|
}
|
|
488
505
|
}
|
|
489
|
-
} catch (
|
|
506
|
+
} catch (_unused3) {
|
|
490
507
|
// getPos can return stale positions during AI streaming — fall back to non-sticky
|
|
491
508
|
return false;
|
|
492
509
|
}
|
|
@@ -195,7 +195,18 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
195
195
|
|
|
196
196
|
// see if we're changing into a header row or
|
|
197
197
|
// changing away from one
|
|
198
|
-
var
|
|
198
|
+
var rowIndex = 0;
|
|
199
|
+
if (expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true)) {
|
|
200
|
+
try {
|
|
201
|
+
var pos = this.getPos();
|
|
202
|
+
if (pos) {
|
|
203
|
+
rowIndex = this.view.state.doc.resolve(pos).index();
|
|
204
|
+
}
|
|
205
|
+
} catch (_unused2) {
|
|
206
|
+
// Intentionally swallowed — getPos can return stale positions during AI streaming
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
var newNodeIsHeaderRow = supportedHeaderRow(node, rowIndex);
|
|
199
210
|
if (this.isHeaderRow !== newNodeIsHeaderRow) {
|
|
200
211
|
if (!newNodeIsHeaderRow && this.isHeaderRow) {
|
|
201
212
|
var _this$dom$closest;
|
|
@@ -731,7 +742,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
731
742
|
return false;
|
|
732
743
|
}
|
|
733
744
|
}
|
|
734
|
-
} catch (
|
|
745
|
+
} catch (_unused3) {
|
|
735
746
|
// getPos can return stale positions during AI streaming — fall back to non-sticky
|
|
736
747
|
return false;
|
|
737
748
|
}
|
|
@@ -911,7 +922,7 @@ var TableRowNativeStickyWithFallback = /*#__PURE__*/function (_TableNodeView) {
|
|
|
911
922
|
return node.type === _this1.view.state.schema.nodes.table;
|
|
912
923
|
})) === null || _findParentNodeCloses3 === void 0 ? void 0 : _findParentNodeCloses3.node;
|
|
913
924
|
return (tableNode === null || tableNode === void 0 ? void 0 : tableNode.childCount) === 1;
|
|
914
|
-
} catch (
|
|
925
|
+
} catch (_unused4) {
|
|
915
926
|
// getPos can return stale positions during AI streaming. Preserve the original sticky
|
|
916
927
|
// header behaviour when the containing table cannot be determined.
|
|
917
928
|
return false;
|
|
@@ -139,7 +139,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
139
139
|
var contentModeSizeTableId = null;
|
|
140
140
|
var hasMeasuredContentModeTables = false;
|
|
141
141
|
var focusListenerBinding = null;
|
|
142
|
-
if (
|
|
142
|
+
if (!__livePage && (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.editorViewMode) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.sharedState.currentState()) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.mode) !== 'view' && isContentModeSupported({
|
|
143
143
|
allowColumnResizing: !!pluginConfig.allowColumnResizing,
|
|
144
144
|
allowTableResizing: !!pluginConfig.allowTableResizing,
|
|
145
145
|
isFullPageEditor: !isChromelessEditor && !isCommentEditor
|
|
@@ -141,18 +141,24 @@ var anyChildCellMergedAcrossColumn = function anyChildCellMergedAcrossColumn(nod
|
|
|
141
141
|
* - all children are tableHeader cells
|
|
142
142
|
* - no table cells have been merged with other table row cells (rowspan > 1)
|
|
143
143
|
* - no table cells have been merged with other table column cells (colspan > 1),
|
|
144
|
-
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction
|
|
144
|
+
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction,
|
|
145
|
+
* and only applied to non-first rows — the first/sticky header row is allowed
|
|
146
|
+
* to have merged columns within itself, gated behind platform_editor_fix_sticky_header_row)
|
|
145
147
|
*
|
|
146
148
|
* @param node ProseMirror node
|
|
149
|
+
* @param rowIndex index of this row within its parent (default 0 = first/sticky row)
|
|
147
150
|
* @returns boolean if it meets definition
|
|
148
151
|
*/
|
|
149
152
|
export var supportedHeaderRow = function supportedHeaderRow(node) {
|
|
153
|
+
var rowIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
150
154
|
var allHeaders = mapChildren(node, function (child) {
|
|
151
155
|
return child.type.name === 'tableHeader';
|
|
152
156
|
}).every(Boolean);
|
|
153
157
|
if (expValEquals('platform_editor_fix_sticky_header_malfunction', 'isEnabled', true)) {
|
|
154
158
|
var someMergedAcrossRow = anyChildCellMergedAcrossRow(node);
|
|
155
|
-
|
|
159
|
+
// Only apply the colspan check to non-first rows (rowIndex > 0) when the fix is enabled.
|
|
160
|
+
var isFirstStickyRowExempt = expValEquals('platform_editor_fix_sticky_header_row', 'isEnabled', true) && rowIndex === 0;
|
|
161
|
+
var someMergedAcrossColumn = isFirstStickyRowExempt ? false : anyChildCellMergedAcrossColumn(node);
|
|
156
162
|
return allHeaders && !someMergedAcrossRow && !someMergedAcrossColumn;
|
|
157
163
|
}
|
|
158
164
|
var someMerged = anyChildCellMergedAcrossRow(node);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { TableSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import {
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { isTableInContentMode } from '@atlaskit/editor-common/table';
|
|
5
4
|
import { applyTableMeasurement, getTableMeasurement } from '../../transforms/content-mode';
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -20,18 +19,12 @@ export var applyMeasuredWidthToAllTables = function applyMeasuredWidthToAllTable
|
|
|
20
19
|
|
|
21
20
|
// modify only top-level tables
|
|
22
21
|
doc.forEach(function (node, offset) {
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
} else {
|
|
32
|
-
if (node.type !== table || hasTableBeenResized(node) && node.attrs.layout !== 'align-start') {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
22
|
+
if (node.type !== table || !isTableInContentMode({
|
|
23
|
+
tableNode: node,
|
|
24
|
+
isSupported: true,
|
|
25
|
+
isTableNested: false
|
|
26
|
+
})) {
|
|
27
|
+
return;
|
|
35
28
|
}
|
|
36
29
|
var domNode = view.domAtPos(offset + 1).node;
|
|
37
30
|
var tableWrapper = domNode instanceof HTMLElement ? domNode.closest(".".concat(TableSharedCssClassName.TABLE_VIEW_CONTENT_WRAP)) : null;
|
|
@@ -22,9 +22,12 @@ export declare const isTableNestedUnderBodiedSyncBlock: (state: EditorState, tab
|
|
|
22
22
|
* - all children are tableHeader cells
|
|
23
23
|
* - no table cells have been merged with other table row cells (rowspan > 1)
|
|
24
24
|
* - no table cells have been merged with other table column cells (colspan > 1),
|
|
25
|
-
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction
|
|
25
|
+
* (colspan check gated behind platform_editor_fix_sticky_header_malfunction,
|
|
26
|
+
* and only applied to non-first rows — the first/sticky header row is allowed
|
|
27
|
+
* to have merged columns within itself, gated behind platform_editor_fix_sticky_header_row)
|
|
26
28
|
*
|
|
27
29
|
* @param node ProseMirror node
|
|
30
|
+
* @param rowIndex index of this row within its parent (default 0 = first/sticky row)
|
|
28
31
|
* @returns boolean if it meets definition
|
|
29
32
|
*/
|
|
30
|
-
export declare const supportedHeaderRow: (node: PmNode) => boolean;
|
|
33
|
+
export declare const supportedHeaderRow: (node: PmNode, rowIndex?: number) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "24.4.
|
|
3
|
+
"version": "24.4.20",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0",
|
|
53
53
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0",
|
|
54
54
|
"@atlaskit/primitives": "^22.1.0",
|
|
55
|
-
"@atlaskit/tmp-editor-statsig": "^132.
|
|
55
|
+
"@atlaskit/tmp-editor-statsig": "^132.5.0",
|
|
56
56
|
"@atlaskit/toggle": "^17.1.0",
|
|
57
|
-
"@atlaskit/tokens": "^16.
|
|
57
|
+
"@atlaskit/tokens": "^16.3.0",
|
|
58
58
|
"@atlaskit/tooltip": "^23.1.0",
|
|
59
59
|
"@babel/runtime": "^7.0.0",
|
|
60
60
|
"@compiled/react": "^1.0.0",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"uuid": "^3.1.0"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"@atlaskit/editor-common": "^116.
|
|
70
|
+
"@atlaskit/editor-common": "^116.37.0",
|
|
71
71
|
"react": "^18.2.0",
|
|
72
72
|
"react-dom": "^18.2.0",
|
|
73
73
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -118,9 +118,6 @@
|
|
|
118
118
|
"platform_editor_content_mode_button_mvp": {
|
|
119
119
|
"type": "boolean"
|
|
120
120
|
},
|
|
121
|
-
"platform_editor_table_auto_convert_fix": {
|
|
122
|
-
"type": "boolean"
|
|
123
|
-
},
|
|
124
121
|
"platform_editor_table_height_analytics": {
|
|
125
122
|
"type": "boolean"
|
|
126
123
|
},
|