@manuscripts/body-editor 2.5.6-date-fix.0 → 2.5.7
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 +121 -211
- package/dist/cjs/components/views/DeleteFootnoteDialog.js +2 -2
- package/dist/cjs/components/views/FootnotesSelector.js +18 -19
- package/dist/cjs/configs/ManuscriptsEditor.js +2 -1
- package/dist/cjs/configs/editor-plugins.js +0 -2
- package/dist/cjs/configs/editor-views.js +6 -4
- package/dist/cjs/icons.js +8 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/lib/comments.js +5 -1
- package/dist/cjs/lib/context-menu.js +21 -101
- package/dist/cjs/lib/doc.js +27 -4
- package/dist/cjs/lib/footnotes.js +31 -122
- package/dist/cjs/lib/plugins.js +8 -0
- package/dist/cjs/menus.js +1 -1
- package/dist/cjs/plugins/affiliations.js +2 -1
- package/dist/cjs/plugins/comments.js +10 -8
- package/dist/cjs/plugins/footnotes.js +188 -0
- package/dist/cjs/plugins/persist.js +4 -4
- package/dist/cjs/plugins/placeholder.js +19 -12
- package/dist/cjs/testing/default-editor-data.js +1 -1
- package/dist/cjs/testing/setup-editor.js +1 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/editable_block.js +1 -1
- package/dist/cjs/views/footnote.js +117 -13
- package/dist/cjs/views/footnotes_element.js +10 -2
- package/dist/cjs/views/general_table_footnote.js +83 -0
- package/dist/cjs/views/inline_footnote.js +74 -124
- package/dist/cjs/views/table_element_footer.js +2 -5
- package/dist/es/commands.js +118 -207
- package/dist/es/components/views/DeleteFootnoteDialog.js +2 -2
- package/dist/es/components/views/FootnotesSelector.js +18 -19
- package/dist/es/configs/ManuscriptsEditor.js +2 -1
- package/dist/es/configs/editor-plugins.js +0 -2
- package/dist/es/configs/editor-views.js +4 -2
- package/dist/es/icons.js +5 -0
- package/dist/es/index.js +1 -0
- package/dist/es/lib/comments.js +3 -0
- package/dist/es/lib/context-menu.js +24 -101
- package/dist/es/lib/doc.js +25 -4
- package/dist/es/lib/footnotes.js +28 -116
- package/dist/es/lib/plugins.js +4 -0
- package/dist/es/menus.js +1 -1
- package/dist/es/plugins/affiliations.js +2 -1
- package/dist/es/plugins/comments.js +11 -9
- package/dist/es/plugins/footnotes.js +185 -0
- package/dist/es/plugins/persist.js +4 -4
- package/dist/es/plugins/placeholder.js +20 -11
- package/dist/es/testing/default-editor-data.js +1 -1
- package/dist/es/testing/setup-editor.js +1 -0
- package/dist/es/versions.js +1 -1
- package/dist/es/views/editable_block.js +1 -1
- package/dist/es/views/footnote.js +118 -13
- package/dist/es/views/footnotes_element.js +10 -2
- package/dist/es/views/general_table_footnote.js +76 -0
- package/dist/es/views/inline_footnote.js +78 -128
- package/dist/es/views/table_element_footer.js +4 -5
- package/dist/types/commands.d.ts +10 -14
- package/dist/types/components/views/DeleteFootnoteDialog.d.ts +2 -2
- package/dist/types/components/views/FootnotesSelector.d.ts +7 -7
- package/dist/types/configs/editor-views.d.ts +22 -35
- package/dist/types/icons.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/comments.d.ts +1 -0
- package/dist/types/lib/context-menu.d.ts +1 -3
- package/dist/types/lib/doc.d.ts +2 -0
- package/dist/types/lib/footnotes.d.ts +8 -19
- package/dist/types/lib/plugins.d.ts +3 -0
- package/dist/types/plugins/{footnotes/index.d.ts → footnotes.d.ts} +14 -11
- package/dist/types/plugins/placeholder.d.ts +0 -2
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/footnote.d.ts +14 -6
- package/dist/types/views/footnotes_element.d.ts +1 -0
- package/dist/types/views/{table_element_footer_editable.d.ts → general_table_footnote.d.ts} +11 -2
- package/dist/types/views/inline_footnote.d.ts +8 -14
- package/dist/types/views/table_element_footer.d.ts +2 -2
- package/package.json +3 -3
- package/styles/Editor.css +35 -64
- package/dist/cjs/plugins/footnotes/index.js +0 -215
- package/dist/cjs/plugins/footnotes/widgets.js +0 -136
- package/dist/cjs/plugins/table-footnote.js +0 -46
- package/dist/cjs/views/footnote_editable.js +0 -21
- package/dist/cjs/views/footnotes_element_editable.js +0 -22
- package/dist/cjs/views/table_element_footer_editable.js +0 -20
- package/dist/es/plugins/footnotes/index.js +0 -211
- package/dist/es/plugins/footnotes/widgets.js +0 -127
- package/dist/es/plugins/table-footnote.js +0 -44
- package/dist/es/views/footnote_editable.js +0 -19
- package/dist/es/views/footnotes_element_editable.js +0 -20
- package/dist/es/views/table_element_footer_editable.js +0 -18
- package/dist/types/plugins/footnotes/widgets.d.ts +0 -22
- package/dist/types/plugins/table-footnote.d.ts +0 -3
- package/dist/types/views/footnote_editable.d.ts +0 -51
- package/dist/types/views/footnotes_element_editable.d.ts +0 -51
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.TableElementFooterView = void 0;
|
|
19
18
|
const base_node_view_1 = require("./base_node_view");
|
|
20
19
|
const creators_1 = require("./creators");
|
|
21
20
|
class TableElementFooterView extends base_node_view_1.BaseNodeView {
|
|
@@ -28,10 +27,8 @@ class TableElementFooterView extends base_node_view_1.BaseNodeView {
|
|
|
28
27
|
this.dom = document.createElement('div');
|
|
29
28
|
this.dom.classList.add('table-footer');
|
|
30
29
|
this.dom.setAttribute('id', this.node.attrs.id);
|
|
31
|
-
this.contentDOM =
|
|
32
|
-
this.dom.appendChild(this.contentDOM);
|
|
30
|
+
this.contentDOM = this.dom;
|
|
33
31
|
};
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
exports.
|
|
37
|
-
exports.default = (0, creators_1.createNodeView)(TableElementFooterView);
|
|
34
|
+
exports.default = (0, creators_1.createEditableNodeView)(TableElementFooterView);
|
package/dist/es/commands.js
CHANGED
|
@@ -15,23 +15,22 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { buildContribution } from '@manuscripts/json-schema';
|
|
17
17
|
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
|
18
|
-
import { generateNodeID, isElementNodeType,
|
|
18
|
+
import { generateNodeID, isElementNodeType, isListNode, isSectionNodeType, isTableElementNode, schema, } from '@manuscripts/transform';
|
|
19
19
|
import { Fragment, NodeRange, } from 'prosemirror-model';
|
|
20
20
|
import { wrapInList } from 'prosemirror-schema-list';
|
|
21
21
|
import { NodeSelection, TextSelection, } from 'prosemirror-state';
|
|
22
22
|
import { addColSpan, addColumnAfter, addColumnBefore, addRow, CellSelection, selectedRect, } from 'prosemirror-tables';
|
|
23
23
|
import { findWrapping, liftTarget, ReplaceAroundStep, } from 'prosemirror-transform';
|
|
24
|
-
import { findChildrenByType, findParentNodeOfType, hasParentNodeOfType, } from 'prosemirror-utils';
|
|
24
|
+
import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, } from 'prosemirror-utils';
|
|
25
25
|
import { getCommentKey, getCommentRange } from './lib/comments';
|
|
26
|
-
import { findBackmatter, findBibliographySection, findBody, insertSupplementsNode, } from './lib/doc';
|
|
27
|
-
import {
|
|
26
|
+
import { findBackmatter, findBibliographySection, findBody, insertFootnotesSection, insertSupplementsNode, } from './lib/doc';
|
|
27
|
+
import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, } from './lib/footnotes';
|
|
28
28
|
import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
|
|
29
29
|
import { sectionTitles } from './lib/section-titles';
|
|
30
30
|
import { isDeleted } from './lib/track-changes-utils';
|
|
31
31
|
import { findParentNodeWithId, getChildOfType, getMatchingChild, } from './lib/utils';
|
|
32
32
|
import { setCommentSelection } from './plugins/comments';
|
|
33
33
|
import { getEditorProps } from './plugins/editor-props';
|
|
34
|
-
import { footnotesKey } from './plugins/footnotes';
|
|
35
34
|
import { checkForCompletion } from './plugins/section_title/autocompletion';
|
|
36
35
|
export const addToStart = (state, dispatch) => {
|
|
37
36
|
const { selection } = state;
|
|
@@ -152,45 +151,35 @@ export const createBlock = (nodeType, position, state, dispatch, attrs) => {
|
|
|
152
151
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
153
152
|
}
|
|
154
153
|
};
|
|
155
|
-
export const
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const { state, dispatch } = view;
|
|
161
|
-
const paragraph = state.schema.nodes.paragraph.create({
|
|
162
|
-
placeholder: 'Add general note here',
|
|
163
|
-
});
|
|
164
|
-
const generalNote = state.schema.nodes.general_table_footnote.create({}, [
|
|
165
|
-
paragraph,
|
|
166
|
-
]);
|
|
167
|
-
const tableColGroup = findChildrenByType(tableElementNode, schema.nodes.table_colgroup)[0];
|
|
168
|
-
const table = findChildrenByType(tableElementNode, schema.nodes.table)[0];
|
|
169
|
-
const tr = state.tr;
|
|
170
|
-
const pos = (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length)
|
|
171
|
-
? position + tableElementFooter[0].pos + 2
|
|
172
|
-
: position +
|
|
173
|
-
(!tableColGroup
|
|
174
|
-
? table.pos + table.node.nodeSize
|
|
175
|
-
: tableColGroup.pos + tableColGroup.node.nodeSize);
|
|
176
|
-
if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
|
|
177
|
-
if (isDeleted(tableElementFooter[0].node)) {
|
|
178
|
-
const tableElementFooterPos = tr.mapping.map(position + tableElementFooter[0].pos + 1);
|
|
179
|
-
undoFootnoteDelete(tr, tableElementFooter[0], tableElementFooterPos);
|
|
180
|
-
}
|
|
181
|
-
tr.insert(pos, generalNote);
|
|
154
|
+
export const insertInlineTableFootnote = (state, dispatch) => {
|
|
155
|
+
const $pos = state.selection.$to;
|
|
156
|
+
const table = findParentNodeOfTypeClosestToPos($pos, schema.nodes.table);
|
|
157
|
+
if (!table) {
|
|
158
|
+
return false;
|
|
182
159
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
id: generateNodeID(schema.nodes.table_element_footer),
|
|
186
|
-
}, [generalNote]);
|
|
187
|
-
tr.insert(pos, tableElementFooter);
|
|
160
|
+
if (!dispatch) {
|
|
161
|
+
return true;
|
|
188
162
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
163
|
+
return insertInlineFootnote(state, dispatch);
|
|
164
|
+
};
|
|
165
|
+
export const insertGeneralTableFootnote = (element, state, dispatch) => {
|
|
166
|
+
const existing = findChildrenByType(element[0], schema.nodes.general_table_footnote);
|
|
167
|
+
if (existing.length) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
if (!dispatch) {
|
|
171
|
+
return true;
|
|
193
172
|
}
|
|
173
|
+
const tr = state.tr;
|
|
174
|
+
const footer = insertTableElementFooter(tr, element);
|
|
175
|
+
const pos = footer.pos + 1;
|
|
176
|
+
const node = schema.nodes.general_table_footnote.create({}, [
|
|
177
|
+
schema.nodes.paragraph.create(),
|
|
178
|
+
]);
|
|
179
|
+
tr.insert(pos, node);
|
|
180
|
+
const selection = TextSelection.create(tr.doc, pos + 1);
|
|
181
|
+
tr.setSelection(selection).scrollIntoView();
|
|
182
|
+
dispatch(tr);
|
|
194
183
|
};
|
|
195
184
|
export const insertFigure = (file, state, dispatch) => {
|
|
196
185
|
const position = findBlockInsertPosition(state);
|
|
@@ -380,81 +369,99 @@ export const insertInlineEquation = (state, dispatch) => {
|
|
|
380
369
|
}
|
|
381
370
|
return true;
|
|
382
371
|
};
|
|
383
|
-
export const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
372
|
+
export const insertTableElementFooter = (tr, table) => {
|
|
373
|
+
const footer = findChildrenByType(table[0], schema.nodes.table_element_footer)[0];
|
|
374
|
+
if (footer) {
|
|
375
|
+
const pos = tr.mapping.map(table[1] + footer.pos + 1);
|
|
376
|
+
if (isDeleted(footer.node)) {
|
|
377
|
+
reinstateNode(tr, footer.node, pos);
|
|
378
|
+
}
|
|
379
|
+
return {
|
|
380
|
+
node: footer.node,
|
|
381
|
+
pos,
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
const pos = tr.mapping.map(table[1] + table[0].nodeSize - 2);
|
|
385
|
+
const node = schema.nodes.table_element_footer.create();
|
|
386
|
+
tr.insert(pos, node);
|
|
387
|
+
return {
|
|
388
|
+
node,
|
|
389
|
+
pos,
|
|
390
|
+
};
|
|
388
391
|
};
|
|
389
|
-
export const
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Footnotes')),
|
|
395
|
-
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
396
|
-
]);
|
|
397
|
-
const backmatter = findChildrenByType(tr.doc, schema.nodes.backmatter)[0];
|
|
398
|
-
const sectionPos = backmatter.pos + 1;
|
|
399
|
-
tr.insert(sectionPos, section);
|
|
400
|
-
let footnotePos = 0;
|
|
401
|
-
section.descendants((n, pos) => {
|
|
402
|
-
if (isFootnoteNode(n)) {
|
|
403
|
-
footnotePos = pos;
|
|
404
|
-
n.descendants((childNode, childPos) => {
|
|
405
|
-
if (isParagraphNode(childNode)) {
|
|
406
|
-
footnotePos += childPos;
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
selectionPos = sectionPos + footnotePos;
|
|
392
|
+
export const insertFootnotesElement = (tr, container) => {
|
|
393
|
+
let pos;
|
|
394
|
+
if (isTableElementNode(container[0])) {
|
|
395
|
+
const footer = insertTableElementFooter(tr, container);
|
|
396
|
+
pos = footer.pos + footer.node.nodeSize - 1;
|
|
412
397
|
}
|
|
413
398
|
else {
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
399
|
+
const section = insertFootnotesSection(tr);
|
|
400
|
+
pos = section.pos + section.node.nodeSize - 1;
|
|
401
|
+
}
|
|
402
|
+
const node = schema.nodes.footnotes_element.create();
|
|
403
|
+
tr.insert(pos, node);
|
|
404
|
+
return [node, pos];
|
|
405
|
+
};
|
|
406
|
+
export const insertInlineFootnote = (state, dispatch) => {
|
|
407
|
+
const pos = state.selection.to;
|
|
408
|
+
const tr = state.tr;
|
|
409
|
+
const container = findFootnotesContainerNode(state.doc, pos);
|
|
410
|
+
const fn = getFootnotesElementState(state, container.node.attrs.id);
|
|
411
|
+
const hasUnusedFootnotes = fn && fn.unusedFootnoteIDs.size > 0;
|
|
412
|
+
const footnote = !hasUnusedFootnotes && createFootnote();
|
|
413
|
+
const node = schema.nodes.inline_footnote.create({
|
|
414
|
+
rids: footnote ? [footnote.attrs.id] : [],
|
|
415
|
+
});
|
|
416
|
+
tr.insert(pos, node);
|
|
417
|
+
if (footnote) {
|
|
418
|
+
let element;
|
|
419
|
+
if (fn) {
|
|
420
|
+
element = [fn.element[0], tr.mapping.map(fn.element[1])];
|
|
428
421
|
}
|
|
429
422
|
else {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
423
|
+
element = insertFootnotesElement(tr, [container.node, container.pos]);
|
|
424
|
+
}
|
|
425
|
+
if (isDeleted(element[0])) {
|
|
426
|
+
reinstateNode(tr, element[0], element[1]);
|
|
434
427
|
}
|
|
428
|
+
const fnPos = element[1] + element[0].nodeSize - 1;
|
|
429
|
+
tr.insert(fnPos, footnote);
|
|
430
|
+
const selection = TextSelection.create(tr.doc, fnPos + 2);
|
|
431
|
+
tr.setSelection(selection).scrollIntoView();
|
|
435
432
|
}
|
|
436
|
-
|
|
437
|
-
const selection =
|
|
433
|
+
else {
|
|
434
|
+
const selection = NodeSelection.create(tr.doc, pos);
|
|
438
435
|
tr.setSelection(selection).scrollIntoView();
|
|
439
436
|
}
|
|
440
|
-
|
|
437
|
+
if (dispatch) {
|
|
438
|
+
dispatch(tr);
|
|
439
|
+
}
|
|
440
|
+
return true;
|
|
441
441
|
};
|
|
442
|
-
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
});
|
|
453
|
-
tr.insert(insertedAt, node);
|
|
454
|
-
if (footnote) {
|
|
455
|
-
tr = insertFootnote(state, tr, footnote);
|
|
442
|
+
const reinstateNode = (tr, node, pos) => {
|
|
443
|
+
const attrs = Object.assign(Object.assign({}, node.attrs), { dataTracked: null });
|
|
444
|
+
tr.setNodeMarkup(pos, null, attrs);
|
|
445
|
+
};
|
|
446
|
+
export const insertBoxElement = (state, dispatch) => {
|
|
447
|
+
const selection = state.selection;
|
|
448
|
+
const isBody = hasParentNodeOfType(schema.nodes.body)(selection);
|
|
449
|
+
const isBoxText = hasParentNodeOfType(schema.nodes.box_element)(selection);
|
|
450
|
+
if (!isBody || isBoxText) {
|
|
451
|
+
return false;
|
|
456
452
|
}
|
|
457
|
-
|
|
453
|
+
const position = findBlockInsertPosition(state);
|
|
454
|
+
const paragraph = schema.nodes.paragraph.create({});
|
|
455
|
+
const section = schema.nodes.section.createAndFill({}, [
|
|
456
|
+
schema.nodes.section_title.create(),
|
|
457
|
+
paragraph,
|
|
458
|
+
]);
|
|
459
|
+
const node = schema.nodes.box_element.createAndFill({}, [
|
|
460
|
+
schema.nodes.figcaption.create({}, [schema.nodes.caption_title.create()]),
|
|
461
|
+
section,
|
|
462
|
+
]);
|
|
463
|
+
if (position && dispatch) {
|
|
464
|
+
const tr = state.tr.insert(position, node);
|
|
458
465
|
dispatch(tr);
|
|
459
466
|
}
|
|
460
467
|
return true;
|
|
@@ -930,6 +937,11 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
930
937
|
}
|
|
931
938
|
let from = selection.from;
|
|
932
939
|
let to = selection.to;
|
|
940
|
+
if (from === to) {
|
|
941
|
+
const result = findWordBoundaries(state, from);
|
|
942
|
+
from = result.from;
|
|
943
|
+
to = result.to;
|
|
944
|
+
}
|
|
933
945
|
const props = getEditorProps(state);
|
|
934
946
|
const contribution = buildContribution(props.userID);
|
|
935
947
|
const attrs = {
|
|
@@ -937,7 +949,7 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
937
949
|
contents: '',
|
|
938
950
|
target: node.attrs.id,
|
|
939
951
|
contributions: [contribution],
|
|
940
|
-
originalText: selectedText(),
|
|
952
|
+
originalText: selectedText() || state.doc.textBetween(from, to),
|
|
941
953
|
selector: {
|
|
942
954
|
from,
|
|
943
955
|
to,
|
|
@@ -948,11 +960,6 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
948
960
|
if (comments) {
|
|
949
961
|
const pos = comments.pos + 1;
|
|
950
962
|
const tr = state.tr.insert(pos, comment);
|
|
951
|
-
if (from === to) {
|
|
952
|
-
const result = findWordBoundaries(state, from);
|
|
953
|
-
from = result.from;
|
|
954
|
-
to = result.to;
|
|
955
|
-
}
|
|
956
963
|
const start = schema.nodes.highlight_marker.create({
|
|
957
964
|
id: comment.attrs.id,
|
|
958
965
|
tid: node.attrs.id,
|
|
@@ -974,102 +981,6 @@ export const addInlineComment = (state, dispatch) => {
|
|
|
974
981
|
}
|
|
975
982
|
return false;
|
|
976
983
|
};
|
|
977
|
-
export const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) => {
|
|
978
|
-
const { state, dispatch } = view;
|
|
979
|
-
const tr = state.tr;
|
|
980
|
-
const footnote = schema.nodes.footnote.createAndFill({
|
|
981
|
-
id: generateNodeID(schema.nodes.footnote),
|
|
982
|
-
kind: 'footnote',
|
|
983
|
-
});
|
|
984
|
-
const insertedAt = state.selection.to;
|
|
985
|
-
let footnoteIndex;
|
|
986
|
-
if (inlineFootnote) {
|
|
987
|
-
const contents = inlineFootnote.node.attrs.contents.split(',').map(Number);
|
|
988
|
-
footnoteIndex = Math.max(...contents) + 1;
|
|
989
|
-
tr.setNodeMarkup(inlineFootnote.pos, undefined, {
|
|
990
|
-
rids: [...inlineFootnote.node.attrs.rids, footnote.attrs.id],
|
|
991
|
-
contents: inlineFootnote.node.attrs.contents + ',' + footnoteIndex,
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
else {
|
|
995
|
-
const inlineFootnotes = findChildrenByType(tableElementNode, schema.nodes.inline_footnote);
|
|
996
|
-
footnoteIndex =
|
|
997
|
-
inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
|
|
998
|
-
1;
|
|
999
|
-
const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
|
|
1000
|
-
rids: [footnote.attrs.id],
|
|
1001
|
-
contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
|
|
1002
|
-
});
|
|
1003
|
-
tr.insert(insertedAt, inlineFootnoteNode);
|
|
1004
|
-
}
|
|
1005
|
-
let insertionPos = position;
|
|
1006
|
-
const footnotesElement = findChildrenByType(tableElementNode, schema.nodes.footnotes_element).pop();
|
|
1007
|
-
if (footnotesElement) {
|
|
1008
|
-
if (isDeleted(footnotesElement.node)) {
|
|
1009
|
-
const footnotesElementPos = tr.mapping.map(position + footnotesElement.pos + 1);
|
|
1010
|
-
undoFootnoteDelete(tr, footnotesElement, footnotesElementPos);
|
|
1011
|
-
}
|
|
1012
|
-
const footnotePos = getNewFootnotePos(footnotesElement, footnoteIndex);
|
|
1013
|
-
insertionPos = tr.mapping.map(position + footnotePos);
|
|
1014
|
-
tr.insert(insertionPos, footnote);
|
|
1015
|
-
}
|
|
1016
|
-
else {
|
|
1017
|
-
const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
|
|
1018
|
-
const tableElementFooter = findChildrenByType(tableElementNode, schema.nodes.table_element_footer)[0];
|
|
1019
|
-
if (tableElementFooter) {
|
|
1020
|
-
if (isDeleted(tableElementFooter.node)) {
|
|
1021
|
-
const tableElementFooterPos = tr.mapping.map(position + tableElementFooter.pos + 1);
|
|
1022
|
-
undoFootnoteDelete(tr, tableElementFooter, tableElementFooterPos);
|
|
1023
|
-
}
|
|
1024
|
-
const pos = tableElementFooter.pos;
|
|
1025
|
-
insertionPos = position + pos + tableElementFooter.node.nodeSize;
|
|
1026
|
-
tr.insert(tr.mapping.map(insertionPos), footnoteElement);
|
|
1027
|
-
}
|
|
1028
|
-
else {
|
|
1029
|
-
const tableElementFooter = schema.nodes.table_element_footer.create({
|
|
1030
|
-
id: generateNodeID(schema.nodes.table_element_footer),
|
|
1031
|
-
}, [footnoteElement]);
|
|
1032
|
-
const tableColGroup = findChildrenByType(tableElementNode, schema.nodes.table_colgroup)[0];
|
|
1033
|
-
const table = findChildrenByType(tableElementNode, schema.nodes.table)[0];
|
|
1034
|
-
if (tableColGroup) {
|
|
1035
|
-
insertionPos =
|
|
1036
|
-
position + tableColGroup.pos + tableColGroup.node.nodeSize;
|
|
1037
|
-
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
1038
|
-
}
|
|
1039
|
-
else {
|
|
1040
|
-
insertionPos = position + table.pos + table.node.nodeSize;
|
|
1041
|
-
tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
dispatch(tr);
|
|
1046
|
-
const textSelection = TextSelection.near(view.state.tr.doc.resolve(insertionPos + 1));
|
|
1047
|
-
view.focus();
|
|
1048
|
-
dispatch(view.state.tr.setSelection(textSelection).scrollIntoView());
|
|
1049
|
-
};
|
|
1050
|
-
export const insertBoxElement = (state, dispatch) => {
|
|
1051
|
-
const selection = state.selection;
|
|
1052
|
-
const isBody = hasParentNodeOfType(schema.nodes.body)(selection);
|
|
1053
|
-
const isBoxText = hasParentNodeOfType(schema.nodes.box_element)(selection);
|
|
1054
|
-
if (!isBody || isBoxText) {
|
|
1055
|
-
return false;
|
|
1056
|
-
}
|
|
1057
|
-
const position = findBlockInsertPosition(state);
|
|
1058
|
-
const paragraph = schema.nodes.paragraph.create({});
|
|
1059
|
-
const section = schema.nodes.section.createAndFill({}, [
|
|
1060
|
-
schema.nodes.section_title.create(),
|
|
1061
|
-
paragraph,
|
|
1062
|
-
]);
|
|
1063
|
-
const BoxElementNode = schema.nodes.box_element.createAndFill({}, [
|
|
1064
|
-
schema.nodes.figcaption.create({}, [schema.nodes.caption_title.create()]),
|
|
1065
|
-
section,
|
|
1066
|
-
]);
|
|
1067
|
-
if (position && dispatch) {
|
|
1068
|
-
const tr = state.tr.insert(position, BoxElementNode);
|
|
1069
|
-
dispatch(tr);
|
|
1070
|
-
}
|
|
1071
|
-
return true;
|
|
1072
|
-
};
|
|
1073
984
|
export const addRows = (direction) => (state, dispatch) => {
|
|
1074
985
|
if (dispatch) {
|
|
1075
986
|
const { tr } = state;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Category, Dialog } from '@manuscripts/style-guide';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
export const DeleteFootnoteDialog = ({
|
|
3
|
+
export const DeleteFootnoteDialog = ({ header, message, handleDelete, }) => {
|
|
4
4
|
const [isOpen, setOpen] = useState(true);
|
|
5
5
|
return (React.createElement(Dialog, { className: "delete-footnote-dialog", isOpen: isOpen, actions: {
|
|
6
6
|
primary: {
|
|
@@ -14,5 +14,5 @@ export const DeleteFootnoteDialog = ({ footnoteType, footnoteMessage, handleDele
|
|
|
14
14
|
action: () => setOpen(false),
|
|
15
15
|
title: 'Cancel',
|
|
16
16
|
},
|
|
17
|
-
}, category: Category.confirmation, header:
|
|
17
|
+
}, category: Category.confirmation, header: header, message: message }));
|
|
18
18
|
};
|
|
@@ -47,12 +47,12 @@ const AddNewFootnote = styled(ButtonGroup) `
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
`;
|
|
50
|
-
export const FootnotesSelector = ({
|
|
50
|
+
export const FootnotesSelector = ({ footnotes, inlineFootnote, labels, onAdd, onInsert, onCancel, }) => {
|
|
51
51
|
let selectedNotesMap;
|
|
52
52
|
if (inlineFootnote) {
|
|
53
53
|
const rids = inlineFootnote.attrs.rids;
|
|
54
|
-
const selectedNotes =
|
|
55
|
-
selectedNotesMap = new Map(selectedNotes.map((
|
|
54
|
+
const selectedNotes = footnotes.filter((node) => rids.includes(node.attrs.id));
|
|
55
|
+
selectedNotesMap = new Map(selectedNotes.map((node) => [node.attrs.id, node]));
|
|
56
56
|
}
|
|
57
57
|
const [selections, setSelections] = useState(new Map(selectedNotesMap));
|
|
58
58
|
const toggleSelection = (item) => {
|
|
@@ -70,43 +70,42 @@ export const FootnotesSelector = ({ notes, inlineFootnote, onAdd, onInsert, onCa
|
|
|
70
70
|
return selections.has(item.attrs.id);
|
|
71
71
|
};
|
|
72
72
|
const handleClick = () => {
|
|
73
|
-
return onInsert(
|
|
73
|
+
return onInsert(footnotes.filter((node) => selections.has(node.attrs.id)));
|
|
74
74
|
};
|
|
75
75
|
return (React.createElement(Container, null,
|
|
76
76
|
React.createElement(NotesContainer, null,
|
|
77
|
-
React.createElement(FootnotesList, {
|
|
77
|
+
React.createElement(FootnotesList, { footnotes: footnotes, inlineFootnote: inlineFootnote, labels: labels, isSelected: isSelected, onSelect: toggleSelection })),
|
|
78
78
|
React.createElement(Actions, null,
|
|
79
79
|
React.createElement(AddNewFootnote, null,
|
|
80
80
|
React.createElement(IconTextButton, { onClick: onAdd },
|
|
81
81
|
React.createElement(AddNewIcon, null),
|
|
82
|
-
|
|
82
|
+
"Add new")),
|
|
83
83
|
React.createElement(ButtonGroup, null,
|
|
84
84
|
React.createElement(SecondaryButton, { onClick: onCancel }, "Cancel"),
|
|
85
85
|
React.createElement(PrimaryButton, { onClick: handleClick, disabled: selections.size === 0 && !inlineFootnote }, inlineFootnote ? 'Update' : 'Insert')))));
|
|
86
86
|
};
|
|
87
|
-
const FootnotesList = ({
|
|
87
|
+
const FootnotesList = ({ footnotes, inlineFootnote, labels, isSelected, onSelect }) => {
|
|
88
|
+
const rids = inlineFootnote === null || inlineFootnote === void 0 ? void 0 : inlineFootnote.attrs.rids;
|
|
88
89
|
const selectedNotes = [];
|
|
89
90
|
const remainingNotes = [];
|
|
90
|
-
|
|
91
|
-
const isNoteSelected =
|
|
91
|
+
footnotes.forEach((footnote) => {
|
|
92
|
+
const isNoteSelected = rids === null || rids === void 0 ? void 0 : rids.includes(footnote.attrs.id);
|
|
92
93
|
if (isNoteSelected) {
|
|
93
|
-
selectedNotes.push(
|
|
94
|
+
selectedNotes.push(footnote);
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
|
-
remainingNotes.push(
|
|
97
|
+
remainingNotes.push(footnote);
|
|
97
98
|
}
|
|
98
99
|
});
|
|
99
100
|
return (React.createElement(NotesListContainer, null,
|
|
100
|
-
selectedNotes.map((
|
|
101
|
+
selectedNotes.map((footnote) => (React.createElement(FootnoteItem, { key: footnote.attrs.id, footnote: footnote, label: labels.get(footnote.attrs.id), isSelected: isSelected, onSelect: onSelect }))),
|
|
101
102
|
selectedNotes.length > 0 && remainingNotes.length > 0 && React.createElement(Separator, null),
|
|
102
|
-
remainingNotes.map((
|
|
103
|
+
remainingNotes.map((footnote) => (React.createElement(FootnoteItem, { key: footnote.attrs.id, footnote: footnote, label: labels.get(footnote.attrs.id), isSelected: isSelected, onSelect: onSelect })))));
|
|
103
104
|
};
|
|
104
|
-
const FootnoteItem = ({
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
React.createElement(StatusIcon, null, isSelected(node) ? (React.createElement(AddedIcon, { "data-cy": 'plus-icon-ok' })) : (React.createElement(AddIcon, { "data-cy": 'plus-icon' }))),
|
|
109
|
-
React.createElement(NoteText, null, (index ? index + '. ' : '') + ((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent))));
|
|
105
|
+
const FootnoteItem = ({ footnote, label, isSelected, onSelect }) => {
|
|
106
|
+
return (React.createElement(FootnoteItemContainer, { onClick: () => onSelect(footnote) },
|
|
107
|
+
React.createElement(StatusIcon, null, isSelected(footnote) ? (React.createElement(AddedIcon, { "data-cy": 'plus-icon-ok' })) : (React.createElement(AddIcon, { "data-cy": 'plus-icon' }))),
|
|
108
|
+
React.createElement(NoteText, null, (label ? label + '. ' : '') + footnote.textContent)));
|
|
110
109
|
};
|
|
111
110
|
const Separator = styled.div `
|
|
112
111
|
height: 0;
|
|
@@ -20,6 +20,7 @@ import { EditorView } from 'prosemirror-view';
|
|
|
20
20
|
import { clipboardParser } from '../clipboard';
|
|
21
21
|
import { handleScrollToBibliographyItem } from '../lib/helpers';
|
|
22
22
|
import { handlePaste, transformPasted } from '../lib/paste';
|
|
23
|
+
import { INIT_META } from '../lib/plugins';
|
|
23
24
|
import plugins from './editor-plugins';
|
|
24
25
|
import views from './editor-views';
|
|
25
26
|
export const createEditorState = (props) => EditorState.create({
|
|
@@ -51,7 +52,7 @@ export const createEditorView = (props, root, state, dispatch) => {
|
|
|
51
52
|
}
|
|
52
53
|
},
|
|
53
54
|
});
|
|
54
|
-
const tr = view.state.tr.setMeta(
|
|
55
|
+
const tr = view.state.tr.setMeta(INIT_META, true);
|
|
55
56
|
const nextState = view.state.apply(tr);
|
|
56
57
|
view.updateState(nextState);
|
|
57
58
|
return view;
|
|
@@ -36,7 +36,6 @@ import section_title from '../plugins/section_title';
|
|
|
36
36
|
import section_category from '../plugins/section-category';
|
|
37
37
|
import sections from '../plugins/sections';
|
|
38
38
|
import selected_suggestion from '../plugins/selected-suggestion';
|
|
39
|
-
import table_footnote from '../plugins/table-footnote';
|
|
40
39
|
import table_editing_fix from '../plugins/tables-cursor-fix';
|
|
41
40
|
import toc from '../plugins/toc';
|
|
42
41
|
import rules from '../rules';
|
|
@@ -68,7 +67,6 @@ export default (props) => {
|
|
|
68
67
|
tableEditing(),
|
|
69
68
|
selected_suggestion(),
|
|
70
69
|
footnotes(props),
|
|
71
|
-
table_footnote(),
|
|
72
70
|
editorProps(props),
|
|
73
71
|
doi(),
|
|
74
72
|
section_category(props),
|
|
@@ -26,8 +26,9 @@ import equation from '../views/equation_editable';
|
|
|
26
26
|
import equationElement from '../views/equation_element_editable';
|
|
27
27
|
import figure from '../views/figure_editable';
|
|
28
28
|
import figureElement from '../views/figure_element_editable';
|
|
29
|
-
import footnote from '../views/
|
|
29
|
+
import footnote from '../views/footnote';
|
|
30
30
|
import footnotesElement from '../views/footnotes_element';
|
|
31
|
+
import generalTableFootnote from '../views/general_table_footnote';
|
|
31
32
|
import inlineEquation from '../views/inline_equation_editable';
|
|
32
33
|
import inlineFootnote from '../views/inline_footnote_editable';
|
|
33
34
|
import keyword from '../views/keyword';
|
|
@@ -44,7 +45,7 @@ import sectionLabel from '../views/section_label';
|
|
|
44
45
|
import sectionTitle from '../views/section_title_editable';
|
|
45
46
|
import tableCell from '../views/table_cell';
|
|
46
47
|
import tableElement from '../views/table_element_editable';
|
|
47
|
-
import tableElementFooter from '../views/
|
|
48
|
+
import tableElementFooter from '../views/table_element_footer';
|
|
48
49
|
import title from '../views/title_editable';
|
|
49
50
|
import tocElement from '../views/toc_element_editable';
|
|
50
51
|
export default (props, dispatch) => {
|
|
@@ -63,6 +64,7 @@ export default (props, dispatch) => {
|
|
|
63
64
|
figure_element: figureElement(props, dispatch),
|
|
64
65
|
footnote: footnote(props),
|
|
65
66
|
footnotes_element: footnotesElement(props),
|
|
67
|
+
general_table_footnote: generalTableFootnote(props, dispatch),
|
|
66
68
|
inline_equation: inlineEquation(props),
|
|
67
69
|
inline_footnote: inlineFootnote(props, dispatch),
|
|
68
70
|
keyword: keyword(props, dispatch),
|
package/dist/es/icons.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AlertIcon, DeleteIcon } from '@manuscripts/style-guide';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
4
|
+
export const alertIcon = renderToStaticMarkup(createElement(AlertIcon));
|
|
5
|
+
export const deleteIcon = renderToStaticMarkup(createElement(DeleteIcon));
|
package/dist/es/index.js
CHANGED
|
@@ -25,6 +25,7 @@ export { PopperManager } from './lib/popper';
|
|
|
25
25
|
export * from './toolbar';
|
|
26
26
|
export * from './lib/comments';
|
|
27
27
|
export * from './lib/files';
|
|
28
|
+
export * from './lib/footnotes';
|
|
28
29
|
export * from './lib/doc';
|
|
29
30
|
export * from './plugins/comments';
|
|
30
31
|
export { selectedSuggestionKey } from './plugins/selected-suggestion';
|
package/dist/es/lib/comments.js
CHANGED