@atlaskit/editor-plugin-table 1.1.5 → 1.2.1
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 +32 -0
- package/dist/cjs/plugins/table/index.js +2 -1
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +1 -2
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +39 -17
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/misc.js +3 -38
- package/dist/cjs/plugins/table/toolbar.js +3 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +20 -4
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
- package/dist/cjs/plugins/table/ui/common-styles.js +1 -1
- package/dist/cjs/plugins/table/ui/messages.js +5 -0
- package/dist/cjs/plugins/table/ui/ui-styles.js +2 -2
- package/dist/cjs/types/i18n.js +5 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/index.js +2 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +39 -17
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -37
- package/dist/es2019/plugins/table/toolbar.js +3 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +23 -6
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
- package/dist/es2019/plugins/table/ui/common-styles.js +10 -3
- package/dist/es2019/plugins/table/ui/messages.js +5 -0
- package/dist/es2019/plugins/table/ui/ui-styles.js +8 -4
- package/dist/es2019/types/i18n.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/index.js +2 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +39 -17
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -5
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/misc.js +1 -35
- package/dist/esm/plugins/table/toolbar.js +3 -2
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +22 -6
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +6 -3
- package/dist/esm/plugins/table/ui/common-styles.js +1 -1
- package/dist/esm/plugins/table/ui/messages.js +5 -0
- package/dist/esm/plugins/table/ui/ui-styles.js +3 -3
- package/dist/esm/types/i18n.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +3 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -2
- package/dist/types/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +2 -1
- package/dist/types/plugins/table/ui/FloatingContextualMenu/index.d.ts +3 -2
- package/dist/types/plugins/table/ui/messages.d.ts +5 -0
- package/dist/types/types/i18n.d.ts +5 -0
- package/package.json +10 -10
- package/report.api.md +3 -2
- package/src/__tests__/integration/__fixtures__/large-table-with-sticky-header.ts +2311 -0
- package/src/__tests__/integration/horizontal-scroll.ts +4 -9
- package/src/__tests__/integration/sticky-header.ts +220 -0
- package/src/__tests__/unit/commands/insert.ts +8 -8
- package/src/__tests__/unit/nodeviews/cell.ts +14 -0
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +2 -2
- package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +1 -0
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +2 -2
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +2 -2
- package/src/plugins/table/index.tsx +7 -2
- package/src/plugins/table/nodeviews/TableComponent.tsx +1 -2
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +47 -25
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -9
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -57
- package/src/plugins/table/toolbar.tsx +6 -2
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +29 -4
- package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +8 -1
- package/src/plugins/table/ui/common-styles.ts +10 -3
- package/src/plugins/table/ui/messages.ts +5 -0
- package/src/plugins/table/ui/ui-styles.ts +8 -4
- package/src/types/i18n.ts +5 -0
|
@@ -172,7 +172,7 @@ export class TableRowNodeView {
|
|
|
172
172
|
syncStickyRowToTable(tree.table);
|
|
173
173
|
}, 0);
|
|
174
174
|
});
|
|
175
|
-
_defineProperty(this, "
|
|
175
|
+
_defineProperty(this, "updateStickyHeaderWidth", () => {
|
|
176
176
|
// table width might have changed, sync that back to sticky row
|
|
177
177
|
const tree = this.tree;
|
|
178
178
|
if (!tree) {
|
|
@@ -206,7 +206,7 @@ export class TableRowNodeView {
|
|
|
206
206
|
// otherwise make it non-sticky
|
|
207
207
|
return false;
|
|
208
208
|
});
|
|
209
|
-
_defineProperty(this, "makeHeaderRowSticky", tree => {
|
|
209
|
+
_defineProperty(this, "makeHeaderRowSticky", (tree, scrollTop) => {
|
|
210
210
|
var _tbody$firstChild;
|
|
211
211
|
// If header row height is more than 50% of viewport height don't do this
|
|
212
212
|
if (this.stickyRowHeight && this.stickyRowHeight > window.innerHeight / 2) {
|
|
@@ -223,7 +223,10 @@ export class TableRowNodeView {
|
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
225
|
const currentTableTop = this.getCurrentTableTop(tree);
|
|
226
|
-
|
|
226
|
+
if (!scrollTop) {
|
|
227
|
+
scrollTop = getTop(this.editorScrollableElement);
|
|
228
|
+
}
|
|
229
|
+
const domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
|
|
227
230
|
if (!this.isSticky) {
|
|
228
231
|
syncStickyRowToTable(table);
|
|
229
232
|
this.dom.classList.add('sticky');
|
|
@@ -315,7 +318,7 @@ export class TableRowNodeView {
|
|
|
315
318
|
}
|
|
316
319
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
317
320
|
}
|
|
318
|
-
this.eventDispatcher.on('widthPlugin', this.
|
|
321
|
+
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
|
|
319
322
|
this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
|
|
320
323
|
this.listening = true;
|
|
321
324
|
this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this));
|
|
@@ -327,6 +330,13 @@ export class TableRowNodeView {
|
|
|
327
330
|
}
|
|
328
331
|
if (this.intersectionObserver) {
|
|
329
332
|
this.intersectionObserver.disconnect();
|
|
333
|
+
// ED-16211 Once intersection observer is disconnected, we need to remove the isObserved from the sentinels
|
|
334
|
+
// Otherwise when new intersection observer is created it will not observe because it thinks its already being observed
|
|
335
|
+
[this.sentinels.top, this.sentinels.bottom].forEach(el => {
|
|
336
|
+
if (el) {
|
|
337
|
+
delete el.dataset.isObserved;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
330
340
|
}
|
|
331
341
|
if (this.resizeObserver) {
|
|
332
342
|
this.resizeObserver.disconnect();
|
|
@@ -334,7 +344,7 @@ export class TableRowNodeView {
|
|
|
334
344
|
if (this.editorScrollableElement && !this.stickyHeadersOptimization) {
|
|
335
345
|
this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
|
|
336
346
|
}
|
|
337
|
-
this.eventDispatcher.off('widthPlugin', this.
|
|
347
|
+
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
338
348
|
this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
|
|
339
349
|
this.listening = false;
|
|
340
350
|
this.dom.removeEventListener('wheel', this.headerRowMouseScroll);
|
|
@@ -353,6 +363,9 @@ export class TableRowNodeView {
|
|
|
353
363
|
return;
|
|
354
364
|
}
|
|
355
365
|
this.resizeObserver.observe(this.dom);
|
|
366
|
+
if (this.editorScrollableElement) {
|
|
367
|
+
this.resizeObserver.observe(this.editorScrollableElement);
|
|
368
|
+
}
|
|
356
369
|
window.requestAnimationFrame(() => {
|
|
357
370
|
var _this$tree;
|
|
358
371
|
// we expect tree to be defined after animation frame
|
|
@@ -382,14 +395,21 @@ export class TableRowNodeView {
|
|
|
382
395
|
table
|
|
383
396
|
} = this.tree;
|
|
384
397
|
entries.forEach(entry => {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
//
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
398
|
+
var _this$editorScrollabl;
|
|
399
|
+
// On resize of the parent scroll element we need to adjust the width
|
|
400
|
+
// of the sticky header
|
|
401
|
+
if (entry.target.className === ((_this$editorScrollabl = this.editorScrollableElement) === null || _this$editorScrollabl === void 0 ? void 0 : _this$editorScrollabl.className)) {
|
|
402
|
+
this.updateStickyHeaderWidth();
|
|
403
|
+
} else {
|
|
404
|
+
const newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
|
|
405
|
+
if (this.sentinels.bottom &&
|
|
406
|
+
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
407
|
+
// So we adding this check to allow a 1px difference.
|
|
408
|
+
Math.abs(newHeight - (this.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
|
|
409
|
+
this.stickyRowHeight = newHeight;
|
|
410
|
+
this.sentinels.bottom.style.bottom = `${tableScrollbarOffset + stickyRowOffsetTop + newHeight}px`;
|
|
411
|
+
updateTableMargin(table);
|
|
412
|
+
}
|
|
393
413
|
}
|
|
394
414
|
});
|
|
395
415
|
});
|
|
@@ -414,18 +434,20 @@ export class TableRowNodeView {
|
|
|
414
434
|
var _entry$rootBounds2;
|
|
415
435
|
const sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
416
436
|
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
417
|
-
|
|
437
|
+
var _entry$rootBounds3;
|
|
438
|
+
this.tree && this.makeHeaderRowSticky(this.tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
418
439
|
} else {
|
|
419
440
|
table && this.makeRowHeaderNotSticky(table);
|
|
420
441
|
}
|
|
421
442
|
}
|
|
422
443
|
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
423
|
-
var _entry$
|
|
424
|
-
const sentinelIsAboveScrollArea = entry.boundingClientRect.top - this.dom.offsetHeight < (((_entry$
|
|
444
|
+
var _entry$rootBounds4;
|
|
445
|
+
const sentinelIsAboveScrollArea = entry.boundingClientRect.top - this.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
425
446
|
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
426
447
|
this.makeRowHeaderNotSticky(table);
|
|
427
448
|
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
428
|
-
|
|
449
|
+
var _entry$rootBounds5;
|
|
450
|
+
this.tree && this.makeHeaderRowSticky(this.tree, entry === null || entry === void 0 ? void 0 : (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
429
451
|
}
|
|
430
452
|
}
|
|
431
453
|
});
|
|
@@ -9,7 +9,6 @@ import { evenColumns, setDragging, stopResizing } from './commands';
|
|
|
9
9
|
import { getPluginState } from './plugin-factory';
|
|
10
10
|
import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
11
11
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
12
|
-
import { getParentWidthWithoutPadding } from './utils/misc';
|
|
13
12
|
export const handleMouseDown = (view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) => {
|
|
14
13
|
const {
|
|
15
14
|
state,
|
|
@@ -32,10 +31,7 @@ export const handleMouseDown = (view, event, localResizeHandlePos, getEditorCont
|
|
|
32
31
|
}
|
|
33
32
|
const containerWidth = getEditorContainerWidth();
|
|
34
33
|
const parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
35
|
-
|
|
36
|
-
// TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
|
|
37
|
-
const parentActualWidth = getParentWidthWithoutPadding(parentWidth, start, state);
|
|
38
|
-
let maxSize = parentActualWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
34
|
+
let maxSize = parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
39
35
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
40
36
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
41
37
|
}
|
|
@@ -3,8 +3,6 @@ import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-c
|
|
|
3
3
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorWideLayoutWidth, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { containsClassName } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
6
|
-
import { gridSize } from '@atlaskit/theme/constants';
|
|
7
|
-
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
8
6
|
export const tableLayoutToSize = {
|
|
9
7
|
default: akEditorDefaultLayoutWidth,
|
|
10
8
|
wide: akEditorWideLayoutWidth,
|
|
@@ -73,43 +71,9 @@ export const getTableMaxWidth = ({
|
|
|
73
71
|
}) => {
|
|
74
72
|
const containerWidth = getEditorContainerWidth();
|
|
75
73
|
const parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
76
|
-
|
|
77
|
-
// TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
|
|
78
|
-
const parentActualWidth = getParentWidthWithoutPadding(parentWidth, tableStart, state);
|
|
79
|
-
let maxWidth = parentActualWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
74
|
+
let maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
80
75
|
if (table.attrs.isNumberColumnEnabled) {
|
|
81
76
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
82
77
|
}
|
|
83
78
|
return maxWidth;
|
|
84
|
-
};
|
|
85
|
-
export const getParentWidthWithoutPadding = (parentWidth, tableStartPos, state) => {
|
|
86
|
-
const node = getNestedParentNode(tableStartPos, state);
|
|
87
|
-
if (!node) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const {
|
|
91
|
-
schema
|
|
92
|
-
} = state;
|
|
93
|
-
if (node.type === schema.nodes.expand) {
|
|
94
|
-
// padding
|
|
95
|
-
parentWidth -= gridSize() * 2;
|
|
96
|
-
// gutter offset
|
|
97
|
-
parentWidth += gridSize() * 1.5 * 2;
|
|
98
|
-
// padding right
|
|
99
|
-
parentWidth -= gridSize();
|
|
100
|
-
// padding left
|
|
101
|
-
parentWidth -= gridSize() * 4 - gridSize() / 2;
|
|
102
|
-
}
|
|
103
|
-
return parentWidth;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// copy of getNestedParentNode() from packages/editor/editor-common/src/node-width/index.ts
|
|
107
|
-
// to be removed later when we will move getParentWidthWithoutPadding() logic to editor-common
|
|
108
|
-
const getNestedParentNode = (tablePos, state) => {
|
|
109
|
-
if (tablePos === undefined) {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const $pos = state.doc.resolve(tablePos);
|
|
113
|
-
const parent = findParentNodeOfTypeClosestToPos($pos, [state.schema.nodes.bodiedExtension, state.schema.nodes.layoutSection, state.schema.nodes.expand]);
|
|
114
|
-
return parent ? parent.node : null;
|
|
115
79
|
};
|
|
@@ -306,11 +306,12 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
306
306
|
// Check if we need to show confirm dialog for delete button
|
|
307
307
|
let confirmDialog;
|
|
308
308
|
if (isReferencedSource(state, tableObject.node)) {
|
|
309
|
+
const localSourceName = intl.formatMessage(tableMessages.unnamedSource);
|
|
309
310
|
confirmDialog = () => ({
|
|
310
311
|
title: intl.formatMessage(tableMessages.deleteElementTitle),
|
|
311
312
|
okButtonLabel: intl.formatMessage(tableMessages.confirmDeleteLinkedModalOKButton),
|
|
312
313
|
message: intl.formatMessage(tableMessages.confirmDeleteLinkedModalMessage, {
|
|
313
|
-
nodeName: getNodeName(state, tableObject.node)
|
|
314
|
+
nodeName: getNodeName(state, tableObject.node) || localSourceName
|
|
314
315
|
}),
|
|
315
316
|
messagePrefix: intl.formatMessage(tableMessages.confirmDeleteLinkedModalMessagePrefix),
|
|
316
317
|
isReferentialityDialog: true,
|
|
@@ -335,7 +336,7 @@ export const getToolbarConfig = (getEditorContainerWidth, editorAnalyticsAPI, ge
|
|
|
335
336
|
title: 'Table floating controls',
|
|
336
337
|
getDomRef,
|
|
337
338
|
nodeType,
|
|
338
|
-
offset: [0,
|
|
339
|
+
offset: [0, 18],
|
|
339
340
|
zIndex: akEditorFloatingPanelZIndex + 1,
|
|
340
341
|
// Place the context menu slightly above the others
|
|
341
342
|
items: [menu, separator(menu.hidden), ...cellItems, ...colorPicker, {
|
|
@@ -5,9 +5,9 @@ import { jsx } from '@emotion/react';
|
|
|
5
5
|
import { splitCell } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
7
7
|
import { addColumnAfter, addRowAfter, backspace, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
8
|
-
import { ColorPalette, cellBackgroundColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
8
|
+
import { ColorPalette, backgroundPaletteTooltipMessages, cellBackgroundColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
9
9
|
import { DropdownMenuSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
10
|
-
import { DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
10
|
+
import { ArrowKeyNavigationType, DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
11
11
|
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
12
12
|
import { cellColourPreviewStyles } from './styles';
|
|
13
13
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
@@ -94,12 +94,16 @@ export class ContextualMenu extends Component {
|
|
|
94
94
|
intl: {
|
|
95
95
|
formatMessage
|
|
96
96
|
},
|
|
97
|
-
editorView
|
|
97
|
+
editorView,
|
|
98
|
+
getEditorFeatureFlags
|
|
98
99
|
} = this.props;
|
|
99
100
|
const items = [];
|
|
100
101
|
const {
|
|
101
102
|
isSubmenuOpen
|
|
102
103
|
} = this.state;
|
|
104
|
+
const {
|
|
105
|
+
useSomewhatSemanticTextColorNames
|
|
106
|
+
} = getEditorFeatureFlags();
|
|
103
107
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
104
108
|
const {
|
|
105
109
|
targetCellPosition,
|
|
@@ -126,9 +130,19 @@ export class ContextualMenu extends Component {
|
|
|
126
130
|
ref: this.handleSubMenuRef
|
|
127
131
|
}, jsx(ColorPalette, {
|
|
128
132
|
cols: 7,
|
|
129
|
-
palette: cellBackgroundColorPalette,
|
|
130
133
|
onClick: this.setColor,
|
|
131
|
-
selectedColor: background
|
|
134
|
+
selectedColor: background,
|
|
135
|
+
paletteOptions: {
|
|
136
|
+
palette: cellBackgroundColorPalette,
|
|
137
|
+
paletteColorTooltipMessages: backgroundPaletteTooltipMessages,
|
|
138
|
+
// We did not want to create new FF or update
|
|
139
|
+
// useSomewhatSemanticTextColorNames name
|
|
140
|
+
// because it is temporary and require extra work.
|
|
141
|
+
// So even though it says text color names,
|
|
142
|
+
// we are going to use for all color pickers
|
|
143
|
+
// such as text, background and table charts.
|
|
144
|
+
showSomewhatSemanticTooltips: useSomewhatSemanticTextColorNames
|
|
145
|
+
}
|
|
132
146
|
})))
|
|
133
147
|
});
|
|
134
148
|
}
|
|
@@ -420,7 +434,10 @@ export class ContextualMenu extends Component {
|
|
|
420
434
|
//This needs be removed when the a11y is completely handled
|
|
421
435
|
//Disabling key navigation now as it works only partially
|
|
422
436
|
,
|
|
423
|
-
|
|
437
|
+
arrowKeyNavigationProviderOptions: {
|
|
438
|
+
type: ArrowKeyNavigationType.MENU,
|
|
439
|
+
disableArrowKeyNavigation: true
|
|
440
|
+
},
|
|
424
441
|
items: items,
|
|
425
442
|
isOpen: isOpen,
|
|
426
443
|
onOpenChange: this.handleOpenChange,
|
|
@@ -34,7 +34,8 @@ const FloatingContextualMenu = ({
|
|
|
34
34
|
isOpen,
|
|
35
35
|
pluginConfig,
|
|
36
36
|
editorAnalyticsAPI,
|
|
37
|
-
getEditorContainerWidth
|
|
37
|
+
getEditorContainerWidth,
|
|
38
|
+
getEditorFeatureFlags
|
|
38
39
|
}) => {
|
|
39
40
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
40
41
|
const {
|
|
@@ -69,7 +70,8 @@ const FloatingContextualMenu = ({
|
|
|
69
70
|
,
|
|
70
71
|
zIndex: akEditorFloatingOverlapPanelZIndex,
|
|
71
72
|
forcePlacement: true,
|
|
72
|
-
offset: [-7, 0]
|
|
73
|
+
offset: [-7, 0],
|
|
74
|
+
stick: true
|
|
73
75
|
}, jsx("div", {
|
|
74
76
|
css: tablePopupStyles
|
|
75
77
|
}, jsx(ContextualMenu, {
|
|
@@ -83,7 +85,8 @@ const FloatingContextualMenu = ({
|
|
|
83
85
|
selectionRect: selectionRect,
|
|
84
86
|
boundariesElement: boundariesElement,
|
|
85
87
|
editorAnalyticsAPI: editorAnalyticsAPI,
|
|
86
|
-
getEditorContainerWidth: getEditorContainerWidth
|
|
88
|
+
getEditorContainerWidth: getEditorContainerWidth,
|
|
89
|
+
getEditorFeatureFlags: getEditorFeatureFlags
|
|
87
90
|
})));
|
|
88
91
|
};
|
|
89
92
|
FloatingContextualMenu.displayName = 'FloatingContextualMenu';
|
|
@@ -294,6 +294,13 @@ export const tableStyles = props => {
|
|
|
294
294
|
|
|
295
295
|
.${ClassName.ROW_CONTROLS_WRAPPER} {
|
|
296
296
|
padding: 0 ${tablePadding}px;
|
|
297
|
+
|
|
298
|
+
// https://product-fabric.atlassian.net/browse/ED-16386
|
|
299
|
+
// Fixes issue where the extra padding that is added here throws off the position
|
|
300
|
+
// of the rows control dot
|
|
301
|
+
&::after {
|
|
302
|
+
right: 6px !important;
|
|
303
|
+
}
|
|
297
304
|
}
|
|
298
305
|
|
|
299
306
|
&.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
@@ -615,10 +622,10 @@ export const tableStyles = props => {
|
|
|
615
622
|
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
616
623
|
padding-right: ${insertColumnButtonOffset}px;
|
|
617
624
|
margin-right: -${insertColumnButtonOffset}px;
|
|
618
|
-
padding-bottom:
|
|
619
|
-
margin-bottom: -${tableScrollbarOffset}px;
|
|
625
|
+
padding-bottom: 0px;
|
|
620
626
|
/* fixes gap cursor height */
|
|
621
627
|
overflow: auto;
|
|
628
|
+
overflow-y: hidden;
|
|
622
629
|
position: relative;
|
|
623
630
|
}
|
|
624
631
|
}
|
|
@@ -634,7 +641,7 @@ export const tableStyles = props => {
|
|
|
634
641
|
cursor: col-resize;
|
|
635
642
|
}
|
|
636
643
|
|
|
637
|
-
/*
|
|
644
|
+
/*
|
|
638
645
|
ED-15882: When custom start numbers is enabled for lists, we have
|
|
639
646
|
styles that handle this generally (in editor-common) so we can
|
|
640
647
|
throw away the older table-specific styles here.
|
|
@@ -49,5 +49,10 @@ export default defineMessages({
|
|
|
49
49
|
id: 'fabric.editor.extension.deleteElementTitle',
|
|
50
50
|
defaultMessage: 'Delete element',
|
|
51
51
|
description: 'Title text for confirm modal when deleting an extension linked to a data consumer.'
|
|
52
|
+
},
|
|
53
|
+
unnamedSource: {
|
|
54
|
+
id: 'fabric.editor.extension.sourceNoTitledName',
|
|
55
|
+
defaultMessage: 'this element',
|
|
56
|
+
description: 'The current element without preset name been selected'
|
|
52
57
|
}
|
|
53
58
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
-
import { tableCellBorderWidth,
|
|
2
|
+
import { tableCellBorderWidth, tableMarginTop, tableMarginTopWithControl } from '@atlaskit/editor-common/styles';
|
|
3
3
|
import { akEditorShadowZIndex, akEditorTableNumberColumnWidth, akEditorUnitZIndex } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { N40A, B300, N300, R300, N20A, N60A, N0, Y50, Y200 } from '@atlaskit/theme/colors';
|
|
5
5
|
import { tableToolbarColor, tableBorderColor, tableToolbarSelectedColor, tableBorderSelectedColor, tableCellDeleteColor, tableBorderDeleteColor, tableToolbarDeleteColor, lineMarkerSize, columnControlsDecorationHeight, columnControlsZIndex, columnControlsSelectedZIndex, resizeHandlerAreaWidth, resizeLineWidth, resizeHandlerZIndex, tableToolbarSize, tableInsertColumnButtonSize, tableDeleteButtonSize } from './consts';
|
|
@@ -181,7 +181,7 @@ export const DeleteButton = css`
|
|
|
181
181
|
export const OverflowShadow = props => css`
|
|
182
182
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
183
183
|
display: block;
|
|
184
|
-
height: calc(100% - ${tableMarginTop
|
|
184
|
+
height: calc(100% - ${tableMarginTop}px);
|
|
185
185
|
position: absolute;
|
|
186
186
|
pointer-events: none;
|
|
187
187
|
top: ${tableMarginTop}px;
|
|
@@ -217,10 +217,13 @@ export const OverflowShadow = props => css`
|
|
|
217
217
|
);
|
|
218
218
|
left: calc(100% + 2px);
|
|
219
219
|
}
|
|
220
|
+
.${ClassName.TABLE_COLUMN_CONTROLS_DECORATIONS} {
|
|
221
|
+
z-index: 0;
|
|
222
|
+
}
|
|
220
223
|
.${ClassName.WITH_CONTROLS} {
|
|
221
224
|
.${ClassName.TABLE_RIGHT_SHADOW}, .${ClassName.TABLE_LEFT_SHADOW} {
|
|
222
|
-
height: calc(100% - ${
|
|
223
|
-
top: ${
|
|
225
|
+
height: calc(100% - ${tableMarginTopWithControl}px);
|
|
226
|
+
top: ${tableMarginTopWithControl}px;
|
|
224
227
|
}
|
|
225
228
|
.${ClassName.TABLE_LEFT_SHADOW} {
|
|
226
229
|
border-left: 1px solid ${tableBorderColor(props)};
|
|
@@ -255,6 +258,7 @@ export const columnControlsDecoration = props => css`
|
|
|
255
258
|
left: -1px;
|
|
256
259
|
top: -${columnControlsDecorationHeight + tableCellBorderWidth}px;
|
|
257
260
|
height: ${columnControlsDecorationHeight}px;
|
|
261
|
+
z-index: 0;
|
|
258
262
|
|
|
259
263
|
&::before {
|
|
260
264
|
content: ' ';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/es2019/version.json
CHANGED
|
@@ -266,7 +266,8 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
266
266
|
isOpen: Boolean(isContextualMenuOpen),
|
|
267
267
|
pluginConfig: pluginConfig,
|
|
268
268
|
editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
|
|
269
|
-
getEditorContainerWidth: defaultGetEditorContainerWidth
|
|
269
|
+
getEditorContainerWidth: defaultGetEditorContainerWidth,
|
|
270
|
+
getEditorFeatureFlags: (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags
|
|
270
271
|
}), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
|
|
271
272
|
editorView: editorView,
|
|
272
273
|
selection: editorView.state.selection,
|
|
@@ -31,7 +31,6 @@ import { containsHeaderRow, tablesHaveDifferentColumnWidths, tablesHaveDifferent
|
|
|
31
31
|
import { updateOverflowShadows } from './update-overflow-shadows';
|
|
32
32
|
import memoizeOne from 'memoize-one';
|
|
33
33
|
import { OverflowShadowsObserver } from './OverflowShadowsObserver';
|
|
34
|
-
import { getParentWidthWithoutPadding } from '../pm-plugins/table-resizing/utils/misc';
|
|
35
34
|
var isIE11 = browser.ie_version === 11;
|
|
36
35
|
var NOOP = function NOOP() {
|
|
37
36
|
return undefined;
|
|
@@ -246,7 +245,7 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
246
245
|
return;
|
|
247
246
|
}
|
|
248
247
|
var parentNodeWith = getParentNodeWidth(pos, state, containerWidth, options && options.isFullWidthModeEnabled);
|
|
249
|
-
return
|
|
248
|
+
return parentNodeWith;
|
|
250
249
|
});
|
|
251
250
|
_defineProperty(_assertThisInitialized(_this), "updateParentWidth", function (width) {
|
|
252
251
|
_this.setState({
|
|
@@ -181,7 +181,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
181
181
|
syncStickyRowToTable(tree.table);
|
|
182
182
|
}, 0);
|
|
183
183
|
});
|
|
184
|
-
_defineProperty(this, "
|
|
184
|
+
_defineProperty(this, "updateStickyHeaderWidth", function () {
|
|
185
185
|
// table width might have changed, sync that back to sticky row
|
|
186
186
|
var tree = _this.tree;
|
|
187
187
|
if (!tree) {
|
|
@@ -213,7 +213,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
213
213
|
// otherwise make it non-sticky
|
|
214
214
|
return false;
|
|
215
215
|
});
|
|
216
|
-
_defineProperty(this, "makeHeaderRowSticky", function (tree) {
|
|
216
|
+
_defineProperty(this, "makeHeaderRowSticky", function (tree, scrollTop) {
|
|
217
217
|
var _tbody$firstChild;
|
|
218
218
|
// If header row height is more than 50% of viewport height don't do this
|
|
219
219
|
if (_this.stickyRowHeight && _this.stickyRowHeight > window.innerHeight / 2) {
|
|
@@ -228,7 +228,10 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
230
|
var currentTableTop = _this.getCurrentTableTop(tree);
|
|
231
|
-
|
|
231
|
+
if (!scrollTop) {
|
|
232
|
+
scrollTop = getTop(_this.editorScrollableElement);
|
|
233
|
+
}
|
|
234
|
+
var domTop = currentTableTop > 0 ? scrollTop : scrollTop + currentTableTop;
|
|
232
235
|
if (!_this.isSticky) {
|
|
233
236
|
syncStickyRowToTable(table);
|
|
234
237
|
_this.dom.classList.add('sticky');
|
|
@@ -335,7 +338,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
335
338
|
}
|
|
336
339
|
this.topPosEditorElement = getTop(this.editorScrollableElement);
|
|
337
340
|
}
|
|
338
|
-
this.eventDispatcher.on('widthPlugin', this.
|
|
341
|
+
this.eventDispatcher.on('widthPlugin', this.updateStickyHeaderWidth);
|
|
339
342
|
this.eventDispatcher.on(tablePluginKey.key, this.onTablePluginState);
|
|
340
343
|
this.listening = true;
|
|
341
344
|
this.dom.addEventListener('wheel', this.headerRowMouseScroll.bind(this));
|
|
@@ -349,6 +352,13 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
349
352
|
}
|
|
350
353
|
if (this.intersectionObserver) {
|
|
351
354
|
this.intersectionObserver.disconnect();
|
|
355
|
+
// ED-16211 Once intersection observer is disconnected, we need to remove the isObserved from the sentinels
|
|
356
|
+
// Otherwise when new intersection observer is created it will not observe because it thinks its already being observed
|
|
357
|
+
[this.sentinels.top, this.sentinels.bottom].forEach(function (el) {
|
|
358
|
+
if (el) {
|
|
359
|
+
delete el.dataset.isObserved;
|
|
360
|
+
}
|
|
361
|
+
});
|
|
352
362
|
}
|
|
353
363
|
if (this.resizeObserver) {
|
|
354
364
|
this.resizeObserver.disconnect();
|
|
@@ -356,7 +366,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
356
366
|
if (this.editorScrollableElement && !this.stickyHeadersOptimization) {
|
|
357
367
|
this.editorScrollableElement.removeEventListener('scroll', this.onScroll);
|
|
358
368
|
}
|
|
359
|
-
this.eventDispatcher.off('widthPlugin', this.
|
|
369
|
+
this.eventDispatcher.off('widthPlugin', this.updateStickyHeaderWidth);
|
|
360
370
|
this.eventDispatcher.off(tablePluginKey.key, this.onTablePluginState);
|
|
361
371
|
this.listening = false;
|
|
362
372
|
this.dom.removeEventListener('wheel', this.headerRowMouseScroll);
|
|
@@ -378,6 +388,9 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
378
388
|
return;
|
|
379
389
|
}
|
|
380
390
|
this.resizeObserver.observe(this.dom);
|
|
391
|
+
if (this.editorScrollableElement) {
|
|
392
|
+
this.resizeObserver.observe(this.editorScrollableElement);
|
|
393
|
+
}
|
|
381
394
|
window.requestAnimationFrame(function () {
|
|
382
395
|
var _this2$tree;
|
|
383
396
|
// we expect tree to be defined after animation frame
|
|
@@ -408,14 +421,21 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
408
421
|
}
|
|
409
422
|
var table = _this3.tree.table;
|
|
410
423
|
entries.forEach(function (entry) {
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
//
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
424
|
+
var _this3$editorScrollab;
|
|
425
|
+
// On resize of the parent scroll element we need to adjust the width
|
|
426
|
+
// of the sticky header
|
|
427
|
+
if (entry.target.className === ((_this3$editorScrollab = _this3.editorScrollableElement) === null || _this3$editorScrollab === void 0 ? void 0 : _this3$editorScrollab.className)) {
|
|
428
|
+
_this3.updateStickyHeaderWidth();
|
|
429
|
+
} else {
|
|
430
|
+
var newHeight = entry.contentRect ? entry.contentRect.height : entry.target.offsetHeight;
|
|
431
|
+
if (_this3.sentinels.bottom &&
|
|
432
|
+
// When the table header is sticky, it would be taller by a 1px (border-bottom),
|
|
433
|
+
// So we adding this check to allow a 1px difference.
|
|
434
|
+
Math.abs(newHeight - (_this3.stickyRowHeight || 0)) > stickyHeaderBorderBottomWidth) {
|
|
435
|
+
_this3.stickyRowHeight = newHeight;
|
|
436
|
+
_this3.sentinels.bottom.style.bottom = "".concat(tableScrollbarOffset + stickyRowOffsetTop + newHeight, "px");
|
|
437
|
+
updateTableMargin(table);
|
|
438
|
+
}
|
|
419
439
|
}
|
|
420
440
|
});
|
|
421
441
|
});
|
|
@@ -441,18 +461,20 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
441
461
|
var _entry$rootBounds2;
|
|
442
462
|
var sentinelIsBelowScrollArea = (((_entry$rootBounds2 = entry.rootBounds) === null || _entry$rootBounds2 === void 0 ? void 0 : _entry$rootBounds2.bottom) || 0) < entry.boundingClientRect.bottom;
|
|
443
463
|
if (!entry.isIntersecting && !sentinelIsBelowScrollArea) {
|
|
444
|
-
|
|
464
|
+
var _entry$rootBounds3;
|
|
465
|
+
_this4.tree && _this4.makeHeaderRowSticky(_this4.tree, (_entry$rootBounds3 = entry.rootBounds) === null || _entry$rootBounds3 === void 0 ? void 0 : _entry$rootBounds3.top);
|
|
445
466
|
} else {
|
|
446
467
|
table && _this4.makeRowHeaderNotSticky(table);
|
|
447
468
|
}
|
|
448
469
|
}
|
|
449
470
|
if (target.classList.contains(ClassName.TABLE_STICKY_SENTINEL_BOTTOM)) {
|
|
450
|
-
var _entry$
|
|
451
|
-
var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$
|
|
471
|
+
var _entry$rootBounds4;
|
|
472
|
+
var sentinelIsAboveScrollArea = entry.boundingClientRect.top - _this4.dom.offsetHeight < (((_entry$rootBounds4 = entry.rootBounds) === null || _entry$rootBounds4 === void 0 ? void 0 : _entry$rootBounds4.top) || 0);
|
|
452
473
|
if (table && !entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
453
474
|
_this4.makeRowHeaderNotSticky(table);
|
|
454
475
|
} else if (entry.isIntersecting && sentinelIsAboveScrollArea) {
|
|
455
|
-
|
|
476
|
+
var _entry$rootBounds5;
|
|
477
|
+
_this4.tree && _this4.makeHeaderRowSticky(_this4.tree, entry === null || entry === void 0 ? void 0 : (_entry$rootBounds5 = entry.rootBounds) === null || _entry$rootBounds5 === void 0 ? void 0 : _entry$rootBounds5.top);
|
|
456
478
|
}
|
|
457
479
|
}
|
|
458
480
|
});
|
|
@@ -9,7 +9,6 @@ import { evenColumns, setDragging, stopResizing } from './commands';
|
|
|
9
9
|
import { getPluginState } from './plugin-factory';
|
|
10
10
|
import { currentColWidth, getLayoutSize, getResizeState, pointsAtCell, resizeColumn, updateControls } from './utils';
|
|
11
11
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
12
|
-
import { getParentWidthWithoutPadding } from './utils/misc';
|
|
13
12
|
export var handleMouseDown = function handleMouseDown(view, event, localResizeHandlePos, getEditorContainerWidth, getEditorFeatureFlags, editorAnalyticsAPI) {
|
|
14
13
|
var state = view.state,
|
|
15
14
|
dispatch = view.dispatch;
|
|
@@ -30,10 +29,7 @@ export var handleMouseDown = function handleMouseDown(view, event, localResizeHa
|
|
|
30
29
|
}
|
|
31
30
|
var containerWidth = getEditorContainerWidth();
|
|
32
31
|
var parentWidth = getParentNodeWidth(start, state, containerWidth);
|
|
33
|
-
|
|
34
|
-
// TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
|
|
35
|
-
var parentActualWidth = getParentWidthWithoutPadding(parentWidth, start, state);
|
|
36
|
-
var maxSize = parentActualWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
32
|
+
var maxSize = parentWidth || getLayoutSize(dom.getAttribute('data-layout'), containerWidth.width, {});
|
|
37
33
|
if (originalTable.attrs.isNumberColumnEnabled) {
|
|
38
34
|
maxSize -= akEditorTableNumberColumnWidth;
|
|
39
35
|
}
|
|
@@ -3,8 +3,6 @@ import { getBreakpoint, mapBreakpointToLayoutMaxWidth } from '@atlaskit/editor-c
|
|
|
3
3
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding, akEditorWideLayoutWidth, akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
4
4
|
import { containsClassName } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { getParentNodeWidth } from '@atlaskit/editor-common/node-width';
|
|
6
|
-
import { gridSize } from '@atlaskit/theme/constants';
|
|
7
|
-
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
8
6
|
export var tableLayoutToSize = {
|
|
9
7
|
default: akEditorDefaultLayoutWidth,
|
|
10
8
|
wide: akEditorWideLayoutWidth,
|
|
@@ -71,41 +69,9 @@ export var getTableMaxWidth = function getTableMaxWidth(_ref2) {
|
|
|
71
69
|
getEditorContainerWidth = _ref2.getEditorContainerWidth;
|
|
72
70
|
var containerWidth = getEditorContainerWidth();
|
|
73
71
|
var parentWidth = getParentNodeWidth(tableStart, state, containerWidth);
|
|
74
|
-
|
|
75
|
-
// TODO - refactor this logic into getParentNodeWidth() in editor-common [ED-16718]
|
|
76
|
-
var parentActualWidth = getParentWidthWithoutPadding(parentWidth, tableStart, state);
|
|
77
|
-
var maxWidth = parentActualWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
72
|
+
var maxWidth = parentWidth || getLayoutSize(layout, containerWidth.width, {});
|
|
78
73
|
if (table.attrs.isNumberColumnEnabled) {
|
|
79
74
|
maxWidth -= akEditorTableNumberColumnWidth;
|
|
80
75
|
}
|
|
81
76
|
return maxWidth;
|
|
82
|
-
};
|
|
83
|
-
export var getParentWidthWithoutPadding = function getParentWidthWithoutPadding(parentWidth, tableStartPos, state) {
|
|
84
|
-
var node = getNestedParentNode(tableStartPos, state);
|
|
85
|
-
if (!node) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
var schema = state.schema;
|
|
89
|
-
if (node.type === schema.nodes.expand) {
|
|
90
|
-
// padding
|
|
91
|
-
parentWidth -= gridSize() * 2;
|
|
92
|
-
// gutter offset
|
|
93
|
-
parentWidth += gridSize() * 1.5 * 2;
|
|
94
|
-
// padding right
|
|
95
|
-
parentWidth -= gridSize();
|
|
96
|
-
// padding left
|
|
97
|
-
parentWidth -= gridSize() * 4 - gridSize() / 2;
|
|
98
|
-
}
|
|
99
|
-
return parentWidth;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// copy of getNestedParentNode() from packages/editor/editor-common/src/node-width/index.ts
|
|
103
|
-
// to be removed later when we will move getParentWidthWithoutPadding() logic to editor-common
|
|
104
|
-
var getNestedParentNode = function getNestedParentNode(tablePos, state) {
|
|
105
|
-
if (tablePos === undefined) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
var $pos = state.doc.resolve(tablePos);
|
|
109
|
-
var parent = findParentNodeOfTypeClosestToPos($pos, [state.schema.nodes.bodiedExtension, state.schema.nodes.layoutSection, state.schema.nodes.expand]);
|
|
110
|
-
return parent ? parent.node : null;
|
|
111
77
|
};
|