@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,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.autoJoin = autoJoin;
|
|
7
|
-
exports.wrapInList = wrapInList;
|
|
8
|
-
exports.wrapInListAndJoin = wrapInListAndJoin;
|
|
9
|
-
|
|
10
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
11
|
-
|
|
12
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Wraps the selection in a list with the given type. If this results in
|
|
16
|
-
* two adjacent lists of the same type, those will be joined together.
|
|
17
|
-
*/
|
|
18
|
-
function wrapInListAndJoin(nodeType, tr) {
|
|
19
|
-
wrapInList(nodeType)(tr);
|
|
20
|
-
autoJoin(tr, function (before, after) {
|
|
21
|
-
return before.type === after.type && before.type === nodeType;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Wraps the selection in a list with the given type and attributes.
|
|
26
|
-
*
|
|
27
|
-
* Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L64-L89
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function wrapInList(listType, attrs) {
|
|
32
|
-
return function (tr) {
|
|
33
|
-
var _tr$selection = tr.selection,
|
|
34
|
-
$from = _tr$selection.$from,
|
|
35
|
-
$to = _tr$selection.$to;
|
|
36
|
-
var range = $from.blockRange($to);
|
|
37
|
-
var doJoin = false;
|
|
38
|
-
var outerRange = range;
|
|
39
|
-
|
|
40
|
-
if (!range) {
|
|
41
|
-
return false;
|
|
42
|
-
} // This is at the top of an existing list item
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (range.depth >= 2 && // @ts-ignore - missing type for compatibleContent
|
|
46
|
-
$from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex === 0) {
|
|
47
|
-
// Don't do anything if this is the top of the list
|
|
48
|
-
if ($from.index(range.depth - 1) === 0) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
var $insert = tr.doc.resolve(range.start - 2);
|
|
53
|
-
outerRange = new _prosemirrorModel.NodeRange($insert, $insert, range.depth);
|
|
54
|
-
|
|
55
|
-
if (range.endIndex < range.parent.childCount) {
|
|
56
|
-
range = new _prosemirrorModel.NodeRange($from, tr.doc.resolve($to.end(range.depth)), range.depth);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
doJoin = true;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var wrap = (0, _prosemirrorTransform.findWrapping)(outerRange, listType, attrs, range);
|
|
63
|
-
|
|
64
|
-
if (!wrap) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
tr = doWrapInList(tr, range, wrap, doJoin, listType);
|
|
69
|
-
return true;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Internal function used by wrapInList
|
|
74
|
-
*
|
|
75
|
-
* Adapted from https://github.com/ProseMirror/prosemirror-schema-list/blob/master/src/schema-list.js#L91-L112
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
80
|
-
var content = _prosemirrorModel.Fragment.empty;
|
|
81
|
-
|
|
82
|
-
for (var i = wrappers.length - 1; i >= 0; i--) {
|
|
83
|
-
content = _prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
tr.step(new _prosemirrorTransform.ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new _prosemirrorModel.Slice(content, 0, 0), wrappers.length, true));
|
|
87
|
-
var found = 0;
|
|
88
|
-
|
|
89
|
-
for (var _i = 0; _i < wrappers.length; _i++) {
|
|
90
|
-
if (wrappers[_i].type === listType) {
|
|
91
|
-
found = _i + 1;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
var splitDepth = wrappers.length - found;
|
|
96
|
-
var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0);
|
|
97
|
-
var parent = range.parent;
|
|
98
|
-
|
|
99
|
-
for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {
|
|
100
|
-
if (!first && (0, _prosemirrorTransform.canSplit)(tr.doc, splitPos, splitDepth)) {
|
|
101
|
-
tr.split(splitPos, splitDepth);
|
|
102
|
-
splitPos += 2 * splitDepth;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
splitPos += parent.child(_i2).nodeSize;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return tr;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Checks whether two adjacent nodes can be joined. If so, the document
|
|
112
|
-
* will be updated to join those nodes. If not, the original transaction
|
|
113
|
-
* remains untouched.
|
|
114
|
-
*
|
|
115
|
-
* Nodes are considered joinable if the `isJoinable` predicate returns true.
|
|
116
|
-
*
|
|
117
|
-
* Adapted from https://github.com/ProseMirror/prosemirror-commands/blob/master/src/commands.js#L597-L610
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
function autoJoin(tr, isJoinable) {
|
|
122
|
-
if (!tr.isGeneric) {
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
var ranges = [];
|
|
127
|
-
|
|
128
|
-
for (var i = 0; i < tr.mapping.maps.length; i++) {
|
|
129
|
-
var map = tr.mapping.maps[i];
|
|
130
|
-
|
|
131
|
-
for (var j = 0; j < ranges.length; j++) {
|
|
132
|
-
ranges[j] = map.map(ranges[j]);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
map.forEach(function (_s, _e, from, to) {
|
|
136
|
-
return ranges.push(from, to);
|
|
137
|
-
});
|
|
138
|
-
} // Figure out which joinable points exist inside those ranges,
|
|
139
|
-
// by checking all node boundaries in their parent nodes.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
var joinable = [];
|
|
143
|
-
|
|
144
|
-
for (var _i3 = 0; _i3 < ranges.length; _i3 += 2) {
|
|
145
|
-
var from = ranges[_i3];
|
|
146
|
-
var to = ranges[_i3 + 1];
|
|
147
|
-
var $from = tr.doc.resolve(from);
|
|
148
|
-
var depth = $from.sharedDepth(to);
|
|
149
|
-
var parent = $from.node(depth);
|
|
150
|
-
|
|
151
|
-
for (var index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {
|
|
152
|
-
var _after = parent.maybeChild(index);
|
|
153
|
-
|
|
154
|
-
if (!_after) {
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (index && joinable.indexOf(pos) === -1) {
|
|
159
|
-
var _before = parent.child(index - 1);
|
|
160
|
-
|
|
161
|
-
if (_before.type === _after.type && isJoinable(_before, _after)) {
|
|
162
|
-
joinable.push(pos);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
pos += _after.nodeSize;
|
|
167
|
-
}
|
|
168
|
-
} // Join the joinable points
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
joinable.sort(function (a, b) {
|
|
172
|
-
return a - b;
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
for (var _i4 = joinable.length - 1; _i4 >= 0; _i4--) {
|
|
176
|
-
if ((0, _prosemirrorTransform.canJoin)(tr.doc, joinable[_i4])) {
|
|
177
|
-
tr.join(joinable[_i4]);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.addListNodes = addListNodes;
|
|
7
|
-
exports.bulletList = void 0;
|
|
8
|
-
exports.liftListItem = liftListItem;
|
|
9
|
-
exports.orderedList = exports.listItem = void 0;
|
|
10
|
-
exports.sinkListItem = sinkListItem;
|
|
11
|
-
exports.splitListItem = splitListItem;
|
|
12
|
-
exports.wrapInList = wrapInList;
|
|
13
|
-
|
|
14
|
-
var _prosemirrorTransform = require("prosemirror-transform");
|
|
15
|
-
|
|
16
|
-
var _prosemirrorModel = require("prosemirror-model");
|
|
17
|
-
|
|
18
|
-
var olDOM = ["ol", 0],
|
|
19
|
-
ulDOM = ["ul", 0],
|
|
20
|
-
liDOM = ["li", 0]; // :: NodeSpec
|
|
21
|
-
// An ordered list [node spec](#model.NodeSpec). Has a single
|
|
22
|
-
// attribute, `order`, which determines the number at which the list
|
|
23
|
-
// starts counting, and defaults to 1. Represented as an `<ol>`
|
|
24
|
-
// element.
|
|
25
|
-
|
|
26
|
-
var orderedList = {
|
|
27
|
-
attrs: {
|
|
28
|
-
order: {
|
|
29
|
-
"default": 1
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
parseDOM: [{
|
|
33
|
-
tag: "ol",
|
|
34
|
-
getAttrs: function getAttrs(dom) {
|
|
35
|
-
return {
|
|
36
|
-
order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}],
|
|
40
|
-
toDOM: function toDOM(node) {
|
|
41
|
-
return node.attrs.order == 1 ? olDOM : ["ol", {
|
|
42
|
-
start: node.attrs.order
|
|
43
|
-
}, 0];
|
|
44
|
-
}
|
|
45
|
-
}; // :: NodeSpec
|
|
46
|
-
// A bullet list node spec, represented in the DOM as `<ul>`.
|
|
47
|
-
|
|
48
|
-
exports.orderedList = orderedList;
|
|
49
|
-
var bulletList = {
|
|
50
|
-
parseDOM: [{
|
|
51
|
-
tag: "ul"
|
|
52
|
-
}],
|
|
53
|
-
toDOM: function toDOM() {
|
|
54
|
-
return ulDOM;
|
|
55
|
-
}
|
|
56
|
-
}; // :: NodeSpec
|
|
57
|
-
// A list item (`<li>`) spec.
|
|
58
|
-
|
|
59
|
-
exports.bulletList = bulletList;
|
|
60
|
-
var listItem = {
|
|
61
|
-
parseDOM: [{
|
|
62
|
-
tag: "li"
|
|
63
|
-
}],
|
|
64
|
-
toDOM: function toDOM() {
|
|
65
|
-
return liDOM;
|
|
66
|
-
},
|
|
67
|
-
defining: true
|
|
68
|
-
};
|
|
69
|
-
exports.listItem = listItem;
|
|
70
|
-
|
|
71
|
-
function add(obj, props) {
|
|
72
|
-
var copy = {};
|
|
73
|
-
|
|
74
|
-
for (var prop in obj) {
|
|
75
|
-
copy[prop] = obj[prop];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
for (var _prop in props) {
|
|
79
|
-
copy[_prop] = props[_prop];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return copy;
|
|
83
|
-
} // :: (OrderedMap<NodeSpec>, string, ?string) → OrderedMap<NodeSpec>
|
|
84
|
-
// Convenience function for adding list-related node types to a map
|
|
85
|
-
// specifying the nodes for a schema. Adds
|
|
86
|
-
// [`orderedList`](#schema-list.orderedList) as `"ordered_list"`,
|
|
87
|
-
// [`bulletList`](#schema-list.bulletList) as `"bullet_list"`, and
|
|
88
|
-
// [`listItem`](#schema-list.listItem) as `"list_item"`.
|
|
89
|
-
//
|
|
90
|
-
// `itemContent` determines the content expression for the list items.
|
|
91
|
-
// If you want the commands defined in this module to apply to your
|
|
92
|
-
// list structure, it should have a shape like `"paragraph block*"` or
|
|
93
|
-
// `"paragraph (ordered_list | bullet_list)*"`. `listGroup` can be
|
|
94
|
-
// given to assign a group name to the list node types, for example
|
|
95
|
-
// `"block"`.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function addListNodes(nodes, itemContent, listGroup) {
|
|
99
|
-
return nodes.append({
|
|
100
|
-
ordered_list: add(orderedList, {
|
|
101
|
-
content: "list_item+",
|
|
102
|
-
group: listGroup
|
|
103
|
-
}),
|
|
104
|
-
bullet_list: add(bulletList, {
|
|
105
|
-
content: "list_item+",
|
|
106
|
-
group: listGroup
|
|
107
|
-
}),
|
|
108
|
-
list_item: add(listItem, {
|
|
109
|
-
content: itemContent
|
|
110
|
-
})
|
|
111
|
-
});
|
|
112
|
-
} // :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
113
|
-
// Returns a command function that wraps the selection in a list with
|
|
114
|
-
// the given type an attributes. If `dispatch` is null, only return a
|
|
115
|
-
// value to indicate whether this is possible, but don't actually
|
|
116
|
-
// perform the change.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function wrapInList(listType, attrs) {
|
|
120
|
-
return function (state, dispatch) {
|
|
121
|
-
var _state$selection = state.selection,
|
|
122
|
-
$from = _state$selection.$from,
|
|
123
|
-
$to = _state$selection.$to;
|
|
124
|
-
var range = $from.blockRange($to),
|
|
125
|
-
doJoin = false,
|
|
126
|
-
outerRange = range;
|
|
127
|
-
if (!range) return false; // This is at the top of an existing list item
|
|
128
|
-
|
|
129
|
-
if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex == 0) {
|
|
130
|
-
// Don't do anything if this is the top of the list
|
|
131
|
-
if ($from.index(range.depth - 1) == 0) return false;
|
|
132
|
-
var $insert = state.doc.resolve(range.start - 2);
|
|
133
|
-
outerRange = new _prosemirrorModel.NodeRange($insert, $insert, range.depth);
|
|
134
|
-
if (range.endIndex < range.parent.childCount) range = new _prosemirrorModel.NodeRange($from, state.doc.resolve($to.end(range.depth)), range.depth);
|
|
135
|
-
doJoin = true;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
var wrap = (0, _prosemirrorTransform.findWrapping)(outerRange, listType, attrs, range);
|
|
139
|
-
if (!wrap) return false;
|
|
140
|
-
if (dispatch) dispatch(doWrapInList(state.tr, range, wrap, doJoin, listType).scrollIntoView());
|
|
141
|
-
return true;
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function doWrapInList(tr, range, wrappers, joinBefore, listType) {
|
|
146
|
-
var content = _prosemirrorModel.Fragment.empty;
|
|
147
|
-
|
|
148
|
-
for (var i = wrappers.length - 1; i >= 0; i--) {
|
|
149
|
-
content = _prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
tr.step(new _prosemirrorTransform.ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new _prosemirrorModel.Slice(content, 0, 0), wrappers.length, true));
|
|
153
|
-
var found = 0;
|
|
154
|
-
|
|
155
|
-
for (var _i = 0; _i < wrappers.length; _i++) {
|
|
156
|
-
if (wrappers[_i].type == listType) found = _i + 1;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
var splitDepth = wrappers.length - found;
|
|
160
|
-
var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0),
|
|
161
|
-
parent = range.parent;
|
|
162
|
-
|
|
163
|
-
for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {
|
|
164
|
-
if (!first && (0, _prosemirrorTransform.canSplit)(tr.doc, splitPos, splitDepth)) {
|
|
165
|
-
tr.split(splitPos, splitDepth);
|
|
166
|
-
splitPos += 2 * splitDepth;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
splitPos += parent.child(_i2).nodeSize;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return tr;
|
|
173
|
-
} // :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
174
|
-
// Build a command that splits a non-empty textblock at the top level
|
|
175
|
-
// of a list item by also splitting that list item.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
function splitListItem(itemType) {
|
|
179
|
-
return function (state, dispatch) {
|
|
180
|
-
var _state$selection2 = state.selection,
|
|
181
|
-
$from = _state$selection2.$from,
|
|
182
|
-
$to = _state$selection2.$to,
|
|
183
|
-
node = _state$selection2.node;
|
|
184
|
-
if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) return false;
|
|
185
|
-
var grandParent = $from.node(-1);
|
|
186
|
-
if (grandParent.type != itemType) return false;
|
|
187
|
-
|
|
188
|
-
if ($from.parent.content.size == 0 && $from.node(-1).childCount == $from.indexAfter(-1)) {
|
|
189
|
-
// In an empty block. If this is a nested list, the wrapping
|
|
190
|
-
// list item should be split. Otherwise, bail out and let next
|
|
191
|
-
// command handle lifting.
|
|
192
|
-
if ($from.depth == 2 || $from.node(-3).type != itemType || $from.index(-2) != $from.node(-2).childCount - 1) return false;
|
|
193
|
-
|
|
194
|
-
if (dispatch) {
|
|
195
|
-
var wrap = _prosemirrorModel.Fragment.empty;
|
|
196
|
-
var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3; // Build a fragment containing empty versions of the structure
|
|
197
|
-
// from the outer list item to the parent node of the cursor
|
|
198
|
-
|
|
199
|
-
for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--) {
|
|
200
|
-
wrap = _prosemirrorModel.Fragment.from($from.node(d).copy(wrap));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3; // Add a second list item with an empty default start node
|
|
204
|
-
|
|
205
|
-
wrap = wrap.append(_prosemirrorModel.Fragment.from(itemType.createAndFill()));
|
|
206
|
-
var start = $from.before($from.depth - (depthBefore - 1));
|
|
207
|
-
|
|
208
|
-
var _tr = state.tr.replace(start, $from.after(-depthAfter), new _prosemirrorModel.Slice(wrap, 4 - depthBefore, 0));
|
|
209
|
-
|
|
210
|
-
var sel = -1;
|
|
211
|
-
|
|
212
|
-
_tr.doc.nodesBetween(start, _tr.doc.content.size, function (node, pos) {
|
|
213
|
-
if (sel > -1) return false;
|
|
214
|
-
if (node.isTextblock && node.content.size == 0) sel = pos + 1;
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
if (sel > -1) _tr.setSelection(state.selection.constructor.near(_tr.doc.resolve(sel)));
|
|
218
|
-
dispatch(_tr.scrollIntoView());
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
var nextType = $to.pos == $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
|
|
225
|
-
var tr = state.tr["delete"]($from.pos, $to.pos);
|
|
226
|
-
var types = nextType && [null, {
|
|
227
|
-
type: nextType
|
|
228
|
-
}];
|
|
229
|
-
if (!(0, _prosemirrorTransform.canSplit)(tr.doc, $from.pos, 2, types)) return false;
|
|
230
|
-
if (dispatch) dispatch(tr.split($from.pos, 2, types).scrollIntoView());
|
|
231
|
-
return true;
|
|
232
|
-
};
|
|
233
|
-
} // :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
234
|
-
// Create a command to lift the list item around the selection up into
|
|
235
|
-
// a wrapping list.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
function liftListItem(itemType) {
|
|
239
|
-
return function (state, dispatch) {
|
|
240
|
-
var _state$selection3 = state.selection,
|
|
241
|
-
$from = _state$selection3.$from,
|
|
242
|
-
$to = _state$selection3.$to;
|
|
243
|
-
var range = $from.blockRange($to, function (node) {
|
|
244
|
-
return node.childCount && node.firstChild.type == itemType;
|
|
245
|
-
});
|
|
246
|
-
if (!range) return false;
|
|
247
|
-
if (!dispatch) return true;
|
|
248
|
-
if ($from.node(range.depth - 1).type == itemType) // Inside a parent list
|
|
249
|
-
return liftToOuterList(state, dispatch, itemType, range);else // Outer list node
|
|
250
|
-
return liftOutOfList(state, dispatch, range);
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function liftToOuterList(state, dispatch, itemType, range) {
|
|
255
|
-
var tr = state.tr,
|
|
256
|
-
end = range.end,
|
|
257
|
-
endOfList = range.$to.end(range.depth);
|
|
258
|
-
|
|
259
|
-
if (end < endOfList) {
|
|
260
|
-
// There are siblings after the lifted items, which must become
|
|
261
|
-
// children of the last item
|
|
262
|
-
tr.step(new _prosemirrorTransform.ReplaceAroundStep(end - 1, endOfList, end, endOfList, new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));
|
|
263
|
-
range = new _prosemirrorModel.NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
dispatch(tr.lift(range, (0, _prosemirrorTransform.liftTarget)(range)).scrollIntoView());
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function liftOutOfList(state, dispatch, range) {
|
|
271
|
-
var tr = state.tr,
|
|
272
|
-
list = range.parent; // Merge the list items into a single big item
|
|
273
|
-
|
|
274
|
-
for (var pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {
|
|
275
|
-
pos -= list.child(i).nodeSize;
|
|
276
|
-
tr["delete"](pos - 1, pos + 1);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
var $start = tr.doc.resolve(range.start),
|
|
280
|
-
item = $start.nodeAfter;
|
|
281
|
-
if (tr.mapping.map(range.end) != range.start + $start.nodeAfter.nodeSize) return false;
|
|
282
|
-
var atStart = range.startIndex == 0,
|
|
283
|
-
atEnd = range.endIndex == list.childCount;
|
|
284
|
-
var parent = $start.node(-1),
|
|
285
|
-
indexBefore = $start.index(-1);
|
|
286
|
-
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? _prosemirrorModel.Fragment.empty : _prosemirrorModel.Fragment.from(list)))) return false;
|
|
287
|
-
var start = $start.pos,
|
|
288
|
-
end = start + item.nodeSize; // Strip off the surrounding list. At the sides where we're not at
|
|
289
|
-
// the end of the list, the existing list is closed. At sides where
|
|
290
|
-
// this is the end, it is overwritten to its end.
|
|
291
|
-
|
|
292
|
-
tr.step(new _prosemirrorTransform.ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new _prosemirrorModel.Slice((atStart ? _prosemirrorModel.Fragment.empty : _prosemirrorModel.Fragment.from(list.copy(_prosemirrorModel.Fragment.empty))).append(atEnd ? _prosemirrorModel.Fragment.empty : _prosemirrorModel.Fragment.from(list.copy(_prosemirrorModel.Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
|
|
293
|
-
dispatch(tr.scrollIntoView());
|
|
294
|
-
return true;
|
|
295
|
-
} // :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
296
|
-
// Create a command to sink the list item around the selection down
|
|
297
|
-
// into an inner list.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
function sinkListItem(itemType) {
|
|
301
|
-
return function (state, dispatch) {
|
|
302
|
-
var _state$selection4 = state.selection,
|
|
303
|
-
$from = _state$selection4.$from,
|
|
304
|
-
$to = _state$selection4.$to;
|
|
305
|
-
var range = $from.blockRange($to, function (node) {
|
|
306
|
-
return node.childCount && node.firstChild.type == itemType;
|
|
307
|
-
});
|
|
308
|
-
if (!range) return false;
|
|
309
|
-
var startIndex = range.startIndex;
|
|
310
|
-
if (startIndex == 0) return false;
|
|
311
|
-
var parent = range.parent,
|
|
312
|
-
nodeBefore = parent.child(startIndex - 1);
|
|
313
|
-
if (nodeBefore.type != itemType) return false;
|
|
314
|
-
|
|
315
|
-
if (dispatch) {
|
|
316
|
-
var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
|
|
317
|
-
|
|
318
|
-
var inner = _prosemirrorModel.Fragment.from(nestedBefore ? itemType.create() : null);
|
|
319
|
-
|
|
320
|
-
var slice = new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(itemType.create(null, _prosemirrorModel.Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
|
|
321
|
-
var before = range.start,
|
|
322
|
-
after = range.end;
|
|
323
|
-
dispatch(state.tr.step(new _prosemirrorTransform.ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return true;
|
|
327
|
-
};
|
|
328
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MAX_NESTED_LIST_INDENTATION = void 0;
|
|
7
|
-
exports.indentList = indentList;
|
|
8
|
-
|
|
9
|
-
var _indentation = require("../utils/indentation");
|
|
10
|
-
|
|
11
|
-
var _indentListItemsSelected = require("../actions/indent-list-items-selected");
|
|
12
|
-
|
|
13
|
-
var _find = require("../utils/find");
|
|
14
|
-
|
|
15
|
-
var _selection = require("../utils/selection");
|
|
16
|
-
|
|
17
|
-
// import { Command } from '../../../types';
|
|
18
|
-
var MAX_NESTED_LIST_INDENTATION = 6;
|
|
19
|
-
exports.MAX_NESTED_LIST_INDENTATION = MAX_NESTED_LIST_INDENTATION;
|
|
20
|
-
|
|
21
|
-
function indentList() {
|
|
22
|
-
return function (state, dispatch) {
|
|
23
|
-
var tr = state.tr,
|
|
24
|
-
$from = state.selection.$from; // don't indent if selection is not inside a list
|
|
25
|
-
|
|
26
|
-
if (!(0, _selection.isInsideListItem)(state)) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var firstListItemSelectedAttributes = (0, _selection.getListItemAttributes)($from);
|
|
31
|
-
var parentListNode = (0, _find.findFirstParentListNode)($from);
|
|
32
|
-
|
|
33
|
-
if (!parentListNode || firstListItemSelectedAttributes && firstListItemSelectedAttributes.indentLevel === 0 && firstListItemSelectedAttributes.itemIndex === 0) {
|
|
34
|
-
if ((0, _selection.isInsideTableCell)(state)) {
|
|
35
|
-
// dont consume tab, as table-keymap should move cursor to next cell
|
|
36
|
-
return false;
|
|
37
|
-
} else {
|
|
38
|
-
// Even though this is a non-operation, we don't want to send this event to the browser. Because if we return false, the browser will move the focus to another place
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
(0, _indentListItemsSelected.indentListItemsSelected)(tr);
|
|
44
|
-
var maximimunNestedLevelReached = !(0, _indentation.hasValidListIndentationLevel)({
|
|
45
|
-
tr: tr,
|
|
46
|
-
maxIndentation: MAX_NESTED_LIST_INDENTATION
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
if (maximimunNestedLevelReached || !tr.docChanged) {
|
|
50
|
-
// Even though this is a non-operation, we don't want to send this event to the browser. Because if we return false, the browser will move the focus to another place
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (dispatch) {
|
|
55
|
-
dispatch(tr);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return true;
|
|
59
|
-
};
|
|
60
|
-
}
|