@manuscripts/body-editor 2.2.21 → 2.3.0
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 +12 -13
- package/dist/cjs/components/keywords/AddKeywordInline.js +1 -2
- package/dist/cjs/components/outline/DraggableTree.js +0 -4
- package/dist/cjs/components/views/FootnotesSelector.js +2 -4
- package/dist/cjs/keys/list.js +1 -3
- package/dist/cjs/lib/context-menu.js +8 -11
- package/dist/cjs/lib/files.js +2 -2
- package/dist/cjs/lib/footnotes.js +1 -6
- package/dist/cjs/lib/track-changes-utils.js +5 -43
- package/dist/cjs/lib/view.js +1 -1
- package/dist/cjs/plugins/affiliations.js +1 -1
- package/dist/cjs/plugins/bibliography/bibliography-utils.js +1 -2
- package/dist/cjs/plugins/bibliography/index.js +2 -2
- package/dist/cjs/plugins/footnotes/index.js +5 -6
- package/dist/cjs/plugins/footnotes/widgets.js +1 -2
- package/dist/cjs/plugins/section_title/autocompletion.js +1 -1
- package/dist/cjs/plugins/section_title/index.js +2 -4
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/citation_editable.js +5 -5
- package/dist/cjs/views/cross_reference.js +2 -5
- package/dist/cjs/views/equation.js +1 -2
- package/dist/cjs/views/figure_editable.js +1 -2
- package/dist/cjs/views/inline_equation.js +4 -12
- package/dist/cjs/views/inline_footnote.js +5 -5
- package/dist/cjs/views/link_editable.js +5 -10
- package/dist/cjs/views/list.js +1 -2
- package/dist/cjs/views/section.js +1 -2
- package/dist/es/commands.js +13 -14
- package/dist/es/components/keywords/AddKeywordInline.js +2 -3
- package/dist/es/components/outline/DraggableTree.js +1 -5
- package/dist/es/components/views/FootnotesSelector.js +2 -4
- package/dist/es/keys/list.js +1 -3
- package/dist/es/lib/context-menu.js +9 -12
- package/dist/es/lib/files.js +3 -3
- package/dist/es/lib/footnotes.js +1 -6
- package/dist/es/lib/track-changes-utils.js +4 -39
- package/dist/es/lib/view.js +2 -2
- package/dist/es/plugins/affiliations.js +2 -2
- package/dist/es/plugins/bibliography/bibliography-utils.js +1 -2
- package/dist/es/plugins/bibliography/index.js +3 -3
- package/dist/es/plugins/footnotes/index.js +5 -6
- package/dist/es/plugins/footnotes/widgets.js +2 -3
- package/dist/es/plugins/section_title/autocompletion.js +2 -2
- package/dist/es/plugins/section_title/index.js +2 -4
- package/dist/es/versions.js +1 -1
- package/dist/es/views/citation_editable.js +6 -6
- package/dist/es/views/cross_reference.js +3 -6
- package/dist/es/views/equation.js +1 -2
- package/dist/es/views/figure_editable.js +1 -2
- package/dist/es/views/inline_equation.js +4 -12
- package/dist/es/views/inline_footnote.js +6 -6
- package/dist/es/views/link_editable.js +6 -11
- package/dist/es/views/list.js +1 -2
- package/dist/es/views/section.js +1 -2
- package/dist/types/lib/track-changes-utils.d.ts +0 -4
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -50,7 +50,11 @@ const addToStart = (state, dispatch) => {
|
|
|
50
50
|
endOffset === parentSize) {
|
|
51
51
|
const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
|
|
52
52
|
.pos - (startOffset === 0 ? 1 : 0);
|
|
53
|
-
const tr = state.tr
|
|
53
|
+
const tr = state.tr;
|
|
54
|
+
const from = $from.node().type.createAndFill();
|
|
55
|
+
if (from) {
|
|
56
|
+
tr.insert(side, from);
|
|
57
|
+
}
|
|
54
58
|
tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, side + 1));
|
|
55
59
|
dispatch(tr.scrollIntoView());
|
|
56
60
|
return true;
|
|
@@ -179,8 +183,7 @@ const insertGeneralFootnote = (tableElementNode, position, view, tableElementFoo
|
|
|
179
183
|
? table.pos + table.node.nodeSize
|
|
180
184
|
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
181
185
|
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
182
|
-
if ((0, track_changes_utils_1.isDeleted)(tableElementFooter[0].node)
|
|
183
|
-
(0, track_changes_utils_1.isRejectedInsert)(tableElementFooter[0].node)) {
|
|
186
|
+
if ((0, track_changes_utils_1.isDeleted)(tableElementFooter[0].node)) {
|
|
184
187
|
const tableElementFooterPos = tr.mapping.map(position + tableElementFooter[0].pos + 1);
|
|
185
188
|
(0, exports.undoFootnoteDelete)(tr, tableElementFooter[0], tableElementFooterPos);
|
|
186
189
|
}
|
|
@@ -433,8 +436,7 @@ const insertFootnote = (state, tr, footnote) => {
|
|
|
433
436
|
else {
|
|
434
437
|
const footnoteElement = (0, prosemirror_utils_1.findChildrenByType)(footnotesSection.node, transform_1.schema.nodes.footnotes_element).pop();
|
|
435
438
|
if (footnoteElement) {
|
|
436
|
-
if ((0, track_changes_utils_1.isDeleted)(footnoteElement.node)
|
|
437
|
-
(0, track_changes_utils_1.isRejectedInsert)(footnoteElement.node)) {
|
|
439
|
+
if ((0, track_changes_utils_1.isDeleted)(footnoteElement.node)) {
|
|
438
440
|
const footnoteElementPos = footnotesSection.pos + footnoteElement.pos + 1;
|
|
439
441
|
(0, exports.undoFootnoteDelete)(tr, footnoteElement, footnoteElementPos);
|
|
440
442
|
const updatedAttrs = Object.assign(Object.assign({}, footnoteElement.node.attrs), { dataTracked: null });
|
|
@@ -483,9 +485,7 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
483
485
|
};
|
|
484
486
|
exports.insertInlineFootnote = insertInlineFootnote;
|
|
485
487
|
const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
486
|
-
|
|
487
|
-
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.graphical_abstract_section, true) &&
|
|
488
|
-
!(0, track_changes_utils_1.isRejectedInsert)(GraphicalAbstractSectionNode.node)) {
|
|
488
|
+
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.graphical_abstract_section, true)) {
|
|
489
489
|
return false;
|
|
490
490
|
}
|
|
491
491
|
const abstracts = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.abstracts)[0];
|
|
@@ -1038,7 +1038,8 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
1038
1038
|
else {
|
|
1039
1039
|
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.inline_footnote);
|
|
1040
1040
|
footnoteIndex =
|
|
1041
|
-
inlineFootnotes.filter(({ pos }) =>
|
|
1041
|
+
inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
|
|
1042
|
+
1;
|
|
1042
1043
|
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
1043
1044
|
rids: [footnote.attrs.id],
|
|
1044
1045
|
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
@@ -1048,8 +1049,7 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
1048
1049
|
let insertionPos = position;
|
|
1049
1050
|
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.footnotes_element).pop();
|
|
1050
1051
|
if (footnotesElement) {
|
|
1051
|
-
if ((0, track_changes_utils_1.isDeleted)(footnotesElement.node)
|
|
1052
|
-
(0, track_changes_utils_1.isRejectedInsert)(footnotesElement.node)) {
|
|
1052
|
+
if ((0, track_changes_utils_1.isDeleted)(footnotesElement.node)) {
|
|
1053
1053
|
const footnotesElementPos = tr.mapping.map(position + footnotesElement.pos + 1);
|
|
1054
1054
|
(0, exports.undoFootnoteDelete)(tr, footnotesElement, footnotesElementPos);
|
|
1055
1055
|
}
|
|
@@ -1061,8 +1061,7 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
|
|
|
1061
1061
|
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
1062
1062
|
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table_element_footer)[0];
|
|
1063
1063
|
if (tableElementFooter) {
|
|
1064
|
-
if ((0, track_changes_utils_1.isDeleted)(tableElementFooter.node)
|
|
1065
|
-
(0, track_changes_utils_1.isRejectedInsert)(tableElementFooter.node)) {
|
|
1064
|
+
if ((0, track_changes_utils_1.isDeleted)(tableElementFooter.node)) {
|
|
1066
1065
|
const tableElementFooterPos = tr.mapping.map(position + tableElementFooter.pos + 1);
|
|
1067
1066
|
(0, exports.undoFootnoteDelete)(tr, tableElementFooter, tableElementFooterPos);
|
|
1068
1067
|
}
|
|
@@ -89,8 +89,7 @@ const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
|
|
|
89
89
|
const keywords = [];
|
|
90
90
|
node.content.descendants((descNode) => {
|
|
91
91
|
if (descNode.type === descNode.type.schema.nodes.keyword &&
|
|
92
|
-
!(0, track_changes_utils_1.isDeleted)(descNode)
|
|
93
|
-
!(0, track_changes_utils_1.isRejectedInsert)(descNode)) {
|
|
92
|
+
!(0, track_changes_utils_1.isDeleted)(descNode)) {
|
|
94
93
|
keywords.push({
|
|
95
94
|
id: descNode.attrs.id,
|
|
96
95
|
contents: descNode.textContent,
|
|
@@ -160,11 +160,7 @@ const DraggableTree = ({ tree, view, depth, can, }) => {
|
|
|
160
160
|
}),
|
|
161
161
|
});
|
|
162
162
|
const isDeletedItem = (0, track_changes_utils_1.isDeleted)(node);
|
|
163
|
-
const isRejectedItem = (0, track_changes_utils_1.isRejectedInsert)(node);
|
|
164
163
|
const isTop = isManuscriptNode(parent);
|
|
165
|
-
if (isRejectedItem) {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
164
|
const handleContextMenu = (e) => {
|
|
169
165
|
e.preventDefault();
|
|
170
166
|
e.stopPropagation();
|
|
@@ -45,7 +45,6 @@ exports.FootnotesSelector = void 0;
|
|
|
45
45
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
46
46
|
const react_1 = __importStar(require("react"));
|
|
47
47
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
48
|
-
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
49
48
|
const NotesContainer = styled_components_1.default.div `
|
|
50
49
|
height: 90vh;
|
|
51
50
|
max-height: 400px;
|
|
@@ -80,7 +79,7 @@ const AddNewFootnote = (0, styled_components_1.default)(style_guide_1.ButtonGrou
|
|
|
80
79
|
const FootnotesSelector = ({ notes, inlineFootnote, onAdd, onInsert, onCancel, addNewLabel }) => {
|
|
81
80
|
let selectedNotesMap;
|
|
82
81
|
if (inlineFootnote) {
|
|
83
|
-
const rids =
|
|
82
|
+
const rids = inlineFootnote.attrs.rids;
|
|
84
83
|
const selectedNotes = notes.filter(({ node }) => rids.includes(node.attrs.id));
|
|
85
84
|
selectedNotesMap = new Map(selectedNotes.map(({ node }) => [node.attrs.id, node]));
|
|
86
85
|
}
|
|
@@ -119,8 +118,7 @@ const FootnotesList = ({ notes, isSelected, onSelect, inlineFootnote }) => {
|
|
|
119
118
|
const selectedNotes = [];
|
|
120
119
|
const remainingNotes = [];
|
|
121
120
|
notes.forEach((note) => {
|
|
122
|
-
const isNoteSelected = inlineFootnote &&
|
|
123
|
-
(0, track_changes_utils_1.getActualAttrs)(inlineFootnote).rids.includes(note.node.attrs.id);
|
|
121
|
+
const isNoteSelected = inlineFootnote && inlineFootnote.attrs.rids.includes(note.node.attrs.id);
|
|
124
122
|
if (isNoteSelected) {
|
|
125
123
|
selectedNotes.push(note);
|
|
126
124
|
}
|
package/dist/cjs/keys/list.js
CHANGED
|
@@ -23,7 +23,6 @@ const prosemirror_model_1 = require("prosemirror-model");
|
|
|
23
23
|
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
24
24
|
const prosemirror_transform_1 = require("prosemirror-transform");
|
|
25
25
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
26
|
-
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
27
26
|
const skipCommandTracking = (command) => (state, dispatch) => {
|
|
28
27
|
return command(state, (tr) => {
|
|
29
28
|
if (dispatch) {
|
|
@@ -76,8 +75,7 @@ function sinkListItem(itemType) {
|
|
|
76
75
|
}
|
|
77
76
|
if (dispatch) {
|
|
78
77
|
const nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
|
|
79
|
-
const
|
|
80
|
-
const listType = actualAttrs.listStyleType;
|
|
78
|
+
const listType = parent.attrs.listStyleType;
|
|
81
79
|
const inner = prosemirror_model_1.Fragment.from(nestedBefore ? itemType.create() : null);
|
|
82
80
|
const slice = new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from(itemType.create(null, prosemirror_model_1.Fragment.from(parent.type.create({ listStyleType: listType }, inner)))), nestedBefore ? 3 : 1, 0);
|
|
83
81
|
const before = range.start, after = range.end;
|
|
@@ -158,8 +158,8 @@ class ContextMenu {
|
|
|
158
158
|
const type = isBox ? transform_1.schema.nodes.box_element : this.node.type;
|
|
159
159
|
if (type === transform_1.schema.nodes.list) {
|
|
160
160
|
menu.appendChild(this.createMenuSection((section) => {
|
|
161
|
-
const
|
|
162
|
-
const listType = (0, transform_1.getListType)(
|
|
161
|
+
const attrs = this.node.attrs;
|
|
162
|
+
const listType = (0, transform_1.getListType)(attrs.listStyleType).style;
|
|
163
163
|
if (listType === 'none' || listType === 'disc') {
|
|
164
164
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
165
165
|
this.changeNodeType(null, 'order');
|
|
@@ -187,17 +187,16 @@ class ContextMenu {
|
|
|
187
187
|
if (type === transform_1.schema.nodes.table_element) {
|
|
188
188
|
const isInTable = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table)(this.view.state.selection);
|
|
189
189
|
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
|
|
190
|
-
let
|
|
190
|
+
let isDeletedInsert = false;
|
|
191
191
|
const hasGeneralNote = tableElementFooter.length &&
|
|
192
192
|
(0, utils_1.getChildOfType)(tableElementFooter[0].node, transform_1.schema.nodes.general_table_footnote, true);
|
|
193
193
|
if (hasGeneralNote) {
|
|
194
194
|
const generalFootnote = (_a = tableElementFooter[0]) === null || _a === void 0 ? void 0 : _a.node.firstChild;
|
|
195
195
|
if (generalFootnote) {
|
|
196
|
-
|
|
197
|
-
(0, track_changes_utils_1.isDeleted)(generalFootnote) || (0, track_changes_utils_1.isRejectedInsert)(generalFootnote);
|
|
196
|
+
isDeletedInsert = (0, track_changes_utils_1.isDeleted)(generalFootnote);
|
|
198
197
|
}
|
|
199
198
|
}
|
|
200
|
-
if (!hasGeneralNote ||
|
|
199
|
+
if (!hasGeneralNote || isDeletedInsert) {
|
|
201
200
|
menu.appendChild(this.createMenuSection((section) => {
|
|
202
201
|
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
203
202
|
(0, commands_1.insertGeneralFootnote)(this.node, this.getPos(), this.view, tableElementFooter);
|
|
@@ -211,15 +210,14 @@ class ContextMenu {
|
|
|
211
210
|
const footnotesElementWithPos = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element).pop();
|
|
212
211
|
if (!footnotesElementWithPos ||
|
|
213
212
|
!(footnotesElementWithPos === null || footnotesElementWithPos === void 0 ? void 0 : footnotesElementWithPos.node.content.childCount) ||
|
|
214
|
-
(0, track_changes_utils_1.isDeleted)(footnotesElementWithPos.node)
|
|
215
|
-
(0, track_changes_utils_1.isRejectedInsert)(footnotesElementWithPos.node)) {
|
|
213
|
+
(0, track_changes_utils_1.isDeleted)(footnotesElementWithPos.node)) {
|
|
216
214
|
(0, commands_1.insertTableFootnote)(this.node, this.getPos(), this.view);
|
|
217
215
|
}
|
|
218
216
|
else {
|
|
219
217
|
const tablesFootnoteLabels = (0, footnotes_1.buildTableFootnoteLabels)(this.node);
|
|
220
218
|
const footnotesWithPos = (0, prosemirror_utils_1.findChildrenByType)(footnotesElementWithPos.node, transform_1.schema.nodes.footnote);
|
|
221
219
|
const footnotes = footnotesWithPos
|
|
222
|
-
.filter(({ node }) => !(0, track_changes_utils_1.isDeleted)(node)
|
|
220
|
+
.filter(({ node }) => !(0, track_changes_utils_1.isDeleted)(node))
|
|
223
221
|
.map(({ node }) => ({
|
|
224
222
|
node: node,
|
|
225
223
|
index: tablesFootnoteLabels.get(node.attrs.id),
|
|
@@ -243,8 +241,7 @@ class ContextMenu {
|
|
|
243
241
|
this.view.state.doc
|
|
244
242
|
.slice(this.getPos(), insertedAt)
|
|
245
243
|
.content.descendants((node) => {
|
|
246
|
-
if (node.type === transform_1.schema.nodes.inline_footnote
|
|
247
|
-
!(0, track_changes_utils_1.isRejectedInsert)(node)) {
|
|
244
|
+
if (node.type === transform_1.schema.nodes.inline_footnote) {
|
|
248
245
|
inlineFootnoteIndex++;
|
|
249
246
|
return false;
|
|
250
247
|
}
|
package/dist/cjs/lib/files.js
CHANGED
|
@@ -22,7 +22,7 @@ const groupFiles = (doc, files) => {
|
|
|
22
22
|
if ((0, track_changes_utils_1.isHidden)(figure.node)) {
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
|
-
const src =
|
|
25
|
+
const src = figure.node.attrs.src;
|
|
26
26
|
if (!src) {
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
@@ -59,7 +59,7 @@ const groupFiles = (doc, files) => {
|
|
|
59
59
|
if ((0, track_changes_utils_1.isHidden)(node)) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
const href =
|
|
62
|
+
const href = node.attrs.href;
|
|
63
63
|
let file = fileMap.get(href);
|
|
64
64
|
if (file) {
|
|
65
65
|
fileMap.delete(href);
|
|
@@ -20,13 +20,11 @@ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
|
20
20
|
const transform_1 = require("@manuscripts/transform");
|
|
21
21
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
22
22
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
23
|
-
const track_changes_utils_1 = require("./track-changes-utils");
|
|
24
23
|
const findTableInlineFootnoteIds = ($pos) => {
|
|
25
24
|
var _a;
|
|
26
25
|
const tableElement = (_a = (0, prosemirror_utils_1.findParentNodeClosestToPos)($pos, (node) => node.type === transform_1.schema.nodes.table_element)) === null || _a === void 0 ? void 0 : _a.node;
|
|
27
26
|
return new Set(tableElement
|
|
28
27
|
? (0, prosemirror_utils_1.findChildren)(tableElement, (node) => node.type === transform_1.schema.nodes.inline_footnote)
|
|
29
|
-
.filter(({ node }) => !(0, track_changes_utils_1.isRejectedInsert)(node))
|
|
30
28
|
.map(({ node }) => node.attrs.rids)
|
|
31
29
|
.flat()
|
|
32
30
|
: []);
|
|
@@ -51,7 +49,6 @@ const buildTableFootnoteLabels = (node) => {
|
|
|
51
49
|
]));
|
|
52
50
|
let index = 0;
|
|
53
51
|
(0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote)
|
|
54
|
-
.filter(({ node }) => !(0, track_changes_utils_1.isRejectedInsert)(node))
|
|
55
52
|
.map(({ node }) => node.attrs.rids)
|
|
56
53
|
.flat()
|
|
57
54
|
.map((rid) => {
|
|
@@ -92,9 +89,7 @@ const orderTableFootnotes = (tr, footnotesElementWithPos, position) => {
|
|
|
92
89
|
exports.orderTableFootnotes = orderTableFootnotes;
|
|
93
90
|
const updateTableInlineFootnoteLabels = (tr, table) => {
|
|
94
91
|
const labels = (0, exports.buildTableFootnoteLabels)(table.node);
|
|
95
|
-
(0, prosemirror_utils_1.findChildrenByType)(table.node, transform_1.schema.nodes.inline_footnote)
|
|
96
|
-
.filter(({ node }) => !(0, track_changes_utils_1.isRejectedInsert)(node))
|
|
97
|
-
.map(({ node, pos }) => {
|
|
92
|
+
(0, prosemirror_utils_1.findChildrenByType)(table.node, transform_1.schema.nodes.inline_footnote).map(({ node, pos }) => {
|
|
98
93
|
const contents = node.attrs.rids
|
|
99
94
|
.map((rid) => labels.get(rid))
|
|
100
95
|
.join(',');
|
|
@@ -15,23 +15,15 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.sanitizeAttrsChange = exports.getActualTextContent = exports.
|
|
18
|
+
exports.sanitizeAttrsChange = exports.getActualTextContent = exports.isDeletedText = exports.isHidden = exports.getAttrsTrackingButton = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = void 0;
|
|
19
19
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
20
20
|
const transform_1 = require("@manuscripts/transform");
|
|
21
21
|
const react_1 = require("react");
|
|
22
22
|
const server_1 = require("react-dom/server");
|
|
23
|
-
function isRejectedInsert(node) {
|
|
24
|
-
if (node.attrs.dataTracked) {
|
|
25
|
-
const changes = node.attrs.dataTracked;
|
|
26
|
-
return changes.some(({ operation, status }) => operation === 'insert' && status == 'rejected');
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
exports.isRejectedInsert = isRejectedInsert;
|
|
31
23
|
function isDeleted(node) {
|
|
32
24
|
if (node.attrs.dataTracked) {
|
|
33
25
|
const changes = node.attrs.dataTracked;
|
|
34
|
-
return changes.some(({ operation
|
|
26
|
+
return changes.some(({ operation }) => operation === 'delete');
|
|
35
27
|
}
|
|
36
28
|
return false;
|
|
37
29
|
}
|
|
@@ -84,25 +76,6 @@ function isTracked(node) {
|
|
|
84
76
|
return false;
|
|
85
77
|
}
|
|
86
78
|
exports.isTracked = isTracked;
|
|
87
|
-
function getActualAttrs(node) {
|
|
88
|
-
var _a;
|
|
89
|
-
const attrs = node.attrs;
|
|
90
|
-
if ((_a = attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
|
|
91
|
-
const changes = attrs.dataTracked.filter((c) => c.operation === 'set_attrs');
|
|
92
|
-
const hasPendingAttrs = changes.some((c) => c.status === 'pending');
|
|
93
|
-
if (hasPendingAttrs) {
|
|
94
|
-
return attrs;
|
|
95
|
-
}
|
|
96
|
-
const rejected = changes
|
|
97
|
-
.filter((c) => c.status === 'rejected')
|
|
98
|
-
.sort((a, b) => b.statusUpdateAt - a.statusUpdateAt)[0];
|
|
99
|
-
if (rejected && rejected.status === 'rejected') {
|
|
100
|
-
return rejected.oldAttrs;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return attrs;
|
|
104
|
-
}
|
|
105
|
-
exports.getActualAttrs = getActualAttrs;
|
|
106
79
|
const getAttrsTrackingButton = (changeID) => {
|
|
107
80
|
const el = document.createElement('button');
|
|
108
81
|
el.className = 'attrs-popper-button';
|
|
@@ -112,7 +85,7 @@ const getAttrsTrackingButton = (changeID) => {
|
|
|
112
85
|
};
|
|
113
86
|
exports.getAttrsTrackingButton = getAttrsTrackingButton;
|
|
114
87
|
function isHidden(node) {
|
|
115
|
-
return isDeleted(node)
|
|
88
|
+
return isDeleted(node);
|
|
116
89
|
}
|
|
117
90
|
exports.isHidden = isHidden;
|
|
118
91
|
function isDeletedText(node) {
|
|
@@ -121,24 +94,13 @@ function isDeletedText(node) {
|
|
|
121
94
|
const deleteMark = node.marks.find((mark) => mark.type === transform_1.schema.marks.tracked_delete);
|
|
122
95
|
if (deleteMark &&
|
|
123
96
|
((_b = (_a = deleteMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked) === null || _b === void 0 ? void 0 : _b.status) &&
|
|
124
|
-
|
|
97
|
+
'pending' === ((_d = (_c = deleteMark.attrs) === null || _c === void 0 ? void 0 : _c.dataTracked) === null || _d === void 0 ? void 0 : _d.status)) {
|
|
125
98
|
return true;
|
|
126
99
|
}
|
|
127
100
|
}
|
|
128
101
|
return false;
|
|
129
102
|
}
|
|
130
103
|
exports.isDeletedText = isDeletedText;
|
|
131
|
-
function isRejectedText(node) {
|
|
132
|
-
var _a, _b;
|
|
133
|
-
if (node.type === transform_1.schema.nodes.text) {
|
|
134
|
-
const insertMark = node.marks.find((mark) => mark.type === transform_1.schema.marks.tracked_insert);
|
|
135
|
-
if (insertMark && ((_b = (_a = insertMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked) === null || _b === void 0 ? void 0 : _b.status) === 'rejected') {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
exports.isRejectedText = isRejectedText;
|
|
142
104
|
function getActualTextContent(fragment) {
|
|
143
105
|
let finalContent = '';
|
|
144
106
|
function getContent(fragment) {
|
|
@@ -146,7 +108,7 @@ function getActualTextContent(fragment) {
|
|
|
146
108
|
if (node.type !== transform_1.schema.nodes.text) {
|
|
147
109
|
finalContent += getContent(node.content);
|
|
148
110
|
}
|
|
149
|
-
if (!isDeletedText(node)
|
|
111
|
+
if (!isDeletedText(node)) {
|
|
150
112
|
finalContent += node.textContent;
|
|
151
113
|
}
|
|
152
114
|
});
|
package/dist/cjs/lib/view.js
CHANGED
|
@@ -65,7 +65,7 @@ const findChildrenByType = (view, type) => {
|
|
|
65
65
|
};
|
|
66
66
|
exports.findChildrenByType = findChildrenByType;
|
|
67
67
|
const findChildrenAttrsByType = (view, type) => {
|
|
68
|
-
return (0, exports.findChildrenByType)(view, type).map((n) =>
|
|
68
|
+
return (0, exports.findChildrenByType)(view, type).map((n) => n.node.attrs);
|
|
69
69
|
};
|
|
70
70
|
exports.findChildrenAttrsByType = findChildrenAttrsByType;
|
|
71
71
|
const updateNodeAttrs = (view, type, attrs) => {
|
|
@@ -30,7 +30,7 @@ const buildPluginState = (doc, $old) => {
|
|
|
30
30
|
const affiliations = [];
|
|
31
31
|
const deletedContribId = new Set();
|
|
32
32
|
doc.descendants((node, pos) => {
|
|
33
|
-
const attrs =
|
|
33
|
+
const attrs = node.attrs;
|
|
34
34
|
if ((0, transform_1.isAffiliationNode)(node)) {
|
|
35
35
|
nodes.push([node, pos]);
|
|
36
36
|
affiliations.push(attrs);
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.buildCitations = exports.getLatest = exports.buildDecorations = exports.isBibliographyElement = void 0;
|
|
19
19
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
20
|
-
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
21
20
|
const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
|
|
22
21
|
exports.isBibliographyElement = isBibliographyElement;
|
|
23
22
|
const buildDecorations = (state, doc) => {
|
|
@@ -72,7 +71,7 @@ exports.buildDecorations = buildDecorations;
|
|
|
72
71
|
const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
|
|
73
72
|
exports.getLatest = getLatest;
|
|
74
73
|
const buildCitations = (citations) => citations
|
|
75
|
-
.map((c) =>
|
|
74
|
+
.map((c) => c[0].attrs)
|
|
76
75
|
.map((attrs) => ({
|
|
77
76
|
citationID: attrs.id,
|
|
78
77
|
citationItems: attrs.rids.map((rid) => ({
|
|
@@ -63,7 +63,7 @@ let version = 1;
|
|
|
63
63
|
const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
64
64
|
const nodes = [];
|
|
65
65
|
doc.descendants((node, pos) => {
|
|
66
|
-
if ((0, transform_1.isCitationNode)(node)
|
|
66
|
+
if ((0, transform_1.isCitationNode)(node)) {
|
|
67
67
|
nodes.push([node, pos]);
|
|
68
68
|
}
|
|
69
69
|
});
|
|
@@ -117,7 +117,7 @@ const getBibliographyItemAttrs = (doc) => {
|
|
|
117
117
|
const attrs = new Map();
|
|
118
118
|
(0, prosemirror_utils_1.findChildrenByType)(doc, transform_1.schema.nodes.bibliography_item)
|
|
119
119
|
.filter((n) => !(0, track_changes_utils_1.isHidden)(n.node))
|
|
120
|
-
.map((n) =>
|
|
120
|
+
.map((n) => n.node.attrs)
|
|
121
121
|
.forEach((a) => attrs.set(a.id, a));
|
|
122
122
|
return attrs;
|
|
123
123
|
};
|
|
@@ -24,7 +24,6 @@ const prosemirror_utils_1 = require("prosemirror-utils");
|
|
|
24
24
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
25
25
|
const commands_1 = require("../../commands");
|
|
26
26
|
const footnotes_1 = require("../../lib/footnotes");
|
|
27
|
-
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
28
27
|
const placeholder_1 = require("../placeholder");
|
|
29
28
|
const widgets_1 = require("./widgets");
|
|
30
29
|
exports.footnotesKey = new prosemirror_state_1.PluginKey('footnotes');
|
|
@@ -54,7 +53,7 @@ const buildPluginState = (doc) => {
|
|
|
54
53
|
const labels = new Map();
|
|
55
54
|
inlineFootnotes.sort((a, b) => a[1] - b[1]);
|
|
56
55
|
inlineFootnotes.forEach(([node]) => {
|
|
57
|
-
|
|
56
|
+
node.attrs.rids.forEach((rid) => {
|
|
58
57
|
labels.set(rid, (0, footnotes_1.getAlphaOrderIndices)(index++));
|
|
59
58
|
});
|
|
60
59
|
});
|
|
@@ -62,7 +61,7 @@ const buildPluginState = (doc) => {
|
|
|
62
61
|
const unusedFootnotes = new Map(footnotes);
|
|
63
62
|
inlineFootnotes.forEach(([node]) => {
|
|
64
63
|
const footnote = node;
|
|
65
|
-
|
|
64
|
+
footnote.attrs.rids.forEach((rid) => {
|
|
66
65
|
const currentFnNode = unusedFootnotes.get(rid);
|
|
67
66
|
if (currentFnNode) {
|
|
68
67
|
footnotesReordered.push(currentFnNode[0]);
|
|
@@ -97,8 +96,8 @@ exports.default = (props) => {
|
|
|
97
96
|
appendTransaction(transactions, oldState, newState) {
|
|
98
97
|
const { inlineFootnotes: oldInlineFootnoteNodes } = exports.footnotesKey.getState(oldState);
|
|
99
98
|
const { inlineFootnotes: inlineFootnoteNodes, footnotes, labels, footnoteElement, unusedFootnotes, } = exports.footnotesKey.getState(newState);
|
|
100
|
-
const prevIds = oldInlineFootnoteNodes.map(([node]) =>
|
|
101
|
-
const newIds = inlineFootnoteNodes.map(([node]) =>
|
|
99
|
+
const prevIds = oldInlineFootnoteNodes.map(([node]) => node.attrs.rids);
|
|
100
|
+
const newIds = inlineFootnoteNodes.map(([node]) => node.attrs.rids);
|
|
102
101
|
const initTransaction = transactions.find((t) => t.getMeta('INIT'));
|
|
103
102
|
if (!footnoteElement || (!initTransaction && (0, lodash_1.isEqual)(prevIds, newIds))) {
|
|
104
103
|
return null;
|
|
@@ -107,7 +106,7 @@ exports.default = (props) => {
|
|
|
107
106
|
const footnotesReordered = [];
|
|
108
107
|
inlineFootnoteNodes.forEach(([node, pos]) => {
|
|
109
108
|
const footnote = node;
|
|
110
|
-
const attrs =
|
|
109
|
+
const attrs = footnote.attrs;
|
|
111
110
|
const contents = attrs.rids
|
|
112
111
|
.map((rid) => {
|
|
113
112
|
const currentFnNode = footnotes.get(rid);
|
|
@@ -111,8 +111,7 @@ exports.deleteFootnoteWidget = deleteFootnoteWidget;
|
|
|
111
111
|
const scrollToInlineFootnote = (rid, view) => {
|
|
112
112
|
view.state.doc.descendants((node, pos) => {
|
|
113
113
|
const footnote = node;
|
|
114
|
-
if ((0, transform_1.isInlineFootnoteNode)(node) &&
|
|
115
|
-
(0, track_changes_utils_1.getActualAttrs)(footnote).rids.includes(rid)) {
|
|
114
|
+
if ((0, transform_1.isInlineFootnoteNode)(node) && footnote.attrs.rids.includes(rid)) {
|
|
116
115
|
const selection = prosemirror_state_1.NodeSelection.create(view.state.doc, pos);
|
|
117
116
|
view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
|
|
118
117
|
}
|
|
@@ -12,7 +12,7 @@ function cursorAtTheEndOfText(state, nodeSize, nodePos) {
|
|
|
12
12
|
const isUpperCase = (test) => test === test.toUpperCase() && test.length > 1;
|
|
13
13
|
function hasAutoCompletionSlack(parentSection, titleSection) {
|
|
14
14
|
var _a;
|
|
15
|
-
const category =
|
|
15
|
+
const category = parentSection.attrs.category;
|
|
16
16
|
const titles = (_a = section_titles_1.sectionTitles.get(category)) === null || _a === void 0 ? void 0 : _a.split('|');
|
|
17
17
|
if (category && (titles === null || titles === void 0 ? void 0 : titles.length) && titleSection.textContent) {
|
|
18
18
|
const actualTextContent = (0, track_changes_utils_1.getActualTextContent)(titleSection.content);
|
|
@@ -5,14 +5,12 @@ const transform_1 = require("@manuscripts/transform");
|
|
|
5
5
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
6
6
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
7
7
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
8
|
-
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
9
8
|
const autocompletion_1 = require("./autocompletion");
|
|
10
9
|
exports.sectionTitleKey = new prosemirror_state_1.PluginKey('sectionNumbering');
|
|
11
10
|
const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
|
|
12
11
|
node.forEach((childNode, offset) => {
|
|
13
|
-
if (
|
|
14
|
-
childNode.type === transform_1.schema.nodes.box_element)
|
|
15
|
-
!(0, track_changes_utils_1.isRejectedInsert)(childNode)) {
|
|
12
|
+
if (childNode.type === transform_1.schema.nodes.section ||
|
|
13
|
+
childNode.type === transform_1.schema.nodes.box_element) {
|
|
16
14
|
numbering[numbering.length - 1] += 1;
|
|
17
15
|
const sectionNumber = numbering.join('.');
|
|
18
16
|
const sectionStartPos = startPos + offset + 1;
|
package/dist/cjs/versions.js
CHANGED
|
@@ -56,7 +56,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
56
56
|
this.showPopper();
|
|
57
57
|
}
|
|
58
58
|
else if (!(0, track_changes_utils_1.isDeleted)(this.node) && event.button === 0) {
|
|
59
|
-
const attrs =
|
|
59
|
+
const attrs = this.node.attrs;
|
|
60
60
|
if (attrs.rids.length) {
|
|
61
61
|
this.showContextMenu();
|
|
62
62
|
}
|
|
@@ -65,7 +65,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
65
65
|
this.selectNode = () => {
|
|
66
66
|
this.dom.classList.add('ProseMirror-selectednode');
|
|
67
67
|
if (this.can.seeReferencesButtons && !(0, track_changes_utils_1.isDeleted)(this.node)) {
|
|
68
|
-
const attrs =
|
|
68
|
+
const attrs = this.node.attrs;
|
|
69
69
|
if (!attrs.rids.length) {
|
|
70
70
|
this.showPopper();
|
|
71
71
|
}
|
|
@@ -98,7 +98,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
const can = this.props.getCapabilities();
|
|
101
|
-
const attrs =
|
|
101
|
+
const attrs = this.node.attrs;
|
|
102
102
|
const rids = attrs.rids;
|
|
103
103
|
const items = Array.from(bib.bibliographyItems.values());
|
|
104
104
|
if (can.editArticle) {
|
|
@@ -144,7 +144,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
144
144
|
}
|
|
145
145
|
};
|
|
146
146
|
this.handleUncite = (id) => {
|
|
147
|
-
const attrs =
|
|
147
|
+
const attrs = this.node.attrs;
|
|
148
148
|
const rids = attrs.rids.filter((i) => i !== id);
|
|
149
149
|
const pos = this.getPos();
|
|
150
150
|
const tr = this.view.state.tr;
|
|
@@ -162,7 +162,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
162
162
|
if (!bib) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
165
|
-
const attrs =
|
|
165
|
+
const attrs = this.node.attrs;
|
|
166
166
|
const rids = [...attrs.rids];
|
|
167
167
|
items = items.filter((i) => !rids.includes(i.id));
|
|
168
168
|
for (const item of items) {
|
|
@@ -38,11 +38,8 @@ class CrossReferenceView extends base_node_view_1.BaseNodeView {
|
|
|
38
38
|
this.updateContents = () => {
|
|
39
39
|
var _a;
|
|
40
40
|
const targets = objects_1.objectsKey.getState(this.view.state);
|
|
41
|
-
const attrs =
|
|
42
|
-
const classes = [
|
|
43
|
-
'cross-reference',
|
|
44
|
-
...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
|
|
45
|
-
];
|
|
41
|
+
const attrs = this.node.attrs;
|
|
42
|
+
const classes = ['cross-reference', ...(0, track_changes_utils_1.getChangeClasses)(attrs.dataTracked)];
|
|
46
43
|
this.dom.className = classes.join(' ');
|
|
47
44
|
const label = attrs.rids.length && ((_a = targets.get(attrs.rids[0])) === null || _a === void 0 ? void 0 : _a.label);
|
|
48
45
|
this.dom.textContent = attrs.label || label || '';
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.EquationView = void 0;
|
|
19
19
|
const math_1 = require("../lib/math");
|
|
20
|
-
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
21
20
|
const base_node_view_1 = require("./base_node_view");
|
|
22
21
|
const creators_1 = require("./creators");
|
|
23
22
|
class EquationView extends base_node_view_1.BaseNodeView {
|
|
@@ -33,7 +32,7 @@ class EquationView extends base_node_view_1.BaseNodeView {
|
|
|
33
32
|
this.dom.setAttribute('id', this.node.attrs.id);
|
|
34
33
|
};
|
|
35
34
|
this.updateContents = () => {
|
|
36
|
-
this.dom.innerHTML =
|
|
35
|
+
this.dom.innerHTML = this.node.attrs.contents;
|
|
37
36
|
(0, math_1.renderMath)(this.dom);
|
|
38
37
|
};
|
|
39
38
|
this.ignoreMutation = () => true;
|
|
@@ -33,7 +33,6 @@ const react_1 = require("react");
|
|
|
33
33
|
const server_1 = require("react-dom/server");
|
|
34
34
|
const FigureDropdown_1 = require("../components/views/FigureDropdown");
|
|
35
35
|
const files_1 = require("../lib/files");
|
|
36
|
-
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
37
36
|
const creators_1 = require("./creators");
|
|
38
37
|
const figure_1 = require("./figure");
|
|
39
38
|
const figure_uploader_1 = require("./figure_uploader");
|
|
@@ -52,7 +51,7 @@ class FigureEditableView extends figure_1.FigureView {
|
|
|
52
51
|
};
|
|
53
52
|
this.updateContents = () => {
|
|
54
53
|
var _a, _b;
|
|
55
|
-
const attrs =
|
|
54
|
+
const attrs = this.node.attrs;
|
|
56
55
|
if ((_a = this.node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
|
|
57
56
|
const change = this.node.attrs.dataTracked[0];
|
|
58
57
|
this.dom.setAttribute('data-track-status', change.status);
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.InlineEquationView = void 0;
|
|
19
19
|
const math_1 = require("../lib/math");
|
|
20
|
-
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
21
20
|
const base_node_view_1 = require("./base_node_view");
|
|
22
21
|
const creators_1 = require("./creators");
|
|
23
22
|
class InlineEquationView extends base_node_view_1.BaseNodeView {
|
|
@@ -28,21 +27,14 @@ class InlineEquationView extends base_node_view_1.BaseNodeView {
|
|
|
28
27
|
this.updateContents();
|
|
29
28
|
};
|
|
30
29
|
this.updateContents = () => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
this.dom.innerHTML = (0, track_changes_utils_1.getActualAttrs)(this.node).contents;
|
|
36
|
-
(0, math_1.renderMath)(this.dom);
|
|
37
|
-
}
|
|
30
|
+
this.dom.innerHTML = this.node.attrs.contents;
|
|
31
|
+
(0, math_1.renderMath)(this.dom);
|
|
38
32
|
};
|
|
39
33
|
this.ignoreMutation = () => true;
|
|
40
34
|
this.createDOM = () => {
|
|
41
35
|
this.dom = document.createElement('span');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.dom.setAttribute('id', this.node.attrs.id);
|
|
45
|
-
}
|
|
36
|
+
this.dom.classList.add('equation');
|
|
37
|
+
this.dom.setAttribute('id', this.node.attrs.id);
|
|
46
38
|
};
|
|
47
39
|
}
|
|
48
40
|
}
|