@manuscripts/body-editor 3.2.0 → 3.2.2
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/components/authors/AuthorList.js +1 -1
- package/dist/cjs/lib/context-menu.js +10 -11
- package/dist/cjs/lib/utils.js +3 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/editable_block.js +10 -5
- package/dist/es/components/authors/AuthorList.js +1 -1
- package/dist/es/lib/context-menu.js +11 -12
- package/dist/es/lib/utils.js +3 -0
- package/dist/es/versions.js +1 -1
- package/dist/es/views/editable_block.js +10 -5
- package/dist/types/lib/context-menu.d.ts +1 -1
- package/dist/types/lib/utils.d.ts +1 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +1 -1
- package/styles/Editor.css +2 -0
|
@@ -37,7 +37,7 @@ const AuthorListTitle = styled_components_1.default.h2 `
|
|
|
37
37
|
margin-top: 20px;
|
|
38
38
|
`;
|
|
39
39
|
const AuthorList = ({ author, authors, onSelect, onDelete, moveAuthor, lastSavedAuthor, }) => {
|
|
40
|
-
return (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend },
|
|
40
|
+
return (react_1.default.createElement(react_dnd_1.DndProvider, { backend: react_dnd_html5_backend_1.HTML5Backend, context: window },
|
|
41
41
|
react_1.default.createElement(AuthorListTitle, null, "Existing Authors"),
|
|
42
42
|
react_1.default.createElement(AuthorListContainer, { "data-cy": "authors-list" }, authors.map((a) => {
|
|
43
43
|
return (react_1.default.createElement(DraggableAuthor_1.DraggableAuthor, { key: a.id, author: a, isSelected: a.id === author?.id, onClick: () => onSelect(a), onDelete: () => onDelete(), moveAuthor: moveAuthor, showSuccessIcon: lastSavedAuthor === a.id }));
|
|
@@ -51,20 +51,17 @@ exports.contextMenuBtnClass = 'btn-context-menu';
|
|
|
51
51
|
const contextSubmenuBtnClass = 'context-submenu-trigger';
|
|
52
52
|
class ContextMenu {
|
|
53
53
|
constructor(node, view, getPos) {
|
|
54
|
-
this.showAddMenu = (target
|
|
54
|
+
this.showAddMenu = (target) => {
|
|
55
55
|
const menu = document.createElement('div');
|
|
56
56
|
menu.className = 'menu';
|
|
57
57
|
const $pos = this.resolvePos();
|
|
58
|
-
|
|
59
|
-
after = false;
|
|
60
|
-
}
|
|
61
|
-
const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
|
|
58
|
+
const insertPos = $pos.after($pos.depth);
|
|
62
59
|
const endPos = $pos.end();
|
|
63
|
-
const types = this.insertableTypes(
|
|
60
|
+
const types = this.insertableTypes(insertPos, endPos);
|
|
64
61
|
const insertNode = (type, pos, attrs) => {
|
|
65
62
|
const { state, dispatch } = this.view;
|
|
66
63
|
if (pos === undefined) {
|
|
67
|
-
pos =
|
|
64
|
+
pos = this.getPos() + this.node.nodeSize;
|
|
68
65
|
}
|
|
69
66
|
(0, commands_1.createBlock)(type, pos, state, dispatch, attrs);
|
|
70
67
|
};
|
|
@@ -79,7 +76,7 @@ class ContextMenu {
|
|
|
79
76
|
transform_1.schema.nodes.abstracts,
|
|
80
77
|
transform_1.schema.nodes.backmatter,
|
|
81
78
|
])) {
|
|
82
|
-
const labelPosition =
|
|
79
|
+
const labelPosition = 'After';
|
|
83
80
|
const level = (0, exports.sectionLevel)($pos.depth - 1);
|
|
84
81
|
const label = `New ${level} ${labelPosition} ${itemTitle}`;
|
|
85
82
|
section.appendChild(this.createMenuItem(label, () => {
|
|
@@ -267,7 +264,9 @@ class ContextMenu {
|
|
|
267
264
|
menu.append(this.createMenuSection((e) => e.append(...items)));
|
|
268
265
|
}
|
|
269
266
|
}
|
|
270
|
-
if (!
|
|
267
|
+
if (!(type === transform_1.schema.nodes.figure_element &&
|
|
268
|
+
(0, transform_1.isInGraphicalAbstractSection)($pos)) &&
|
|
269
|
+
!readonlyTypes.includes(type) &&
|
|
271
270
|
!readonlyTypes.includes($pos.parent.type)) {
|
|
272
271
|
menu.appendChild(this.createMenuSection((section) => {
|
|
273
272
|
let nodeName = transform_1.nodeNames.get(type) || '';
|
|
@@ -325,13 +324,13 @@ class ContextMenu {
|
|
|
325
324
|
}, true));
|
|
326
325
|
return submenu;
|
|
327
326
|
};
|
|
328
|
-
this.insertableTypes = (
|
|
327
|
+
this.insertableTypes = (insertPos, endPos) => {
|
|
329
328
|
const { nodes } = transform_1.schema;
|
|
330
329
|
const insertable = new Set();
|
|
331
330
|
const doc = this.view.state.doc;
|
|
332
331
|
const getPos = (pos) => {
|
|
333
332
|
if (pos === undefined) {
|
|
334
|
-
pos =
|
|
333
|
+
pos = this.getPos() + this.node.nodeSize;
|
|
335
334
|
}
|
|
336
335
|
return pos;
|
|
337
336
|
};
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -105,6 +105,9 @@ exports.createHeader = createHeader;
|
|
|
105
105
|
const isNotNull = (a) => a !== null;
|
|
106
106
|
exports.isNotNull = isNotNull;
|
|
107
107
|
const hasParent = ($pos, type) => {
|
|
108
|
+
if (Array.isArray(type)) {
|
|
109
|
+
return type.some((nodeType) => !!(0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodeType));
|
|
110
|
+
}
|
|
108
111
|
return !!(0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, type);
|
|
109
112
|
};
|
|
110
113
|
exports.hasParent = hasParent;
|
package/dist/cjs/versions.js
CHANGED
|
@@ -39,19 +39,24 @@ const EditableBlock = (Base) => {
|
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
41
|
const $pos = this.view.state.doc.resolve(this.getPos());
|
|
42
|
-
|
|
42
|
+
const nodeType = this.node.type;
|
|
43
|
+
if (nodeType === transform_1.schema.nodes.hero_image ||
|
|
44
|
+
(0, utils_1.hasParent)($pos, [
|
|
45
|
+
transform_1.schema.nodes.keywords,
|
|
46
|
+
transform_1.schema.nodes.bibliography_section,
|
|
47
|
+
transform_1.schema.nodes.footnotes_section,
|
|
48
|
+
])) {
|
|
43
49
|
return null;
|
|
44
50
|
}
|
|
45
|
-
const after = !(0, utils_1.hasParent)($pos, transform_1.schema.nodes.bibliography_section);
|
|
46
51
|
const button = document.createElement('a');
|
|
47
52
|
button.classList.add('add-block', context_menu_1.contextMenuBtnClass);
|
|
48
|
-
button.classList.add(
|
|
49
|
-
button.setAttribute('aria-label', `Add an element
|
|
53
|
+
button.classList.add('add-block-after');
|
|
54
|
+
button.setAttribute('aria-label', `Add an element below`);
|
|
50
55
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
51
56
|
button.addEventListener('mousedown', (event) => {
|
|
52
57
|
event.preventDefault();
|
|
53
58
|
const menu = this.createMenu();
|
|
54
|
-
menu.showAddMenu(event.currentTarget
|
|
59
|
+
menu.showAddMenu(event.currentTarget);
|
|
55
60
|
});
|
|
56
61
|
return button;
|
|
57
62
|
}
|
|
@@ -31,7 +31,7 @@ const AuthorListTitle = styled.h2 `
|
|
|
31
31
|
margin-top: 20px;
|
|
32
32
|
`;
|
|
33
33
|
export const AuthorList = ({ author, authors, onSelect, onDelete, moveAuthor, lastSavedAuthor, }) => {
|
|
34
|
-
return (React.createElement(DndProvider, { backend: HTML5Backend },
|
|
34
|
+
return (React.createElement(DndProvider, { backend: HTML5Backend, context: window },
|
|
35
35
|
React.createElement(AuthorListTitle, null, "Existing Authors"),
|
|
36
36
|
React.createElement(AuthorListContainer, { "data-cy": "authors-list" }, authors.map((a) => {
|
|
37
37
|
return (React.createElement(DraggableAuthor, { key: a.id, author: a, isSelected: a.id === author?.id, onClick: () => onSelect(a), onDelete: () => onDelete(), moveAuthor: moveAuthor, showSuccessIcon: lastSavedAuthor === a.id }));
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ImageDefaultIcon, ImageLeftIcon, ImageRightIcon, TriangleCollapsedIcon, } from '@manuscripts/style-guide';
|
|
17
|
-
import {
|
|
17
|
+
import { isInGraphicalAbstractSection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
|
|
18
18
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
19
19
|
import { createElement } from 'react';
|
|
20
20
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
@@ -47,20 +47,17 @@ export const contextMenuBtnClass = 'btn-context-menu';
|
|
|
47
47
|
const contextSubmenuBtnClass = 'context-submenu-trigger';
|
|
48
48
|
export class ContextMenu {
|
|
49
49
|
constructor(node, view, getPos) {
|
|
50
|
-
this.showAddMenu = (target
|
|
50
|
+
this.showAddMenu = (target) => {
|
|
51
51
|
const menu = document.createElement('div');
|
|
52
52
|
menu.className = 'menu';
|
|
53
53
|
const $pos = this.resolvePos();
|
|
54
|
-
|
|
55
|
-
after = false;
|
|
56
|
-
}
|
|
57
|
-
const insertPos = after ? $pos.after($pos.depth) : $pos.before($pos.depth);
|
|
54
|
+
const insertPos = $pos.after($pos.depth);
|
|
58
55
|
const endPos = $pos.end();
|
|
59
|
-
const types = this.insertableTypes(
|
|
56
|
+
const types = this.insertableTypes(insertPos, endPos);
|
|
60
57
|
const insertNode = (type, pos, attrs) => {
|
|
61
58
|
const { state, dispatch } = this.view;
|
|
62
59
|
if (pos === undefined) {
|
|
63
|
-
pos =
|
|
60
|
+
pos = this.getPos() + this.node.nodeSize;
|
|
64
61
|
}
|
|
65
62
|
createBlock(type, pos, state, dispatch, attrs);
|
|
66
63
|
};
|
|
@@ -75,7 +72,7 @@ export class ContextMenu {
|
|
|
75
72
|
schema.nodes.abstracts,
|
|
76
73
|
schema.nodes.backmatter,
|
|
77
74
|
])) {
|
|
78
|
-
const labelPosition =
|
|
75
|
+
const labelPosition = 'After';
|
|
79
76
|
const level = sectionLevel($pos.depth - 1);
|
|
80
77
|
const label = `New ${level} ${labelPosition} ${itemTitle}`;
|
|
81
78
|
section.appendChild(this.createMenuItem(label, () => {
|
|
@@ -263,7 +260,9 @@ export class ContextMenu {
|
|
|
263
260
|
menu.append(this.createMenuSection((e) => e.append(...items)));
|
|
264
261
|
}
|
|
265
262
|
}
|
|
266
|
-
if (!
|
|
263
|
+
if (!(type === schema.nodes.figure_element &&
|
|
264
|
+
isInGraphicalAbstractSection($pos)) &&
|
|
265
|
+
!readonlyTypes.includes(type) &&
|
|
267
266
|
!readonlyTypes.includes($pos.parent.type)) {
|
|
268
267
|
menu.appendChild(this.createMenuSection((section) => {
|
|
269
268
|
let nodeName = nodeNames.get(type) || '';
|
|
@@ -321,13 +320,13 @@ export class ContextMenu {
|
|
|
321
320
|
}, true));
|
|
322
321
|
return submenu;
|
|
323
322
|
};
|
|
324
|
-
this.insertableTypes = (
|
|
323
|
+
this.insertableTypes = (insertPos, endPos) => {
|
|
325
324
|
const { nodes } = schema;
|
|
326
325
|
const insertable = new Set();
|
|
327
326
|
const doc = this.view.state.doc;
|
|
328
327
|
const getPos = (pos) => {
|
|
329
328
|
if (pos === undefined) {
|
|
330
|
-
pos =
|
|
329
|
+
pos = this.getPos() + this.node.nodeSize;
|
|
331
330
|
}
|
|
332
331
|
return pos;
|
|
333
332
|
};
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -92,6 +92,9 @@ export const createHeader = (typeName, text) => {
|
|
|
92
92
|
};
|
|
93
93
|
export const isNotNull = (a) => a !== null;
|
|
94
94
|
export const hasParent = ($pos, type) => {
|
|
95
|
+
if (Array.isArray(type)) {
|
|
96
|
+
return type.some((nodeType) => !!findParentNodeOfTypeClosestToPos($pos, nodeType));
|
|
97
|
+
}
|
|
95
98
|
return !!findParentNodeOfTypeClosestToPos($pos, type);
|
|
96
99
|
};
|
|
97
100
|
export const shouldRenderField = (field, type) => {
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.2.
|
|
1
|
+
export const VERSION = '3.2.2';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -36,19 +36,24 @@ export const EditableBlock = (Base) => {
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
const $pos = this.view.state.doc.resolve(this.getPos());
|
|
39
|
-
|
|
39
|
+
const nodeType = this.node.type;
|
|
40
|
+
if (nodeType === schema.nodes.hero_image ||
|
|
41
|
+
hasParent($pos, [
|
|
42
|
+
schema.nodes.keywords,
|
|
43
|
+
schema.nodes.bibliography_section,
|
|
44
|
+
schema.nodes.footnotes_section,
|
|
45
|
+
])) {
|
|
40
46
|
return null;
|
|
41
47
|
}
|
|
42
|
-
const after = !hasParent($pos, schema.nodes.bibliography_section);
|
|
43
48
|
const button = document.createElement('a');
|
|
44
49
|
button.classList.add('add-block', contextMenuBtnClass);
|
|
45
|
-
button.classList.add(
|
|
46
|
-
button.setAttribute('aria-label', `Add an element
|
|
50
|
+
button.classList.add('add-block-after');
|
|
51
|
+
button.setAttribute('aria-label', `Add an element below`);
|
|
47
52
|
button.setAttribute('data-balloon-pos', 'down-left');
|
|
48
53
|
button.addEventListener('mousedown', (event) => {
|
|
49
54
|
event.preventDefault();
|
|
50
55
|
const menu = this.createMenu();
|
|
51
|
-
menu.showAddMenu(event.currentTarget
|
|
56
|
+
menu.showAddMenu(event.currentTarget);
|
|
52
57
|
});
|
|
53
58
|
return button;
|
|
54
59
|
}
|
|
@@ -21,7 +21,7 @@ export declare class ContextMenu {
|
|
|
21
21
|
private readonly view;
|
|
22
22
|
private readonly getPos;
|
|
23
23
|
constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number);
|
|
24
|
-
showAddMenu: (target: Element
|
|
24
|
+
showAddMenu: (target: Element) => void;
|
|
25
25
|
showEditMenu: (target: Element) => void;
|
|
26
26
|
private createSubmenuTrigger;
|
|
27
27
|
private createMenuItem;
|
|
@@ -29,7 +29,7 @@ export declare const isSelectionInNode: (state: EditorState, targetNode: ProseMi
|
|
|
29
29
|
export declare const isSelectionInBody: (state: EditorState) => boolean;
|
|
30
30
|
export declare const createHeader: (typeName: string, text: string) => HTMLHeadingElement;
|
|
31
31
|
export declare const isNotNull: <T>(a: T | null) => a is T;
|
|
32
|
-
export declare const hasParent: ($pos: ResolvedPos, type: ManuscriptNodeType) => boolean;
|
|
32
|
+
export declare const hasParent: ($pos: ResolvedPos, type: ManuscriptNodeType | ManuscriptNodeType[]) => boolean;
|
|
33
33
|
export declare const shouldRenderField: (field: string, type: BibliographyItemType) => boolean;
|
|
34
34
|
export declare const cleanItemValues: (item: BibliographyItemAttrs) => BibliographyItemAttrs;
|
|
35
35
|
export declare const isBodyLocked: (state: EditorState) => boolean;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.2.
|
|
1
|
+
export declare const VERSION = "3.2.2";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
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": "3.2.
|
|
4
|
+
"version": "3.2.2",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|