@atlaskit/editor-common 122.12.0 → 123.0.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 +22 -0
- package/dist/cjs/lists/flatten-list.js +1 -73
- package/dist/cjs/lists/index.js +0 -26
- package/dist/cjs/lists/node.js +1 -78
- package/dist/cjs/lists/replace-content.js +1 -9
- package/dist/cjs/lists/selection.js +2 -29
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/node-anchor/node-anchor-provider.js +1 -3
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/lists/flatten-list.js +1 -76
- package/dist/es2019/lists/index.js +2 -4
- package/dist/es2019/lists/node.js +0 -77
- package/dist/es2019/lists/replace-content.js +1 -3
- package/dist/es2019/lists/selection.js +1 -31
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/node-anchor/node-anchor-provider.js +1 -3
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/lists/flatten-list.js +1 -71
- package/dist/esm/lists/index.js +2 -4
- package/dist/esm/lists/node.js +0 -77
- package/dist/esm/lists/replace-content.js +1 -3
- package/dist/esm/lists/selection.js +1 -28
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/node-anchor/node-anchor-provider.js +1 -3
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/lists/flatten-list.d.ts +0 -28
- package/dist/types/lists/index.d.ts +2 -4
- package/dist/types/lists/node.d.ts +0 -1
- package/dist/types/lists/replace-content.d.ts +1 -1
- package/dist/types/lists/selection.d.ts +1 -7
- package/package.json +3 -3
- package/dist/cjs/lists/indentation.js +0 -23
- package/dist/cjs/lists/wrapTaskListIntoListAbove.js +0 -30
- package/dist/es2019/lists/indentation.js +0 -18
- package/dist/es2019/lists/wrapTaskListIntoListAbove.js +0 -24
- package/dist/esm/lists/indentation.js +0 -17
- package/dist/esm/lists/wrapTaskListIntoListAbove.js +0 -24
- package/dist/types/lists/indentation.d.ts +0 -5
- package/dist/types/lists/wrapTaskListIntoListAbove.d.ts +0 -2
- package/lists/indentation/package.json +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 123.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`3b3e57040d2d0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3b3e57040d2d0) -
|
|
8
|
+
Remove retired flexible-list feature controls and schema styles while preserving shipped list
|
|
9
|
+
normalization, hidden-marker rendering for wrapper list items, task paste and task-list tab
|
|
10
|
+
behavior, and toolbar indentation behavior.
|
|
11
|
+
|
|
12
|
+
Remove unused legacy list utilities after the flexible-list rollout: `flattenList`,
|
|
13
|
+
`normalizeListItemsSelection`, `hasValidListIndentationLevel`,
|
|
14
|
+
`processNestedTaskListsInSameLevel`, and `wrapTaskListIntoListAbove`. The
|
|
15
|
+
`@atlaskit/editor-common/lists/indentation` entrypoint is also removed.
|
|
16
|
+
|
|
17
|
+
Consumers of the removed runtime helpers should use the editor list plugin's indent/outdent
|
|
18
|
+
commands. The shared `FlattenedItem`, `FlattenListOptions`, and `FlattenListResult` types remain
|
|
19
|
+
available for the active list implementations.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 122.12.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -2,76 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.flattenList = flattenList;
|
|
7
|
-
/**
|
|
8
|
-
* Type-specific predicates that vary between regular lists and task lists.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Flattens a list-like PM structure (regular list or task list) into an
|
|
13
|
-
* array of content-bearing items with computed depths.
|
|
14
|
-
*
|
|
15
|
-
* Uses `doc.nodesBetween` to walk the tree and delegates type-specific
|
|
16
|
-
* decisions to the provided predicates. The core algorithm — selection
|
|
17
|
-
* intersection, depth adjustment, index tracking — is shared.
|
|
18
|
-
*
|
|
19
|
-
* @private
|
|
20
|
-
* @deprecated Cannot represent content placed between an item's sub-lists
|
|
21
|
-
* (e.g. `li(p, ul, p, ul)`). Callers provide their own flatten that handles this.
|
|
22
|
-
*/
|
|
23
|
-
function flattenList(options, predicates) {
|
|
24
|
-
var doc = options.doc,
|
|
25
|
-
rootListStart = options.rootListStart,
|
|
26
|
-
rootListEnd = options.rootListEnd,
|
|
27
|
-
selectionFrom = options.selectionFrom,
|
|
28
|
-
selectionTo = options.selectionTo,
|
|
29
|
-
indentDelta = options.indentDelta,
|
|
30
|
-
maxDepth = options.maxDepth;
|
|
31
|
-
var isContentNode = predicates.isContentNode,
|
|
32
|
-
getSelectionBounds = predicates.getSelectionBounds,
|
|
33
|
-
getDepth = predicates.getDepth;
|
|
34
|
-
var items = [];
|
|
35
|
-
var startIndex = -1;
|
|
36
|
-
var endIndex = -1;
|
|
37
|
-
var exceedsMaxDepth = false;
|
|
38
|
-
var rootDepth = doc.resolve(rootListStart).depth;
|
|
39
|
-
doc.nodesBetween(rootListStart, rootListEnd, function (node, pos, parent) {
|
|
40
|
-
if (!isContentNode(node, parent) || parent == null) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
var _getSelectionBounds = getSelectionBounds(node, pos),
|
|
44
|
-
start = _getSelectionBounds.start,
|
|
45
|
-
end = _getSelectionBounds.end;
|
|
46
|
-
var isSelected = selectionFrom === selectionTo ? selectionFrom >= start && selectionFrom <= end : start < selectionTo && end > selectionFrom;
|
|
47
|
-
var resolvedDepth = doc.resolve(pos).depth;
|
|
48
|
-
var depth = getDepth(resolvedDepth, rootDepth) + (isSelected ? indentDelta : 0);
|
|
49
|
-
items.push({
|
|
50
|
-
node: node,
|
|
51
|
-
pos: pos,
|
|
52
|
-
depth: depth,
|
|
53
|
-
isSelected: isSelected,
|
|
54
|
-
listType: parent.type.name,
|
|
55
|
-
parentListAttrs: parent.attrs
|
|
56
|
-
});
|
|
57
|
-
if (isSelected) {
|
|
58
|
-
var index = items.length - 1;
|
|
59
|
-
if (startIndex === -1) {
|
|
60
|
-
startIndex = index;
|
|
61
|
-
}
|
|
62
|
-
endIndex = index;
|
|
63
|
-
if (maxDepth != null && depth >= maxDepth) {
|
|
64
|
-
exceedsMaxDepth = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
});
|
|
69
|
-
if (items.length === 0 || startIndex === -1 || exceedsMaxDepth) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
items: items,
|
|
74
|
-
startIndex: startIndex,
|
|
75
|
-
endIndex: endIndex
|
|
76
|
-
};
|
|
77
|
-
}
|
|
5
|
+
});
|
package/dist/cjs/lists/index.js
CHANGED
|
@@ -27,12 +27,6 @@ Object.defineProperty(exports, "countListItemsInSelection", {
|
|
|
27
27
|
return _countListItemsInSelection.countListItemsInSelection;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "flattenList", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _flattenList.flattenList;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
30
|
Object.defineProperty(exports, "getBlockMarkAttrs", {
|
|
37
31
|
enumerable: true,
|
|
38
32
|
get: function get() {
|
|
@@ -57,12 +51,6 @@ Object.defineProperty(exports, "getListItemAttributes", {
|
|
|
57
51
|
return _selection.getListItemAttributes;
|
|
58
52
|
}
|
|
59
53
|
});
|
|
60
|
-
Object.defineProperty(exports, "hasValidListIndentationLevel", {
|
|
61
|
-
enumerable: true,
|
|
62
|
-
get: function get() {
|
|
63
|
-
return _indentation.hasValidListIndentationLevel;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
54
|
Object.defineProperty(exports, "isBulletList", {
|
|
67
55
|
enumerable: true,
|
|
68
56
|
get: function get() {
|
|
@@ -117,18 +105,6 @@ Object.defineProperty(exports, "narrowReplacementRange", {
|
|
|
117
105
|
return _narrowReplacementRange.narrowReplacementRange;
|
|
118
106
|
}
|
|
119
107
|
});
|
|
120
|
-
Object.defineProperty(exports, "normalizeListItemsSelection", {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: function get() {
|
|
123
|
-
return _selection.normalizeListItemsSelection;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(exports, "processNestedTaskListsInSameLevel", {
|
|
127
|
-
enumerable: true,
|
|
128
|
-
get: function get() {
|
|
129
|
-
return _node.processNestedTaskListsInSameLevel;
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
108
|
Object.defineProperty(exports, "reconcileBlockMarkForContainerAtPos", {
|
|
133
109
|
enumerable: true,
|
|
134
110
|
get: function get() {
|
|
@@ -160,11 +136,9 @@ var _isListNodeValidContent = require("./isListNodeValidContent");
|
|
|
160
136
|
var _node = require("./node");
|
|
161
137
|
var _analytics = require("./analytics");
|
|
162
138
|
var _countListItemsInSelection = require("./countListItemsInSelection");
|
|
163
|
-
var _indentation = require("./indentation");
|
|
164
139
|
var _restoreSelection = require("./restore-selection");
|
|
165
140
|
var _buildReplacementFragment = require("./build-replacement-fragment");
|
|
166
141
|
var _narrowReplacementRange = require("./narrow-replacement-range");
|
|
167
|
-
var _flattenList = require("./flatten-list");
|
|
168
142
|
var _blockMark = require("./block-mark");
|
|
169
143
|
var _utils = require("../utils");
|
|
170
144
|
var _messages = require("./messages");
|
package/dist/cjs/lists/node.js
CHANGED
|
@@ -15,11 +15,10 @@ Object.defineProperty(exports, "isListNodeValidContent", {
|
|
|
15
15
|
return _isListNodeValidContent.isListNodeValidContent;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
exports.
|
|
18
|
+
exports.joinSiblingLists = void 0;
|
|
19
19
|
var _utils = require("../utils");
|
|
20
20
|
var _isListNodeValidContent = require("./isListNodeValidContent");
|
|
21
21
|
var _JoinDirection = require("./JoinDirection");
|
|
22
|
-
var _wrapTaskListIntoListAbove = require("./wrapTaskListIntoListAbove");
|
|
23
22
|
var joinSiblingLists = exports.joinSiblingLists = function joinSiblingLists(_ref) {
|
|
24
23
|
var tr = _ref.tr,
|
|
25
24
|
direction = _ref.direction,
|
|
@@ -93,82 +92,6 @@ var joinSiblingLists = exports.joinSiblingLists = function joinSiblingLists(_ref
|
|
|
93
92
|
return result;
|
|
94
93
|
};
|
|
95
94
|
|
|
96
|
-
/**
|
|
97
|
-
* Returns the prosemirror position for the child at give index inside the parent node.
|
|
98
|
-
* Example: Considering doc structure as below using the function
|
|
99
|
-
* passing parent resolved position for li and index 2
|
|
100
|
-
* would return starting position of taskList
|
|
101
|
-
* DOC STRUCTURE:
|
|
102
|
-
* ol()
|
|
103
|
-
* ( li(
|
|
104
|
-
* p('text'),
|
|
105
|
-
* ul(content),
|
|
106
|
-
* taskList(),
|
|
107
|
-
* )
|
|
108
|
-
* )
|
|
109
|
-
* @param $from Starting resolved position for the parent node of the child we are looking for.
|
|
110
|
-
* @param index Index of the child node we want the position for.
|
|
111
|
-
* @returns
|
|
112
|
-
*/
|
|
113
|
-
var findStartPositionOfChildWithIndex = function findStartPositionOfChildWithIndex($from, index) {
|
|
114
|
-
var parent = $from.node();
|
|
115
|
-
var currentPos = $from.pos + 1;
|
|
116
|
-
for (var i = 0; i < index; i++) {
|
|
117
|
-
currentPos += parent.child(i).nodeSize;
|
|
118
|
-
}
|
|
119
|
-
return currentPos;
|
|
120
|
-
};
|
|
121
|
-
var findGrandParentResolvedPos = function findGrandParentResolvedPos(tr, $from) {
|
|
122
|
-
return $from.depth > 2 ? tr.doc.resolve($from.start($from.depth - 2)) : null;
|
|
123
|
-
};
|
|
124
|
-
var findNestedTaskListsIndexAtSameLevel = function findNestedTaskListsIndexAtSameLevel(tr, $from) {
|
|
125
|
-
/*
|
|
126
|
-
Currently our cursor would be inside a pargraph of a list of type numbered/bullet list,
|
|
127
|
-
we need to find the grandparent of the cursor which is the list at same level of taskList.
|
|
128
|
-
We can get the root list item(inside which various lists are being resolved before outdenting) by going one depth above that list.
|
|
129
|
-
*/
|
|
130
|
-
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
131
|
-
var rootListItem = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.node(nestedListResolvedPos.depth - 1);
|
|
132
|
-
var nestedTaskListsIndexes = [];
|
|
133
|
-
var rootListItemChildCount = (rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.childCount) || 0;
|
|
134
|
-
// first child of list item is always paragraph (i = 0) so we start from 1
|
|
135
|
-
for (var i = 1; i < rootListItemChildCount; i++) {
|
|
136
|
-
if ((rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.child(i).type.name) === 'taskList') {
|
|
137
|
-
nestedTaskListsIndexes.push(i);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return nestedTaskListsIndexes;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
144
|
-
var processNestedTaskListsInSameLevel = exports.processNestedTaskListsInSameLevel = function processNestedTaskListsInSameLevel(tr) {
|
|
145
|
-
var $from = tr.selection.$from;
|
|
146
|
-
var nestedTaskListIndexes = findNestedTaskListsIndexAtSameLevel(tr, $from);
|
|
147
|
-
if (nestedTaskListIndexes.length === 0) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
151
|
-
var rootListItemStart = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.start(nestedListResolvedPos.depth - 1);
|
|
152
|
-
|
|
153
|
-
/* We need not wrap the taskList present above other lists since it doesn't affect the flow. */
|
|
154
|
-
var nestedTaskListIndexesToWrap = nestedTaskListIndexes.filter(function (index) {
|
|
155
|
-
return index > 1;
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
/*
|
|
159
|
-
Wraps the taskLists present at each index mentioned in the nestedTaskListIndexesToWrap to the list above it.
|
|
160
|
-
After each wrap the indexes changes since two lists are being merged into one,
|
|
161
|
-
so we keep track of it and use it to access actual calculated taskList indexes.
|
|
162
|
-
*/
|
|
163
|
-
if (rootListItemStart) {
|
|
164
|
-
var taskListsFixedNested = 0;
|
|
165
|
-
nestedTaskListIndexesToWrap.forEach(function (index) {
|
|
166
|
-
(0, _wrapTaskListIntoListAbove.wrapTaskListIntoListAbove)(tr, findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - taskListsFixedNested), findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - 1 - taskListsFixedNested));
|
|
167
|
-
taskListsFixedNested++;
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
return;
|
|
171
|
-
};
|
|
172
95
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
173
96
|
|
|
174
97
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
@@ -4,14 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.moveTargetIntoList = void 0;
|
|
7
|
-
Object.defineProperty(exports, "wrapTaskListIntoListAbove", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _wrapTaskListIntoListAbove.wrapTaskListIntoListAbove;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
7
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
14
|
-
var _wrapTaskListIntoListAbove = require("./wrapTaskListIntoListAbove");
|
|
15
8
|
var moveTargetIntoList = exports.moveTargetIntoList = function moveTargetIntoList(_ref) {
|
|
16
9
|
var _$target$nodeAfter;
|
|
17
10
|
var insertPosition = _ref.insertPosition,
|
|
@@ -27,5 +20,4 @@ var moveTargetIntoList = exports.moveTargetIntoList = function moveTargetIntoLis
|
|
|
27
20
|
}
|
|
28
21
|
var step = new _transform.ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
29
22
|
return step;
|
|
30
|
-
};
|
|
31
|
-
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
23
|
+
};
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getListItemAttributes = void 0;
|
|
7
7
|
Object.defineProperty(exports, "numberNestedLists", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function get() {
|
|
10
10
|
return _numberNestedLists.numberNestedLists;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
13
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
15
14
|
var _utils2 = require("../utils");
|
|
16
15
|
var _numberNestedLists = require("./numberNestedLists");
|
|
@@ -26,31 +25,5 @@ var getListItemAttributes = exports.getListItemAttributes = function getListItem
|
|
|
26
25
|
itemIndex: itemIndex
|
|
27
26
|
};
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
var normalizeListItemsSelection = exports.normalizeListItemsSelection = function normalizeListItemsSelection(_ref) {
|
|
31
|
-
var selection = _ref.selection,
|
|
32
|
-
doc = _ref.doc;
|
|
33
|
-
if (selection.empty) {
|
|
34
|
-
return selection;
|
|
35
|
-
}
|
|
36
|
-
var $from = selection.$from,
|
|
37
|
-
$to = selection.$to;
|
|
38
|
-
if (selection instanceof _state.NodeSelection) {
|
|
39
|
-
var _head = resolvePositionToStartOfListItem($from);
|
|
40
|
-
return new _state.TextSelection(_head, _head);
|
|
41
|
-
}
|
|
42
|
-
var head = resolvePositionToStartOfListItem($from);
|
|
43
|
-
var anchor = resolvePositionToEndOfListItem($to);
|
|
44
|
-
return new _state.TextSelection(anchor, head);
|
|
45
|
-
};
|
|
46
|
-
var resolvePositionToStartOfListItem = function resolvePositionToStartOfListItem($pos) {
|
|
47
|
-
var fromRange = $pos.blockRange($pos, _utils2.isListItemNode);
|
|
48
|
-
var fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
|
|
49
|
-
return fromPosition;
|
|
50
|
-
};
|
|
51
|
-
var resolvePositionToEndOfListItem = function resolvePositionToEndOfListItem($pos) {
|
|
52
|
-
var toRange = $pos.blockRange($pos, _utils2.isListItemNode);
|
|
53
|
-
var toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
|
|
54
|
-
return toPosition;
|
|
55
|
-
};
|
|
28
|
+
|
|
56
29
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
@@ -27,7 +27,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
27
27
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
28
28
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
29
29
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
30
|
-
var packageVersion = "122.
|
|
30
|
+
var packageVersion = "122.12.0";
|
|
31
31
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
32
32
|
// Remove URL as it has UGC
|
|
33
33
|
// Ignored via go/ees007
|
|
@@ -8,10 +8,8 @@ exports.getNodeIdProvider = exports.NodeAnchorProvider = void 0;
|
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
12
11
|
var _utils = require("../utils");
|
|
13
12
|
var _dynamicBitArray = require("./dynamic-bit-array");
|
|
14
|
-
var _shouldEnableLimitedMode = require("./should-enable-limited-mode");
|
|
15
13
|
// The slice of `@atlaskit/editor-plugin-limited-mode`'s state read below. Declared
|
|
16
14
|
// structurally because `editor-common` must not depend on a plugin package.
|
|
17
15
|
|
|
@@ -123,7 +121,7 @@ var nodeIdProviderMap = new WeakMap();
|
|
|
123
121
|
*/
|
|
124
122
|
var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
|
|
125
123
|
var _limitedModePluginKey, _limitedModePluginKey2;
|
|
126
|
-
return (
|
|
124
|
+
return (_limitedModePluginKey = (_limitedModePluginKey2 = limitedModePluginKey.getState(editorView.state)) === null || _limitedModePluginKey2 === void 0 ? void 0 : _limitedModePluginKey2.documentSizeBreachesThreshold) !== null && _limitedModePluginKey !== void 0 ? _limitedModePluginKey : false;
|
|
127
125
|
};
|
|
128
126
|
|
|
129
127
|
// Get the NodeIdProvider for a specific EditorView instance.
|
|
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
24
24
|
* @jsx jsx
|
|
25
25
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
26
26
|
var packageName = "@atlaskit/editor-common";
|
|
27
|
-
var packageVersion = "122.
|
|
27
|
+
var packageVersion = "122.12.0";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var fadeIn = (0, _react2.keyframes)({
|
|
@@ -1,76 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Type-specific predicates that vary between regular lists and task lists.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Flattens a list-like PM structure (regular list or task list) into an
|
|
7
|
-
* array of content-bearing items with computed depths.
|
|
8
|
-
*
|
|
9
|
-
* Uses `doc.nodesBetween` to walk the tree and delegates type-specific
|
|
10
|
-
* decisions to the provided predicates. The core algorithm — selection
|
|
11
|
-
* intersection, depth adjustment, index tracking — is shared.
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
14
|
-
* @deprecated Cannot represent content placed between an item's sub-lists
|
|
15
|
-
* (e.g. `li(p, ul, p, ul)`). Callers provide their own flatten that handles this.
|
|
16
|
-
*/
|
|
17
|
-
export function flattenList(options, predicates) {
|
|
18
|
-
const {
|
|
19
|
-
doc,
|
|
20
|
-
rootListStart,
|
|
21
|
-
rootListEnd,
|
|
22
|
-
selectionFrom,
|
|
23
|
-
selectionTo,
|
|
24
|
-
indentDelta,
|
|
25
|
-
maxDepth
|
|
26
|
-
} = options;
|
|
27
|
-
const {
|
|
28
|
-
isContentNode,
|
|
29
|
-
getSelectionBounds,
|
|
30
|
-
getDepth
|
|
31
|
-
} = predicates;
|
|
32
|
-
const items = [];
|
|
33
|
-
let startIndex = -1;
|
|
34
|
-
let endIndex = -1;
|
|
35
|
-
let exceedsMaxDepth = false;
|
|
36
|
-
const rootDepth = doc.resolve(rootListStart).depth;
|
|
37
|
-
doc.nodesBetween(rootListStart, rootListEnd, (node, pos, parent) => {
|
|
38
|
-
if (!isContentNode(node, parent) || parent == null) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
const {
|
|
42
|
-
start,
|
|
43
|
-
end
|
|
44
|
-
} = getSelectionBounds(node, pos);
|
|
45
|
-
const isSelected = selectionFrom === selectionTo ? selectionFrom >= start && selectionFrom <= end : start < selectionTo && end > selectionFrom;
|
|
46
|
-
const resolvedDepth = doc.resolve(pos).depth;
|
|
47
|
-
const depth = getDepth(resolvedDepth, rootDepth) + (isSelected ? indentDelta : 0);
|
|
48
|
-
items.push({
|
|
49
|
-
node,
|
|
50
|
-
pos,
|
|
51
|
-
depth,
|
|
52
|
-
isSelected,
|
|
53
|
-
listType: parent.type.name,
|
|
54
|
-
parentListAttrs: parent.attrs
|
|
55
|
-
});
|
|
56
|
-
if (isSelected) {
|
|
57
|
-
const index = items.length - 1;
|
|
58
|
-
if (startIndex === -1) {
|
|
59
|
-
startIndex = index;
|
|
60
|
-
}
|
|
61
|
-
endIndex = index;
|
|
62
|
-
if (maxDepth != null && depth >= maxDepth) {
|
|
63
|
-
exceedsMaxDepth = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return true;
|
|
67
|
-
});
|
|
68
|
-
if (items.length === 0 || startIndex === -1 || exceedsMaxDepth) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
items,
|
|
73
|
-
startIndex,
|
|
74
|
-
endIndex
|
|
75
|
-
};
|
|
76
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// Disable no-re-export rule for entry point files
|
|
2
2
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
3
3
|
|
|
4
|
-
export { getListItemAttributes
|
|
4
|
+
export { getListItemAttributes } from './selection';
|
|
5
5
|
export { moveTargetIntoList } from './replace-content';
|
|
6
6
|
export { JoinDirection } from './JoinDirection';
|
|
7
7
|
export { isListNodeValidContent } from './isListNodeValidContent';
|
|
8
|
-
export { joinSiblingLists
|
|
8
|
+
export { joinSiblingLists } from './node';
|
|
9
9
|
export { getCommonListAnalyticsAttributes } from './analytics';
|
|
10
10
|
export { countListItemsInSelection } from './countListItemsInSelection';
|
|
11
|
-
export { hasValidListIndentationLevel } from './indentation';
|
|
12
11
|
export { restoreSelection, computeSelectionOffsets } from './restore-selection';
|
|
13
12
|
export { buildReplacementFragment } from './build-replacement-fragment';
|
|
14
13
|
export { narrowReplacementRange } from './narrow-replacement-range';
|
|
15
|
-
export { flattenList } from './flatten-list';
|
|
16
14
|
export { getBlockMarkAttrs, getFirstParagraphBlockMarkAttrs, reconcileBlockMarkForContainerAtPos, reconcileBlockMarkForParagraphAtPos, reconcileBlockMarkInRange } from './block-mark';
|
|
17
15
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
|
|
18
16
|
export { messages } from './messages';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isListItemNode, isListNode } from '../utils';
|
|
2
2
|
import { isListNodeValidContent } from './isListNodeValidContent';
|
|
3
3
|
import { JoinDirection } from './JoinDirection';
|
|
4
|
-
import { wrapTaskListIntoListAbove } from './wrapTaskListIntoListAbove';
|
|
5
4
|
export const joinSiblingLists = ({
|
|
6
5
|
tr,
|
|
7
6
|
direction,
|
|
@@ -83,82 +82,6 @@ export const joinSiblingLists = ({
|
|
|
83
82
|
return result;
|
|
84
83
|
};
|
|
85
84
|
|
|
86
|
-
/**
|
|
87
|
-
* Returns the prosemirror position for the child at give index inside the parent node.
|
|
88
|
-
* Example: Considering doc structure as below using the function
|
|
89
|
-
* passing parent resolved position for li and index 2
|
|
90
|
-
* would return starting position of taskList
|
|
91
|
-
* DOC STRUCTURE:
|
|
92
|
-
* ol()
|
|
93
|
-
* ( li(
|
|
94
|
-
* p('text'),
|
|
95
|
-
* ul(content),
|
|
96
|
-
* taskList(),
|
|
97
|
-
* )
|
|
98
|
-
* )
|
|
99
|
-
* @param $from Starting resolved position for the parent node of the child we are looking for.
|
|
100
|
-
* @param index Index of the child node we want the position for.
|
|
101
|
-
* @returns
|
|
102
|
-
*/
|
|
103
|
-
const findStartPositionOfChildWithIndex = ($from, index) => {
|
|
104
|
-
const parent = $from.node();
|
|
105
|
-
let currentPos = $from.pos + 1;
|
|
106
|
-
for (let i = 0; i < index; i++) {
|
|
107
|
-
currentPos += parent.child(i).nodeSize;
|
|
108
|
-
}
|
|
109
|
-
return currentPos;
|
|
110
|
-
};
|
|
111
|
-
const findGrandParentResolvedPos = (tr, $from) => {
|
|
112
|
-
return $from.depth > 2 ? tr.doc.resolve($from.start($from.depth - 2)) : null;
|
|
113
|
-
};
|
|
114
|
-
const findNestedTaskListsIndexAtSameLevel = (tr, $from) => {
|
|
115
|
-
/*
|
|
116
|
-
Currently our cursor would be inside a pargraph of a list of type numbered/bullet list,
|
|
117
|
-
we need to find the grandparent of the cursor which is the list at same level of taskList.
|
|
118
|
-
We can get the root list item(inside which various lists are being resolved before outdenting) by going one depth above that list.
|
|
119
|
-
*/
|
|
120
|
-
const nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
121
|
-
const rootListItem = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.node(nestedListResolvedPos.depth - 1);
|
|
122
|
-
const nestedTaskListsIndexes = [];
|
|
123
|
-
const rootListItemChildCount = (rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.childCount) || 0;
|
|
124
|
-
// first child of list item is always paragraph (i = 0) so we start from 1
|
|
125
|
-
for (let i = 1; i < rootListItemChildCount; i++) {
|
|
126
|
-
if ((rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.child(i).type.name) === 'taskList') {
|
|
127
|
-
nestedTaskListsIndexes.push(i);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return nestedTaskListsIndexes;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
134
|
-
export const processNestedTaskListsInSameLevel = tr => {
|
|
135
|
-
const {
|
|
136
|
-
$from
|
|
137
|
-
} = tr.selection;
|
|
138
|
-
const nestedTaskListIndexes = findNestedTaskListsIndexAtSameLevel(tr, $from);
|
|
139
|
-
if (nestedTaskListIndexes.length === 0) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
143
|
-
const rootListItemStart = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.start(nestedListResolvedPos.depth - 1);
|
|
144
|
-
|
|
145
|
-
/* We need not wrap the taskList present above other lists since it doesn't affect the flow. */
|
|
146
|
-
const nestedTaskListIndexesToWrap = nestedTaskListIndexes.filter(index => index > 1);
|
|
147
|
-
|
|
148
|
-
/*
|
|
149
|
-
Wraps the taskLists present at each index mentioned in the nestedTaskListIndexesToWrap to the list above it.
|
|
150
|
-
After each wrap the indexes changes since two lists are being merged into one,
|
|
151
|
-
so we keep track of it and use it to access actual calculated taskList indexes.
|
|
152
|
-
*/
|
|
153
|
-
if (rootListItemStart) {
|
|
154
|
-
let taskListsFixedNested = 0;
|
|
155
|
-
nestedTaskListIndexesToWrap.forEach(index => {
|
|
156
|
-
wrapTaskListIntoListAbove(tr, findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - taskListsFixedNested), findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - 1 - taskListsFixedNested));
|
|
157
|
-
taskListsFixedNested++;
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
return;
|
|
161
|
-
};
|
|
162
85
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
163
86
|
export { isListNodeValidContent } from './isListNodeValidContent';
|
|
164
87
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
@@ -15,6 +15,4 @@ export const moveTargetIntoList = ({
|
|
|
15
15
|
}
|
|
16
16
|
const step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
17
17
|
return step;
|
|
18
|
-
};
|
|
19
|
-
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
20
|
-
export { wrapTaskListIntoListAbove } from './wrapTaskListIntoListAbove';
|
|
18
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
1
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
2
|
import { isListItemNode } from '../utils';
|
|
4
3
|
import { numberNestedLists } from './numberNestedLists';
|
|
@@ -14,35 +13,6 @@ export const getListItemAttributes = $pos => {
|
|
|
14
13
|
itemIndex
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
export const normalizeListItemsSelection = ({
|
|
19
|
-
selection,
|
|
20
|
-
doc
|
|
21
|
-
}) => {
|
|
22
|
-
if (selection.empty) {
|
|
23
|
-
return selection;
|
|
24
|
-
}
|
|
25
|
-
const {
|
|
26
|
-
$from,
|
|
27
|
-
$to
|
|
28
|
-
} = selection;
|
|
29
|
-
if (selection instanceof NodeSelection) {
|
|
30
|
-
const head = resolvePositionToStartOfListItem($from);
|
|
31
|
-
return new TextSelection(head, head);
|
|
32
|
-
}
|
|
33
|
-
const head = resolvePositionToStartOfListItem($from);
|
|
34
|
-
const anchor = resolvePositionToEndOfListItem($to);
|
|
35
|
-
return new TextSelection(anchor, head);
|
|
36
|
-
};
|
|
37
|
-
const resolvePositionToStartOfListItem = $pos => {
|
|
38
|
-
const fromRange = $pos.blockRange($pos, isListItemNode);
|
|
39
|
-
const fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
|
|
40
|
-
return fromPosition;
|
|
41
|
-
};
|
|
42
|
-
const resolvePositionToEndOfListItem = $pos => {
|
|
43
|
-
const toRange = $pos.blockRange($pos, isListItemNode);
|
|
44
|
-
const toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
|
|
45
|
-
return toPosition;
|
|
46
|
-
};
|
|
16
|
+
|
|
47
17
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
48
18
|
export { numberNestedLists } from './numberNestedLists';
|
|
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
13
13
|
const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
14
14
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
15
15
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
16
|
-
const packageVersion = "122.
|
|
16
|
+
const packageVersion = "122.12.0";
|
|
17
17
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
18
18
|
// Remove URL as it has UGC
|
|
19
19
|
// Ignored via go/ees007
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
3
2
|
import { isEmptyDocument } from '../utils';
|
|
4
3
|
import { DynamicBitArray } from './dynamic-bit-array';
|
|
5
|
-
import { shouldEnableLimitedModeForDocument } from './should-enable-limited-mode';
|
|
6
4
|
|
|
7
5
|
// The slice of `@atlaskit/editor-plugin-limited-mode`'s state read below. Declared
|
|
8
6
|
// structurally because `editor-common` must not depend on a plugin package.
|
|
@@ -97,7 +95,7 @@ const nodeIdProviderMap = new WeakMap();
|
|
|
97
95
|
*/
|
|
98
96
|
const isLimitedModeEnabled = editorView => {
|
|
99
97
|
var _limitedModePluginKey, _limitedModePluginKey2;
|
|
100
|
-
return
|
|
98
|
+
return (_limitedModePluginKey = (_limitedModePluginKey2 = limitedModePluginKey.getState(editorView.state)) === null || _limitedModePluginKey2 === void 0 ? void 0 : _limitedModePluginKey2.documentSizeBreachesThreshold) !== null && _limitedModePluginKey !== void 0 ? _limitedModePluginKey : false;
|
|
101
99
|
};
|
|
102
100
|
|
|
103
101
|
// Get the NodeIdProvider for a specific EditorView instance.
|
|
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
15
15
|
import Layer from '../Layer';
|
|
16
16
|
const packageName = "@atlaskit/editor-common";
|
|
17
|
-
const packageVersion = "122.
|
|
17
|
+
const packageVersion = "122.12.0";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -1,71 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Type-specific predicates that vary between regular lists and task lists.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Flattens a list-like PM structure (regular list or task list) into an
|
|
7
|
-
* array of content-bearing items with computed depths.
|
|
8
|
-
*
|
|
9
|
-
* Uses `doc.nodesBetween` to walk the tree and delegates type-specific
|
|
10
|
-
* decisions to the provided predicates. The core algorithm — selection
|
|
11
|
-
* intersection, depth adjustment, index tracking — is shared.
|
|
12
|
-
*
|
|
13
|
-
* @private
|
|
14
|
-
* @deprecated Cannot represent content placed between an item's sub-lists
|
|
15
|
-
* (e.g. `li(p, ul, p, ul)`). Callers provide their own flatten that handles this.
|
|
16
|
-
*/
|
|
17
|
-
export function flattenList(options, predicates) {
|
|
18
|
-
var doc = options.doc,
|
|
19
|
-
rootListStart = options.rootListStart,
|
|
20
|
-
rootListEnd = options.rootListEnd,
|
|
21
|
-
selectionFrom = options.selectionFrom,
|
|
22
|
-
selectionTo = options.selectionTo,
|
|
23
|
-
indentDelta = options.indentDelta,
|
|
24
|
-
maxDepth = options.maxDepth;
|
|
25
|
-
var isContentNode = predicates.isContentNode,
|
|
26
|
-
getSelectionBounds = predicates.getSelectionBounds,
|
|
27
|
-
getDepth = predicates.getDepth;
|
|
28
|
-
var items = [];
|
|
29
|
-
var startIndex = -1;
|
|
30
|
-
var endIndex = -1;
|
|
31
|
-
var exceedsMaxDepth = false;
|
|
32
|
-
var rootDepth = doc.resolve(rootListStart).depth;
|
|
33
|
-
doc.nodesBetween(rootListStart, rootListEnd, function (node, pos, parent) {
|
|
34
|
-
if (!isContentNode(node, parent) || parent == null) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
var _getSelectionBounds = getSelectionBounds(node, pos),
|
|
38
|
-
start = _getSelectionBounds.start,
|
|
39
|
-
end = _getSelectionBounds.end;
|
|
40
|
-
var isSelected = selectionFrom === selectionTo ? selectionFrom >= start && selectionFrom <= end : start < selectionTo && end > selectionFrom;
|
|
41
|
-
var resolvedDepth = doc.resolve(pos).depth;
|
|
42
|
-
var depth = getDepth(resolvedDepth, rootDepth) + (isSelected ? indentDelta : 0);
|
|
43
|
-
items.push({
|
|
44
|
-
node: node,
|
|
45
|
-
pos: pos,
|
|
46
|
-
depth: depth,
|
|
47
|
-
isSelected: isSelected,
|
|
48
|
-
listType: parent.type.name,
|
|
49
|
-
parentListAttrs: parent.attrs
|
|
50
|
-
});
|
|
51
|
-
if (isSelected) {
|
|
52
|
-
var index = items.length - 1;
|
|
53
|
-
if (startIndex === -1) {
|
|
54
|
-
startIndex = index;
|
|
55
|
-
}
|
|
56
|
-
endIndex = index;
|
|
57
|
-
if (maxDepth != null && depth >= maxDepth) {
|
|
58
|
-
exceedsMaxDepth = true;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
});
|
|
63
|
-
if (items.length === 0 || startIndex === -1 || exceedsMaxDepth) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
items: items,
|
|
68
|
-
startIndex: startIndex,
|
|
69
|
-
endIndex: endIndex
|
|
70
|
-
};
|
|
71
|
-
}
|
|
1
|
+
export {};
|
package/dist/esm/lists/index.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// Disable no-re-export rule for entry point files
|
|
2
2
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
3
3
|
|
|
4
|
-
export { getListItemAttributes
|
|
4
|
+
export { getListItemAttributes } from './selection';
|
|
5
5
|
export { moveTargetIntoList } from './replace-content';
|
|
6
6
|
export { JoinDirection } from './JoinDirection';
|
|
7
7
|
export { isListNodeValidContent } from './isListNodeValidContent';
|
|
8
|
-
export { joinSiblingLists
|
|
8
|
+
export { joinSiblingLists } from './node';
|
|
9
9
|
export { getCommonListAnalyticsAttributes } from './analytics';
|
|
10
10
|
export { countListItemsInSelection } from './countListItemsInSelection';
|
|
11
|
-
export { hasValidListIndentationLevel } from './indentation';
|
|
12
11
|
export { restoreSelection, computeSelectionOffsets } from './restore-selection';
|
|
13
12
|
export { buildReplacementFragment } from './build-replacement-fragment';
|
|
14
13
|
export { narrowReplacementRange } from './narrow-replacement-range';
|
|
15
|
-
export { flattenList } from './flatten-list';
|
|
16
14
|
export { getBlockMarkAttrs, getFirstParagraphBlockMarkAttrs, reconcileBlockMarkForContainerAtPos, reconcileBlockMarkForParagraphAtPos, reconcileBlockMarkInRange } from './block-mark';
|
|
17
15
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
|
|
18
16
|
export { messages } from './messages';
|
package/dist/esm/lists/node.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isListItemNode, isListNode } from '../utils';
|
|
2
2
|
import { isListNodeValidContent } from './isListNodeValidContent';
|
|
3
3
|
import { JoinDirection } from './JoinDirection';
|
|
4
|
-
import { wrapTaskListIntoListAbove } from './wrapTaskListIntoListAbove';
|
|
5
4
|
export var joinSiblingLists = function joinSiblingLists(_ref) {
|
|
6
5
|
var tr = _ref.tr,
|
|
7
6
|
direction = _ref.direction,
|
|
@@ -75,82 +74,6 @@ export var joinSiblingLists = function joinSiblingLists(_ref) {
|
|
|
75
74
|
return result;
|
|
76
75
|
};
|
|
77
76
|
|
|
78
|
-
/**
|
|
79
|
-
* Returns the prosemirror position for the child at give index inside the parent node.
|
|
80
|
-
* Example: Considering doc structure as below using the function
|
|
81
|
-
* passing parent resolved position for li and index 2
|
|
82
|
-
* would return starting position of taskList
|
|
83
|
-
* DOC STRUCTURE:
|
|
84
|
-
* ol()
|
|
85
|
-
* ( li(
|
|
86
|
-
* p('text'),
|
|
87
|
-
* ul(content),
|
|
88
|
-
* taskList(),
|
|
89
|
-
* )
|
|
90
|
-
* )
|
|
91
|
-
* @param $from Starting resolved position for the parent node of the child we are looking for.
|
|
92
|
-
* @param index Index of the child node we want the position for.
|
|
93
|
-
* @returns
|
|
94
|
-
*/
|
|
95
|
-
var findStartPositionOfChildWithIndex = function findStartPositionOfChildWithIndex($from, index) {
|
|
96
|
-
var parent = $from.node();
|
|
97
|
-
var currentPos = $from.pos + 1;
|
|
98
|
-
for (var i = 0; i < index; i++) {
|
|
99
|
-
currentPos += parent.child(i).nodeSize;
|
|
100
|
-
}
|
|
101
|
-
return currentPos;
|
|
102
|
-
};
|
|
103
|
-
var findGrandParentResolvedPos = function findGrandParentResolvedPos(tr, $from) {
|
|
104
|
-
return $from.depth > 2 ? tr.doc.resolve($from.start($from.depth - 2)) : null;
|
|
105
|
-
};
|
|
106
|
-
var findNestedTaskListsIndexAtSameLevel = function findNestedTaskListsIndexAtSameLevel(tr, $from) {
|
|
107
|
-
/*
|
|
108
|
-
Currently our cursor would be inside a pargraph of a list of type numbered/bullet list,
|
|
109
|
-
we need to find the grandparent of the cursor which is the list at same level of taskList.
|
|
110
|
-
We can get the root list item(inside which various lists are being resolved before outdenting) by going one depth above that list.
|
|
111
|
-
*/
|
|
112
|
-
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
113
|
-
var rootListItem = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.node(nestedListResolvedPos.depth - 1);
|
|
114
|
-
var nestedTaskListsIndexes = [];
|
|
115
|
-
var rootListItemChildCount = (rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.childCount) || 0;
|
|
116
|
-
// first child of list item is always paragraph (i = 0) so we start from 1
|
|
117
|
-
for (var i = 1; i < rootListItemChildCount; i++) {
|
|
118
|
-
if ((rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.child(i).type.name) === 'taskList') {
|
|
119
|
-
nestedTaskListsIndexes.push(i);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return nestedTaskListsIndexes;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
126
|
-
export var processNestedTaskListsInSameLevel = function processNestedTaskListsInSameLevel(tr) {
|
|
127
|
-
var $from = tr.selection.$from;
|
|
128
|
-
var nestedTaskListIndexes = findNestedTaskListsIndexAtSameLevel(tr, $from);
|
|
129
|
-
if (nestedTaskListIndexes.length === 0) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
133
|
-
var rootListItemStart = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.start(nestedListResolvedPos.depth - 1);
|
|
134
|
-
|
|
135
|
-
/* We need not wrap the taskList present above other lists since it doesn't affect the flow. */
|
|
136
|
-
var nestedTaskListIndexesToWrap = nestedTaskListIndexes.filter(function (index) {
|
|
137
|
-
return index > 1;
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
/*
|
|
141
|
-
Wraps the taskLists present at each index mentioned in the nestedTaskListIndexesToWrap to the list above it.
|
|
142
|
-
After each wrap the indexes changes since two lists are being merged into one,
|
|
143
|
-
so we keep track of it and use it to access actual calculated taskList indexes.
|
|
144
|
-
*/
|
|
145
|
-
if (rootListItemStart) {
|
|
146
|
-
var taskListsFixedNested = 0;
|
|
147
|
-
nestedTaskListIndexesToWrap.forEach(function (index) {
|
|
148
|
-
wrapTaskListIntoListAbove(tr, findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - taskListsFixedNested), findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - 1 - taskListsFixedNested));
|
|
149
|
-
taskListsFixedNested++;
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return;
|
|
153
|
-
};
|
|
154
77
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
155
78
|
export { isListNodeValidContent } from './isListNodeValidContent';
|
|
156
79
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
@@ -14,6 +14,4 @@ export var moveTargetIntoList = function moveTargetIntoList(_ref) {
|
|
|
14
14
|
}
|
|
15
15
|
var step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
16
16
|
return step;
|
|
17
|
-
};
|
|
18
|
-
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
19
|
-
export { wrapTaskListIntoListAbove } from './wrapTaskListIntoListAbove';
|
|
17
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
1
|
import { findParentNodeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
2
|
import { isListItemNode } from '../utils';
|
|
4
3
|
import { numberNestedLists } from './numberNestedLists';
|
|
@@ -14,32 +13,6 @@ export var getListItemAttributes = function getListItemAttributes($pos) {
|
|
|
14
13
|
itemIndex: itemIndex
|
|
15
14
|
};
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
export var normalizeListItemsSelection = function normalizeListItemsSelection(_ref) {
|
|
19
|
-
var selection = _ref.selection,
|
|
20
|
-
doc = _ref.doc;
|
|
21
|
-
if (selection.empty) {
|
|
22
|
-
return selection;
|
|
23
|
-
}
|
|
24
|
-
var $from = selection.$from,
|
|
25
|
-
$to = selection.$to;
|
|
26
|
-
if (selection instanceof NodeSelection) {
|
|
27
|
-
var _head = resolvePositionToStartOfListItem($from);
|
|
28
|
-
return new TextSelection(_head, _head);
|
|
29
|
-
}
|
|
30
|
-
var head = resolvePositionToStartOfListItem($from);
|
|
31
|
-
var anchor = resolvePositionToEndOfListItem($to);
|
|
32
|
-
return new TextSelection(anchor, head);
|
|
33
|
-
};
|
|
34
|
-
var resolvePositionToStartOfListItem = function resolvePositionToStartOfListItem($pos) {
|
|
35
|
-
var fromRange = $pos.blockRange($pos, isListItemNode);
|
|
36
|
-
var fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
|
|
37
|
-
return fromPosition;
|
|
38
|
-
};
|
|
39
|
-
var resolvePositionToEndOfListItem = function resolvePositionToEndOfListItem($pos) {
|
|
40
|
-
var toRange = $pos.blockRange($pos, isListItemNode);
|
|
41
|
-
var toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
|
|
42
|
-
return toPosition;
|
|
43
|
-
};
|
|
16
|
+
|
|
44
17
|
// eslint-disable-next-line @atlaskit/editor/no-re-export
|
|
45
18
|
export { numberNestedLists } from './numberNestedLists';
|
|
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
19
19
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
20
20
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
21
21
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
22
|
-
var packageVersion = "122.
|
|
22
|
+
var packageVersion = "122.12.0";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// Ignored via go/ees007
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
5
4
|
import { isEmptyDocument } from '../utils';
|
|
6
5
|
import { DynamicBitArray } from './dynamic-bit-array';
|
|
7
|
-
import { shouldEnableLimitedModeForDocument } from './should-enable-limited-mode';
|
|
8
6
|
|
|
9
7
|
// The slice of `@atlaskit/editor-plugin-limited-mode`'s state read below. Declared
|
|
10
8
|
// structurally because `editor-common` must not depend on a plugin package.
|
|
@@ -117,7 +115,7 @@ var nodeIdProviderMap = new WeakMap();
|
|
|
117
115
|
*/
|
|
118
116
|
var isLimitedModeEnabled = function isLimitedModeEnabled(editorView) {
|
|
119
117
|
var _limitedModePluginKey, _limitedModePluginKey2;
|
|
120
|
-
return
|
|
118
|
+
return (_limitedModePluginKey = (_limitedModePluginKey2 = limitedModePluginKey.getState(editorView.state)) === null || _limitedModePluginKey2 === void 0 ? void 0 : _limitedModePluginKey2.documentSizeBreachesThreshold) !== null && _limitedModePluginKey !== void 0 ? _limitedModePluginKey : false;
|
|
121
119
|
};
|
|
122
120
|
|
|
123
121
|
// Get the NodeIdProvider for a specific EditorView instance.
|
|
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
21
21
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
22
22
|
import Layer from '../Layer';
|
|
23
23
|
var packageName = "@atlaskit/editor-common";
|
|
24
|
-
var packageVersion = "122.
|
|
24
|
+
var packageVersion = "122.12.0";
|
|
25
25
|
var halfFocusRing = 1;
|
|
26
26
|
var dropOffset = '0, 8';
|
|
27
27
|
var fadeIn = keyframes({
|
|
@@ -16,36 +16,8 @@ export interface FlattenListOptions {
|
|
|
16
16
|
selectionFrom: number;
|
|
17
17
|
selectionTo: number;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Type-specific predicates that vary between regular lists and task lists.
|
|
21
|
-
*/
|
|
22
|
-
interface FlattenListPredicates {
|
|
23
|
-
/** Computes the nesting depth for a node given its resolved depth and the root's depth. */
|
|
24
|
-
getDepth: (resolvedDepth: number, rootDepth: number) => number;
|
|
25
|
-
/** Returns the selection bounds for an item, used to check selection intersection. */
|
|
26
|
-
getSelectionBounds: (node: PMNode, pos: number) => {
|
|
27
|
-
end: number;
|
|
28
|
-
start: number;
|
|
29
|
-
};
|
|
30
|
-
/** Returns true if `node` is a content-bearing item to include in the flattened output. */
|
|
31
|
-
isContentNode: (node: PMNode, parent: PMNode | null) => boolean;
|
|
32
|
-
}
|
|
33
19
|
export interface FlattenListResult {
|
|
34
20
|
endIndex: number;
|
|
35
21
|
items: FlattenedItem[];
|
|
36
22
|
startIndex: number;
|
|
37
23
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Flattens a list-like PM structure (regular list or task list) into an
|
|
40
|
-
* array of content-bearing items with computed depths.
|
|
41
|
-
*
|
|
42
|
-
* Uses `doc.nodesBetween` to walk the tree and delegates type-specific
|
|
43
|
-
* decisions to the provided predicates. The core algorithm — selection
|
|
44
|
-
* intersection, depth adjustment, index tracking — is shared.
|
|
45
|
-
*
|
|
46
|
-
* @private
|
|
47
|
-
* @deprecated Cannot represent content placed between an item's sub-lists
|
|
48
|
-
* (e.g. `li(p, ul, p, ul)`). Callers provide their own flatten that handles this.
|
|
49
|
-
*/
|
|
50
|
-
export declare function flattenList(options: FlattenListOptions, predicates: FlattenListPredicates): FlattenListResult | null;
|
|
51
|
-
export {};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
export { getListItemAttributes
|
|
1
|
+
export { getListItemAttributes } from './selection';
|
|
2
2
|
export { moveTargetIntoList } from './replace-content';
|
|
3
3
|
export { JoinDirection } from './JoinDirection';
|
|
4
4
|
export { isListNodeValidContent } from './isListNodeValidContent';
|
|
5
|
-
export { joinSiblingLists
|
|
5
|
+
export { joinSiblingLists } from './node';
|
|
6
6
|
export { getCommonListAnalyticsAttributes } from './analytics';
|
|
7
7
|
export { countListItemsInSelection } from './countListItemsInSelection';
|
|
8
|
-
export { hasValidListIndentationLevel } from './indentation';
|
|
9
8
|
export { restoreSelection, computeSelectionOffsets } from './restore-selection';
|
|
10
9
|
export { buildReplacementFragment } from './build-replacement-fragment';
|
|
11
10
|
export type { BuildResult } from './build-replacement-fragment';
|
|
12
11
|
export { narrowReplacementRange } from './narrow-replacement-range';
|
|
13
12
|
export type { NarrowedReplacement } from './narrow-replacement-range';
|
|
14
13
|
export type { FlattenedItem } from './flatten-list';
|
|
15
|
-
export { flattenList } from './flatten-list';
|
|
16
14
|
export type { FlattenListOptions, FlattenListResult } from './flatten-list';
|
|
17
15
|
export { getBlockMarkAttrs, getFirstParagraphBlockMarkAttrs, reconcileBlockMarkForContainerAtPos, reconcileBlockMarkForParagraphAtPos, reconcileBlockMarkInRange, } from './block-mark';
|
|
18
16
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
|
|
@@ -11,6 +11,5 @@ type ListsJoined = {
|
|
|
11
11
|
orderedList: number;
|
|
12
12
|
};
|
|
13
13
|
export declare const joinSiblingLists: ({ tr, direction, forceListType, }: JoinSiblingListsProps) => ListsJoined;
|
|
14
|
-
export declare const processNestedTaskListsInSameLevel: (tr: Transaction) => void;
|
|
15
14
|
export { isListNodeValidContent } from './isListNodeValidContent';
|
|
16
15
|
export { JoinDirection } from './JoinDirection';
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
3
2
|
export declare const getListItemAttributes: ($pos: ResolvedPos) => {
|
|
4
3
|
indentLevel: number;
|
|
5
4
|
itemIndex: number;
|
|
6
5
|
};
|
|
7
|
-
type NormalizeListItemsSelection = (props: {
|
|
8
|
-
doc: PMNode;
|
|
9
|
-
selection: Selection;
|
|
10
|
-
}) => Selection;
|
|
11
|
-
export declare const normalizeListItemsSelection: NormalizeListItemsSelection;
|
|
12
6
|
export { numberNestedLists } from './numberNestedLists';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "123.0.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@atlaskit/dropdown-menu": "^18.3.0",
|
|
45
45
|
"@atlaskit/editor-json-transformer": "^9.8.0",
|
|
46
46
|
"@atlaskit/editor-palette": "^3.5.0",
|
|
47
|
-
"@atlaskit/editor-prosemirror": "^
|
|
47
|
+
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
48
48
|
"@atlaskit/editor-shared-styles": "^4.3.0",
|
|
49
49
|
"@atlaskit/editor-tables": "^3.2.0",
|
|
50
50
|
"@atlaskit/editor-toolbar": "^2.6.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@atlaskit/teams-app-config": "^3.1.0",
|
|
86
86
|
"@atlaskit/textfield": "^10.2.0",
|
|
87
87
|
"@atlaskit/tmp-editor-statsig": "^199.0.0",
|
|
88
|
-
"@atlaskit/tokens": "^18.
|
|
88
|
+
"@atlaskit/tokens": "^18.2.0",
|
|
89
89
|
"@atlaskit/tooltip": "^24.3.0",
|
|
90
90
|
"@atlaskit/width-detector": "^7.2.0",
|
|
91
91
|
"@babel/runtime": "^7.0.0",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hasValidListIndentationLevel = void 0;
|
|
7
|
-
var _numberNestedLists = require("./numberNestedLists");
|
|
8
|
-
var hasValidListIndentationLevel = exports.hasValidListIndentationLevel = function hasValidListIndentationLevel(_ref) {
|
|
9
|
-
var tr = _ref.tr,
|
|
10
|
-
maxIndentation = _ref.maxIndentation;
|
|
11
|
-
var initialIndentationLevel = (0, _numberNestedLists.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, _numberNestedLists.numberNestedLists)(resolvedPos);
|
|
17
|
-
if (currentIndentationLevel > maxIndentation) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
currentPos++;
|
|
21
|
-
} while (currentIndentationLevel >= initialIndentationLevel);
|
|
22
|
-
return true;
|
|
23
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapTaskListIntoListAbove = void 0;
|
|
7
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
8
|
-
var wrapTaskListIntoListAbove = exports.wrapTaskListIntoListAbove = function wrapTaskListIntoListAbove(tr, taskListStart, previousListStart) {
|
|
9
|
-
var $taskListStart = tr.doc.resolve(taskListStart);
|
|
10
|
-
|
|
11
|
-
/* Safecheck: if not passed a taskList node, return */
|
|
12
|
-
if ($taskListStart.node().type.name !== 'taskList') {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
var $previousListStart = tr.doc.resolve(previousListStart);
|
|
16
|
-
var taskList = tr.doc.slice($taskListStart.pos, $taskListStart.after());
|
|
17
|
-
var frag = _model.Fragment.from(taskList.content);
|
|
18
|
-
|
|
19
|
-
/*
|
|
20
|
-
Delete the existing taskList at the same level and insert inside above list provided
|
|
21
|
-
1. To delete the tasklist, we need wrapping positions before and after it to completely delete it.
|
|
22
|
-
$taskListStart.after() would give us closing position enclosed by node itself using it would remove only the contents of taskList
|
|
23
|
-
so we add 1 to it to get the position after the taskList node and completly remove it.
|
|
24
|
-
2. Inserting the taskList at the end() position safe inserts the taskList to next available position which would lead to deleting and inserting taskList at same place.
|
|
25
|
-
Reason: $previousListStart.end() gives us end position of listItem but we can add content only inside listItem not at same level
|
|
26
|
-
so we subtract 1 to get the position inside the list item and insert the TaskList same level as paragraph/content inside listItem.
|
|
27
|
-
*/
|
|
28
|
-
tr.delete($taskListStart.before(), $taskListStart.after() + 1);
|
|
29
|
-
tr.insert($previousListStart.end() - 1, frag);
|
|
30
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { numberNestedLists } from './numberNestedLists';
|
|
2
|
-
export const hasValidListIndentationLevel = ({
|
|
3
|
-
tr,
|
|
4
|
-
maxIndentation
|
|
5
|
-
}) => {
|
|
6
|
-
const initialIndentationLevel = numberNestedLists(tr.selection.$from);
|
|
7
|
-
let currentIndentationLevel;
|
|
8
|
-
let currentPos = tr.selection.$to.pos;
|
|
9
|
-
do {
|
|
10
|
-
const resolvedPos = tr.doc.resolve(currentPos);
|
|
11
|
-
currentIndentationLevel = numberNestedLists(resolvedPos);
|
|
12
|
-
if (currentIndentationLevel > maxIndentation) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
currentPos++;
|
|
16
|
-
} while (currentIndentationLevel >= initialIndentationLevel);
|
|
17
|
-
return true;
|
|
18
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
export const wrapTaskListIntoListAbove = (tr, taskListStart, previousListStart) => {
|
|
3
|
-
const $taskListStart = tr.doc.resolve(taskListStart);
|
|
4
|
-
|
|
5
|
-
/* Safecheck: if not passed a taskList node, return */
|
|
6
|
-
if ($taskListStart.node().type.name !== 'taskList') {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const $previousListStart = tr.doc.resolve(previousListStart);
|
|
10
|
-
const taskList = tr.doc.slice($taskListStart.pos, $taskListStart.after());
|
|
11
|
-
const frag = Fragment.from(taskList.content);
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
Delete the existing taskList at the same level and insert inside above list provided
|
|
15
|
-
1. To delete the tasklist, we need wrapping positions before and after it to completely delete it.
|
|
16
|
-
$taskListStart.after() would give us closing position enclosed by node itself using it would remove only the contents of taskList
|
|
17
|
-
so we add 1 to it to get the position after the taskList node and completly remove it.
|
|
18
|
-
2. Inserting the taskList at the end() position safe inserts the taskList to next available position which would lead to deleting and inserting taskList at same place.
|
|
19
|
-
Reason: $previousListStart.end() gives us end position of listItem but we can add content only inside listItem not at same level
|
|
20
|
-
so we subtract 1 to get the position inside the list item and insert the TaskList same level as paragraph/content inside listItem.
|
|
21
|
-
*/
|
|
22
|
-
tr.delete($taskListStart.before(), $taskListStart.after() + 1);
|
|
23
|
-
tr.insert($previousListStart.end() - 1, frag);
|
|
24
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { numberNestedLists } from './numberNestedLists';
|
|
2
|
-
export var hasValidListIndentationLevel = function hasValidListIndentationLevel(_ref) {
|
|
3
|
-
var tr = _ref.tr,
|
|
4
|
-
maxIndentation = _ref.maxIndentation;
|
|
5
|
-
var initialIndentationLevel = numberNestedLists(tr.selection.$from);
|
|
6
|
-
var currentIndentationLevel;
|
|
7
|
-
var currentPos = tr.selection.$to.pos;
|
|
8
|
-
do {
|
|
9
|
-
var resolvedPos = tr.doc.resolve(currentPos);
|
|
10
|
-
currentIndentationLevel = numberNestedLists(resolvedPos);
|
|
11
|
-
if (currentIndentationLevel > maxIndentation) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
currentPos++;
|
|
15
|
-
} while (currentIndentationLevel >= initialIndentationLevel);
|
|
16
|
-
return true;
|
|
17
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
export var wrapTaskListIntoListAbove = function wrapTaskListIntoListAbove(tr, taskListStart, previousListStart) {
|
|
3
|
-
var $taskListStart = tr.doc.resolve(taskListStart);
|
|
4
|
-
|
|
5
|
-
/* Safecheck: if not passed a taskList node, return */
|
|
6
|
-
if ($taskListStart.node().type.name !== 'taskList') {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
var $previousListStart = tr.doc.resolve(previousListStart);
|
|
10
|
-
var taskList = tr.doc.slice($taskListStart.pos, $taskListStart.after());
|
|
11
|
-
var frag = Fragment.from(taskList.content);
|
|
12
|
-
|
|
13
|
-
/*
|
|
14
|
-
Delete the existing taskList at the same level and insert inside above list provided
|
|
15
|
-
1. To delete the tasklist, we need wrapping positions before and after it to completely delete it.
|
|
16
|
-
$taskListStart.after() would give us closing position enclosed by node itself using it would remove only the contents of taskList
|
|
17
|
-
so we add 1 to it to get the position after the taskList node and completly remove it.
|
|
18
|
-
2. Inserting the taskList at the end() position safe inserts the taskList to next available position which would lead to deleting and inserting taskList at same place.
|
|
19
|
-
Reason: $previousListStart.end() gives us end position of listItem but we can add content only inside listItem not at same level
|
|
20
|
-
so we subtract 1 to get the position inside the list item and insert the TaskList same level as paragraph/content inside listItem.
|
|
21
|
-
*/
|
|
22
|
-
tr.delete($taskListStart.before(), $taskListStart.after() + 1);
|
|
23
|
-
tr.insert($previousListStart.end() - 1, frag);
|
|
24
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/editor-common/lists/indentation",
|
|
3
|
-
"main": "../../dist/cjs/lists/indentation.js",
|
|
4
|
-
"module": "../../dist/esm/lists/indentation.js",
|
|
5
|
-
"module:es2019": "../../dist/es2019/lists/indentation.js",
|
|
6
|
-
"sideEffects": [
|
|
7
|
-
"**/*.compiled.css"
|
|
8
|
-
],
|
|
9
|
-
"types": "../../dist/types/lists/indentation.d.ts"
|
|
10
|
-
}
|