@atlaskit/editor-plugin-table 12.1.15 → 12.2.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 +12 -0
- package/afm-cc/tsconfig.json +3 -0
- package/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/nodeviews/TableComponent.js +73 -22
- package/dist/cjs/nodeviews/TableContainer.js +270 -10
- package/dist/cjs/nodeviews/TableResizer.js +9 -2
- package/dist/cjs/nodeviews/table.js +12 -2
- package/dist/cjs/nodeviews/toDOM.js +23 -7
- package/dist/cjs/pm-plugins/main.js +57 -23
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +72 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +70 -1
- package/dist/cjs/tablePlugin.js +17 -3
- package/dist/es2019/nodeviews/TableComponent.js +76 -22
- package/dist/es2019/nodeviews/TableContainer.js +256 -2
- package/dist/es2019/nodeviews/TableResizer.js +9 -2
- package/dist/es2019/nodeviews/table.js +12 -2
- package/dist/es2019/nodeviews/toDOM.js +24 -8
- package/dist/es2019/pm-plugins/main.js +57 -23
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +72 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +70 -1
- package/dist/es2019/tablePlugin.js +17 -3
- package/dist/esm/nodeviews/TableComponent.js +73 -22
- package/dist/esm/nodeviews/TableContainer.js +270 -10
- package/dist/esm/nodeviews/TableResizer.js +9 -2
- package/dist/esm/nodeviews/table.js +12 -2
- package/dist/esm/nodeviews/toDOM.js +24 -8
- package/dist/esm/pm-plugins/main.js +57 -23
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +74 -3
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +70 -1
- package/dist/esm/tablePlugin.js +17 -3
- package/dist/types/nodeviews/TableContainer.d.ts +7 -2
- package/dist/types/nodeviews/TableResizer.d.ts +1 -1
- package/dist/types/nodeviews/toDOM.d.ts +5 -0
- package/dist/types/nodeviews/types.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types/pm-plugins/table-resizing/utils/misc.d.ts +41 -0
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +7 -2
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/toDOM.d.ts +5 -0
- package/dist/types-ts4.5/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/colgroup.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/misc.d.ts +41 -0
- package/package.json +8 -7
- package/src/nodeviews/TableComponent.tsx +105 -19
- package/src/nodeviews/TableContainer.tsx +331 -2
- package/src/nodeviews/TableResizer.tsx +10 -5
- package/src/nodeviews/table.tsx +14 -0
- package/src/nodeviews/toDOM.ts +75 -9
- package/src/nodeviews/types.ts +1 -0
- package/src/pm-plugins/main.ts +41 -18
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +139 -6
- package/src/pm-plugins/table-resizing/utils/misc.ts +87 -0
- package/src/tablePlugin.tsx +21 -0
- package/tsconfig.app.json +3 -0
- package/types/package.json +1 -1
- package/ui/common-styles/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
|
-
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { calcTableColumnWidths, getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
5
6
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
|
-
import { COLUMN_MIN_WIDTH } from './consts';
|
|
7
|
-
import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from './misc';
|
|
7
|
+
import { COLUMN_MIN_WIDTH, MAX_SCALING_PERCENT, MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION } from './consts';
|
|
8
|
+
import { getScalingPercentForTableWithoutWidth, getTableContainerElementWidth, getTableScalingPercent } from './misc';
|
|
8
9
|
/**
|
|
9
10
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
10
11
|
* than the table and table wrapper elements. This is necessary as there is no longer
|
|
@@ -14,6 +15,75 @@ import { getScalingPercentForTableWithoutWidth, getTableScalingPercent } from '.
|
|
|
14
15
|
export var getColWidthFix = function getColWidthFix(colwidth, tableColumnCount) {
|
|
15
16
|
return colwidth - 1 / tableColumnCount;
|
|
16
17
|
};
|
|
18
|
+
var generateColStyle = function generateColStyle(fixedColWidth, tableWidth, isCommentEditor, isChromelessEditor, isNested, shouldUseIncreasedScalingPercent, isNumberColumnEnabled, isTableHasWidth, hasTableBeenResized) {
|
|
19
|
+
var maxScalingPercent = shouldUseIncreasedScalingPercent ? MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION : MAX_SCALING_PERCENT;
|
|
20
|
+
var maxScaledRatio = 1 - maxScalingPercent;
|
|
21
|
+
var isFullPageEditor = !isChromelessEditor && !isCommentEditor;
|
|
22
|
+
|
|
23
|
+
// for nested tables, or chromeless editor, which used non resizable table container
|
|
24
|
+
if (isNested || isChromelessEditor) {
|
|
25
|
+
if (hasTableBeenResized) {
|
|
26
|
+
return "width: max(".concat(fixedColWidth, "px, ").concat(tableCellMinWidth, "px)");
|
|
27
|
+
}
|
|
28
|
+
return "width: ".concat(tableCellMinWidth, "px)");
|
|
29
|
+
}
|
|
30
|
+
if (isFullPageEditor || !isFullPageEditor && isTableHasWidth) {
|
|
31
|
+
var scaledPercent = isNumberColumnEnabled ? "calc(calc(var(--ak-editor-table-width) - ".concat(akEditorTableNumberColumnWidth, "px - 1px)/").concat(tableWidth, ")") : "calc(calc(var(--ak-editor-table-width) - 1px)/".concat(tableWidth, ")");
|
|
32
|
+
return "width: max(calc(".concat(fixedColWidth, "px * ").concat(maxScaledRatio, "), calc(").concat(fixedColWidth, " * ").concat(scaledPercent, "), ").concat(tableCellMinWidth, "px)");
|
|
33
|
+
}
|
|
34
|
+
// table resized to full-width in comment editor
|
|
35
|
+
// it doesn't have a width attribute, and cols has been resized
|
|
36
|
+
if (hasTableBeenResized) {
|
|
37
|
+
var _scaledPercent = isNumberColumnEnabled ? "calc(calc(var(--ak-editor-table-width) - ".concat(akEditorTableNumberColumnWidth, "px - 1px)/").concat(tableWidth, ")") : "calc(calc(var(--ak-editor-table-width) - 1px)/".concat(tableWidth, ")");
|
|
38
|
+
return "width: max(calc(".concat(fixedColWidth, " * ").concat(_scaledPercent, "), ").concat(tableCellMinWidth, "px)");
|
|
39
|
+
}
|
|
40
|
+
return "width: ".concat(tableCellMinWidth, "px");
|
|
41
|
+
};
|
|
42
|
+
export var generateColgroupFromNode = function generateColgroupFromNode(table, isCommentEditor, isChromelessEditor, isNested, isTableScalingEnabled, shouldUseIncreasedScalingPercent) {
|
|
43
|
+
var cols = [];
|
|
44
|
+
var map = TableMap.get(table);
|
|
45
|
+
var isTableHasWidth = !!table.attrs.width;
|
|
46
|
+
var isNumberColumnEnabled = table.attrs.isNumberColumnEnabled || false;
|
|
47
|
+
var isFullPageEditor = !isChromelessEditor && !isCommentEditor;
|
|
48
|
+
|
|
49
|
+
// Ignored via go/ees005
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
51
|
+
table.content.firstChild.content.forEach(function (cell) {
|
|
52
|
+
var colspan = cell.attrs.colspan || 1;
|
|
53
|
+
// if the table has been resized
|
|
54
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
55
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
56
|
+
// existing logic for calculating the width of the column
|
|
57
|
+
var fixedColWidth = getColWidthFix(width, map.width);
|
|
58
|
+
var tableWidth = isFullPageEditor || !isFullPageEditor && isTableHasWidth ? getTableContainerElementWidth(table) : calcTableColumnWidths(table).reduce(function (sum, width) {
|
|
59
|
+
return sum + width;
|
|
60
|
+
}, 0);
|
|
61
|
+
if (isTableScalingEnabled) {
|
|
62
|
+
cols.push(['col', {
|
|
63
|
+
style: generateColStyle(fixedColWidth, tableWidth, isCommentEditor, isChromelessEditor, isNested, shouldUseIncreasedScalingPercent, isNumberColumnEnabled, isTableHasWidth, true)
|
|
64
|
+
}]);
|
|
65
|
+
} else {
|
|
66
|
+
cols.push(['col', {
|
|
67
|
+
style: "width: max(".concat(fixedColWidth, "px, ").concat(tableCellMinWidth, "px)")
|
|
68
|
+
}]);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
// columns has not been resized, so distribute the width evenly
|
|
73
|
+
cols.push.apply(cols, _toConsumableArray(Array.from({
|
|
74
|
+
length: colspan
|
|
75
|
+
}, function (_) {
|
|
76
|
+
var tableWidth = getTableContainerElementWidth(table);
|
|
77
|
+
var columnWidth = tableWidth / map.width || 0;
|
|
78
|
+
var fixedColWidth = getColWidthFix(columnWidth, map.width || 0);
|
|
79
|
+
return ['col', {
|
|
80
|
+
style: generateColStyle(fixedColWidth, tableWidth, isCommentEditor, isChromelessEditor, isNested, shouldUseIncreasedScalingPercent, isNumberColumnEnabled, isTableHasWidth)
|
|
81
|
+
}];
|
|
82
|
+
})));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return cols;
|
|
86
|
+
};
|
|
17
87
|
export var generateColgroup = function generateColgroup(table, tableRef, shouldUseIncreasedScalingPercent, isCommentEditor) {
|
|
18
88
|
var cols = [];
|
|
19
89
|
var map = TableMap.get(table);
|
|
@@ -35,6 +105,7 @@ export var generateColgroup = function generateColgroup(table, tableRef, shouldU
|
|
|
35
105
|
scalePercent = getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent);
|
|
36
106
|
}
|
|
37
107
|
cell.attrs.colwidth.slice(0, colspan).forEach(function (width) {
|
|
108
|
+
// existing logic for calculating the width of the column
|
|
38
109
|
var fixedColWidth = getColWidthFix(width, map.width);
|
|
39
110
|
var scaledWidth = fixedColWidth * scalePercent;
|
|
40
111
|
var finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
@@ -4,7 +4,7 @@ import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorTableNumberColumnWidth, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles';
|
|
5
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
6
|
import { hasTableBeenResized, hasTableColumnBeenResized } from './colgroup';
|
|
7
|
-
import { MAX_SCALING_PERCENT, MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION } from './consts';
|
|
7
|
+
import { MAX_SCALING_PERCENT, MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION, TABLE_MAX_WIDTH } from './consts';
|
|
8
8
|
|
|
9
9
|
// Translates named layouts in number values.
|
|
10
10
|
export function getLayoutSize(tableLayout) {
|
|
@@ -85,6 +85,75 @@ export var getTableElementWidth = function getTableElementWidth(table) {
|
|
|
85
85
|
export var getTableContainerElementWidth = function getTableContainerElementWidth(table) {
|
|
86
86
|
return getTableContainerWidth(table);
|
|
87
87
|
};
|
|
88
|
+
|
|
89
|
+
// eslint-disable-next-line jsdoc/require-example
|
|
90
|
+
/**
|
|
91
|
+
* This function is used to set the max width for table resizer container.
|
|
92
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
93
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
94
|
+
* @param isTableScalingEnabled Whether table scaling is enabled.
|
|
95
|
+
* @returns The CSS max-width value
|
|
96
|
+
*/
|
|
97
|
+
export var getTableResizerContainerMaxWidthInCSS = function getTableResizerContainerMaxWidthInCSS(isCommentEditor, isChromelessEditor, isTableScalingEnabled) {
|
|
98
|
+
var maxResizerWidthForNonCommentEditor = isTableScalingEnabled ? "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ".concat(TABLE_MAX_WIDTH, "px)") : "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2) - var(--ak-editor--resizer-handle-spacing)), ".concat(TABLE_MAX_WIDTH, "px)");
|
|
99
|
+
return isCommentEditor || isChromelessEditor ? '100%' : maxResizerWidthForNonCommentEditor;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line jsdoc/require-example
|
|
103
|
+
/**
|
|
104
|
+
* This function is used in NodeView for TableResizer to set the max width for table resizer container
|
|
105
|
+
* @param node The ProseMirror node representing the table.
|
|
106
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
107
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
108
|
+
* @returns The CSS max-width value for the table resizer container.
|
|
109
|
+
*/
|
|
110
|
+
export var getTableResizerItemWidth = function getTableResizerItemWidth(node, isCommentEditor, isChromelessEditor) {
|
|
111
|
+
var tableWidthAttribute = getTableContainerWidth(node);
|
|
112
|
+
if (!node.attrs.width && (isCommentEditor || isChromelessEditor)) {
|
|
113
|
+
// width undefined would make .resizer-item width to be `auto`
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return tableWidthAttribute;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// eslint-disable-next-line jsdoc/require-example
|
|
120
|
+
/**
|
|
121
|
+
* This function is used to set the CSS width value for the table resizer-item.
|
|
122
|
+
* Because comment and chromeless editors don't have container-type: inline-size set,
|
|
123
|
+
* we need to calculate the width based on the table node width.
|
|
124
|
+
* If the table node width is not set, it will return 'auto'.
|
|
125
|
+
* This is used in table toDOM
|
|
126
|
+
* @param node The ProseMirror node representing the table.
|
|
127
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
128
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
129
|
+
* @returns The CSS width value for the table container.
|
|
130
|
+
*/
|
|
131
|
+
export var getTableResizerItemWidthInCSS = function getTableResizerItemWidthInCSS(node, isCommentEditor, isChromelessEditor) {
|
|
132
|
+
var tableWidthAttribute = getTableResizerItemWidth(node, isCommentEditor, isChromelessEditor);
|
|
133
|
+
return tableWidthAttribute ? "".concat(tableWidthAttribute, "px") : 'auto';
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// eslint-disable-next-line jsdoc/require-example
|
|
137
|
+
/**
|
|
138
|
+
* This function is used to set the table width --ak-editor-table-width CSS property for full page editor.
|
|
139
|
+
* Which is applied to the table resizer container.
|
|
140
|
+
* For Full page appearance, we don't need to use containerWidth from JS, as we can use cqw value.
|
|
141
|
+
* So we set dynamic containerWidth from JS to CSS property.
|
|
142
|
+
* @param node The ProseMirror node representing the table.
|
|
143
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
144
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
145
|
+
* @param isTableScalingEnabled Whether table scaling is enabled.
|
|
146
|
+
* @param tableWidthFromJS The width of the container element. In toDOM it'd be undefined, but will have a value from nodeView.
|
|
147
|
+
* @returns The CSS width value for the table.
|
|
148
|
+
*/
|
|
149
|
+
export var getTableResizerContainerForFullPageWidthInCSS = function getTableResizerContainerForFullPageWidthInCSS(node, isTableScalingEnabled) {
|
|
150
|
+
var tableWidth = getTableContainerElementWidth(node);
|
|
151
|
+
// for full page appearance
|
|
152
|
+
if (isTableScalingEnabled) {
|
|
153
|
+
return "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2)), ".concat(tableWidth, "px)");
|
|
154
|
+
}
|
|
155
|
+
return "min(calc(100cqw - calc(var(--ak-editor--large-gutter-padding) * 2) - var(--ak-editor--resizer-handle-spacing)), ".concat(tableWidth, "px)");
|
|
156
|
+
};
|
|
88
157
|
export var getTableScalingPercent = function getTableScalingPercent(table, tableRef, shouldUseIncreasedScalingPercent) {
|
|
89
158
|
var _tableRef$parentEleme;
|
|
90
159
|
var maxScalingPercent = shouldUseIncreasedScalingPercent ? MAX_SCALING_PERCENT_TABLES_WITH_FIXED_COLUMN_WIDTHS_OPTION : MAX_SCALING_PERCENT;
|
package/dist/esm/tablePlugin.js
CHANGED
|
@@ -232,18 +232,28 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
232
232
|
} : insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
233
233
|
},
|
|
234
234
|
nodes: function nodes() {
|
|
235
|
-
var _options$tableOptions2;
|
|
235
|
+
var _options$tableOptions2, _options$getEditorFea3;
|
|
236
236
|
var _pluginConfig = pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions),
|
|
237
237
|
allowColumnResizing = _pluginConfig.allowColumnResizing;
|
|
238
238
|
// TODO: ED-25901 - We need to move this into a plugin config option so we don't accidentally enable nested nodes in Jira
|
|
239
239
|
var isNestingSupported = Boolean(options === null || options === void 0 || (_options$tableOptions2 = options.tableOptions) === null || _options$tableOptions2 === void 0 ? void 0 : _options$tableOptions2.allowNestedTables);
|
|
240
|
+
var isTableFixedColumnWidthsOptionEnabled = (options === null || options === void 0 || (_options$getEditorFea3 = options.getEditorFeatureFlags) === null || _options$getEditorFea3 === void 0 ? void 0 : _options$getEditorFea3.call(options).tableWithFixedColumnWidthsOption) || false;
|
|
241
|
+
var shouldUseIncreasedScalingPercent = (options === null || options === void 0 ? void 0 : options.isTableScalingEnabled) && (isTableFixedColumnWidthsOptionEnabled || ( // When in comment editor, we need the scaling percent to be 40% while tableWithFixedColumnWidthsOption is not visible
|
|
242
|
+
options === null || options === void 0 ? void 0 : options.isCommentEditor));
|
|
243
|
+
var isTableScalingEnabled = options === null || options === void 0 ? void 0 : options.isTableScalingEnabled;
|
|
244
|
+
var isCommentEditor = options === null || options === void 0 ? void 0 : options.isCommentEditor;
|
|
245
|
+
var isChromelessEditor = options === null || options === void 0 ? void 0 : options.isChromelessEditor;
|
|
240
246
|
return isNestingSupported ? [{
|
|
241
247
|
name: 'table',
|
|
242
248
|
node: tableNodeSpecWithFixedToDOM({
|
|
243
249
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
244
250
|
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
245
251
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
246
|
-
isNestingSupported: isNestingSupported
|
|
252
|
+
isNestingSupported: isNestingSupported,
|
|
253
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
254
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
255
|
+
isCommentEditor: isCommentEditor,
|
|
256
|
+
isChromelessEditor: isChromelessEditor
|
|
247
257
|
})
|
|
248
258
|
}, {
|
|
249
259
|
name: 'tableHeader',
|
|
@@ -260,7 +270,11 @@ var tablePlugin = function tablePlugin(_ref) {
|
|
|
260
270
|
allowColumnResizing: Boolean(allowColumnResizing),
|
|
261
271
|
tableResizingEnabled: Boolean(options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing),
|
|
262
272
|
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
263
|
-
isNestingSupported: isNestingSupported
|
|
273
|
+
isNestingSupported: isNestingSupported,
|
|
274
|
+
isTableScalingEnabled: isTableScalingEnabled,
|
|
275
|
+
shouldUseIncreasedScalingPercent: shouldUseIncreasedScalingPercent,
|
|
276
|
+
isCommentEditor: isCommentEditor,
|
|
277
|
+
isChromelessEditor: isChromelessEditor
|
|
264
278
|
})
|
|
265
279
|
}, {
|
|
266
280
|
name: 'tableHeader',
|
|
@@ -13,6 +13,7 @@ type ResizableTableContainerProps = {
|
|
|
13
13
|
getPos: () => number | undefined;
|
|
14
14
|
tableRef: HTMLTableElement;
|
|
15
15
|
isResizing?: boolean;
|
|
16
|
+
isWindowResized?: boolean;
|
|
16
17
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
17
18
|
tableWrapperHeight?: number;
|
|
18
19
|
isWholeTableInDanger?: boolean;
|
|
@@ -21,8 +22,11 @@ type ResizableTableContainerProps = {
|
|
|
21
22
|
isTableAlignmentEnabled?: boolean;
|
|
22
23
|
shouldUseIncreasedScalingPercent?: boolean;
|
|
23
24
|
isCommentEditor?: boolean;
|
|
25
|
+
isChromelessEditor?: boolean;
|
|
24
26
|
};
|
|
25
|
-
export declare const ResizableTableContainer: React.
|
|
27
|
+
export declare const ResizableTableContainer: React.FC<ResizableTableContainerProps & {
|
|
28
|
+
children?: React.ReactNode | undefined;
|
|
29
|
+
}>;
|
|
26
30
|
type TableContainerProps = {
|
|
27
31
|
node: PMNode;
|
|
28
32
|
className: string;
|
|
@@ -32,6 +36,7 @@ type TableContainerProps = {
|
|
|
32
36
|
tableRef: HTMLTableElement;
|
|
33
37
|
isNested: boolean;
|
|
34
38
|
isResizing?: boolean;
|
|
39
|
+
isWindowResized?: boolean;
|
|
35
40
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
36
41
|
tableWrapperHeight?: number;
|
|
37
42
|
isWholeTableInDanger?: boolean;
|
|
@@ -43,5 +48,5 @@ type TableContainerProps = {
|
|
|
43
48
|
isCommentEditor?: boolean;
|
|
44
49
|
isChromelessEditor?: boolean;
|
|
45
50
|
};
|
|
46
|
-
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth, lineLength }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, }: PropsWithChildren<TableContainerProps>) => React.JSX.Element;
|
|
51
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth, lineLength }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, isWindowResized, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, }: PropsWithChildren<TableContainerProps>) => React.JSX.Element;
|
|
47
52
|
export {};
|
|
@@ -8,7 +8,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
8
8
|
import type { PluginInjectionAPI } from '../types';
|
|
9
9
|
interface TableResizerProps {
|
|
10
10
|
width: number;
|
|
11
|
-
maxWidth: number;
|
|
11
|
+
maxWidth: number | string;
|
|
12
12
|
containerWidth: number;
|
|
13
13
|
lineLength: number;
|
|
14
14
|
updateWidth: (width: number) => void;
|
|
@@ -5,6 +5,11 @@ type Config = {
|
|
|
5
5
|
tableResizingEnabled: boolean;
|
|
6
6
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
7
7
|
isNestingSupported?: boolean;
|
|
8
|
+
isTableScalingEnabled?: boolean;
|
|
9
|
+
shouldUseIncreasedScalingPercent?: boolean;
|
|
10
|
+
isCommentEditor?: boolean;
|
|
11
|
+
isChromelessEditor?: boolean;
|
|
12
|
+
isNested?: boolean;
|
|
8
13
|
};
|
|
9
14
|
export declare const tableNodeSpecWithFixedToDOM: (config: Config) => NodeSpec & {
|
|
10
15
|
toDOM: (node: PMNode) => DOMOutputSpec;
|
|
@@ -9,6 +9,7 @@ type Col = Array<string | {
|
|
|
9
9
|
* overflow.
|
|
10
10
|
*/
|
|
11
11
|
export declare const getColWidthFix: (colwidth: number, tableColumnCount: number) => number;
|
|
12
|
+
export declare const generateColgroupFromNode: (table: PmNode, isCommentEditor?: boolean, isChromelessEditor?: boolean, isNested?: boolean, isTableScalingEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => Col[];
|
|
12
13
|
export declare const generateColgroup: (table: PmNode, tableRef?: HTMLElement, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => Col[];
|
|
13
14
|
export declare const insertColgroupFromNode: (tableRef: HTMLTableElement | null, table: PmNode, isTableScalingEnabled?: boolean, shouldRemove?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => HTMLCollection;
|
|
14
15
|
export declare const hasTableBeenResized: (table: PmNode) => boolean;
|
|
@@ -22,6 +22,47 @@ export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getE
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const getTableElementWidth: (table: PMNode) => number;
|
|
24
24
|
export declare const getTableContainerElementWidth: (table: PMNode) => number;
|
|
25
|
+
/**
|
|
26
|
+
* This function is used to set the max width for table resizer container.
|
|
27
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
28
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
29
|
+
* @param isTableScalingEnabled Whether table scaling is enabled.
|
|
30
|
+
* @returns The CSS max-width value
|
|
31
|
+
*/
|
|
32
|
+
export declare const getTableResizerContainerMaxWidthInCSS: (isCommentEditor?: boolean, isChromelessEditor?: boolean, isTableScalingEnabled?: boolean) => string;
|
|
33
|
+
/**
|
|
34
|
+
* This function is used in NodeView for TableResizer to set the max width for table resizer container
|
|
35
|
+
* @param node The ProseMirror node representing the table.
|
|
36
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
37
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
38
|
+
* @returns The CSS max-width value for the table resizer container.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getTableResizerItemWidth: (node: PMNode, isCommentEditor?: boolean, isChromelessEditor?: boolean) => number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* This function is used to set the CSS width value for the table resizer-item.
|
|
43
|
+
* Because comment and chromeless editors don't have container-type: inline-size set,
|
|
44
|
+
* we need to calculate the width based on the table node width.
|
|
45
|
+
* If the table node width is not set, it will return 'auto'.
|
|
46
|
+
* This is used in table toDOM
|
|
47
|
+
* @param node The ProseMirror node representing the table.
|
|
48
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
49
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
50
|
+
* @returns The CSS width value for the table container.
|
|
51
|
+
*/
|
|
52
|
+
export declare const getTableResizerItemWidthInCSS: (node: PMNode, isCommentEditor?: boolean, isChromelessEditor?: boolean) => string;
|
|
53
|
+
/**
|
|
54
|
+
* This function is used to set the table width --ak-editor-table-width CSS property for full page editor.
|
|
55
|
+
* Which is applied to the table resizer container.
|
|
56
|
+
* For Full page appearance, we don't need to use containerWidth from JS, as we can use cqw value.
|
|
57
|
+
* So we set dynamic containerWidth from JS to CSS property.
|
|
58
|
+
* @param node The ProseMirror node representing the table.
|
|
59
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
60
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
61
|
+
* @param isTableScalingEnabled Whether table scaling is enabled.
|
|
62
|
+
* @param tableWidthFromJS The width of the container element. In toDOM it'd be undefined, but will have a value from nodeView.
|
|
63
|
+
* @returns The CSS width value for the table.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getTableResizerContainerForFullPageWidthInCSS: (node: PMNode, isTableScalingEnabled?: boolean) => string;
|
|
25
66
|
export declare const getTableScalingPercent: (table: PMNode, tableRef: HTMLElement | null, shouldUseIncreasedScalingPercent?: boolean) => number;
|
|
26
67
|
export declare const getScalingPercentForTableWithoutWidth: (table: PMNode, tableRef: HTMLElement | null) => number;
|
|
27
68
|
export declare const getStaticTableScalingPercent: (table: PMNode, tableRenderWidth: number, shouldUseIncreasedScalingPercent?: boolean) => number;
|
|
@@ -13,6 +13,7 @@ type ResizableTableContainerProps = {
|
|
|
13
13
|
getPos: () => number | undefined;
|
|
14
14
|
tableRef: HTMLTableElement;
|
|
15
15
|
isResizing?: boolean;
|
|
16
|
+
isWindowResized?: boolean;
|
|
16
17
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
17
18
|
tableWrapperHeight?: number;
|
|
18
19
|
isWholeTableInDanger?: boolean;
|
|
@@ -21,8 +22,11 @@ type ResizableTableContainerProps = {
|
|
|
21
22
|
isTableAlignmentEnabled?: boolean;
|
|
22
23
|
shouldUseIncreasedScalingPercent?: boolean;
|
|
23
24
|
isCommentEditor?: boolean;
|
|
25
|
+
isChromelessEditor?: boolean;
|
|
24
26
|
};
|
|
25
|
-
export declare const ResizableTableContainer: React.
|
|
27
|
+
export declare const ResizableTableContainer: React.FC<ResizableTableContainerProps & {
|
|
28
|
+
children?: React.ReactNode | undefined;
|
|
29
|
+
}>;
|
|
26
30
|
type TableContainerProps = {
|
|
27
31
|
node: PMNode;
|
|
28
32
|
className: string;
|
|
@@ -32,6 +36,7 @@ type TableContainerProps = {
|
|
|
32
36
|
tableRef: HTMLTableElement;
|
|
33
37
|
isNested: boolean;
|
|
34
38
|
isResizing?: boolean;
|
|
39
|
+
isWindowResized?: boolean;
|
|
35
40
|
pluginInjectionApi?: PluginInjectionAPI;
|
|
36
41
|
tableWrapperHeight?: number;
|
|
37
42
|
isWholeTableInDanger?: boolean;
|
|
@@ -43,5 +48,5 @@ type TableContainerProps = {
|
|
|
43
48
|
isCommentEditor?: boolean;
|
|
44
49
|
isChromelessEditor?: boolean;
|
|
45
50
|
};
|
|
46
|
-
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth, lineLength }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, }: PropsWithChildren<TableContainerProps>) => React.JSX.Element;
|
|
51
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { width: editorWidth, lineLength }, editorView, getPos, tableRef, isNested, tableWrapperHeight, isResizing, isWindowResized, pluginInjectionApi, isWholeTableInDanger, isTableResizingEnabled, isTableScalingEnabled, isTableWithFixedColumnWidthsOptionEnabled, isTableAlignmentEnabled, shouldUseIncreasedScalingPercent, isCommentEditor, isChromelessEditor, }: PropsWithChildren<TableContainerProps>) => React.JSX.Element;
|
|
47
52
|
export {};
|
|
@@ -8,7 +8,7 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
8
8
|
import type { PluginInjectionAPI } from '../types';
|
|
9
9
|
interface TableResizerProps {
|
|
10
10
|
width: number;
|
|
11
|
-
maxWidth: number;
|
|
11
|
+
maxWidth: number | string;
|
|
12
12
|
containerWidth: number;
|
|
13
13
|
lineLength: number;
|
|
14
14
|
updateWidth: (width: number) => void;
|
|
@@ -5,6 +5,11 @@ type Config = {
|
|
|
5
5
|
tableResizingEnabled: boolean;
|
|
6
6
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
7
7
|
isNestingSupported?: boolean;
|
|
8
|
+
isTableScalingEnabled?: boolean;
|
|
9
|
+
shouldUseIncreasedScalingPercent?: boolean;
|
|
10
|
+
isCommentEditor?: boolean;
|
|
11
|
+
isChromelessEditor?: boolean;
|
|
12
|
+
isNested?: boolean;
|
|
8
13
|
};
|
|
9
14
|
export declare const tableNodeSpecWithFixedToDOM: (config: Config) => NodeSpec & {
|
|
10
15
|
toDOM: (node: PMNode) => DOMOutputSpec;
|
|
@@ -9,6 +9,7 @@ type Col = Array<string | {
|
|
|
9
9
|
* overflow.
|
|
10
10
|
*/
|
|
11
11
|
export declare const getColWidthFix: (colwidth: number, tableColumnCount: number) => number;
|
|
12
|
+
export declare const generateColgroupFromNode: (table: PmNode, isCommentEditor?: boolean, isChromelessEditor?: boolean, isNested?: boolean, isTableScalingEnabled?: boolean, shouldUseIncreasedScalingPercent?: boolean) => Col[];
|
|
12
13
|
export declare const generateColgroup: (table: PmNode, tableRef?: HTMLElement, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => Col[];
|
|
13
14
|
export declare const insertColgroupFromNode: (tableRef: HTMLTableElement | null, table: PmNode, isTableScalingEnabled?: boolean, shouldRemove?: boolean, shouldUseIncreasedScalingPercent?: boolean, isCommentEditor?: boolean) => HTMLCollection;
|
|
14
15
|
export declare const hasTableBeenResized: (table: PmNode) => boolean;
|
|
@@ -22,6 +22,47 @@ export declare const getTableMaxWidth: ({ table, tableStart, state, layout, getE
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const getTableElementWidth: (table: PMNode) => number;
|
|
24
24
|
export declare const getTableContainerElementWidth: (table: PMNode) => number;
|
|
25
|
+
/**
|
|
26
|
+
* This function is used to set the max width for table resizer container.
|
|
27
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
28
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
29
|
+
* @param isTableScalingEnabled Whether table scaling is enabled.
|
|
30
|
+
* @returns The CSS max-width value
|
|
31
|
+
*/
|
|
32
|
+
export declare const getTableResizerContainerMaxWidthInCSS: (isCommentEditor?: boolean, isChromelessEditor?: boolean, isTableScalingEnabled?: boolean) => string;
|
|
33
|
+
/**
|
|
34
|
+
* This function is used in NodeView for TableResizer to set the max width for table resizer container
|
|
35
|
+
* @param node The ProseMirror node representing the table.
|
|
36
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
37
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
38
|
+
* @returns The CSS max-width value for the table resizer container.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getTableResizerItemWidth: (node: PMNode, isCommentEditor?: boolean, isChromelessEditor?: boolean) => number | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* This function is used to set the CSS width value for the table resizer-item.
|
|
43
|
+
* Because comment and chromeless editors don't have container-type: inline-size set,
|
|
44
|
+
* we need to calculate the width based on the table node width.
|
|
45
|
+
* If the table node width is not set, it will return 'auto'.
|
|
46
|
+
* This is used in table toDOM
|
|
47
|
+
* @param node The ProseMirror node representing the table.
|
|
48
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
49
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
50
|
+
* @returns The CSS width value for the table container.
|
|
51
|
+
*/
|
|
52
|
+
export declare const getTableResizerItemWidthInCSS: (node: PMNode, isCommentEditor?: boolean, isChromelessEditor?: boolean) => string;
|
|
53
|
+
/**
|
|
54
|
+
* This function is used to set the table width --ak-editor-table-width CSS property for full page editor.
|
|
55
|
+
* Which is applied to the table resizer container.
|
|
56
|
+
* For Full page appearance, we don't need to use containerWidth from JS, as we can use cqw value.
|
|
57
|
+
* So we set dynamic containerWidth from JS to CSS property.
|
|
58
|
+
* @param node The ProseMirror node representing the table.
|
|
59
|
+
* @param isCommentEditor Whether the editor is in comment mode.
|
|
60
|
+
* @param isChromelessEditor Whether the editor is chromeless.
|
|
61
|
+
* @param isTableScalingEnabled Whether table scaling is enabled.
|
|
62
|
+
* @param tableWidthFromJS The width of the container element. In toDOM it'd be undefined, but will have a value from nodeView.
|
|
63
|
+
* @returns The CSS width value for the table.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getTableResizerContainerForFullPageWidthInCSS: (node: PMNode, isTableScalingEnabled?: boolean) => string;
|
|
25
66
|
export declare const getTableScalingPercent: (table: PMNode, tableRef: HTMLElement | null, shouldUseIncreasedScalingPercent?: boolean) => number;
|
|
26
67
|
export declare const getScalingPercentForTableWithoutWidth: (table: PMNode, tableRef: HTMLElement | null) => number;
|
|
27
68
|
export declare const getStaticTableScalingPercent: (table: PMNode, tableRenderWidth: number, shouldUseIncreasedScalingPercent?: boolean) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^50.2.0",
|
|
32
|
-
"@atlaskit/button": "^23.
|
|
32
|
+
"@atlaskit/button": "^23.4.0",
|
|
33
33
|
"@atlaskit/custom-steps": "^0.11.0",
|
|
34
34
|
"@atlaskit/editor-palette": "^2.1.0",
|
|
35
35
|
"@atlaskit/editor-plugin-accessibility-utils": "^3.0.0",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"@atlaskit/editor-plugin-batch-attribute-updates": "^3.0.0",
|
|
38
38
|
"@atlaskit/editor-plugin-content-insertion": "^3.1.0",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
|
|
40
|
-
"@atlaskit/editor-plugin-extension": "6.1.
|
|
40
|
+
"@atlaskit/editor-plugin-extension": "6.1.7",
|
|
41
41
|
"@atlaskit/editor-plugin-guideline": "^3.0.0",
|
|
42
42
|
"@atlaskit/editor-plugin-interaction": "^5.0.0",
|
|
43
|
-
"@atlaskit/editor-plugin-limited-mode": "^0.0.
|
|
43
|
+
"@atlaskit/editor-plugin-limited-mode": "^0.0.1",
|
|
44
44
|
"@atlaskit/editor-plugin-selection": "^3.0.0",
|
|
45
45
|
"@atlaskit/editor-plugin-width": "^4.0.0",
|
|
46
46
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
@@ -49,13 +49,14 @@
|
|
|
49
49
|
"@atlaskit/icon": "^27.12.0",
|
|
50
50
|
"@atlaskit/menu": "^8.3.0",
|
|
51
51
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
52
|
+
"@atlaskit/platform-feature-flags-react": "^0.2.0",
|
|
52
53
|
"@atlaskit/pragmatic-drag-and-drop": "^1.7.0",
|
|
53
54
|
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
|
|
54
55
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0",
|
|
55
56
|
"@atlaskit/primitives": "^14.11.0",
|
|
56
|
-
"@atlaskit/react-ufo": "^4.
|
|
57
|
+
"@atlaskit/react-ufo": "^4.3.0",
|
|
57
58
|
"@atlaskit/theme": "^19.0.0",
|
|
58
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^10.0.0",
|
|
59
60
|
"@atlaskit/toggle": "^15.1.0",
|
|
60
61
|
"@atlaskit/tokens": "^6.0.0",
|
|
61
62
|
"@atlaskit/tooltip": "^20.4.0",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
"uuid": "^3.1.0"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
|
-
"@atlaskit/editor-common": "^107.
|
|
72
|
+
"@atlaskit/editor-common": "^107.25.0",
|
|
72
73
|
"react": "^18.2.0",
|
|
73
74
|
"react-dom": "^18.2.0",
|
|
74
75
|
"react-intl-next": "npm:react-intl@^5.18.1"
|