@manuscripts/body-editor 3.12.58 → 3.12.60

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.
@@ -294,14 +294,19 @@ const insertTable = (config, state, dispatch) => {
294
294
  return true;
295
295
  };
296
296
  exports.insertTable = insertTable;
297
- const insertSupplement = (file, view) => {
297
+ const insertSupplement = (file, view, setSelection = true) => {
298
298
  const supplement = transform_1.schema.nodes.supplement.createAndFill({
299
299
  id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.supplement),
300
300
  href: file.id,
301
301
  }, createAndFillCaption());
302
- const tr = view.state.tr;
302
+ let tr = view.state.tr;
303
303
  const { pos } = (0, doc_1.upsertSupplementsSection)(tr, supplement);
304
- tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
304
+ if (setSelection) {
305
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
306
+ }
307
+ else {
308
+ tr = (0, track_changes_plugin_1.skipSelect)(tr);
309
+ }
305
310
  view.focus();
306
311
  view.dispatch(tr.scrollIntoView());
307
312
  return true;
@@ -392,7 +392,7 @@ const AffiliationsModal = ({ authors: $authors, affiliations: $affiliations, aff
392
392
  setPendingAction(null);
393
393
  setAffiliationDetailsUnsavedContinue(true);
394
394
  }, onSecondary: handleConfirmationCancel, type: ConfirmationDialog_1.DialogType.SAVE, entityType: "affiliation" }))) : (react_1.default.createElement(FormPlaceholder_1.FormPlaceholder, { type: "affiliation", title: "Affiliation Details", message: "Select an affiliation from the list to display it's details here.", placeholderIcon: react_1.default.createElement(style_guide_1.AffiliationPlaceholderIcon, null) })))),
395
- react_1.default.createElement(FormFooter_1.default, { onCancel: handleClose, primaryAction: selection ? (react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "affiliation-form", newEntity: newAffiliation, isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
395
+ react_1.default.createElement(FormFooter_1.default, { onCancel: handleClose, primaryAction: selection ? (react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "affiliation-form", isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
396
396
  };
397
397
  exports.AffiliationsModal = AffiliationsModal;
398
398
  function createEmptyAffiliation(priority) {
@@ -91,6 +91,6 @@ const CreateAffiliationModal = ({ affiliationsCount, onSave, onClose, }) => {
91
91
  react_1.default.createElement(CreateModalStyles_1.StyledScrollableModalContent, null,
92
92
  react_1.default.createElement(CreateModalStyles_1.FormTitle, null, "Create New Affiliation"),
93
93
  react_1.default.createElement(AffiliationForm_1.AffiliationForm, { values: (0, normalize_1.checkID)(selection, 'affiliation'), onSave: handleSave, onChange: handleChange, actionsRef: actionsRef, newEntity: true, onAffiliationErrorChange: setHasError }))),
94
- react_1.default.createElement(FormFooter_1.default, { onCancel: () => setIsOpen(false), primaryAction: react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "affiliation-form", newEntity: true, isDisableSave: isDisableSave || hasError, createLabel: "Create New Affiliation", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
94
+ react_1.default.createElement(FormFooter_1.default, { onCancel: () => setIsOpen(false), primaryAction: react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "affiliation-form", isDisableSave: isDisableSave || hasError, label: "Create New Affiliation", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
95
95
  };
96
96
  exports.CreateAffiliationModal = CreateAffiliationModal;
@@ -383,7 +383,7 @@ const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author,
383
383
  setNextAuthor(null);
384
384
  setAuthorDetailsUnsavedContinue(true);
385
385
  }, onSecondary: cancel, type: ConfirmationDialog_1.DialogType.SAVE, entityType: "author" }))) : (react_1.default.createElement(FormPlaceholder_1.FormPlaceholder, { type: "author", title: "Author Details", message: "Select an author from the list to display their details here.", placeholderIcon: react_1.default.createElement(style_guide_1.AuthorPlaceholderIcon, null) })))),
386
- react_1.default.createElement(FormFooter_1.default, { onCancel: close, primaryAction: selection ? (react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "author-details-form", newEntity: newEntity, isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
386
+ react_1.default.createElement(FormFooter_1.default, { onCancel: close, primaryAction: selection ? (react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "author-details-form", isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
387
387
  };
388
388
  exports.AuthorsModal = AuthorsModal;
389
389
  function createEmptyAuthor(priority) {
@@ -96,7 +96,7 @@ const CreateAuthorModal = ({ authorsCount, affiliations: $affiliations, onSave,
96
96
  react_1.default.createElement(CreateModalStyles_1.StyledScrollableModalContent, null,
97
97
  react_1.default.createElement(CreateModalStyles_1.FormTitle, null, "Create New Author"),
98
98
  react_1.default.createElement(AuthorDetailsForm_1.AuthorDetailsForm, { values: (0, normalize_1.normalizeAuthor)(selection), onChange: handleChange, onSave: handleSave, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliations.map((a) => a.id), authorFormRef: authorFormRef, selectedCreditRoles: selectedCreditRoles, newEntity: true, onAuthorDetailsTabErrorChange: setHasError }))),
99
- react_1.default.createElement(FormFooter_1.default, { onCancel: () => setIsOpen(false), primaryAction: react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "author-details-form", newEntity: true, isDisableSave: isDisableSave || hasError, createLabel: "Create New Author", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
99
+ react_1.default.createElement(FormFooter_1.default, { onCancel: () => setIsOpen(false), primaryAction: react_1.default.createElement(ModalFormActions_1.ModalFormSaveButton, { form: "author-details-form", isDisableSave: isDisableSave || hasError, label: "Create New Author", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
100
100
  };
101
101
  exports.CreateAuthorModal = CreateAuthorModal;
102
102
  function createEmptyAuthor(priority) {
@@ -8,11 +8,9 @@ const style_guide_1 = require("@manuscripts/style-guide");
8
8
  const react_1 = __importDefault(require("react"));
9
9
  const ConfirmationDialog_1 = require("../dialog/ConfirmationDialog");
10
10
  const styled_components_1 = __importDefault(require("styled-components"));
11
- const ModalFormSaveButton = ({ form, newEntity, isDisableSave, onSubmitForm, createLabel, updateLabel, }) => {
12
- const label = newEntity
13
- ? (createLabel ?? 'Save Changes')
14
- : (updateLabel ?? 'Update Changes');
15
- const saveButton = onSubmitForm ? (react_1.default.createElement(StylePrimaryButton, { disabled: isDisableSave, type: "button", onClick: () => {
11
+ const ModalFormSaveButton = ({ form, isDisableSave, onSubmitForm, label, }) => {
12
+ label = label || 'Save Changes';
13
+ const saveButton = onSubmitForm ? (react_1.default.createElement(StylePrimaryButton, { "data-cy": "save-changes", disabled: isDisableSave, type: "button", onClick: () => {
16
14
  if (!isDisableSave) {
17
15
  void onSubmitForm();
18
16
  }
@@ -98,7 +98,21 @@ const focusNearestElement = (state, dispatch, view) => {
98
98
  const { from } = view.state.selection;
99
99
  const coords = view.coordsAtPos(from);
100
100
  const container = getCursorContainer(view);
101
- const target = findNearestTabbable(container, coords.top);
101
+ let target = findNearestTabbable(container, coords.top);
102
+ if (!target) {
103
+ const parent = (0, utils_1.findParentNodeWithIdValue)(view.state.selection);
104
+ const grandparent = parent
105
+ ? (0, utils_1.findParentNodeWithIdValue)({
106
+ $from: view.state.doc.resolve(parent.pos),
107
+ })
108
+ : null;
109
+ if (grandparent) {
110
+ const dom = view.nodeDOM(grandparent.pos);
111
+ if (dom instanceof HTMLElement) {
112
+ target = findNearestTabbable(dom, coords.top);
113
+ }
114
+ }
115
+ }
102
116
  if (!target) {
103
117
  return false;
104
118
  }
@@ -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 = '3.12.58';
4
+ exports.VERSION = '3.12.60';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { isDeleted, skipTracking } from '@manuscripts/track-changes-plugin';
16
+ import { isDeleted, skipTracking, skipSelect } from '@manuscripts/track-changes-plugin';
17
17
  import { generateNodeID, isElementNodeType, isListNode, isSectionNodeType, isTableElementNode, schema, } from '@manuscripts/transform';
18
18
  import { Fragment, NodeRange, Slice, } from 'prosemirror-model';
19
19
  import { wrapInList } from 'prosemirror-schema-list';
@@ -278,14 +278,19 @@ export const insertTable = (config, state, dispatch) => {
278
278
  dispatch && dispatch(tr);
279
279
  return true;
280
280
  };
281
- export const insertSupplement = (file, view) => {
281
+ export const insertSupplement = (file, view, setSelection = true) => {
282
282
  const supplement = schema.nodes.supplement.createAndFill({
283
283
  id: generateNodeID(schema.nodes.supplement),
284
284
  href: file.id,
285
285
  }, createAndFillCaption());
286
- const tr = view.state.tr;
286
+ let tr = view.state.tr;
287
287
  const { pos } = upsertSupplementsSection(tr, supplement);
288
- tr.setSelection(NodeSelection.create(tr.doc, pos));
288
+ if (setSelection) {
289
+ tr.setSelection(NodeSelection.create(tr.doc, pos));
290
+ }
291
+ else {
292
+ tr = skipSelect(tr);
293
+ }
289
294
  view.focus();
290
295
  view.dispatch(tr.scrollIntoView());
291
296
  return true;
@@ -353,7 +353,7 @@ export const AffiliationsModal = ({ authors: $authors, affiliations: $affiliatio
353
353
  setPendingAction(null);
354
354
  setAffiliationDetailsUnsavedContinue(true);
355
355
  }, onSecondary: handleConfirmationCancel, type: DialogType.SAVE, entityType: "affiliation" }))) : (React.createElement(FormPlaceholder, { type: "affiliation", title: "Affiliation Details", message: "Select an affiliation from the list to display it's details here.", placeholderIcon: React.createElement(AffiliationPlaceholderIcon, null) })))),
356
- React.createElement(FormFooter, { onCancel: handleClose, primaryAction: selection ? (React.createElement(ModalFormSaveButton, { form: "affiliation-form", newEntity: newAffiliation, isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
356
+ React.createElement(FormFooter, { onCancel: handleClose, primaryAction: selection ? (React.createElement(ModalFormSaveButton, { form: "affiliation-form", isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
357
357
  };
358
358
  function createEmptyAffiliation(priority) {
359
359
  return {
@@ -52,5 +52,5 @@ export const CreateAffiliationModal = ({ affiliationsCount, onSave, onClose, })
52
52
  React.createElement(StyledScrollableModalContent, null,
53
53
  React.createElement(FormTitle, null, "Create New Affiliation"),
54
54
  React.createElement(AffiliationForm, { values: checkID(selection, 'affiliation'), onSave: handleSave, onChange: handleChange, actionsRef: actionsRef, newEntity: true, onAffiliationErrorChange: setHasError }))),
55
- React.createElement(FormFooter, { onCancel: () => setIsOpen(false), primaryAction: React.createElement(ModalFormSaveButton, { form: "affiliation-form", newEntity: true, isDisableSave: isDisableSave || hasError, createLabel: "Create New Affiliation", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
55
+ React.createElement(FormFooter, { onCancel: () => setIsOpen(false), primaryAction: React.createElement(ModalFormSaveButton, { form: "affiliation-form", isDisableSave: isDisableSave || hasError, label: "Create New Affiliation", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
56
56
  };
@@ -344,7 +344,7 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
344
344
  setNextAuthor(null);
345
345
  setAuthorDetailsUnsavedContinue(true);
346
346
  }, onSecondary: cancel, type: DialogType.SAVE, entityType: "author" }))) : (React.createElement(FormPlaceholder, { type: "author", title: "Author Details", message: "Select an author from the list to display their details here.", placeholderIcon: React.createElement(AuthorPlaceholderIcon, null) })))),
347
- React.createElement(FormFooter, { onCancel: close, primaryAction: selection ? (React.createElement(ModalFormSaveButton, { form: "author-details-form", newEntity: newEntity, isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
347
+ React.createElement(FormFooter, { onCancel: close, primaryAction: selection ? (React.createElement(ModalFormSaveButton, { form: "author-details-form", isDisableSave: isDisableSave, onSubmitForm: () => actionsRef.current?.submitForm?.() })) : undefined }))));
348
348
  };
349
349
  function createEmptyAuthor(priority) {
350
350
  return {
@@ -57,7 +57,7 @@ export const CreateAuthorModal = ({ authorsCount, affiliations: $affiliations, o
57
57
  React.createElement(StyledScrollableModalContent, null,
58
58
  React.createElement(FormTitle, null, "Create New Author"),
59
59
  React.createElement(AuthorDetailsForm, { values: normalizeAuthor(selection), onChange: handleChange, onSave: handleSave, actionsRef: actionsRef, isEmailRequired: isEmailRequired, selectedAffiliations: selectedAffiliations.map((a) => a.id), authorFormRef: authorFormRef, selectedCreditRoles: selectedCreditRoles, newEntity: true, onAuthorDetailsTabErrorChange: setHasError }))),
60
- React.createElement(FormFooter, { onCancel: () => setIsOpen(false), primaryAction: React.createElement(ModalFormSaveButton, { form: "author-details-form", newEntity: true, isDisableSave: isDisableSave || hasError, createLabel: "Create New Author", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
60
+ React.createElement(FormFooter, { onCancel: () => setIsOpen(false), primaryAction: React.createElement(ModalFormSaveButton, { form: "author-details-form", isDisableSave: isDisableSave || hasError, label: "Create New Author", onSubmitForm: () => actionsRef.current?.submitForm?.() }) }))));
61
61
  };
62
62
  function createEmptyAuthor(priority) {
63
63
  return {
@@ -2,11 +2,9 @@ import { PrimaryButton } from '@manuscripts/style-guide';
2
2
  import React from 'react';
3
3
  import { ConfirmationDialog, DialogType } from '../dialog/ConfirmationDialog';
4
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: () => {
5
+ export const ModalFormSaveButton = ({ form, isDisableSave, onSubmitForm, label, }) => {
6
+ label = label || 'Save Changes';
7
+ const saveButton = onSubmitForm ? (React.createElement(StylePrimaryButton, { "data-cy": "save-changes", disabled: isDisableSave, type: "button", onClick: () => {
10
8
  if (!isDisableSave) {
11
9
  void onSubmitForm();
12
10
  }
@@ -89,7 +89,21 @@ export const focusNearestElement = (state, dispatch, view) => {
89
89
  const { from } = view.state.selection;
90
90
  const coords = view.coordsAtPos(from);
91
91
  const container = getCursorContainer(view);
92
- const target = findNearestTabbable(container, coords.top);
92
+ let target = findNearestTabbable(container, coords.top);
93
+ if (!target) {
94
+ const parent = findParentNodeWithIdValue(view.state.selection);
95
+ const grandparent = parent
96
+ ? findParentNodeWithIdValue({
97
+ $from: view.state.doc.resolve(parent.pos),
98
+ })
99
+ : null;
100
+ if (grandparent) {
101
+ const dom = view.nodeDOM(grandparent.pos);
102
+ if (dom instanceof HTMLElement) {
103
+ target = findNearestTabbable(dom, coords.top);
104
+ }
105
+ }
106
+ }
93
107
  if (!target) {
94
108
  return false;
95
109
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.12.58';
1
+ export const VERSION = '3.12.60';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -33,7 +33,7 @@ export declare const insertGeneralTableFootnote: (element: [ManuscriptNode, numb
33
33
  export declare const insertFigure: (file: FileAttachment, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
34
34
  export declare const insertEmbed: (state: ManuscriptEditorState, dispatch?: Dispatch, attrs?: Attrs) => boolean;
35
35
  export declare const insertTable: (config: TableConfig, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
36
- export declare const insertSupplement: (file: FileAttachment, view: ManuscriptEditorView) => boolean;
36
+ export declare const insertSupplement: (file: FileAttachment, view: ManuscriptEditorView, setSelection?: boolean) => boolean;
37
37
  export declare const insertAttachment: (file: FileAttachment, state: ManuscriptEditorState, type: string, dispatch?: Dispatch) => boolean;
38
38
  export declare const insertBlock: (nodeType: ManuscriptNodeType) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
39
39
  export declare const deleteBlock: (typeToDelete: string) => (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
@@ -1,11 +1,9 @@
1
1
  import React from 'react';
2
2
  export interface ModalFormSaveButtonProps {
3
3
  form: string;
4
- newEntity: boolean;
5
4
  isDisableSave: boolean;
6
5
  onSubmitForm?: () => void | Promise<void>;
7
- createLabel?: string;
8
- updateLabel?: string;
6
+ label?: string;
9
7
  }
10
8
  export declare const ModalFormSaveButton: React.FC<ModalFormSaveButtonProps>;
11
9
  interface ModalFormActionsProps {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.12.58";
1
+ export declare const VERSION = "3.12.60";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "3.12.58",
4
+ "version": "3.12.60",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -40,8 +40,8 @@
40
40
  "@citation-js/plugin-pubmed": "0.3.0",
41
41
  "@citation-js/plugin-ris": "0.7.18",
42
42
  "@iarna/word-count": "1.1.2",
43
- "@manuscripts/style-guide": "3.5.27",
44
- "@manuscripts/track-changes-plugin": "2.3.13",
43
+ "@manuscripts/style-guide": "3.5.28",
44
+ "@manuscripts/track-changes-plugin": "2.3.15",
45
45
  "@manuscripts/transform": "4.3.51",
46
46
  "@popperjs/core": "2.11.8",
47
47
  "citeproc": "2.4.63",