@atlaskit/editor-plugin-table 7.6.13 → 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 +12 -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/FloatingDragMenu/DropdownMenu.js +35 -8
- 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/FloatingDragMenu/DropdownMenu.js +30 -5
- 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/FloatingDragMenu/DropdownMenu.js +35 -8
- 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 +6 -6
- 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/FloatingDragMenu/DropdownMenu.tsx +39 -7
- 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
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import { useIntl } from 'react-intl-next';
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
startColumnResizing,
|
|
7
|
+
ToolTipContent,
|
|
8
|
+
} from '@atlaskit/editor-common/keymaps';
|
|
5
9
|
import { tableMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
10
|
import Tooltip from '@atlaskit/tooltip';
|
|
7
11
|
|
|
@@ -32,7 +36,12 @@ export const ColumnResizeWidget = ({
|
|
|
32
36
|
|
|
33
37
|
return (
|
|
34
38
|
<Tooltip
|
|
35
|
-
content={
|
|
39
|
+
content={
|
|
40
|
+
<ToolTipContent
|
|
41
|
+
description={formatMessage(messages.adjustColumns)}
|
|
42
|
+
keymap={startColumnResizing}
|
|
43
|
+
/>
|
|
44
|
+
}
|
|
36
45
|
hideTooltipOnClick
|
|
37
46
|
hideTooltipOnMouseDown
|
|
38
47
|
position="mouse"
|
|
@@ -5,7 +5,6 @@ import { jsx } from '@emotion/react';
|
|
|
5
5
|
import type { WrappedComponentProps } from 'react-intl-next';
|
|
6
6
|
import { injectIntl } from 'react-intl-next';
|
|
7
7
|
|
|
8
|
-
import type { TableLayout } from '@atlaskit/adf-schema';
|
|
9
8
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
10
9
|
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
@@ -37,7 +36,6 @@ export interface Props {
|
|
|
37
36
|
mountPoint?: HTMLElement;
|
|
38
37
|
boundariesElement?: HTMLElement;
|
|
39
38
|
scrollableElement?: HTMLElement;
|
|
40
|
-
layout?: TableLayout;
|
|
41
39
|
isNumberColumnEnabled?: boolean;
|
|
42
40
|
stickyHeader?: RowStickyState;
|
|
43
41
|
dispatchAnalyticsEvent?: DispatchAnalyticsEvent;
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
|
|
12
12
|
import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
|
|
13
13
|
import { MenuGroup, Section } from '@atlaskit/menu';
|
|
14
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
15
|
|
|
15
16
|
import { dragMenuDropdownWidth } from '../consts';
|
|
16
17
|
|
|
@@ -63,6 +64,13 @@ export const DropdownMenu = ({
|
|
|
63
64
|
const handleRef = (ref: HTMLDivElement | null) => {
|
|
64
65
|
setTargetRefDiv(ref);
|
|
65
66
|
};
|
|
67
|
+
|
|
68
|
+
// more offsets calculation as offsets depend on the direction and updated placement here
|
|
69
|
+
let offsetY =
|
|
70
|
+
direction === 'row' ? (popupPlacement[0] === 'bottom' ? -8 : -34) : 0;
|
|
71
|
+
let offsetX =
|
|
72
|
+
direction === 'column' ? (popupPlacement[1] === 'left' ? 0 : -7) : 0;
|
|
73
|
+
|
|
66
74
|
const innerMenu = () => {
|
|
67
75
|
return (
|
|
68
76
|
<DropListWithOutsideListeners
|
|
@@ -109,15 +117,38 @@ export const DropdownMenu = ({
|
|
|
109
117
|
};
|
|
110
118
|
|
|
111
119
|
if (disableKeyboardHandling) {
|
|
112
|
-
|
|
120
|
+
if (
|
|
121
|
+
getBooleanFF(
|
|
122
|
+
'platform.editor.table.background-color-flicker-in-drag-menu',
|
|
123
|
+
)
|
|
124
|
+
) {
|
|
125
|
+
// This part need be refactor when clean up the ff, to reuse the wrapper
|
|
126
|
+
return (
|
|
127
|
+
<div className="drag-dropdown-menu-wrapper">
|
|
128
|
+
<div className="drag-dropdown-menu-popup-ref" ref={handleRef}></div>
|
|
129
|
+
<Popup
|
|
130
|
+
target={targetRefDiv as HTMLElement}
|
|
131
|
+
mountTo={mountPoint}
|
|
132
|
+
boundariesElement={boundariesElement}
|
|
133
|
+
scrollableElement={scrollableElement}
|
|
134
|
+
onPlacementChanged={(placement: [string, string]) => {
|
|
135
|
+
setPopupPlacement(placement);
|
|
136
|
+
}}
|
|
137
|
+
fitHeight={fitHeight}
|
|
138
|
+
fitWidth={fitWidth}
|
|
139
|
+
zIndex={akEditorFloatingPanelZIndex}
|
|
140
|
+
offset={[offsetX, offsetY]}
|
|
141
|
+
allowOutOfBounds // required as this popup is child of a parent popup, should be allowed to be out of bound of the parent popup, otherwise horizontal offset is not right
|
|
142
|
+
>
|
|
143
|
+
{innerMenu()}
|
|
144
|
+
</Popup>
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
} else {
|
|
148
|
+
return innerMenu();
|
|
149
|
+
}
|
|
113
150
|
}
|
|
114
151
|
|
|
115
|
-
// more offsets calculation as offsets depend on the direction and updated placement here
|
|
116
|
-
let offsetY =
|
|
117
|
-
direction === 'row' ? (popupPlacement[0] === 'bottom' ? -8 : -34) : 0;
|
|
118
|
-
let offsetX =
|
|
119
|
-
direction === 'column' ? (popupPlacement[1] === 'left' ? 0 : -7) : 0;
|
|
120
|
-
|
|
121
152
|
return (
|
|
122
153
|
<div className="drag-dropdown-menu-wrapper">
|
|
123
154
|
<div className="drag-dropdown-menu-popup-ref" ref={handleRef}></div>
|
|
@@ -138,6 +169,7 @@ export const DropdownMenu = ({
|
|
|
138
169
|
<ArrowKeyNavigationProvider
|
|
139
170
|
closeOnTab
|
|
140
171
|
type={ArrowKeyNavigationType.MENU}
|
|
172
|
+
handleClose={() => handleClose('handle')}
|
|
141
173
|
onSelection={(index) => {
|
|
142
174
|
const results = items.flatMap((item) =>
|
|
143
175
|
'items' in item ? item.items : item,
|
package/src/ui/common-styles.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from '@atlaskit/editor-shared-styles';
|
|
24
24
|
import { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
25
25
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
26
|
-
import {
|
|
26
|
+
import { N0, N40A, R500 } from '@atlaskit/theme/colors';
|
|
27
27
|
import { fontSize } from '@atlaskit/theme/constants';
|
|
28
28
|
import { token } from '@atlaskit/tokens';
|
|
29
29
|
|
|
@@ -259,36 +259,6 @@ const tableStickyHeaderFirefoxFixStyle = () => {
|
|
|
259
259
|
}
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
-
const tableWrapperStyles = () => {
|
|
263
|
-
if (getBooleanFF('platform.editor.custom-table-width')) {
|
|
264
|
-
return css`
|
|
265
|
-
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
266
|
-
padding-bottom: 0px;
|
|
267
|
-
/* fixes gap cursor height */
|
|
268
|
-
overflow: auto;
|
|
269
|
-
overflow-y: hidden;
|
|
270
|
-
position: relative;
|
|
271
|
-
|
|
272
|
-
> table[data-number-column='true'] {
|
|
273
|
-
width: calc(100% - 1px);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
`;
|
|
277
|
-
} else {
|
|
278
|
-
return css`
|
|
279
|
-
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
280
|
-
padding-right: ${insertColumnButtonOffset}px;
|
|
281
|
-
margin-right: -${insertColumnButtonOffset}px;
|
|
282
|
-
padding-bottom: 0px;
|
|
283
|
-
/* fixes gap cursor height */
|
|
284
|
-
overflow: auto;
|
|
285
|
-
overflow-y: hidden;
|
|
286
|
-
position: relative;
|
|
287
|
-
}
|
|
288
|
-
`;
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
262
|
// re-exporting these styles to use in Gemini test when table node view is rendered outside of PM
|
|
293
263
|
export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
294
264
|
${tableSharedStyle()};
|
|
@@ -608,9 +578,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
608
578
|
|
|
609
579
|
.${ClassName.TABLE_CONTAINER}[data-number-column='true'] {
|
|
610
580
|
.${ClassName.CORNER_CONTROLS}, .${ClassName.CONTROLS_CORNER_BUTTON} {
|
|
611
|
-
width: ${
|
|
612
|
-
? akEditorTableToolbarSize + akEditorTableNumberColumnWidth + 1
|
|
613
|
-
: akEditorTableToolbarSize + akEditorTableNumberColumnWidth}px;
|
|
581
|
+
width: ${akEditorTableToolbarSize + akEditorTableNumberColumnWidth + 1}px;
|
|
614
582
|
}
|
|
615
583
|
.${ClassName.ROW_CONTROLS} .${ClassName.CONTROLS_BUTTON} {
|
|
616
584
|
border-right-width: 0;
|
|
@@ -861,9 +829,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
861
829
|
.${ClassName.NUMBERED_COLUMN} {
|
|
862
830
|
position: relative;
|
|
863
831
|
float: right;
|
|
864
|
-
margin-left: ${
|
|
865
|
-
? akEditorTableToolbarSize
|
|
866
|
-
: akEditorTableToolbarSize - 1}px;
|
|
832
|
+
margin-left: ${akEditorTableToolbarSize}px;
|
|
867
833
|
top: ${props.featureFlags?.tableDragAndDrop
|
|
868
834
|
? 0
|
|
869
835
|
: akEditorTableToolbarSize}px;
|
|
@@ -914,9 +880,7 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
914
880
|
display: block;
|
|
915
881
|
}
|
|
916
882
|
.${ClassName.NUMBERED_COLUMN} {
|
|
917
|
-
padding-left:
|
|
918
|
-
? 0
|
|
919
|
-
: 1}px;
|
|
883
|
+
padding-left: 0px;
|
|
920
884
|
|
|
921
885
|
.${ClassName.NUMBERED_COLUMN_BUTTON} {
|
|
922
886
|
border-left: 0 none;
|
|
@@ -1082,23 +1046,21 @@ export const baseTableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
|
1082
1046
|
z-index: ${akEditorTableCellOnStickyHeaderZIndex - 4};
|
|
1083
1047
|
}
|
|
1084
1048
|
|
|
1085
|
-
|
|
1049
|
+
.${ClassName.TABLE_NODE_WRAPPER} {
|
|
1050
|
+
padding-bottom: 0px;
|
|
1051
|
+
/* fixes gap cursor height */
|
|
1052
|
+
overflow: auto;
|
|
1053
|
+
overflow-y: hidden;
|
|
1054
|
+
position: relative;
|
|
1055
|
+
|
|
1056
|
+
> table[data-number-column='true'] {
|
|
1057
|
+
width: calc(100% - 1px);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1086
1060
|
`;
|
|
1087
1061
|
|
|
1088
1062
|
// TODO: https://product-fabric.atlassian.net/browse/DSP-4139
|
|
1089
1063
|
export const tableStyles = (props: { featureFlags?: FeatureFlags }) => css`
|
|
1090
|
-
.${ClassName.LAYOUT_BUTTON} button {
|
|
1091
|
-
background: ${token('color.background.neutral', N20A)};
|
|
1092
|
-
color: ${token('color.icon', N300)};
|
|
1093
|
-
cursor: none;
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
.${ClassName.LAYOUT_BUTTON}:not(.${ClassName.IS_RESIZING}) button:hover {
|
|
1097
|
-
background: ${token('color.background.neutral.hovered', B300)};
|
|
1098
|
-
color: ${token('color.icon', 'white')} !important;
|
|
1099
|
-
cursor: pointer;
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
1064
|
.ProseMirror {
|
|
1103
1065
|
${baseTableStyles(props)}
|
|
1104
1066
|
}
|
package/src/ui/ui-styles.ts
CHANGED
|
@@ -374,9 +374,7 @@ export const OverflowShadow = (
|
|
|
374
374
|
${token('elevation.shadow.overflow.perimeter', 'transparent')} 0px,
|
|
375
375
|
transparent 1px
|
|
376
376
|
);
|
|
377
|
-
left: ${
|
|
378
|
-
? `calc(100% - ${tableOverflowShadowWidthWide}px)`
|
|
379
|
-
: `calc(100% - ${tableOverflowShadowWidthWide - 10}px)`};
|
|
377
|
+
left: calc(100% - ${tableOverflowShadowWidthWide}px);
|
|
380
378
|
}
|
|
381
379
|
.${ClassName.WITH_CONTROLS} {
|
|
382
380
|
${overflowShadowWidhoutDnD(isDragAndDropEnabled)}
|
|
@@ -439,26 +437,24 @@ const columnHeaderButtonSelected = () =>
|
|
|
439
437
|
});
|
|
440
438
|
|
|
441
439
|
const getFloatingDotOverrides = () => {
|
|
442
|
-
return
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
`
|
|
461
|
-
: '';
|
|
440
|
+
return css`
|
|
441
|
+
tr
|
|
442
|
+
th:last-child
|
|
443
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::before,
|
|
444
|
+
tr
|
|
445
|
+
td:last-child
|
|
446
|
+
.${ClassName.COLUMN_CONTROLS_DECORATIONS}::before {
|
|
447
|
+
content: '';
|
|
448
|
+
background-color: ${tableBorderColor};
|
|
449
|
+
position: absolute;
|
|
450
|
+
height: ${lineMarkerSize}px;
|
|
451
|
+
width: ${lineMarkerSize}px;
|
|
452
|
+
border-radius: 50%;
|
|
453
|
+
pointer-events: none;
|
|
454
|
+
top: ${token('space.025', '2px')};
|
|
455
|
+
right: 0px;
|
|
456
|
+
}
|
|
457
|
+
`;
|
|
462
458
|
};
|
|
463
459
|
|
|
464
460
|
export const floatingColumnControls = () => {
|
|
@@ -755,29 +751,6 @@ export const hoveredWarningCell = css`
|
|
|
755
751
|
}
|
|
756
752
|
`;
|
|
757
753
|
|
|
758
|
-
// move the resize handle zone completely inside the table cell to avoid overflow
|
|
759
|
-
const getLastColumnResizerOverrides = () => {
|
|
760
|
-
return getBooleanFF('platform.editor.custom-table-width')
|
|
761
|
-
? css`
|
|
762
|
-
tr
|
|
763
|
-
th:last-child
|
|
764
|
-
.${ClassName.RESIZE_HANDLE_DECORATION},
|
|
765
|
-
tr
|
|
766
|
-
td:last-child
|
|
767
|
-
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
768
|
-
background-color: transparent;
|
|
769
|
-
position: absolute;
|
|
770
|
-
width: ${resizeHandlerAreaWidth / 2}px;
|
|
771
|
-
height: 100%;
|
|
772
|
-
top: 0;
|
|
773
|
-
right: 0;
|
|
774
|
-
cursor: col-resize;
|
|
775
|
-
z-index: ${resizeHandlerZIndex};
|
|
776
|
-
}
|
|
777
|
-
`
|
|
778
|
-
: '';
|
|
779
|
-
};
|
|
780
|
-
|
|
781
754
|
// Explicit pixel values required here to ensure correct positioning and sizes of column resize handle
|
|
782
755
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
783
756
|
const resizeHandleOverrides = (isDragAndDropEnabled: boolean | undefined) => {
|
|
@@ -868,7 +841,21 @@ export const resizeHandle = (isDragAndDropEnabled: boolean | undefined) => css`
|
|
|
868
841
|
z-index: ${resizeHandlerZIndex};
|
|
869
842
|
}
|
|
870
843
|
|
|
871
|
-
|
|
844
|
+
tr
|
|
845
|
+
th:last-child
|
|
846
|
+
.${ClassName.RESIZE_HANDLE_DECORATION},
|
|
847
|
+
tr
|
|
848
|
+
td:last-child
|
|
849
|
+
.${ClassName.RESIZE_HANDLE_DECORATION} {
|
|
850
|
+
background-color: transparent;
|
|
851
|
+
position: absolute;
|
|
852
|
+
width: ${resizeHandlerAreaWidth / 2}px;
|
|
853
|
+
height: 100%;
|
|
854
|
+
top: 0;
|
|
855
|
+
right: 0;
|
|
856
|
+
cursor: col-resize;
|
|
857
|
+
z-index: ${resizeHandlerZIndex};
|
|
858
|
+
}
|
|
872
859
|
|
|
873
860
|
${resizeHandleOverrides(isDragAndDropEnabled)}
|
|
874
861
|
|
package/src/utils/index.ts
CHANGED
package/src/utils/nodes.ts
CHANGED
|
@@ -4,12 +4,9 @@ import type {
|
|
|
4
4
|
EditorState,
|
|
5
5
|
Selection,
|
|
6
6
|
} from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
8
7
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
9
8
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
9
|
|
|
11
|
-
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
12
|
-
|
|
13
10
|
export const isIsolating = (node: PmNode): boolean => {
|
|
14
11
|
return !!node.type.spec.isolating;
|
|
15
12
|
};
|
|
@@ -63,26 +60,6 @@ export const checkIfNumberColumnEnabled = (selection: Selection): boolean =>
|
|
|
63
60
|
false,
|
|
64
61
|
);
|
|
65
62
|
|
|
66
|
-
export const isLayoutSupported = (state: EditorState): boolean => {
|
|
67
|
-
const { permittedLayouts } = pluginKey.getState(state)?.pluginConfig || {};
|
|
68
|
-
const { bodiedExtension, layoutSection, expand, extensionFrame } =
|
|
69
|
-
state.schema.nodes;
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
!hasParentNodeOfType([
|
|
73
|
-
expand,
|
|
74
|
-
layoutSection,
|
|
75
|
-
bodiedExtension,
|
|
76
|
-
extensionFrame,
|
|
77
|
-
])(state.selection) &&
|
|
78
|
-
!!permittedLayouts &&
|
|
79
|
-
(permittedLayouts === 'all' ||
|
|
80
|
-
(permittedLayouts.indexOf('default') > -1 &&
|
|
81
|
-
permittedLayouts.indexOf('wide') > -1 &&
|
|
82
|
-
permittedLayouts.indexOf('full-width') > -1))
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
63
|
export const getTableWidth = (node: PmNode) => {
|
|
87
64
|
return getTableWidths(node).reduce((acc, current) => acc + current, 0);
|
|
88
65
|
};
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
18
|
-
var _reactIntlNext = require("react-intl-next");
|
|
19
|
-
var _messages = _interopRequireDefault(require("@atlaskit/editor-common/messages"));
|
|
20
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
21
|
-
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
22
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
23
|
-
var _collapse = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/collapse"));
|
|
24
|
-
var _expand = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/expand"));
|
|
25
|
-
var _commandsWithAnalytics = require("../../commands-with-analytics");
|
|
26
|
-
var _types = require("../../types");
|
|
27
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
28
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
29
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
30
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
31
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
32
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
|
-
var addPopupOffset = function addPopupOffset(pos) {
|
|
34
|
-
return _objectSpread(_objectSpread({}, pos), {}, {
|
|
35
|
-
// add 12 pixels to align y position with
|
|
36
|
-
//the columns controls
|
|
37
|
-
top: pos.top ? pos.top + 12 : undefined
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
var getMessage = function getMessage(layout) {
|
|
41
|
-
switch (layout) {
|
|
42
|
-
case 'default':
|
|
43
|
-
return _messages.default.layoutWide;
|
|
44
|
-
case 'wide':
|
|
45
|
-
return _messages.default.layoutFullWidth;
|
|
46
|
-
default:
|
|
47
|
-
return _messages.default.layoutFixedWidth;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
var LayoutButton = /*#__PURE__*/function (_React$Component) {
|
|
51
|
-
(0, _inherits2.default)(LayoutButton, _React$Component);
|
|
52
|
-
var _super = _createSuper(LayoutButton);
|
|
53
|
-
function LayoutButton() {
|
|
54
|
-
var _this;
|
|
55
|
-
(0, _classCallCheck2.default)(this, LayoutButton);
|
|
56
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
|
-
args[_key] = arguments[_key];
|
|
58
|
-
}
|
|
59
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
60
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "stickyButtonRef", /*#__PURE__*/(0, _react.createRef)());
|
|
61
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resizeObserver", new ResizeObserver(function (entries) {
|
|
62
|
-
entries.forEach(function () {
|
|
63
|
-
var resizeButton = _this.stickyButtonRef.current;
|
|
64
|
-
var tableWrapper = _this.props.targetRef;
|
|
65
|
-
if (resizeButton && tableWrapper) {
|
|
66
|
-
var clientRect = tableWrapper.getBoundingClientRect();
|
|
67
|
-
resizeButton.style.left = "".concat(clientRect.right, "px");
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}));
|
|
71
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function () {
|
|
72
|
-
var _this$props$editorVie = _this.props.editorView,
|
|
73
|
-
state = _this$props$editorVie.state,
|
|
74
|
-
dispatch = _this$props$editorVie.dispatch;
|
|
75
|
-
(0, _commandsWithAnalytics.toggleTableLayoutWithAnalytics)(_this.props.editorAnalyticsAPI)(state, dispatch);
|
|
76
|
-
});
|
|
77
|
-
return _this;
|
|
78
|
-
}
|
|
79
|
-
(0, _createClass2.default)(LayoutButton, [{
|
|
80
|
-
key: "getTitle",
|
|
81
|
-
value: function getTitle() {
|
|
82
|
-
var _this$props = this.props,
|
|
83
|
-
formatMessage = _this$props.intl.formatMessage,
|
|
84
|
-
_this$props$layout = _this$props.layout,
|
|
85
|
-
layout = _this$props$layout === void 0 ? 'default' : _this$props$layout;
|
|
86
|
-
return formatMessage(getMessage(layout));
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "toolbarButton",
|
|
90
|
-
value: function toolbarButton() {
|
|
91
|
-
var _this$props2 = this.props,
|
|
92
|
-
isResizing = _this$props2.isResizing,
|
|
93
|
-
_this$props2$layout = _this$props2.layout,
|
|
94
|
-
layout = _this$props2$layout === void 0 ? 'default' : _this$props2$layout;
|
|
95
|
-
var title = this.getTitle();
|
|
96
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
97
|
-
className: (0, _classnames2.default)(_types.TableCssClassName.LAYOUT_BUTTON, (0, _defineProperty2.default)({}, _types.TableCssClassName.IS_RESIZING, isResizing))
|
|
98
|
-
}, /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarButton, {
|
|
99
|
-
title: title,
|
|
100
|
-
onClick: this.handleClick,
|
|
101
|
-
iconBefore: layout === 'full-width' ? /*#__PURE__*/_react.default.createElement(_collapse.default, {
|
|
102
|
-
label: title
|
|
103
|
-
}) : /*#__PURE__*/_react.default.createElement(_expand.default, {
|
|
104
|
-
label: title
|
|
105
|
-
})
|
|
106
|
-
}));
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
key: "getStickyTargetRef",
|
|
110
|
-
value: function getStickyTargetRef(pos) {
|
|
111
|
-
var editorView = this.props.editorView;
|
|
112
|
-
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
113
|
-
var node = (0, _utils.findDomRefAtPos)(pos, domAtPos);
|
|
114
|
-
return node.dataset['headerRow'] && node.classList.contains('sticky') ? node : null;
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: "renderSticky",
|
|
118
|
-
value: function renderSticky(button, targetRef, tableRef) {
|
|
119
|
-
var title = this.getTitle();
|
|
120
|
-
if (!(targetRef instanceof HTMLElement) || !(tableRef instanceof HTMLElement)) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
var pos = targetRef.getBoundingClientRect();
|
|
124
|
-
var tablePos = tableRef.getBoundingClientRect();
|
|
125
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
126
|
-
ref: this.stickyButtonRef,
|
|
127
|
-
"aria-label": title,
|
|
128
|
-
style: {
|
|
129
|
-
position: 'fixed',
|
|
130
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
131
|
-
top: pos.top + 22,
|
|
132
|
-
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage/preview
|
|
133
|
-
left: tablePos.right
|
|
134
|
-
}
|
|
135
|
-
}, button);
|
|
136
|
-
}
|
|
137
|
-
}, {
|
|
138
|
-
key: "renderPopup",
|
|
139
|
-
value: function renderPopup(button) {
|
|
140
|
-
var _this$props3 = this.props,
|
|
141
|
-
mountPoint = _this$props3.mountPoint,
|
|
142
|
-
boundariesElement = _this$props3.boundariesElement,
|
|
143
|
-
scrollableElement = _this$props3.scrollableElement,
|
|
144
|
-
targetRef = _this$props3.targetRef;
|
|
145
|
-
if (!targetRef) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
var title = this.getTitle();
|
|
149
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
150
|
-
ariaLabel: title,
|
|
151
|
-
target: targetRef,
|
|
152
|
-
alignY: "start",
|
|
153
|
-
alignX: "end",
|
|
154
|
-
onPositionCalculated: addPopupOffset,
|
|
155
|
-
stick: true,
|
|
156
|
-
mountTo: mountPoint,
|
|
157
|
-
boundariesElement: boundariesElement,
|
|
158
|
-
scrollableElement: scrollableElement,
|
|
159
|
-
forcePlacement: true
|
|
160
|
-
}, button);
|
|
161
|
-
}
|
|
162
|
-
}, {
|
|
163
|
-
key: "render",
|
|
164
|
-
value: function render() {
|
|
165
|
-
var stickyHeader = this.props.stickyHeader;
|
|
166
|
-
var button = this.toolbarButton();
|
|
167
|
-
var stickyTargetRef = stickyHeader && stickyHeader.sticky && stickyHeader.pos ? this.getStickyTargetRef(stickyHeader.pos) : null;
|
|
168
|
-
if (stickyTargetRef && this.props.targetRef) {
|
|
169
|
-
return this.renderSticky(button, stickyTargetRef, this.props.targetRef);
|
|
170
|
-
} else {
|
|
171
|
-
return this.renderPopup(button);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "componentDidMount",
|
|
176
|
-
value: function componentDidMount() {
|
|
177
|
-
var dom = this.props.editorView.dom;
|
|
178
|
-
var scrollPanel = dom.closest('.fabric-editor-popup-scroll-parent');
|
|
179
|
-
if (scrollPanel instanceof HTMLElement) {
|
|
180
|
-
this.resizeObserver.observe(scrollPanel);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}, {
|
|
184
|
-
key: "componentWillUnmount",
|
|
185
|
-
value: function componentWillUnmount() {
|
|
186
|
-
var dom = this.props.editorView.dom;
|
|
187
|
-
var scrollPanel = dom.closest('.fabric-editor-popup-scroll-parent');
|
|
188
|
-
if (scrollPanel instanceof HTMLElement) {
|
|
189
|
-
this.resizeObserver.unobserve(scrollPanel);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "shouldComponentUpdate",
|
|
194
|
-
value: function shouldComponentUpdate(nextProps) {
|
|
195
|
-
var _this$props4 = this.props,
|
|
196
|
-
targetRef = _this$props4.targetRef,
|
|
197
|
-
layout = _this$props4.layout,
|
|
198
|
-
isResizing = _this$props4.isResizing,
|
|
199
|
-
stickyHeader = _this$props4.stickyHeader;
|
|
200
|
-
return stickyHeader !== nextProps.stickyHeader || targetRef !== nextProps.targetRef || layout !== nextProps.layout || isResizing !== nextProps.isResizing;
|
|
201
|
-
}
|
|
202
|
-
}]);
|
|
203
|
-
return LayoutButton;
|
|
204
|
-
}(_react.default.Component);
|
|
205
|
-
(0, _defineProperty2.default)(LayoutButton, "displayName", 'LayoutButton');
|
|
206
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(LayoutButton);
|