@manuscripts/body-editor 1.7.17-LEAN-3301-1 → 1.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 (83) hide show
  1. package/dist/cjs/lib/array-reducer.js +0 -2
  2. package/dist/cjs/lib/track-changes-utils.js +1 -5
  3. package/dist/cjs/lib/utils.js +5 -1
  4. package/dist/cjs/views/base_node_view.js +19 -0
  5. package/dist/cjs/views/bibliography_element.js +2 -3
  6. package/dist/cjs/views/citation_editable.js +2 -3
  7. package/dist/cjs/views/contributors.js +25 -78
  8. package/dist/es/configs/editor-views.js +2 -2
  9. package/dist/es/lib/array-reducer.js +0 -2
  10. package/dist/es/lib/track-changes-utils.js +0 -3
  11. package/dist/es/lib/utils.js +4 -1
  12. package/dist/es/views/base_node_view.js +19 -0
  13. package/dist/es/views/bibliography_element.js +2 -3
  14. package/dist/es/views/citation_editable.js +2 -3
  15. package/dist/es/views/contributors.js +26 -79
  16. package/dist/types/components/outline/DraggableTree.d.ts +1 -1
  17. package/dist/types/configs/ManuscriptsEditor.d.ts +2 -0
  18. package/dist/types/configs/editor-views.d.ts +28 -0
  19. package/dist/types/lib/array-reducer.d.ts +1 -5
  20. package/dist/types/lib/track-changes-utils.d.ts +0 -1
  21. package/dist/types/lib/utils.d.ts +1 -0
  22. package/dist/types/views/base_node_view.d.ts +4 -1
  23. package/dist/types/views/bibliography_element_editable.d.ts +2 -0
  24. package/dist/types/views/blockquote_element_editable.d.ts +2 -0
  25. package/dist/types/views/bullet_list_editable.d.ts +2 -0
  26. package/dist/types/views/contributors.d.ts +8 -25
  27. package/dist/types/views/editable_block.d.ts +2 -0
  28. package/dist/types/views/equation_element_editable.d.ts +2 -0
  29. package/dist/types/views/figure_element_editable.d.ts +2 -0
  30. package/dist/types/views/footnote_editable.d.ts +2 -0
  31. package/dist/types/views/footnotes_element_editable.d.ts +2 -0
  32. package/dist/types/views/listing_element_editable.d.ts +2 -0
  33. package/dist/types/views/ordered_list_editable.d.ts +2 -0
  34. package/dist/types/views/paragraph_editable.d.ts +2 -0
  35. package/dist/types/views/placeholder_element_editable.d.ts +2 -0
  36. package/dist/types/views/pullquote_element_editable.d.ts +2 -0
  37. package/dist/types/views/section_title_editable.d.ts +2 -0
  38. package/dist/types/views/table_element_editable.d.ts +2 -0
  39. package/dist/types/views/toc_element_editable.d.ts +2 -0
  40. package/package.json +6 -7
  41. package/styles/AdvancedEditor.css +3 -3
  42. package/dist/cjs/components/authors/AffiliationButton.js +0 -105
  43. package/dist/cjs/components/authors/AffiliationForm.js +0 -50
  44. package/dist/cjs/components/authors/AuthorActions.js +0 -61
  45. package/dist/cjs/components/authors/AuthorAffiliations.js +0 -116
  46. package/dist/cjs/components/authors/AuthorDetailsForm.js +0 -97
  47. package/dist/cjs/components/authors/AuthorFormPlaceholder.js +0 -57
  48. package/dist/cjs/components/authors/AuthorList.js +0 -40
  49. package/dist/cjs/components/authors/AuthorsModal.js +0 -226
  50. package/dist/cjs/components/authors/ChangeHandlingForm.js +0 -37
  51. package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +0 -23
  52. package/dist/cjs/components/authors/DraggableAuthor.js +0 -170
  53. package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +0 -21
  54. package/dist/cjs/lib/authors.js +0 -43
  55. package/dist/cjs/lib/view.js +0 -97
  56. package/dist/es/components/authors/AffiliationButton.js +0 -75
  57. package/dist/es/components/authors/AffiliationForm.js +0 -43
  58. package/dist/es/components/authors/AuthorActions.js +0 -31
  59. package/dist/es/components/authors/AuthorAffiliations.js +0 -85
  60. package/dist/es/components/authors/AuthorDetailsForm.js +0 -67
  61. package/dist/es/components/authors/AuthorFormPlaceholder.js +0 -50
  62. package/dist/es/components/authors/AuthorList.js +0 -33
  63. package/dist/es/components/authors/AuthorsModal.js +0 -196
  64. package/dist/es/components/authors/ChangeHandlingForm.js +0 -10
  65. package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +0 -16
  66. package/dist/es/components/authors/DraggableAuthor.js +0 -140
  67. package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +0 -14
  68. package/dist/es/lib/authors.js +0 -36
  69. package/dist/es/lib/view.js +0 -64
  70. package/dist/types/components/authors/AffiliationButton.d.ts +0 -8
  71. package/dist/types/components/authors/AffiliationForm.d.ts +0 -7
  72. package/dist/types/components/authors/AuthorActions.d.ts +0 -9
  73. package/dist/types/components/authors/AuthorAffiliations.d.ts +0 -11
  74. package/dist/types/components/authors/AuthorDetailsForm.d.ts +0 -30
  75. package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +0 -2
  76. package/dist/types/components/authors/AuthorList.d.ts +0 -25
  77. package/dist/types/components/authors/AuthorsModal.d.ts +0 -26
  78. package/dist/types/components/authors/ChangeHandlingForm.d.ts +0 -5
  79. package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +0 -9
  80. package/dist/types/components/authors/DraggableAuthor.d.ts +0 -25
  81. package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +0 -7
  82. package/dist/types/lib/authors.d.ts +0 -23
  83. package/dist/types/lib/view.d.ts +0 -25
@@ -39,8 +39,6 @@ const arrayReducer = (isEqual = (a, b) => a === b) => {
39
39
  return handleUpdate(state, action.items);
40
40
  case 'delete':
41
41
  return handleDelete(state, action.item);
42
- case 'set':
43
- return action.state;
44
42
  }
45
43
  };
46
44
  };
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isHidden = exports.getAttrsTrackingButton = exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
18
+ exports.getAttrsTrackingButton = exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
19
19
  const assets_1 = require("../assets");
20
20
  function isRejectedInsert(node) {
21
21
  if (node.attrs.dataTracked) {
@@ -99,7 +99,3 @@ const getAttrsTrackingButton = (changeID) => {
99
99
  return el;
100
100
  };
101
101
  exports.getAttrsTrackingButton = getAttrsTrackingButton;
102
- function isHidden(node) {
103
- return isDeleted(node) || isRejectedInsert(node);
104
- }
105
- exports.isHidden = isHidden;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
18
+ exports.isMetaNode = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const prosemirror_utils_1 = require("prosemirror-utils");
21
21
  function* iterateChildren(node, recurse = false) {
@@ -58,3 +58,7 @@ const findParentElement = (selection, validIds) => (0, prosemirror_utils_1.findP
58
58
  return (0, transform_1.isElementNodeType)(node.type) && node.attrs.id;
59
59
  })(selection);
60
60
  exports.findParentElement = findParentElement;
61
+ const isMetaNode = (nodeType) => nodeType === transform_1.schema.nodes.bibliography_item.name ||
62
+ nodeType === transform_1.schema.nodes.affiliation.name ||
63
+ nodeType === transform_1.schema.nodes.contributor.name;
64
+ exports.isMetaNode = isMetaNode;
@@ -16,6 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.BaseNodeView = void 0;
19
+ const utils_1 = require("../lib/utils");
19
20
  class BaseNodeView {
20
21
  constructor(props, node, view, getPos, decorations) {
21
22
  this.props = props;
@@ -61,6 +62,24 @@ class BaseNodeView {
61
62
  this.dom.classList.toggle('has-sync-error', this.syncErrors.length > 0);
62
63
  }
63
64
  };
65
+ this.updateNodeAttrs = (attrs) => {
66
+ this.view.state.doc.descendants((node, pos) => {
67
+ if (node.attrs.id === attrs.id) {
68
+ const tr = this.view.state.tr.setNodeMarkup(pos, undefined, attrs);
69
+ if ((0, utils_1.isMetaNode)(node.type.name)) {
70
+ tr.setMeta('track-changes-update-meta-node', true);
71
+ }
72
+ this.view.dispatch(tr);
73
+ }
74
+ });
75
+ };
76
+ this.deleteNode = (id) => {
77
+ this.view.state.doc.descendants((node, pos) => {
78
+ if (node.attrs.id === id) {
79
+ this.view.dispatch(this.view.state.tr.delete(pos, pos + node.nodeSize));
80
+ }
81
+ });
82
+ };
64
83
  }
65
84
  setDomAttrs(node, element, omit = []) {
66
85
  Object.keys(node.attrs || {}).forEach((attr) => {
@@ -33,7 +33,6 @@ const transform_1 = require("@manuscripts/transform");
33
33
  const assets_1 = require("../assets");
34
34
  const dompurify_1 = require("../lib/dompurify");
35
35
  const track_changes_utils_1 = require("../lib/track-changes-utils");
36
- const view_1 = require("../lib/view");
37
36
  const bibliography_1 = require("../plugins/bibliography");
38
37
  const comment_annotation_1 = require("../plugins/comment_annotation");
39
38
  const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
@@ -152,10 +151,10 @@ class BibliographyElementBlockView extends block_view_1.default {
152
151
  };
153
152
  this.handleSave = (item) => {
154
153
  const node = this.decoder.decode(item);
155
- (0, view_1.updateNode)(this.view, node);
154
+ this.updateNodeAttrs(node.attrs);
156
155
  };
157
156
  this.handleDelete = (item) => {
158
- (0, view_1.deleteNode)(this.view, item._id);
157
+ return this.deleteNode(item._id);
159
158
  };
160
159
  this.addClickListenerToBibItem = (element, dataTracked) => {
161
160
  if (dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
@@ -27,7 +27,6 @@ const prosemirror_state_1 = require("prosemirror-state");
27
27
  const prosemirror_utils_1 = require("prosemirror-utils");
28
28
  const citation_sources_1 = require("../citation-sources");
29
29
  const track_changes_utils_1 = require("../lib/track-changes-utils");
30
- const view_1 = require("../lib/view");
31
30
  const bibliography_1 = require("../plugins/bibliography");
32
31
  const citation_1 = require("./citation");
33
32
  const CitationEditorWrapper_1 = require("./CitationEditorWrapper");
@@ -102,7 +101,7 @@ class CitationEditableView extends citation_1.CitationView {
102
101
  }
103
102
  else {
104
103
  const node = this.decoder.decode(item);
105
- (0, view_1.updateNodeAttrs)(this.view, node.type, node.attrs);
104
+ this.updateNodeAttrs(node.attrs);
106
105
  }
107
106
  };
108
107
  this.handleUncite = (id) => {
@@ -146,7 +145,7 @@ class CitationEditableView extends citation_1.CitationView {
146
145
  this.handleCancel();
147
146
  };
148
147
  this.handleDelete = (item) => {
149
- return (0, view_1.deleteNode)(this.view, item._id);
148
+ return this.deleteNode(item._id);
150
149
  };
151
150
  this.handleComment = () => {
152
151
  const comment = (0, transform_1.buildComment)(this.node.attrs.id);
@@ -1,19 +1,4 @@
1
1
  "use strict";
2
- /*!
3
- * © 2023 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
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
@@ -21,10 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
6
  exports.ContributorsView = void 0;
22
7
  const style_guide_1 = require("@manuscripts/style-guide");
23
8
  const transform_1 = require("@manuscripts/transform");
24
- const AuthorsModal_1 = require("../components/authors/AuthorsModal");
25
- const authors_1 = require("../lib/authors");
26
9
  const track_changes_utils_1 = require("../lib/track-changes-utils");
27
- const view_1 = require("../lib/view");
28
10
  const affiliations_1 = require("../plugins/affiliations");
29
11
  const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
30
12
  const block_view_1 = __importDefault(require("./block_view"));
@@ -95,11 +77,15 @@ class ContributorsView extends block_view_1.default {
95
77
  }
96
78
  const can = this.props.getCapabilities();
97
79
  const disableEditButton = !can.editMetadata;
98
- const { isCorresponding, email } = displayAttr;
99
- if (!disableEditButton) {
100
- container.addEventListener('click', this.handleClick);
101
- }
102
- const name = (0, authors_1.authorLabel)(displayAttr);
80
+ const { bibliographicName, isCorresponding, email, id } = displayAttr;
81
+ container.addEventListener('click', (e) => {
82
+ e.preventDefault();
83
+ if (!disableEditButton) {
84
+ this.props.openAuthorEditing();
85
+ this.props.selectAuthorForEditing(id);
86
+ }
87
+ });
88
+ const name = this.buildNameLiteral(bibliographicName);
103
89
  container.innerHTML =
104
90
  isCorresponding && email
105
91
  ? `<span class="name">${name} (${email})</span>`
@@ -127,6 +113,21 @@ class ContributorsView extends block_view_1.default {
127
113
  }
128
114
  return container;
129
115
  };
116
+ this.initials = (given) => given
117
+ ? given
118
+ .trim()
119
+ .split(' ')
120
+ .map((part) => part.substr(0, 1).toUpperCase() + '.')
121
+ .join('')
122
+ : '';
123
+ this.buildNameLiteral = ({ given = '', family = '', suffix = '' }) => {
124
+ if (!given && !family) {
125
+ return 'Unknown Author';
126
+ }
127
+ return [this.initials(given), family, suffix]
128
+ .filter((part) => part)
129
+ .join(' ');
130
+ };
130
131
  this.isJointFirstAuthor = (authors, index) => {
131
132
  const author = index === 0 ? authors[index] : authors[index - 1];
132
133
  return Boolean(author.attrs.isJointContributor);
@@ -147,7 +148,7 @@ class ContributorsView extends block_view_1.default {
147
148
  const can = this.props.getCapabilities();
148
149
  const button = (0, ReactSubView_1.default)(this.props, style_guide_1.SecondaryButton, {
149
150
  mini: true,
150
- onClick: this.handleClick,
151
+ onClick: this.props.openAuthorEditing,
151
152
  className: 'edit-authors-button',
152
153
  disabled: !can.editMetadata,
153
154
  children: 'Edit Authors',
@@ -167,60 +168,6 @@ class ContributorsView extends block_view_1.default {
167
168
  }
168
169
  }
169
170
  };
170
- this.handleClick = (e) => {
171
- var _a, _b;
172
- e.stopPropagation();
173
- const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
174
- const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
175
- let author = undefined;
176
- const target = e.target;
177
- if (target) {
178
- const id = (_a = target.closest('.contributor')) === null || _a === void 0 ? void 0 : _a.getAttribute('id');
179
- author = contributors.filter((a) => a.id === id)[0];
180
- }
181
- const componentProps = {
182
- author,
183
- authors: contributors,
184
- affiliations,
185
- onSaveAuthor: this.handleSaveAuthor,
186
- onDeleteAuthor: this.handleDeleteAuthor,
187
- onSaveAffiliation: this.handleSaveAffiliation,
188
- };
189
- (_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
190
- this.popper = (0, ReactSubView_1.default)(this.props, AuthorsModal_1.AuthorsModal, componentProps, this.node, this.getPos, this.view);
191
- this.container.appendChild(this.popper);
192
- };
193
- this.handleSaveAuthor = (author) => {
194
- if (!(0, view_1.findChildByID)(this.view, author.id)) {
195
- this.insertAuthorNode(author);
196
- }
197
- else {
198
- (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.contributor, author);
199
- }
200
- };
201
- this.handleDeleteAuthor = (author) => {
202
- (0, view_1.deleteNode)(this.view, author.id);
203
- };
204
- this.handleSaveAffiliation = (affiliation) => {
205
- if (!(0, view_1.findChildByID)(this.view, affiliation.id)) {
206
- this.insertAffiliationNode(affiliation);
207
- }
208
- else {
209
- (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.affiliation, affiliation);
210
- }
211
- };
212
- this.insertAuthorNode = (attrs) => {
213
- const parent = (0, view_1.findChildByType)(this.view, transform_1.schema.nodes.contributors);
214
- const tr = this.view.state.tr;
215
- const node = transform_1.schema.nodes.contributor.create(attrs);
216
- this.view.dispatch(tr.insert(parent.pos + 1, node));
217
- };
218
- this.insertAffiliationNode = (attrs) => {
219
- const parent = (0, view_1.findChildByType)(this.view, transform_1.schema.nodes.affiliations);
220
- const tr = this.view.state.tr;
221
- const node = transform_1.schema.nodes.affiliation.create(attrs);
222
- this.view.dispatch(tr.insert(parent.pos + 1, node));
223
- };
224
171
  this.ignoreMutation = () => true;
225
172
  this.stopEvent = () => true;
226
173
  }
@@ -19,7 +19,7 @@ import bibliographyElement from '../views/bibliography_element_editable';
19
19
  import blockquoteElement from '../views/blockquote_element_editable';
20
20
  import bulletList from '../views/bullet_list_editable';
21
21
  import citation from '../views/citation_editable';
22
- import contributors from '../views/contributors';
22
+ import contributorsSection from '../views/contributors';
23
23
  import crossReference from '../views/cross_reference_editable';
24
24
  import empty from '../views/empty';
25
25
  import equation from '../views/equation_editable';
@@ -54,7 +54,7 @@ export default (props, dispatch) => {
54
54
  bullet_list: bulletList(props),
55
55
  citation: citation(props, dispatch),
56
56
  cross_reference: crossReference(props, dispatch),
57
- contributors: contributors(props, dispatch),
57
+ contributors: contributorsSection(props, dispatch),
58
58
  affiliations: affiliationsSection(props, dispatch),
59
59
  affiliation: affiliation(props, dispatch),
60
60
  equation: equation(props),
@@ -36,8 +36,6 @@ export const arrayReducer = (isEqual = (a, b) => a === b) => {
36
36
  return handleUpdate(state, action.items);
37
37
  case 'delete':
38
38
  return handleDelete(state, action.item);
39
- case 'set':
40
- return action.state;
41
39
  }
42
40
  };
43
41
  };
@@ -87,6 +87,3 @@ export const getAttrsTrackingButton = (changeID) => {
87
87
  el.innerHTML = editAttrsTrackingIcon;
88
88
  return el;
89
89
  };
90
- export function isHidden(node) {
91
- return isDeleted(node) || isRejectedInsert(node);
92
- }
@@ -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 { isElementNodeType, isSectionNodeType, } from '@manuscripts/transform';
16
+ import { isElementNodeType, isSectionNodeType, schema, } from '@manuscripts/transform';
17
17
  import { findParentNode } from 'prosemirror-utils';
18
18
  export function* iterateChildren(node, recurse = false) {
19
19
  for (let i = 0; i < node.childCount; i++) {
@@ -50,3 +50,6 @@ export const findParentElement = (selection, validIds) => findParentNode((node)
50
50
  }
51
51
  return isElementNodeType(node.type) && node.attrs.id;
52
52
  })(selection);
53
+ export const isMetaNode = (nodeType) => nodeType === schema.nodes.bibliography_item.name ||
54
+ nodeType === schema.nodes.affiliation.name ||
55
+ nodeType === schema.nodes.contributor.name;
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { isMetaNode } from '../lib/utils';
16
17
  export class BaseNodeView {
17
18
  constructor(props, node, view, getPos, decorations) {
18
19
  this.props = props;
@@ -58,6 +59,24 @@ export class BaseNodeView {
58
59
  this.dom.classList.toggle('has-sync-error', this.syncErrors.length > 0);
59
60
  }
60
61
  };
62
+ this.updateNodeAttrs = (attrs) => {
63
+ this.view.state.doc.descendants((node, pos) => {
64
+ if (node.attrs.id === attrs.id) {
65
+ const tr = this.view.state.tr.setNodeMarkup(pos, undefined, attrs);
66
+ if (isMetaNode(node.type.name)) {
67
+ tr.setMeta('track-changes-update-meta-node', true);
68
+ }
69
+ this.view.dispatch(tr);
70
+ }
71
+ });
72
+ };
73
+ this.deleteNode = (id) => {
74
+ this.view.state.doc.descendants((node, pos) => {
75
+ if (node.attrs.id === id) {
76
+ this.view.dispatch(this.view.state.tr.delete(pos, pos + node.nodeSize));
77
+ }
78
+ });
79
+ };
61
80
  }
62
81
  setDomAttrs(node, element, omit = []) {
63
82
  Object.keys(node.attrs || {}).forEach((attr) => {
@@ -27,7 +27,6 @@ import { buildComment, Decoder, } from '@manuscripts/transform';
27
27
  import { commentIcon, editIcon } from '../assets';
28
28
  import { sanitize } from '../lib/dompurify';
29
29
  import { getAttrsTrackingButton, getChangeClasses, } from '../lib/track-changes-utils';
30
- import { deleteNode, updateNode } from '../lib/view';
31
30
  import { getBibliographyPluginState } from '../plugins/bibliography';
32
31
  import { commentAnnotation } from '../plugins/comment_annotation';
33
32
  import { selectedSuggestionKey, SET_SUGGESTION_ID, } from '../plugins/selected-suggestion-ui';
@@ -146,10 +145,10 @@ export class BibliographyElementBlockView extends BlockView {
146
145
  };
147
146
  this.handleSave = (item) => {
148
147
  const node = this.decoder.decode(item);
149
- updateNode(this.view, node);
148
+ this.updateNodeAttrs(node.attrs);
150
149
  };
151
150
  this.handleDelete = (item) => {
152
- deleteNode(this.view, item._id);
151
+ return this.deleteNode(item._id);
153
152
  };
154
153
  this.addClickListenerToBibItem = (element, dataTracked) => {
155
154
  if (dataTracked.status !== CHANGE_STATUS.rejected) {
@@ -21,7 +21,6 @@ import { TextSelection } from 'prosemirror-state';
21
21
  import { findChildren, findChildrenByType } from 'prosemirror-utils';
22
22
  import { crossref } from '../citation-sources';
23
23
  import { isDeleted } from '../lib/track-changes-utils';
24
- import { deleteNode, updateNodeAttrs } from '../lib/view';
25
24
  import { getBibliographyPluginState } from '../plugins/bibliography';
26
25
  import { CitationView } from './citation';
27
26
  import { CitationEditorWrapper } from './CitationEditorWrapper';
@@ -96,7 +95,7 @@ export class CitationEditableView extends CitationView {
96
95
  }
97
96
  else {
98
97
  const node = this.decoder.decode(item);
99
- updateNodeAttrs(this.view, node.type, node.attrs);
98
+ this.updateNodeAttrs(node.attrs);
100
99
  }
101
100
  };
102
101
  this.handleUncite = (id) => {
@@ -140,7 +139,7 @@ export class CitationEditableView extends CitationView {
140
139
  this.handleCancel();
141
140
  };
142
141
  this.handleDelete = (item) => {
143
- return deleteNode(this.view, item._id);
142
+ return this.deleteNode(item._id);
144
143
  };
145
144
  this.handleComment = () => {
146
145
  const comment = buildComment(this.node.attrs.id);
@@ -1,24 +1,6 @@
1
- /*!
2
- * © 2023 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
1
  import { SecondaryButton } from '@manuscripts/style-guide';
17
- import { isContributorNode, schema, } from '@manuscripts/transform';
18
- import { AuthorsModal, } from '../components/authors/AuthorsModal';
19
- import { authorLabel } from '../lib/authors';
2
+ import { isContributorNode } from '@manuscripts/transform';
20
3
  import { getActualAttrs } from '../lib/track-changes-utils';
21
- import { deleteNode, findChildByID, findChildByType, findChildrenAttrsByType, updateNodeAttrs, } from '../lib/view';
22
4
  import { affiliationsKey } from '../plugins/affiliations';
23
5
  import { selectedSuggestionKey } from '../plugins/selected-suggestion-ui';
24
6
  import BlockView from './block_view';
@@ -89,11 +71,15 @@ export class ContributorsView extends BlockView {
89
71
  }
90
72
  const can = this.props.getCapabilities();
91
73
  const disableEditButton = !can.editMetadata;
92
- const { isCorresponding, email } = displayAttr;
93
- if (!disableEditButton) {
94
- container.addEventListener('click', this.handleClick);
95
- }
96
- const name = authorLabel(displayAttr);
74
+ const { bibliographicName, isCorresponding, email, id } = displayAttr;
75
+ container.addEventListener('click', (e) => {
76
+ e.preventDefault();
77
+ if (!disableEditButton) {
78
+ this.props.openAuthorEditing();
79
+ this.props.selectAuthorForEditing(id);
80
+ }
81
+ });
82
+ const name = this.buildNameLiteral(bibliographicName);
97
83
  container.innerHTML =
98
84
  isCorresponding && email
99
85
  ? `<span class="name">${name} (${email})</span>`
@@ -121,6 +107,21 @@ export class ContributorsView extends BlockView {
121
107
  }
122
108
  return container;
123
109
  };
110
+ this.initials = (given) => given
111
+ ? given
112
+ .trim()
113
+ .split(' ')
114
+ .map((part) => part.substr(0, 1).toUpperCase() + '.')
115
+ .join('')
116
+ : '';
117
+ this.buildNameLiteral = ({ given = '', family = '', suffix = '' }) => {
118
+ if (!given && !family) {
119
+ return 'Unknown Author';
120
+ }
121
+ return [this.initials(given), family, suffix]
122
+ .filter((part) => part)
123
+ .join(' ');
124
+ };
124
125
  this.isJointFirstAuthor = (authors, index) => {
125
126
  const author = index === 0 ? authors[index] : authors[index - 1];
126
127
  return Boolean(author.attrs.isJointContributor);
@@ -141,7 +142,7 @@ export class ContributorsView extends BlockView {
141
142
  const can = this.props.getCapabilities();
142
143
  const button = ReactSubView(this.props, SecondaryButton, {
143
144
  mini: true,
144
- onClick: this.handleClick,
145
+ onClick: this.props.openAuthorEditing,
145
146
  className: 'edit-authors-button',
146
147
  disabled: !can.editMetadata,
147
148
  children: 'Edit Authors',
@@ -161,60 +162,6 @@ export class ContributorsView extends BlockView {
161
162
  }
162
163
  }
163
164
  };
164
- this.handleClick = (e) => {
165
- var _a, _b;
166
- e.stopPropagation();
167
- const contributors = findChildrenAttrsByType(this.view, schema.nodes.contributor);
168
- const affiliations = findChildrenAttrsByType(this.view, schema.nodes.affiliation);
169
- let author = undefined;
170
- const target = e.target;
171
- if (target) {
172
- const id = (_a = target.closest('.contributor')) === null || _a === void 0 ? void 0 : _a.getAttribute('id');
173
- author = contributors.filter((a) => a.id === id)[0];
174
- }
175
- const componentProps = {
176
- author,
177
- authors: contributors,
178
- affiliations,
179
- onSaveAuthor: this.handleSaveAuthor,
180
- onDeleteAuthor: this.handleDeleteAuthor,
181
- onSaveAffiliation: this.handleSaveAffiliation,
182
- };
183
- (_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
184
- this.popper = ReactSubView(this.props, AuthorsModal, componentProps, this.node, this.getPos, this.view);
185
- this.container.appendChild(this.popper);
186
- };
187
- this.handleSaveAuthor = (author) => {
188
- if (!findChildByID(this.view, author.id)) {
189
- this.insertAuthorNode(author);
190
- }
191
- else {
192
- updateNodeAttrs(this.view, schema.nodes.contributor, author);
193
- }
194
- };
195
- this.handleDeleteAuthor = (author) => {
196
- deleteNode(this.view, author.id);
197
- };
198
- this.handleSaveAffiliation = (affiliation) => {
199
- if (!findChildByID(this.view, affiliation.id)) {
200
- this.insertAffiliationNode(affiliation);
201
- }
202
- else {
203
- updateNodeAttrs(this.view, schema.nodes.affiliation, affiliation);
204
- }
205
- };
206
- this.insertAuthorNode = (attrs) => {
207
- const parent = findChildByType(this.view, schema.nodes.contributors);
208
- const tr = this.view.state.tr;
209
- const node = schema.nodes.contributor.create(attrs);
210
- this.view.dispatch(tr.insert(parent.pos + 1, node));
211
- };
212
- this.insertAffiliationNode = (attrs) => {
213
- const parent = findChildByType(this.view, schema.nodes.affiliations);
214
- const tr = this.view.state.tr;
215
- const node = schema.nodes.affiliation.create(attrs);
216
- this.view.dispatch(tr.insert(parent.pos + 1, node));
217
- };
218
165
  this.ignoreMutation = () => true;
219
166
  this.stopEvent = () => true;
220
167
  }
@@ -59,5 +59,5 @@ declare class Tree extends React.Component<Props & ConnectedProps, State> {
59
59
  private handleContextMenu;
60
60
  private createMenu;
61
61
  }
62
- declare const DraggableTree: import("react-dnd").DndComponentClass<import("react-dnd").DndComponentClass<typeof Tree, import("react-dnd").Omit<Props & ConnectedDragSourceProps & ConnectedDropTargetProps, "itemType" | "connectDropTarget" | "isOverCurrent" | "canDrop">>, import("react-dnd").Omit<import("react-dnd").Omit<Props & ConnectedDragSourceProps & ConnectedDropTargetProps, "itemType" | "connectDropTarget" | "isOverCurrent" | "canDrop">, "item" | "isDragging" | "connectDragSource" | "connectDragPreview" | "canDrag">>;
62
+ declare const DraggableTree: import("react-dnd").DndComponentClass<import("react-dnd").DndComponentClass<typeof Tree, import("react-dnd").Omit<Props & ConnectedDragSourceProps & ConnectedDropTargetProps, "itemType" | "connectDropTarget" | "isOverCurrent" | "canDrop">>, import("react-dnd").Omit<import("react-dnd").Omit<Props & ConnectedDragSourceProps & ConnectedDropTargetProps, "itemType" | "connectDropTarget" | "isOverCurrent" | "canDrop">, "item" | "connectDragSource" | "connectDragPreview" | "isDragging" | "canDrag">>;
63
63
  export default DraggableTree;
@@ -51,6 +51,8 @@ export interface EditorProps {
51
51
  retrySync: (componentIDs: string[]) => Promise<void>;
52
52
  environment?: string;
53
53
  collabProvider?: CollabProvider;
54
+ openAuthorEditing: () => void;
55
+ selectAuthorForEditing: (authorId: string) => void;
54
56
  }
55
57
  export declare const createEditorState: (props: EditorProps) => EditorState;
56
58
  export declare const createEditorView: (props: EditorProps, root: HTMLElement, state: EditorState, dispatch: Dispatch) => EditorView;