@titaui/pc 1.10.39 → 1.10.43
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/lib/components/dynamic/dynamic-item/dynamic-chart/index.js +18 -3
- package/lib/components/upload/index.js +2 -4
- package/lib/index.js +0 -8
- package/package.json +2 -20
- package/lib/components/rich-editor/basic/schema.js +0 -47
- package/lib/components/rich-editor/consts/events.js +0 -12
- package/lib/components/rich-editor/enums.js +0 -42
- package/lib/components/rich-editor/index.js +0 -58
- package/lib/components/rich-editor/keymap.js +0 -119
- package/lib/components/rich-editor/keymaps/index.js +0 -241
- package/lib/components/rich-editor/models/controller.js +0 -18
- package/lib/components/rich-editor/models/editor.js +0 -47
- package/lib/components/rich-editor/models/plugin.js +0 -20
- package/lib/components/rich-editor/models/schema.js +0 -121
- package/lib/components/rich-editor/plugins/block/block-quote/commond.js +0 -27
- package/lib/components/rich-editor/plugins/block/block-quote/index.js +0 -126
- package/lib/components/rich-editor/plugins/block/heading/commonds.js +0 -31
- package/lib/components/rich-editor/plugins/block/heading/index.js +0 -188
- package/lib/components/rich-editor/plugins/block/index.js +0 -57
- package/lib/components/rich-editor/plugins/block/lists/actions/conversions.js +0 -172
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js +0 -163
- package/lib/components/rich-editor/plugins/block/lists/actions/indent-list.js +0 -59
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-forward.js +0 -74
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/index.js +0 -45
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +0 -104
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +0 -92
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +0 -89
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-paragraph-with-list.js +0 -48
- package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-sibling-list-items.js +0 -61
- package/lib/components/rich-editor/plugins/block/lists/actions/merge-lists.js +0 -34
- package/lib/components/rich-editor/plugins/block/lists/actions/outdent-list-items-selected.js +0 -289
- package/lib/components/rich-editor/plugins/block/lists/actions/wrap-and-join-lists.js +0 -180
- package/lib/components/rich-editor/plugins/block/lists/baseCommand.js +0 -328
- package/lib/components/rich-editor/plugins/block/lists/commond/indent-list.js +0 -60
- package/lib/components/rich-editor/plugins/block/lists/commond/index.js +0 -398
- package/lib/components/rich-editor/plugins/block/lists/commond/join-list-item-forward.js +0 -45
- package/lib/components/rich-editor/plugins/block/lists/commond/listBackspace.js +0 -302
- package/lib/components/rich-editor/plugins/block/lists/commond/outdent-list.js +0 -43
- package/lib/components/rich-editor/plugins/block/lists/index.js +0 -222
- package/lib/components/rich-editor/plugins/block/lists/messages.js +0 -38
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/input-rule.js +0 -152
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/keymap.js +0 -33
- package/lib/components/rich-editor/plugins/block/lists/pm-plugins/main.js +0 -94
- package/lib/components/rich-editor/plugins/block/lists/styles.js +0 -15
- package/lib/components/rich-editor/plugins/block/lists/transforms.js +0 -347
- package/lib/components/rich-editor/plugins/block/lists/utils/analytics.js +0 -48
- package/lib/components/rich-editor/plugins/block/lists/utils/find.js +0 -126
- package/lib/components/rich-editor/plugins/block/lists/utils/indentation.js +0 -87
- package/lib/components/rich-editor/plugins/block/lists/utils/node.js +0 -144
- package/lib/components/rich-editor/plugins/block/lists/utils/replace-content.js +0 -31
- package/lib/components/rich-editor/plugins/block/lists/utils/selection.js +0 -201
- package/lib/components/rich-editor/plugins/block/lists/utils.js +0 -52
- package/lib/components/rich-editor/plugins/block/paragraph/index.js +0 -91
- package/lib/components/rich-editor/plugins/core/index.js +0 -90
- package/lib/components/rich-editor/plugins/core/pm-plugins/focus-handler.js +0 -67
- package/lib/components/rich-editor/plugins/core/pm-plugins/keymap.js +0 -29
- package/lib/components/rich-editor/plugins/core/pm-plugins/reactNodeView.js +0 -80
- package/lib/components/rich-editor/plugins/extension/alignment/commond.js +0 -24
- package/lib/components/rich-editor/plugins/extension/alignment/index.js +0 -111
- package/lib/components/rich-editor/plugins/extension/alignment/utils.js +0 -19
- package/lib/components/rich-editor/plugins/extension/index.js +0 -18
- package/lib/components/rich-editor/plugins/index.js +0 -44
- package/lib/components/rich-editor/plugins/inline/color/commond.js +0 -128
- package/lib/components/rich-editor/plugins/inline/color/consts.js +0 -43
- package/lib/components/rich-editor/plugins/inline/color/index.css +0 -61
- package/lib/components/rich-editor/plugins/inline/color/index.js +0 -209
- package/lib/components/rich-editor/plugins/inline/color/selector.js +0 -252
- package/lib/components/rich-editor/plugins/inline/delete-line/index.js +0 -147
- package/lib/components/rich-editor/plugins/inline/em/index.js +0 -93
- package/lib/components/rich-editor/plugins/inline/index.js +0 -83
- package/lib/components/rich-editor/plugins/inline/link/commands.js +0 -256
- package/lib/components/rich-editor/plugins/inline/link/index.js +0 -149
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/fake-cursor-for-toolbar.js +0 -77
- package/lib/components/rich-editor/plugins/inline/link/pm-plugins/main.js +0 -293
- package/lib/components/rich-editor/plugins/inline/link/ui/index.css +0 -79
- package/lib/components/rich-editor/plugins/inline/link/ui/linkEditor.js +0 -148
- package/lib/components/rich-editor/plugins/inline/link/ui/linkToolbar.js +0 -88
- package/lib/components/rich-editor/plugins/inline/link/ui/toolbarBtn.js +0 -117
- package/lib/components/rich-editor/plugins/inline/link/utils.js +0 -33
- package/lib/components/rich-editor/plugins/inline/strong/index.js +0 -137
- package/lib/components/rich-editor/plugins/inline/under-line/index.js +0 -145
- package/lib/components/rich-editor/plugins/util.js +0 -281
- package/lib/components/rich-editor/react/reactNodeView.js +0 -383
- package/lib/components/rich-editor/react/uiProvider.js +0 -185
- package/lib/components/rich-editor/schemas/basic.js +0 -309
- package/lib/components/rich-editor/schemas/index.js +0 -19
- package/lib/components/rich-editor/schemas/list.js +0 -342
- package/lib/components/rich-editor/types/commond.js +0 -5
- package/lib/components/rich-editor/types/index.js +0 -18
- package/lib/components/rich-editor/ui/Popup/index.js +0 -247
- package/lib/components/rich-editor/ui/Popup/utils.js +0 -399
- package/lib/components/rich-editor/ui/editor/index.css +0 -141
- package/lib/components/rich-editor/ui/editor/index.js +0 -130
- package/lib/components/rich-editor/ui/normal-toolbar/index.css +0 -28
- package/lib/components/rich-editor/ui/normal-toolbar/index.js +0 -109
- package/lib/components/rich-editor/utils/browser.js +0 -35
- package/lib/components/rich-editor/utils/commands.js +0 -266
- package/lib/components/rich-editor/utils/document.js +0 -160
- package/lib/components/rich-editor/utils/event.js +0 -79
- package/lib/components/rich-editor/utils/helpers.js +0 -16
- package/lib/components/rich-editor/utils/mark.js +0 -168
- package/lib/components/rich-editor/utils/slice.js +0 -85
- package/lib/components/rich-editor/utils/toolbar.js +0 -228
- package/yarn-error.log +0 -22184
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.convertListType = convertListType;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
|
-
|
|
14
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
15
|
-
|
|
16
|
-
var _node = require("../utils/node");
|
|
17
|
-
|
|
18
|
-
var _find = require("../utils/find");
|
|
19
|
-
|
|
20
|
-
// import { isEmptyParagraph } from '../../../utils';
|
|
21
|
-
function isEmptyParagraph(node) {
|
|
22
|
-
return !!node && node.type.name === 'paragraph' && !node.childCount;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function convertListType(_ref) {
|
|
26
|
-
var tr = _ref.tr,
|
|
27
|
-
nextListNodeType = _ref.nextListNodeType;
|
|
28
|
-
var doc = tr.doc,
|
|
29
|
-
_tr$selection = tr.selection,
|
|
30
|
-
$from = _tr$selection.$from,
|
|
31
|
-
$to = _tr$selection.$to;
|
|
32
|
-
var listRange = $from.blockRange($to, _node.isListNode);
|
|
33
|
-
|
|
34
|
-
if (listRange) {
|
|
35
|
-
return convertSelectedList({
|
|
36
|
-
tr: tr,
|
|
37
|
-
nextListNodeType: nextListNodeType
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var nodeRangeAroundList = $from.blockRange($to);
|
|
42
|
-
|
|
43
|
-
if (!nodeRangeAroundList) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var parentNode = nodeRangeAroundList.parent;
|
|
48
|
-
var startIndex = nodeRangeAroundList.startIndex,
|
|
49
|
-
endIndex = nodeRangeAroundList.endIndex,
|
|
50
|
-
depth = nodeRangeAroundList.depth; // Checking for invalid nodes to prevent conversion
|
|
51
|
-
// eg. a panel cannot be wrapped in a list so return
|
|
52
|
-
// It will skip this check if the selection begins within a list
|
|
53
|
-
// This is to match the behaviour of the toolbar buttons being disabled
|
|
54
|
-
|
|
55
|
-
if (!(0, _find.findFirstParentListNode)($from)) {
|
|
56
|
-
for (var i = startIndex; i < endIndex; i++) {
|
|
57
|
-
var position = nodeRangeAroundList.$from.posAtIndex(i, depth);
|
|
58
|
-
var resolvedPosition = doc.resolve(position);
|
|
59
|
-
var currentChild = parentNode.child(i);
|
|
60
|
-
var currentNodeRange = resolvedPosition.blockRange(tr.doc.resolve(position + currentChild.nodeSize));
|
|
61
|
-
|
|
62
|
-
if (currentNodeRange && !(0, _node.isListNode)(currentChild) && !(0, _prosemirrorTransform.findWrapping)(currentNodeRange, nextListNodeType)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
} // Checking for any non list nodes and wrapping them in a list
|
|
67
|
-
// so they can be converted
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
tr.doc.nodesBetween(nodeRangeAroundList.start, nodeRangeAroundList.end, function (node, pos) {
|
|
71
|
-
// Skip over any nodes that are part of a list
|
|
72
|
-
if ((0, _find.findFirstParentListNode)(tr.doc.resolve(tr.mapping.map(pos)))) {
|
|
73
|
-
return false;
|
|
74
|
-
} // The following applies to suitable nodes that are not within a list
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
var currentNodeNotWrappedInList = node;
|
|
78
|
-
var isNotAnEmptyParagraphAndIsParagraphOrLeafNode = !isEmptyParagraph(currentNodeNotWrappedInList) && (!node.type.isBlock || node.type.name === 'paragraph');
|
|
79
|
-
|
|
80
|
-
if (isNotAnEmptyParagraphAndIsParagraphOrLeafNode) {
|
|
81
|
-
var remainingNodeRange = new _prosemirrorModel.NodeRange(tr.doc.resolve(tr.mapping.map(pos)), tr.doc.resolve(tr.mapping.map(pos) + currentNodeNotWrappedInList.nodeSize), nodeRangeAroundList.depth);
|
|
82
|
-
convertAroundList({
|
|
83
|
-
tr: tr,
|
|
84
|
-
nextListNodeType: nextListNodeType,
|
|
85
|
-
nodeRange: remainingNodeRange
|
|
86
|
-
});
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
convertSelectedList({
|
|
91
|
-
tr: tr,
|
|
92
|
-
nextListNodeType: nextListNodeType
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
if (tr.docChanged) {
|
|
96
|
-
(0, _node.joinSiblingLists)({
|
|
97
|
-
tr: tr,
|
|
98
|
-
forceListType: nextListNodeType
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
var convertSelectedList = function convertSelectedList(_ref2) {
|
|
104
|
-
var tr = _ref2.tr,
|
|
105
|
-
nextListNodeType = _ref2.nextListNodeType;
|
|
106
|
-
var selection = tr.selection,
|
|
107
|
-
_tr$selection2 = tr.selection,
|
|
108
|
-
from = _tr$selection2.from,
|
|
109
|
-
to = _tr$selection2.to; // get the positions of all the leaf nodes within the selection
|
|
110
|
-
|
|
111
|
-
var nodePositions = [];
|
|
112
|
-
|
|
113
|
-
if (selection instanceof _prosemirrorState.TextSelection && selection.$cursor) {
|
|
114
|
-
nodePositions.push(from);
|
|
115
|
-
} else {
|
|
116
|
-
// nodesBetween doesn't return leaf nodes that are outside of from and to
|
|
117
|
-
tr.doc.nodesBetween(from, to, function (node, pos) {
|
|
118
|
-
if (!node.isLeaf) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
nodePositions.push(pos);
|
|
123
|
-
});
|
|
124
|
-
} // use those positions to get the closest parent list nodes
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
nodePositions.reduce(function (acc, pos) {
|
|
128
|
-
var closestParentListNode = (0, _prosemirrorUtils.findParentNodeClosestToPos)(tr.doc.resolve(pos), _node.isListNode);
|
|
129
|
-
|
|
130
|
-
if (!closestParentListNode) {
|
|
131
|
-
return acc;
|
|
132
|
-
} // don't add duplicates if the parent has already been added into the array
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
var existingParent = acc.find(function (node) {
|
|
136
|
-
return node.pos === closestParentListNode.pos && node.start === closestParentListNode.start && node.depth === closestParentListNode.depth;
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
if (!existingParent) {
|
|
140
|
-
acc.push(closestParentListNode);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return acc;
|
|
144
|
-
}, []).forEach(function (item) {
|
|
145
|
-
tr.setNodeMarkup(item.pos, nextListNodeType);
|
|
146
|
-
});
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var convertAroundList = function convertAroundList(_ref3) {
|
|
150
|
-
var tr = _ref3.tr,
|
|
151
|
-
nextListNodeType = _ref3.nextListNodeType,
|
|
152
|
-
nodeRange = _ref3.nodeRange;
|
|
153
|
-
|
|
154
|
-
for (var i = nodeRange.endIndex - 1; i >= nodeRange.startIndex; i--) {
|
|
155
|
-
// @ts-ignore posAtIndex is a public API but has no type yet
|
|
156
|
-
var position = nodeRange.$from.posAtIndex(i, nodeRange.depth);
|
|
157
|
-
var resolvedPos = tr.doc.resolve(position + 1);
|
|
158
|
-
var range = resolvedPos.blockRange(resolvedPos);
|
|
159
|
-
|
|
160
|
-
if (!range) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
var wrappings = (0, _prosemirrorTransform.findWrapping)(range, nextListNodeType);
|
|
165
|
-
|
|
166
|
-
if (!range || !wrappings) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
tr.wrap(range, wrappings);
|
|
171
|
-
}
|
|
172
|
-
};
|
package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.indentListItemsSelected = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
var _node = require("../utils/node");
|
|
13
|
-
|
|
14
|
-
var _find = require("../utils/find");
|
|
15
|
-
|
|
16
|
-
var _selection = require("../utils/selection");
|
|
17
|
-
|
|
18
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
-
|
|
20
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
|
|
22
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
|
|
24
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
-
|
|
26
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
27
|
-
|
|
28
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
-
|
|
30
|
-
// import { GapCursorSelection } from '../../selection/gap-cursor-selection';
|
|
31
|
-
var indentListItemsSelected = function indentListItemsSelected(tr) {
|
|
32
|
-
var originalSelection = tr.selection;
|
|
33
|
-
var normalizedSelection = (0, _selection.normalizeListItemsSelection)({
|
|
34
|
-
selection: originalSelection,
|
|
35
|
-
doc: tr.doc
|
|
36
|
-
});
|
|
37
|
-
var $from = normalizedSelection.$from,
|
|
38
|
-
$to = normalizedSelection.$to;
|
|
39
|
-
var range = calculateRange({
|
|
40
|
-
selection: normalizedSelection
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (!range) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var listItemsSelected = {
|
|
48
|
-
from: (0, _find.findFirstParentListItemNode)($from),
|
|
49
|
-
to: (0, _find.findFirstParentListItemNode)($to)
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
if (listItemsSelected.from === null || listItemsSelected.to === null) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var resolvedPos = tr.doc.resolve(listItemsSelected.from.pos);
|
|
57
|
-
var listItemIndex = resolvedPos.index(); // @ts-ignore
|
|
58
|
-
|
|
59
|
-
var positionListItemPosition = resolvedPos.posAtIndex(listItemIndex - 1);
|
|
60
|
-
var previousListItem = tr.doc.nodeAt(positionListItemPosition);
|
|
61
|
-
|
|
62
|
-
if (!previousListItem || !(0, _node.isListItemNode)(previousListItem)) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if ((0, _node.isListItemNode)(previousListItem) && listItemIndex === 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var listItemSelectedCommonParent = range.parent;
|
|
71
|
-
var previousNestedList = (0, _node.isListNode)(previousListItem.lastChild) ? previousListItem.lastChild : null;
|
|
72
|
-
var listNodeType = previousNestedList ? previousNestedList.type : listItemSelectedCommonParent.type;
|
|
73
|
-
var nestedList = listItemsSelected.to.node.lastChild;
|
|
74
|
-
var nestedItemsOffset = nestedList && (0, _node.isListNode)(nestedList) ? nestedList.nodeSize : 0;
|
|
75
|
-
var from = listItemsSelected.from.pos;
|
|
76
|
-
var to = listItemsSelected.to.pos + listItemsSelected.to.node.nodeSize - nestedItemsOffset;
|
|
77
|
-
|
|
78
|
-
var _createIndentedListIt = createIndentedListItemsSlice({
|
|
79
|
-
tr: tr,
|
|
80
|
-
listNodeType: listNodeType,
|
|
81
|
-
range: range,
|
|
82
|
-
from: from,
|
|
83
|
-
to: to
|
|
84
|
-
}),
|
|
85
|
-
_createIndentedListIt2 = _slicedToArray(_createIndentedListIt, 2),
|
|
86
|
-
sliceSelected = _createIndentedListIt2[0],
|
|
87
|
-
nestedListItemsLeftover = _createIndentedListIt2[1];
|
|
88
|
-
|
|
89
|
-
var hasPreviousNestedList = Boolean(previousNestedList);
|
|
90
|
-
var start = from - 1;
|
|
91
|
-
tr.replaceRange(hasPreviousNestedList ? start - 1 : start, range.end, sliceSelected);
|
|
92
|
-
var leftoverContentPosition = tr.mapping.map(to) - 2;
|
|
93
|
-
|
|
94
|
-
if (nestedListItemsLeftover.openStart === 0) {
|
|
95
|
-
tr.insert(leftoverContentPosition, nestedListItemsLeftover.content);
|
|
96
|
-
} else {
|
|
97
|
-
tr.replace(leftoverContentPosition - nestedListItemsLeftover.openStart, leftoverContentPosition - nestedListItemsLeftover.openStart, nestedListItemsLeftover);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var nextSelection = calculateNewSelection({
|
|
101
|
-
originalSelection: originalSelection,
|
|
102
|
-
normalizedSelection: normalizedSelection,
|
|
103
|
-
tr: tr,
|
|
104
|
-
hasPreviousNestedList: hasPreviousNestedList
|
|
105
|
-
});
|
|
106
|
-
tr.setSelection(nextSelection);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
exports.indentListItemsSelected = indentListItemsSelected;
|
|
110
|
-
|
|
111
|
-
var calculateRange = function calculateRange(_ref) {
|
|
112
|
-
var selection = _ref.selection;
|
|
113
|
-
var $from = selection.$from,
|
|
114
|
-
$to = selection.$to;
|
|
115
|
-
var range = $from.blockRange($to, _node.isListNode);
|
|
116
|
-
|
|
117
|
-
if (!range) {
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return range;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
var calculateNewSelection = function calculateNewSelection(_ref2) {
|
|
125
|
-
var tr = _ref2.tr,
|
|
126
|
-
normalizedSelection = _ref2.normalizedSelection,
|
|
127
|
-
originalSelection = _ref2.originalSelection,
|
|
128
|
-
hasPreviousNestedList = _ref2.hasPreviousNestedList;
|
|
129
|
-
var offset = hasPreviousNestedList ? 2 : 0;
|
|
130
|
-
var $from = normalizedSelection.$from,
|
|
131
|
-
$to = normalizedSelection.$to; // if (normalizedSelection instanceof GapCursorSelection) {
|
|
132
|
-
// const nextSelectionFrom = tr.doc.resolve($from.pos - offset);
|
|
133
|
-
// return new GapCursorSelection(nextSelectionFrom, normalizedSelection.side);
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
if (originalSelection instanceof _prosemirrorState.NodeSelection) {
|
|
137
|
-
return _prosemirrorState.NodeSelection.create(tr.doc, $from.pos - offset);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
var _Selection$near = _prosemirrorState.Selection.near(tr.doc.resolve($from.pos - offset)),
|
|
141
|
-
nextSelectionFrom = _Selection$near.$from;
|
|
142
|
-
|
|
143
|
-
var _Selection$near2 = _prosemirrorState.Selection.near(tr.doc.resolve($to.pos - offset), -1),
|
|
144
|
-
nextSelectionTo = _Selection$near2.$to;
|
|
145
|
-
|
|
146
|
-
return new _prosemirrorState.TextSelection(nextSelectionFrom, nextSelectionTo);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
var createIndentedListItemsSlice = function createIndentedListItemsSlice(_ref3) {
|
|
150
|
-
var tr = _ref3.tr,
|
|
151
|
-
from = _ref3.from,
|
|
152
|
-
to = _ref3.to,
|
|
153
|
-
listNodeType = _ref3.listNodeType,
|
|
154
|
-
range = _ref3.range;
|
|
155
|
-
var listItemsSlice = tr.doc.slice(from, to - 2);
|
|
156
|
-
|
|
157
|
-
var listFragment = _prosemirrorModel.Fragment.from(listNodeType.create(null, listItemsSlice.content));
|
|
158
|
-
|
|
159
|
-
var nonSelectedListItemsSlice = tr.doc.slice(to, range.end - 2);
|
|
160
|
-
var openStart = tr.doc.slice(from - 1, range.end).openStart;
|
|
161
|
-
var slice = new _prosemirrorModel.Slice(listFragment, openStart, 0);
|
|
162
|
-
return [slice, nonSelectedListItemsSlice];
|
|
163
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.indentList = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
// adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L206:L231
|
|
13
|
-
var indentList = function indentList(tr) {
|
|
14
|
-
var _tr$selection = tr.selection,
|
|
15
|
-
$from = _tr$selection.$from,
|
|
16
|
-
$to = _tr$selection.$to;
|
|
17
|
-
var listItem = tr.doc.type.schema.nodes.listItem;
|
|
18
|
-
var range = $from.blockRange($to, function (node) {
|
|
19
|
-
return !!node.childCount && !!node.firstChild && node.firstChild.type === listItem;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (!range) {
|
|
23
|
-
return false;
|
|
24
|
-
} // get the index of the selected list item in the list it is part of
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var startIndex = range.startIndex;
|
|
28
|
-
|
|
29
|
-
if (startIndex === 0) {
|
|
30
|
-
return false;
|
|
31
|
-
} // get the parent list of the list item(s) in the selected range
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var parent = range.parent; // get the list immediately before the selection start
|
|
35
|
-
|
|
36
|
-
var previousListItem = parent.child(startIndex - 1);
|
|
37
|
-
|
|
38
|
-
if (previousListItem.type !== listItem) {
|
|
39
|
-
return false;
|
|
40
|
-
} // if that list was nested, join the selected list items into the same
|
|
41
|
-
// nested list; if not, create a new child list of the same type and
|
|
42
|
-
// nest it under the current level
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var isPreviousListNested = previousListItem.lastChild && ['bulletList', 'orderedList'].includes(previousListItem.lastChild.type.name);
|
|
46
|
-
|
|
47
|
-
var inner = _prosemirrorModel.Fragment.from(isPreviousListNested ? listItem.create() : undefined);
|
|
48
|
-
|
|
49
|
-
var nextListNodeType = isPreviousListNested ? previousListItem.lastChild.type : parent.type;
|
|
50
|
-
|
|
51
|
-
var nextListNodeContent = _prosemirrorModel.Fragment.from(nextListNodeType.create(null, inner));
|
|
52
|
-
|
|
53
|
-
var slice = new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(listItem.create(null, nextListNodeContent)), isPreviousListNested ? 3 : 1, 0);
|
|
54
|
-
var before = range.start;
|
|
55
|
-
var after = range.end;
|
|
56
|
-
tr.step(new _prosemirrorTransform.ReplaceAroundStep(before - (isPreviousListNested ? 3 : 1), after, before, after, slice, 1, true));
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
exports.indentList = indentList;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calcJoinListScenario = void 0;
|
|
7
|
-
|
|
8
|
-
var _node = require("../utils/node");
|
|
9
|
-
|
|
10
|
-
var _selection = require("../utils/selection");
|
|
11
|
-
|
|
12
|
-
var _joinListItemsScenarios = require("./join-list-items-scenarios");
|
|
13
|
-
|
|
14
|
-
// import { WalkNode } from '../../../utils/commands';
|
|
15
|
-
// import { LIST_TEXT_SCENARIOS } from '../../analytics';
|
|
16
|
-
var calcJoinListScenario = function calcJoinListScenario(walkNode, $head) {
|
|
17
|
-
var $next = walkNode.$pos,
|
|
18
|
-
nextFoundNode = walkNode.foundNode;
|
|
19
|
-
var headParent = $head.parent;
|
|
20
|
-
var headGrandParent = $head.node(-1);
|
|
21
|
-
var headInList = (0, _selection.isPosInsideList)($head);
|
|
22
|
-
var headInParagraph = (0, _selection.isPosInsideParagraph)($head);
|
|
23
|
-
var headInLastNonListChild = headGrandParent && headGrandParent.lastChild && (headGrandParent.lastChild === headParent || headGrandParent.childCount > 1 && headGrandParent.child(headGrandParent.childCount - 2) === headParent && //find the second last child if a list item may be the last child
|
|
24
|
-
(0, _node.isListNode)(headGrandParent.lastChild));
|
|
25
|
-
var nextInList = (0, _selection.isPosInsideList)($next);
|
|
26
|
-
var nextInParagraph = (0, _selection.isPosInsideParagraph)($next);
|
|
27
|
-
|
|
28
|
-
if (!headInList && headInParagraph && nextInList) {
|
|
29
|
-
return _joinListItemsScenarios.joinListItemWithParagraph;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!nextFoundNode || !headInList || !headInParagraph || !headInLastNonListChild) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!nextInList && nextInParagraph) {
|
|
37
|
-
return _joinListItemsScenarios.joinParagrapWithList;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!nextInList) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var nextNodeAfter = $next.nodeAfter;
|
|
45
|
-
var nextGrandParent = $next.node(-1);
|
|
46
|
-
var headGreatGrandParent = $head.node(-2);
|
|
47
|
-
var nextInListItem = (0, _node.isListItemNode)($next.parent);
|
|
48
|
-
var nextNodeAfterListItem = (0, _node.isListItemNode)(nextNodeAfter);
|
|
49
|
-
var nextListItemHasFirstChildParagraph = nextNodeAfter && //Redundant check but the linter complains otherwise
|
|
50
|
-
nextNodeAfterListItem && (0, _node.isParagraphNode)(nextNodeAfter.firstChild);
|
|
51
|
-
|
|
52
|
-
if (!nextInListItem && nextListItemHasFirstChildParagraph) {
|
|
53
|
-
return _joinListItemsScenarios.joinNestedListWithParentListItem;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!nextInListItem) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var nextParentSiblingOfHeadParent = nextGrandParent && nextGrandParent === headGreatGrandParent;
|
|
61
|
-
var nextNodeAfterIsParagraph = (0, _node.isParagraphNode)(nextNodeAfter);
|
|
62
|
-
|
|
63
|
-
if (!nextNodeAfterIsParagraph) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (nextParentSiblingOfHeadParent) {
|
|
68
|
-
return _joinListItemsScenarios.joinSiblingListItems;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return _joinListItemsScenarios.joinListItemWithParentNestedList;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
exports.calcJoinListScenario = calcJoinListScenario;
|
package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/index.js
DELETED
|
@@ -1,45 +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
|
-
|
|
37
|
-
var _joinParagraphWithList = require("./join-paragraph-with-list");
|
|
38
|
-
|
|
39
|
-
var _joinSiblingListItems = require("./join-sibling-list-items");
|
|
40
|
-
|
|
41
|
-
var _joinNestedListWithParentListItem = require("./join-nested-list-with-parent-list-item");
|
|
42
|
-
|
|
43
|
-
var _joinListItemWithParentNestedList = require("./join-list-item-with-parent-nested-list");
|
|
44
|
-
|
|
45
|
-
var _joinListItemWithParagraph = require("./join-list-item-with-paragraph");
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinListItemWithParagraph = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
9
|
-
|
|
10
|
-
var _commond = require("../../commond");
|
|
11
|
-
|
|
12
|
-
var _node = require("../../utils/node");
|
|
13
|
-
|
|
14
|
-
// Case for when a users selection is at the end of a paragraph, the paragraph
|
|
15
|
-
// is followed by a list, and they delete forward
|
|
16
|
-
var joinListItemWithParagraph = function joinListItemWithParagraph(_ref) {
|
|
17
|
-
var tr = _ref.tr,
|
|
18
|
-
$next = _ref.$next,
|
|
19
|
-
$head = _ref.$head;
|
|
20
|
-
|
|
21
|
-
// For empty paragraphs before a list
|
|
22
|
-
if ($head.parent.content.size < 1) {
|
|
23
|
-
(0, _commond.insertContentDeleteRange)(tr, function (tr) {
|
|
24
|
-
return tr.doc.resolve($head.pos);
|
|
25
|
-
}, [], [[$head.pos - 1, $head.pos]]);
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var paragraphPosition = $head.pos;
|
|
30
|
-
var list = tr.doc.nodeAt($next.pos - 1);
|
|
31
|
-
var firstListItem = tr.doc.nodeAt($next.pos);
|
|
32
|
-
|
|
33
|
-
if (!list || !firstListItem) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var firstChildNodeOfFirstListItem = firstListItem.firstChild;
|
|
38
|
-
|
|
39
|
-
if (!firstChildNodeOfFirstListItem) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
var lastChildOfFirstListItem = firstListItem.lastChild;
|
|
44
|
-
var firstGrandchildOfFirstListItem = firstChildNodeOfFirstListItem.firstChild;
|
|
45
|
-
var firstListItemHasOneChildWithNoNestedLists = hasSingleChild(firstListItem) && firstChildNodeOfFirstListItem.childCount < 2 && $next.nodeAfter;
|
|
46
|
-
var firstListItemContainsParagraphAndNestedList = !hasSingleChild(firstListItem) && lastChildOfFirstListItem && (0, _node.isListNode)(lastChildOfFirstListItem);
|
|
47
|
-
var insertions = [];
|
|
48
|
-
var deletions = []; // For lists that only have one list item with no children - need to remove remaining list
|
|
49
|
-
|
|
50
|
-
if (hasSingleChild(list) && hasSingleChild(firstListItem) && $next.nodeAfter) {
|
|
51
|
-
deletions.push([tr.mapping.map($next.pos - 1), tr.mapping.map($next.pos + $next.nodeAfter.nodeSize + 1)]);
|
|
52
|
-
} // For first list items that have a paragraph and a list
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (firstListItemContainsParagraphAndNestedList) {
|
|
56
|
-
var firstListItemNestedList = _prosemirrorModel.Fragment.from(lastChildOfFirstListItem.content);
|
|
57
|
-
|
|
58
|
-
insertions.push([firstListItemNestedList, tr.mapping.map($next.pos)]);
|
|
59
|
-
} // For first list item has one child & no nested lists OR first list items that have a paragraph and a list
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (firstListItemHasOneChildWithNoNestedLists || firstListItemContainsParagraphAndNestedList) {
|
|
63
|
-
deletions.push([tr.mapping.map($next.pos), tr.mapping.map($next.pos + firstListItem.nodeSize - 1)]);
|
|
64
|
-
|
|
65
|
-
var firstListItemText = _prosemirrorModel.Fragment.from(firstChildNodeOfFirstListItem.content);
|
|
66
|
-
|
|
67
|
-
insertions.push([firstListItemText, paragraphPosition]);
|
|
68
|
-
(0, _commond.insertContentDeleteRange)(tr, function (tr) {
|
|
69
|
-
return tr.doc.resolve($head.pos);
|
|
70
|
-
}, insertions, deletions);
|
|
71
|
-
return true;
|
|
72
|
-
} // For any first list items that have multiple children (eg. multiple paragraphs)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (firstListItem.childCount > 1) {
|
|
76
|
-
insertions.push([_prosemirrorModel.Fragment.from(firstChildNodeOfFirstListItem.content), paragraphPosition]);
|
|
77
|
-
deletions.push([tr.mapping.map($next.pos + 1), tr.mapping.map($next.pos + firstChildNodeOfFirstListItem.nodeSize + 1)]);
|
|
78
|
-
(0, _commond.insertContentDeleteRange)(tr, function (tr) {
|
|
79
|
-
return tr.doc.resolve($head.pos);
|
|
80
|
-
}, insertions, deletions);
|
|
81
|
-
return true;
|
|
82
|
-
} // For any remaining first list items that have a single child (eg. single paragraph, multiple lines of text)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (firstGrandchildOfFirstListItem && firstGrandchildOfFirstListItem.type.name === 'hardBreak') {
|
|
86
|
-
var nodeSizeOfGrandchild = firstGrandchildOfFirstListItem ? firstGrandchildOfFirstListItem.nodeSize : 0;
|
|
87
|
-
deletions.push([tr.mapping.map($next.pos + 2), tr.mapping.map($next.pos + 2 + nodeSizeOfGrandchild)]);
|
|
88
|
-
} else {
|
|
89
|
-
insertions.push([_prosemirrorModel.Fragment.from(firstChildNodeOfFirstListItem.content), paragraphPosition]);
|
|
90
|
-
var nodeSizeOfFirstChild = firstChildNodeOfFirstListItem.nodeSize;
|
|
91
|
-
deletions.push([tr.mapping.map($next.pos), tr.mapping.map($next.pos + 2 + nodeSizeOfFirstChild)]);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
(0, _commond.insertContentDeleteRange)(tr, function (tr) {
|
|
95
|
-
return tr.doc.resolve($head.pos);
|
|
96
|
-
}, insertions, deletions);
|
|
97
|
-
return true;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
exports.joinListItemWithParagraph = joinListItemWithParagraph;
|
|
101
|
-
|
|
102
|
-
var hasSingleChild = function hasSingleChild(node) {
|
|
103
|
-
return node.childCount === 1;
|
|
104
|
-
};
|