@manuscripts/body-editor 3.12.33 → 3.12.35
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/ChangeHandlingForm.js +3 -2
- package/dist/cjs/components/affiliations/AffiliationForm.js +77 -44
- package/dist/cjs/components/affiliations/AffiliationsModal.js +69 -58
- package/dist/cjs/components/affiliations/AffiliationsPanel.js +1 -1
- package/dist/cjs/components/affiliations/CreateAffiliationModal.js +96 -0
- package/dist/cjs/components/authors/AuthorDetailsForm.js +110 -54
- package/dist/cjs/components/authors/AuthorsModal.js +71 -48
- package/dist/cjs/components/authors/AuthorsPanel.js +2 -2
- package/dist/cjs/components/authors/CreateAuthorModal.js +121 -0
- package/dist/cjs/components/authors/CreditDrawer.js +14 -12
- package/dist/cjs/components/authors-affiliations/AuthorsAndAffiliationsModals.js +8 -24
- package/dist/cjs/components/authors-affiliations/GenericPanel.js +2 -2
- package/dist/cjs/components/authors-affiliations/ModalTabs.js +80 -0
- package/dist/cjs/components/dialog/ConfirmationDialog.js +3 -2
- package/dist/cjs/components/form/CreateModalStyles.js +24 -0
- package/dist/cjs/components/form/FormFooter.js +8 -3
- package/dist/cjs/components/form/ModalFormActions.js +19 -42
- package/dist/cjs/components/form/UnsavedLabel.js +25 -0
- package/dist/cjs/components/hooks/useAffiliationShowsErrorIndicator.js +27 -0
- package/dist/cjs/components/hooks/useAuthorShowsErrorIndicator.js +40 -0
- package/dist/cjs/lib/authors-and-affiliations.js +51 -0
- package/dist/cjs/lib/helpers.js +28 -1
- package/dist/cjs/lib/normalize.js +17 -5
- package/dist/cjs/useEditor.js +7 -4
- package/dist/cjs/versions.js +1 -1
- package/dist/es/components/ChangeHandlingForm.js +3 -2
- package/dist/es/components/affiliations/AffiliationForm.js +75 -46
- package/dist/es/components/affiliations/AffiliationsModal.js +71 -60
- package/dist/es/components/affiliations/AffiliationsPanel.js +2 -2
- package/dist/es/components/affiliations/CreateAffiliationModal.js +56 -0
- package/dist/es/components/authors/AuthorDetailsForm.js +111 -56
- package/dist/es/components/authors/AuthorsModal.js +74 -51
- package/dist/es/components/authors/AuthorsPanel.js +3 -3
- package/dist/es/components/authors/CreateAuthorModal.js +81 -0
- package/dist/es/components/authors/CreditDrawer.js +13 -11
- package/dist/es/components/authors-affiliations/AuthorsAndAffiliationsModals.js +8 -24
- package/dist/es/components/authors-affiliations/GenericPanel.js +2 -2
- package/dist/es/components/authors-affiliations/ModalTabs.js +73 -0
- package/dist/es/components/dialog/ConfirmationDialog.js +3 -2
- package/dist/es/components/form/CreateModalStyles.js +18 -0
- package/dist/es/components/form/FormFooter.js +9 -4
- package/dist/es/components/form/ModalFormActions.js +18 -42
- package/dist/es/components/form/UnsavedLabel.js +18 -0
- package/dist/es/components/hooks/useAffiliationShowsErrorIndicator.js +21 -0
- package/dist/es/components/hooks/useAuthorShowsErrorIndicator.js +34 -0
- package/dist/es/lib/authors-and-affiliations.js +48 -0
- package/dist/es/lib/helpers.js +27 -1
- package/dist/es/lib/normalize.js +15 -4
- package/dist/es/useEditor.js +8 -5
- package/dist/es/versions.js +1 -1
- package/dist/es/views/affiliations.js +1 -1
- package/dist/types/components/affiliations/AffiliationForm.d.ts +6 -2
- package/dist/types/components/affiliations/AffiliationsModal.d.ts +1 -1
- package/dist/types/components/affiliations/CreateAffiliationModal.d.ts +8 -0
- package/dist/types/components/authors/AuthorDetailsForm.d.ts +11 -1
- package/dist/types/components/authors/AuthorsPanel.d.ts +1 -1
- package/dist/types/components/authors/CreateAuthorModal.d.ts +9 -0
- package/dist/types/components/authors/CreditDrawer.d.ts +2 -4
- package/dist/types/components/authors-affiliations/ModalTabs.d.ts +22 -0
- package/dist/types/components/form/CreateModalStyles.d.ts +4 -0
- package/dist/types/components/form/FormFooter.d.ts +2 -1
- package/dist/types/components/form/ModalFormActions.d.ts +12 -6
- package/dist/types/components/form/UnsavedLabel.d.ts +10 -0
- package/dist/types/components/hooks/useAffiliationShowsErrorIndicator.d.ts +5 -0
- package/dist/types/components/hooks/useAuthorShowsErrorIndicator.d.ts +5 -0
- package/dist/types/lib/authors-and-affiliations.d.ts +19 -0
- package/dist/types/lib/helpers.d.ts +2 -0
- package/dist/types/lib/normalize.d.ts +2 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2026 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 { InspectorTab, InspectorTabList } from '@manuscripts/style-guide';
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import styled from 'styled-components';
|
|
19
|
+
export const ModalTabs = ({ tabLabels, tabErrorIndicators, tabWarningIndicators, }) => (React.createElement(StyledTabList, null, tabLabels.map((label, i) => {
|
|
20
|
+
const hasError = tabErrorIndicators?.[i];
|
|
21
|
+
const showWarning = tabWarningIndicators?.[i] && !hasError;
|
|
22
|
+
return (React.createElement(StyledTab, { key: label },
|
|
23
|
+
label,
|
|
24
|
+
(showWarning || hasError) && (React.createElement(TabIndicatorGroup, { role: "presentation" },
|
|
25
|
+
showWarning ? React.createElement(TabWarningDot, { "aria-hidden": true }) : null,
|
|
26
|
+
hasError ? React.createElement(TabErrorDot, { "aria-hidden": true }) : null))));
|
|
27
|
+
})));
|
|
28
|
+
const TabIndicatorGroup = styled.span `
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 6px;
|
|
32
|
+
margin-left: 6px;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
`;
|
|
35
|
+
const TabErrorDot = styled.span `
|
|
36
|
+
display: inline-block;
|
|
37
|
+
width: 8px;
|
|
38
|
+
height: 8px;
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
background: #cf1322;
|
|
41
|
+
flex-shrink: 0;
|
|
42
|
+
vertical-align: middle;
|
|
43
|
+
`;
|
|
44
|
+
const TabWarningDot = styled.span `
|
|
45
|
+
display: inline-block;
|
|
46
|
+
width: 8px;
|
|
47
|
+
height: 8px;
|
|
48
|
+
border-radius: 50%;
|
|
49
|
+
background: ${(props) => props.theme.colors.text.warning};
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
vertical-align: middle;
|
|
52
|
+
`;
|
|
53
|
+
const StyledTab = styled(InspectorTab) `
|
|
54
|
+
border-radius: 14px;
|
|
55
|
+
flex: 1;
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
|
|
60
|
+
&[aria-selected='true'] {
|
|
61
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
62
|
+
border: unset;
|
|
63
|
+
color: ${(props) => props.theme.colors.text.primary} !important;
|
|
64
|
+
font-weight: 700;
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
const StyledTabList = styled(InspectorTabList) `
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: space-evenly;
|
|
70
|
+
border-radius: 14px;
|
|
71
|
+
background: #e2e2e2 !important;
|
|
72
|
+
padding: 2px;
|
|
73
|
+
`;
|
|
@@ -25,8 +25,8 @@ const getDialogConfig = (dialogType, entityType) => {
|
|
|
25
25
|
secondary: 'Would you like to save or discard your changes?',
|
|
26
26
|
},
|
|
27
27
|
buttons: {
|
|
28
|
-
primary: '
|
|
29
|
-
secondary: 'Discard',
|
|
28
|
+
primary: 'Continue editing',
|
|
29
|
+
secondary: 'Discard changes',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
[DialogType.DELETE]: {
|
|
@@ -74,6 +74,7 @@ export const ConfirmationDialog = ({ isOpen, type, entityType, onPrimary, onSeco
|
|
|
74
74
|
secondary: {
|
|
75
75
|
action: onSecondary,
|
|
76
76
|
title: config.buttons.secondary,
|
|
77
|
+
variant: type === DialogType.DELETE ? 'default' : 'textDanger',
|
|
77
78
|
},
|
|
78
79
|
} }));
|
|
79
80
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModalBody, ScrollableModalContent } from '@manuscripts/style-guide';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
export const MODAL_ON_CLOSE_NOTIFY_DELAY_MS = 220;
|
|
4
|
+
export const StyledModalBody = styled(ModalBody) `
|
|
5
|
+
position: relative;
|
|
6
|
+
height: calc(90vh - 250px);
|
|
7
|
+
`;
|
|
8
|
+
export const FormTitle = styled.h2 `
|
|
9
|
+
margin: 0 0 ${(props) => props.theme.grid.unit * 3}px;
|
|
10
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
11
|
+
font-size: ${(props) => props.theme.font.size.large};
|
|
12
|
+
font-weight: ${(props) => props.theme.font.weight.semibold};
|
|
13
|
+
line-height: ${(props) => props.theme.font.lineHeight.large};
|
|
14
|
+
color: ${(props) => props.theme.colors.text.primary};
|
|
15
|
+
`;
|
|
16
|
+
export const StyledScrollableModalContent = styled(ScrollableModalContent) `
|
|
17
|
+
padding: 45px 16px 16px;
|
|
18
|
+
`;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IconTextButton } from '@manuscripts/style-guide';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
const Footer = styled.div `
|
|
5
5
|
display: flex;
|
|
6
6
|
justify-content: flex-end;
|
|
7
7
|
align-items: center;
|
|
8
|
+
gap: ${(props) => props.theme.grid.unit * 6}px;
|
|
8
9
|
padding: 16px 32px;
|
|
9
|
-
height: 40px;
|
|
10
|
+
min-height: 40px;
|
|
10
11
|
box-shadow: 0px -2px 12px 0px rgba(216, 216, 216, 0.26);
|
|
11
12
|
border-radius: 0px 0px 8px 8px;
|
|
12
13
|
position: relative;
|
|
13
14
|
z-index: 3;
|
|
14
15
|
`;
|
|
15
|
-
const
|
|
16
|
+
const StyledIconTextButton = styled(IconTextButton) `
|
|
17
|
+
color: ${(props) => props.theme.colors.brand.default};
|
|
18
|
+
`;
|
|
19
|
+
const FormFooter = ({ onCancel, primaryAction, }) => {
|
|
16
20
|
return (React.createElement(Footer, null,
|
|
17
|
-
React.createElement(
|
|
21
|
+
React.createElement(StyledIconTextButton, { color: "secondary", onClick: onCancel }, "Close"),
|
|
22
|
+
primaryAction));
|
|
18
23
|
};
|
|
19
24
|
export default FormFooter;
|
|
@@ -1,48 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimaryButton } from '@manuscripts/style-guide';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import styled from 'styled-components';
|
|
4
3
|
import { ConfirmationDialog, DialogType } from '../dialog/ConfirmationDialog';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const StyledButtonGroup = styled(ButtonGroup) `
|
|
12
|
-
flex: 1;
|
|
13
|
-
`;
|
|
14
|
-
const StyledIconButton = styled(IconButton) `
|
|
15
|
-
color: #0d79d0;
|
|
16
|
-
text-align: center;
|
|
17
|
-
font-size: 14px;
|
|
18
|
-
font-style: normal;
|
|
19
|
-
font-weight: 400;
|
|
20
|
-
line-height: 1;
|
|
21
|
-
width: auto;
|
|
22
|
-
height: 24px;
|
|
23
|
-
&:disabled {
|
|
24
|
-
color: #c9c9c9 !important;
|
|
25
|
-
background-color: unset !important;
|
|
26
|
-
border: unset;
|
|
27
|
-
}
|
|
28
|
-
svg {
|
|
29
|
-
margin-right: 4px;
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
export const ModalFormActions = ({ type, form, onDelete, showingDeleteDialog, showDeleteDialog, newEntity, isDisableSave, onSubmitForm, }) => {
|
|
33
|
-
const saveButton = onSubmitForm ? (React.createElement(StyledIconButton, { disabled: isDisableSave, type: "button", onClick: () => {
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
export const ModalFormSaveButton = ({ form, newEntity, isDisableSave, onSubmitForm, createLabel, updateLabel, }) => {
|
|
6
|
+
const label = newEntity
|
|
7
|
+
? (createLabel ?? 'Save Changes')
|
|
8
|
+
: (updateLabel ?? 'Update Changes');
|
|
9
|
+
const saveButton = onSubmitForm ? (React.createElement(StylePrimaryButton, { disabled: isDisableSave, type: "button", onClick: () => {
|
|
34
10
|
if (!isDisableSave) {
|
|
35
11
|
void onSubmitForm();
|
|
36
12
|
}
|
|
37
|
-
} },
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
showDeleteDialog();
|
|
46
|
-
}, onSecondary: showDeleteDialog, type: DialogType.DELETE, entityType: type }),
|
|
47
|
-
React.createElement(StyledButtonGroup, null, saveButton)));
|
|
13
|
+
} }, label)) : (React.createElement(StylePrimaryButton, { disabled: isDisableSave, type: "submit", form: form }, label));
|
|
14
|
+
return saveButton;
|
|
15
|
+
};
|
|
16
|
+
export const ModalFormActions = ({ type, onDelete, showingDeleteDialog, showDeleteDialog, }) => {
|
|
17
|
+
return (React.createElement(ConfirmationDialog, { isOpen: showingDeleteDialog, onPrimary: () => {
|
|
18
|
+
onDelete();
|
|
19
|
+
showDeleteDialog();
|
|
20
|
+
}, onSecondary: showDeleteDialog, type: DialogType.DELETE, entityType: type }));
|
|
48
21
|
};
|
|
22
|
+
const StylePrimaryButton = styled(PrimaryButton) `
|
|
23
|
+
min-width: 145px;
|
|
24
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Label } from '@manuscripts/style-guide';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
export const UnsavedLabel = ({ htmlFor, showDot, children, }) => (React.createElement(UnsavedLabelRow, null,
|
|
5
|
+
showDot ? React.createElement(FieldUnsavedDot, { "aria-hidden": true }) : null,
|
|
6
|
+
React.createElement(Label, { htmlFor: htmlFor }, children)));
|
|
7
|
+
export const UnsavedLabelRow = styled.div `
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: 6px;
|
|
11
|
+
`;
|
|
12
|
+
export const FieldUnsavedDot = styled.span `
|
|
13
|
+
width: 8px;
|
|
14
|
+
height: 8px;
|
|
15
|
+
border-radius: 50%;
|
|
16
|
+
background: ${(props) => props.theme.colors.text.warning};
|
|
17
|
+
flex-shrink: 0;
|
|
18
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getIn, useFormikContext } from 'formik';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
export function isInstitutionError(formik, newEntity) {
|
|
4
|
+
if (!getIn(formik.errors, 'institution')) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (newEntity) {
|
|
8
|
+
return Boolean(formik.touched.institution || formik.dirty);
|
|
9
|
+
}
|
|
10
|
+
return Boolean(formik.touched.institution);
|
|
11
|
+
}
|
|
12
|
+
export function affiliationShowsErrorIndicator(formik, newEntity) {
|
|
13
|
+
return isInstitutionError(formik, newEntity);
|
|
14
|
+
}
|
|
15
|
+
export const useAffiliationShowsErrorIndicator = (newEntity, onChange) => {
|
|
16
|
+
const formik = useFormikContext();
|
|
17
|
+
const hasError = affiliationShowsErrorIndicator(formik, newEntity);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
onChange?.(hasError);
|
|
20
|
+
}, [hasError, onChange]);
|
|
21
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getIn, useFormikContext } from 'formik';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
export function isNamePairError(formik, newEntity, requiredContinueActive = false) {
|
|
4
|
+
if (!getIn(formik.errors, 'given')) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (requiredContinueActive) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (newEntity) {
|
|
11
|
+
return Boolean(formik.touched.given || formik.touched.family);
|
|
12
|
+
}
|
|
13
|
+
return Boolean(formik.touched.given || formik.touched.family || formik.dirty);
|
|
14
|
+
}
|
|
15
|
+
export function authorShowsErrorIndicator(formik, newEntity, requiredContinueActive = false) {
|
|
16
|
+
if (isNamePairError(formik, newEntity, requiredContinueActive)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if ((getIn(formik.touched, 'email') || requiredContinueActive) &&
|
|
20
|
+
getIn(formik.errors, 'email')) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (getIn(formik.touched, 'ORCID') && getIn(formik.errors, 'ORCID')) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
export const useAuthorShowsErrorIndicator = (newEntity, requiredContinueActive, onChange) => {
|
|
29
|
+
const formik = useFormikContext();
|
|
30
|
+
const hasError = authorShowsErrorIndicator(formik, newEntity, requiredContinueActive);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
onChange?.(hasError);
|
|
33
|
+
}, [hasError, onChange]);
|
|
34
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2026 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 { generateNodeID, schema, } from '@manuscripts/transform';
|
|
17
|
+
import { findInsertionPosition } from './utils';
|
|
18
|
+
import { findChildByType, updateNodeAttrs } from './view';
|
|
19
|
+
function insertNode(parentType, childType) {
|
|
20
|
+
return (view, attrs) => {
|
|
21
|
+
const parent = findChildByType(view, parentType);
|
|
22
|
+
let tr = view.state.tr;
|
|
23
|
+
if (parent) {
|
|
24
|
+
tr = tr.insert(parent.pos + 1, childType.create(attrs));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const insertPos = findInsertionPosition(parentType, view.state.doc);
|
|
28
|
+
const wrapper = parentType.create({
|
|
29
|
+
id: generateNodeID(parentType),
|
|
30
|
+
});
|
|
31
|
+
tr = tr
|
|
32
|
+
.insert(insertPos, wrapper)
|
|
33
|
+
.insert(insertPos + 1, childType.create(attrs));
|
|
34
|
+
}
|
|
35
|
+
view.dispatch(tr);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function upsertNode(nodeType, insertFn) {
|
|
39
|
+
return (view, attrs) => {
|
|
40
|
+
if (!updateNodeAttrs(view, nodeType, attrs)) {
|
|
41
|
+
insertFn(view, attrs);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const insertAuthorNode = insertNode(schema.nodes.contributors, schema.nodes.contributor);
|
|
46
|
+
const insertAffiliationNode = insertNode(schema.nodes.affiliations, schema.nodes.affiliation);
|
|
47
|
+
export const upsertAuthor = upsertNode(schema.nodes.contributor, insertAuthorNode);
|
|
48
|
+
export const upsertAffiliation = upsertNode(schema.nodes.affiliation, insertAffiliationNode);
|
package/dist/es/lib/helpers.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { schema, } from '@manuscripts/transform';
|
|
16
|
+
import { isExecutableNodeType, schema, } from '@manuscripts/transform';
|
|
17
|
+
import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
17
18
|
export const isNodeOfType = (...type) => (node) => {
|
|
18
19
|
const [head, ...tail] = type;
|
|
19
20
|
if (node.type === node.type.schema.nodes[head]) {
|
|
@@ -45,6 +46,31 @@ export const mergeSimilarItems = (compareFunc, mergeFunc) => (items) => {
|
|
|
45
46
|
];
|
|
46
47
|
}, []);
|
|
47
48
|
};
|
|
49
|
+
export const selectionForOutlineNavigation = (doc, pos) => {
|
|
50
|
+
const node = doc.nodeAt(pos);
|
|
51
|
+
if (!node || isExecutableNodeType(node.type)) {
|
|
52
|
+
return NodeSelection.create(doc, pos);
|
|
53
|
+
}
|
|
54
|
+
if (node.isTextblock) {
|
|
55
|
+
return TextSelection.create(doc, pos + 1);
|
|
56
|
+
}
|
|
57
|
+
if (node.type === schema.nodes.section) {
|
|
58
|
+
let textPos = null;
|
|
59
|
+
node.forEach((child, offset) => {
|
|
60
|
+
if (textPos !== null) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (child.type === schema.nodes.section_title ||
|
|
64
|
+
child.type === schema.nodes.section_title_plain) {
|
|
65
|
+
textPos = pos + 1 + offset + 1;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (textPos !== null) {
|
|
69
|
+
return TextSelection.create(doc, textPos);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return NodeSelection.create(doc, pos);
|
|
73
|
+
};
|
|
48
74
|
export const handleScrollToSelectedTarget = (view) => {
|
|
49
75
|
const selection = view.state.selection;
|
|
50
76
|
if (selection.empty) {
|
package/dist/es/lib/normalize.js
CHANGED
|
@@ -15,6 +15,19 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { generateNodeID, schema } from '@manuscripts/transform';
|
|
17
17
|
const trim = (value) => (value ?? '').trim();
|
|
18
|
+
export const normalizeAffiliation = (a) => ({
|
|
19
|
+
...a,
|
|
20
|
+
institution: trim(a.institution),
|
|
21
|
+
department: trim(a.department),
|
|
22
|
+
addressLine1: trim(a.addressLine1),
|
|
23
|
+
addressLine2: trim(a.addressLine2),
|
|
24
|
+
addressLine3: trim(a.addressLine3),
|
|
25
|
+
postCode: trim(a.postCode),
|
|
26
|
+
country: trim(a.country),
|
|
27
|
+
county: trim(a.county),
|
|
28
|
+
city: trim(a.city),
|
|
29
|
+
email: a.email ?? { href: '', text: '' },
|
|
30
|
+
});
|
|
18
31
|
export const normalizeAuthor = (author) => {
|
|
19
32
|
const basic = {
|
|
20
33
|
id: author.id,
|
|
@@ -28,15 +41,13 @@ export const normalizeAuthor = (author) => {
|
|
|
28
41
|
isAuthenticated: author.isAuthenticated || false,
|
|
29
42
|
priority: author.priority,
|
|
30
43
|
isJointContributor: author.isJointContributor || false,
|
|
31
|
-
degrees: author.degrees
|
|
44
|
+
degrees: Array.isArray(author.degrees) ? author.degrees : [],
|
|
32
45
|
footnoteIDs: author.footnoteIDs || [],
|
|
33
46
|
correspIDs: author.correspIDs || [],
|
|
34
47
|
prefix: trim(author.prefix),
|
|
35
48
|
suffix: trim(author.suffix),
|
|
49
|
+
creditRoles: Array.isArray(author.creditRoles) ? author.creditRoles : [],
|
|
36
50
|
};
|
|
37
|
-
if (author.creditRoles && Array.isArray(author.creditRoles)) {
|
|
38
|
-
basic.creditRoles = author.creditRoles;
|
|
39
|
-
}
|
|
40
51
|
return basic;
|
|
41
52
|
};
|
|
42
53
|
export const checkID = (attrs, nodeType) => {
|
package/dist/es/useEditor.js
CHANGED
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { trackChangesPluginKey, TrackChangesStatus, } from '@manuscripts/track-changes-plugin';
|
|
17
17
|
import { getVersion, receiveTransaction, sendableSteps, } from 'prosemirror-collab';
|
|
18
|
-
import {
|
|
18
|
+
import { TextSelection, } from 'prosemirror-state';
|
|
19
19
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
20
20
|
import { useLocation } from 'react-router-dom';
|
|
21
21
|
import { createEditorState, createEditorView, } from './configs/ManuscriptsEditor';
|
|
22
22
|
import { PopperManager } from './lib/popper';
|
|
23
23
|
import { useDoWithDebounce } from './lib/use-do-with-debounce';
|
|
24
|
+
import { selectionForOutlineNavigation } from './lib/helpers';
|
|
24
25
|
import { searchReplaceKey } from './plugins/search-replace';
|
|
25
26
|
export const useEditor = (externalProps) => {
|
|
26
27
|
const view = useRef(undefined);
|
|
@@ -106,12 +107,14 @@ export const useEditor = (externalProps) => {
|
|
|
106
107
|
if (!id || !currentView || !state) {
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
+
const viewState = currentView.state;
|
|
111
|
+
viewState.doc.descendants((node, pos) => {
|
|
110
112
|
if (node.attrs.id === id) {
|
|
111
113
|
currentView.focus();
|
|
112
|
-
const selection =
|
|
113
|
-
currentView.dispatch(
|
|
114
|
-
const
|
|
114
|
+
const selection = selectionForOutlineNavigation(viewState.doc, pos);
|
|
115
|
+
currentView.dispatch(viewState.tr.setSelection(selection));
|
|
116
|
+
const scrollPos = selection instanceof TextSelection ? selection.from : pos + 1;
|
|
117
|
+
const dom = currentView.domAtPos(scrollPos);
|
|
115
118
|
if (dom.node instanceof Element) {
|
|
116
119
|
dom.node.scrollIntoView({
|
|
117
120
|
behavior: 'smooth',
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.12.
|
|
1
|
+
export const VERSION = '3.12.35';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -19,7 +19,7 @@ import { schema } from '@manuscripts/transform';
|
|
|
19
19
|
import { NodeSelection } from 'prosemirror-state';
|
|
20
20
|
import { AuthorsAndAffiliationsModals, } from '../components/authors-affiliations/AuthorsAndAffiliationsModals';
|
|
21
21
|
import { alertIcon } from '../icons';
|
|
22
|
-
import { affiliationName
|
|
22
|
+
import { affiliationName } from '../lib/authors';
|
|
23
23
|
import { handleComment } from '../lib/comments';
|
|
24
24
|
import { findChildByID, findChildrenAttrsByType } from '../lib/view';
|
|
25
25
|
import { affiliationsKey } from '../plugins/affiliations';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { MutableRefObject } from 'react';
|
|
2
2
|
import { AffiliationAttrs } from '../../lib/authors';
|
|
3
|
+
export { affiliationShowsErrorIndicator } from '../hooks/useAffiliationShowsErrorIndicator';
|
|
3
4
|
export interface FormActions {
|
|
4
5
|
reset: () => void;
|
|
5
6
|
submitForm: () => Promise<void> | void;
|
|
@@ -8,6 +9,9 @@ export interface AffiliationFormProps {
|
|
|
8
9
|
values: AffiliationAttrs;
|
|
9
10
|
onSave: (values: AffiliationAttrs) => void;
|
|
10
11
|
onChange: (values: AffiliationAttrs) => void;
|
|
11
|
-
actionsRef?:
|
|
12
|
+
actionsRef?: MutableRefObject<FormActions | undefined>;
|
|
13
|
+
newEntity?: boolean;
|
|
14
|
+
onAffiliationErrorChange?: (hasError: boolean) => void;
|
|
15
|
+
unsavedContinueActive?: boolean;
|
|
12
16
|
}
|
|
13
17
|
export declare const AffiliationForm: React.FC<AffiliationFormProps>;
|
|
@@ -9,6 +9,6 @@ export interface AffiliationsModalProps {
|
|
|
9
9
|
onUpdateAuthors: (authors: ContributorAttrs[]) => void;
|
|
10
10
|
addNewAffiliation?: boolean;
|
|
11
11
|
onClose?: () => void;
|
|
12
|
-
|
|
12
|
+
openAuthorsModal?: () => void;
|
|
13
13
|
}
|
|
14
14
|
export declare const AffiliationsModal: React.FC<AffiliationsModalProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AffiliationAttrs } from '../../lib/authors';
|
|
3
|
+
export interface CreateAffiliationModalProps {
|
|
4
|
+
affiliationsCount: number;
|
|
5
|
+
onSave: (affiliation: AffiliationAttrs) => void;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const CreateAffiliationModal: React.FC<CreateAffiliationModalProps>;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { CreditRole } from '@manuscripts/transform';
|
|
17
17
|
import React, { MutableRefObject } from 'react';
|
|
18
18
|
import { ContributorAttrs } from '../../lib/authors';
|
|
19
|
+
export { authorShowsErrorIndicator as authorDetailsTabShowsErrorIndicator } from '../hooks/useAuthorShowsErrorIndicator';
|
|
19
20
|
export interface FormActions {
|
|
20
21
|
reset: () => void;
|
|
21
22
|
submitForm: () => Promise<void> | void;
|
|
@@ -29,8 +30,17 @@ interface AuthorDetailsFormProps {
|
|
|
29
30
|
isEmailRequired?: boolean;
|
|
30
31
|
selectedAffiliations?: string[];
|
|
31
32
|
selectedCreditRoles: CreditRole[];
|
|
33
|
+
newEntity: boolean;
|
|
34
|
+
onAuthorDetailsTabErrorChange?: (hasError: boolean) => void;
|
|
35
|
+
unsavedContinueActive?: boolean;
|
|
36
|
+
requiredContinueActive?: boolean;
|
|
32
37
|
}
|
|
33
38
|
export declare const AuthorDetailsForm: React.FC<AuthorDetailsFormProps>;
|
|
34
39
|
export declare const Fieldset: import("styled-components").StyledComponent<"fieldset", any, {}, never>;
|
|
35
40
|
export declare const CheckboxContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
36
|
-
export {}
|
|
41
|
+
export declare const StyledFormGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
42
|
+
export declare const StyledFormRow: import("styled-components").StyledComponent<"div", any, {
|
|
43
|
+
direction?: "row" | "column";
|
|
44
|
+
justify?: string;
|
|
45
|
+
align?: string;
|
|
46
|
+
}, never>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AffiliationAttrs, ContributorAttrs } from '../../lib/authors';
|
|
3
|
+
export interface CreateAuthorModalProps {
|
|
4
|
+
authorsCount: number;
|
|
5
|
+
affiliations: AffiliationAttrs[];
|
|
6
|
+
onSave: (author: ContributorAttrs) => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const CreateAuthorModal: React.FC<CreateAuthorModalProps>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DrawerProps } from '@manuscripts/style-guide';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
interface
|
|
2
|
+
export interface CreditContributionsCheckboxesProps {
|
|
4
3
|
items: {
|
|
5
4
|
id: string;
|
|
6
5
|
vocabTerm: string;
|
|
@@ -10,5 +9,4 @@ interface CreditDrawerProps {
|
|
|
10
9
|
}[];
|
|
11
10
|
onSelect: (id: string) => void;
|
|
12
11
|
}
|
|
13
|
-
export declare const
|
|
14
|
-
export {};
|
|
12
|
+
export declare const CreditContributionsCheckboxes: React.FC<CreditContributionsCheckboxesProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2026 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 React from 'react';
|
|
17
|
+
export interface ModalTabsProps {
|
|
18
|
+
tabLabels: string[];
|
|
19
|
+
tabErrorIndicators?: boolean[];
|
|
20
|
+
tabWarningIndicators?: boolean[];
|
|
21
|
+
}
|
|
22
|
+
export declare const ModalTabs: React.FC<ModalTabsProps>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const MODAL_ON_CLOSE_NOTIFY_DELAY_MS = 220;
|
|
2
|
+
export declare const StyledModalBody: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const FormTitle: import("styled-components").StyledComponent<"h2", any, {}, never>;
|
|
4
|
+
export declare const StyledScrollableModalContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
export interface
|
|
3
|
-
type: string;
|
|
2
|
+
export interface ModalFormSaveButtonProps {
|
|
4
3
|
form: string;
|
|
5
|
-
onDelete: () => void;
|
|
6
|
-
showingDeleteDialog: boolean;
|
|
7
|
-
showDeleteDialog: () => void;
|
|
8
4
|
newEntity: boolean;
|
|
9
5
|
isDisableSave: boolean;
|
|
10
6
|
onSubmitForm?: () => void | Promise<void>;
|
|
7
|
+
createLabel?: string;
|
|
8
|
+
updateLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const ModalFormSaveButton: React.FC<ModalFormSaveButtonProps>;
|
|
11
|
+
interface ModalFormActionsProps {
|
|
12
|
+
type: string;
|
|
13
|
+
onDelete: () => void;
|
|
14
|
+
showingDeleteDialog: boolean;
|
|
15
|
+
showDeleteDialog: () => void;
|
|
11
16
|
}
|
|
12
|
-
export declare const ModalFormActions: React.FC<
|
|
17
|
+
export declare const ModalFormActions: React.FC<ModalFormActionsProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface UnsavedLabelProps {
|
|
3
|
+
htmlFor: string;
|
|
4
|
+
showDot: boolean;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const UnsavedLabel: React.FC<UnsavedLabelProps>;
|
|
8
|
+
export declare const UnsavedLabelRow: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const FieldUnsavedDot: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FormikProps } from 'formik';
|
|
2
|
+
import { AffiliationAttrs } from '../../lib/authors';
|
|
3
|
+
export declare function isInstitutionError(formik: FormikProps<AffiliationAttrs>, newEntity: boolean): boolean;
|
|
4
|
+
export declare function affiliationShowsErrorIndicator(formik: FormikProps<AffiliationAttrs>, newEntity: boolean): boolean;
|
|
5
|
+
export declare const useAffiliationShowsErrorIndicator: (newEntity: boolean, onChange?: (hasError: boolean) => void) => void;
|