@manuscripts/body-editor 3.12.17 → 3.12.20

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 (57) hide show
  1. package/dist/cjs/commands.js +16 -24
  2. package/dist/cjs/components/affiliations/AffiliationForm.js +5 -6
  3. package/dist/cjs/components/affiliations/AffiliationsModal.js +21 -57
  4. package/dist/cjs/components/affiliations/AffiliationsPanel.js +22 -0
  5. package/dist/cjs/components/authors/AuthorDetailsForm.js +3 -4
  6. package/dist/cjs/components/authors/AuthorsModal.js +15 -48
  7. package/dist/cjs/components/authors/AuthorsPanel.js +18 -0
  8. package/dist/cjs/components/authors/useManageAffiliations.js +6 -4
  9. package/dist/cjs/components/authors-affiliations/AuthorsAndAffiliationsModals.js +134 -0
  10. package/dist/cjs/components/authors-affiliations/GenericPanel.js +136 -0
  11. package/dist/cjs/components/form/ModalFormActions.js +11 -5
  12. package/dist/cjs/keys/title.js +24 -10
  13. package/dist/cjs/lib/__tests__/plugins.test.js +2 -2
  14. package/dist/cjs/lib/context-menu.js +8 -9
  15. package/dist/cjs/plugins/objects.js +24 -19
  16. package/dist/cjs/versions.js +1 -1
  17. package/dist/cjs/views/affiliations.js +5 -11
  18. package/dist/cjs/views/caption.js +1 -1
  19. package/dist/cjs/views/contributors.js +4 -7
  20. package/dist/cjs/views/figure.js +0 -1
  21. package/dist/es/commands.js +16 -24
  22. package/dist/es/components/affiliations/AffiliationForm.js +5 -6
  23. package/dist/es/components/affiliations/AffiliationsModal.js +21 -53
  24. package/dist/es/components/affiliations/AffiliationsPanel.js +15 -0
  25. package/dist/es/components/authors/AuthorDetailsForm.js +3 -4
  26. package/dist/es/components/authors/AuthorsModal.js +15 -45
  27. package/dist/es/components/authors/AuthorsPanel.js +11 -0
  28. package/dist/es/components/authors/useManageAffiliations.js +7 -5
  29. package/dist/es/components/authors-affiliations/AuthorsAndAffiliationsModals.js +93 -0
  30. package/dist/es/components/authors-affiliations/GenericPanel.js +94 -0
  31. package/dist/es/components/form/ModalFormActions.js +11 -5
  32. package/dist/es/keys/title.js +24 -10
  33. package/dist/es/lib/__tests__/plugins.test.js +2 -2
  34. package/dist/es/lib/context-menu.js +8 -9
  35. package/dist/es/plugins/objects.js +25 -20
  36. package/dist/es/versions.js +1 -1
  37. package/dist/es/views/affiliations.js +5 -11
  38. package/dist/es/views/caption.js +1 -1
  39. package/dist/es/views/contributors.js +5 -8
  40. package/dist/es/views/figure.js +0 -1
  41. package/dist/types/components/affiliations/AffiliationForm.d.ts +1 -0
  42. package/dist/types/components/affiliations/AffiliationsModal.d.ts +2 -5
  43. package/dist/types/components/affiliations/AffiliationsPanel.d.ts +11 -0
  44. package/dist/types/components/authors/AuthorDetailsForm.d.ts +1 -0
  45. package/dist/types/components/authors/AuthorsModal.d.ts +2 -4
  46. package/dist/types/components/authors/AuthorsPanel.d.ts +13 -0
  47. package/dist/types/components/authors/useManageAffiliations.d.ts +0 -2
  48. package/dist/types/components/authors-affiliations/AuthorsAndAffiliationsModals.d.ts +29 -0
  49. package/dist/types/components/authors-affiliations/GenericPanel.d.ts +48 -0
  50. package/dist/types/components/form/ModalFormActions.d.ts +1 -0
  51. package/dist/types/versions.d.ts +1 -1
  52. package/package.json +3 -3
  53. package/styles/AdvancedEditor.css +18 -48
  54. package/styles/Editor.css +28 -63
  55. package/dist/cjs/components/authors/AffiliationDrawer.js +0 -24
  56. package/dist/es/components/authors/AffiliationDrawer.js +0 -17
  57. package/dist/types/components/authors/AffiliationDrawer.d.ts +0 -12
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2026 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ var __importDefault = (this && this.__importDefault) || function (mod) {
51
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.openAuthorsAndAffiliationsModals = exports.AuthorsAndAffiliationsModals = void 0;
55
+ const transform_1 = require("@manuscripts/transform");
56
+ const react_1 = __importStar(require("react"));
57
+ const editor_props_1 = require("../../plugins/editor-props");
58
+ const ReactSubView_1 = __importDefault(require("../../views/ReactSubView"));
59
+ const view_1 = require("../../lib/view");
60
+ const AffiliationsModal_1 = require("../affiliations/AffiliationsModal");
61
+ const AuthorsModal_1 = require("../authors/AuthorsModal");
62
+ function insertNode(parentType, childType) {
63
+ return (view, attrs) => {
64
+ const parent = (0, view_1.findChildByType)(view, parentType);
65
+ if (parent) {
66
+ view.dispatch(view.state.tr.insert(parent.pos + 1, childType.create(attrs)));
67
+ }
68
+ };
69
+ }
70
+ function upsertNode(nodeType, insertFn) {
71
+ return (view, attrs) => {
72
+ if (!(0, view_1.updateNodeAttrs)(view, nodeType, attrs)) {
73
+ insertFn(view, attrs);
74
+ }
75
+ };
76
+ }
77
+ const insertAuthorNode = insertNode(transform_1.schema.nodes.contributors, transform_1.schema.nodes.contributor);
78
+ const insertAffiliationNode = insertNode(transform_1.schema.nodes.affiliations, transform_1.schema.nodes.affiliation);
79
+ const upsertAuthor = upsertNode(transform_1.schema.nodes.contributor, insertAuthorNode);
80
+ const upsertAffiliation = upsertNode(transform_1.schema.nodes.affiliation, insertAffiliationNode);
81
+ const AuthorsAndAffiliationsModals = ({ initialModal, view, author, affiliation, addNewAuthor, addNewAffiliation, }) => {
82
+ const [showOverlay, setShowOverlay] = (0, react_1.useState)(false);
83
+ const [authors, setAuthors] = (0, react_1.useState)(() => (0, view_1.findChildrenAttrsByType)(view, transform_1.schema.nodes.contributor));
84
+ const [affiliations, setAffiliations] = (0, react_1.useState)(() => (0, view_1.findChildrenAttrsByType)(view, transform_1.schema.nodes.affiliation));
85
+ const handleOpenOverlay = () => setShowOverlay(true);
86
+ const handleOverlayClose = () => {
87
+ setShowOverlay(false);
88
+ setAuthors((0, view_1.findChildrenAttrsByType)(view, transform_1.schema.nodes.contributor));
89
+ setAffiliations((0, view_1.findChildrenAttrsByType)(view, transform_1.schema.nodes.affiliation));
90
+ };
91
+ const authorsProps = {
92
+ author,
93
+ authors,
94
+ affiliations,
95
+ addNewAuthor,
96
+ onSaveAuthor: (a) => upsertAuthor(view, a),
97
+ onDeleteAuthor: (a) => (0, view_1.deleteNode)(view, a.id),
98
+ };
99
+ const affiliationsProps = {
100
+ affiliation,
101
+ authors,
102
+ affiliations,
103
+ addNewAffiliation,
104
+ onSaveAffiliation: (a) => upsertAffiliation(view, a),
105
+ onDeleteAffiliation: (a) => (0, view_1.deleteNode)(view, a.id),
106
+ onUpdateAuthors: (updated) => updated.forEach((a) => (0, view_1.updateNodeAttrs)(view, transform_1.schema.nodes.contributor, a)),
107
+ };
108
+ if (initialModal === 'authors') {
109
+ return (react_1.default.createElement(react_1.default.Fragment, null,
110
+ react_1.default.createElement(AuthorsModal_1.AuthorsModal, { ...authorsProps, onOpenAffiliationsModal: handleOpenOverlay }),
111
+ showOverlay && (react_1.default.createElement(AffiliationsModal_1.AffiliationsModal, { ...affiliationsProps, addNewAffiliation: true, onClose: handleOverlayClose }))));
112
+ }
113
+ return (react_1.default.createElement(react_1.default.Fragment, null,
114
+ react_1.default.createElement(AffiliationsModal_1.AffiliationsModal, { ...affiliationsProps, onOpenAuthorsModal: handleOpenOverlay }),
115
+ showOverlay && (react_1.default.createElement(AuthorsModal_1.AuthorsModal, { ...authorsProps, addNewAuthor: true, onClose: handleOverlayClose }))));
116
+ };
117
+ exports.AuthorsAndAffiliationsModals = AuthorsAndAffiliationsModals;
118
+ const openAuthorsAndAffiliationsModals = (pos, view, initialModal) => {
119
+ if (!view) {
120
+ return;
121
+ }
122
+ const { state } = view;
123
+ const props = (0, editor_props_1.getEditorProps)(state);
124
+ const componentProps = {
125
+ initialModal,
126
+ view: view,
127
+ addNewAuthor: initialModal === 'authors',
128
+ addNewAffiliation: initialModal === 'affiliations',
129
+ };
130
+ const dialog = (0, ReactSubView_1.default)(props, exports.AuthorsAndAffiliationsModals, componentProps, state.doc, () => pos, view);
131
+ view.focus();
132
+ document.body.appendChild(dialog);
133
+ };
134
+ exports.openAuthorsAndAffiliationsModals = openAuthorsAndAffiliationsModals;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2026 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
29
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
30
+ }) : function(o, v) {
31
+ o["default"] = v;
32
+ });
33
+ var __importStar = (this && this.__importStar) || (function () {
34
+ var ownKeys = function(o) {
35
+ ownKeys = Object.getOwnPropertyNames || function (o) {
36
+ var ar = [];
37
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
38
+ return ar;
39
+ };
40
+ return ownKeys(o);
41
+ };
42
+ return function (mod) {
43
+ if (mod && mod.__esModule) return mod;
44
+ var result = {};
45
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
46
+ __setModuleDefault(result, mod);
47
+ return result;
48
+ };
49
+ })();
50
+ var __importDefault = (this && this.__importDefault) || function (mod) {
51
+ return (mod && mod.__esModule) ? mod : { "default": mod };
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.ListItem = exports.GenericPanel = exports.ListItems = void 0;
55
+ exports.useListSelectedIds = useListSelectedIds;
56
+ const style_guide_1 = require("@manuscripts/style-guide");
57
+ const react_1 = __importStar(require("react"));
58
+ const styled_components_1 = __importDefault(require("styled-components"));
59
+ exports.ListItems = style_guide_1.DrawerItemsList;
60
+ const Panel = styled_components_1.default.div `
61
+ display: flex;
62
+ flex-direction: column;
63
+ `;
64
+ const PanelHeader = styled_components_1.default.div `
65
+ display: flex;
66
+ align-items: flex-start;
67
+ padding: ${(props) => props.theme.grid.unit * 2}px
68
+ ${(props) => props.theme.grid.unit * 4}px;
69
+ `;
70
+ const PanelTitle = styled_components_1.default.span `
71
+ font-family: ${(props) => props.theme.font.family.sans};
72
+ font-size: 18px;
73
+ line-height: 24px;
74
+ letter-spacing: -0.37px;
75
+ color: ${(props) => props.theme.colors.text.secondary};
76
+ `;
77
+ const PanelCreateButton = (0, styled_components_1.default)(style_guide_1.IconButton) `
78
+ color: #0d79d0;
79
+ font-size: 14px;
80
+ font-weight: 400;
81
+ font-style: normal;
82
+ line-height: 1;
83
+ width: auto;
84
+ height: 24px;
85
+ margin-left: auto;
86
+ svg {
87
+ margin-right: 4px;
88
+ }
89
+ `;
90
+ const PanelEmpty = styled_components_1.default.div `
91
+ display: flex;
92
+ flex-direction: column;
93
+ align-items: center;
94
+ justify-content: center;
95
+ gap: 16px;
96
+ padding: ${(props) => props.theme.grid.unit * 20}px
97
+ ${(props) => props.theme.grid.unit * 4}px;
98
+ `;
99
+ const PanelEmptyIcon = styled_components_1.default.div `
100
+ width: 120px;
101
+ height: 120px;
102
+ flex-shrink: 0;
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ svg {
107
+ width: 100%;
108
+ height: 100%;
109
+ }
110
+ `;
111
+ const PanelEmptyText = styled_components_1.default.p `
112
+ margin: 0;
113
+ font-size: 18px;
114
+ line-height: 24px;
115
+ text-align: center;
116
+ letter-spacing: -0.369px;
117
+ `;
118
+ const GenericPanel = ({ title, createLabel, onCreate, createDataCy, emptyDataCy, isEmpty, emptyIcon, emptyMessage, children, }) => (react_1.default.createElement(Panel, null,
119
+ react_1.default.createElement(PanelHeader, null,
120
+ react_1.default.createElement(PanelTitle, null, title),
121
+ react_1.default.createElement(PanelCreateButton, { onClick: onCreate, "data-cy": createDataCy },
122
+ react_1.default.createElement(style_guide_1.PlusIcon, null),
123
+ createLabel)),
124
+ isEmpty ? (react_1.default.createElement(PanelEmpty, { "data-cy": emptyDataCy },
125
+ react_1.default.createElement(PanelEmptyIcon, { "aria-hidden": true }, emptyIcon),
126
+ react_1.default.createElement(PanelEmptyText, null, emptyMessage))) : (children)));
127
+ exports.GenericPanel = GenericPanel;
128
+ const ListItem = ({ selected, onClick, primary, secondary, }) => (react_1.default.createElement(style_guide_1.DrawerListItem, { "data-cy": "item", selected: selected, onClick: onClick },
129
+ react_1.default.createElement(style_guide_1.DrawerIcon, null, selected ? (react_1.default.createElement(style_guide_1.AddedIcon, { width: 22, height: 22 })) : (react_1.default.createElement(style_guide_1.AddIcon, { width: 22, height: 22 }))),
130
+ react_1.default.createElement(style_guide_1.DrawerLabelContainer, null,
131
+ react_1.default.createElement(style_guide_1.DrawerItemLabel, null, primary),
132
+ secondary != null && secondary !== '' ? (react_1.default.createElement(style_guide_1.DrawerItemMeta, null, secondary)) : null)));
133
+ exports.ListItem = ListItem;
134
+ function useListSelectedIds(selectedItems) {
135
+ return (0, react_1.useMemo)(() => new Set(selectedItems.map((x) => x.id)), [selectedItems]);
136
+ }
@@ -35,15 +35,21 @@ const StyledIconButton = (0, styled_components_1.default)(style_guide_1.IconButt
35
35
  margin-right: 4px;
36
36
  }
37
37
  `;
38
- const ModalFormActions = ({ type, form, onDelete, showingDeleteDialog, showDeleteDialog, newEntity, isDisableSave, }) => {
38
+ const ModalFormActions = ({ type, form, onDelete, showingDeleteDialog, showDeleteDialog, newEntity, isDisableSave, onSubmitForm, }) => {
39
+ const saveButton = onSubmitForm ? (react_1.default.createElement(StyledIconButton, { disabled: isDisableSave, type: "button", onClick: () => {
40
+ if (!isDisableSave) {
41
+ void onSubmitForm();
42
+ }
43
+ } },
44
+ react_1.default.createElement(style_guide_1.PlusIcon, null),
45
+ newEntity ? 'Save Details' : 'Update Details')) : (react_1.default.createElement(StyledIconButton, { disabled: isDisableSave, type: "submit", form: form },
46
+ react_1.default.createElement(style_guide_1.PlusIcon, null),
47
+ newEntity ? 'Save Details' : 'Update Details'));
39
48
  return (react_1.default.createElement(ActionsContainer, { "data-cy": `${type}-action` },
40
49
  react_1.default.createElement(ConfirmationDialog_1.ConfirmationDialog, { isOpen: showingDeleteDialog, onPrimary: () => {
41
50
  onDelete();
42
51
  showDeleteDialog();
43
52
  }, onSecondary: showDeleteDialog, type: ConfirmationDialog_1.DialogType.DELETE, entityType: type }),
44
- react_1.default.createElement(StyledButtonGroup, null,
45
- react_1.default.createElement(StyledIconButton, { disabled: isDisableSave, type: "submit", form: form },
46
- react_1.default.createElement(style_guide_1.PlusIcon, null),
47
- newEntity ? 'Save Details' : 'Update Details'))));
53
+ react_1.default.createElement(StyledButtonGroup, null, saveButton)));
48
54
  };
49
55
  exports.ModalFormActions = ModalFormActions;
@@ -65,9 +65,11 @@ const leaveTitle = (state, dispatch, view) => {
65
65
  }
66
66
  return true;
67
67
  };
68
- const leaveFigcaption = (state) => {
68
+ const leaveCaption = (state) => {
69
69
  const { selection: { $anchor }, } = state;
70
- return $anchor.parent.type === $anchor.parent.type.schema.nodes.caption_title;
70
+ return ($anchor.parent.type === $anchor.parent.type.schema.nodes.caption_title ||
71
+ $anchor.node($anchor.depth - 1)?.type ===
72
+ $anchor.parent.type.schema.nodes.caption);
71
73
  };
72
74
  const protectTitles = (state, dispatch, view) => {
73
75
  const { selection } = state;
@@ -99,25 +101,37 @@ const protectReferencesTitle = (state) => {
99
101
  exports.protectReferencesTitle = protectReferencesTitle;
100
102
  const protectCaption = (state, dispatch) => {
101
103
  const { selection: { $anchor }, } = state;
102
- if (dispatch &&
103
- ($anchor.parent.type === $anchor.parent.type.schema.nodes.caption_title ||
104
- $anchor.parent.type === $anchor.parent.type.schema.nodes.caption) &&
104
+ let nodeType = undefined;
105
+ if ($anchor.node($anchor.depth - 1)?.type ===
106
+ $anchor.parent.type.schema.nodes.caption &&
107
+ $anchor.node($anchor.depth).content.size === 1) {
108
+ nodeType = $anchor.node($anchor.depth - 1).type;
109
+ }
110
+ else if ($anchor.parent.type === $anchor.parent.type.schema.nodes.caption_title &&
105
111
  $anchor.parent.content.size === 1) {
106
- const slice = new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from([state.schema.nodes.caption_title.create()]), 1, 1);
112
+ nodeType = $anchor.parent.type;
113
+ }
114
+ if (dispatch && nodeType) {
115
+ const slice = new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from([nodeType.create()]), 1, 1);
107
116
  const tr = state.tr.replace($anchor.pos - 1, $anchor.pos, slice);
108
117
  dispatch(tr);
109
118
  return true;
110
119
  }
111
120
  return false;
112
121
  };
113
- const keepCaption = (state) => {
122
+ const keepCaption = (state, dispatch) => {
114
123
  const { selection: { $anchor }, } = state;
115
- return ($anchor.parent.type === $anchor.parent.type.schema.nodes.caption_title &&
116
- $anchor.parent.content.size === 0);
124
+ if (dispatch &&
125
+ $anchor.parent.type === $anchor.parent.type.schema.nodes.caption_title &&
126
+ $anchor.parent.content.size === 1) {
127
+ dispatch(state.tr.delete($anchor.pos, $anchor.pos + 1));
128
+ return true;
129
+ }
130
+ return false;
117
131
  };
118
132
  const titleKeymap = {
119
133
  Backspace: (0, prosemirror_commands_1.chainCommands)(protectTitles, exports.protectReferencesTitle, protectCaption),
120
- Enter: (0, prosemirror_commands_1.chainCommands)(commands_1.autoComplete, leaveTitle, leaveFigcaption),
134
+ Enter: (0, prosemirror_commands_1.chainCommands)(commands_1.autoComplete, leaveTitle, leaveCaption),
121
135
  Delete: (0, prosemirror_commands_1.chainCommands)(keepCaption, exports.protectReferencesTitle),
122
136
  };
123
137
  exports.default = titleKeymap;
@@ -99,7 +99,7 @@ describe('editor view', () => {
99
99
  expect(figureElement.childCount).toBe(5);
100
100
  expect(figureElement.type).toBe(transform_1.schema.nodes.figure_element);
101
101
  expect(figureElement.content.child(0).type).toBe(transform_1.schema.nodes.figure);
102
- expect(figureElement.content.child(1).type).toBe(transform_1.schema.nodes.figcaption);
102
+ expect(figureElement.content.child(1).type).toBe(transform_1.schema.nodes.caption);
103
103
  const sectionWithTable = view.state.doc.child(2).child(8);
104
104
  expect(sectionWithTable.attrs.id).toBe('section-with-table');
105
105
  expect(sectionWithTable.childCount).toBe(2);
@@ -107,7 +107,7 @@ describe('editor view', () => {
107
107
  const tableElement = sectionWithTable.content.child(1);
108
108
  expect(tableElement.childCount).toBe(5);
109
109
  expect(tableElement.type).toBe(tableElement.type.schema.nodes.table_element);
110
- expect(tableElement.content.child(0).type).toBe(tableElement.type.schema.nodes.figcaption);
110
+ expect(tableElement.content.child(0).type).toBe(tableElement.type.schema.nodes.caption_title);
111
111
  expect(tableElement.content.child(1).type).toBe(tableElement.type.schema.nodes.table);
112
112
  });
113
113
  });
@@ -258,19 +258,18 @@ class ContextMenu {
258
258
  const tr = this.view.state.tr;
259
259
  const boxElementNode = $pos.node($pos.depth - 1);
260
260
  const boxStartPos = $pos.start($pos.depth - 1);
261
- const figcaptions = (0, prosemirror_utils_1.findChildrenByType)(boxElementNode, transform_1.schema.nodes.figcaption);
262
- const hasLabel = figcaptions.length > 0;
261
+ const captionTitle = (0, prosemirror_utils_1.findChildrenByType)(boxElementNode, transform_1.schema.nodes.caption_title, false)[0];
262
+ const caption = (0, prosemirror_utils_1.findChildrenByType)(boxElementNode, transform_1.schema.nodes.caption, false)[0];
263
+ const hasLabel = captionTitle;
263
264
  menu.insertBefore(this.createMenuItem(hasLabel ? 'Delete Label' : 'Add Label', () => {
264
265
  if (hasLabel) {
265
- const figcaptionNode = figcaptions[0].node;
266
- const figcaptionPos = boxStartPos + figcaptions[0].pos;
267
- tr.delete(figcaptionPos, figcaptionPos + figcaptionNode.nodeSize);
266
+ const captionNode = captionTitle.node;
267
+ const captionPos = boxStartPos + captionTitle.pos;
268
+ tr.delete(captionPos, captionPos + captionNode.nodeSize + (caption?.node.nodeSize || 0));
268
269
  }
269
270
  else {
270
- const newFigcaption = transform_1.schema.nodes.figcaption.create({}, [
271
- transform_1.schema.nodes.caption_title.create(),
272
- ]);
273
- tr.insert(boxStartPos, newFigcaption);
271
+ const captionTitle = transform_1.schema.nodes.caption_title.create();
272
+ tr.insert(boxStartPos, captionTitle);
274
273
  }
275
274
  this.view.dispatch(tr);
276
275
  popper.destroy();
@@ -19,6 +19,7 @@ exports.objectsKey = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const prosemirror_state_1 = require("prosemirror-state");
21
21
  const prosemirror_view_1 = require("prosemirror-view");
22
+ const prosemirror_utils_1 = require("prosemirror-utils");
22
23
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
23
24
  exports.objectsKey = new prosemirror_state_1.PluginKey('objects');
24
25
  exports.default = () => {
@@ -41,26 +42,19 @@ exports.default = () => {
41
42
  const { id } = node.attrs;
42
43
  if (id) {
43
44
  const target = targets.get(id);
44
- const resolvedPos = state.doc.resolve(pos);
45
- const isInGraphicalAbstract = (0, transform_1.isInGraphicalAbstractSection)(resolvedPos);
46
- if (target && !isInGraphicalAbstract) {
45
+ if (target) {
47
46
  const labelNode = document.createElement('span');
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.firstChild?.nodeSize || 0) + 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
- }
47
+ labelNode.className = 'element-label';
48
+ const caption = (0, prosemirror_utils_1.findChildren)(node, (node) => node.type === transform_1.schema.nodes.caption ||
49
+ node.type === transform_1.schema.nodes.caption_title, false)[0];
50
+ const labelPos = getDecorationPos(target, state.doc, pos, caption);
51
+ labelNode.textContent = caption
52
+ ? target.label + ':'
53
+ : target.label;
54
+ decorations.push(prosemirror_view_1.Decoration.widget(labelPos, labelNode, {
55
+ side: -1,
56
+ key: `element-label-${id}-${target.label}`,
57
+ }));
64
58
  }
65
59
  }
66
60
  });
@@ -70,3 +64,14 @@ exports.default = () => {
70
64
  },
71
65
  });
72
66
  };
67
+ const getDecorationPos = (target, doc, pos, caption) => {
68
+ const $pos = doc.resolve(pos + (caption?.pos || 1) + 1);
69
+ let targetPos = $pos.pos;
70
+ if (!caption) {
71
+ targetPos = $pos.end();
72
+ }
73
+ else if (!$pos.nodeBefore) {
74
+ targetPos -= 1;
75
+ }
76
+ return targetPos;
77
+ };
@@ -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.17';
4
+ exports.VERSION = '3.12.20';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -23,7 +23,7 @@ const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
24
24
  const transform_1 = require("@manuscripts/transform");
25
25
  const prosemirror_state_1 = require("prosemirror-state");
26
- const AffiliationsModal_1 = require("../components/affiliations/AffiliationsModal");
26
+ const AuthorsAndAffiliationsModals_1 = require("../components/authors-affiliations/AuthorsAndAffiliationsModals");
27
27
  const icons_1 = require("../icons");
28
28
  const authors_1 = require("../lib/authors");
29
29
  const comments_1 = require("../lib/comments");
@@ -58,22 +58,16 @@ class AffiliationsView extends block_view_1.default {
58
58
  };
59
59
  this.handleEdit = (id, addNew) => {
60
60
  this.props.popper.destroy();
61
- const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
62
61
  const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
63
- const affiliation = id
64
- ? affiliations.filter((a) => a.id === id)[0]
65
- : undefined;
62
+ const affiliation = id ? affiliations.find((a) => a.id === id) : undefined;
66
63
  const componentProps = {
64
+ initialModal: 'affiliations',
65
+ view: this.view,
67
66
  affiliation,
68
- authors: contributors,
69
- affiliations,
70
- onSaveAffiliation: (affiliation) => (0, AffiliationsModal_1.handleSaveAffiliation)(this.view, affiliation, this.getPos()),
71
- onDeleteAffiliation: (affiliation) => (0, AffiliationsModal_1.handleDeleteAffiliation)(this.view, affiliation),
72
- onUpdateAuthors: (authors) => (0, AffiliationsModal_1.handleUpdateAuthors)(this.view, authors),
73
67
  addNewAffiliation: addNew,
74
68
  };
75
69
  this.popper?.remove();
76
- this.popper = (0, ReactSubView_1.default)(this.props, AffiliationsModal_1.AffiliationsModal, componentProps, this.node, this.getPos, this.view);
70
+ this.popper = (0, ReactSubView_1.default)(this.props, AuthorsAndAffiliationsModals_1.AuthorsAndAffiliationsModals, componentProps, this.node, this.getPos, this.view);
77
71
  this.container.appendChild(this.popper);
78
72
  };
79
73
  this.showGroupContextMenu = () => {
@@ -26,7 +26,7 @@ class CaptionView extends base_node_view_1.BaseNodeView {
26
26
  };
27
27
  }
28
28
  createDOM() {
29
- this.dom = document.createElement('p');
29
+ this.dom = document.createElement('caption');
30
30
  this.dom.className = 'caption-description placeholder';
31
31
  this.dom.contentEditable = 'true';
32
32
  this.contentDOM = this.dom;
@@ -23,7 +23,7 @@ const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
24
24
  const transform_1 = require("@manuscripts/transform");
25
25
  const prosemirror_state_1 = require("prosemirror-state");
26
- const AuthorsModal_1 = require("../components/authors/AuthorsModal");
26
+ const AuthorsAndAffiliationsModals_1 = require("../components/authors-affiliations/AuthorsAndAffiliationsModals");
27
27
  const authors_1 = require("../lib/authors");
28
28
  const comments_1 = require("../lib/comments");
29
29
  const navigation_utils_1 = require("../lib/navigation-utils");
@@ -216,18 +216,15 @@ class ContributorsView extends block_view_1.default {
216
216
  this.handleEdit = (id, addNew) => {
217
217
  this.props.popper.destroy();
218
218
  const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
219
- const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
220
219
  const author = id ? contributors.filter((a) => a.id === id)[0] : undefined;
221
220
  const componentProps = {
221
+ initialModal: 'authors',
222
+ view: this.view,
222
223
  author,
223
- authors: contributors,
224
- affiliations,
225
- onSaveAuthor: (contributor) => (0, AuthorsModal_1.handleSaveContributor)(this.view, contributor, this.getPos()),
226
- onDeleteAuthor: (contributor) => (0, AuthorsModal_1.handleDeleteContributor)(this.view, contributor),
227
224
  addNewAuthor: addNew,
228
225
  };
229
226
  this.popper?.remove();
230
- this.popper = (0, ReactSubView_1.default)(this.props, AuthorsModal_1.AuthorsModal, componentProps, this.node, this.getPos, this.view);
227
+ this.popper = (0, ReactSubView_1.default)(this.props, AuthorsAndAffiliationsModals_1.AuthorsAndAffiliationsModals, componentProps, this.node, this.getPos, this.view);
231
228
  this.container.appendChild(this.popper);
232
229
  };
233
230
  }
@@ -60,7 +60,6 @@ class FigureView extends base_node_view_1.BaseNodeView {
60
60
  this.container.contentEditable = 'false';
61
61
  this.dom.appendChild(this.container);
62
62
  this.contentDOM = document.createElement('div');
63
- this.contentDOM.className = 'figure-caption';
64
63
  this.contentDOM.setAttribute('tabindex', '1337');
65
64
  this.dom.appendChild(this.contentDOM);
66
65
  }