@manuscripts/body-editor 1.6.20 → 1.7.0-LEAN-3181-3

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.
Files changed (58) hide show
  1. package/dist/cjs/commands.js +1 -1
  2. package/dist/cjs/components/views/FigureDropdown.js +4 -4
  3. package/dist/cjs/configs/editor-plugins.js +3 -1
  4. package/dist/cjs/configs/editor-views.js +5 -0
  5. package/dist/cjs/index.js +1 -0
  6. package/dist/cjs/lib/build-file-models.js +33 -0
  7. package/dist/cjs/lib/track-changes-utils.js +11 -1
  8. package/dist/cjs/plugins/affiliations.js +118 -0
  9. package/dist/cjs/plugins/bibliography/bibliography-utils.js +7 -6
  10. package/dist/cjs/plugins/bibliography/index.js +4 -4
  11. package/dist/cjs/plugins/toc.js +6 -40
  12. package/dist/cjs/testing/default-editor-data.js +0 -5
  13. package/dist/cjs/views/affiliation.js +75 -0
  14. package/dist/cjs/views/affiliations.js +24 -0
  15. package/dist/cjs/views/contributors.js +150 -11
  16. package/dist/cjs/views/figure_editable.js +4 -6
  17. package/dist/cjs/views/figure_element.js +16 -5
  18. package/dist/cjs/views/keyword.js +2 -1
  19. package/dist/es/commands.js +1 -1
  20. package/dist/es/components/views/FigureDropdown.js +4 -4
  21. package/dist/es/configs/editor-plugins.js +3 -1
  22. package/dist/es/configs/editor-views.js +5 -0
  23. package/dist/es/index.js +1 -0
  24. package/dist/es/lib/build-file-models.js +29 -0
  25. package/dist/es/lib/track-changes-utils.js +9 -0
  26. package/dist/es/plugins/affiliations.js +114 -0
  27. package/dist/es/plugins/bibliography/bibliography-utils.js +4 -4
  28. package/dist/es/plugins/bibliography/index.js +4 -4
  29. package/dist/es/plugins/toc.js +9 -43
  30. package/dist/es/testing/default-editor-data.js +0 -5
  31. package/dist/es/views/affiliation.js +71 -0
  32. package/dist/es/views/affiliations.js +17 -0
  33. package/dist/es/views/contributors.js +150 -11
  34. package/dist/es/views/figure_editable.js +4 -6
  35. package/dist/es/views/figure_element.js +16 -5
  36. package/dist/es/views/keyword.js +2 -1
  37. package/dist/types/components/views/FigureDropdown.d.ts +1 -1
  38. package/dist/types/configs/ManuscriptsEditor.d.ts +3 -3
  39. package/dist/types/configs/editor-plugins.d.ts +1 -3
  40. package/dist/types/configs/editor-views.d.ts +5 -0
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/lib/build-file-models.d.ts +2 -0
  43. package/dist/types/lib/track-changes-utils.d.ts +2 -0
  44. package/dist/types/plugins/{styles.d.ts → affiliations.d.ts} +9 -7
  45. package/dist/types/plugins/bibliography/bibliography-utils.d.ts +2 -0
  46. package/dist/types/plugins/toc.d.ts +1 -5
  47. package/dist/types/types.d.ts +4 -0
  48. package/dist/types/views/affiliation.d.ts +31 -0
  49. package/dist/types/views/affiliations.d.ts +9 -0
  50. package/dist/types/views/base_node_view.d.ts +0 -2
  51. package/dist/types/views/contributors.d.ts +24 -8
  52. package/dist/types/views/figure_editable.d.ts +0 -2
  53. package/dist/types/views/figure_element.d.ts +1 -3
  54. package/package.json +3 -3
  55. package/styles/AdvancedEditor.css +143 -47
  56. package/styles/Editor.css +1 -2
  57. package/dist/cjs/plugins/styles.js +0 -120
  58. package/dist/es/plugins/styles.js +0 -118
@@ -351,7 +351,7 @@ const findSelectedList = (0, prosemirror_utils_1.findParentNodeOfType)([
351
351
  transform_1.schema.nodes.bullet_list,
352
352
  ]);
353
353
  const findRootList = ($pos) => {
354
- for (let i = 0; i <= $pos.depth; i++) {
354
+ for (let i = 0; i < $pos.depth; i++) {
355
355
  const node = $pos.node(i);
356
356
  if ((0, transform_1.isListNode)(node)) {
357
357
  const pos = $pos.start(i);
@@ -10,9 +10,9 @@ const TriangleCollapsed_1 = __importDefault(require("@manuscripts/assets/react/T
10
10
  const style_guide_1 = require("@manuscripts/style-guide");
11
11
  const react_1 = __importDefault(require("react"));
12
12
  const styled_components_1 = __importDefault(require("styled-components"));
13
- const FigureElementOptions = ({ can, files, modelMap, handleAdd, handleUpload, }) => {
13
+ const FigureElementOptions = ({ can, files, getFilesMap, handleAdd, handleUpload, }) => {
14
14
  const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
15
- let { supplements, otherFiles } = (0, style_guide_1.useFiles)(modelMap, files);
15
+ let { supplements, otherFiles } = (0, style_guide_1.useFiles)(getFilesMap(), files);
16
16
  supplements = supplements.filter(style_guide_1.isImageFile);
17
17
  otherFiles = otherFiles.filter(style_guide_1.isImageFile);
18
18
  return (react_1.default.createElement(FilesDropdownWrapper, { onClick: toggleOpen, ref: wrapperRef },
@@ -30,9 +30,9 @@ const FigureElementOptions = ({ can, files, modelMap, handleAdd, handleUpload, }
30
30
  " New file...")))));
31
31
  };
32
32
  exports.FigureElementOptions = FigureElementOptions;
33
- const FigureOptions = ({ can, files, modelMap, handleDownload, handleUpload, handleDetach, handleReplace, }) => {
33
+ const FigureOptions = ({ can, files, getFilesMap, handleDownload, handleUpload, handleDetach, handleReplace, }) => {
34
34
  const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
35
- const otherFiles = (0, style_guide_1.useFiles)(modelMap, files).otherFiles.filter(style_guide_1.isImageFile);
35
+ const otherFiles = (0, style_guide_1.useFiles)(getFilesMap(), files).otherFiles.filter(style_guide_1.isImageFile);
36
36
  const showDownload = handleDownload && can.downloadFiles;
37
37
  const showUpload = handleUpload && can.uploadFile;
38
38
  const showDetach = handleDetach && can.editArticle;
@@ -25,6 +25,7 @@ const prosemirror_dropcursor_1 = require("prosemirror-dropcursor");
25
25
  const prosemirror_history_1 = require("prosemirror-history");
26
26
  const prosemirror_tables_1 = require("prosemirror-tables");
27
27
  const keys_1 = __importDefault(require("../keys"));
28
+ const affiliations_1 = __importDefault(require("../plugins/affiliations"));
28
29
  const bibliography_1 = __importDefault(require("../plugins/bibliography"));
29
30
  const comment_annotation_1 = __importDefault(require("../plugins/comment_annotation"));
30
31
  const elements_1 = __importDefault(require("../plugins/elements"));
@@ -52,9 +53,10 @@ exports.default = (props) => {
52
53
  (0, elements_1.default)(),
53
54
  (0, persist_1.default)(),
54
55
  (0, sections_1.default)(),
55
- (0, toc_1.default)(props),
56
+ (0, toc_1.default)(),
56
57
  (0, bibliography_1.default)(props),
57
58
  (0, objects_1.default)(props),
59
+ (0, affiliations_1.default)(),
58
60
  (0, comment_annotation_1.default)(props),
59
61
  (0, paragraphs_1.default)(),
60
62
  (0, placeholder_1.default)(),
@@ -18,6 +18,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ const affiliation_1 = __importDefault(require("../views/affiliation"));
22
+ const affiliations_1 = __importDefault(require("../views/affiliations"));
21
23
  const bibliography_element_editable_1 = __importDefault(require("../views/bibliography_element_editable"));
22
24
  const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
23
25
  const bullet_list_editable_1 = __importDefault(require("../views/bullet_list_editable"));
@@ -58,6 +60,8 @@ exports.default = (props, dispatch) => {
58
60
  citation: (0, citation_editable_1.default)(props, dispatch),
59
61
  cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
60
62
  contributors: (0, contributors_1.default)(props, dispatch),
63
+ affiliations: (0, affiliations_1.default)(props, dispatch),
64
+ affiliation: (0, affiliation_1.default)(props, dispatch),
61
65
  equation: (0, equation_editable_1.default)(props),
62
66
  equation_element: (0, equation_element_editable_1.default)(props),
63
67
  figure: (0, figure_editable_1.default)(props, dispatch),
@@ -82,5 +86,6 @@ exports.default = (props, dispatch) => {
82
86
  table_element_footer: (0, table_element_footer_editable_1.default)(props),
83
87
  toc_element: (0, toc_element_editable_1.default)(props),
84
88
  comments: (0, empty_1.default)('comments'),
89
+ supplements: (0, empty_1.default)('supplements'),
85
90
  };
86
91
  };
package/dist/cjs/index.js CHANGED
@@ -52,4 +52,5 @@ Object.defineProperty(exports, "commentScroll", { enumerable: true, get: functio
52
52
  Object.defineProperty(exports, "isThereSelector", { enumerable: true, get: function () { return comment_annotation_1.isThereSelector; } });
53
53
  Object.defineProperty(exports, "isHighlightComment", { enumerable: true, get: function () { return comment_annotation_1.isHighlightComment; } });
54
54
  __exportStar(require("./lib/utils"), exports);
55
+ __exportStar(require("./lib/track-changes-utils"), exports);
55
56
  __exportStar(require("./useEditor"), exports);
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildFileMap = void 0;
4
+ const json_schema_1 = require("@manuscripts/json-schema");
5
+ const transform_1 = require("@manuscripts/transform");
6
+ const bibliography_utils_1 = require("../plugins/bibliography/bibliography-utils");
7
+ const buildFileMap = (doc) => {
8
+ const figures = [];
9
+ const supplements = [];
10
+ const sections = [];
11
+ const buildNode = (node, group) => {
12
+ const attrs = (0, bibliography_utils_1.getEffectiveAttrs)(node, true);
13
+ if (attrs) {
14
+ group.push(node.type.create(Object.assign({}, attrs), node.content));
15
+ }
16
+ return false;
17
+ };
18
+ doc.descendants((node) => {
19
+ if (node.type === transform_1.schema.nodes.section &&
20
+ node.attrs.category === 'MPSectionCategory:abstract-graphical') {
21
+ return buildNode(node, sections);
22
+ }
23
+ if (node.type === transform_1.schema.nodes.figure_element) {
24
+ return buildNode(node, figures);
25
+ }
26
+ if (node.type === transform_1.schema.nodes.supplement) {
27
+ buildNode(node, supplements);
28
+ }
29
+ });
30
+ sections.push(transform_1.schema.nodes.section.create({ id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Section) }, figures), transform_1.schema.nodes.supplements.create({ id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Supplement) }, supplements));
31
+ return (0, transform_1.encode)(transform_1.schema.nodes.manuscript.create({}, sections));
32
+ };
33
+ exports.buildFileMap = buildFileMap;
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
18
+ exports.getActualAttrs = exports.isTracked = exports.getChangeClasses = exports.isPendingSetAttrs = exports.isPending = exports.isPendingInsert = exports.isDeleted = exports.isRejectedInsert = void 0;
19
19
  function isRejectedInsert(node) {
20
20
  if (node.attrs.dataTracked) {
21
21
  const changes = node.attrs.dataTracked;
@@ -80,3 +80,13 @@ function isTracked(node) {
80
80
  return false;
81
81
  }
82
82
  exports.isTracked = isTracked;
83
+ function getActualAttrs(node) {
84
+ const attrs = node.attrs;
85
+ if (attrs.dataTracked &&
86
+ attrs.dataTracked[0].status === 'rejected' &&
87
+ attrs.dataTracked[0].operation === 'set_attrs') {
88
+ return attrs.dataTracked[0].oldAttrs;
89
+ }
90
+ return attrs;
91
+ }
92
+ exports.getActualAttrs = getActualAttrs;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.buildPluginState = exports.affiliationsKey = void 0;
19
+ const transform_1 = require("@manuscripts/transform");
20
+ const prosemirror_state_1 = require("prosemirror-state");
21
+ const prosemirror_view_1 = require("prosemirror-view");
22
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
23
+ exports.affiliationsKey = new prosemirror_state_1.PluginKey('affiliations');
24
+ const buildPluginState = (doc) => {
25
+ const contributors = [];
26
+ const affiliations = [];
27
+ doc.descendants((node, pos) => {
28
+ if ((0, track_changes_utils_1.isDeleted)(node)) {
29
+ return;
30
+ }
31
+ if ((0, transform_1.isAffiliationNode)(node)) {
32
+ affiliations.push([node, pos]);
33
+ }
34
+ if ((0, transform_1.isContributorNode)(node)) {
35
+ contributors.push([node, pos]);
36
+ }
37
+ });
38
+ const iAffiliations = new Set();
39
+ contributors
40
+ .sort(([a], [b]) => {
41
+ return (Number((0, track_changes_utils_1.getActualAttrs)(a).priority) - Number((0, track_changes_utils_1.getActualAttrs)(b).priority));
42
+ })
43
+ .forEach(([author]) => {
44
+ (0, track_changes_utils_1.getActualAttrs)(author).affiliations.forEach((aff) => {
45
+ iAffiliations.add(aff);
46
+ });
47
+ });
48
+ const indexedAffiliationIds = new Map([...iAffiliations].map((id, i) => [id, i + 1]));
49
+ return {
50
+ indexedAffiliationIds,
51
+ contributors,
52
+ affiliations,
53
+ };
54
+ };
55
+ exports.buildPluginState = buildPluginState;
56
+ let count = 0;
57
+ exports.default = () => {
58
+ return new prosemirror_state_1.Plugin({
59
+ key: exports.affiliationsKey,
60
+ state: {
61
+ init(config, instance) {
62
+ return (0, exports.buildPluginState)(instance.doc);
63
+ },
64
+ apply(tr, value, oldState, newState) {
65
+ const prevPluginState = exports.affiliationsKey.getState(oldState);
66
+ if (!tr.docChanged && prevPluginState) {
67
+ return prevPluginState;
68
+ }
69
+ else {
70
+ return (0, exports.buildPluginState)(newState.doc);
71
+ }
72
+ },
73
+ },
74
+ appendTransaction(transactions, oldState, newState) {
75
+ const { indexedAffiliationIds } = exports.affiliationsKey.getState(newState);
76
+ const oldPluginState = exports.affiliationsKey.getState(oldState);
77
+ const { tr } = newState;
78
+ const affiliations = [];
79
+ newState.doc.descendants((node, pos) => {
80
+ if ((0, track_changes_utils_1.isDeleted)(node)) {
81
+ return;
82
+ }
83
+ if ((0, transform_1.isAffiliationNode)(node)) {
84
+ affiliations.push([node, pos]);
85
+ }
86
+ });
87
+ for (const [id] of oldPluginState.indexedAffiliationIds.entries()) {
88
+ if (!indexedAffiliationIds.has(id)) {
89
+ const affiliation = affiliations.find(([node]) => node.attrs.id === id);
90
+ if (affiliation && !(0, track_changes_utils_1.isPendingInsert)(affiliation[0])) {
91
+ tr.delete(affiliation[1], affiliation[1] + affiliation[0].nodeSize);
92
+ }
93
+ }
94
+ }
95
+ tr.setMeta('origin', 'affiliations');
96
+ return tr;
97
+ },
98
+ props: {
99
+ decorations: (state) => {
100
+ const decorations = [];
101
+ const allNodes = [];
102
+ state.doc.descendants((node, pos) => {
103
+ if ((0, transform_1.isAffiliationNode)(node) || (0, transform_1.isContributorNode)(node)) {
104
+ allNodes.push([node, pos]);
105
+ }
106
+ });
107
+ if (allNodes.length) {
108
+ allNodes.forEach(([node, pos]) => {
109
+ decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
110
+ refresh: count++,
111
+ }));
112
+ });
113
+ }
114
+ return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
115
+ },
116
+ },
117
+ });
118
+ };
@@ -26,7 +26,7 @@ var __rest = (this && this.__rest) || function (s, e) {
26
26
  return t;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.buildCitations = exports.getBibliographyItemModelMap = exports.getBibliographyItem = exports.getCitation = exports.buildDecorations = exports.isBibliographyElement = void 0;
29
+ exports.buildCitations = exports.getBibliographyItemModelMap = exports.getEffectiveAttrs = 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");
@@ -85,7 +85,7 @@ const buildDecorations = (state, doc) => {
85
85
  };
86
86
  exports.buildDecorations = buildDecorations;
87
87
  const getCitation = (node) => {
88
- const attrs = getEffectiveAttrs(node);
88
+ const attrs = (0, exports.getEffectiveAttrs)(node);
89
89
  if (!attrs) {
90
90
  return undefined;
91
91
  }
@@ -103,7 +103,7 @@ const getCitation = (node) => {
103
103
  };
104
104
  exports.getCitation = getCitation;
105
105
  const getBibliographyItem = (node) => {
106
- const attrs = getEffectiveAttrs(node, true);
106
+ const attrs = (0, exports.getEffectiveAttrs)(node, true);
107
107
  if (!attrs) {
108
108
  return undefined;
109
109
  }
@@ -127,17 +127,18 @@ const getEffectiveAttrs = (node, excludeDeletedNode) => {
127
127
  nodeChange.status === track_changes_plugin_1.CHANGE_STATUS.rejected;
128
128
  return isRejected ? nodeChange === null || nodeChange === void 0 ? void 0 : nodeChange.oldAttrs : attrs;
129
129
  };
130
+ exports.getEffectiveAttrs = getEffectiveAttrs;
130
131
  const getBibliographyItemModelMap = (doc) => {
131
- const modelMap = new Map();
132
+ const bibliographyItemMap = new Map();
132
133
  doc.descendants((node) => {
133
134
  if (node.type === transform_1.schema.nodes.bibliography_item) {
134
135
  const model = (0, exports.getBibliographyItem)(node);
135
136
  if (model) {
136
- modelMap.set(model._id, model);
137
+ bibliographyItemMap.set(model._id, model);
137
138
  }
138
139
  }
139
140
  });
140
- return modelMap;
141
+ return bibliographyItemMap;
141
142
  };
142
143
  exports.getBibliographyItemModelMap = getBibliographyItemModelMap;
143
144
  const buildCitations = (citations) => citations.map((citation) => ({
@@ -53,19 +53,19 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
53
53
  nodes.push([node, pos]);
54
54
  }
55
55
  });
56
- const modelMap = (0, bibliography_utils_1.getBibliographyItemModelMap)(doc);
56
+ const bibliographyItemMap = (0, bibliography_utils_1.getBibliographyItemModelMap)(doc);
57
57
  const citations = (0, bibliography_utils_1.buildCitations)(nodes);
58
58
  const $new = {
59
59
  citationNodes: nodes,
60
60
  citations,
61
- bibliographyItems: modelMap,
61
+ bibliographyItems: bibliographyItemMap,
62
62
  };
63
63
  if (!csl.style) {
64
64
  return $new;
65
65
  }
66
66
  if ($old &&
67
67
  (0, lodash_1.isEqual)(citations, $old.citations) &&
68
- (0, lodash_1.isEqual)(modelMap, $old.bibliographyItems)) {
68
+ (0, lodash_1.isEqual)(bibliographyItemMap, $old.bibliographyItems)) {
69
69
  $new.citationCounts = $old.citationCounts;
70
70
  $new.provider = $old.provider;
71
71
  $new.renderedCitations = $old.renderedCitations;
@@ -78,7 +78,7 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
78
78
  citationCounts.set(rid, count + 1);
79
79
  });
80
80
  const provider = new library_1.CitationProvider({
81
- getLibraryItem: (id) => modelMap.get(id),
81
+ getLibraryItem: (id) => bibliographyItemMap.get(id),
82
82
  citationStyle: csl.style || '',
83
83
  locale: csl.locale,
84
84
  });
@@ -21,27 +21,17 @@ const transform_1 = require("@manuscripts/transform");
21
21
  const prosemirror_state_1 = require("prosemirror-state");
22
22
  const utils_1 = require("../lib/utils");
23
23
  exports.tocKey = new prosemirror_state_1.PluginKey('toc');
24
- const buildTOCList = (headingStyles, list, node, depth = 1, prefix = '') => {
24
+ const buildTOCList = (list, node, depth = 1, prefix = '') => {
25
25
  list.classList.add('manuscript-toc-list');
26
26
  if (depth > 1) {
27
27
  list.classList.add('manuscript-toc-inner-list');
28
28
  }
29
- const paragraphStyle = headingStyles.get(`heading${depth}`);
30
- const sectionNumberingStyle = paragraphStyle
31
- ? paragraphStyle.sectionNumberingStyle
32
- : undefined;
33
- const numberingScheme = sectionNumberingStyle && sectionNumberingStyle.numberingScheme
34
- ? sectionNumberingStyle.numberingScheme
35
- : 'decimal';
36
- const suffix = sectionNumberingStyle && sectionNumberingStyle.suffix !== undefined
37
- ? sectionNumberingStyle.suffix
38
- : '.';
39
- let index = sectionNumberingStyle ? sectionNumberingStyle.startIndex : 1;
29
+ let index = 1;
40
30
  node.forEach((child) => {
41
31
  if (child.type === transform_1.schema.nodes.body) {
42
32
  for (const childNode of (0, utils_1.iterateChildren)(child)) {
43
33
  if ((0, transform_1.isSectionNodeType)(childNode.type) && !(0, transform_1.isTOCSectionNode)(childNode)) {
44
- const numbering = numberingScheme === 'none' ? '' : `${prefix}${index}`;
34
+ const numbering = `${prefix}${index}`;
45
35
  const firstChildNode = childNode.child(0);
46
36
  if (firstChildNode.type ===
47
37
  firstChildNode.type.schema.nodes.section_title) {
@@ -49,39 +39,16 @@ const buildTOCList = (headingStyles, list, node, depth = 1, prefix = '') => {
49
39
  item.classList.add('manuscript-toc-list-item');
50
40
  item.setAttribute('data-referenced-section', childNode.attrs.id);
51
41
  item.setAttribute('data-referenced-section-path-length', String(depth));
52
- item.textContent = `${numbering ? `${numbering}${suffix}` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
42
+ item.textContent = `${numbering ? `${numbering}.` : ''} ${firstChildNode.textContent || 'Untitled Section'}`;
53
43
  list.appendChild(item);
54
44
  }
55
- const childSection = (0, utils_1.getMatchingChild)(childNode, (node) => (0, transform_1.isSectionNodeType)(node.type));
56
- if (childSection) {
57
- const paragraphStyle = headingStyles.get(`heading${depth + 1}`);
58
- if (!paragraphStyle || paragraphStyle.partOfTOC) {
59
- const sublist = document.createElement('ul');
60
- buildTOCList(headingStyles, sublist, childNode, depth + 1, numbering ? `${numbering}.` : '');
61
- const item = document.createElement('li');
62
- item.appendChild(sublist);
63
- list.appendChild(item);
64
- }
65
- }
66
45
  index++;
67
46
  }
68
47
  }
69
48
  }
70
49
  });
71
50
  };
72
- const isParagraphStyle = (0, transform_1.hasObjectType)(json_schema_1.ObjectTypes.ParagraphStyle);
73
- const buildHeadingStyles = (modelMap) => {
74
- const styles = new Map();
75
- for (const model of modelMap.values()) {
76
- if (isParagraphStyle(model)) {
77
- if (model.name && /^heading\d+$/.test(model.name)) {
78
- styles.set(model.name, model);
79
- }
80
- }
81
- }
82
- return styles;
83
- };
84
- exports.default = (props) => {
51
+ exports.default = () => {
85
52
  return new prosemirror_state_1.Plugin({
86
53
  key: exports.tocKey,
87
54
  appendTransaction(transactions, oldState, newState) {
@@ -94,8 +61,7 @@ exports.default = (props) => {
94
61
  if (node.type === node.type.schema.nodes.toc_element) {
95
62
  const list = document.createElement('ul');
96
63
  list.setAttribute('data-paragraph-style', node.attrs.paragraphStyle);
97
- const headingStyles = buildHeadingStyles(props.getModelMap());
98
- buildTOCList(headingStyles, list, newState.doc);
64
+ buildTOCList(list, newState.doc);
99
65
  const contents = list.outerHTML;
100
66
  if (contents !== node.attrs.contents) {
101
67
  nodesToUpdate.push({
@@ -75,7 +75,6 @@ exports.defaultEditorProps = {
75
75
  download: () => { },
76
76
  },
77
77
  getCapabilities: () => (0, style_guide_1.getAllPermitted)(),
78
- getModelMap: () => exports.TEST_DATA.MODEL_MAP,
79
78
  getManuscript: () => exports.TEST_DATA.MANUSCRIPT,
80
79
  cslProps: {
81
80
  style: '',
@@ -83,10 +82,6 @@ exports.defaultEditorProps = {
83
82
  },
84
83
  getCitationProvider: () => undefined,
85
84
  plugins: [],
86
- deleteModel: (id) => {
87
- exports.TEST_DATA.MODEL_MAP.delete(id);
88
- return Promise.resolve(id);
89
- },
90
85
  retrySync: () => Promise.resolve(),
91
86
  setComment: () => undefined,
92
87
  setSelectedComment: () => undefined,
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /*!
3
+ * © 2019 Atypon Systems LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.AffiliationView = void 0;
19
+ const track_changes_utils_1 = require("../lib/track-changes-utils");
20
+ const affiliations_1 = require("../plugins/affiliations");
21
+ const base_node_view_1 = require("./base_node_view");
22
+ const creators_1 = require("./creators");
23
+ class AffiliationView extends base_node_view_1.BaseNodeView {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.initialise = () => {
27
+ this.createDOM();
28
+ };
29
+ this.updateContents = () => {
30
+ var _a;
31
+ const attrs = this.node.attrs;
32
+ const pluginState = affiliations_1.affiliationsKey.getState(this.view.state);
33
+ this.dom.innerHTML = this.formatAddress((0, track_changes_utils_1.getActualAttrs)(this.node));
34
+ if (pluginState === null || pluginState === void 0 ? void 0 : pluginState.indexedAffiliationIds) {
35
+ const order = pluginState.indexedAffiliationIds.get(attrs.id);
36
+ this.dom.innerHTML = order
37
+ ? `<b>${order}</b> ${this.dom.innerHTML}`
38
+ : this.dom.innerHTML;
39
+ this.dom.setAttribute('style', 'order: ' + (order || (pluginState === null || pluginState === void 0 ? void 0 : pluginState.affiliations.length) + 1));
40
+ }
41
+ if ((_a = attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
42
+ this.dom.setAttribute('data-track-status', attrs.dataTracked[0].status);
43
+ this.dom.setAttribute('data-track-op', attrs.dataTracked[0].operation);
44
+ }
45
+ else {
46
+ this.dom.removeAttribute('data-track-status');
47
+ this.dom.removeAttribute('data-track-type');
48
+ }
49
+ };
50
+ this.createDOM = () => {
51
+ this.dom = document.createElement('div');
52
+ this.dom.classList.add('affiliation');
53
+ this.dom.setAttribute('id', this.node.attrs.id);
54
+ this.updateContents();
55
+ };
56
+ this.ignoreMutation = () => true;
57
+ this.stopEvent = () => true;
58
+ this.formatAddress = (affiliation) => {
59
+ const { department, institution, addressLine1, city, county, country, postCode, } = affiliation;
60
+ return [
61
+ department,
62
+ institution,
63
+ addressLine1,
64
+ city,
65
+ county,
66
+ country,
67
+ postCode,
68
+ ]
69
+ .filter(Boolean)
70
+ .join(', ');
71
+ };
72
+ }
73
+ }
74
+ exports.AffiliationView = AffiliationView;
75
+ exports.default = (0, creators_1.createNodeView)(AffiliationView);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AffiliationsView = void 0;
7
+ const block_view_1 = __importDefault(require("./block_view"));
8
+ const creators_1 = require("./creators");
9
+ class AffiliationsView extends block_view_1.default {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.ignoreMutation = () => true;
13
+ this.stopEvent = () => true;
14
+ this.createElement = () => {
15
+ this.contentDOM = document.createElement(this.elementType);
16
+ this.contentDOM.className = 'block';
17
+ this.contentDOM.setAttribute('contenteditable', 'false');
18
+ this.dom.setAttribute('contenteditable', 'false');
19
+ this.dom.appendChild(this.contentDOM);
20
+ };
21
+ }
22
+ }
23
+ exports.AffiliationsView = AffiliationsView;
24
+ exports.default = (0, creators_1.createNodeView)(AffiliationsView);