@atlaskit/editor-plugin-table 2.1.7 → 2.3.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 +20 -0
- package/dist/cjs/plugins/table/handlers.js +1 -0
- package/dist/cjs/plugins/table/index.js +41 -35
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/cjs/plugins/table/nodeviews/TableContainer.js +50 -47
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +72 -28
- package/dist/cjs/plugins/table/nodeviews/table.js +12 -5
- package/dist/cjs/plugins/table/pm-plugins/decorations/plugin.js +14 -5
- package/dist/cjs/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/cjs/plugins/table/pm-plugins/main.js +2 -2
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/plugin-factory.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +27 -4
- package/dist/cjs/plugins/table/toolbar.js +6 -1
- package/dist/cjs/plugins/table/ui/consts.js +6 -2
- package/dist/cjs/plugins/table/utils/collapse.js +2 -0
- package/dist/cjs/plugins/table/utils/decoration.js +2 -0
- package/dist/cjs/plugins/table/utils/guidelines.js +12 -0
- package/dist/cjs/plugins/table/utils/snapping.js +37 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/handlers.js +1 -0
- package/dist/es2019/plugins/table/index.js +19 -10
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/es2019/plugins/table/nodeviews/TableContainer.js +25 -23
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +71 -29
- package/dist/es2019/plugins/table/nodeviews/table.js +12 -5
- package/dist/es2019/plugins/table/pm-plugins/decorations/plugin.js +18 -6
- package/dist/es2019/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/main.js +2 -2
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
- package/dist/es2019/plugins/table/toolbar.js +6 -1
- package/dist/es2019/plugins/table/ui/consts.js +3 -1
- package/dist/es2019/plugins/table/utils/collapse.js +2 -0
- package/dist/es2019/plugins/table/utils/decoration.js +2 -0
- package/dist/es2019/plugins/table/utils/guidelines.js +4 -0
- package/dist/es2019/plugins/table/utils/snapping.js +27 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/handlers.js +1 -0
- package/dist/esm/plugins/table/index.js +41 -35
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/esm/plugins/table/nodeviews/TableContainer.js +50 -47
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +69 -28
- package/dist/esm/plugins/table/nodeviews/table.js +12 -5
- package/dist/esm/plugins/table/pm-plugins/decorations/plugin.js +18 -6
- package/dist/esm/plugins/table/pm-plugins/decorations/utils/column-controls.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/main.js +2 -2
- package/dist/esm/plugins/table/pm-plugins/table-resizing/plugin-factory.js +2 -0
- package/dist/esm/plugins/table/pm-plugins/{table-add-width.js → table-width.js} +25 -3
- package/dist/esm/plugins/table/toolbar.js +6 -1
- package/dist/esm/plugins/table/ui/consts.js +3 -1
- package/dist/esm/plugins/table/utils/collapse.js +2 -0
- package/dist/esm/plugins/table/utils/decoration.js +2 -0
- package/dist/esm/plugins/table/utils/guidelines.js +4 -0
- package/dist/esm/plugins/table/utils/snapping.js +30 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +3 -1
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +3 -2
- package/dist/types/plugins/table/nodeviews/TableContainer.d.ts +5 -2
- package/dist/types/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/table/pm-plugins/table-width.d.ts +16 -0
- package/dist/types/plugins/table/types.d.ts +3 -0
- package/dist/types/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types/plugins/table/utils/guidelines.d.ts +3 -0
- package/dist/types/plugins/table/utils/snapping.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +3 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableContainer.d.ts +5 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableResizer.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-width.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/guidelines.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/utils/snapping.d.ts +8 -0
- package/package.json +4 -3
- package/report.api.md +2 -0
- package/src/__tests__/unit/analytics.ts +2 -0
- package/src/__tests__/unit/collab.ts +2 -0
- package/src/__tests__/unit/commands/go-to-next-cell.ts +2 -0
- package/src/__tests__/unit/commands/insert.ts +2 -0
- package/src/__tests__/unit/commands/misc.ts +2 -0
- package/src/__tests__/unit/commands/sort.ts +4 -0
- package/src/__tests__/unit/commands.ts +2 -0
- package/src/__tests__/unit/copy-paste.ts +2 -0
- package/src/__tests__/unit/event-handlers/index.ts +3 -0
- package/src/__tests__/unit/event-handlers.ts +3 -0
- package/src/__tests__/unit/fix-tables.ts +2 -0
- package/src/__tests__/unit/get-toolbar-config.ts +2 -0
- package/src/__tests__/unit/handlers.ts +2 -0
- package/src/__tests__/unit/hover-selection.ts +2 -0
- package/src/__tests__/unit/index.ts +2 -0
- package/src/__tests__/unit/layout.ts +2 -0
- package/src/__tests__/unit/nodeviews/cell.ts +2 -0
- package/src/__tests__/unit/nodeviews/table.ts +2 -0
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +2 -0
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +68 -0
- package/src/__tests__/unit/pm-plugins/main.ts +2 -0
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -0
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +3 -0
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -0
- package/src/__tests__/unit/sort-column.ts +2 -0
- package/src/__tests__/unit/toolbar.ts +2 -0
- package/src/__tests__/unit/transforms/delete-columns.ts +2 -0
- package/src/__tests__/unit/transforms/delete-rows.ts +2 -0
- package/src/__tests__/unit/transforms/merging.ts +2 -0
- package/src/__tests__/unit/ui/ContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +2 -0
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +2 -0
- package/src/__tests__/unit/ui/RowControls.tsx +2 -0
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -0
- package/src/__tests__/unit/undo-redo.ts +2 -0
- package/src/__tests__/unit/utils/collapse.ts +2 -0
- package/src/__tests__/unit/utils/nodes.ts +2 -0
- package/src/__tests__/unit/utils/row-controls.ts +2 -0
- package/src/__tests__/unit/utils.ts +2 -0
- package/src/plugins/table/handlers.ts +1 -0
- package/src/plugins/table/index.tsx +38 -23
- package/src/plugins/table/nodeviews/TableComponent.tsx +6 -5
- package/src/plugins/table/nodeviews/TableContainer.tsx +31 -22
- package/src/plugins/table/nodeviews/TableResizer.tsx +107 -34
- package/src/plugins/table/nodeviews/table.tsx +16 -2
- package/src/plugins/table/nodeviews/types.ts +2 -0
- package/src/plugins/table/pm-plugins/decorations/plugin.ts +27 -4
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +1 -0
- package/src/plugins/table/pm-plugins/decorations/utils/types.ts +1 -0
- package/src/plugins/table/pm-plugins/main.ts +3 -0
- package/src/plugins/table/pm-plugins/table-resizing/plugin-factory.ts +1 -0
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +1 -0
- package/src/plugins/table/pm-plugins/{table-add-width.ts → table-width.ts} +33 -3
- package/src/plugins/table/toolbar.tsx +7 -1
- package/src/plugins/table/types.ts +4 -0
- package/src/plugins/table/ui/consts.ts +3 -0
- package/src/plugins/table/utils/collapse.ts +1 -0
- package/src/plugins/table/utils/decoration.ts +1 -0
- package/src/plugins/table/utils/guidelines.ts +17 -0
- package/src/plugins/table/utils/snapping.ts +38 -0
- package/tmp/api-report-tmp.d.ts +3 -1
- package/dist/types/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-add-width.d.ts +0 -7
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import React from 'react';
|
|
5
|
+
import React, { useCallback, useRef, useMemo, useState } from 'react';
|
|
5
6
|
import rafSchd from 'raf-schd';
|
|
6
7
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
8
|
+
import { getGuidelinesWithHighlights } from '@atlaskit/editor-common/guideline';
|
|
7
9
|
import { scaleTable, previewScaleTable, getColgroupChildrenLength, COLUMN_MIN_WIDTH } from '../pm-plugins/table-resizing/utils';
|
|
10
|
+
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
11
|
+
import { defaultGuidelines, defaultGuidelineWidths } from '../utils/guidelines';
|
|
12
|
+
import { findClosestSnap } from '../utils/snapping';
|
|
13
|
+
import { TABLE_SNAP_GAP, TABLE_HIGHLIGHT_GAP } from '../ui/consts';
|
|
8
14
|
var handles = {
|
|
9
15
|
right: true
|
|
10
16
|
};
|
|
@@ -17,7 +23,8 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
17
23
|
editorView = _ref.editorView,
|
|
18
24
|
getPos = _ref.getPos,
|
|
19
25
|
node = _ref.node,
|
|
20
|
-
tableRef = _ref.tableRef
|
|
26
|
+
tableRef = _ref.tableRef,
|
|
27
|
+
displayGuideline = _ref.displayGuideline;
|
|
21
28
|
var currentColumnCount = getColgroupChildrenLength(node);
|
|
22
29
|
var minColumnWidth = currentColumnCount <= 3 ? currentColumnCount * COLUMN_MIN_WIDTH : 3 * COLUMN_MIN_WIDTH;
|
|
23
30
|
var tableHeight = tableRef === null || tableRef === void 0 ? void 0 : tableRef.clientHeight;
|
|
@@ -35,15 +42,67 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
35
42
|
} else if (tableHeight && tableHeight >= 96) {
|
|
36
43
|
handleHeightSize = 'large';
|
|
37
44
|
}
|
|
45
|
+
var currentGap = useRef(0);
|
|
46
|
+
var _useState = useState(false),
|
|
47
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
48
|
+
snappingEnabled = _useState2[0],
|
|
49
|
+
setSnappingEnabled = _useState2[1];
|
|
50
|
+
var updateActiveGuidelines = useCallback(function (_ref2) {
|
|
51
|
+
var gap = _ref2.gap,
|
|
52
|
+
keys = _ref2.keys;
|
|
53
|
+
if (gap !== currentGap.current) {
|
|
54
|
+
currentGap.current = gap;
|
|
55
|
+
displayGuideline(getGuidelinesWithHighlights(gap, TABLE_SNAP_GAP, keys, defaultGuidelines));
|
|
56
|
+
}
|
|
57
|
+
}, [displayGuideline]);
|
|
58
|
+
var guidelineSnaps = useMemo(function () {
|
|
59
|
+
return snappingEnabled ? {
|
|
60
|
+
x: defaultGuidelineWidths
|
|
61
|
+
} : undefined;
|
|
62
|
+
}, [snappingEnabled]);
|
|
63
|
+
var handleResizeStart = useCallback(function () {
|
|
64
|
+
var dispatch = editorView.dispatch,
|
|
65
|
+
tr = editorView.state.tr;
|
|
66
|
+
dispatch(tr.setMeta(tableWidthPluginKey, {
|
|
67
|
+
resizing: true
|
|
68
|
+
}));
|
|
69
|
+
setSnappingEnabled(displayGuideline(defaultGuidelines));
|
|
70
|
+
return width;
|
|
71
|
+
}, [width, displayGuideline, editorView]);
|
|
72
|
+
var handleResizeStop = useCallback(function (originalState, delta) {
|
|
73
|
+
var newWidth = originalState.width + delta.width;
|
|
74
|
+
var state = editorView.state,
|
|
75
|
+
dispatch = editorView.dispatch;
|
|
76
|
+
var pos = getPos();
|
|
77
|
+
var tr = state.tr.setMeta(tableWidthPluginKey, {
|
|
78
|
+
resizing: false
|
|
79
|
+
});
|
|
80
|
+
if (typeof pos === 'number') {
|
|
81
|
+
tr = tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
82
|
+
width: newWidth
|
|
83
|
+
}));
|
|
84
|
+
var newNode = tr.doc.nodeAt(pos);
|
|
85
|
+
tr = scaleTable(tableRef, {
|
|
86
|
+
node: newNode,
|
|
87
|
+
prevNode: node,
|
|
88
|
+
start: pos + 1,
|
|
89
|
+
parentWidth: newWidth
|
|
90
|
+
}, editorView.domAtPos.bind(editorView))(tr);
|
|
91
|
+
}
|
|
92
|
+
dispatch(tr);
|
|
93
|
+
|
|
94
|
+
// Hide guidelines when resizing stops
|
|
95
|
+
displayGuideline([]);
|
|
96
|
+
updateWidth(newWidth);
|
|
97
|
+
return newWidth;
|
|
98
|
+
}, [updateWidth, editorView, getPos, node, tableRef, displayGuideline]);
|
|
38
99
|
return /*#__PURE__*/React.createElement(ResizerNext, {
|
|
39
100
|
enable: handles,
|
|
40
101
|
width: width,
|
|
41
102
|
handleAlignmentMethod: "sticky",
|
|
42
103
|
handleHeightSize: handleHeightSize,
|
|
43
104
|
handleMarginTop: tableHandleMarginTop,
|
|
44
|
-
handleResizeStart:
|
|
45
|
-
return width;
|
|
46
|
-
},
|
|
105
|
+
handleResizeStart: handleResizeStart,
|
|
47
106
|
handleResize: rafSchd(function (originalState, delta) {
|
|
48
107
|
var newWidth = originalState.width + delta.width;
|
|
49
108
|
var pos = getPos();
|
|
@@ -56,33 +115,15 @@ export var TableResizer = function TableResizer(_ref) {
|
|
|
56
115
|
start: pos + 1,
|
|
57
116
|
parentWidth: newWidth
|
|
58
117
|
}, editorView.domAtPos.bind(editorView));
|
|
118
|
+
updateActiveGuidelines(findClosestSnap(newWidth, defaultGuidelineWidths, defaultGuidelines, TABLE_HIGHLIGHT_GAP));
|
|
59
119
|
updateWidth(newWidth);
|
|
60
120
|
return newWidth;
|
|
61
121
|
}),
|
|
62
|
-
handleResizeStop:
|
|
63
|
-
var newWidth = originalState.width + delta.width;
|
|
64
|
-
var state = editorView.state,
|
|
65
|
-
dispatch = editorView.dispatch;
|
|
66
|
-
var pos = getPos();
|
|
67
|
-
if (typeof pos !== 'number') {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
71
|
-
width: newWidth
|
|
72
|
-
}));
|
|
73
|
-
var newNode = tr.doc.nodeAt(pos);
|
|
74
|
-
tr = scaleTable(tableRef, {
|
|
75
|
-
node: newNode,
|
|
76
|
-
prevNode: node,
|
|
77
|
-
start: pos + 1,
|
|
78
|
-
parentWidth: newWidth
|
|
79
|
-
}, editorView.domAtPos.bind(editorView))(tr);
|
|
80
|
-
dispatch(tr);
|
|
81
|
-
updateWidth(newWidth);
|
|
82
|
-
return newWidth;
|
|
83
|
-
},
|
|
122
|
+
handleResizeStop: handleResizeStop,
|
|
84
123
|
resizeRatio: 2,
|
|
85
124
|
minWidth: minColumnWidth,
|
|
86
|
-
maxWidth: maxWidth
|
|
125
|
+
maxWidth: maxWidth,
|
|
126
|
+
snapGap: TABLE_SNAP_GAP,
|
|
127
|
+
snap: guidelineSnaps
|
|
87
128
|
}, children);
|
|
88
129
|
};
|
|
@@ -18,6 +18,7 @@ import { pluginConfig as getPluginConfig } from '../create-plugin-config';
|
|
|
18
18
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
19
19
|
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
20
20
|
import { pluginKey as tableResizingPluginKey } from '../pm-plugins/table-resizing';
|
|
21
|
+
import { pluginKey as tableWidthPluginKey } from '../pm-plugins/table-width';
|
|
21
22
|
import { generateColgroup } from '../pm-plugins/table-resizing/utils';
|
|
22
23
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
23
24
|
import TableComponent from './TableComponent';
|
|
@@ -107,16 +108,20 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
107
108
|
plugins: {
|
|
108
109
|
pluginState: pluginKey,
|
|
109
110
|
tableResizingPluginState: tableResizingPluginKey,
|
|
111
|
+
tableWidthPluginState: tableWidthPluginKey,
|
|
110
112
|
widthPlugin: fakePluginKey,
|
|
111
113
|
mediaState: fakeMediaPluginKey
|
|
112
114
|
},
|
|
113
115
|
editorView: props.view,
|
|
114
116
|
render: function render(pluginStates) {
|
|
115
117
|
var tableResizingPluginState = pluginStates.tableResizingPluginState,
|
|
118
|
+
tableWidthPluginState = pluginStates.tableWidthPluginState,
|
|
116
119
|
pluginState = pluginStates.pluginState,
|
|
117
120
|
mediaState = pluginStates.mediaState;
|
|
118
|
-
var tableActive = props.getPos() === pluginState.tablePos;
|
|
119
121
|
var containerWidth = props.getEditorContainerWidth();
|
|
122
|
+
var isTableResizing = tableWidthPluginState === null || tableWidthPluginState === void 0 ? void 0 : tableWidthPluginState.resizing;
|
|
123
|
+
var isResizing = Boolean((tableResizingPluginState === null || tableResizingPluginState === void 0 ? void 0 : tableResizingPluginState.dragging) || isTableResizing);
|
|
124
|
+
var tableActive = props.getPos() === pluginState.tablePos && !isTableResizing;
|
|
120
125
|
return /*#__PURE__*/React.createElement(TableComponent, {
|
|
121
126
|
view: props.view,
|
|
122
127
|
allowColumnResizing: props.allowColumnResizing,
|
|
@@ -129,11 +134,12 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
129
134
|
isHeaderColumnEnabled: pluginState.isHeaderColumnEnabled,
|
|
130
135
|
tableActive: tableActive,
|
|
131
136
|
ordering: pluginState.ordering,
|
|
132
|
-
|
|
137
|
+
isResizing: isResizing,
|
|
133
138
|
getNode: _this3.getNode,
|
|
134
139
|
containerWidth: containerWidth,
|
|
135
140
|
contentDOM: forwardRef,
|
|
136
|
-
getEditorFeatureFlags: props.getEditorFeatureFlags
|
|
141
|
+
getEditorFeatureFlags: props.getEditorFeatureFlags,
|
|
142
|
+
pluginInjectionApi: props.pluginInjectionApi
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
145
|
});
|
|
@@ -202,7 +208,7 @@ var TableView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
202
208
|
return TableView;
|
|
203
209
|
}(ReactNodeView);
|
|
204
210
|
export { TableView as default };
|
|
205
|
-
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags) {
|
|
211
|
+
export var createTableView = function createTableView(node, view, getPos, portalProviderAPI, eventDispatcher, options, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi) {
|
|
206
212
|
var _getPluginState2 = getPluginState(view.state),
|
|
207
213
|
pluginConfig = _getPluginState2.pluginConfig;
|
|
208
214
|
var _getPluginConfig = getPluginConfig(pluginConfig),
|
|
@@ -221,6 +227,7 @@ export var createTableView = function createTableView(node, view, getPos, portal
|
|
|
221
227
|
tableRenderOptimization: tableRenderOptimization,
|
|
222
228
|
getEditorContainerWidth: getEditorContainerWidth,
|
|
223
229
|
getEditorFeatureFlags: getEditorFeatureFlags,
|
|
224
|
-
hasIntlContext: hasIntlContext
|
|
230
|
+
hasIntlContext: hasIntlContext,
|
|
231
|
+
pluginInjectionApi: pluginInjectionApi
|
|
225
232
|
}).init();
|
|
226
233
|
};
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey
|
|
2
|
+
import { PluginKey
|
|
3
|
+
|
|
4
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
5
|
+
} from 'prosemirror-state';
|
|
3
6
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
7
|
import { DecorationSet } from 'prosemirror-view';
|
|
5
8
|
import { pluginKey as tablePluginKey } from '../plugin-key';
|
|
9
|
+
import { pluginKey as tableWidthPluginKey } from '../table-width';
|
|
6
10
|
import { buildColumnControlsDecorations, maybeUpdateColumnControlsSelectedDecoration } from './utils';
|
|
7
11
|
export var pluginKey = new PluginKey('tableDecorationsPlugin');
|
|
8
12
|
export var getDecorations = function getDecorations(state) {
|
|
9
13
|
return pluginKey.getState(state);
|
|
10
14
|
};
|
|
11
|
-
export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState) {
|
|
12
|
-
|
|
15
|
+
export var handleDocOrSelectionChanged = function handleDocOrSelectionChanged(tr, decorationSet, oldState, newState) {
|
|
16
|
+
var _tableWidthPluginKey$, _tableWidthPluginKey$2;
|
|
17
|
+
var isResizing = (_tableWidthPluginKey$ = tableWidthPluginKey.getState(newState)) === null || _tableWidthPluginKey$ === void 0 ? void 0 : _tableWidthPluginKey$.resizing;
|
|
18
|
+
var wasResizing = (_tableWidthPluginKey$2 = tableWidthPluginKey.getState(oldState)) === null || _tableWidthPluginKey$2 === void 0 ? void 0 : _tableWidthPluginKey$2.resizing;
|
|
19
|
+
var changedResizing = isResizing !== wasResizing;
|
|
20
|
+
|
|
21
|
+
// Remove column controls when resizing
|
|
22
|
+
if (isResizing) {
|
|
23
|
+
return DecorationSet.empty;
|
|
24
|
+
} else if (tr.docChanged || tr.selection instanceof CellSelection || changedResizing) {
|
|
13
25
|
return buildColumnControlsDecorations({
|
|
14
26
|
decorationSet: decorationSet,
|
|
15
27
|
tr: tr
|
|
@@ -31,15 +43,15 @@ export var createPlugin = function createPlugin() {
|
|
|
31
43
|
init: function init() {
|
|
32
44
|
return DecorationSet.empty;
|
|
33
45
|
},
|
|
34
|
-
apply: function apply(tr, decorationSet, oldState) {
|
|
46
|
+
apply: function apply(tr, decorationSet, oldState, newState) {
|
|
35
47
|
var pluginState = decorationSet;
|
|
36
48
|
var meta = tr.getMeta(tablePluginKey);
|
|
37
49
|
if (meta && meta.data && meta.data.decorationSet) {
|
|
38
50
|
pluginState = meta.data.decorationSet;
|
|
39
51
|
}
|
|
40
|
-
if (tr.docChanged || tr.selectionSet) {
|
|
52
|
+
if (tr.docChanged || tr.selectionSet || tr.getMeta(tableWidthPluginKey)) {
|
|
41
53
|
pluginState = pluginState.map(tr.mapping, tr.doc);
|
|
42
|
-
return handleDocOrSelectionChanged(tr, pluginState, oldState);
|
|
54
|
+
return handleDocOrSelectionChanged(tr, pluginState, oldState, newState);
|
|
43
55
|
}
|
|
44
56
|
return pluginState;
|
|
45
57
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
2
|
+
|
|
1
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
2
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
5
|
import { TableDecorations } from '../../../types';
|
|
@@ -27,7 +27,7 @@ import { isHeaderRowRequired } from '../utils/paste';
|
|
|
27
27
|
var isBreakoutEnabled;
|
|
28
28
|
var isFullWidthModeEnabled;
|
|
29
29
|
var wasFullWidthModeEnabled;
|
|
30
|
-
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI) {
|
|
30
|
+
export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, breakoutEnabled, fullWidthModeEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
31
31
|
var _window;
|
|
32
32
|
isBreakoutEnabled = breakoutEnabled;
|
|
33
33
|
isFullWidthModeEnabled = fullWidthModeEnabled;
|
|
@@ -232,7 +232,7 @@ export var createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch
|
|
|
232
232
|
isBreakoutEnabled: isBreakoutEnabled,
|
|
233
233
|
isFullWidthModeEnabled: isFullWidthModeEnabled,
|
|
234
234
|
wasFullWidthModeEnabled: wasFullWidthModeEnabled
|
|
235
|
-
}, getEditorContainerWidth, getEditorFeatureFlags);
|
|
235
|
+
}, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
236
236
|
}
|
|
237
237
|
}),
|
|
238
238
|
handleDOMEvents: {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
5
|
+
|
|
4
6
|
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
5
7
|
import { pluginKey } from './plugin-key';
|
|
6
8
|
import reducer from './reducer';
|
|
@@ -4,15 +4,37 @@ var _excluded = ["width"];
|
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
/**
|
|
7
|
-
* A plugin for
|
|
8
|
-
*
|
|
7
|
+
* A plugin for handle table custom widths
|
|
8
|
+
* Has login to scan the document, add width value to table's width attribute when necessary
|
|
9
|
+
* Also holds resizing state to hide / show table controls
|
|
9
10
|
*/
|
|
10
11
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
11
12
|
import { akEditorFullWidthLayoutWidth, akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
12
13
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
13
14
|
import { ReplaceStep } from 'prosemirror-transform';
|
|
14
|
-
|
|
15
|
+
import { PluginKey } from 'prosemirror-state';
|
|
16
|
+
export var pluginKey = new PluginKey('tableWidthPlugin');
|
|
17
|
+
var createPlugin = function createPlugin(dispatch, fullWidthEnabled) {
|
|
15
18
|
return new SafePlugin({
|
|
19
|
+
key: pluginKey,
|
|
20
|
+
state: {
|
|
21
|
+
init: function init() {
|
|
22
|
+
return {
|
|
23
|
+
resizing: false
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
apply: function apply(tr, pluginState) {
|
|
27
|
+
var meta = tr.getMeta(pluginKey);
|
|
28
|
+
if (meta && meta.resizing !== pluginState.resizing) {
|
|
29
|
+
var newState = {
|
|
30
|
+
resizing: meta.resizing
|
|
31
|
+
};
|
|
32
|
+
dispatch(pluginKey, newState);
|
|
33
|
+
return newState;
|
|
34
|
+
}
|
|
35
|
+
return pluginState;
|
|
36
|
+
}
|
|
37
|
+
},
|
|
16
38
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
17
39
|
// When document first load in Confluence, initially it is an empty document
|
|
18
40
|
// and Collab service triggers a transaction to replace the empty document with the real document that should be rendered.
|
|
@@ -7,6 +7,7 @@ import { clearHoverSelection, hoverTable, hoverColumns, hoverRows, removeDescend
|
|
|
7
7
|
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
|
|
8
8
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
9
9
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
10
|
+
import { pluginKey as tableWidthPluginKey } from './pm-plugins/table-width';
|
|
10
11
|
import { TableCssClassName } from './types';
|
|
11
12
|
import { getMergedCellsPositions, getSelectedColumnIndexes, getSelectedRowIndexes } from './utils';
|
|
12
13
|
import { isReferencedSource, getChildrenInfo as _getChildrenInfo, getNodeName } from '@atlaskit/editor-common/utils';
|
|
@@ -293,7 +294,11 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
293
294
|
var tableObject = findTable(state.selection);
|
|
294
295
|
var pluginState = getPluginState(state);
|
|
295
296
|
var resizeState = tableResizingPluginKey.getState(state);
|
|
296
|
-
|
|
297
|
+
var tableWidthState = tableWidthPluginKey.getState(state);
|
|
298
|
+
|
|
299
|
+
// We don't want to show floating toolbar while resizing the table
|
|
300
|
+
var isWidthResizing = tableWidthState === null || tableWidthState === void 0 ? void 0 : tableWidthState.resizing;
|
|
301
|
+
if (tableObject && pluginState.editorHasFocus && !isWidthResizing) {
|
|
297
302
|
var nodeType = state.schema.nodes.table;
|
|
298
303
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
299
304
|
var _ref3 = getEditorFeatureFlags() || {},
|
|
@@ -62,4 +62,6 @@ export var contextualMenuTriggerSize = 16;
|
|
|
62
62
|
export var contextualMenuDropdownWidth = 180;
|
|
63
63
|
export var stickyRowZIndex = resizeHandlerZIndex + 2;
|
|
64
64
|
export var stickyRowOffsetTop = 8;
|
|
65
|
-
export var stickyHeaderBorderBottomWidth = 1;
|
|
65
|
+
export var stickyHeaderBorderBottomWidth = 1;
|
|
66
|
+
export var TABLE_SNAP_GAP = 5;
|
|
67
|
+
export var TABLE_HIGHLIGHT_GAP = 10;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { NodeRange } from 'prosemirror-model';
|
|
2
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
3
|
+
|
|
2
4
|
import { findWrapping } from 'prosemirror-transform';
|
|
3
5
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
4
6
|
var bail = function bail() {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
// @ts-ignore -- ReadonlyTransaction is a local declaration and will cause a TS2305 error in CCFE typecheck
|
|
3
|
+
|
|
2
4
|
import { Rect, TableMap } from '@atlaskit/editor-tables/table-map';
|
|
3
5
|
import { findTable, getCellsInRow, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
4
6
|
import { Decoration } from 'prosemirror-view';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createFixedGuidelinesFromLengths } from '@atlaskit/editor-common/guideline';
|
|
2
|
+
import { akEditorDefaultLayoutWidth, akEditorWideLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
export var defaultGuidelineWidths = [akEditorDefaultLayoutWidth, akEditorWideLayoutWidth, akEditorFullWidthLayoutWidth];
|
|
4
|
+
export var defaultGuidelines = createFixedGuidelinesFromLengths(defaultGuidelineWidths);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
3
|
+
*/
|
|
4
|
+
export var findClosestSnap = function findClosestSnap(currentWidth, snapWidths, guidelines) {
|
|
5
|
+
var snapGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
6
|
+
var closestGapIndex = snapWidths.reduce(function (prev, curr, index) {
|
|
7
|
+
return Math.abs(curr - currentWidth) < Math.abs(snapWidths[prev] - currentWidth) ? index : prev;
|
|
8
|
+
}, 0);
|
|
9
|
+
var gap = Math.abs(snapWidths[closestGapIndex] - currentWidth);
|
|
10
|
+
if (gap < snapGap) {
|
|
11
|
+
var snappingWidth = Math.round(snapWidths[closestGapIndex]);
|
|
12
|
+
var guidelineKeys = guidelines.reduce(function (acc, guideline) {
|
|
13
|
+
// NOTE: The snap points are based on the guidelines, however their formatted as a length value whereas the guidelines
|
|
14
|
+
// are point based. The point base x coords are calculated by halving the lengths. This means we can convert the
|
|
15
|
+
// point base position to length by simply multiplying by 2.
|
|
16
|
+
if (Math.round(Math.abs(guideline.position.x) * 2) === snappingWidth) {
|
|
17
|
+
acc.push(guideline.key);
|
|
18
|
+
}
|
|
19
|
+
return acc;
|
|
20
|
+
}, []);
|
|
21
|
+
return {
|
|
22
|
+
gap: gap,
|
|
23
|
+
keys: guidelineKeys
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
gap: gap,
|
|
28
|
+
keys: []
|
|
29
|
+
};
|
|
30
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -6,6 +6,7 @@ import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-c
|
|
|
6
6
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
7
7
|
import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
8
8
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
|
+
import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
9
10
|
interface TablePluginOptions {
|
|
10
11
|
tableOptions: PluginConfig;
|
|
11
12
|
breakoutEnabled?: boolean;
|
|
@@ -24,7 +25,8 @@ declare const tablesPlugin: NextEditorPlugin<'table', {
|
|
|
24
25
|
dependencies: [
|
|
25
26
|
typeof analyticsPlugin,
|
|
26
27
|
typeof contentInsertionPlugin,
|
|
27
|
-
typeof widthPlugin
|
|
28
|
+
typeof widthPlugin,
|
|
29
|
+
typeof guidelinePlugin
|
|
28
30
|
];
|
|
29
31
|
}>;
|
|
30
32
|
export default tablesPlugin;
|
|
@@ -4,7 +4,7 @@ import { EditorView } from 'prosemirror-view';
|
|
|
4
4
|
import type { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
5
5
|
import { RowStickyState, StickyPluginState } from '../pm-plugins/sticky-headers';
|
|
6
6
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
7
|
-
import {
|
|
7
|
+
import { PluginInjectionAPI, ShadowEvent } from '../types';
|
|
8
8
|
import type { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
|
|
9
9
|
import type { TableOptions } from './types';
|
|
10
10
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
@@ -23,8 +23,9 @@ export interface ComponentProps {
|
|
|
23
23
|
isMediaFullscreen?: boolean;
|
|
24
24
|
tableActive: boolean;
|
|
25
25
|
ordering: TableColumnOrdering;
|
|
26
|
-
|
|
26
|
+
isResizing?: boolean;
|
|
27
27
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
28
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
28
29
|
}
|
|
29
30
|
interface TableState {
|
|
30
31
|
scroll: number;
|
|
@@ -2,6 +2,7 @@ import React, { PropsWithChildren } from 'react';
|
|
|
2
2
|
import { Node as PMNode } from 'prosemirror-model';
|
|
3
3
|
import { EditorView } from 'prosemirror-view';
|
|
4
4
|
import { EditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { PluginInjectionAPI } from '../types';
|
|
5
6
|
type InnerContainerProps = {
|
|
6
7
|
className: string;
|
|
7
8
|
style?: {
|
|
@@ -21,8 +22,9 @@ type ResizableTableContainerProps = {
|
|
|
21
22
|
editorView: EditorView;
|
|
22
23
|
getPos: () => number | undefined;
|
|
23
24
|
tableRef: HTMLTableElement;
|
|
25
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
26
|
};
|
|
25
|
-
export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
|
|
27
|
+
export declare const ResizableTableContainer: ({ children, className, node, lineLength, containerWidth, editorView, getPos, tableRef, pluginInjectionApi, }: PropsWithChildren<ResizableTableContainerProps>) => JSX.Element;
|
|
26
28
|
type TableContainerProps = {
|
|
27
29
|
node: PMNode;
|
|
28
30
|
className: string;
|
|
@@ -33,6 +35,7 @@ type TableContainerProps = {
|
|
|
33
35
|
getPos: () => number | undefined;
|
|
34
36
|
tableRef: HTMLTableElement;
|
|
35
37
|
isNested: boolean;
|
|
38
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
36
39
|
};
|
|
37
|
-
export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
40
|
+
export declare const TableContainer: ({ children, node, className, containerWidth: { lineLength, width: editorWidth }, isFullWidthModeEnabled, isBreakoutEnabled, editorView, getPos, tableRef, isNested, pluginInjectionApi, }: PropsWithChildren<TableContainerProps>) => JSX.Element;
|
|
38
41
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { EditorView } from 'prosemirror-view';
|
|
3
3
|
import { Node as PMNode } from 'prosemirror-model';
|
|
4
|
+
import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
|
|
4
5
|
interface TableResizerProps {
|
|
5
6
|
width: number;
|
|
6
7
|
maxWidth: number;
|
|
@@ -9,6 +10,7 @@ interface TableResizerProps {
|
|
|
9
10
|
getPos: () => number | undefined;
|
|
10
11
|
node: PMNode;
|
|
11
12
|
tableRef: HTMLTableElement;
|
|
13
|
+
displayGuideline: (guideline: GuidelineConfig[]) => boolean;
|
|
12
14
|
}
|
|
13
|
-
export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
15
|
+
export declare const TableResizer: ({ children, width, maxWidth, updateWidth, editorView, getPos, node, tableRef, displayGuideline, }: PropsWithChildren<TableResizerProps>) => JSX.Element;
|
|
14
16
|
export {};
|
|
@@ -7,6 +7,7 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
7
7
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
8
8
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
9
9
|
import { Props, TableOptions } from './types';
|
|
10
|
+
import { PluginInjectionAPI } from '../types';
|
|
10
11
|
type ForwardRef = (node: HTMLElement | null) => void;
|
|
11
12
|
export default class TableView extends ReactNodeView<Props> {
|
|
12
13
|
private table;
|
|
@@ -30,5 +31,5 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
30
31
|
}): boolean;
|
|
31
32
|
destroy(): void;
|
|
32
33
|
}
|
|
33
|
-
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, options: TableOptions, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags) => NodeView;
|
|
34
|
+
export declare const createTableView: (node: PmNode, view: EditorView, getPos: getPosHandler, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, options: TableOptions, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, pluginInjectionApi?: PluginInjectionAPI) => NodeView;
|
|
34
35
|
export {};
|
|
@@ -3,6 +3,7 @@ import { EditorView } from 'prosemirror-view';
|
|
|
3
3
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
4
|
import { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
5
5
|
import type { PortalProviderAPI } from '@atlaskit/editor-common/portal-provider';
|
|
6
|
+
import type { PluginInjectionAPI } from '../types';
|
|
6
7
|
export type TableOptions = {
|
|
7
8
|
isBreakoutEnabled?: boolean;
|
|
8
9
|
isFullWidthModeEnabled?: boolean;
|
|
@@ -21,4 +22,5 @@ export interface Props {
|
|
|
21
22
|
getEditorContainerWidth: GetEditorContainerWidth;
|
|
22
23
|
getEditorFeatureFlags: GetEditorFeatureFlags;
|
|
23
24
|
hasIntlContext: boolean;
|
|
25
|
+
pluginInjectionApi?: PluginInjectionAPI;
|
|
24
26
|
}
|
|
@@ -3,5 +3,5 @@ import { EditorState, PluginKey, Transaction, ReadonlyTransaction } from 'prosem
|
|
|
3
3
|
import { DecorationSet } from 'prosemirror-view';
|
|
4
4
|
export declare const pluginKey: PluginKey<any>;
|
|
5
5
|
export declare const getDecorations: (state: EditorState) => DecorationSet;
|
|
6
|
-
export declare const handleDocOrSelectionChanged: (tr: Transaction | ReadonlyTransaction, decorationSet: DecorationSet, oldState: EditorState) => DecorationSet;
|
|
6
|
+
export declare const handleDocOrSelectionChanged: (tr: Transaction | ReadonlyTransaction, decorationSet: DecorationSet, oldState: EditorState, newState: EditorState) => DecorationSet;
|
|
7
7
|
export declare const createPlugin: () => SafePlugin<any>;
|
|
@@ -5,4 +5,5 @@ import { PluginConfig } from '../types';
|
|
|
5
5
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
6
6
|
import type { DispatchAnalyticsEvent } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import type { GetEditorContainerWidth, GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
8
|
-
|
|
8
|
+
import type { PluginInjectionAPI } from '../types';
|
|
9
|
+
export declare const createPlugin: (dispatchAnalyticsEvent: DispatchAnalyticsEvent, dispatch: Dispatch, portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, pluginConfig: PluginConfig, getEditorContainerWidth: GetEditorContainerWidth, getEditorFeatureFlags: GetEditorFeatureFlags, breakoutEnabled?: boolean, fullWidthModeEnabled?: boolean, previousFullWidthModeEnabled?: boolean, editorAnalyticsAPI?: EditorAnalyticsAPI, pluginInjectionApi?: PluginInjectionAPI) => SafePlugin<import("../types").TablePluginState>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin for handle table custom widths
|
|
3
|
+
* Has login to scan the document, add width value to table's width attribute when necessary
|
|
4
|
+
* Also holds resizing state to hide / show table controls
|
|
5
|
+
*/
|
|
6
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
+
import { PluginKey } from 'prosemirror-state';
|
|
8
|
+
import { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
9
|
+
type TableWidthPluginState = {
|
|
10
|
+
resizing: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const pluginKey: PluginKey<TableWidthPluginState>;
|
|
13
|
+
declare const createPlugin: (dispatch: Dispatch, fullWidthEnabled: boolean) => SafePlugin<{
|
|
14
|
+
resizing: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
export { createPlugin };
|
|
@@ -6,6 +6,8 @@ import { IntlShape } from 'react-intl-next';
|
|
|
6
6
|
import { TableLayout } from '@atlaskit/adf-schema';
|
|
7
7
|
import { TableColumnOrdering } from '@atlaskit/adf-schema/steps';
|
|
8
8
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
9
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
10
|
+
import type tablePlugin from './index';
|
|
9
11
|
export declare const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
|
|
10
12
|
export type RowInsertPosition = 'TOP' | 'BOTTOM';
|
|
11
13
|
export type PermittedLayoutsDescriptor = TableLayout[] | 'all';
|
|
@@ -19,6 +21,7 @@ export interface InsertRowOptions {
|
|
|
19
21
|
index: number;
|
|
20
22
|
moveCursorToInsertedRow: boolean;
|
|
21
23
|
}
|
|
24
|
+
export type PluginInjectionAPI = ExtractInjectionAPI<typeof tablePlugin>;
|
|
22
25
|
export type InsertRowMethods = INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.BUTTON | INPUT_METHOD.SHORTCUT | INPUT_METHOD.KEYBOARD | INPUT_METHOD.FLOATING_TB;
|
|
23
26
|
export interface PluginConfig {
|
|
24
27
|
advanced?: boolean;
|
|
@@ -38,3 +38,5 @@ export declare const contextualMenuDropdownWidth = 180;
|
|
|
38
38
|
export declare const stickyRowZIndex: number;
|
|
39
39
|
export declare const stickyRowOffsetTop = 8;
|
|
40
40
|
export declare const stickyHeaderBorderBottomWidth = 1;
|
|
41
|
+
export declare const TABLE_SNAP_GAP = 5;
|
|
42
|
+
export declare const TABLE_HIGHLIGHT_GAP = 10;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GuidelineConfig } from '@atlaskit/editor-plugin-guideline';
|
|
2
|
+
/**
|
|
3
|
+
* Returns keys of guidelines that are closest to the table and withthin the snapGap
|
|
4
|
+
*/
|
|
5
|
+
export declare const findClosestSnap: (currentWidth: number, snapWidths: number[], guidelines: GuidelineConfig[], snapGap?: number) => {
|
|
6
|
+
gap: number;
|
|
7
|
+
keys: string[];
|
|
8
|
+
};
|
|
@@ -6,6 +6,7 @@ import type { GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-c
|
|
|
6
6
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
7
7
|
import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
8
8
|
import type { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
|
+
import type { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
9
10
|
interface TablePluginOptions {
|
|
10
11
|
tableOptions: PluginConfig;
|
|
11
12
|
breakoutEnabled?: boolean;
|
|
@@ -24,7 +25,8 @@ declare const tablesPlugin: NextEditorPlugin<'table', {
|
|
|
24
25
|
dependencies: [
|
|
25
26
|
typeof analyticsPlugin,
|
|
26
27
|
typeof contentInsertionPlugin,
|
|
27
|
-
typeof widthPlugin
|
|
28
|
+
typeof widthPlugin,
|
|
29
|
+
typeof guidelinePlugin
|
|
28
30
|
];
|
|
29
31
|
}>;
|
|
30
32
|
export default tablesPlugin;
|