@atlaskit/editor-common 77.3.0 → 77.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/lists/index.js +6 -0
- package/dist/cjs/lists/node.js +77 -1
- package/dist/cjs/lists/replace-content.js +25 -1
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/lists/index.js +1 -1
- package/dist/es2019/lists/node.js +76 -0
- package/dist/es2019/lists/replace-content.js +24 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/lists/index.js +1 -1
- package/dist/esm/lists/node.js +76 -0
- package/dist/esm/lists/replace-content.js +24 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/lists/index.d.ts +1 -1
- package/dist/types/lists/node.d.ts +1 -0
- package/dist/types/lists/replace-content.d.ts +3 -1
- package/dist/types-ts4.5/lists/index.d.ts +1 -1
- package/dist/types-ts4.5/lists/node.d.ts +1 -0
- package/dist/types-ts4.5/lists/replace-content.d.ts +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 77.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#71503](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71503) [`2e81432d605a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2e81432d605a) - [ux] ED-21943 Fixed outdent behaviour when multiple lists at same level including TaskList, and add relevant testcases.
|
|
8
|
+
|
|
3
9
|
## 77.3.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/cjs/lists/index.js
CHANGED
|
@@ -87,6 +87,12 @@ Object.defineProperty(exports, "normalizeListItemsSelection", {
|
|
|
87
87
|
return _selection.normalizeListItemsSelection;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
+
Object.defineProperty(exports, "processNestedTaskListsInSameLevel", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _node.processNestedTaskListsInSameLevel;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
90
96
|
var _selection = require("./selection");
|
|
91
97
|
var _replaceContent = require("./replace-content");
|
|
92
98
|
var _node = require("./node");
|
package/dist/cjs/lists/node.js
CHANGED
|
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.JoinDirection = void 0;
|
|
7
7
|
exports.isListNodeValidContent = isListNodeValidContent;
|
|
8
|
-
exports.joinSiblingLists = void 0;
|
|
8
|
+
exports.processNestedTaskListsInSameLevel = exports.joinSiblingLists = void 0;
|
|
9
9
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
11
|
var _utils = require("../utils");
|
|
12
|
+
var _replaceContent = require("./replace-content");
|
|
12
13
|
function isListNodeValidContent(node) {
|
|
13
14
|
var bulletList = node.type.schema.nodes.bulletList;
|
|
14
15
|
if (!bulletList) {
|
|
@@ -104,4 +105,79 @@ var joinSiblingLists = exports.joinSiblingLists = function joinSiblingLists(_ref
|
|
|
104
105
|
tr.join(joins[i]);
|
|
105
106
|
}
|
|
106
107
|
return result;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns the prosemirror position for the child at give index inside the parent node.
|
|
112
|
+
* Example: Considering doc structure as below using the function
|
|
113
|
+
* passing parent resolved position for li and index 2
|
|
114
|
+
* would return starting position of taskList
|
|
115
|
+
* DOC STRUCTURE:
|
|
116
|
+
* ol()
|
|
117
|
+
* ( li(
|
|
118
|
+
* p('text'),
|
|
119
|
+
* ul(content),
|
|
120
|
+
* taskList(),
|
|
121
|
+
* )
|
|
122
|
+
* )
|
|
123
|
+
* @param $from Starting resolved position for the parent node of the child we are looking for.
|
|
124
|
+
* @param index Index of the child node we want the position for.
|
|
125
|
+
* @returns
|
|
126
|
+
*/
|
|
127
|
+
var findStartPositionOfChildWithIndex = function findStartPositionOfChildWithIndex($from, index) {
|
|
128
|
+
var parent = $from.node();
|
|
129
|
+
var currentPos = $from.pos + 1;
|
|
130
|
+
for (var i = 0; i < index; i++) {
|
|
131
|
+
currentPos += parent.child(i).nodeSize;
|
|
132
|
+
}
|
|
133
|
+
return currentPos;
|
|
134
|
+
};
|
|
135
|
+
var findGrandParentResolvedPos = function findGrandParentResolvedPos(tr, $from) {
|
|
136
|
+
return $from.depth > 2 ? tr.doc.resolve($from.start($from.depth - 2)) : null;
|
|
137
|
+
};
|
|
138
|
+
var findNestedTaskListsIndexAtSameLevel = function findNestedTaskListsIndexAtSameLevel(tr, $from) {
|
|
139
|
+
/*
|
|
140
|
+
Currently our cursor would be inside a pargraph of a list of type numbered/bullet list,
|
|
141
|
+
we need to find the grandparent of the cursor which is the list at same level of taskList.
|
|
142
|
+
We can get the root list item(inside which various lists are being resolved before outdenting) by going one depth above that list.
|
|
143
|
+
*/
|
|
144
|
+
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
145
|
+
var rootListItem = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.node(nestedListResolvedPos.depth - 1);
|
|
146
|
+
var nestedTaskListsIndexes = [];
|
|
147
|
+
var rootListItemChildCount = (rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.childCount) || 0;
|
|
148
|
+
// first child of list item is always paragraph (i = 0) so we start from 1
|
|
149
|
+
for (var i = 1; i < rootListItemChildCount; i++) {
|
|
150
|
+
if ((rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.child(i).type.name) === 'taskList') {
|
|
151
|
+
nestedTaskListsIndexes.push(i);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return nestedTaskListsIndexes;
|
|
155
|
+
};
|
|
156
|
+
var processNestedTaskListsInSameLevel = exports.processNestedTaskListsInSameLevel = function processNestedTaskListsInSameLevel(tr) {
|
|
157
|
+
var $from = tr.selection.$from;
|
|
158
|
+
var nestedTaskListIndexes = findNestedTaskListsIndexAtSameLevel(tr, $from);
|
|
159
|
+
if (nestedTaskListIndexes.length === 0) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
163
|
+
var rootListItemStart = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.start(nestedListResolvedPos.depth - 1);
|
|
164
|
+
|
|
165
|
+
/* We need not wrap the taskList present above other lists since it doesn't affect the flow. */
|
|
166
|
+
var nestedTaskListIndexesToWrap = nestedTaskListIndexes.filter(function (index) {
|
|
167
|
+
return index > 1;
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
Wraps the taskLists present at each index mentioned in the nestedTaskListIndexesToWrap to the list above it.
|
|
172
|
+
After each wrap the indexes changes since two lists are being merged into one,
|
|
173
|
+
so we keep track of it and use it to access actual calculated taskList indexes.
|
|
174
|
+
*/
|
|
175
|
+
if (rootListItemStart) {
|
|
176
|
+
var taskListsFixedNested = 0;
|
|
177
|
+
nestedTaskListIndexesToWrap.forEach(function (index) {
|
|
178
|
+
(0, _replaceContent.wrapTaskListIntoListAbove)(tr, findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - taskListsFixedNested), findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - 1 - taskListsFixedNested));
|
|
179
|
+
taskListsFixedNested++;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
107
183
|
};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.moveTargetIntoList = void 0;
|
|
6
|
+
exports.wrapTaskListIntoListAbove = exports.moveTargetIntoList = void 0;
|
|
7
|
+
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
7
8
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
9
|
var moveTargetIntoList = exports.moveTargetIntoList = function moveTargetIntoList(_ref) {
|
|
9
10
|
var _$target$nodeAfter;
|
|
@@ -20,4 +21,27 @@ var moveTargetIntoList = exports.moveTargetIntoList = function moveTargetIntoLis
|
|
|
20
21
|
}
|
|
21
22
|
var step = new _transform.ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
22
23
|
return step;
|
|
24
|
+
};
|
|
25
|
+
var wrapTaskListIntoListAbove = exports.wrapTaskListIntoListAbove = function wrapTaskListIntoListAbove(tr, taskListStart, previousListStart) {
|
|
26
|
+
var $taskListStart = tr.doc.resolve(taskListStart);
|
|
27
|
+
|
|
28
|
+
/* Safecheck: if not passed a taskList node, return */
|
|
29
|
+
if ($taskListStart.node().type.name !== 'taskList') {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
var $previousListStart = tr.doc.resolve(previousListStart);
|
|
33
|
+
var taskList = tr.doc.slice($taskListStart.pos, $taskListStart.after());
|
|
34
|
+
var frag = _model.Fragment.from(taskList.content);
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
Delete the existing taskList at the same level and insert inside above list provided
|
|
38
|
+
1. To delete the tasklist, we need wrapping positions before and after it to completely delete it.
|
|
39
|
+
$taskListStart.after() would give us closing position enclosed by node itself using it would remove only the contents of taskList
|
|
40
|
+
so we add 1 to it to get the position after the taskList node and completly remove it.
|
|
41
|
+
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.
|
|
42
|
+
Reason: $previousListStart.end() gives us end position of listItem but we can add content only inside listItem not at same level
|
|
43
|
+
so we subtract 1 to get the position inside the list item and insert the TaskList same level as paragraph/content inside listItem.
|
|
44
|
+
*/
|
|
45
|
+
tr.delete($taskListStart.before(), $taskListStart.after() + 1);
|
|
46
|
+
tr.insert($previousListStart.end() - 1, frag);
|
|
23
47
|
};
|
|
@@ -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 = "77.3.
|
|
19
|
+
var packageVersion = "77.3.1";
|
|
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
|
|
@@ -22,7 +22,7 @@ var _templateObject, _templateObject2, _templateObject3;
|
|
|
22
22
|
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); }; }
|
|
23
23
|
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 */
|
|
24
24
|
var packageName = "@atlaskit/editor-common";
|
|
25
|
-
var packageVersion = "77.3.
|
|
25
|
+
var packageVersion = "77.3.1";
|
|
26
26
|
var halfFocusRing = 1;
|
|
27
27
|
var dropOffset = '0, 8';
|
|
28
28
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getListItemAttributes, normalizeListItemsSelection } from './selection';
|
|
2
2
|
export { moveTargetIntoList } from './replace-content';
|
|
3
|
-
export { JoinDirection, isListNodeValidContent, joinSiblingLists } from './node';
|
|
3
|
+
export { JoinDirection, isListNodeValidContent, joinSiblingLists, processNestedTaskListsInSameLevel } from './node';
|
|
4
4
|
export { getCommonListAnalyticsAttributes, countListItemsInSelection } from './analytics';
|
|
5
5
|
export { hasValidListIndentationLevel } from './indentation';
|
|
6
6
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { isListItemNode, isListNode, isOrderedList, isOrderedListContinuous } from '../utils';
|
|
4
|
+
import { wrapTaskListIntoListAbove } from './replace-content';
|
|
4
5
|
export function isListNodeValidContent(node) {
|
|
5
6
|
const {
|
|
6
7
|
bulletList
|
|
@@ -106,4 +107,79 @@ export const joinSiblingLists = ({
|
|
|
106
107
|
tr.join(joins[i]);
|
|
107
108
|
}
|
|
108
109
|
return result;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns the prosemirror position for the child at give index inside the parent node.
|
|
114
|
+
* Example: Considering doc structure as below using the function
|
|
115
|
+
* passing parent resolved position for li and index 2
|
|
116
|
+
* would return starting position of taskList
|
|
117
|
+
* DOC STRUCTURE:
|
|
118
|
+
* ol()
|
|
119
|
+
* ( li(
|
|
120
|
+
* p('text'),
|
|
121
|
+
* ul(content),
|
|
122
|
+
* taskList(),
|
|
123
|
+
* )
|
|
124
|
+
* )
|
|
125
|
+
* @param $from Starting resolved position for the parent node of the child we are looking for.
|
|
126
|
+
* @param index Index of the child node we want the position for.
|
|
127
|
+
* @returns
|
|
128
|
+
*/
|
|
129
|
+
const findStartPositionOfChildWithIndex = ($from, index) => {
|
|
130
|
+
const parent = $from.node();
|
|
131
|
+
let currentPos = $from.pos + 1;
|
|
132
|
+
for (let i = 0; i < index; i++) {
|
|
133
|
+
currentPos += parent.child(i).nodeSize;
|
|
134
|
+
}
|
|
135
|
+
return currentPos;
|
|
136
|
+
};
|
|
137
|
+
const findGrandParentResolvedPos = (tr, $from) => {
|
|
138
|
+
return $from.depth > 2 ? tr.doc.resolve($from.start($from.depth - 2)) : null;
|
|
139
|
+
};
|
|
140
|
+
const findNestedTaskListsIndexAtSameLevel = (tr, $from) => {
|
|
141
|
+
/*
|
|
142
|
+
Currently our cursor would be inside a pargraph of a list of type numbered/bullet list,
|
|
143
|
+
we need to find the grandparent of the cursor which is the list at same level of taskList.
|
|
144
|
+
We can get the root list item(inside which various lists are being resolved before outdenting) by going one depth above that list.
|
|
145
|
+
*/
|
|
146
|
+
const nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
147
|
+
const rootListItem = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.node(nestedListResolvedPos.depth - 1);
|
|
148
|
+
const nestedTaskListsIndexes = [];
|
|
149
|
+
const rootListItemChildCount = (rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.childCount) || 0;
|
|
150
|
+
// first child of list item is always paragraph (i = 0) so we start from 1
|
|
151
|
+
for (let i = 1; i < rootListItemChildCount; i++) {
|
|
152
|
+
if ((rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.child(i).type.name) === 'taskList') {
|
|
153
|
+
nestedTaskListsIndexes.push(i);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return nestedTaskListsIndexes;
|
|
157
|
+
};
|
|
158
|
+
export const processNestedTaskListsInSameLevel = tr => {
|
|
159
|
+
const {
|
|
160
|
+
$from
|
|
161
|
+
} = tr.selection;
|
|
162
|
+
const nestedTaskListIndexes = findNestedTaskListsIndexAtSameLevel(tr, $from);
|
|
163
|
+
if (nestedTaskListIndexes.length === 0) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
167
|
+
const rootListItemStart = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.start(nestedListResolvedPos.depth - 1);
|
|
168
|
+
|
|
169
|
+
/* We need not wrap the taskList present above other lists since it doesn't affect the flow. */
|
|
170
|
+
const nestedTaskListIndexesToWrap = nestedTaskListIndexes.filter(index => index > 1);
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
Wraps the taskLists present at each index mentioned in the nestedTaskListIndexesToWrap to the list above it.
|
|
174
|
+
After each wrap the indexes changes since two lists are being merged into one,
|
|
175
|
+
so we keep track of it and use it to access actual calculated taskList indexes.
|
|
176
|
+
*/
|
|
177
|
+
if (rootListItemStart) {
|
|
178
|
+
let taskListsFixedNested = 0;
|
|
179
|
+
nestedTaskListIndexesToWrap.forEach(index => {
|
|
180
|
+
wrapTaskListIntoListAbove(tr, findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - taskListsFixedNested), findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - 1 - taskListsFixedNested));
|
|
181
|
+
taskListsFixedNested++;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return;
|
|
109
185
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
3
|
export const moveTargetIntoList = ({
|
|
3
4
|
insertPosition,
|
|
@@ -15,4 +16,27 @@ export const moveTargetIntoList = ({
|
|
|
15
16
|
}
|
|
16
17
|
const step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
17
18
|
return step;
|
|
19
|
+
};
|
|
20
|
+
export const wrapTaskListIntoListAbove = (tr, taskListStart, previousListStart) => {
|
|
21
|
+
const $taskListStart = tr.doc.resolve(taskListStart);
|
|
22
|
+
|
|
23
|
+
/* Safecheck: if not passed a taskList node, return */
|
|
24
|
+
if ($taskListStart.node().type.name !== 'taskList') {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const $previousListStart = tr.doc.resolve(previousListStart);
|
|
28
|
+
const taskList = tr.doc.slice($taskListStart.pos, $taskListStart.after());
|
|
29
|
+
const frag = Fragment.from(taskList.content);
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
Delete the existing taskList at the same level and insert inside above list provided
|
|
33
|
+
1. To delete the tasklist, we need wrapping positions before and after it to completely delete it.
|
|
34
|
+
$taskListStart.after() would give us closing position enclosed by node itself using it would remove only the contents of taskList
|
|
35
|
+
so we add 1 to it to get the position after the taskList node and completly remove it.
|
|
36
|
+
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.
|
|
37
|
+
Reason: $previousListStart.end() gives us end position of listItem but we can add content only inside listItem not at same level
|
|
38
|
+
so we subtract 1 to get the position inside the list item and insert the TaskList same level as paragraph/content inside listItem.
|
|
39
|
+
*/
|
|
40
|
+
tr.delete($taskListStart.before(), $taskListStart.after() + 1);
|
|
41
|
+
tr.insert($previousListStart.end() - 1, frag);
|
|
18
42
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "77.3.
|
|
3
|
+
const packageVersion = "77.3.1";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -7,7 +7,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
7
7
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
8
8
|
import Layer from '../Layer';
|
|
9
9
|
const packageName = "@atlaskit/editor-common";
|
|
10
|
-
const packageVersion = "77.3.
|
|
10
|
+
const packageVersion = "77.3.1";
|
|
11
11
|
const halfFocusRing = 1;
|
|
12
12
|
const dropOffset = '0, 8';
|
|
13
13
|
class DropList extends Component {
|
package/dist/esm/lists/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getListItemAttributes, normalizeListItemsSelection } from './selection';
|
|
2
2
|
export { moveTargetIntoList } from './replace-content';
|
|
3
|
-
export { JoinDirection, isListNodeValidContent, joinSiblingLists } from './node';
|
|
3
|
+
export { JoinDirection, isListNodeValidContent, joinSiblingLists, processNestedTaskListsInSameLevel } from './node';
|
|
4
4
|
export { getCommonListAnalyticsAttributes, countListItemsInSelection } from './analytics';
|
|
5
5
|
export { hasValidListIndentationLevel } from './indentation';
|
|
6
6
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
|
package/dist/esm/lists/node.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { isListItemNode, isListNode, isOrderedList, isOrderedListContinuous } from '../utils';
|
|
4
|
+
import { wrapTaskListIntoListAbove } from './replace-content';
|
|
4
5
|
export function isListNodeValidContent(node) {
|
|
5
6
|
var bulletList = node.type.schema.nodes.bulletList;
|
|
6
7
|
if (!bulletList) {
|
|
@@ -96,4 +97,79 @@ export var joinSiblingLists = function joinSiblingLists(_ref) {
|
|
|
96
97
|
tr.join(joins[i]);
|
|
97
98
|
}
|
|
98
99
|
return result;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Returns the prosemirror position for the child at give index inside the parent node.
|
|
104
|
+
* Example: Considering doc structure as below using the function
|
|
105
|
+
* passing parent resolved position for li and index 2
|
|
106
|
+
* would return starting position of taskList
|
|
107
|
+
* DOC STRUCTURE:
|
|
108
|
+
* ol()
|
|
109
|
+
* ( li(
|
|
110
|
+
* p('text'),
|
|
111
|
+
* ul(content),
|
|
112
|
+
* taskList(),
|
|
113
|
+
* )
|
|
114
|
+
* )
|
|
115
|
+
* @param $from Starting resolved position for the parent node of the child we are looking for.
|
|
116
|
+
* @param index Index of the child node we want the position for.
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
var findStartPositionOfChildWithIndex = function findStartPositionOfChildWithIndex($from, index) {
|
|
120
|
+
var parent = $from.node();
|
|
121
|
+
var currentPos = $from.pos + 1;
|
|
122
|
+
for (var i = 0; i < index; i++) {
|
|
123
|
+
currentPos += parent.child(i).nodeSize;
|
|
124
|
+
}
|
|
125
|
+
return currentPos;
|
|
126
|
+
};
|
|
127
|
+
var findGrandParentResolvedPos = function findGrandParentResolvedPos(tr, $from) {
|
|
128
|
+
return $from.depth > 2 ? tr.doc.resolve($from.start($from.depth - 2)) : null;
|
|
129
|
+
};
|
|
130
|
+
var findNestedTaskListsIndexAtSameLevel = function findNestedTaskListsIndexAtSameLevel(tr, $from) {
|
|
131
|
+
/*
|
|
132
|
+
Currently our cursor would be inside a pargraph of a list of type numbered/bullet list,
|
|
133
|
+
we need to find the grandparent of the cursor which is the list at same level of taskList.
|
|
134
|
+
We can get the root list item(inside which various lists are being resolved before outdenting) by going one depth above that list.
|
|
135
|
+
*/
|
|
136
|
+
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
137
|
+
var rootListItem = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.node(nestedListResolvedPos.depth - 1);
|
|
138
|
+
var nestedTaskListsIndexes = [];
|
|
139
|
+
var rootListItemChildCount = (rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.childCount) || 0;
|
|
140
|
+
// first child of list item is always paragraph (i = 0) so we start from 1
|
|
141
|
+
for (var i = 1; i < rootListItemChildCount; i++) {
|
|
142
|
+
if ((rootListItem === null || rootListItem === void 0 ? void 0 : rootListItem.child(i).type.name) === 'taskList') {
|
|
143
|
+
nestedTaskListsIndexes.push(i);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return nestedTaskListsIndexes;
|
|
147
|
+
};
|
|
148
|
+
export var processNestedTaskListsInSameLevel = function processNestedTaskListsInSameLevel(tr) {
|
|
149
|
+
var $from = tr.selection.$from;
|
|
150
|
+
var nestedTaskListIndexes = findNestedTaskListsIndexAtSameLevel(tr, $from);
|
|
151
|
+
if (nestedTaskListIndexes.length === 0) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
var nestedListResolvedPos = findGrandParentResolvedPos(tr, $from);
|
|
155
|
+
var rootListItemStart = nestedListResolvedPos === null || nestedListResolvedPos === void 0 ? void 0 : nestedListResolvedPos.start(nestedListResolvedPos.depth - 1);
|
|
156
|
+
|
|
157
|
+
/* We need not wrap the taskList present above other lists since it doesn't affect the flow. */
|
|
158
|
+
var nestedTaskListIndexesToWrap = nestedTaskListIndexes.filter(function (index) {
|
|
159
|
+
return index > 1;
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
Wraps the taskLists present at each index mentioned in the nestedTaskListIndexesToWrap to the list above it.
|
|
164
|
+
After each wrap the indexes changes since two lists are being merged into one,
|
|
165
|
+
so we keep track of it and use it to access actual calculated taskList indexes.
|
|
166
|
+
*/
|
|
167
|
+
if (rootListItemStart) {
|
|
168
|
+
var taskListsFixedNested = 0;
|
|
169
|
+
nestedTaskListIndexesToWrap.forEach(function (index) {
|
|
170
|
+
wrapTaskListIntoListAbove(tr, findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - taskListsFixedNested), findStartPositionOfChildWithIndex(tr.doc.resolve(rootListItemStart), index - 1 - taskListsFixedNested));
|
|
171
|
+
taskListsFixedNested++;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
99
175
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
1
2
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
3
|
export var moveTargetIntoList = function moveTargetIntoList(_ref) {
|
|
3
4
|
var _$target$nodeAfter;
|
|
@@ -14,4 +15,27 @@ export var moveTargetIntoList = function moveTargetIntoList(_ref) {
|
|
|
14
15
|
}
|
|
15
16
|
var step = new ReplaceAroundStep(from, to, gapFrom, gapTo, $target.doc.slice(insertPosition, $target.pos), 0, true);
|
|
16
17
|
return step;
|
|
18
|
+
};
|
|
19
|
+
export var wrapTaskListIntoListAbove = function wrapTaskListIntoListAbove(tr, taskListStart, previousListStart) {
|
|
20
|
+
var $taskListStart = tr.doc.resolve(taskListStart);
|
|
21
|
+
|
|
22
|
+
/* Safecheck: if not passed a taskList node, return */
|
|
23
|
+
if ($taskListStart.node().type.name !== 'taskList') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
var $previousListStart = tr.doc.resolve(previousListStart);
|
|
27
|
+
var taskList = tr.doc.slice($taskListStart.pos, $taskListStart.after());
|
|
28
|
+
var frag = Fragment.from(taskList.content);
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
Delete the existing taskList at the same level and insert inside above list provided
|
|
32
|
+
1. To delete the tasklist, we need wrapping positions before and after it to completely delete it.
|
|
33
|
+
$taskListStart.after() would give us closing position enclosed by node itself using it would remove only the contents of taskList
|
|
34
|
+
so we add 1 to it to get the position after the taskList node and completly remove it.
|
|
35
|
+
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.
|
|
36
|
+
Reason: $previousListStart.end() gives us end position of listItem but we can add content only inside listItem not at same level
|
|
37
|
+
so we subtract 1 to get the position inside the list item and insert the TaskList same level as paragraph/content inside listItem.
|
|
38
|
+
*/
|
|
39
|
+
tr.delete($taskListStart.before(), $taskListStart.after() + 1);
|
|
40
|
+
tr.insert($previousListStart.end() - 1, frag);
|
|
17
41
|
};
|
|
@@ -6,7 +6,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
8
8
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
9
|
-
var packageVersion = "77.3.
|
|
9
|
+
var packageVersion = "77.3.1";
|
|
10
10
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
11
11
|
// Remove URL as it has UGC
|
|
12
12
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -17,7 +17,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
17
17
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
18
18
|
import Layer from '../Layer';
|
|
19
19
|
var packageName = "@atlaskit/editor-common";
|
|
20
|
-
var packageVersion = "77.3.
|
|
20
|
+
var packageVersion = "77.3.1";
|
|
21
21
|
var halfFocusRing = 1;
|
|
22
22
|
var dropOffset = '0, 8';
|
|
23
23
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getListItemAttributes, normalizeListItemsSelection, } from './selection';
|
|
2
2
|
export { moveTargetIntoList } from './replace-content';
|
|
3
|
-
export { JoinDirection, isListNodeValidContent, joinSiblingLists, } from './node';
|
|
3
|
+
export { JoinDirection, isListNodeValidContent, joinSiblingLists, processNestedTaskListsInSameLevel, } from './node';
|
|
4
4
|
export { getCommonListAnalyticsAttributes, countListItemsInSelection, } from './analytics';
|
|
5
5
|
export { hasValidListIndentationLevel } from './indentation';
|
|
6
6
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode, } from '../utils';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import {
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
3
4
|
type Params = {
|
|
4
5
|
insertPosition: number;
|
|
5
6
|
$target: ResolvedPos;
|
|
6
7
|
};
|
|
7
8
|
export declare const moveTargetIntoList: ({ insertPosition, $target, }: Params) => Step;
|
|
9
|
+
export declare const wrapTaskListIntoListAbove: (tr: Transaction, taskListStart: number, previousListStart: number) => void;
|
|
8
10
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getListItemAttributes, normalizeListItemsSelection, } from './selection';
|
|
2
2
|
export { moveTargetIntoList } from './replace-content';
|
|
3
|
-
export { JoinDirection, isListNodeValidContent, joinSiblingLists, } from './node';
|
|
3
|
+
export { JoinDirection, isListNodeValidContent, joinSiblingLists, processNestedTaskListsInSameLevel, } from './node';
|
|
4
4
|
export { getCommonListAnalyticsAttributes, countListItemsInSelection, } from './analytics';
|
|
5
5
|
export { hasValidListIndentationLevel } from './indentation';
|
|
6
6
|
export { isListNode, isListItemNode, isBulletList, isParagraphNode, } from '../utils';
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import {
|
|
2
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
3
4
|
type Params = {
|
|
4
5
|
insertPosition: number;
|
|
5
6
|
$target: ResolvedPos;
|
|
6
7
|
};
|
|
7
8
|
export declare const moveTargetIntoList: ({ insertPosition, $target, }: Params) => Step;
|
|
9
|
+
export declare const wrapTaskListIntoListAbove: (tr: Transaction, taskListStart: number, previousListStart: number) => void;
|
|
8
10
|
export {};
|
package/package.json
CHANGED