@manuscripts/body-editor 1.5.16 → 1.6.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 +53 -132
- package/dist/cjs/components/outline/DraggableTree.js +33 -25
- package/dist/cjs/components/toolbar/OrderListSelector.js +3 -11
- package/dist/cjs/configs/editor-plugins.js +2 -2
- package/dist/cjs/configs/editor-views.js +4 -6
- package/dist/cjs/lib/context-menu.js +6 -5
- package/dist/cjs/node-type-icons.js +0 -1
- package/dist/cjs/plugins/bibliography/bibliography-utils.js +60 -47
- package/dist/cjs/plugins/bibliography/index.js +48 -63
- package/dist/cjs/plugins/comment_annotation.js +2 -2
- package/dist/cjs/plugins/footnotes/index.js +19 -10
- package/dist/cjs/plugins/persist.js +21 -31
- package/dist/cjs/plugins/sections.js +1 -2
- package/dist/cjs/plugins/toc.js +28 -23
- package/dist/cjs/views/bibliography_element.js +20 -38
- package/dist/cjs/views/citation.js +29 -26
- package/dist/cjs/views/citation_editable.js +25 -44
- package/dist/cjs/views/{contributors_section.js → contributors.js} +4 -4
- package/dist/cjs/views/cross_reference.js +7 -36
- package/dist/cjs/views/cross_reference_editable.js +6 -14
- package/dist/cjs/views/editable_block.js +2 -2
- package/dist/cjs/views/{meta_section.js → empty.js} +3 -3
- package/dist/cjs/views/section_title.js +1 -16
- package/dist/es/commands.js +55 -110
- package/dist/es/components/outline/DraggableTree.js +33 -25
- package/dist/es/components/toolbar/OrderListSelector.js +4 -12
- package/dist/es/configs/editor-plugins.js +2 -2
- package/dist/es/configs/editor-views.js +4 -6
- package/dist/es/lib/context-menu.js +7 -6
- package/dist/es/node-type-icons.js +0 -1
- package/dist/es/plugins/bibliography/bibliography-utils.js +56 -45
- package/dist/es/plugins/bibliography/index.js +49 -65
- package/dist/es/plugins/comment_annotation.js +2 -2
- package/dist/es/plugins/footnotes/index.js +20 -11
- package/dist/es/plugins/persist.js +22 -32
- package/dist/es/plugins/sections.js +2 -3
- package/dist/es/plugins/toc.js +29 -24
- package/dist/es/views/bibliography_element.js +21 -39
- package/dist/es/views/citation.js +31 -28
- package/dist/es/views/citation_editable.js +28 -47
- package/dist/es/views/{contributors_section.js → contributors.js} +2 -2
- package/dist/es/views/cross_reference.js +7 -33
- package/dist/es/views/cross_reference_editable.js +6 -14
- package/dist/es/views/editable_block.js +3 -3
- package/dist/es/views/{meta_section.js → empty.js} +3 -3
- package/dist/es/views/section_title.js +0 -14
- package/dist/types/commands.d.ts +1 -2
- package/dist/types/components/outline/DraggableTree.d.ts +1 -2
- package/dist/types/configs/ManuscriptsEditor.d.ts +1 -10
- package/dist/types/configs/editor-plugins.d.ts +1 -5
- package/dist/types/configs/editor-views.d.ts +5 -6
- package/dist/types/lib/context-menu.d.ts +0 -1
- package/dist/types/plugins/bibliography/bibliography-utils.d.ts +10 -7
- package/dist/types/plugins/bibliography/index.d.ts +21 -3
- package/dist/types/views/bibliography_element.d.ts +1 -0
- package/dist/types/views/citation.d.ts +3 -4
- package/dist/types/views/citation_editable.d.ts +2 -8
- package/dist/types/views/{contributors_section.d.ts → contributors.d.ts} +3 -3
- package/dist/types/views/cross_reference.d.ts +0 -5
- package/dist/types/views/{meta_section.d.ts → empty.d.ts} +2 -2
- package/dist/types/views/section_title.d.ts +0 -2
- package/package.json +4 -22
- package/styles/AdvancedEditor.css +30 -34
- package/dist/cjs/plugins/auxiliary_object_order.js +0 -49
- package/dist/cjs/plugins/bibliography/types.js +0 -17
- package/dist/cjs/plugins/footnotes/footnotes-utils.js +0 -52
- package/dist/cjs/views/bibliography_item.js +0 -138
- package/dist/cjs/views/bibliography_item_editable.js +0 -20
- package/dist/es/plugins/auxiliary_object_order.js +0 -46
- package/dist/es/plugins/bibliography/types.js +0 -16
- package/dist/es/plugins/footnotes/footnotes-utils.js +0 -46
- package/dist/es/views/bibliography_item.js +0 -131
- package/dist/es/views/bibliography_item_editable.js +0 -18
- package/dist/types/plugins/auxiliary_object_order.d.ts +0 -12
- package/dist/types/plugins/bibliography/types.d.ts +0 -40
- package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -25
- package/dist/types/views/bibliography_item.d.ts +0 -34
- package/dist/types/views/bibliography_item_editable.d.ts +0 -18
package/dist/es/commands.js
CHANGED
|
@@ -14,17 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
17
|
-
import {
|
|
17
|
+
import { buildComment, buildInlineMathFragment, generateID, isElementNodeType, isInBibliographySection, isSectionNodeType, schema, } from '@manuscripts/transform';
|
|
18
18
|
import { NodeRange } from 'prosemirror-model';
|
|
19
19
|
import { NodeSelection, TextSelection, } from 'prosemirror-state';
|
|
20
20
|
import { findWrapping } from 'prosemirror-transform';
|
|
21
|
-
import {
|
|
21
|
+
import { findChildrenByType, findParentNodeOfType } from 'prosemirror-utils';
|
|
22
22
|
import { isNodeOfType, nearestAncestor } from './lib/helpers';
|
|
23
|
-
import { findParentNodeWithId, getChildOfType
|
|
24
|
-
import { bibliographyKey } from './plugins/bibliography';
|
|
23
|
+
import { findParentNodeWithId, getChildOfType } from './lib/utils';
|
|
25
24
|
import { commentAnnotation } from './plugins/comment_annotation';
|
|
26
|
-
import { footnotesKey } from './plugins/footnotes';
|
|
27
|
-
import * as footnotesUtils from './plugins/footnotes/footnotes-utils';
|
|
28
25
|
import { highlightKey, SET_COMMENT } from './plugins/highlight';
|
|
29
26
|
export const markActive = (type) => (state) => {
|
|
30
27
|
const { from, $from, to, empty } = state.selection;
|
|
@@ -219,12 +216,11 @@ export const insertLink = (state, dispatch) => {
|
|
|
219
216
|
}
|
|
220
217
|
return true;
|
|
221
218
|
};
|
|
222
|
-
export const insertInlineCitation = (state, dispatch, view
|
|
223
|
-
const citation = buildCitation(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
|
|
219
|
+
export const insertInlineCitation = (state, dispatch, view) => {
|
|
224
220
|
const node = state.schema.nodes.citation.create({
|
|
225
|
-
|
|
221
|
+
id: generateID(ObjectTypes.Citation),
|
|
222
|
+
rids: [],
|
|
226
223
|
selectedText: selectedText(),
|
|
227
|
-
embeddedCitationItems: [],
|
|
228
224
|
});
|
|
229
225
|
const pos = state.selection.to;
|
|
230
226
|
const { tr } = state;
|
|
@@ -237,7 +233,7 @@ export const insertInlineCitation = (state, dispatch, view, embeddedCitationItem
|
|
|
237
233
|
};
|
|
238
234
|
export const insertCrossReference = (state, dispatch) => {
|
|
239
235
|
const node = state.schema.nodes.cross_reference.create({
|
|
240
|
-
|
|
236
|
+
rids: [],
|
|
241
237
|
});
|
|
242
238
|
const pos = state.selection.to;
|
|
243
239
|
const tr = state.tr.insert(pos, node);
|
|
@@ -265,52 +261,47 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
265
261
|
kind,
|
|
266
262
|
});
|
|
267
263
|
const insertedAt = state.selection.to;
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
rid: footnote.attrs.id,
|
|
271
|
-
contents: thisFootnoteNumbering.toString(),
|
|
264
|
+
const node = state.schema.nodes.inline_footnote.create({
|
|
265
|
+
rids: [footnote.attrs.id],
|
|
272
266
|
});
|
|
273
267
|
const tr = state.tr;
|
|
274
|
-
tr.insert(insertedAt,
|
|
275
|
-
const
|
|
268
|
+
tr.insert(insertedAt, node);
|
|
269
|
+
const elements = findChildrenByType(tr.doc, schema.nodes.footnotes_element);
|
|
276
270
|
let selectionPos;
|
|
277
|
-
if (
|
|
278
|
-
const
|
|
271
|
+
if (!elements.length) {
|
|
272
|
+
const section = state.schema.nodes.footnotes_section.create({}, [
|
|
279
273
|
state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
|
|
280
274
|
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
281
275
|
]);
|
|
282
|
-
const
|
|
283
|
-
tr.insert(
|
|
284
|
-
selectionPos =
|
|
276
|
+
const backmatter = findChildrenByType(tr.doc, schema.nodes.backmatter)[0];
|
|
277
|
+
tr.insert(backmatter.pos + 1, section);
|
|
278
|
+
selectionPos = backmatter.pos + section.nodeSize - 3;
|
|
285
279
|
}
|
|
286
280
|
else {
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
281
|
+
const element = elements[0];
|
|
282
|
+
const pos = element.pos + element.node.nodeSize - 1;
|
|
283
|
+
tr.insert(pos, footnote);
|
|
284
|
+
selectionPos = pos + 2;
|
|
290
285
|
}
|
|
291
|
-
if (dispatch) {
|
|
286
|
+
if (dispatch && selectionPos) {
|
|
292
287
|
const selection = TextSelection.create(tr.doc, selectionPos);
|
|
293
288
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
294
289
|
}
|
|
295
290
|
return true;
|
|
296
291
|
};
|
|
297
292
|
export const insertGraphicalAbstract = (state, dispatch) => {
|
|
298
|
-
|
|
299
|
-
if (pos === null ||
|
|
300
|
-
isInBibliographySection(state.selection.$from) ||
|
|
301
|
-
!isInAbstractsSection(state.selection.$from)) {
|
|
293
|
+
if (getChildOfType(state.doc, schema.nodes.graphical_abstract_section)) {
|
|
302
294
|
return false;
|
|
303
295
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
const section = state.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
|
|
308
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Graphical Abstract')),
|
|
296
|
+
const abstracts = findChildrenByType(state.doc, schema.nodes.abstracts)[0];
|
|
297
|
+
const section = schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
|
|
298
|
+
schema.nodes.section_title.create({}, schema.text('Graphical Abstract')),
|
|
309
299
|
createAndFillFigureElement(state),
|
|
310
300
|
]);
|
|
301
|
+
const pos = abstracts.pos + abstracts.node.nodeSize + 1;
|
|
311
302
|
const tr = state.tr.insert(pos, section);
|
|
312
303
|
if (dispatch) {
|
|
313
|
-
const selection = TextSelection.create(tr.doc, pos +
|
|
304
|
+
const selection = TextSelection.create(tr.doc, pos + 1);
|
|
314
305
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
315
306
|
}
|
|
316
307
|
return true;
|
|
@@ -328,56 +319,11 @@ export const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
328
319
|
}
|
|
329
320
|
return true;
|
|
330
321
|
};
|
|
331
|
-
export const insertFootnotesSection = (state, dispatch) => {
|
|
332
|
-
if (getChildOfType(state.doc, state.schema.nodes.footnotes_section)) {
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
const section = state.schema.nodes.footnotes_section.createAndFill({}, [
|
|
336
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
|
|
337
|
-
state.schema.nodes.footnotes_element.create(),
|
|
338
|
-
]);
|
|
339
|
-
const pos = state.tr.doc.content.size;
|
|
340
|
-
const tr = state.tr;
|
|
341
|
-
tr.insert(pos, section).setMeta(footnotesKey, {
|
|
342
|
-
footnotesElementInserted: true,
|
|
343
|
-
});
|
|
344
|
-
if (dispatch) {
|
|
345
|
-
const selection = NodeSelection.create(tr.doc, pos);
|
|
346
|
-
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
347
|
-
}
|
|
348
|
-
return true;
|
|
349
|
-
};
|
|
350
322
|
export const insertBibliographySection = (state, dispatch) => {
|
|
351
|
-
|
|
352
|
-
return false;
|
|
353
|
-
}
|
|
354
|
-
const section = state.schema.nodes.bibliography_section.createAndFill({}, [
|
|
355
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Bibliography')),
|
|
356
|
-
]);
|
|
357
|
-
const pos = state.tr.doc.content.size;
|
|
358
|
-
const tr = state.tr;
|
|
359
|
-
tr.insert(pos, section).setMeta(bibliographyKey, {
|
|
360
|
-
bibliographyInserted: true,
|
|
361
|
-
});
|
|
362
|
-
if (dispatch) {
|
|
363
|
-
const selection = NodeSelection.create(tr.doc, pos);
|
|
364
|
-
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
365
|
-
}
|
|
366
|
-
return true;
|
|
323
|
+
return false;
|
|
367
324
|
};
|
|
368
325
|
export const insertTOCSection = (state, dispatch) => {
|
|
369
|
-
|
|
370
|
-
return false;
|
|
371
|
-
}
|
|
372
|
-
const section = state.schema.nodes.toc_section.createAndFill({}, [
|
|
373
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Table of Contents')),
|
|
374
|
-
]);
|
|
375
|
-
const pos = 0;
|
|
376
|
-
const tr = state.tr.insert(pos, section);
|
|
377
|
-
if (dispatch) {
|
|
378
|
-
dispatch(tr.setSelection(NodeSelection.create(tr.doc, pos)).scrollIntoView());
|
|
379
|
-
}
|
|
380
|
-
return true;
|
|
326
|
+
return false;
|
|
381
327
|
};
|
|
382
328
|
export const ifInTableBody = (command) => (state) => {
|
|
383
329
|
const $head = state.selection.$head;
|
|
@@ -562,11 +508,17 @@ export const deleteHighlightMarkers = (rid) => (state, dispatch) => {
|
|
|
562
508
|
};
|
|
563
509
|
export function addComment(state, dispatch, viewNode, resolvePos) {
|
|
564
510
|
const { selection } = state;
|
|
565
|
-
const
|
|
566
|
-
const
|
|
511
|
+
const hasText = selection.content().size > 0;
|
|
512
|
+
const parent = getParentNode(selection);
|
|
513
|
+
if (!parent) {
|
|
514
|
+
return false;
|
|
515
|
+
}
|
|
567
516
|
if (viewNode && resolvePos) {
|
|
568
517
|
const viewNode = getParentNode(TextSelection.near(resolvePos));
|
|
569
|
-
if (
|
|
518
|
+
if (!viewNode) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
if (hasText && parent.attrs.id === viewNode.attrs.id) {
|
|
570
522
|
return addHighlightComment(viewNode, state, dispatch);
|
|
571
523
|
}
|
|
572
524
|
else {
|
|
@@ -574,41 +526,34 @@ export function addComment(state, dispatch, viewNode, resolvePos) {
|
|
|
574
526
|
}
|
|
575
527
|
}
|
|
576
528
|
else {
|
|
577
|
-
if (
|
|
578
|
-
return addHighlightComment(
|
|
529
|
+
if (hasText) {
|
|
530
|
+
return addHighlightComment(parent, state, dispatch);
|
|
579
531
|
}
|
|
580
532
|
else {
|
|
581
|
-
return addBlockComment(
|
|
533
|
+
return addBlockComment(parent, state, dispatch);
|
|
582
534
|
}
|
|
583
535
|
}
|
|
584
536
|
}
|
|
585
537
|
const getParentNode = (selection) => {
|
|
586
538
|
var _a;
|
|
587
539
|
const parentNode = findParentNodeWithId(selection);
|
|
588
|
-
|
|
589
|
-
if (node
|
|
590
|
-
|
|
591
|
-
node = (_a = findTableElement(selection)) === null || _a === void 0 ? void 0 : _a.node;
|
|
540
|
+
const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
|
|
541
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === schema.nodes.table) {
|
|
542
|
+
return (_a = findParentNodeOfType(schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
|
|
592
543
|
}
|
|
593
544
|
return node;
|
|
594
545
|
};
|
|
595
|
-
const isAllowedType = (type) => type ===
|
|
596
|
-
type ===
|
|
597
|
-
type ===
|
|
598
|
-
type ===
|
|
599
|
-
type ===
|
|
600
|
-
type ===
|
|
601
|
-
type ===
|
|
546
|
+
const isAllowedType = (type) => type === schema.nodes.section ||
|
|
547
|
+
type === schema.nodes.footnotes_section ||
|
|
548
|
+
type === schema.nodes.bibliography_section ||
|
|
549
|
+
type === schema.nodes.keyword_group ||
|
|
550
|
+
type === schema.nodes.paragraph ||
|
|
551
|
+
type === schema.nodes.figure_element ||
|
|
552
|
+
type === schema.nodes.table_element;
|
|
602
553
|
const getNode = (node) => {
|
|
603
|
-
if (node.type ===
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
if (child.type === node.type.schema.nodes.keywords_group) {
|
|
607
|
-
keywordGroup = child;
|
|
608
|
-
return false;
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
return keywordGroup || node;
|
|
554
|
+
if (node.type === schema.nodes.keywords) {
|
|
555
|
+
const keywordGroups = findChildrenByType(node, schema.nodes.keyword_group, true);
|
|
556
|
+
return keywordGroups.length ? keywordGroups[0].node : node;
|
|
612
557
|
}
|
|
613
558
|
return node;
|
|
614
559
|
};
|
|
@@ -627,7 +572,7 @@ const addBlockComment = (node, state, dispatch) => {
|
|
|
627
572
|
const addHighlightComment = (node, state, dispatch) => {
|
|
628
573
|
const { attrs: { id }, type, } = node;
|
|
629
574
|
const comment = buildComment(id);
|
|
630
|
-
if (type ===
|
|
575
|
+
if (type === schema.nodes.paragraph) {
|
|
631
576
|
const { $anchor, $head } = state.selection;
|
|
632
577
|
const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
|
|
633
578
|
$anchor.textOffset === $head.textOffset;
|
|
@@ -6,16 +6,15 @@ import { findDOMNode } from 'react-dom';
|
|
|
6
6
|
import { ContextMenu } from '../../lib/context-menu';
|
|
7
7
|
import { isDeleted, isRejectedInsert } from '../../lib/track-changes-utils';
|
|
8
8
|
import { nodeTypeIcon } from '../../node-type-icons';
|
|
9
|
-
import { isSpecialSection } from '../../views/section_title';
|
|
10
9
|
import { Outline, OutlineDropPreview, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemNoArrow, OutlineItemPlaceholder, StyledTriangleCollapsed, StyledTriangleExpanded, } from './Outline';
|
|
11
10
|
const excludedTypes = [
|
|
12
11
|
schema.nodes.table,
|
|
13
12
|
schema.nodes.figure,
|
|
14
13
|
schema.nodes.footnotes_element,
|
|
15
14
|
schema.nodes.bibliography_element,
|
|
16
|
-
schema.nodes.
|
|
17
|
-
schema.nodes.
|
|
18
|
-
schema.nodes.
|
|
15
|
+
schema.nodes.keywords,
|
|
16
|
+
schema.nodes.affiliations,
|
|
17
|
+
schema.nodes.contributors,
|
|
19
18
|
schema.nodes.title,
|
|
20
19
|
];
|
|
21
20
|
const childrenExcludedTypes = [
|
|
@@ -28,6 +27,9 @@ const isExcluded = (nodeType) => {
|
|
|
28
27
|
const isChildrenExcluded = (nodeType) => {
|
|
29
28
|
return childrenExcludedTypes.includes(nodeType);
|
|
30
29
|
};
|
|
30
|
+
const isManuscriptNode = (node) => {
|
|
31
|
+
return (node === null || node === void 0 ? void 0 : node.type) === schema.nodes.manuscript;
|
|
32
|
+
};
|
|
31
33
|
export const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
32
34
|
const items = [];
|
|
33
35
|
const startPos = pos + 1;
|
|
@@ -35,9 +37,12 @@ export const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
|
35
37
|
const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
|
|
36
38
|
if (!isChildrenExcluded(node.type)) {
|
|
37
39
|
node.forEach((childNode, offset, childIndex) => {
|
|
38
|
-
if ((
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
if (isExcluded(childNode.type)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (isManuscriptNode(node) ||
|
|
44
|
+
((!childNode.isAtom || isElementNodeType(childNode.type)) &&
|
|
45
|
+
childNode.attrs.id)) {
|
|
41
46
|
items.push(buildTree({
|
|
42
47
|
node: childNode,
|
|
43
48
|
pos: startPos + offset,
|
|
@@ -104,29 +109,32 @@ class Tree extends React.Component {
|
|
|
104
109
|
render() {
|
|
105
110
|
const { depth = 0, tree, canDrop, connectDragSource, connectDragPreview, connectDropTarget, isDragging, isOverCurrent, item, view, } = this.props;
|
|
106
111
|
const { open, dragPosition } = this.state;
|
|
107
|
-
const { node, items, isSelected } = tree;
|
|
112
|
+
const { node, items, isSelected, parent } = tree;
|
|
108
113
|
const isDeletedItem = isDeleted(node);
|
|
109
114
|
const isRejectedItem = isRejectedInsert(node);
|
|
110
115
|
const mightDrop = item && isOverCurrent && canDrop;
|
|
111
|
-
|
|
116
|
+
const isTop = isManuscriptNode(parent);
|
|
117
|
+
if (isRejectedItem) {
|
|
112
118
|
return null;
|
|
113
119
|
}
|
|
114
|
-
return connectDropTarget(React.createElement("div", null,
|
|
115
|
-
React.createElement(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
return connectDropTarget(React.createElement("div", null,
|
|
121
|
+
React.createElement(Outline, { style: this.outlineStyles(isDragging) },
|
|
122
|
+
React.createElement(OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
|
|
123
|
+
!isTop &&
|
|
124
|
+
connectDragSource(React.createElement("div", null,
|
|
125
|
+
React.createElement(OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
|
|
126
|
+
items.length ? (React.createElement(OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(StyledTriangleExpanded, null)) : (React.createElement(StyledTriangleCollapsed, null)))) : (React.createElement(OutlineItemNoArrow, null)),
|
|
127
|
+
React.createElement(OutlineItemLink, { to: `#${node.attrs.id || ''}` },
|
|
128
|
+
connectDragPreview(React.createElement("span", { style: {
|
|
129
|
+
display: 'inline-flex',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
} },
|
|
132
|
+
React.createElement(OutlineItemIcon, null, nodeTypeIcon(node.type)))),
|
|
133
|
+
React.createElement(OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))),
|
|
134
|
+
items.length ? (React.createElement("div", { style: {
|
|
135
|
+
display: open || isTop ? '' : 'none',
|
|
136
|
+
} }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: isTop ? depth : depth + 1 })))))) : (''),
|
|
137
|
+
React.createElement(OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
|
|
130
138
|
}
|
|
131
139
|
}
|
|
132
140
|
const dragSource = DragSource('outline', {
|
|
@@ -3,20 +3,12 @@ import { skipTracking } from '@manuscripts/track-changes-plugin';
|
|
|
3
3
|
import { schema, } from '@manuscripts/transform';
|
|
4
4
|
import { wrapInList } from 'prosemirror-schema-list';
|
|
5
5
|
import { Selection } from 'prosemirror-state';
|
|
6
|
-
import React, { useCallback
|
|
6
|
+
import React, { useCallback } from 'react';
|
|
7
7
|
import { skipTrackingChanges } from '../../keys/list';
|
|
8
8
|
import { ListButton, ListStyleSelector } from './ListStyleSelector';
|
|
9
9
|
import { ToolbarItem } from './ManuscriptToolbar';
|
|
10
10
|
export const OrderListSelector = ({ state, dispatch, view, title, active, run, enable }) => {
|
|
11
|
-
const
|
|
12
|
-
const dropDownDisabled = useMemo(() => {
|
|
13
|
-
const { $from, $to } = state.selection;
|
|
14
|
-
const range = $from.blockRange($to);
|
|
15
|
-
return !!(enable &&
|
|
16
|
-
!enable(state) &&
|
|
17
|
-
range &&
|
|
18
|
-
!schema.nodes.ordered_list.compatibleContent($from.node(range.depth - 1).type));
|
|
19
|
-
}, [state.selection]);
|
|
11
|
+
const isEnabled = !enable || enable(state);
|
|
20
12
|
const onClickListType = useCallback((type) => {
|
|
21
13
|
if (!dispatch) {
|
|
22
14
|
return;
|
|
@@ -34,13 +26,13 @@ export const OrderListSelector = ({ state, dispatch, view, title, active, run, e
|
|
|
34
26
|
}
|
|
35
27
|
}, [dispatch, state, view]);
|
|
36
28
|
return (React.createElement(ToolbarItem, null,
|
|
37
|
-
React.createElement(ListButton, { title: title, "data-active": active && active(state), disabled:
|
|
29
|
+
React.createElement(ListButton, { title: title, "data-active": active && active(state), disabled: !isEnabled, onMouseDown: (event) => {
|
|
38
30
|
event.preventDefault();
|
|
39
31
|
run(state, dispatch);
|
|
40
32
|
view && view.focus();
|
|
41
33
|
} },
|
|
42
34
|
React.createElement(OrderedList, null)),
|
|
43
|
-
React.createElement(ListStyleSelector, { disabled:
|
|
35
|
+
React.createElement(ListStyleSelector, { disabled: !isEnabled, onClickListType: onClickListType, list: [
|
|
44
36
|
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
45
37
|
{ items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
|
|
46
38
|
{ items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
|
|
@@ -19,10 +19,10 @@ import { dropCursor } from 'prosemirror-dropcursor';
|
|
|
19
19
|
import { history } from 'prosemirror-history';
|
|
20
20
|
import { tableEditing } from 'prosemirror-tables';
|
|
21
21
|
import keys from '../keys';
|
|
22
|
-
import auxiliary_object_order from '../plugins/auxiliary_object_order';
|
|
23
22
|
import bibliography from '../plugins/bibliography';
|
|
24
23
|
import comment_annotation from '../plugins/comment_annotation';
|
|
25
24
|
import elements from '../plugins/elements';
|
|
25
|
+
import footnotes from '../plugins/footnotes';
|
|
26
26
|
import highlights from '../plugins/highlight';
|
|
27
27
|
import keywords from '../plugins/keywords';
|
|
28
28
|
import objects from '../plugins/objects';
|
|
@@ -51,7 +51,6 @@ export default (props) => {
|
|
|
51
51
|
keywords(props),
|
|
52
52
|
bibliography(props),
|
|
53
53
|
objects(props),
|
|
54
|
-
auxiliary_object_order(props),
|
|
55
54
|
comment_annotation(props),
|
|
56
55
|
paragraphs(),
|
|
57
56
|
placeholder(),
|
|
@@ -59,6 +58,7 @@ export default (props) => {
|
|
|
59
58
|
highlights(props),
|
|
60
59
|
track_changes_ui(props),
|
|
61
60
|
tracking_mark(),
|
|
61
|
+
footnotes(),
|
|
62
62
|
];
|
|
63
63
|
};
|
|
64
64
|
document.execCommand('enableObjectResizing', false, 'false');
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import bibliographyElement from '../views/bibliography_element_editable';
|
|
17
|
-
import bibliographyItem from '../views/bibliography_item_editable';
|
|
18
17
|
import blockquoteElement from '../views/blockquote_element_editable';
|
|
19
18
|
import bulletList from '../views/bullet_list_editable';
|
|
20
19
|
import citation from '../views/citation_editable';
|
|
21
|
-
import contributorsSection from '../views/
|
|
20
|
+
import contributorsSection from '../views/contributors';
|
|
22
21
|
import crossReference from '../views/cross_reference_editable';
|
|
22
|
+
import empty from '../views/empty';
|
|
23
23
|
import equation from '../views/equation_editable';
|
|
24
24
|
import equationElement from '../views/equation_element_editable';
|
|
25
25
|
import figure from '../views/figure_editable';
|
|
@@ -33,7 +33,6 @@ import keywordsElement from '../views/keywords_element';
|
|
|
33
33
|
import link from '../views/link_editable';
|
|
34
34
|
import listing from '../views/listing_editable';
|
|
35
35
|
import listingElement from '../views/listing_element_editable';
|
|
36
|
-
import metaSection from '../views/meta_section';
|
|
37
36
|
import orderedList from '../views/ordered_list_editable';
|
|
38
37
|
import paragraph from '../views/paragraph_editable';
|
|
39
38
|
import placeholder from '../views/placeholder';
|
|
@@ -47,13 +46,12 @@ import tocElement from '../views/toc_element_editable';
|
|
|
47
46
|
export default (props, dispatch) => {
|
|
48
47
|
return {
|
|
49
48
|
title: title(props, dispatch),
|
|
50
|
-
bibliography_item: bibliographyItem(props),
|
|
51
49
|
bibliography_element: bibliographyElement(props),
|
|
52
50
|
blockquote_element: blockquoteElement(props),
|
|
53
51
|
bullet_list: bulletList(props),
|
|
54
52
|
citation: citation(props),
|
|
55
53
|
cross_reference: crossReference(props),
|
|
56
|
-
|
|
54
|
+
contributors: contributorsSection(props, dispatch),
|
|
57
55
|
equation: equation(props),
|
|
58
56
|
equation_element: equationElement(props),
|
|
59
57
|
figure: figure(props, dispatch),
|
|
@@ -76,6 +74,6 @@ export default (props, dispatch) => {
|
|
|
76
74
|
section_label: sectionLabel(props),
|
|
77
75
|
table_element: tableElement(props),
|
|
78
76
|
toc_element: tocElement(props),
|
|
79
|
-
|
|
77
|
+
comments: empty('comments'),
|
|
80
78
|
};
|
|
81
79
|
};
|
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { isInBibliographySection, nodeNames, } from '@manuscripts/transform';
|
|
16
|
+
import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { Fragment, Slice } from 'prosemirror-model';
|
|
18
18
|
import { addComment, createBlock } from '../commands';
|
|
19
19
|
import { PopperManager } from './popper';
|
|
20
20
|
const popper = new PopperManager();
|
|
21
|
+
const listTypes = [schema.nodes.ordered_list, schema.nodes.bullet_list];
|
|
22
|
+
const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
|
|
21
23
|
export const sectionLevel = (depth) => {
|
|
22
24
|
switch (depth) {
|
|
23
25
|
case 1:
|
|
@@ -155,8 +157,8 @@ export class ContextMenu {
|
|
|
155
157
|
menu.className = 'menu';
|
|
156
158
|
const $pos = this.resolvePos();
|
|
157
159
|
const nodeType = this.node.type;
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
+
const nodes = schema.nodes;
|
|
161
|
+
if (listTypes.includes(nodeType)) {
|
|
160
162
|
menu.appendChild(this.createMenuSection((section) => {
|
|
161
163
|
if (nodeType === nodes.bullet_list) {
|
|
162
164
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
@@ -204,8 +206,8 @@ export class ContextMenu {
|
|
|
204
206
|
}));
|
|
205
207
|
}));
|
|
206
208
|
}
|
|
207
|
-
if (nodeType
|
|
208
|
-
$pos.parent.type
|
|
209
|
+
if (!readonlyTypes.includes(nodeType) &&
|
|
210
|
+
!readonlyTypes.includes($pos.parent.type)) {
|
|
209
211
|
menu.appendChild(this.createMenuSection((section) => {
|
|
210
212
|
const nodeName = nodeNames.get(nodeType) || '';
|
|
211
213
|
section.appendChild(this.createMenuItem(`Delete ${nodeName}`, () => {
|
|
@@ -313,7 +315,6 @@ export class ContextMenu {
|
|
|
313
315
|
const { getPos, attr, attrs } = option;
|
|
314
316
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, attrs), { [attr]: !attrs[attr] })));
|
|
315
317
|
};
|
|
316
|
-
this.isListType = (type) => ['bullet_list', 'ordered_list'].includes(type);
|
|
317
318
|
this.buildSuppressOptions = () => {
|
|
318
319
|
const items = [];
|
|
319
320
|
let attrs = this.node.attrs;
|
|
@@ -34,7 +34,6 @@ const icons = new Map([
|
|
|
34
34
|
[nodes.equation_element, EquationIcon],
|
|
35
35
|
[nodes.figure_element, FigureIcon],
|
|
36
36
|
[nodes.multi_graphic_figure_element, FigureIcon],
|
|
37
|
-
[nodes.keywords_section, SectionIcon],
|
|
38
37
|
[nodes.listing_element, ListingIcon],
|
|
39
38
|
[nodes.ordered_list, OrderedListIcon],
|
|
40
39
|
[nodes.paragraph, ParagraphIcon],
|