@atlaskit/editor-plugin-list 8.2.18 → 8.2.19
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
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-list
|
|
2
2
|
|
|
3
|
+
## 8.2.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`fa963aec58f3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa963aec58f3d) -
|
|
8
|
+
EDITOR-3064 Clean up feature gate platform_editor_split_list_item_for_gap_cursor
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 8.2.18
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -16,7 +16,6 @@ var _commands2 = require("@atlaskit/editor-prosemirror/commands");
|
|
|
16
16
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
17
17
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
18
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
19
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
19
|
var _conversions = require("../actions/conversions");
|
|
21
20
|
var _wrapAndJoinLists = require("../actions/wrap-and-join-lists");
|
|
22
21
|
var _transforms = require("../transforms");
|
|
@@ -39,9 +38,9 @@ var enterKeyCommand = exports.enterKeyCommand = function enterKeyCommand(editorA
|
|
|
39
38
|
codeBlock = _state$schema$nodes.codeBlock;
|
|
40
39
|
|
|
41
40
|
// the list item is the parent of the gap cursor
|
|
42
|
-
// while for text, list item is the
|
|
41
|
+
// while for text, list item is the grandparent of the text node
|
|
43
42
|
var isGapCursorSelection = selection instanceof _selection.GapCursorSelection;
|
|
44
|
-
var wrapper = isGapCursorSelection
|
|
43
|
+
var wrapper = isGapCursorSelection ? $from.parent : $from.node($from.depth - 1);
|
|
45
44
|
if (wrapper && wrapper.type === listItem) {
|
|
46
45
|
/** Check if the wrapper has any visible content */
|
|
47
46
|
var wrapperHasContent = (0, _utils.hasVisibleContent)(wrapper);
|
|
@@ -208,17 +207,16 @@ function splitListItem(itemType) {
|
|
|
208
207
|
return false;
|
|
209
208
|
}
|
|
210
209
|
|
|
211
|
-
// list item is the parent of the gap cursor instead of
|
|
212
|
-
// rename grantParent to WrapperlistItem once we clean up platform_editor_split_list_item_for_gap_cursor
|
|
210
|
+
// list item is the parent of the gap cursor instead of grandparent
|
|
213
211
|
var isGapCursorSelection = ref instanceof _selection.GapCursorSelection;
|
|
214
|
-
var
|
|
215
|
-
if (
|
|
212
|
+
var wrapperListItem = isGapCursorSelection ? $from.parent : $from.node(-1);
|
|
213
|
+
if (wrapperListItem.type !== itemType) {
|
|
216
214
|
return false;
|
|
217
215
|
}
|
|
218
216
|
/** --> The following line changed from the original PM implementation to allow list additions with multiple paragraphs */
|
|
219
217
|
if (
|
|
220
218
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
221
|
-
|
|
219
|
+
wrapperListItem.content.content.length <= 1 && $from.parent.content.size === 0 && !(wrapperListItem.content.size === 0)) {
|
|
222
220
|
// In an empty block. If this is a nested list, the wrapping
|
|
223
221
|
// list item should be split. Otherwise, bail out and let next
|
|
224
222
|
// command handle lifting.
|
|
@@ -245,38 +243,31 @@ function splitListItem(itemType) {
|
|
|
245
243
|
}
|
|
246
244
|
return true;
|
|
247
245
|
}
|
|
248
|
-
var nextType = $to.pos === $from.end() ?
|
|
246
|
+
var nextType = $to.pos === $from.end() ? wrapperListItem.contentMatchAt(0).defaultType : null;
|
|
249
247
|
var tr = state.tr.delete($from.pos, $to.pos);
|
|
250
248
|
var types = nextType && [null, {
|
|
251
249
|
type: nextType
|
|
252
250
|
}];
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (ref instanceof _state.TextSelection) {
|
|
257
|
-
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// create new list item with empty paragraph when user click enter on gap cursor
|
|
262
|
-
if (isGapCursorSelection && (_$from$nodeBefore = $from.nodeBefore) !== null && _$from$nodeBefore !== void 0 && _$from$nodeBefore.isBlock) {
|
|
263
|
-
// For gap cursor selection , we can not split the list item directly
|
|
264
|
-
// We need to insert a new list item after the current list item to simulate the split behaviour
|
|
265
|
-
var _state$schema$nodes2 = state.schema.nodes,
|
|
266
|
-
listItem = _state$schema$nodes2.listItem,
|
|
267
|
-
paragraph = _state$schema$nodes2.paragraph;
|
|
268
|
-
var newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
269
|
-
dispatch(tr.insert($from.pos, newListItem).setSelection(_state.Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return false;
|
|
274
|
-
} else {
|
|
275
|
-
if (dispatch) {
|
|
251
|
+
if (dispatch) {
|
|
252
|
+
var _$from$nodeBefore;
|
|
253
|
+
if (ref instanceof _state.TextSelection) {
|
|
276
254
|
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// create new list item with empty paragraph when user clicks enter on gap cursor
|
|
259
|
+
if (isGapCursorSelection && (_$from$nodeBefore = $from.nodeBefore) !== null && _$from$nodeBefore !== void 0 && _$from$nodeBefore.isBlock) {
|
|
260
|
+
// For gap cursor selection, we cannot split the list item directly
|
|
261
|
+
// We need to insert a new list item after the current list item to simulate the split behaviour
|
|
262
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
263
|
+
listItem = _state$schema$nodes2.listItem,
|
|
264
|
+
paragraph = _state$schema$nodes2.paragraph;
|
|
265
|
+
var newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
266
|
+
dispatch(tr.insert($from.pos, newListItem).setSelection(_state.Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
267
|
+
return true;
|
|
277
268
|
}
|
|
278
|
-
return true;
|
|
279
269
|
}
|
|
270
|
+
return false;
|
|
280
271
|
};
|
|
281
272
|
}
|
|
282
273
|
var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, dispatch) {
|
|
@@ -8,7 +8,6 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
8
8
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
9
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
11
|
import { convertListType } from '../actions/conversions';
|
|
13
12
|
import { wrapInListAndJoin } from '../actions/wrap-and-join-lists';
|
|
14
13
|
import { liftFollowingList, liftNodeSelectionList, liftTextSelectionList } from '../transforms';
|
|
@@ -32,9 +31,9 @@ export const enterKeyCommand = editorAnalyticsAPI => () => (state, dispatch) =>
|
|
|
32
31
|
} = state.schema.nodes;
|
|
33
32
|
|
|
34
33
|
// the list item is the parent of the gap cursor
|
|
35
|
-
// while for text, list item is the
|
|
34
|
+
// while for text, list item is the grandparent of the text node
|
|
36
35
|
const isGapCursorSelection = selection instanceof GapCursorSelection;
|
|
37
|
-
const wrapper = isGapCursorSelection
|
|
36
|
+
const wrapper = isGapCursorSelection ? $from.parent : $from.node($from.depth - 1);
|
|
38
37
|
if (wrapper && wrapper.type === listItem) {
|
|
39
38
|
/** Check if the wrapper has any visible content */
|
|
40
39
|
const wrapperHasContent = hasVisibleContent(wrapper);
|
|
@@ -191,17 +190,16 @@ function splitListItem(itemType) {
|
|
|
191
190
|
return false;
|
|
192
191
|
}
|
|
193
192
|
|
|
194
|
-
// list item is the parent of the gap cursor instead of
|
|
195
|
-
// rename grantParent to WrapperlistItem once we clean up platform_editor_split_list_item_for_gap_cursor
|
|
193
|
+
// list item is the parent of the gap cursor instead of grandparent
|
|
196
194
|
const isGapCursorSelection = ref instanceof GapCursorSelection;
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
195
|
+
const wrapperListItem = isGapCursorSelection ? $from.parent : $from.node(-1);
|
|
196
|
+
if (wrapperListItem.type !== itemType) {
|
|
199
197
|
return false;
|
|
200
198
|
}
|
|
201
199
|
/** --> The following line changed from the original PM implementation to allow list additions with multiple paragraphs */
|
|
202
200
|
if (
|
|
203
201
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
|
-
|
|
202
|
+
wrapperListItem.content.content.length <= 1 && $from.parent.content.size === 0 && !(wrapperListItem.content.size === 0)) {
|
|
205
203
|
// In an empty block. If this is a nested list, the wrapping
|
|
206
204
|
// list item should be split. Otherwise, bail out and let next
|
|
207
205
|
// command handle lifting.
|
|
@@ -228,39 +226,32 @@ function splitListItem(itemType) {
|
|
|
228
226
|
}
|
|
229
227
|
return true;
|
|
230
228
|
}
|
|
231
|
-
const nextType = $to.pos === $from.end() ?
|
|
229
|
+
const nextType = $to.pos === $from.end() ? wrapperListItem.contentMatchAt(0).defaultType : null;
|
|
232
230
|
const tr = state.tr.delete($from.pos, $to.pos);
|
|
233
231
|
const types = nextType && [null, {
|
|
234
232
|
type: nextType
|
|
235
233
|
}];
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (ref instanceof TextSelection) {
|
|
240
|
-
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// create new list item with empty paragraph when user click enter on gap cursor
|
|
245
|
-
if (isGapCursorSelection && (_$from$nodeBefore = $from.nodeBefore) !== null && _$from$nodeBefore !== void 0 && _$from$nodeBefore.isBlock) {
|
|
246
|
-
// For gap cursor selection , we can not split the list item directly
|
|
247
|
-
// We need to insert a new list item after the current list item to simulate the split behaviour
|
|
248
|
-
const {
|
|
249
|
-
listItem,
|
|
250
|
-
paragraph
|
|
251
|
-
} = state.schema.nodes;
|
|
252
|
-
const newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
253
|
-
dispatch(tr.insert($from.pos, newListItem).setSelection(Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
return false;
|
|
258
|
-
} else {
|
|
259
|
-
if (dispatch) {
|
|
234
|
+
if (dispatch) {
|
|
235
|
+
var _$from$nodeBefore;
|
|
236
|
+
if (ref instanceof TextSelection) {
|
|
260
237
|
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// create new list item with empty paragraph when user clicks enter on gap cursor
|
|
242
|
+
if (isGapCursorSelection && (_$from$nodeBefore = $from.nodeBefore) !== null && _$from$nodeBefore !== void 0 && _$from$nodeBefore.isBlock) {
|
|
243
|
+
// For gap cursor selection, we cannot split the list item directly
|
|
244
|
+
// We need to insert a new list item after the current list item to simulate the split behaviour
|
|
245
|
+
const {
|
|
246
|
+
listItem,
|
|
247
|
+
paragraph
|
|
248
|
+
} = state.schema.nodes;
|
|
249
|
+
const newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
250
|
+
dispatch(tr.insert($from.pos, newListItem).setSelection(Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
251
|
+
return true;
|
|
261
252
|
}
|
|
262
|
-
return true;
|
|
263
253
|
}
|
|
254
|
+
return false;
|
|
264
255
|
};
|
|
265
256
|
}
|
|
266
257
|
const deletePreviousEmptyListItem = (state, dispatch) => {
|
|
@@ -11,7 +11,6 @@ import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
|
11
11
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
12
12
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
14
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
14
|
import { convertListType } from '../actions/conversions';
|
|
16
15
|
import { wrapInListAndJoin } from '../actions/wrap-and-join-lists';
|
|
17
16
|
import { liftFollowingList, liftNodeSelectionList, liftTextSelectionList } from '../transforms';
|
|
@@ -32,9 +31,9 @@ export var enterKeyCommand = function enterKeyCommand(editorAnalyticsAPI) {
|
|
|
32
31
|
codeBlock = _state$schema$nodes.codeBlock;
|
|
33
32
|
|
|
34
33
|
// the list item is the parent of the gap cursor
|
|
35
|
-
// while for text, list item is the
|
|
34
|
+
// while for text, list item is the grandparent of the text node
|
|
36
35
|
var isGapCursorSelection = selection instanceof GapCursorSelection;
|
|
37
|
-
var wrapper = isGapCursorSelection
|
|
36
|
+
var wrapper = isGapCursorSelection ? $from.parent : $from.node($from.depth - 1);
|
|
38
37
|
if (wrapper && wrapper.type === listItem) {
|
|
39
38
|
/** Check if the wrapper has any visible content */
|
|
40
39
|
var wrapperHasContent = hasVisibleContent(wrapper);
|
|
@@ -201,17 +200,16 @@ function splitListItem(itemType) {
|
|
|
201
200
|
return false;
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
// list item is the parent of the gap cursor instead of
|
|
205
|
-
// rename grantParent to WrapperlistItem once we clean up platform_editor_split_list_item_for_gap_cursor
|
|
203
|
+
// list item is the parent of the gap cursor instead of grandparent
|
|
206
204
|
var isGapCursorSelection = ref instanceof GapCursorSelection;
|
|
207
|
-
var
|
|
208
|
-
if (
|
|
205
|
+
var wrapperListItem = isGapCursorSelection ? $from.parent : $from.node(-1);
|
|
206
|
+
if (wrapperListItem.type !== itemType) {
|
|
209
207
|
return false;
|
|
210
208
|
}
|
|
211
209
|
/** --> The following line changed from the original PM implementation to allow list additions with multiple paragraphs */
|
|
212
210
|
if (
|
|
213
211
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
214
|
-
|
|
212
|
+
wrapperListItem.content.content.length <= 1 && $from.parent.content.size === 0 && !(wrapperListItem.content.size === 0)) {
|
|
215
213
|
// In an empty block. If this is a nested list, the wrapping
|
|
216
214
|
// list item should be split. Otherwise, bail out and let next
|
|
217
215
|
// command handle lifting.
|
|
@@ -238,38 +236,31 @@ function splitListItem(itemType) {
|
|
|
238
236
|
}
|
|
239
237
|
return true;
|
|
240
238
|
}
|
|
241
|
-
var nextType = $to.pos === $from.end() ?
|
|
239
|
+
var nextType = $to.pos === $from.end() ? wrapperListItem.contentMatchAt(0).defaultType : null;
|
|
242
240
|
var tr = state.tr.delete($from.pos, $to.pos);
|
|
243
241
|
var types = nextType && [null, {
|
|
244
242
|
type: nextType
|
|
245
243
|
}];
|
|
246
|
-
if (
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
if (ref instanceof TextSelection) {
|
|
250
|
-
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
251
|
-
return true;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// create new list item with empty paragraph when user click enter on gap cursor
|
|
255
|
-
if (isGapCursorSelection && (_$from$nodeBefore = $from.nodeBefore) !== null && _$from$nodeBefore !== void 0 && _$from$nodeBefore.isBlock) {
|
|
256
|
-
// For gap cursor selection , we can not split the list item directly
|
|
257
|
-
// We need to insert a new list item after the current list item to simulate the split behaviour
|
|
258
|
-
var _state$schema$nodes2 = state.schema.nodes,
|
|
259
|
-
listItem = _state$schema$nodes2.listItem,
|
|
260
|
-
paragraph = _state$schema$nodes2.paragraph;
|
|
261
|
-
var newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
262
|
-
dispatch(tr.insert($from.pos, newListItem).setSelection(Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return false;
|
|
267
|
-
} else {
|
|
268
|
-
if (dispatch) {
|
|
244
|
+
if (dispatch) {
|
|
245
|
+
var _$from$nodeBefore;
|
|
246
|
+
if (ref instanceof TextSelection) {
|
|
269
247
|
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// create new list item with empty paragraph when user clicks enter on gap cursor
|
|
252
|
+
if (isGapCursorSelection && (_$from$nodeBefore = $from.nodeBefore) !== null && _$from$nodeBefore !== void 0 && _$from$nodeBefore.isBlock) {
|
|
253
|
+
// For gap cursor selection, we cannot split the list item directly
|
|
254
|
+
// We need to insert a new list item after the current list item to simulate the split behaviour
|
|
255
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
256
|
+
listItem = _state$schema$nodes2.listItem,
|
|
257
|
+
paragraph = _state$schema$nodes2.paragraph;
|
|
258
|
+
var newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
259
|
+
dispatch(tr.insert($from.pos, newListItem).setSelection(Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
260
|
+
return true;
|
|
270
261
|
}
|
|
271
|
-
return true;
|
|
272
262
|
}
|
|
263
|
+
return false;
|
|
273
264
|
};
|
|
274
265
|
}
|
|
275
266
|
var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, dispatch) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-list",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.19",
|
|
4
4
|
"description": "List plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,23 +27,23 @@
|
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"atlaskit:src": "src/index.ts",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^51.5.
|
|
30
|
+
"@atlaskit/adf-schema": "^51.5.0",
|
|
31
31
|
"@atlaskit/editor-plugin-analytics": "^6.2.0",
|
|
32
|
-
"@atlaskit/editor-plugin-block-menu": "^5.
|
|
32
|
+
"@atlaskit/editor-plugin-block-menu": "^5.2.0",
|
|
33
33
|
"@atlaskit/editor-plugin-feature-flags": "^5.0.0",
|
|
34
34
|
"@atlaskit/editor-plugin-toolbar": "^3.4.0",
|
|
35
|
-
"@atlaskit/editor-prosemirror": "7.
|
|
35
|
+
"@atlaskit/editor-prosemirror": "^7.2.0",
|
|
36
36
|
"@atlaskit/editor-toolbar": "^0.18.0",
|
|
37
|
-
"@atlaskit/icon": "^29.
|
|
37
|
+
"@atlaskit/icon": "^29.1.0",
|
|
38
38
|
"@atlaskit/insm": "^0.2.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
41
41
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
42
|
-
"@atlaskit/tmp-editor-statsig": "^15.
|
|
42
|
+
"@atlaskit/tmp-editor-statsig": "^15.10.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@atlaskit/editor-common": "^110.
|
|
46
|
+
"@atlaskit/editor-common": "^110.42.0",
|
|
47
47
|
"react": "^18.2.0",
|
|
48
48
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
49
49
|
},
|
|
@@ -83,9 +83,6 @@
|
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
"platform-feature-flags": {
|
|
86
|
-
"platform_editor_split_list_item_for_gap_cursor": {
|
|
87
|
-
"type": "boolean"
|
|
88
|
-
},
|
|
89
86
|
"platform_editor_adf_with_localid": {
|
|
90
87
|
"type": "boolean"
|
|
91
88
|
}
|