@manuscripts/body-editor 2.7.17-LEAN-4231.0 → 2.7.18

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.
Files changed (37) hide show
  1. package/dist/cjs/commands.js +0 -6
  2. package/dist/cjs/components/ChangeHandlingForm.js +1 -1
  3. package/dist/cjs/components/affiliations/AffiliationForm.js +1 -1
  4. package/dist/cjs/components/affiliations/AffiliationsModal.js +2 -2
  5. package/dist/cjs/components/authors/AuthorDetailsForm.js +4 -4
  6. package/dist/cjs/components/authors/AuthorsModal.js +27 -16
  7. package/dist/cjs/components/authors/DraggableAuthor.js +3 -1
  8. package/dist/cjs/components/form/ModalFormActions.js +2 -2
  9. package/dist/cjs/components/outline/DraggableTree.js +0 -1
  10. package/dist/cjs/configs/editor-views.js +0 -1
  11. package/dist/cjs/lib/files.js +1 -3
  12. package/dist/cjs/menus.js +0 -6
  13. package/dist/cjs/node-type-icons.js +0 -2
  14. package/dist/cjs/plugins/objects.js +9 -15
  15. package/dist/cjs/versions.js +1 -1
  16. package/dist/es/commands.js +0 -6
  17. package/dist/es/components/ChangeHandlingForm.js +1 -1
  18. package/dist/es/components/affiliations/AffiliationForm.js +1 -1
  19. package/dist/es/components/affiliations/AffiliationsModal.js +2 -2
  20. package/dist/es/components/authors/AuthorDetailsForm.js +4 -4
  21. package/dist/es/components/authors/AuthorsModal.js +27 -16
  22. package/dist/es/components/authors/DraggableAuthor.js +3 -1
  23. package/dist/es/components/form/ModalFormActions.js +2 -2
  24. package/dist/es/components/outline/DraggableTree.js +0 -1
  25. package/dist/es/configs/editor-views.js +0 -1
  26. package/dist/es/lib/files.js +1 -3
  27. package/dist/es/menus.js +0 -6
  28. package/dist/es/node-type-icons.js +1 -3
  29. package/dist/es/plugins/objects.js +9 -15
  30. package/dist/es/versions.js +1 -1
  31. package/dist/types/components/ChangeHandlingForm.d.ts +3 -1
  32. package/dist/types/components/authors/AuthorDetailsForm.d.ts +1 -0
  33. package/dist/types/components/form/ModalFormActions.d.ts +1 -1
  34. package/dist/types/configs/editor-views.d.ts +0 -26
  35. package/dist/types/versions.d.ts +1 -1
  36. package/package.json +2 -2
  37. package/styles/Editor.css +0 -6
@@ -145,9 +145,6 @@ const createBlock = (nodeType, position, state, dispatch, attrs) => {
145
145
  case state.schema.nodes.figure_element:
146
146
  node = createAndFillFigureElement(state);
147
147
  break;
148
- case state.schema.nodes.image_element:
149
- node = createImageElement(state);
150
- break;
151
148
  case state.schema.nodes.listing_element:
152
149
  node = state.schema.nodes.listing_element.create({}, [
153
150
  state.schema.nodes.listing.create(),
@@ -993,9 +990,6 @@ const createAndFillFigcaptionElement = (state) => state.schema.nodes.figcaption.
993
990
  state.schema.nodes.caption_title.create(),
994
991
  state.schema.nodes.caption.create(),
995
992
  ]);
996
- const createImageElement = (state) => state.schema.nodes.image_element.create({}, [
997
- state.schema.nodes.figure.create(),
998
- ]);
999
993
  const getParentNode = (selection) => {
1000
994
  var _a;
1001
995
  const parentNode = (0, utils_1.findParentNodeWithId)(selection);
@@ -36,7 +36,7 @@ const ChangeHandlingForm = (props) => {
36
36
  var _a;
37
37
  (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values);
38
38
  }, [props.onChange, values]);
39
- return react_1.default.createElement(exports.FlexForm, null, props.children);
39
+ return (react_1.default.createElement(exports.FlexForm, { id: props.id, ref: props.formRef }, props.children));
40
40
  };
41
41
  exports.ChangeHandlingForm = ChangeHandlingForm;
42
42
  exports.FlexForm = (0, styled_components_1.default)(formik_1.Form) `
@@ -87,7 +87,7 @@ const AffiliationForm = ({ values, onSave, onChange, actionsRef, }) => {
87
87
  };
88
88
  }
89
89
  const formRef = (0, react_1.useRef)(null);
90
- return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, innerRef: formRef, enableReinitialize: true }, () => (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange },
90
+ return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, innerRef: formRef, enableReinitialize: true }, () => (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange, id: "affiliation-form" },
91
91
  react_1.default.createElement(FormLabel, null, "Institution*"),
92
92
  react_1.default.createElement(Row, null,
93
93
  react_1.default.createElement(formik_1.Field, { name: "institution" }, (props) => (react_1.default.createElement(AffiliationsTextField, Object.assign({ id: "institution", placeholder: "Institution Name" }, props.field))))),
@@ -397,8 +397,8 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, onS
397
397
  react_1.default.createElement(ActionTitle, null, "New Affiliation")),
398
398
  react_1.default.createElement(AffiliationList_1.AffiliationList, { affiliation: selection, affiliations: affiliations, onSelect: handleSelect, onDelete: handleShowDeleteDialog, lastSavedAffiliationId: savedAffiliationId }))),
399
399
  react_1.default.createElement(style_guide_1.ScrollableModalContent, { "data-cy": "affiliations-modal-content" }, selection ? (react_1.default.createElement(AffiliationForms, null,
400
- react_1.default.createElement(ModalFormActions_1.ModalFormActions, { type: 'affiliation', onSave: () => handleSaveAffiliation(valuesRef.current), onDelete: handleDeleteAffiliation, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAffiliation, isDisableSave: isDisableSave }),
401
- react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values: normalize(selection), onSave: handleSaveAffiliation, onChange: handleAffiliationChange, actionsRef: actionsRef }),
400
+ react_1.default.createElement(ModalFormActions_1.ModalFormActions, { type: 'affiliation', form: 'affiliation-form', onDelete: handleDeleteAffiliation, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAffiliation, isDisableSave: isDisableSave }),
401
+ react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values: normalize(selection), onSave: () => handleSaveAffiliation(valuesRef.current), onChange: handleAffiliationChange, actionsRef: actionsRef }),
402
402
  react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => setShowRequiredFieldConfirmationDialog(false), onSecondary: handleConfirmationCancel, type: ConfirmationDialog_1.DialogType.REQUIRED, entityType: "affiliation" }),
403
403
  react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: handleConfirmationSave, onSecondary: handleConfirmationCancel, type: ConfirmationDialog_1.DialogType.SAVE, entityType: "affiliation" }),
404
404
  react_1.default.createElement(AuthorsSection, null,
@@ -75,7 +75,7 @@ const CheckboxContainer = styled_components_1.default.div `
75
75
  align-items: center;
76
76
  gap: 32px;
77
77
  `;
78
- const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, }) => {
78
+ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, authorFormRef, }) => {
79
79
  const formRef = (0, react_1.useRef)(null);
80
80
  (0, react_1.useEffect)(() => {
81
81
  if (selectedAffiliations && formRef.current) {
@@ -92,7 +92,7 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
92
92
  }
93
93
  return (react_1.default.createElement(formik_1.Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, validateOnChange: true, innerRef: formRef }, (formik) => {
94
94
  const isAuthor = formik.values.role === 'author';
95
- return (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange },
95
+ return (react_1.default.createElement(ChangeHandlingForm_1.ChangeHandlingForm, { onChange: onChange, id: "author-details-form", formRef: authorFormRef },
96
96
  react_1.default.createElement(exports.Fieldset, null,
97
97
  react_1.default.createElement(style_guide_1.TextFieldGroupContainer, null,
98
98
  react_1.default.createElement(formik_1.Field, { name: 'bibliographicName.given' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'given-name', placeholder: 'Given name' }, props.field)))),
@@ -101,7 +101,7 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
101
101
  const placeholder = isEmailRequired
102
102
  ? '*Email address (required)'
103
103
  : 'Email address';
104
- return (react_1.default.createElement(TextFieldWithError, Object.assign({ required: isEmailRequired, id: 'email', placeholder: placeholder }, props.field)));
104
+ return (react_1.default.createElement(TextFieldWithError, Object.assign({ id: 'email', type: "email", required: isEmailRequired, placeholder: placeholder }, props.field)));
105
105
  }),
106
106
  react_1.default.createElement(CheckboxContainer, null,
107
107
  react_1.default.createElement(style_guide_1.CheckboxLabel, { disabled: !isAuthor },
@@ -115,7 +115,7 @@ const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequir
115
115
  react_1.default.createElement(OrcidContainer, null,
116
116
  react_1.default.createElement(style_guide_1.TextFieldLabel, null,
117
117
  react_1.default.createElement(exports.LabelText, null, "ORCID"),
118
- react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...' }, props.field)))))),
118
+ react_1.default.createElement(formik_1.Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (react_1.default.createElement(style_guide_1.TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...', pattern: "https://orcid\\.org/\\d{4}-\\d{4}-\\d{4}-\\d{4}", title: "Please enter a valid ORCID URL format: https://orcid.org/xxxx-xxxx-xxxx-xxxx" }, props.field)))))),
119
119
  react_1.default.createElement(formik_1.Field, { name: "affiliations", type: "hidden" }, (props) => {
120
120
  return (react_1.default.createElement(style_guide_1.TextField, Object.assign({ type: "hidden" }, props.field, { value: selectedAffiliations || [] })));
121
121
  }))));
@@ -165,6 +165,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
165
165
  const [selectedAffiliations, setSelectedAffiliations] = (0, react_1.useState)([]);
166
166
  const valuesRef = (0, react_1.useRef)();
167
167
  const actionsRef = (0, react_1.useRef)();
168
+ const authorFormRef = (0, react_1.useRef)(null);
168
169
  const [authors, dispatchAuthors] = (0, react_1.useReducer)(exports.authorsReducer, $authors.sort(authors_1.authorComparator));
169
170
  const [affiliations] = (0, react_1.useReducer)(exports.affiliationsReducer, $affiliations);
170
171
  const affiliationItems = affiliations.map((affiliation) => ({
@@ -237,22 +238,32 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
237
238
  }
238
239
  };
239
240
  const handleSave = () => {
240
- if (valuesRef.current && selection) {
241
- handleSaveAuthor(valuesRef.current);
242
- }
243
- if (nextAuthor) {
244
- setSelection(nextAuthor);
245
- setNextAuthor(null);
246
- setNewAuthor(false);
247
- setShowAffiliationDrawer(false);
248
- updateAffiliationSelection(nextAuthor);
249
- setIsCreatingNewAuthor(false);
241
+ var _a;
242
+ if (!((_a = authorFormRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity())) {
243
+ setShowConfirmationDialog(false);
244
+ setTimeout(() => {
245
+ var _a;
246
+ (_a = authorFormRef.current) === null || _a === void 0 ? void 0 : _a.reportValidity();
247
+ }, 830);
250
248
  }
251
- else if (isCreatingNewAuthor) {
252
- createNewAuthor();
253
- setIsCreatingNewAuthor(false);
249
+ else {
250
+ if (valuesRef.current && selection) {
251
+ handleSaveAuthor(valuesRef.current);
252
+ }
253
+ if (nextAuthor) {
254
+ setSelection(nextAuthor);
255
+ setNextAuthor(null);
256
+ setNewAuthor(false);
257
+ setShowAffiliationDrawer(false);
258
+ updateAffiliationSelection(nextAuthor);
259
+ setIsCreatingNewAuthor(false);
260
+ }
261
+ else if (isCreatingNewAuthor) {
262
+ createNewAuthor();
263
+ setIsCreatingNewAuthor(false);
264
+ }
265
+ setShowConfirmationDialog(false);
254
266
  }
255
- setShowConfirmationDialog(false);
256
267
  };
257
268
  const handleCancel = () => {
258
269
  handleResetAuthor();
@@ -455,12 +466,12 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
455
466
  react_1.default.createElement(style_guide_1.ScrollableModalContent, { "data-cy": "author-modal-content" }, selection ? (react_1.default.createElement(AuthorForms, null,
456
467
  react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => setShowRequiredFieldConfirmationDialog(false), onSecondary: handleCancel, type: ConfirmationDialog_1.DialogType.REQUIRED, entityType: "author" }),
457
468
  react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: handleSave, onSecondary: handleCancel, type: ConfirmationDialog_1.DialogType.SAVE, entityType: "author" }),
458
- react_1.default.createElement(ModalFormActions_1.ModalFormActions, { type: "author", onSave: () => handleSaveAuthor(valuesRef.current), onDelete: handleDeleteAuthor, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAuthor ||
469
+ react_1.default.createElement(ModalFormActions_1.ModalFormActions, { form: 'author-details-form', type: "author", onDelete: handleDeleteAuthor, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAuthor ||
459
470
  (isCreatingNewAuthor &&
460
471
  !showConfirmationDialog &&
461
472
  !showRequiredFieldConfirmationDialog), isDisableSave: isDisableSave }),
462
473
  react_1.default.createElement(FormLabel, null, "Details"),
463
- react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: normalize(selection), onChange: handleChangeAuthor, onSave: handleSaveAuthor, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliationIds }),
474
+ react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: normalize(selection), onChange: handleChangeAuthor, onSave: handleSaveAuthor, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliationIds, authorFormRef: authorFormRef }),
464
475
  react_1.default.createElement(AuthorsSection, null,
465
476
  react_1.default.createElement(AuthorsHeader, null,
466
477
  react_1.default.createElement(AuthorsTitle, null, "Authors"),
@@ -64,7 +64,9 @@ const AuthorContainer = styled_components_1.default.div `
64
64
  background: ${(props) => props.theme.colors.background.fifth};
65
65
  border-color: ${(props) => props.theme.colors.border.primary};
66
66
  }
67
-
67
+ &.active {
68
+ pointer-events: none;
69
+ }
68
70
  &.dragging {
69
71
  opacity: 1;
70
72
  cursor: grabbing;
@@ -32,14 +32,14 @@ const StyledIconButton = (0, styled_components_1.default)(style_guide_1.IconButt
32
32
  margin-right: 4px;
33
33
  }
34
34
  `;
35
- const ModalFormActions = ({ type, onSave, onDelete, showDeleteDialog, handleShowDeleteDialog, newEntity, isDisableSave, }) => {
35
+ const ModalFormActions = ({ type, form, onDelete, showDeleteDialog, handleShowDeleteDialog, newEntity, isDisableSave, }) => {
36
36
  return (react_1.default.createElement(ActionsContainer, { "data-cy": `${type}-action` },
37
37
  react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showDeleteDialog, onPrimary: () => {
38
38
  onDelete();
39
39
  handleShowDeleteDialog();
40
40
  }, onSecondary: handleShowDeleteDialog, type: ConfirmationDialog_1.DialogType.DELETE, entityType: type }),
41
41
  react_1.default.createElement(StyledButtonGroup, null,
42
- react_1.default.createElement(StyledIconButton, { onClick: onSave, disabled: isDisableSave, type: "submit" },
42
+ react_1.default.createElement(StyledIconButton, { disabled: isDisableSave, type: "submit", form: form },
43
43
  react_1.default.createElement(style_guide_1.PlusIcon, null),
44
44
  newEntity ? 'Save Details' : 'Update Details'))));
45
45
  };
@@ -45,7 +45,6 @@ const excludedTypes = [
45
45
  transform_1.schema.nodes.author_notes,
46
46
  transform_1.schema.nodes.title,
47
47
  transform_1.schema.nodes.image_element,
48
- transform_1.schema.nodes.embed,
49
48
  ];
50
49
  const childrenExcludedTypes = [
51
50
  transform_1.schema.nodes.pullquote_element,
@@ -70,7 +70,6 @@ exports.default = (props, dispatch) => {
70
70
  equation_element: (0, equation_element_editable_1.default)(props),
71
71
  figure: (0, figure_editable_1.default)(props, dispatch),
72
72
  figure_element: (0, figure_element_editable_1.default)(props, dispatch),
73
- image_element: (0, figure_element_editable_1.default)(props, dispatch),
74
73
  footnote: (0, footnote_1.default)(props),
75
74
  footnotes_element: (0, footnotes_element_1.default)(props),
76
75
  general_table_footnote: (0, general_table_footnote_1.default)(props, dispatch),
@@ -52,9 +52,7 @@ const groupFiles = (doc, files) => {
52
52
  figures.push(getFigureElementFiles(element.node, element.pos));
53
53
  }
54
54
  doc.descendants((node, pos) => {
55
- if ((node.type === transform_1.schema.nodes.figure_element ||
56
- node.type === transform_1.schema.nodes.image_element) &&
57
- node.attrs.id !== gaID) {
55
+ if (node.type === transform_1.schema.nodes.figure_element && node.attrs.id !== gaID) {
58
56
  figures.push(getFigureElementFiles(node, pos));
59
57
  }
60
58
  if (node.type === transform_1.schema.nodes.supplement) {
package/dist/cjs/menus.js CHANGED
@@ -199,12 +199,6 @@ const getEditorMenus = (editor) => {
199
199
  isEnabled: isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.figure_element)),
200
200
  run: doCommand((0, commands_1.insertBlock)(transform_1.schema.nodes.figure_element)),
201
201
  },
202
- {
203
- id: 'insert-image-element',
204
- label: 'Simple Image',
205
- isEnabled: isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.image_element)),
206
- run: doCommand((0, commands_1.insertBlock)(transform_1.schema.nodes.image_element)),
207
- },
208
202
  {
209
203
  id: 'insert-table-element',
210
204
  label: 'Table',
@@ -23,7 +23,6 @@ const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const transform_1 = require("@manuscripts/transform");
24
24
  const react_1 = __importDefault(require("react"));
25
25
  const { nodes } = transform_1.schema;
26
- const OutlineImageIcon = () => (react_1.default.createElement(style_guide_1.FileImageIcon, { width: "11", height: "14" }));
27
26
  const icons = new Map([
28
27
  [nodes.manuscript, style_guide_1.OutlineManuscriptIcon],
29
28
  [nodes.bibliography_section, style_guide_1.OutlineSectionIcon],
@@ -37,7 +36,6 @@ const icons = new Map([
37
36
  [nodes.table_element, style_guide_1.OutlineTableIcon],
38
37
  [nodes.graphical_abstract_section, style_guide_1.OutlineSectionIcon],
39
38
  [nodes.footnotes_section, style_guide_1.OutlineSectionIcon],
40
- [nodes.image_element, OutlineImageIcon],
41
39
  ]);
42
40
  const nodeTypeIcon = (nodeType, listType) => {
43
41
  if (nodeType === transform_1.schema.nodes.list) {
@@ -46,21 +46,15 @@ exports.default = () => {
46
46
  if (target && !isInGraphicalAbstract) {
47
47
  const labelNode = document.createElement('span');
48
48
  labelNode.className = 'figure-label';
49
- if (node.type.name === 'image_element') {
50
- labelNode.textContent = target.label;
51
- decorations.push(prosemirror_view_1.Decoration.widget(pos + node.nodeSize - 1, labelNode));
52
- }
53
- else {
54
- labelNode.textContent = target.label + ':';
55
- node.forEach((child, offset) => {
56
- if (child.type.name === 'figcaption') {
57
- decorations.push(prosemirror_view_1.Decoration.widget(pos + 1 + offset + 1, labelNode, {
58
- side: -1,
59
- key: `figure-label-${id}-${target.label}`,
60
- }));
61
- }
62
- });
63
- }
49
+ labelNode.textContent = target.label + ':';
50
+ node.forEach((child, offset) => {
51
+ if (child.type.name === 'figcaption') {
52
+ decorations.push(prosemirror_view_1.Decoration.widget(pos + 1 + offset + 1, labelNode, {
53
+ side: -1,
54
+ key: `figure-label-${id}-${target.label}`,
55
+ }));
56
+ }
57
+ });
64
58
  }
65
59
  }
66
60
  });
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.7.17-LEAN-4231.0';
4
+ exports.VERSION = '2.7.18';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -135,9 +135,6 @@ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
135
135
  case state.schema.nodes.figure_element:
136
136
  node = createAndFillFigureElement(state);
137
137
  break;
138
- case state.schema.nodes.image_element:
139
- node = createImageElement(state);
140
- break;
141
138
  case state.schema.nodes.listing_element:
142
139
  node = state.schema.nodes.listing_element.create({}, [
143
140
  state.schema.nodes.listing.create(),
@@ -944,9 +941,6 @@ const createAndFillFigcaptionElement = (state) => state.schema.nodes.figcaption.
944
941
  state.schema.nodes.caption_title.create(),
945
942
  state.schema.nodes.caption.create(),
946
943
  ]);
947
- const createImageElement = (state) => state.schema.nodes.image_element.create({}, [
948
- state.schema.nodes.figure.create(),
949
- ]);
950
944
  const getParentNode = (selection) => {
951
945
  var _a;
952
946
  const parentNode = findParentNodeWithId(selection);
@@ -7,7 +7,7 @@ export const ChangeHandlingForm = (props) => {
7
7
  var _a;
8
8
  (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, values);
9
9
  }, [props.onChange, values]);
10
- return React.createElement(FlexForm, null, props.children);
10
+ return (React.createElement(FlexForm, { id: props.id, ref: props.formRef }, props.children));
11
11
  };
12
12
  export const FlexForm = styled(Form) `
13
13
  height: 100%;
@@ -58,7 +58,7 @@ export const AffiliationForm = ({ values, onSave, onChange, actionsRef, }) => {
58
58
  };
59
59
  }
60
60
  const formRef = useRef(null);
61
- return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, innerRef: formRef, enableReinitialize: true }, () => (React.createElement(ChangeHandlingForm, { onChange: onChange },
61
+ return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, innerRef: formRef, enableReinitialize: true }, () => (React.createElement(ChangeHandlingForm, { onChange: onChange, id: "affiliation-form" },
62
62
  React.createElement(FormLabel, null, "Institution*"),
63
63
  React.createElement(Row, null,
64
64
  React.createElement(Field, { name: "institution" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "institution", placeholder: "Institution Name" }, props.field))))),
@@ -368,8 +368,8 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
368
368
  React.createElement(ActionTitle, null, "New Affiliation")),
369
369
  React.createElement(AffiliationList, { affiliation: selection, affiliations: affiliations, onSelect: handleSelect, onDelete: handleShowDeleteDialog, lastSavedAffiliationId: savedAffiliationId }))),
370
370
  React.createElement(ScrollableModalContent, { "data-cy": "affiliations-modal-content" }, selection ? (React.createElement(AffiliationForms, null,
371
- React.createElement(ModalFormActions, { type: 'affiliation', onSave: () => handleSaveAffiliation(valuesRef.current), onDelete: handleDeleteAffiliation, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAffiliation, isDisableSave: isDisableSave }),
372
- React.createElement(AffiliationForm, { values: normalize(selection), onSave: handleSaveAffiliation, onChange: handleAffiliationChange, actionsRef: actionsRef }),
371
+ React.createElement(ModalFormActions, { type: 'affiliation', form: 'affiliation-form', onDelete: handleDeleteAffiliation, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAffiliation, isDisableSave: isDisableSave }),
372
+ React.createElement(AffiliationForm, { values: normalize(selection), onSave: () => handleSaveAffiliation(valuesRef.current), onChange: handleAffiliationChange, actionsRef: actionsRef }),
373
373
  React.createElement(ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => setShowRequiredFieldConfirmationDialog(false), onSecondary: handleConfirmationCancel, type: DialogType.REQUIRED, entityType: "affiliation" }),
374
374
  React.createElement(ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: handleConfirmationSave, onSecondary: handleConfirmationCancel, type: DialogType.SAVE, entityType: "affiliation" }),
375
375
  React.createElement(AuthorsSection, null,
@@ -46,7 +46,7 @@ const CheckboxContainer = styled.div `
46
46
  align-items: center;
47
47
  gap: 32px;
48
48
  `;
49
- export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, }) => {
49
+ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmailRequired, selectedAffiliations, authorFormRef, }) => {
50
50
  const formRef = useRef(null);
51
51
  useEffect(() => {
52
52
  if (selectedAffiliations && formRef.current) {
@@ -63,7 +63,7 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
63
63
  }
64
64
  return (React.createElement(Formik, { initialValues: values, onSubmit: onSave, enableReinitialize: true, validateOnChange: true, innerRef: formRef }, (formik) => {
65
65
  const isAuthor = formik.values.role === 'author';
66
- return (React.createElement(ChangeHandlingForm, { onChange: onChange },
66
+ return (React.createElement(ChangeHandlingForm, { onChange: onChange, id: "author-details-form", formRef: authorFormRef },
67
67
  React.createElement(Fieldset, null,
68
68
  React.createElement(TextFieldGroupContainer, null,
69
69
  React.createElement(Field, { name: 'bibliographicName.given' }, (props) => (React.createElement(TextField, Object.assign({ id: 'given-name', placeholder: 'Given name' }, props.field)))),
@@ -72,7 +72,7 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
72
72
  const placeholder = isEmailRequired
73
73
  ? '*Email address (required)'
74
74
  : 'Email address';
75
- return (React.createElement(TextFieldWithError, Object.assign({ required: isEmailRequired, id: 'email', placeholder: placeholder }, props.field)));
75
+ return (React.createElement(TextFieldWithError, Object.assign({ id: 'email', type: "email", required: isEmailRequired, placeholder: placeholder }, props.field)));
76
76
  }),
77
77
  React.createElement(CheckboxContainer, null,
78
78
  React.createElement(CheckboxLabel, { disabled: !isAuthor },
@@ -86,7 +86,7 @@ export const AuthorDetailsForm = ({ values, onChange, onSave, actionsRef, isEmai
86
86
  React.createElement(OrcidContainer, null,
87
87
  React.createElement(TextFieldLabel, null,
88
88
  React.createElement(LabelText, null, "ORCID"),
89
- React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...' }, props.field)))))),
89
+ React.createElement(Field, { name: 'ORCIDIdentifier', type: 'text' }, (props) => (React.createElement(TextField, Object.assign({ id: 'orcid', placeholder: 'https://orcid.org/...', pattern: "https://orcid\\.org/\\d{4}-\\d{4}-\\d{4}-\\d{4}", title: "Please enter a valid ORCID URL format: https://orcid.org/xxxx-xxxx-xxxx-xxxx" }, props.field)))))),
90
90
  React.createElement(Field, { name: "affiliations", type: "hidden" }, (props) => {
91
91
  return (React.createElement(TextField, Object.assign({ type: "hidden" }, props.field, { value: selectedAffiliations || [] })));
92
92
  }))));
@@ -136,6 +136,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
136
136
  const [selectedAffiliations, setSelectedAffiliations] = useState([]);
137
137
  const valuesRef = useRef();
138
138
  const actionsRef = useRef();
139
+ const authorFormRef = useRef(null);
139
140
  const [authors, dispatchAuthors] = useReducer(authorsReducer, $authors.sort(authorComparator));
140
141
  const [affiliations] = useReducer(affiliationsReducer, $affiliations);
141
142
  const affiliationItems = affiliations.map((affiliation) => ({
@@ -208,22 +209,32 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
208
209
  }
209
210
  };
210
211
  const handleSave = () => {
211
- if (valuesRef.current && selection) {
212
- handleSaveAuthor(valuesRef.current);
213
- }
214
- if (nextAuthor) {
215
- setSelection(nextAuthor);
216
- setNextAuthor(null);
217
- setNewAuthor(false);
218
- setShowAffiliationDrawer(false);
219
- updateAffiliationSelection(nextAuthor);
220
- setIsCreatingNewAuthor(false);
212
+ var _a;
213
+ if (!((_a = authorFormRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity())) {
214
+ setShowConfirmationDialog(false);
215
+ setTimeout(() => {
216
+ var _a;
217
+ (_a = authorFormRef.current) === null || _a === void 0 ? void 0 : _a.reportValidity();
218
+ }, 830);
221
219
  }
222
- else if (isCreatingNewAuthor) {
223
- createNewAuthor();
224
- setIsCreatingNewAuthor(false);
220
+ else {
221
+ if (valuesRef.current && selection) {
222
+ handleSaveAuthor(valuesRef.current);
223
+ }
224
+ if (nextAuthor) {
225
+ setSelection(nextAuthor);
226
+ setNextAuthor(null);
227
+ setNewAuthor(false);
228
+ setShowAffiliationDrawer(false);
229
+ updateAffiliationSelection(nextAuthor);
230
+ setIsCreatingNewAuthor(false);
231
+ }
232
+ else if (isCreatingNewAuthor) {
233
+ createNewAuthor();
234
+ setIsCreatingNewAuthor(false);
235
+ }
236
+ setShowConfirmationDialog(false);
225
237
  }
226
- setShowConfirmationDialog(false);
227
238
  };
228
239
  const handleCancel = () => {
229
240
  handleResetAuthor();
@@ -426,12 +437,12 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
426
437
  React.createElement(ScrollableModalContent, { "data-cy": "author-modal-content" }, selection ? (React.createElement(AuthorForms, null,
427
438
  React.createElement(ConfirmationDialog, { isOpen: showRequiredFieldConfirmationDialog, onPrimary: () => setShowRequiredFieldConfirmationDialog(false), onSecondary: handleCancel, type: DialogType.REQUIRED, entityType: "author" }),
428
439
  React.createElement(ConfirmationDialog, { isOpen: showConfirmationDialog, onPrimary: handleSave, onSecondary: handleCancel, type: DialogType.SAVE, entityType: "author" }),
429
- React.createElement(ModalFormActions, { type: "author", onSave: () => handleSaveAuthor(valuesRef.current), onDelete: handleDeleteAuthor, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAuthor ||
440
+ React.createElement(ModalFormActions, { form: 'author-details-form', type: "author", onDelete: handleDeleteAuthor, showDeleteDialog: showDeleteDialog, handleShowDeleteDialog: handleShowDeleteDialog, newEntity: newAuthor ||
430
441
  (isCreatingNewAuthor &&
431
442
  !showConfirmationDialog &&
432
443
  !showRequiredFieldConfirmationDialog), isDisableSave: isDisableSave }),
433
444
  React.createElement(FormLabel, null, "Details"),
434
- React.createElement(AuthorDetailsForm, { values: normalize(selection), onChange: handleChangeAuthor, onSave: handleSaveAuthor, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliationIds }),
445
+ React.createElement(AuthorDetailsForm, { values: normalize(selection), onChange: handleChangeAuthor, onSave: handleSaveAuthor, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliationIds, authorFormRef: authorFormRef }),
435
446
  React.createElement(AuthorsSection, null,
436
447
  React.createElement(AuthorsHeader, null,
437
448
  React.createElement(AuthorsTitle, null, "Authors"),
@@ -35,7 +35,9 @@ const AuthorContainer = styled.div `
35
35
  background: ${(props) => props.theme.colors.background.fifth};
36
36
  border-color: ${(props) => props.theme.colors.border.primary};
37
37
  }
38
-
38
+ &.active {
39
+ pointer-events: none;
40
+ }
39
41
  &.dragging {
40
42
  opacity: 1;
41
43
  cursor: grabbing;
@@ -26,14 +26,14 @@ const StyledIconButton = styled(IconButton) `
26
26
  margin-right: 4px;
27
27
  }
28
28
  `;
29
- export const ModalFormActions = ({ type, onSave, onDelete, showDeleteDialog, handleShowDeleteDialog, newEntity, isDisableSave, }) => {
29
+ export const ModalFormActions = ({ type, form, onDelete, showDeleteDialog, handleShowDeleteDialog, newEntity, isDisableSave, }) => {
30
30
  return (React.createElement(ActionsContainer, { "data-cy": `${type}-action` },
31
31
  React.createElement(ConfirmationDialog, { isOpen: showDeleteDialog, onPrimary: () => {
32
32
  onDelete();
33
33
  handleShowDeleteDialog();
34
34
  }, onSecondary: handleShowDeleteDialog, type: DialogType.DELETE, entityType: type }),
35
35
  React.createElement(StyledButtonGroup, null,
36
- React.createElement(StyledIconButton, { onClick: onSave, disabled: isDisableSave, type: "submit" },
36
+ React.createElement(StyledIconButton, { disabled: isDisableSave, type: "submit", form: form },
37
37
  React.createElement(PlusIcon, null),
38
38
  newEntity ? 'Save Details' : 'Update Details'))));
39
39
  };
@@ -19,7 +19,6 @@ const excludedTypes = [
19
19
  schema.nodes.author_notes,
20
20
  schema.nodes.title,
21
21
  schema.nodes.image_element,
22
- schema.nodes.embed,
23
22
  ];
24
23
  const childrenExcludedTypes = [
25
24
  schema.nodes.pullquote_element,
@@ -65,7 +65,6 @@ export default (props, dispatch) => {
65
65
  equation_element: equationElement(props),
66
66
  figure: figure(props, dispatch),
67
67
  figure_element: figureElement(props, dispatch),
68
- image_element: figureElement(props, dispatch),
69
68
  footnote: footnote(props),
70
69
  footnotes_element: footnotesElement(props),
71
70
  general_table_footnote: generalTableFootnote(props, dispatch),
@@ -49,9 +49,7 @@ export const groupFiles = (doc, files) => {
49
49
  figures.push(getFigureElementFiles(element.node, element.pos));
50
50
  }
51
51
  doc.descendants((node, pos) => {
52
- if ((node.type === schema.nodes.figure_element ||
53
- node.type === schema.nodes.image_element) &&
54
- node.attrs.id !== gaID) {
52
+ if (node.type === schema.nodes.figure_element && node.attrs.id !== gaID) {
55
53
  figures.push(getFigureElementFiles(node, pos));
56
54
  }
57
55
  if (node.type === schema.nodes.supplement) {
package/dist/es/menus.js CHANGED
@@ -196,12 +196,6 @@ export const getEditorMenus = (editor) => {
196
196
  isEnabled: isCommandValid(canInsert(schema.nodes.figure_element)),
197
197
  run: doCommand(insertBlock(schema.nodes.figure_element)),
198
198
  },
199
- {
200
- id: 'insert-image-element',
201
- label: 'Simple Image',
202
- isEnabled: isCommandValid(canInsert(schema.nodes.image_element)),
203
- run: doCommand(insertBlock(schema.nodes.image_element)),
204
- },
205
199
  {
206
200
  id: 'insert-table-element',
207
201
  label: 'Table',
@@ -13,11 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { FileImageIcon, OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlineEquationIcon, OutlineFigureIcon, OutlineManuscriptIcon, OutlineOrderedListIcon, OutlineParagraphIcon, OutlinePullQuoteIcon, OutlineSectionIcon, OutlineTableIcon, OutlineUnorderedListIcon, } from '@manuscripts/style-guide';
16
+ import { OutlineBlockQuoteIcon, OutlineEmbedIcon, OutlineEquationIcon, OutlineFigureIcon, OutlineManuscriptIcon, OutlineOrderedListIcon, OutlineParagraphIcon, OutlinePullQuoteIcon, OutlineSectionIcon, OutlineTableIcon, OutlineUnorderedListIcon, } from '@manuscripts/style-guide';
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import React from 'react';
19
19
  const { nodes } = schema;
20
- const OutlineImageIcon = () => (React.createElement(FileImageIcon, { width: "11", height: "14" }));
21
20
  const icons = new Map([
22
21
  [nodes.manuscript, OutlineManuscriptIcon],
23
22
  [nodes.bibliography_section, OutlineSectionIcon],
@@ -31,7 +30,6 @@ const icons = new Map([
31
30
  [nodes.table_element, OutlineTableIcon],
32
31
  [nodes.graphical_abstract_section, OutlineSectionIcon],
33
32
  [nodes.footnotes_section, OutlineSectionIcon],
34
- [nodes.image_element, OutlineImageIcon],
35
33
  ]);
36
34
  export const nodeTypeIcon = (nodeType, listType) => {
37
35
  if (nodeType === schema.nodes.list) {
@@ -43,21 +43,15 @@ export default () => {
43
43
  if (target && !isInGraphicalAbstract) {
44
44
  const labelNode = document.createElement('span');
45
45
  labelNode.className = 'figure-label';
46
- if (node.type.name === 'image_element') {
47
- labelNode.textContent = target.label;
48
- decorations.push(Decoration.widget(pos + node.nodeSize - 1, labelNode));
49
- }
50
- else {
51
- labelNode.textContent = target.label + ':';
52
- node.forEach((child, offset) => {
53
- if (child.type.name === 'figcaption') {
54
- decorations.push(Decoration.widget(pos + 1 + offset + 1, labelNode, {
55
- side: -1,
56
- key: `figure-label-${id}-${target.label}`,
57
- }));
58
- }
59
- });
60
- }
46
+ labelNode.textContent = target.label + ':';
47
+ node.forEach((child, offset) => {
48
+ if (child.type.name === 'figcaption') {
49
+ decorations.push(Decoration.widget(pos + 1 + offset + 1, labelNode, {
50
+ side: -1,
51
+ key: `figure-label-${id}-${target.label}`,
52
+ }));
53
+ }
54
+ });
61
55
  }
62
56
  }
63
57
  });
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.17-LEAN-4231.0';
1
+ export const VERSION = '2.7.18';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,6 +1,8 @@
1
- import React, { PropsWithChildren } from 'react';
1
+ import React, { MutableRefObject, PropsWithChildren } from 'react';
2
2
  export interface ChangeHandlingFormProps<Values> {
3
3
  onChange: (values: Values) => void;
4
+ id?: string;
5
+ formRef?: MutableRefObject<HTMLFormElement | null>;
4
6
  }
5
7
  export declare const ChangeHandlingForm: <Values>(props: React.PropsWithChildren<ChangeHandlingFormProps<Values>>) => React.JSX.Element;
6
8
  export declare const FlexForm: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref"> & React.RefAttributes<HTMLFormElement>>, any, {}, never>;
@@ -24,6 +24,7 @@ interface AuthorDetailsFormProps {
24
24
  values: ContributorAttrs;
25
25
  onChange: (values: ContributorAttrs) => void;
26
26
  onSave: (values: ContributorAttrs) => void;
27
+ authorFormRef?: MutableRefObject<HTMLFormElement | null>;
27
28
  actionsRef?: MutableRefObject<FormActions | undefined>;
28
29
  isEmailRequired?: boolean;
29
30
  selectedAffiliations?: string[];
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  export interface FormActionsProps {
3
3
  type: string;
4
- onSave: () => void;
4
+ form: string;
5
5
  onDelete: () => void;
6
6
  showDeleteDialog: boolean;
7
7
  handleShowDeleteDialog: () => void;
@@ -104,32 +104,6 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
104
104
  deselectNode(): void;
105
105
  destroy(): void;
106
106
  } & import("../views/figure_element").FigureElementView>;
107
- image_element: import("../types").NodeViewCreator<{
108
- gutterButtons(): HTMLElement[];
109
- actionGutterButtons(): never[];
110
- createAddButton(): HTMLAnchorElement | null;
111
- createEditButton(): HTMLElement | null;
112
- createMenu: () => import("../lib/context-menu").ContextMenu;
113
- initialise(): void;
114
- updateContents(): void;
115
- handleTrackChanges(): void;
116
- updateClasses(): void;
117
- updatePlaceholder(): void;
118
- createElement(): void;
119
- createDOM(): void;
120
- createGutter(className: string, buttons: HTMLElement[]): void;
121
- dom: HTMLElement;
122
- contentDOM?: HTMLElement | undefined;
123
- elementType: string;
124
- readonly props: EditorProps;
125
- node: import("prosemirror-model").Node;
126
- readonly view: import("prosemirror-view").EditorView;
127
- readonly getPos: () => number;
128
- update(newNode: import("prosemirror-model").Node): boolean;
129
- selectNode(): void;
130
- deselectNode(): void;
131
- destroy(): void;
132
- } & import("../views/figure_element").FigureElementView>;
133
107
  footnote: import("../types").NodeViewCreator<import("../views/footnote").FootnoteView>;
134
108
  footnotes_element: import("../types").NodeViewCreator<import("../views/footnotes_element").FootnotesElementView>;
135
109
  general_table_footnote: import("../types").NodeViewCreator<import("../views/general_table_footnote").GeneralTableFootnoteView>;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.17-LEAN-4231.0";
1
+ export declare const VERSION = "2.7.18";
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.7.17-LEAN-4231.0",
4
+ "version": "2.7.18",
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.32",
36
36
  "@manuscripts/track-changes-plugin": "1.9.2",
37
- "@manuscripts/transform": "3.0.37-LEAN-4231.0",
37
+ "@manuscripts/transform": "3.0.36",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",
package/styles/Editor.css CHANGED
@@ -352,12 +352,6 @@
352
352
  white-space: nowrap;
353
353
  }
354
354
 
355
- .block-image_element .figure-label {
356
- text-align: center;
357
- grid-column-start: 1;
358
- grid-column-end: -1;
359
- }
360
-
361
355
  .ProseMirror .executable-container {
362
356
  width: 100%;
363
357
  position: relative;