@atlaskit/editor-plugin-table 7.6.14 → 7.7.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 +6 -0
- package/dist/cjs/commands/misc.js +0 -2
- package/dist/cjs/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/cjs/nodeviews/TableComponent.js +3 -18
- package/dist/cjs/nodeviews/TableContainer.js +2 -18
- package/dist/cjs/nodeviews/table.js +0 -2
- package/dist/cjs/plugin.js +3 -20
- package/dist/cjs/pm-plugins/main.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +7 -21
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/cjs/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/cjs/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/cjs/reducer.js +0 -2
- package/dist/cjs/transforms/column-width.js +3 -5
- package/dist/cjs/types.js +0 -1
- package/dist/cjs/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/cjs/ui/common-styles.js +5 -12
- package/dist/cjs/ui/ui-styles.js +7 -12
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/utils/nodes.js +5 -18
- package/dist/es2019/commands/misc.js +0 -2
- package/dist/es2019/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/es2019/nodeviews/TableComponent.js +3 -18
- package/dist/es2019/nodeviews/TableContainer.js +1 -16
- package/dist/es2019/nodeviews/table.js +0 -2
- package/dist/es2019/plugin.js +5 -24
- package/dist/es2019/pm-plugins/main.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +8 -22
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +30 -53
- package/dist/es2019/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +14 -24
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/es2019/reducer.js +0 -5
- package/dist/es2019/transforms/column-width.js +3 -5
- package/dist/es2019/types.js +0 -1
- package/dist/es2019/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/es2019/ui/common-styles.js +15 -46
- package/dist/es2019/ui/ui-styles.js +34 -41
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/utils/nodes.js +0 -15
- package/dist/esm/commands/misc.js +0 -2
- package/dist/esm/nodeviews/OverflowShadowsObserver.js +1 -3
- package/dist/esm/nodeviews/TableComponent.js +3 -18
- package/dist/esm/nodeviews/TableContainer.js +2 -18
- package/dist/esm/nodeviews/table.js +0 -2
- package/dist/esm/plugin.js +5 -22
- package/dist/esm/pm-plugins/main.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +8 -22
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +32 -57
- package/dist/esm/pm-plugins/table-resizing/utils/misc.js +1 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +16 -28
- package/dist/esm/pm-plugins/table-resizing/utils/scale-table.js +2 -12
- package/dist/esm/reducer.js +0 -2
- package/dist/esm/transforms/column-width.js +3 -5
- package/dist/esm/types.js +0 -1
- package/dist/esm/ui/ColumnResizeWidget/index.js +5 -1
- package/dist/esm/ui/common-styles.js +6 -13
- package/dist/esm/ui/ui-styles.js +7 -12
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/nodes.js +0 -13
- package/dist/types/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types/nodeviews/types.d.ts +0 -1
- package/dist/types/plugin.d.ts +0 -1
- package/dist/types/pm-plugins/main.d.ts +1 -1
- package/dist/types/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types/types.d.ts +0 -9
- package/dist/types/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/nodes.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableContainer.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/types.d.ts +0 -1
- package/dist/types-ts4.5/plugin.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -1
- package/dist/types-ts4.5/types.d.ts +0 -9
- package/dist/types-ts4.5/ui/FloatingContextualButton/index.d.ts +0 -2
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/nodes.d.ts +0 -1
- package/package.json +2 -5
- package/src/commands/misc.ts +0 -2
- package/src/nodeviews/OverflowShadowsObserver.ts +1 -6
- package/src/nodeviews/TableComponent.tsx +2 -25
- package/src/nodeviews/TableContainer.tsx +2 -26
- package/src/nodeviews/table.tsx +0 -2
- package/src/nodeviews/types.ts +0 -1
- package/src/plugin.tsx +4 -43
- package/src/pm-plugins/main.ts +0 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +8 -37
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +40 -61
- package/src/pm-plugins/table-resizing/utils/misc.ts +4 -6
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +18 -29
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +2 -13
- package/src/reducer.ts +0 -3
- package/src/transforms/column-width.ts +2 -10
- package/src/types.ts +0 -8
- package/src/ui/ColumnResizeWidget/index.tsx +10 -1
- package/src/ui/FloatingContextualButton/index.tsx +0 -2
- package/src/ui/common-styles.ts +15 -53
- package/src/ui/ui-styles.ts +34 -47
- package/src/utils/index.ts +0 -1
- package/src/utils/nodes.ts +0 -23
- package/dist/cjs/ui/LayoutButton/index.js +0 -206
- package/dist/es2019/ui/LayoutButton/index.js +0 -168
- package/dist/esm/ui/LayoutButton/index.js +0 -196
- package/dist/types/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.5/ui/LayoutButton/index.d.ts +0 -21
- package/src/ui/LayoutButton/index.tsx +0 -217
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { table, tableCell, tableHeader, tableRow
|
|
2
|
+
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
5
5
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
@@ -33,8 +33,7 @@ import FloatingContextualMenu from './ui/FloatingContextualMenu';
|
|
|
33
33
|
import FloatingDeleteButton from './ui/FloatingDeleteButton';
|
|
34
34
|
import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
35
35
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
36
|
-
import
|
|
37
|
-
import { createTableWithWidth, isLayoutSupported } from './utils';
|
|
36
|
+
import { createTableWithWidth } from './utils';
|
|
38
37
|
const defaultGetEditorFeatureFlags = () => ({});
|
|
39
38
|
|
|
40
39
|
// TODO: duplicating type instead of importing media plugin causing a circular dependency
|
|
@@ -107,10 +106,9 @@ const tablesPlugin = ({
|
|
|
107
106
|
insertTableWithSize: insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
108
107
|
},
|
|
109
108
|
nodes() {
|
|
110
|
-
const tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
|
|
111
109
|
return [{
|
|
112
110
|
name: 'table',
|
|
113
|
-
node:
|
|
111
|
+
node: table
|
|
114
112
|
}, {
|
|
115
113
|
name: 'tableHeader',
|
|
116
114
|
node: tableHeader
|
|
@@ -136,13 +134,12 @@ const tablesPlugin = ({
|
|
|
136
134
|
fullWidthEnabled,
|
|
137
135
|
wasFullWidthEnabled,
|
|
138
136
|
tableResizingEnabled,
|
|
139
|
-
breakoutEnabled,
|
|
140
137
|
tableOptions,
|
|
141
138
|
getEditorFeatureFlags,
|
|
142
139
|
dragAndDropEnabled,
|
|
143
140
|
isTableScalingEnabled
|
|
144
141
|
} = options || {};
|
|
145
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl,
|
|
142
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api, isTableScalingEnabled);
|
|
146
143
|
}
|
|
147
144
|
}, {
|
|
148
145
|
name: 'tablePMColResizing',
|
|
@@ -305,9 +302,6 @@ const tablesPlugin = ({
|
|
|
305
302
|
tableWidthPluginState,
|
|
306
303
|
dragAndDropState
|
|
307
304
|
}) => {
|
|
308
|
-
const {
|
|
309
|
-
state
|
|
310
|
-
} = editorView;
|
|
311
305
|
const isColumnResizing = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
312
306
|
const isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
313
307
|
const isResizing = isColumnResizing || isTableResizing;
|
|
@@ -316,7 +310,6 @@ const tablesPlugin = ({
|
|
|
316
310
|
tablePos,
|
|
317
311
|
targetCellPosition,
|
|
318
312
|
isContextualMenuOpen,
|
|
319
|
-
layout,
|
|
320
313
|
tableRef,
|
|
321
314
|
pluginConfig,
|
|
322
315
|
insertColumnButtonIndex,
|
|
@@ -330,17 +323,6 @@ const tablesPlugin = ({
|
|
|
330
323
|
allowControls
|
|
331
324
|
} = pluginConfig;
|
|
332
325
|
const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
333
|
-
const LayoutContent = options && !options.tableResizingEnabled && isLayoutSupported(state) && options.breakoutEnabled ? /*#__PURE__*/React.createElement(LayoutButton, {
|
|
334
|
-
editorView: editorView,
|
|
335
|
-
mountPoint: popupsMountPoint,
|
|
336
|
-
boundariesElement: popupsBoundariesElement,
|
|
337
|
-
scrollableElement: popupsScrollableElement,
|
|
338
|
-
targetRef: tableWrapperTarget,
|
|
339
|
-
layout: layout,
|
|
340
|
-
isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
|
|
341
|
-
stickyHeader: stickyHeader,
|
|
342
|
-
editorAnalyticsAPI: editorAnalyticsAPI
|
|
343
|
-
}) : null;
|
|
344
326
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isResizing && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
345
327
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
346
328
|
editorView: editorView,
|
|
@@ -350,7 +332,6 @@ const tablesPlugin = ({
|
|
|
350
332
|
scrollableElement: popupsScrollableElement,
|
|
351
333
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
352
334
|
isContextualMenuOpen: isContextualMenuOpen,
|
|
353
|
-
layout: layout,
|
|
354
335
|
stickyHeader: stickyHeader,
|
|
355
336
|
tableWrapper: tableWrapperTarget
|
|
356
337
|
}), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
|
|
@@ -403,7 +384,7 @@ const tablesPlugin = ({
|
|
|
403
384
|
stickyHeaders: stickyHeader,
|
|
404
385
|
isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
|
|
405
386
|
editorAnalyticsAPI: editorAnalyticsAPI
|
|
406
|
-
})
|
|
387
|
+
}));
|
|
407
388
|
}
|
|
408
389
|
}));
|
|
409
390
|
},
|
|
@@ -22,7 +22,7 @@ import { isHeaderRowRequired } from '../utils/paste';
|
|
|
22
22
|
import { defaultHoveredCell, defaultTableSelection } from './default-table-selection';
|
|
23
23
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
24
24
|
import { pluginKey } from './plugin-key';
|
|
25
|
-
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl,
|
|
25
|
+
export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, tableResizingEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi, isTableScalingEnabled) => {
|
|
26
26
|
var _accessibilityUtils;
|
|
27
27
|
const state = createPluginState(dispatch, {
|
|
28
28
|
pluginConfig,
|
|
@@ -30,7 +30,6 @@ export const createPlugin = (dispatchAnalyticsEvent, dispatch, portalProviderAPI
|
|
|
30
30
|
insertColumnButtonIndex: undefined,
|
|
31
31
|
insertRowButtonIndex: undefined,
|
|
32
32
|
isFullWidthModeEnabled: fullWidthModeEnabled,
|
|
33
|
-
isBreakoutEnabled: breakoutEnabled,
|
|
34
33
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
35
34
|
isTableResizingEnabled: tableResizingEnabled,
|
|
36
35
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION, TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
3
2
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
4
|
-
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
5
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
6
4
|
import { getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
7
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -13,7 +11,7 @@ import { getPluginState as getTablePluginState } from '../plugin-factory';
|
|
|
13
11
|
import { META_KEYS } from '../table-analytics';
|
|
14
12
|
import { evenColumns, setDragging, stopResizing } from './commands';
|
|
15
13
|
import { getPluginState } from './plugin-factory';
|
|
16
|
-
import { currentColWidth,
|
|
14
|
+
import { currentColWidth, getResizeState, getTableMaxWidth, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
17
15
|
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) => {
|
|
18
16
|
const {
|
|
19
17
|
state,
|
|
@@ -47,25 +45,13 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
47
45
|
if (dom && dom.nodeName !== 'TABLE') {
|
|
48
46
|
dom = dom.closest('table');
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
58
|
-
maxSize -= akEditorTableNumberColumnWidth;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
maxSize = getTableMaxWidth({
|
|
62
|
-
table: originalTable,
|
|
63
|
-
tableStart: start,
|
|
64
|
-
state,
|
|
65
|
-
layout: originalTable.attrs.layout,
|
|
66
|
-
getEditorContainerWidth
|
|
67
|
-
});
|
|
68
|
-
}
|
|
48
|
+
const maxSize = getTableMaxWidth({
|
|
49
|
+
table: originalTable,
|
|
50
|
+
tableStart: start,
|
|
51
|
+
state,
|
|
52
|
+
layout: originalTable.attrs.layout,
|
|
53
|
+
getEditorContainerWidth
|
|
54
|
+
});
|
|
69
55
|
const shouldScale = tableDepth === 0 && isTableScalingEnabled;
|
|
70
56
|
const resizeState = getResizeState({
|
|
71
57
|
minWidth: tableCellMinWidth,
|
|
@@ -2,7 +2,6 @@ import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
|
2
2
|
import { getFragmentBackingArray } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { getTableScalingPercent } from './misc';
|
|
7
6
|
/**
|
|
8
7
|
* This ensures the combined width of the columns (and tbody) of table is always smaller or equal
|
|
@@ -13,62 +12,40 @@ import { getTableScalingPercent } from './misc';
|
|
|
13
12
|
export const getColWidthFix = (colwidth, tableColumnCount) => colwidth - 1 / tableColumnCount;
|
|
14
13
|
export const generateColgroup = (table, tableRef) => {
|
|
15
14
|
const cols = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const scalePercent = getTableScalingPercent(table, tableRef);
|
|
25
|
-
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
26
|
-
const fixedColWidth = getColWidthFix(width, map.width);
|
|
27
|
-
const scaledWidth = fixedColWidth * scalePercent;
|
|
28
|
-
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
29
|
-
cols.push(['col', {
|
|
30
|
-
style: `width: ${finalWidth}px;`
|
|
31
|
-
}]);
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
35
|
-
cols.push(['col', {
|
|
36
|
-
style: `width: ${getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width)}px;`
|
|
37
|
-
}]);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
// When we have merged cells on the first row (firstChild),
|
|
42
|
-
// We want to ensure we're creating the appropriate amount of
|
|
43
|
-
// cols the table still has.
|
|
44
|
-
cols.push(...Array.from({
|
|
45
|
-
length: colspan
|
|
46
|
-
}, _ => ['col', {
|
|
47
|
-
style: `width: ${tableCellMinWidth}px;`
|
|
48
|
-
}]));
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
} else {
|
|
52
|
-
table.content.firstChild.content.forEach(cell => {
|
|
53
|
-
const colspan = cell.attrs.colspan || 1;
|
|
54
|
-
if (Array.isArray(cell.attrs.colwidth)) {
|
|
55
|
-
// We slice here to guard against our colwidth array having more entries
|
|
56
|
-
// Than the we actually span. We'll patch the document at a later point.
|
|
15
|
+
const map = TableMap.get(table);
|
|
16
|
+
table.content.firstChild.content.forEach(cell => {
|
|
17
|
+
const colspan = cell.attrs.colspan || 1;
|
|
18
|
+
if (Array.isArray(cell.attrs.colwidth)) {
|
|
19
|
+
// We slice here to guard against our colwidth array having more entries
|
|
20
|
+
// Than the we actually span. We'll patch the document at a later point.
|
|
21
|
+
if (tableRef) {
|
|
22
|
+
const scalePercent = getTableScalingPercent(table, tableRef);
|
|
57
23
|
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
24
|
+
const fixedColWidth = getColWidthFix(width, map.width);
|
|
25
|
+
const scaledWidth = fixedColWidth * scalePercent;
|
|
26
|
+
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
27
|
+
cols.push(['col', {
|
|
28
|
+
style: `width: ${finalWidth}px;`
|
|
29
|
+
}]);
|
|
61
30
|
});
|
|
62
31
|
} else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, _ => ['col', {}]));
|
|
32
|
+
cell.attrs.colwidth.slice(0, colspan).forEach(width => {
|
|
33
|
+
cols.push(['col', {
|
|
34
|
+
style: `width: ${getColWidthFix(width ? Math.max(width, tableCellMinWidth) : tableCellMinWidth, map.width)}px;`
|
|
35
|
+
}]);
|
|
36
|
+
});
|
|
69
37
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
38
|
+
} else {
|
|
39
|
+
// When we have merged cells on the first row (firstChild),
|
|
40
|
+
// We want to ensure we're creating the appropriate amount of
|
|
41
|
+
// cols the table still has.
|
|
42
|
+
cols.push(...Array.from({
|
|
43
|
+
length: colspan
|
|
44
|
+
}, _ => ['col', {
|
|
45
|
+
style: `width: ${tableCellMinWidth}px;`
|
|
46
|
+
}]));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
72
49
|
return cols;
|
|
73
50
|
};
|
|
74
51
|
export const insertColgroupFromNode = (tableRef, table, isTableScalingEnabled = false, shouldRemove = true) => {
|
|
@@ -3,7 +3,6 @@ import { calcTableWidth } from '@atlaskit/editor-common/styles';
|
|
|
3
3
|
import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-common/ui';
|
|
4
4
|
import { calcTableColumnWidths, containsClassName } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
6
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
6
|
import { hasTableBeenResized } from './colgroup';
|
|
8
7
|
import { MAX_SCALING_PERCENT } from './consts';
|
|
9
8
|
|
|
@@ -69,7 +68,7 @@ export const getTableMaxWidth = ({
|
|
|
69
68
|
}) => {
|
|
70
69
|
const containerWidth = getEditorContainerWidth();
|
|
71
70
|
const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
72
|
-
let maxWidth =
|
|
71
|
+
let maxWidth = parentWidth || table.attrs.width || getLayoutSize(layout, containerWidth.width, {});
|
|
73
72
|
if (table.attrs.isNumberColumnEnabled) {
|
|
74
73
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
75
74
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
2
2
|
import { tableCellMinWidth, tableNewColumnMinWidth } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { calcTableColumnWidths } from '@atlaskit/editor-common/utils';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { getSelectedTableInfo } from '../../../utils';
|
|
6
5
|
import { getColWidthFix, hasTableBeenResized, insertColgroupFromNode } from './colgroup';
|
|
7
6
|
import { getCellsRefsInColumn, getColumnStateFromDOM } from './column-state';
|
|
@@ -74,33 +73,24 @@ export const getResizeState = ({
|
|
|
74
73
|
// updates Colgroup DOM node with new widths
|
|
75
74
|
export const updateColgroup = (state, tableRef, tableNode, isTableScalingEnabled) => {
|
|
76
75
|
const cols = tableRef.querySelectorAll('col');
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
} else {
|
|
92
|
-
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
93
|
-
.forEach((column, i) => {
|
|
94
|
-
if (cols[i]) {
|
|
95
|
-
cols[i].style.width = `${getColWidthFix(column.width, columnsCount)}px`;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
76
|
+
const columnsCount = cols.length;
|
|
77
|
+
if (isTableScalingEnabled && tableNode) {
|
|
78
|
+
const scalePercent = getTableScalingPercent(tableNode, tableRef);
|
|
79
|
+
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
80
|
+
.forEach((column, i) => {
|
|
81
|
+
const fixedColWidth = getColWidthFix(column.width, columnsCount);
|
|
82
|
+
const scaledWidth = fixedColWidth * scalePercent;
|
|
83
|
+
const finalWidth = Math.max(scaledWidth, tableCellMinWidth);
|
|
84
|
+
// we aren't handling the remaining pixels here when the 48px min width is reached
|
|
85
|
+
if (cols[i]) {
|
|
86
|
+
cols[i].style.width = `${finalWidth}px`;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
99
89
|
} else {
|
|
100
90
|
state.cols.filter(column => column && !!column.width) // if width is 0, we dont want to apply that.
|
|
101
91
|
.forEach((column, i) => {
|
|
102
92
|
if (cols[i]) {
|
|
103
|
-
cols[i].style.width = `${column.width}px`;
|
|
93
|
+
cols[i].style.width = `${getColWidthFix(column.width, columnsCount)}px`;
|
|
104
94
|
}
|
|
105
95
|
});
|
|
106
96
|
}
|
|
@@ -11,28 +11,18 @@ import { syncStickyRowToTable } from './dom';
|
|
|
11
11
|
// Base function to trigger the actual scale on a table node.
|
|
12
12
|
// Will only resize/scale if a table has been previously resized.
|
|
13
13
|
export const scale = (tableRef, options, domAtPos, isTableScalingEnabled = false) => {
|
|
14
|
-
/**
|
|
15
|
-
* isBreakoutEnabled === true -> default center aligned
|
|
16
|
-
* isBreakoutEnabled === false -> full width mode
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
14
|
const {
|
|
20
15
|
node,
|
|
21
16
|
containerWidth,
|
|
22
17
|
previousContainerWidth,
|
|
23
18
|
prevNode,
|
|
24
19
|
start,
|
|
25
|
-
isBreakoutEnabled,
|
|
26
20
|
layoutChanged,
|
|
27
21
|
isTableResizingEnabled
|
|
28
22
|
} = options;
|
|
29
|
-
const maxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(node.attrs.layout, containerWidth, {
|
|
30
|
-
isBreakoutEnabled
|
|
31
|
-
});
|
|
23
|
+
const maxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(node.attrs.layout, containerWidth, {});
|
|
32
24
|
const prevTableWidth = getTableWidth(prevNode);
|
|
33
|
-
const previousMaxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {
|
|
34
|
-
isBreakoutEnabled
|
|
35
|
-
});
|
|
25
|
+
const previousMaxSize = isTableResizingEnabled ? getTableContainerWidth(node) : getLayoutSize(prevNode.attrs.layout, previousContainerWidth, {});
|
|
36
26
|
let newWidth = maxSize;
|
|
37
27
|
|
|
38
28
|
// adjust table width if layout is updated
|
package/dist/es2019/reducer.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
2
2
|
import { AttrStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
4
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
import { getTableContainerElementWidth, getTableElementWidth, hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
6
5
|
import { isMinCellWidthTable } from '../pm-plugins/table-resizing/utils/colgroup';
|
|
7
6
|
import { getResizeState } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
8
7
|
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
9
|
-
import { insertColumnButtonOffset } from '../ui/common-styles';
|
|
10
8
|
|
|
11
9
|
/**
|
|
12
10
|
* Given a new ResizeState object, create a transaction that replaces and updates the table node based on new state.
|
|
@@ -111,16 +109,16 @@ export const rescaleColumns = (isTableScalingEnabled = false) => (table, view) =
|
|
|
111
109
|
if (shouldScale) {
|
|
112
110
|
previousTableInfo = {
|
|
113
111
|
width: getTableElementWidth(table.node),
|
|
114
|
-
possibleMaxWidth:
|
|
112
|
+
possibleMaxWidth: getTableContainerElementWidth(table.node),
|
|
115
113
|
isResized
|
|
116
114
|
};
|
|
117
115
|
} else {
|
|
118
|
-
var _tableRef$parentEleme
|
|
116
|
+
var _tableRef$parentEleme;
|
|
119
117
|
previousTableInfo = {
|
|
120
118
|
// when table is resized the tableRef client width will be 1px larger than colGroup, which is used in calculations
|
|
121
119
|
width: isResized ? tableRef.clientWidth - 1 : tableRef.clientWidth,
|
|
122
120
|
/** the is the width the table can reach before overflowing */
|
|
123
|
-
possibleMaxWidth:
|
|
121
|
+
possibleMaxWidth: (tableRef === null || tableRef === void 0 ? void 0 : (_tableRef$parentEleme = tableRef.parentElement) === null || _tableRef$parentEleme === void 0 ? void 0 : _tableRef$parentEleme.clientWidth) || 0,
|
|
124
122
|
isResized
|
|
125
123
|
};
|
|
126
124
|
}
|
package/dist/es2019/types.js
CHANGED
|
@@ -69,7 +69,6 @@ export const TableCssClassName = {
|
|
|
69
69
|
CONTROLS_INSERT_BUTTON_WRAP: `${tablePrefixSelector}-controls__insert-button-wrap`,
|
|
70
70
|
CONTROLS_INSERT_LINE: `${tablePrefixSelector}-controls__insert-line`,
|
|
71
71
|
CONTROLS_BUTTON_OVERLAY: `${tablePrefixSelector}-controls__button-overlay`,
|
|
72
|
-
LAYOUT_BUTTON: `${tablePrefixSelector}-layout-button`,
|
|
73
72
|
DRAG_CONTROLS_INSERT_BUTTON: `${tablePrefixSelector}-controls__drag-insert-button`,
|
|
74
73
|
DRAG_CONTROLS_INSERT_BUTTON_INNER: `${tablePrefixSelector}-controls__drag-insert-button-inner`,
|
|
75
74
|
DRAG_CONTROLS_INSERT_BUTTON_INNER_COLUMN: `${tablePrefixSelector}-controls__drag-insert-button-inner-column`,
|
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import { useIntl } from 'react-intl-next';
|
|
5
|
+
import { startColumnResizing, ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
5
6
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
7
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
8
|
import { TableCssClassName } from '../../types';
|
|
@@ -21,7 +22,10 @@ export const ColumnResizeWidget = ({
|
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
return jsx(Tooltip, {
|
|
24
|
-
content:
|
|
25
|
+
content: jsx(ToolTipContent, {
|
|
26
|
+
description: formatMessage(messages.adjustColumns),
|
|
27
|
+
keymap: startColumnResizing
|
|
28
|
+
}),
|
|
25
29
|
hideTooltipOnClick: true,
|
|
26
30
|
hideTooltipOnMouseDown: true,
|
|
27
31
|
position: "mouse",
|
|
@@ -6,7 +6,7 @@ import { browser } from '@atlaskit/editor-common/utils';
|
|
|
6
6
|
import { akEditorSelectedNodeClassName, akEditorSmallZIndex, akEditorStickyHeaderZIndex, akEditorTableCellOnStickyHeaderZIndex, akEditorTableNumberColumnWidth, akEditorTableToolbarSize, akEditorUnitZIndex, getSelectionStyles, MAX_BROWSER_SCROLLBAR_HEIGHT, relativeFontSizeToBase16, SelectionStyle } from '@atlaskit/editor-shared-styles';
|
|
7
7
|
import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import {
|
|
9
|
+
import { N0, N40A, R500 } from '@atlaskit/theme/colors';
|
|
10
10
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
11
11
|
import { TableCssClassName as ClassName } from '../types';
|
|
12
12
|
import { columnControlsDecorationHeight, resizeHandlerAreaWidth, resizeHandlerZIndex, resizeLineWidth, rowControlsZIndex, stickyHeaderBorderBottomWidth, stickyRowOffsetTop, tableBorderColor, tableBorderDeleteColor, tableBorderRadiusSize, tableBorderSelectedColor, tableCellBackgroundColor, tableCellDeleteColor, tableCellSelectedColor, tableControlsSpacing, tableHeaderCellBackgroundColor, tableInsertColumnButtonSize, tableOverflowShadowWidth, tablePadding, tableScrollbarOffset, tableTextColor, tableToolbarDeleteColor, tableToolbarSelectedColor, tableToolbarSize } from './consts';
|
|
@@ -177,35 +177,6 @@ const tableStickyHeaderFirefoxFixStyle = () => {
|
|
|
177
177
|
`;
|
|
178
178
|
}
|
|
179
179
|
};
|
|
180
|
-
const tableWrapperStyles = () => {
|
|
181
|
-
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
182
|
-
return css`
|
|
183
|
-
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
184
|
-
padding-bottom: 0px;
|
|
185
|
-
/* fixes gap cursor height */
|
|
186
|
-
overflow: auto;
|
|
187
|
-
overflow-y: hidden;
|
|
188
|
-
position: relative;
|
|
189
|
-
|
|
190
|
-
> table[data-number-column='true'] {
|
|
191
|
-
width: calc(100% - 1px);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
`;
|
|
195
|
-
} else {
|
|
196
|
-
return css`
|
|
197
|
-
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
198
|
-
padding-right: ${insertColumnButtonOffset}px;
|
|
199
|
-
margin-right: -${insertColumnButtonOffset}px;
|
|
200
|
-
padding-bottom: 0px;
|
|
201
|
-
/* fixes gap cursor height */
|
|
202
|
-
overflow: auto;
|
|
203
|
-
overflow-y: hidden;
|
|
204
|
-
position: relative;
|
|
205
|
-
}
|
|
206
|
-
`;
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
180
|
|
|
210
181
|
// re-exporting these styles to use in Gemini test when table node view is rendered outside of PM
|
|
211
182
|
export const baseTableStyles = props => {
|
|
@@ -526,7 +497,7 @@ export const baseTableStyles = props => {
|
|
|
526
497
|
|
|
527
498
|
.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
528
499
|
.${ClassName.CORNER_CONTROLS}, .${ClassName.CONTROLS_CORNER_BUTTON} {
|
|
529
|
-
width: ${
|
|
500
|
+
width: ${akEditorTableToolbarSize + akEditorTableNumberColumnWidth + 1}px;
|
|
530
501
|
}
|
|
531
502
|
.${ClassName.ROW_CONTROLS} .${ClassName.CONTROLS_BUTTON} {
|
|
532
503
|
border-right-width: 0;
|
|
@@ -764,7 +735,7 @@ export const baseTableStyles = props => {
|
|
|
764
735
|
.${ClassName.NUMBERED_COLUMN} {
|
|
765
736
|
position: relative;
|
|
766
737
|
float: right;
|
|
767
|
-
margin-left: ${
|
|
738
|
+
margin-left: ${akEditorTableToolbarSize}px;
|
|
768
739
|
top: ${(_props$featureFlags4 = props.featureFlags) !== null && _props$featureFlags4 !== void 0 && _props$featureFlags4.tableDragAndDrop ? 0 : akEditorTableToolbarSize}px;
|
|
769
740
|
width: ${akEditorTableNumberColumnWidth + 1}px;
|
|
770
741
|
box-sizing: border-box;
|
|
@@ -813,7 +784,7 @@ export const baseTableStyles = props => {
|
|
|
813
784
|
display: block;
|
|
814
785
|
}
|
|
815
786
|
.${ClassName.NUMBERED_COLUMN} {
|
|
816
|
-
padding-left:
|
|
787
|
+
padding-left: 0px;
|
|
817
788
|
|
|
818
789
|
.${ClassName.NUMBERED_COLUMN_BUTTON} {
|
|
819
790
|
border-left: 0 none;
|
|
@@ -979,24 +950,22 @@ export const baseTableStyles = props => {
|
|
|
979
950
|
z-index: ${akEditorTableCellOnStickyHeaderZIndex - 4};
|
|
980
951
|
}
|
|
981
952
|
|
|
982
|
-
|
|
953
|
+
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
954
|
+
padding-bottom: 0px;
|
|
955
|
+
/* fixes gap cursor height */
|
|
956
|
+
overflow: auto;
|
|
957
|
+
overflow-y: hidden;
|
|
958
|
+
position: relative;
|
|
959
|
+
|
|
960
|
+
> table[data-number-column='true'] {
|
|
961
|
+
width: calc(100% - 1px);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
983
964
|
`;
|
|
984
965
|
};
|
|
985
966
|
|
|
986
967
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4139
|
|
987
968
|
export const tableStyles = props => css`
|
|
988
|
-
.${ClassName.LAYOUT_BUTTON} button {
|
|
989
|
-
background: ${`var(--ds-background-neutral, ${N20A})`};
|
|
990
|
-
color: ${`var(--ds-icon, ${N300})`};
|
|
991
|
-
cursor: none;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
.${ClassName.LAYOUT_BUTTON}:not(.${ClassName.IS_RESIZING}) button:hover {
|
|
995
|
-
background: ${`var(--ds-background-neutral-hovered, ${B300})`};
|
|
996
|
-
color: ${"var(--ds-icon, white)"} !important;
|
|
997
|
-
cursor: pointer;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
969
|
.ProseMirror {
|
|
1001
970
|
${baseTableStyles(props)}
|
|
1002
971
|
}
|