@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/cjs/commands.js
CHANGED
|
@@ -14,31 +14,8 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.
|
|
18
|
+
exports.updateCommentAnnotationState = exports.addComment = exports.deleteHighlightMarkers = exports.insertHighlight = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.ifInTableBody = exports.insertTOCSection = exports.insertBibliographySection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertFileAsFigure = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
42
19
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
43
20
|
const transform_1 = require("@manuscripts/transform");
|
|
44
21
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
@@ -47,10 +24,7 @@ const prosemirror_transform_1 = require("prosemirror-transform");
|
|
|
47
24
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
48
25
|
const helpers_1 = require("./lib/helpers");
|
|
49
26
|
const utils_1 = require("./lib/utils");
|
|
50
|
-
const bibliography_1 = require("./plugins/bibliography");
|
|
51
27
|
const comment_annotation_1 = require("./plugins/comment_annotation");
|
|
52
|
-
const footnotes_1 = require("./plugins/footnotes");
|
|
53
|
-
const footnotesUtils = __importStar(require("./plugins/footnotes/footnotes-utils"));
|
|
54
28
|
const highlight_1 = require("./plugins/highlight");
|
|
55
29
|
const markActive = (type) => (state) => {
|
|
56
30
|
const { from, $from, to, empty } = state.selection;
|
|
@@ -257,12 +231,11 @@ const insertLink = (state, dispatch) => {
|
|
|
257
231
|
return true;
|
|
258
232
|
};
|
|
259
233
|
exports.insertLink = insertLink;
|
|
260
|
-
const insertInlineCitation = (state, dispatch, view
|
|
261
|
-
const citation = (0, transform_1.buildCitation)(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
|
|
234
|
+
const insertInlineCitation = (state, dispatch, view) => {
|
|
262
235
|
const node = state.schema.nodes.citation.create({
|
|
263
|
-
|
|
236
|
+
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Citation),
|
|
237
|
+
rids: [],
|
|
264
238
|
selectedText: selectedText(),
|
|
265
|
-
embeddedCitationItems: [],
|
|
266
239
|
});
|
|
267
240
|
const pos = state.selection.to;
|
|
268
241
|
const { tr } = state;
|
|
@@ -276,7 +249,7 @@ const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = [])
|
|
|
276
249
|
exports.insertInlineCitation = insertInlineCitation;
|
|
277
250
|
const insertCrossReference = (state, dispatch) => {
|
|
278
251
|
const node = state.schema.nodes.cross_reference.create({
|
|
279
|
-
|
|
252
|
+
rids: [],
|
|
280
253
|
});
|
|
281
254
|
const pos = state.selection.to;
|
|
282
255
|
const tr = state.tr.insert(pos, node);
|
|
@@ -306,30 +279,29 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
306
279
|
kind,
|
|
307
280
|
});
|
|
308
281
|
const insertedAt = state.selection.to;
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
rid: footnote.attrs.id,
|
|
312
|
-
contents: thisFootnoteNumbering.toString(),
|
|
282
|
+
const node = state.schema.nodes.inline_footnote.create({
|
|
283
|
+
rids: [footnote.attrs.id],
|
|
313
284
|
});
|
|
314
285
|
const tr = state.tr;
|
|
315
|
-
tr.insert(insertedAt,
|
|
316
|
-
const
|
|
286
|
+
tr.insert(insertedAt, node);
|
|
287
|
+
const elements = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_element);
|
|
317
288
|
let selectionPos;
|
|
318
|
-
if (
|
|
319
|
-
const
|
|
289
|
+
if (!elements.length) {
|
|
290
|
+
const section = state.schema.nodes.footnotes_section.create({}, [
|
|
320
291
|
state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
|
|
321
292
|
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
322
293
|
]);
|
|
323
|
-
const
|
|
324
|
-
tr.insert(
|
|
325
|
-
selectionPos =
|
|
294
|
+
const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
|
|
295
|
+
tr.insert(backmatter.pos + 1, section);
|
|
296
|
+
selectionPos = backmatter.pos + section.nodeSize - 3;
|
|
326
297
|
}
|
|
327
298
|
else {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
299
|
+
const element = elements[0];
|
|
300
|
+
const pos = element.pos + element.node.nodeSize - 1;
|
|
301
|
+
tr.insert(pos, footnote);
|
|
302
|
+
selectionPos = pos + 2;
|
|
331
303
|
}
|
|
332
|
-
if (dispatch) {
|
|
304
|
+
if (dispatch && selectionPos) {
|
|
333
305
|
const selection = prosemirror_state_1.TextSelection.create(tr.doc, selectionPos);
|
|
334
306
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
335
307
|
}
|
|
@@ -337,22 +309,18 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
337
309
|
};
|
|
338
310
|
exports.insertInlineFootnote = insertInlineFootnote;
|
|
339
311
|
const insertGraphicalAbstract = (state, dispatch) => {
|
|
340
|
-
|
|
341
|
-
if (pos === null ||
|
|
342
|
-
(0, transform_1.isInBibliographySection)(state.selection.$from) ||
|
|
343
|
-
!(0, transform_1.isInAbstractsSection)(state.selection.$from)) {
|
|
344
|
-
return false;
|
|
345
|
-
}
|
|
346
|
-
if ((0, utils_1.getMatchingDescendant)(state.doc, (node) => node.type === state.schema.nodes.graphical_abstract_section)) {
|
|
312
|
+
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.graphical_abstract_section)) {
|
|
347
313
|
return false;
|
|
348
314
|
}
|
|
349
|
-
const
|
|
350
|
-
|
|
315
|
+
const abstracts = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.abstracts)[0];
|
|
316
|
+
const section = transform_1.schema.nodes.graphical_abstract_section.createAndFill({ category: 'MPSectionCategory:abstract-graphical' }, [
|
|
317
|
+
transform_1.schema.nodes.section_title.create({}, transform_1.schema.text('Graphical Abstract')),
|
|
351
318
|
createAndFillFigureElement(state),
|
|
352
319
|
]);
|
|
320
|
+
const pos = abstracts.pos + abstracts.node.nodeSize + 1;
|
|
353
321
|
const tr = state.tr.insert(pos, section);
|
|
354
322
|
if (dispatch) {
|
|
355
|
-
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos +
|
|
323
|
+
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 1);
|
|
356
324
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
357
325
|
}
|
|
358
326
|
return true;
|
|
@@ -372,58 +340,12 @@ const insertSection = (subsection = false) => (state, dispatch) => {
|
|
|
372
340
|
return true;
|
|
373
341
|
};
|
|
374
342
|
exports.insertSection = insertSection;
|
|
375
|
-
const insertFootnotesSection = (state, dispatch) => {
|
|
376
|
-
if ((0, utils_1.getChildOfType)(state.doc, state.schema.nodes.footnotes_section)) {
|
|
377
|
-
return false;
|
|
378
|
-
}
|
|
379
|
-
const section = state.schema.nodes.footnotes_section.createAndFill({}, [
|
|
380
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
|
|
381
|
-
state.schema.nodes.footnotes_element.create(),
|
|
382
|
-
]);
|
|
383
|
-
const pos = state.tr.doc.content.size;
|
|
384
|
-
const tr = state.tr;
|
|
385
|
-
tr.insert(pos, section).setMeta(footnotes_1.footnotesKey, {
|
|
386
|
-
footnotesElementInserted: true,
|
|
387
|
-
});
|
|
388
|
-
if (dispatch) {
|
|
389
|
-
const selection = prosemirror_state_1.NodeSelection.create(tr.doc, pos);
|
|
390
|
-
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
391
|
-
}
|
|
392
|
-
return true;
|
|
393
|
-
};
|
|
394
|
-
exports.insertFootnotesSection = insertFootnotesSection;
|
|
395
343
|
const insertBibliographySection = (state, dispatch) => {
|
|
396
|
-
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
const section = state.schema.nodes.bibliography_section.createAndFill({}, [
|
|
400
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Bibliography')),
|
|
401
|
-
]);
|
|
402
|
-
const pos = state.tr.doc.content.size;
|
|
403
|
-
const tr = state.tr;
|
|
404
|
-
tr.insert(pos, section).setMeta(bibliography_1.bibliographyKey, {
|
|
405
|
-
bibliographyInserted: true,
|
|
406
|
-
});
|
|
407
|
-
if (dispatch) {
|
|
408
|
-
const selection = prosemirror_state_1.NodeSelection.create(tr.doc, pos);
|
|
409
|
-
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
410
|
-
}
|
|
411
|
-
return true;
|
|
344
|
+
return false;
|
|
412
345
|
};
|
|
413
346
|
exports.insertBibliographySection = insertBibliographySection;
|
|
414
347
|
const insertTOCSection = (state, dispatch) => {
|
|
415
|
-
|
|
416
|
-
return false;
|
|
417
|
-
}
|
|
418
|
-
const section = state.schema.nodes.toc_section.createAndFill({}, [
|
|
419
|
-
state.schema.nodes.section_title.create({}, state.schema.text('Table of Contents')),
|
|
420
|
-
]);
|
|
421
|
-
const pos = 0;
|
|
422
|
-
const tr = state.tr.insert(pos, section);
|
|
423
|
-
if (dispatch) {
|
|
424
|
-
dispatch(tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos)).scrollIntoView());
|
|
425
|
-
}
|
|
426
|
-
return true;
|
|
348
|
+
return false;
|
|
427
349
|
};
|
|
428
350
|
exports.insertTOCSection = insertTOCSection;
|
|
429
351
|
const ifInTableBody = (command) => (state) => {
|
|
@@ -619,11 +541,17 @@ const deleteHighlightMarkers = (rid) => (state, dispatch) => {
|
|
|
619
541
|
exports.deleteHighlightMarkers = deleteHighlightMarkers;
|
|
620
542
|
function addComment(state, dispatch, viewNode, resolvePos) {
|
|
621
543
|
const { selection } = state;
|
|
622
|
-
const
|
|
623
|
-
const
|
|
544
|
+
const hasText = selection.content().size > 0;
|
|
545
|
+
const parent = getParentNode(selection);
|
|
546
|
+
if (!parent) {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
624
549
|
if (viewNode && resolvePos) {
|
|
625
550
|
const viewNode = getParentNode(prosemirror_state_1.TextSelection.near(resolvePos));
|
|
626
|
-
if (
|
|
551
|
+
if (!viewNode) {
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
if (hasText && parent.attrs.id === viewNode.attrs.id) {
|
|
627
555
|
return addHighlightComment(viewNode, state, dispatch);
|
|
628
556
|
}
|
|
629
557
|
else {
|
|
@@ -631,11 +559,11 @@ function addComment(state, dispatch, viewNode, resolvePos) {
|
|
|
631
559
|
}
|
|
632
560
|
}
|
|
633
561
|
else {
|
|
634
|
-
if (
|
|
635
|
-
return addHighlightComment(
|
|
562
|
+
if (hasText) {
|
|
563
|
+
return addHighlightComment(parent, state, dispatch);
|
|
636
564
|
}
|
|
637
565
|
else {
|
|
638
|
-
return addBlockComment(
|
|
566
|
+
return addBlockComment(parent, state, dispatch);
|
|
639
567
|
}
|
|
640
568
|
}
|
|
641
569
|
}
|
|
@@ -643,30 +571,23 @@ exports.addComment = addComment;
|
|
|
643
571
|
const getParentNode = (selection) => {
|
|
644
572
|
var _a;
|
|
645
573
|
const parentNode = (0, utils_1.findParentNodeWithId)(selection);
|
|
646
|
-
|
|
647
|
-
if (node
|
|
648
|
-
|
|
649
|
-
node = (_a = findTableElement(selection)) === null || _a === void 0 ? void 0 : _a.node;
|
|
574
|
+
const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
|
|
575
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === transform_1.schema.nodes.table) {
|
|
576
|
+
return (_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
|
|
650
577
|
}
|
|
651
578
|
return node;
|
|
652
579
|
};
|
|
653
|
-
const isAllowedType = (type) => type ===
|
|
654
|
-
type ===
|
|
655
|
-
type ===
|
|
656
|
-
type ===
|
|
657
|
-
type ===
|
|
658
|
-
type ===
|
|
659
|
-
type ===
|
|
580
|
+
const isAllowedType = (type) => type === transform_1.schema.nodes.section ||
|
|
581
|
+
type === transform_1.schema.nodes.footnotes_section ||
|
|
582
|
+
type === transform_1.schema.nodes.bibliography_section ||
|
|
583
|
+
type === transform_1.schema.nodes.keyword_group ||
|
|
584
|
+
type === transform_1.schema.nodes.paragraph ||
|
|
585
|
+
type === transform_1.schema.nodes.figure_element ||
|
|
586
|
+
type === transform_1.schema.nodes.table_element;
|
|
660
587
|
const getNode = (node) => {
|
|
661
|
-
if (node.type ===
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if (child.type === node.type.schema.nodes.keywords_group) {
|
|
665
|
-
keywordGroup = child;
|
|
666
|
-
return false;
|
|
667
|
-
}
|
|
668
|
-
});
|
|
669
|
-
return keywordGroup || node;
|
|
588
|
+
if (node.type === transform_1.schema.nodes.keywords) {
|
|
589
|
+
const keywordGroups = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.keyword_group, true);
|
|
590
|
+
return keywordGroups.length ? keywordGroups[0].node : node;
|
|
670
591
|
}
|
|
671
592
|
return node;
|
|
672
593
|
};
|
|
@@ -685,7 +606,7 @@ const addBlockComment = (node, state, dispatch) => {
|
|
|
685
606
|
const addHighlightComment = (node, state, dispatch) => {
|
|
686
607
|
const { attrs: { id }, type, } = node;
|
|
687
608
|
const comment = (0, transform_1.buildComment)(id);
|
|
688
|
-
if (type ===
|
|
609
|
+
if (type === transform_1.schema.nodes.paragraph) {
|
|
689
610
|
const { $anchor, $head } = state.selection;
|
|
690
611
|
const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
|
|
691
612
|
$anchor.textOffset === $head.textOffset;
|
|
@@ -32,16 +32,15 @@ const react_dom_1 = require("react-dom");
|
|
|
32
32
|
const context_menu_1 = require("../../lib/context-menu");
|
|
33
33
|
const track_changes_utils_1 = require("../../lib/track-changes-utils");
|
|
34
34
|
const node_type_icons_1 = require("../../node-type-icons");
|
|
35
|
-
const section_title_1 = require("../../views/section_title");
|
|
36
35
|
const Outline_1 = require("./Outline");
|
|
37
36
|
const excludedTypes = [
|
|
38
37
|
transform_1.schema.nodes.table,
|
|
39
38
|
transform_1.schema.nodes.figure,
|
|
40
39
|
transform_1.schema.nodes.footnotes_element,
|
|
41
40
|
transform_1.schema.nodes.bibliography_element,
|
|
42
|
-
transform_1.schema.nodes.
|
|
43
|
-
transform_1.schema.nodes.
|
|
44
|
-
transform_1.schema.nodes.
|
|
41
|
+
transform_1.schema.nodes.keywords,
|
|
42
|
+
transform_1.schema.nodes.affiliations,
|
|
43
|
+
transform_1.schema.nodes.contributors,
|
|
45
44
|
transform_1.schema.nodes.title,
|
|
46
45
|
];
|
|
47
46
|
const childrenExcludedTypes = [
|
|
@@ -54,6 +53,9 @@ const isExcluded = (nodeType) => {
|
|
|
54
53
|
const isChildrenExcluded = (nodeType) => {
|
|
55
54
|
return childrenExcludedTypes.includes(nodeType);
|
|
56
55
|
};
|
|
56
|
+
const isManuscriptNode = (node) => {
|
|
57
|
+
return (node === null || node === void 0 ? void 0 : node.type) === transform_1.schema.nodes.manuscript;
|
|
58
|
+
};
|
|
57
59
|
const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
58
60
|
const items = [];
|
|
59
61
|
const startPos = pos + 1;
|
|
@@ -61,9 +63,12 @@ const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
|
61
63
|
const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
|
|
62
64
|
if (!isChildrenExcluded(node.type)) {
|
|
63
65
|
node.forEach((childNode, offset, childIndex) => {
|
|
64
|
-
if ((
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
if (isExcluded(childNode.type)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (isManuscriptNode(node) ||
|
|
70
|
+
((!childNode.isAtom || (0, transform_1.isElementNodeType)(childNode.type)) &&
|
|
71
|
+
childNode.attrs.id)) {
|
|
67
72
|
items.push((0, exports.buildTree)({
|
|
68
73
|
node: childNode,
|
|
69
74
|
pos: startPos + offset,
|
|
@@ -131,29 +136,32 @@ class Tree extends React.Component {
|
|
|
131
136
|
render() {
|
|
132
137
|
const { depth = 0, tree, canDrop, connectDragSource, connectDragPreview, connectDropTarget, isDragging, isOverCurrent, item, view, } = this.props;
|
|
133
138
|
const { open, dragPosition } = this.state;
|
|
134
|
-
const { node, items, isSelected } = tree;
|
|
139
|
+
const { node, items, isSelected, parent } = tree;
|
|
135
140
|
const isDeletedItem = (0, track_changes_utils_1.isDeleted)(node);
|
|
136
141
|
const isRejectedItem = (0, track_changes_utils_1.isRejectedInsert)(node);
|
|
137
142
|
const mightDrop = item && isOverCurrent && canDrop;
|
|
138
|
-
|
|
143
|
+
const isTop = isManuscriptNode(parent);
|
|
144
|
+
if (isRejectedItem) {
|
|
139
145
|
return null;
|
|
140
146
|
}
|
|
141
|
-
return connectDropTarget(React.createElement("div", null,
|
|
142
|
-
React.createElement(Outline_1.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
147
|
+
return connectDropTarget(React.createElement("div", null,
|
|
148
|
+
React.createElement(Outline_1.Outline, { style: this.outlineStyles(isDragging) },
|
|
149
|
+
React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.topPreviewStyles(mightDrop, dragPosition) }),
|
|
150
|
+
!isTop &&
|
|
151
|
+
connectDragSource(React.createElement("div", null,
|
|
152
|
+
React.createElement(Outline_1.OutlineItem, { isSelected: isSelected, depth: depth, onContextMenu: this.handleContextMenu },
|
|
153
|
+
items.length ? (React.createElement(Outline_1.OutlineItemArrow, { onClick: this.toggle }, open ? (React.createElement(Outline_1.StyledTriangleExpanded, null)) : (React.createElement(Outline_1.StyledTriangleCollapsed, null)))) : (React.createElement(Outline_1.OutlineItemNoArrow, null)),
|
|
154
|
+
React.createElement(Outline_1.OutlineItemLink, { to: `#${node.attrs.id || ''}` },
|
|
155
|
+
connectDragPreview(React.createElement("span", { style: {
|
|
156
|
+
display: 'inline-flex',
|
|
157
|
+
alignItems: 'center',
|
|
158
|
+
} },
|
|
159
|
+
React.createElement(Outline_1.OutlineItemIcon, null, (0, node_type_icons_1.nodeTypeIcon)(node.type)))),
|
|
160
|
+
React.createElement(Outline_1.OutlineItemLinkText, { className: `outline-text-${node.type.name} ${isDeletedItem && 'deleted'}` }, this.itemText(node)))))),
|
|
161
|
+
items.length ? (React.createElement("div", { style: {
|
|
162
|
+
display: open || isTop ? '' : 'none',
|
|
163
|
+
} }, items.map((subtree) => (React.createElement(DraggableTree, Object.assign({}, this.props, { key: subtree.node.attrs.id, tree: subtree, view: view, depth: isTop ? depth : depth + 1 })))))) : (''),
|
|
164
|
+
React.createElement(Outline_1.OutlineDropPreview, { depth: depth, style: this.bottomPreviewStyles(mightDrop, dragPosition) }))));
|
|
157
165
|
}
|
|
158
166
|
}
|
|
159
167
|
const dragSource = (0, react_dnd_1.DragSource)('outline', {
|
|
@@ -37,15 +37,7 @@ const list_1 = require("../../keys/list");
|
|
|
37
37
|
const ListStyleSelector_1 = require("./ListStyleSelector");
|
|
38
38
|
const ManuscriptToolbar_1 = require("./ManuscriptToolbar");
|
|
39
39
|
const OrderListSelector = ({ state, dispatch, view, title, active, run, enable }) => {
|
|
40
|
-
const
|
|
41
|
-
const dropDownDisabled = (0, react_1.useMemo)(() => {
|
|
42
|
-
const { $from, $to } = state.selection;
|
|
43
|
-
const range = $from.blockRange($to);
|
|
44
|
-
return !!(enable &&
|
|
45
|
-
!enable(state) &&
|
|
46
|
-
range &&
|
|
47
|
-
!transform_1.schema.nodes.ordered_list.compatibleContent($from.node(range.depth - 1).type));
|
|
48
|
-
}, [state.selection]);
|
|
40
|
+
const isEnabled = !enable || enable(state);
|
|
49
41
|
const onClickListType = (0, react_1.useCallback)((type) => {
|
|
50
42
|
if (!dispatch) {
|
|
51
43
|
return;
|
|
@@ -63,13 +55,13 @@ const OrderListSelector = ({ state, dispatch, view, title, active, run, enable }
|
|
|
63
55
|
}
|
|
64
56
|
}, [dispatch, state, view]);
|
|
65
57
|
return (react_1.default.createElement(ManuscriptToolbar_1.ToolbarItem, null,
|
|
66
|
-
react_1.default.createElement(ListStyleSelector_1.ListButton, { title: title, "data-active": active && active(state), disabled:
|
|
58
|
+
react_1.default.createElement(ListStyleSelector_1.ListButton, { title: title, "data-active": active && active(state), disabled: !isEnabled, onMouseDown: (event) => {
|
|
67
59
|
event.preventDefault();
|
|
68
60
|
run(state, dispatch);
|
|
69
61
|
view && view.focus();
|
|
70
62
|
} },
|
|
71
63
|
react_1.default.createElement(ToolbarIconOrderedList_1.default, null)),
|
|
72
|
-
react_1.default.createElement(ListStyleSelector_1.ListStyleSelector, { disabled:
|
|
64
|
+
react_1.default.createElement(ListStyleSelector_1.ListStyleSelector, { disabled: !isEnabled, onClickListType: onClickListType, list: [
|
|
73
65
|
{ items: ['1.', '2.', '3.'], type: 'order' },
|
|
74
66
|
{ items: ['A.', 'B.', 'C.'], type: 'alpha-upper' },
|
|
75
67
|
{ items: ['a.', 'b.', 'c.'], type: 'alpha-lower' },
|
|
@@ -24,10 +24,10 @@ const prosemirror_dropcursor_1 = require("prosemirror-dropcursor");
|
|
|
24
24
|
const prosemirror_history_1 = require("prosemirror-history");
|
|
25
25
|
const prosemirror_tables_1 = require("prosemirror-tables");
|
|
26
26
|
const keys_1 = __importDefault(require("../keys"));
|
|
27
|
-
const auxiliary_object_order_1 = __importDefault(require("../plugins/auxiliary_object_order"));
|
|
28
27
|
const bibliography_1 = __importDefault(require("../plugins/bibliography"));
|
|
29
28
|
const comment_annotation_1 = __importDefault(require("../plugins/comment_annotation"));
|
|
30
29
|
const elements_1 = __importDefault(require("../plugins/elements"));
|
|
30
|
+
const footnotes_1 = __importDefault(require("../plugins/footnotes"));
|
|
31
31
|
const highlight_1 = __importDefault(require("../plugins/highlight"));
|
|
32
32
|
const keywords_1 = __importDefault(require("../plugins/keywords"));
|
|
33
33
|
const objects_1 = __importDefault(require("../plugins/objects"));
|
|
@@ -56,7 +56,6 @@ exports.default = (props) => {
|
|
|
56
56
|
(0, keywords_1.default)(props),
|
|
57
57
|
(0, bibliography_1.default)(props),
|
|
58
58
|
(0, objects_1.default)(props),
|
|
59
|
-
(0, auxiliary_object_order_1.default)(props),
|
|
60
59
|
(0, comment_annotation_1.default)(props),
|
|
61
60
|
(0, paragraphs_1.default)(),
|
|
62
61
|
(0, placeholder_1.default)(),
|
|
@@ -64,6 +63,7 @@ exports.default = (props) => {
|
|
|
64
63
|
(0, highlight_1.default)(props),
|
|
65
64
|
(0, track_changes_ui_1.default)(props),
|
|
66
65
|
(0, tracking_mark_1.default)(),
|
|
66
|
+
(0, footnotes_1.default)(),
|
|
67
67
|
];
|
|
68
68
|
};
|
|
69
69
|
document.execCommand('enableObjectResizing', false, 'false');
|
|
@@ -19,12 +19,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const bibliography_element_editable_1 = __importDefault(require("../views/bibliography_element_editable"));
|
|
22
|
-
const bibliography_item_editable_1 = __importDefault(require("../views/bibliography_item_editable"));
|
|
23
22
|
const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
|
|
24
23
|
const bullet_list_editable_1 = __importDefault(require("../views/bullet_list_editable"));
|
|
25
24
|
const citation_editable_1 = __importDefault(require("../views/citation_editable"));
|
|
26
|
-
const
|
|
25
|
+
const contributors_1 = __importDefault(require("../views/contributors"));
|
|
27
26
|
const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
|
|
27
|
+
const empty_1 = __importDefault(require("../views/empty"));
|
|
28
28
|
const equation_editable_1 = __importDefault(require("../views/equation_editable"));
|
|
29
29
|
const equation_element_editable_1 = __importDefault(require("../views/equation_element_editable"));
|
|
30
30
|
const figure_editable_1 = __importDefault(require("../views/figure_editable"));
|
|
@@ -38,7 +38,6 @@ const keywords_element_1 = __importDefault(require("../views/keywords_element"))
|
|
|
38
38
|
const link_editable_1 = __importDefault(require("../views/link_editable"));
|
|
39
39
|
const listing_editable_1 = __importDefault(require("../views/listing_editable"));
|
|
40
40
|
const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
|
|
41
|
-
const meta_section_1 = __importDefault(require("../views/meta_section"));
|
|
42
41
|
const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
|
|
43
42
|
const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
|
|
44
43
|
const placeholder_1 = __importDefault(require("../views/placeholder"));
|
|
@@ -52,13 +51,12 @@ const toc_element_editable_1 = __importDefault(require("../views/toc_element_edi
|
|
|
52
51
|
exports.default = (props, dispatch) => {
|
|
53
52
|
return {
|
|
54
53
|
title: (0, title_editable_1.default)(props, dispatch),
|
|
55
|
-
bibliography_item: (0, bibliography_item_editable_1.default)(props),
|
|
56
54
|
bibliography_element: (0, bibliography_element_editable_1.default)(props),
|
|
57
55
|
blockquote_element: (0, blockquote_element_editable_1.default)(props),
|
|
58
56
|
bullet_list: (0, bullet_list_editable_1.default)(props),
|
|
59
57
|
citation: (0, citation_editable_1.default)(props),
|
|
60
58
|
cross_reference: (0, cross_reference_editable_1.default)(props),
|
|
61
|
-
|
|
59
|
+
contributors: (0, contributors_1.default)(props, dispatch),
|
|
62
60
|
equation: (0, equation_editable_1.default)(props),
|
|
63
61
|
equation_element: (0, equation_element_editable_1.default)(props),
|
|
64
62
|
figure: (0, figure_editable_1.default)(props, dispatch),
|
|
@@ -81,6 +79,6 @@ exports.default = (props, dispatch) => {
|
|
|
81
79
|
section_label: (0, section_label_1.default)(props),
|
|
82
80
|
table_element: (0, table_element_editable_1.default)(props),
|
|
83
81
|
toc_element: (0, toc_element_editable_1.default)(props),
|
|
84
|
-
|
|
82
|
+
comments: (0, empty_1.default)('comments'),
|
|
85
83
|
};
|
|
86
84
|
};
|
|
@@ -21,6 +21,8 @@ const prosemirror_model_1 = require("prosemirror-model");
|
|
|
21
21
|
const commands_1 = require("../commands");
|
|
22
22
|
const popper_1 = require("./popper");
|
|
23
23
|
const popper = new popper_1.PopperManager();
|
|
24
|
+
const listTypes = [transform_1.schema.nodes.ordered_list, transform_1.schema.nodes.bullet_list];
|
|
25
|
+
const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
|
|
24
26
|
const sectionLevel = (depth) => {
|
|
25
27
|
switch (depth) {
|
|
26
28
|
case 1:
|
|
@@ -159,8 +161,8 @@ class ContextMenu {
|
|
|
159
161
|
menu.className = 'menu';
|
|
160
162
|
const $pos = this.resolvePos();
|
|
161
163
|
const nodeType = this.node.type;
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
+
const nodes = transform_1.schema.nodes;
|
|
165
|
+
if (listTypes.includes(nodeType)) {
|
|
164
166
|
menu.appendChild(this.createMenuSection((section) => {
|
|
165
167
|
if (nodeType === nodes.bullet_list) {
|
|
166
168
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
@@ -208,8 +210,8 @@ class ContextMenu {
|
|
|
208
210
|
}));
|
|
209
211
|
}));
|
|
210
212
|
}
|
|
211
|
-
if (nodeType
|
|
212
|
-
$pos.parent.type
|
|
213
|
+
if (!readonlyTypes.includes(nodeType) &&
|
|
214
|
+
!readonlyTypes.includes($pos.parent.type)) {
|
|
213
215
|
menu.appendChild(this.createMenuSection((section) => {
|
|
214
216
|
const nodeName = transform_1.nodeNames.get(nodeType) || '';
|
|
215
217
|
section.appendChild(this.createMenuItem(`Delete ${nodeName}`, () => {
|
|
@@ -317,7 +319,6 @@ class ContextMenu {
|
|
|
317
319
|
const { getPos, attr, attrs } = option;
|
|
318
320
|
this.view.dispatch(this.view.state.tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, attrs), { [attr]: !attrs[attr] })));
|
|
319
321
|
};
|
|
320
|
-
this.isListType = (type) => ['bullet_list', 'ordered_list'].includes(type);
|
|
321
322
|
this.buildSuppressOptions = () => {
|
|
322
323
|
const items = [];
|
|
323
324
|
let attrs = this.node.attrs;
|
|
@@ -40,7 +40,6 @@ const icons = new Map([
|
|
|
40
40
|
[nodes.equation_element, OutlineIconEquation_1.default],
|
|
41
41
|
[nodes.figure_element, OutlineIconFigure_1.default],
|
|
42
42
|
[nodes.multi_graphic_figure_element, OutlineIconFigure_1.default],
|
|
43
|
-
[nodes.keywords_section, OutlineIconSection_1.default],
|
|
44
43
|
[nodes.listing_element, OutlineIconCodeSnippet_1.default],
|
|
45
44
|
[nodes.ordered_list, OutlineIconOrderedList_1.default],
|
|
46
45
|
[nodes.paragraph, OutlineIconParagraph_1.default],
|