@manuscripts/body-editor 1.7.32-LEAN-2746-3 → 1.7.33
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/assets.js +1 -47
- package/dist/cjs/commands.js +9 -22
- package/dist/cjs/configs/editor-plugins.js +1 -1
- package/dist/cjs/lib/context-menu.js +5 -14
- package/dist/cjs/plugins/footnotes/index.js +1 -64
- package/dist/cjs/views/affiliations.js +0 -9
- package/dist/cjs/views/bibliography_element.js +2 -7
- package/dist/cjs/views/citation_editable.js +0 -1
- package/dist/cjs/views/contributors.js +22 -61
- package/dist/cjs/views/inline_footnote.js +1 -71
- package/dist/cjs/views/keyword_group.js +0 -10
- package/dist/es/assets.js +0 -46
- package/dist/es/commands.js +9 -22
- package/dist/es/configs/editor-plugins.js +1 -1
- package/dist/es/lib/context-menu.js +5 -14
- package/dist/es/plugins/footnotes/index.js +3 -63
- package/dist/es/views/affiliations.js +0 -9
- package/dist/es/views/bibliography_element.js +2 -7
- package/dist/es/views/citation_editable.js +0 -1
- package/dist/es/views/contributors.js +24 -63
- package/dist/es/views/inline_footnote.js +2 -69
- package/dist/es/views/keyword_group.js +0 -10
- package/dist/types/assets.d.ts +0 -1
- package/dist/types/commands.d.ts +2 -7
- package/dist/types/configs/editor-plugins.d.ts +1 -1
- package/dist/types/plugins/footnotes/index.d.ts +1 -2
- package/dist/types/views/affiliations.d.ts +0 -2
- package/dist/types/views/contributors.d.ts +4 -5
- package/dist/types/views/inline_footnote.d.ts +2 -11
- package/dist/types/views/keyword_group.d.ts +0 -2
- package/package.json +4 -4
- package/styles/AdvancedEditor.css +27 -33
- package/styles/Editor.css +3 -31
- package/dist/cjs/components/views/DeleteFootnoteDialog.js +0 -45
- package/dist/es/components/views/DeleteFootnoteDialog.js +0 -18
- package/dist/types/components/views/DeleteFootnoteDialog.d.ts +0 -7
package/dist/cjs/assets.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
18
|
+
exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
|
|
19
19
|
exports.editIcon = `
|
|
20
20
|
<svg
|
|
21
21
|
width="14"
|
|
@@ -118,49 +118,3 @@ exports.alertIcon = `
|
|
|
118
118
|
/>
|
|
119
119
|
</svg>
|
|
120
120
|
`;
|
|
121
|
-
exports.deleteIcon = `
|
|
122
|
-
<svg
|
|
123
|
-
width="13"
|
|
124
|
-
height="15"
|
|
125
|
-
viewBox="0 0 13 15"
|
|
126
|
-
fill="none"
|
|
127
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
128
|
-
>
|
|
129
|
-
<path
|
|
130
|
-
fill-rule="evenodd"
|
|
131
|
-
clip-rule="evenodd"
|
|
132
|
-
d="M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z"
|
|
133
|
-
fill="#C9C9C9"
|
|
134
|
-
/>
|
|
135
|
-
<path
|
|
136
|
-
fill-rule="evenodd"
|
|
137
|
-
clip-rule="evenodd"
|
|
138
|
-
d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z"
|
|
139
|
-
fill="#C9C9C9"
|
|
140
|
-
/>
|
|
141
|
-
<rect
|
|
142
|
-
y="2"
|
|
143
|
-
width="13"
|
|
144
|
-
height="3"
|
|
145
|
-
rx="1.5"
|
|
146
|
-
fill="#C9C9C9"
|
|
147
|
-
/>
|
|
148
|
-
<path
|
|
149
|
-
fill-rule="evenodd"
|
|
150
|
-
clip-rule="evenodd"
|
|
151
|
-
d="M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z"
|
|
152
|
-
fill="#C9C9C9"
|
|
153
|
-
/>
|
|
154
|
-
<path
|
|
155
|
-
fill-rule="evenodd"
|
|
156
|
-
clip-rule="evenodd"
|
|
157
|
-
d="M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z"
|
|
158
|
-
fill="#C9C9C9"
|
|
159
|
-
/>
|
|
160
|
-
<path
|
|
161
|
-
fill-rule="evenodd"
|
|
162
|
-
clip-rule="evenodd"
|
|
163
|
-
d="M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z"
|
|
164
|
-
fill="white"
|
|
165
|
-
/>
|
|
166
|
-
</svg>`;
|
package/dist/cjs/commands.js
CHANGED
|
@@ -727,35 +727,22 @@ const updateCommentAnnotationState = (state, dispatch) => {
|
|
|
727
727
|
}
|
|
728
728
|
};
|
|
729
729
|
exports.updateCommentAnnotationState = updateCommentAnnotationState;
|
|
730
|
-
const insertTableFootnote = (node, position, view
|
|
730
|
+
const insertTableFootnote = (node, position, view) => {
|
|
731
731
|
var _a;
|
|
732
732
|
const { state, dispatch } = view;
|
|
733
|
-
const tr = state.tr;
|
|
734
733
|
const footnote = state.schema.nodes.footnote.createAndFill({
|
|
735
734
|
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Footnote),
|
|
736
735
|
kind: 'footnote',
|
|
737
736
|
});
|
|
738
737
|
const insertedAt = state.selection.to;
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
}
|
|
748
|
-
else {
|
|
749
|
-
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
|
|
750
|
-
footnoteIndex =
|
|
751
|
-
inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
|
|
752
|
-
1;
|
|
753
|
-
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
754
|
-
rids: [footnote.attrs.id],
|
|
755
|
-
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
756
|
-
});
|
|
757
|
-
tr.insert(insertedAt, inlineFootnoteNode);
|
|
758
|
-
}
|
|
738
|
+
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
|
|
739
|
+
const footnoteIndex = inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length + 1;
|
|
740
|
+
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
741
|
+
rids: [footnote.attrs.id],
|
|
742
|
+
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
743
|
+
});
|
|
744
|
+
const tr = state.tr;
|
|
745
|
+
tr.insert(insertedAt, inlineFootnoteNode);
|
|
759
746
|
let insertionPos = position;
|
|
760
747
|
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element).pop();
|
|
761
748
|
if (footnotesElement &&
|
|
@@ -69,7 +69,7 @@ exports.default = (props) => {
|
|
|
69
69
|
(0, prosemirror_tables_1.tableEditing)(),
|
|
70
70
|
(0, highlight_1.default)(props),
|
|
71
71
|
(0, selected_suggestion_ui_1.default)(props),
|
|
72
|
-
(0, footnotes_1.default)(
|
|
72
|
+
(0, footnotes_1.default)(),
|
|
73
73
|
(0, table_footnote_1.default)(),
|
|
74
74
|
];
|
|
75
75
|
if (props.collabProvider) {
|
|
@@ -142,7 +142,7 @@ class ContextMenu {
|
|
|
142
142
|
this.addPopperEventListeners();
|
|
143
143
|
};
|
|
144
144
|
this.showEditMenu = (target) => {
|
|
145
|
-
var _a
|
|
145
|
+
var _a;
|
|
146
146
|
const menu = document.createElement('div');
|
|
147
147
|
menu.className = 'menu';
|
|
148
148
|
const $pos = this.resolvePos();
|
|
@@ -176,17 +176,9 @@ class ContextMenu {
|
|
|
176
176
|
if (type === transform_1.schema.nodes.table_element) {
|
|
177
177
|
const isInTable = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table)(this.view.state.selection);
|
|
178
178
|
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
|
|
179
|
-
let isDeletedOrRejected = false;
|
|
180
179
|
const hasGeneralNote = tableElementFooter.length &&
|
|
181
180
|
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.paragraph;
|
|
182
|
-
if (hasGeneralNote) {
|
|
183
|
-
const generalFootnote = (_b = tableElementFooter[0]) === null || _b === void 0 ? void 0 : _b.node.firstChild;
|
|
184
|
-
if (generalFootnote) {
|
|
185
|
-
isDeletedOrRejected =
|
|
186
|
-
(0, track_changes_utils_1.isDeleted)(generalFootnote) || (0, track_changes_utils_1.isRejectedInsert)(generalFootnote);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (!hasGeneralNote || isDeletedOrRejected) {
|
|
181
|
+
if (!hasGeneralNote) {
|
|
190
182
|
menu.appendChild(this.createMenuSection((section) => {
|
|
191
183
|
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
192
184
|
(0, commands_1.insertGeneralFootnote)(this.node, this.getPos(), this.view, tableElementFooter);
|
|
@@ -206,10 +198,9 @@ class ContextMenu {
|
|
|
206
198
|
else {
|
|
207
199
|
const tablesFootnoteLabels = (0, footnotes_utils_1.buildTableFootnoteLabels)(this.node);
|
|
208
200
|
const footnotesWithPos = (0, prosemirror_utils_1.findChildrenByType)(footnotesElementWithPos.node, transform_1.schema.nodes.footnote);
|
|
209
|
-
const footnotes = footnotesWithPos
|
|
210
|
-
.
|
|
211
|
-
|
|
212
|
-
index: tablesFootnoteLabels.get(node.attrs.id),
|
|
201
|
+
const footnotes = footnotesWithPos.map((nodeWithPos) => ({
|
|
202
|
+
node: nodeWithPos.node,
|
|
203
|
+
index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
|
|
213
204
|
}));
|
|
214
205
|
const targetDom = this.view.domAtPos(this.view.state.selection.from);
|
|
215
206
|
if (targetDom.node instanceof Element && this.props) {
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
18
|
exports.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
|
|
22
19
|
const transform_1 = require("@manuscripts/transform");
|
|
@@ -25,9 +22,7 @@ const prosemirror_state_1 = require("prosemirror-state");
|
|
|
25
22
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
26
23
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
27
24
|
const assets_1 = require("../../assets");
|
|
28
|
-
const DeleteFootnoteDialog_1 = require("../../components/views/DeleteFootnoteDialog");
|
|
29
25
|
const utils_1 = require("../../lib/utils");
|
|
30
|
-
const ReactSubView_1 = __importDefault(require("../../views/ReactSubView"));
|
|
31
26
|
const placeholder_1 = require("../placeholder");
|
|
32
27
|
const footnotes_utils_1 = require("./footnotes-utils");
|
|
33
28
|
exports.footnotesKey = new prosemirror_state_1.PluginKey('footnotes');
|
|
@@ -73,39 +68,7 @@ const uncitedFootnoteWidget = () => () => {
|
|
|
73
68
|
return element;
|
|
74
69
|
};
|
|
75
70
|
exports.uncitedFootnoteWidget = uncitedFootnoteWidget;
|
|
76
|
-
|
|
77
|
-
const deleteBtn = document.createElement('span');
|
|
78
|
-
deleteBtn.className = 'delete-icon';
|
|
79
|
-
deleteBtn.innerHTML = assets_1.deleteIcon;
|
|
80
|
-
deleteBtn.addEventListener('click', () => {
|
|
81
|
-
const handleDelete = () => {
|
|
82
|
-
const tr = view.state.tr;
|
|
83
|
-
const pos = getPos();
|
|
84
|
-
if (node.type === transform_1.schema.nodes.table_element_footer) {
|
|
85
|
-
if (!(0, utils_1.getChildOfType)(node, transform_1.schema.nodes.footnotes_element, true) &&
|
|
86
|
-
pos) {
|
|
87
|
-
tr.delete(pos - 1, pos + node.nodeSize);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
node.content.forEach((item) => {
|
|
91
|
-
if (item.type === transform_1.schema.nodes.paragraph && pos) {
|
|
92
|
-
tr.delete(pos - 1, pos + item.nodeSize + 1);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
view.dispatch(tr);
|
|
98
|
-
};
|
|
99
|
-
const componentProps = {
|
|
100
|
-
footnoteType: footnoteType,
|
|
101
|
-
footnoteMessage: footnoteMessage,
|
|
102
|
-
handleDelete: handleDelete,
|
|
103
|
-
};
|
|
104
|
-
(0, ReactSubView_1.default)(Object.assign(Object.assign({}, props), { dispatch: view.dispatch }), DeleteFootnoteDialog_1.DeleteFootnoteDialog, componentProps, node, () => getPos(), view);
|
|
105
|
-
});
|
|
106
|
-
return deleteBtn;
|
|
107
|
-
};
|
|
108
|
-
exports.default = (props) => {
|
|
71
|
+
exports.default = () => {
|
|
109
72
|
return new prosemirror_state_1.Plugin({
|
|
110
73
|
key: exports.footnotesKey,
|
|
111
74
|
state: {
|
|
@@ -138,7 +101,6 @@ exports.default = (props) => {
|
|
|
138
101
|
decorations: (state) => {
|
|
139
102
|
const decorations = [];
|
|
140
103
|
const isInTableElementFooter = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table_element_footer)(state.selection);
|
|
141
|
-
const isInTableElement = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table_element)(state.selection);
|
|
142
104
|
if (isInTableElementFooter) {
|
|
143
105
|
const parent = (0, utils_1.findParentNodeWithIdValue)(state.selection);
|
|
144
106
|
if (parent) {
|
|
@@ -149,7 +111,6 @@ exports.default = (props) => {
|
|
|
149
111
|
}
|
|
150
112
|
const { labels } = exports.footnotesKey.getState(state);
|
|
151
113
|
let tableInlineFootnoteIds = undefined;
|
|
152
|
-
const can = props.getCapabilities();
|
|
153
114
|
state.doc.descendants((node, pos, parent) => {
|
|
154
115
|
var _a;
|
|
155
116
|
if ((0, transform_1.isFootnoteNode)(node)) {
|
|
@@ -170,30 +131,6 @@ exports.default = (props) => {
|
|
|
170
131
|
decorations.push(prosemirror_view_1.Decoration.widget(pos + node.nodeSize - 1, (0, exports.uncitedFootnoteWidget)()));
|
|
171
132
|
}
|
|
172
133
|
}
|
|
173
|
-
if (can.editArticle) {
|
|
174
|
-
if (isInTableElement) {
|
|
175
|
-
const footnote = (() => {
|
|
176
|
-
switch (node.type) {
|
|
177
|
-
case transform_1.schema.nodes.footnote:
|
|
178
|
-
return {
|
|
179
|
-
type: 'table footnote',
|
|
180
|
-
message: 'This action will entirely remove the table footnote from the list because it will no longer be used.',
|
|
181
|
-
};
|
|
182
|
-
default:
|
|
183
|
-
return {
|
|
184
|
-
type: 'table general note',
|
|
185
|
-
message: 'This action will entirely remove the table general note.',
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
})();
|
|
189
|
-
if (node.type === transform_1.schema.nodes.paragraph &&
|
|
190
|
-
(parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
|
|
191
|
-
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, deleteFootnoteWidget(parent, props, footnote.type, footnote.message), {
|
|
192
|
-
key: parent.attrs.id,
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
134
|
if (node.type === transform_1.schema.nodes.footnotes_element) {
|
|
198
135
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
|
|
199
136
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
@@ -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', () => this.onClickHandler());
|
|
24
|
-
};
|
|
25
|
-
this.onClickHandler = () => {
|
|
26
|
-
const { tr, doc } = this.view.state;
|
|
27
|
-
tr.setSelection(prosemirror_state_1.NodeSelection.create(doc, this.getPos()));
|
|
28
|
-
this.view.dispatch(tr);
|
|
29
|
-
};
|
|
30
21
|
}
|
|
31
22
|
}
|
|
32
23
|
exports.AffiliationsView = AffiliationsView;
|
|
@@ -31,7 +31,6 @@ exports.BibliographyElementBlockView = void 0;
|
|
|
31
31
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
32
32
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
33
33
|
const transform_1 = require("@manuscripts/transform");
|
|
34
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
35
34
|
const dompurify_1 = require("../lib/dompurify");
|
|
36
35
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
37
36
|
const view_1 = require("../lib/view");
|
|
@@ -96,23 +95,19 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
96
95
|
this.clickedElementId = elementId;
|
|
97
96
|
const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
|
|
98
97
|
.getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
|
|
99
|
-
const { tr, doc } = this.view.state;
|
|
100
|
-
tr.setSelection(prosemirror_state_1.NodeSelection.create(doc, this.getPos()));
|
|
101
98
|
if (dataTracked && dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
|
|
102
|
-
tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id);
|
|
99
|
+
this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id));
|
|
103
100
|
}
|
|
104
101
|
else {
|
|
105
102
|
if (isSelectedSuggestion) {
|
|
106
|
-
tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true);
|
|
103
|
+
this.view.dispatch(this.view.state.tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true));
|
|
107
104
|
}
|
|
108
105
|
else {
|
|
109
106
|
this.showContextMenu(elementId);
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
|
-
this.view.dispatch(tr);
|
|
113
109
|
};
|
|
114
110
|
this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
this.props.popper.destroy();
|
|
116
111
|
const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
|
|
117
112
|
const commentsDecorationSet = comment_annotation_1.commentAnnotation.getState(this.view.state);
|
|
118
113
|
const selectedSuggestion = selected_suggestion_ui_1.selectedSuggestionKey.getState(this.view.state);
|
|
@@ -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");
|
|
@@ -43,14 +41,12 @@ class ContributorsView extends block_view_1.default {
|
|
|
43
41
|
this.updateContents();
|
|
44
42
|
};
|
|
45
43
|
this.updateContents = () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.createLegend();
|
|
53
|
-
}, 0);
|
|
44
|
+
this.updateClasses();
|
|
45
|
+
this.updateAttributes();
|
|
46
|
+
this.container.innerHTML = '';
|
|
47
|
+
this.buildAuthors();
|
|
48
|
+
this.createEditButton();
|
|
49
|
+
this.createLegend();
|
|
54
50
|
};
|
|
55
51
|
this.buildAuthors = () => {
|
|
56
52
|
var _a;
|
|
@@ -83,9 +79,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
83
79
|
const pluginState = affiliations_1.affiliationsKey.getState(this.view.state);
|
|
84
80
|
const attrs = node.attrs;
|
|
85
81
|
const displayAttr = (0, track_changes_utils_1.getActualAttrs)(node);
|
|
86
|
-
const containerWrapper = document.createElement('div');
|
|
87
82
|
const container = document.createElement('button');
|
|
88
|
-
containerWrapper.classList.add('contributor-wrapper');
|
|
89
83
|
container.classList.add('contributor');
|
|
90
84
|
container.setAttribute('id', attrs.id);
|
|
91
85
|
container.setAttribute('contenteditable', 'false');
|
|
@@ -101,12 +95,9 @@ class ContributorsView extends block_view_1.default {
|
|
|
101
95
|
}
|
|
102
96
|
const can = this.props.getCapabilities();
|
|
103
97
|
const disableEditButton = !can.editMetadata;
|
|
104
|
-
const { isCorresponding, email
|
|
98
|
+
const { isCorresponding, email } = displayAttr;
|
|
105
99
|
if (!disableEditButton) {
|
|
106
|
-
container.addEventListener('click',
|
|
107
|
-
const dataTracked = attrs.dataTracked;
|
|
108
|
-
this.onClickHandler(id, dataTracked ? dataTracked[0] : undefined);
|
|
109
|
-
});
|
|
100
|
+
container.addEventListener('click', this.handleClick);
|
|
110
101
|
}
|
|
111
102
|
const name = (0, authors_1.authorLabel)(displayAttr);
|
|
112
103
|
container.innerHTML =
|
|
@@ -134,8 +125,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
134
125
|
if (selectedAuthor && selectedAuthor === attrs.id) {
|
|
135
126
|
container.classList.add('selected-suggestion');
|
|
136
127
|
}
|
|
137
|
-
|
|
138
|
-
return containerWrapper;
|
|
128
|
+
return container;
|
|
139
129
|
};
|
|
140
130
|
this.isJointFirstAuthor = (authors, index) => {
|
|
141
131
|
const author = index === 0 ? authors[index] : authors[index - 1];
|
|
@@ -157,7 +147,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
157
147
|
const can = this.props.getCapabilities();
|
|
158
148
|
const button = (0, ReactSubView_1.default)(this.props, style_guide_1.SecondaryButton, {
|
|
159
149
|
mini: true,
|
|
160
|
-
onClick:
|
|
150
|
+
onClick: this.handleClick,
|
|
161
151
|
className: 'edit-authors-button',
|
|
162
152
|
disabled: !can.editMetadata,
|
|
163
153
|
children: 'Edit Authors',
|
|
@@ -177,48 +167,17 @@ class ContributorsView extends block_view_1.default {
|
|
|
177
167
|
}
|
|
178
168
|
}
|
|
179
169
|
};
|
|
180
|
-
this.
|
|
181
|
-
var _a;
|
|
182
|
-
|
|
183
|
-
const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
|
|
184
|
-
.getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
|
|
185
|
-
const { tr, doc } = this.view.state;
|
|
186
|
-
tr.setSelection(prosemirror_state_1.NodeSelection.create(doc, this.getPos()));
|
|
187
|
-
if (dataTracked && dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
|
|
188
|
-
tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id);
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
if (isSelectedSuggestion) {
|
|
192
|
-
tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (!((dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.operation) === track_changes_plugin_1.CHANGE_OPERATION.delete &&
|
|
196
|
-
(dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.status) !== track_changes_plugin_1.CHANGE_STATUS.rejected)) {
|
|
197
|
-
this.showContextMenu(elementId);
|
|
198
|
-
}
|
|
199
|
-
this.view.dispatch(tr);
|
|
200
|
-
};
|
|
201
|
-
this.showContextMenu = (elementId) => {
|
|
202
|
-
this.props.popper.destroy();
|
|
203
|
-
const element = document.getElementById(elementId);
|
|
204
|
-
const componentProps = {
|
|
205
|
-
actions: [
|
|
206
|
-
{
|
|
207
|
-
label: 'Edit',
|
|
208
|
-
action: () => this.handleEdit(elementId),
|
|
209
|
-
icon: 'EditIcon',
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
};
|
|
213
|
-
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
214
|
-
this.props.popper.show(element, this.contextMenu, 'right-start');
|
|
215
|
-
};
|
|
216
|
-
this.handleEdit = (id) => {
|
|
217
|
-
var _a;
|
|
218
|
-
this.props.popper.destroy();
|
|
170
|
+
this.handleClick = (e) => {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
e.stopPropagation();
|
|
219
173
|
const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
|
|
220
174
|
const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
|
|
221
|
-
|
|
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
|
+
}
|
|
222
181
|
const componentProps = {
|
|
223
182
|
author,
|
|
224
183
|
authors: contributors,
|
|
@@ -227,7 +186,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
227
186
|
onDeleteAuthor: this.handleDeleteAuthor,
|
|
228
187
|
onSaveAffiliation: this.handleSaveAffiliation,
|
|
229
188
|
};
|
|
230
|
-
(
|
|
189
|
+
(_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
|
|
231
190
|
this.popper = (0, ReactSubView_1.default)(this.props, AuthorsModal_1.AuthorsModal, componentProps, this.node, this.getPos, this.view);
|
|
232
191
|
this.container.appendChild(this.popper);
|
|
233
192
|
};
|
|
@@ -260,6 +219,8 @@ class ContributorsView extends block_view_1.default {
|
|
|
260
219
|
const node = transform_1.schema.nodes.affiliation.create(attrs);
|
|
261
220
|
this.view.dispatch(tr.insert(parent.pos + 1, node));
|
|
262
221
|
};
|
|
222
|
+
this.ignoreMutation = () => true;
|
|
223
|
+
this.stopEvent = () => true;
|
|
263
224
|
}
|
|
264
225
|
createNote(text = '', title = '') {
|
|
265
226
|
const el = document.createElement('span');
|
|
@@ -14,43 +14,16 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
18
|
exports.InlineFootnoteView = void 0;
|
|
22
|
-
const style_guide_1 = require("@manuscripts/style-guide");
|
|
23
|
-
const transform_1 = require("@manuscripts/transform");
|
|
24
|
-
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
25
|
-
const commands_1 = require("../commands");
|
|
26
19
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
27
|
-
const footnotes_utils_1 = require("../plugins/footnotes/footnotes-utils");
|
|
28
20
|
const base_node_view_1 = require("./base_node_view");
|
|
29
21
|
const creators_1 = require("./creators");
|
|
30
|
-
const ReactSubView_1 = __importDefault(require("./ReactSubView"));
|
|
31
22
|
class InlineFootnoteView extends base_node_view_1.BaseNodeView {
|
|
32
23
|
constructor() {
|
|
33
24
|
super(...arguments);
|
|
34
|
-
this.findParentTableElement = () => (0, prosemirror_utils_1.findParentNodeClosestToPos)(this.view.state.doc.resolve(this.getPos()), (node) => node.type === transform_1.schema.nodes.table_element);
|
|
35
25
|
this.handleClick = () => {
|
|
36
|
-
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const tableElement = this.findParentTableElement();
|
|
40
|
-
if (tableElement) {
|
|
41
|
-
const componentProps = {
|
|
42
|
-
notes: this.getNotes(tableElement),
|
|
43
|
-
onAdd: this.onAdd,
|
|
44
|
-
onInsert: this.onUpdate,
|
|
45
|
-
onCancel: this.destroy,
|
|
46
|
-
inlineFootnote: this.node,
|
|
47
|
-
};
|
|
48
|
-
this.popperContainer = (0, ReactSubView_1.default)(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), style_guide_1.TableFootnotesSelector, componentProps, this.node, this.getPos, this.view, 'table-footnote-editor');
|
|
49
|
-
this.props.popper.show(this.dom, this.popperContainer, 'bottom-end');
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
|
|
53
|
-
}
|
|
26
|
+
this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
|
|
54
27
|
};
|
|
55
28
|
this.updateContents = () => {
|
|
56
29
|
this.setDomAttrs(this.node, this.dom);
|
|
@@ -69,49 +42,6 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
|
|
|
69
42
|
this.createDOM = () => {
|
|
70
43
|
return document.createElement('span');
|
|
71
44
|
};
|
|
72
|
-
this.destroy = () => {
|
|
73
|
-
var _a;
|
|
74
|
-
this.props.popper.destroy();
|
|
75
|
-
(_a = this.popperContainer) === null || _a === void 0 ? void 0 : _a.remove();
|
|
76
|
-
};
|
|
77
|
-
this.getNotes = (tableElement) => {
|
|
78
|
-
var _a;
|
|
79
|
-
const footnotesElement = (_a = (0, prosemirror_utils_1.findChildrenByType)(tableElement.node, transform_1.schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
|
|
80
|
-
let footnotes = [];
|
|
81
|
-
if (footnotesElement) {
|
|
82
|
-
const tablesFootnoteLabels = (0, footnotes_utils_1.buildTableFootnoteLabels)(tableElement.node);
|
|
83
|
-
footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement, transform_1.schema.nodes.footnote)
|
|
84
|
-
.map(({ node }) => ({
|
|
85
|
-
node: node,
|
|
86
|
-
index: tablesFootnoteLabels.get(node.attrs.id),
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
return footnotes;
|
|
90
|
-
};
|
|
91
|
-
this.onAdd = () => {
|
|
92
|
-
const tableElement = this.findParentTableElement();
|
|
93
|
-
if (tableElement) {
|
|
94
|
-
(0, commands_1.insertTableFootnote)(tableElement.node, tableElement.pos, this.view, {
|
|
95
|
-
node: this.node,
|
|
96
|
-
pos: this.getPos(),
|
|
97
|
-
});
|
|
98
|
-
this.destroy();
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
this.onUpdate = (notes) => {
|
|
102
|
-
const contents = this.node.attrs.contents.split(',');
|
|
103
|
-
const rids = notes.map((note) => note.node.attrs.id);
|
|
104
|
-
const { tr } = this.view.state;
|
|
105
|
-
this.view.dispatch(rids.length
|
|
106
|
-
? tr.setNodeMarkup(this.getPos(), undefined, {
|
|
107
|
-
rids,
|
|
108
|
-
contents: notes
|
|
109
|
-
.map(({ index }) => (index ? index : Math.max(...contents) + 1))
|
|
110
|
-
.join(),
|
|
111
|
-
})
|
|
112
|
-
: tr.delete(this.getPos(), this.getPos() + this.node.nodeSize));
|
|
113
|
-
this.destroy();
|
|
114
|
-
};
|
|
115
45
|
}
|
|
116
46
|
}
|
|
117
47
|
exports.InlineFootnoteView = InlineFootnoteView;
|
|
@@ -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;
|
package/dist/es/assets.js
CHANGED
|
@@ -115,49 +115,3 @@ export const alertIcon = `
|
|
|
115
115
|
/>
|
|
116
116
|
</svg>
|
|
117
117
|
`;
|
|
118
|
-
export const deleteIcon = `
|
|
119
|
-
<svg
|
|
120
|
-
width="13"
|
|
121
|
-
height="15"
|
|
122
|
-
viewBox="0 0 13 15"
|
|
123
|
-
fill="none"
|
|
124
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
125
|
-
>
|
|
126
|
-
<path
|
|
127
|
-
fill-rule="evenodd"
|
|
128
|
-
clip-rule="evenodd"
|
|
129
|
-
d="M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z"
|
|
130
|
-
fill="#C9C9C9"
|
|
131
|
-
/>
|
|
132
|
-
<path
|
|
133
|
-
fill-rule="evenodd"
|
|
134
|
-
clip-rule="evenodd"
|
|
135
|
-
d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z"
|
|
136
|
-
fill="#C9C9C9"
|
|
137
|
-
/>
|
|
138
|
-
<rect
|
|
139
|
-
y="2"
|
|
140
|
-
width="13"
|
|
141
|
-
height="3"
|
|
142
|
-
rx="1.5"
|
|
143
|
-
fill="#C9C9C9"
|
|
144
|
-
/>
|
|
145
|
-
<path
|
|
146
|
-
fill-rule="evenodd"
|
|
147
|
-
clip-rule="evenodd"
|
|
148
|
-
d="M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z"
|
|
149
|
-
fill="#C9C9C9"
|
|
150
|
-
/>
|
|
151
|
-
<path
|
|
152
|
-
fill-rule="evenodd"
|
|
153
|
-
clip-rule="evenodd"
|
|
154
|
-
d="M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z"
|
|
155
|
-
fill="#C9C9C9"
|
|
156
|
-
/>
|
|
157
|
-
<path
|
|
158
|
-
fill-rule="evenodd"
|
|
159
|
-
clip-rule="evenodd"
|
|
160
|
-
d="M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z"
|
|
161
|
-
fill="white"
|
|
162
|
-
/>
|
|
163
|
-
</svg>`;
|