@manuscripts/body-editor 2.6.22-LEAN-4192.0 → 2.6.22
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 +13 -16
- package/dist/cjs/icons.js +5 -3
- package/dist/cjs/lib/context-menu.js +1 -3
- package/dist/cjs/menus.js +13 -50
- package/dist/cjs/plugins/section-category/section-category-utils.js +40 -70
- package/dist/cjs/plugins/section_title/autocompletion.js +15 -12
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +11 -14
- package/dist/es/icons.js +5 -3
- package/dist/es/lib/context-menu.js +1 -3
- package/dist/es/menus.js +15 -52
- package/dist/es/plugins/section-category/section-category-utils.js +40 -70
- package/dist/es/plugins/section_title/autocompletion.js +16 -13
- package/dist/es/versions.js +1 -1
- package/dist/types/commands.d.ts +1 -1
- package/dist/types/configs/ManuscriptsEditor.d.ts +3 -3
- package/dist/types/icons.d.ts +1 -0
- package/dist/types/plugins/section-category/index.d.ts +1 -5
- package/dist/types/plugins/section-category/section-category-utils.d.ts +3 -11
- package/dist/types/plugins/section_title/autocompletion.d.ts +3 -3
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +1 -1
- package/dist/cjs/lib/section-categories.js +0 -48
- package/dist/cjs/lib/section-titles.js +0 -38
- package/dist/cjs/testing/default-editor-data.js +0 -85
- package/dist/cjs/testing/polyfill-dom.js +0 -35
- package/dist/cjs/testing/setup-editor.js +0 -63
- package/dist/es/lib/section-categories.js +0 -40
- package/dist/es/lib/section-titles.js +0 -35
- package/dist/es/testing/default-editor-data.js +0 -79
- package/dist/es/testing/polyfill-dom.js +0 -31
- package/dist/es/testing/setup-editor.js +0 -55
- package/dist/types/lib/section-categories.d.ts +0 -23
- package/dist/types/lib/section-titles.d.ts +0 -17
- package/dist/types/testing/default-editor-data.d.ts +0 -28
- package/dist/types/testing/polyfill-dom.d.ts +0 -16
- package/dist/types/testing/setup-editor.d.ts +0 -20
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { PluginKey } from 'prosemirror-state';
|
|
1
|
+
import { getGroupCateogries, isSectionNode, schema } from '@manuscripts/transform';
|
|
2
|
+
import { findChildrenByType, findParentNodeOfTypeClosestToPos, } from 'prosemirror-utils';
|
|
4
3
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
5
|
-
import {
|
|
6
|
-
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
|
+
import { sectionCategoryIcon } from '../../icons';
|
|
7
5
|
import { PopperManager } from '../../lib/popper';
|
|
8
|
-
import { getCategoryName, isBackMatterSection, isEditableSectionCategoryID, isSubSection, isUnique, } from '../../lib/section-categories';
|
|
9
|
-
import { isChildOfNodeTypes } from '../../lib/utils';
|
|
10
|
-
export const sectionCategoryKey = new PluginKey('section-category');
|
|
11
6
|
const popper = new PopperManager();
|
|
12
|
-
function changeNodeAttrs(view, node, type, pos) {
|
|
13
|
-
view.dispatch(view.state.tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, node.attrs), { category: type })));
|
|
14
|
-
}
|
|
15
7
|
function createMenuItem(contents, handler, isDisabled = false, isSelected = false) {
|
|
16
8
|
const item = document.createElement('button');
|
|
17
9
|
item.className = `menu-item ${isDisabled ? 'disabled' : ''} ${isSelected ? 'selected' : ''}`;
|
|
@@ -22,13 +14,11 @@ function createMenuItem(contents, handler, isDisabled = false, isSelected = fals
|
|
|
22
14
|
});
|
|
23
15
|
return item;
|
|
24
16
|
}
|
|
25
|
-
function createMenu(
|
|
17
|
+
function createMenu(currentCategory, categories, usedCategoryIDs, onSelect) {
|
|
26
18
|
const menu = document.createElement('div');
|
|
27
19
|
menu.className = 'section-category menu';
|
|
28
|
-
const existingCatsCounted = getExistingCatsCounted(view.state);
|
|
29
|
-
const categories = getSortedSectionCategories(view.state, node, props.sectionCategories, pos, existingCatsCounted);
|
|
30
20
|
categories.forEach((category) => {
|
|
31
|
-
const item = createMenuItem(category.
|
|
21
|
+
const item = createMenuItem(category.titles[0], () => onSelect(category), category.isUnique && usedCategoryIDs.has(category.id), currentCategory === category);
|
|
32
22
|
menu.appendChild(item);
|
|
33
23
|
});
|
|
34
24
|
document.addEventListener('mousedown', (event) => {
|
|
@@ -38,16 +28,24 @@ function createMenu(view, props, node, pos, currCategory) {
|
|
|
38
28
|
});
|
|
39
29
|
return menu;
|
|
40
30
|
}
|
|
41
|
-
function createButton(view,
|
|
31
|
+
function createButton(view, pos, currentCategory, categories, usedCategoryIDs, canEdit = true) {
|
|
32
|
+
const handleSelect = (category) => {
|
|
33
|
+
const tr = view.state.tr;
|
|
34
|
+
tr.setNodeAttribute(pos, 'category', category.id);
|
|
35
|
+
view.dispatch(tr);
|
|
36
|
+
};
|
|
42
37
|
const arrow = document.createElement('div');
|
|
43
38
|
arrow.className = 'section-category popper-arrow';
|
|
44
39
|
const button = document.createElement('button');
|
|
45
|
-
button.innerHTML =
|
|
46
|
-
button.
|
|
40
|
+
button.innerHTML = sectionCategoryIcon;
|
|
41
|
+
button.classList.add('section-category-button');
|
|
42
|
+
if (currentCategory) {
|
|
43
|
+
button.classList.add('assigned');
|
|
44
|
+
}
|
|
47
45
|
if (canEdit) {
|
|
48
46
|
button.addEventListener('mousedown', () => {
|
|
49
47
|
popper.destroy();
|
|
50
|
-
const menu = createMenu(
|
|
48
|
+
const menu = createMenu(currentCategory, categories, usedCategoryIDs, handleSelect);
|
|
51
49
|
popper.show(button, menu, 'bottom-end', false, [
|
|
52
50
|
{ name: 'offset', options: { offset: [0, -10] } },
|
|
53
51
|
]);
|
|
@@ -59,7 +57,7 @@ function createButton(view, props, node, pos, category, canEdit = true) {
|
|
|
59
57
|
tooltip.className = 'section-category tooltip';
|
|
60
58
|
tooltip.textContent = 'Category:';
|
|
61
59
|
const span = document.createElement('span');
|
|
62
|
-
span.textContent =
|
|
60
|
+
span.textContent = (currentCategory === null || currentCategory === void 0 ? void 0 : currentCategory.titles[0]) || '';
|
|
63
61
|
tooltip.appendChild(span);
|
|
64
62
|
tooltip.appendChild(arrow);
|
|
65
63
|
popper.show(button, tooltip, 'left', false, [
|
|
@@ -76,61 +74,33 @@ function createButton(view, props, node, pos, category, canEdit = true) {
|
|
|
76
74
|
export function buildPluginState(state, props) {
|
|
77
75
|
const decorations = [];
|
|
78
76
|
const can = props.getCapabilities();
|
|
77
|
+
const categories = props.sectionCategories;
|
|
78
|
+
const usedCategoryIDs = getUsedSectionCategoryIDs(state);
|
|
79
79
|
state.doc.descendants((node, pos) => {
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
!isUnique(attrs.category) &&
|
|
84
|
-
!isSubSection(attrs.category)) {
|
|
85
|
-
decorations.push(Decoration.widget(pos + 1, (view) => createButton(view, props, node, pos, attrs.category, can === null || can === void 0 ? void 0 : can.editArticle)));
|
|
86
|
-
}
|
|
80
|
+
if (node.type === schema.nodes.abstracts ||
|
|
81
|
+
node.type === schema.nodes.box_element) {
|
|
82
|
+
return false;
|
|
87
83
|
}
|
|
88
|
-
if (node
|
|
84
|
+
if (isSectionNode(node)) {
|
|
85
|
+
const categoryID = node.attrs.category;
|
|
86
|
+
const category = categories.get(categoryID);
|
|
87
|
+
const $pos = state.doc.resolve(pos);
|
|
88
|
+
const group = isInBackmatter($pos) ? 'backmatter' : 'body';
|
|
89
|
+
const groupCategories = getGroupCateogries(categories, group);
|
|
90
|
+
decorations.push(Decoration.widget(pos + 1, (view) => createButton(view, pos, category, groupCategories, usedCategoryIDs, can === null || can === void 0 ? void 0 : can.editArticle)));
|
|
89
91
|
return false;
|
|
90
92
|
}
|
|
91
93
|
});
|
|
92
94
|
return { decorations: DecorationSet.create(state.doc, decorations) };
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
((_a = node.attrs.category) === null || _a === void 0 ? void 0 : _a.startsWith('MPSectionCategory:'))) {
|
|
100
|
-
existingCatsCounted[node.attrs.category] =
|
|
101
|
-
(existingCatsCounted[node.attrs.category] || 0) + 1;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
return existingCatsCounted;
|
|
105
|
-
}
|
|
106
|
-
function getSortedSectionCategories(state, container, sectionCategories, pos, existingCatsCounted) {
|
|
107
|
-
var _a;
|
|
108
|
-
let groupIDToUse = '';
|
|
109
|
-
if (container.attrs.category) {
|
|
110
|
-
const sectionCategory = sectionCategories.find(({ _id }) => _id === container.attrs.category);
|
|
111
|
-
if (sectionCategory) {
|
|
112
|
-
groupIDToUse = (_a = sectionCategory.groupIDs) === null || _a === void 0 ? void 0 : _a[0];
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const isChildOfBody = isChildOfNodeTypes(state.doc, pos, [
|
|
117
|
-
schema.nodes.body,
|
|
118
|
-
]);
|
|
119
|
-
if (isChildOfBody) {
|
|
120
|
-
groupIDToUse = 'MPSectionCategory:body';
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
groupIDToUse = 'MPSectionCategory:backmatter';
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (!groupIDToUse) {
|
|
127
|
-
return [];
|
|
128
|
-
}
|
|
129
|
-
return sectionCategories
|
|
130
|
-
.filter((category) => { var _a; return (_a = category.groupIDs) === null || _a === void 0 ? void 0 : _a.includes(groupIDToUse); })
|
|
131
|
-
.map((category) => {
|
|
132
|
-
var _a, _b;
|
|
133
|
-
return (Object.assign(Object.assign({}, category), { isDisabled: Boolean(existingCatsCounted[category._id] &&
|
|
134
|
-
isBackMatterSection((_b = (_a = category.groupIDs) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '')) }));
|
|
96
|
+
const getUsedSectionCategoryIDs = (state) => {
|
|
97
|
+
const sections = findChildrenByType(state.doc, schema.nodes.section);
|
|
98
|
+
const used = new Set();
|
|
99
|
+
sections.forEach(({ node }) => {
|
|
100
|
+
node.attrs.category && used.add(node.attrs.category);
|
|
135
101
|
});
|
|
136
|
-
|
|
102
|
+
return used;
|
|
103
|
+
};
|
|
104
|
+
const isInBackmatter = ($pos) => {
|
|
105
|
+
return !!findParentNodeOfTypeClosestToPos($pos, schema.nodes.backmatter);
|
|
106
|
+
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { schema
|
|
1
|
+
import { schema } from '@manuscripts/transform';
|
|
2
2
|
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
3
|
-
import { sectionTitles } from '../../lib/section-titles';
|
|
4
3
|
import { getActualTextContent } from '../../lib/track-changes-utils';
|
|
4
|
+
import { getEditorProps } from '../editor-props';
|
|
5
5
|
function cursorAtTheEndOfText(state, nodeSize, nodePos) {
|
|
6
6
|
const { from, to } = state.selection;
|
|
7
7
|
return from === to && to === nodePos + nodeSize - 1;
|
|
8
8
|
}
|
|
9
9
|
const isUpperCase = (test) => test === test.toUpperCase() && test.length > 1;
|
|
10
|
-
export function hasAutoCompletionSlack(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (category && (titles === null || titles === void 0 ? void 0 : titles.length) && titleSection.textContent) {
|
|
15
|
-
const actualTextContent = getActualTextContent(titleSection.content);
|
|
10
|
+
export function hasAutoCompletionSlack(node, category) {
|
|
11
|
+
const titles = category.titles;
|
|
12
|
+
if (titles.length && node.textContent) {
|
|
13
|
+
const actualTextContent = getActualTextContent(node.content);
|
|
16
14
|
const title = titles.find((t) => t.toLowerCase().startsWith(actualTextContent.toLowerCase()));
|
|
17
15
|
if (title) {
|
|
18
16
|
const suggestionPart = title.slice(actualTextContent.length);
|
|
@@ -29,14 +27,19 @@ export function hasAutoCompletionSlack(parentSection, titleSection) {
|
|
|
29
27
|
}
|
|
30
28
|
export function checkForCompletion(state) {
|
|
31
29
|
const section = findParentNodeOfTypeClosestToPos(state.selection.$from, schema.nodes.section);
|
|
30
|
+
if (!section) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
32
33
|
const title = findParentNodeOfTypeClosestToPos(state.selection.$from, schema.nodes.section_title);
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (!title || !cursorAtTheEndOfText(state, title.node.nodeSize, title.pos)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const props = getEditorProps(state);
|
|
38
|
+
const category = props.sectionCategories.get(section.node.attrs.category);
|
|
39
|
+
if (category) {
|
|
40
|
+
const text = hasAutoCompletionSlack(title.node, category);
|
|
37
41
|
if (text) {
|
|
38
42
|
return text;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
|
-
return null;
|
|
42
45
|
}
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.6.22
|
|
1
|
+
export const VERSION = '2.6.22';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare const insertInlineFootnote: (state: ManuscriptEditorState, dispat
|
|
|
50
50
|
export declare const insertBoxElement: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
51
51
|
export declare const insertGraphicalAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
|
|
52
52
|
export declare const insertSection: (subsection?: boolean) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
|
|
53
|
-
export declare const
|
|
53
|
+
export declare const insertBackmatterSection: (category: SectionCategory) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
|
|
54
54
|
export declare const insertAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
|
|
55
55
|
export declare const insertContributors: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
|
|
56
56
|
export declare const insertKeywords: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import 'prosemirror-view/style/prosemirror.css';
|
|
17
|
-
import {
|
|
17
|
+
import { UserProfile } from '@manuscripts/json-schema';
|
|
18
18
|
import { Capabilities } from '@manuscripts/style-guide';
|
|
19
|
-
import { ManuscriptNode } from '@manuscripts/transform';
|
|
19
|
+
import { ManuscriptNode, SectionCategory } from '@manuscripts/transform';
|
|
20
20
|
import { EditorState } from 'prosemirror-state';
|
|
21
21
|
import { EditorView } from 'prosemirror-view';
|
|
22
22
|
import { Location, NavigateFunction } from 'react-router-dom';
|
|
@@ -45,7 +45,7 @@ export interface EditorProps {
|
|
|
45
45
|
userID: string;
|
|
46
46
|
debug: boolean;
|
|
47
47
|
cslProps: CSLProps;
|
|
48
|
-
sectionCategories: SectionCategory
|
|
48
|
+
sectionCategories: Map<string, SectionCategory>;
|
|
49
49
|
collabProvider?: CollabProvider;
|
|
50
50
|
navigate: NavigateFunction;
|
|
51
51
|
location: Location;
|
package/dist/types/icons.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SectionCategory } from '@manuscripts/json-schema';
|
|
2
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
3
2
|
import { DecorationSet } from 'prosemirror-view';
|
|
4
3
|
import { EditorProps } from '../../configs/ManuscriptsEditor';
|
|
@@ -6,8 +5,5 @@ export declare const sectionCategoryKey: PluginKey<PluginState>;
|
|
|
6
5
|
export interface PluginState {
|
|
7
6
|
decorations: DecorationSet;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
sectionCategories: SectionCategory[];
|
|
11
|
-
}
|
|
12
|
-
declare const _default: (props: SectionCategoryProps) => Plugin<PluginState>;
|
|
8
|
+
declare const _default: (props: EditorProps) => Plugin<PluginState>;
|
|
13
9
|
export default _default;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EditorState, PluginKey } from 'prosemirror-state';
|
|
3
|
-
import { DecorationSet } from 'prosemirror-view';
|
|
1
|
+
import { EditorState } from 'prosemirror-state';
|
|
4
2
|
import { EditorProps } from '../../configs/ManuscriptsEditor';
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
decorations: DecorationSet;
|
|
8
|
-
}
|
|
9
|
-
export interface SectionCategoryProps extends EditorProps {
|
|
10
|
-
sectionCategories: SectionCategory[];
|
|
11
|
-
}
|
|
12
|
-
export declare function buildPluginState(state: EditorState, props: SectionCategoryProps): PluginState;
|
|
3
|
+
import { PluginState } from './index';
|
|
4
|
+
export declare function buildPluginState(state: EditorState, props: EditorProps): PluginState;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ManuscriptNode, SectionCategory } from '@manuscripts/transform';
|
|
2
2
|
import { EditorState } from 'prosemirror-state';
|
|
3
|
-
export declare function hasAutoCompletionSlack(
|
|
3
|
+
export declare function hasAutoCompletionSlack(node: ManuscriptNode, category: SectionCategory): {
|
|
4
4
|
suggestion: string;
|
|
5
5
|
title: string;
|
|
6
6
|
} | null;
|
|
7
7
|
export declare function checkForCompletion(state: EditorState): {
|
|
8
8
|
suggestion: string;
|
|
9
9
|
title: string;
|
|
10
|
-
} |
|
|
10
|
+
} | undefined;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.6.22
|
|
1
|
+
export declare const VERSION = "2.6.22";
|
|
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": "2.6.22
|
|
4
|
+
"version": "2.6.22",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
35
|
"@manuscripts/style-guide": "2.0.24",
|
|
36
36
|
"@manuscripts/track-changes-plugin": "1.8.4",
|
|
37
|
-
"@manuscripts/transform": "3.0.21
|
|
37
|
+
"@manuscripts/transform": "3.0.21",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
font-size: 13.5pt !important;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
.ProseMirror div.backmatter:not(.empty-node)::before, .ProseMirror div.body
|
|
57
|
+
.ProseMirror div.backmatter:not(.empty-node)::before, .ProseMirror div.body .block-section:first-of-type::before {
|
|
58
58
|
content: '';
|
|
59
59
|
border-bottom: 1px dashed #c9c9c9;
|
|
60
60
|
display: block;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2024 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getCategoryName = exports.isSubSection = exports.isBackMatterSection = exports.isUnique = exports.isEditableSectionCategoryID = exports.uniqueSectionCategories = exports.uneditableSectionCategories = void 0;
|
|
19
|
-
exports.uneditableSectionCategories = [
|
|
20
|
-
'MPSectionCategory:bibliography',
|
|
21
|
-
'MPSectionCategory:keywords',
|
|
22
|
-
'MPSectionCategory:list-of-figures',
|
|
23
|
-
'MPSectionCategory:list-of-tables',
|
|
24
|
-
'MPSectionCategory:toc',
|
|
25
|
-
];
|
|
26
|
-
exports.uniqueSectionCategories = [
|
|
27
|
-
'MPSectionCategory:abstract-graphical',
|
|
28
|
-
'MPSectionCategory:abstract',
|
|
29
|
-
];
|
|
30
|
-
const isEditableSectionCategoryID = (id) => !exports.uneditableSectionCategories.includes(id);
|
|
31
|
-
exports.isEditableSectionCategoryID = isEditableSectionCategoryID;
|
|
32
|
-
const isUnique = (categoryId) => {
|
|
33
|
-
return exports.uniqueSectionCategories.includes(categoryId);
|
|
34
|
-
};
|
|
35
|
-
exports.isUnique = isUnique;
|
|
36
|
-
const isBackMatterSection = (groupId) => {
|
|
37
|
-
return groupId === 'MPSectionCategory:backmatter';
|
|
38
|
-
};
|
|
39
|
-
exports.isBackMatterSection = isBackMatterSection;
|
|
40
|
-
const isSubSection = (categoryId) => {
|
|
41
|
-
return categoryId === 'MPSectionCategory:subsection';
|
|
42
|
-
};
|
|
43
|
-
exports.isSubSection = isSubSection;
|
|
44
|
-
const getCategoryName = (categories, id) => {
|
|
45
|
-
const category = categories.find((item) => item._id === id);
|
|
46
|
-
return category ? category.name : '';
|
|
47
|
-
};
|
|
48
|
-
exports.getCategoryName = getCategoryName;
|
|
@@ -1,38 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.sectionTitles = void 0;
|
|
19
|
-
exports.sectionTitles = new Map([
|
|
20
|
-
['MPSectionCategory:abstract', 'Abstract'],
|
|
21
|
-
['MPSectionCategory:abstract-graphical', 'Graphical Abstract'],
|
|
22
|
-
['MPSectionCategory:introduction', 'Introduction'],
|
|
23
|
-
['MPSectionCategory:materials-method', 'Materials & Methods'],
|
|
24
|
-
['MPSectionCategory:results', 'Results'],
|
|
25
|
-
['MPSectionCategory:discussion', 'Discussion'],
|
|
26
|
-
['MPSectionCategory:conclusions', 'Conclusions'],
|
|
27
|
-
['MPSectionCategory:acknowledgement', 'Acknowledgments'],
|
|
28
|
-
['MPSectionCategory:availability', 'Availability'],
|
|
29
|
-
[
|
|
30
|
-
'MPSectionCategory:competing-interests',
|
|
31
|
-
'COI Statement|Competing Interests',
|
|
32
|
-
],
|
|
33
|
-
['MPSectionCategory:con', 'Contributed-by information'],
|
|
34
|
-
['MPSectionCategory:ethics-statement', 'Ethics Statement'],
|
|
35
|
-
['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
|
|
36
|
-
['MPSectionCategory:supplementary-material', 'Supplementary Material'],
|
|
37
|
-
['MPSectionCategory:supported-by', 'Supported By'],
|
|
38
|
-
]);
|
|
@@ -1,85 +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.defaultEditorProps = exports.TEST_DATA = void 0;
|
|
22
|
-
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
|
-
const transform_1 = require("@manuscripts/transform");
|
|
24
|
-
const history_1 = require("history");
|
|
25
|
-
const popper_1 = require("../lib/popper");
|
|
26
|
-
const empty_editor_doc_json_1 = __importDefault(require("./empty-editor-doc.json"));
|
|
27
|
-
const theme = {};
|
|
28
|
-
exports.TEST_DATA = {
|
|
29
|
-
MANUSCRIPT: {
|
|
30
|
-
containerID: 'test-manuscript-1-containerID',
|
|
31
|
-
_id: 'test-manuscript-1-id',
|
|
32
|
-
objectType: 'MPManuscript',
|
|
33
|
-
createdAt: 1618400000,
|
|
34
|
-
updatedAt: 1618407000,
|
|
35
|
-
},
|
|
36
|
-
MODEL: {
|
|
37
|
-
_id: 'test-model-1-id',
|
|
38
|
-
objectType: 'MPSection',
|
|
39
|
-
createdAt: 1618400000,
|
|
40
|
-
updatedAt: 1618407000,
|
|
41
|
-
prototype: 'test-model-1-prototype',
|
|
42
|
-
},
|
|
43
|
-
USER: {
|
|
44
|
-
_id: 'test-user-profile-1-id',
|
|
45
|
-
objectType: 'MPUserProfile',
|
|
46
|
-
createdAt: 1618400000,
|
|
47
|
-
updatedAt: 1618407000,
|
|
48
|
-
bibliographicName: {
|
|
49
|
-
_id: 'test-user-profile-bibliographicName-1',
|
|
50
|
-
objectType: 'MPBibliographicName',
|
|
51
|
-
},
|
|
52
|
-
userID: 'test-user-profile-1-user-id',
|
|
53
|
-
},
|
|
54
|
-
DOC: transform_1.schema.nodeFromJSON(empty_editor_doc_json_1.default),
|
|
55
|
-
MODEL_MAP: new Map(),
|
|
56
|
-
};
|
|
57
|
-
exports.defaultEditorProps = {
|
|
58
|
-
attributes: {
|
|
59
|
-
class: 'manuscript-editor',
|
|
60
|
-
dir: 'ltr',
|
|
61
|
-
lang: 'en-GB',
|
|
62
|
-
spellcheck: 'true',
|
|
63
|
-
tabindex: '2',
|
|
64
|
-
},
|
|
65
|
-
doc: exports.TEST_DATA.DOC,
|
|
66
|
-
locale: 'en-GB',
|
|
67
|
-
popper: new popper_1.PopperManager(),
|
|
68
|
-
projectID: 'test-project-id',
|
|
69
|
-
getCurrentUser: () => exports.TEST_DATA.USER,
|
|
70
|
-
history: (0, history_1.createBrowserHistory)(),
|
|
71
|
-
theme,
|
|
72
|
-
getFiles: () => [],
|
|
73
|
-
fileManagement: {
|
|
74
|
-
upload: () => { },
|
|
75
|
-
download: () => { },
|
|
76
|
-
},
|
|
77
|
-
getCapabilities: () => (Object.assign(Object.assign({}, (0, style_guide_1.getAllPermitted)()), { editWithoutTracking: true })),
|
|
78
|
-
cslProps: {
|
|
79
|
-
style: '',
|
|
80
|
-
locale: '',
|
|
81
|
-
},
|
|
82
|
-
setComment: () => undefined,
|
|
83
|
-
setSelectedComment: () => undefined,
|
|
84
|
-
setEditorSelectedSuggestion: () => undefined,
|
|
85
|
-
};
|
|
@@ -1,35 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.polyfillDom = void 0;
|
|
19
|
-
function polyfillDom() {
|
|
20
|
-
window.scrollBy = jest.fn();
|
|
21
|
-
document.getSelection = jest.fn(() => ({
|
|
22
|
-
anchorNode: null,
|
|
23
|
-
anchorOffset: 0,
|
|
24
|
-
baseNode: null,
|
|
25
|
-
baseOffset: 0,
|
|
26
|
-
extentNode: null,
|
|
27
|
-
extentOffset: 0,
|
|
28
|
-
focusNode: null,
|
|
29
|
-
focusOffset: 0,
|
|
30
|
-
isCollapsed: true,
|
|
31
|
-
rangeCount: 0,
|
|
32
|
-
type: 'None',
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
exports.polyfillDom = polyfillDom;
|
|
@@ -1,63 +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.setupEditor = exports.parseDoc = void 0;
|
|
22
|
-
const transform_1 = require("@manuscripts/transform");
|
|
23
|
-
const jest_prosemirror_1 = require("jest-prosemirror");
|
|
24
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
25
|
-
const prosemirror_view_1 = require("prosemirror-view");
|
|
26
|
-
const editor_plugins_1 = __importDefault(require("../configs/editor-plugins"));
|
|
27
|
-
const editor_views_1 = __importDefault(require("../configs/editor-views"));
|
|
28
|
-
const default_editor_data_1 = require("./default-editor-data");
|
|
29
|
-
const polyfill_dom_1 = require("./polyfill-dom");
|
|
30
|
-
jest.mock('@manuscripts/transform', () => {
|
|
31
|
-
const mockTransformOriginal = jest.requireActual('@manuscripts/transform');
|
|
32
|
-
return Object.assign(Object.assign({}, mockTransformOriginal), { generateNodeID: () => {
|
|
33
|
-
return 'MOCKED_NODE_ID';
|
|
34
|
-
} });
|
|
35
|
-
});
|
|
36
|
-
function parseDoc(json) {
|
|
37
|
-
return transform_1.schema.nodeFromJSON(json);
|
|
38
|
-
}
|
|
39
|
-
exports.parseDoc = parseDoc;
|
|
40
|
-
function setupEditor() {
|
|
41
|
-
(0, polyfill_dom_1.polyfillDom)();
|
|
42
|
-
const props = Object.assign({}, default_editor_data_1.defaultEditorProps);
|
|
43
|
-
const { doc } = props;
|
|
44
|
-
const place = document.body.appendChild(document.createElement('div'));
|
|
45
|
-
const state = prosemirror_state_1.EditorState.create({
|
|
46
|
-
doc,
|
|
47
|
-
schema: transform_1.schema,
|
|
48
|
-
plugins: (0, editor_plugins_1.default)(props),
|
|
49
|
-
});
|
|
50
|
-
const view = new prosemirror_view_1.EditorView(place, {
|
|
51
|
-
state,
|
|
52
|
-
scrollMargin: {
|
|
53
|
-
top: 100,
|
|
54
|
-
bottom: 100,
|
|
55
|
-
left: 0,
|
|
56
|
-
right: 0,
|
|
57
|
-
},
|
|
58
|
-
handleScrollToSelection: () => true,
|
|
59
|
-
nodeViews: (0, editor_views_1.default)(props, () => { }),
|
|
60
|
-
});
|
|
61
|
-
return jest_prosemirror_1.ProsemirrorTestChain.of(view);
|
|
62
|
-
}
|
|
63
|
-
exports.setupEditor = setupEditor;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2024 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
|
-
export const uneditableSectionCategories = [
|
|
17
|
-
'MPSectionCategory:bibliography',
|
|
18
|
-
'MPSectionCategory:keywords',
|
|
19
|
-
'MPSectionCategory:list-of-figures',
|
|
20
|
-
'MPSectionCategory:list-of-tables',
|
|
21
|
-
'MPSectionCategory:toc',
|
|
22
|
-
];
|
|
23
|
-
export const uniqueSectionCategories = [
|
|
24
|
-
'MPSectionCategory:abstract-graphical',
|
|
25
|
-
'MPSectionCategory:abstract',
|
|
26
|
-
];
|
|
27
|
-
export const isEditableSectionCategoryID = (id) => !uneditableSectionCategories.includes(id);
|
|
28
|
-
export const isUnique = (categoryId) => {
|
|
29
|
-
return uniqueSectionCategories.includes(categoryId);
|
|
30
|
-
};
|
|
31
|
-
export const isBackMatterSection = (groupId) => {
|
|
32
|
-
return groupId === 'MPSectionCategory:backmatter';
|
|
33
|
-
};
|
|
34
|
-
export const isSubSection = (categoryId) => {
|
|
35
|
-
return categoryId === 'MPSectionCategory:subsection';
|
|
36
|
-
};
|
|
37
|
-
export const getCategoryName = (categories, id) => {
|
|
38
|
-
const category = categories.find((item) => item._id === id);
|
|
39
|
-
return category ? category.name : '';
|
|
40
|
-
};
|