@atlaskit/editor-plugin-table 1.2.5 → 1.2.7
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 +14 -0
- package/dist/cjs/plugins/table/commands/selection.js +4 -4
- package/dist/cjs/plugins/table/event-handlers.js +3 -3
- package/dist/cjs/plugins/table/nodeviews/OverflowShadowsObserver.js +5 -6
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +9 -16
- package/dist/cjs/plugins/table/pm-plugins/table-local-id.js +65 -37
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +4 -4
- package/dist/cjs/plugins/table/transforms/delete-rows.js +2 -2
- package/dist/cjs/plugins/table/types.js +8 -8
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +6 -7
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/selection.js +3 -3
- package/dist/es2019/plugins/table/nodeviews/OverflowShadowsObserver.js +5 -7
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +8 -14
- package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +47 -38
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +4 -4
- package/dist/es2019/plugins/table/types.js +6 -6
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +6 -8
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/selection.js +3 -3
- package/dist/esm/plugins/table/event-handlers.js +3 -3
- package/dist/esm/plugins/table/nodeviews/OverflowShadowsObserver.js +5 -6
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +9 -16
- package/dist/esm/plugins/table/pm-plugins/table-local-id.js +66 -38
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-logic.js +4 -4
- package/dist/esm/plugins/table/transforms/delete-rows.js +2 -2
- package/dist/esm/plugins/table/types.js +6 -6
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +6 -7
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +4 -4
- package/src/__tests__/unit/pm-plugins/table-local-id.ts +2 -14
- package/src/plugins/table/pm-plugins/table-local-id.ts +57 -41
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +3 -1
|
@@ -79,12 +79,12 @@ export function reduceSpace(state, amount, ignoreCols = []) {
|
|
|
79
79
|
}
|
|
80
80
|
return state;
|
|
81
81
|
}
|
|
82
|
-
var ColType
|
|
83
|
-
// - is beyond the range, and then not give it back
|
|
84
|
-
(function (ColType) {
|
|
82
|
+
var ColType = /*#__PURE__*/function (ColType) {
|
|
85
83
|
ColType["SOURCE"] = "src";
|
|
86
84
|
ColType["DEST"] = "dest";
|
|
87
|
-
|
|
85
|
+
return ColType;
|
|
86
|
+
}(ColType || {}); // TODO: should handle when destIdx:
|
|
87
|
+
// - is beyond the range, and then not give it back
|
|
88
88
|
function moveSpaceFrom(state, srcIdx, destIdx, amount, useFreeSpace = true) {
|
|
89
89
|
const srcCol = state.cols[srcIdx];
|
|
90
90
|
const destCol = state.cols[destIdx];
|
|
@@ -27,8 +27,7 @@ export const RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
|
|
|
27
27
|
*
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
export let TableDecorations
|
|
31
|
-
(function (TableDecorations) {
|
|
30
|
+
export let TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
32
31
|
TableDecorations["ALL_CONTROLS_HOVER"] = "CONTROLS_HOVER";
|
|
33
32
|
TableDecorations["ROW_CONTROLS_HOVER"] = "ROW_CONTROLS_HOVER";
|
|
34
33
|
TableDecorations["COLUMN_CONTROLS_HOVER"] = "COLUMN_CONTROLS_HOVER";
|
|
@@ -39,7 +38,8 @@ export let TableDecorations;
|
|
|
39
38
|
TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
|
|
40
39
|
TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
|
|
41
40
|
TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
|
|
42
|
-
|
|
41
|
+
return TableDecorations;
|
|
42
|
+
}({});
|
|
43
43
|
export const TableCssClassName = {
|
|
44
44
|
...TableSharedCssClassName,
|
|
45
45
|
COLUMN_CONTROLS: `${tablePrefixSelector}-column-controls`,
|
|
@@ -102,8 +102,8 @@ export const TableCssClassName = {
|
|
|
102
102
|
WITH_RESIZE_LINE: `${tablePrefixSelector}-column-resize-line`,
|
|
103
103
|
WITH_RESIZE_LINE_LAST_COLUMN: `${tablePrefixSelector}-column-resize-line-last-column`
|
|
104
104
|
};
|
|
105
|
-
export let ShadowEvent
|
|
106
|
-
(function (ShadowEvent) {
|
|
105
|
+
export let ShadowEvent = /*#__PURE__*/function (ShadowEvent) {
|
|
107
106
|
ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";
|
|
108
107
|
ShadowEvent["SHOW_AFTER_SHADOW"] = "showAfterShadow";
|
|
109
|
-
|
|
108
|
+
return ShadowEvent;
|
|
109
|
+
}({});
|
|
@@ -115,7 +115,7 @@ export class ContextualMenu extends Component {
|
|
|
115
115
|
if (allowBackgroundColor) {
|
|
116
116
|
var _node$attrs;
|
|
117
117
|
const node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
118
|
-
const background = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
118
|
+
const background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
119
119
|
items.push({
|
|
120
120
|
content: formatMessage(messages.cellBackground),
|
|
121
121
|
value: {
|
|
@@ -83,6 +83,12 @@ class FloatingDeleteButton extends Component {
|
|
|
83
83
|
} = this.props.editorView;
|
|
84
84
|
return clearHoverSelection()(state, dispatch);
|
|
85
85
|
});
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
*
|
|
89
|
+
* @private
|
|
90
|
+
* @memberof FloatingDeleteButton
|
|
91
|
+
*/
|
|
86
92
|
_defineProperty(this, "handleClick", event => {
|
|
87
93
|
event.preventDefault();
|
|
88
94
|
const {
|
|
@@ -207,14 +213,6 @@ class FloatingDeleteButton extends Component {
|
|
|
207
213
|
// Do nothing if doesn't change anything
|
|
208
214
|
return null;
|
|
209
215
|
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
* @private
|
|
215
|
-
* @memberof FloatingDeleteButton
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
216
|
render() {
|
|
219
217
|
const {
|
|
220
218
|
mountPoint,
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,11 +3,11 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
3
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
4
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { RelativeSelectionPos, GapCursorSelection, Side, isSelectionAtStartOfNode, isSelectionAtEndOfNode } from '@atlaskit/editor-common/selection';
|
|
6
|
-
export var TableSelectionDirection
|
|
7
|
-
(function (TableSelectionDirection) {
|
|
6
|
+
export var TableSelectionDirection = /*#__PURE__*/function (TableSelectionDirection) {
|
|
8
7
|
TableSelectionDirection["TopToBottom"] = "TopToBottom";
|
|
9
8
|
TableSelectionDirection["BottomToTop"] = "BottomToTop";
|
|
10
|
-
|
|
9
|
+
return TableSelectionDirection;
|
|
10
|
+
}({});
|
|
11
11
|
export var arrowLeftFromTable = function arrowLeftFromTable(editorSelectionAPI) {
|
|
12
12
|
return function () {
|
|
13
13
|
return function (state, dispatch) {
|
|
@@ -213,8 +213,8 @@ export var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
|
|
|
213
213
|
var _getEditorFeatureFlag = getEditorFeatureFlags(),
|
|
214
214
|
mouseMoveOptimization = _getEditorFeatureFlag.mouseMoveOptimization;
|
|
215
215
|
if (!isResizeHandleDecoration(element) && isCell(element)) {
|
|
216
|
-
var
|
|
217
|
-
if (
|
|
216
|
+
var _positionColumn = getMousePositionHorizontalRelativeByElement(event, mouseMoveOptimization, elementContentRects, RESIZE_HANDLE_AREA_DECORATION_GAP);
|
|
217
|
+
if (_positionColumn !== null) {
|
|
218
218
|
var _state4 = view.state,
|
|
219
219
|
_dispatch5 = view.dispatch;
|
|
220
220
|
var _getPluginState5 = getPluginState(_state4),
|
|
@@ -224,7 +224,7 @@ export var handleMouseMove = function handleMouseMove(getEditorFeatureFlags) {
|
|
|
224
224
|
var cellStartPosition = view.posAtDOM(tableCell, 0);
|
|
225
225
|
var rect = findCellRectClosestToPos(_state4.doc.resolve(cellStartPosition));
|
|
226
226
|
if (rect) {
|
|
227
|
-
var columnEndIndexTarget =
|
|
227
|
+
var columnEndIndexTarget = _positionColumn === 'left' ? rect.left : rect.right;
|
|
228
228
|
var rowIndexTarget = rect.top;
|
|
229
229
|
if (columnEndIndexTarget !== resizeHandleColumnIndex || rowIndexTarget !== resizeHandleRowIndex || !hasResizeHandler({
|
|
230
230
|
target: element,
|
|
@@ -69,6 +69,11 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
69
69
|
_this.shadowsObserved = true;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
+
/**
|
|
73
|
+
* Takes a heightStyle if it can be computed in a less expensive manner,
|
|
74
|
+
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
75
|
+
* reading it from sticky cell
|
|
76
|
+
*/
|
|
72
77
|
_defineProperty(this, "updateStickyShadows", function (stickyRowHeight) {
|
|
73
78
|
var _this$wrapper, _this$wrapper2, _this$wrapper2$parent, _this$wrapper3, _this$wrapper3$parent;
|
|
74
79
|
if (!_this.isSticky) {
|
|
@@ -115,12 +120,6 @@ export var OverflowShadowsObserver = /*#__PURE__*/function () {
|
|
|
115
120
|
var stickyCell = stickyRow && stickyRow.firstElementChild;
|
|
116
121
|
return stickyCell;
|
|
117
122
|
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Takes a heightStyle if it can be computed in a less expensive manner,
|
|
121
|
-
* e.g. bounds on an IntersectionObserverEntry, otherwise proceed with
|
|
122
|
-
* reading it from sticky cell
|
|
123
|
-
*/
|
|
124
123
|
}, {
|
|
125
124
|
key: "dispose",
|
|
126
125
|
value: function dispose() {
|
|
@@ -61,15 +61,20 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
61
61
|
function TableRowNodeView(node, view, getPos, eventDispatcher, getEditorFeatureFlags) {
|
|
62
62
|
var _this = this;
|
|
63
63
|
_classCallCheck(this, TableRowNodeView);
|
|
64
|
+
// this is the sticky header table row
|
|
64
65
|
_defineProperty(this, "colControlsOffset", 0);
|
|
65
66
|
_defineProperty(this, "focused", false);
|
|
66
67
|
_defineProperty(this, "topPosEditorElement", 0);
|
|
67
68
|
_defineProperty(this, "stickyHeadersOptimization", false);
|
|
68
69
|
_defineProperty(this, "sentinels", {});
|
|
70
|
+
/* external events */
|
|
69
71
|
_defineProperty(this, "listening", false);
|
|
70
72
|
_defineProperty(this, "headerRowMouseScrollEnd", debounce(function () {
|
|
71
73
|
_this.dom.classList.remove('no-pointer-events');
|
|
72
74
|
}, HEADER_ROW_SCROLL_RESET_DEBOUNCE_TIMEOUT));
|
|
75
|
+
// When the header is sticky, the header row is set to position: fixed
|
|
76
|
+
// This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
|
|
77
|
+
// This fix sets pointer-events: none on the header row briefly to avoid this behaviour
|
|
73
78
|
_defineProperty(this, "headerRowMouseScroll", throttle(function () {
|
|
74
79
|
if (_this.isSticky) {
|
|
75
80
|
_this.dom.classList.add('no-pointer-events');
|
|
@@ -128,6 +133,7 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
128
133
|
_this.dom.scrollLeft = wrapper.scrollLeft;
|
|
129
134
|
_this.lastTimePainted = performance.now();
|
|
130
135
|
});
|
|
136
|
+
/* receive external events */
|
|
131
137
|
_defineProperty(this, "onTablePluginState", function (state) {
|
|
132
138
|
var tableRef = state.tableRef;
|
|
133
139
|
var focusChanged = false;
|
|
@@ -263,12 +269,14 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
263
269
|
_defineProperty(this, "getWrapperRefTop", function (wrapper) {
|
|
264
270
|
return Math.round(getTop(wrapper)) + _this.getWrapperoffset();
|
|
265
271
|
});
|
|
272
|
+
// TODO: rename!
|
|
266
273
|
_defineProperty(this, "getScrolledTableTop", function (wrapper) {
|
|
267
274
|
return _this.getWrapperRefTop(wrapper) - _this.topPosEditorElement;
|
|
268
275
|
});
|
|
269
276
|
_defineProperty(this, "getCurrentTableTop", function (tree) {
|
|
270
277
|
return _this.getScrolledTableTop(tree.wrapper) + tree.table.clientHeight;
|
|
271
278
|
});
|
|
279
|
+
/* emit external events */
|
|
272
280
|
_defineProperty(this, "padding", 0);
|
|
273
281
|
_defineProperty(this, "top", 0);
|
|
274
282
|
_defineProperty(this, "emitOn", function (top, padding) {
|
|
@@ -316,18 +324,9 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
316
324
|
this.subscribe();
|
|
317
325
|
}
|
|
318
326
|
}
|
|
319
|
-
|
|
320
|
-
/* external events */
|
|
321
|
-
|
|
322
|
-
// When the header is sticky, the header row is set to position: fixed
|
|
323
|
-
// This prevents mouse wheel scrolling on the scroll-parent div when user's mouse is hovering the header row.
|
|
324
|
-
// This fix sets pointer-events: none on the header row briefly to avoid this behaviour
|
|
325
327
|
_createClass(TableRowNodeView, [{
|
|
326
328
|
key: "tree",
|
|
327
|
-
get:
|
|
328
|
-
// this is the sticky header table row
|
|
329
|
-
|
|
330
|
-
function get() {
|
|
329
|
+
get: function get() {
|
|
331
330
|
return getTree(this.dom);
|
|
332
331
|
}
|
|
333
332
|
}, {
|
|
@@ -556,12 +555,6 @@ export var TableRowNodeView = /*#__PURE__*/function () {
|
|
|
556
555
|
}
|
|
557
556
|
return true;
|
|
558
557
|
}
|
|
559
|
-
|
|
560
|
-
/* receive external events */
|
|
561
|
-
|
|
562
|
-
// TODO: rename!
|
|
563
|
-
|
|
564
|
-
/* emit external events */
|
|
565
558
|
}]);
|
|
566
559
|
return TableRowNodeView;
|
|
567
560
|
}();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
2
5
|
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
6
|
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
7
|
/**
|
|
@@ -18,21 +21,12 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
18
21
|
import { PluginKey } from 'prosemirror-state';
|
|
19
22
|
import rafSchedule from 'raf-schd';
|
|
20
23
|
import { uuid } from '@atlaskit/adf-schema';
|
|
21
|
-
import {
|
|
24
|
+
import { stepHasSlice } from '@atlaskit/editor-common/utils';
|
|
22
25
|
var pluginKey = new PluginKey('tableLocalIdPlugin');
|
|
23
26
|
var getPluginState = function getPluginState(state) {
|
|
24
27
|
return state && pluginKey.getState(state);
|
|
25
28
|
};
|
|
26
29
|
|
|
27
|
-
/**
|
|
28
|
-
* Traverses a transaction's steps to see if we're inserting any tables
|
|
29
|
-
*/
|
|
30
|
-
var checkIsAddingTable = function checkIsAddingTable(transaction, nodeType) {
|
|
31
|
-
return transaction.steps.some(function (step) {
|
|
32
|
-
return stepAddsOneOf(step, new Set([nodeType]));
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
30
|
/**
|
|
37
31
|
* Ensures uniqueness of `localId`s on tables being created or edited
|
|
38
32
|
*/
|
|
@@ -125,7 +119,9 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
125
119
|
var modified = false;
|
|
126
120
|
var tr = newState.tr;
|
|
127
121
|
var table = newState.schema.nodes.table;
|
|
128
|
-
var
|
|
122
|
+
var addedTableNodes = new Set();
|
|
123
|
+
var addedTableNodePos = new Map();
|
|
124
|
+
var localIds = new Set();
|
|
129
125
|
transactions.forEach(function (transaction) {
|
|
130
126
|
if (!transaction.docChanged) {
|
|
131
127
|
return;
|
|
@@ -138,38 +134,70 @@ var createPlugin = function createPlugin(dispatch) {
|
|
|
138
134
|
return;
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
/**
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var isTable = node.type === table;
|
|
150
|
-
var localId = node.attrs.localId;
|
|
151
|
-
|
|
152
|
-
// Dealing with a table - make sure it's a unique ID
|
|
153
|
-
if (isTable) {
|
|
154
|
-
if (localId && !idsObserved.has(localId)) {
|
|
155
|
-
idsObserved.add(localId);
|
|
156
|
-
// Also add a localId if it happens to not have one,
|
|
157
|
-
} else if (!localId || idsObserved.has(localId)) {
|
|
158
|
-
modified = true;
|
|
159
|
-
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
160
|
-
localId: uuid.generate()
|
|
161
|
-
}));
|
|
137
|
+
/** Get the tables we are adding and their position */
|
|
138
|
+
var _iterator = _createForOfIteratorHelper(transaction.steps),
|
|
139
|
+
_step;
|
|
140
|
+
try {
|
|
141
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
142
|
+
var step = _step.value;
|
|
143
|
+
if (!stepHasSlice(step)) {
|
|
144
|
+
continue;
|
|
162
145
|
}
|
|
163
|
-
|
|
146
|
+
step.slice.content.descendants(function (node, pos) {
|
|
147
|
+
if (node.type === table) {
|
|
148
|
+
addedTableNodes.add(node);
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
});
|
|
164
152
|
}
|
|
153
|
+
} catch (err) {
|
|
154
|
+
_iterator.e(err);
|
|
155
|
+
} finally {
|
|
156
|
+
_iterator.f();
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
if (!addedTableNodes.size) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
165
162
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
163
|
+
// Get the existing localIds on the page
|
|
164
|
+
newState.doc.descendants(function (node, pos) {
|
|
165
|
+
// Skip if this is position of added table
|
|
166
|
+
if (addedTableNodes.has(node)) {
|
|
167
|
+
addedTableNodePos.set(node, pos);
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (node.type !== table) {
|
|
170
171
|
return true;
|
|
171
|
-
}
|
|
172
|
+
}
|
|
173
|
+
localIds.add(node.attrs.localId);
|
|
174
|
+
|
|
175
|
+
// can't have table within a table
|
|
176
|
+
return false;
|
|
172
177
|
});
|
|
178
|
+
|
|
179
|
+
// If the added nodes have duplicate id, generate a new one
|
|
180
|
+
var _iterator2 = _createForOfIteratorHelper(addedTableNodes),
|
|
181
|
+
_step2;
|
|
182
|
+
try {
|
|
183
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
184
|
+
var node = _step2.value;
|
|
185
|
+
if (!node.attrs.localId || localIds.has(node.attrs.localId)) {
|
|
186
|
+
var pos = addedTableNodePos.get(node);
|
|
187
|
+
if (pos === undefined) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
191
|
+
localId: uuid.generate()
|
|
192
|
+
}));
|
|
193
|
+
modified = true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
} catch (err) {
|
|
197
|
+
_iterator2.e(err);
|
|
198
|
+
} finally {
|
|
199
|
+
_iterator2.f();
|
|
200
|
+
}
|
|
173
201
|
if (modified) {
|
|
174
202
|
return tr;
|
|
175
203
|
}
|
|
@@ -87,12 +87,12 @@ export function reduceSpace(state, amount) {
|
|
|
87
87
|
}
|
|
88
88
|
return state;
|
|
89
89
|
}
|
|
90
|
-
var ColType
|
|
91
|
-
// - is beyond the range, and then not give it back
|
|
92
|
-
(function (ColType) {
|
|
90
|
+
var ColType = /*#__PURE__*/function (ColType) {
|
|
93
91
|
ColType["SOURCE"] = "src";
|
|
94
92
|
ColType["DEST"] = "dest";
|
|
95
|
-
|
|
93
|
+
return ColType;
|
|
94
|
+
}(ColType || {}); // TODO: should handle when destIdx:
|
|
95
|
+
// - is beyond the range, and then not give it back
|
|
96
96
|
function moveSpaceFrom(state, srcIdx, destIdx, amount) {
|
|
97
97
|
var useFreeSpace = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
98
98
|
var srcCol = state.cols[srcIdx];
|
|
@@ -36,7 +36,7 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
36
36
|
var _loop = function _loop(rowIndex) {
|
|
37
37
|
var rowCells = [];
|
|
38
38
|
var row = table.node.child(rowIndex);
|
|
39
|
-
var _loop2 = function _loop2(
|
|
39
|
+
var _loop2 = function _loop2() {
|
|
40
40
|
var cellPos = map.map[rowIndex * map.width + colIndex];
|
|
41
41
|
var cell = table.node.nodeAt(cellPos);
|
|
42
42
|
if (!cell) {
|
|
@@ -90,7 +90,7 @@ export var deleteRows = function deleteRows(rect) {
|
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
92
|
for (var colIndex = 0; colIndex < map.width; colIndex++) {
|
|
93
|
-
var _ret = _loop2(
|
|
93
|
+
var _ret = _loop2();
|
|
94
94
|
if (_ret === "continue") continue;
|
|
95
95
|
}
|
|
96
96
|
if (rowCells.length) {
|
|
@@ -30,8 +30,7 @@ export var RESIZE_HANDLE_AREA_DECORATION_GAP = 30;
|
|
|
30
30
|
*
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
|
-
export var TableDecorations
|
|
34
|
-
(function (TableDecorations) {
|
|
33
|
+
export var TableDecorations = /*#__PURE__*/function (TableDecorations) {
|
|
35
34
|
TableDecorations["ALL_CONTROLS_HOVER"] = "CONTROLS_HOVER";
|
|
36
35
|
TableDecorations["ROW_CONTROLS_HOVER"] = "ROW_CONTROLS_HOVER";
|
|
37
36
|
TableDecorations["COLUMN_CONTROLS_HOVER"] = "COLUMN_CONTROLS_HOVER";
|
|
@@ -42,7 +41,8 @@ export var TableDecorations;
|
|
|
42
41
|
TableDecorations["COLUMN_RESIZING_HANDLE"] = "COLUMN_RESIZING_HANDLE";
|
|
43
42
|
TableDecorations["COLUMN_RESIZING_HANDLE_LINE"] = "COLUMN_RESIZING_HANDLE_LINE";
|
|
44
43
|
TableDecorations["LAST_CELL_ELEMENT"] = "LAST_CELL_ELEMENT";
|
|
45
|
-
|
|
44
|
+
return TableDecorations;
|
|
45
|
+
}({});
|
|
46
46
|
export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssClassName), {}, {
|
|
47
47
|
COLUMN_CONTROLS: "".concat(tablePrefixSelector, "-column-controls"),
|
|
48
48
|
COLUMN_CONTROLS_DECORATIONS: "".concat(tablePrefixSelector, "-column-controls-decoration"),
|
|
@@ -104,8 +104,8 @@ export var TableCssClassName = _objectSpread(_objectSpread({}, TableSharedCssCla
|
|
|
104
104
|
WITH_RESIZE_LINE: "".concat(tablePrefixSelector, "-column-resize-line"),
|
|
105
105
|
WITH_RESIZE_LINE_LAST_COLUMN: "".concat(tablePrefixSelector, "-column-resize-line-last-column")
|
|
106
106
|
});
|
|
107
|
-
export var ShadowEvent
|
|
108
|
-
(function (ShadowEvent) {
|
|
107
|
+
export var ShadowEvent = /*#__PURE__*/function (ShadowEvent) {
|
|
109
108
|
ShadowEvent["SHOW_BEFORE_SHADOW"] = "showBeforeShadow";
|
|
110
109
|
ShadowEvent["SHOW_AFTER_SHADOW"] = "showAfterShadow";
|
|
111
|
-
|
|
110
|
+
return ShadowEvent;
|
|
111
|
+
}({});
|
|
@@ -121,7 +121,7 @@ export var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
121
121
|
if (allowBackgroundColor) {
|
|
122
122
|
var _node$attrs;
|
|
123
123
|
var node = isOpen && targetCellPosition ? state.doc.nodeAt(targetCellPosition) : null;
|
|
124
|
-
var background = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
124
|
+
var background = hexToEditorBackgroundPaletteColor((node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff');
|
|
125
125
|
items.push({
|
|
126
126
|
content: formatMessage(messages.cellBackground),
|
|
127
127
|
value: {
|
|
@@ -95,6 +95,12 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
95
95
|
dispatch = _this$props$editorVie2.dispatch;
|
|
96
96
|
return clearHoverSelection()(state, dispatch);
|
|
97
97
|
});
|
|
98
|
+
/**
|
|
99
|
+
*
|
|
100
|
+
*
|
|
101
|
+
* @private
|
|
102
|
+
* @memberof FloatingDeleteButton
|
|
103
|
+
*/
|
|
98
104
|
_defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
|
|
99
105
|
event.preventDefault();
|
|
100
106
|
var editorAnalyticsAPI = _this.props.editorAnalyticsAPI;
|
|
@@ -277,13 +283,6 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
277
283
|
// Do nothing if doesn't change anything
|
|
278
284
|
return null;
|
|
279
285
|
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* @private
|
|
285
|
-
* @memberof FloatingDeleteButton
|
|
286
|
-
*/
|
|
287
286
|
}]);
|
|
288
287
|
return FloatingDeleteButton;
|
|
289
288
|
}(Component);
|
|
@@ -7,7 +7,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
9
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
13
|
import React, { Component } from 'react';
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@atlaskit/adf-schema": "^25.5.0",
|
|
22
|
-
"@atlaskit/editor-common": "^
|
|
22
|
+
"@atlaskit/editor-common": "^73.0.0",
|
|
23
23
|
"@atlaskit/editor-palette": "1.3.0",
|
|
24
24
|
"@atlaskit/editor-shared-styles": "^2.3.0",
|
|
25
25
|
"@atlaskit/editor-tables": "^2.2.0",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@atlaskit/analytics-next": "^9.0.0",
|
|
54
54
|
"@atlaskit/button": "^16.6.0",
|
|
55
|
-
"@atlaskit/editor-core": "^182.
|
|
56
|
-
"@atlaskit/editor-plugin-feature-flags": "^0.0.
|
|
55
|
+
"@atlaskit/editor-core": "^182.2.0",
|
|
56
|
+
"@atlaskit/editor-plugin-feature-flags": "^0.0.4",
|
|
57
57
|
"@atlaskit/editor-test-helpers": "^18.2.0",
|
|
58
58
|
"@atlaskit/link-provider": "^1.5.0",
|
|
59
59
|
"@atlaskit/logo": "^13.13.0",
|
|
@@ -347,23 +347,11 @@ describe('table local id plugin', () => {
|
|
|
347
347
|
editorView.updateState(state3);
|
|
348
348
|
dispatchPasteEvent(editorView, { html: dom.innerHTML, plain: text });
|
|
349
349
|
|
|
350
|
-
/**
|
|
351
|
-
* The end result order of IDs that we'll now observe is the following:
|
|
352
|
-
* 1. flooFirst
|
|
353
|
-
* 2. flooThird
|
|
354
|
-
* 3. flooSecond
|
|
355
|
-
*
|
|
356
|
-
* This is because we had `flooFirst` in our clipboard. We've now pasted
|
|
357
|
-
* it into the expand, so that becomes the first observed instance of
|
|
358
|
-
* the table. The "third" ID (second unique regeneration) then gets
|
|
359
|
-
* replaced in the first layout column.
|
|
360
|
-
*
|
|
361
|
-
*/
|
|
362
350
|
expect(editorView.state.doc).toEqualDocument(
|
|
363
351
|
doc(
|
|
364
|
-
expand({ title: '' })(generateTableWithLocalId(
|
|
352
|
+
expand({ title: '' })(generateTableWithLocalId(flooThird)),
|
|
365
353
|
layoutSection(
|
|
366
|
-
layoutColumn({ width: 50 })(generateTableWithLocalId(
|
|
354
|
+
layoutColumn({ width: 50 })(generateTableWithLocalId(flooFirst)),
|
|
367
355
|
layoutColumn({ width: 50 })(generateTableWithLocalId(flooSecond)),
|
|
368
356
|
),
|
|
369
357
|
p(),
|