@atlaskit/editor-plugin-table 5.1.0 → 5.2.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 +6 -0
- package/dist/cjs/plugins/table/index.js +3 -2
- package/dist/cjs/plugins/table/nodeviews/TableCell.js +111 -0
- package/dist/cjs/plugins/table/nodeviews/TableNodeViewBase.js +30 -0
- package/dist/cjs/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +313 -307
- package/dist/cjs/plugins/table/pm-plugins/main.js +16 -13
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/index.js +1 -8
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/cjs/plugins/table/utils/dom.js +31 -1
- package/dist/cjs/plugins/table/utils/index.js +12 -0
- package/dist/cjs/plugins/table/utils/nodes.js +31 -7
- package/dist/es2019/plugins/table/index.js +3 -2
- package/dist/es2019/plugins/table/nodeviews/{tableCell.js → TableCell.js} +28 -24
- package/dist/es2019/plugins/table/nodeviews/TableNodeViewBase.js +22 -0
- package/dist/es2019/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +273 -284
- package/dist/es2019/plugins/table/pm-plugins/main.js +8 -8
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/es2019/plugins/table/utils/dom.js +30 -0
- package/dist/es2019/plugins/table/utils/index.js +1 -1
- package/dist/es2019/plugins/table/utils/nodes.js +16 -0
- package/dist/esm/plugins/table/index.js +3 -2
- package/dist/esm/plugins/table/nodeviews/TableCell.js +105 -0
- package/dist/esm/plugins/table/nodeviews/TableNodeViewBase.js +24 -0
- package/dist/esm/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.js → nodeviews/TableRow.js} +314 -307
- package/dist/esm/plugins/table/pm-plugins/main.js +16 -13
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/index.js +1 -2
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -9
- package/dist/esm/plugins/table/utils/dom.js +30 -0
- package/dist/esm/plugins/table/utils/index.js +1 -1
- package/dist/esm/plugins/table/utils/nodes.js +24 -0
- package/dist/types/plugins/table/nodeviews/TableCell.d.ts +13 -0
- package/dist/types/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
- package/dist/types/plugins/table/nodeviews/TableRow.d.ts +60 -0
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types/plugins/table/types.d.ts +1 -0
- package/dist/types/plugins/table/utils/dom.d.ts +6 -0
- package/dist/types/plugins/table/utils/index.d.ts +1 -1
- package/dist/types/plugins/table/utils/nodes.d.ts +12 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableCell.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableNodeViewBase.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableRow.d.ts +60 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +12 -2
- package/package.json +1 -1
- package/src/__tests__/unit/nodeviews/cell.ts +2 -2
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -148
- package/src/plugins/table/index.tsx +2 -0
- package/src/plugins/table/nodeviews/{tableCell.tsx → TableCell.ts} +41 -46
- package/src/plugins/table/nodeviews/TableNodeViewBase.ts +32 -0
- package/src/plugins/table/{pm-plugins/sticky-headers/nodeviews/tableRow.ts → nodeviews/TableRow.ts} +193 -246
- package/src/plugins/table/pm-plugins/main.ts +10 -19
- package/src/plugins/table/pm-plugins/sticky-headers/index.ts +0 -1
- package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -9
- package/src/plugins/table/types.ts +2 -0
- package/src/plugins/table/utils/dom.ts +38 -0
- package/src/plugins/table/utils/index.ts +2 -0
- package/src/plugins/table/utils/nodes.ts +30 -2
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +0 -99
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -35
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
- package/dist/esm/plugins/table/nodeviews/tableCell.js +0 -93
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.js +0 -29
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +0 -17
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
- package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +0 -17
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -73
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.ts +0 -37
|
@@ -18,7 +18,8 @@ var _commands = require("../commands");
|
|
|
18
18
|
var _misc = require("../commands/misc");
|
|
19
19
|
var _eventHandlers = require("../event-handlers");
|
|
20
20
|
var _table = require("../nodeviews/table");
|
|
21
|
-
var
|
|
21
|
+
var _TableCell = _interopRequireDefault(require("../nodeviews/TableCell"));
|
|
22
|
+
var _TableRow = _interopRequireDefault(require("../nodeviews/TableRow"));
|
|
22
23
|
var _plugin = require("../pm-plugins/decorations/plugin");
|
|
23
24
|
var _transforms2 = require("../transforms");
|
|
24
25
|
var _types = require("../types");
|
|
@@ -29,7 +30,7 @@ var _pluginFactory = require("./plugin-factory");
|
|
|
29
30
|
var _pluginKey = require("./plugin-key");
|
|
30
31
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
32
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
-
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
33
|
+
var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig, getEditorContainerWidth, getEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthModeEnabled, tableResizingEnabled, previousFullWidthModeEnabled, dragAndDropEnabled, editorAnalyticsAPI, pluginInjectionApi) {
|
|
33
34
|
var _window;
|
|
34
35
|
var state = (0, _pluginFactory.createPluginState)(dispatch, _objectSpread(_objectSpread({
|
|
35
36
|
pluginConfig: pluginConfig,
|
|
@@ -40,7 +41,8 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
40
41
|
wasFullWidthModeEnabled: previousFullWidthModeEnabled,
|
|
41
42
|
isTableResizingEnabled: tableResizingEnabled,
|
|
42
43
|
isHeaderRowEnabled: !!pluginConfig.allowHeaderRow,
|
|
43
|
-
isHeaderColumnEnabled: false
|
|
44
|
+
isHeaderColumnEnabled: false,
|
|
45
|
+
isDragAndDropEnabled: dragAndDropEnabled
|
|
44
46
|
}, _defaultTableSelection.defaultTableSelection), {}, {
|
|
45
47
|
getIntl: getIntl
|
|
46
48
|
}));
|
|
@@ -53,14 +55,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
53
55
|
elementContentRects[entry.target.id] = entry.contentRect;
|
|
54
56
|
});
|
|
55
57
|
}) : undefined;
|
|
56
|
-
var tableCellNodeview = {
|
|
57
|
-
tableCell: function tableCell(node, view, getPos) {
|
|
58
|
-
return new _tableCell.default(node, view, getPos, observer);
|
|
59
|
-
},
|
|
60
|
-
tableHeader: function tableHeader(node, view, getPos) {
|
|
61
|
-
return new _tableCell.default(node, view, getPos, observer);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
58
|
|
|
65
59
|
// Used to prevent invalid table cell spans being reported more than once per editor/document
|
|
66
60
|
var invalidTableIds = [];
|
|
@@ -236,11 +230,20 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatchAnalytic
|
|
|
236
230
|
}
|
|
237
231
|
return false;
|
|
238
232
|
},
|
|
239
|
-
nodeViews:
|
|
233
|
+
nodeViews: {
|
|
240
234
|
table: function table(node, view, getPos) {
|
|
241
235
|
return (0, _table.createTableView)(node, view, getPos, portalProviderAPI, eventDispatcher, getEditorContainerWidth, getEditorFeatureFlags, pluginInjectionApi);
|
|
236
|
+
},
|
|
237
|
+
tableRow: function tableRow(node, view, getPos) {
|
|
238
|
+
return new _TableRow.default(node, view, getPos, eventDispatcher);
|
|
239
|
+
},
|
|
240
|
+
tableCell: function tableCell(node, view, getPos) {
|
|
241
|
+
return new _TableCell.default(node, view, getPos, eventDispatcher, observer);
|
|
242
|
+
},
|
|
243
|
+
tableHeader: function tableHeader(node, view, getPos) {
|
|
244
|
+
return new _TableCell.default(node, view, getPos, eventDispatcher, observer);
|
|
242
245
|
}
|
|
243
|
-
}
|
|
246
|
+
},
|
|
244
247
|
handleDOMEvents: {
|
|
245
248
|
focus: _eventHandlers.handleFocus,
|
|
246
249
|
blur: _eventHandlers.handleBlur,
|
|
@@ -3,12 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "TableRowNodeView", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _tableRow.TableRowNodeView;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
6
|
Object.defineProperty(exports, "createPlugin", {
|
|
13
7
|
enumerable: true,
|
|
14
8
|
get: function get() {
|
|
@@ -42,5 +36,4 @@ Object.defineProperty(exports, "updateStickyState", {
|
|
|
42
36
|
var _plugin = require("./plugin");
|
|
43
37
|
var _pluginKey = require("./plugin-key");
|
|
44
38
|
var _util = require("./util");
|
|
45
|
-
var _commands = require("./commands");
|
|
46
|
-
var _tableRow = require("./nodeviews/tableRow");
|
|
39
|
+
var _commands = require("./commands");
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createPlugin = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _tableRow = require("./nodeviews/tableRow");
|
|
9
8
|
var _pluginKey = require("./plugin-key");
|
|
10
9
|
var _pluginState = require("./plugin-state");
|
|
11
10
|
var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventDispatcher) {
|
|
@@ -15,13 +14,6 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, eventD
|
|
|
15
14
|
var getEditorFeatureFlags = arguments.length > 3 ? arguments[3] : undefined;
|
|
16
15
|
return new _safePlugin.SafePlugin({
|
|
17
16
|
state: (0, _pluginState.createPluginState)(dispatch, initialState),
|
|
18
|
-
key: _pluginKey.pluginKey
|
|
19
|
-
props: {
|
|
20
|
-
nodeViews: {
|
|
21
|
-
tableRow: function tableRow(node, view, getPos) {
|
|
22
|
-
return new _tableRow.TableRowNodeView(node, view, getPos, eventDispatcher);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
17
|
+
key: _pluginKey.pluginKey
|
|
26
18
|
});
|
|
27
19
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.updateResizeHandles = exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = void 0;
|
|
6
|
+
exports.updateResizeHandles = exports.isTableControlsButton = exports.isTableContainerOrWrapper = exports.isRowControlsButton = exports.isResizeHandleDecoration = exports.isInsertRowButton = exports.isCornerButton = exports.isColumnControlsDecorations = exports.isCell = exports.hasResizeHandler = exports.getTree = exports.getTop = exports.getMousePositionVerticalRelativeByElement = exports.getMousePositionHorizontalRelativeByElement = exports.getColumnOrRowIndex = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
8
|
var _types = require("../types");
|
|
9
9
|
var _consts = require("../ui/consts");
|
|
@@ -156,4 +156,34 @@ var hasResizeHandler = exports.hasResizeHandler = function hasResizeHandler(_ref
|
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
158
|
return true;
|
|
159
|
+
};
|
|
160
|
+
var getTree = exports.getTree = function getTree(tr) {
|
|
161
|
+
// pm renders into tbody, owned by react
|
|
162
|
+
var tbody = tr.parentElement;
|
|
163
|
+
if (!tbody) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// rendered by react
|
|
168
|
+
var table = tbody.parentElement;
|
|
169
|
+
if (!table) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// rendered by react
|
|
174
|
+
var wrapper = table.parentElement;
|
|
175
|
+
if (!wrapper) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
wrapper: wrapper,
|
|
180
|
+
table: table
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
var getTop = exports.getTop = function getTop(element) {
|
|
184
|
+
var _element$getBoundingC, _element$getBoundingC2;
|
|
185
|
+
if (!element || element instanceof Window) {
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
return (_element$getBoundingC = element === null || element === void 0 || (_element$getBoundingC2 = element.getBoundingClientRect) === null || _element$getBoundingC2 === void 0 || (_element$getBoundingC2 = _element$getBoundingC2.call(element)) === null || _element$getBoundingC2 === void 0 ? void 0 : _element$getBoundingC2.top) !== null && _element$getBoundingC !== void 0 ? _element$getBoundingC : 0;
|
|
159
189
|
};
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "anyChildCellMergedAcrossRow", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _nodes.anyChildCellMergedAcrossRow;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "checkIfHeaderColumnEnabled", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -285,6 +291,12 @@ Object.defineProperty(exports, "removeTableFromLastChild", {
|
|
|
285
291
|
return _paste.removeTableFromLastChild;
|
|
286
292
|
}
|
|
287
293
|
});
|
|
294
|
+
Object.defineProperty(exports, "supportedHeaderRow", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
get: function get() {
|
|
297
|
+
return _nodes.supportedHeaderRow;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
288
300
|
Object.defineProperty(exports, "tablesHaveDifferentColumnWidths", {
|
|
289
301
|
enumerable: true,
|
|
290
302
|
get: function get() {
|
|
@@ -4,11 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.isTableNested = exports.isLayoutSupported = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = void 0;
|
|
7
|
+
exports.tablesHaveDifferentNoOfColumns = exports.tablesHaveDifferentColumnWidths = exports.supportedHeaderRow = exports.isTableNested = exports.isLayoutSupported = exports.isIsolating = exports.getTableWidth = exports.containsHeaderRow = exports.containsHeaderColumn = exports.checkIfNumberColumnEnabled = exports.checkIfHeaderRowEnabled = exports.checkIfHeaderColumnEnabled = exports.anyChildCellMergedAcrossRow = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _utils = require("@atlaskit/editor-
|
|
9
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
10
11
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
|
11
|
-
var
|
|
12
|
+
var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
12
13
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
13
14
|
var isIsolating = exports.isIsolating = function isIsolating(node) {
|
|
14
15
|
return !!node.type.spec.isolating;
|
|
@@ -45,13 +46,13 @@ var containsHeaderRow = exports.containsHeaderRow = function containsHeaderRow(t
|
|
|
45
46
|
return true;
|
|
46
47
|
};
|
|
47
48
|
var checkIfHeaderColumnEnabled = exports.checkIfHeaderColumnEnabled = function checkIfHeaderColumnEnabled(selection) {
|
|
48
|
-
return filterNearSelection(selection,
|
|
49
|
+
return filterNearSelection(selection, _utils3.findTable, containsHeaderColumn, false);
|
|
49
50
|
};
|
|
50
51
|
var checkIfHeaderRowEnabled = exports.checkIfHeaderRowEnabled = function checkIfHeaderRowEnabled(selection) {
|
|
51
|
-
return filterNearSelection(selection,
|
|
52
|
+
return filterNearSelection(selection, _utils3.findTable, containsHeaderRow, false);
|
|
52
53
|
};
|
|
53
54
|
var checkIfNumberColumnEnabled = exports.checkIfNumberColumnEnabled = function checkIfNumberColumnEnabled(selection) {
|
|
54
|
-
return filterNearSelection(selection,
|
|
55
|
+
return filterNearSelection(selection, _utils3.findTable, function (table) {
|
|
55
56
|
return !!table.attrs.isNumberColumnEnabled;
|
|
56
57
|
}, false);
|
|
57
58
|
};
|
|
@@ -63,7 +64,7 @@ var isLayoutSupported = exports.isLayoutSupported = function isLayoutSupported(s
|
|
|
63
64
|
bodiedExtension = _state$schema$nodes.bodiedExtension,
|
|
64
65
|
layoutSection = _state$schema$nodes.layoutSection,
|
|
65
66
|
expand = _state$schema$nodes.expand;
|
|
66
|
-
return !(0,
|
|
67
|
+
return !(0, _utils2.hasParentNodeOfType)([expand, layoutSection, bodiedExtension])(state.selection) && !!permittedLayouts && (permittedLayouts === 'all' || permittedLayouts.indexOf('default') > -1 && permittedLayouts.indexOf('wide') > -1 && permittedLayouts.indexOf('full-width') > -1);
|
|
67
68
|
};
|
|
68
69
|
var getTableWidth = exports.getTableWidth = function getTableWidth(node) {
|
|
69
70
|
return getTableWidths(node).reduce(function (acc, current) {
|
|
@@ -111,4 +112,27 @@ var isTableNested = exports.isTableNested = function isTableNested(state) {
|
|
|
111
112
|
var parent = state.doc.resolve(tablePos).parent;
|
|
112
113
|
var nodeTypes = state.schema.nodes;
|
|
113
114
|
return parent.type === nodeTypes.layoutColumn || parent.type === nodeTypes.expand || parent.type === nodeTypes.bodiedExtension;
|
|
115
|
+
};
|
|
116
|
+
var anyChildCellMergedAcrossRow = exports.anyChildCellMergedAcrossRow = function anyChildCellMergedAcrossRow(node) {
|
|
117
|
+
return (0, _utils.mapChildren)(node, function (child) {
|
|
118
|
+
return child.attrs.rowspan || 0;
|
|
119
|
+
}).some(function (rowspan) {
|
|
120
|
+
return rowspan > 1;
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Check if a given node is a header row with this definition:
|
|
126
|
+
* - all children are tableHeader cells
|
|
127
|
+
* - no table cells have been have merged with other table row cells
|
|
128
|
+
*
|
|
129
|
+
* @param node ProseMirror node
|
|
130
|
+
* @return boolean if it meets definition
|
|
131
|
+
*/
|
|
132
|
+
var supportedHeaderRow = exports.supportedHeaderRow = function supportedHeaderRow(node) {
|
|
133
|
+
var allHeaders = (0, _utils.mapChildren)(node, function (child) {
|
|
134
|
+
return child.type.name === 'tableHeader';
|
|
135
|
+
}).every(Boolean);
|
|
136
|
+
var someMerged = anyChildCellMergedAcrossRow(node);
|
|
137
|
+
return allHeaders && !someMerged;
|
|
114
138
|
};
|
|
@@ -103,9 +103,10 @@ const tablesPlugin = ({
|
|
|
103
103
|
tableResizingEnabled,
|
|
104
104
|
breakoutEnabled,
|
|
105
105
|
tableOptions,
|
|
106
|
-
getEditorFeatureFlags
|
|
106
|
+
getEditorFeatureFlags,
|
|
107
|
+
dragAndDropEnabled
|
|
107
108
|
} = options || {};
|
|
108
|
-
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, editorAnalyticsAPI, api);
|
|
109
|
+
return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
|
|
109
110
|
}
|
|
110
111
|
}, {
|
|
111
112
|
name: 'tablePMColResizing',
|
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
import uuid from 'uuid';
|
|
2
2
|
import { getCellAttrs, getCellDomAttrs } from '@atlaskit/adf-schema';
|
|
3
|
-
import {
|
|
3
|
+
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
4
|
+
import TableNodeView from './TableNodeViewBase';
|
|
4
5
|
const DEFAULT_COL_SPAN = 1;
|
|
5
6
|
const DEFAULT_ROW_SPAN = 1;
|
|
6
|
-
export default class
|
|
7
|
-
constructor(node, view, getPos, observer) {
|
|
8
|
-
|
|
9
|
-
this.
|
|
7
|
+
export default class TableCell extends TableNodeView {
|
|
8
|
+
constructor(node, view, getPos, eventDispatcher, observer) {
|
|
9
|
+
super(node, view, getPos, eventDispatcher);
|
|
10
|
+
this.observer = observer;
|
|
10
11
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} =
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.contentDOM = contentDOM;
|
|
12
|
+
pluginConfig,
|
|
13
|
+
isDragAndDropEnabled
|
|
14
|
+
} = getPluginState(view.state);
|
|
15
|
+
this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
16
|
+
this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
17
17
|
if (observer) {
|
|
18
18
|
this.contentDOM.id = uuid();
|
|
19
|
-
this.observer = observer;
|
|
20
19
|
observer.observe(this.contentDOM);
|
|
21
20
|
}
|
|
22
21
|
}
|
|
22
|
+
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
|
|
27
|
+
update(node) {
|
|
28
|
+
const didUpdate = this.updateNodeView(node);
|
|
29
|
+
if (didUpdate) {
|
|
30
|
+
this.node = node;
|
|
31
|
+
}
|
|
32
|
+
return didUpdate;
|
|
33
|
+
}
|
|
34
|
+
destroy() {
|
|
35
|
+
if (this.observer) {
|
|
36
|
+
this.observer.unobserve(this.contentDOM);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
23
39
|
updateNodeView(node) {
|
|
24
40
|
if (this.node.type !== node.type) {
|
|
25
41
|
return false;
|
|
@@ -52,16 +68,4 @@ export default class TableCellNodeView {
|
|
|
52
68
|
}
|
|
53
69
|
return false;
|
|
54
70
|
}
|
|
55
|
-
update(node) {
|
|
56
|
-
const didUpdate = this.updateNodeView(node);
|
|
57
|
-
if (didUpdate) {
|
|
58
|
-
this.node = node;
|
|
59
|
-
}
|
|
60
|
-
return didUpdate;
|
|
61
|
-
}
|
|
62
|
-
destroy() {
|
|
63
|
-
if (this.observer) {
|
|
64
|
-
this.observer.unobserve(this.contentDOM);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
71
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
export default class TableNodeView {
|
|
3
|
+
/**
|
|
4
|
+
* @constructor
|
|
5
|
+
*/
|
|
6
|
+
constructor(node, view, getPos, eventDispatcher) {
|
|
7
|
+
this.node = node;
|
|
8
|
+
this.view = view;
|
|
9
|
+
this.getPos = getPos;
|
|
10
|
+
this.eventDispatcher = eventDispatcher;
|
|
11
|
+
const {
|
|
12
|
+
dom,
|
|
13
|
+
contentDOM
|
|
14
|
+
} = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node));
|
|
15
|
+
this.dom = dom;
|
|
16
|
+
this.contentDOM = contentDOM;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Variables
|
|
21
|
+
*/
|
|
22
|
+
}
|