@atlaskit/editor-plugin-list 4.1.5 → 4.2.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
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-list
|
|
2
2
|
|
|
3
|
+
## 4.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 4.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#130794](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/130794)
|
|
14
|
+
[`6271b4a0cda38`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6271b4a0cda38) -
|
|
15
|
+
[ux] ED-26943 Create new list item when hit Enter at the end of a block element in list
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 4.1.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -37,7 +37,11 @@ var enterKeyCommand = exports.enterKeyCommand = function enterKeyCommand(editorA
|
|
|
37
37
|
var _state$schema$nodes = state.schema.nodes,
|
|
38
38
|
listItem = _state$schema$nodes.listItem,
|
|
39
39
|
codeBlock = _state$schema$nodes.codeBlock;
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
// the list item is the parent of the gap cursor
|
|
42
|
+
// while for text, list item is the grant parent of the text node
|
|
43
|
+
var isGapCursorSelection = selection instanceof _selection.GapCursorSelection;
|
|
44
|
+
var wrapper = isGapCursorSelection && (0, _platformFeatureFlags.fg)('platform_editor_split_list_item_for_gap_cursor') ? $from.parent : $from.node($from.depth - 1);
|
|
41
45
|
if (wrapper && wrapper.type === listItem) {
|
|
42
46
|
/** Check if the wrapper has any visible content */
|
|
43
47
|
var wrapperHasContent = (0, _utils.hasVisibleContent)(wrapper);
|
|
@@ -203,7 +207,11 @@ function splitListItem(itemType) {
|
|
|
203
207
|
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
204
208
|
return false;
|
|
205
209
|
}
|
|
206
|
-
|
|
210
|
+
|
|
211
|
+
// list item is the parent of the gap cursor instead of grant parent;
|
|
212
|
+
// rename grantParent to WrapperlistItem once we clean up platform_editor_split_list_item_for_gap_cursor
|
|
213
|
+
var isGapCursorSelection = ref instanceof _selection.GapCursorSelection;
|
|
214
|
+
var grandParent = isGapCursorSelection && (0, _platformFeatureFlags.fg)('platform_editor_split_list_item_for_gap_cursor') ? $from.parent : $from.node(-1);
|
|
207
215
|
if (grandParent.type !== itemType) {
|
|
208
216
|
return false;
|
|
209
217
|
}
|
|
@@ -242,10 +250,33 @@ function splitListItem(itemType) {
|
|
|
242
250
|
var types = nextType && [null, {
|
|
243
251
|
type: nextType
|
|
244
252
|
}];
|
|
245
|
-
if (
|
|
246
|
-
|
|
253
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_split_list_item_for_gap_cursor')) {
|
|
254
|
+
if (dispatch) {
|
|
255
|
+
var _$from$nodeBefore;
|
|
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) {
|
|
276
|
+
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
247
279
|
}
|
|
248
|
-
return true;
|
|
249
280
|
};
|
|
250
281
|
}
|
|
251
282
|
var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, dispatch) {
|
|
@@ -272,12 +303,12 @@ var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, di
|
|
|
272
303
|
};
|
|
273
304
|
var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
274
305
|
var $from = state.selection.$from;
|
|
275
|
-
var _state$schema$
|
|
276
|
-
paragraph = _state$schema$
|
|
277
|
-
listItem = _state$schema$
|
|
278
|
-
codeBlock = _state$schema$
|
|
279
|
-
bulletList = _state$schema$
|
|
280
|
-
orderedList = _state$schema$
|
|
306
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
307
|
+
paragraph = _state$schema$nodes3.paragraph,
|
|
308
|
+
listItem = _state$schema$nodes3.listItem,
|
|
309
|
+
codeBlock = _state$schema$nodes3.codeBlock,
|
|
310
|
+
bulletList = _state$schema$nodes3.bulletList,
|
|
311
|
+
orderedList = _state$schema$nodes3.orderedList;
|
|
281
312
|
var isGapCursorShown = state.selection instanceof _selection.GapCursorSelection;
|
|
282
313
|
var $cutPos = isGapCursorShown ? state.doc.resolve($from.pos + 1) : $from;
|
|
283
314
|
var $cut = (0, _commands.findCutBefore)($cutPos);
|
|
@@ -6,7 +6,7 @@ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
|
6
6
|
import { filterCommand as filter, hasVisibleContent, isEmptySelectionAtStart } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
8
8
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
12
|
import { convertListType } from '../actions/conversions';
|
|
@@ -30,7 +30,11 @@ export const enterKeyCommand = editorAnalyticsAPI => () => (state, dispatch) =>
|
|
|
30
30
|
listItem,
|
|
31
31
|
codeBlock
|
|
32
32
|
} = state.schema.nodes;
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
// the list item is the parent of the gap cursor
|
|
35
|
+
// while for text, list item is the grant parent of the text node
|
|
36
|
+
const isGapCursorSelection = selection instanceof GapCursorSelection;
|
|
37
|
+
const wrapper = isGapCursorSelection && fg('platform_editor_split_list_item_for_gap_cursor') ? $from.parent : $from.node($from.depth - 1);
|
|
34
38
|
if (wrapper && wrapper.type === listItem) {
|
|
35
39
|
/** Check if the wrapper has any visible content */
|
|
36
40
|
const wrapperHasContent = hasVisibleContent(wrapper);
|
|
@@ -186,7 +190,11 @@ function splitListItem(itemType) {
|
|
|
186
190
|
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
187
191
|
return false;
|
|
188
192
|
}
|
|
189
|
-
|
|
193
|
+
|
|
194
|
+
// list item is the parent of the gap cursor instead of grant parent;
|
|
195
|
+
// rename grantParent to WrapperlistItem once we clean up platform_editor_split_list_item_for_gap_cursor
|
|
196
|
+
const isGapCursorSelection = ref instanceof GapCursorSelection;
|
|
197
|
+
const grandParent = isGapCursorSelection && fg('platform_editor_split_list_item_for_gap_cursor') ? $from.parent : $from.node(-1);
|
|
190
198
|
if (grandParent.type !== itemType) {
|
|
191
199
|
return false;
|
|
192
200
|
}
|
|
@@ -225,10 +233,34 @@ function splitListItem(itemType) {
|
|
|
225
233
|
const types = nextType && [null, {
|
|
226
234
|
type: nextType
|
|
227
235
|
}];
|
|
228
|
-
if (
|
|
229
|
-
|
|
236
|
+
if (fg('platform_editor_split_list_item_for_gap_cursor')) {
|
|
237
|
+
if (dispatch) {
|
|
238
|
+
var _$from$nodeBefore;
|
|
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) {
|
|
260
|
+
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
230
263
|
}
|
|
231
|
-
return true;
|
|
232
264
|
};
|
|
233
265
|
}
|
|
234
266
|
const deletePreviousEmptyListItem = (state, dispatch) => {
|
|
@@ -9,7 +9,7 @@ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
|
9
9
|
import { filterCommand as filter, hasVisibleContent, isEmptySelectionAtStart } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
11
11
|
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
12
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
+
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
13
|
import { findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
import { convertListType } from '../actions/conversions';
|
|
@@ -30,7 +30,11 @@ export var enterKeyCommand = function enterKeyCommand(editorAnalyticsAPI) {
|
|
|
30
30
|
var _state$schema$nodes = state.schema.nodes,
|
|
31
31
|
listItem = _state$schema$nodes.listItem,
|
|
32
32
|
codeBlock = _state$schema$nodes.codeBlock;
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
// the list item is the parent of the gap cursor
|
|
35
|
+
// while for text, list item is the grant parent of the text node
|
|
36
|
+
var isGapCursorSelection = selection instanceof GapCursorSelection;
|
|
37
|
+
var wrapper = isGapCursorSelection && fg('platform_editor_split_list_item_for_gap_cursor') ? $from.parent : $from.node($from.depth - 1);
|
|
34
38
|
if (wrapper && wrapper.type === listItem) {
|
|
35
39
|
/** Check if the wrapper has any visible content */
|
|
36
40
|
var wrapperHasContent = hasVisibleContent(wrapper);
|
|
@@ -196,7 +200,11 @@ function splitListItem(itemType) {
|
|
|
196
200
|
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
197
201
|
return false;
|
|
198
202
|
}
|
|
199
|
-
|
|
203
|
+
|
|
204
|
+
// list item is the parent of the gap cursor instead of grant parent;
|
|
205
|
+
// rename grantParent to WrapperlistItem once we clean up platform_editor_split_list_item_for_gap_cursor
|
|
206
|
+
var isGapCursorSelection = ref instanceof GapCursorSelection;
|
|
207
|
+
var grandParent = isGapCursorSelection && fg('platform_editor_split_list_item_for_gap_cursor') ? $from.parent : $from.node(-1);
|
|
200
208
|
if (grandParent.type !== itemType) {
|
|
201
209
|
return false;
|
|
202
210
|
}
|
|
@@ -235,10 +243,33 @@ function splitListItem(itemType) {
|
|
|
235
243
|
var types = nextType && [null, {
|
|
236
244
|
type: nextType
|
|
237
245
|
}];
|
|
238
|
-
if (
|
|
239
|
-
|
|
246
|
+
if (fg('platform_editor_split_list_item_for_gap_cursor')) {
|
|
247
|
+
if (dispatch) {
|
|
248
|
+
var _$from$nodeBefore;
|
|
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) {
|
|
269
|
+
dispatch(tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined).scrollIntoView());
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
240
272
|
}
|
|
241
|
-
return true;
|
|
242
273
|
};
|
|
243
274
|
}
|
|
244
275
|
var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, dispatch) {
|
|
@@ -265,12 +296,12 @@ var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, di
|
|
|
265
296
|
};
|
|
266
297
|
var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
267
298
|
var $from = state.selection.$from;
|
|
268
|
-
var _state$schema$
|
|
269
|
-
paragraph = _state$schema$
|
|
270
|
-
listItem = _state$schema$
|
|
271
|
-
codeBlock = _state$schema$
|
|
272
|
-
bulletList = _state$schema$
|
|
273
|
-
orderedList = _state$schema$
|
|
299
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
300
|
+
paragraph = _state$schema$nodes3.paragraph,
|
|
301
|
+
listItem = _state$schema$nodes3.listItem,
|
|
302
|
+
codeBlock = _state$schema$nodes3.codeBlock,
|
|
303
|
+
bulletList = _state$schema$nodes3.bulletList,
|
|
304
|
+
orderedList = _state$schema$nodes3.orderedList;
|
|
274
305
|
var isGapCursorShown = state.selection instanceof GapCursorSelection;
|
|
275
306
|
var $cutPos = isGapCursorShown ? state.doc.resolve($from.pos + 1) : $from;
|
|
276
307
|
var $cut = findCutBefore($cutPos);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-list",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.2.1",
|
|
4
4
|
"description": "List plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^47.6.0",
|
|
35
|
-
"@atlaskit/editor-common": "^
|
|
35
|
+
"@atlaskit/editor-common": "^103.0.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^2.2.0",
|
|
37
37
|
"@atlaskit/editor-plugin-feature-flags": "^1.3.0",
|
|
38
38
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
40
40
|
"@atlaskit/prosemirror-input-rules": "^3.3.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^4.6.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -89,6 +89,9 @@
|
|
|
89
89
|
},
|
|
90
90
|
"platform_editor_non_macros_list_indent_fix": {
|
|
91
91
|
"type": "boolean"
|
|
92
|
+
},
|
|
93
|
+
"platform_editor_split_list_item_for_gap_cursor": {
|
|
94
|
+
"type": "boolean"
|
|
92
95
|
}
|
|
93
96
|
},
|
|
94
97
|
"stricter": {
|