@atlaskit/editor-plugin-table 2.8.1 → 2.8.3
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/.eslintrc.js +0 -1
- package/CHANGELOG.md +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +22 -21
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +20 -19
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +22 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +5 -5
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +0 -2
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +0 -2
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +5 -5
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/package.json +5 -5
- package/src/plugins/table/nodeviews/TableResizer.tsx +56 -59
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`77b74847baa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/77b74847baa) - ED-19152 Cancels scheduled resize to avoid handleResize being called after handleResizeStop.
|
|
8
|
+
|
|
9
|
+
## 2.8.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 2.8.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -96,6 +96,26 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
96
96
|
}));
|
|
97
97
|
setSnappingEnabled(displayGuideline(_guidelines.defaultGuidelines));
|
|
98
98
|
}, [displayGuideline, editorView, startMeasure]);
|
|
99
|
+
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
100
|
+
countFrames();
|
|
101
|
+
var newWidth = originalState.width + delta.width;
|
|
102
|
+
var pos = getPos();
|
|
103
|
+
if (typeof pos !== 'number') {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
(0, _utils2.previewScaleTable)(tableRef, {
|
|
107
|
+
node: node,
|
|
108
|
+
prevNode: node,
|
|
109
|
+
start: pos + 1,
|
|
110
|
+
parentWidth: newWidth
|
|
111
|
+
}, editorView.domAtPos.bind(editorView));
|
|
112
|
+
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, _guidelines.defaultGuidelineWidths, _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP));
|
|
113
|
+
updateWidth(newWidth);
|
|
114
|
+
return newWidth;
|
|
115
|
+
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
116
|
+
var scheduleResize = (0, _react.useMemo)(function () {
|
|
117
|
+
return (0, _rafSchd.default)(handleResize);
|
|
118
|
+
}, [handleResize]);
|
|
99
119
|
var handleResizeStop = (0, _react.useCallback)(function (originalState, delta) {
|
|
100
120
|
var newWidth = originalState.width + delta.width;
|
|
101
121
|
var state = editorView.state,
|
|
@@ -139,28 +159,9 @@ var TableResizer = function TableResizer(_ref) {
|
|
|
139
159
|
// Hide guidelines when resizing stops
|
|
140
160
|
displayGuideline([]);
|
|
141
161
|
updateWidth(newWidth);
|
|
162
|
+
scheduleResize.cancel();
|
|
142
163
|
return newWidth;
|
|
143
|
-
}, [updateWidth, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
144
|
-
var handleResize = (0, _react.useCallback)(function (originalState, delta) {
|
|
145
|
-
countFrames();
|
|
146
|
-
var newWidth = originalState.width + delta.width;
|
|
147
|
-
var pos = getPos();
|
|
148
|
-
if (typeof pos !== 'number') {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
(0, _utils2.previewScaleTable)(tableRef, {
|
|
152
|
-
node: node,
|
|
153
|
-
prevNode: node,
|
|
154
|
-
start: pos + 1,
|
|
155
|
-
parentWidth: newWidth
|
|
156
|
-
}, editorView.domAtPos.bind(editorView));
|
|
157
|
-
updateActiveGuidelines((0, _snapping.findClosestSnap)(newWidth, _guidelines.defaultGuidelineWidths, _guidelines.defaultGuidelines, _consts.TABLE_HIGHLIGHT_GAP));
|
|
158
|
-
updateWidth(newWidth);
|
|
159
|
-
return newWidth;
|
|
160
|
-
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
161
|
-
var scheduleResize = (0, _react.useMemo)(function () {
|
|
162
|
-
return (0, _rafSchd.default)(handleResize);
|
|
163
|
-
}, [handleResize]);
|
|
164
|
+
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
164
165
|
var handleComponent = (0, _react.useMemo)(function () {
|
|
165
166
|
return {
|
|
166
167
|
left: /*#__PURE__*/_react.default.createElement("div", {
|
package/dist/cjs/version.json
CHANGED
|
@@ -84,6 +84,24 @@ export const TableResizer = ({
|
|
|
84
84
|
}));
|
|
85
85
|
setSnappingEnabled(displayGuideline(defaultGuidelines));
|
|
86
86
|
}, [displayGuideline, editorView, startMeasure]);
|
|
87
|
+
const handleResize = useCallback((originalState, delta) => {
|
|
88
|
+
countFrames();
|
|
89
|
+
const newWidth = originalState.width + delta.width;
|
|
90
|
+
const pos = getPos();
|
|
91
|
+
if (typeof pos !== 'number') {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
previewScaleTable(tableRef, {
|
|
95
|
+
node,
|
|
96
|
+
prevNode: node,
|
|
97
|
+
start: pos + 1,
|
|
98
|
+
parentWidth: newWidth
|
|
99
|
+
}, editorView.domAtPos.bind(editorView));
|
|
100
|
+
updateActiveGuidelines(findClosestSnap(newWidth, defaultGuidelineWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP));
|
|
101
|
+
updateWidth(newWidth);
|
|
102
|
+
return newWidth;
|
|
103
|
+
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
104
|
+
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
87
105
|
const handleResizeStop = useCallback((originalState, delta) => {
|
|
88
106
|
const newWidth = originalState.width + delta.width;
|
|
89
107
|
const {
|
|
@@ -130,26 +148,9 @@ export const TableResizer = ({
|
|
|
130
148
|
// Hide guidelines when resizing stops
|
|
131
149
|
displayGuideline([]);
|
|
132
150
|
updateWidth(newWidth);
|
|
151
|
+
scheduleResize.cancel();
|
|
133
152
|
return newWidth;
|
|
134
|
-
}, [updateWidth, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
135
|
-
const handleResize = useCallback((originalState, delta) => {
|
|
136
|
-
countFrames();
|
|
137
|
-
const newWidth = originalState.width + delta.width;
|
|
138
|
-
const pos = getPos();
|
|
139
|
-
if (typeof pos !== 'number') {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
previewScaleTable(tableRef, {
|
|
143
|
-
node,
|
|
144
|
-
prevNode: node,
|
|
145
|
-
start: pos + 1,
|
|
146
|
-
parentWidth: newWidth
|
|
147
|
-
}, editorView.domAtPos.bind(editorView));
|
|
148
|
-
updateActiveGuidelines(findClosestSnap(newWidth, defaultGuidelineWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP));
|
|
149
|
-
updateWidth(newWidth);
|
|
150
|
-
return newWidth;
|
|
151
|
-
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
152
|
-
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
153
|
+
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
153
154
|
const handleComponent = useMemo(() => ({
|
|
154
155
|
left: /*#__PURE__*/React.createElement("div", {
|
|
155
156
|
className: resizerHandleShadowClassName,
|
package/dist/es2019/version.json
CHANGED
|
@@ -86,6 +86,26 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
86
86
|
}));
|
|
87
87
|
setSnappingEnabled(displayGuideline(defaultGuidelines));
|
|
88
88
|
}, [displayGuideline, editorView, startMeasure]);
|
|
89
|
+
var handleResize = useCallback(function (originalState, delta) {
|
|
90
|
+
countFrames();
|
|
91
|
+
var newWidth = originalState.width + delta.width;
|
|
92
|
+
var pos = getPos();
|
|
93
|
+
if (typeof pos !== 'number') {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
previewScaleTable(tableRef, {
|
|
97
|
+
node: node,
|
|
98
|
+
prevNode: node,
|
|
99
|
+
start: pos + 1,
|
|
100
|
+
parentWidth: newWidth
|
|
101
|
+
}, editorView.domAtPos.bind(editorView));
|
|
102
|
+
updateActiveGuidelines(findClosestSnap(newWidth, defaultGuidelineWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP));
|
|
103
|
+
updateWidth(newWidth);
|
|
104
|
+
return newWidth;
|
|
105
|
+
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
106
|
+
var scheduleResize = useMemo(function () {
|
|
107
|
+
return rafSchd(handleResize);
|
|
108
|
+
}, [handleResize]);
|
|
89
109
|
var handleResizeStop = useCallback(function (originalState, delta) {
|
|
90
110
|
var newWidth = originalState.width + delta.width;
|
|
91
111
|
var state = editorView.state,
|
|
@@ -129,28 +149,9 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
129
149
|
// Hide guidelines when resizing stops
|
|
130
150
|
displayGuideline([]);
|
|
131
151
|
updateWidth(newWidth);
|
|
152
|
+
scheduleResize.cancel();
|
|
132
153
|
return newWidth;
|
|
133
|
-
}, [updateWidth, editorView, getPos, node, tableRef, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
134
|
-
var handleResize = useCallback(function (originalState, delta) {
|
|
135
|
-
countFrames();
|
|
136
|
-
var newWidth = originalState.width + delta.width;
|
|
137
|
-
var pos = getPos();
|
|
138
|
-
if (typeof pos !== 'number') {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
previewScaleTable(tableRef, {
|
|
142
|
-
node: node,
|
|
143
|
-
prevNode: node,
|
|
144
|
-
start: pos + 1,
|
|
145
|
-
parentWidth: newWidth
|
|
146
|
-
}, editorView.domAtPos.bind(editorView));
|
|
147
|
-
updateActiveGuidelines(findClosestSnap(newWidth, defaultGuidelineWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP));
|
|
148
|
-
updateWidth(newWidth);
|
|
149
|
-
return newWidth;
|
|
150
|
-
}, [editorView, getPos, node, tableRef, updateWidth, updateActiveGuidelines, countFrames]);
|
|
151
|
-
var scheduleResize = useMemo(function () {
|
|
152
|
-
return rafSchd(handleResize);
|
|
153
|
-
}, [handleResize]);
|
|
154
|
+
}, [updateWidth, editorView, getPos, node, tableRef, scheduleResize, displayGuideline, attachAnalyticsEvent, endMeasure]);
|
|
154
155
|
var handleComponent = useMemo(function () {
|
|
155
156
|
return {
|
|
156
157
|
left: /*#__PURE__*/React.createElement("div", {
|
package/dist/esm/version.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
4
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
interface TableResizerProps {
|
|
8
8
|
width: number;
|
|
9
9
|
maxWidth: number;
|
|
@@ -4,4 +4,4 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
4
4
|
export declare const pluginKey: PluginKey<any>;
|
|
5
5
|
export declare const getDecorations: (state: EditorState) => DecorationSet;
|
|
6
6
|
export declare const handleDocOrSelectionChanged: (tr: Transaction | ReadonlyTransaction, decorationSet: DecorationSet, oldState: EditorState, newState: EditorState) => DecorationSet;
|
|
7
|
-
export declare const createPlugin: () => SafePlugin<
|
|
7
|
+
export declare const createPlugin: () => SafePlugin<DecorationSet>;
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
/// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
-
/// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
1
|
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("../types").TablePluginState | ((state: import("prosemirror-state").EditorState) => import("../types").TablePluginState)) => import("prosemirror-state").SafeStateField<import("../types").TablePluginState>, createCommand: <A = import("../types").TablePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("../types").TablePluginState;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference path="../../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
-
/// <reference path="../../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
1
|
import { StickyPluginAction, StickyPluginState } from './types';
|
|
4
2
|
declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: StickyPluginState | ((state: import("prosemirror-state").EditorState) => StickyPluginState)) => import("prosemirror-state").SafeStateField<StickyPluginState>, createCommand: <A = StickyPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
5
3
|
export { createPluginState, createCommand };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference path="../../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
-
/// <reference path="../../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
1
|
import { ColumnResizingPluginState } from '../../types';
|
|
4
2
|
export declare const createCommand: <A = import("../../types").ColumnResizingPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
5
3
|
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: ColumnResizingPluginState | ((state: import("prosemirror-state").EditorState) => ColumnResizingPluginState)) => import("prosemirror-state").SafeStateField<ColumnResizingPluginState>;
|
|
@@ -6,7 +6,7 @@ import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import { TableOptions } from '../../../nodeviews/types';
|
|
7
7
|
export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
|
|
8
8
|
export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
|
|
9
|
-
export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null
|
|
9
|
+
export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null;
|
|
10
10
|
export declare function currentColWidth(view: EditorView, cellPos: number, { colspan, colwidth }: CellAttributes): number;
|
|
11
11
|
export declare function domCellAround(target: HTMLElement | null): HTMLElement | null;
|
|
12
12
|
interface getTableMaxWidthProps {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
4
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
7
|
interface TableResizerProps {
|
|
8
8
|
width: number;
|
|
9
9
|
maxWidth: number;
|
|
@@ -4,4 +4,4 @@ import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
|
4
4
|
export declare const pluginKey: PluginKey<any>;
|
|
5
5
|
export declare const getDecorations: (state: EditorState) => DecorationSet;
|
|
6
6
|
export declare const handleDocOrSelectionChanged: (tr: Transaction | ReadonlyTransaction, decorationSet: DecorationSet, oldState: EditorState, newState: EditorState) => DecorationSet;
|
|
7
|
-
export declare const createPlugin: () => SafePlugin<
|
|
7
|
+
export declare const createPlugin: () => SafePlugin<DecorationSet>;
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
/// <reference path="../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
-
/// <reference path="../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
1
|
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: import("../types").TablePluginState | ((state: import("prosemirror-state").EditorState) => import("../types").TablePluginState)) => import("prosemirror-state").SafeStateField<import("../types").TablePluginState>, createCommand: <A = import("../types").TablePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => import("../types").TablePluginState;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference path="../../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
-
/// <reference path="../../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
1
|
import { StickyPluginAction, StickyPluginState } from './types';
|
|
4
2
|
declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: StickyPluginState | ((state: import("prosemirror-state").EditorState) => StickyPluginState)) => import("prosemirror-state").SafeStateField<StickyPluginState>, createCommand: <A = StickyPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
5
3
|
export { createPluginState, createCommand };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference path="../../../../../../../../../typings/prosemirror.d.ts" />
|
|
2
|
-
/// <reference path="../../../../../../../../../typings/prosemirror-state.d.ts" />
|
|
3
1
|
import { ColumnResizingPluginState } from '../../types';
|
|
4
2
|
export declare const createCommand: <A = import("../../types").ColumnResizingPluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
5
3
|
export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch<any>, initialState: ColumnResizingPluginState | ((state: import("prosemirror-state").EditorState) => ColumnResizingPluginState)) => import("prosemirror-state").SafeStateField<ColumnResizingPluginState>;
|
|
@@ -6,7 +6,7 @@ import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
6
6
|
import { TableOptions } from '../../../nodeviews/types';
|
|
7
7
|
export declare function getLayoutSize(tableLayout: TableLayout, containerWidth: number | undefined, options: TableOptions): number;
|
|
8
8
|
export declare function getDefaultLayoutMaxWidth(containerWidth?: number): number;
|
|
9
|
-
export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null
|
|
9
|
+
export declare function pointsAtCell($pos: ResolvedPos): false | PMNode | null;
|
|
10
10
|
export declare function currentColWidth(view: EditorView, cellPos: number, { colspan, colwidth }: CellAttributes): number;
|
|
11
11
|
export declare function domCellAround(target: HTMLElement | null): HTMLElement | null;
|
|
12
12
|
interface getTableMaxWidthProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.3",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"releaseModel": "continuous"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^28.
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
30
|
+
"@atlaskit/adf-schema": "^28.1.0",
|
|
31
|
+
"@atlaskit/editor-common": "^74.44.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
34
|
-
"@atlaskit/editor-plugin-content-insertion": "^0.0.
|
|
35
|
-
"@atlaskit/editor-prosemirror": "1.0
|
|
34
|
+
"@atlaskit/editor-plugin-content-insertion": "^0.0.8",
|
|
35
|
+
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
36
36
|
"@atlaskit/editor-shared-styles": "^2.6.0",
|
|
37
37
|
"@atlaskit/editor-tables": "^2.3.0",
|
|
38
38
|
"@atlaskit/icon": "^21.12.0",
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
useCallback,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from 'react';
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import React, { useCallback, useMemo, useRef, useState } from 'react';
|
|
8
3
|
|
|
9
4
|
import rafSchd from 'raf-schd';
|
|
10
5
|
|
|
11
|
-
import { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import type { TableEventPayload } from '@atlaskit/editor-common/analytics';
|
|
12
7
|
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
13
8
|
import type { GuidelineConfig } from '@atlaskit/editor-common/guideline';
|
|
14
|
-
import {
|
|
9
|
+
import type {
|
|
15
10
|
HandleHeightSizeType,
|
|
16
11
|
HandleResize,
|
|
17
|
-
ResizerNext,
|
|
18
12
|
} from '@atlaskit/editor-common/resizer';
|
|
13
|
+
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
19
14
|
import { resizerHandleShadowClassName } from '@atlaskit/editor-common/styles';
|
|
20
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
21
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
22
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
15
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
16
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
17
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
23
18
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
24
19
|
|
|
25
20
|
import {
|
|
@@ -146,6 +141,52 @@ export const TableResizer = ({
|
|
|
146
141
|
setSnappingEnabled(displayGuideline(defaultGuidelines));
|
|
147
142
|
}, [displayGuideline, editorView, startMeasure]);
|
|
148
143
|
|
|
144
|
+
const handleResize = useCallback(
|
|
145
|
+
(originalState, delta) => {
|
|
146
|
+
countFrames();
|
|
147
|
+
const newWidth = originalState.width + delta.width;
|
|
148
|
+
const pos = getPos();
|
|
149
|
+
if (typeof pos !== 'number') {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
previewScaleTable(
|
|
154
|
+
tableRef,
|
|
155
|
+
{
|
|
156
|
+
node,
|
|
157
|
+
prevNode: node,
|
|
158
|
+
start: pos + 1,
|
|
159
|
+
parentWidth: newWidth,
|
|
160
|
+
},
|
|
161
|
+
editorView.domAtPos.bind(editorView),
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
updateActiveGuidelines(
|
|
165
|
+
findClosestSnap(
|
|
166
|
+
newWidth,
|
|
167
|
+
defaultGuidelineWidths,
|
|
168
|
+
defaultGuidelines,
|
|
169
|
+
TABLE_HIGHLIGHT_GAP,
|
|
170
|
+
),
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
updateWidth(newWidth);
|
|
174
|
+
|
|
175
|
+
return newWidth;
|
|
176
|
+
},
|
|
177
|
+
[
|
|
178
|
+
editorView,
|
|
179
|
+
getPos,
|
|
180
|
+
node,
|
|
181
|
+
tableRef,
|
|
182
|
+
updateWidth,
|
|
183
|
+
updateActiveGuidelines,
|
|
184
|
+
countFrames,
|
|
185
|
+
],
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
189
|
+
|
|
149
190
|
const handleResizeStop = useCallback<HandleResize>(
|
|
150
191
|
(originalState, delta) => {
|
|
151
192
|
const newWidth = originalState.width + delta.width;
|
|
@@ -199,6 +240,7 @@ export const TableResizer = ({
|
|
|
199
240
|
// Hide guidelines when resizing stops
|
|
200
241
|
displayGuideline([]);
|
|
201
242
|
updateWidth(newWidth);
|
|
243
|
+
scheduleResize.cancel();
|
|
202
244
|
|
|
203
245
|
return newWidth;
|
|
204
246
|
},
|
|
@@ -208,58 +250,13 @@ export const TableResizer = ({
|
|
|
208
250
|
getPos,
|
|
209
251
|
node,
|
|
210
252
|
tableRef,
|
|
253
|
+
scheduleResize,
|
|
211
254
|
displayGuideline,
|
|
212
255
|
attachAnalyticsEvent,
|
|
213
256
|
endMeasure,
|
|
214
257
|
],
|
|
215
258
|
);
|
|
216
259
|
|
|
217
|
-
const handleResize = useCallback(
|
|
218
|
-
(originalState, delta) => {
|
|
219
|
-
countFrames();
|
|
220
|
-
const newWidth = originalState.width + delta.width;
|
|
221
|
-
const pos = getPos();
|
|
222
|
-
if (typeof pos !== 'number') {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
previewScaleTable(
|
|
227
|
-
tableRef,
|
|
228
|
-
{
|
|
229
|
-
node,
|
|
230
|
-
prevNode: node,
|
|
231
|
-
start: pos + 1,
|
|
232
|
-
parentWidth: newWidth,
|
|
233
|
-
},
|
|
234
|
-
editorView.domAtPos.bind(editorView),
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
updateActiveGuidelines(
|
|
238
|
-
findClosestSnap(
|
|
239
|
-
newWidth,
|
|
240
|
-
defaultGuidelineWidths,
|
|
241
|
-
defaultGuidelines,
|
|
242
|
-
TABLE_HIGHLIGHT_GAP,
|
|
243
|
-
),
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
updateWidth(newWidth);
|
|
247
|
-
|
|
248
|
-
return newWidth;
|
|
249
|
-
},
|
|
250
|
-
[
|
|
251
|
-
editorView,
|
|
252
|
-
getPos,
|
|
253
|
-
node,
|
|
254
|
-
tableRef,
|
|
255
|
-
updateWidth,
|
|
256
|
-
updateActiveGuidelines,
|
|
257
|
-
countFrames,
|
|
258
|
-
],
|
|
259
|
-
);
|
|
260
|
-
|
|
261
|
-
const scheduleResize = useMemo(() => rafSchd(handleResize), [handleResize]);
|
|
262
|
-
|
|
263
260
|
const handleComponent = useMemo(
|
|
264
261
|
() => ({
|
|
265
262
|
left: (
|