@atlaskit/editor-core 187.28.5 → 187.29.2
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 +16 -0
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/labs/next/presets/universal.js +2 -1
- package/dist/cjs/plugins/analytics/index.js +0 -6
- package/dist/cjs/plugins/analytics/types/index.js +0 -6
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/commands.js +1 -1
- package/dist/cjs/utils/commands.js +1 -33
- package/dist/cjs/utils/index.js +0 -13
- package/dist/cjs/utils/mark.js +2 -46
- package/dist/cjs/utils/selection.js +0 -5
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/index.js +0 -1
- package/dist/es2019/labs/next/presets/universal.js +2 -1
- package/dist/es2019/plugins/analytics/index.js +1 -1
- package/dist/es2019/plugins/analytics/types/index.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/commands.js +1 -1
- package/dist/es2019/utils/commands.js +1 -33
- package/dist/es2019/utils/index.js +1 -2
- package/dist/es2019/utils/mark.js +0 -41
- package/dist/es2019/utils/selection.js +0 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/labs/next/presets/universal.js +2 -1
- package/dist/esm/plugins/analytics/index.js +1 -1
- package/dist/esm/plugins/analytics/types/index.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/commands.js +1 -1
- package/dist/esm/utils/commands.js +1 -31
- package/dist/esm/utils/index.js +1 -2
- package/dist/esm/utils/mark.js +0 -42
- package/dist/esm/utils/selection.js +0 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/paste/index.d.ts +1 -1
- package/dist/types/utils/commands.d.ts +1 -4
- package/dist/types/utils/index.d.ts +1 -2
- package/dist/types/utils/mark.d.ts +2 -12
- package/dist/types/utils/selection.d.ts +0 -2
- package/dist/types-ts4.5/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/analytics/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/paste/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/commands.d.ts +1 -4
- package/dist/types-ts4.5/utils/index.d.ts +1 -2
- package/dist/types-ts4.5/utils/mark.d.ts +2 -12
- package/dist/types-ts4.5/utils/selection.d.ts +0 -2
- package/package.json +7 -3
- package/report.api.md +0 -9
- package/tmp/api-report-tmp.d.ts +0 -9
- package/dist/cjs/plugins/list/actions/conversions.js +0 -153
- package/dist/cjs/plugins/list/actions/indent-list-items-selected.js +0 -125
- package/dist/cjs/plugins/list/actions/indent-list.js +0 -49
- package/dist/cjs/plugins/list/actions/join-list-items-forward.js +0 -59
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/index.js +0 -40
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -88
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -85
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -79
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -45
- package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -56
- package/dist/cjs/plugins/list/actions/merge-lists.js +0 -27
- package/dist/cjs/plugins/list/actions/outdent-list-items-selected.js +0 -291
- package/dist/cjs/plugins/list/actions/wrap-and-join-lists.js +0 -98
- package/dist/cjs/plugins/list/commands/indent-list.js +0 -71
- package/dist/cjs/plugins/list/commands/index.js +0 -348
- package/dist/cjs/plugins/list/commands/join-list-item-forward.js +0 -61
- package/dist/cjs/plugins/list/commands/listBackspace.js +0 -284
- package/dist/cjs/plugins/list/commands/outdent-list.js +0 -70
- package/dist/cjs/plugins/list/index.js +0 -133
- package/dist/cjs/plugins/list/messages.js +0 -37
- package/dist/cjs/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +0 -61
- package/dist/cjs/plugins/list/pm-plugins/input-rules/index.js +0 -36
- package/dist/cjs/plugins/list/pm-plugins/input-rules/wrapping-join-rule.js +0 -58
- package/dist/cjs/plugins/list/pm-plugins/keymap.js +0 -27
- package/dist/cjs/plugins/list/pm-plugins/main.js +0 -168
- package/dist/cjs/plugins/list/transforms.js +0 -100
- package/dist/cjs/plugins/list/types.js +0 -8
- package/dist/cjs/plugins/list/utils/analytics.js +0 -22
- package/dist/cjs/plugins/list/utils/find.js +0 -68
- package/dist/cjs/plugins/list/utils/indentation.js +0 -22
- package/dist/cjs/plugins/list/utils/node.js +0 -16
- package/dist/cjs/plugins/list/utils/selection.js +0 -95
- package/dist/cjs/utils/input-rules.js +0 -30
- package/dist/es2019/plugins/list/actions/conversions.js +0 -160
- package/dist/es2019/plugins/list/actions/indent-list-items-selected.js +0 -124
- package/dist/es2019/plugins/list/actions/indent-list.js +0 -44
- package/dist/es2019/plugins/list/actions/join-list-items-forward.js +0 -54
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/index.js +0 -5
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -74
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -78
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -72
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -37
- package/dist/es2019/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -48
- package/dist/es2019/plugins/list/actions/merge-lists.js +0 -24
- package/dist/es2019/plugins/list/actions/outdent-list-items-selected.js +0 -295
- package/dist/es2019/plugins/list/actions/wrap-and-join-lists.js +0 -91
- package/dist/es2019/plugins/list/commands/indent-list.js +0 -62
- package/dist/es2019/plugins/list/commands/index.js +0 -322
- package/dist/es2019/plugins/list/commands/join-list-item-forward.js +0 -53
- package/dist/es2019/plugins/list/commands/listBackspace.js +0 -276
- package/dist/es2019/plugins/list/commands/outdent-list.js +0 -60
- package/dist/es2019/plugins/list/index.js +0 -120
- package/dist/es2019/plugins/list/messages.js +0 -29
- package/dist/es2019/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +0 -55
- package/dist/es2019/plugins/list/pm-plugins/input-rules/index.js +0 -33
- package/dist/es2019/plugins/list/pm-plugins/input-rules/wrapping-join-rule.js +0 -52
- package/dist/es2019/plugins/list/pm-plugins/keymap.js +0 -19
- package/dist/es2019/plugins/list/pm-plugins/main.js +0 -159
- package/dist/es2019/plugins/list/transforms.js +0 -102
- package/dist/es2019/plugins/list/types.js +0 -1
- package/dist/es2019/plugins/list/utils/analytics.js +0 -12
- package/dist/es2019/plugins/list/utils/find.js +0 -61
- package/dist/es2019/plugins/list/utils/indentation.js +0 -16
- package/dist/es2019/plugins/list/utils/node.js +0 -12
- package/dist/es2019/plugins/list/utils/selection.js +0 -96
- package/dist/es2019/utils/input-rules.js +0 -20
- package/dist/esm/plugins/list/actions/conversions.js +0 -147
- package/dist/esm/plugins/list/actions/indent-list-items-selected.js +0 -117
- package/dist/esm/plugins/list/actions/indent-list.js +0 -43
- package/dist/esm/plugins/list/actions/join-list-items-forward.js +0 -52
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/index.js +0 -5
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -81
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -79
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -73
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -38
- package/dist/esm/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -49
- package/dist/esm/plugins/list/actions/merge-lists.js +0 -21
- package/dist/esm/plugins/list/actions/outdent-list-items-selected.js +0 -283
- package/dist/esm/plugins/list/actions/wrap-and-join-lists.js +0 -92
- package/dist/esm/plugins/list/commands/indent-list.js +0 -63
- package/dist/esm/plugins/list/commands/index.js +0 -320
- package/dist/esm/plugins/list/commands/join-list-item-forward.js +0 -53
- package/dist/esm/plugins/list/commands/listBackspace.js +0 -275
- package/dist/esm/plugins/list/commands/outdent-list.js +0 -62
- package/dist/esm/plugins/list/index.js +0 -127
- package/dist/esm/plugins/list/messages.js +0 -29
- package/dist/esm/plugins/list/pm-plugins/input-rules/create-list-input-rule.js +0 -56
- package/dist/esm/plugins/list/pm-plugins/input-rules/index.js +0 -30
- package/dist/esm/plugins/list/pm-plugins/input-rules/wrapping-join-rule.js +0 -51
- package/dist/esm/plugins/list/pm-plugins/keymap.js +0 -19
- package/dist/esm/plugins/list/pm-plugins/main.js +0 -159
- package/dist/esm/plugins/list/transforms.js +0 -92
- package/dist/esm/plugins/list/types.js +0 -1
- package/dist/esm/plugins/list/utils/analytics.js +0 -12
- package/dist/esm/plugins/list/utils/find.js +0 -59
- package/dist/esm/plugins/list/utils/indentation.js +0 -16
- package/dist/esm/plugins/list/utils/node.js +0 -10
- package/dist/esm/plugins/list/utils/selection.js +0 -81
- package/dist/esm/utils/input-rules.js +0 -22
- package/dist/types/plugins/list/actions/conversions.d.ts +0 -6
- package/dist/types/plugins/list/actions/indent-list-items-selected.d.ts +0 -2
- package/dist/types/plugins/list/actions/indent-list.d.ts +0 -2
- package/dist/types/plugins/list/actions/join-list-items-forward.d.ts +0 -13
- package/dist/types/plugins/list/actions/join-list-items-scenarios/index.d.ts +0 -5
- package/dist/types/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +0 -9
- package/dist/types/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +0 -9
- package/dist/types/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +0 -9
- package/dist/types/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +0 -9
- package/dist/types/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +0 -9
- package/dist/types/plugins/list/actions/merge-lists.d.ts +0 -7
- package/dist/types/plugins/list/actions/outdent-list-items-selected.d.ts +0 -3
- package/dist/types/plugins/list/actions/wrap-and-join-lists.d.ts +0 -15
- package/dist/types/plugins/list/commands/indent-list.d.ts +0 -6
- package/dist/types/plugins/list/commands/index.d.ts +0 -17
- package/dist/types/plugins/list/commands/join-list-item-forward.d.ts +0 -3
- package/dist/types/plugins/list/commands/listBackspace.d.ts +0 -10
- package/dist/types/plugins/list/commands/outdent-list.d.ts +0 -7
- package/dist/types/plugins/list/index.d.ts +0 -3
- package/dist/types/plugins/list/messages.d.ts +0 -27
- package/dist/types/plugins/list/pm-plugins/input-rules/create-list-input-rule.d.ts +0 -9
- package/dist/types/plugins/list/pm-plugins/input-rules/index.d.ts +0 -4
- package/dist/types/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +0 -12
- package/dist/types/plugins/list/pm-plugins/keymap.d.ts +0 -5
- package/dist/types/plugins/list/pm-plugins/main.d.ts +0 -11
- package/dist/types/plugins/list/transforms.d.ts +0 -4
- package/dist/types/plugins/list/types.d.ts +0 -4
- package/dist/types/plugins/list/utils/analytics.d.ts +0 -5
- package/dist/types/plugins/list/utils/find.d.ts +0 -10
- package/dist/types/plugins/list/utils/indentation.d.ts +0 -2
- package/dist/types/plugins/list/utils/node.d.ts +0 -2
- package/dist/types/plugins/list/utils/selection.d.ts +0 -14
- package/dist/types/utils/input-rules.d.ts +0 -10
- package/dist/types-ts4.5/plugins/list/actions/conversions.d.ts +0 -6
- package/dist/types-ts4.5/plugins/list/actions/indent-list-items-selected.d.ts +0 -2
- package/dist/types-ts4.5/plugins/list/actions/indent-list.d.ts +0 -2
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-forward.d.ts +0 -16
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/index.d.ts +0 -5
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.d.ts +0 -9
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.d.ts +0 -9
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.d.ts +0 -9
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-paragraph-with-list.d.ts +0 -9
- package/dist/types-ts4.5/plugins/list/actions/join-list-items-scenarios/join-sibling-list-items.d.ts +0 -9
- package/dist/types-ts4.5/plugins/list/actions/merge-lists.d.ts +0 -7
- package/dist/types-ts4.5/plugins/list/actions/outdent-list-items-selected.d.ts +0 -3
- package/dist/types-ts4.5/plugins/list/actions/wrap-and-join-lists.d.ts +0 -15
- package/dist/types-ts4.5/plugins/list/commands/indent-list.d.ts +0 -6
- package/dist/types-ts4.5/plugins/list/commands/index.d.ts +0 -17
- package/dist/types-ts4.5/plugins/list/commands/join-list-item-forward.d.ts +0 -3
- package/dist/types-ts4.5/plugins/list/commands/listBackspace.d.ts +0 -13
- package/dist/types-ts4.5/plugins/list/commands/outdent-list.d.ts +0 -7
- package/dist/types-ts4.5/plugins/list/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/list/messages.d.ts +0 -27
- package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/create-list-input-rule.d.ts +0 -9
- package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/list/pm-plugins/input-rules/wrapping-join-rule.d.ts +0 -12
- package/dist/types-ts4.5/plugins/list/pm-plugins/keymap.d.ts +0 -5
- package/dist/types-ts4.5/plugins/list/pm-plugins/main.d.ts +0 -11
- package/dist/types-ts4.5/plugins/list/transforms.d.ts +0 -4
- package/dist/types-ts4.5/plugins/list/types.d.ts +0 -4
- package/dist/types-ts4.5/plugins/list/utils/analytics.d.ts +0 -5
- package/dist/types-ts4.5/plugins/list/utils/find.d.ts +0 -10
- package/dist/types-ts4.5/plugins/list/utils/indentation.d.ts +0 -2
- package/dist/types-ts4.5/plugins/list/utils/node.d.ts +0 -2
- package/dist/types-ts4.5/plugins/list/utils/selection.d.ts +0 -14
- package/dist/types-ts4.5/utils/input-rules.d.ts +0 -10
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.indentListItemsSelected = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
|
-
var _lists = require("@atlaskit/editor-common/lists");
|
|
12
|
-
var _find = require("../utils/find");
|
|
13
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
|
-
var _selection = require("@atlaskit/editor-common/selection");
|
|
15
|
-
var indentListItemsSelected = function indentListItemsSelected(tr) {
|
|
16
|
-
var originalSelection = tr.selection;
|
|
17
|
-
var normalizedSelection = (0, _lists.normalizeListItemsSelection)({
|
|
18
|
-
selection: originalSelection,
|
|
19
|
-
doc: tr.doc
|
|
20
|
-
});
|
|
21
|
-
var $from = normalizedSelection.$from,
|
|
22
|
-
$to = normalizedSelection.$to;
|
|
23
|
-
var range = calculateRange({
|
|
24
|
-
selection: normalizedSelection
|
|
25
|
-
});
|
|
26
|
-
if (!range) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
var listItemsSelected = {
|
|
30
|
-
from: (0, _find.findFirstParentListItemNode)($from),
|
|
31
|
-
to: (0, _find.findFirstParentListItemNode)($to)
|
|
32
|
-
};
|
|
33
|
-
if (listItemsSelected.from === null || listItemsSelected.to === null) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
var resolvedPos = tr.doc.resolve(listItemsSelected.from.pos);
|
|
37
|
-
var listItemIndex = resolvedPos.index();
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
var positionListItemPosition = resolvedPos.posAtIndex(listItemIndex - 1);
|
|
40
|
-
var previousListItem = tr.doc.nodeAt(positionListItemPosition);
|
|
41
|
-
if (!previousListItem || !(0, _utils.isListItemNode)(previousListItem)) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
if ((0, _utils.isListItemNode)(previousListItem) && listItemIndex === 0) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
var listItemSelectedCommonParent = range.parent;
|
|
48
|
-
var previousNestedList = (0, _utils.isListNode)(previousListItem.lastChild) ? previousListItem.lastChild : null;
|
|
49
|
-
var listNodeType = previousNestedList ? previousNestedList.type : listItemSelectedCommonParent.type;
|
|
50
|
-
var nestedList = listItemsSelected.to.node.lastChild;
|
|
51
|
-
var nestedItemsOffset = nestedList && (0, _utils.isListNode)(nestedList) ? nestedList.nodeSize : 0;
|
|
52
|
-
var from = listItemsSelected.from.pos;
|
|
53
|
-
var to = listItemsSelected.to.pos + listItemsSelected.to.node.nodeSize - nestedItemsOffset;
|
|
54
|
-
var _createIndentedListIt = createIndentedListItemsSlice({
|
|
55
|
-
tr: tr,
|
|
56
|
-
listNodeType: listNodeType,
|
|
57
|
-
range: range,
|
|
58
|
-
from: from,
|
|
59
|
-
to: to
|
|
60
|
-
}),
|
|
61
|
-
_createIndentedListIt2 = (0, _slicedToArray2.default)(_createIndentedListIt, 2),
|
|
62
|
-
sliceSelected = _createIndentedListIt2[0],
|
|
63
|
-
nestedListItemsLeftover = _createIndentedListIt2[1];
|
|
64
|
-
var hasPreviousNestedList = Boolean(previousNestedList);
|
|
65
|
-
var start = from - 1;
|
|
66
|
-
tr.replaceRange(hasPreviousNestedList ? start - 1 : start, range.end, sliceSelected);
|
|
67
|
-
var leftoverContentPosition = tr.mapping.map(to) - 2;
|
|
68
|
-
if (nestedListItemsLeftover.openStart === 0) {
|
|
69
|
-
tr.insert(leftoverContentPosition, nestedListItemsLeftover.content);
|
|
70
|
-
} else {
|
|
71
|
-
tr.replace(leftoverContentPosition - nestedListItemsLeftover.openStart, leftoverContentPosition - nestedListItemsLeftover.openStart, nestedListItemsLeftover);
|
|
72
|
-
}
|
|
73
|
-
var nextSelection = calculateNewSelection({
|
|
74
|
-
originalSelection: originalSelection,
|
|
75
|
-
normalizedSelection: normalizedSelection,
|
|
76
|
-
tr: tr,
|
|
77
|
-
hasPreviousNestedList: hasPreviousNestedList
|
|
78
|
-
});
|
|
79
|
-
tr.setSelection(nextSelection);
|
|
80
|
-
};
|
|
81
|
-
exports.indentListItemsSelected = indentListItemsSelected;
|
|
82
|
-
var calculateRange = function calculateRange(_ref) {
|
|
83
|
-
var selection = _ref.selection;
|
|
84
|
-
var $from = selection.$from,
|
|
85
|
-
$to = selection.$to;
|
|
86
|
-
var range = $from.blockRange($to, _utils.isListNode);
|
|
87
|
-
if (!range) {
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
return range;
|
|
91
|
-
};
|
|
92
|
-
var calculateNewSelection = function calculateNewSelection(_ref2) {
|
|
93
|
-
var tr = _ref2.tr,
|
|
94
|
-
normalizedSelection = _ref2.normalizedSelection,
|
|
95
|
-
originalSelection = _ref2.originalSelection,
|
|
96
|
-
hasPreviousNestedList = _ref2.hasPreviousNestedList;
|
|
97
|
-
var offset = hasPreviousNestedList ? 2 : 0;
|
|
98
|
-
var $from = normalizedSelection.$from,
|
|
99
|
-
$to = normalizedSelection.$to;
|
|
100
|
-
if (normalizedSelection instanceof _selection.GapCursorSelection) {
|
|
101
|
-
var _nextSelectionFrom = tr.doc.resolve($from.pos - offset);
|
|
102
|
-
return new _selection.GapCursorSelection(_nextSelectionFrom, normalizedSelection.side);
|
|
103
|
-
}
|
|
104
|
-
if (originalSelection instanceof _state.NodeSelection) {
|
|
105
|
-
return _state.NodeSelection.create(tr.doc, $from.pos - offset);
|
|
106
|
-
}
|
|
107
|
-
var _Selection$near = _state.Selection.near(tr.doc.resolve($from.pos - offset)),
|
|
108
|
-
nextSelectionFrom = _Selection$near.$from;
|
|
109
|
-
var _Selection$near2 = _state.Selection.near(tr.doc.resolve($to.pos - offset), -1),
|
|
110
|
-
nextSelectionTo = _Selection$near2.$to;
|
|
111
|
-
return new _state.TextSelection(nextSelectionFrom, nextSelectionTo);
|
|
112
|
-
};
|
|
113
|
-
var createIndentedListItemsSlice = function createIndentedListItemsSlice(_ref3) {
|
|
114
|
-
var tr = _ref3.tr,
|
|
115
|
-
from = _ref3.from,
|
|
116
|
-
to = _ref3.to,
|
|
117
|
-
listNodeType = _ref3.listNodeType,
|
|
118
|
-
range = _ref3.range;
|
|
119
|
-
var listItemsSlice = tr.doc.slice(from, to - 2);
|
|
120
|
-
var listFragment = _model.Fragment.from(listNodeType.create(null, listItemsSlice.content));
|
|
121
|
-
var nonSelectedListItemsSlice = tr.doc.slice(to, range.end - 2);
|
|
122
|
-
var openStart = tr.doc.slice(from - 1, range.end).openStart;
|
|
123
|
-
var slice = new _model.Slice(listFragment, openStart, 0);
|
|
124
|
-
return [slice, nonSelectedListItemsSlice];
|
|
125
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.indentList = void 0;
|
|
7
|
-
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
|
-
// adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L206:L231
|
|
10
|
-
var indentList = function indentList(tr) {
|
|
11
|
-
var _tr$selection = tr.selection,
|
|
12
|
-
$from = _tr$selection.$from,
|
|
13
|
-
$to = _tr$selection.$to;
|
|
14
|
-
var listItem = tr.doc.type.schema.nodes.listItem;
|
|
15
|
-
var range = $from.blockRange($to, function (node) {
|
|
16
|
-
return !!node.childCount && !!node.firstChild && node.firstChild.type === listItem;
|
|
17
|
-
});
|
|
18
|
-
if (!range) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// get the index of the selected list item in the list it is part of
|
|
23
|
-
var startIndex = range.startIndex;
|
|
24
|
-
if (startIndex === 0) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// get the parent list of the list item(s) in the selected range
|
|
29
|
-
var parent = range.parent;
|
|
30
|
-
|
|
31
|
-
// get the list immediately before the selection start
|
|
32
|
-
var previousListItem = parent.child(startIndex - 1);
|
|
33
|
-
if (previousListItem.type !== listItem) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// if that list was nested, join the selected list items into the same
|
|
38
|
-
// nested list; if not, create a new child list of the same type and
|
|
39
|
-
// nest it under the current level
|
|
40
|
-
var isPreviousListNested = previousListItem.lastChild && ['bulletList', 'orderedList'].includes(previousListItem.lastChild.type.name);
|
|
41
|
-
var inner = _model.Fragment.from(isPreviousListNested ? listItem.create() : undefined);
|
|
42
|
-
var nextListNodeType = isPreviousListNested ? previousListItem.lastChild.type : parent.type;
|
|
43
|
-
var nextListNodeContent = _model.Fragment.from(nextListNodeType.create(null, inner));
|
|
44
|
-
var slice = new _model.Slice(_model.Fragment.from(listItem.create(null, nextListNodeContent)), isPreviousListNested ? 3 : 1, 0);
|
|
45
|
-
var before = range.start;
|
|
46
|
-
var after = range.end;
|
|
47
|
-
tr.step(new _transform.ReplaceAroundStep(before - (isPreviousListNested ? 3 : 1), after, before, after, slice, 1, true));
|
|
48
|
-
};
|
|
49
|
-
exports.indentList = indentList;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calcJoinListScenario = void 0;
|
|
7
|
-
var _analytics = require("../../analytics");
|
|
8
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
|
-
var _selection = require("../utils/selection");
|
|
10
|
-
var _joinListItemsScenarios = require("./join-list-items-scenarios");
|
|
11
|
-
var calcJoinListScenario = function calcJoinListScenario(walkNode, $head) {
|
|
12
|
-
var $next = walkNode.$pos,
|
|
13
|
-
nextFoundNode = walkNode.foundNode;
|
|
14
|
-
var headParent = $head.parent;
|
|
15
|
-
var headGrandParent = $head.node(-1);
|
|
16
|
-
var headInList = (0, _selection.isPosInsideList)($head);
|
|
17
|
-
var headInParagraph = (0, _selection.isPosInsideParagraph)($head);
|
|
18
|
-
var headInLastNonListChild = headGrandParent && headGrandParent.lastChild && (headGrandParent.lastChild === headParent || headGrandParent.childCount > 1 && headGrandParent.child(headGrandParent.childCount - 2) === headParent &&
|
|
19
|
-
//find the second last child if a list item may be the last child
|
|
20
|
-
(0, _utils.isListNode)(headGrandParent.lastChild));
|
|
21
|
-
var nextInList = (0, _selection.isPosInsideList)($next);
|
|
22
|
-
var nextInParagraph = (0, _selection.isPosInsideParagraph)($next);
|
|
23
|
-
if (!headInList && headInParagraph && nextInList) {
|
|
24
|
-
return [_analytics.LIST_TEXT_SCENARIOS.JOIN_LIST_ITEM_WITH_PARAGRAPH, _joinListItemsScenarios.joinListItemWithParagraph];
|
|
25
|
-
}
|
|
26
|
-
if (!nextFoundNode || !headInList || !headInParagraph || !headInLastNonListChild) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
if (!nextInList && nextInParagraph) {
|
|
30
|
-
return [_analytics.LIST_TEXT_SCENARIOS.JOIN_PARAGRAPH_WITH_LIST, _joinListItemsScenarios.joinParagrapWithList];
|
|
31
|
-
}
|
|
32
|
-
if (!nextInList) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
var nextNodeAfter = $next.nodeAfter;
|
|
36
|
-
var nextGrandParent = $next.node(-1);
|
|
37
|
-
var headGreatGrandParent = $head.node(-2);
|
|
38
|
-
var nextInListItem = (0, _utils.isListItemNode)($next.parent);
|
|
39
|
-
var nextNodeAfterListItem = (0, _utils.isListItemNode)(nextNodeAfter);
|
|
40
|
-
var nextListItemHasFirstChildParagraph = nextNodeAfter &&
|
|
41
|
-
//Redundant check but the linter complains otherwise
|
|
42
|
-
nextNodeAfterListItem && (0, _utils.isParagraphNode)(nextNodeAfter.firstChild);
|
|
43
|
-
if (!nextInListItem && nextListItemHasFirstChildParagraph) {
|
|
44
|
-
return [_analytics.LIST_TEXT_SCENARIOS.JOIN_DESCENDANT_TO_PARENT, _joinListItemsScenarios.joinNestedListWithParentListItem];
|
|
45
|
-
}
|
|
46
|
-
if (!nextInListItem) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
var nextParentSiblingOfHeadParent = nextGrandParent && nextGrandParent === headGreatGrandParent;
|
|
50
|
-
var nextNodeAfterIsParagraph = (0, _utils.isParagraphNode)(nextNodeAfter);
|
|
51
|
-
if (!nextNodeAfterIsParagraph) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if (nextParentSiblingOfHeadParent) {
|
|
55
|
-
return [_analytics.LIST_TEXT_SCENARIOS.JOIN_SIBLINGS, _joinListItemsScenarios.joinSiblingListItems];
|
|
56
|
-
}
|
|
57
|
-
return [_analytics.LIST_TEXT_SCENARIOS.JOIN_PARENT_SIBLING_TO_PARENT_CHILD, _joinListItemsScenarios.joinListItemWithParentNestedList];
|
|
58
|
-
};
|
|
59
|
-
exports.calcJoinListScenario = calcJoinListScenario;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "joinListItemWithParagraph", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _joinListItemWithParagraph.joinListItemWithParagraph;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "joinListItemWithParentNestedList", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _joinListItemWithParentNestedList.joinListItemWithParentNestedList;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "joinNestedListWithParentListItem", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _joinNestedListWithParentListItem.joinNestedListWithParentListItem;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "joinParagrapWithList", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _joinParagraphWithList.joinParagrapWithList;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "joinSiblingListItems", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _joinSiblingListItems.joinSiblingListItems;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
var _joinParagraphWithList = require("./join-paragraph-with-list");
|
|
37
|
-
var _joinSiblingListItems = require("./join-sibling-list-items");
|
|
38
|
-
var _joinNestedListWithParentListItem = require("./join-nested-list-with-parent-list-item");
|
|
39
|
-
var _joinListItemWithParentNestedList = require("./join-list-item-with-parent-nested-list");
|
|
40
|
-
var _joinListItemWithParagraph = require("./join-list-item-with-paragraph");
|
package/dist/cjs/plugins/list/actions/join-list-items-scenarios/join-list-item-with-paragraph.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinListItemWithParagraph = void 0;
|
|
7
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
|
-
// Case for when a users selection is at the end of a paragraph, the paragraph
|
|
10
|
-
// is followed by a list, and they delete forward
|
|
11
|
-
var joinListItemWithParagraph = function joinListItemWithParagraph(_ref) {
|
|
12
|
-
var tr = _ref.tr,
|
|
13
|
-
$next = _ref.$next,
|
|
14
|
-
$head = _ref.$head;
|
|
15
|
-
// For empty paragraphs before a list
|
|
16
|
-
if ($head.parent.content.size < 1) {
|
|
17
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
18
|
-
return tr.doc.resolve($head.pos);
|
|
19
|
-
}, [], [[$head.pos - 1, $head.pos]]);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
var paragraphPosition = $head.pos;
|
|
23
|
-
var list = tr.doc.nodeAt($next.pos - 1);
|
|
24
|
-
var firstListItem = tr.doc.nodeAt($next.pos);
|
|
25
|
-
if (!list || !firstListItem) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
var firstChildNodeOfFirstListItem = firstListItem.firstChild;
|
|
29
|
-
if (!firstChildNodeOfFirstListItem) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
var lastChildOfFirstListItem = firstListItem.lastChild;
|
|
33
|
-
var firstGrandchildOfFirstListItem = firstChildNodeOfFirstListItem.firstChild;
|
|
34
|
-
var firstListItemHasOneChildWithNoNestedLists = hasSingleChild(firstListItem) && firstChildNodeOfFirstListItem.childCount < 2 && $next.nodeAfter;
|
|
35
|
-
var firstListItemContainsParagraphAndNestedList = !hasSingleChild(firstListItem) && lastChildOfFirstListItem && (0, _utils.isListNode)(lastChildOfFirstListItem);
|
|
36
|
-
var insertions = [];
|
|
37
|
-
var deletions = [];
|
|
38
|
-
|
|
39
|
-
// For lists that only have one list item with no children - need to remove remaining list
|
|
40
|
-
if (hasSingleChild(list) && hasSingleChild(firstListItem) && $next.nodeAfter) {
|
|
41
|
-
deletions.push([tr.mapping.map($next.pos - 1), tr.mapping.map($next.pos + $next.nodeAfter.nodeSize + 1)]);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// For first list items that have a paragraph and a list
|
|
45
|
-
if (firstListItemContainsParagraphAndNestedList) {
|
|
46
|
-
var firstListItemNestedList = _model.Fragment.from(lastChildOfFirstListItem.content);
|
|
47
|
-
insertions.push([firstListItemNestedList, tr.mapping.map($next.pos)]);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// For first list item has one child & no nested lists OR first list items that have a paragraph and a list
|
|
51
|
-
if (firstListItemHasOneChildWithNoNestedLists || firstListItemContainsParagraphAndNestedList) {
|
|
52
|
-
deletions.push([tr.mapping.map($next.pos), tr.mapping.map($next.pos + firstListItem.nodeSize - 1)]);
|
|
53
|
-
var firstListItemText = _model.Fragment.from(firstChildNodeOfFirstListItem.content);
|
|
54
|
-
insertions.push([firstListItemText, paragraphPosition]);
|
|
55
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
56
|
-
return tr.doc.resolve($head.pos);
|
|
57
|
-
}, insertions, deletions);
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// For any first list items that have multiple children (eg. multiple paragraphs)
|
|
62
|
-
if (firstListItem.childCount > 1) {
|
|
63
|
-
insertions.push([_model.Fragment.from(firstChildNodeOfFirstListItem.content), paragraphPosition]);
|
|
64
|
-
deletions.push([tr.mapping.map($next.pos + 1), tr.mapping.map($next.pos + firstChildNodeOfFirstListItem.nodeSize + 1)]);
|
|
65
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
66
|
-
return tr.doc.resolve($head.pos);
|
|
67
|
-
}, insertions, deletions);
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// For any remaining first list items that have a single child (eg. single paragraph, multiple lines of text)
|
|
72
|
-
if (firstGrandchildOfFirstListItem && firstGrandchildOfFirstListItem.type.name === 'hardBreak') {
|
|
73
|
-
var nodeSizeOfGrandchild = firstGrandchildOfFirstListItem ? firstGrandchildOfFirstListItem.nodeSize : 0;
|
|
74
|
-
deletions.push([tr.mapping.map($next.pos + 2), tr.mapping.map($next.pos + 2 + nodeSizeOfGrandchild)]);
|
|
75
|
-
} else {
|
|
76
|
-
insertions.push([_model.Fragment.from(firstChildNodeOfFirstListItem.content), paragraphPosition]);
|
|
77
|
-
var nodeSizeOfFirstChild = firstChildNodeOfFirstListItem.nodeSize;
|
|
78
|
-
deletions.push([tr.mapping.map($next.pos), tr.mapping.map($next.pos + 2 + nodeSizeOfFirstChild)]);
|
|
79
|
-
}
|
|
80
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
81
|
-
return tr.doc.resolve($head.pos);
|
|
82
|
-
}, insertions, deletions);
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
exports.joinListItemWithParagraph = joinListItemWithParagraph;
|
|
86
|
-
var hasSingleChild = function hasSingleChild(node) {
|
|
87
|
-
return node.childCount === 1;
|
|
88
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinListItemWithParentNestedList = void 0;
|
|
7
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
//Case for two adjacent list items with the first being of greater indentation
|
|
9
|
-
var joinListItemWithParentNestedList = function joinListItemWithParentNestedList(_ref) {
|
|
10
|
-
var tr = _ref.tr,
|
|
11
|
-
$next = _ref.$next,
|
|
12
|
-
$head = _ref.$head;
|
|
13
|
-
/* CASE 4
|
|
14
|
-
* Initial Structure:
|
|
15
|
-
*
|
|
16
|
-
* List A {
|
|
17
|
-
* ListItem B {
|
|
18
|
-
* Paragraph C { text1 }
|
|
19
|
-
* ...Children D
|
|
20
|
-
* List E {
|
|
21
|
-
* ...
|
|
22
|
-
* List F { //May be multiple levels of lists
|
|
23
|
-
* ...Children G
|
|
24
|
-
* ListItem H { //Last node of the block
|
|
25
|
-
* ...Children I
|
|
26
|
-
* Paragraph J { text2 |$head||textInsertPos| } |childrenMInsertPos| //Cant have children since this ListItem is the last of the block
|
|
27
|
-
* }
|
|
28
|
-
* }
|
|
29
|
-
* ...
|
|
30
|
-
* |childrenOInsertPos| }
|
|
31
|
-
* }
|
|
32
|
-
* ListItem K { |$next|
|
|
33
|
-
* Paragraph L { text3 }
|
|
34
|
-
* ...Children M
|
|
35
|
-
* List? N {
|
|
36
|
-
* ...Children O
|
|
37
|
-
* }
|
|
38
|
-
* }
|
|
39
|
-
* }
|
|
40
|
-
*
|
|
41
|
-
* Converts to:
|
|
42
|
-
*
|
|
43
|
-
* List A {
|
|
44
|
-
* ListItem B {
|
|
45
|
-
* Paragraph C { text1 }
|
|
46
|
-
* ...Children D
|
|
47
|
-
* List E {
|
|
48
|
-
* ...
|
|
49
|
-
* List F {
|
|
50
|
-
* ...Children G
|
|
51
|
-
* ListItem H {
|
|
52
|
-
* ...Children I
|
|
53
|
-
* Paragraph J { text2text3 }
|
|
54
|
-
* ...Children M
|
|
55
|
-
* }
|
|
56
|
-
* }
|
|
57
|
-
* ...
|
|
58
|
-
* ...Children O
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
*
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
var listItemK = $next.parent; //List must have at least one child
|
|
66
|
-
if (!listItemK.firstChild || !listItemK.lastChild) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
var beforeListItemK = $next.before();
|
|
70
|
-
var afterListItemB = $next.before();
|
|
71
|
-
var afterListItemK = $next.after();
|
|
72
|
-
var containsChildrenO = (0, _utils.isListNode)(listItemK.lastChild);
|
|
73
|
-
var textInsertPos = $head.pos;
|
|
74
|
-
var childrenMInsertPos = $head.pos + 1;
|
|
75
|
-
var childrenOInsertPos = afterListItemB - 2;
|
|
76
|
-
var textContent = listItemK.firstChild.content;
|
|
77
|
-
var childrenMContent = containsChildrenO ? listItemK.content.cut(listItemK.firstChild.nodeSize, listItemK.nodeSize - listItemK.lastChild.nodeSize - 2 //Get the position before
|
|
78
|
-
) : listItemK.content.cut(listItemK.firstChild.nodeSize);
|
|
79
|
-
var childrenOContent = listItemK.lastChild.content;
|
|
80
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
81
|
-
return tr.doc.resolve(textInsertPos);
|
|
82
|
-
}, containsChildrenO ? [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos], [childrenOContent, childrenOInsertPos]] : [[textContent, textInsertPos], [childrenMContent, childrenMInsertPos]], [[beforeListItemK, afterListItemK]]);
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
exports.joinListItemWithParentNestedList = joinListItemWithParentNestedList;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinNestedListWithParentListItem = void 0;
|
|
7
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
//Case for two adjacent list items with the first being of lower indentation
|
|
9
|
-
var joinNestedListWithParentListItem = function joinNestedListWithParentListItem(_ref) {
|
|
10
|
-
var tr = _ref.tr,
|
|
11
|
-
$next = _ref.$next,
|
|
12
|
-
$head = _ref.$head;
|
|
13
|
-
/* CASE 3
|
|
14
|
-
* Initial Structure:
|
|
15
|
-
*
|
|
16
|
-
* List A {
|
|
17
|
-
* ListItem B {
|
|
18
|
-
* ...Children C
|
|
19
|
-
* Paragraph D { text1 |$head||textInsertPos| } |childrenHInsertPos|
|
|
20
|
-
* List E { |$next||childrenJInsertPos|
|
|
21
|
-
* ListItem F {
|
|
22
|
-
* Paragraph G { text2 }
|
|
23
|
-
* ...Children H
|
|
24
|
-
* List? I {
|
|
25
|
-
* ...Children J
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
* ...Children K
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
* Converts to:
|
|
34
|
-
*
|
|
35
|
-
* List A {
|
|
36
|
-
* ListItem B {
|
|
37
|
-
* ...Children C
|
|
38
|
-
* Paragraph D { text1text2 }
|
|
39
|
-
* ...Children H
|
|
40
|
-
* List E {
|
|
41
|
-
* ...Children J
|
|
42
|
-
* ...Children K
|
|
43
|
-
* }
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
var listE = $next.parent;
|
|
50
|
-
var listItemF = $next.nodeAfter; //We know next is before a ListItem. ListItem must have at least one child
|
|
51
|
-
if (!listItemF || !listItemF.lastChild) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
var paragraphG = listItemF.firstChild; //ListItem must have at least one child
|
|
55
|
-
if (!paragraphG) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
var beforeListE = $next.before();
|
|
59
|
-
var beforeListItemF = $next.pos;
|
|
60
|
-
var afterParagraphD = $head.after();
|
|
61
|
-
var afterListE = $next.after();
|
|
62
|
-
var afterListItemF = tr.doc.resolve($next.pos + 1).after(); //List must always have at least one listItem
|
|
63
|
-
|
|
64
|
-
var containsChildrenJ = (0, _utils.isListNode)(listItemF.lastChild);
|
|
65
|
-
var shouldRemoveListE = listE.childCount === 1 && !containsChildrenJ; //Assures no Children J and K
|
|
66
|
-
|
|
67
|
-
var textInsertPos = $head.pos;
|
|
68
|
-
var childrenHInsertPos = afterParagraphD;
|
|
69
|
-
var childrenJInsertPos = $next.pos;
|
|
70
|
-
var textContent = paragraphG.content;
|
|
71
|
-
var childrenHContent = containsChildrenJ ? listItemF.content.cut(paragraphG.nodeSize, listItemF.nodeSize - listItemF.lastChild.nodeSize - 2) : listItemF.content.cut(paragraphG.nodeSize); //If Children J doesn't exist then Children H will include the last node
|
|
72
|
-
var childrenJContent = listItemF.lastChild.content; //Will be invalid if there are no Children J but it will be unused
|
|
73
|
-
|
|
74
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
75
|
-
return tr.doc.resolve(textInsertPos);
|
|
76
|
-
}, containsChildrenJ ? [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos], [childrenJContent, childrenJInsertPos]] : [[textContent, textInsertPos], [childrenHContent, childrenHInsertPos]], [shouldRemoveListE ? [beforeListE, afterListE] : [beforeListItemF, afterListItemF]]);
|
|
77
|
-
return true;
|
|
78
|
-
};
|
|
79
|
-
exports.joinNestedListWithParentListItem = joinNestedListWithParentListItem;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinParagrapWithList = void 0;
|
|
7
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
//Case for two adjacent nodes with the first being a list item and the last being a paragraph
|
|
9
|
-
var joinParagrapWithList = function joinParagrapWithList(_ref) {
|
|
10
|
-
var tr = _ref.tr,
|
|
11
|
-
$next = _ref.$next,
|
|
12
|
-
$head = _ref.$head;
|
|
13
|
-
/* CASE 1
|
|
14
|
-
* Initial Structure:
|
|
15
|
-
*
|
|
16
|
-
* List A {
|
|
17
|
-
* ListItem B {
|
|
18
|
-
* ...Children C
|
|
19
|
-
* Paragraph D { text1 |$head||textInsertPos| }
|
|
20
|
-
* }
|
|
21
|
-
* }
|
|
22
|
-
* Paragraph E { |$next| text 2 }
|
|
23
|
-
*
|
|
24
|
-
* Converts to:
|
|
25
|
-
*
|
|
26
|
-
* List A {
|
|
27
|
-
* ListItem B {
|
|
28
|
-
* ...Children C
|
|
29
|
-
* Paragraph D { text1text2 }
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
var paragraphE = $next.parent;
|
|
36
|
-
var beforeParagraphE = $next.before();
|
|
37
|
-
var afterParagraphE = $next.after();
|
|
38
|
-
var textInsertPos = $head.pos;
|
|
39
|
-
var textContent = paragraphE.content;
|
|
40
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
41
|
-
return tr.doc.resolve(textInsertPos);
|
|
42
|
-
}, [[textContent, textInsertPos]], [[beforeParagraphE, afterParagraphE]]);
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
45
|
-
exports.joinParagrapWithList = joinParagrapWithList;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinSiblingListItems = void 0;
|
|
7
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
//Case for two adjacent list items of the same indentation
|
|
9
|
-
var joinSiblingListItems = function joinSiblingListItems(_ref) {
|
|
10
|
-
var tr = _ref.tr,
|
|
11
|
-
$next = _ref.$next,
|
|
12
|
-
$head = _ref.$head;
|
|
13
|
-
/* CASE 2
|
|
14
|
-
* Initial Structure:
|
|
15
|
-
*
|
|
16
|
-
* List A {
|
|
17
|
-
* ListItem B {
|
|
18
|
-
* ...Children C
|
|
19
|
-
* Paragraph D { text1 |$head||textInsertPos| } //Cant have children since that would be Case 4
|
|
20
|
-
* |childrenGInsertPos| }
|
|
21
|
-
* ListItem E { |$next|
|
|
22
|
-
* Paragraph F { text2 }
|
|
23
|
-
* ...Children G
|
|
24
|
-
* }
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* Converts to:
|
|
28
|
-
*
|
|
29
|
-
* List A {
|
|
30
|
-
* ListItem B {
|
|
31
|
-
* ...Children C
|
|
32
|
-
* Paragraph C { text1text2 }
|
|
33
|
-
* ...Children G
|
|
34
|
-
* }
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
var listItemE = $next.parent;
|
|
40
|
-
var paragraphF = $next.nodeAfter; //ListItem must have at least one child
|
|
41
|
-
if (!paragraphF) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
var beforeListItemE = $next.before();
|
|
45
|
-
var afterListItemE = $next.after();
|
|
46
|
-
var endListItemB = $head.end(-1);
|
|
47
|
-
var textInsertPos = $head.pos;
|
|
48
|
-
var childrenGInsertPos = endListItemB;
|
|
49
|
-
var textContent = paragraphF.content;
|
|
50
|
-
var childrenGContent = listItemE.content.cut(paragraphF.nodeSize);
|
|
51
|
-
(0, _utils.insertContentDeleteRange)(tr, function (tr) {
|
|
52
|
-
return tr.doc.resolve(textInsertPos);
|
|
53
|
-
}, [[textContent, textInsertPos], [childrenGContent, childrenGInsertPos]], [[beforeListItemE, afterListItemE]]);
|
|
54
|
-
return true;
|
|
55
|
-
};
|
|
56
|
-
exports.joinSiblingListItems = joinSiblingListItems;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mergeNextListAtPosition = mergeNextListAtPosition;
|
|
7
|
-
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
-
function mergeNextListAtPosition(_ref) {
|
|
9
|
-
var tr = _ref.tr,
|
|
10
|
-
listPosition = _ref.listPosition;
|
|
11
|
-
var listNodeAtPosition = tr.doc.nodeAt(listPosition);
|
|
12
|
-
if (!(0, _utils.isListNode)(listNodeAtPosition)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
var listPositionResolved = tr.doc.resolve(listPosition + listNodeAtPosition.nodeSize);
|
|
16
|
-
var pos = listPositionResolved.pos,
|
|
17
|
-
nodeAfter = listPositionResolved.nodeAfter,
|
|
18
|
-
nodeBefore = listPositionResolved.nodeBefore;
|
|
19
|
-
if (!(0, _utils.isListNode)(nodeBefore) || !(0, _utils.isListNode)(nodeAfter)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if ((nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.type.name) !== (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name)) {
|
|
23
|
-
var previousListPosition = pos - nodeBefore.nodeSize;
|
|
24
|
-
tr.setNodeMarkup(previousListPosition, nodeAfter.type);
|
|
25
|
-
}
|
|
26
|
-
tr.join(pos);
|
|
27
|
-
}
|