@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,398 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.enterKeyCommand = exports.deleteKeyCommand = exports.backspaceKeyCommand = void 0;
|
|
9
|
-
Object.defineProperty(exports, "indentList", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function get() {
|
|
12
|
-
return _indentList.indentList;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
exports.insertContentDeleteRange = void 0;
|
|
16
|
-
Object.defineProperty(exports, "outdentList", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
return _outdentList.outdentList;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
exports.rootListDepth = void 0;
|
|
23
|
-
exports.toggleBulletList = toggleBulletList;
|
|
24
|
-
exports.toggleList = toggleList;
|
|
25
|
-
exports.toggleOrderedList = toggleOrderedList;
|
|
26
|
-
|
|
27
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
28
|
-
|
|
29
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
30
|
-
|
|
31
|
-
var baseCommand = _interopRequireWildcard(require("prosemirror-commands"));
|
|
32
|
-
|
|
33
|
-
var _prosemirrorUtils = require("prosemirror-utils");
|
|
34
|
-
|
|
35
|
-
var _document = require("../../../../utils/document");
|
|
36
|
-
|
|
37
|
-
var _commands = require("../../../../utils/commands");
|
|
38
|
-
|
|
39
|
-
var _mark = require("../../../../utils/mark");
|
|
40
|
-
|
|
41
|
-
var _transforms = require("../transforms");
|
|
42
|
-
|
|
43
|
-
var _selection = require("../utils/selection");
|
|
44
|
-
|
|
45
|
-
var _listBackspace = require("./listBackspace");
|
|
46
|
-
|
|
47
|
-
var _joinListItemForward = require("./join-list-item-forward");
|
|
48
|
-
|
|
49
|
-
var _conversions = require("../actions/conversions");
|
|
50
|
-
|
|
51
|
-
var _wrapAndJoinLists = require("../actions/wrap-and-join-lists");
|
|
52
|
-
|
|
53
|
-
var _outdentList = require("./outdent-list");
|
|
54
|
-
|
|
55
|
-
var _indentList = require("./indent-list");
|
|
56
|
-
|
|
57
|
-
var _replaceContent = require("../utils/replace-content");
|
|
58
|
-
|
|
59
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
60
|
-
|
|
61
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
62
|
-
|
|
63
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
64
|
-
|
|
65
|
-
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."); }
|
|
66
|
-
|
|
67
|
-
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); }
|
|
68
|
-
|
|
69
|
-
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; }
|
|
70
|
-
|
|
71
|
-
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; }
|
|
72
|
-
|
|
73
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
74
|
-
|
|
75
|
-
// export type InputMethod = INPUT_METHOD.KEYBOARD | INPUT_METHOD.TOOLBAR;
|
|
76
|
-
var enterKeyCommand = function enterKeyCommand(state, dispatch) {
|
|
77
|
-
var selection = state.selection;
|
|
78
|
-
|
|
79
|
-
if (selection.empty) {
|
|
80
|
-
var $from = selection.$from;
|
|
81
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
82
|
-
listItem = _state$schema$nodes.listItem,
|
|
83
|
-
codeBlock = _state$schema$nodes.codeBlock;
|
|
84
|
-
var node = $from.node($from.depth);
|
|
85
|
-
var wrapper = $from.node($from.depth - 1);
|
|
86
|
-
|
|
87
|
-
if (wrapper && wrapper.type === listItem) {
|
|
88
|
-
/** Check if the wrapper has any visible content */
|
|
89
|
-
var wrapperHasContent = (0, _document.hasVisibleContent)(wrapper);
|
|
90
|
-
|
|
91
|
-
if ((0, _document.isNodeEmpty)(node) && !wrapperHasContent) {
|
|
92
|
-
return (0, _outdentList.outdentList)()(state, dispatch);
|
|
93
|
-
} else if (!(0, _prosemirrorUtils.hasParentNodeOfType)(codeBlock)(selection)) {
|
|
94
|
-
return splitListItem(listItem)(state, dispatch);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return false;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
exports.enterKeyCommand = enterKeyCommand;
|
|
103
|
-
|
|
104
|
-
var backspaceKeyCommand = function backspaceKeyCommand(state, dispatch) {
|
|
105
|
-
return baseCommand.chainCommands(_listBackspace.listBackspace, // if we're at the start of a list item, we need to either backspace
|
|
106
|
-
// directly to an empty list item above, or outdent this node
|
|
107
|
-
(0, _commands.filter)([function (state) {
|
|
108
|
-
return state.selection.empty;
|
|
109
|
-
}, // list items might have multiple paragraphs; only do this at the first one
|
|
110
|
-
_commands.isFirstChildOfParent, _selection.isInsideListItem], baseCommand.chainCommands(deletePreviousEmptyListItem, (0, _outdentList.outdentList)())), // if we're just inside a paragraph node (or gapcursor is shown) and backspace, then try to join
|
|
111
|
-
// the text to the previous list item, if one exists
|
|
112
|
-
(0, _commands.filter)([function (state) {
|
|
113
|
-
return state.selection.empty;
|
|
114
|
-
}, _selection.canJoinToPreviousListItem], joinToPreviousListItem))(state, dispatch);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
exports.backspaceKeyCommand = backspaceKeyCommand;
|
|
118
|
-
var deleteKeyCommand = _joinListItemForward.joinListItemForward; // Get the depth of the nearest ancestor list
|
|
119
|
-
|
|
120
|
-
exports.deleteKeyCommand = deleteKeyCommand;
|
|
121
|
-
|
|
122
|
-
var rootListDepth = function rootListDepth(pos, nodes) {
|
|
123
|
-
var bulletList = nodes.bulletList,
|
|
124
|
-
orderedList = nodes.orderedList,
|
|
125
|
-
listItem = nodes.listItem;
|
|
126
|
-
var depth;
|
|
127
|
-
|
|
128
|
-
for (var i = pos.depth - 1; i > 0; i--) {
|
|
129
|
-
var node = pos.node(i);
|
|
130
|
-
|
|
131
|
-
if (node.type === bulletList || node.type === orderedList) {
|
|
132
|
-
depth = i;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
if (node.type !== bulletList && node.type !== orderedList && node.type !== listItem) {
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return depth;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
exports.rootListDepth = rootListDepth;
|
|
144
|
-
|
|
145
|
-
function untoggleSelectedList(tr) {
|
|
146
|
-
var _tr = tr,
|
|
147
|
-
selection = _tr.selection;
|
|
148
|
-
var depth = rootListDepth(selection.$to, tr.doc.type.schema.nodes);
|
|
149
|
-
tr = (0, _transforms.liftFollowingList)(selection.$to.pos, selection.$to.end(depth), depth || 0, tr);
|
|
150
|
-
tr = (0, _transforms.liftSelectionList)(selection, tr);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function toggleList(listType) {
|
|
154
|
-
return function (state, dispatch) {
|
|
155
|
-
var tr = state.tr;
|
|
156
|
-
var listInsideSelection = (0, _selection.selectionContainsList)(tr);
|
|
157
|
-
var listNodeType = state.schema.nodes[listType];
|
|
158
|
-
|
|
159
|
-
if (listInsideSelection) {
|
|
160
|
-
var selection = state.selection;
|
|
161
|
-
var fromNode = selection.$from.node(selection.$from.depth - 2);
|
|
162
|
-
var toNode = selection.$to.node(selection.$to.depth - 2);
|
|
163
|
-
|
|
164
|
-
if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type.name) === listType && (toNode === null || toNode === void 0 ? void 0 : toNode.type.name) === listType) {
|
|
165
|
-
var _tr2 = state.tr;
|
|
166
|
-
untoggleSelectedList(_tr2);
|
|
167
|
-
|
|
168
|
-
if (dispatch) {
|
|
169
|
-
dispatch(_tr2);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
(0, _conversions.convertListType)({
|
|
176
|
-
tr: tr,
|
|
177
|
-
nextListNodeType: listNodeType
|
|
178
|
-
});
|
|
179
|
-
} else {
|
|
180
|
-
// Need to have this before wrapInList so the wrapping is done with valid content
|
|
181
|
-
// For example, if trying to convert centre or right aligned paragraphs to lists
|
|
182
|
-
(0, _mark.sanitiseMarksInSelection)(tr, listNodeType);
|
|
183
|
-
(0, _wrapAndJoinLists.wrapInListAndJoin)(listNodeType, tr);
|
|
184
|
-
} // If document wasn't changed, return false from the command to indicate that the
|
|
185
|
-
// editing action failed
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (!tr.docChanged) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (dispatch) {
|
|
193
|
-
dispatch(tr);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return true;
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function toggleBulletList(view) {
|
|
201
|
-
return toggleList('bulletList')(view.state, view.dispatch);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function toggleOrderedList(view) {
|
|
205
|
-
return toggleList('orderedList')(view.state, view.dispatch);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Implementation taken and modified for our needs from PM
|
|
209
|
-
* @param itemType Node
|
|
210
|
-
* Splits the list items, specific implementation take from PM
|
|
211
|
-
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
function splitListItem(itemType) {
|
|
215
|
-
return function (state, dispatch) {
|
|
216
|
-
var ref = state.selection;
|
|
217
|
-
var $from = ref.$from;
|
|
218
|
-
var $to = ref.$to;
|
|
219
|
-
var node = ref.node;
|
|
220
|
-
|
|
221
|
-
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
|
|
222
|
-
return false;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
var grandParent = $from.node(-1);
|
|
226
|
-
|
|
227
|
-
if (grandParent.type !== itemType) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
/** --> The following line changed from the original PM implementation to allow list additions with multiple paragraphs */
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (grandParent.content.content.length <= 1 && $from.parent.content.size === 0 && !(grandParent.content.size === 0)) {
|
|
234
|
-
// In an empty block. If this is a nested list, the wrapping
|
|
235
|
-
// list item should be split. Otherwise, bail out and let next
|
|
236
|
-
// command handle lifting.
|
|
237
|
-
if ($from.depth === 2 || $from.node(-3).type !== itemType || $from.index(-2) !== $from.node(-2).childCount - 1) {
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (dispatch) {
|
|
242
|
-
var wrap = _prosemirrorModel.Fragment.empty;
|
|
243
|
-
var keepItem = $from.index(-1) > 0; // Build a fragment containing empty versions of the structure
|
|
244
|
-
// from the outer list item to the parent node of the cursor
|
|
245
|
-
|
|
246
|
-
for (var d = $from.depth - (keepItem ? 1 : 2); d >= $from.depth - 3; d--) {
|
|
247
|
-
wrap = _prosemirrorModel.Fragment.from($from.node(d).copy(wrap));
|
|
248
|
-
} // Add a second list item with an empty default start node
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
wrap = wrap.append(_prosemirrorModel.Fragment.from(itemType.createAndFill()));
|
|
252
|
-
var tr$1 = state.tr.replace($from.before(keepItem ? undefined : -1), $from.after(-3), new _prosemirrorModel.Slice(wrap, keepItem ? 3 : 2, 2));
|
|
253
|
-
tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve($from.pos + (keepItem ? 3 : 2))));
|
|
254
|
-
dispatch(tr$1.scrollIntoView());
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
var nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : undefined;
|
|
261
|
-
var tr = state.tr["delete"]($from.pos, $to.pos);
|
|
262
|
-
var types = nextType && [undefined, {
|
|
263
|
-
type: nextType
|
|
264
|
-
}];
|
|
265
|
-
|
|
266
|
-
if (dispatch) {
|
|
267
|
-
dispatch(tr.split($from.pos, 2, types).scrollIntoView());
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return true;
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
var deletePreviousEmptyListItem = function deletePreviousEmptyListItem(state, dispatch) {
|
|
275
|
-
var $from = state.selection.$from;
|
|
276
|
-
var listItem = state.schema.nodes.listItem;
|
|
277
|
-
var $cut = (0, _commands.findCutBefore)($from);
|
|
278
|
-
|
|
279
|
-
if (!$cut || !$cut.nodeBefore || !($cut.nodeBefore.type === listItem)) {
|
|
280
|
-
return false;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
var previousListItemEmpty = $cut.nodeBefore.childCount === 1 && $cut.nodeBefore.firstChild.nodeSize <= 2;
|
|
284
|
-
|
|
285
|
-
if (previousListItemEmpty) {
|
|
286
|
-
var tr = state.tr;
|
|
287
|
-
|
|
288
|
-
if (dispatch) {
|
|
289
|
-
dispatch(tr["delete"]($cut.pos - $cut.nodeBefore.nodeSize, $from.pos).scrollIntoView());
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return true;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return false;
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
var joinToPreviousListItem = function joinToPreviousListItem(state, dispatch) {
|
|
299
|
-
var $from = state.selection.$from;
|
|
300
|
-
var _state$schema$nodes2 = state.schema.nodes,
|
|
301
|
-
paragraph = _state$schema$nodes2.paragraph,
|
|
302
|
-
listItem = _state$schema$nodes2.listItem,
|
|
303
|
-
codeBlock = _state$schema$nodes2.codeBlock,
|
|
304
|
-
bulletList = _state$schema$nodes2.bulletList,
|
|
305
|
-
orderedList = _state$schema$nodes2.orderedList; // const isGapCursorShown = state.selection instanceof GapCursorSelection;
|
|
306
|
-
|
|
307
|
-
var $cutPos =
|
|
308
|
-
/*isGapCursorShown ? state.doc.resolve($from.pos + 1) :*/
|
|
309
|
-
$from;
|
|
310
|
-
var $cut = (0, _commands.findCutBefore)($cutPos);
|
|
311
|
-
|
|
312
|
-
if (!$cut) {
|
|
313
|
-
return false;
|
|
314
|
-
} // see if the containing node is a list
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if ($cut.nodeBefore && [bulletList, orderedList].indexOf($cut.nodeBefore.type) > -1) {
|
|
318
|
-
// and the node after this is a paragraph or a codeBlock
|
|
319
|
-
if ($cut.nodeAfter && ($cut.nodeAfter.type === paragraph || $cut.nodeAfter.type === codeBlock)) {
|
|
320
|
-
// find the nearest paragraph that precedes this node
|
|
321
|
-
var $lastNode = $cut.doc.resolve($cut.pos - 1);
|
|
322
|
-
|
|
323
|
-
while ($lastNode.parent.type !== paragraph) {
|
|
324
|
-
$lastNode = state.doc.resolve($lastNode.pos - 1);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
var tr = state.tr; // if (isGapCursorShown) {
|
|
328
|
-
// const nodeBeforePos = findPositionOfNodeBefore(tr.selection);
|
|
329
|
-
// if (typeof nodeBeforePos !== 'number') {
|
|
330
|
-
// return false;
|
|
331
|
-
// }
|
|
332
|
-
// // append the codeblock to the list node
|
|
333
|
-
// const list = $cut.nodeBefore.copy(
|
|
334
|
-
// $cut.nodeBefore.content.append(
|
|
335
|
-
// Fragment.from(listItem.createChecked({}, $cut.nodeAfter)),
|
|
336
|
-
// ),
|
|
337
|
-
// );
|
|
338
|
-
// tr.replaceWith(
|
|
339
|
-
// nodeBeforePos,
|
|
340
|
-
// $from.pos + $cut.nodeAfter.nodeSize,
|
|
341
|
-
// list,
|
|
342
|
-
// );
|
|
343
|
-
// } else {
|
|
344
|
-
|
|
345
|
-
var step = (0, _replaceContent.moveTargetIntoList)({
|
|
346
|
-
insertPosition: $lastNode.pos,
|
|
347
|
-
$target: $cut
|
|
348
|
-
}); // ED-13966: check if the step will cause an ProseMirror error
|
|
349
|
-
// if there's an error don't apply the step as it will might lead into a data loss.
|
|
350
|
-
// It doesn't play well with media being a leaf node.
|
|
351
|
-
|
|
352
|
-
var stepResult = state.tr.maybeStep(step);
|
|
353
|
-
|
|
354
|
-
if (stepResult.failed) {
|
|
355
|
-
return false;
|
|
356
|
-
} else {
|
|
357
|
-
tr = state.tr.step(step);
|
|
358
|
-
} // }
|
|
359
|
-
// find out if there's now another list following and join them
|
|
360
|
-
// as in, [list, p, list] => [list with p, list], and we want [joined list]
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
var $postCut = tr.doc.resolve(tr.mapping.map($cut.pos + $cut.nodeAfter.nodeSize));
|
|
364
|
-
|
|
365
|
-
if ($postCut.nodeBefore && $postCut.nodeAfter && $postCut.nodeBefore.type === $postCut.nodeAfter.type && [bulletList, orderedList].indexOf($postCut.nodeBefore.type) > -1) {
|
|
366
|
-
tr = tr.join($postCut.pos);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
if (dispatch) {
|
|
370
|
-
dispatch(tr.scrollIntoView());
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return true;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
return false;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
var insertContentDeleteRange = function insertContentDeleteRange(tr, getSelectionResolvedPos, insertions, deletions) {
|
|
381
|
-
insertions.forEach(function (contentInsert) {
|
|
382
|
-
var _contentInsert = _slicedToArray(contentInsert, 2),
|
|
383
|
-
content = _contentInsert[0],
|
|
384
|
-
pos = _contentInsert[1];
|
|
385
|
-
|
|
386
|
-
tr.insert(tr.mapping.map(pos), content);
|
|
387
|
-
});
|
|
388
|
-
deletions.forEach(function (deleteRange) {
|
|
389
|
-
var _deleteRange = _slicedToArray(deleteRange, 2),
|
|
390
|
-
firstPos = _deleteRange[0],
|
|
391
|
-
lastPos = _deleteRange[1];
|
|
392
|
-
|
|
393
|
-
tr["delete"](tr.mapping.map(firstPos), tr.mapping.map(lastPos));
|
|
394
|
-
});
|
|
395
|
-
tr.setSelection(new _prosemirrorState.TextSelection(getSelectionResolvedPos(tr)));
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
exports.insertContentDeleteRange = insertContentDeleteRange;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.joinListItemForward = void 0;
|
|
7
|
-
|
|
8
|
-
var _commands = require("../../../../utils/commands");
|
|
9
|
-
|
|
10
|
-
var _joinListItemsForward = require("../actions/join-list-items-forward");
|
|
11
|
-
|
|
12
|
-
var joinListItemForward = function joinListItemForward(state, dispatch) {
|
|
13
|
-
var tr = state.tr,
|
|
14
|
-
$head = state.selection.$head;
|
|
15
|
-
var walkNode = (0, _commands.walkNextNode)($head);
|
|
16
|
-
|
|
17
|
-
if (!(0, _commands.isEmptySelectionAtEnd)(state)) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
var scenarios = (0, _joinListItemsForward.calcJoinListScenario)(walkNode, $head);
|
|
22
|
-
|
|
23
|
-
if (!scenarios) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var action = scenarios;
|
|
28
|
-
var result = action({
|
|
29
|
-
tr: tr,
|
|
30
|
-
$next: walkNode.$pos,
|
|
31
|
-
$head: $head
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (!result) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (dispatch) {
|
|
39
|
-
dispatch(tr);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return true;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
exports.joinListItemForward = joinListItemForward;
|