@manuscripts/body-editor 1.11.7-LEAN-3572.0 → 1.11.7
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/dist/cjs/commands.js +4 -7
- package/dist/cjs/components/toolbar/LevelSelector.js +24 -40
- package/dist/cjs/configs/editor-views.js +2 -4
- package/dist/cjs/keys/list.js +38 -5
- package/dist/cjs/lib/comments.js +1 -1
- package/dist/cjs/lib/context-menu.js +22 -19
- package/dist/cjs/menus.js +9 -9
- package/dist/cjs/node-type-icons.js +9 -3
- package/dist/cjs/plugins/comments.js +17 -21
- package/dist/cjs/rules.js +1 -2
- package/dist/cjs/toolbar.js +13 -13
- package/dist/cjs/views/list.js +56 -0
- package/dist/es/commands.js +4 -7
- package/dist/es/components/toolbar/LevelSelector.js +25 -41
- package/dist/es/configs/editor-views.js +2 -4
- package/dist/es/keys/list.js +35 -3
- package/dist/es/lib/comments.js +1 -1
- package/dist/es/lib/context-menu.js +24 -21
- package/dist/es/menus.js +9 -9
- package/dist/es/node-type-icons.js +9 -3
- package/dist/es/plugins/comments.js +17 -21
- package/dist/es/rules.js +1 -2
- package/dist/es/toolbar.js +13 -13
- package/dist/es/views/list.js +48 -0
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/configs/editor-views.d.ts +2 -37
- package/dist/types/keys/list.d.ts +2 -0
- package/dist/types/lib/comments.d.ts +3 -5
- package/dist/types/node-type-icons.d.ts +1 -1
- package/dist/types/views/list.d.ts +59 -0
- package/package.json +4 -4
package/dist/cjs/commands.js
CHANGED
|
@@ -96,7 +96,7 @@ const createSelection = (nodeType, position, doc) => {
|
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
exports.createSelection = createSelection;
|
|
99
|
-
const createBlock = (nodeType, position, state, dispatch) => {
|
|
99
|
+
const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
100
100
|
let node;
|
|
101
101
|
switch (nodeType) {
|
|
102
102
|
case state.schema.nodes.table_element:
|
|
@@ -117,7 +117,7 @@ const createBlock = (nodeType, position, state, dispatch) => {
|
|
|
117
117
|
]);
|
|
118
118
|
break;
|
|
119
119
|
default:
|
|
120
|
-
node = nodeType.createAndFill();
|
|
120
|
+
node = nodeType.createAndFill(attrs);
|
|
121
121
|
}
|
|
122
122
|
const tr = state.tr.insert(position, node);
|
|
123
123
|
if (dispatch) {
|
|
@@ -397,10 +397,7 @@ const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
397
397
|
return true;
|
|
398
398
|
};
|
|
399
399
|
exports.insertSection = insertSection;
|
|
400
|
-
const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([
|
|
401
|
-
transform_1.schema.nodes.ordered_list,
|
|
402
|
-
transform_1.schema.nodes.bullet_list,
|
|
403
|
-
]);
|
|
400
|
+
const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([transform_1.schema.nodes.list]);
|
|
404
401
|
const findRootList = ($pos) => {
|
|
405
402
|
for (let i = 0; i < $pos.depth; i++) {
|
|
406
403
|
const node = $pos.node(i);
|
|
@@ -467,7 +464,7 @@ const insertList = (type, style) => (state, dispatch, view) => {
|
|
|
467
464
|
for (const { node, pos } of nodes) {
|
|
468
465
|
tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
|
|
469
466
|
}
|
|
470
|
-
dispatch(
|
|
467
|
+
dispatch(tr);
|
|
471
468
|
return true;
|
|
472
469
|
}
|
|
473
470
|
else {
|
|
@@ -27,16 +27,18 @@ const react_select_1 = __importDefault(require("react-select"));
|
|
|
27
27
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
28
28
|
const hierarchy_1 = require("../../lib/hierarchy");
|
|
29
29
|
const node_type_icons_1 = require("../../node-type-icons");
|
|
30
|
-
const optionName = (nodeType, depth) => {
|
|
30
|
+
const optionName = (nodeType, depth, listType) => {
|
|
31
31
|
switch (nodeType) {
|
|
32
32
|
case nodeType.schema.nodes.section:
|
|
33
33
|
return (depth > 0 ? 'sub'.repeat(depth - 1) : '') + 'section heading';
|
|
34
|
+
case nodeType.schema.nodes.list:
|
|
35
|
+
return listType === 'order' ? 'Ordered List' : 'Bullet List';
|
|
34
36
|
default:
|
|
35
37
|
return transform_1.nodeNames.get(nodeType) || nodeType.name;
|
|
36
38
|
}
|
|
37
39
|
};
|
|
38
40
|
const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
|
|
39
|
-
const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: (0, node_type_icons_1.nodeTypeIcon)(props.nodeType), label: titleCase(optionName(props.nodeType, props.depth)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
|
|
41
|
+
const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: (0, node_type_icons_1.nodeTypeIcon)(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth, props.listType)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
|
|
40
42
|
const buildOptions = (state, dispatch, view) => {
|
|
41
43
|
const { doc, selection: { $from, $to }, schema, tr, } = state;
|
|
42
44
|
const { nodes } = schema;
|
|
@@ -189,12 +191,13 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
189
191
|
dispatch(tr.scrollIntoView());
|
|
190
192
|
view && view.focus();
|
|
191
193
|
};
|
|
192
|
-
const convertParagraphToList = (nodeType) => () => {
|
|
194
|
+
const convertParagraphToList = (nodeType, listType) => () => {
|
|
193
195
|
const paragraph = $from.node($from.depth);
|
|
194
196
|
const beforeParagraph = $from.before($from.depth);
|
|
195
197
|
const afterParagraph = $from.after($from.depth);
|
|
196
198
|
const list = nodeType.create({
|
|
197
199
|
id: (0, transform_1.generateNodeID)(nodeType),
|
|
200
|
+
listStyleType: listType,
|
|
198
201
|
}, nodes.list_item.create({}, schema.nodes.paragraph.create({}, paragraph.content)));
|
|
199
202
|
tr.replaceWith(beforeParagraph, afterParagraph, list);
|
|
200
203
|
const anchor = beforeParagraph + 3;
|
|
@@ -202,8 +205,8 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
202
205
|
dispatch(tr.scrollIntoView());
|
|
203
206
|
view && view.focus();
|
|
204
207
|
};
|
|
205
|
-
const convertListType = (nodeType, list) => () => {
|
|
206
|
-
tr.setNodeMarkup(list.before, nodeType, list.node.attrs);
|
|
208
|
+
const convertListType = (nodeType, list, listType) => () => {
|
|
209
|
+
tr.setNodeMarkup(list.before, nodeType, Object.assign(Object.assign({}, list.node.attrs), { listStyleType: listType }));
|
|
207
210
|
dispatch(tr.scrollIntoView());
|
|
208
211
|
view && view.focus();
|
|
209
212
|
};
|
|
@@ -225,16 +228,18 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
225
228
|
isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
|
|
226
229
|
}),
|
|
227
230
|
buildOption({
|
|
228
|
-
nodeType: nodes.
|
|
231
|
+
nodeType: nodes.list,
|
|
229
232
|
value: -3,
|
|
230
233
|
depth: 1,
|
|
231
234
|
isDisabled: true,
|
|
235
|
+
listType: 'order',
|
|
232
236
|
}),
|
|
233
237
|
buildOption({
|
|
234
|
-
nodeType: nodes.
|
|
238
|
+
nodeType: nodes.list,
|
|
235
239
|
value: -2,
|
|
236
240
|
depth: 1,
|
|
237
241
|
isDisabled: true,
|
|
242
|
+
listType: 'bullet',
|
|
238
243
|
}),
|
|
239
244
|
];
|
|
240
245
|
const sectionOptions = [];
|
|
@@ -291,16 +296,18 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
291
296
|
isSelected: true,
|
|
292
297
|
}),
|
|
293
298
|
buildOption({
|
|
294
|
-
nodeType: nodes.
|
|
299
|
+
nodeType: nodes.list,
|
|
295
300
|
value: -3,
|
|
296
301
|
depth: 1,
|
|
297
|
-
action: convertParagraphToList(nodes.
|
|
302
|
+
action: convertParagraphToList(nodes.list, 'order'),
|
|
303
|
+
listType: 'order',
|
|
298
304
|
}),
|
|
299
305
|
buildOption({
|
|
300
|
-
nodeType: nodes.
|
|
306
|
+
nodeType: nodes.list,
|
|
301
307
|
value: -2,
|
|
302
308
|
depth: 1,
|
|
303
|
-
action: convertParagraphToList(nodes.
|
|
309
|
+
action: convertParagraphToList(nodes.list, 'bullet'),
|
|
310
|
+
listType: 'bullet',
|
|
304
311
|
}),
|
|
305
312
|
];
|
|
306
313
|
const sectionOptions = [];
|
|
@@ -326,7 +333,8 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
326
333
|
}));
|
|
327
334
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
328
335
|
}
|
|
329
|
-
case schema.nodes.
|
|
336
|
+
case schema.nodes.list: {
|
|
337
|
+
const { style } = (0, transform_1.getListType)(parentElement.node.attrs.listStyleType);
|
|
330
338
|
return [
|
|
331
339
|
{
|
|
332
340
|
options: [
|
|
@@ -342,35 +350,11 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
342
350
|
{
|
|
343
351
|
options: [
|
|
344
352
|
buildOption({
|
|
345
|
-
nodeType: nodes.
|
|
353
|
+
nodeType: nodes.list,
|
|
346
354
|
value: -3,
|
|
347
355
|
depth: 1,
|
|
348
|
-
action: convertListType(nodes.
|
|
349
|
-
|
|
350
|
-
],
|
|
351
|
-
},
|
|
352
|
-
];
|
|
353
|
-
}
|
|
354
|
-
case parentElementType.schema.nodes.ordered_list: {
|
|
355
|
-
return [
|
|
356
|
-
{
|
|
357
|
-
options: [
|
|
358
|
-
buildOption({
|
|
359
|
-
nodeType: parentElementType,
|
|
360
|
-
value: -4,
|
|
361
|
-
depth: 1,
|
|
362
|
-
isDisabled: true,
|
|
363
|
-
isSelected: true,
|
|
364
|
-
}),
|
|
365
|
-
],
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
options: [
|
|
369
|
-
buildOption({
|
|
370
|
-
nodeType: nodes.bullet_list,
|
|
371
|
-
value: -3,
|
|
372
|
-
depth: 1,
|
|
373
|
-
action: convertListType(nodes.bullet_list, parentElement),
|
|
356
|
+
action: convertListType(nodes.list, parentElement, style),
|
|
357
|
+
listType: style === 'none' || style === 'disc' ? 'bullet' : 'order',
|
|
374
358
|
}),
|
|
375
359
|
],
|
|
376
360
|
},
|
|
@@ -458,7 +442,7 @@ const LevelSelector = ({ state, dispatch, view }) => {
|
|
|
458
442
|
style.opacity = 0.4;
|
|
459
443
|
}
|
|
460
444
|
return (react_1.default.createElement(OptionContainer, Object.assign({}, props.innerProps, { ref: null, style: style }),
|
|
461
|
-
react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType)),
|
|
445
|
+
react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType, data.listType)),
|
|
462
446
|
react_1.default.createElement(OptionLabel, null, data.label)));
|
|
463
447
|
},
|
|
464
448
|
}, onChange: (value) => {
|
|
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
const affiliations_1 = __importDefault(require("../views/affiliations"));
|
|
22
22
|
const bibliography_element_editable_1 = __importDefault(require("../views/bibliography_element_editable"));
|
|
23
23
|
const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
|
|
24
|
-
const bullet_list_editable_1 = __importDefault(require("../views/bullet_list_editable"));
|
|
25
24
|
const citation_editable_1 = __importDefault(require("../views/citation_editable"));
|
|
26
25
|
const contributors_1 = __importDefault(require("../views/contributors"));
|
|
27
26
|
const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
|
|
@@ -37,10 +36,10 @@ const inline_footnote_editable_1 = __importDefault(require("../views/inline_foot
|
|
|
37
36
|
const keyword_1 = __importDefault(require("../views/keyword"));
|
|
38
37
|
const keyword_group_1 = __importDefault(require("../views/keyword_group"));
|
|
39
38
|
const link_editable_1 = __importDefault(require("../views/link_editable"));
|
|
39
|
+
const list_1 = __importDefault(require("../views/list"));
|
|
40
40
|
const list_item_1 = __importDefault(require("../views/list_item"));
|
|
41
41
|
const listing_editable_1 = __importDefault(require("../views/listing_editable"));
|
|
42
42
|
const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
|
|
43
|
-
const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
|
|
44
43
|
const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
|
|
45
44
|
const placeholder_1 = __importDefault(require("../views/placeholder"));
|
|
46
45
|
const placeholder_element_editable_1 = __importDefault(require("../views/placeholder_element_editable"));
|
|
@@ -56,7 +55,7 @@ exports.default = (props, dispatch) => {
|
|
|
56
55
|
title: (0, title_editable_1.default)(props, dispatch),
|
|
57
56
|
bibliography_element: (0, bibliography_element_editable_1.default)(props, dispatch),
|
|
58
57
|
blockquote_element: (0, blockquote_element_editable_1.default)(props),
|
|
59
|
-
|
|
58
|
+
list: (0, list_1.default)(props),
|
|
60
59
|
citation: (0, citation_editable_1.default)(props, dispatch),
|
|
61
60
|
cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
|
|
62
61
|
contributors: (0, contributors_1.default)(props, dispatch),
|
|
@@ -75,7 +74,6 @@ exports.default = (props, dispatch) => {
|
|
|
75
74
|
listing: (0, listing_editable_1.default)(props),
|
|
76
75
|
listing_element: (0, listing_element_editable_1.default)(props),
|
|
77
76
|
list_item: (0, list_item_1.default)(props),
|
|
78
|
-
ordered_list: (0, ordered_list_editable_1.default)(props),
|
|
79
77
|
paragraph: (0, paragraph_editable_1.default)(props),
|
|
80
78
|
placeholder: (0, placeholder_1.default)(props),
|
|
81
79
|
placeholder_element: (0, placeholder_element_editable_1.default)(props),
|
package/dist/cjs/keys/list.js
CHANGED
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.skipCommandTracking = void 0;
|
|
18
|
+
exports.sinkListItem = exports.skipCommandTracking = void 0;
|
|
19
19
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
20
20
|
const transform_1 = require("@manuscripts/transform");
|
|
21
21
|
const prosemirror_commands_1 = require("prosemirror-commands");
|
|
22
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
22
23
|
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
24
|
+
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
23
25
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
26
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
24
27
|
const skipCommandTracking = (command) => (state, dispatch) => {
|
|
25
28
|
return command(state, (tr) => {
|
|
26
29
|
if (dispatch) {
|
|
@@ -56,14 +59,44 @@ const liftToOuterList = (itemType) => {
|
|
|
56
59
|
}
|
|
57
60
|
};
|
|
58
61
|
};
|
|
62
|
+
function sinkListItem(itemType) {
|
|
63
|
+
return function (state, dispatch) {
|
|
64
|
+
const { $from, $to } = state.selection;
|
|
65
|
+
const range = $from.blockRange($to, (node) => { var _a; return node.childCount > 0 && ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.type) == itemType; });
|
|
66
|
+
if (!range) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const startIndex = range.startIndex;
|
|
70
|
+
if (startIndex == 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const parent = range.parent, nodeBefore = parent.child(startIndex - 1);
|
|
74
|
+
if (nodeBefore.type != itemType) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (dispatch) {
|
|
78
|
+
const nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
|
|
79
|
+
const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(parent);
|
|
80
|
+
const listType = actualAttrs.listStyleType;
|
|
81
|
+
const inner = prosemirror_model_1.Fragment.from(nestedBefore ? itemType.create() : null);
|
|
82
|
+
const slice = new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from(itemType.create(null, prosemirror_model_1.Fragment.from(parent.type.create({ listStyleType: listType }, inner)))), nestedBefore ? 3 : 1, 0);
|
|
83
|
+
const before = range.start, after = range.end;
|
|
84
|
+
dispatch(state.tr
|
|
85
|
+
.step(new prosemirror_transform_1.ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true))
|
|
86
|
+
.scrollIntoView());
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
exports.sinkListItem = sinkListItem;
|
|
59
92
|
const listKeymap = {
|
|
60
93
|
Enter: (0, prosemirror_schema_list_1.splitListItem)(transform_1.schema.nodes.list_item),
|
|
61
94
|
'Mod-[': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
|
|
62
|
-
'Mod-]': (0, exports.skipCommandTracking)(
|
|
63
|
-
'Mod-Alt-o': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.
|
|
64
|
-
'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.
|
|
95
|
+
'Mod-]': (0, exports.skipCommandTracking)(sinkListItem(transform_1.schema.nodes.list_item)),
|
|
96
|
+
'Mod-Alt-o': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.list, { listStyleType: 'order' })),
|
|
97
|
+
'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.list, { listStyleType: 'bullet' })),
|
|
65
98
|
'Shift-Tab': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
|
|
66
|
-
Tab: (0, exports.skipCommandTracking)(
|
|
99
|
+
Tab: (0, exports.skipCommandTracking)(sinkListItem(transform_1.schema.nodes.list_item)),
|
|
67
100
|
Backspace: (0, exports.skipCommandTracking)(listItemBackward),
|
|
68
101
|
};
|
|
69
102
|
exports.default = listKeymap;
|
package/dist/cjs/lib/comments.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCommentMarker = exports.getCommentRange = exports.getCommentKey = exports.isNodeComment = void 0;
|
|
4
|
-
const isNodeComment = (
|
|
4
|
+
const isNodeComment = (comment) => !comment.range;
|
|
5
5
|
exports.isNodeComment = isNodeComment;
|
|
6
6
|
const getCommentKey = (comment, range, target) => {
|
|
7
7
|
if (!range) {
|
|
@@ -29,7 +29,6 @@ const popper_1 = require("./popper");
|
|
|
29
29
|
const track_changes_utils_1 = require("./track-changes-utils");
|
|
30
30
|
const utils_1 = require("./utils");
|
|
31
31
|
const popper = new popper_1.PopperManager();
|
|
32
|
-
const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
|
|
33
32
|
const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
|
|
34
33
|
const sectionLevel = (depth) => {
|
|
35
34
|
switch (depth) {
|
|
@@ -56,12 +55,12 @@ class ContextMenu {
|
|
|
56
55
|
const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
|
|
57
56
|
const endPos = $pos.end();
|
|
58
57
|
const types = this.insertableTypes(after, insertPos, endPos);
|
|
59
|
-
const insertNode = (type, pos) => {
|
|
58
|
+
const insertNode = (type, pos, attrs) => {
|
|
60
59
|
const { state, dispatch } = this.view;
|
|
61
60
|
if (pos === undefined) {
|
|
62
61
|
pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
|
|
63
62
|
}
|
|
64
|
-
(0, commands_1.createBlock)(type, pos, state, dispatch);
|
|
63
|
+
(0, commands_1.createBlock)(type, pos, state, dispatch, attrs);
|
|
65
64
|
};
|
|
66
65
|
if (hasAny(types, 'section', 'subsection')) {
|
|
67
66
|
menu.appendChild(this.createMenuSection((section) => {
|
|
@@ -88,7 +87,7 @@ class ContextMenu {
|
|
|
88
87
|
}
|
|
89
88
|
}));
|
|
90
89
|
}
|
|
91
|
-
if (hasAny(types, 'paragraph', '
|
|
90
|
+
if (hasAny(types, 'paragraph', 'list')) {
|
|
92
91
|
menu.appendChild(this.createMenuSection((section) => {
|
|
93
92
|
if (types.has('paragraph')) {
|
|
94
93
|
section.appendChild(this.createMenuItem('Paragraph', () => {
|
|
@@ -96,15 +95,17 @@ class ContextMenu {
|
|
|
96
95
|
popper.destroy();
|
|
97
96
|
}));
|
|
98
97
|
}
|
|
99
|
-
if (types.has('
|
|
100
|
-
section.appendChild(this.createMenuItem('
|
|
101
|
-
insertNode(transform_1.schema.nodes.
|
|
98
|
+
if (types.has('list')) {
|
|
99
|
+
section.appendChild(this.createMenuItem('Bullet List', () => {
|
|
100
|
+
insertNode(transform_1.schema.nodes.list, undefined, {
|
|
101
|
+
listStyleType: 'bullet',
|
|
102
|
+
});
|
|
102
103
|
popper.destroy();
|
|
103
104
|
}));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
section.appendChild(this.createMenuItem('Ordered List', () => {
|
|
106
|
+
insertNode(transform_1.schema.nodes.list, undefined, {
|
|
107
|
+
listStyleType: 'order',
|
|
108
|
+
});
|
|
108
109
|
popper.destroy();
|
|
109
110
|
}));
|
|
110
111
|
}
|
|
@@ -149,17 +150,19 @@ class ContextMenu {
|
|
|
149
150
|
menu.className = 'menu';
|
|
150
151
|
const $pos = this.resolvePos();
|
|
151
152
|
const type = this.node.type;
|
|
152
|
-
if (
|
|
153
|
+
if (type === transform_1.schema.nodes.list) {
|
|
153
154
|
menu.appendChild(this.createMenuSection((section) => {
|
|
154
|
-
|
|
155
|
+
const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
|
|
156
|
+
const listType = (0, transform_1.getListType)(actualAttrs.listStyleType).style;
|
|
157
|
+
if (listType === 'none' || listType === 'disc') {
|
|
155
158
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
156
|
-
this.changeNodeType(
|
|
159
|
+
this.changeNodeType(null, 'order');
|
|
157
160
|
popper.destroy();
|
|
158
161
|
}));
|
|
159
162
|
}
|
|
160
|
-
|
|
163
|
+
else {
|
|
161
164
|
section.appendChild(this.createMenuItem('Change to Bullet List', () => {
|
|
162
|
-
this.changeNodeType(
|
|
165
|
+
this.changeNodeType(null, 'bullet');
|
|
163
166
|
popper.destroy();
|
|
164
167
|
}));
|
|
165
168
|
}
|
|
@@ -319,8 +322,7 @@ class ContextMenu {
|
|
|
319
322
|
}
|
|
320
323
|
checkNode('section', insertPos);
|
|
321
324
|
checkNode('paragraph');
|
|
322
|
-
checkNode('
|
|
323
|
-
checkNode('bullet_list');
|
|
325
|
+
checkNode('list');
|
|
324
326
|
checkNode('figure_element');
|
|
325
327
|
checkNode('table_element');
|
|
326
328
|
checkNode('equation_element');
|
|
@@ -328,9 +330,10 @@ class ContextMenu {
|
|
|
328
330
|
checkNode('pullquote_element');
|
|
329
331
|
return insertable;
|
|
330
332
|
};
|
|
331
|
-
this.changeNodeType = (nodeType) => {
|
|
333
|
+
this.changeNodeType = (nodeType, listType) => {
|
|
332
334
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
|
|
333
335
|
id: this.node.attrs.id,
|
|
336
|
+
listStyleType: listType,
|
|
334
337
|
}));
|
|
335
338
|
popper.destroy();
|
|
336
339
|
};
|
package/dist/cjs/menus.js
CHANGED
|
@@ -300,15 +300,15 @@ const getEditorMenus = (editor) => {
|
|
|
300
300
|
{
|
|
301
301
|
id: 'insert-bullet-list',
|
|
302
302
|
label: 'Bullet List',
|
|
303
|
-
isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
303
|
+
isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet')),
|
|
304
304
|
submenu: [
|
|
305
305
|
{
|
|
306
306
|
id: 'bullet-list-context-menu',
|
|
307
307
|
label: '',
|
|
308
308
|
isEnabled: true,
|
|
309
309
|
options: {
|
|
310
|
-
bullet: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
311
|
-
simple: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
310
|
+
bullet: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet')),
|
|
311
|
+
simple: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'simple')),
|
|
312
312
|
},
|
|
313
313
|
},
|
|
314
314
|
],
|
|
@@ -316,18 +316,18 @@ const getEditorMenus = (editor) => {
|
|
|
316
316
|
{
|
|
317
317
|
id: 'insert-ordered-list',
|
|
318
318
|
label: 'Ordered List',
|
|
319
|
-
isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
319
|
+
isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.list, 'order')),
|
|
320
320
|
submenu: [
|
|
321
321
|
{
|
|
322
322
|
id: 'ordered-list-context-menu',
|
|
323
323
|
label: '',
|
|
324
324
|
isEnabled: true,
|
|
325
325
|
options: {
|
|
326
|
-
order: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
327
|
-
'alpha-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
328
|
-
'alpha-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
329
|
-
'roman-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
330
|
-
'roman-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.
|
|
326
|
+
order: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'order')),
|
|
327
|
+
'alpha-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-upper')),
|
|
328
|
+
'alpha-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-lower')),
|
|
329
|
+
'roman-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-upper')),
|
|
330
|
+
'roman-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-lower')),
|
|
331
331
|
},
|
|
332
332
|
},
|
|
333
333
|
],
|
|
@@ -27,10 +27,8 @@ const icons = new Map([
|
|
|
27
27
|
[nodes.manuscript, style_guide_1.OutlineManuscriptIcon],
|
|
28
28
|
[nodes.bibliography_section, style_guide_1.OutlineSectionIcon],
|
|
29
29
|
[nodes.blockquote_element, style_guide_1.OutlineBlockQuoteIcon],
|
|
30
|
-
[nodes.bullet_list, style_guide_1.OutlineUnorderedListIcon],
|
|
31
30
|
[nodes.equation_element, style_guide_1.OutlineEquationIcon],
|
|
32
31
|
[nodes.figure_element, style_guide_1.OutlineFigureIcon],
|
|
33
|
-
[nodes.ordered_list, style_guide_1.OutlineOrderedListIcon],
|
|
34
32
|
[nodes.paragraph, style_guide_1.OutlineParagraphIcon],
|
|
35
33
|
[nodes.pullquote_element, style_guide_1.OutlinePullQuoteIcon],
|
|
36
34
|
[nodes.section, style_guide_1.OutlineSectionIcon],
|
|
@@ -39,7 +37,15 @@ const icons = new Map([
|
|
|
39
37
|
[nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
|
|
40
38
|
[nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
|
|
41
39
|
]);
|
|
42
|
-
const nodeTypeIcon = (nodeType) => {
|
|
40
|
+
const nodeTypeIcon = (nodeType, listType) => {
|
|
41
|
+
if (nodeType === transform_1.schema.nodes.list) {
|
|
42
|
+
if (listType === 'bullet') {
|
|
43
|
+
return react_1.default.createElement(style_guide_1.OutlineUnorderedListIcon, null);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return react_1.default.createElement(style_guide_1.OutlineOrderedListIcon, null);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
43
49
|
const Icon = icons.get(nodeType);
|
|
44
50
|
return Icon ? react_1.default.createElement(Icon, null) : null;
|
|
45
51
|
};
|
|
@@ -90,12 +90,13 @@ const findCommentRanges = (doc) => {
|
|
|
90
90
|
return ranges;
|
|
91
91
|
};
|
|
92
92
|
const findComments = (doc) => {
|
|
93
|
-
const
|
|
93
|
+
const nodes = (0, prosemirror_utils_1.findChildrenByType)(doc, transform_1.schema.nodes.comment);
|
|
94
94
|
const commentsByTarget = new Map();
|
|
95
|
-
for (const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
commentsByTarget.
|
|
95
|
+
for (const { node } of nodes) {
|
|
96
|
+
const attrs = node.attrs;
|
|
97
|
+
const targetID = attrs.target;
|
|
98
|
+
const comments = commentsByTarget.get(targetID) || [];
|
|
99
|
+
commentsByTarget.set(targetID, [...comments, attrs]);
|
|
99
100
|
}
|
|
100
101
|
return commentsByTarget;
|
|
101
102
|
};
|
|
@@ -117,32 +118,27 @@ const buildPluginState = (doc, selection) => {
|
|
|
117
118
|
const nodeComments = [];
|
|
118
119
|
const highlightComments = [];
|
|
119
120
|
const pointComments = [];
|
|
120
|
-
comments
|
|
121
|
-
.map((c) => {
|
|
122
|
-
const attrs = c.node.attrs;
|
|
121
|
+
for (const attrs of comments) {
|
|
123
122
|
const id = attrs.id;
|
|
124
123
|
const range = ranges.get(id);
|
|
125
124
|
const key = (0, comments_1.getCommentKey)(attrs, range, node);
|
|
126
|
-
|
|
125
|
+
const comment = {
|
|
127
126
|
key,
|
|
128
|
-
|
|
129
|
-
pos: c.pos,
|
|
127
|
+
attrs,
|
|
130
128
|
target,
|
|
131
129
|
range,
|
|
132
130
|
};
|
|
133
|
-
|
|
134
|
-
.
|
|
135
|
-
|
|
136
|
-
if (!c.range) {
|
|
137
|
-
nodeComments.push(c);
|
|
131
|
+
allComments.push(comment);
|
|
132
|
+
if (!comment.range) {
|
|
133
|
+
nodeComments.push(comment);
|
|
138
134
|
}
|
|
139
|
-
else if (
|
|
140
|
-
highlightComments.push(
|
|
135
|
+
else if (comment.range.size) {
|
|
136
|
+
highlightComments.push(comment);
|
|
141
137
|
}
|
|
142
138
|
else {
|
|
143
|
-
pointComments.push(
|
|
139
|
+
pointComments.push(comment);
|
|
144
140
|
}
|
|
145
|
-
}
|
|
141
|
+
}
|
|
146
142
|
for (const comment of highlightComments) {
|
|
147
143
|
const key = comment.key;
|
|
148
144
|
const range = comment.range;
|
|
@@ -165,7 +161,7 @@ const buildPluginState = (doc, selection) => {
|
|
|
165
161
|
});
|
|
166
162
|
return {
|
|
167
163
|
decorations: prosemirror_view_1.DecorationSet.create(doc, decorations),
|
|
168
|
-
comments: new Map(allComments.map((c) => [c.
|
|
164
|
+
comments: new Map(allComments.map((c) => [c.attrs.id, c])),
|
|
169
165
|
commentsByKey: groupByKey(allComments),
|
|
170
166
|
selection,
|
|
171
167
|
};
|
package/dist/cjs/rules.js
CHANGED
|
@@ -35,8 +35,7 @@ exports.default = (0, prosemirror_inputrules_1.inputRules)({
|
|
|
35
35
|
...prosemirror_inputrules_1.smartQuotes,
|
|
36
36
|
prosemirror_inputrules_1.ellipsis,
|
|
37
37
|
prosemirror_inputrules_1.emDash,
|
|
38
|
-
creatingInputRule(
|
|
39
|
-
creatingInputRule(/^\s*\*\s$/, transform_1.schema.nodes.bullet_list),
|
|
38
|
+
creatingInputRule(/^(\d+[.)]\s|\s*\*\s)$/, transform_1.schema.nodes.list),
|
|
40
39
|
creatingInputRule(/^\s*>\s$/, transform_1.schema.nodes.blockquote_element),
|
|
41
40
|
creatingInputRule(/^```$/, transform_1.schema.nodes.listing_element),
|
|
42
41
|
creatingInputRule(/^#\s$/, transform_1.schema.nodes.section),
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -68,26 +68,26 @@ exports.toolbar = {
|
|
|
68
68
|
bullet_list: {
|
|
69
69
|
title: 'Wrap in bullet list',
|
|
70
70
|
content: react_1.default.createElement(style_guide_1.ToolbarUnorderedListIcon, null),
|
|
71
|
-
isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.
|
|
72
|
-
isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
73
|
-
run: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
71
|
+
isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.list),
|
|
72
|
+
isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet'),
|
|
73
|
+
run: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet'),
|
|
74
74
|
options: {
|
|
75
|
-
bullet: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
76
|
-
simple: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
75
|
+
bullet: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'bullet'),
|
|
76
|
+
simple: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'simple'),
|
|
77
77
|
},
|
|
78
78
|
},
|
|
79
79
|
ordered_list: {
|
|
80
80
|
title: 'Wrap in ordered list',
|
|
81
81
|
content: react_1.default.createElement(style_guide_1.ToolbarOrderedListIcon, null),
|
|
82
|
-
isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.
|
|
83
|
-
isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
84
|
-
run: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
82
|
+
isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.list),
|
|
83
|
+
isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'order'),
|
|
84
|
+
run: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'order'),
|
|
85
85
|
options: {
|
|
86
|
-
order: (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
87
|
-
'alpha-upper': (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
88
|
-
'alpha-lower': (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
89
|
-
'roman-upper': (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
90
|
-
'roman-lower': (0, commands_1.insertList)(transform_1.schema.nodes.
|
|
86
|
+
order: (0, commands_1.insertList)(transform_1.schema.nodes.list, 'order'),
|
|
87
|
+
'alpha-upper': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-upper'),
|
|
88
|
+
'alpha-lower': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'alpha-lower'),
|
|
89
|
+
'roman-upper': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-upper'),
|
|
90
|
+
'roman-lower': (0, commands_1.insertList)(transform_1.schema.nodes.list, 'roman-lower'),
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
93
|
},
|