@manuscripts/body-editor 1.10.10-LEAN-3608.0 → 1.10.10
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 +7 -4
- package/dist/cjs/components/toolbar/LevelSelector.js +39 -21
- package/dist/cjs/configs/editor-views.js +4 -2
- package/dist/cjs/keys/list.js +2 -2
- package/dist/cjs/lib/context-menu.js +19 -21
- package/dist/cjs/menus.js +9 -9
- package/dist/cjs/node-type-icons.js +3 -9
- package/dist/cjs/plugins/footnotes/footnotes-utils.js +6 -2
- package/dist/cjs/rules.js +2 -1
- package/dist/cjs/toolbar.js +13 -13
- package/dist/es/commands.js +7 -4
- package/dist/es/components/toolbar/LevelSelector.js +40 -22
- package/dist/es/configs/editor-views.js +4 -2
- package/dist/es/keys/list.js +2 -2
- package/dist/es/lib/context-menu.js +20 -22
- package/dist/es/menus.js +9 -9
- package/dist/es/node-type-icons.js +3 -9
- package/dist/es/plugins/footnotes/footnotes-utils.js +6 -2
- package/dist/es/rules.js +2 -1
- package/dist/es/toolbar.js +13 -13
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/configs/editor-views.d.ts +37 -2
- package/dist/types/node-type-icons.d.ts +1 -1
- package/dist/types/plugins/footnotes/footnotes-utils.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/views/list.js +0 -56
- package/dist/es/views/list.js +0 -48
- package/dist/types/views/list.d.ts +0 -59
package/dist/cjs/commands.js
CHANGED
|
@@ -95,7 +95,7 @@ const createSelection = (nodeType, position, doc) => {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
exports.createSelection = createSelection;
|
|
98
|
-
const createBlock = (nodeType, position, state, dispatch
|
|
98
|
+
const createBlock = (nodeType, position, state, dispatch) => {
|
|
99
99
|
let node;
|
|
100
100
|
switch (nodeType) {
|
|
101
101
|
case state.schema.nodes.table_element:
|
|
@@ -116,7 +116,7 @@ const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
|
116
116
|
]);
|
|
117
117
|
break;
|
|
118
118
|
default:
|
|
119
|
-
node = nodeType.createAndFill(
|
|
119
|
+
node = nodeType.createAndFill();
|
|
120
120
|
}
|
|
121
121
|
const tr = state.tr.insert(position, node);
|
|
122
122
|
if (dispatch) {
|
|
@@ -393,7 +393,10 @@ const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
393
393
|
return true;
|
|
394
394
|
};
|
|
395
395
|
exports.insertSection = insertSection;
|
|
396
|
-
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
|
+
]);
|
|
397
400
|
const findRootList = ($pos) => {
|
|
398
401
|
for (let i = 0; i < $pos.depth; i++) {
|
|
399
402
|
const node = $pos.node(i);
|
|
@@ -460,7 +463,7 @@ const insertList = (type, style) => (state, dispatch, view) => {
|
|
|
460
463
|
for (const { node, pos } of nodes) {
|
|
461
464
|
tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
|
|
462
465
|
}
|
|
463
|
-
dispatch(tr);
|
|
466
|
+
dispatch((0, track_changes_plugin_1.skipTracking)(tr));
|
|
464
467
|
return true;
|
|
465
468
|
}
|
|
466
469
|
else {
|
|
@@ -36,7 +36,7 @@ const optionName = (nodeType, depth) => {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
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
|
|
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) }));
|
|
40
40
|
const buildOptions = (state, dispatch, view) => {
|
|
41
41
|
const { doc, selection: { $from, $to }, schema, tr, } = state;
|
|
42
42
|
const { nodes } = schema;
|
|
@@ -189,13 +189,12 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
189
189
|
dispatch(tr.scrollIntoView());
|
|
190
190
|
view && view.focus();
|
|
191
191
|
};
|
|
192
|
-
const convertParagraphToList = (nodeType
|
|
192
|
+
const convertParagraphToList = (nodeType) => () => {
|
|
193
193
|
const paragraph = $from.node($from.depth);
|
|
194
194
|
const beforeParagraph = $from.before($from.depth);
|
|
195
195
|
const afterParagraph = $from.after($from.depth);
|
|
196
196
|
const list = nodeType.create({
|
|
197
197
|
id: (0, transform_1.generateNodeID)(nodeType),
|
|
198
|
-
listStyleType: listType,
|
|
199
198
|
}, nodes.list_item.create({}, schema.nodes.paragraph.create({}, paragraph.content)));
|
|
200
199
|
tr.replaceWith(beforeParagraph, afterParagraph, list);
|
|
201
200
|
const anchor = beforeParagraph + 3;
|
|
@@ -203,8 +202,8 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
203
202
|
dispatch(tr.scrollIntoView());
|
|
204
203
|
view && view.focus();
|
|
205
204
|
};
|
|
206
|
-
const convertListType = (nodeType, list
|
|
207
|
-
tr.setNodeMarkup(list.before, nodeType,
|
|
205
|
+
const convertListType = (nodeType, list) => () => {
|
|
206
|
+
tr.setNodeMarkup(list.before, nodeType, list.node.attrs);
|
|
208
207
|
dispatch(tr.scrollIntoView());
|
|
209
208
|
view && view.focus();
|
|
210
209
|
};
|
|
@@ -226,18 +225,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
226
225
|
isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
|
|
227
226
|
}),
|
|
228
227
|
buildOption({
|
|
229
|
-
nodeType: nodes.
|
|
228
|
+
nodeType: nodes.ordered_list,
|
|
230
229
|
value: -3,
|
|
231
230
|
depth: 1,
|
|
232
231
|
isDisabled: true,
|
|
233
|
-
listType: 'order',
|
|
234
232
|
}),
|
|
235
233
|
buildOption({
|
|
236
|
-
nodeType: nodes.
|
|
234
|
+
nodeType: nodes.bullet_list,
|
|
237
235
|
value: -2,
|
|
238
236
|
depth: 1,
|
|
239
237
|
isDisabled: true,
|
|
240
|
-
listType: 'bullet',
|
|
241
238
|
}),
|
|
242
239
|
];
|
|
243
240
|
const sectionOptions = [];
|
|
@@ -294,18 +291,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
294
291
|
isSelected: true,
|
|
295
292
|
}),
|
|
296
293
|
buildOption({
|
|
297
|
-
nodeType: nodes.
|
|
294
|
+
nodeType: nodes.ordered_list,
|
|
298
295
|
value: -3,
|
|
299
296
|
depth: 1,
|
|
300
|
-
action: convertParagraphToList(nodes.
|
|
301
|
-
listType: 'order',
|
|
297
|
+
action: convertParagraphToList(nodes.ordered_list),
|
|
302
298
|
}),
|
|
303
299
|
buildOption({
|
|
304
|
-
nodeType: nodes.
|
|
300
|
+
nodeType: nodes.bullet_list,
|
|
305
301
|
value: -2,
|
|
306
302
|
depth: 1,
|
|
307
|
-
action: convertParagraphToList(nodes.
|
|
308
|
-
listType: 'bullet',
|
|
303
|
+
action: convertParagraphToList(nodes.bullet_list),
|
|
309
304
|
}),
|
|
310
305
|
];
|
|
311
306
|
const sectionOptions = [];
|
|
@@ -331,8 +326,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
331
326
|
}));
|
|
332
327
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
333
328
|
}
|
|
334
|
-
case schema.nodes.
|
|
335
|
-
const { style, type } = (0, transform_1.getListType)(parentElement.node.attrs.listStyleType);
|
|
329
|
+
case schema.nodes.bullet_list: {
|
|
336
330
|
return [
|
|
337
331
|
{
|
|
338
332
|
options: [
|
|
@@ -348,11 +342,35 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
348
342
|
{
|
|
349
343
|
options: [
|
|
350
344
|
buildOption({
|
|
351
|
-
nodeType: nodes.
|
|
345
|
+
nodeType: nodes.ordered_list,
|
|
352
346
|
value: -3,
|
|
353
347
|
depth: 1,
|
|
354
|
-
action: convertListType(nodes.
|
|
355
|
-
|
|
348
|
+
action: convertListType(nodes.ordered_list, parentElement),
|
|
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
374
|
}),
|
|
357
375
|
],
|
|
358
376
|
},
|
|
@@ -440,7 +458,7 @@ const LevelSelector = ({ state, dispatch, view }) => {
|
|
|
440
458
|
style.opacity = 0.4;
|
|
441
459
|
}
|
|
442
460
|
return (react_1.default.createElement(OptionContainer, Object.assign({}, props.innerProps, { ref: null, style: style }),
|
|
443
|
-
react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType
|
|
461
|
+
react_1.default.createElement(OptionIcon, null, (0, node_type_icons_1.nodeTypeIcon)(data.nodeType)),
|
|
444
462
|
react_1.default.createElement(OptionLabel, null, data.label)));
|
|
445
463
|
},
|
|
446
464
|
}, onChange: (value) => {
|
|
@@ -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,10 +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 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"));
|
|
43
44
|
const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
|
|
44
45
|
const placeholder_1 = __importDefault(require("../views/placeholder"));
|
|
45
46
|
const placeholder_element_editable_1 = __importDefault(require("../views/placeholder_element_editable"));
|
|
@@ -55,7 +56,7 @@ exports.default = (props, dispatch) => {
|
|
|
55
56
|
title: (0, title_editable_1.default)(props, dispatch),
|
|
56
57
|
bibliography_element: (0, bibliography_element_editable_1.default)(props, dispatch),
|
|
57
58
|
blockquote_element: (0, blockquote_element_editable_1.default)(props),
|
|
58
|
-
|
|
59
|
+
bullet_list: (0, bullet_list_editable_1.default)(props),
|
|
59
60
|
citation: (0, citation_editable_1.default)(props, dispatch),
|
|
60
61
|
cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
|
|
61
62
|
contributors: (0, contributors_1.default)(props, dispatch),
|
|
@@ -74,6 +75,7 @@ exports.default = (props, dispatch) => {
|
|
|
74
75
|
listing: (0, listing_editable_1.default)(props),
|
|
75
76
|
listing_element: (0, listing_element_editable_1.default)(props),
|
|
76
77
|
list_item: (0, list_item_1.default)(props),
|
|
78
|
+
ordered_list: (0, ordered_list_editable_1.default)(props),
|
|
77
79
|
paragraph: (0, paragraph_editable_1.default)(props),
|
|
78
80
|
placeholder: (0, placeholder_1.default)(props),
|
|
79
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) {
|
|
@@ -54,12 +55,12 @@ class ContextMenu {
|
|
|
54
55
|
const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
|
|
55
56
|
const endPos = $pos.end();
|
|
56
57
|
const types = this.insertableTypes(after, insertPos, endPos);
|
|
57
|
-
const insertNode = (type, pos
|
|
58
|
+
const insertNode = (type, pos) => {
|
|
58
59
|
const { state, dispatch } = this.view;
|
|
59
60
|
if (pos === undefined) {
|
|
60
61
|
pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
|
|
61
62
|
}
|
|
62
|
-
(0, commands_1.createBlock)(type, pos, state, dispatch
|
|
63
|
+
(0, commands_1.createBlock)(type, pos, state, dispatch);
|
|
63
64
|
};
|
|
64
65
|
if (hasAny(types, 'section', 'subsection')) {
|
|
65
66
|
menu.appendChild(this.createMenuSection((section) => {
|
|
@@ -86,7 +87,7 @@ class ContextMenu {
|
|
|
86
87
|
}
|
|
87
88
|
}));
|
|
88
89
|
}
|
|
89
|
-
if (hasAny(types, 'paragraph', '
|
|
90
|
+
if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
|
|
90
91
|
menu.appendChild(this.createMenuSection((section) => {
|
|
91
92
|
if (types.has('paragraph')) {
|
|
92
93
|
section.appendChild(this.createMenuItem('Paragraph', () => {
|
|
@@ -94,17 +95,15 @@ class ContextMenu {
|
|
|
94
95
|
popper.destroy();
|
|
95
96
|
}));
|
|
96
97
|
}
|
|
97
|
-
if (types.has('
|
|
98
|
-
section.appendChild(this.createMenuItem('
|
|
99
|
-
insertNode(transform_1.schema.nodes.
|
|
100
|
-
listStyleType: 'bullet',
|
|
101
|
-
});
|
|
98
|
+
if (types.has('ordered_list')) {
|
|
99
|
+
section.appendChild(this.createMenuItem('Numbered List', () => {
|
|
100
|
+
insertNode(transform_1.schema.nodes.ordered_list);
|
|
102
101
|
popper.destroy();
|
|
103
102
|
}));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
}
|
|
104
|
+
if (types.has('bullet_list')) {
|
|
105
|
+
section.appendChild(this.createMenuItem('Bullet List', () => {
|
|
106
|
+
insertNode(transform_1.schema.nodes.bullet_list);
|
|
108
107
|
popper.destroy();
|
|
109
108
|
}));
|
|
110
109
|
}
|
|
@@ -149,18 +148,17 @@ class ContextMenu {
|
|
|
149
148
|
menu.className = 'menu';
|
|
150
149
|
const $pos = this.resolvePos();
|
|
151
150
|
const type = this.node.type;
|
|
152
|
-
if (type
|
|
151
|
+
if (listTypes.includes(type)) {
|
|
153
152
|
menu.appendChild(this.createMenuSection((section) => {
|
|
154
|
-
|
|
155
|
-
if (listType === 'ul') {
|
|
153
|
+
if (type === transform_1.schema.nodes.bullet_list) {
|
|
156
154
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
157
|
-
this.changeNodeType(transform_1.schema.nodes.
|
|
155
|
+
this.changeNodeType(transform_1.schema.nodes.ordered_list);
|
|
158
156
|
popper.destroy();
|
|
159
157
|
}));
|
|
160
158
|
}
|
|
161
|
-
if (
|
|
159
|
+
if (type === transform_1.schema.nodes.ordered_list) {
|
|
162
160
|
section.appendChild(this.createMenuItem('Change to Bullet List', () => {
|
|
163
|
-
this.changeNodeType(transform_1.schema.nodes.
|
|
161
|
+
this.changeNodeType(transform_1.schema.nodes.bullet_list);
|
|
164
162
|
popper.destroy();
|
|
165
163
|
}));
|
|
166
164
|
}
|
|
@@ -320,7 +318,8 @@ class ContextMenu {
|
|
|
320
318
|
}
|
|
321
319
|
checkNode('section', insertPos);
|
|
322
320
|
checkNode('paragraph');
|
|
323
|
-
checkNode('
|
|
321
|
+
checkNode('ordered_list');
|
|
322
|
+
checkNode('bullet_list');
|
|
324
323
|
checkNode('figure_element');
|
|
325
324
|
checkNode('table_element');
|
|
326
325
|
checkNode('equation_element');
|
|
@@ -328,10 +327,9 @@ class ContextMenu {
|
|
|
328
327
|
checkNode('pullquote_element');
|
|
329
328
|
return insertable;
|
|
330
329
|
};
|
|
331
|
-
this.changeNodeType = (nodeType
|
|
330
|
+
this.changeNodeType = (nodeType) => {
|
|
332
331
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
|
|
333
332
|
id: this.node.attrs.id,
|
|
334
|
-
listStyleType: listType,
|
|
335
333
|
}));
|
|
336
334
|
popper.destroy();
|
|
337
335
|
};
|
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
|
],
|
|
@@ -27,8 +27,10 @@ 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],
|
|
30
31
|
[nodes.equation_element, style_guide_1.OutlineEquationIcon],
|
|
31
32
|
[nodes.figure_element, style_guide_1.OutlineFigureIcon],
|
|
33
|
+
[nodes.ordered_list, style_guide_1.OutlineOrderedListIcon],
|
|
32
34
|
[nodes.paragraph, style_guide_1.OutlineParagraphIcon],
|
|
33
35
|
[nodes.pullquote_element, style_guide_1.OutlinePullQuoteIcon],
|
|
34
36
|
[nodes.section, style_guide_1.OutlineSectionIcon],
|
|
@@ -37,15 +39,7 @@ const icons = new Map([
|
|
|
37
39
|
[nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
|
|
38
40
|
[nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
|
|
39
41
|
]);
|
|
40
|
-
const nodeTypeIcon = (nodeType
|
|
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
|
-
}
|
|
42
|
+
const nodeTypeIcon = (nodeType) => {
|
|
49
43
|
const Icon = icons.get(nodeType);
|
|
50
44
|
return Icon ? react_1.default.createElement(Icon, null) : null;
|
|
51
45
|
};
|
|
@@ -79,8 +79,12 @@ const orderTableFootnotes = (tr, footnotesElementWithPos, position) => {
|
|
|
79
79
|
})
|
|
80
80
|
.map(({ node }) => node);
|
|
81
81
|
const { node: footnotesElement, pos } = footnotesElementWithPos;
|
|
82
|
-
const footnoteElementPos = position + pos;
|
|
83
|
-
|
|
82
|
+
const footnoteElementPos = position + pos + 1;
|
|
83
|
+
const oldDataTracked = footnotesElement.attrs.dataTracked;
|
|
84
|
+
(0, track_changes_plugin_1.skipTracking)(tr.replaceWith(tr.mapping.map(footnoteElementPos), tr.mapping.map(footnoteElementPos + footnotesElement.nodeSize), prosemirror_model_1.Fragment.fromArray(orderedFootnotes)));
|
|
85
|
+
if (oldDataTracked) {
|
|
86
|
+
tr.setNodeMarkup(footnoteElementPos, transform_1.schema.nodes.footnotes_element, Object.assign(Object.assign({}, footnotesElement.attrs), { dataTracked: oldDataTracked }));
|
|
87
|
+
}
|
|
84
88
|
};
|
|
85
89
|
exports.orderTableFootnotes = orderTableFootnotes;
|
|
86
90
|
const updateTableInlineFootnoteLabels = (tr, table) => {
|
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
|
},
|
package/dist/es/commands.js
CHANGED
|
@@ -87,7 +87,7 @@ export const createSelection = (nodeType, position, doc) => {
|
|
|
87
87
|
: TextSelection.near(doc.resolve(position + 1));
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
export const createBlock = (nodeType, position, state, dispatch
|
|
90
|
+
export const createBlock = (nodeType, position, state, dispatch) => {
|
|
91
91
|
let node;
|
|
92
92
|
switch (nodeType) {
|
|
93
93
|
case state.schema.nodes.table_element:
|
|
@@ -108,7 +108,7 @@ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
|
108
108
|
]);
|
|
109
109
|
break;
|
|
110
110
|
default:
|
|
111
|
-
node = nodeType.createAndFill(
|
|
111
|
+
node = nodeType.createAndFill();
|
|
112
112
|
}
|
|
113
113
|
const tr = state.tr.insert(position, node);
|
|
114
114
|
if (dispatch) {
|
|
@@ -371,7 +371,10 @@ export const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
371
371
|
}
|
|
372
372
|
return true;
|
|
373
373
|
};
|
|
374
|
-
const findSelectedList = findParentNodeOfType([
|
|
374
|
+
const findSelectedList = findParentNodeOfType([
|
|
375
|
+
schema.nodes.ordered_list,
|
|
376
|
+
schema.nodes.bullet_list,
|
|
377
|
+
]);
|
|
375
378
|
const findRootList = ($pos) => {
|
|
376
379
|
for (let i = 0; i < $pos.depth; i++) {
|
|
377
380
|
const node = $pos.node(i);
|
|
@@ -438,7 +441,7 @@ export const insertList = (type, style) => (state, dispatch, view) => {
|
|
|
438
441
|
for (const { node, pos } of nodes) {
|
|
439
442
|
tr.setNodeMarkup(pos, type, Object.assign(Object.assign({}, node.attrs), { listStyleType: style }), node.marks);
|
|
440
443
|
}
|
|
441
|
-
dispatch(tr);
|
|
444
|
+
dispatch(skipTracking(tr));
|
|
442
445
|
return true;
|
|
443
446
|
}
|
|
444
447
|
else {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { generateNodeID,
|
|
16
|
+
import { generateNodeID, isSectionNodeType, nodeNames, } from '@manuscripts/transform';
|
|
17
17
|
import { Fragment } from 'prosemirror-model';
|
|
18
18
|
import { TextSelection } from 'prosemirror-state';
|
|
19
19
|
import React from 'react';
|
|
@@ -30,7 +30,7 @@ const optionName = (nodeType, depth) => {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
|
|
33
|
-
const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: nodeTypeIcon(props.nodeType
|
|
33
|
+
const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: nodeTypeIcon(props.nodeType), label: titleCase(optionName(props.nodeType, props.depth)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
|
|
34
34
|
const buildOptions = (state, dispatch, view) => {
|
|
35
35
|
const { doc, selection: { $from, $to }, schema, tr, } = state;
|
|
36
36
|
const { nodes } = schema;
|
|
@@ -183,13 +183,12 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
183
183
|
dispatch(tr.scrollIntoView());
|
|
184
184
|
view && view.focus();
|
|
185
185
|
};
|
|
186
|
-
const convertParagraphToList = (nodeType
|
|
186
|
+
const convertParagraphToList = (nodeType) => () => {
|
|
187
187
|
const paragraph = $from.node($from.depth);
|
|
188
188
|
const beforeParagraph = $from.before($from.depth);
|
|
189
189
|
const afterParagraph = $from.after($from.depth);
|
|
190
190
|
const list = nodeType.create({
|
|
191
191
|
id: generateNodeID(nodeType),
|
|
192
|
-
listStyleType: listType,
|
|
193
192
|
}, nodes.list_item.create({}, schema.nodes.paragraph.create({}, paragraph.content)));
|
|
194
193
|
tr.replaceWith(beforeParagraph, afterParagraph, list);
|
|
195
194
|
const anchor = beforeParagraph + 3;
|
|
@@ -197,8 +196,8 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
197
196
|
dispatch(tr.scrollIntoView());
|
|
198
197
|
view && view.focus();
|
|
199
198
|
};
|
|
200
|
-
const convertListType = (nodeType, list
|
|
201
|
-
tr.setNodeMarkup(list.before, nodeType,
|
|
199
|
+
const convertListType = (nodeType, list) => () => {
|
|
200
|
+
tr.setNodeMarkup(list.before, nodeType, list.node.attrs);
|
|
202
201
|
dispatch(tr.scrollIntoView());
|
|
203
202
|
view && view.focus();
|
|
204
203
|
};
|
|
@@ -220,18 +219,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
220
219
|
isDisabled: sectionDepth <= 1 && sectionOffset <= 1,
|
|
221
220
|
}),
|
|
222
221
|
buildOption({
|
|
223
|
-
nodeType: nodes.
|
|
222
|
+
nodeType: nodes.ordered_list,
|
|
224
223
|
value: -3,
|
|
225
224
|
depth: 1,
|
|
226
225
|
isDisabled: true,
|
|
227
|
-
listType: 'order',
|
|
228
226
|
}),
|
|
229
227
|
buildOption({
|
|
230
|
-
nodeType: nodes.
|
|
228
|
+
nodeType: nodes.bullet_list,
|
|
231
229
|
value: -2,
|
|
232
230
|
depth: 1,
|
|
233
231
|
isDisabled: true,
|
|
234
|
-
listType: 'bullet',
|
|
235
232
|
}),
|
|
236
233
|
];
|
|
237
234
|
const sectionOptions = [];
|
|
@@ -288,18 +285,16 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
288
285
|
isSelected: true,
|
|
289
286
|
}),
|
|
290
287
|
buildOption({
|
|
291
|
-
nodeType: nodes.
|
|
288
|
+
nodeType: nodes.ordered_list,
|
|
292
289
|
value: -3,
|
|
293
290
|
depth: 1,
|
|
294
|
-
action: convertParagraphToList(nodes.
|
|
295
|
-
listType: 'order',
|
|
291
|
+
action: convertParagraphToList(nodes.ordered_list),
|
|
296
292
|
}),
|
|
297
293
|
buildOption({
|
|
298
|
-
nodeType: nodes.
|
|
294
|
+
nodeType: nodes.bullet_list,
|
|
299
295
|
value: -2,
|
|
300
296
|
depth: 1,
|
|
301
|
-
action: convertParagraphToList(nodes.
|
|
302
|
-
listType: 'bullet',
|
|
297
|
+
action: convertParagraphToList(nodes.bullet_list),
|
|
303
298
|
}),
|
|
304
299
|
];
|
|
305
300
|
const sectionOptions = [];
|
|
@@ -325,8 +320,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
325
320
|
}));
|
|
326
321
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
327
322
|
}
|
|
328
|
-
case schema.nodes.
|
|
329
|
-
const { style, type } = getListType(parentElement.node.attrs.listStyleType);
|
|
323
|
+
case schema.nodes.bullet_list: {
|
|
330
324
|
return [
|
|
331
325
|
{
|
|
332
326
|
options: [
|
|
@@ -342,11 +336,35 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
342
336
|
{
|
|
343
337
|
options: [
|
|
344
338
|
buildOption({
|
|
345
|
-
nodeType: nodes.
|
|
339
|
+
nodeType: nodes.ordered_list,
|
|
346
340
|
value: -3,
|
|
347
341
|
depth: 1,
|
|
348
|
-
action: convertListType(nodes.
|
|
349
|
-
|
|
342
|
+
action: convertListType(nodes.ordered_list, parentElement),
|
|
343
|
+
}),
|
|
344
|
+
],
|
|
345
|
+
},
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
case parentElementType.schema.nodes.ordered_list: {
|
|
349
|
+
return [
|
|
350
|
+
{
|
|
351
|
+
options: [
|
|
352
|
+
buildOption({
|
|
353
|
+
nodeType: parentElementType,
|
|
354
|
+
value: -4,
|
|
355
|
+
depth: 1,
|
|
356
|
+
isDisabled: true,
|
|
357
|
+
isSelected: true,
|
|
358
|
+
}),
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
options: [
|
|
363
|
+
buildOption({
|
|
364
|
+
nodeType: nodes.bullet_list,
|
|
365
|
+
value: -3,
|
|
366
|
+
depth: 1,
|
|
367
|
+
action: convertListType(nodes.bullet_list, parentElement),
|
|
350
368
|
}),
|
|
351
369
|
],
|
|
352
370
|
},
|
|
@@ -434,7 +452,7 @@ export const LevelSelector = ({ state, dispatch, view }) => {
|
|
|
434
452
|
style.opacity = 0.4;
|
|
435
453
|
}
|
|
436
454
|
return (React.createElement(OptionContainer, Object.assign({}, props.innerProps, { ref: null, style: style }),
|
|
437
|
-
React.createElement(OptionIcon, null, nodeTypeIcon(data.nodeType
|
|
455
|
+
React.createElement(OptionIcon, null, nodeTypeIcon(data.nodeType)),
|
|
438
456
|
React.createElement(OptionLabel, null, data.label)));
|
|
439
457
|
},
|
|
440
458
|
}, onChange: (value) => {
|
|
@@ -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,10 +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 list from '../views/list';
|
|
35
35
|
import list_item from '../views/list_item';
|
|
36
36
|
import listing from '../views/listing_editable';
|
|
37
37
|
import listingElement from '../views/listing_element_editable';
|
|
38
|
+
import orderedList from '../views/ordered_list_editable';
|
|
38
39
|
import paragraph from '../views/paragraph_editable';
|
|
39
40
|
import placeholder from '../views/placeholder';
|
|
40
41
|
import placeholderElement from '../views/placeholder_element_editable';
|
|
@@ -50,7 +51,7 @@ export default (props, dispatch) => {
|
|
|
50
51
|
title: title(props, dispatch),
|
|
51
52
|
bibliography_element: bibliographyElement(props, dispatch),
|
|
52
53
|
blockquote_element: blockquoteElement(props),
|
|
53
|
-
|
|
54
|
+
bullet_list: bulletList(props),
|
|
54
55
|
citation: citation(props, dispatch),
|
|
55
56
|
cross_reference: crossReference(props, dispatch),
|
|
56
57
|
contributors: contributors(props, dispatch),
|
|
@@ -69,6 +70,7 @@ export default (props, dispatch) => {
|
|
|
69
70
|
listing: listing(props),
|
|
70
71
|
listing_element: listingElement(props),
|
|
71
72
|
list_item: list_item(props),
|
|
73
|
+
ordered_list: orderedList(props),
|
|
72
74
|
paragraph: paragraph(props),
|
|
73
75
|
placeholder: placeholder(props),
|
|
74
76
|
placeholder_element: placeholderElement(props),
|
package/dist/es/keys/list.js
CHANGED
|
@@ -56,8 +56,8 @@ const listKeymap = {
|
|
|
56
56
|
Enter: splitListItem(schema.nodes.list_item),
|
|
57
57
|
'Mod-[': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
|
|
58
58
|
'Mod-]': skipCommandTracking(sinkListItem(schema.nodes.list_item)),
|
|
59
|
-
'Mod-Alt-o': skipCommandTracking(wrapInList(schema.nodes.
|
|
60
|
-
'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.
|
|
59
|
+
'Mod-Alt-o': skipCommandTracking(wrapInList(schema.nodes.ordered_list)),
|
|
60
|
+
'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.bullet_list)),
|
|
61
61
|
'Shift-Tab': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
|
|
62
62
|
Tab: skipCommandTracking(sinkListItem(schema.nodes.list_item)),
|
|
63
63
|
Backspace: skipCommandTracking(listItemBackward),
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { TableFootnotesSelector, } from '@manuscripts/style-guide';
|
|
17
|
-
import {
|
|
17
|
+
import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
18
18
|
import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
19
19
|
import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
|
|
20
20
|
import { buildTableFootnoteLabels } from '../plugins/footnotes/footnotes-utils';
|
|
@@ -22,6 +22,7 @@ import ReactSubView from '../views/ReactSubView';
|
|
|
22
22
|
import { PopperManager } from './popper';
|
|
23
23
|
import { isDeleted, isRejectedInsert } from './track-changes-utils';
|
|
24
24
|
const popper = new PopperManager();
|
|
25
|
+
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
25
26
|
const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
|
|
26
27
|
export const sectionLevel = (depth) => {
|
|
27
28
|
switch (depth) {
|
|
@@ -47,12 +48,12 @@ export class ContextMenu {
|
|
|
47
48
|
const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
|
|
48
49
|
const endPos = $pos.end();
|
|
49
50
|
const types = this.insertableTypes(after, insertPos, endPos);
|
|
50
|
-
const insertNode = (type, pos
|
|
51
|
+
const insertNode = (type, pos) => {
|
|
51
52
|
const { state, dispatch } = this.view;
|
|
52
53
|
if (pos === undefined) {
|
|
53
54
|
pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
|
|
54
55
|
}
|
|
55
|
-
createBlock(type, pos, state, dispatch
|
|
56
|
+
createBlock(type, pos, state, dispatch);
|
|
56
57
|
};
|
|
57
58
|
if (hasAny(types, 'section', 'subsection')) {
|
|
58
59
|
menu.appendChild(this.createMenuSection((section) => {
|
|
@@ -79,7 +80,7 @@ export class ContextMenu {
|
|
|
79
80
|
}
|
|
80
81
|
}));
|
|
81
82
|
}
|
|
82
|
-
if (hasAny(types, 'paragraph', '
|
|
83
|
+
if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
|
|
83
84
|
menu.appendChild(this.createMenuSection((section) => {
|
|
84
85
|
if (types.has('paragraph')) {
|
|
85
86
|
section.appendChild(this.createMenuItem('Paragraph', () => {
|
|
@@ -87,17 +88,15 @@ export class ContextMenu {
|
|
|
87
88
|
popper.destroy();
|
|
88
89
|
}));
|
|
89
90
|
}
|
|
90
|
-
if (types.has('
|
|
91
|
-
section.appendChild(this.createMenuItem('
|
|
92
|
-
insertNode(schema.nodes.
|
|
93
|
-
listStyleType: 'bullet',
|
|
94
|
-
});
|
|
91
|
+
if (types.has('ordered_list')) {
|
|
92
|
+
section.appendChild(this.createMenuItem('Numbered List', () => {
|
|
93
|
+
insertNode(schema.nodes.ordered_list);
|
|
95
94
|
popper.destroy();
|
|
96
95
|
}));
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
}
|
|
97
|
+
if (types.has('bullet_list')) {
|
|
98
|
+
section.appendChild(this.createMenuItem('Bullet List', () => {
|
|
99
|
+
insertNode(schema.nodes.bullet_list);
|
|
101
100
|
popper.destroy();
|
|
102
101
|
}));
|
|
103
102
|
}
|
|
@@ -142,18 +141,17 @@ export class ContextMenu {
|
|
|
142
141
|
menu.className = 'menu';
|
|
143
142
|
const $pos = this.resolvePos();
|
|
144
143
|
const type = this.node.type;
|
|
145
|
-
if (type
|
|
144
|
+
if (listTypes.includes(type)) {
|
|
146
145
|
menu.appendChild(this.createMenuSection((section) => {
|
|
147
|
-
|
|
148
|
-
if (listType === 'ul') {
|
|
146
|
+
if (type === schema.nodes.bullet_list) {
|
|
149
147
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
150
|
-
this.changeNodeType(schema.nodes.
|
|
148
|
+
this.changeNodeType(schema.nodes.ordered_list);
|
|
151
149
|
popper.destroy();
|
|
152
150
|
}));
|
|
153
151
|
}
|
|
154
|
-
if (
|
|
152
|
+
if (type === schema.nodes.ordered_list) {
|
|
155
153
|
section.appendChild(this.createMenuItem('Change to Bullet List', () => {
|
|
156
|
-
this.changeNodeType(schema.nodes.
|
|
154
|
+
this.changeNodeType(schema.nodes.bullet_list);
|
|
157
155
|
popper.destroy();
|
|
158
156
|
}));
|
|
159
157
|
}
|
|
@@ -313,7 +311,8 @@ export class ContextMenu {
|
|
|
313
311
|
}
|
|
314
312
|
checkNode('section', insertPos);
|
|
315
313
|
checkNode('paragraph');
|
|
316
|
-
checkNode('
|
|
314
|
+
checkNode('ordered_list');
|
|
315
|
+
checkNode('bullet_list');
|
|
317
316
|
checkNode('figure_element');
|
|
318
317
|
checkNode('table_element');
|
|
319
318
|
checkNode('equation_element');
|
|
@@ -321,10 +320,9 @@ export class ContextMenu {
|
|
|
321
320
|
checkNode('pullquote_element');
|
|
322
321
|
return insertable;
|
|
323
322
|
};
|
|
324
|
-
this.changeNodeType = (nodeType
|
|
323
|
+
this.changeNodeType = (nodeType) => {
|
|
325
324
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
|
|
326
325
|
id: this.node.attrs.id,
|
|
327
|
-
listStyleType: listType,
|
|
328
326
|
}));
|
|
329
327
|
popper.destroy();
|
|
330
328
|
};
|
package/dist/es/menus.js
CHANGED
|
@@ -297,15 +297,15 @@ export const getEditorMenus = (editor) => {
|
|
|
297
297
|
{
|
|
298
298
|
id: 'insert-bullet-list',
|
|
299
299
|
label: 'Bullet List',
|
|
300
|
-
isEnabled: isCommandValid(insertList(schema.nodes.
|
|
300
|
+
isEnabled: isCommandValid(insertList(schema.nodes.bullet_list)),
|
|
301
301
|
submenu: [
|
|
302
302
|
{
|
|
303
303
|
id: 'bullet-list-context-menu',
|
|
304
304
|
label: '',
|
|
305
305
|
isEnabled: true,
|
|
306
306
|
options: {
|
|
307
|
-
bullet: doCommand(insertList(schema.nodes.
|
|
308
|
-
simple: doCommand(insertList(schema.nodes.
|
|
307
|
+
bullet: doCommand(insertList(schema.nodes.bullet_list, 'bullet')),
|
|
308
|
+
simple: doCommand(insertList(schema.nodes.bullet_list, 'simple')),
|
|
309
309
|
},
|
|
310
310
|
},
|
|
311
311
|
],
|
|
@@ -313,18 +313,18 @@ export const getEditorMenus = (editor) => {
|
|
|
313
313
|
{
|
|
314
314
|
id: 'insert-ordered-list',
|
|
315
315
|
label: 'Ordered List',
|
|
316
|
-
isEnabled: isCommandValid(insertList(schema.nodes.
|
|
316
|
+
isEnabled: isCommandValid(insertList(schema.nodes.ordered_list)),
|
|
317
317
|
submenu: [
|
|
318
318
|
{
|
|
319
319
|
id: 'ordered-list-context-menu',
|
|
320
320
|
label: '',
|
|
321
321
|
isEnabled: true,
|
|
322
322
|
options: {
|
|
323
|
-
order: doCommand(insertList(schema.nodes.
|
|
324
|
-
'alpha-upper': doCommand(insertList(schema.nodes.
|
|
325
|
-
'alpha-lower': doCommand(insertList(schema.nodes.
|
|
326
|
-
'roman-upper': doCommand(insertList(schema.nodes.
|
|
327
|
-
'roman-lower': doCommand(insertList(schema.nodes.
|
|
323
|
+
order: doCommand(insertList(schema.nodes.ordered_list, 'order')),
|
|
324
|
+
'alpha-upper': doCommand(insertList(schema.nodes.ordered_list, 'alpha-upper')),
|
|
325
|
+
'alpha-lower': doCommand(insertList(schema.nodes.ordered_list, 'alpha-lower')),
|
|
326
|
+
'roman-upper': doCommand(insertList(schema.nodes.ordered_list, 'roman-upper')),
|
|
327
|
+
'roman-lower': doCommand(insertList(schema.nodes.ordered_list, 'roman-lower')),
|
|
328
328
|
},
|
|
329
329
|
},
|
|
330
330
|
],
|
|
@@ -21,8 +21,10 @@ const icons = new Map([
|
|
|
21
21
|
[nodes.manuscript, OutlineManuscriptIcon],
|
|
22
22
|
[nodes.bibliography_section, OutlineSectionIcon],
|
|
23
23
|
[nodes.blockquote_element, OutlineBlockQuoteIcon],
|
|
24
|
+
[nodes.bullet_list, OutlineUnorderedListIcon],
|
|
24
25
|
[nodes.equation_element, OutlineEquationIcon],
|
|
25
26
|
[nodes.figure_element, OutlineFigureIcon],
|
|
27
|
+
[nodes.ordered_list, OutlineOrderedListIcon],
|
|
26
28
|
[nodes.paragraph, OutlineParagraphIcon],
|
|
27
29
|
[nodes.pullquote_element, OutlinePullQuoteIcon],
|
|
28
30
|
[nodes.section, OutlineSectionIcon],
|
|
@@ -31,15 +33,7 @@ const icons = new Map([
|
|
|
31
33
|
[nodes.graphical_abstract_section, OutlineSectionIcon],
|
|
32
34
|
[nodes.footnotes_section, OutlineSectionIcon],
|
|
33
35
|
]);
|
|
34
|
-
export const nodeTypeIcon = (nodeType
|
|
35
|
-
if (nodeType === schema.nodes.list) {
|
|
36
|
-
if (listType === 'bullet') {
|
|
37
|
-
return React.createElement(OutlineUnorderedListIcon, null);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return React.createElement(OutlineOrderedListIcon, null);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
36
|
+
export const nodeTypeIcon = (nodeType) => {
|
|
43
37
|
const Icon = icons.get(nodeType);
|
|
44
38
|
return Icon ? React.createElement(Icon, null) : null;
|
|
45
39
|
};
|
|
@@ -73,8 +73,12 @@ export const orderTableFootnotes = (tr, footnotesElementWithPos, position) => {
|
|
|
73
73
|
})
|
|
74
74
|
.map(({ node }) => node);
|
|
75
75
|
const { node: footnotesElement, pos } = footnotesElementWithPos;
|
|
76
|
-
const footnoteElementPos = position + pos;
|
|
77
|
-
|
|
76
|
+
const footnoteElementPos = position + pos + 1;
|
|
77
|
+
const oldDataTracked = footnotesElement.attrs.dataTracked;
|
|
78
|
+
skipTracking(tr.replaceWith(tr.mapping.map(footnoteElementPos), tr.mapping.map(footnoteElementPos + footnotesElement.nodeSize), Fragment.fromArray(orderedFootnotes)));
|
|
79
|
+
if (oldDataTracked) {
|
|
80
|
+
tr.setNodeMarkup(footnoteElementPos, schema.nodes.footnotes_element, Object.assign(Object.assign({}, footnotesElement.attrs), { dataTracked: oldDataTracked }));
|
|
81
|
+
}
|
|
78
82
|
};
|
|
79
83
|
export const updateTableInlineFootnoteLabels = (tr, table) => {
|
|
80
84
|
const labels = buildTableFootnoteLabels(table.node);
|
package/dist/es/rules.js
CHANGED
|
@@ -33,7 +33,8 @@ export default inputRules({
|
|
|
33
33
|
...smartQuotes,
|
|
34
34
|
ellipsis,
|
|
35
35
|
emDash,
|
|
36
|
-
creatingInputRule(
|
|
36
|
+
creatingInputRule(/^\d+[.)]\s$/, schema.nodes.ordered_list),
|
|
37
|
+
creatingInputRule(/^\s*\*\s$/, schema.nodes.bullet_list),
|
|
37
38
|
creatingInputRule(/^\s*>\s$/, schema.nodes.blockquote_element),
|
|
38
39
|
creatingInputRule(/^```$/, schema.nodes.listing_element),
|
|
39
40
|
creatingInputRule(/^#\s$/, schema.nodes.section),
|
package/dist/es/toolbar.js
CHANGED
|
@@ -62,26 +62,26 @@ export const toolbar = {
|
|
|
62
62
|
bullet_list: {
|
|
63
63
|
title: 'Wrap in bullet list',
|
|
64
64
|
content: React.createElement(ToolbarUnorderedListIcon, null),
|
|
65
|
-
isActive: blockActive(schema.nodes.
|
|
66
|
-
isEnabled: insertList(schema.nodes.
|
|
67
|
-
run: insertList(schema.nodes.
|
|
65
|
+
isActive: blockActive(schema.nodes.bullet_list),
|
|
66
|
+
isEnabled: insertList(schema.nodes.bullet_list, 'bullet'),
|
|
67
|
+
run: insertList(schema.nodes.bullet_list, 'bullet'),
|
|
68
68
|
options: {
|
|
69
|
-
bullet: insertList(schema.nodes.
|
|
70
|
-
simple: insertList(schema.nodes.
|
|
69
|
+
bullet: insertList(schema.nodes.bullet_list, 'bullet'),
|
|
70
|
+
simple: insertList(schema.nodes.bullet_list, 'simple'),
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
ordered_list: {
|
|
74
74
|
title: 'Wrap in ordered list',
|
|
75
75
|
content: React.createElement(ToolbarOrderedListIcon, null),
|
|
76
|
-
isActive: blockActive(schema.nodes.
|
|
77
|
-
isEnabled: insertList(schema.nodes.
|
|
78
|
-
run: insertList(schema.nodes.
|
|
76
|
+
isActive: blockActive(schema.nodes.ordered_list),
|
|
77
|
+
isEnabled: insertList(schema.nodes.ordered_list, 'order'),
|
|
78
|
+
run: insertList(schema.nodes.ordered_list, 'order'),
|
|
79
79
|
options: {
|
|
80
|
-
order: insertList(schema.nodes.
|
|
81
|
-
'alpha-upper': insertList(schema.nodes.
|
|
82
|
-
'alpha-lower': insertList(schema.nodes.
|
|
83
|
-
'roman-upper': insertList(schema.nodes.
|
|
84
|
-
'roman-lower': insertList(schema.nodes.
|
|
80
|
+
order: insertList(schema.nodes.ordered_list, 'order'),
|
|
81
|
+
'alpha-upper': insertList(schema.nodes.ordered_list, 'alpha-upper'),
|
|
82
|
+
'alpha-lower': insertList(schema.nodes.ordered_list, 'alpha-lower'),
|
|
83
|
+
'roman-upper': insertList(schema.nodes.ordered_list, 'roman-upper'),
|
|
84
|
+
'roman-lower': insertList(schema.nodes.ordered_list, 'roman-lower'),
|
|
85
85
|
},
|
|
86
86
|
},
|
|
87
87
|
},
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { CommentAnnotation } from '@manuscripts/json-schema';
|
|
17
17
|
import { FileAttachment } from '@manuscripts/style-guide';
|
|
18
18
|
import { InlineFootnoteNode, ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
|
|
19
|
-
import {
|
|
19
|
+
import { ResolvedPos } from 'prosemirror-model';
|
|
20
20
|
import { Command, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
|
|
21
21
|
import { NodeWithPos } from 'prosemirror-utils';
|
|
22
22
|
import { EditorView } from 'prosemirror-view';
|
|
@@ -27,7 +27,7 @@ export declare const isNodeSelection: (selection: Selection) => selection is Nod
|
|
|
27
27
|
export declare const blockActive: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
|
|
28
28
|
export declare const canInsert: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
|
|
29
29
|
export declare const createSelection: (nodeType: ManuscriptNodeType, position: number, doc: ManuscriptNode) => Selection;
|
|
30
|
-
export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch
|
|
30
|
+
export declare const createBlock: (nodeType: ManuscriptNodeType, position: number, state: ManuscriptEditorState, dispatch?: Dispatch) => void;
|
|
31
31
|
export declare const insertGeneralFootnote: (tableNode: ManuscriptNode, position: number, view: ManuscriptEditorView, tableElementFooter?: NodeWithPos[]) => void;
|
|
32
32
|
export declare const insertFileAsFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
33
33
|
export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
@@ -92,7 +92,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
|
92
92
|
destroy: () => void;
|
|
93
93
|
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
94
94
|
} & import("../views/blockquote_element").BlockquoteElementView<any>>;
|
|
95
|
-
|
|
95
|
+
bullet_list: import("../types").NodeViewCreator<{
|
|
96
96
|
gutterButtons: () => HTMLElement[];
|
|
97
97
|
actionGutterButtons: () => HTMLElement[];
|
|
98
98
|
createAddButton: () => HTMLElement | null;
|
|
@@ -126,7 +126,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
|
126
126
|
deselectNode: () => void;
|
|
127
127
|
destroy: () => void;
|
|
128
128
|
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
129
|
-
} & import("../views/
|
|
129
|
+
} & import("../views/bullet_list").BulletListView<any>>;
|
|
130
130
|
citation: import("../types").NodeViewCreator<import("../views/citation_editable").CitationEditableView>;
|
|
131
131
|
cross_reference: import("../types").NodeViewCreator<import("../views/cross_reference_editable").CrossReferenceEditableView>;
|
|
132
132
|
contributors: import("../types").NodeViewCreator<import("../views/contributors").ContributorsView>;
|
|
@@ -281,6 +281,41 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
|
281
281
|
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
282
282
|
} & import("../views/listing_element").ListingElementView<any>>;
|
|
283
283
|
list_item: import("../types").NodeViewCreator<import("../views/list_item").ListItemView<any>>;
|
|
284
|
+
ordered_list: import("../types").NodeViewCreator<{
|
|
285
|
+
gutterButtons: () => HTMLElement[];
|
|
286
|
+
actionGutterButtons: () => HTMLElement[];
|
|
287
|
+
createAddButton: () => HTMLElement | null;
|
|
288
|
+
createEditButton: () => HTMLElement | null;
|
|
289
|
+
createMenu: () => import("../lib/context-menu").ContextMenu;
|
|
290
|
+
viewAttributes: {
|
|
291
|
+
id: string;
|
|
292
|
+
placeholder: string;
|
|
293
|
+
paragraphStyle: string;
|
|
294
|
+
};
|
|
295
|
+
initialise: () => void;
|
|
296
|
+
updateContents: () => void;
|
|
297
|
+
onUpdateContent(): void;
|
|
298
|
+
updateClasses: () => void;
|
|
299
|
+
updateAttributes: () => void;
|
|
300
|
+
createElement: () => void;
|
|
301
|
+
createDOM: () => void;
|
|
302
|
+
createGutter: (className: string, buttons: HTMLElement[]) => void;
|
|
303
|
+
dom: HTMLElement;
|
|
304
|
+
contentDOM?: HTMLElement | undefined;
|
|
305
|
+
syncErrors: import("../types").SyncError[];
|
|
306
|
+
elementType: string;
|
|
307
|
+
readonly props: EditableBlockProps;
|
|
308
|
+
node: import("prosemirror-model").Node;
|
|
309
|
+
readonly view: import("prosemirror-view").EditorView;
|
|
310
|
+
readonly getPos: () => number;
|
|
311
|
+
decorations: readonly import("prosemirror-view").Decoration[];
|
|
312
|
+
update: (newNode: import("prosemirror-model").Node, decorations: readonly import("prosemirror-view").Decoration[]) => boolean;
|
|
313
|
+
setDomAttrs(node: import("prosemirror-model").Node, element: HTMLElement, omit?: string[]): void;
|
|
314
|
+
selectNode: () => void;
|
|
315
|
+
deselectNode: () => void;
|
|
316
|
+
destroy: () => void;
|
|
317
|
+
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
318
|
+
} & import("../views/ordered_list").OrderedListView<any>>;
|
|
284
319
|
paragraph: import("../types").NodeViewCreator<{
|
|
285
320
|
gutterButtons: () => HTMLElement[];
|
|
286
321
|
actionGutterButtons: () => HTMLElement[];
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { NodeType } from 'prosemirror-model';
|
|
17
17
|
import React from 'react';
|
|
18
|
-
export declare const nodeTypeIcon: (nodeType: NodeType
|
|
18
|
+
export declare const nodeTypeIcon: (nodeType: NodeType) => React.JSX.Element | null;
|
|
@@ -20,7 +20,7 @@ import { ContentNodeWithPos, NodeWithPos } from 'prosemirror-utils';
|
|
|
20
20
|
export declare const findTableInlineFootnoteIds: ($pos: ResolvedPos) => Set<string>;
|
|
21
21
|
export declare const getNewFootnotePos: (footnotesElement: NodeWithPos, footnoteIndex: number) => number;
|
|
22
22
|
export declare const buildTableFootnoteLabels: (node: ManuscriptNode) => Map<string, string | undefined>;
|
|
23
|
-
export declare const orderTableFootnotes: (tr: Transaction, footnotesElementWithPos: NodeWithPos, position: number) =>
|
|
23
|
+
export declare const orderTableFootnotes: (tr: Transaction, footnotesElementWithPos: NodeWithPos, position: number) => void;
|
|
24
24
|
export declare const updateTableInlineFootnoteLabels: (tr: Transaction, table: ContentNodeWithPos) => Transaction;
|
|
25
25
|
interface InlineFootnote {
|
|
26
26
|
node: InlineFootnoteNode;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manuscripts/body-editor",
|
|
3
3
|
"description": "Prosemirror components for editing and viewing manuscripts",
|
|
4
|
-
"version": "1.10.10
|
|
4
|
+
"version": "1.10.10",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@iarna/word-count": "^1.1.2",
|
|
31
31
|
"@manuscripts/json-schema": "2.2.8",
|
|
32
32
|
"@manuscripts/library": "1.3.7",
|
|
33
|
-
"@manuscripts/style-guide": "1.12.11
|
|
33
|
+
"@manuscripts/style-guide": "1.12.11",
|
|
34
34
|
"@manuscripts/track-changes-plugin": "1.7.12",
|
|
35
|
-
"@manuscripts/transform": "2.3.
|
|
35
|
+
"@manuscripts/transform": "2.3.6",
|
|
36
36
|
"astrocite-eutils": "^0.16.4",
|
|
37
37
|
"mathjax-full": "^3.2.2",
|
|
38
38
|
"codemirror": "^5.58.1",
|
package/dist/cjs/views/list.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
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.listCallback = exports.ListView = void 0;
|
|
22
|
-
const transform_1 = require("@manuscripts/transform");
|
|
23
|
-
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
24
|
-
const block_view_1 = __importDefault(require("./block_view"));
|
|
25
|
-
const creators_1 = require("./creators");
|
|
26
|
-
const editable_block_1 = require("./editable_block");
|
|
27
|
-
class ListView extends block_view_1.default {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...arguments);
|
|
30
|
-
this.elementType = 'ul';
|
|
31
|
-
this.updateContents = () => {
|
|
32
|
-
var _a;
|
|
33
|
-
const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
|
|
34
|
-
if (this.contentDOM) {
|
|
35
|
-
const type = actualAttrs.listStyleType;
|
|
36
|
-
this.contentDOM.style.listStyleType = (0, transform_1.getListType)(type).style;
|
|
37
|
-
}
|
|
38
|
-
if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
|
|
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-type');
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.ListView = ListView;
|
|
50
|
-
const listCallback = (node, dom) => {
|
|
51
|
-
dom.classList.add('list');
|
|
52
|
-
const type = node.attrs.listStyleType;
|
|
53
|
-
dom.style.listStyleType = (0, transform_1.getListType)(type).style;
|
|
54
|
-
};
|
|
55
|
-
exports.listCallback = listCallback;
|
|
56
|
-
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(ListView), 'ul', exports.listCallback);
|
package/dist/es/views/list.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { getListType, } from '@manuscripts/transform';
|
|
17
|
-
import { getActualAttrs } from '../lib/track-changes-utils';
|
|
18
|
-
import BlockView from './block_view';
|
|
19
|
-
import { createNodeOrElementView } from './creators';
|
|
20
|
-
import { EditableBlock } from './editable_block';
|
|
21
|
-
export class ListView extends BlockView {
|
|
22
|
-
constructor() {
|
|
23
|
-
super(...arguments);
|
|
24
|
-
this.elementType = 'ul';
|
|
25
|
-
this.updateContents = () => {
|
|
26
|
-
var _a;
|
|
27
|
-
const actualAttrs = getActualAttrs(this.node);
|
|
28
|
-
if (this.contentDOM) {
|
|
29
|
-
const type = actualAttrs.listStyleType;
|
|
30
|
-
this.contentDOM.style.listStyleType = getListType(type).style;
|
|
31
|
-
}
|
|
32
|
-
if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
|
|
33
|
-
this.dom.setAttribute('data-track-status', this.node.attrs.dataTracked[0].status);
|
|
34
|
-
this.dom.setAttribute('data-track-op', this.node.attrs.dataTracked[0].operation);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.dom.removeAttribute('data-track-status');
|
|
38
|
-
this.dom.removeAttribute('data-track-type');
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export const listCallback = (node, dom) => {
|
|
44
|
-
dom.classList.add('list');
|
|
45
|
-
const type = node.attrs.listStyleType;
|
|
46
|
-
dom.style.listStyleType = getListType(type).style;
|
|
47
|
-
};
|
|
48
|
-
export default createNodeOrElementView(EditableBlock(ListView), 'ul', listCallback);
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2019 Atypon Systems LLC
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { ManuscriptNode } from '@manuscripts/transform';
|
|
17
|
-
import { BaseNodeProps } from './base_node_view';
|
|
18
|
-
import BlockView from './block_view';
|
|
19
|
-
export declare class ListView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
|
|
20
|
-
elementType: string;
|
|
21
|
-
updateContents: () => void;
|
|
22
|
-
}
|
|
23
|
-
export declare const listCallback: (node: ManuscriptNode, dom: HTMLElement) => void;
|
|
24
|
-
declare const _default: (props: BaseNodeProps) => import("../types").NodeViewCreator<{
|
|
25
|
-
gutterButtons: () => HTMLElement[];
|
|
26
|
-
actionGutterButtons: () => HTMLElement[];
|
|
27
|
-
createAddButton: () => HTMLElement | null;
|
|
28
|
-
createEditButton: () => HTMLElement | null;
|
|
29
|
-
createMenu: () => import("../lib/context-menu").ContextMenu;
|
|
30
|
-
viewAttributes: {
|
|
31
|
-
id: string;
|
|
32
|
-
placeholder: string;
|
|
33
|
-
paragraphStyle: string;
|
|
34
|
-
};
|
|
35
|
-
initialise: () => void;
|
|
36
|
-
updateContents: () => void;
|
|
37
|
-
onUpdateContent(): void;
|
|
38
|
-
updateClasses: () => void;
|
|
39
|
-
updateAttributes: () => void;
|
|
40
|
-
createElement: () => void;
|
|
41
|
-
createDOM: () => void;
|
|
42
|
-
createGutter: (className: string, buttons: HTMLElement[]) => void;
|
|
43
|
-
dom: HTMLElement;
|
|
44
|
-
contentDOM?: HTMLElement | undefined;
|
|
45
|
-
syncErrors: import("../types").SyncError[];
|
|
46
|
-
elementType: string;
|
|
47
|
-
readonly props: import("./editable_block").EditableBlockProps;
|
|
48
|
-
node: import("prosemirror-model").Node;
|
|
49
|
-
readonly view: import("prosemirror-view").EditorView;
|
|
50
|
-
readonly getPos: () => number;
|
|
51
|
-
decorations: readonly import("prosemirror-view").Decoration[];
|
|
52
|
-
update: (newNode: import("prosemirror-model").Node, decorations: readonly import("prosemirror-view").Decoration[]) => boolean;
|
|
53
|
-
setDomAttrs(node: import("prosemirror-model").Node, element: HTMLElement, omit?: string[]): void;
|
|
54
|
-
selectNode: () => void;
|
|
55
|
-
deselectNode: () => void;
|
|
56
|
-
destroy: () => void;
|
|
57
|
-
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
58
|
-
} & ListView<any>>;
|
|
59
|
-
export default _default;
|