@manuscripts/body-editor 2.5.2-LEAN-4053.0 → 2.5.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/commands.js +207 -116
- package/dist/cjs/components/toolbar/LevelSelector.js +1 -1
- package/dist/cjs/components/views/DeleteFootnoteDialog.js +2 -2
- package/dist/cjs/components/views/FootnotesSelector.js +18 -17
- package/dist/cjs/configs/ManuscriptsEditor.js +1 -2
- package/dist/cjs/configs/editor-plugins.js +2 -0
- package/dist/cjs/configs/editor-views.js +4 -6
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/lib/context-menu.js +92 -17
- package/dist/cjs/lib/doc.js +4 -27
- package/dist/cjs/lib/footnotes.js +122 -31
- package/dist/cjs/menus.js +3 -3
- package/dist/cjs/plugins/affiliations.js +1 -2
- package/dist/cjs/plugins/footnotes/index.js +215 -0
- package/dist/cjs/plugins/footnotes/widgets.js +136 -0
- package/dist/cjs/plugins/persist.js +3 -3
- package/dist/cjs/plugins/placeholder.js +12 -19
- package/dist/cjs/plugins/table-footnote.js +46 -0
- package/dist/cjs/testing/default-editor-data.js +1 -1
- package/dist/cjs/testing/setup-editor.js +0 -1
- package/dist/cjs/toolbar.js +2 -2
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/editable_block.js +1 -1
- package/dist/cjs/views/footnote.js +13 -97
- package/dist/cjs/views/footnote_editable.js +21 -0
- package/dist/cjs/views/footnotes_element.js +2 -11
- package/dist/cjs/views/footnotes_element_editable.js +22 -0
- package/dist/cjs/views/inline_footnote.js +124 -74
- package/dist/cjs/views/table_element_footer.js +5 -2
- package/dist/cjs/views/table_element_footer_editable.js +20 -0
- package/dist/es/commands.js +203 -113
- package/dist/es/components/toolbar/LevelSelector.js +1 -1
- package/dist/es/components/views/DeleteFootnoteDialog.js +2 -2
- package/dist/es/components/views/FootnotesSelector.js +18 -17
- package/dist/es/configs/ManuscriptsEditor.js +1 -2
- package/dist/es/configs/editor-plugins.js +2 -0
- package/dist/es/configs/editor-views.js +2 -4
- package/dist/es/index.js +0 -1
- package/dist/es/lib/context-menu.js +92 -20
- package/dist/es/lib/doc.js +4 -25
- package/dist/es/lib/footnotes.js +116 -28
- package/dist/es/menus.js +3 -3
- package/dist/es/plugins/affiliations.js +1 -2
- package/dist/es/plugins/footnotes/index.js +211 -0
- package/dist/es/plugins/footnotes/widgets.js +127 -0
- package/dist/es/plugins/persist.js +3 -3
- package/dist/es/plugins/placeholder.js +11 -20
- package/dist/es/plugins/table-footnote.js +44 -0
- package/dist/es/testing/default-editor-data.js +1 -1
- package/dist/es/testing/setup-editor.js +0 -1
- package/dist/es/toolbar.js +2 -2
- package/dist/es/versions.js +1 -1
- package/dist/es/views/editable_block.js +1 -1
- package/dist/es/views/footnote.js +13 -98
- package/dist/es/views/footnote_editable.js +19 -0
- package/dist/es/views/footnotes_element.js +2 -11
- package/dist/es/views/footnotes_element_editable.js +20 -0
- package/dist/es/views/inline_footnote.js +128 -78
- package/dist/es/views/table_element_footer.js +5 -4
- package/dist/es/views/table_element_footer_editable.js +18 -0
- package/dist/types/commands.d.ts +14 -10
- package/dist/types/components/views/DeleteFootnoteDialog.d.ts +2 -2
- package/dist/types/components/views/FootnotesSelector.d.ts +6 -7
- package/dist/types/configs/editor-views.d.ts +35 -22
- package/dist/types/index.d.ts +0 -1
- package/dist/types/lib/context-menu.d.ts +3 -1
- package/dist/types/lib/doc.d.ts +0 -2
- package/dist/types/lib/footnotes.d.ts +19 -8
- package/dist/types/plugins/{footnotes.d.ts → footnotes/index.d.ts} +11 -14
- package/dist/types/plugins/footnotes/widgets.d.ts +22 -0
- package/dist/types/plugins/placeholder.d.ts +2 -0
- package/dist/types/plugins/table-footnote.d.ts +3 -0
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/footnote.d.ts +6 -13
- package/dist/types/views/footnote_editable.d.ts +51 -0
- package/dist/types/views/footnotes_element.d.ts +0 -1
- package/dist/types/views/footnotes_element_editable.d.ts +51 -0
- package/dist/types/views/inline_footnote.d.ts +14 -8
- package/dist/types/views/table_element_footer.d.ts +2 -2
- package/dist/types/views/{general_table_footnote.d.ts → table_element_footer_editable.d.ts} +2 -11
- package/package.json +2 -2
- package/styles/Editor.css +64 -33
- package/dist/cjs/icons.js +0 -8
- package/dist/cjs/lib/plugins.js +0 -8
- package/dist/cjs/plugins/footnotes.js +0 -188
- package/dist/cjs/views/general_table_footnote.js +0 -83
- package/dist/es/icons.js +0 -5
- package/dist/es/lib/plugins.js +0 -4
- package/dist/es/plugins/footnotes.js +0 -185
- package/dist/es/views/general_table_footnote.js +0 -76
- package/dist/types/icons.d.ts +0 -2
- package/dist/types/lib/plugins.d.ts +0 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.autoComplete = exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertContributors = exports.insertAbstract = exports.insertBackMatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.
|
|
18
|
+
exports.autoComplete = exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.insertBoxElement = exports.insertTableFootnote = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertContributors = exports.insertAbstract = exports.insertBackMatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertTable = exports.insertFigure = exports.insertGeneralFootnote = exports.undoFootnoteDelete = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
|
|
19
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
20
20
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
21
21
|
const transform_1 = require("@manuscripts/transform");
|
|
@@ -34,6 +34,7 @@ const track_changes_utils_1 = require("./lib/track-changes-utils");
|
|
|
34
34
|
const utils_1 = require("./lib/utils");
|
|
35
35
|
const comments_2 = require("./plugins/comments");
|
|
36
36
|
const editor_props_1 = require("./plugins/editor-props");
|
|
37
|
+
const footnotes_2 = require("./plugins/footnotes");
|
|
37
38
|
const autocompletion_1 = require("./plugins/section_title/autocompletion");
|
|
38
39
|
const addToStart = (state, dispatch) => {
|
|
39
40
|
const { selection } = state;
|
|
@@ -91,7 +92,8 @@ exports.blockActive = blockActive;
|
|
|
91
92
|
const canInsert = (type) => (state) => {
|
|
92
93
|
var _a;
|
|
93
94
|
const { $from, $to } = state.selection;
|
|
94
|
-
if (($from.node().type === transform_1.schema.nodes.title ||
|
|
95
|
+
if (($from.node().type === transform_1.schema.nodes.title ||
|
|
96
|
+
$from.node().type === transform_1.schema.nodes.section_title) &&
|
|
95
97
|
$from.pos === $to.pos) {
|
|
96
98
|
return false;
|
|
97
99
|
}
|
|
@@ -160,38 +162,48 @@ const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
|
160
162
|
}
|
|
161
163
|
};
|
|
162
164
|
exports.createBlock = createBlock;
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
if (!table) {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
if (!dispatch) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
return (0, exports.insertInlineFootnote)(state, dispatch);
|
|
165
|
+
const undoFootnoteDelete = (tr, footnote, position) => {
|
|
166
|
+
const updatedAttrs = Object.assign(Object.assign({}, footnote.node.attrs), { dataTracked: null });
|
|
167
|
+
tr.setNodeMarkup(position, undefined, updatedAttrs, footnote.node.marks);
|
|
173
168
|
};
|
|
174
|
-
exports.
|
|
175
|
-
const
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
exports.undoFootnoteDelete = undoFootnoteDelete;
|
|
170
|
+
const insertGeneralFootnote = (tableElementNode, position, view, tableElementFooter) => {
|
|
171
|
+
const { state, dispatch } = view;
|
|
172
|
+
const paragraph = state.schema.nodes.paragraph.create({
|
|
173
|
+
placeholder: 'Add general note here',
|
|
174
|
+
});
|
|
175
|
+
const generalNote = state.schema.nodes.general_table_footnote.create({}, [
|
|
176
|
+
paragraph,
|
|
177
|
+
]);
|
|
178
|
+
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table_colgroup)[0];
|
|
179
|
+
const table = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table)[0];
|
|
180
|
+
const tr = state.tr;
|
|
181
|
+
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
182
|
+
? position + tableElementFooter[0].pos + 2
|
|
183
|
+
: position +
|
|
184
|
+
(!tableColGroup
|
|
185
|
+
? table.pos + table.node.nodeSize
|
|
186
|
+
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
187
|
+
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
188
|
+
if ((0, track_changes_utils_1.isDeleted)(tableElementFooter[0].node)) {
|
|
189
|
+
const tableElementFooterPos = tr.mapping.map(position + tableElementFooter[0].pos + 1);
|
|
190
|
+
(0, exports.undoFootnoteDelete)(tr, tableElementFooter[0], tableElementFooterPos);
|
|
191
|
+
}
|
|
192
|
+
tr.insert(pos, generalNote);
|
|
179
193
|
}
|
|
180
|
-
|
|
181
|
-
|
|
194
|
+
else {
|
|
195
|
+
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
196
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.table_element_footer),
|
|
197
|
+
}, [generalNote]);
|
|
198
|
+
tr.insert(pos, tableElementFooter);
|
|
199
|
+
}
|
|
200
|
+
if (dispatch && pos) {
|
|
201
|
+
const selection = (0, exports.createSelection)(state.schema.nodes.paragraph, pos, tr.doc);
|
|
202
|
+
view === null || view === void 0 ? void 0 : view.focus();
|
|
203
|
+
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
182
204
|
}
|
|
183
|
-
const tr = state.tr;
|
|
184
|
-
const footer = (0, exports.insertTableElementFooter)(tr, element);
|
|
185
|
-
const pos = footer.pos + 1;
|
|
186
|
-
const node = transform_1.schema.nodes.general_table_footnote.create({}, [
|
|
187
|
-
transform_1.schema.nodes.paragraph.create(),
|
|
188
|
-
]);
|
|
189
|
-
tr.insert(pos, node);
|
|
190
|
-
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 1);
|
|
191
|
-
tr.setSelection(selection).scrollIntoView();
|
|
192
|
-
dispatch(tr);
|
|
193
205
|
};
|
|
194
|
-
exports.
|
|
206
|
+
exports.insertGeneralFootnote = insertGeneralFootnote;
|
|
195
207
|
const insertFigure = (file, state, dispatch) => {
|
|
196
208
|
const position = findBlockInsertPosition(state);
|
|
197
209
|
if (position === null || !dispatch) {
|
|
@@ -392,107 +404,88 @@ const insertInlineEquation = (state, dispatch) => {
|
|
|
392
404
|
return true;
|
|
393
405
|
};
|
|
394
406
|
exports.insertInlineEquation = insertInlineEquation;
|
|
395
|
-
const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
reinstateNode(tr, footer.node, pos);
|
|
401
|
-
}
|
|
402
|
-
return {
|
|
403
|
-
node: footer.node,
|
|
404
|
-
pos,
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
const pos = tr.mapping.map(table[1] + table[0].nodeSize - 2);
|
|
408
|
-
const node = transform_1.schema.nodes.table_element_footer.create();
|
|
409
|
-
tr.insert(pos, node);
|
|
410
|
-
return {
|
|
411
|
-
node,
|
|
412
|
-
pos,
|
|
413
|
-
};
|
|
407
|
+
const createFootnote = (state, kind) => {
|
|
408
|
+
return transform_1.schema.nodes.footnote.createAndFill({
|
|
409
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.footnote),
|
|
410
|
+
kind,
|
|
411
|
+
});
|
|
414
412
|
};
|
|
415
|
-
exports.
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
413
|
+
exports.createFootnote = createFootnote;
|
|
414
|
+
const insertFootnote = (state, tr, footnote) => {
|
|
415
|
+
const footnotesSection = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_section)[0];
|
|
416
|
+
let selectionPos = 0;
|
|
417
|
+
if (!footnotesSection) {
|
|
418
|
+
const section = state.schema.nodes.footnotes_section.create({}, [
|
|
419
|
+
state.schema.nodes.section_title.create({}, state.schema.text('Footnotes')),
|
|
420
|
+
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
421
|
+
]);
|
|
422
|
+
const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
|
|
423
|
+
const sectionPos = backmatter.pos + 1;
|
|
424
|
+
tr.insert(sectionPos, section);
|
|
425
|
+
let footnotePos = 0;
|
|
426
|
+
section.descendants((n, pos) => {
|
|
427
|
+
if ((0, transform_1.isFootnoteNode)(n)) {
|
|
428
|
+
footnotePos = pos;
|
|
429
|
+
n.descendants((childNode, childPos) => {
|
|
430
|
+
if ((0, transform_1.isParagraphNode)(childNode)) {
|
|
431
|
+
footnotePos += childPos;
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
selectionPos = sectionPos + footnotePos;
|
|
421
437
|
}
|
|
422
438
|
else {
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
const footnote = !hasUnusedFootnotes && (0, footnotes_1.createFootnote)();
|
|
438
|
-
const node = transform_1.schema.nodes.inline_footnote.create({
|
|
439
|
-
rids: footnote ? [footnote.attrs.id] : [],
|
|
440
|
-
});
|
|
441
|
-
tr.insert(pos, node);
|
|
442
|
-
if (footnote) {
|
|
443
|
-
let element;
|
|
444
|
-
if (fn) {
|
|
445
|
-
element = [fn.element[0], tr.mapping.map(fn.element[1])];
|
|
439
|
+
const footnoteElement = (0, prosemirror_utils_1.findChildrenByType)(footnotesSection.node, transform_1.schema.nodes.footnotes_element).pop();
|
|
440
|
+
if (footnoteElement) {
|
|
441
|
+
if ((0, track_changes_utils_1.isDeleted)(footnoteElement.node)) {
|
|
442
|
+
const footnoteElementPos = footnotesSection.pos + footnoteElement.pos + 1;
|
|
443
|
+
(0, exports.undoFootnoteDelete)(tr, footnoteElement, footnoteElementPos);
|
|
444
|
+
const updatedAttrs = Object.assign(Object.assign({}, footnoteElement.node.attrs), { dataTracked: null });
|
|
445
|
+
tr.setNodeMarkup(footnoteElementPos, undefined, updatedAttrs, footnoteElement.node.marks);
|
|
446
|
+
}
|
|
447
|
+
const pos = footnotesSection.pos +
|
|
448
|
+
footnoteElement.pos +
|
|
449
|
+
footnoteElement.node.nodeSize -
|
|
450
|
+
1;
|
|
451
|
+
tr.insert(pos, footnote);
|
|
452
|
+
selectionPos = pos + 2;
|
|
446
453
|
}
|
|
447
454
|
else {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
455
|
+
const footnoteElement = transform_1.schema.nodes.footnotes_element.create({}, footnote);
|
|
456
|
+
const pos = footnotesSection.pos + footnotesSection.node.nodeSize - 1;
|
|
457
|
+
tr.insert(pos, footnoteElement);
|
|
458
|
+
selectionPos = pos + 2;
|
|
452
459
|
}
|
|
453
|
-
const fnPos = element[1] + element[0].nodeSize - 1;
|
|
454
|
-
tr.insert(fnPos, footnote);
|
|
455
|
-
const selection = prosemirror_state_1.TextSelection.create(tr.doc, fnPos + 2);
|
|
456
|
-
tr.setSelection(selection).scrollIntoView();
|
|
457
460
|
}
|
|
458
|
-
|
|
459
|
-
const selection = prosemirror_state_1.
|
|
461
|
+
if (selectionPos) {
|
|
462
|
+
const selection = prosemirror_state_1.TextSelection.near(tr.doc.resolve(selectionPos));
|
|
460
463
|
tr.setSelection(selection).scrollIntoView();
|
|
461
464
|
}
|
|
462
|
-
|
|
463
|
-
dispatch(tr);
|
|
464
|
-
}
|
|
465
|
-
return true;
|
|
466
|
-
};
|
|
467
|
-
exports.insertInlineFootnote = insertInlineFootnote;
|
|
468
|
-
const reinstateNode = (tr, node, pos) => {
|
|
469
|
-
const attrs = Object.assign(Object.assign({}, node.attrs), { dataTracked: null });
|
|
470
|
-
tr.setNodeMarkup(pos, null, attrs);
|
|
465
|
+
return tr;
|
|
471
466
|
};
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
|
|
467
|
+
exports.insertFootnote = insertFootnote;
|
|
468
|
+
const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
469
|
+
const fnState = footnotes_2.footnotesKey.getState(state);
|
|
470
|
+
const hasUnusedNodes = fnState && fnState.unusedFootnotes.size > 0;
|
|
471
|
+
const footnote = !hasUnusedNodes
|
|
472
|
+
? (0, exports.createFootnote)(state, kind)
|
|
473
|
+
: null;
|
|
474
|
+
const insertedAt = state.selection.to;
|
|
475
|
+
let tr = state.tr;
|
|
476
|
+
const node = state.schema.nodes.inline_footnote.create({
|
|
477
|
+
rids: footnote ? [footnote.attrs.id] : [],
|
|
478
|
+
});
|
|
479
|
+
tr.insert(insertedAt, node);
|
|
480
|
+
if (footnote) {
|
|
481
|
+
tr = (0, exports.insertFootnote)(state, tr, footnote);
|
|
478
482
|
}
|
|
479
|
-
|
|
480
|
-
const paragraph = transform_1.schema.nodes.paragraph.create({});
|
|
481
|
-
const section = transform_1.schema.nodes.section.createAndFill({}, [
|
|
482
|
-
transform_1.schema.nodes.section_title.create(),
|
|
483
|
-
paragraph,
|
|
484
|
-
]);
|
|
485
|
-
const node = transform_1.schema.nodes.box_element.createAndFill({}, [
|
|
486
|
-
transform_1.schema.nodes.figcaption.create({}, [transform_1.schema.nodes.caption_title.create()]),
|
|
487
|
-
section,
|
|
488
|
-
]);
|
|
489
|
-
if (position && dispatch) {
|
|
490
|
-
const tr = state.tr.insert(position, node);
|
|
483
|
+
if (dispatch) {
|
|
491
484
|
dispatch(tr);
|
|
492
485
|
}
|
|
493
486
|
return true;
|
|
494
487
|
};
|
|
495
|
-
exports.
|
|
488
|
+
exports.insertInlineFootnote = insertInlineFootnote;
|
|
496
489
|
const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
497
490
|
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.graphical_abstract_section, true)) {
|
|
498
491
|
return false;
|
|
@@ -1027,6 +1020,104 @@ const addInlineComment = (state, dispatch) => {
|
|
|
1027
1020
|
return false;
|
|
1028
1021
|
};
|
|
1029
1022
|
exports.addInlineComment = addInlineComment;
|
|
1023
|
+
const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) => {
|
|
1024
|
+
const { state, dispatch } = view;
|
|
1025
|
+
const tr = state.tr;
|
|
1026
|
+
const footnote = transform_1.schema.nodes.footnote.createAndFill({
|
|
1027
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.footnote),
|
|
1028
|
+
kind: 'footnote',
|
|
1029
|
+
});
|
|
1030
|
+
const insertedAt = state.selection.to;
|
|
1031
|
+
let footnoteIndex;
|
|
1032
|
+
if (inlineFootnote) {
|
|
1033
|
+
const contents = inlineFootnote.node.attrs.contents.split(',').map(Number);
|
|
1034
|
+
footnoteIndex = Math.max(...contents) + 1;
|
|
1035
|
+
tr.setNodeMarkup(inlineFootnote.pos, undefined, {
|
|
1036
|
+
rids: [...inlineFootnote.node.attrs.rids, footnote.attrs.id],
|
|
1037
|
+
contents: inlineFootnote.node.attrs.contents + ',' + footnoteIndex,
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
else {
|
|
1041
|
+
const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.inline_footnote);
|
|
1042
|
+
footnoteIndex =
|
|
1043
|
+
inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
|
|
1044
|
+
1;
|
|
1045
|
+
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
1046
|
+
rids: [footnote.attrs.id],
|
|
1047
|
+
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
1048
|
+
});
|
|
1049
|
+
tr.insert(insertedAt, inlineFootnoteNode);
|
|
1050
|
+
}
|
|
1051
|
+
let insertionPos = position;
|
|
1052
|
+
const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.footnotes_element).pop();
|
|
1053
|
+
if (footnotesElement) {
|
|
1054
|
+
if ((0, track_changes_utils_1.isDeleted)(footnotesElement.node)) {
|
|
1055
|
+
const footnotesElementPos = tr.mapping.map(position + footnotesElement.pos + 1);
|
|
1056
|
+
(0, exports.undoFootnoteDelete)(tr, footnotesElement, footnotesElementPos);
|
|
1057
|
+
}
|
|
1058
|
+
const footnotePos = (0, footnotes_1.getNewFootnotePos)(footnotesElement, footnoteIndex);
|
|
1059
|
+
insertionPos = tr.mapping.map(position + footnotePos);
|
|
1060
|
+
tr.insert(insertionPos, footnote);
|
|
1061
|
+
}
|
|
1062
|
+
else {
|
|
1063
|
+
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
1064
|
+
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table_element_footer)[0];
|
|
1065
|
+
if (tableElementFooter) {
|
|
1066
|
+
if ((0, track_changes_utils_1.isDeleted)(tableElementFooter.node)) {
|
|
1067
|
+
const tableElementFooterPos = tr.mapping.map(position + tableElementFooter.pos + 1);
|
|
1068
|
+
(0, exports.undoFootnoteDelete)(tr, tableElementFooter, tableElementFooterPos);
|
|
1069
|
+
}
|
|
1070
|
+
const pos = tableElementFooter.pos;
|
|
1071
|
+
insertionPos = position + pos + tableElementFooter.node.nodeSize;
|
|
1072
|
+
tr.insert(tr.mapping.map(insertionPos), footnoteElement);
|
|
1073
|
+
}
|
|
1074
|
+
else {
|
|
1075
|
+
const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
|
|
1076
|
+
id: (0, transform_1.generateNodeID)(transform_1.schema.nodes.table_element_footer),
|
|
1077
|
+
}, [footnoteElement]);
|
|
1078
|
+
const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table_colgroup)[0];
|
|
1079
|
+
const table = (0, prosemirror_utils_1.findChildrenByType)(tableElementNode, transform_1.schema.nodes.table)[0];
|
|
1080
|
+
if (tableColGroup) {
|
|
1081
|
+
insertionPos =
|
|
1082
|
+
position + tableColGroup.pos + tableColGroup.node.nodeSize;
|
|
1083
|
+
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
insertionPos = position + table.pos + table.node.nodeSize;
|
|
1087
|
+
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
dispatch(tr);
|
|
1092
|
+
const textSelection = prosemirror_state_1.TextSelection.near(view.state.tr.doc.resolve(insertionPos + 1));
|
|
1093
|
+
view.focus();
|
|
1094
|
+
dispatch(view.state.tr.setSelection(textSelection).scrollIntoView());
|
|
1095
|
+
};
|
|
1096
|
+
exports.insertTableFootnote = insertTableFootnote;
|
|
1097
|
+
const insertBoxElement = (state, dispatch) => {
|
|
1098
|
+
const selection = state.selection;
|
|
1099
|
+
const isBody = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(selection);
|
|
1100
|
+
const isBoxText = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection);
|
|
1101
|
+
if (!isBody || isBoxText) {
|
|
1102
|
+
return false;
|
|
1103
|
+
}
|
|
1104
|
+
const position = findBlockInsertPosition(state);
|
|
1105
|
+
const paragraph = transform_1.schema.nodes.paragraph.create({});
|
|
1106
|
+
const section = transform_1.schema.nodes.section.createAndFill({}, [
|
|
1107
|
+
transform_1.schema.nodes.section_title.create(),
|
|
1108
|
+
paragraph,
|
|
1109
|
+
]);
|
|
1110
|
+
const BoxElementNode = transform_1.schema.nodes.box_element.createAndFill({}, [
|
|
1111
|
+
transform_1.schema.nodes.figcaption.create({}, [transform_1.schema.nodes.caption_title.create()]),
|
|
1112
|
+
section,
|
|
1113
|
+
]);
|
|
1114
|
+
if (position && dispatch) {
|
|
1115
|
+
const tr = state.tr.insert(position, BoxElementNode);
|
|
1116
|
+
dispatch(tr);
|
|
1117
|
+
}
|
|
1118
|
+
return true;
|
|
1119
|
+
};
|
|
1120
|
+
exports.insertBoxElement = insertBoxElement;
|
|
1030
1121
|
const addRows = (direction) => (state, dispatch) => {
|
|
1031
1122
|
if (dispatch) {
|
|
1032
1123
|
const { tr } = state;
|
|
@@ -33,7 +33,7 @@ const optionName = (nodeType, depth, listType) => {
|
|
|
33
33
|
case nodeType.schema.nodes.section:
|
|
34
34
|
return (depth > 0 ? 'sub'.repeat(depth - 1) : '') + 'section heading';
|
|
35
35
|
case nodeType.schema.nodes.list:
|
|
36
|
-
return listType === 'order' ? 'Ordered
|
|
36
|
+
return listType === 'order' ? 'Ordered list' : 'Bulleted list';
|
|
37
37
|
default:
|
|
38
38
|
return transform_1.nodeNames.get(nodeType) || nodeType.name;
|
|
39
39
|
}
|
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.DeleteFootnoteDialog = void 0;
|
|
27
27
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
28
28
|
const react_1 = __importStar(require("react"));
|
|
29
|
-
const DeleteFootnoteDialog = ({
|
|
29
|
+
const DeleteFootnoteDialog = ({ footnoteType, footnoteMessage, handleDelete, }) => {
|
|
30
30
|
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
31
31
|
return (react_1.default.createElement(style_guide_1.Dialog, { className: "delete-footnote-dialog", isOpen: isOpen, actions: {
|
|
32
32
|
primary: {
|
|
@@ -40,6 +40,6 @@ const DeleteFootnoteDialog = ({ header, message, handleDelete, }) => {
|
|
|
40
40
|
action: () => setOpen(false),
|
|
41
41
|
title: 'Cancel',
|
|
42
42
|
},
|
|
43
|
-
}, category: style_guide_1.Category.confirmation, header:
|
|
43
|
+
}, category: style_guide_1.Category.confirmation, header: `Delete ${footnoteType}`, message: `${footnoteMessage}` }));
|
|
44
44
|
};
|
|
45
45
|
exports.DeleteFootnoteDialog = DeleteFootnoteDialog;
|
|
@@ -76,12 +76,12 @@ const AddNewFootnote = (0, styled_components_1.default)(style_guide_1.ButtonGrou
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
`;
|
|
79
|
-
const FootnotesSelector = ({
|
|
79
|
+
const FootnotesSelector = ({ notes, inlineFootnote, onAdd, onInsert, onCancel, addNewLabel }) => {
|
|
80
80
|
let selectedNotesMap;
|
|
81
81
|
if (inlineFootnote) {
|
|
82
82
|
const rids = inlineFootnote.attrs.rids;
|
|
83
|
-
const selectedNotes =
|
|
84
|
-
selectedNotesMap = new Map(selectedNotes.map((node) => [node.attrs.id, node]));
|
|
83
|
+
const selectedNotes = notes.filter(({ node }) => rids.includes(node.attrs.id));
|
|
84
|
+
selectedNotesMap = new Map(selectedNotes.map(({ node }) => [node.attrs.id, node]));
|
|
85
85
|
}
|
|
86
86
|
const [selections, setSelections] = (0, react_1.useState)(new Map(selectedNotesMap));
|
|
87
87
|
const toggleSelection = (item) => {
|
|
@@ -99,11 +99,11 @@ const FootnotesSelector = ({ footnotes, inlineFootnote, labels, onAdd, onInsert,
|
|
|
99
99
|
return selections.has(item.attrs.id);
|
|
100
100
|
};
|
|
101
101
|
const handleClick = () => {
|
|
102
|
-
return onInsert(
|
|
102
|
+
return onInsert(notes.filter(({ node }) => selections.has(node.attrs.id)));
|
|
103
103
|
};
|
|
104
104
|
return (react_1.default.createElement(Container, null,
|
|
105
105
|
react_1.default.createElement(NotesContainer, null,
|
|
106
|
-
react_1.default.createElement(FootnotesList, {
|
|
106
|
+
react_1.default.createElement(FootnotesList, { notes: notes, inlineFootnote: inlineFootnote, isSelected: isSelected, onSelect: toggleSelection })),
|
|
107
107
|
react_1.default.createElement(Actions, null,
|
|
108
108
|
react_1.default.createElement(AddNewFootnote, null,
|
|
109
109
|
react_1.default.createElement(style_guide_1.IconTextButton, { onClick: onAdd },
|
|
@@ -114,28 +114,29 @@ const FootnotesSelector = ({ footnotes, inlineFootnote, labels, onAdd, onInsert,
|
|
|
114
114
|
react_1.default.createElement(style_guide_1.PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 && !inlineFootnote }, inlineFootnote ? 'Update' : 'Insert')))));
|
|
115
115
|
};
|
|
116
116
|
exports.FootnotesSelector = FootnotesSelector;
|
|
117
|
-
const FootnotesList = ({
|
|
118
|
-
const rids = inlineFootnote === null || inlineFootnote === void 0 ? void 0 : inlineFootnote.attrs.rids;
|
|
117
|
+
const FootnotesList = ({ notes, isSelected, onSelect, inlineFootnote }) => {
|
|
119
118
|
const selectedNotes = [];
|
|
120
119
|
const remainingNotes = [];
|
|
121
|
-
|
|
122
|
-
const isNoteSelected =
|
|
120
|
+
notes.forEach((note) => {
|
|
121
|
+
const isNoteSelected = inlineFootnote && inlineFootnote.attrs.rids.includes(note.node.attrs.id);
|
|
123
122
|
if (isNoteSelected) {
|
|
124
|
-
selectedNotes.push(
|
|
123
|
+
selectedNotes.push(note);
|
|
125
124
|
}
|
|
126
125
|
else {
|
|
127
|
-
remainingNotes.push(
|
|
126
|
+
remainingNotes.push(note);
|
|
128
127
|
}
|
|
129
128
|
});
|
|
130
129
|
return (react_1.default.createElement(NotesListContainer, null,
|
|
131
|
-
selectedNotes.map((
|
|
130
|
+
selectedNotes.map((note) => (react_1.default.createElement(FootnoteItem, { key: note.node.attrs.id, note: note, isSelected: isSelected, onSelect: onSelect }))),
|
|
132
131
|
selectedNotes.length > 0 && remainingNotes.length > 0 && react_1.default.createElement(Separator, null),
|
|
133
|
-
remainingNotes.map((
|
|
132
|
+
remainingNotes.map((note) => (react_1.default.createElement(FootnoteItem, { key: note.node.attrs.id, note: note, isSelected: isSelected, onSelect: onSelect })))));
|
|
134
133
|
};
|
|
135
|
-
const FootnoteItem = ({
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
const FootnoteItem = ({ note, isSelected, onSelect }) => {
|
|
135
|
+
var _a;
|
|
136
|
+
const { node, index } = note;
|
|
137
|
+
return (react_1.default.createElement(FootnoteItemContainer, { onClick: () => onSelect(node) },
|
|
138
|
+
react_1.default.createElement(StatusIcon, null, isSelected(node) ? (react_1.default.createElement(style_guide_1.AddedIcon, { "data-cy": 'plus-icon-ok' })) : (react_1.default.createElement(style_guide_1.AddIcon, { "data-cy": 'plus-icon' }))),
|
|
139
|
+
react_1.default.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
|
|
139
140
|
};
|
|
140
141
|
const Separator = styled_components_1.default.div `
|
|
141
142
|
height: 0;
|
|
@@ -26,7 +26,6 @@ const prosemirror_view_1 = require("prosemirror-view");
|
|
|
26
26
|
const clipboard_1 = require("../clipboard");
|
|
27
27
|
const helpers_1 = require("../lib/helpers");
|
|
28
28
|
const paste_1 = require("../lib/paste");
|
|
29
|
-
const plugins_1 = require("../lib/plugins");
|
|
30
29
|
const editor_plugins_1 = __importDefault(require("./editor-plugins"));
|
|
31
30
|
const editor_views_1 = __importDefault(require("./editor-views"));
|
|
32
31
|
const createEditorState = (props) => prosemirror_state_1.EditorState.create({
|
|
@@ -59,7 +58,7 @@ const createEditorView = (props, root, state, dispatch) => {
|
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
});
|
|
62
|
-
const tr = view.state.tr.setMeta(
|
|
61
|
+
const tr = view.state.tr.setMeta('INIT', true);
|
|
63
62
|
const nextState = view.state.apply(tr);
|
|
64
63
|
view.updateState(nextState);
|
|
65
64
|
return view;
|
|
@@ -41,6 +41,7 @@ const section_title_1 = __importDefault(require("../plugins/section_title"));
|
|
|
41
41
|
const section_category_1 = __importDefault(require("../plugins/section-category"));
|
|
42
42
|
const sections_1 = __importDefault(require("../plugins/sections"));
|
|
43
43
|
const selected_suggestion_1 = __importDefault(require("../plugins/selected-suggestion"));
|
|
44
|
+
const table_footnote_1 = __importDefault(require("../plugins/table-footnote"));
|
|
44
45
|
const tables_cursor_fix_1 = __importDefault(require("../plugins/tables-cursor-fix"));
|
|
45
46
|
const toc_1 = __importDefault(require("../plugins/toc"));
|
|
46
47
|
const rules_1 = __importDefault(require("../rules"));
|
|
@@ -72,6 +73,7 @@ exports.default = (props) => {
|
|
|
72
73
|
(0, prosemirror_tables_1.tableEditing)(),
|
|
73
74
|
(0, selected_suggestion_1.default)(),
|
|
74
75
|
(0, footnotes_1.default)(props),
|
|
76
|
+
(0, table_footnote_1.default)(),
|
|
75
77
|
(0, editor_props_1.default)(props),
|
|
76
78
|
(0, doi_1.default)(),
|
|
77
79
|
(0, section_category_1.default)(props),
|
|
@@ -31,9 +31,8 @@ const equation_editable_1 = __importDefault(require("../views/equation_editable"
|
|
|
31
31
|
const equation_element_editable_1 = __importDefault(require("../views/equation_element_editable"));
|
|
32
32
|
const figure_editable_1 = __importDefault(require("../views/figure_editable"));
|
|
33
33
|
const figure_element_editable_1 = __importDefault(require("../views/figure_element_editable"));
|
|
34
|
-
const
|
|
34
|
+
const footnote_editable_1 = __importDefault(require("../views/footnote_editable"));
|
|
35
35
|
const footnotes_element_1 = __importDefault(require("../views/footnotes_element"));
|
|
36
|
-
const general_table_footnote_1 = __importDefault(require("../views/general_table_footnote"));
|
|
37
36
|
const inline_equation_editable_1 = __importDefault(require("../views/inline_equation_editable"));
|
|
38
37
|
const inline_footnote_editable_1 = __importDefault(require("../views/inline_footnote_editable"));
|
|
39
38
|
const keyword_1 = __importDefault(require("../views/keyword"));
|
|
@@ -50,7 +49,7 @@ const section_label_1 = __importDefault(require("../views/section_label"));
|
|
|
50
49
|
const section_title_editable_1 = __importDefault(require("../views/section_title_editable"));
|
|
51
50
|
const table_cell_1 = __importDefault(require("../views/table_cell"));
|
|
52
51
|
const table_element_editable_1 = __importDefault(require("../views/table_element_editable"));
|
|
53
|
-
const
|
|
52
|
+
const table_element_footer_editable_1 = __importDefault(require("../views/table_element_footer_editable"));
|
|
54
53
|
const title_editable_1 = __importDefault(require("../views/title_editable"));
|
|
55
54
|
const toc_element_editable_1 = __importDefault(require("../views/toc_element_editable"));
|
|
56
55
|
exports.default = (props, dispatch) => {
|
|
@@ -67,9 +66,8 @@ exports.default = (props, dispatch) => {
|
|
|
67
66
|
equation_element: (0, equation_element_editable_1.default)(props),
|
|
68
67
|
figure: (0, figure_editable_1.default)(props, dispatch),
|
|
69
68
|
figure_element: (0, figure_element_editable_1.default)(props, dispatch),
|
|
70
|
-
footnote: (0,
|
|
69
|
+
footnote: (0, footnote_editable_1.default)(props),
|
|
71
70
|
footnotes_element: (0, footnotes_element_1.default)(props),
|
|
72
|
-
general_table_footnote: (0, general_table_footnote_1.default)(props, dispatch),
|
|
73
71
|
inline_equation: (0, inline_equation_editable_1.default)(props),
|
|
74
72
|
inline_footnote: (0, inline_footnote_editable_1.default)(props, dispatch),
|
|
75
73
|
keyword: (0, keyword_1.default)(props, dispatch),
|
|
@@ -87,7 +85,7 @@ exports.default = (props, dispatch) => {
|
|
|
87
85
|
table_element: (0, table_element_editable_1.default)(props),
|
|
88
86
|
table_cell: (0, table_cell_1.default)(props),
|
|
89
87
|
table_header: (0, table_cell_1.default)(props),
|
|
90
|
-
table_element_footer: (0,
|
|
88
|
+
table_element_footer: (0, table_element_footer_editable_1.default)(props),
|
|
91
89
|
toc_element: (0, toc_element_editable_1.default)(props),
|
|
92
90
|
comments: (0, empty_1.default)('comments'),
|
|
93
91
|
supplements: (0, empty_1.default)('supplements'),
|
package/dist/cjs/index.js
CHANGED
|
@@ -47,7 +47,6 @@ Object.defineProperty(exports, "PopperManager", { enumerable: true, get: functio
|
|
|
47
47
|
__exportStar(require("./toolbar"), exports);
|
|
48
48
|
__exportStar(require("./lib/comments"), exports);
|
|
49
49
|
__exportStar(require("./lib/files"), exports);
|
|
50
|
-
__exportStar(require("./lib/footnotes"), exports);
|
|
51
50
|
__exportStar(require("./lib/doc"), exports);
|
|
52
51
|
__exportStar(require("./plugins/comments"), exports);
|
|
53
52
|
var selected_suggestion_1 = require("./plugins/selected-suggestion");
|