@manuscripts/body-editor 1.5.14 → 1.5.15-LEAN-3030
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 +45 -72
- package/dist/cjs/components/outline/DraggableTree.js +4 -4
- 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/keys/title.js +4 -0
- 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 -42
- 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/sections.js +1 -2
- package/dist/cjs/plugins/toc.js +28 -23
- package/dist/cjs/views/bibliography_element.js +21 -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 +4 -9
- package/dist/es/commands.js +47 -51
- package/dist/es/components/outline/DraggableTree.js +4 -4
- 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/keys/title.js +4 -0
- 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 -40
- 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/sections.js +2 -3
- package/dist/es/plugins/toc.js +29 -24
- package/dist/es/views/bibliography_element.js +22 -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 +4 -9
- package/dist/types/commands.d.ts +1 -1
- 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 +1 -1
- package/package.json +4 -5
- 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,29 +14,6 @@
|
|
|
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
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.insertFootnotesSection = 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");
|
|
@@ -50,7 +27,6 @@ const utils_1 = require("./lib/utils");
|
|
|
50
27
|
const bibliography_1 = require("./plugins/bibliography");
|
|
51
28
|
const comment_annotation_1 = require("./plugins/comment_annotation");
|
|
52
29
|
const footnotes_1 = require("./plugins/footnotes");
|
|
53
|
-
const footnotesUtils = __importStar(require("./plugins/footnotes/footnotes-utils"));
|
|
54
30
|
const highlight_1 = require("./plugins/highlight");
|
|
55
31
|
const markActive = (type) => (state) => {
|
|
56
32
|
const { from, $from, to, empty } = state.selection;
|
|
@@ -257,12 +233,11 @@ const insertLink = (state, dispatch) => {
|
|
|
257
233
|
return true;
|
|
258
234
|
};
|
|
259
235
|
exports.insertLink = insertLink;
|
|
260
|
-
const insertInlineCitation = (state, dispatch, view
|
|
261
|
-
const citation = (0, transform_1.buildCitation)(state.selection.$anchor.parent.attrs.id, embeddedCitationItems);
|
|
236
|
+
const insertInlineCitation = (state, dispatch, view) => {
|
|
262
237
|
const node = state.schema.nodes.citation.create({
|
|
263
|
-
|
|
238
|
+
id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Citation),
|
|
239
|
+
rids: [],
|
|
264
240
|
selectedText: selectedText(),
|
|
265
|
-
embeddedCitationItems: [],
|
|
266
241
|
});
|
|
267
242
|
const pos = state.selection.to;
|
|
268
243
|
const { tr } = state;
|
|
@@ -276,7 +251,7 @@ const insertInlineCitation = (state, dispatch, view, embeddedCitationItems = [])
|
|
|
276
251
|
exports.insertInlineCitation = insertInlineCitation;
|
|
277
252
|
const insertCrossReference = (state, dispatch) => {
|
|
278
253
|
const node = state.schema.nodes.cross_reference.create({
|
|
279
|
-
|
|
254
|
+
rids: [],
|
|
280
255
|
});
|
|
281
256
|
const pos = state.selection.to;
|
|
282
257
|
const tr = state.tr.insert(pos, node);
|
|
@@ -306,30 +281,29 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
|
|
|
306
281
|
kind,
|
|
307
282
|
});
|
|
308
283
|
const insertedAt = state.selection.to;
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
rid: footnote.attrs.id,
|
|
312
|
-
contents: thisFootnoteNumbering.toString(),
|
|
284
|
+
const node = state.schema.nodes.inline_footnote.create({
|
|
285
|
+
rids: [footnote.attrs.id],
|
|
313
286
|
});
|
|
314
287
|
const tr = state.tr;
|
|
315
|
-
tr.insert(insertedAt,
|
|
316
|
-
const
|
|
317
|
-
let selectionPos;
|
|
318
|
-
if (
|
|
319
|
-
const
|
|
288
|
+
tr.insert(insertedAt, node);
|
|
289
|
+
const elements = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_element);
|
|
290
|
+
let selectionPos = undefined;
|
|
291
|
+
if (!elements.length) {
|
|
292
|
+
const section = state.schema.nodes.footnotes_section.create({}, [
|
|
320
293
|
state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
|
|
321
294
|
state.schema.nodes.footnotes_element.create({}, footnote),
|
|
322
295
|
]);
|
|
323
|
-
const
|
|
324
|
-
tr.insert(
|
|
325
|
-
selectionPos =
|
|
296
|
+
const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
|
|
297
|
+
tr.insert(backmatter.pos + 1, section);
|
|
298
|
+
selectionPos = backmatter.pos + section.nodeSize;
|
|
326
299
|
}
|
|
327
300
|
else {
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
301
|
+
const element = elements[0];
|
|
302
|
+
const pos = element.pos + element.node.nodeSize - 1;
|
|
303
|
+
tr.insert(pos, footnote);
|
|
304
|
+
selectionPos = pos + 2;
|
|
331
305
|
}
|
|
332
|
-
if (dispatch) {
|
|
306
|
+
if (dispatch && selectionPos) {
|
|
333
307
|
const selection = prosemirror_state_1.TextSelection.create(tr.doc, selectionPos);
|
|
334
308
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
335
309
|
}
|
|
@@ -619,11 +593,17 @@ const deleteHighlightMarkers = (rid) => (state, dispatch) => {
|
|
|
619
593
|
exports.deleteHighlightMarkers = deleteHighlightMarkers;
|
|
620
594
|
function addComment(state, dispatch, viewNode, resolvePos) {
|
|
621
595
|
const { selection } = state;
|
|
622
|
-
const
|
|
623
|
-
const
|
|
596
|
+
const hasText = selection.content().size > 0;
|
|
597
|
+
const parent = getParentNode(selection);
|
|
598
|
+
if (!parent) {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
624
601
|
if (viewNode && resolvePos) {
|
|
625
602
|
const viewNode = getParentNode(prosemirror_state_1.TextSelection.near(resolvePos));
|
|
626
|
-
if (
|
|
603
|
+
if (!viewNode) {
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
if (hasText && parent.attrs.id === viewNode.attrs.id) {
|
|
627
607
|
return addHighlightComment(viewNode, state, dispatch);
|
|
628
608
|
}
|
|
629
609
|
else {
|
|
@@ -631,11 +611,11 @@ function addComment(state, dispatch, viewNode, resolvePos) {
|
|
|
631
611
|
}
|
|
632
612
|
}
|
|
633
613
|
else {
|
|
634
|
-
if (
|
|
635
|
-
return addHighlightComment(
|
|
614
|
+
if (hasText) {
|
|
615
|
+
return addHighlightComment(parent, state, dispatch);
|
|
636
616
|
}
|
|
637
617
|
else {
|
|
638
|
-
return addBlockComment(
|
|
618
|
+
return addBlockComment(parent, state, dispatch);
|
|
639
619
|
}
|
|
640
620
|
}
|
|
641
621
|
}
|
|
@@ -643,30 +623,23 @@ exports.addComment = addComment;
|
|
|
643
623
|
const getParentNode = (selection) => {
|
|
644
624
|
var _a;
|
|
645
625
|
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;
|
|
626
|
+
const node = parentNode === null || parentNode === void 0 ? void 0 : parentNode.node;
|
|
627
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === transform_1.schema.nodes.table) {
|
|
628
|
+
return (_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element)(selection)) === null || _a === void 0 ? void 0 : _a.node;
|
|
650
629
|
}
|
|
651
630
|
return node;
|
|
652
631
|
};
|
|
653
|
-
const isAllowedType = (type) => type ===
|
|
654
|
-
type ===
|
|
655
|
-
type ===
|
|
656
|
-
type ===
|
|
657
|
-
type ===
|
|
658
|
-
type ===
|
|
659
|
-
type ===
|
|
632
|
+
const isAllowedType = (type) => type === transform_1.schema.nodes.section ||
|
|
633
|
+
type === transform_1.schema.nodes.footnotes_section ||
|
|
634
|
+
type === transform_1.schema.nodes.bibliography_section ||
|
|
635
|
+
type === transform_1.schema.nodes.keyword_group ||
|
|
636
|
+
type === transform_1.schema.nodes.paragraph ||
|
|
637
|
+
type === transform_1.schema.nodes.figure_element ||
|
|
638
|
+
type === transform_1.schema.nodes.table_element;
|
|
660
639
|
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;
|
|
640
|
+
if (node.type === transform_1.schema.nodes.keywords) {
|
|
641
|
+
const keywordGroups = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.keyword_group, true);
|
|
642
|
+
return keywordGroups.length ? keywordGroups[0].node : node;
|
|
670
643
|
}
|
|
671
644
|
return node;
|
|
672
645
|
};
|
|
@@ -685,7 +658,7 @@ const addBlockComment = (node, state, dispatch) => {
|
|
|
685
658
|
const addHighlightComment = (node, state, dispatch) => {
|
|
686
659
|
const { attrs: { id }, type, } = node;
|
|
687
660
|
const comment = (0, transform_1.buildComment)(id);
|
|
688
|
-
if (type ===
|
|
661
|
+
if (type === transform_1.schema.nodes.paragraph) {
|
|
689
662
|
const { $anchor, $head } = state.selection;
|
|
690
663
|
const isAllTextSelected = ($anchor.textOffset === 0 && $head.textOffset === 0) ||
|
|
691
664
|
$anchor.textOffset === $head.textOffset;
|
|
@@ -39,9 +39,9 @@ const excludedTypes = [
|
|
|
39
39
|
transform_1.schema.nodes.figure,
|
|
40
40
|
transform_1.schema.nodes.footnotes_element,
|
|
41
41
|
transform_1.schema.nodes.bibliography_element,
|
|
42
|
-
transform_1.schema.nodes.
|
|
43
|
-
transform_1.schema.nodes.
|
|
44
|
-
transform_1.schema.nodes.
|
|
42
|
+
transform_1.schema.nodes.keywords,
|
|
43
|
+
transform_1.schema.nodes.affiliations,
|
|
44
|
+
transform_1.schema.nodes.contributors,
|
|
45
45
|
transform_1.schema.nodes.title,
|
|
46
46
|
];
|
|
47
47
|
const childrenExcludedTypes = [
|
|
@@ -61,7 +61,7 @@ const buildTree = ({ node, pos, index, selected, parent, }) => {
|
|
|
61
61
|
const isSelected = selected ? node.attrs.id === selected.node.attrs.id : false;
|
|
62
62
|
if (!isChildrenExcluded(node.type)) {
|
|
63
63
|
node.forEach((childNode, offset, childIndex) => {
|
|
64
|
-
if ((!childNode.isAtom || (0, transform_1.isElementNodeType)(childNode.type)) &&
|
|
64
|
+
if ((!childNode.isAtom || (0, transform_1.isElementNodeType)(childNode.type) || (0, section_title_1.isSpecialSection)(childNode)) &&
|
|
65
65
|
childNode.attrs.id &&
|
|
66
66
|
!isExcluded(childNode.type)) {
|
|
67
67
|
items.push((0, exports.buildTree)({
|
|
@@ -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,11 +19,10 @@ 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"));
|
|
28
27
|
const equation_editable_1 = __importDefault(require("../views/equation_editable"));
|
|
29
28
|
const equation_element_editable_1 = __importDefault(require("../views/equation_element_editable"));
|
|
@@ -38,7 +37,6 @@ const keywords_element_1 = __importDefault(require("../views/keywords_element"))
|
|
|
38
37
|
const link_editable_1 = __importDefault(require("../views/link_editable"));
|
|
39
38
|
const listing_editable_1 = __importDefault(require("../views/listing_editable"));
|
|
40
39
|
const listing_element_editable_1 = __importDefault(require("../views/listing_element_editable"));
|
|
41
|
-
const meta_section_1 = __importDefault(require("../views/meta_section"));
|
|
42
40
|
const ordered_list_editable_1 = __importDefault(require("../views/ordered_list_editable"));
|
|
43
41
|
const paragraph_editable_1 = __importDefault(require("../views/paragraph_editable"));
|
|
44
42
|
const placeholder_1 = __importDefault(require("../views/placeholder"));
|
|
@@ -49,16 +47,16 @@ const section_title_editable_1 = __importDefault(require("../views/section_title
|
|
|
49
47
|
const table_element_editable_1 = __importDefault(require("../views/table_element_editable"));
|
|
50
48
|
const title_editable_1 = __importDefault(require("../views/title_editable"));
|
|
51
49
|
const toc_element_editable_1 = __importDefault(require("../views/toc_element_editable"));
|
|
50
|
+
const empty_1 = __importDefault(require("../views/empty"));
|
|
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
|
};
|
package/dist/cjs/keys/title.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const transform_1 = require("@manuscripts/transform");
|
|
18
19
|
const prosemirror_commands_1 = require("prosemirror-commands");
|
|
19
20
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
20
21
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
@@ -80,6 +81,9 @@ const leaveSectionTitle = (state, dispatch, view) => {
|
|
|
80
81
|
if ($cursor.parent.type !== $cursor.parent.type.schema.nodes.section_title) {
|
|
81
82
|
return false;
|
|
82
83
|
}
|
|
84
|
+
if ((0, transform_1.isInGraphicalAbstractSection)($cursor)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
83
87
|
if (!(0, commands_1.isAtEndOfTextBlock)(state, $cursor, view)) {
|
|
84
88
|
return false;
|
|
85
89
|
}
|
|
@@ -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],
|
|
@@ -26,21 +26,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
26
26
|
return t;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.buildCitations = exports.getBibliographyItemModelMap = exports.getBibliographyItem = exports.getCitation = exports.buildDecorations = exports.isBibliographyElement = void 0;
|
|
30
30
|
const json_schema_1 = require("@manuscripts/json-schema");
|
|
31
31
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
32
32
|
const transform_1 = require("@manuscripts/transform");
|
|
33
|
-
const
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
34
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
35
35
|
const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
|
|
36
36
|
exports.isBibliographyElement = isBibliographyElement;
|
|
37
|
-
|
|
37
|
+
let count = 0;
|
|
38
|
+
const buildDecorations = (state, doc) => {
|
|
38
39
|
const decorations = [];
|
|
39
40
|
let hasMissingItems = false;
|
|
40
|
-
for (const [node, pos
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
for (const [node, pos] of state.citationNodes) {
|
|
42
|
+
const rids = node.attrs.rids;
|
|
43
|
+
if (rids.length) {
|
|
44
|
+
for (const rid of rids) {
|
|
45
|
+
if (!state.bibliographyItems.has(rid)) {
|
|
44
46
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
45
47
|
class: 'citation-missing',
|
|
46
48
|
}));
|
|
@@ -72,41 +74,49 @@ const buildDecorations = (doc, citationNodes, popper, referencesModelMap, trigge
|
|
|
72
74
|
}
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
}
|
|
77
|
+
doc.descendants((node, pos) => {
|
|
78
|
+
if ((0, exports.isBibliographyElement)(node)) {
|
|
79
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
80
|
+
refresh: count++,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
84
|
return decorations;
|
|
85
85
|
};
|
|
86
86
|
exports.buildDecorations = buildDecorations;
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}))) || [],
|
|
103
|
-
objectType: json_schema_1.ObjectTypes.Citation,
|
|
104
|
-
};
|
|
87
|
+
const getCitation = (node) => {
|
|
88
|
+
const attrs = getEffectiveAttrs(node);
|
|
89
|
+
if (!attrs) {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
const rids = attrs.rids;
|
|
93
|
+
const items = rids.map((i) => ({
|
|
94
|
+
_id: '_',
|
|
95
|
+
objectType: json_schema_1.ObjectTypes.CitationItem,
|
|
96
|
+
bibliographyItem: i,
|
|
97
|
+
}));
|
|
98
|
+
return {
|
|
99
|
+
_id: attrs.id,
|
|
100
|
+
objectType: json_schema_1.ObjectTypes.Citation,
|
|
101
|
+
embeddedCitationItems: items,
|
|
105
102
|
};
|
|
103
|
+
};
|
|
104
|
+
exports.getCitation = getCitation;
|
|
105
|
+
const getBibliographyItem = (node) => {
|
|
106
|
+
const attrs = getEffectiveAttrs(node);
|
|
107
|
+
if (!attrs) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const { id, containerTitle, doi } = attrs, rest = __rest(attrs, ["id", "containerTitle", "doi"]);
|
|
111
|
+
const item = Object.assign({ _id: id, objectType: json_schema_1.ObjectTypes.BibliographyItem, 'container-title': containerTitle, DOI: doi }, rest);
|
|
112
|
+
return (0, lodash_1.pickBy)(item, (v) => v !== undefined);
|
|
113
|
+
};
|
|
114
|
+
exports.getBibliographyItem = getBibliographyItem;
|
|
115
|
+
const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
|
|
116
|
+
const getEffectiveAttrs = (node) => {
|
|
106
117
|
const _a = node.attrs, { dataTracked } = _a, attrs = __rest(_a, ["dataTracked"]);
|
|
107
118
|
const nodeChange = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.reduce(getLatest);
|
|
108
119
|
if (nodeChange &&
|
|
109
|
-
excludeDeletedNode &&
|
|
110
120
|
nodeChange.operation === track_changes_plugin_1.CHANGE_OPERATION.delete &&
|
|
111
121
|
nodeChange.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
|
|
112
122
|
return undefined;
|
|
@@ -114,15 +124,13 @@ const getNodeModel = (node, excludeDeletedNode) => {
|
|
|
114
124
|
const isRejected = nodeChange &&
|
|
115
125
|
nodeChange.operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes &&
|
|
116
126
|
nodeChange.status === track_changes_plugin_1.CHANGE_STATUS.rejected;
|
|
117
|
-
return
|
|
127
|
+
return isRejected ? nodeChange === null || nodeChange === void 0 ? void 0 : nodeChange.oldAttrs : attrs;
|
|
118
128
|
};
|
|
119
|
-
|
|
120
|
-
const getReferencesModelMap = (doc, excludeDeletedNode) => {
|
|
129
|
+
const getBibliographyItemModelMap = (doc) => {
|
|
121
130
|
const modelMap = new Map();
|
|
122
131
|
doc.descendants((node) => {
|
|
123
|
-
if (node.type === transform_1.schema.nodes.bibliography_item
|
|
124
|
-
|
|
125
|
-
const model = (0, exports.getNodeModel)(node, excludeDeletedNode);
|
|
132
|
+
if (node.type === transform_1.schema.nodes.bibliography_item) {
|
|
133
|
+
const model = (0, exports.getBibliographyItem)(node);
|
|
126
134
|
if (model) {
|
|
127
135
|
modelMap.set(model._id, model);
|
|
128
136
|
}
|
|
@@ -130,4 +138,14 @@ const getReferencesModelMap = (doc, excludeDeletedNode) => {
|
|
|
130
138
|
});
|
|
131
139
|
return modelMap;
|
|
132
140
|
};
|
|
133
|
-
exports.
|
|
141
|
+
exports.getBibliographyItemModelMap = getBibliographyItemModelMap;
|
|
142
|
+
const buildCitations = (citations) => citations.map((citation) => ({
|
|
143
|
+
citationID: citation[0].attrs.id,
|
|
144
|
+
citationItems: citation[0].attrs.rids.map((rid) => ({
|
|
145
|
+
id: rid,
|
|
146
|
+
})),
|
|
147
|
+
properties: {
|
|
148
|
+
noteIndex: 0,
|
|
149
|
+
},
|
|
150
|
+
}));
|
|
151
|
+
exports.buildCitations = buildCitations;
|