@manuscripts/body-editor 1.10.3-LEAN-3608.5 → 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 +7 -4
- package/dist/cjs/components/toolbar/LevelSelector.js +39 -21
- package/dist/cjs/components/views/FigureDropdown.js +1 -1
- package/dist/cjs/configs/editor-views.js +4 -2
- package/dist/cjs/keys/list.js +2 -2
- package/dist/cjs/lib/context-menu.js +21 -28
- package/dist/cjs/lib/popper.js +5 -5
- package/dist/cjs/menus.js +9 -9
- package/dist/cjs/node-type-icons.js +3 -9
- package/dist/cjs/rules.js +2 -1
- package/dist/cjs/toolbar.js +13 -13
- package/dist/cjs/views/bibliography_element.js +1 -1
- package/dist/cjs/views/citation_editable.js +4 -0
- package/dist/cjs/views/editable_block.js +4 -2
- package/dist/es/commands.js +7 -4
- package/dist/es/components/toolbar/LevelSelector.js +40 -22
- package/dist/es/components/views/FigureDropdown.js +1 -1
- package/dist/es/configs/editor-views.js +4 -2
- package/dist/es/keys/list.js +2 -2
- package/dist/es/lib/context-menu.js +21 -28
- package/dist/es/lib/popper.js +5 -5
- package/dist/es/menus.js +9 -9
- package/dist/es/node-type-icons.js +3 -9
- package/dist/es/rules.js +2 -1
- package/dist/es/toolbar.js +13 -13
- package/dist/es/views/bibliography_element.js +1 -1
- package/dist/es/views/citation_editable.js +4 -0
- package/dist/es/views/editable_block.js +5 -3
- package/dist/types/commands.d.ts +2 -2
- package/dist/types/configs/editor-views.d.ts +37 -2
- package/dist/types/lib/context-menu.d.ts +0 -1
- package/dist/types/node-type-icons.d.ts +1 -1
- package/dist/types/views/citation_editable.d.ts +1 -0
- package/package.json +4 -4
- package/dist/cjs/views/list.js +0 -70
- package/dist/es/views/list.js +0 -62
- 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) => {
|
|
@@ -37,7 +37,7 @@ const FigureOptions = ({ can, files, getFilesMap, handleDownload, handleUpload,
|
|
|
37
37
|
return (react_1.default.createElement(DropdownWrapper, { ref: wrapperRef },
|
|
38
38
|
react_1.default.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
|
|
39
39
|
react_1.default.createElement(style_guide_1.DotsIcon, null)),
|
|
40
|
-
isOpen && (react_1.default.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
|
|
40
|
+
isOpen && (react_1.default.createElement(OptionsDropdownList, { direction: 'right', width: 128, onClick: toggleOpen, top: 5 },
|
|
41
41
|
react_1.default.createElement(ListItemButton, { onClick: handleDownload, disabled: !showDownload }, "Download"),
|
|
42
42
|
react_1.default.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: 'Replace', moveLeft: true, list: react_1.default.createElement(react_1.default.Fragment, null,
|
|
43
43
|
otherFiles.map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => handleReplace && handleReplace(file) },
|
|
@@ -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),
|
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.ContextMenu = exports.
|
|
21
|
+
exports.ContextMenu = exports.sectionLevel = void 0;
|
|
22
22
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
23
|
const transform_1 = require("@manuscripts/transform");
|
|
24
24
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
@@ -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) {
|
|
@@ -41,7 +42,6 @@ exports.sectionLevel = sectionLevel;
|
|
|
41
42
|
const hasAny = (set, ...items) => {
|
|
42
43
|
return items.some((i) => set.has(i));
|
|
43
44
|
};
|
|
44
|
-
exports.contextMenuBtnClass = 'btn-context-menu';
|
|
45
45
|
class ContextMenu {
|
|
46
46
|
constructor(node, view, getPos, actions = {}, props) {
|
|
47
47
|
this.showAddMenu = (target, after) => {
|
|
@@ -54,12 +54,12 @@ class ContextMenu {
|
|
|
54
54
|
const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
|
|
55
55
|
const endPos = $pos.end();
|
|
56
56
|
const types = this.insertableTypes(after, insertPos, endPos);
|
|
57
|
-
const insertNode = (type, pos
|
|
57
|
+
const insertNode = (type, pos) => {
|
|
58
58
|
const { state, dispatch } = this.view;
|
|
59
59
|
if (pos === undefined) {
|
|
60
60
|
pos = after ? this.getPos() + this.node.nodeSize : this.getPos();
|
|
61
61
|
}
|
|
62
|
-
(0, commands_1.createBlock)(type, pos, state, dispatch
|
|
62
|
+
(0, commands_1.createBlock)(type, pos, state, dispatch);
|
|
63
63
|
};
|
|
64
64
|
if (hasAny(types, 'section', 'subsection')) {
|
|
65
65
|
menu.appendChild(this.createMenuSection((section) => {
|
|
@@ -86,7 +86,7 @@ class ContextMenu {
|
|
|
86
86
|
}
|
|
87
87
|
}));
|
|
88
88
|
}
|
|
89
|
-
if (hasAny(types, 'paragraph', '
|
|
89
|
+
if (hasAny(types, 'paragraph', 'ordered_list', 'bullet_list')) {
|
|
90
90
|
menu.appendChild(this.createMenuSection((section) => {
|
|
91
91
|
if (types.has('paragraph')) {
|
|
92
92
|
section.appendChild(this.createMenuItem('Paragraph', () => {
|
|
@@ -94,17 +94,15 @@ class ContextMenu {
|
|
|
94
94
|
popper.destroy();
|
|
95
95
|
}));
|
|
96
96
|
}
|
|
97
|
-
if (types.has('
|
|
98
|
-
section.appendChild(this.createMenuItem('
|
|
99
|
-
insertNode(transform_1.schema.nodes.
|
|
100
|
-
listStyleType: 'bullet',
|
|
101
|
-
});
|
|
97
|
+
if (types.has('ordered_list')) {
|
|
98
|
+
section.appendChild(this.createMenuItem('Numbered List', () => {
|
|
99
|
+
insertNode(transform_1.schema.nodes.ordered_list);
|
|
102
100
|
popper.destroy();
|
|
103
101
|
}));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
}
|
|
103
|
+
if (types.has('bullet_list')) {
|
|
104
|
+
section.appendChild(this.createMenuItem('Bullet List', () => {
|
|
105
|
+
insertNode(transform_1.schema.nodes.bullet_list);
|
|
108
106
|
popper.destroy();
|
|
109
107
|
}));
|
|
110
108
|
}
|
|
@@ -149,18 +147,17 @@ class ContextMenu {
|
|
|
149
147
|
menu.className = 'menu';
|
|
150
148
|
const $pos = this.resolvePos();
|
|
151
149
|
const type = this.node.type;
|
|
152
|
-
if (type
|
|
150
|
+
if (listTypes.includes(type)) {
|
|
153
151
|
menu.appendChild(this.createMenuSection((section) => {
|
|
154
|
-
|
|
155
|
-
if (list_type === 'ul') {
|
|
152
|
+
if (type === transform_1.schema.nodes.bullet_list) {
|
|
156
153
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
157
|
-
this.changeNodeType(transform_1.schema.nodes.
|
|
154
|
+
this.changeNodeType(transform_1.schema.nodes.ordered_list);
|
|
158
155
|
popper.destroy();
|
|
159
156
|
}));
|
|
160
157
|
}
|
|
161
|
-
if (
|
|
158
|
+
if (type === transform_1.schema.nodes.ordered_list) {
|
|
162
159
|
section.appendChild(this.createMenuItem('Change to Bullet List', () => {
|
|
163
|
-
this.changeNodeType(transform_1.schema.nodes.
|
|
160
|
+
this.changeNodeType(transform_1.schema.nodes.bullet_list);
|
|
164
161
|
popper.destroy();
|
|
165
162
|
}));
|
|
166
163
|
}
|
|
@@ -320,7 +317,8 @@ class ContextMenu {
|
|
|
320
317
|
}
|
|
321
318
|
checkNode('section', insertPos);
|
|
322
319
|
checkNode('paragraph');
|
|
323
|
-
checkNode('
|
|
320
|
+
checkNode('ordered_list');
|
|
321
|
+
checkNode('bullet_list');
|
|
324
322
|
checkNode('figure_element');
|
|
325
323
|
checkNode('table_element');
|
|
326
324
|
checkNode('equation_element');
|
|
@@ -328,10 +326,9 @@ class ContextMenu {
|
|
|
328
326
|
checkNode('pullquote_element');
|
|
329
327
|
return insertable;
|
|
330
328
|
};
|
|
331
|
-
this.changeNodeType = (nodeType
|
|
329
|
+
this.changeNodeType = (nodeType) => {
|
|
332
330
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
|
|
333
331
|
id: this.node.attrs.id,
|
|
334
|
-
listStyleType: listType,
|
|
335
332
|
}));
|
|
336
333
|
popper.destroy();
|
|
337
334
|
};
|
|
@@ -358,11 +355,7 @@ class ContextMenu {
|
|
|
358
355
|
};
|
|
359
356
|
this.resolvePos = () => this.view.state.doc.resolve(this.getPos());
|
|
360
357
|
this.addPopperEventListeners = () => {
|
|
361
|
-
const mouseListener = (
|
|
362
|
-
const target = event.target;
|
|
363
|
-
if (target.classList.contains(exports.contextMenuBtnClass)) {
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
358
|
+
const mouseListener = () => {
|
|
366
359
|
window.requestAnimationFrame(() => {
|
|
367
360
|
window.removeEventListener('mousedown', mouseListener);
|
|
368
361
|
popper.destroy();
|
package/dist/cjs/lib/popper.js
CHANGED
|
@@ -22,7 +22,9 @@ exports.PopperManager = void 0;
|
|
|
22
22
|
const popper_js_1 = __importDefault(require("popper.js"));
|
|
23
23
|
class PopperManager {
|
|
24
24
|
show(target, contents, placement = 'bottom', showArrow = true, modifiers = {}) {
|
|
25
|
-
this.
|
|
25
|
+
if (this.activePopper) {
|
|
26
|
+
return this.destroy();
|
|
27
|
+
}
|
|
26
28
|
window.requestAnimationFrame(() => {
|
|
27
29
|
const container = document.createElement('div');
|
|
28
30
|
container.className = 'popper';
|
|
@@ -62,9 +64,7 @@ class PopperManager {
|
|
|
62
64
|
this.destroy();
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
|
-
|
|
66
|
-
window.addEventListener('click', this.handleDocumentClick);
|
|
67
|
-
}
|
|
67
|
+
document.addEventListener('click', this.handleDocumentClick);
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
destroy() {
|
|
@@ -72,7 +72,7 @@ class PopperManager {
|
|
|
72
72
|
this.removeContainerClass(this.activePopper.reference);
|
|
73
73
|
this.activePopper.destroy();
|
|
74
74
|
if (this.handleDocumentClick) {
|
|
75
|
-
|
|
75
|
+
document.removeEventListener('click', this.handleDocumentClick);
|
|
76
76
|
}
|
|
77
77
|
delete this.activePopper;
|
|
78
78
|
}
|
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
|
};
|
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
|
},
|
|
@@ -36,6 +36,7 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
36
36
|
constructor() {
|
|
37
37
|
super(...arguments);
|
|
38
38
|
this.showPopper = (id) => {
|
|
39
|
+
this.props.popper.destroy();
|
|
39
40
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
40
41
|
if (!bib) {
|
|
41
42
|
return;
|
|
@@ -56,7 +57,6 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
56
57
|
this.showPopper(citationId);
|
|
57
58
|
};
|
|
58
59
|
this.handleComment = (citationId) => {
|
|
59
|
-
this.props.popper.destroy();
|
|
60
60
|
this.props.setComment((0, transform_1.buildComment)(citationId));
|
|
61
61
|
};
|
|
62
62
|
this.showContextMenu = (element) => {
|
|
@@ -59,6 +59,10 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
+
this.deselectNode = () => {
|
|
63
|
+
this.dom.classList.remove('ProseMirror-selectednode');
|
|
64
|
+
this.props.popper.destroy();
|
|
65
|
+
};
|
|
62
66
|
this.destroy = () => {
|
|
63
67
|
var _a;
|
|
64
68
|
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.remove();
|
|
@@ -41,12 +41,13 @@ const EditableBlock = (Base) => {
|
|
|
41
41
|
}
|
|
42
42
|
const after = !hasParent($pos, transform_1.schema.nodes.bibliography_section);
|
|
43
43
|
const button = document.createElement('a');
|
|
44
|
-
button.classList.add('add-block'
|
|
44
|
+
button.classList.add('add-block');
|
|
45
45
|
button.classList.add(after ? 'add-block-after' : 'add-block-before');
|
|
46
46
|
button.setAttribute('aria-label', `Add an element ${after ? 'below' : 'above'}`);
|
|
47
47
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
48
48
|
button.addEventListener('mousedown', (event) => {
|
|
49
49
|
event.preventDefault();
|
|
50
|
+
event.stopPropagation();
|
|
50
51
|
const menu = this.createMenu();
|
|
51
52
|
menu.showAddMenu(event.currentTarget, after);
|
|
52
53
|
});
|
|
@@ -58,11 +59,12 @@ const EditableBlock = (Base) => {
|
|
|
58
59
|
return null;
|
|
59
60
|
}
|
|
60
61
|
const button = document.createElement('a');
|
|
61
|
-
button.classList.add('edit-block'
|
|
62
|
+
button.classList.add('edit-block');
|
|
62
63
|
button.setAttribute('aria-label', 'Open menu');
|
|
63
64
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
64
65
|
button.addEventListener('mousedown', (event) => {
|
|
65
66
|
event.preventDefault();
|
|
67
|
+
event.stopPropagation();
|
|
66
68
|
const menu = this.createMenu();
|
|
67
69
|
menu.showEditMenu(event.currentTarget);
|
|
68
70
|
});
|
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 {
|