@manuscripts/body-editor 1.10.2-LEAN-3530.0 → 1.10.2
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/components/authors/AuthorAffiliations.js +6 -0
- package/dist/cjs/components/authors/AuthorsModal.js +4 -0
- package/dist/cjs/components/views/FigureDropdown.js +1 -1
- package/dist/cjs/configs/editor-plugins.js +2 -2
- package/dist/cjs/configs/editor-views.js +0 -2
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/lib/authors.js +15 -1
- package/dist/cjs/lib/popper.js +13 -0
- package/dist/cjs/plugins/affiliations.js +53 -43
- package/dist/cjs/plugins/selected-suggestion.js +123 -0
- package/dist/cjs/useEditor.js +1 -1
- package/dist/cjs/views/affiliations.js +102 -9
- package/dist/cjs/views/bibliography_element.js +44 -56
- package/dist/cjs/views/citation.js +6 -5
- package/dist/cjs/views/citation_editable.js +2 -10
- package/dist/cjs/views/contributors.js +92 -95
- package/dist/cjs/views/keyword_group.js +0 -10
- package/dist/es/components/authors/AuthorAffiliations.js +6 -0
- package/dist/es/components/authors/AuthorsModal.js +4 -0
- package/dist/es/components/views/FigureDropdown.js +1 -1
- package/dist/es/configs/editor-plugins.js +2 -2
- package/dist/es/configs/editor-views.js +2 -4
- package/dist/es/index.js +1 -1
- package/dist/es/lib/authors.js +13 -0
- package/dist/es/lib/popper.js +13 -0
- package/dist/es/plugins/affiliations.js +53 -43
- package/dist/es/plugins/selected-suggestion.js +120 -0
- package/dist/es/useEditor.js +1 -1
- package/dist/es/views/affiliations.js +102 -9
- package/dist/es/views/bibliography_element.js +45 -57
- package/dist/es/views/citation.js +6 -5
- package/dist/es/views/citation_editable.js +2 -10
- package/dist/es/views/contributors.js +95 -98
- package/dist/es/views/keyword_group.js +0 -10
- package/dist/types/configs/ManuscriptsEditor.d.ts +0 -1
- package/dist/types/configs/editor-plugins.d.ts +2 -21
- package/dist/types/configs/editor-views.d.ts +2 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/authors.d.ts +4 -2
- package/dist/types/lib/popper.d.ts +2 -1
- package/dist/types/plugins/affiliations.d.ts +8 -5
- package/dist/types/plugins/footnotes/index.d.ts +2 -2
- package/dist/types/plugins/selected-suggestion.d.ts +10 -0
- package/dist/types/views/affiliations.d.ts +28 -3
- package/dist/types/views/base_node_view.d.ts +0 -1
- package/dist/types/views/bibliography_element.d.ts +5 -4
- package/dist/types/views/contributors.d.ts +13 -15
- package/dist/types/views/keyword_group.d.ts +0 -2
- package/package.json +1 -1
- package/styles/AdvancedEditor.css +41 -22
- package/dist/cjs/plugins/selected-suggestion-ui.js +0 -132
- package/dist/cjs/views/affiliation.js +0 -76
- package/dist/es/plugins/selected-suggestion-ui.js +0 -129
- package/dist/es/views/affiliation.js +0 -72
- package/dist/types/plugins/selected-suggestion-ui.d.ts +0 -25
- package/dist/types/views/affiliation.d.ts +0 -30
|
@@ -14,22 +14,12 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
17
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
19
|
};
|
|
29
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
21
|
exports.BibliographyElementBlockView = void 0;
|
|
31
22
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
32
|
-
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
33
23
|
const transform_1 = require("@manuscripts/transform");
|
|
34
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
35
25
|
const ReferencesEditor_1 = require("../components/references/ReferencesEditor");
|
|
@@ -38,14 +28,13 @@ const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
|
38
28
|
const view_1 = require("../lib/view");
|
|
39
29
|
const bibliography_1 = require("../plugins/bibliography");
|
|
40
30
|
const comment_annotation_1 = require("../plugins/comment_annotation");
|
|
41
|
-
const
|
|
31
|
+
const selected_suggestion_1 = require("../plugins/selected-suggestion");
|
|
42
32
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
43
33
|
const creators_1 = require("./creators");
|
|
44
34
|
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
45
35
|
class BibliographyElementBlockView extends block_view_1.default {
|
|
46
36
|
constructor() {
|
|
47
37
|
super(...arguments);
|
|
48
|
-
this.clickedElementId = null;
|
|
49
38
|
this.showPopper = (id) => {
|
|
50
39
|
this.props.popper.destroy();
|
|
51
40
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
@@ -70,57 +59,57 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
70
59
|
this.handleComment = (citationId) => {
|
|
71
60
|
this.props.setComment((0, transform_1.buildComment)(citationId));
|
|
72
61
|
};
|
|
73
|
-
this.showContextMenu = (
|
|
62
|
+
this.showContextMenu = (element) => {
|
|
74
63
|
this.props.popper.destroy();
|
|
75
|
-
this.clickedElementId = null;
|
|
76
64
|
const can = this.props.getCapabilities();
|
|
77
|
-
const element = document.getElementById(elementId);
|
|
78
65
|
const componentProps = {
|
|
79
66
|
actions: [],
|
|
80
67
|
};
|
|
81
68
|
if (can.editCitationsAndRefs) {
|
|
82
69
|
componentProps.actions.push({
|
|
83
70
|
label: 'Edit',
|
|
84
|
-
action: () => this.handleEdit(
|
|
71
|
+
action: () => this.handleEdit(element.id),
|
|
85
72
|
icon: 'EditIcon',
|
|
86
73
|
});
|
|
87
74
|
}
|
|
88
75
|
componentProps.actions.push({
|
|
89
76
|
label: 'Comment',
|
|
90
|
-
action: () => this.handleComment(
|
|
77
|
+
action: () => this.handleComment(element.id),
|
|
91
78
|
icon: 'AddComment',
|
|
92
79
|
});
|
|
93
80
|
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
94
81
|
this.props.popper.show(element, this.contextMenu, 'right-start');
|
|
95
82
|
};
|
|
96
|
-
this.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
if (isSelectedSuggestion) {
|
|
108
|
-
tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
this.showContextMenu(elementId);
|
|
83
|
+
this.handleClick = (event) => {
|
|
84
|
+
this.props.popper.destroy();
|
|
85
|
+
const element = event.target;
|
|
86
|
+
const item = element.closest('.bib-item');
|
|
87
|
+
if (item) {
|
|
88
|
+
this.showContextMenu(item);
|
|
89
|
+
const node = (0, view_1.findChildByID)(this.view, item.id);
|
|
90
|
+
if (!node) {
|
|
91
|
+
return;
|
|
112
92
|
}
|
|
93
|
+
const view = this.view;
|
|
94
|
+
const tr = view.state.tr;
|
|
95
|
+
tr.setSelection(prosemirror_state_1.NodeSelection.create(view.state.doc, node.pos));
|
|
96
|
+
view.dispatch(tr);
|
|
113
97
|
}
|
|
114
|
-
this.view.dispatch(tr);
|
|
115
98
|
};
|
|
116
|
-
this.updateContents = () =>
|
|
99
|
+
this.updateContents = () => {
|
|
117
100
|
this.props.popper.destroy();
|
|
118
101
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
102
|
+
if (!bib) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (bib.version === this.version) {
|
|
106
|
+
this.updateSelection();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.version = bib.version;
|
|
119
110
|
const commentsDecorationSet = comment_annotation_1.commentAnnotation.getState(this.view.state);
|
|
120
|
-
const selectedSuggestion = selected_suggestion_ui_1.selectedSuggestionKey.getState(this.view.state);
|
|
121
111
|
const commentElementMap = new Map();
|
|
122
112
|
const dataTrackedMap = new Map();
|
|
123
|
-
let selectedBibItemSuggestion;
|
|
124
113
|
this.node.descendants((node, pos) => {
|
|
125
114
|
const nodePosition = this.getPos() + pos + 2;
|
|
126
115
|
if (commentsDecorationSet) {
|
|
@@ -135,20 +124,16 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
135
124
|
const lastChange = dataTracked[dataTracked.length - 1];
|
|
136
125
|
dataTrackedMap.set(node.attrs.id, lastChange);
|
|
137
126
|
}
|
|
138
|
-
if ((dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) &&
|
|
139
|
-
(selectedSuggestion === null || selectedSuggestion === void 0 ? void 0 : selectedSuggestion.find(nodePosition, nodePosition + node.nodeSize).length)) {
|
|
140
|
-
selectedBibItemSuggestion = node.attrs.id;
|
|
141
|
-
}
|
|
142
127
|
});
|
|
143
128
|
const can = this.props.getCapabilities();
|
|
144
129
|
const wrapper = document.createElement('div');
|
|
145
130
|
wrapper.classList.add('contents');
|
|
146
|
-
if (
|
|
147
|
-
|
|
131
|
+
if (can.seeReferencesButtons) {
|
|
132
|
+
wrapper.addEventListener('click', this.handleClick);
|
|
148
133
|
}
|
|
149
134
|
const [meta, bibliography] = bib.provider.makeBibliography();
|
|
150
135
|
for (let i = 0; i < bibliography.length; i++) {
|
|
151
|
-
const id = meta.entry_ids[i];
|
|
136
|
+
const id = meta.entry_ids[i][0];
|
|
152
137
|
const fragment = bibliography[i];
|
|
153
138
|
const element = (0, dompurify_1.sanitize)(`<div id="${id}" class="bib-item"><div class="csl-bib-body">${fragment}</div></div>`).firstElementChild;
|
|
154
139
|
const commentElement = commentElementMap.get(element.id);
|
|
@@ -157,14 +142,8 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
157
142
|
}
|
|
158
143
|
const dataTracked = dataTrackedMap.get(element.id);
|
|
159
144
|
if (dataTracked) {
|
|
160
|
-
element.classList.add(
|
|
161
|
-
|
|
162
|
-
if (selectedBibItemSuggestion &&
|
|
163
|
-
selectedBibItemSuggestion === element.id) {
|
|
164
|
-
element.classList.add('selected-suggestion');
|
|
165
|
-
}
|
|
166
|
-
if (can.seeReferencesButtons) {
|
|
167
|
-
element.addEventListener('click', () => this.onClickHandler(element.id, dataTracked));
|
|
145
|
+
element.classList.add(...(0, track_changes_utils_1.getChangeClasses)([dataTracked]));
|
|
146
|
+
element.dataset.trackId = dataTracked.id;
|
|
168
147
|
}
|
|
169
148
|
wrapper.append(element);
|
|
170
149
|
}
|
|
@@ -175,10 +154,8 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
175
154
|
else {
|
|
176
155
|
this.container.appendChild(wrapper);
|
|
177
156
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
});
|
|
157
|
+
this.updateSelection();
|
|
158
|
+
};
|
|
182
159
|
this.createElement = () => {
|
|
183
160
|
this.container = document.createElement('div');
|
|
184
161
|
this.container.classList.add('block');
|
|
@@ -192,6 +169,17 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
192
169
|
this.handleDelete = (item) => {
|
|
193
170
|
(0, view_1.deleteNode)(this.view, item.id);
|
|
194
171
|
};
|
|
172
|
+
this.updateSelection = () => {
|
|
173
|
+
var _a;
|
|
174
|
+
const selection = (_a = selected_suggestion_1.selectedSuggestionKey.getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.suggestion;
|
|
175
|
+
this.container
|
|
176
|
+
.querySelectorAll('.bib-item')
|
|
177
|
+
.forEach((e) => e.classList.remove('selected-suggestion'));
|
|
178
|
+
if (selection) {
|
|
179
|
+
const item = this.container.querySelector(`[data-track-id="${selection.id}"]`);
|
|
180
|
+
item === null || item === void 0 ? void 0 : item.classList.add('selected-suggestion');
|
|
181
|
+
}
|
|
182
|
+
};
|
|
195
183
|
}
|
|
196
184
|
}
|
|
197
185
|
exports.BibliographyElementBlockView = BibliographyElementBlockView;
|
|
@@ -39,16 +39,17 @@ class CitationView extends base_node_view_1.BaseNodeView {
|
|
|
39
39
|
return this;
|
|
40
40
|
};
|
|
41
41
|
this.updateContents = () => {
|
|
42
|
+
var _a;
|
|
42
43
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
43
44
|
if (!bib) {
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
|
-
const classes = [
|
|
47
|
-
'citation',
|
|
48
|
-
...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
|
|
49
|
-
];
|
|
50
47
|
const element = document.createElement('span');
|
|
51
|
-
element.
|
|
48
|
+
element.classList.add('citation');
|
|
49
|
+
if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
|
|
50
|
+
element.classList.add(...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked));
|
|
51
|
+
element.dataset.trackId = this.node.attrs.dataTracked[0].id;
|
|
52
|
+
}
|
|
52
53
|
const text = bib.renderedCitations.get(this.node.attrs.id);
|
|
53
54
|
const fragment = (0, dompurify_1.sanitize)(text && text !== '[NO_PRINTED_FORM]' ? text : ' ', {
|
|
54
55
|
ALLOWED_TAGS: ['i', 'b', 'span', 'sup', 'sub', '#text'],
|
|
@@ -29,7 +29,6 @@ const crossref_1 = require("../lib/crossref");
|
|
|
29
29
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
30
30
|
const view_1 = require("../lib/view");
|
|
31
31
|
const bibliography_1 = require("../plugins/bibliography");
|
|
32
|
-
const selected_suggestion_ui_1 = require("../plugins/selected-suggestion-ui");
|
|
33
32
|
const citation_1 = require("./citation");
|
|
34
33
|
const creators_1 = require("./creators");
|
|
35
34
|
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
@@ -48,16 +47,9 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
48
47
|
((_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.classList.contains('comment-icon')));
|
|
49
48
|
};
|
|
50
49
|
this.selectNode = () => {
|
|
51
|
-
var _a;
|
|
52
|
-
const can = this.props.getCapabilities();
|
|
53
|
-
const dataTracked = this.node.attrs.dataTracked;
|
|
54
|
-
const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
|
|
55
|
-
.getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
|
|
56
50
|
this.dom.classList.add('ProseMirror-selectednode');
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
else if (can.seeReferencesButtons && !(0, track_changes_utils_1.isDeleted)(this.node)) {
|
|
51
|
+
const can = this.props.getCapabilities();
|
|
52
|
+
if (can.seeReferencesButtons && !(0, track_changes_utils_1.isDeleted)(this.node)) {
|
|
61
53
|
const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
|
|
62
54
|
if (!attrs.rids.length) {
|
|
63
55
|
this.showPopper();
|
|
@@ -20,7 +20,6 @@ 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
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
26
25
|
const AuthorsModal_1 = require("../components/authors/AuthorsModal");
|
|
@@ -28,13 +27,15 @@ const authors_1 = require("../lib/authors");
|
|
|
28
27
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
29
28
|
const view_1 = require("../lib/view");
|
|
30
29
|
const affiliations_1 = require("../plugins/affiliations");
|
|
31
|
-
const
|
|
30
|
+
const selected_suggestion_1 = require("../plugins/selected-suggestion");
|
|
32
31
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
33
32
|
const creators_1 = require("./creators");
|
|
34
33
|
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
35
34
|
class ContributorsView extends block_view_1.default {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
37
|
+
this.ignoreMutation = () => true;
|
|
38
|
+
this.stopEvent = () => true;
|
|
38
39
|
this.initialise = () => {
|
|
39
40
|
this.createDOM();
|
|
40
41
|
this.createGutter('block-gutter', this.gutterButtons().filter(Boolean));
|
|
@@ -43,80 +44,71 @@ class ContributorsView extends block_view_1.default {
|
|
|
43
44
|
this.updateContents();
|
|
44
45
|
};
|
|
45
46
|
this.updateContents = () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
}
|
|
47
|
+
const affs = affiliations_1.affiliationsKey.getState(this.view.state);
|
|
48
|
+
if (!affs) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (affs.version === this.version) {
|
|
52
|
+
this.updateSelection();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.version = affs.version;
|
|
56
|
+
this.container.innerHTML = '';
|
|
57
|
+
this.buildAuthors(affs);
|
|
58
|
+
this.createEditButton();
|
|
59
|
+
this.createLegend();
|
|
60
|
+
this.updateSelection();
|
|
54
61
|
};
|
|
55
|
-
this.buildAuthors = () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (selectedSuggestion === null || selectedSuggestion === void 0 ? void 0 : selectedSuggestion.find(this.getPos() + offset + 2, this.getPos() + offset + node.nodeSize + 2).length) {
|
|
66
|
-
selectedAuthor = node.attrs.id;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
authors
|
|
71
|
-
.sort((a, b) => Number(a.attrs.priority) - Number(b.attrs.priority))
|
|
72
|
-
.forEach((author, i) => {
|
|
73
|
-
if ((0, track_changes_utils_1.getActualAttrs)(author).role !== 'author') {
|
|
62
|
+
this.buildAuthors = (affs) => {
|
|
63
|
+
const wrapper = document.createElement('div');
|
|
64
|
+
wrapper.classList.add('contributors-list');
|
|
65
|
+
const can = this.props.getCapabilities();
|
|
66
|
+
if (can.editMetadata) {
|
|
67
|
+
wrapper.addEventListener('click', this.handleClick);
|
|
68
|
+
}
|
|
69
|
+
const authors = affs.contributors;
|
|
70
|
+
authors.sort(authors_1.authorComparator).forEach((author, i) => {
|
|
71
|
+
if (author.role !== 'author') {
|
|
74
72
|
return;
|
|
75
73
|
}
|
|
76
74
|
const jointAuthors = this.isJointFirstAuthor(authors, i);
|
|
77
|
-
|
|
75
|
+
wrapper.appendChild(this.buildAuthor(author, jointAuthors));
|
|
76
|
+
if (i !== authors.length - 1) {
|
|
77
|
+
const separator = document.createElement('span');
|
|
78
|
+
separator.classList.add('separator');
|
|
79
|
+
separator.innerHTML = ',';
|
|
80
|
+
wrapper.appendChild(separator);
|
|
81
|
+
}
|
|
78
82
|
});
|
|
79
|
-
this.container.appendChild(
|
|
83
|
+
this.container.appendChild(wrapper);
|
|
80
84
|
};
|
|
81
|
-
this.buildAuthor = (
|
|
82
|
-
var _a;
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
const container = document.createElement('button');
|
|
88
|
-
containerWrapper.classList.add('contributor-wrapper');
|
|
85
|
+
this.buildAuthor = (attrs, isJointFirstAuthor) => {
|
|
86
|
+
var _a, _b, _c;
|
|
87
|
+
const state = this.view.state;
|
|
88
|
+
const affs = (_a = affiliations_1.affiliationsKey.getState(state)) === null || _a === void 0 ? void 0 : _a.indexedAffiliationIds;
|
|
89
|
+
const suggestion = (_b = selected_suggestion_1.selectedSuggestionKey.getState(state)) === null || _b === void 0 ? void 0 : _b.suggestion;
|
|
90
|
+
const container = document.createElement('span');
|
|
89
91
|
container.classList.add('contributor');
|
|
90
92
|
container.setAttribute('id', attrs.id);
|
|
91
93
|
container.setAttribute('contenteditable', 'false');
|
|
92
|
-
if ((
|
|
93
|
-
|
|
94
|
-
container.setAttribute('data-track-
|
|
95
|
-
container.setAttribute('data-track-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
container.removeAttribute('data-track-type');
|
|
101
|
-
}
|
|
102
|
-
const can = this.props.getCapabilities();
|
|
103
|
-
const disableEditButton = !can.editMetadata;
|
|
104
|
-
const { isCorresponding, email, id } = displayAttr;
|
|
105
|
-
if (!disableEditButton) {
|
|
106
|
-
container.addEventListener('click', () => {
|
|
107
|
-
const dataTracked = attrs.dataTracked;
|
|
108
|
-
this.onClickHandler(id, dataTracked ? dataTracked[0] : undefined);
|
|
109
|
-
});
|
|
94
|
+
if ((_c = attrs.dataTracked) === null || _c === void 0 ? void 0 : _c.length) {
|
|
95
|
+
const change = attrs.dataTracked[0];
|
|
96
|
+
container.setAttribute('data-track-id', change.id);
|
|
97
|
+
container.setAttribute('data-track-status', change.status);
|
|
98
|
+
container.setAttribute('data-track-op', change.operation);
|
|
99
|
+
if ((suggestion === null || suggestion === void 0 ? void 0 : suggestion.id) === change.id) {
|
|
100
|
+
container.classList.add('selected-suggestion');
|
|
101
|
+
}
|
|
110
102
|
}
|
|
111
|
-
const name = (0, authors_1.authorLabel)(
|
|
103
|
+
const name = (0, authors_1.authorLabel)(attrs);
|
|
112
104
|
container.innerHTML =
|
|
113
|
-
isCorresponding && email
|
|
114
|
-
? `<span class="name">${name} (${email})</span>`
|
|
105
|
+
attrs.isCorresponding && attrs.email
|
|
106
|
+
? `<span class="name">${name} (${attrs.email})</span>`
|
|
115
107
|
: `<span class="name">${name}</span>`;
|
|
116
108
|
const noteText = [];
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
const index =
|
|
109
|
+
if (affs) {
|
|
110
|
+
attrs.affiliations.map((a) => {
|
|
111
|
+
const index = affs.get(a);
|
|
120
112
|
if (index) {
|
|
121
113
|
noteText.push(index.toString());
|
|
122
114
|
}
|
|
@@ -128,18 +120,14 @@ class ContributorsView extends block_view_1.default {
|
|
|
128
120
|
if (noteText) {
|
|
129
121
|
container.appendChild(this.createNote(noteText.join(',')));
|
|
130
122
|
}
|
|
131
|
-
if (
|
|
123
|
+
if (attrs.isCorresponding) {
|
|
132
124
|
container.appendChild(this.createNote('*', 'Corresponding author'));
|
|
133
125
|
}
|
|
134
|
-
|
|
135
|
-
container.classList.add('selected-suggestion');
|
|
136
|
-
}
|
|
137
|
-
containerWrapper.appendChild(container);
|
|
138
|
-
return containerWrapper;
|
|
126
|
+
return container;
|
|
139
127
|
};
|
|
140
128
|
this.isJointFirstAuthor = (authors, index) => {
|
|
141
129
|
const author = index === 0 ? authors[index] : authors[index - 1];
|
|
142
|
-
return Boolean(author.
|
|
130
|
+
return Boolean(author.isJointContributor);
|
|
143
131
|
};
|
|
144
132
|
this.createElement = () => {
|
|
145
133
|
this.inner = document.createElement('div');
|
|
@@ -167,7 +155,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
167
155
|
this.createLegend = () => {
|
|
168
156
|
const state = affiliations_1.affiliationsKey.getState(this.view.state);
|
|
169
157
|
if (state === null || state === void 0 ? void 0 : state.contributors) {
|
|
170
|
-
const isThereJointContributor = state.contributors.find((
|
|
158
|
+
const isThereJointContributor = state.contributors.find((attrs) => attrs.isJointContributor);
|
|
171
159
|
if (isThereJointContributor) {
|
|
172
160
|
const element = document.createElement('p');
|
|
173
161
|
element.classList.add('contributors-legend');
|
|
@@ -177,35 +165,44 @@ class ContributorsView extends block_view_1.default {
|
|
|
177
165
|
}
|
|
178
166
|
}
|
|
179
167
|
};
|
|
180
|
-
this.
|
|
181
|
-
var _a;
|
|
168
|
+
this.handleClick = (event) => {
|
|
182
169
|
this.props.popper.destroy();
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (dataTracked && dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
|
|
188
|
-
tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id);
|
|
170
|
+
const element = event.target;
|
|
171
|
+
const author = element.closest('.contributor');
|
|
172
|
+
if (!author) {
|
|
173
|
+
return;
|
|
189
174
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
175
|
+
const { node, pos } = (0, view_1.findChildByID)(this.view, author.id) || {};
|
|
176
|
+
if (!node || !pos) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (!(0, track_changes_utils_1.isDeleted)(node)) {
|
|
180
|
+
this.showContextMenu(author);
|
|
194
181
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
182
|
+
const view = this.view;
|
|
183
|
+
const tr = view.state.tr;
|
|
184
|
+
tr.setSelection(prosemirror_state_1.NodeSelection.create(view.state.doc, pos));
|
|
185
|
+
view.dispatch(tr);
|
|
186
|
+
};
|
|
187
|
+
this.updateSelection = () => {
|
|
188
|
+
var _a;
|
|
189
|
+
const state = this.view.state;
|
|
190
|
+
const selection = (_a = selected_suggestion_1.selectedSuggestionKey.getState(state)) === null || _a === void 0 ? void 0 : _a.suggestion;
|
|
191
|
+
this.container
|
|
192
|
+
.querySelectorAll('.selected-suggestion')
|
|
193
|
+
.forEach((e) => e.classList.remove('selected-suggestion'));
|
|
194
|
+
if (selection) {
|
|
195
|
+
const item = this.container.querySelector(`[data-track-id="${selection.id}"]`);
|
|
196
|
+
item === null || item === void 0 ? void 0 : item.classList.add('selected-suggestion');
|
|
198
197
|
}
|
|
199
|
-
this.view.dispatch(tr);
|
|
200
198
|
};
|
|
201
|
-
this.showContextMenu = (
|
|
199
|
+
this.showContextMenu = (element) => {
|
|
202
200
|
this.props.popper.destroy();
|
|
203
|
-
const element = document.getElementById(elementId);
|
|
204
201
|
const componentProps = {
|
|
205
202
|
actions: [
|
|
206
203
|
{
|
|
207
204
|
label: 'Edit',
|
|
208
|
-
action: () => this.handleEdit(
|
|
205
|
+
action: () => this.handleEdit(element.id),
|
|
209
206
|
icon: 'EditIcon',
|
|
210
207
|
},
|
|
211
208
|
],
|
|
@@ -262,13 +259,13 @@ class ContributorsView extends block_view_1.default {
|
|
|
262
259
|
};
|
|
263
260
|
}
|
|
264
261
|
createNote(text = '', title = '') {
|
|
265
|
-
const
|
|
266
|
-
|
|
262
|
+
const note = document.createElement('span');
|
|
263
|
+
note.innerHTML = text;
|
|
267
264
|
if (title) {
|
|
268
|
-
|
|
265
|
+
note.setAttribute('title', title);
|
|
269
266
|
}
|
|
270
|
-
|
|
271
|
-
return
|
|
267
|
+
note.classList.add('contributor-note');
|
|
268
|
+
return note;
|
|
272
269
|
}
|
|
273
270
|
}
|
|
274
271
|
exports.ContributorsView = ContributorsView;
|
|
@@ -19,7 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.KeywordGroupView = void 0;
|
|
22
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
23
22
|
const AddKeywordInline_1 = require("../components/keywords/AddKeywordInline");
|
|
24
23
|
const block_view_1 = __importDefault(require("./block_view"));
|
|
25
24
|
const creators_1 = require("./creators");
|
|
@@ -45,15 +44,6 @@ class KeywordGroupView extends block_view_1.default {
|
|
|
45
44
|
this.element.appendChild(this.addingTools);
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
|
-
this.updateContents = () => {
|
|
49
|
-
this.dom.addEventListener('click', (event) => this.onClickHandler(event));
|
|
50
|
-
};
|
|
51
|
-
this.onClickHandler = (event) => {
|
|
52
|
-
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
53
|
-
const { tr, doc } = this.view.state;
|
|
54
|
-
tr.setSelection(prosemirror_state_1.NodeSelection.create(doc, this.getPos()));
|
|
55
|
-
this.view.dispatch(tr);
|
|
56
|
-
};
|
|
57
47
|
}
|
|
58
48
|
}
|
|
59
49
|
exports.KeywordGroupView = KeywordGroupView;
|
|
@@ -62,10 +62,16 @@ export const AuthorAffiliations = ({ author, affiliations, onSave, onAdd, onRemo
|
|
|
62
62
|
const affiliation = {
|
|
63
63
|
id: generateID(ObjectTypes.Affiliation),
|
|
64
64
|
addressLine1: '',
|
|
65
|
+
addressLine2: '',
|
|
66
|
+
addressLine3: '',
|
|
65
67
|
city: '',
|
|
66
68
|
country: '',
|
|
67
69
|
county: '',
|
|
68
70
|
department: '',
|
|
71
|
+
email: {
|
|
72
|
+
href: '',
|
|
73
|
+
text: '',
|
|
74
|
+
},
|
|
69
75
|
institution: institution,
|
|
70
76
|
postCode: '',
|
|
71
77
|
priority: 0,
|
|
@@ -62,6 +62,8 @@ const normalize = (author) => ({
|
|
|
62
62
|
ORCIDIdentifier: author.ORCIDIdentifier || '',
|
|
63
63
|
priority: author.priority,
|
|
64
64
|
isJointContributor: author.isJointContributor || false,
|
|
65
|
+
userID: '',
|
|
66
|
+
invitationID: '',
|
|
65
67
|
});
|
|
66
68
|
export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, author, onSaveAuthor, onDeleteAuthor, onSaveAffiliation, }) => {
|
|
67
69
|
const [isOpen, setOpen] = useState(true);
|
|
@@ -129,6 +131,8 @@ export const AuthorsModal = ({ authors: $authors, affiliations: $affiliations, a
|
|
|
129
131
|
ORCIDIdentifier: '',
|
|
130
132
|
priority: authors.length,
|
|
131
133
|
isJointContributor: false,
|
|
134
|
+
userID: '',
|
|
135
|
+
invitationID: '',
|
|
132
136
|
};
|
|
133
137
|
onSaveAuthor(author);
|
|
134
138
|
setSelection(author);
|
|
@@ -30,7 +30,7 @@ export const FigureOptions = ({ can, files, getFilesMap, handleDownload, handleU
|
|
|
30
30
|
return (React.createElement(DropdownWrapper, { ref: wrapperRef },
|
|
31
31
|
React.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
|
|
32
32
|
React.createElement(DotsIcon, null)),
|
|
33
|
-
isOpen && (React.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
|
|
33
|
+
isOpen && (React.createElement(OptionsDropdownList, { direction: 'right', width: 128, onClick: toggleOpen, top: 5 },
|
|
34
34
|
React.createElement(ListItemButton, { onClick: handleDownload, disabled: !showDownload }, "Download"),
|
|
35
35
|
React.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: 'Replace', moveLeft: true, list: React.createElement(React.Fragment, null,
|
|
36
36
|
otherFiles.map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => handleReplace && handleReplace(file) },
|
|
@@ -32,7 +32,7 @@ import paragraphs from '../plugins/paragraphs';
|
|
|
32
32
|
import persist from '../plugins/persist';
|
|
33
33
|
import placeholder from '../plugins/placeholder';
|
|
34
34
|
import sections from '../plugins/sections';
|
|
35
|
-
import
|
|
35
|
+
import selected_suggestion from '../plugins/selected-suggestion';
|
|
36
36
|
import table_footnote from '../plugins/table-footnote';
|
|
37
37
|
import table_editing_fix from '../plugins/tables-cursor-fix';
|
|
38
38
|
import toc from '../plugins/toc';
|
|
@@ -63,9 +63,9 @@ export default (props) => {
|
|
|
63
63
|
placeholder(),
|
|
64
64
|
tableEditing(),
|
|
65
65
|
highlights(props),
|
|
66
|
-
selected_suggestion_ui(props),
|
|
67
66
|
footnotes(props),
|
|
68
67
|
table_footnote(),
|
|
68
|
+
selected_suggestion(),
|
|
69
69
|
];
|
|
70
70
|
if (props.collabProvider) {
|
|
71
71
|
allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
17
|
-
import affiliationsSection from '../views/affiliations';
|
|
16
|
+
import affiliations from '../views/affiliations';
|
|
18
17
|
import bibliographyElement from '../views/bibliography_element_editable';
|
|
19
18
|
import blockquoteElement from '../views/blockquote_element_editable';
|
|
20
19
|
import bulletList from '../views/bullet_list_editable';
|
|
@@ -55,8 +54,7 @@ export default (props, dispatch) => {
|
|
|
55
54
|
citation: citation(props, dispatch),
|
|
56
55
|
cross_reference: crossReference(props, dispatch),
|
|
57
56
|
contributors: contributors(props, dispatch),
|
|
58
|
-
affiliations:
|
|
59
|
-
affiliation: affiliation(props, dispatch),
|
|
57
|
+
affiliations: affiliations(props, dispatch),
|
|
60
58
|
equation: equation(props),
|
|
61
59
|
equation_element: equationElement(props),
|
|
62
60
|
figure: figure(props, dispatch),
|
package/dist/es/index.js
CHANGED
|
@@ -21,9 +21,9 @@ export * from './menus';
|
|
|
21
21
|
export { CollabProvider } from './classes/collabProvider';
|
|
22
22
|
export { PopperManager } from './lib/popper';
|
|
23
23
|
export * from './toolbar';
|
|
24
|
+
export { selectedSuggestionKey } from './plugins/selected-suggestion';
|
|
24
25
|
export * from './plugins/highlight';
|
|
25
26
|
export { commentScroll, isThereSelector, isHighlightComment, } from './plugins/comment_annotation';
|
|
26
|
-
export { SET_SUGGESTION_ID } from './plugins/selected-suggestion-ui';
|
|
27
27
|
export * from './lib/utils';
|
|
28
28
|
export * from './lib/track-changes-utils';
|
|
29
29
|
export * from './useEditor';
|