@atlaskit/editor-plugin-table 7.5.2 → 7.5.4
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 +13 -0
- package/dist/cjs/commands-with-analytics.js +65 -38
- package/dist/cjs/nodeviews/ExternalDropTargets.js +2 -2
- package/dist/cjs/nodeviews/TableCell.js +1 -1
- package/dist/cjs/nodeviews/TableComponent.js +1 -1
- package/dist/cjs/nodeviews/TableContainer.js +3 -3
- package/dist/cjs/nodeviews/TableResizer.js +10 -10
- package/dist/cjs/nodeviews/TableRow.js +1 -1
- package/dist/cjs/nodeviews/table.js +1 -1
- package/dist/cjs/pm-plugins/keymap.js +2 -2
- package/dist/cjs/pm-plugins/table-analytics.js +2 -2
- package/dist/cjs/pm-plugins/table-local-id.js +11 -11
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +16 -1
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +0 -1
- package/dist/cjs/reducer.js +0 -2
- package/dist/cjs/toolbar.js +2 -2
- package/dist/cjs/ui/ColumnResizeWidget/index.js +4 -5
- package/dist/cjs/ui/DragHandle/index.js +2 -2
- package/dist/cjs/ui/FloatingContextualButton/FixedButton.js +2 -2
- package/dist/cjs/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/ui/FloatingDeleteButton/index.js +3 -3
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +2 -2
- package/dist/cjs/ui/FloatingDragMenu/DropdownMenu.js +2 -2
- package/dist/cjs/ui/FloatingInsertButton/index.js +3 -3
- package/dist/cjs/ui/LayoutButton/index.js +3 -3
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnDropTargets/index.js +2 -2
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/CornerControls/DragCornerControls.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/NumberColumn/index.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/RowControls/ClassicControls.js +3 -3
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/RowDropTarget/index.js +2 -2
- package/dist/cjs/ui/TableFloatingControls/index.js +3 -3
- package/dist/cjs/utils/decoration.js +0 -4
- package/dist/cjs/utils/guidelines.js +5 -2
- package/dist/cjs/utils/merged-cells.js +0 -1
- package/dist/cjs/utils/snapping.js +14 -1
- package/dist/es2019/commands-with-analytics.js +27 -0
- package/dist/es2019/nodeviews/TableContainer.js +2 -2
- package/dist/es2019/nodeviews/TableResizer.js +10 -10
- package/dist/es2019/pm-plugins/keymap.js +4 -4
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +17 -2
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +0 -1
- package/dist/es2019/reducer.js +0 -2
- package/dist/es2019/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/es2019/utils/decoration.js +0 -4
- package/dist/es2019/utils/guidelines.js +3 -2
- package/dist/es2019/utils/merged-cells.js +0 -1
- package/dist/es2019/utils/snapping.js +12 -1
- package/dist/esm/commands-with-analytics.js +64 -37
- package/dist/esm/nodeviews/TableCell.js +1 -1
- package/dist/esm/nodeviews/TableComponent.js +1 -1
- package/dist/esm/nodeviews/TableContainer.js +2 -2
- package/dist/esm/nodeviews/TableResizer.js +10 -10
- package/dist/esm/nodeviews/TableRow.js +1 -1
- package/dist/esm/nodeviews/table.js +1 -1
- package/dist/esm/pm-plugins/keymap.js +4 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +17 -2
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +0 -1
- package/dist/esm/reducer.js +0 -2
- package/dist/esm/ui/ColumnResizeWidget/index.js +0 -1
- package/dist/esm/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/ui/FloatingDeleteButton/index.js +1 -1
- package/dist/esm/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/ui/LayoutButton/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/CornerControls/ClassicCornerControls.js +1 -1
- package/dist/esm/ui/TableFloatingControls/NumberColumn/index.js +1 -1
- package/dist/esm/ui/TableFloatingControls/RowControls/ClassicControls.js +1 -1
- package/dist/esm/ui/TableFloatingControls/index.js +1 -1
- package/dist/esm/utils/decoration.js +0 -4
- package/dist/esm/utils/guidelines.js +5 -2
- package/dist/esm/utils/merged-cells.js +0 -1
- package/dist/esm/utils/snapping.js +14 -1
- package/dist/types/commands-with-analytics.d.ts +1 -0
- package/dist/types/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types/utils/drag-menu.d.ts +1 -1
- package/dist/types/utils/guidelines.d.ts +1 -0
- package/dist/types/utils/snapping.d.ts +2 -0
- package/dist/types-ts4.5/commands-with-analytics.d.ts +1 -0
- package/dist/types-ts4.5/ui/ColumnResizeWidget/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnDropTargets/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/drag-menu.d.ts +1 -1
- package/dist/types-ts4.5/utils/guidelines.d.ts +1 -0
- package/dist/types-ts4.5/utils/snapping.d.ts +2 -0
- package/package.json +1 -1
- package/src/commands-with-analytics.ts +39 -0
- package/src/nodeviews/TableContainer.tsx +10 -1
- package/src/nodeviews/TableResizer.tsx +39 -19
- package/src/pm-plugins/keymap.ts +13 -3
- package/src/pm-plugins/table-resizing/event-handlers.ts +20 -1
- package/src/ui/ColumnResizeWidget/index.tsx +2 -4
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/ColumnDropTarget.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/ColumnDropTargets/index.tsx +2 -2
- package/src/ui/TableFloatingColumnControls/index.tsx +2 -2
- package/src/utils/drag-menu.ts +1 -1
- package/src/utils/guidelines.ts +12 -1
- package/src/utils/snapping.ts +36 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
2
|
import { jsx } from '@emotion/react';
|
|
5
3
|
import { useIntl } from 'react-intl-next';
|
|
6
4
|
|
|
@@ -15,11 +13,11 @@ type Props = {
|
|
|
15
13
|
includeTooltip?: boolean;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
export const ColumnResizeWidget
|
|
16
|
+
export const ColumnResizeWidget = ({
|
|
19
17
|
startIndex,
|
|
20
18
|
endIndex,
|
|
21
19
|
includeTooltip,
|
|
22
|
-
}) => {
|
|
20
|
+
}: Props) => {
|
|
23
21
|
const { formatMessage } = useIntl();
|
|
24
22
|
|
|
25
23
|
if (!includeTooltip) {
|
|
@@ -13,13 +13,13 @@ export interface Props {
|
|
|
13
13
|
marginTop?: number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const ColumnDropTarget
|
|
16
|
+
export const ColumnDropTarget = ({
|
|
17
17
|
index,
|
|
18
18
|
localId,
|
|
19
19
|
width,
|
|
20
20
|
height,
|
|
21
21
|
marginTop,
|
|
22
|
-
}) => {
|
|
22
|
+
}: Props) => {
|
|
23
23
|
const dropTargetRef = useRef<HTMLDivElement | null>(null);
|
|
24
24
|
|
|
25
25
|
useEffect(() => {
|
|
@@ -13,14 +13,14 @@ export interface Props {
|
|
|
13
13
|
getScrollOffset?: () => number;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const ColumnDropTargets
|
|
16
|
+
export const ColumnDropTargets = ({
|
|
17
17
|
tableRef,
|
|
18
18
|
tableHeight,
|
|
19
19
|
localId,
|
|
20
20
|
colWidths,
|
|
21
21
|
isHeaderSticky,
|
|
22
22
|
getScrollOffset,
|
|
23
|
-
}) => {
|
|
23
|
+
}: Props) => {
|
|
24
24
|
const dropTargetRef = useRef<HTMLDivElement>(null);
|
|
25
25
|
|
|
26
26
|
if (!tableRef) {
|
|
@@ -40,7 +40,7 @@ export interface Props {
|
|
|
40
40
|
getScrollOffset?: () => number;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export const TableFloatingColumnControls
|
|
43
|
+
export const TableFloatingColumnControls = ({
|
|
44
44
|
editorView,
|
|
45
45
|
tableRef,
|
|
46
46
|
getNode,
|
|
@@ -55,7 +55,7 @@ export const TableFloatingColumnControls: React.FC<Props> = ({
|
|
|
55
55
|
tableContainerWidth,
|
|
56
56
|
isNumberColumnEnabled,
|
|
57
57
|
getScrollOffset,
|
|
58
|
-
}) => {
|
|
58
|
+
}: Props) => {
|
|
59
59
|
const [tableRect, setTableRect] = useState<{ width: number; height: number }>(
|
|
60
60
|
{ width: 0, height: 0 },
|
|
61
61
|
);
|
package/src/utils/drag-menu.ts
CHANGED
|
@@ -141,7 +141,7 @@ export type DragMenuOptionIdType =
|
|
|
141
141
|
|
|
142
142
|
export interface DragMenuConfig extends DropdownOptionT<Command> {
|
|
143
143
|
id: DragMenuOptionIdType;
|
|
144
|
-
icon?: React.ComponentType<IconProps
|
|
144
|
+
icon?: React.ComponentType<React.PropsWithChildren<IconProps>>;
|
|
145
145
|
keymap?: string;
|
|
146
146
|
}
|
|
147
147
|
|
package/src/utils/guidelines.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
|
|
2
2
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
calculateDefaultSnappings,
|
|
6
|
+
calculateDefaultTablePreserveSnappings,
|
|
7
|
+
} from './snapping';
|
|
5
8
|
|
|
6
9
|
// NOTE: We have to take 1 pixel off every length due to the fact that the tbody is 1px smaller then the table container.
|
|
7
10
|
// If we don't do this then the guidelines will not align correctly to the edge of the table
|
|
@@ -9,3 +12,11 @@ export const defaultGuidelines = createFixedGuidelinesFromLengths([
|
|
|
9
12
|
0,
|
|
10
13
|
...calculateDefaultSnappings(-1),
|
|
11
14
|
]) as GuidelineConfig[];
|
|
15
|
+
|
|
16
|
+
export const defaultGuidelinesForPreserveTable = (
|
|
17
|
+
editorContainerWidth: number,
|
|
18
|
+
) =>
|
|
19
|
+
createFixedGuidelinesFromLengths([
|
|
20
|
+
0,
|
|
21
|
+
...calculateDefaultTablePreserveSnappings(-1, editorContainerWidth),
|
|
22
|
+
]) as GuidelineConfig[];
|
package/src/utils/snapping.ts
CHANGED
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
akEditorCalculatedWideLayoutWidth,
|
|
5
5
|
akEditorDefaultLayoutWidth,
|
|
6
6
|
akEditorFullWidthLayoutWidth,
|
|
7
|
+
akEditorGutterPadding,
|
|
8
|
+
akEditorMediaResizeHandlerPaddingWide,
|
|
7
9
|
} from '@atlaskit/editor-shared-styles';
|
|
8
10
|
|
|
9
11
|
const numberOfLanesInDefaultLayoutWidth = 12;
|
|
@@ -23,8 +25,42 @@ export const calculateDefaultSnappings = (lengthOffset: number = 0) => [
|
|
|
23
25
|
akEditorFullWidthLayoutWidth + lengthOffset,
|
|
24
26
|
];
|
|
25
27
|
|
|
28
|
+
// FF TablePreserve for calculateDefaultSnappings
|
|
29
|
+
export const calculateDefaultTablePreserveSnappings = (
|
|
30
|
+
lengthOffset: number = 0,
|
|
31
|
+
editorContainerWith: number = akEditorFullWidthLayoutWidth,
|
|
32
|
+
) => {
|
|
33
|
+
const dynamicFullWidthLine =
|
|
34
|
+
editorContainerWith - akEditorGutterPadding * 2 >=
|
|
35
|
+
akEditorFullWidthLayoutWidth
|
|
36
|
+
? akEditorFullWidthLayoutWidth
|
|
37
|
+
: editorContainerWith -
|
|
38
|
+
akEditorGutterPadding * 2 -
|
|
39
|
+
akEditorMediaResizeHandlerPaddingWide;
|
|
40
|
+
|
|
41
|
+
return [
|
|
42
|
+
...calculateSubSnappingWidths(
|
|
43
|
+
numberOfLanesInDefaultLayoutWidth,
|
|
44
|
+
akEditorDefaultLayoutWidth + lengthOffset,
|
|
45
|
+
),
|
|
46
|
+
akEditorDefaultLayoutWidth + lengthOffset,
|
|
47
|
+
akEditorCalculatedWideLayoutWidth + lengthOffset,
|
|
48
|
+
dynamicFullWidthLine - lengthOffset,
|
|
49
|
+
];
|
|
50
|
+
};
|
|
51
|
+
|
|
26
52
|
export const defaultSnappingWidths = calculateDefaultSnappings();
|
|
27
53
|
|
|
54
|
+
// FF TablePreserve for defaultSnappingWidths
|
|
55
|
+
export const defaultTablePreserveSnappingWidths = (
|
|
56
|
+
editorContainerWidth: number,
|
|
57
|
+
) => {
|
|
58
|
+
return editorContainerWidth - akEditorGutterPadding * 2 >
|
|
59
|
+
akEditorFullWidthLayoutWidth
|
|
60
|
+
? calculateDefaultSnappings()
|
|
61
|
+
: calculateDefaultTablePreserveSnappings(0, editorContainerWidth);
|
|
62
|
+
};
|
|
63
|
+
|
|
28
64
|
/**
|
|
29
65
|
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
30
66
|
*/
|