@atlaskit/editor-plugin-list 10.1.6 → 10.2.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 +11 -0
- package/dist/cjs/pm-plugins/actions/merge-lists.js +8 -6
- package/dist/cjs/pm-plugins/commands/index.js +18 -2
- package/dist/cjs/pm-plugins/commands/listBackspace.js +17 -0
- package/dist/es2019/pm-plugins/actions/merge-lists.js +8 -6
- package/dist/es2019/pm-plugins/commands/index.js +22 -4
- package/dist/es2019/pm-plugins/commands/listBackspace.js +23 -0
- package/dist/esm/pm-plugins/actions/merge-lists.js +8 -6
- package/dist/esm/pm-plugins/commands/index.js +20 -4
- package/dist/esm/pm-plugins/commands/listBackspace.js +17 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-list
|
|
2
2
|
|
|
3
|
+
## 10.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`b749ce678d575`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b749ce678d575) -
|
|
8
|
+
Preserve small text formatting across list and task list edits
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 10.1.6
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.mergeNextListAtPosition = mergeNextListAtPosition;
|
|
7
|
+
var _lists = require("@atlaskit/editor-common/lists");
|
|
7
8
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
10
|
function mergeNextListAtPosition(_ref) {
|
|
9
11
|
var tr = _ref.tr,
|
|
10
12
|
listPosition = _ref.listPosition;
|
|
@@ -22,13 +24,13 @@ function mergeNextListAtPosition(_ref) {
|
|
|
22
24
|
if (!(0, _utils.isListNode)(nodeBefore) || !(0, _utils.isListNode)(nodeAfter)) {
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
28
|
-
var previousListPosition = pos - nodeBefore.nodeSize;
|
|
29
|
-
// Ignored via go/ees005
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
27
|
+
var previousListPosition = pos - nodeBefore.nodeSize;
|
|
28
|
+
if (nodeAfter && nodeAfter.type.name !== (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name)) {
|
|
31
29
|
tr.setNodeMarkup(previousListPosition, nodeAfter.type);
|
|
32
30
|
}
|
|
33
31
|
tr.join(pos);
|
|
32
|
+
if (tr.doc.type.schema.marks.fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
33
|
+
var upperListFontSizeAttrs = (0, _lists.getFirstParagraphBlockMarkAttrs)(nodeBefore, tr.doc.type.schema.marks.fontSize);
|
|
34
|
+
(0, _lists.reconcileBlockMarkForContainerAtPos)(tr, previousListPosition, tr.doc.type.schema.marks.fontSize, upperListFontSizeAttrs);
|
|
35
|
+
}
|
|
34
36
|
}
|
|
@@ -16,6 +16,7 @@ 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 _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
19
20
|
var _conversions = require("../actions/conversions");
|
|
20
21
|
var _wrapAndJoinLists = require("../actions/wrap-and-join-lists");
|
|
21
22
|
var _transforms = require("../transforms");
|
|
@@ -248,10 +249,17 @@ function splitListItem(itemType) {
|
|
|
248
249
|
var types = nextType && [null, {
|
|
249
250
|
type: nextType
|
|
250
251
|
}];
|
|
252
|
+
var fontSize = state.schema.marks.fontSize;
|
|
253
|
+
var isFontSizeSupported = fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true);
|
|
254
|
+
var currentFontSizeAttrs = isFontSizeSupported ? (0, _lists.getBlockMarkAttrs)($from.parent, fontSize) : false;
|
|
251
255
|
if (dispatch) {
|
|
252
256
|
var _$from$nodeBefore;
|
|
253
257
|
if (ref instanceof _state.TextSelection) {
|
|
254
|
-
|
|
258
|
+
var splitTr = tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined);
|
|
259
|
+
if (isFontSizeSupported) {
|
|
260
|
+
(0, _lists.reconcileBlockMarkForParagraphAtPos)(splitTr, splitTr.selection.from, fontSize, currentFontSizeAttrs);
|
|
261
|
+
}
|
|
262
|
+
dispatch(splitTr.scrollIntoView());
|
|
255
263
|
return true;
|
|
256
264
|
}
|
|
257
265
|
|
|
@@ -262,7 +270,7 @@ function splitListItem(itemType) {
|
|
|
262
270
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
263
271
|
listItem = _state$schema$nodes2.listItem,
|
|
264
272
|
paragraph = _state$schema$nodes2.paragraph;
|
|
265
|
-
var newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
273
|
+
var newListItem = listItem.createChecked({}, paragraph.createChecked({}, undefined, currentFontSizeAttrs && isFontSizeSupported ? [fontSize.create(currentFontSizeAttrs)] : undefined));
|
|
266
274
|
dispatch(tr.insert($from.pos, newListItem).setSelection(_state.Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
267
275
|
return true;
|
|
268
276
|
}
|
|
@@ -298,6 +306,7 @@ var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
|
298
306
|
codeBlock = _state$schema$nodes3.codeBlock,
|
|
299
307
|
bulletList = _state$schema$nodes3.bulletList,
|
|
300
308
|
orderedList = _state$schema$nodes3.orderedList;
|
|
309
|
+
var fontSize = state.schema.marks.fontSize;
|
|
301
310
|
var isGapCursorShown = state.selection instanceof _selection.GapCursorSelection;
|
|
302
311
|
var $cutPos = isGapCursorShown ? state.doc.resolve($from.pos + 1) : $from;
|
|
303
312
|
var $cut = (0, _commands.findCutBefore)($cutPos);
|
|
@@ -346,6 +355,13 @@ var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
|
346
355
|
if ($postCut.nodeBefore && $postCut.nodeAfter && $postCut.nodeBefore.type === $postCut.nodeAfter.type && [bulletList, orderedList].indexOf($postCut.nodeBefore.type) > -1) {
|
|
347
356
|
tr = tr.join($postCut.pos);
|
|
348
357
|
}
|
|
358
|
+
if (fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
359
|
+
var prevListFontSizeAttrs = (0, _lists.getFirstParagraphBlockMarkAttrs)($cut.nodeBefore, fontSize);
|
|
360
|
+
var containingList = (0, _utils2.findParentNodeOfTypeClosestToPos)(tr.doc.resolve(tr.mapping.map($cut.pos)), [bulletList, orderedList]);
|
|
361
|
+
if (containingList) {
|
|
362
|
+
(0, _lists.reconcileBlockMarkForContainerAtPos)(tr, containingList.pos, fontSize, prevListFontSizeAttrs);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
349
365
|
if (dispatch) {
|
|
350
366
|
var _tr$doc$resolve$nodeB;
|
|
351
367
|
if (!((_tr$doc$resolve$nodeB = tr.doc.resolve($lastNode.pos).nodeBefore) !== null && _tr$doc$resolve$nodeB !== void 0 && _tr$doc$resolve$nodeB.isBlock) || tr.doc.resolve($lastNode.pos).nodeBefore === null) {
|
|
@@ -7,8 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.listBackspace = exports.calcJoinListScenario = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _lists = require("@atlaskit/editor-common/lists");
|
|
10
11
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
12
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
12
14
|
var _selection = require("../utils/selection");
|
|
13
15
|
//Cases below refer to the cases found in this document: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1146954996/List+Backspace+and+Delete+Behaviour
|
|
14
16
|
|
|
@@ -41,6 +43,7 @@ var listBackspaceCase2 = function listBackspaceCase2(tr, dispatch, $prev, $head)
|
|
|
41
43
|
*/
|
|
42
44
|
|
|
43
45
|
var listItemE = $head.node(-1); //Head is inside listItem E so it must have a first and last child
|
|
46
|
+
var fontSize = tr.doc.type.schema.marks.fontSize;
|
|
44
47
|
if (!listItemE.firstChild) {
|
|
45
48
|
return false;
|
|
46
49
|
}
|
|
@@ -53,6 +56,10 @@ var listBackspaceCase2 = function listBackspaceCase2(tr, dispatch, $prev, $head)
|
|
|
53
56
|
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
54
57
|
return tr.doc.resolve(textInsertPos);
|
|
55
58
|
}, [[textContent, textInsertPos], [childrenGContent, childrenGInsertPos]], [[beforeListItemE, afterListItemE]]);
|
|
59
|
+
if (fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
60
|
+
var targetParagraphFontSizeAttrs = (0, _lists.getBlockMarkAttrs)($prev.parent.lastChild, fontSize);
|
|
61
|
+
(0, _lists.reconcileBlockMarkForParagraphAtPos)(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
62
|
+
}
|
|
56
63
|
if (dispatch) {
|
|
57
64
|
dispatch(tr);
|
|
58
65
|
}
|
|
@@ -99,6 +106,7 @@ var listBackspaceCase3 = function listBackspaceCase3(tr, dispatch, $prev, $head)
|
|
|
99
106
|
|
|
100
107
|
var listE = $head.node(-2);
|
|
101
108
|
var listItemF = $head.node(-1); //Head is inside listItem F so it must have a first and last child
|
|
109
|
+
var fontSize = tr.doc.type.schema.marks.fontSize;
|
|
102
110
|
if (!listItemF.firstChild || !listItemF.lastChild) {
|
|
103
111
|
return false;
|
|
104
112
|
}
|
|
@@ -120,6 +128,10 @@ var listBackspaceCase3 = function listBackspaceCase3(tr, dispatch, $prev, $head)
|
|
|
120
128
|
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
121
129
|
return tr.doc.resolve(textInsertPos);
|
|
122
130
|
}, containsChildrenJ ? [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos], [childrenJContent, childrenJInsertPos]] : [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos]], [shouldRemoveListE ? [beforeListE, afterListE] : [beforeListItemF, afterListItemF]]);
|
|
131
|
+
if (fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
132
|
+
var targetParagraphFontSizeAttrs = (0, _lists.getBlockMarkAttrs)($prev.parent, fontSize);
|
|
133
|
+
(0, _lists.reconcileBlockMarkForParagraphAtPos)(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
134
|
+
}
|
|
123
135
|
if (dispatch) {
|
|
124
136
|
dispatch(tr);
|
|
125
137
|
}
|
|
@@ -185,6 +197,7 @@ var listBackspaceCase4 = function listBackspaceCase4(tr, dispatch, $prev, $head,
|
|
|
185
197
|
return false;
|
|
186
198
|
}
|
|
187
199
|
var listItemK = $head.node(-1); //Head is inside listItem K so it must have a first and last child
|
|
200
|
+
var fontSize = tr.doc.type.schema.marks.fontSize;
|
|
188
201
|
if (!listItemK.firstChild || !listItemK.lastChild) {
|
|
189
202
|
return false;
|
|
190
203
|
}
|
|
@@ -203,6 +216,10 @@ var listBackspaceCase4 = function listBackspaceCase4(tr, dispatch, $prev, $head,
|
|
|
203
216
|
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
204
217
|
return tr.doc.resolve(textInsertPos);
|
|
205
218
|
}, containsChildrenO ? [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos], [childrenOContent, childrenOInsertPos]] : [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos]], [[beforeListItemK, afterListItemK]]);
|
|
219
|
+
if (fontSize && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
220
|
+
var targetParagraphFontSizeAttrs = (0, _lists.getBlockMarkAttrs)($last.parent, fontSize);
|
|
221
|
+
(0, _lists.reconcileBlockMarkForParagraphAtPos)(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
222
|
+
}
|
|
206
223
|
if (dispatch) {
|
|
207
224
|
dispatch(tr);
|
|
208
225
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { getFirstParagraphBlockMarkAttrs, reconcileBlockMarkForContainerAtPos } from '@atlaskit/editor-common/lists';
|
|
1
2
|
import { isListNode } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
4
|
export function mergeNextListAtPosition({
|
|
3
5
|
tr,
|
|
4
6
|
listPosition
|
|
@@ -19,13 +21,13 @@ export function mergeNextListAtPosition({
|
|
|
19
21
|
if (!isListNode(nodeBefore) || !isListNode(nodeAfter)) {
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
25
|
-
const previousListPosition = pos - nodeBefore.nodeSize;
|
|
26
|
-
// Ignored via go/ees005
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
24
|
+
const previousListPosition = pos - nodeBefore.nodeSize;
|
|
25
|
+
if (nodeAfter && nodeAfter.type.name !== (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name)) {
|
|
28
26
|
tr.setNodeMarkup(previousListPosition, nodeAfter.type);
|
|
29
27
|
}
|
|
30
28
|
tr.join(pos);
|
|
29
|
+
if (tr.doc.type.schema.marks.fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
30
|
+
const upperListFontSizeAttrs = getFirstParagraphBlockMarkAttrs(nodeBefore, tr.doc.type.schema.marks.fontSize);
|
|
31
|
+
reconcileBlockMarkForContainerAtPos(tr, previousListPosition, tr.doc.type.schema.marks.fontSize, upperListFontSizeAttrs);
|
|
32
|
+
}
|
|
31
33
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { findCutBefore } from '@atlaskit/editor-common/commands';
|
|
3
|
-
import { getCommonListAnalyticsAttributes, moveTargetIntoList } from '@atlaskit/editor-common/lists';
|
|
3
|
+
import { getBlockMarkAttrs, getCommonListAnalyticsAttributes, getFirstParagraphBlockMarkAttrs, moveTargetIntoList, reconcileBlockMarkForContainerAtPos, reconcileBlockMarkForParagraphAtPos } from '@atlaskit/editor-common/lists';
|
|
4
4
|
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
5
5
|
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
9
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
+
import { findParentNodeOfTypeClosestToPos, findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
11
12
|
import { convertListType } from '../actions/conversions';
|
|
12
13
|
import { wrapInListAndJoin } from '../actions/wrap-and-join-lists';
|
|
13
14
|
import { liftFollowingList, liftNodeSelectionList, liftTextSelectionList } from '../transforms';
|
|
@@ -231,10 +232,17 @@ function splitListItem(itemType) {
|
|
|
231
232
|
const types = nextType && [null, {
|
|
232
233
|
type: nextType
|
|
233
234
|
}];
|
|
235
|
+
const fontSize = state.schema.marks.fontSize;
|
|
236
|
+
const isFontSizeSupported = fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true);
|
|
237
|
+
const currentFontSizeAttrs = isFontSizeSupported ? getBlockMarkAttrs($from.parent, fontSize) : false;
|
|
234
238
|
if (dispatch) {
|
|
235
239
|
var _$from$nodeBefore;
|
|
236
240
|
if (ref instanceof TextSelection) {
|
|
237
|
-
|
|
241
|
+
const splitTr = tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined);
|
|
242
|
+
if (isFontSizeSupported) {
|
|
243
|
+
reconcileBlockMarkForParagraphAtPos(splitTr, splitTr.selection.from, fontSize, currentFontSizeAttrs);
|
|
244
|
+
}
|
|
245
|
+
dispatch(splitTr.scrollIntoView());
|
|
238
246
|
return true;
|
|
239
247
|
}
|
|
240
248
|
|
|
@@ -246,7 +254,7 @@ function splitListItem(itemType) {
|
|
|
246
254
|
listItem,
|
|
247
255
|
paragraph
|
|
248
256
|
} = state.schema.nodes;
|
|
249
|
-
const newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
257
|
+
const newListItem = listItem.createChecked({}, paragraph.createChecked({}, undefined, currentFontSizeAttrs && isFontSizeSupported ? [fontSize.create(currentFontSizeAttrs)] : undefined));
|
|
250
258
|
dispatch(tr.insert($from.pos, newListItem).setSelection(Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
251
259
|
return true;
|
|
252
260
|
}
|
|
@@ -291,6 +299,9 @@ const joinToPreviousListItem = (state, dispatch) => {
|
|
|
291
299
|
bulletList,
|
|
292
300
|
orderedList
|
|
293
301
|
} = state.schema.nodes;
|
|
302
|
+
const {
|
|
303
|
+
fontSize
|
|
304
|
+
} = state.schema.marks;
|
|
294
305
|
const isGapCursorShown = state.selection instanceof GapCursorSelection;
|
|
295
306
|
const $cutPos = isGapCursorShown ? state.doc.resolve($from.pos + 1) : $from;
|
|
296
307
|
const $cut = findCutBefore($cutPos);
|
|
@@ -341,6 +352,13 @@ const joinToPreviousListItem = (state, dispatch) => {
|
|
|
341
352
|
if ($postCut.nodeBefore && $postCut.nodeAfter && $postCut.nodeBefore.type === $postCut.nodeAfter.type && [bulletList, orderedList].indexOf($postCut.nodeBefore.type) > -1) {
|
|
342
353
|
tr = tr.join($postCut.pos);
|
|
343
354
|
}
|
|
355
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
356
|
+
const prevListFontSizeAttrs = getFirstParagraphBlockMarkAttrs($cut.nodeBefore, fontSize);
|
|
357
|
+
const containingList = findParentNodeOfTypeClosestToPos(tr.doc.resolve(tr.mapping.map($cut.pos)), [bulletList, orderedList]);
|
|
358
|
+
if (containingList) {
|
|
359
|
+
reconcileBlockMarkForContainerAtPos(tr, containingList.pos, fontSize, prevListFontSizeAttrs);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
344
362
|
if (dispatch) {
|
|
345
363
|
var _tr$doc$resolve$nodeB;
|
|
346
364
|
if (!((_tr$doc$resolve$nodeB = tr.doc.resolve($lastNode.pos).nodeBefore) !== null && _tr$doc$resolve$nodeB !== void 0 && _tr$doc$resolve$nodeB.isBlock) || tr.doc.resolve($lastNode.pos).nodeBefore === null) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, DELETE_DIRECTION, EVENT_TYPE, INPUT_METHOD, LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { getBlockMarkAttrs, reconcileBlockMarkForParagraphAtPos } from '@atlaskit/editor-common/lists';
|
|
2
3
|
import { insertContentDeleteRange, isEmptySelectionAtStart, isListNode, isParagraphNode, walkPrevNode } from '@atlaskit/editor-common/utils';
|
|
3
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
4
6
|
import { isPosInsideList, isPosInsideParagraph } from '../utils/selection';
|
|
5
7
|
//Cases below refer to the cases found in this document: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1146954996/List+Backspace+and+Delete+Behaviour
|
|
6
8
|
|
|
@@ -33,6 +35,9 @@ const listBackspaceCase2 = (tr, dispatch, $prev, $head) => {
|
|
|
33
35
|
*/
|
|
34
36
|
|
|
35
37
|
const listItemE = $head.node(-1); //Head is inside listItem E so it must have a first and last child
|
|
38
|
+
const {
|
|
39
|
+
fontSize
|
|
40
|
+
} = tr.doc.type.schema.marks;
|
|
36
41
|
if (!listItemE.firstChild) {
|
|
37
42
|
return false;
|
|
38
43
|
}
|
|
@@ -43,6 +48,10 @@ const listBackspaceCase2 = (tr, dispatch, $prev, $head) => {
|
|
|
43
48
|
const textContent = $head.parent.content;
|
|
44
49
|
const childrenGContent = listItemE.content.cut(listItemE.firstChild.nodeSize);
|
|
45
50
|
insertContentDeleteRange(tr, tr => tr.doc.resolve(textInsertPos), [[textContent, textInsertPos], [childrenGContent, childrenGInsertPos]], [[beforeListItemE, afterListItemE]]);
|
|
51
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
52
|
+
const targetParagraphFontSizeAttrs = getBlockMarkAttrs($prev.parent.lastChild, fontSize);
|
|
53
|
+
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
54
|
+
}
|
|
46
55
|
if (dispatch) {
|
|
47
56
|
dispatch(tr);
|
|
48
57
|
}
|
|
@@ -89,6 +98,9 @@ const listBackspaceCase3 = (tr, dispatch, $prev, $head) => {
|
|
|
89
98
|
|
|
90
99
|
const listE = $head.node(-2);
|
|
91
100
|
const listItemF = $head.node(-1); //Head is inside listItem F so it must have a first and last child
|
|
101
|
+
const {
|
|
102
|
+
fontSize
|
|
103
|
+
} = tr.doc.type.schema.marks;
|
|
92
104
|
if (!listItemF.firstChild || !listItemF.lastChild) {
|
|
93
105
|
return false;
|
|
94
106
|
}
|
|
@@ -108,6 +120,10 @@ const listBackspaceCase3 = (tr, dispatch, $prev, $head) => {
|
|
|
108
120
|
const childrenJContent = listItemF.lastChild.content; //Will be invalid if there are no Children J but it will be unused
|
|
109
121
|
|
|
110
122
|
insertContentDeleteRange(tr, tr => tr.doc.resolve(textInsertPos), containsChildrenJ ? [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos], [childrenJContent, childrenJInsertPos]] : [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos]], [shouldRemoveListE ? [beforeListE, afterListE] : [beforeListItemF, afterListItemF]]);
|
|
123
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
124
|
+
const targetParagraphFontSizeAttrs = getBlockMarkAttrs($prev.parent, fontSize);
|
|
125
|
+
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
126
|
+
}
|
|
111
127
|
if (dispatch) {
|
|
112
128
|
dispatch(tr);
|
|
113
129
|
}
|
|
@@ -173,6 +189,9 @@ const listBackspaceCase4 = (tr, dispatch, $prev, $head, $last) => {
|
|
|
173
189
|
return false;
|
|
174
190
|
}
|
|
175
191
|
const listItemK = $head.node(-1); //Head is inside listItem K so it must have a first and last child
|
|
192
|
+
const {
|
|
193
|
+
fontSize
|
|
194
|
+
} = tr.doc.type.schema.marks;
|
|
176
195
|
if (!listItemK.firstChild || !listItemK.lastChild) {
|
|
177
196
|
return false;
|
|
178
197
|
}
|
|
@@ -189,6 +208,10 @@ const listBackspaceCase4 = (tr, dispatch, $prev, $head, $last) => {
|
|
|
189
208
|
const childrenMContent = containsChildrenO ? listItemK.content.cut(listItemK.firstChild.nodeSize, listItemK.nodeSize - listItemK.lastChild.nodeSize - 2) : listItemK.content.cut(listItemK.firstChild.nodeSize);
|
|
190
209
|
const childrenOContent = listItemK.lastChild.content;
|
|
191
210
|
insertContentDeleteRange(tr, tr => tr.doc.resolve(textInsertPos), containsChildrenO ? [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos], [childrenOContent, childrenOInsertPos]] : [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos]], [[beforeListItemK, afterListItemK]]);
|
|
211
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
212
|
+
const targetParagraphFontSizeAttrs = getBlockMarkAttrs($last.parent, fontSize);
|
|
213
|
+
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
214
|
+
}
|
|
192
215
|
if (dispatch) {
|
|
193
216
|
dispatch(tr);
|
|
194
217
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { getFirstParagraphBlockMarkAttrs, reconcileBlockMarkForContainerAtPos } from '@atlaskit/editor-common/lists';
|
|
1
2
|
import { isListNode } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
4
|
export function mergeNextListAtPosition(_ref) {
|
|
3
5
|
var tr = _ref.tr,
|
|
4
6
|
listPosition = _ref.listPosition;
|
|
@@ -16,13 +18,13 @@ export function mergeNextListAtPosition(_ref) {
|
|
|
16
18
|
if (!isListNode(nodeBefore) || !isListNode(nodeAfter)) {
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
22
|
-
var previousListPosition = pos - nodeBefore.nodeSize;
|
|
23
|
-
// Ignored via go/ees005
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
21
|
+
var previousListPosition = pos - nodeBefore.nodeSize;
|
|
22
|
+
if (nodeAfter && nodeAfter.type.name !== (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name)) {
|
|
25
23
|
tr.setNodeMarkup(previousListPosition, nodeAfter.type);
|
|
26
24
|
}
|
|
27
25
|
tr.join(pos);
|
|
26
|
+
if (tr.doc.type.schema.marks.fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
27
|
+
var upperListFontSizeAttrs = getFirstParagraphBlockMarkAttrs(nodeBefore, tr.doc.type.schema.marks.fontSize);
|
|
28
|
+
reconcileBlockMarkForContainerAtPos(tr, previousListPosition, tr.doc.type.schema.marks.fontSize, upperListFontSizeAttrs);
|
|
29
|
+
}
|
|
28
30
|
}
|
|
@@ -3,14 +3,15 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
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; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { findCutBefore } from '@atlaskit/editor-common/commands';
|
|
6
|
-
import { getCommonListAnalyticsAttributes, moveTargetIntoList } from '@atlaskit/editor-common/lists';
|
|
6
|
+
import { getBlockMarkAttrs, getCommonListAnalyticsAttributes, getFirstParagraphBlockMarkAttrs, moveTargetIntoList, reconcileBlockMarkForContainerAtPos, reconcileBlockMarkForParagraphAtPos } from '@atlaskit/editor-common/lists';
|
|
7
7
|
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
8
8
|
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
12
|
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
13
|
-
import { findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
13
|
+
import { findParentNodeOfTypeClosestToPos, findPositionOfNodeBefore, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
14
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
14
15
|
import { convertListType } from '../actions/conversions';
|
|
15
16
|
import { wrapInListAndJoin } from '../actions/wrap-and-join-lists';
|
|
16
17
|
import { liftFollowingList, liftNodeSelectionList, liftTextSelectionList } from '../transforms';
|
|
@@ -241,10 +242,17 @@ function splitListItem(itemType) {
|
|
|
241
242
|
var types = nextType && [null, {
|
|
242
243
|
type: nextType
|
|
243
244
|
}];
|
|
245
|
+
var fontSize = state.schema.marks.fontSize;
|
|
246
|
+
var isFontSizeSupported = fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true);
|
|
247
|
+
var currentFontSizeAttrs = isFontSizeSupported ? getBlockMarkAttrs($from.parent, fontSize) : false;
|
|
244
248
|
if (dispatch) {
|
|
245
249
|
var _$from$nodeBefore;
|
|
246
250
|
if (ref instanceof TextSelection) {
|
|
247
|
-
|
|
251
|
+
var splitTr = tr.split($from.pos, 2, types !== null && types !== void 0 ? types : undefined);
|
|
252
|
+
if (isFontSizeSupported) {
|
|
253
|
+
reconcileBlockMarkForParagraphAtPos(splitTr, splitTr.selection.from, fontSize, currentFontSizeAttrs);
|
|
254
|
+
}
|
|
255
|
+
dispatch(splitTr.scrollIntoView());
|
|
248
256
|
return true;
|
|
249
257
|
}
|
|
250
258
|
|
|
@@ -255,7 +263,7 @@ function splitListItem(itemType) {
|
|
|
255
263
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
256
264
|
listItem = _state$schema$nodes2.listItem,
|
|
257
265
|
paragraph = _state$schema$nodes2.paragraph;
|
|
258
|
-
var newListItem = listItem.createChecked({}, paragraph.createChecked());
|
|
266
|
+
var newListItem = listItem.createChecked({}, paragraph.createChecked({}, undefined, currentFontSizeAttrs && isFontSizeSupported ? [fontSize.create(currentFontSizeAttrs)] : undefined));
|
|
259
267
|
dispatch(tr.insert($from.pos, newListItem).setSelection(Selection.near(tr.doc.resolve($to.pos + 1))).scrollIntoView());
|
|
260
268
|
return true;
|
|
261
269
|
}
|
|
@@ -291,6 +299,7 @@ var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
|
291
299
|
codeBlock = _state$schema$nodes3.codeBlock,
|
|
292
300
|
bulletList = _state$schema$nodes3.bulletList,
|
|
293
301
|
orderedList = _state$schema$nodes3.orderedList;
|
|
302
|
+
var fontSize = state.schema.marks.fontSize;
|
|
294
303
|
var isGapCursorShown = state.selection instanceof GapCursorSelection;
|
|
295
304
|
var $cutPos = isGapCursorShown ? state.doc.resolve($from.pos + 1) : $from;
|
|
296
305
|
var $cut = findCutBefore($cutPos);
|
|
@@ -339,6 +348,13 @@ var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
|
339
348
|
if ($postCut.nodeBefore && $postCut.nodeAfter && $postCut.nodeBefore.type === $postCut.nodeAfter.type && [bulletList, orderedList].indexOf($postCut.nodeBefore.type) > -1) {
|
|
340
349
|
tr = tr.join($postCut.pos);
|
|
341
350
|
}
|
|
351
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
352
|
+
var prevListFontSizeAttrs = getFirstParagraphBlockMarkAttrs($cut.nodeBefore, fontSize);
|
|
353
|
+
var containingList = findParentNodeOfTypeClosestToPos(tr.doc.resolve(tr.mapping.map($cut.pos)), [bulletList, orderedList]);
|
|
354
|
+
if (containingList) {
|
|
355
|
+
reconcileBlockMarkForContainerAtPos(tr, containingList.pos, fontSize, prevListFontSizeAttrs);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
342
358
|
if (dispatch) {
|
|
343
359
|
var _tr$doc$resolve$nodeB;
|
|
344
360
|
if (!((_tr$doc$resolve$nodeB = tr.doc.resolve($lastNode.pos).nodeBefore) !== null && _tr$doc$resolve$nodeB !== void 0 && _tr$doc$resolve$nodeB.isBlock) || tr.doc.resolve($lastNode.pos).nodeBefore === null) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, DELETE_DIRECTION, EVENT_TYPE, INPUT_METHOD, LIST_TEXT_SCENARIOS } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { getBlockMarkAttrs, reconcileBlockMarkForParagraphAtPos } from '@atlaskit/editor-common/lists';
|
|
3
4
|
import { insertContentDeleteRange, isEmptySelectionAtStart, isListNode, isParagraphNode, walkPrevNode } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
7
|
import { isPosInsideList, isPosInsideParagraph } from '../utils/selection';
|
|
6
8
|
//Cases below refer to the cases found in this document: https://product-fabric.atlassian.net/wiki/spaces/E/pages/1146954996/List+Backspace+and+Delete+Behaviour
|
|
7
9
|
|
|
@@ -34,6 +36,7 @@ var listBackspaceCase2 = function listBackspaceCase2(tr, dispatch, $prev, $head)
|
|
|
34
36
|
*/
|
|
35
37
|
|
|
36
38
|
var listItemE = $head.node(-1); //Head is inside listItem E so it must have a first and last child
|
|
39
|
+
var fontSize = tr.doc.type.schema.marks.fontSize;
|
|
37
40
|
if (!listItemE.firstChild) {
|
|
38
41
|
return false;
|
|
39
42
|
}
|
|
@@ -46,6 +49,10 @@ var listBackspaceCase2 = function listBackspaceCase2(tr, dispatch, $prev, $head)
|
|
|
46
49
|
insertContentDeleteRange(tr, function (tr) {
|
|
47
50
|
return tr.doc.resolve(textInsertPos);
|
|
48
51
|
}, [[textContent, textInsertPos], [childrenGContent, childrenGInsertPos]], [[beforeListItemE, afterListItemE]]);
|
|
52
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
53
|
+
var targetParagraphFontSizeAttrs = getBlockMarkAttrs($prev.parent.lastChild, fontSize);
|
|
54
|
+
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
55
|
+
}
|
|
49
56
|
if (dispatch) {
|
|
50
57
|
dispatch(tr);
|
|
51
58
|
}
|
|
@@ -92,6 +99,7 @@ var listBackspaceCase3 = function listBackspaceCase3(tr, dispatch, $prev, $head)
|
|
|
92
99
|
|
|
93
100
|
var listE = $head.node(-2);
|
|
94
101
|
var listItemF = $head.node(-1); //Head is inside listItem F so it must have a first and last child
|
|
102
|
+
var fontSize = tr.doc.type.schema.marks.fontSize;
|
|
95
103
|
if (!listItemF.firstChild || !listItemF.lastChild) {
|
|
96
104
|
return false;
|
|
97
105
|
}
|
|
@@ -113,6 +121,10 @@ var listBackspaceCase3 = function listBackspaceCase3(tr, dispatch, $prev, $head)
|
|
|
113
121
|
insertContentDeleteRange(tr, function (tr) {
|
|
114
122
|
return tr.doc.resolve(textInsertPos);
|
|
115
123
|
}, containsChildrenJ ? [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos], [childrenJContent, childrenJInsertPos]] : [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos]], [shouldRemoveListE ? [beforeListE, afterListE] : [beforeListItemF, afterListItemF]]);
|
|
124
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
125
|
+
var targetParagraphFontSizeAttrs = getBlockMarkAttrs($prev.parent, fontSize);
|
|
126
|
+
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
127
|
+
}
|
|
116
128
|
if (dispatch) {
|
|
117
129
|
dispatch(tr);
|
|
118
130
|
}
|
|
@@ -178,6 +190,7 @@ var listBackspaceCase4 = function listBackspaceCase4(tr, dispatch, $prev, $head,
|
|
|
178
190
|
return false;
|
|
179
191
|
}
|
|
180
192
|
var listItemK = $head.node(-1); //Head is inside listItem K so it must have a first and last child
|
|
193
|
+
var fontSize = tr.doc.type.schema.marks.fontSize;
|
|
181
194
|
if (!listItemK.firstChild || !listItemK.lastChild) {
|
|
182
195
|
return false;
|
|
183
196
|
}
|
|
@@ -196,6 +209,10 @@ var listBackspaceCase4 = function listBackspaceCase4(tr, dispatch, $prev, $head,
|
|
|
196
209
|
insertContentDeleteRange(tr, function (tr) {
|
|
197
210
|
return tr.doc.resolve(textInsertPos);
|
|
198
211
|
}, containsChildrenO ? [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos], [childrenOContent, childrenOInsertPos]] : [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos]], [[beforeListItemK, afterListItemK]]);
|
|
212
|
+
if (fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
213
|
+
var targetParagraphFontSizeAttrs = getBlockMarkAttrs($last.parent, fontSize);
|
|
214
|
+
reconcileBlockMarkForParagraphAtPos(tr, tr.mapping.map(textInsertPos), fontSize, targetParagraphFontSizeAttrs);
|
|
215
|
+
}
|
|
199
216
|
if (dispatch) {
|
|
200
217
|
dispatch(tr);
|
|
201
218
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-list",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.2.0",
|
|
4
4
|
"description": "List plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
39
39
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
40
40
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^49.0.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@atlaskit/editor-common": "^112.
|
|
45
|
+
"@atlaskit/editor-common": "^112.13.0",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
48
|
},
|