@atlaskit/editor-plugin-table 5.1.0 → 5.2.1
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 +12 -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} +363 -303
- 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/types.js +4 -1
- 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} +324 -280
- 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/types.js +5 -1
- 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} +364 -303
- 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/types.js +5 -1
- 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 +62 -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 +15 -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 +62 -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 +15 -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 +4 -2
- 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} +246 -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 +18 -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/tsconfig.app.json +6 -0
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41471](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41471) [`94c3351cece`](https://bitbucket.org/atlassian/atlassian-frontend/commits/94c3351cece) - Table row nodeviews will now be set as drop targets when the DnD FF is enabled
|
|
8
|
+
|
|
9
|
+
## 5.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#41423](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41423) [`d0acefc12f6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d0acefc12f6) - The nodeviews are now all located in a single space rather then being spread out amounst other sub-plugins. Only the main pm-plugin should add one nodeview per node.
|
|
14
|
+
|
|
3
15
|
## 5.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -112,8 +112,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
112
112
|
tableResizingEnabled = _ref3.tableResizingEnabled,
|
|
113
113
|
breakoutEnabled = _ref3.breakoutEnabled,
|
|
114
114
|
tableOptions = _ref3.tableOptions,
|
|
115
|
-
getEditorFeatureFlags = _ref3.getEditorFeatureFlags
|
|
116
|
-
|
|
115
|
+
getEditorFeatureFlags = _ref3.getEditorFeatureFlags,
|
|
116
|
+
dragAndDropEnabled = _ref3.dragAndDropEnabled;
|
|
117
|
+
return (0, _main.createPlugin)(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, (0, _createPluginConfig.pluginConfig)(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, getIntl, breakoutEnabled, fullWidthEnabled, tableResizingEnabled, wasFullWidthEnabled, dragAndDropEnabled, editorAnalyticsAPI, api);
|
|
117
118
|
}
|
|
118
119
|
}, {
|
|
119
120
|
name: 'tablePMColResizing',
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _uuid = _interopRequireDefault(require("uuid"));
|
|
15
|
+
var _adfSchema = require("@atlaskit/adf-schema");
|
|
16
|
+
var _pluginFactory = require("../pm-plugins/plugin-factory");
|
|
17
|
+
var _TableNodeViewBase = _interopRequireDefault(require("./TableNodeViewBase"));
|
|
18
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
19
|
+
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; } }
|
|
20
|
+
var DEFAULT_COL_SPAN = 1;
|
|
21
|
+
var DEFAULT_ROW_SPAN = 1;
|
|
22
|
+
var TableCell = exports.default = /*#__PURE__*/function (_ref) {
|
|
23
|
+
(0, _inherits2.default)(TableCell, _ref);
|
|
24
|
+
var _super = _createSuper(TableCell);
|
|
25
|
+
function TableCell(node, view, getPos, eventDispatcher, observer) {
|
|
26
|
+
var _this;
|
|
27
|
+
(0, _classCallCheck2.default)(this, TableCell);
|
|
28
|
+
_this = _super.call(this, node, view, getPos, eventDispatcher);
|
|
29
|
+
_this.observer = observer;
|
|
30
|
+
var _getPluginState = (0, _pluginFactory.getPluginState)(view.state),
|
|
31
|
+
pluginConfig = _getPluginState.pluginConfig,
|
|
32
|
+
isDragAndDropEnabled = _getPluginState.isDragAndDropEnabled;
|
|
33
|
+
_this.isStickyHeaderEnabled = !!pluginConfig.stickyHeaders;
|
|
34
|
+
_this.isDragAndDropEnabled = !!isDragAndDropEnabled;
|
|
35
|
+
if (observer) {
|
|
36
|
+
_this.contentDOM.id = (0, _uuid.default)();
|
|
37
|
+
observer.observe(_this.contentDOM);
|
|
38
|
+
}
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
(0, _createClass2.default)(TableCell, [{
|
|
46
|
+
key: "update",
|
|
47
|
+
value: function update(node) {
|
|
48
|
+
var didUpdate = this.updateNodeView(node);
|
|
49
|
+
if (didUpdate) {
|
|
50
|
+
this.node = node;
|
|
51
|
+
}
|
|
52
|
+
return didUpdate;
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "destroy",
|
|
56
|
+
value: function destroy() {
|
|
57
|
+
if (this.observer) {
|
|
58
|
+
this.observer.unobserve(this.contentDOM);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "updateNodeView",
|
|
63
|
+
value: function updateNodeView(node) {
|
|
64
|
+
var _this2 = this;
|
|
65
|
+
if (this.node.type !== node.type) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
var attrs = (0, _adfSchema.getCellDomAttrs)(this.node);
|
|
69
|
+
var nextAttrs = (0, _adfSchema.getCellDomAttrs)(node);
|
|
70
|
+
var _getCellAttrs = (0, _adfSchema.getCellAttrs)(this.dom),
|
|
71
|
+
colspan = _getCellAttrs.colspan,
|
|
72
|
+
rowspan = _getCellAttrs.rowspan;
|
|
73
|
+
|
|
74
|
+
// need to rerender when colspan/rowspan in dom are different from the node attrs
|
|
75
|
+
// this can happen when undoing merge cells
|
|
76
|
+
if (colspan !== (node.attrs.colspan || DEFAULT_COL_SPAN) || rowspan !== (node.attrs.rowspan || DEFAULT_ROW_SPAN)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// added + changed attributes
|
|
81
|
+
var addedAttrs = Object.entries(nextAttrs).filter(function (_ref2) {
|
|
82
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
83
|
+
key = _ref3[0],
|
|
84
|
+
value = _ref3[1];
|
|
85
|
+
return attrs[key] !== value;
|
|
86
|
+
});
|
|
87
|
+
var removedAttrs = Object.keys(attrs).filter(function (key) {
|
|
88
|
+
return !nextAttrs.hasOwnProperty(key);
|
|
89
|
+
});
|
|
90
|
+
if (addedAttrs.length || removedAttrs.length) {
|
|
91
|
+
addedAttrs.forEach(function (_ref4) {
|
|
92
|
+
var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
93
|
+
key = _ref5[0],
|
|
94
|
+
value = _ref5[1];
|
|
95
|
+
return _this2.dom.setAttribute(key, value || '');
|
|
96
|
+
});
|
|
97
|
+
removedAttrs.forEach(function (key) {
|
|
98
|
+
return _this2.dom.removeAttribute(key);
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Return true to not re-render this node view
|
|
104
|
+
if (this.node.sameMarkup(node)) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
}]);
|
|
110
|
+
return TableCell;
|
|
111
|
+
}(_TableNodeViewBase.default);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
|
+
var TableNodeView = exports.default = /*#__PURE__*/(0, _createClass2.default)(
|
|
12
|
+
/**
|
|
13
|
+
* @constructor
|
|
14
|
+
*/
|
|
15
|
+
function TableNodeView(node, view, getPos, eventDispatcher) {
|
|
16
|
+
(0, _classCallCheck2.default)(this, TableNodeView);
|
|
17
|
+
this.node = node;
|
|
18
|
+
this.view = view;
|
|
19
|
+
this.getPos = getPos;
|
|
20
|
+
this.eventDispatcher = eventDispatcher;
|
|
21
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, node.type.spec.toDOM(node)),
|
|
22
|
+
dom = _DOMSerializer$render.dom,
|
|
23
|
+
contentDOM = _DOMSerializer$render.contentDOM;
|
|
24
|
+
this.dom = dom;
|
|
25
|
+
this.contentDOM = contentDOM;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Variables
|
|
30
|
+
*/);
|