@atlaskit/adf-schema 25.1.0 → 25.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 +14 -0
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/json-schema/index.js +0 -3
- package/dist/cjs/schema/bitbucket-schema.js +0 -2
- package/dist/cjs/schema/confluence-schema.js +1 -4
- package/dist/cjs/schema/create-schema.js +12 -38
- package/dist/cjs/schema/default-schema.js +3 -16
- package/dist/cjs/schema/groups.js +13 -6
- package/dist/cjs/schema/index.js +0 -5
- package/dist/cjs/schema/inline-nodes.js +0 -5
- package/dist/cjs/schema/jira-schema.js +0 -36
- package/dist/cjs/schema/marks/alignment.js +0 -2
- package/dist/cjs/schema/marks/annotation.js +2 -14
- package/dist/cjs/schema/marks/code.js +0 -5
- package/dist/cjs/schema/marks/confluence-inline-comment.js +1 -1
- package/dist/cjs/schema/marks/data-consumer.js +2 -7
- package/dist/cjs/schema/marks/em.js +0 -2
- package/dist/cjs/schema/marks/fragment.js +0 -13
- package/dist/cjs/schema/marks/indentation.js +0 -2
- package/dist/cjs/schema/marks/index.js +0 -18
- package/dist/cjs/schema/marks/link.js +0 -17
- package/dist/cjs/schema/marks/strike.js +0 -2
- package/dist/cjs/schema/marks/strong.js +2 -3
- package/dist/cjs/schema/marks/subsup.js +0 -5
- package/dist/cjs/schema/marks/text-color.js +46 -37
- package/dist/cjs/schema/marks/type-ahead-query.js +0 -3
- package/dist/cjs/schema/marks/underline.js +0 -2
- package/dist/cjs/schema/nodes/block-card.js +1 -2
- package/dist/cjs/schema/nodes/blockquote.js +1 -1
- package/dist/cjs/schema/nodes/bodied-extension.js +0 -3
- package/dist/cjs/schema/nodes/caption.js +1 -1
- package/dist/cjs/schema/nodes/code-block.js +11 -29
- package/dist/cjs/schema/nodes/date.js +1 -1
- package/dist/cjs/schema/nodes/decision-item.js +2 -4
- package/dist/cjs/schema/nodes/decision-list.js +0 -2
- package/dist/cjs/schema/nodes/doc.js +1 -1
- package/dist/cjs/schema/nodes/embed-card.js +6 -6
- package/dist/cjs/schema/nodes/emoji.js +11 -9
- package/dist/cjs/schema/nodes/expand.js +1 -4
- package/dist/cjs/schema/nodes/extension.js +0 -3
- package/dist/cjs/schema/nodes/hard-break.js +1 -1
- package/dist/cjs/schema/nodes/heading.js +2 -2
- package/dist/cjs/schema/nodes/index.js +0 -45
- package/dist/cjs/schema/nodes/inline-card.js +4 -4
- package/dist/cjs/schema/nodes/inline-extension.js +0 -3
- package/dist/cjs/schema/nodes/layout-column.js +4 -5
- package/dist/cjs/schema/nodes/layout-section.js +1 -1
- package/dist/cjs/schema/nodes/media-group.js +1 -1
- package/dist/cjs/schema/nodes/media-inline.js +0 -2
- package/dist/cjs/schema/nodes/media-single.js +3 -14
- package/dist/cjs/schema/nodes/media.js +10 -28
- package/dist/cjs/schema/nodes/mention.js +4 -14
- package/dist/cjs/schema/nodes/nested-expand.js +1 -1
- package/dist/cjs/schema/nodes/ordered-list.js +3 -17
- package/dist/cjs/schema/nodes/panel.js +1 -13
- package/dist/cjs/schema/nodes/paragraph.js +1 -6
- package/dist/cjs/schema/nodes/placeholder.js +1 -1
- package/dist/cjs/schema/nodes/rule.js +1 -1
- package/dist/cjs/schema/nodes/status.js +4 -6
- package/dist/cjs/schema/nodes/tableNodes.js +12 -39
- package/dist/cjs/schema/nodes/task-item.js +2 -4
- package/dist/cjs/schema/nodes/task-list.js +0 -2
- package/dist/cjs/schema/nodes/text.js +1 -1
- package/dist/cjs/steps/analytics.js +4 -38
- package/dist/cjs/steps/set-attrs.js +0 -26
- package/dist/cjs/steps/table/add-column.js +33 -105
- package/dist/cjs/steps/table/constants.js +0 -1
- package/dist/cjs/steps/table/sort-column.js +0 -19
- package/dist/cjs/steps/table/utils/cell-step.js +18 -49
- package/dist/cjs/steps/table/utils/cells-at-column.js +2 -21
- package/dist/cjs/steps/table/utils/find-column.js +13 -17
- package/dist/cjs/steps/table/utils/get-table-rect-from-doc.js +6 -8
- package/dist/cjs/steps/table/utils/side-effects/rows.js +23 -78
- package/dist/cjs/steps/table/utils/side-effects/side-effects.js +0 -23
- package/dist/cjs/steps/table/utils/side-effects/table.js +2 -18
- package/dist/cjs/steps/table/utils/table-map.js +0 -6
- package/dist/cjs/steps/type-ahead.js +5 -25
- package/dist/cjs/steps.js +0 -6
- package/dist/cjs/utils/colors.js +13 -36
- package/dist/cjs/utils/confluence/emoji.js +6 -13
- package/dist/cjs/utils/extensions.js +0 -8
- package/dist/cjs/utils/index.js +0 -4
- package/dist/cjs/utils/parseDOM.js +0 -2
- package/dist/cjs/utils/url.js +3 -20
- package/dist/cjs/utils/uuid.js +0 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/schema/bitbucket-schema.js +1 -1
- package/dist/es2019/schema/confluence-schema.js +1 -2
- package/dist/es2019/schema/create-schema.js +12 -25
- package/dist/es2019/schema/default-schema.js +3 -11
- package/dist/es2019/schema/groups.js +13 -6
- package/dist/es2019/schema/index.js +1 -2
- package/dist/es2019/schema/jira-schema.js +0 -24
- package/dist/es2019/schema/marks/alignment.js +1 -3
- package/dist/es2019/schema/marks/annotation.js +3 -9
- package/dist/es2019/schema/marks/breakout.js +0 -4
- package/dist/es2019/schema/marks/code.js +1 -5
- package/dist/es2019/schema/marks/confluence-inline-comment.js +1 -2
- package/dist/es2019/schema/marks/data-consumer.js +3 -5
- package/dist/es2019/schema/marks/em.js +1 -2
- package/dist/es2019/schema/marks/fragment.js +0 -8
- package/dist/es2019/schema/marks/indentation.js +0 -4
- package/dist/es2019/schema/marks/link.js +2 -11
- package/dist/es2019/schema/marks/strike.js +1 -2
- package/dist/es2019/schema/marks/strong.js +3 -7
- package/dist/es2019/schema/marks/subsup.js +0 -6
- package/dist/es2019/schema/marks/text-color.js +44 -29
- package/dist/es2019/schema/marks/type-ahead-query.js +0 -2
- package/dist/es2019/schema/marks/underline.js +1 -2
- package/dist/es2019/schema/marks/unsupported-mark.js +0 -1
- package/dist/es2019/schema/marks/unsupported-node-attributes.js +0 -1
- package/dist/es2019/schema/nodes/block-card.js +1 -3
- package/dist/es2019/schema/nodes/blockquote.js +1 -2
- package/dist/es2019/schema/nodes/bodied-extension.js +0 -4
- package/dist/es2019/schema/nodes/bullet-list.js +0 -2
- package/dist/es2019/schema/nodes/caption.js +1 -2
- package/dist/es2019/schema/nodes/code-block.js +11 -28
- package/dist/es2019/schema/nodes/confluence-jira-issue.js +0 -2
- package/dist/es2019/schema/nodes/confluence-unsupported-block.js +0 -4
- package/dist/es2019/schema/nodes/confluence-unsupported-inline.js +0 -4
- package/dist/es2019/schema/nodes/date.js +1 -2
- package/dist/es2019/schema/nodes/decision-item.js +0 -2
- package/dist/es2019/schema/nodes/decision-list.js +1 -2
- package/dist/es2019/schema/nodes/doc.js +1 -0
- package/dist/es2019/schema/nodes/embed-card.js +1 -2
- package/dist/es2019/schema/nodes/emoji.js +9 -6
- package/dist/es2019/schema/nodes/expand.js +1 -3
- package/dist/es2019/schema/nodes/extension.js +0 -4
- package/dist/es2019/schema/nodes/hard-break.js +1 -2
- package/dist/es2019/schema/nodes/heading.js +2 -3
- package/dist/es2019/schema/nodes/image.js +0 -4
- package/dist/es2019/schema/nodes/inline-card.js +4 -5
- package/dist/es2019/schema/nodes/inline-extension.js +0 -4
- package/dist/es2019/schema/nodes/layout-column.js +4 -6
- package/dist/es2019/schema/nodes/layout-section.js +1 -4
- package/dist/es2019/schema/nodes/list-item.js +0 -2
- package/dist/es2019/schema/nodes/media-group.js +1 -2
- package/dist/es2019/schema/nodes/media-single.js +3 -6
- package/dist/es2019/schema/nodes/media.js +10 -20
- package/dist/es2019/schema/nodes/mention.js +0 -11
- package/dist/es2019/schema/nodes/nested-expand.js +1 -2
- package/dist/es2019/schema/nodes/ordered-list.js +4 -14
- package/dist/es2019/schema/nodes/panel.js +3 -10
- package/dist/es2019/schema/nodes/paragraph.js +1 -7
- package/dist/es2019/schema/nodes/placeholder.js +1 -2
- package/dist/es2019/schema/nodes/rule.js +1 -2
- package/dist/es2019/schema/nodes/status.js +1 -2
- package/dist/es2019/schema/nodes/tableNodes.js +10 -26
- package/dist/es2019/schema/nodes/task-item.js +0 -2
- package/dist/es2019/schema/nodes/task-list.js +0 -2
- package/dist/es2019/schema/nodes/text.js +1 -0
- package/dist/es2019/schema/nodes/unknown-block.js +0 -2
- package/dist/es2019/schema/nodes/unsupported-block.js +0 -2
- package/dist/es2019/schema/nodes/unsupported-inline.js +0 -2
- package/dist/es2019/steps/analytics.js +13 -30
- package/dist/es2019/steps/set-attrs.js +3 -12
- package/dist/es2019/steps/table/add-column.js +33 -76
- package/dist/es2019/steps/table/constants.js +0 -1
- package/dist/es2019/steps/table/sort-column.js +1 -8
- package/dist/es2019/steps/table/utils/cell-step.js +15 -32
- package/dist/es2019/steps/table/utils/cells-at-column.js +6 -11
- package/dist/es2019/steps/table/utils/find-column.js +12 -15
- package/dist/es2019/steps/table/utils/get-table-rect-from-doc.js +7 -6
- package/dist/es2019/steps/table/utils/side-effects/rows.js +19 -59
- package/dist/es2019/steps/table/utils/side-effects/side-effects.js +0 -21
- package/dist/es2019/steps/table/utils/side-effects/table.js +0 -17
- package/dist/es2019/steps/type-ahead.js +3 -15
- package/dist/es2019/utils/colors.js +8 -18
- package/dist/es2019/utils/confluence/emoji.js +5 -8
- package/dist/es2019/utils/extensions.js +0 -4
- package/dist/es2019/utils/url.js +2 -12
- package/dist/es2019/utils/uuid.js +0 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/schema/bitbucket-schema.js +1 -1
- package/dist/esm/schema/confluence-schema.js +1 -2
- package/dist/esm/schema/create-schema.js +12 -31
- package/dist/esm/schema/default-schema.js +3 -11
- package/dist/esm/schema/groups.js +13 -6
- package/dist/esm/schema/index.js +1 -2
- package/dist/esm/schema/jira-schema.js +0 -24
- package/dist/esm/schema/marks/alignment.js +1 -1
- package/dist/esm/schema/marks/annotation.js +3 -11
- package/dist/esm/schema/marks/code.js +1 -3
- package/dist/esm/schema/marks/confluence-inline-comment.js +1 -0
- package/dist/esm/schema/marks/data-consumer.js +3 -3
- package/dist/esm/schema/marks/em.js +1 -0
- package/dist/esm/schema/marks/fragment.js +0 -9
- package/dist/esm/schema/marks/link.js +0 -12
- package/dist/esm/schema/marks/strike.js +1 -0
- package/dist/esm/schema/marks/strong.js +3 -1
- package/dist/esm/schema/marks/subsup.js +0 -4
- package/dist/esm/schema/marks/text-color.js +46 -30
- package/dist/esm/schema/marks/underline.js +1 -0
- package/dist/esm/schema/nodes/block-card.js +1 -1
- package/dist/esm/schema/nodes/blockquote.js +1 -0
- package/dist/esm/schema/nodes/bodied-extension.js +0 -2
- package/dist/esm/schema/nodes/caption.js +1 -0
- package/dist/esm/schema/nodes/code-block.js +11 -26
- package/dist/esm/schema/nodes/date.js +1 -0
- package/dist/esm/schema/nodes/decision-item.js +2 -2
- package/dist/esm/schema/nodes/decision-list.js +1 -0
- package/dist/esm/schema/nodes/doc.js +1 -0
- package/dist/esm/schema/nodes/embed-card.js +6 -5
- package/dist/esm/schema/nodes/emoji.js +12 -7
- package/dist/esm/schema/nodes/expand.js +1 -1
- package/dist/esm/schema/nodes/extension.js +0 -2
- package/dist/esm/schema/nodes/hard-break.js +1 -0
- package/dist/esm/schema/nodes/heading.js +2 -1
- package/dist/esm/schema/nodes/inline-card.js +4 -3
- package/dist/esm/schema/nodes/inline-extension.js +0 -2
- package/dist/esm/schema/nodes/layout-column.js +4 -4
- package/dist/esm/schema/nodes/layout-section.js +1 -0
- package/dist/esm/schema/nodes/media-group.js +1 -0
- package/dist/esm/schema/nodes/media-single.js +3 -8
- package/dist/esm/schema/nodes/media.js +10 -18
- package/dist/esm/schema/nodes/mention.js +4 -13
- package/dist/esm/schema/nodes/nested-expand.js +1 -0
- package/dist/esm/schema/nodes/ordered-list.js +3 -13
- package/dist/esm/schema/nodes/panel.js +1 -10
- package/dist/esm/schema/nodes/paragraph.js +1 -5
- package/dist/esm/schema/nodes/placeholder.js +1 -0
- package/dist/esm/schema/nodes/rule.js +1 -0
- package/dist/esm/schema/nodes/status.js +5 -4
- package/dist/esm/schema/nodes/tableNodes.js +12 -25
- package/dist/esm/schema/nodes/task-item.js +2 -2
- package/dist/esm/schema/nodes/text.js +1 -0
- package/dist/esm/steps/analytics.js +5 -31
- package/dist/esm/steps/set-attrs.js +1 -17
- package/dist/esm/steps/table/add-column.js +33 -91
- package/dist/esm/steps/table/constants.js +0 -1
- package/dist/esm/steps/table/sort-column.js +1 -10
- package/dist/esm/steps/table/utils/cell-step.js +18 -42
- package/dist/esm/steps/table/utils/cells-at-column.js +2 -18
- package/dist/esm/steps/table/utils/find-column.js +13 -16
- package/dist/esm/steps/table/utils/get-table-rect-from-doc.js +7 -6
- package/dist/esm/steps/table/utils/side-effects/rows.js +23 -76
- package/dist/esm/steps/table/utils/side-effects/side-effects.js +0 -18
- package/dist/esm/steps/table/utils/side-effects/table.js +2 -13
- package/dist/esm/steps/type-ahead.js +6 -18
- package/dist/esm/utils/colors.js +12 -23
- package/dist/esm/utils/confluence/emoji.js +6 -10
- package/dist/esm/utils/extensions.js +0 -4
- package/dist/esm/utils/url.js +2 -12
- package/dist/esm/version.json +1 -1
- package/dist/types/schema/default-schema.d.ts +1 -1
- package/dist/types/utils/colors.d.ts +1 -1
- package/package.json +2 -2
@@ -1,41 +1,26 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.tableSortingStepType = exports.TableSortStep = void 0;
|
9
|
-
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
11
|
-
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
13
|
-
|
14
10
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
15
|
-
|
16
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
17
|
-
|
18
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
19
|
-
|
20
13
|
var _prosemirrorModel = require("prosemirror-model");
|
21
|
-
|
22
14
|
var _prosemirrorTransform = require("prosemirror-transform");
|
23
|
-
|
24
15
|
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); }; }
|
25
|
-
|
26
16
|
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; } }
|
27
|
-
|
28
17
|
var tableSortingStepType = 'atlaskit-table-sorting-ordering';
|
29
18
|
exports.tableSortingStepType = tableSortingStepType;
|
30
|
-
|
31
19
|
var TableSortStep = /*#__PURE__*/function (_Step) {
|
32
20
|
(0, _inherits2.default)(TableSortStep, _Step);
|
33
|
-
|
34
21
|
var _super = _createSuper(TableSortStep);
|
35
|
-
|
36
22
|
function TableSortStep(pos, prev, next) {
|
37
23
|
var _this;
|
38
|
-
|
39
24
|
(0, _classCallCheck2.default)(this, TableSortStep);
|
40
25
|
_this = _super.call(this);
|
41
26
|
_this.prev = prev;
|
@@ -43,7 +28,6 @@ var TableSortStep = /*#__PURE__*/function (_Step) {
|
|
43
28
|
_this.pos = pos;
|
44
29
|
return _this;
|
45
30
|
}
|
46
|
-
|
47
31
|
(0, _createClass2.default)(TableSortStep, [{
|
48
32
|
key: "invert",
|
49
33
|
value: function invert() {
|
@@ -80,8 +64,5 @@ var TableSortStep = /*#__PURE__*/function (_Step) {
|
|
80
64
|
return TableSortStep;
|
81
65
|
}(_prosemirrorTransform.Step);
|
82
66
|
/** Register this step with Prosemirror */
|
83
|
-
|
84
|
-
|
85
67
|
exports.TableSortStep = TableSortStep;
|
86
|
-
|
87
68
|
_prosemirrorTransform.Step.jsonID(tableSortingStepType, TableSortStep);
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
@@ -9,26 +8,19 @@ exports.applyCellStep = applyCellStep;
|
|
9
8
|
exports.createCellStep = createCellStep;
|
10
9
|
exports.getMapFromCellStep = getMapFromCellStep;
|
11
10
|
exports.invertCellStep = invertCellStep;
|
12
|
-
|
13
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
14
|
-
|
15
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
16
|
-
|
17
13
|
var _utils = require("@atlaskit/editor-tables/utils");
|
18
|
-
|
19
14
|
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; }
|
20
|
-
|
21
15
|
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) { (0, _defineProperty2.default)(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; }
|
22
|
-
|
23
16
|
var EmptyCellNodeSize = 4;
|
24
|
-
|
25
17
|
function calculateRowsToSkip(attrs) {
|
26
18
|
if (attrs && attrs.rowspan) {
|
27
19
|
return attrs.rowspan - 1;
|
28
20
|
}
|
29
|
-
|
30
21
|
return 0;
|
31
22
|
}
|
23
|
+
|
32
24
|
/**
|
33
25
|
* Given a cell step, this function has to do the specific transformation to executed that step.
|
34
26
|
* It returns the applied cellStep and rows that needs to skip (because it was already handled).
|
@@ -39,15 +31,12 @@ function calculateRowsToSkip(attrs) {
|
|
39
31
|
* @param isDelete
|
40
32
|
* @param column
|
41
33
|
*/
|
42
|
-
|
43
|
-
|
44
34
|
function applyCellStep(tr, tableRect, cell, cellStep, isDelete, column) {
|
45
35
|
// Apply the merge actions,
|
46
36
|
if (cellStep.mergeWith !== undefined) {
|
47
37
|
var cellNode = tr.doc.nodeAt(tr.mapping.map(cellStep.mergeWith));
|
48
38
|
var columns = column - tableRect.map.colCount(cellStep.mergeWith - tableRect.tableStart);
|
49
39
|
var cellAttrs = isDelete ? (0, _utils.removeColSpan)(cellNode.attrs, columns) : (0, _utils.addColSpan)(cellNode.attrs, columns);
|
50
|
-
|
51
40
|
if (cellAttrs.colspan > 0) {
|
52
41
|
// When colspan is 0 should remove the cell
|
53
42
|
tr.setNodeMarkup(tr.mapping.map(cellStep.mergeWith), undefined, cellAttrs);
|
@@ -56,20 +45,18 @@ function applyCellStep(tr, tableRect, cell, cellStep, isDelete, column) {
|
|
56
45
|
skipRows: calculateRowsToSkip(cellAttrs),
|
57
46
|
cellStep: cellStep
|
58
47
|
};
|
59
|
-
}
|
60
|
-
// Update cellStep with the proper data
|
61
|
-
|
48
|
+
}
|
62
49
|
|
50
|
+
// When the new colspan is 0, I need to change the operation to a delete operation
|
51
|
+
// Update cellStep with the proper data
|
63
52
|
cellStep.from = cellStep.mergeWith;
|
64
53
|
cellStep.to = cellStep.from + cellNode.nodeSize;
|
65
54
|
cellStep.mergeWith = undefined;
|
66
55
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
56
|
+
var skipRows = 0;
|
57
|
+
// Modify temporary document
|
70
58
|
if (isDelete) {
|
71
59
|
var _cellNode = tr.doc.nodeAt(tr.mapping.map(cellStep.from));
|
72
|
-
|
73
60
|
skipRows = calculateRowsToSkip(_cellNode.attrs);
|
74
61
|
tr.delete(tr.mapping.map(cellStep.from), tr.mapping.map(cellStep.to));
|
75
62
|
} else {
|
@@ -80,36 +67,33 @@ function applyCellStep(tr, tableRect, cell, cellStep, isDelete, column) {
|
|
80
67
|
tr.insert(tr.mapping.map(cellStep.from), cell.type.createAndFill());
|
81
68
|
}
|
82
69
|
}
|
83
|
-
|
84
70
|
return {
|
85
71
|
tr: tr,
|
86
72
|
skipRows: skipRows,
|
87
73
|
cellStep: cellStep
|
88
74
|
};
|
89
75
|
}
|
76
|
+
|
90
77
|
/**
|
91
78
|
* Given a cell step, this functions return un StepMap representing this action.
|
92
79
|
* [position, oldSize, newSize]
|
93
80
|
* @param cellStep
|
94
81
|
* @param isDelete
|
95
82
|
*/
|
96
|
-
|
97
|
-
|
98
83
|
function getMapFromCellStep(cellStep, isDelete) {
|
99
84
|
if (cellStep.mergeWith !== undefined) {
|
100
85
|
return [cellStep.mergeWith, 1, 1];
|
101
86
|
}
|
102
|
-
|
103
87
|
if (isDelete) {
|
104
88
|
return [cellStep.from, cellStep.to - cellStep.from, 0];
|
105
89
|
} else {
|
106
90
|
if (cellStep.newCell) {
|
107
91
|
return [cellStep.from, 0, cellStep.newCell.nodeSize];
|
108
92
|
}
|
109
|
-
|
110
93
|
return [cellStep.from, 0, EmptyCellNodeSize];
|
111
94
|
}
|
112
95
|
}
|
96
|
+
|
113
97
|
/**
|
114
98
|
* Helper to calculate the offset of the inverted cells.
|
115
99
|
* When you delete consecutive rows in a single step, the position in the generated document
|
@@ -118,20 +102,17 @@ function getMapFromCellStep(cellStep, isDelete) {
|
|
118
102
|
* @param cellStep
|
119
103
|
* @param isDelete
|
120
104
|
*/
|
121
|
-
|
122
|
-
|
123
105
|
function getOffset(map, cellStep, isDelete) {
|
124
106
|
if (isDelete) {
|
125
107
|
return map.map(cellStep.from) - cellStep.from;
|
126
108
|
}
|
127
|
-
|
128
109
|
var _getMapFromCellStep = getMapFromCellStep(cellStep, isDelete),
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
110
|
+
_getMapFromCellStep2 = (0, _slicedToArray2.default)(_getMapFromCellStep, 3),
|
111
|
+
oldSize = _getMapFromCellStep2[1],
|
112
|
+
newSize = _getMapFromCellStep2[2];
|
133
113
|
return map.map(cellStep.from) - cellStep.from - (newSize - oldSize);
|
134
114
|
}
|
115
|
+
|
135
116
|
/**
|
136
117
|
* Given a cell step, this function invert that step.
|
137
118
|
* @param doc
|
@@ -140,8 +121,6 @@ function getOffset(map, cellStep, isDelete) {
|
|
140
121
|
* @param isDelete
|
141
122
|
* @param stepMap
|
142
123
|
*/
|
143
|
-
|
144
|
-
|
145
124
|
function invertCellStep(doc, getTableRectAndColumn, cellStep, isDelete, stepMap) {
|
146
125
|
/**
|
147
126
|
* We need a correct map when a cell is added
|
@@ -163,40 +142,36 @@ function invertCellStep(doc, getTableRectAndColumn, cellStep, isDelete, stepMap)
|
|
163
142
|
* For a delete action this not happen, it will always return the right value
|
164
143
|
*/
|
165
144
|
var offset = getOffset(stepMap, cellStep, isDelete);
|
166
|
-
|
167
145
|
var newCellStepInfo = _objectSpread(_objectSpread({}, cellStep), {}, {
|
168
146
|
// Map the position to position of the generated document
|
169
147
|
from: cellStep.from + offset,
|
170
148
|
to: cellStep.to + offset
|
171
149
|
});
|
172
|
-
|
173
150
|
if (cellStep.mergeWith !== undefined) {
|
174
151
|
newCellStepInfo.mergeWith = cellStep.mergeWith + offset;
|
175
152
|
}
|
176
|
-
|
177
153
|
if (isDelete) {
|
178
154
|
// Add the removed cell as the new cell of the inverted step
|
179
155
|
var removedCell = doc.nodeAt(cellStep.from);
|
180
|
-
newCellStepInfo.newCell = removedCell.copy(removedCell.content);
|
156
|
+
newCellStepInfo.newCell = removedCell.copy(removedCell.content);
|
157
|
+
|
158
|
+
// When we delete a column we can end in a position that doesnt represent the right column.
|
181
159
|
// This only happens on merged cell that ends in the deleted column.
|
182
160
|
// We need to remap this position to the "next" cell (AKA cellStep.to)
|
183
|
-
|
184
161
|
var _getTableRectAndColum = getTableRectAndColumn(),
|
185
|
-
|
186
|
-
|
187
|
-
|
162
|
+
column = _getTableRectAndColum.column,
|
163
|
+
rect = _getTableRectAndColum.rect;
|
188
164
|
if (column < rect.map.width) {
|
189
165
|
var isAtTheEnd = rect.map.colCount(cellStep.from - rect.tableStart) + removedCell.attrs.colspan - 1 === column;
|
190
|
-
|
191
166
|
if (cellStep.mergeWith !== undefined && isAtTheEnd) {
|
192
167
|
newCellStepInfo.mergeWith = newCellStepInfo.from;
|
193
168
|
newCellStepInfo.from = newCellStepInfo.to;
|
194
169
|
}
|
195
170
|
}
|
196
171
|
}
|
197
|
-
|
198
172
|
return newCellStepInfo;
|
199
173
|
}
|
174
|
+
|
200
175
|
/**
|
201
176
|
* Create a cell step based on the current cell and operation (add/delete)
|
202
177
|
* @param cell
|
@@ -204,30 +179,24 @@ function invertCellStep(doc, getTableRectAndColumn, cellStep, isDelete, stepMap)
|
|
204
179
|
* @param isDelete
|
205
180
|
* @param previousCellStep
|
206
181
|
*/
|
207
|
-
|
208
|
-
|
209
182
|
function createCellStep(cell, column, isDelete, previousCellStep) {
|
210
183
|
var newCellStepInfo = {
|
211
184
|
from: cell.from,
|
212
185
|
to: cell.to
|
213
186
|
};
|
214
|
-
|
215
187
|
if (cell.hasMergedCells) {
|
216
188
|
// Check what column has to merge
|
217
189
|
if (column !== cell.col || isDelete) {
|
218
190
|
newCellStepInfo.mergeWith = cell.from;
|
219
191
|
}
|
220
192
|
}
|
221
|
-
|
222
193
|
if (previousCellStep) {
|
223
194
|
if (previousCellStep.mergeWith !== undefined) {
|
224
195
|
newCellStepInfo.mergeWith = previousCellStep.mergeWith;
|
225
196
|
}
|
226
|
-
|
227
197
|
if (previousCellStep.newCell) {
|
228
198
|
newCellStepInfo.newCell = previousCellStep.newCell;
|
229
199
|
}
|
230
200
|
}
|
231
|
-
|
232
201
|
return newCellStepInfo;
|
233
202
|
}
|
@@ -1,20 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.cellsAtColumn = cellsAtColumn;
|
9
|
-
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
-
|
12
9
|
var _utils = require("@atlaskit/editor-tables/utils");
|
13
|
-
|
14
10
|
var _tableMap = require("./table-map");
|
15
|
-
|
16
11
|
var _marked = /*#__PURE__*/_regenerator.default.mark(cellsAtColumn);
|
17
|
-
|
18
12
|
/**
|
19
13
|
* Helper to have a consistent way to iterate for all the cells in a column.
|
20
14
|
* You can skip rows by passing the rows to skipped in the next arguments.
|
@@ -30,30 +24,22 @@ function cellsAtColumn(rect, col) {
|
|
30
24
|
case 0:
|
31
25
|
map = rect.map, tableStart = rect.tableStart, table = rect.table;
|
32
26
|
refColumn = col > 0 ? -1 : 0;
|
33
|
-
|
34
27
|
if ((0, _utils.columnIsHeader)(map, table, col + refColumn)) {
|
35
28
|
refColumn = col === 0 || col === map.width ? null : 0;
|
36
29
|
}
|
37
|
-
|
38
30
|
row = 0;
|
39
|
-
|
40
31
|
case 4:
|
41
32
|
if (!(row < map.height)) {
|
42
33
|
_context.next = 20;
|
43
34
|
break;
|
44
35
|
}
|
45
|
-
|
46
36
|
index = (0, _tableMap.getCellIndex)(rect.map, row, col);
|
47
37
|
pos = map.map[index]; // We only consider to has merged cell to the first cell in a rowspan.
|
48
|
-
|
49
38
|
hasMergedCells = (0, _tableMap.hasMergedColumns)(rect.map, row, col) && (0, _tableMap.isRootRow)(rect.map, row, col); // If this position falls inside a col-spanning cell
|
50
|
-
|
51
39
|
type = refColumn == null ? (0, _utils.tableNodeTypes)(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;
|
52
|
-
|
53
40
|
if (!hasMergedCells) {
|
54
41
|
pos = map.positionAt(row, col, table);
|
55
42
|
}
|
56
|
-
|
57
43
|
cell = table.nodeAt(pos);
|
58
44
|
cellInfo = {
|
59
45
|
from: tableStart + pos,
|
@@ -63,28 +49,23 @@ function cellsAtColumn(rect, col) {
|
|
63
49
|
type: type,
|
64
50
|
hasMergedCells: hasMergedCells
|
65
51
|
};
|
66
|
-
|
67
52
|
if (cell) {
|
68
53
|
cellInfo.attrs = cell.attrs;
|
69
54
|
cellInfo.to = tableStart + pos + cell.nodeSize;
|
70
|
-
}
|
71
|
-
|
55
|
+
}
|
72
56
|
|
57
|
+
// We let the consumer to pass the rows that we want to skip
|
73
58
|
_context.next = 15;
|
74
59
|
return cellInfo;
|
75
|
-
|
76
60
|
case 15:
|
77
61
|
skippedRows = _context.sent;
|
78
|
-
|
79
62
|
if (skippedRows && skippedRows > 0) {
|
80
63
|
row += skippedRows;
|
81
64
|
}
|
82
|
-
|
83
65
|
case 17:
|
84
66
|
row++;
|
85
67
|
_context.next = 4;
|
86
68
|
break;
|
87
|
-
|
88
69
|
case 20:
|
89
70
|
case "end":
|
90
71
|
return _context.stop();
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.findColumn = findColumn;
|
7
|
-
|
8
7
|
/**
|
9
8
|
* Try to find the right column based on the cell steps in column info..
|
10
9
|
* @param columnInfo - Map of cell positions sorted from lower to greather
|
@@ -36,35 +35,35 @@ function findColumn(columnInfo, rect) {
|
|
36
35
|
* end = 1
|
37
36
|
* * Start === end return 1
|
38
37
|
*/
|
38
|
+
|
39
39
|
// Initial range (start and end column) to search for each row
|
40
40
|
var start = 0,
|
41
|
-
|
41
|
+
end = rect.map.width - 1;
|
42
42
|
var iter = columnInfo.values();
|
43
|
-
var next = iter.next();
|
43
|
+
var next = iter.next();
|
44
44
|
|
45
|
+
// Iterate for each row
|
45
46
|
for (var row = 0; row < rect.map.height; row++) {
|
46
47
|
if (next.done) {
|
47
48
|
break;
|
48
|
-
}
|
49
|
-
|
50
|
-
|
49
|
+
}
|
50
|
+
// Iterate for the column. Starting with the current start range
|
51
51
|
for (var col = start; col <= end; col++) {
|
52
52
|
var i = row * rect.map.width + col;
|
53
53
|
var cell = rect.map.map[i];
|
54
|
-
var cellInfo = next.value.from - rect.tableStart;
|
54
|
+
var cellInfo = next.value.from - rect.tableStart;
|
55
55
|
|
56
|
+
// When cell is found update range with the new values
|
56
57
|
if (cell === cellInfo) {
|
57
58
|
start = col; // Start column will be the current column
|
58
59
|
// Try to find the end column. End column will be different that start when has merged cells.
|
59
|
-
|
60
60
|
var endIndex = end - start + i;
|
61
|
-
|
62
61
|
for (var j = i; j <= endIndex; j++) {
|
63
62
|
if (rect.map.map[j] !== cell) {
|
64
63
|
break;
|
65
|
-
}
|
66
|
-
|
64
|
+
}
|
67
65
|
|
66
|
+
// merged columns
|
68
67
|
end = start + j - i; // Update the end column with the new position
|
69
68
|
}
|
70
69
|
|
@@ -72,23 +71,20 @@ function findColumn(columnInfo, rect) {
|
|
72
71
|
// We found the right column only when start and end columns are the same.
|
73
72
|
return start;
|
74
73
|
}
|
75
|
-
|
76
74
|
next = iter.next();
|
77
75
|
break;
|
78
|
-
}
|
76
|
+
}
|
77
|
+
|
78
|
+
// Sometimes I want to find a column at the end of the table (It doesn't exist, but we can add a new cell there).
|
79
79
|
// This is represented by the end position of the last cell in the column.
|
80
80
|
// In this case return, table width
|
81
|
-
|
82
|
-
|
83
81
|
if (col === rect.map.width - 1) {
|
84
82
|
var cellNode = rect.table.nodeAt(cell);
|
85
|
-
|
86
83
|
if (cell + cellNode.nodeSize === cellInfo) {
|
87
84
|
return rect.map.width;
|
88
85
|
}
|
89
86
|
}
|
90
87
|
}
|
91
88
|
}
|
92
|
-
|
93
89
|
return null;
|
94
90
|
}
|
@@ -4,26 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getTableRectFromDoc = getTableRectFromDoc;
|
7
|
-
|
8
7
|
var _tableMap = require("@atlaskit/editor-tables/table-map");
|
9
|
-
|
10
8
|
/**
|
11
9
|
* Util to get the table rect from the docs
|
12
10
|
* @param doc
|
13
11
|
* @param tablePos
|
14
12
|
*/
|
15
13
|
function getTableRectFromDoc(doc, tablePos) {
|
16
|
-
var table = doc.nodeAt(tablePos);
|
14
|
+
var table = doc.nodeAt(tablePos);
|
17
15
|
|
16
|
+
// Check for table existence
|
18
17
|
if (!table || table.type.name !== 'table') {
|
19
18
|
throw new Error("No table at position \"".concat(tablePos, "\"."));
|
20
|
-
}
|
21
|
-
|
19
|
+
}
|
22
20
|
|
21
|
+
// Create transform base on the doc
|
23
22
|
var map = _tableMap.TableMap.get(table);
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
var $table = doc.resolve(tablePos);
|
24
|
+
// Nested tables start position might differ from the original position
|
27
25
|
var start = $table.start($table.depth + 1);
|
28
26
|
return {
|
29
27
|
map: map,
|