@atlaskit/editor-common 74.30.0 → 74.32.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 +12 -0
- package/dist/cjs/lists/analytics.js +40 -0
- package/dist/cjs/lists/indentation.js +24 -0
- package/dist/cjs/lists/index.js +89 -0
- package/dist/cjs/lists/node.js +97 -0
- package/dist/cjs/lists/replace-content.js +24 -0
- package/dist/cjs/lists/selection.js +59 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/node-width/index.js +10 -2
- package/dist/cjs/types/input-rules.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/utils/commands.js +110 -2
- package/dist/cjs/utils/document.js +26 -1
- package/dist/cjs/utils/index.js +58 -2
- package/dist/cjs/utils/input-rules.js +26 -0
- package/dist/cjs/utils/prosemirror/autojoin.js +68 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/lists/analytics.js +36 -0
- package/dist/es2019/lists/indentation.js +18 -0
- package/dist/es2019/lists/index.js +6 -0
- package/dist/es2019/lists/node.js +97 -0
- package/dist/es2019/lists/replace-content.js +18 -0
- package/dist/es2019/lists/selection.js +53 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/node-width/index.js +7 -0
- package/dist/es2019/types/input-rules.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/utils/commands.js +106 -2
- package/dist/es2019/utils/document.js +25 -1
- package/dist/es2019/utils/index.js +5 -3
- package/dist/es2019/utils/input-rules.js +16 -0
- package/dist/es2019/utils/prosemirror/autojoin.js +57 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/lists/analytics.js +32 -0
- package/dist/esm/lists/indentation.js +17 -0
- package/dist/esm/lists/index.js +6 -0
- package/dist/esm/lists/node.js +87 -0
- package/dist/esm/lists/replace-content.js +17 -0
- package/dist/esm/lists/selection.js +50 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/node-width/index.js +7 -0
- package/dist/esm/types/input-rules.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/utils/commands.js +104 -2
- package/dist/esm/utils/document.js +25 -1
- package/dist/esm/utils/index.js +5 -3
- package/dist/esm/utils/input-rules.js +18 -0
- package/dist/esm/utils/prosemirror/autojoin.js +63 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/lists/analytics.d.ts +4 -0
- package/dist/types/lists/indentation.d.ts +5 -0
- package/dist/types/lists/index.d.ts +6 -0
- package/dist/types/lists/node.d.ts +18 -0
- package/dist/types/lists/replace-content.d.ts +8 -0
- package/dist/types/lists/selection.d.ts +13 -0
- package/dist/types/node-width/index.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/input-rules.d.ts +8 -0
- package/dist/types/utils/commands.d.ts +36 -2
- package/dist/types/utils/document.d.ts +4 -0
- package/dist/types/utils/index.d.ts +5 -2
- package/dist/types/utils/input-rules.d.ts +7 -0
- package/dist/types/utils/prosemirror/autojoin.d.ts +13 -0
- package/dist/types-ts4.5/lists/analytics.d.ts +4 -0
- package/dist/types-ts4.5/lists/indentation.d.ts +5 -0
- package/dist/types-ts4.5/lists/index.d.ts +6 -0
- package/dist/types-ts4.5/lists/node.d.ts +18 -0
- package/dist/types-ts4.5/lists/replace-content.d.ts +8 -0
- package/dist/types-ts4.5/lists/selection.d.ts +13 -0
- package/dist/types-ts4.5/node-width/index.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -0
- package/dist/types-ts4.5/types/input-rules.d.ts +8 -0
- package/dist/types-ts4.5/utils/commands.d.ts +42 -2
- package/dist/types-ts4.5/utils/document.d.ts +4 -0
- package/dist/types-ts4.5/utils/index.d.ts +5 -2
- package/dist/types-ts4.5/utils/input-rules.d.ts +7 -0
- package/dist/types-ts4.5/utils/prosemirror/autojoin.d.ts +13 -0
- package/lists/package.json +15 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`2b54c3b0d24`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2b54c3b0d24) - [ED-19203] Decouple text-formatting plugin and editor-core
|
|
8
|
+
|
|
9
|
+
## 74.31.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`d8c1bcdc71a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d8c1bcdc71a) - ED-19217 decoupled lists related util functions from editor-core
|
|
14
|
+
|
|
3
15
|
## 74.30.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCommonListAnalyticsAttributes = exports.countListItemsInSelection = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
var _selection = require("./selection");
|
|
9
|
+
var getCommonListAnalyticsAttributes = function getCommonListAnalyticsAttributes(state) {
|
|
10
|
+
var _state$selection = state.selection,
|
|
11
|
+
$from = _state$selection.$from,
|
|
12
|
+
$to = _state$selection.$to;
|
|
13
|
+
var fromAttrs = (0, _selection.getListItemAttributes)($from);
|
|
14
|
+
var toAttrs = (0, _selection.getListItemAttributes)($to);
|
|
15
|
+
return {
|
|
16
|
+
itemIndexAtSelectionStart: fromAttrs.itemIndex,
|
|
17
|
+
itemIndexAtSelectionEnd: toAttrs.itemIndex,
|
|
18
|
+
indentLevelAtSelectionStart: fromAttrs.indentLevel,
|
|
19
|
+
indentLevelAtSelectionEnd: toAttrs.indentLevel,
|
|
20
|
+
itemsInSelection: countListItemsInSelection(state)
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.getCommonListAnalyticsAttributes = getCommonListAnalyticsAttributes;
|
|
24
|
+
var countListItemsInSelection = function countListItemsInSelection(state) {
|
|
25
|
+
var _state$selection2 = state.selection,
|
|
26
|
+
from = _state$selection2.from,
|
|
27
|
+
to = _state$selection2.to;
|
|
28
|
+
if (from === to) {
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
var count = 0;
|
|
32
|
+
var listSlice = state.doc.cut(from, to);
|
|
33
|
+
listSlice.content.nodesBetween(0, listSlice.content.size, function (node, pos, parent, index) {
|
|
34
|
+
if (parent && (0, _utils.isListItemNode)(parent) && !(0, _utils.isListNode)(node) && index === 0) {
|
|
35
|
+
count++;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return count;
|
|
39
|
+
};
|
|
40
|
+
exports.countListItemsInSelection = countListItemsInSelection;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasValidListIndentationLevel = void 0;
|
|
7
|
+
var _selection = require("./selection");
|
|
8
|
+
var hasValidListIndentationLevel = function hasValidListIndentationLevel(_ref) {
|
|
9
|
+
var tr = _ref.tr,
|
|
10
|
+
maxIndentation = _ref.maxIndentation;
|
|
11
|
+
var initialIndentationLevel = (0, _selection.numberNestedLists)(tr.selection.$from);
|
|
12
|
+
var currentIndentationLevel;
|
|
13
|
+
var currentPos = tr.selection.$to.pos;
|
|
14
|
+
do {
|
|
15
|
+
var resolvedPos = tr.doc.resolve(currentPos);
|
|
16
|
+
currentIndentationLevel = (0, _selection.numberNestedLists)(resolvedPos);
|
|
17
|
+
if (currentIndentationLevel > maxIndentation) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
currentPos++;
|
|
21
|
+
} while (currentIndentationLevel >= initialIndentationLevel);
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
exports.hasValidListIndentationLevel = hasValidListIndentationLevel;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "JoinDirection", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _node.JoinDirection;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "countListItemsInSelection", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _analytics.countListItemsInSelection;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "getCommonListAnalyticsAttributes", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _analytics.getCommonListAnalyticsAttributes;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "getListItemAttributes", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _selection.getListItemAttributes;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "hasValidListIndentationLevel", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _indentation.hasValidListIndentationLevel;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "isBulletList", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _utils.isBulletList;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "isListItemNode", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _utils.isListItemNode;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "isListNode", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _utils.isListNode;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "isListNodeValidContent", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _node.isListNodeValidContent;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "isParagraphNode", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _utils.isParagraphNode;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "joinSiblingLists", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _node.joinSiblingLists;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "moveTargetIntoList", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _replaceContent.moveTargetIntoList;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "normalizeListItemsSelection", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _selection.normalizeListItemsSelection;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var _selection = require("./selection");
|
|
85
|
+
var _replaceContent = require("./replace-content");
|
|
86
|
+
var _node = require("./node");
|
|
87
|
+
var _analytics = require("./analytics");
|
|
88
|
+
var _indentation = require("./indentation");
|
|
89
|
+
var _utils = require("../utils");
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.JoinDirection = void 0;
|
|
7
|
+
exports.isListNodeValidContent = isListNodeValidContent;
|
|
8
|
+
exports.joinSiblingLists = void 0;
|
|
9
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
function isListNodeValidContent(node) {
|
|
12
|
+
var bulletList = node.type.schema.nodes.bulletList;
|
|
13
|
+
if (!bulletList) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
var listFragment = _model.Fragment.from(bulletList.createAndFill());
|
|
17
|
+
return !(0, _utils.isListItemNode)(node) && node.type.validContent(listFragment);
|
|
18
|
+
}
|
|
19
|
+
var JoinDirection = /*#__PURE__*/function (JoinDirection) {
|
|
20
|
+
JoinDirection[JoinDirection["LEFT"] = 1] = "LEFT";
|
|
21
|
+
JoinDirection[JoinDirection["RIGHT"] = -1] = "RIGHT";
|
|
22
|
+
return JoinDirection;
|
|
23
|
+
}({});
|
|
24
|
+
exports.JoinDirection = JoinDirection;
|
|
25
|
+
var joinSiblingLists = function joinSiblingLists(_ref) {
|
|
26
|
+
var tr = _ref.tr,
|
|
27
|
+
direction = _ref.direction,
|
|
28
|
+
forceListType = _ref.forceListType;
|
|
29
|
+
var result = {
|
|
30
|
+
orderedList: 0,
|
|
31
|
+
bulletList: 0
|
|
32
|
+
};
|
|
33
|
+
var doc = tr.doc,
|
|
34
|
+
_tr$selection = tr.selection,
|
|
35
|
+
$from = _tr$selection.$from,
|
|
36
|
+
$to = _tr$selection.$to,
|
|
37
|
+
selection = tr.selection;
|
|
38
|
+
var range = $from.blockRange($to, isListNodeValidContent);
|
|
39
|
+
if (!range) {
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
var rootListNode = doc.nodeAt(range.start);
|
|
43
|
+
var from = (0, _utils.isListNode)(rootListNode) ? range.start : 0;
|
|
44
|
+
var to = (0, _utils.isListNode)(rootListNode) ? range.end : tr.doc.content.size;
|
|
45
|
+
var joins = [];
|
|
46
|
+
doc.nodesBetween(from, to, function (node, pos, parent) {
|
|
47
|
+
var resolvedPos = doc.resolve(pos);
|
|
48
|
+
var nodeBefore = resolvedPos.nodeBefore,
|
|
49
|
+
nodeAfter = resolvedPos.nodeAfter;
|
|
50
|
+
if (!nodeBefore || !nodeAfter || !(0, _utils.isListNode)(nodeBefore) || !(0, _utils.isListNode)(nodeAfter)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
var isNestedList = (0, _utils.isListItemNode)(parent);
|
|
54
|
+
if (!isNestedList && nodeBefore.type !== nodeAfter.type && !forceListType) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
var index = resolvedPos.index();
|
|
58
|
+
var positionPreviousNode = resolvedPos.posAtIndex(index - 1);
|
|
59
|
+
var positionCurrentNode = resolvedPos.posAtIndex(index);
|
|
60
|
+
|
|
61
|
+
// If the previous node is part of the selection, OR
|
|
62
|
+
// If the previous node is not part of the selection and the previous node has the same list type that we’re converting to
|
|
63
|
+
var joinBefore = positionPreviousNode >= from || nodeBefore.type === forceListType;
|
|
64
|
+
if (forceListType) {
|
|
65
|
+
if (joinBefore) {
|
|
66
|
+
tr.setNodeMarkup(positionPreviousNode, forceListType);
|
|
67
|
+
}
|
|
68
|
+
tr.setNodeMarkup(positionCurrentNode, forceListType);
|
|
69
|
+
}
|
|
70
|
+
if (isNestedList && nodeBefore.type !== nodeAfter.type) {
|
|
71
|
+
var nodeType = direction === JoinDirection.RIGHT ? nodeAfter.type : nodeBefore.type;
|
|
72
|
+
tr.setNodeMarkup(positionPreviousNode, nodeType);
|
|
73
|
+
}
|
|
74
|
+
if (joinBefore) {
|
|
75
|
+
joins.push(pos);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (selection.empty && rootListNode && (0, _utils.isListNode)(rootListNode)) {
|
|
79
|
+
var resolvedPos = doc.resolve(range.start + rootListNode.nodeSize);
|
|
80
|
+
var nodeBefore = resolvedPos.nodeBefore,
|
|
81
|
+
nodeAfter = resolvedPos.nodeAfter;
|
|
82
|
+
if (nodeBefore && nodeAfter && (0, _utils.isListNode)(nodeBefore) && (0, _utils.isListNode)(nodeAfter) && nodeAfter.type === nodeBefore.type) {
|
|
83
|
+
joins.push(resolvedPos.pos);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (var i = joins.length - 1; i >= 0; i--) {
|
|
87
|
+
var listNode = tr.doc.nodeAt(joins[i]);
|
|
88
|
+
var listName = listNode === null || listNode === void 0 ? void 0 : listNode.type.name;
|
|
89
|
+
if (listName && (listName === 'orderedList' || listName === 'bulletList')) {
|
|
90
|
+
var amount = result[listName] || 0;
|
|
91
|
+
result[listName] = amount + 1;
|
|
92
|
+
}
|
|
93
|
+
tr.join(joins[i]);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
};
|
|
97
|
+
exports.joinSiblingLists = joinSiblingLists;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.moveTargetIntoList = void 0;
|
|
7
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
|
+
var moveTargetIntoList = function moveTargetIntoList(_ref) {
|
|
9
|
+
var _$target$nodeAfter;
|
|
10
|
+
var insertPosition = _ref.insertPosition,
|
|
11
|
+
$target = _ref.$target;
|
|
12
|
+
// take the text content of the paragraph and insert after the paragraph up until before the the cut
|
|
13
|
+
var from = insertPosition;
|
|
14
|
+
var to = $target.pos + (((_$target$nodeAfter = $target.nodeAfter) === null || _$target$nodeAfter === void 0 ? void 0 : _$target$nodeAfter.nodeSize) || 0); //$cut.pos + $cut.nodeAfter.nodeSize;
|
|
15
|
+
var gapFrom = $target.posAtIndex(0, $target.depth + 1); // start pos of the child
|
|
16
|
+
var gapTo = $target.doc.resolve(gapFrom).end(); // end pos of the paragraph
|
|
17
|
+
|
|
18
|
+
if (gapTo - gapFrom === 0) {
|
|
19
|
+
return new _transform.ReplaceStep(from, to, $target.doc.slice(insertPosition, $target.pos));
|
|
20
|
+
}
|
|
21
|
+
var step = new _transform.ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
22
|
+
return step;
|
|
23
|
+
};
|
|
24
|
+
exports.moveTargetIntoList = moveTargetIntoList;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.numberNestedLists = exports.normalizeListItemsSelection = exports.getListItemAttributes = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _utils2 = require("../utils");
|
|
10
|
+
var numberNestedLists = function numberNestedLists(resolvedPos) {
|
|
11
|
+
var count = 0;
|
|
12
|
+
for (var i = resolvedPos.depth - 1; i > 0; i--) {
|
|
13
|
+
var node = resolvedPos.node(i);
|
|
14
|
+
if ((0, _utils2.isListNode)(node)) {
|
|
15
|
+
count += 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return count;
|
|
19
|
+
};
|
|
20
|
+
exports.numberNestedLists = numberNestedLists;
|
|
21
|
+
var getListItemAttributes = function getListItemAttributes($pos) {
|
|
22
|
+
var indentLevel = numberNestedLists($pos) - 1;
|
|
23
|
+
var itemAtPos = (0, _utils.findParentNodeClosestToPos)($pos, _utils2.isListItemNode);
|
|
24
|
+
|
|
25
|
+
// Get the index of the current item relative to parent (parent is at item depth - 1)
|
|
26
|
+
var itemIndex = $pos.index(itemAtPos ? itemAtPos.depth - 1 : undefined);
|
|
27
|
+
return {
|
|
28
|
+
indentLevel: indentLevel,
|
|
29
|
+
itemIndex: itemIndex
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.getListItemAttributes = getListItemAttributes;
|
|
33
|
+
var normalizeListItemsSelection = function normalizeListItemsSelection(_ref) {
|
|
34
|
+
var selection = _ref.selection,
|
|
35
|
+
doc = _ref.doc;
|
|
36
|
+
if (selection.empty) {
|
|
37
|
+
return selection;
|
|
38
|
+
}
|
|
39
|
+
var $from = selection.$from,
|
|
40
|
+
$to = selection.$to;
|
|
41
|
+
if (selection instanceof _state.NodeSelection) {
|
|
42
|
+
var _head = resolvePositionToStartOfListItem($from);
|
|
43
|
+
return new _state.TextSelection(_head, _head);
|
|
44
|
+
}
|
|
45
|
+
var head = resolvePositionToStartOfListItem($from);
|
|
46
|
+
var anchor = resolvePositionToEndOfListItem($to);
|
|
47
|
+
return new _state.TextSelection(anchor, head);
|
|
48
|
+
};
|
|
49
|
+
exports.normalizeListItemsSelection = normalizeListItemsSelection;
|
|
50
|
+
var resolvePositionToStartOfListItem = function resolvePositionToStartOfListItem($pos) {
|
|
51
|
+
var fromRange = $pos.blockRange($pos, _utils2.isListItemNode);
|
|
52
|
+
var fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
|
|
53
|
+
return fromPosition;
|
|
54
|
+
};
|
|
55
|
+
var resolvePositionToEndOfListItem = function resolvePositionToEndOfListItem($pos) {
|
|
56
|
+
var toRange = $pos.blockRange($pos, _utils2.isListItemNode);
|
|
57
|
+
var toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
|
|
58
|
+
return toPosition;
|
|
59
|
+
};
|
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
18
18
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
19
|
-
var packageVersion = "74.
|
|
19
|
+
var packageVersion = "74.32.0";
|
|
20
20
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
21
21
|
// Remove URL as it has UGC
|
|
22
22
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.layoutToWidth = exports.getTableContainerWidth = exports.getParentNodeWidth = void 0;
|
|
6
|
+
exports.layoutToWidth = exports.getTableWidthWithNumberColumn = exports.getTableContainerWidth = exports.getParentNodeWidth = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
8
8
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
9
9
|
var _constants = require("@atlaskit/theme/constants");
|
|
@@ -110,4 +110,12 @@ var getTableContainerWidth = function getTableContainerWidth(node) {
|
|
|
110
110
|
}
|
|
111
111
|
return layoutToWidth[node.attrs.layout];
|
|
112
112
|
};
|
|
113
|
-
exports.getTableContainerWidth = getTableContainerWidth;
|
|
113
|
+
exports.getTableContainerWidth = getTableContainerWidth;
|
|
114
|
+
var getTableWidthWithNumberColumn = function getTableWidthWithNumberColumn(node, offset) {
|
|
115
|
+
var isNumberColumnEnabled = node.attrs.isNumberColumnEnabled;
|
|
116
|
+
if (isNumberColumnEnabled && offset > 0) {
|
|
117
|
+
return getTableContainerWidth(node) - offset;
|
|
118
|
+
}
|
|
119
|
+
return getTableContainerWidth(node);
|
|
120
|
+
};
|
|
121
|
+
exports.getTableWidthWithNumberColumn = getTableWidthWithNumberColumn;
|
|
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
24
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); }; }
|
|
25
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; } } /** @jsx jsx */
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "74.
|
|
27
|
+
var packageVersion = "74.32.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
+
exports.walkPrevNode = exports.walkNextNode = exports.isEmptySelectionAtStart = exports.isEmptySelectionAtEnd = exports.insertContentDeleteRange = exports.filterCommand = exports.deleteEmptyParagraphAndMoveBlockUp = void 0;
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var _selection = require("../selection");
|
|
11
|
+
var _editorCoreUtils = require("./editor-core-utils");
|
|
7
12
|
var filter = function filter(predicates, cmd) {
|
|
8
13
|
return function (state, dispatch, view) {
|
|
9
14
|
if (!Array.isArray(predicates)) {
|
|
@@ -17,4 +22,107 @@ var filter = function filter(predicates, cmd) {
|
|
|
17
22
|
return cmd(state, dispatch, view) || false;
|
|
18
23
|
};
|
|
19
24
|
};
|
|
20
|
-
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Walk forwards from a position until we encounter the (inside) start of
|
|
28
|
+
* the next node, or reach the end of the document.
|
|
29
|
+
*
|
|
30
|
+
* @param $startPos Position to start walking from.
|
|
31
|
+
*/
|
|
32
|
+
exports.filterCommand = filter;
|
|
33
|
+
var walkNextNode = function walkNextNode($startPos) {
|
|
34
|
+
var $pos = $startPos;
|
|
35
|
+
|
|
36
|
+
// invariant 1: don't walk past the end of the document
|
|
37
|
+
// invariant 2: we are at the beginning or
|
|
38
|
+
// we haven't walked to the start of *any* node
|
|
39
|
+
// parentOffset includes textOffset.
|
|
40
|
+
while ($pos.pos < $pos.doc.nodeSize - 2 && ($pos.pos === $startPos.pos || $pos.parentOffset > 0)) {
|
|
41
|
+
$pos = $pos.doc.resolve($pos.pos + 1);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
$pos: $pos,
|
|
45
|
+
foundNode: $pos.pos < $pos.doc.nodeSize - 2
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Walk backwards from a position until we encounter the (inside) end of
|
|
51
|
+
* the previous node, or reach the start of the document.
|
|
52
|
+
*
|
|
53
|
+
* @param $startPos Position to start walking from.
|
|
54
|
+
*/
|
|
55
|
+
exports.walkNextNode = walkNextNode;
|
|
56
|
+
var walkPrevNode = function walkPrevNode($startPos) {
|
|
57
|
+
var $pos = $startPos;
|
|
58
|
+
while ($pos.pos > 0 && ($pos.pos === $startPos.pos || $pos.parentOffset < $pos.parent.nodeSize - 2)) {
|
|
59
|
+
$pos = $pos.doc.resolve($pos.pos - 1);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
$pos: $pos,
|
|
63
|
+
foundNode: $pos.pos > 0
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* If the selection is empty, is inside a paragraph node and `canNextNodeMoveUp` is true then delete current paragraph
|
|
69
|
+
* and move the node below it up. The selection will be retained, to be placed in the moved node.
|
|
70
|
+
*
|
|
71
|
+
* @param canNextNodeMoveUp check if node directly after the selection is able to be brought up to selection
|
|
72
|
+
* @returns PM Command
|
|
73
|
+
*/
|
|
74
|
+
exports.walkPrevNode = walkPrevNode;
|
|
75
|
+
var deleteEmptyParagraphAndMoveBlockUp = function deleteEmptyParagraphAndMoveBlockUp(canNextNodeMoveUp) {
|
|
76
|
+
return function (state, dispatch, view) {
|
|
77
|
+
var _state$selection = state.selection,
|
|
78
|
+
_state$selection$$fro = _state$selection.$from,
|
|
79
|
+
pos = _state$selection$$fro.pos,
|
|
80
|
+
parent = _state$selection$$fro.parent,
|
|
81
|
+
$head = _state$selection.$head,
|
|
82
|
+
empty = _state$selection.empty,
|
|
83
|
+
tr = state.tr,
|
|
84
|
+
doc = state.doc;
|
|
85
|
+
var _walkNextNode = walkNextNode($head),
|
|
86
|
+
$pos = _walkNextNode.$pos;
|
|
87
|
+
var nextPMNode = doc.nodeAt($pos.pos - 1);
|
|
88
|
+
if (empty && nextPMNode && canNextNodeMoveUp(nextPMNode) && (0, _editorCoreUtils.isEmptyParagraph)(parent) && view !== null && view !== void 0 && view.endOfTextblock('right')) {
|
|
89
|
+
tr.deleteRange(pos - 1, pos + 1);
|
|
90
|
+
if (dispatch) {
|
|
91
|
+
dispatch(tr);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
exports.deleteEmptyParagraphAndMoveBlockUp = deleteEmptyParagraphAndMoveBlockUp;
|
|
99
|
+
var insertContentDeleteRange = function insertContentDeleteRange(tr, getSelectionResolvedPos, insertions, deletions) {
|
|
100
|
+
insertions.forEach(function (contentInsert) {
|
|
101
|
+
var _contentInsert = (0, _slicedToArray2.default)(contentInsert, 2),
|
|
102
|
+
content = _contentInsert[0],
|
|
103
|
+
pos = _contentInsert[1];
|
|
104
|
+
tr.insert(tr.mapping.map(pos), content);
|
|
105
|
+
});
|
|
106
|
+
deletions.forEach(function (deleteRange) {
|
|
107
|
+
var _deleteRange = (0, _slicedToArray2.default)(deleteRange, 2),
|
|
108
|
+
firstPos = _deleteRange[0],
|
|
109
|
+
lastPos = _deleteRange[1];
|
|
110
|
+
tr.delete(tr.mapping.map(firstPos), tr.mapping.map(lastPos));
|
|
111
|
+
});
|
|
112
|
+
tr.setSelection(new _state.TextSelection(getSelectionResolvedPos(tr)));
|
|
113
|
+
};
|
|
114
|
+
exports.insertContentDeleteRange = insertContentDeleteRange;
|
|
115
|
+
var isEmptySelectionAtStart = function isEmptySelectionAtStart(state) {
|
|
116
|
+
var _state$selection2 = state.selection,
|
|
117
|
+
empty = _state$selection2.empty,
|
|
118
|
+
$from = _state$selection2.$from;
|
|
119
|
+
return empty && ($from.parentOffset === 0 || state.selection instanceof _selection.GapCursorSelection);
|
|
120
|
+
};
|
|
121
|
+
exports.isEmptySelectionAtStart = isEmptySelectionAtStart;
|
|
122
|
+
var isEmptySelectionAtEnd = function isEmptySelectionAtEnd(state) {
|
|
123
|
+
var _state$selection3 = state.selection,
|
|
124
|
+
empty = _state$selection3.empty,
|
|
125
|
+
$from = _state$selection3.$from;
|
|
126
|
+
return empty && ($from.end() === $from.pos || state.selection instanceof _selection.GapCursorSelection);
|
|
127
|
+
};
|
|
128
|
+
exports.isEmptySelectionAtEnd = isEmptySelectionAtEnd;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.bracketTyped = bracketTyped;
|
|
7
7
|
exports.getStepRange = void 0;
|
|
8
8
|
exports.hasDocAsParent = hasDocAsParent;
|
|
9
|
+
exports.hasVisibleContent = hasVisibleContent;
|
|
9
10
|
exports.isEmptyDocument = isEmptyDocument;
|
|
10
11
|
exports.nodesBetweenChanged = nodesBetweenChanged;
|
|
11
12
|
exports.processRawValue = processRawValue;
|
|
@@ -255,4 +256,28 @@ var maySanitizePrivateContent = function maySanitizePrivateContent(entity, provi
|
|
|
255
256
|
return (0, _privacyFilter.sanitizeNodeForPrivacy)(entity, providerFactory);
|
|
256
257
|
}
|
|
257
258
|
return entity;
|
|
258
|
-
};
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns false if node contains only empty inline nodes and hardBreaks.
|
|
263
|
+
*/
|
|
264
|
+
function hasVisibleContent(node) {
|
|
265
|
+
var isInlineNodeHasVisibleContent = function isInlineNodeHasVisibleContent(inlineNode) {
|
|
266
|
+
return inlineNode.isText ? !!inlineNode.textContent.trim() : inlineNode.type.name !== 'hardBreak';
|
|
267
|
+
};
|
|
268
|
+
if (node.isInline) {
|
|
269
|
+
return isInlineNodeHasVisibleContent(node);
|
|
270
|
+
} else if (node.isBlock && (node.isLeaf || node.isAtom)) {
|
|
271
|
+
return true;
|
|
272
|
+
} else if (!node.childCount) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
for (var _index = 0; _index < node.childCount; _index++) {
|
|
276
|
+
var child = node.child(_index);
|
|
277
|
+
var invisibleNodeTypes = ['paragraph', 'text', 'hardBreak'];
|
|
278
|
+
if (!invisibleNodeTypes.includes(child.type.name) || hasVisibleContent(child)) {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}
|