@manuscripts/body-editor 1.10.3-LEAN-3608.3 → 1.10.3
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 +23 -6
- package/dist/cjs/components/toolbar/LevelSelector.js +12 -12
- package/dist/cjs/configs/editor-views.js +6 -2
- package/dist/cjs/keys/list.js +2 -2
- package/dist/cjs/lib/context-menu.js +19 -13
- package/dist/cjs/menus.js +9 -9
- package/dist/cjs/rules.js +2 -1
- package/dist/cjs/toolbar.js +13 -13
- package/dist/cjs/views/bullet_list.js +14 -0
- package/dist/cjs/views/list_item.js +39 -0
- package/dist/cjs/views/ordered_list.js +14 -0
- package/dist/es/commands.js +24 -7
- package/dist/es/components/toolbar/LevelSelector.js +12 -12
- package/dist/es/configs/editor-views.js +6 -2
- package/dist/es/keys/list.js +2 -2
- package/dist/es/lib/context-menu.js +20 -14
- package/dist/es/menus.js +9 -9
- package/dist/es/rules.js +2 -1
- package/dist/es/toolbar.js +13 -13
- package/dist/es/views/bullet_list.js +14 -0
- package/dist/es/views/{list_editable.js → list_item.js} +15 -3
- package/dist/es/views/ordered_list.js +14 -0
- package/dist/types/commands.d.ts +1 -1
- package/dist/types/configs/editor-views.d.ts +38 -2
- package/dist/types/toolbar.d.ts +3 -2
- package/dist/types/views/{list.d.ts → list_item.d.ts} +3 -6
- package/package.json +4 -4
- package/dist/cjs/views/list.js +0 -74
- package/dist/cjs/views/list_editable.js +0 -21
- package/dist/es/views/list.js +0 -66
- package/dist/types/views/list_editable.d.ts +0 -52
package/dist/cjs/commands.js
CHANGED
|
@@ -24,7 +24,6 @@ const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
|
24
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
25
25
|
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
26
26
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
27
|
-
const list_1 = require("./keys/list");
|
|
28
27
|
const helpers_1 = require("./lib/helpers");
|
|
29
28
|
const track_changes_utils_1 = require("./lib/track-changes-utils");
|
|
30
29
|
const utils_1 = require("./lib/utils");
|
|
@@ -394,7 +393,10 @@ const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
394
393
|
return true;
|
|
395
394
|
};
|
|
396
395
|
exports.insertSection = insertSection;
|
|
397
|
-
const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([
|
|
396
|
+
const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([
|
|
397
|
+
transform_1.schema.nodes.ordered_list,
|
|
398
|
+
transform_1.schema.nodes.bullet_list,
|
|
399
|
+
]);
|
|
398
400
|
const findRootList = ($pos) => {
|
|
399
401
|
for (let i = 0; i < $pos.depth; i++) {
|
|
400
402
|
const node = $pos.node(i);
|
|
@@ -447,7 +449,7 @@ function toggleOffList(state, dispatch) {
|
|
|
447
449
|
return false;
|
|
448
450
|
}
|
|
449
451
|
}
|
|
450
|
-
const insertList = (type, style) => (state, dispatch) => {
|
|
452
|
+
const insertList = (type, style) => (state, dispatch, view) => {
|
|
451
453
|
const list = findSelectedList(state.selection);
|
|
452
454
|
if (list) {
|
|
453
455
|
if (!dispatch) {
|
|
@@ -461,12 +463,27 @@ const insertList = (type, style) => (state, dispatch) => {
|
|
|
461
463
|
for (const { node, pos } of nodes) {
|
|
462
464
|
tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
|
|
463
465
|
}
|
|
464
|
-
dispatch(tr);
|
|
466
|
+
dispatch((0, track_changes_plugin_1.skipTracking)(tr));
|
|
465
467
|
return true;
|
|
466
468
|
}
|
|
467
469
|
else {
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
+
const { selection } = state;
|
|
471
|
+
let tr = state.tr;
|
|
472
|
+
return (0, prosemirror_schema_list_1.wrapInList)(type, { listStyleType: style })(state, (tempTr) => {
|
|
473
|
+
const range = selection.$from.blockRange(selection.$to);
|
|
474
|
+
if (range && dispatch) {
|
|
475
|
+
tempTr.steps.map((step) => {
|
|
476
|
+
if (step instanceof prosemirror_transform_1.ReplaceAroundStep) {
|
|
477
|
+
dispatch(tr.step(step));
|
|
478
|
+
tr = (view === null || view === void 0 ? void 0 : view.state.tr) || tr;
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
tr.step(step);
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
dispatch(tr);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
470
487
|
}
|
|
471
488
|
};
|
|
472
489
|
exports.insertList = insertList;
|
|
@@ -225,13 +225,13 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
225
225
|
isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
|
|
226
226
|
}),
|
|
227
227
|
buildOption({
|
|
228
|
-
nodeType: nodes.
|
|
228
|
+
nodeType: nodes.ordered_list,
|
|
229
229
|
value: -3,
|
|
230
230
|
depth: 1,
|
|
231
231
|
isDisabled: true,
|
|
232
232
|
}),
|
|
233
233
|
buildOption({
|
|
234
|
-
nodeType: nodes.
|
|
234
|
+
nodeType: nodes.bullet_list,
|
|
235
235
|
value: -2,
|
|
236
236
|
depth: 1,
|
|
237
237
|
isDisabled: true,
|
|
@@ -291,16 +291,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
291
291
|
isSelected: true,
|
|
292
292
|
}),
|
|
293
293
|
buildOption({
|
|
294
|
-
nodeType: nodes.
|
|
294
|
+
nodeType: nodes.ordered_list,
|
|
295
295
|
value: -3,
|
|
296
296
|
depth: 1,
|
|
297
|
-
action: convertParagraphToList(nodes.
|
|
297
|
+
action: convertParagraphToList(nodes.ordered_list),
|
|
298
298
|
}),
|
|
299
299
|
buildOption({
|
|
300
|
-
nodeType: nodes.
|
|
300
|
+
nodeType: nodes.bullet_list,
|
|
301
301
|
value: -2,
|
|
302
302
|
depth: 1,
|
|
303
|
-
action: convertParagraphToList(nodes.
|
|
303
|
+
action: convertParagraphToList(nodes.bullet_list),
|
|
304
304
|
}),
|
|
305
305
|
];
|
|
306
306
|
const sectionOptions = [];
|
|
@@ -326,7 +326,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
326
326
|
}));
|
|
327
327
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
328
328
|
}
|
|
329
|
-
case schema.nodes.
|
|
329
|
+
case schema.nodes.bullet_list: {
|
|
330
330
|
return [
|
|
331
331
|
{
|
|
332
332
|
options: [
|
|
@@ -342,16 +342,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
342
342
|
{
|
|
343
343
|
options: [
|
|
344
344
|
buildOption({
|
|
345
|
-
nodeType: nodes.
|
|
345
|
+
nodeType: nodes.ordered_list,
|
|
346
346
|
value: -3,
|
|
347
347
|
depth: 1,
|
|
348
|
-
action: convertListType(nodes.
|
|
348
|
+
action: convertListType(nodes.ordered_list, parentElement),
|
|
349
349
|
}),
|
|
350
350
|
],
|
|
351
351
|
},
|
|
352
352
|
];
|
|
353
353
|
}
|
|
354
|
-
case parentElementType.schema.nodes.
|
|
354
|
+
case parentElementType.schema.nodes.ordered_list: {
|
|
355
355
|
return [
|
|
356
356
|
{
|
|
357
357
|
options: [
|
|
@@ -367,10 +367,10 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
367
367
|
{
|
|
368
368
|
options: [
|
|
369
369
|
buildOption({
|
|
370
|
-
nodeType: nodes.
|
|
370
|
+
nodeType: nodes.bullet_list,
|
|
371
371
|
value: -3,
|
|
372
372
|
depth: 1,
|
|
373
|
-
action: convertListType(nodes.
|
|
373
|
+
action: convertListType(nodes.bullet_list, parentElement),
|
|
374
374
|
}),
|
|
375
375
|
],
|
|
376
376
|
},
|
|
@@ -21,6 +21,7 @@ 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"));
|
|
24
25
|
const citation_editable_1 = __importDefault(require("../views/citation_editable"));
|
|
25
26
|
const contributors_1 = __importDefault(require("../views/contributors"));
|
|
26
27
|
const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
|
|
@@ -36,9 +37,10 @@ const inline_footnote_editable_1 = __importDefault(require("../views/inline_foot
|
|
|
36
37
|
const keyword_1 = __importDefault(require("../views/keyword"));
|
|
37
38
|
const keyword_group_1 = __importDefault(require("../views/keyword_group"));
|
|
38
39
|
const link_editable_1 = __importDefault(require("../views/link_editable"));
|
|
39
|
-
const
|
|
40
|
+
const list_item_1 = __importDefault(require("../views/list_item"));
|
|
40
41
|
const listing_editable_1 = __importDefault(require("../views/listing_editable"));
|
|
41
42
|
const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
|
|
43
|
+
const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
|
|
42
44
|
const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
|
|
43
45
|
const placeholder_1 = __importDefault(require("../views/placeholder"));
|
|
44
46
|
const placeholder_element_editable_1 = __importDefault(require("../views/placeholder_element_editable"));
|
|
@@ -54,7 +56,7 @@ exports.default = (props, dispatch) => {
|
|
|
54
56
|
title: (0, title_editable_1.default)(props, dispatch),
|
|
55
57
|
bibliography_element: (0, bibliography_element_editable_1.default)(props, dispatch),
|
|
56
58
|
blockquote_element: (0, blockquote_element_editable_1.default)(props),
|
|
57
|
-
|
|
59
|
+
bullet_list: (0, bullet_list_editable_1.default)(props),
|
|
58
60
|
citation: (0, citation_editable_1.default)(props, dispatch),
|
|
59
61
|
cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
|
|
60
62
|
contributors: (0, contributors_1.default)(props, dispatch),
|
|
@@ -72,6 +74,8 @@ exports.default = (props, dispatch) => {
|
|
|
72
74
|
link: (0, link_editable_1.default)(props, dispatch),
|
|
73
75
|
listing: (0, listing_editable_1.default)(props),
|
|
74
76
|
listing_element: (0, listing_element_editable_1.default)(props),
|
|
77
|
+
list_item: (0, list_item_1.default)(props),
|
|
78
|
+
ordered_list: (0, ordered_list_editable_1.default)(props),
|
|
75
79
|
paragraph: (0, paragraph_editable_1.default)(props),
|
|
76
80
|
placeholder: (0, placeholder_1.default)(props),
|
|
77
81
|
placeholder_element: (0, placeholder_element_editable_1.default)(props),
|
package/dist/cjs/keys/list.js
CHANGED
|
@@ -60,8 +60,8 @@ const listKeymap = {
|
|
|
60
60
|
Enter: (0, prosemirror_schema_list_1.splitListItem)(transform_1.schema.nodes.list_item),
|
|
61
61
|
'Mod-[': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
|
|
62
62
|
'Mod-]': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
|
|
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.
|
|
63
|
+
'Mod-Alt-o': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.ordered_list)),
|
|
64
|
+
'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.bullet_list)),
|
|
65
65
|
'Shift-Tab': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
|
|
66
66
|
Tab: (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
|
|
67
67
|
Backspace: (0, exports.skipCommandTracking)(listItemBackward),
|
|
@@ -28,6 +28,7 @@ const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
|
|
|
28
28
|
const popper_1 = require("./popper");
|
|
29
29
|
const track_changes_utils_1 = require("./track-changes-utils");
|
|
30
30
|
const popper = new popper_1.PopperManager();
|
|
31
|
+
const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
|
|
31
32
|
const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
|
|
32
33
|
const sectionLevel = (depth) => {
|
|
33
34
|
switch (depth) {
|
|
@@ -85,7 +86,7 @@ class ContextMenu {
|
|
|
85
86
|
}
|
|
86
87
|
}));
|
|
87
88
|
}
|
|
88
|
-
if (hasAny(types, 'paragraph', '
|
|
89
|
+
if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
|
|
89
90
|
menu.appendChild(this.createMenuSection((section) => {
|
|
90
91
|
if (types.has('paragraph')) {
|
|
91
92
|
section.appendChild(this.createMenuItem('Paragraph', () => {
|
|
@@ -93,9 +94,15 @@ class ContextMenu {
|
|
|
93
94
|
popper.destroy();
|
|
94
95
|
}));
|
|
95
96
|
}
|
|
96
|
-
if (types.has('
|
|
97
|
-
section.appendChild(this.createMenuItem('List', () => {
|
|
98
|
-
insertNode(transform_1.schema.nodes.
|
|
97
|
+
if (types.has('ordered_list')) {
|
|
98
|
+
section.appendChild(this.createMenuItem('Numbered List', () => {
|
|
99
|
+
insertNode(transform_1.schema.nodes.ordered_list);
|
|
100
|
+
popper.destroy();
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
if (types.has('bullet_list')) {
|
|
104
|
+
section.appendChild(this.createMenuItem('Bullet List', () => {
|
|
105
|
+
insertNode(transform_1.schema.nodes.bullet_list);
|
|
99
106
|
popper.destroy();
|
|
100
107
|
}));
|
|
101
108
|
}
|
|
@@ -140,18 +147,17 @@ class ContextMenu {
|
|
|
140
147
|
menu.className = 'menu';
|
|
141
148
|
const $pos = this.resolvePos();
|
|
142
149
|
const type = this.node.type;
|
|
143
|
-
if (type
|
|
150
|
+
if (listTypes.includes(type)) {
|
|
144
151
|
menu.appendChild(this.createMenuSection((section) => {
|
|
145
|
-
|
|
146
|
-
if (list_type === 'ul') {
|
|
152
|
+
if (type === transform_1.schema.nodes.bullet_list) {
|
|
147
153
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
148
|
-
this.changeNodeType(transform_1.schema.nodes.
|
|
154
|
+
this.changeNodeType(transform_1.schema.nodes.ordered_list);
|
|
149
155
|
popper.destroy();
|
|
150
156
|
}));
|
|
151
157
|
}
|
|
152
|
-
if (
|
|
158
|
+
if (type === transform_1.schema.nodes.ordered_list) {
|
|
153
159
|
section.appendChild(this.createMenuItem('Change to Bullet List', () => {
|
|
154
|
-
this.changeNodeType(transform_1.schema.nodes.
|
|
160
|
+
this.changeNodeType(transform_1.schema.nodes.bullet_list);
|
|
155
161
|
popper.destroy();
|
|
156
162
|
}));
|
|
157
163
|
}
|
|
@@ -311,7 +317,8 @@ class ContextMenu {
|
|
|
311
317
|
}
|
|
312
318
|
checkNode('section', insertPos);
|
|
313
319
|
checkNode('paragraph');
|
|
314
|
-
checkNode('
|
|
320
|
+
checkNode('ordered_list');
|
|
321
|
+
checkNode('bullet_list');
|
|
315
322
|
checkNode('figure_element');
|
|
316
323
|
checkNode('table_element');
|
|
317
324
|
checkNode('equation_element');
|
|
@@ -319,10 +326,9 @@ class ContextMenu {
|
|
|
319
326
|
checkNode('pullquote_element');
|
|
320
327
|
return insertable;
|
|
321
328
|
};
|
|
322
|
-
this.changeNodeType = (nodeType
|
|
329
|
+
this.changeNodeType = (nodeType) => {
|
|
323
330
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
|
|
324
331
|
id: this.node.attrs.id,
|
|
325
|
-
listStyleType: listType,
|
|
326
332
|
}));
|
|
327
333
|
popper.destroy();
|
|
328
334
|
};
|
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.bullet_list)),
|
|
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.bullet_list, 'bullet')),
|
|
311
|
+
simple: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.bullet_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.ordered_list)),
|
|
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.ordered_list, 'order')),
|
|
327
|
+
'alpha-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-upper')),
|
|
328
|
+
'alpha-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-lower')),
|
|
329
|
+
'roman-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-upper')),
|
|
330
|
+
'roman-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-lower')),
|
|
331
331
|
},
|
|
332
332
|
},
|
|
333
333
|
],
|
package/dist/cjs/rules.js
CHANGED
|
@@ -35,7 +35,8 @@ 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(
|
|
38
|
+
creatingInputRule(/^\d+[.)]\s$/, transform_1.schema.nodes.ordered_list),
|
|
39
|
+
creatingInputRule(/^\s*\*\s$/, transform_1.schema.nodes.bullet_list),
|
|
39
40
|
creatingInputRule(/^\s*>\s$/, transform_1.schema.nodes.blockquote_element),
|
|
40
41
|
creatingInputRule(/^```$/, transform_1.schema.nodes.listing_element),
|
|
41
42
|
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.bullet_list),
|
|
72
|
+
isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
|
|
73
|
+
run: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_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.bullet_list, 'bullet'),
|
|
76
|
+
simple: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_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.ordered_list),
|
|
83
|
+
isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'order'),
|
|
84
|
+
run: (0, commands_1.insertList)(transform_1.schema.nodes.ordered_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.ordered_list, 'order'),
|
|
87
|
+
'alpha-upper': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-upper'),
|
|
88
|
+
'alpha-lower': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-lower'),
|
|
89
|
+
'roman-upper': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-upper'),
|
|
90
|
+
'roman-lower': (0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-lower'),
|
|
91
91
|
},
|
|
92
92
|
},
|
|
93
93
|
},
|
|
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.bulletListCallback = exports.BulletListView = void 0;
|
|
22
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
22
23
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
24
|
const creators_1 = require("./creators");
|
|
24
25
|
const ordered_list_1 = require("./ordered_list");
|
|
@@ -30,6 +31,19 @@ class BulletListView extends block_view_1.default {
|
|
|
30
31
|
if (this.contentDOM) {
|
|
31
32
|
const type = this.node.attrs.listStyleType || 'bullet';
|
|
32
33
|
this.contentDOM.style.listStyleType = ordered_list_1.JATS_HTML_LIST_STYLE_MAPPING[type];
|
|
34
|
+
const classes = [
|
|
35
|
+
'block',
|
|
36
|
+
...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
|
|
37
|
+
];
|
|
38
|
+
if (this.node.attrs.dataTracked) {
|
|
39
|
+
this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
|
|
40
|
+
this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.dom.removeAttribute('data-track-status');
|
|
44
|
+
this.dom.removeAttribute('data-track-op');
|
|
45
|
+
}
|
|
46
|
+
this.contentDOM.className = classes.join(' ');
|
|
33
47
|
}
|
|
34
48
|
};
|
|
35
49
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.listItemCallback = exports.ListItemView = void 0;
|
|
22
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
23
|
+
const block_view_1 = __importDefault(require("./block_view"));
|
|
24
|
+
const creators_1 = require("./creators");
|
|
25
|
+
class ListItemView extends block_view_1.default {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.elementType = 'li';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.ListItemView = ListItemView;
|
|
32
|
+
const listItemCallback = (node, dom) => {
|
|
33
|
+
if (node.attrs.dataTracked) {
|
|
34
|
+
const classes = (0, track_changes_utils_1.getChangeClasses)(node.attrs.dataTracked);
|
|
35
|
+
dom.className = classes.join(' ');
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
exports.listItemCallback = listItemCallback;
|
|
39
|
+
exports.default = (0, creators_1.createNodeOrElementView)(ListItemView, 'li', exports.listItemCallback);
|
|
@@ -19,6 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.orderedListCallback = exports.OrderedListView = exports.JATS_HTML_LIST_STYLE_MAPPING = void 0;
|
|
22
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
22
23
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
24
|
const creators_1 = require("./creators");
|
|
24
25
|
exports.JATS_HTML_LIST_STYLE_MAPPING = {
|
|
@@ -38,6 +39,19 @@ class OrderedListView extends block_view_1.default {
|
|
|
38
39
|
if (this.contentDOM) {
|
|
39
40
|
const type = this.node.attrs.listStyleType || 'order';
|
|
40
41
|
this.contentDOM.style.listStyleType = exports.JATS_HTML_LIST_STYLE_MAPPING[type];
|
|
42
|
+
const classes = [
|
|
43
|
+
'block',
|
|
44
|
+
...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
|
|
45
|
+
];
|
|
46
|
+
if (this.node.attrs.dataTracked) {
|
|
47
|
+
this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
|
|
48
|
+
this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.dom.removeAttribute('data-track-status');
|
|
52
|
+
this.dom.removeAttribute('data-track-op');
|
|
53
|
+
}
|
|
54
|
+
this.contentDOM.className = classes.join(' ');
|
|
41
55
|
}
|
|
42
56
|
};
|
|
43
57
|
}
|
package/dist/es/commands.js
CHANGED
|
@@ -19,9 +19,8 @@ import { buildComment, generateID, isElementNodeType, isFootnoteNode, isInBiblio
|
|
|
19
19
|
import { NodeRange } from 'prosemirror-model';
|
|
20
20
|
import { wrapInList } from 'prosemirror-schema-list';
|
|
21
21
|
import { NodeSelection, TextSelection, } from 'prosemirror-state';
|
|
22
|
-
import { findWrapping, liftTarget } from 'prosemirror-transform';
|
|
22
|
+
import { findWrapping, liftTarget, ReplaceAroundStep, } from 'prosemirror-transform';
|
|
23
23
|
import { findChildrenByType, findParentNodeOfType, } from 'prosemirror-utils';
|
|
24
|
-
import { skipCommandTracking } from './keys/list';
|
|
25
24
|
import { isNodeOfType, nearestAncestor } from './lib/helpers';
|
|
26
25
|
import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
|
|
27
26
|
import { findParentNodeWithId, getChildOfType } from './lib/utils';
|
|
@@ -372,7 +371,10 @@ export const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
372
371
|
}
|
|
373
372
|
return true;
|
|
374
373
|
};
|
|
375
|
-
const findSelectedList = findParentNodeOfType([
|
|
374
|
+
const findSelectedList = findParentNodeOfType([
|
|
375
|
+
schema.nodes.ordered_list,
|
|
376
|
+
schema.nodes.bullet_list,
|
|
377
|
+
]);
|
|
376
378
|
const findRootList = ($pos) => {
|
|
377
379
|
for (let i = 0; i < $pos.depth; i++) {
|
|
378
380
|
const node = $pos.node(i);
|
|
@@ -425,7 +427,7 @@ function toggleOffList(state, dispatch) {
|
|
|
425
427
|
return false;
|
|
426
428
|
}
|
|
427
429
|
}
|
|
428
|
-
export const insertList = (type, style) => (state, dispatch) => {
|
|
430
|
+
export const insertList = (type, style) => (state, dispatch, view) => {
|
|
429
431
|
const list = findSelectedList(state.selection);
|
|
430
432
|
if (list) {
|
|
431
433
|
if (!dispatch) {
|
|
@@ -439,12 +441,27 @@ export const insertList = (type, style) => (state, dispatch) => {
|
|
|
439
441
|
for (const { node, pos } of nodes) {
|
|
440
442
|
tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
|
|
441
443
|
}
|
|
442
|
-
dispatch(tr);
|
|
444
|
+
dispatch(skipTracking(tr));
|
|
443
445
|
return true;
|
|
444
446
|
}
|
|
445
447
|
else {
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
+
const { selection } = state;
|
|
449
|
+
let tr = state.tr;
|
|
450
|
+
return wrapInList(type, { listStyleType: style })(state, (tempTr) => {
|
|
451
|
+
const range = selection.$from.blockRange(selection.$to);
|
|
452
|
+
if (range && dispatch) {
|
|
453
|
+
tempTr.steps.map((step) => {
|
|
454
|
+
if (step instanceof ReplaceAroundStep) {
|
|
455
|
+
dispatch(tr.step(step));
|
|
456
|
+
tr = (view === null || view === void 0 ? void 0 : view.state.tr) || tr;
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
tr.step(step);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
dispatch(tr);
|
|
463
|
+
}
|
|
464
|
+
});
|
|
448
465
|
}
|
|
449
466
|
};
|
|
450
467
|
export const insertBibliographySection = () => {
|
|
@@ -219,13 +219,13 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
219
219
|
isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
|
|
220
220
|
}),
|
|
221
221
|
buildOption({
|
|
222
|
-
nodeType: nodes.
|
|
222
|
+
nodeType: nodes.ordered_list,
|
|
223
223
|
value: -3,
|
|
224
224
|
depth: 1,
|
|
225
225
|
isDisabled: true,
|
|
226
226
|
}),
|
|
227
227
|
buildOption({
|
|
228
|
-
nodeType: nodes.
|
|
228
|
+
nodeType: nodes.bullet_list,
|
|
229
229
|
value: -2,
|
|
230
230
|
depth: 1,
|
|
231
231
|
isDisabled: true,
|
|
@@ -285,16 +285,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
285
285
|
isSelected: true,
|
|
286
286
|
}),
|
|
287
287
|
buildOption({
|
|
288
|
-
nodeType: nodes.
|
|
288
|
+
nodeType: nodes.ordered_list,
|
|
289
289
|
value: -3,
|
|
290
290
|
depth: 1,
|
|
291
|
-
action: convertParagraphToList(nodes.
|
|
291
|
+
action: convertParagraphToList(nodes.ordered_list),
|
|
292
292
|
}),
|
|
293
293
|
buildOption({
|
|
294
|
-
nodeType: nodes.
|
|
294
|
+
nodeType: nodes.bullet_list,
|
|
295
295
|
value: -2,
|
|
296
296
|
depth: 1,
|
|
297
|
-
action: convertParagraphToList(nodes.
|
|
297
|
+
action: convertParagraphToList(nodes.bullet_list),
|
|
298
298
|
}),
|
|
299
299
|
];
|
|
300
300
|
const sectionOptions = [];
|
|
@@ -320,7 +320,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
320
320
|
}));
|
|
321
321
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
322
322
|
}
|
|
323
|
-
case schema.nodes.
|
|
323
|
+
case schema.nodes.bullet_list: {
|
|
324
324
|
return [
|
|
325
325
|
{
|
|
326
326
|
options: [
|
|
@@ -336,16 +336,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
336
336
|
{
|
|
337
337
|
options: [
|
|
338
338
|
buildOption({
|
|
339
|
-
nodeType: nodes.
|
|
339
|
+
nodeType: nodes.ordered_list,
|
|
340
340
|
value: -3,
|
|
341
341
|
depth: 1,
|
|
342
|
-
action: convertListType(nodes.
|
|
342
|
+
action: convertListType(nodes.ordered_list, parentElement),
|
|
343
343
|
}),
|
|
344
344
|
],
|
|
345
345
|
},
|
|
346
346
|
];
|
|
347
347
|
}
|
|
348
|
-
case parentElementType.schema.nodes.
|
|
348
|
+
case parentElementType.schema.nodes.ordered_list: {
|
|
349
349
|
return [
|
|
350
350
|
{
|
|
351
351
|
options: [
|
|
@@ -361,10 +361,10 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
361
361
|
{
|
|
362
362
|
options: [
|
|
363
363
|
buildOption({
|
|
364
|
-
nodeType: nodes.
|
|
364
|
+
nodeType: nodes.bullet_list,
|
|
365
365
|
value: -3,
|
|
366
366
|
depth: 1,
|
|
367
|
-
action: convertListType(nodes.
|
|
367
|
+
action: convertListType(nodes.bullet_list, parentElement),
|
|
368
368
|
}),
|
|
369
369
|
],
|
|
370
370
|
},
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import affiliations from '../views/affiliations';
|
|
17
17
|
import bibliographyElement from '../views/bibliography_element_editable';
|
|
18
18
|
import blockquoteElement from '../views/blockquote_element_editable';
|
|
19
|
+
import bulletList from '../views/bullet_list_editable';
|
|
19
20
|
import citation from '../views/citation_editable';
|
|
20
21
|
import contributors from '../views/contributors';
|
|
21
22
|
import crossReference from '../views/cross_reference_editable';
|
|
@@ -31,9 +32,10 @@ import inlineFootnote from '../views/inline_footnote_editable';
|
|
|
31
32
|
import keyword from '../views/keyword';
|
|
32
33
|
import keywordGroup from '../views/keyword_group';
|
|
33
34
|
import link from '../views/link_editable';
|
|
34
|
-
import
|
|
35
|
+
import list_item from '../views/list_item';
|
|
35
36
|
import listing from '../views/listing_editable';
|
|
36
37
|
import listingElement from '../views/listing_element_editable';
|
|
38
|
+
import orderedList from '../views/ordered_list_editable';
|
|
37
39
|
import paragraph from '../views/paragraph_editable';
|
|
38
40
|
import placeholder from '../views/placeholder';
|
|
39
41
|
import placeholderElement from '../views/placeholder_element_editable';
|
|
@@ -49,7 +51,7 @@ export default (props, dispatch) => {
|
|
|
49
51
|
title: title(props, dispatch),
|
|
50
52
|
bibliography_element: bibliographyElement(props, dispatch),
|
|
51
53
|
blockquote_element: blockquoteElement(props),
|
|
52
|
-
|
|
54
|
+
bullet_list: bulletList(props),
|
|
53
55
|
citation: citation(props, dispatch),
|
|
54
56
|
cross_reference: crossReference(props, dispatch),
|
|
55
57
|
contributors: contributors(props, dispatch),
|
|
@@ -67,6 +69,8 @@ export default (props, dispatch) => {
|
|
|
67
69
|
link: link(props, dispatch),
|
|
68
70
|
listing: listing(props),
|
|
69
71
|
listing_element: listingElement(props),
|
|
72
|
+
list_item: list_item(props),
|
|
73
|
+
ordered_list: orderedList(props),
|
|
70
74
|
paragraph: paragraph(props),
|
|
71
75
|
placeholder: placeholder(props),
|
|
72
76
|
placeholder_element: placeholderElement(props),
|