@manuscripts/body-editor 1.7.19 → 1.7.21
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.
- package/dist/cjs/commands.js +7 -4
- package/dist/cjs/components/authors/AffiliationButton.js +105 -0
- package/dist/cjs/components/authors/AffiliationForm.js +50 -0
- package/dist/cjs/components/authors/AuthorActions.js +61 -0
- package/dist/cjs/components/authors/AuthorAffiliations.js +116 -0
- package/dist/cjs/components/authors/AuthorDetailsForm.js +97 -0
- package/dist/cjs/components/authors/AuthorFormPlaceholder.js +57 -0
- package/dist/cjs/components/authors/AuthorList.js +40 -0
- package/dist/cjs/components/authors/AuthorsModal.js +226 -0
- package/dist/cjs/components/authors/ChangeHandlingForm.js +37 -0
- package/dist/cjs/components/authors/DeleteAuthorConfirmationDialog.js +23 -0
- package/dist/cjs/components/authors/DraggableAuthor.js +170 -0
- package/dist/cjs/components/authors/SaveAuthorConfirmationDialog.js +21 -0
- package/dist/cjs/lib/array-reducer.js +2 -0
- package/dist/cjs/lib/authors.js +43 -0
- package/dist/cjs/lib/context-menu.js +8 -5
- package/dist/cjs/lib/track-changes-utils.js +5 -1
- package/dist/cjs/lib/utils.js +1 -5
- package/dist/cjs/lib/view.js +97 -0
- package/dist/cjs/plugins/footnotes/index.js +3 -3
- package/dist/cjs/views/base_node_view.js +0 -19
- package/dist/cjs/views/bibliography_element.js +3 -2
- package/dist/cjs/views/citation_editable.js +3 -2
- package/dist/cjs/views/contributors.js +78 -25
- package/dist/cjs/views/footnote.js +12 -2
- package/dist/cjs/views/footnote_editable.js +1 -1
- package/dist/cjs/views/footnotes_element.js +2 -1
- package/dist/cjs/views/footnotes_element_editable.js +2 -1
- package/dist/cjs/views/inline_footnote.js +5 -0
- package/dist/es/commands.js +7 -4
- package/dist/es/components/authors/AffiliationButton.js +75 -0
- package/dist/es/components/authors/AffiliationForm.js +43 -0
- package/dist/es/components/authors/AuthorActions.js +31 -0
- package/dist/es/components/authors/AuthorAffiliations.js +85 -0
- package/dist/es/components/authors/AuthorDetailsForm.js +67 -0
- package/dist/es/components/authors/AuthorFormPlaceholder.js +50 -0
- package/dist/es/components/authors/AuthorList.js +33 -0
- package/dist/es/components/authors/AuthorsModal.js +196 -0
- package/dist/es/components/authors/ChangeHandlingForm.js +10 -0
- package/dist/es/components/authors/DeleteAuthorConfirmationDialog.js +16 -0
- package/dist/es/components/authors/DraggableAuthor.js +140 -0
- package/dist/es/components/authors/SaveAuthorConfirmationDialog.js +14 -0
- package/dist/es/configs/editor-views.js +2 -2
- package/dist/es/lib/array-reducer.js +2 -0
- package/dist/es/lib/authors.js +36 -0
- package/dist/es/lib/context-menu.js +8 -5
- package/dist/es/lib/track-changes-utils.js +3 -0
- package/dist/es/lib/utils.js +1 -4
- package/dist/es/lib/view.js +64 -0
- package/dist/es/plugins/footnotes/index.js +3 -3
- package/dist/es/views/base_node_view.js +0 -19
- package/dist/es/views/bibliography_element.js +3 -2
- package/dist/es/views/citation_editable.js +3 -2
- package/dist/es/views/contributors.js +79 -26
- package/dist/es/views/footnote.js +10 -1
- package/dist/es/views/footnote_editable.js +2 -2
- package/dist/es/views/footnotes_element.js +2 -1
- package/dist/es/views/footnotes_element_editable.js +2 -1
- package/dist/es/views/inline_footnote.js +5 -0
- package/dist/types/components/authors/AffiliationButton.d.ts +8 -0
- package/dist/types/components/authors/AffiliationForm.d.ts +7 -0
- package/dist/types/components/authors/AuthorActions.d.ts +9 -0
- package/dist/types/components/authors/AuthorAffiliations.d.ts +11 -0
- package/dist/types/components/authors/AuthorDetailsForm.d.ts +30 -0
- package/dist/types/components/authors/AuthorFormPlaceholder.d.ts +2 -0
- package/dist/types/components/authors/AuthorList.d.ts +25 -0
- package/dist/types/components/authors/AuthorsModal.d.ts +26 -0
- package/dist/types/components/authors/ChangeHandlingForm.d.ts +5 -0
- package/dist/types/components/authors/DeleteAuthorConfirmationDialog.d.ts +9 -0
- package/dist/types/components/authors/DraggableAuthor.d.ts +25 -0
- package/dist/types/components/authors/SaveAuthorConfirmationDialog.d.ts +7 -0
- package/dist/types/components/outline/DraggableTree.d.ts +1 -1
- package/dist/types/configs/ManuscriptsEditor.d.ts +0 -2
- package/dist/types/configs/editor-views.d.ts +0 -28
- package/dist/types/lib/array-reducer.d.ts +5 -1
- package/dist/types/lib/authors.d.ts +23 -0
- package/dist/types/lib/track-changes-utils.d.ts +1 -0
- package/dist/types/lib/utils.d.ts +0 -1
- package/dist/types/lib/view.d.ts +25 -0
- package/dist/types/views/base_node_view.d.ts +1 -4
- package/dist/types/views/bibliography_element_editable.d.ts +0 -2
- package/dist/types/views/blockquote_element_editable.d.ts +0 -2
- package/dist/types/views/bullet_list_editable.d.ts +0 -2
- package/dist/types/views/contributors.d.ts +25 -8
- package/dist/types/views/editable_block.d.ts +0 -2
- package/dist/types/views/equation_element_editable.d.ts +0 -2
- package/dist/types/views/figure_element_editable.d.ts +0 -2
- package/dist/types/views/footnote.d.ts +2 -0
- package/dist/types/views/footnote_editable.d.ts +0 -2
- package/dist/types/views/footnotes_element_editable.d.ts +0 -2
- package/dist/types/views/listing_element_editable.d.ts +0 -2
- package/dist/types/views/ordered_list_editable.d.ts +0 -2
- package/dist/types/views/paragraph_editable.d.ts +0 -2
- package/dist/types/views/placeholder_element_editable.d.ts +0 -2
- package/dist/types/views/pullquote_element_editable.d.ts +0 -2
- package/dist/types/views/section_title_editable.d.ts +0 -2
- package/dist/types/views/table_element_editable.d.ts +0 -2
- package/dist/types/views/toc_element_editable.d.ts +0 -2
- package/package.json +3 -2
- package/styles/AdvancedEditor.css +3 -3
- package/styles/Editor.css +5 -5
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2024 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 (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.deleteNode = exports.updateNodeAttrs = exports.updateNode = exports.findChildrenAttrsByType = exports.findChildrenByType = exports.findChildByType = exports.findChildByID = void 0;
|
|
42
|
+
const transform_1 = require("@manuscripts/transform");
|
|
43
|
+
const utils = __importStar(require("prosemirror-utils"));
|
|
44
|
+
const track_changes_utils_1 = require("./track-changes-utils");
|
|
45
|
+
const metaNodeTypes = [
|
|
46
|
+
transform_1.schema.nodes.bibliography_item,
|
|
47
|
+
transform_1.schema.nodes.affiliation,
|
|
48
|
+
transform_1.schema.nodes.contributor,
|
|
49
|
+
];
|
|
50
|
+
const updateMetaNode = 'track-changes-update-meta-node';
|
|
51
|
+
const findChildByID = (view, id) => {
|
|
52
|
+
const doc = view.state.doc;
|
|
53
|
+
const children = utils.findChildren(doc, (n) => n.attrs.id === id);
|
|
54
|
+
return children.length ? children[0] : undefined;
|
|
55
|
+
};
|
|
56
|
+
exports.findChildByID = findChildByID;
|
|
57
|
+
const findChildByType = (view, type) => {
|
|
58
|
+
const children = (0, exports.findChildrenByType)(view, type);
|
|
59
|
+
return children.length ? children[0] : undefined;
|
|
60
|
+
};
|
|
61
|
+
exports.findChildByType = findChildByType;
|
|
62
|
+
const findChildrenByType = (view, type) => {
|
|
63
|
+
const doc = view.state.doc;
|
|
64
|
+
return utils.findChildrenByType(doc, type).filter((n) => !(0, track_changes_utils_1.isHidden)(n.node));
|
|
65
|
+
};
|
|
66
|
+
exports.findChildrenByType = findChildrenByType;
|
|
67
|
+
const findChildrenAttrsByType = (view, type) => {
|
|
68
|
+
return (0, exports.findChildrenByType)(view, type).map((n) => (0, track_changes_utils_1.getActualAttrs)(n.node));
|
|
69
|
+
};
|
|
70
|
+
exports.findChildrenAttrsByType = findChildrenAttrsByType;
|
|
71
|
+
const updateNode = (view, node) => {
|
|
72
|
+
(0, exports.updateNodeAttrs)(view, node.type, node.attrs);
|
|
73
|
+
};
|
|
74
|
+
exports.updateNode = updateNode;
|
|
75
|
+
const updateNodeAttrs = (view, type, attrs) => {
|
|
76
|
+
const copy = Object.assign({}, attrs);
|
|
77
|
+
delete copy.dataTracked;
|
|
78
|
+
const child = (0, exports.findChildByID)(view, attrs.id);
|
|
79
|
+
if (child) {
|
|
80
|
+
const pos = child.pos;
|
|
81
|
+
const tr = view.state.tr.setNodeMarkup(pos, undefined, attrs);
|
|
82
|
+
if (metaNodeTypes.includes(type)) {
|
|
83
|
+
tr.setMeta(updateMetaNode, true);
|
|
84
|
+
}
|
|
85
|
+
view.dispatch(tr);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
exports.updateNodeAttrs = updateNodeAttrs;
|
|
89
|
+
const deleteNode = (view, id) => {
|
|
90
|
+
const child = (0, exports.findChildByID)(view, id);
|
|
91
|
+
if (child) {
|
|
92
|
+
const pos = child.pos;
|
|
93
|
+
const node = child.node;
|
|
94
|
+
view.dispatch(view.state.tr.delete(pos, pos + node.nodeSize));
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.deleteNode = deleteNode;
|
|
@@ -132,10 +132,10 @@ exports.default = () => {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
if (node.type === transform_1.schema.nodes.footnotes_element) {
|
|
135
|
-
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
136
|
-
class: 'footnote-element',
|
|
137
|
-
}));
|
|
138
135
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
|
|
136
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
137
|
+
class: 'table-footnotes-element',
|
|
138
|
+
}));
|
|
139
139
|
tableInlineFootnoteIds = (0, footnotes_utils_1.findTableInlineFootnoteIds)(state.doc.resolve(pos));
|
|
140
140
|
}
|
|
141
141
|
else {
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.BaseNodeView = void 0;
|
|
19
|
-
const utils_1 = require("../lib/utils");
|
|
20
19
|
class BaseNodeView {
|
|
21
20
|
constructor(props, node, view, getPos, decorations) {
|
|
22
21
|
this.props = props;
|
|
@@ -62,24 +61,6 @@ class BaseNodeView {
|
|
|
62
61
|
this.dom.classList.toggle('has-sync-error', this.syncErrors.length > 0);
|
|
63
62
|
}
|
|
64
63
|
};
|
|
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
|
-
};
|
|
83
64
|
}
|
|
84
65
|
setDomAttrs(node, element, omit = []) {
|
|
85
66
|
Object.keys(node.attrs || {}).forEach((attr) => {
|
|
@@ -33,6 +33,7 @@ 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");
|
|
36
37
|
const bibliography_1 = require("../plugins/bibliography");
|
|
37
38
|
const comment_annotation_1 = require("../plugins/comment_annotation");
|
|
38
39
|
const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
|
|
@@ -151,10 +152,10 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
151
152
|
};
|
|
152
153
|
this.handleSave = (item) => {
|
|
153
154
|
const node = this.decoder.decode(item);
|
|
154
|
-
this.
|
|
155
|
+
(0, view_1.updateNode)(this.view, node);
|
|
155
156
|
};
|
|
156
157
|
this.handleDelete = (item) => {
|
|
157
|
-
|
|
158
|
+
(0, view_1.deleteNode)(this.view, item._id);
|
|
158
159
|
};
|
|
159
160
|
this.addClickListenerToBibItem = (element, dataTracked) => {
|
|
160
161
|
if (dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
|
|
@@ -27,6 +27,7 @@ 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");
|
|
30
31
|
const bibliography_1 = require("../plugins/bibliography");
|
|
31
32
|
const citation_1 = require("./citation");
|
|
32
33
|
const CitationEditorWrapper_1 = require("./CitationEditorWrapper");
|
|
@@ -101,7 +102,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
101
102
|
}
|
|
102
103
|
else {
|
|
103
104
|
const node = this.decoder.decode(item);
|
|
104
|
-
|
|
105
|
+
(0, view_1.updateNodeAttrs)(this.view, node.type, node.attrs);
|
|
105
106
|
}
|
|
106
107
|
};
|
|
107
108
|
this.handleUncite = (id) => {
|
|
@@ -145,7 +146,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
145
146
|
this.handleCancel();
|
|
146
147
|
};
|
|
147
148
|
this.handleDelete = (item) => {
|
|
148
|
-
return
|
|
149
|
+
return (0, view_1.deleteNode)(this.view, item._id);
|
|
149
150
|
};
|
|
150
151
|
this.handleComment = () => {
|
|
151
152
|
const comment = (0, transform_1.buildComment)(this.node.attrs.id);
|
|
@@ -1,4 +1,19 @@
|
|
|
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
|
+
*/
|
|
2
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
19
|
};
|
|
@@ -6,7 +21,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
21
|
exports.ContributorsView = void 0;
|
|
7
22
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
23
|
const transform_1 = require("@manuscripts/transform");
|
|
24
|
+
const AuthorsModal_1 = require("../components/authors/AuthorsModal");
|
|
25
|
+
const authors_1 = require("../lib/authors");
|
|
9
26
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
27
|
+
const view_1 = require("../lib/view");
|
|
10
28
|
const affiliations_1 = require("../plugins/affiliations");
|
|
11
29
|
const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
|
|
12
30
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
@@ -77,15 +95,11 @@ class ContributorsView extends block_view_1.default {
|
|
|
77
95
|
}
|
|
78
96
|
const can = this.props.getCapabilities();
|
|
79
97
|
const disableEditButton = !can.editMetadata;
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.props.selectAuthorForEditing(id);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
const name = this.buildNameLiteral(bibliographicName);
|
|
98
|
+
const { isCorresponding, email } = displayAttr;
|
|
99
|
+
if (!disableEditButton) {
|
|
100
|
+
container.addEventListener('click', this.handleClick);
|
|
101
|
+
}
|
|
102
|
+
const name = (0, authors_1.authorLabel)(displayAttr);
|
|
89
103
|
container.innerHTML =
|
|
90
104
|
isCorresponding && email
|
|
91
105
|
? `<span class="name">${name} (${email})</span>`
|
|
@@ -113,21 +127,6 @@ class ContributorsView extends block_view_1.default {
|
|
|
113
127
|
}
|
|
114
128
|
return container;
|
|
115
129
|
};
|
|
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
|
-
};
|
|
131
130
|
this.isJointFirstAuthor = (authors, index) => {
|
|
132
131
|
const author = index === 0 ? authors[index] : authors[index - 1];
|
|
133
132
|
return Boolean(author.attrs.isJointContributor);
|
|
@@ -148,7 +147,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
148
147
|
const can = this.props.getCapabilities();
|
|
149
148
|
const button = (0, ReactSubView_1.default)(this.props, style_guide_1.SecondaryButton, {
|
|
150
149
|
mini: true,
|
|
151
|
-
onClick: this.
|
|
150
|
+
onClick: this.handleClick,
|
|
152
151
|
className: 'edit-authors-button',
|
|
153
152
|
disabled: !can.editMetadata,
|
|
154
153
|
children: 'Edit Authors',
|
|
@@ -168,6 +167,60 @@ class ContributorsView extends block_view_1.default {
|
|
|
168
167
|
}
|
|
169
168
|
}
|
|
170
169
|
};
|
|
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
|
+
};
|
|
171
224
|
this.ignoreMutation = () => true;
|
|
172
225
|
this.stopEvent = () => true;
|
|
173
226
|
}
|
|
@@ -18,7 +18,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.FootnoteView = void 0;
|
|
21
|
+
exports.setTCClasses = exports.FootnoteView = void 0;
|
|
22
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
22
23
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
24
|
const creators_1 = require("./creators");
|
|
24
25
|
class FootnoteView extends block_view_1.default {
|
|
@@ -28,4 +29,13 @@ class FootnoteView extends block_view_1.default {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
exports.FootnoteView = FootnoteView;
|
|
31
|
-
|
|
32
|
+
const setTCClasses = (node, dom) => {
|
|
33
|
+
const dataTracked = node.attrs.dataTracked;
|
|
34
|
+
if (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) {
|
|
35
|
+
const lastChange = dataTracked[dataTracked.length - 1];
|
|
36
|
+
const changeClasses = (0, track_changes_utils_1.getChangeClasses)([lastChange]);
|
|
37
|
+
dom.classList.add(...changeClasses);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.setTCClasses = setTCClasses;
|
|
41
|
+
exports.default = (0, creators_1.createNodeOrElementView)(FootnoteView, 'div', exports.setTCClasses);
|
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
const creators_1 = require("./creators");
|
|
19
19
|
const editable_block_1 = require("./editable_block");
|
|
20
20
|
const footnote_1 = require("./footnote");
|
|
21
|
-
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnote_1.FootnoteView), 'div');
|
|
21
|
+
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnote_1.FootnoteView), 'div', footnote_1.setTCClasses);
|
|
@@ -21,6 +21,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
exports.FootnotesElementView = void 0;
|
|
22
22
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
23
|
const creators_1 = require("./creators");
|
|
24
|
+
const footnote_1 = require("./footnote");
|
|
24
25
|
class FootnotesElementView extends block_view_1.default {
|
|
25
26
|
constructor() {
|
|
26
27
|
super(...arguments);
|
|
@@ -37,4 +38,4 @@ class FootnotesElementView extends block_view_1.default {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
exports.FootnotesElementView = FootnotesElementView;
|
|
40
|
-
exports.default = (0, creators_1.createNodeOrElementView)(FootnotesElementView, 'div');
|
|
41
|
+
exports.default = (0, creators_1.createNodeOrElementView)(FootnotesElementView, 'div', footnote_1.setTCClasses);
|
|
@@ -17,5 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const creators_1 = require("./creators");
|
|
19
19
|
const editable_block_1 = require("./editable_block");
|
|
20
|
+
const footnote_1 = require("./footnote");
|
|
20
21
|
const footnotes_element_1 = require("./footnotes_element");
|
|
21
|
-
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnotes_element_1.FootnotesElementView), 'div');
|
|
22
|
+
exports.default = (0, creators_1.createNodeOrElementView)((0, editable_block_1.EditableBlock)(footnotes_element_1.FootnotesElementView), 'div', footnote_1.setTCClasses);
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.InlineFootnoteView = void 0;
|
|
19
|
+
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
19
20
|
const base_node_view_1 = require("./base_node_view");
|
|
20
21
|
const creators_1 = require("./creators");
|
|
21
22
|
class InlineFootnoteView extends base_node_view_1.BaseNodeView {
|
|
@@ -26,6 +27,10 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
|
|
|
26
27
|
};
|
|
27
28
|
this.updateContents = () => {
|
|
28
29
|
this.setDomAttrs(this.node, this.dom);
|
|
30
|
+
this.dom.className = [
|
|
31
|
+
'footnote',
|
|
32
|
+
...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
|
|
33
|
+
].join(' ');
|
|
29
34
|
};
|
|
30
35
|
this.initialise = () => {
|
|
31
36
|
this.dom = this.createDOM();
|
package/dist/es/commands.js
CHANGED
|
@@ -23,6 +23,7 @@ import { findWrapping } from 'prosemirror-transform';
|
|
|
23
23
|
import { findChildrenByType, findParentNodeOfType, } from 'prosemirror-utils';
|
|
24
24
|
import { skipCommandTracking } from './keys/list';
|
|
25
25
|
import { isNodeOfType, nearestAncestor } from './lib/helpers';
|
|
26
|
+
import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
|
|
26
27
|
import { findParentNodeWithId, getChildOfType } from './lib/utils';
|
|
27
28
|
import { commentAnnotation } from './plugins/comment_annotation';
|
|
28
29
|
import { highlightKey, SET_COMMENT } from './plugins/highlight';
|
|
@@ -700,10 +701,12 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
|
|
|
700
701
|
const tr = state.tr;
|
|
701
702
|
tr.insert(insertedAt, inlineFootnoteNode);
|
|
702
703
|
let insertionPos;
|
|
703
|
-
const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element);
|
|
704
|
-
if (footnotesElement
|
|
705
|
-
|
|
706
|
-
|
|
704
|
+
const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element).pop();
|
|
705
|
+
if (footnotesElement &&
|
|
706
|
+
!isDeleted(footnotesElement.node) &&
|
|
707
|
+
!isRejectedInsert(footnotesElement.node)) {
|
|
708
|
+
const pos = footnotesElement.pos;
|
|
709
|
+
insertionPos = position + pos + footnotesElement.node.nodeSize + 1;
|
|
707
710
|
tr.insert(insertionPos, footnote);
|
|
708
711
|
}
|
|
709
712
|
else {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import ArrowDownBlue from '@manuscripts/assets/react/ArrowDownBlue';
|
|
2
|
+
import { DeleteIcon } from '@manuscripts/style-guide';
|
|
3
|
+
import { isEqual } from 'lodash';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { affiliationLabel } from '../../lib/authors';
|
|
7
|
+
import { AffiliationForm } from './AffiliationForm';
|
|
8
|
+
const Container = styled.div `
|
|
9
|
+
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
10
|
+
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
11
|
+
background: ${(props) => props.theme.colors.background.primary};
|
|
12
|
+
margin-bottom: 2px;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
`;
|
|
15
|
+
const AffiliationFormContainer = styled.div `
|
|
16
|
+
border: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
17
|
+
border-radius: ${(props) => props.theme.grid.radius.default};
|
|
18
|
+
margin: 6px 12px 12px;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
`;
|
|
21
|
+
const AffiliationLabel = styled.div `
|
|
22
|
+
margin: 0;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
font-size: 0.875rem;
|
|
26
|
+
padding-right: 0.5rem;
|
|
27
|
+
`;
|
|
28
|
+
const DropdownIndicator = styled(ArrowDownBlue) `
|
|
29
|
+
border: 0;
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
margin-right: 0.6em;
|
|
32
|
+
min-width: 20px;
|
|
33
|
+
`;
|
|
34
|
+
const ToggleButton = styled.button `
|
|
35
|
+
flex-grow: 1;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
width: 100%;
|
|
39
|
+
background: transparent;
|
|
40
|
+
border: none;
|
|
41
|
+
text-align: left;
|
|
42
|
+
font-family: ${(props) => props.theme.font.family.sans};
|
|
43
|
+
font-size: 1rem;
|
|
44
|
+
padding: 0.6em 0.5em;
|
|
45
|
+
outline: none;
|
|
46
|
+
|
|
47
|
+
&.open svg {
|
|
48
|
+
transform: rotateX(180deg);
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
const RemoveButton = styled.div `
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
`;
|
|
54
|
+
export const AffiliationButton = ({ affiliation, onSave, onRemove, }) => {
|
|
55
|
+
const [isOpen, setOpen] = useState(false);
|
|
56
|
+
const toggleOpen = () => {
|
|
57
|
+
setOpen((o) => !o);
|
|
58
|
+
};
|
|
59
|
+
const handleSave = (values) => {
|
|
60
|
+
if (isEqual(values, affiliation)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const copy = Object.assign(Object.assign({}, affiliation), values);
|
|
64
|
+
onSave(copy);
|
|
65
|
+
};
|
|
66
|
+
return (React.createElement(Container, null,
|
|
67
|
+
React.createElement(AffiliationLabel, null,
|
|
68
|
+
React.createElement(ToggleButton, { type: "button", className: isOpen ? 'open' : '', onClick: toggleOpen },
|
|
69
|
+
React.createElement(DropdownIndicator, null),
|
|
70
|
+
affiliationLabel(affiliation)),
|
|
71
|
+
React.createElement(RemoveButton, { onClick: onRemove },
|
|
72
|
+
React.createElement(DeleteIcon, null))),
|
|
73
|
+
isOpen && (React.createElement(AffiliationFormContainer, null,
|
|
74
|
+
React.createElement(AffiliationForm, { values: affiliation, onSave: handleSave })))));
|
|
75
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TextField } from '@manuscripts/style-guide';
|
|
2
|
+
import { Field, Formik } from 'formik';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { ChangeHandlingForm } from './ChangeHandlingForm';
|
|
6
|
+
const Row = styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
border-top: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
9
|
+
&:first-child {
|
|
10
|
+
border-top: none;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
const AffiliationsTextField = styled(TextField) `
|
|
14
|
+
border: none;
|
|
15
|
+
border-radius: 0;
|
|
16
|
+
background: transparent;
|
|
17
|
+
&:not(:first-child) {
|
|
18
|
+
border-left: 1px solid ${(props) => props.theme.colors.border.field.default};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&[aria-invalid] {
|
|
22
|
+
background: ${(props) => props.theme.colors.background.warning};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&[aria-invalid]:focus {
|
|
26
|
+
background: transparent;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
export const AffiliationForm = ({ values, onSave, }) => {
|
|
30
|
+
return (React.createElement(Formik, { initialValues: values, onSubmit: onSave }, () => (React.createElement(ChangeHandlingForm, { onChange: onSave },
|
|
31
|
+
React.createElement(Row, null,
|
|
32
|
+
React.createElement(Field, { name: "institution" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "institution", placeholder: "Institution Name" }, props.field))))),
|
|
33
|
+
React.createElement(Row, null,
|
|
34
|
+
React.createElement(Field, { name: "department" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "department", placeholder: "Department" }, props.field))))),
|
|
35
|
+
React.createElement(Row, null,
|
|
36
|
+
React.createElement(Field, { name: "addressLine1" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "addressLine1", placeholder: "Street Address" }, props.field))))),
|
|
37
|
+
React.createElement(Row, null,
|
|
38
|
+
React.createElement(Field, { name: "city" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "city", placeholder: "City" }, props.field)))),
|
|
39
|
+
React.createElement(Field, { name: "county" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "county", placeholder: "State / Province" }, props.field))))),
|
|
40
|
+
React.createElement(Row, null,
|
|
41
|
+
React.createElement(Field, { name: "postCode" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "postCode", placeholder: "Postal Code" }, props.field)))),
|
|
42
|
+
React.createElement(Field, { name: "country" }, (props) => (React.createElement(AffiliationsTextField, Object.assign({ id: "country", placeholder: "Country" }, props.field)))))))));
|
|
43
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ButtonGroup, DeleteIcon, PrimaryButton, SecondaryButton, } from '@manuscripts/style-guide';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { DeleteAuthorConfirmationDialog } from './DeleteAuthorConfirmationDialog';
|
|
5
|
+
const AuthorActionsContainer = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
`;
|
|
8
|
+
const RemoveButton = styled.div `
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
|
|
12
|
+
svg {
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
const StyledButtonGroup = styled(ButtonGroup) `
|
|
17
|
+
flex: 1;
|
|
18
|
+
`;
|
|
19
|
+
export const AuthorActions = ({ author, onSave, onDelete, onCancel, }) => {
|
|
20
|
+
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
|
21
|
+
return (React.createElement(AuthorActionsContainer, null,
|
|
22
|
+
React.createElement(DeleteAuthorConfirmationDialog, { author: author, isOpen: showDeleteDialog, onDelete: () => {
|
|
23
|
+
setShowDeleteDialog(true);
|
|
24
|
+
onDelete();
|
|
25
|
+
}, onCancel: () => setShowDeleteDialog(false) }),
|
|
26
|
+
React.createElement(RemoveButton, { onClick: () => setShowDeleteDialog(true) },
|
|
27
|
+
React.createElement(DeleteIcon, null)),
|
|
28
|
+
React.createElement(StyledButtonGroup, null,
|
|
29
|
+
React.createElement(SecondaryButton, { onClick: onCancel }, "Cancel"),
|
|
30
|
+
React.createElement(PrimaryButton, { onClick: onSave }, "Save"))));
|
|
31
|
+
};
|