@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,55 +1,36 @@
|
|
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.analyticsStepType = exports.analyticsInvertStepType = exports.AnalyticsStep = void 0;
|
9
|
-
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
|
-
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
13
|
-
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
15
|
-
|
16
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
17
|
-
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
19
|
-
|
20
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
21
|
-
|
22
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
23
|
-
|
24
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
25
|
-
|
26
16
|
var _prosemirrorTransform = require("prosemirror-transform");
|
27
|
-
|
28
17
|
var _prosemirrorModel = require("prosemirror-model");
|
29
|
-
|
30
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); }; }
|
31
|
-
|
32
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; } }
|
33
|
-
|
34
20
|
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; }
|
35
|
-
|
36
21
|
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; }
|
37
|
-
|
38
22
|
var analyticsStepType = 'atlaskit-analytics';
|
39
23
|
exports.analyticsStepType = analyticsStepType;
|
40
24
|
var analyticsInvertStepType = 'atlaskit-analytics-invert';
|
41
25
|
exports.analyticsInvertStepType = analyticsInvertStepType;
|
42
26
|
var HISTORY_ACTIONS;
|
43
|
-
|
44
27
|
(function (HISTORY_ACTIONS) {
|
45
28
|
HISTORY_ACTIONS["UNDID"] = "undid";
|
46
29
|
HISTORY_ACTIONS["REDID"] = "redid";
|
47
30
|
})(HISTORY_ACTIONS || (HISTORY_ACTIONS = {}));
|
48
|
-
|
49
31
|
/** Creates undo event from a normal analytics event */
|
50
32
|
function createUndoEvent(analyticsEvent) {
|
51
33
|
var _analyticsEvent$paylo;
|
52
|
-
|
53
34
|
return _objectSpread(_objectSpread({}, analyticsEvent), {}, {
|
54
35
|
payload: {
|
55
36
|
action: HISTORY_ACTIONS.UNDID,
|
@@ -63,9 +44,8 @@ function createUndoEvent(analyticsEvent) {
|
|
63
44
|
}
|
64
45
|
});
|
65
46
|
}
|
66
|
-
/** Toggles event action between undo & redo */
|
67
|
-
|
68
47
|
|
48
|
+
/** Toggles event action between undo & redo */
|
69
49
|
var toggleEventAction = function toggleEventAction(analyticsEvent) {
|
70
50
|
return _objectSpread(_objectSpread({}, analyticsEvent), {}, {
|
71
51
|
payload: _objectSpread(_objectSpread({}, analyticsEvent.payload), {}, {
|
@@ -73,11 +53,9 @@ var toggleEventAction = function toggleEventAction(analyticsEvent) {
|
|
73
53
|
})
|
74
54
|
});
|
75
55
|
};
|
76
|
-
|
77
56
|
function isHistoryAnalyticsEvent(event) {
|
78
57
|
return event.payload.action === HISTORY_ACTIONS.UNDID || event.payload.action === HISTORY_ACTIONS.REDID;
|
79
58
|
}
|
80
|
-
|
81
59
|
/**
|
82
60
|
* Custom Prosemirror Step to fire our GAS V3 analytics events
|
83
61
|
* Using a Step means that it will work with prosemirror-history and we get
|
@@ -85,12 +63,9 @@ function isHistoryAnalyticsEvent(event) {
|
|
85
63
|
*/
|
86
64
|
var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
87
65
|
(0, _inherits2.default)(AnalyticsStep, _Step);
|
88
|
-
|
89
66
|
var _super = _createSuper(AnalyticsStep);
|
90
|
-
|
91
67
|
function AnalyticsStep(analyticsEvents) {
|
92
68
|
var _this;
|
93
|
-
|
94
69
|
var actionsToIgnore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
95
70
|
var pos // Used to create the map, prevent splitting history.
|
96
71
|
= arguments.length > 2 ? arguments[2] : undefined;
|
@@ -103,16 +78,14 @@ var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
103
78
|
_this.pos = pos;
|
104
79
|
return _this;
|
105
80
|
}
|
81
|
+
|
106
82
|
/**
|
107
83
|
* Generate new undo/redo analytics event when step is inverted
|
108
84
|
*/
|
109
|
-
|
110
|
-
|
111
85
|
(0, _createClass2.default)(AnalyticsStep, [{
|
112
86
|
key: "invert",
|
113
87
|
value: function invert() {
|
114
88
|
var _this2 = this;
|
115
|
-
|
116
89
|
var analyticsEvents = this.analyticsEvents.filter(function (analyticsEvent) {
|
117
90
|
return _this2.actionsToIgnore.indexOf(analyticsEvent.payload.action) === -1;
|
118
91
|
}).map(function (analyticsEvent) {
|
@@ -133,12 +106,10 @@ var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
133
106
|
key: "map",
|
134
107
|
value: function map(mapping) {
|
135
108
|
var newPos = this.pos;
|
136
|
-
|
137
109
|
if (typeof newPos === 'number') {
|
138
110
|
newPos = mapping.map(newPos);
|
139
|
-
}
|
140
|
-
|
141
|
-
|
111
|
+
}
|
112
|
+
// Return the same events, this step will never be removed
|
142
113
|
return new AnalyticsStep(this.analyticsEvents, this.actionsToIgnore, newPos);
|
143
114
|
}
|
144
115
|
}, {
|
@@ -147,7 +118,6 @@ var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
147
118
|
if (typeof this.pos === 'number') {
|
148
119
|
return new _prosemirrorTransform.StepMap([this.pos, 0, 0]);
|
149
120
|
}
|
150
|
-
|
151
121
|
return new _prosemirrorTransform.StepMap([]);
|
152
122
|
}
|
153
123
|
}, {
|
@@ -157,7 +127,6 @@ var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
157
127
|
var otherAnalyticsEvents = other.analyticsEvents;
|
158
128
|
return new AnalyticsStep([].concat((0, _toConsumableArray2.default)(otherAnalyticsEvents), (0, _toConsumableArray2.default)(this.analyticsEvents)));
|
159
129
|
}
|
160
|
-
|
161
130
|
return null;
|
162
131
|
}
|
163
132
|
}, {
|
@@ -176,8 +145,5 @@ var AnalyticsStep = /*#__PURE__*/function (_Step) {
|
|
176
145
|
return AnalyticsStep;
|
177
146
|
}(_prosemirrorTransform.Step);
|
178
147
|
/** Register this step with Prosemirror */
|
179
|
-
|
180
|
-
|
181
148
|
exports.AnalyticsStep = AnalyticsStep;
|
182
|
-
|
183
149
|
_prosemirrorTransform.Step.jsonID(analyticsStepType, AnalyticsStep);
|
@@ -1,72 +1,49 @@
|
|
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.SetAttrsStep = void 0;
|
9
|
-
|
10
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
11
|
-
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
-
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
15
|
-
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
17
|
-
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
19
|
-
|
20
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
21
|
-
|
22
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
23
|
-
|
24
15
|
var _prosemirrorTransform = require("prosemirror-transform");
|
25
|
-
|
26
16
|
var _prosemirrorModel = require("prosemirror-model");
|
27
|
-
|
28
17
|
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; }
|
29
|
-
|
30
18
|
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; }
|
31
|
-
|
32
19
|
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); }; }
|
33
|
-
|
34
20
|
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; } }
|
35
|
-
|
36
21
|
/**
|
37
22
|
* For more context on what this is about:
|
38
23
|
* @see https://discuss.prosemirror.net/t/preventing-image-placeholder-replacement-from-being-undone/1394
|
39
24
|
*/
|
40
25
|
var SetAttrsStep = /*#__PURE__*/function (_Step) {
|
41
26
|
(0, _inherits2.default)(SetAttrsStep, _Step);
|
42
|
-
|
43
27
|
var _super = _createSuper(SetAttrsStep);
|
44
|
-
|
45
28
|
function SetAttrsStep(pos, attrs) {
|
46
29
|
var _this;
|
47
|
-
|
48
30
|
(0, _classCallCheck2.default)(this, SetAttrsStep);
|
49
31
|
_this = _super.call(this);
|
50
32
|
_this.pos = pos;
|
51
33
|
_this.attrs = attrs;
|
52
34
|
return _this;
|
53
35
|
}
|
54
|
-
|
55
36
|
(0, _createClass2.default)(SetAttrsStep, [{
|
56
37
|
key: "apply",
|
57
38
|
value: function apply(doc) {
|
58
39
|
var target = doc.nodeAt(this.pos);
|
59
|
-
|
60
40
|
if (!target) {
|
61
41
|
return _prosemirrorTransform.StepResult.fail('No node at given position');
|
62
42
|
}
|
63
|
-
|
64
43
|
if (target.isText) {
|
65
44
|
return _prosemirrorTransform.StepResult.fail('Target is a text node. Attributes are not allowed.');
|
66
45
|
}
|
67
|
-
|
68
46
|
var attrs = _objectSpread(_objectSpread({}, target.attrs || {}), this.attrs || {});
|
69
|
-
|
70
47
|
var newNode = target.type.create(attrs, _prosemirrorModel.Fragment.empty, target.marks);
|
71
48
|
var slice = new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(newNode), 0, target.isLeaf ? 0 : 1);
|
72
49
|
return _prosemirrorTransform.StepResult.fromReplace(doc, this.pos, this.pos + 1, slice);
|
@@ -98,13 +75,10 @@ var SetAttrsStep = /*#__PURE__*/function (_Step) {
|
|
98
75
|
if (typeof json.pos !== 'number' || json.attrs !== null && (0, _typeof2.default)(json.attrs) !== 'object') {
|
99
76
|
throw new RangeError('Invalid input for SetAttrsStep.fromJSON');
|
100
77
|
}
|
101
|
-
|
102
78
|
return new SetAttrsStep(json.pos, json.attrs);
|
103
79
|
}
|
104
80
|
}]);
|
105
81
|
return SetAttrsStep;
|
106
82
|
}(_prosemirrorTransform.Step);
|
107
|
-
|
108
83
|
exports.SetAttrsStep = SetAttrsStep;
|
109
|
-
|
110
84
|
_prosemirrorTransform.Step.jsonID('setAttrs', SetAttrsStep);
|
@@ -1,62 +1,36 @@
|
|
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.AddColumnStep = void 0;
|
9
|
-
|
10
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
11
|
-
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
-
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
15
|
-
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
17
|
-
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
19
|
-
|
20
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
21
|
-
|
22
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
23
|
-
|
24
15
|
var _prosemirrorTransform = require("prosemirror-transform");
|
25
|
-
|
26
16
|
var _cellsAtColumn = require("./utils/cells-at-column");
|
27
|
-
|
28
17
|
var _findColumn = require("./utils/find-column");
|
29
|
-
|
30
18
|
var _getTableRectFromDoc = require("./utils/get-table-rect-from-doc");
|
31
|
-
|
32
19
|
var _cellStep = require("./utils/cell-step");
|
33
|
-
|
34
20
|
var _sideEffects = require("./utils/side-effects/side-effects");
|
35
|
-
|
36
21
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
37
|
-
|
38
22
|
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; }
|
39
|
-
|
40
23
|
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; }
|
41
|
-
|
42
24
|
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); }; }
|
43
|
-
|
44
25
|
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; } }
|
45
|
-
|
46
26
|
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; } } }; }
|
47
|
-
|
48
27
|
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); }
|
49
|
-
|
50
28
|
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; }
|
51
|
-
|
52
29
|
var ADD_COLUMN_STEP = 'ak-add-column';
|
53
|
-
|
54
30
|
function printColumnInfo(columnInfo) {
|
55
31
|
var cellsFrom = [];
|
56
|
-
|
57
32
|
var _iterator = _createForOfIteratorHelper(columnInfo.values()),
|
58
|
-
|
59
|
-
|
33
|
+
_step;
|
60
34
|
try {
|
61
35
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
62
36
|
var cellInfo = _step.value;
|
@@ -67,31 +41,27 @@ function printColumnInfo(columnInfo) {
|
|
67
41
|
} finally {
|
68
42
|
_iterator.f();
|
69
43
|
}
|
70
|
-
|
71
44
|
return "[".concat(cellsFrom.join(','), "]");
|
72
45
|
}
|
73
|
-
|
74
46
|
function createColumnInfo(cellsInfo) {
|
75
47
|
return new Map(cellsInfo.map(function (cellInfo) {
|
76
48
|
return [cellInfo.from, cellInfo];
|
77
49
|
}));
|
78
50
|
}
|
79
|
-
|
80
51
|
var getTableRectAndColumnFactory = function getTableRectAndColumnFactory(doc, pos, columnInfo) {
|
81
52
|
return (0, _memoizeOne.default)(function () {
|
82
53
|
var rect = (0, _getTableRectFromDoc.getTableRectFromDoc)(doc, pos);
|
83
54
|
var column = (0, _findColumn.findColumn)(columnInfo, rect);
|
84
|
-
|
85
55
|
if (column === null) {
|
86
56
|
throw new Error('no column');
|
87
57
|
}
|
88
|
-
|
89
58
|
return {
|
90
59
|
rect: rect,
|
91
60
|
column: column
|
92
61
|
};
|
93
62
|
});
|
94
63
|
};
|
64
|
+
|
95
65
|
/**
|
96
66
|
* Index and positions looks like
|
97
67
|
* 0 1 2 3 -> Add Column Index
|
@@ -100,16 +70,11 @@ var getTableRectAndColumnFactory = function getTableRectAndColumnFactory(doc, po
|
|
100
70
|
* 0 1 2 x -> Remove Column Index
|
101
71
|
*
|
102
72
|
*/
|
103
|
-
|
104
|
-
|
105
73
|
var AddColumnStep = /*#__PURE__*/function (_Step) {
|
106
74
|
(0, _inherits2.default)(AddColumnStep, _Step);
|
107
|
-
|
108
75
|
var _super = _createSuper(AddColumnStep);
|
109
|
-
|
110
76
|
function AddColumnStep(tablePos, addColumnStepInfo) {
|
111
77
|
var _this;
|
112
|
-
|
113
78
|
var isDelete = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
114
79
|
(0, _classCallCheck2.default)(this, AddColumnStep);
|
115
80
|
_this = _super.call(this);
|
@@ -119,6 +84,7 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
119
84
|
_this.columnInfo = createColumnInfo(addColumnStepInfo.cells);
|
120
85
|
return _this;
|
121
86
|
}
|
87
|
+
|
122
88
|
/**
|
123
89
|
* Detect the column based on all the cells step in column info.
|
124
90
|
* Recreate columnInfo based on the current document. We might need to add new cells added by insert row or unmerge cells.
|
@@ -133,41 +99,34 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
133
99
|
*
|
134
100
|
* @param doc Current document
|
135
101
|
*/
|
136
|
-
|
137
|
-
|
138
102
|
(0, _createClass2.default)(AddColumnStep, [{
|
139
103
|
key: "apply",
|
140
104
|
value: function apply(doc) {
|
141
|
-
var tablePos = this.tablePos;
|
142
|
-
|
105
|
+
var tablePos = this.tablePos;
|
106
|
+
// Create transform base on the doc
|
143
107
|
var tr = new _prosemirrorTransform.Transform(doc);
|
144
|
-
|
145
108
|
if (this.sideEffectsHandler.table.handleAddTable(tr, this.isDelete)) {
|
146
109
|
return _prosemirrorTransform.StepResult.ok(tr.doc);
|
147
110
|
}
|
148
|
-
|
149
111
|
var tableRect;
|
150
|
-
|
151
112
|
try {
|
152
113
|
tableRect = (0, _getTableRectFromDoc.getTableRectFromDoc)(doc, tablePos);
|
153
114
|
} catch (e) {
|
154
115
|
return _prosemirrorTransform.StepResult.fail(e.message);
|
155
116
|
}
|
156
|
-
|
157
117
|
var column = (0, _findColumn.findColumn)(this.columnInfo, tableRect);
|
158
|
-
|
159
118
|
if (column === null) {
|
160
119
|
return _prosemirrorTransform.StepResult.fail("No column for this cells \"".concat(printColumnInfo(this.columnInfo), "\" in table at position \"").concat(tablePos, "\"."));
|
161
120
|
}
|
162
|
-
|
163
121
|
if (this.sideEffectsHandler.table.handleRemoveTable(tr, this.tablePos, tableRect, column, this.isDelete)) {
|
164
122
|
return _prosemirrorTransform.StepResult.ok(tr.doc);
|
165
123
|
}
|
124
|
+
this.columnInfo = this.applyCellSteps(tr, tableRect, column, this.isDelete);
|
166
125
|
|
167
|
-
|
168
|
-
|
126
|
+
// Return the document modified.
|
169
127
|
return _prosemirrorTransform.StepResult.ok(tr.doc);
|
170
128
|
}
|
129
|
+
|
171
130
|
/**
|
172
131
|
* Update tablePos with the new position. If tablePos doesnt exist any more remove the step
|
173
132
|
* Update all the cellStep inside columnInfo. If cellStep.from position gets deleted removed it from column info
|
@@ -175,41 +134,32 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
175
134
|
* Create a new step with all the position updated
|
176
135
|
* @param mapping
|
177
136
|
*/
|
178
|
-
|
179
137
|
}, {
|
180
138
|
key: "map",
|
181
139
|
value: function map(mapping) {
|
182
140
|
var tablePosResult = mapping.mapResult(this.tablePos);
|
183
|
-
|
184
141
|
if (tablePosResult.deleted) {
|
185
142
|
// If table was deleted remove the step
|
186
143
|
return null;
|
187
144
|
}
|
188
|
-
|
189
145
|
var cellSteps = [];
|
190
|
-
|
191
146
|
var _iterator2 = _createForOfIteratorHelper(this.columnInfo.values()),
|
192
|
-
|
193
|
-
|
147
|
+
_step2;
|
194
148
|
try {
|
195
149
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
196
150
|
var oldCellStep = _step2.value;
|
197
151
|
var fromResult = mapping.mapResult(oldCellStep.from);
|
198
152
|
var toResult = mapping.mapResult(oldCellStep.to);
|
199
|
-
|
200
153
|
if (fromResult.deleted && toResult.deleted) {
|
201
154
|
continue;
|
202
155
|
}
|
203
|
-
|
204
156
|
var cellStep = _objectSpread(_objectSpread({}, oldCellStep), {}, {
|
205
157
|
from: fromResult.pos,
|
206
158
|
to: toResult.pos
|
207
159
|
});
|
208
|
-
|
209
160
|
if (oldCellStep.mergeWith !== undefined) {
|
210
161
|
cellStep.mergeWith = mapping.map(oldCellStep.mergeWith);
|
211
162
|
}
|
212
|
-
|
213
163
|
cellSteps.push(cellStep);
|
214
164
|
}
|
215
165
|
} catch (err) {
|
@@ -217,17 +167,16 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
217
167
|
} finally {
|
218
168
|
_iterator2.f();
|
219
169
|
}
|
220
|
-
|
221
170
|
if (cellSteps.length === 0) {
|
222
171
|
return null;
|
223
172
|
}
|
224
|
-
|
225
173
|
var sideEffects = this.sideEffectsHandler.map(mapping);
|
226
174
|
return new AddColumnStep(tablePosResult.pos, {
|
227
175
|
cells: cellSteps,
|
228
176
|
sideEffects: sideEffects
|
229
177
|
}, this.isDelete);
|
230
178
|
}
|
179
|
+
|
231
180
|
/**
|
232
181
|
* if isDelete
|
233
182
|
* Get the original cell node at columnInfo.cellStep[].from to columnInfo.cellStep[].to
|
@@ -239,16 +188,15 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
239
188
|
* return new step inverted
|
240
189
|
* @param originalDoc
|
241
190
|
*/
|
242
|
-
|
243
191
|
}, {
|
244
192
|
key: "invert",
|
245
193
|
value: function invert(originalDoc) {
|
246
194
|
var _this2 = this;
|
195
|
+
var stepMap = this.getMap();
|
247
196
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
197
|
+
// Memoize function to be called only on delete scenarios
|
198
|
+
var getTableRectAndColumn = getTableRectAndColumnFactory(originalDoc, this.tablePos, this.columnInfo);
|
199
|
+
// This is needed because the real pos of the cell in the generated document is affected by the previous operations.
|
252
200
|
var newCellSteps = Array.from(this.columnInfo.values(), function (oldCellStep) {
|
253
201
|
var newCellStep = (0, _cellStep.invertCellStep)(originalDoc, getTableRectAndColumn, oldCellStep, _this2.isDelete, stepMap);
|
254
202
|
return newCellStep;
|
@@ -259,6 +207,7 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
259
207
|
sideEffects: sideEffects
|
260
208
|
}, !this.isDelete);
|
261
209
|
}
|
210
|
+
|
262
211
|
/**
|
263
212
|
* StepMap is created based on columnInfo.
|
264
213
|
* ColumnInfo is created on constructor and once is applied (the document could have new cells that weren't part of the original set)
|
@@ -273,27 +222,20 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
273
222
|
* currentSize: Represent the affected range, this will be pos + currentSize
|
274
223
|
* newSize: Represent the new values, pos + newSize
|
275
224
|
*/
|
276
|
-
|
277
225
|
}, {
|
278
226
|
key: "getMap",
|
279
227
|
value: function getMap() {
|
280
228
|
var tableMap = this.sideEffectsHandler.getTableMap(this.isDelete);
|
281
|
-
|
282
229
|
if (tableMap) {
|
283
230
|
return tableMap;
|
284
231
|
}
|
285
|
-
|
286
232
|
var ranges = [];
|
287
|
-
|
288
233
|
var _iterator3 = _createForOfIteratorHelper(this.columnInfo.values()),
|
289
|
-
|
290
|
-
|
234
|
+
_step3;
|
291
235
|
try {
|
292
236
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
293
237
|
var _ranges;
|
294
|
-
|
295
238
|
var cellStep = _step3.value;
|
296
|
-
|
297
239
|
(_ranges = ranges).push.apply(_ranges, (0, _toConsumableArray2.default)((0, _cellStep.getMapFromCellStep)(cellStep, this.isDelete)));
|
298
240
|
}
|
299
241
|
} catch (err) {
|
@@ -301,30 +243,30 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
301
243
|
} finally {
|
302
244
|
_iterator3.f();
|
303
245
|
}
|
246
|
+
ranges = this.sideEffectsHandler.rows.addRowRanges(ranges, this.isDelete);
|
304
247
|
|
305
|
-
|
306
|
-
|
248
|
+
// If no steps, I create am empty stepMap
|
307
249
|
return new _prosemirrorTransform.StepMap(ranges);
|
308
250
|
}
|
251
|
+
|
309
252
|
/**
|
310
253
|
* Try to merge this step with another one, to be applied directly
|
311
254
|
* after it. Returns the merged step when possible, null if the
|
312
255
|
* steps can't be merged.
|
313
256
|
*/
|
314
|
-
|
315
257
|
}, {
|
316
258
|
key: "merge",
|
317
259
|
value: function merge(other) {
|
318
260
|
// We cannot merge add column step at the moment
|
319
261
|
return null;
|
320
262
|
}
|
263
|
+
|
321
264
|
/**
|
322
265
|
* Create a JSON-serializeable representation of this step. When
|
323
266
|
* defining this for a custom subclass, make sure the result object
|
324
267
|
* includes the step type's [JSON id](#transform.Step^jsonID) under
|
325
268
|
* the `stepType` property.
|
326
269
|
*/
|
327
|
-
|
328
270
|
}, {
|
329
271
|
key: "toJSON",
|
330
272
|
value: function toJSON() {
|
@@ -336,62 +278,56 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
336
278
|
from: cellStep.from,
|
337
279
|
to: cellStep.to
|
338
280
|
};
|
339
|
-
|
340
281
|
if (cellStep.mergeWith !== undefined) {
|
341
282
|
cellStepJson.mergeWith = cellStep.mergeWith;
|
342
283
|
}
|
343
|
-
|
344
284
|
if (cellStep.newCell !== undefined) {
|
345
285
|
cellStepJson.newCell = cellStep.newCell.toJSON();
|
346
286
|
}
|
347
|
-
|
348
287
|
return cellStepJson;
|
349
288
|
}),
|
350
289
|
isDelete: this.isDelete
|
351
290
|
};
|
352
291
|
var sideEffectsJSON = this.sideEffectsHandler.toJSON();
|
353
|
-
|
354
292
|
if (sideEffectsJSON) {
|
355
293
|
addColumnStepJson.sideEffects = sideEffectsJSON;
|
356
294
|
}
|
357
|
-
|
358
295
|
return addColumnStepJson;
|
359
296
|
}
|
297
|
+
|
360
298
|
/**
|
361
299
|
* Deserialize a step from its JSON representation. Will call
|
362
300
|
* through to the step class' own implementation of this method.
|
363
301
|
*/
|
364
|
-
|
365
302
|
}, {
|
366
303
|
key: "applyCellSteps",
|
367
304
|
value: function applyCellSteps(tr, tableRect, column, isDelete) {
|
368
305
|
var newColumnInfo = new Map();
|
369
306
|
var rowsHandler = this.sideEffectsHandler.rows.start(this.isDelete);
|
370
307
|
var iter = (0, _cellsAtColumn.cellsAtColumn)(tableRect, column);
|
371
|
-
var next = iter.next();
|
372
|
-
|
308
|
+
var next = iter.next();
|
309
|
+
// Iterate for all the cells in the current document
|
373
310
|
while (!next.done) {
|
374
311
|
var cell = next.value;
|
375
312
|
var previousCellStep = this.columnInfo.get(cell.from);
|
376
|
-
var newCellStep = (0, _cellStep.createCellStep)(cell, column, isDelete, previousCellStep);
|
313
|
+
var newCellStep = (0, _cellStep.createCellStep)(cell, column, isDelete, previousCellStep);
|
377
314
|
|
315
|
+
// If is the last cell in the row and doesnt have colspan I need to remove the whole row.
|
378
316
|
var removeRowResult = rowsHandler.handle(tr, tableRect, cell.row, column, cell);
|
379
|
-
|
380
317
|
if (removeRowResult.handled) {
|
381
318
|
next = iter.next(removeRowResult.skipRows);
|
382
319
|
continue;
|
383
|
-
}
|
384
|
-
|
320
|
+
}
|
385
321
|
|
322
|
+
// Apply the step, to the pseudo document, get rows to skip, and the cellstep (might be modified, for example, a merge cell that remove the cell instead)
|
386
323
|
var _applyCellStep = (0, _cellStep.applyCellStep)(tr, tableRect, cell, newCellStep, isDelete, column),
|
387
|
-
|
388
|
-
|
389
|
-
|
324
|
+
skipRows = _applyCellStep.skipRows,
|
325
|
+
cellStep = _applyCellStep.cellStep;
|
390
326
|
|
327
|
+
// Store the new cell step. This could be an existing one or a new cell.
|
391
328
|
newColumnInfo.set(newCellStep.from, cellStep);
|
392
329
|
next = iter.next(skipRows);
|
393
330
|
}
|
394
|
-
|
395
331
|
rowsHandler.end(tr, tableRect, column);
|
396
332
|
return newColumnInfo;
|
397
333
|
}
|
@@ -403,15 +339,12 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
403
339
|
var cell = _objectSpread(_objectSpread({}, cellsJson), {}, {
|
404
340
|
newCell: cellsJson.newCell ? schema.nodeFromJSON(cellsJson.newCell) : undefined
|
405
341
|
});
|
406
|
-
|
407
342
|
return cell;
|
408
343
|
});
|
409
344
|
var sideEffects;
|
410
|
-
|
411
345
|
if (json.sideEffects) {
|
412
346
|
sideEffects = _sideEffects.SideEffectsHandler.fromJSON(schema, json.sideEffects);
|
413
347
|
}
|
414
|
-
|
415
348
|
return new AddColumnStep(json.tablePos, {
|
416
349
|
cells: cells,
|
417
350
|
sideEffects: sideEffects
|
@@ -421,25 +354,22 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
421
354
|
key: "create",
|
422
355
|
value: function create(doc, tablePos, column) {
|
423
356
|
var isDelete = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
424
|
-
var tableRect = (0, _getTableRectFromDoc.getTableRectFromDoc)(doc, tablePos);
|
425
|
-
// There is no need to add content
|
357
|
+
var tableRect = (0, _getTableRectFromDoc.getTableRectFromDoc)(doc, tablePos);
|
426
358
|
|
359
|
+
// By default add column will rely on default behaviour (add empty cell).
|
360
|
+
// There is no need to add content
|
427
361
|
var cells = [];
|
428
362
|
var iter = (0, _cellsAtColumn.cellsAtColumn)(tableRect, column);
|
429
363
|
var next = iter.next();
|
430
|
-
|
431
364
|
while (!next.done) {
|
432
365
|
var cell = next.value;
|
433
366
|
cells.push((0, _cellStep.createCellStep)(cell, column, isDelete));
|
434
367
|
var skipRows = 0;
|
435
|
-
|
436
368
|
if (cell.attrs && cell.attrs.rowspan) {
|
437
369
|
skipRows = cell.attrs.rowspan - 1;
|
438
370
|
}
|
439
|
-
|
440
371
|
next = iter.next(skipRows);
|
441
372
|
}
|
442
|
-
|
443
373
|
return new AddColumnStep(tablePos, {
|
444
374
|
cells: cells
|
445
375
|
}, isDelete);
|
@@ -447,7 +377,5 @@ var AddColumnStep = /*#__PURE__*/function (_Step) {
|
|
447
377
|
}]);
|
448
378
|
return AddColumnStep;
|
449
379
|
}(_prosemirrorTransform.Step);
|
450
|
-
|
451
380
|
exports.AddColumnStep = AddColumnStep;
|
452
|
-
|
453
381
|
_prosemirrorTransform.Step.jsonID(ADD_COLUMN_STEP, AddColumnStep);
|