@manuscripts/body-editor 1.7.28-LEAN-3417-3 → 1.7.29

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.
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AffiliationsView = void 0;
7
- const prosemirror_state_1 = require("prosemirror-state");
8
7
  const block_view_1 = __importDefault(require("./block_view"));
9
8
  const creators_1 = require("./creators");
10
9
  class AffiliationsView extends block_view_1.default {
@@ -19,14 +18,6 @@ class AffiliationsView extends block_view_1.default {
19
18
  this.dom.setAttribute('contenteditable', 'false');
20
19
  this.dom.appendChild(this.contentDOM);
21
20
  };
22
- this.updateContents = () => {
23
- this.dom.addEventListener('click', () => {
24
- const { tr, doc } = this.view.state;
25
- tr.setSelection(prosemirror_state_1.NodeSelection.create(doc, this.getPos()));
26
- this.view.dispatch(tr);
27
- console.log(tr.selection);
28
- });
29
- };
30
21
  }
31
22
  }
32
23
  exports.AffiliationsView = AffiliationsView;
@@ -74,7 +74,6 @@ class CitationEditableView extends citation_1.CitationView {
74
74
  this.props.popper.destroy();
75
75
  };
76
76
  this.showContextMenu = () => {
77
- this.props.popper.destroy();
78
77
  const componentProps = {
79
78
  actions: [
80
79
  { label: 'Edit', action: this.handleEdit, icon: 'EditIcon' },
@@ -20,9 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.ContributorsView = void 0;
22
22
  const style_guide_1 = require("@manuscripts/style-guide");
23
- const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
24
23
  const transform_1 = require("@manuscripts/transform");
25
- const prosemirror_state_1 = require("prosemirror-state");
26
24
  const AuthorsModal_1 = require("../components/authors/AuthorsModal");
27
25
  const authors_1 = require("../lib/authors");
28
26
  const track_changes_utils_1 = require("../lib/track-changes-utils");
@@ -81,9 +79,7 @@ class ContributorsView extends block_view_1.default {
81
79
  const pluginState = affiliations_1.affiliationsKey.getState(this.view.state);
82
80
  const attrs = node.attrs;
83
81
  const displayAttr = (0, track_changes_utils_1.getActualAttrs)(node);
84
- const containerWrapper = document.createElement('div');
85
82
  const container = document.createElement('button');
86
- containerWrapper.classList.add('contributor-wrapper');
87
83
  container.classList.add('contributor');
88
84
  container.setAttribute('id', attrs.id);
89
85
  container.setAttribute('contenteditable', 'false');
@@ -99,12 +95,9 @@ class ContributorsView extends block_view_1.default {
99
95
  }
100
96
  const can = this.props.getCapabilities();
101
97
  const disableEditButton = !can.editMetadata;
102
- const { isCorresponding, email, id } = displayAttr;
98
+ const { isCorresponding, email } = displayAttr;
103
99
  if (!disableEditButton) {
104
- container.addEventListener('click', () => {
105
- const dataTracked = attrs.dataTracked;
106
- this.onClickHandler(id, dataTracked ? dataTracked[0] : undefined);
107
- });
100
+ container.addEventListener('click', this.handleClick);
108
101
  }
109
102
  const name = (0, authors_1.authorLabel)(displayAttr);
110
103
  container.innerHTML =
@@ -132,8 +125,7 @@ class ContributorsView extends block_view_1.default {
132
125
  if (selectedAuthor && selectedAuthor === attrs.id) {
133
126
  container.classList.add('selected-suggestion');
134
127
  }
135
- containerWrapper.appendChild(container);
136
- return containerWrapper;
128
+ return container;
137
129
  };
138
130
  this.isJointFirstAuthor = (authors, index) => {
139
131
  const author = index === 0 ? authors[index] : authors[index - 1];
@@ -155,7 +147,7 @@ class ContributorsView extends block_view_1.default {
155
147
  const can = this.props.getCapabilities();
156
148
  const button = (0, ReactSubView_1.default)(this.props, style_guide_1.SecondaryButton, {
157
149
  mini: true,
158
- onClick: () => this.handleEdit(''),
150
+ onClick: this.handleClick,
159
151
  className: 'edit-authors-button',
160
152
  disabled: !can.editMetadata,
161
153
  children: 'Edit Authors',
@@ -175,48 +167,17 @@ class ContributorsView extends block_view_1.default {
175
167
  }
176
168
  }
177
169
  };
178
- this.onClickHandler = (elementId, dataTracked) => {
179
- var _a;
180
- this.props.popper.destroy();
181
- const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
182
- .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
183
- const { tr } = this.view.state;
184
- tr.setSelection(prosemirror_state_1.NodeSelection.create(this.view.state.doc, this.getPos()));
185
- if (dataTracked && dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
186
- tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id);
187
- }
188
- else {
189
- if (isSelectedSuggestion) {
190
- tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true);
191
- }
192
- }
193
- this.view.dispatch(tr);
194
- if (!((dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.operation) === track_changes_plugin_1.CHANGE_OPERATION.delete &&
195
- (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.status) !== track_changes_plugin_1.CHANGE_STATUS.rejected)) {
196
- this.showContextMenu(elementId);
197
- }
198
- };
199
- this.showContextMenu = (elementId) => {
200
- this.props.popper.destroy();
201
- const element = document.getElementById(elementId);
202
- const componentProps = {
203
- actions: [
204
- {
205
- label: 'Edit',
206
- action: () => this.handleEdit(elementId),
207
- icon: 'EditIcon',
208
- },
209
- ],
210
- };
211
- this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
212
- this.props.popper.show(element, this.contextMenu, 'right-start');
213
- };
214
- this.handleEdit = (id) => {
215
- var _a;
216
- this.props.popper.destroy();
170
+ this.handleClick = (e) => {
171
+ var _a, _b;
172
+ e.stopPropagation();
217
173
  const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
218
174
  const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
219
- const author = id ? contributors.filter((a) => a.id === id)[0] : undefined;
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
+ }
220
181
  const componentProps = {
221
182
  author,
222
183
  authors: contributors,
@@ -225,7 +186,7 @@ class ContributorsView extends block_view_1.default {
225
186
  onDeleteAuthor: this.handleDeleteAuthor,
226
187
  onSaveAffiliation: this.handleSaveAffiliation,
227
188
  };
228
- (_a = this.popper) === null || _a === void 0 ? void 0 : _a.remove();
189
+ (_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
229
190
  this.popper = (0, ReactSubView_1.default)(this.props, AuthorsModal_1.AuthorsModal, componentProps, this.node, this.getPos, this.view);
230
191
  this.container.appendChild(this.popper);
231
192
  };
@@ -1,4 +1,3 @@
1
- import { NodeSelection } from 'prosemirror-state';
2
1
  import BlockView from './block_view';
3
2
  import { createNodeView } from './creators';
4
3
  export class AffiliationsView extends BlockView {
@@ -13,14 +12,6 @@ export class AffiliationsView extends BlockView {
13
12
  this.dom.setAttribute('contenteditable', 'false');
14
13
  this.dom.appendChild(this.contentDOM);
15
14
  };
16
- this.updateContents = () => {
17
- this.dom.addEventListener('click', () => {
18
- const { tr, doc } = this.view.state;
19
- tr.setSelection(NodeSelection.create(doc, this.getPos()));
20
- this.view.dispatch(tr);
21
- console.log(tr.selection);
22
- });
23
- };
24
15
  }
25
16
  }
26
17
  export default createNodeView(AffiliationsView);
@@ -68,7 +68,6 @@ export class CitationEditableView extends CitationView {
68
68
  this.props.popper.destroy();
69
69
  };
70
70
  this.showContextMenu = () => {
71
- this.props.popper.destroy();
72
71
  const componentProps = {
73
72
  actions: [
74
73
  { label: 'Edit', action: this.handleEdit, icon: 'EditIcon' },
@@ -13,16 +13,14 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ContextMenu, SecondaryButton, } from '@manuscripts/style-guide';
17
- import { CHANGE_OPERATION, CHANGE_STATUS, } from '@manuscripts/track-changes-plugin';
16
+ import { SecondaryButton } from '@manuscripts/style-guide';
18
17
  import { isContributorNode, schema, } from '@manuscripts/transform';
19
- import { NodeSelection } from 'prosemirror-state';
20
18
  import { AuthorsModal, } from '../components/authors/AuthorsModal';
21
19
  import { authorLabel } from '../lib/authors';
22
20
  import { getActualAttrs } from '../lib/track-changes-utils';
23
21
  import { deleteNode, findChildByID, findChildByType, findChildrenAttrsByType, updateNodeAttrs, } from '../lib/view';
24
22
  import { affiliationsKey } from '../plugins/affiliations';
25
- import { CLEAR_SUGGESTION_ID, selectedSuggestionKey, SET_SUGGESTION_ID, } from '../plugins/selected-suggestion-ui';
23
+ import { selectedSuggestionKey } from '../plugins/selected-suggestion-ui';
26
24
  import BlockView from './block_view';
27
25
  import { createNodeView } from './creators';
28
26
  import ReactSubView from './ReactSubView';
@@ -75,9 +73,7 @@ export class ContributorsView extends BlockView {
75
73
  const pluginState = affiliationsKey.getState(this.view.state);
76
74
  const attrs = node.attrs;
77
75
  const displayAttr = getActualAttrs(node);
78
- const containerWrapper = document.createElement('div');
79
76
  const container = document.createElement('button');
80
- containerWrapper.classList.add('contributor-wrapper');
81
77
  container.classList.add('contributor');
82
78
  container.setAttribute('id', attrs.id);
83
79
  container.setAttribute('contenteditable', 'false');
@@ -93,12 +89,9 @@ export class ContributorsView extends BlockView {
93
89
  }
94
90
  const can = this.props.getCapabilities();
95
91
  const disableEditButton = !can.editMetadata;
96
- const { isCorresponding, email, id } = displayAttr;
92
+ const { isCorresponding, email } = displayAttr;
97
93
  if (!disableEditButton) {
98
- container.addEventListener('click', () => {
99
- const dataTracked = attrs.dataTracked;
100
- this.onClickHandler(id, dataTracked ? dataTracked[0] : undefined);
101
- });
94
+ container.addEventListener('click', this.handleClick);
102
95
  }
103
96
  const name = authorLabel(displayAttr);
104
97
  container.innerHTML =
@@ -126,8 +119,7 @@ export class ContributorsView extends BlockView {
126
119
  if (selectedAuthor && selectedAuthor === attrs.id) {
127
120
  container.classList.add('selected-suggestion');
128
121
  }
129
- containerWrapper.appendChild(container);
130
- return containerWrapper;
122
+ return container;
131
123
  };
132
124
  this.isJointFirstAuthor = (authors, index) => {
133
125
  const author = index === 0 ? authors[index] : authors[index - 1];
@@ -149,7 +141,7 @@ export class ContributorsView extends BlockView {
149
141
  const can = this.props.getCapabilities();
150
142
  const button = ReactSubView(this.props, SecondaryButton, {
151
143
  mini: true,
152
- onClick: () => this.handleEdit(''),
144
+ onClick: this.handleClick,
153
145
  className: 'edit-authors-button',
154
146
  disabled: !can.editMetadata,
155
147
  children: 'Edit Authors',
@@ -169,48 +161,17 @@ export class ContributorsView extends BlockView {
169
161
  }
170
162
  }
171
163
  };
172
- this.onClickHandler = (elementId, dataTracked) => {
173
- var _a;
174
- this.props.popper.destroy();
175
- const isSelectedSuggestion = !!((_a = selectedSuggestionKey
176
- .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
177
- const { tr } = this.view.state;
178
- tr.setSelection(NodeSelection.create(this.view.state.doc, this.getPos()));
179
- if (dataTracked && dataTracked.status !== CHANGE_STATUS.rejected) {
180
- tr.setMeta(SET_SUGGESTION_ID, dataTracked.id);
181
- }
182
- else {
183
- if (isSelectedSuggestion) {
184
- tr.setMeta(CLEAR_SUGGESTION_ID, true);
185
- }
186
- }
187
- this.view.dispatch(tr);
188
- if (!((dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.operation) === CHANGE_OPERATION.delete &&
189
- (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.status) !== CHANGE_STATUS.rejected)) {
190
- this.showContextMenu(elementId);
191
- }
192
- };
193
- this.showContextMenu = (elementId) => {
194
- this.props.popper.destroy();
195
- const element = document.getElementById(elementId);
196
- const componentProps = {
197
- actions: [
198
- {
199
- label: 'Edit',
200
- action: () => this.handleEdit(elementId),
201
- icon: 'EditIcon',
202
- },
203
- ],
204
- };
205
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
206
- this.props.popper.show(element, this.contextMenu, 'right-start');
207
- };
208
- this.handleEdit = (id) => {
209
- var _a;
210
- this.props.popper.destroy();
164
+ this.handleClick = (e) => {
165
+ var _a, _b;
166
+ e.stopPropagation();
211
167
  const contributors = findChildrenAttrsByType(this.view, schema.nodes.contributor);
212
168
  const affiliations = findChildrenAttrsByType(this.view, schema.nodes.affiliation);
213
- const author = id ? contributors.filter((a) => a.id === id)[0] : undefined;
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
+ }
214
175
  const componentProps = {
215
176
  author,
216
177
  authors: contributors,
@@ -219,7 +180,7 @@ export class ContributorsView extends BlockView {
219
180
  onDeleteAuthor: this.handleDeleteAuthor,
220
181
  onSaveAffiliation: this.handleSaveAffiliation,
221
182
  };
222
- (_a = this.popper) === null || _a === void 0 ? void 0 : _a.remove();
183
+ (_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
223
184
  this.popper = ReactSubView(this.props, AuthorsModal, componentProps, this.node, this.getPos, this.view);
224
185
  this.container.appendChild(this.popper);
225
186
  };
@@ -4,7 +4,6 @@ export declare class AffiliationsView<PropsType extends EditableBlockProps> exte
4
4
  ignoreMutation: () => boolean;
5
5
  stopEvent: () => boolean;
6
6
  createElement: () => void;
7
- updateContents: () => void;
8
7
  }
9
8
  declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<AffiliationsView<any>>;
10
9
  export default _default;
@@ -24,23 +24,20 @@ export interface ContributorsProps extends EditableBlockProps {
24
24
  selectAuthorForEditing: (authorId: string) => void;
25
25
  }
26
26
  export declare class ContributorsView<PropsType extends ContributorsProps> extends BlockView<PropsType> {
27
- contextMenu: HTMLElement;
28
27
  container: HTMLElement;
29
28
  inner: HTMLElement;
30
29
  popper?: HTMLElement;
31
30
  initialise: () => void;
32
31
  updateContents: () => void;
33
32
  buildAuthors: () => void;
34
- buildAuthor: (node: ContributorNode, isJointFirstAuthor: boolean, selectedAuthor?: string) => HTMLDivElement;
33
+ buildAuthor: (node: ContributorNode, isJointFirstAuthor: boolean, selectedAuthor?: string) => HTMLButtonElement;
35
34
  createNote(text?: string, title?: string): HTMLSpanElement;
36
35
  isJointFirstAuthor: (authors: ContributorNode[], index: number) => boolean;
37
36
  createElement: () => void;
38
37
  createDOM: () => void;
39
38
  createEditButton: () => void;
40
39
  createLegend: () => void;
41
- private onClickHandler;
42
- showContextMenu: (elementId: string) => void;
43
- handleEdit: (id: string) => void;
40
+ handleClick: (e: Event) => void;
44
41
  handleSaveAuthor: (author: ContributorAttrs) => void;
45
42
  handleDeleteAuthor: (author: ContributorAttrs) => void;
46
43
  handleSaveAffiliation: (affiliation: AffiliationAttrs) => void;
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": "1.7.28-LEAN-3417-3",
4
+ "version": "1.7.29",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -112,4 +112,4 @@
112
112
  "@types/react": "^17.0.2",
113
113
  "prosemirror-tables": "^1.3.5"
114
114
  }
115
- }
115
+ }
@@ -780,6 +780,12 @@ Next levels are shifted 'up' by 1
780
780
  color: var(--deleted-color);
781
781
  }
782
782
 
783
+ .contributor[data-track-op='delete']:not([data-track-status='rejected']),
784
+ .contributor[data-track-op='delete']:not([data-track-status='rejected']) .name,
785
+ .affiliation[data-track-op='delete']:not([data-track-status='rejected']) {
786
+ pointer-events: none;
787
+ }
788
+
783
789
  .contributor[data-track-op='delete']:not([data-track-status='rejected']) {
784
790
  color: var(--deleted-color);
785
791
  }
@@ -797,52 +803,29 @@ Next levels are shifted 'up' by 1
797
803
  .contributors {
798
804
  white-space: initial;
799
805
  margin-top: 24px;
806
+ align-items: center;
800
807
  display: flex;
801
808
  justify-content: space-between;
802
- align-items: flex-start;
803
- gap: 0 .5em;
804
809
  }
805
810
  .contributors-list {
806
- display: flex;
807
- max-width: 100%;
808
811
  flex: 0 1 auto;
809
- flex-wrap: wrap;
810
- gap: 0 .25em;
811
812
  }
813
+
812
814
  .contributors .tools-panel {
813
815
  position: initial;
814
- display: flex;
815
816
  flex: 1;
816
- align-items: center;
817
- }
818
- .contributor-wrapper {
819
- display: flex;
820
- }
821
- .contributor-wrapper:after {
822
- content: ', ';
823
- color: #353535;
824
- }
825
- .contributor-wrapper:last-child::after {
826
- content: '';
827
- margin-right: 0;
828
- }
829
- .contributor-wrapper .contributor-comment {
830
- left: 0;
831
- top: -8px;
832
- width: auto;
833
- height: auto;
834
817
  }
818
+
835
819
  .contributor {
836
- position: relative;
837
820
  display: inline-flex;
838
821
  background: transparent;
839
822
  border: 0;
823
+ font-family: 'PT Sans', sans-serif;
840
824
  font-size: 1rem;
841
825
  text-decoration: none;
842
826
  color: inherit;
843
827
  outline: none;
844
- padding: 4px;
845
- /* margin: 0 6px; */
828
+ padding: 0;
846
829
  }
847
830
 
848
831
  .contributor:not(:disabled):hover {
@@ -858,6 +841,16 @@ Next levels are shifted 'up' by 1
858
841
  cursor: pointer !important;
859
842
  }
860
843
 
844
+ .contributor:after {
845
+ content: ', ';
846
+ color: #353535;
847
+ margin-right: 5px;
848
+ }
849
+ .contributor:last-child::after {
850
+ content: '';
851
+ margin-right: 0;
852
+ }
853
+
861
854
  .contributors-legend {
862
855
  margin: 16px 0 0 0;
863
856
  }
@@ -869,7 +862,11 @@ Next levels are shifted 'up' by 1
869
862
  vertical-align: top;
870
863
  }
871
864
 
872
-
865
+ .contributors .tools-panel {
866
+ align-items: center;
867
+ display: flex;
868
+ margin-left: 8px;
869
+ }
873
870
 
874
871
  .contributor-note {
875
872
  display: inline-block;
@@ -898,4 +895,4 @@ Next levels are shifted 'up' by 1
898
895
 
899
896
  * {
900
897
  scroll-behavior: smooth;
901
- }
898
+ }