@titaui/pc 1.10.44 → 1.10.45

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.
Files changed (104) hide show
  1. package/lib/components/rich-editor/basic/schema.js +47 -0
  2. package/lib/components/rich-editor/consts/events.js +12 -0
  3. package/lib/components/rich-editor/enums.js +42 -0
  4. package/lib/components/rich-editor/index.js +58 -0
  5. package/lib/components/rich-editor/keymap.js +119 -0
  6. package/lib/components/rich-editor/keymaps/index.js +241 -0
  7. package/lib/components/rich-editor/models/controller.js +18 -0
  8. package/lib/components/rich-editor/models/editor.js +47 -0
  9. package/lib/components/rich-editor/models/plugin.js +20 -0
  10. package/lib/components/rich-editor/models/schema.js +121 -0
  11. package/lib/components/rich-editor/plugins/block/block-quote/commond.js +27 -0
  12. package/lib/components/rich-editor/plugins/block/block-quote/index.js +126 -0
  13. package/lib/components/rich-editor/plugins/block/heading/commonds.js +31 -0
  14. package/lib/components/rich-editor/plugins/block/heading/index.js +188 -0
  15. package/lib/components/rich-editor/plugins/block/index.js +57 -0
  16. package/lib/components/rich-editor/plugins/block/lists/actions/conversions.js +172 -0
  17. package/lib/components/rich-editor/plugins/block/lists/actions/indent-list-items-selected.js +163 -0
  18. package/lib/components/rich-editor/plugins/block/lists/actions/indent-list.js +59 -0
  19. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-forward.js +74 -0
  20. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/index.js +45 -0
  21. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-paragraph.js +104 -0
  22. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-list-item-with-parent-nested-list.js +92 -0
  23. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-nested-list-with-parent-list-item.js +89 -0
  24. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-paragraph-with-list.js +48 -0
  25. package/lib/components/rich-editor/plugins/block/lists/actions/join-list-items-scenarios/join-sibling-list-items.js +61 -0
  26. package/lib/components/rich-editor/plugins/block/lists/actions/merge-lists.js +34 -0
  27. package/lib/components/rich-editor/plugins/block/lists/actions/outdent-list-items-selected.js +289 -0
  28. package/lib/components/rich-editor/plugins/block/lists/actions/wrap-and-join-lists.js +180 -0
  29. package/lib/components/rich-editor/plugins/block/lists/baseCommand.js +328 -0
  30. package/lib/components/rich-editor/plugins/block/lists/commond/indent-list.js +60 -0
  31. package/lib/components/rich-editor/plugins/block/lists/commond/index.js +396 -0
  32. package/lib/components/rich-editor/plugins/block/lists/commond/join-list-item-forward.js +45 -0
  33. package/lib/components/rich-editor/plugins/block/lists/commond/listBackspace.js +302 -0
  34. package/lib/components/rich-editor/plugins/block/lists/commond/outdent-list.js +43 -0
  35. package/lib/components/rich-editor/plugins/block/lists/index.js +222 -0
  36. package/lib/components/rich-editor/plugins/block/lists/messages.js +38 -0
  37. package/lib/components/rich-editor/plugins/block/lists/pm-plugins/input-rule.js +152 -0
  38. package/lib/components/rich-editor/plugins/block/lists/pm-plugins/keymap.js +33 -0
  39. package/lib/components/rich-editor/plugins/block/lists/pm-plugins/main.js +94 -0
  40. package/lib/components/rich-editor/plugins/block/lists/styles.js +15 -0
  41. package/lib/components/rich-editor/plugins/block/lists/transforms.js +347 -0
  42. package/lib/components/rich-editor/plugins/block/lists/utils/analytics.js +48 -0
  43. package/lib/components/rich-editor/plugins/block/lists/utils/find.js +126 -0
  44. package/lib/components/rich-editor/plugins/block/lists/utils/indentation.js +87 -0
  45. package/lib/components/rich-editor/plugins/block/lists/utils/node.js +144 -0
  46. package/lib/components/rich-editor/plugins/block/lists/utils/replace-content.js +31 -0
  47. package/lib/components/rich-editor/plugins/block/lists/utils/selection.js +201 -0
  48. package/lib/components/rich-editor/plugins/block/lists/utils.js +52 -0
  49. package/lib/components/rich-editor/plugins/block/paragraph/index.js +91 -0
  50. package/lib/components/rich-editor/plugins/core/index.js +90 -0
  51. package/lib/components/rich-editor/plugins/core/pm-plugins/focus-handler.js +67 -0
  52. package/lib/components/rich-editor/plugins/core/pm-plugins/keymap.js +29 -0
  53. package/lib/components/rich-editor/plugins/core/pm-plugins/reactNodeView.js +80 -0
  54. package/lib/components/rich-editor/plugins/extension/alignment/commond.js +24 -0
  55. package/lib/components/rich-editor/plugins/extension/alignment/index.js +111 -0
  56. package/lib/components/rich-editor/plugins/extension/alignment/utils.js +19 -0
  57. package/lib/components/rich-editor/plugins/extension/index.js +18 -0
  58. package/lib/components/rich-editor/plugins/index.js +44 -0
  59. package/lib/components/rich-editor/plugins/inline/color/commond.js +128 -0
  60. package/lib/components/rich-editor/plugins/inline/color/consts.js +43 -0
  61. package/lib/components/rich-editor/plugins/inline/color/index.css +61 -0
  62. package/lib/components/rich-editor/plugins/inline/color/index.js +209 -0
  63. package/lib/components/rich-editor/plugins/inline/color/selector.js +250 -0
  64. package/lib/components/rich-editor/plugins/inline/delete-line/index.js +147 -0
  65. package/lib/components/rich-editor/plugins/inline/em/index.js +93 -0
  66. package/lib/components/rich-editor/plugins/inline/index.js +83 -0
  67. package/lib/components/rich-editor/plugins/inline/link/commands.js +256 -0
  68. package/lib/components/rich-editor/plugins/inline/link/index.js +149 -0
  69. package/lib/components/rich-editor/plugins/inline/link/pm-plugins/fake-cursor-for-toolbar.js +77 -0
  70. package/lib/components/rich-editor/plugins/inline/link/pm-plugins/main.js +293 -0
  71. package/lib/components/rich-editor/plugins/inline/link/ui/index.css +79 -0
  72. package/lib/components/rich-editor/plugins/inline/link/ui/linkEditor.js +148 -0
  73. package/lib/components/rich-editor/plugins/inline/link/ui/linkToolbar.js +88 -0
  74. package/lib/components/rich-editor/plugins/inline/link/ui/toolbarBtn.js +117 -0
  75. package/lib/components/rich-editor/plugins/inline/link/utils.js +33 -0
  76. package/lib/components/rich-editor/plugins/inline/strong/index.js +137 -0
  77. package/lib/components/rich-editor/plugins/inline/under-line/index.js +145 -0
  78. package/lib/components/rich-editor/plugins/util.js +281 -0
  79. package/lib/components/rich-editor/react/reactNodeView.js +383 -0
  80. package/lib/components/rich-editor/react/uiProvider.js +185 -0
  81. package/lib/components/rich-editor/schemas/basic.js +309 -0
  82. package/lib/components/rich-editor/schemas/index.js +19 -0
  83. package/lib/components/rich-editor/schemas/list.js +342 -0
  84. package/lib/components/rich-editor/types/commond.js +5 -0
  85. package/lib/components/rich-editor/types/index.js +18 -0
  86. package/lib/components/rich-editor/ui/Popup/index.js +247 -0
  87. package/lib/components/rich-editor/ui/Popup/utils.js +399 -0
  88. package/lib/components/rich-editor/ui/editor/index.css +144 -0
  89. package/lib/components/rich-editor/ui/editor/index.js +143 -0
  90. package/lib/components/rich-editor/ui/normal-toolbar/index.css +29 -0
  91. package/lib/components/rich-editor/ui/normal-toolbar/index.js +109 -0
  92. package/lib/components/rich-editor/utils/browser.js +35 -0
  93. package/lib/components/rich-editor/utils/commands.js +266 -0
  94. package/lib/components/rich-editor/utils/document.js +160 -0
  95. package/lib/components/rich-editor/utils/event.js +79 -0
  96. package/lib/components/rich-editor/utils/helpers.js +16 -0
  97. package/lib/components/rich-editor/utils/mark.js +168 -0
  98. package/lib/components/rich-editor/utils/slice.js +85 -0
  99. package/lib/components/rich-editor/utils/toolbar.js +228 -0
  100. package/lib/components/upload/index.js +4 -2
  101. package/lib/components/upload/util.js +2 -0
  102. package/lib/index.js +8 -0
  103. package/package.json +20 -2
  104. package/yarn-error.log +22184 -0
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.schema = exports.nodes = exports.marks = void 0;
7
+
8
+ var _prosemirrorModel = require("prosemirror-model");
9
+
10
+ var blockquoteDOM = ["blockquote", 0];
11
+ var hrDOM = ["hr"];
12
+ var preDOM = ["pre", ["code", 0]];
13
+ var brDOM = ["br"]; // :: Object
14
+ // [Specs](#model.NodeSpec) for the nodes defined in this schema.
15
+
16
+ var nodes = {
17
+ // :: NodeSpec The top level document node.
18
+ doc: {
19
+ content: "block+"
20
+ },
21
+ // :: NodeSpec A plain paragraph textblock. Represented in the DOM
22
+ // as a `<p>` element.
23
+ paragraph: {
24
+ content: "inline*",
25
+ attrs: {
26
+ textAlign: {
27
+ "default": 'left'
28
+ }
29
+ },
30
+ group: "block",
31
+ parseDOM: [{
32
+ tag: "p"
33
+ }],
34
+ toDOM: function toDOM(node) {
35
+ return ["p", {
36
+ style: "text-align:".concat(node.attrs["textAlign"])
37
+ }, 0];
38
+ }
39
+ },
40
+ // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
41
+ blockquote: {
42
+ content: "block+",
43
+ group: "block",
44
+ defining: true,
45
+ parseDOM: [{
46
+ tag: "blockquote"
47
+ }],
48
+ toDOM: function toDOM() {
49
+ return blockquoteDOM;
50
+ }
51
+ },
52
+ // :: NodeSpec A horizontal rule (`<hr>`).
53
+ horizontal_rule: {
54
+ group: "block",
55
+ parseDOM: [{
56
+ tag: "hr"
57
+ }],
58
+ toDOM: function toDOM() {
59
+ return hrDOM;
60
+ }
61
+ },
62
+ // :: NodeSpec A heading textblock, with a `level` attribute that
63
+ // should hold the number 1 to 6. Parsed and serialized as `<h1>` to
64
+ // `<h6>` elements.
65
+ heading: {
66
+ attrs: {
67
+ level: {
68
+ "default": 1
69
+ },
70
+ textAlign: {
71
+ "default": 'left'
72
+ }
73
+ },
74
+ content: "inline*",
75
+ group: "block",
76
+ defining: true,
77
+ parseDOM: [{
78
+ tag: "h1",
79
+ attrs: {
80
+ level: 1
81
+ }
82
+ }, {
83
+ tag: "h2",
84
+ attrs: {
85
+ level: 2
86
+ }
87
+ }, {
88
+ tag: "h3",
89
+ attrs: {
90
+ level: 3
91
+ }
92
+ }, {
93
+ tag: "h4",
94
+ attrs: {
95
+ level: 4
96
+ }
97
+ }, {
98
+ tag: "h5",
99
+ attrs: {
100
+ level: 5
101
+ }
102
+ }, {
103
+ tag: "h6",
104
+ attrs: {
105
+ level: 6
106
+ }
107
+ }],
108
+ toDOM: function toDOM(node) {
109
+ return ["h".concat(node.attrs.level), {
110
+ style: "text-align:".concat(node.attrs["textAlign"])
111
+ }, 0];
112
+ }
113
+ },
114
+ // :: NodeSpec A code listing. Disallows marks or non-text inline
115
+ // nodes by default. Represented as a `<pre>` element with a
116
+ // `<code>` element inside of it.
117
+ code_block: {
118
+ content: "text*",
119
+ marks: "",
120
+ group: "block",
121
+ code: true,
122
+ defining: true,
123
+ parseDOM: [{
124
+ tag: "pre",
125
+ preserveWhitespace: "full"
126
+ }],
127
+ toDOM: function toDOM() {
128
+ return preDOM;
129
+ }
130
+ },
131
+ // :: NodeSpec The text node.
132
+ text: {
133
+ group: "inline"
134
+ },
135
+ // :: NodeSpec An inline image (`<img>`) node. Supports `src`,
136
+ // `alt`, and `href` attributes. The latter two default to the empty
137
+ // string.
138
+ image: {
139
+ inline: true,
140
+ attrs: {
141
+ src: {},
142
+ alt: {
143
+ "default": null
144
+ },
145
+ title: {
146
+ "default": null
147
+ }
148
+ },
149
+ group: "inline",
150
+ draggable: true,
151
+ parseDOM: [{
152
+ tag: "img[src]",
153
+ getAttrs: function getAttrs(dom) {
154
+ return {
155
+ src: dom.getAttribute("src"),
156
+ title: dom.getAttribute("title"),
157
+ alt: dom.getAttribute("alt")
158
+ };
159
+ }
160
+ }],
161
+ toDOM: function toDOM(node) {
162
+ var _node$attrs = node.attrs,
163
+ src = _node$attrs.src,
164
+ alt = _node$attrs.alt,
165
+ title = _node$attrs.title;
166
+ return ["img", {
167
+ src: src,
168
+ alt: alt,
169
+ title: title
170
+ }];
171
+ }
172
+ },
173
+ // :: NodeSpec A hard line break, represented in the DOM as `<br>`.
174
+ hard_break: {
175
+ inline: true,
176
+ group: "inline",
177
+ selectable: false,
178
+ parseDOM: [{
179
+ tag: "br"
180
+ }],
181
+ toDOM: function toDOM() {
182
+ return brDOM;
183
+ }
184
+ }
185
+ };
186
+ exports.nodes = nodes;
187
+ var emDOM = ["em", 0];
188
+ var strongDOM = ["strong", 0];
189
+ var codeDOM = ["code", 0]; // :: Object [Specs](#model.MarkSpec) for the marks in the schema.
190
+
191
+ var marks = {
192
+ // :: MarkSpec A link. Has `href` and `title` attributes. `title`
193
+ // defaults to the empty string. Rendered and parsed as an `<a>`
194
+ // element.
195
+ link: {
196
+ attrs: {
197
+ href: {},
198
+ title: {
199
+ "default": null
200
+ }
201
+ },
202
+ inclusive: false,
203
+ parseDOM: [{
204
+ tag: "a[href]",
205
+ getAttrs: function getAttrs(dom) {
206
+ return {
207
+ href: dom.getAttribute("href"),
208
+ title: dom.getAttribute("title")
209
+ };
210
+ }
211
+ }],
212
+ toDOM: function toDOM(node) {
213
+ var _node$attrs2 = node.attrs,
214
+ href = _node$attrs2.href,
215
+ title = _node$attrs2.title;
216
+ return ["a", {
217
+ href: href,
218
+ title: title
219
+ }, 0];
220
+ }
221
+ },
222
+ // :: MarkSpec An emphasis mark. Rendered as an `<em>` element.
223
+ // Has parse rules that also match `<i>` and `font-style: italic`.
224
+ em: {
225
+ parseDOM: [{
226
+ tag: "i"
227
+ }, {
228
+ tag: "em"
229
+ }, {
230
+ style: "font-style=italic"
231
+ }],
232
+ toDOM: function toDOM() {
233
+ return emDOM;
234
+ }
235
+ },
236
+ // :: MarkSpec A strong mark. Rendered as `<strong>`, parse rules
237
+ // also match `<b>` and `font-weight: bold`.
238
+ strong: {
239
+ parseDOM: [{
240
+ tag: "strong"
241
+ }, // This works around a Google Docs misbehavior where
242
+ // pasted content will be inexplicably wrapped in `<b>`
243
+ // tags with a font-weight normal.
244
+ {
245
+ tag: "b",
246
+ getAttrs: function getAttrs(node) {
247
+ return node.style.fontWeight !== "normal" && null;
248
+ }
249
+ }, {
250
+ style: "font-weight",
251
+ getAttrs: function getAttrs(value) {
252
+ return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
253
+ }
254
+ }],
255
+ toDOM: function toDOM() {
256
+ return strongDOM;
257
+ }
258
+ },
259
+ // :: MarkSpec Code font mark. Represented as a `<code>` element.
260
+ code: {
261
+ parseDOM: [{
262
+ tag: "code"
263
+ }],
264
+ toDOM: function toDOM() {
265
+ return codeDOM;
266
+ }
267
+ },
268
+ underLine: {
269
+ parseDOM: [{
270
+ tag: "span",
271
+ getAttrs: function getAttrs(node) {
272
+ return node.style.textDecoration == "underline" && null;
273
+ }
274
+ }],
275
+ toDOM: function toDOM() {
276
+ return ["span", {
277
+ style: 'text-decoration:underline;'
278
+ }, 0];
279
+ }
280
+ },
281
+ deleteLine: {
282
+ parseDOM: [{
283
+ tag: "span",
284
+ getAttrs: function getAttrs(node) {
285
+ return node.style.textDecoration == "ine-through" && null;
286
+ }
287
+ }],
288
+ toDOM: function toDOM() {
289
+ return ["span", {
290
+ style: 'text-decoration:line-through;'
291
+ }, 0];
292
+ }
293
+ }
294
+ }; // :: Schema
295
+ // This schema roughly corresponds to the document schema used by
296
+ // [CommonMark](http://commonmark.org/), minus the list elements,
297
+ // which are defined in the [`prosemirror-schema-list`](#schema-list)
298
+ // module.
299
+ //
300
+ // To reuse elements from this schema, extend or read from its
301
+ // `spec.nodes` and `spec.marks` [properties](#model.Schema.spec).
302
+ // @ts-ignore
303
+
304
+ exports.marks = marks;
305
+ var schema = new _prosemirrorModel.Schema({
306
+ nodes: nodes,
307
+ marks: marks
308
+ });
309
+ exports.schema = schema;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _prosemirrorModel = require("prosemirror-model");
9
+
10
+ var _basic = require("./basic");
11
+
12
+ var _list = require("./list");
13
+
14
+ var _default = new _prosemirrorModel.Schema({
15
+ nodes: (0, _list.addListNodes)(_basic.schema.spec.nodes, "paragraph block*", "block"),
16
+ marks: _basic.schema.spec.marks
17
+ });
18
+
19
+ exports["default"] = _default;
@@ -0,0 +1,342 @@
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.liftOutOfList = liftOutOfList;
10
+ exports.orderedList = exports.listItem = void 0;
11
+ exports.sinkListItem = sinkListItem;
12
+ exports.splitListItem = splitListItem;
13
+ exports.wrapInList = wrapInList;
14
+
15
+ var _prosemirrorTransform = require("prosemirror-transform");
16
+
17
+ var _prosemirrorModel = require("prosemirror-model");
18
+
19
+ var preCls = 'tita-rich-editor';
20
+ var olDOM = ["ol", {
21
+ "class": preCls + '-ol'
22
+ }, 0],
23
+ ulDOM = ["ul", {
24
+ "class": preCls + '-ul'
25
+ }, 0]; // :: NodeSpec
26
+ // An ordered list [node spec](#model.NodeSpec). Has a single
27
+ // attribute, `order`, which determines the number at which the list
28
+ // starts counting, and defaults to 1. Represented as an `<ol>`
29
+ // element.
30
+
31
+ var orderedList = {
32
+ attrs: {
33
+ order: {
34
+ "default": 1
35
+ }
36
+ },
37
+ parseDOM: [{
38
+ tag: "ol",
39
+ getAttrs: function getAttrs(dom) {
40
+ return {
41
+ order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1
42
+ };
43
+ }
44
+ }],
45
+ toDOM: function toDOM(node) {
46
+ return node.attrs.order == 1 ? olDOM : ["ol", {
47
+ start: node.attrs.order
48
+ }, 0];
49
+ }
50
+ }; // :: NodeSpec
51
+ // A bullet list node spec, represented in the DOM as `<ul>`.
52
+
53
+ exports.orderedList = orderedList;
54
+ var bulletList = {
55
+ parseDOM: [{
56
+ tag: "ul"
57
+ }],
58
+ toDOM: function toDOM() {
59
+ return ulDOM;
60
+ }
61
+ }; // :: NodeSpec
62
+ // A list item (`<li>`) spec.
63
+
64
+ exports.bulletList = bulletList;
65
+ var listItem = {
66
+ attrs: {
67
+ index: {
68
+ "default": 1
69
+ }
70
+ },
71
+ parseDOM: [{
72
+ tag: "li"
73
+ }],
74
+ toDOM: function toDOM(node) {
75
+ return ["li", {
76
+ "class": preCls + '-li',
77
+ 'data-index': node.attrs.index || 0
78
+ }, 0];
79
+ },
80
+ defining: true
81
+ };
82
+ exports.listItem = listItem;
83
+
84
+ function add(obj, props) {
85
+ var copy = {};
86
+
87
+ for (var prop in obj) {
88
+ copy[prop] = obj[prop];
89
+ }
90
+
91
+ for (var _prop in props) {
92
+ copy[_prop] = props[_prop];
93
+ }
94
+
95
+ return copy;
96
+ } // :: (OrderedMap<NodeSpec>, string, ?string) → OrderedMap<NodeSpec>
97
+ // Convenience function for adding list-related node types to a map
98
+ // specifying the nodes for a schema. Adds
99
+ // [`orderedList`](#schema-list.orderedList) as `"ordered_list"`,
100
+ // [`bulletList`](#schema-list.bulletList) as `"bullet_list"`, and
101
+ // [`listItem`](#schema-list.listItem) as `"list_item"`.
102
+ //
103
+ // `itemContent` determines the content expression for the list items.
104
+ // If you want the commands defined in this module to apply to your
105
+ // list structure, it should have a shape like `"paragraph block*"` or
106
+ // `"paragraph (ordered_list | bullet_list)*"`. `listGroup` can be
107
+ // given to assign a group name to the list node types, for example
108
+ // `"block"`.
109
+
110
+
111
+ function addListNodes(nodes, itemContent, listGroup) {
112
+ return nodes.append({
113
+ ordered_list: add(orderedList, {
114
+ content: "list_item+",
115
+ group: listGroup
116
+ }),
117
+ bullet_list: add(bulletList, {
118
+ content: "list_item+",
119
+ group: listGroup
120
+ }),
121
+ list_item: add(listItem, {
122
+ content: itemContent
123
+ })
124
+ });
125
+ } // :: (NodeType, ?Object) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
126
+ // Returns a command function that wraps the selection in a list with
127
+ // the given type an attributes. If `dispatch` is null, only return a
128
+ // value to indicate whether this is possible, but don't actually
129
+ // perform the change.
130
+
131
+
132
+ function wrapInList(listType, attrs) {
133
+ return function (state, dispatch) {
134
+ var _state$selection = state.selection,
135
+ $from = _state$selection.$from,
136
+ $to = _state$selection.$to;
137
+ var range = $from.blockRange($to),
138
+ doJoin = false,
139
+ outerRange = range;
140
+ if (!range) return false; // This is at the top of an existing list item
141
+
142
+ if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex == 0) {
143
+ // Don't do anything if this is the top of the list
144
+ if ($from.index(range.depth - 1) == 0) return false;
145
+ var $insert = state.doc.resolve(range.start - 2);
146
+ outerRange = new _prosemirrorModel.NodeRange($insert, $insert, range.depth);
147
+ if (range.endIndex < range.parent.childCount) range = new _prosemirrorModel.NodeRange($from, state.doc.resolve($to.end(range.depth)), range.depth);
148
+ doJoin = true;
149
+ }
150
+
151
+ var wrap = (0, _prosemirrorTransform.findWrapping)(outerRange, listType, attrs, range);
152
+ if (!wrap) return false;
153
+ if (dispatch) dispatch(doWrapInList(state.tr, range, wrap, doJoin, listType).scrollIntoView());
154
+ return true;
155
+ };
156
+ }
157
+
158
+ function doWrapInList(tr, range, wrappers, joinBefore, listType) {
159
+ var content = _prosemirrorModel.Fragment.empty;
160
+
161
+ for (var i = wrappers.length - 1; i >= 0; i--) {
162
+ content = _prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
163
+ }
164
+
165
+ 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));
166
+ var found = 0;
167
+
168
+ for (var _i = 0; _i < wrappers.length; _i++) {
169
+ if (wrappers[_i].type == listType) found = _i + 1;
170
+ }
171
+
172
+ var splitDepth = wrappers.length - found;
173
+ var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0),
174
+ parent = range.parent;
175
+
176
+ for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {
177
+ if (!first && (0, _prosemirrorTransform.canSplit)(tr.doc, splitPos, splitDepth)) {
178
+ tr.split(splitPos, splitDepth);
179
+ splitPos += 2 * splitDepth;
180
+ }
181
+
182
+ splitPos += parent.child(_i2).nodeSize;
183
+ }
184
+
185
+ return tr;
186
+ } // :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
187
+ // Build a command that splits a non-empty textblock at the top level
188
+ // of a list item by also splitting that list item.
189
+
190
+
191
+ function splitListItem(itemType) {
192
+ return function (state, dispatch) {
193
+ var _state$selection2 = state.selection,
194
+ $from = _state$selection2.$from,
195
+ $to = _state$selection2.$to,
196
+ node = _state$selection2.node;
197
+ if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) return false;
198
+ var grandParent = $from.node(-1);
199
+ if (grandParent.type != itemType) return false;
200
+
201
+ if ($from.parent.content.size == 0 && $from.node(-1).childCount == $from.indexAfter(-1)) {
202
+ // In an empty block. If this is a nested list, the wrapping
203
+ // list item should be split. Otherwise, bail out and let next
204
+ // command handle lifting.
205
+ if ($from.depth == 2 || $from.node(-3).type != itemType || $from.index(-2) != $from.node(-2).childCount - 1) return false;
206
+
207
+ if (dispatch) {
208
+ var wrap = _prosemirrorModel.Fragment.empty;
209
+ var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3; // Build a fragment containing empty versions of the structure
210
+ // from the outer list item to the parent node of the cursor
211
+
212
+ for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--) {
213
+ wrap = _prosemirrorModel.Fragment.from($from.node(d).copy(wrap));
214
+ }
215
+
216
+ 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
217
+
218
+ wrap = wrap.append(_prosemirrorModel.Fragment.from(itemType.createAndFill()));
219
+ var start = $from.before($from.depth - (depthBefore - 1));
220
+
221
+ var _tr = state.tr.replace(start, $from.after(-depthAfter), new _prosemirrorModel.Slice(wrap, 4 - depthBefore, 0));
222
+
223
+ var sel = -1;
224
+
225
+ _tr.doc.nodesBetween(start, _tr.doc.content.size, function (node, pos) {
226
+ if (sel > -1) return false;
227
+ if (node.isTextblock && node.content.size == 0) sel = pos + 1;
228
+ });
229
+
230
+ if (sel > -1) _tr.setSelection(state.selection.constructor.near(_tr.doc.resolve(sel)));
231
+ dispatch(_tr.scrollIntoView());
232
+ }
233
+
234
+ return true;
235
+ }
236
+
237
+ var nextType = $to.pos == $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
238
+ var tr = state.tr["delete"]($from.pos, $to.pos);
239
+ var types = nextType && [null, {
240
+ type: nextType
241
+ }];
242
+ if (!(0, _prosemirrorTransform.canSplit)(tr.doc, $from.pos, 2, types)) return false;
243
+ if (dispatch) dispatch(tr.split($from.pos, 2, types).scrollIntoView());
244
+ return true;
245
+ };
246
+ } // :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
247
+ // Create a command to lift the list item around the selection up into
248
+ // a wrapping list.
249
+
250
+
251
+ function liftListItem(itemType) {
252
+ return function (state, dispatch) {
253
+ debugger;
254
+ var _state$selection3 = state.selection,
255
+ $from = _state$selection3.$from,
256
+ $to = _state$selection3.$to;
257
+ var range = $from.blockRange($to, function (node) {
258
+ return node.childCount && node.firstChild.type == itemType;
259
+ });
260
+ if (!range) return false;
261
+ if (!dispatch) return true;
262
+ if ($from.node(range.depth - 1).type == itemType) // Inside a parent list
263
+ return liftToOuterList(state, dispatch, itemType, range);else // Outer list node
264
+ return liftOutOfList(state, dispatch, range);
265
+ };
266
+ }
267
+
268
+ function liftToOuterList(state, dispatch, itemType, range) {
269
+ var tr = state.tr,
270
+ end = range.end,
271
+ endOfList = range.$to.end(range.depth);
272
+
273
+ if (end < endOfList) {
274
+ // There are siblings after the lifted items, which must become
275
+ // children of the last item
276
+ 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));
277
+ range = new _prosemirrorModel.NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);
278
+ }
279
+
280
+ dispatch(tr.lift(range, (0, _prosemirrorTransform.liftTarget)(range)).scrollIntoView());
281
+ return true;
282
+ }
283
+
284
+ function liftOutOfList(state, dispatch, range) {
285
+ var tr = state.tr,
286
+ list = range.parent; // Merge the list items into a single big item
287
+
288
+ for (var pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {
289
+ pos -= list.child(i).nodeSize;
290
+ tr["delete"](pos - 1, pos + 1);
291
+ }
292
+
293
+ var $start = tr.doc.resolve(range.start),
294
+ item = $start.nodeAfter;
295
+ if (tr.mapping.map(range.end) != range.start + $start.nodeAfter.nodeSize) return false;
296
+ var atStart = range.startIndex == 0,
297
+ atEnd = range.endIndex == list.childCount;
298
+ var parent = $start.node(-1),
299
+ indexBefore = $start.index(-1);
300
+ if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? _prosemirrorModel.Fragment.empty : _prosemirrorModel.Fragment.from(list)))) return false;
301
+ var start = $start.pos,
302
+ end = start + item.nodeSize; // Strip off the surrounding list. At the sides where we're not at
303
+ // the end of the list, the existing list is closed. At sides where
304
+ // this is the end, it is overwritten to its end.
305
+
306
+ 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));
307
+ dispatch(tr.scrollIntoView());
308
+ return true;
309
+ } // :: (NodeType) → (state: EditorState, dispatch: ?(tr: Transaction)) → bool
310
+ // Create a command to sink the list item around the selection down
311
+ // into an inner list.
312
+
313
+
314
+ function sinkListItem(itemType) {
315
+ return function (state, dispatch) {
316
+ var _state$selection4 = state.selection,
317
+ $from = _state$selection4.$from,
318
+ $to = _state$selection4.$to;
319
+ var range = $from.blockRange($to, function (node) {
320
+ return node.childCount && node.firstChild.type == itemType;
321
+ });
322
+ if (!range) return false;
323
+ var startIndex = range.startIndex;
324
+ if (startIndex == 0) return false;
325
+ var parent = range.parent,
326
+ nodeBefore = parent.child(startIndex - 1);
327
+ if (nodeBefore.type != itemType) return false;
328
+
329
+ if (dispatch) {
330
+ var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
331
+
332
+ var inner = _prosemirrorModel.Fragment.from(nestedBefore ? itemType.create() : null);
333
+
334
+ var slice = new _prosemirrorModel.Slice(_prosemirrorModel.Fragment.from(itemType.create(null, _prosemirrorModel.Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
335
+ var before = range.start,
336
+ after = range.end;
337
+ dispatch(state.tr.step(new _prosemirrorTransform.ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());
338
+ }
339
+
340
+ return true;
341
+ };
342
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _commond = require("./commond");
8
+
9
+ Object.keys(_commond).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _commond[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _commond[key];
16
+ }
17
+ });
18
+ });