@manuscripts/body-editor 2.2.11-LEAN-3966.0 → 2.2.12

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.
@@ -86,11 +86,14 @@ const blockActive = (type) => (state) => {
86
86
  };
87
87
  exports.blockActive = blockActive;
88
88
  const canInsert = (type) => (state) => {
89
+ var _a;
89
90
  const { $from, $to } = state.selection;
90
91
  if ($from.node().type === transform_1.schema.nodes.title && $from.pos === $to.pos) {
91
92
  return false;
92
93
  }
93
- for (let d = $from.depth; d >= 0; d--) {
94
+ const initDepth = ((_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) ||
95
+ 0;
96
+ for (let d = $from.depth; d >= initDepth; d--) {
94
97
  const index = $from.index(d);
95
98
  if ($from.node(d).canReplaceWith(index, index, type)) {
96
99
  return true;
@@ -504,7 +507,8 @@ const insertGraphicalAbstract = (state, dispatch, view) => {
504
507
  exports.insertGraphicalAbstract = insertGraphicalAbstract;
505
508
  const insertSection = (subsection = false) => (state, dispatch, view) => {
506
509
  const selection = state.selection;
507
- if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.bibliography_section)(selection)) {
510
+ if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.bibliography_section)(selection) ||
511
+ (!subsection && (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection))) {
508
512
  return false;
509
513
  }
510
514
  let pos;
@@ -533,6 +537,7 @@ const insertSection = (subsection = false) => (state, dispatch, view) => {
533
537
  };
534
538
  exports.insertSection = insertSection;
535
539
  const insertBackMatterSection = (category) => (state, dispatch, view) => {
540
+ var _a;
536
541
  const backmatter = (0, doc_1.findBackmatter)(state.doc);
537
542
  const sections = (0, prosemirror_utils_1.findChildrenByType)(backmatter.node, transform_1.schema.nodes.section);
538
543
  if (sections.some((s) => s.node.attrs.category === category)) {
@@ -549,7 +554,7 @@ const insertBackMatterSection = (category) => (state, dispatch, view) => {
549
554
  const node = transform_1.schema.nodes.section.createAndFill({
550
555
  category,
551
556
  }, [
552
- transform_1.schema.nodes.section_title.create({}, transform_1.schema.text(section_titles_1.sectionTitles.get(category) || '')),
557
+ transform_1.schema.nodes.section_title.create({}, transform_1.schema.text(((_a = section_titles_1.sectionTitles.get(category)) === null || _a === void 0 ? void 0 : _a.split('|')[0]) || '')),
553
558
  ]);
554
559
  const tr = state.tr.insert(pos, node);
555
560
  if (dispatch) {
@@ -924,6 +929,7 @@ const isCommentingAllowed = (type) => type === transform_1.schema.nodes.title ||
924
929
  type === transform_1.schema.nodes.bibliography_item ||
925
930
  type === transform_1.schema.nodes.footnotes_section ||
926
931
  type === transform_1.schema.nodes.bibliography_section ||
932
+ type === transform_1.schema.nodes.box_element ||
927
933
  type === transform_1.schema.nodes.graphical_abstract_section ||
928
934
  type === transform_1.schema.nodes.keyword_group ||
929
935
  type === transform_1.schema.nodes.paragraph ||
@@ -22,6 +22,7 @@ exports.LevelSelector = void 0;
22
22
  const transform_1 = require("@manuscripts/transform");
23
23
  const prosemirror_model_1 = require("prosemirror-model");
24
24
  const prosemirror_state_1 = require("prosemirror-state");
25
+ const prosemirror_utils_1 = require("prosemirror-utils");
25
26
  const react_1 = __importDefault(require("react"));
26
27
  const react_select_1 = __importDefault(require("react-select"));
27
28
  const styled_components_1 = __importDefault(require("styled-components"));
@@ -40,6 +41,7 @@ const optionName = (nodeType, depth, listType) => {
40
41
  const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
41
42
  const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: (0, node_type_icons_1.nodeTypeIcon)(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth, props.listType)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
42
43
  const buildOptions = (state, dispatch, view) => {
44
+ var _a;
43
45
  const { doc, selection: { $from, $to }, schema, tr, } = state;
44
46
  const { nodes } = schema;
45
47
  if (!$from.sameParent($to)) {
@@ -49,6 +51,7 @@ const buildOptions = (state, dispatch, view) => {
49
51
  if (!parentElement) {
50
52
  return [];
51
53
  }
54
+ const depth = ((_a = (0, prosemirror_utils_1.findParentNodeOfType)(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) || 1;
52
55
  const moveParagraphToNewSubsection = () => {
53
56
  const paragraph = $from.node($from.depth);
54
57
  const beforeParagraph = $from.before($from.depth);
@@ -131,7 +134,7 @@ const buildOptions = (state, dispatch, view) => {
131
134
  const $beforeParagraph = doc.resolve(beforeParagraph);
132
135
  const beforeParagraphOffset = $beforeParagraph.parentOffset;
133
136
  const afterParagraphOffset = beforeParagraphOffset + paragraph.nodeSize;
134
- const sectionDepth = $from.depth - 1;
137
+ const sectionDepth = $from.depth - depth;
135
138
  const parentSection = $from.node(sectionDepth);
136
139
  const startIndex = $from.index(sectionDepth);
137
140
  const endIndex = $from.indexAfter(sectionDepth);
@@ -167,7 +170,7 @@ const buildOptions = (state, dispatch, view) => {
167
170
  const afterSectionTitle = $from.after($from.depth);
168
171
  const $afterSectionTitle = doc.resolve(afterSectionTitle);
169
172
  const afterSectionTitleOffset = $afterSectionTitle.parentOffset;
170
- const sectionDepth = $from.depth - 1;
173
+ const sectionDepth = $from.depth - depth;
171
174
  const section = $from.node(sectionDepth);
172
175
  const beforeSection = $from.before(sectionDepth);
173
176
  const afterSection = $from.after(sectionDepth);
@@ -213,7 +216,7 @@ const buildOptions = (state, dispatch, view) => {
213
216
  const parentElementType = parentElement.node.type;
214
217
  switch (parentElementType) {
215
218
  case parentElementType.schema.nodes.section: {
216
- const sectionDepth = Math.max(1, $from.depth - 1);
219
+ const sectionDepth = Math.max(1, $from.depth - depth);
217
220
  const parentSectionDepth = sectionDepth - 1;
218
221
  const minimumDepth = Math.max(1, parentSectionDepth);
219
222
  const beforeSection = $from.before(sectionDepth);
@@ -284,7 +287,7 @@ const buildOptions = (state, dispatch, view) => {
284
287
  return [{ options: typeOptions }, { options: sectionOptions }];
285
288
  }
286
289
  case parentElementType.schema.nodes.paragraph: {
287
- const sectionDepth = $from.depth - 1;
290
+ const sectionDepth = $from.depth - depth;
288
291
  const minimumDepth = Math.max(1, sectionDepth);
289
292
  let parentSectionDepth = 0;
290
293
  const typeOptions = [
@@ -22,6 +22,7 @@ const affiliations_1 = __importDefault(require("../views/affiliations"));
22
22
  const author_notes_1 = __importDefault(require("../views/author_notes"));
23
23
  const bibliography_element_1 = __importDefault(require("../views/bibliography_element"));
24
24
  const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
25
+ const box_element_1 = __importDefault(require("../views/box_element"));
25
26
  const citation_editable_1 = __importDefault(require("../views/citation_editable"));
26
27
  const contributors_1 = __importDefault(require("../views/contributors"));
27
28
  const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
@@ -56,6 +57,7 @@ exports.default = (props, dispatch) => {
56
57
  title: (0, title_editable_1.default)(props, dispatch),
57
58
  bibliography_element: (0, bibliography_element_1.default)(props, dispatch),
58
59
  blockquote_element: (0, blockquote_element_editable_1.default)(props),
60
+ box_element: (0, box_element_1.default)(props),
59
61
  citation: (0, citation_editable_1.default)(props, dispatch),
60
62
  cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
61
63
  contributors: (0, contributors_1.default)(props, dispatch),
@@ -30,6 +30,8 @@ const track_changes_utils_1 = require("./track-changes-utils");
30
30
  const utils_1 = require("./utils");
31
31
  const popper = new popper_1.PopperManager();
32
32
  const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
33
+ const isBoxElementSectionTitle = ($pos, node) => (0, transform_1.isSectionTitleNode)(node) &&
34
+ $pos.node($pos.depth - 1).type === transform_1.schema.nodes.box_element;
33
35
  const sectionLevel = (depth) => {
34
36
  switch (depth) {
35
37
  case 1:
@@ -150,7 +152,8 @@ class ContextMenu {
150
152
  const menu = document.createElement('div');
151
153
  menu.className = 'menu';
152
154
  const $pos = this.resolvePos();
153
- const type = this.node.type;
155
+ const isBox = isBoxElementSectionTitle($pos, this.node);
156
+ const type = isBox ? transform_1.schema.nodes.box_element : this.node.type;
154
157
  if (type === transform_1.schema.nodes.list) {
155
158
  menu.appendChild(this.createMenuSection((section) => {
156
159
  const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
@@ -338,14 +341,12 @@ class ContextMenu {
338
341
  switch (nodeType.name) {
339
342
  case 'section_title': {
340
343
  const $pos = this.resolvePos();
341
- this.view.dispatch(this.view.state.tr
342
- .setMeta('fromContextMenu', true)
343
- .delete($pos.before(), $pos.after()));
344
+ this.view.dispatch(this.view.state.tr.delete($pos.before(), $pos.after()));
344
345
  break;
345
346
  }
346
- case 'bibliography_element': {
347
+ case 'box_element': {
347
348
  const $pos = this.resolvePos();
348
- this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth), $pos.after($pos.depth)));
349
+ this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth - 1), $pos.after($pos.depth - 1)));
349
350
  break;
350
351
  }
351
352
  default: {
@@ -26,7 +26,10 @@ exports.sectionTitles = new Map([
26
26
  ['MPSectionCategory:conclusions', 'Conclusions'],
27
27
  ['MPSectionCategory:acknowledgement', 'Acknowledgments'],
28
28
  ['MPSectionCategory:availability', 'Availability'],
29
- ['MPSectionCategory:competing-interests', 'COI Statement'],
29
+ [
30
+ 'MPSectionCategory:competing-interests',
31
+ 'COI Statement|Competing Interests',
32
+ ],
30
33
  ['MPSectionCategory:con', 'Contributed-by information'],
31
34
  ['MPSectionCategory:ethics-statement', 'Ethics Statement'],
32
35
  ['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
@@ -87,6 +87,9 @@ function buildPluginState(state, props) {
87
87
  decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => createButton(view, props, node, pos, attrs.category, can === null || can === void 0 ? void 0 : can.editArticle)));
88
88
  }
89
89
  }
90
+ if (node.type === transform_1.schema.nodes.box_element) {
91
+ return false;
92
+ }
90
93
  });
91
94
  return { decorations: prosemirror_view_1.DecorationSet.create(state.doc, decorations) };
92
95
  }
@@ -11,11 +11,13 @@ function cursorAtTheEndOfText(state, nodeSize, nodePos) {
11
11
  }
12
12
  const isUpperCase = (test) => test === test.toUpperCase() && test.length > 1;
13
13
  function hasAutoCompletionSlack(parentSection, titleSection) {
14
+ var _a;
14
15
  const category = (0, track_changes_utils_1.getActualAttrs)(parentSection).category;
15
- const title = section_titles_1.sectionTitles.get(category);
16
- if (category && title && titleSection.textContent) {
16
+ const titles = (_a = section_titles_1.sectionTitles.get(category)) === null || _a === void 0 ? void 0 : _a.split('|');
17
+ if (category && (titles === null || titles === void 0 ? void 0 : titles.length) && titleSection.textContent) {
17
18
  const actualTextContent = (0, track_changes_utils_1.getActualTextContent)(titleSection.content);
18
- if (title.toLowerCase().startsWith(actualTextContent.toLowerCase())) {
19
+ const title = titles.find((t) => t.toLowerCase().startsWith(actualTextContent.toLowerCase()));
20
+ if (title) {
19
21
  const suggestionPart = title.slice(actualTextContent.length);
20
22
  const suggestion = isUpperCase(actualTextContent)
21
23
  ? suggestionPart.toUpperCase()
@@ -10,7 +10,8 @@ const autocompletion_1 = require("./autocompletion");
10
10
  exports.sectionTitleKey = new prosemirror_state_1.PluginKey('sectionNumbering');
11
11
  const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
12
12
  node.forEach((childNode, offset) => {
13
- if (childNode.type === transform_1.schema.nodes.section &&
13
+ if ((childNode.type === transform_1.schema.nodes.section ||
14
+ childNode.type === transform_1.schema.nodes.box_element) &&
14
15
  !(0, track_changes_utils_1.isRejectedInsert)(childNode)) {
15
16
  numbering[numbering.length - 1] += 1;
16
17
  const sectionNumber = numbering.join('.');
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '2.2.11-LEAN-3966.0';
4
+ exports.VERSION = '2.2.12';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -0,0 +1,37 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.BoxElementView = void 0;
22
+ const block_view_1 = __importDefault(require("./block_view"));
23
+ const creators_1 = require("./creators");
24
+ class BoxElementView extends block_view_1.default {
25
+ constructor() {
26
+ super(...arguments);
27
+ this.elementType = 'div';
28
+ this.createElement = () => {
29
+ this.contentDOM = document.createElement(this.elementType);
30
+ this.contentDOM.className = 'block box-element';
31
+ this.contentDOM.setAttribute('id', this.node.attrs.id);
32
+ this.dom.appendChild(this.contentDOM);
33
+ };
34
+ }
35
+ }
36
+ exports.BoxElementView = BoxElementView;
37
+ exports.default = (0, creators_1.createNodeView)(BoxElementView);
@@ -34,7 +34,10 @@ class SectionTitleView extends block_view_1.default {
34
34
  const sectionTitleState = section_title_1.sectionTitleKey.getState(this.view.state);
35
35
  const parentSection = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, transform_1.schema.nodes.section);
36
36
  const sectionNumber = sectionTitleState === null || sectionTitleState === void 0 ? void 0 : sectionTitleState.get(parentSection === null || parentSection === void 0 ? void 0 : parentSection.node.attrs.id);
37
- const level = $pos.depth > 1 ? $pos.depth - 1 : $pos.depth;
37
+ let level = $pos.depth > 1 ? $pos.depth - 1 : $pos.depth;
38
+ if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, transform_1.schema.nodes.box_element)) {
39
+ level = level - 2;
40
+ }
38
41
  if (this.node.childCount) {
39
42
  this.contentDOM.classList.remove('empty-node');
40
43
  }
@@ -42,7 +45,7 @@ class SectionTitleView extends block_view_1.default {
42
45
  this.contentDOM.classList.add('empty-node');
43
46
  this.contentDOM.setAttribute('data-placeholder', `${(0, context_menu_1.sectionLevel)(level)} heading`);
44
47
  }
45
- if (sectionTitleState) {
48
+ if (sectionTitleState && sectionNumber) {
46
49
  this.contentDOM.dataset.sectionNumber = sectionNumber;
47
50
  this.contentDOM.dataset.titleLevel = level.toString();
48
51
  }
@@ -79,11 +79,14 @@ export const blockActive = (type) => (state) => {
79
79
  return false;
80
80
  };
81
81
  export const canInsert = (type) => (state) => {
82
+ var _a;
82
83
  const { $from, $to } = state.selection;
83
84
  if ($from.node().type === schema.nodes.title && $from.pos === $to.pos) {
84
85
  return false;
85
86
  }
86
- for (let d = $from.depth; d >= 0; d--) {
87
+ const initDepth = ((_a = findParentNodeOfType(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) ||
88
+ 0;
89
+ for (let d = $from.depth; d >= initDepth; d--) {
87
90
  const index = $from.index(d);
88
91
  if ($from.node(d).canReplaceWith(index, index, type)) {
89
92
  return true;
@@ -476,7 +479,8 @@ export const insertGraphicalAbstract = (state, dispatch, view) => {
476
479
  };
477
480
  export const insertSection = (subsection = false) => (state, dispatch, view) => {
478
481
  const selection = state.selection;
479
- if (hasParentNodeOfType(schema.nodes.bibliography_section)(selection)) {
482
+ if (hasParentNodeOfType(schema.nodes.bibliography_section)(selection) ||
483
+ (!subsection && hasParentNodeOfType(schema.nodes.box_element)(selection))) {
480
484
  return false;
481
485
  }
482
486
  let pos;
@@ -504,6 +508,7 @@ export const insertSection = (subsection = false) => (state, dispatch, view) =>
504
508
  return true;
505
509
  };
506
510
  export const insertBackMatterSection = (category) => (state, dispatch, view) => {
511
+ var _a;
507
512
  const backmatter = findBackmatter(state.doc);
508
513
  const sections = findChildrenByType(backmatter.node, schema.nodes.section);
509
514
  if (sections.some((s) => s.node.attrs.category === category)) {
@@ -520,7 +525,7 @@ export const insertBackMatterSection = (category) => (state, dispatch, view) =>
520
525
  const node = schema.nodes.section.createAndFill({
521
526
  category,
522
527
  }, [
523
- schema.nodes.section_title.create({}, schema.text(sectionTitles.get(category) || '')),
528
+ schema.nodes.section_title.create({}, schema.text(((_a = sectionTitles.get(category)) === null || _a === void 0 ? void 0 : _a.split('|')[0]) || '')),
524
529
  ]);
525
530
  const tr = state.tr.insert(pos, node);
526
531
  if (dispatch) {
@@ -880,6 +885,7 @@ const isCommentingAllowed = (type) => type === schema.nodes.title ||
880
885
  type === schema.nodes.bibliography_item ||
881
886
  type === schema.nodes.footnotes_section ||
882
887
  type === schema.nodes.bibliography_section ||
888
+ type === schema.nodes.box_element ||
883
889
  type === schema.nodes.graphical_abstract_section ||
884
890
  type === schema.nodes.keyword_group ||
885
891
  type === schema.nodes.paragraph ||
@@ -16,6 +16,7 @@
16
16
  import { generateNodeID, getListType, isSectionNodeType, nodeNames, } from '@manuscripts/transform';
17
17
  import { Fragment } from 'prosemirror-model';
18
18
  import { TextSelection } from 'prosemirror-state';
19
+ import { findParentNodeOfType } from 'prosemirror-utils';
19
20
  import React from 'react';
20
21
  import Select from 'react-select';
21
22
  import styled from 'styled-components';
@@ -34,6 +35,7 @@ const optionName = (nodeType, depth, listType) => {
34
35
  const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
35
36
  const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: nodeTypeIcon(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth, props.listType)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
36
37
  const buildOptions = (state, dispatch, view) => {
38
+ var _a;
37
39
  const { doc, selection: { $from, $to }, schema, tr, } = state;
38
40
  const { nodes } = schema;
39
41
  if (!$from.sameParent($to)) {
@@ -43,6 +45,7 @@ const buildOptions = (state, dispatch, view) => {
43
45
  if (!parentElement) {
44
46
  return [];
45
47
  }
48
+ const depth = ((_a = findParentNodeOfType(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) || 1;
46
49
  const moveParagraphToNewSubsection = () => {
47
50
  const paragraph = $from.node($from.depth);
48
51
  const beforeParagraph = $from.before($from.depth);
@@ -125,7 +128,7 @@ const buildOptions = (state, dispatch, view) => {
125
128
  const $beforeParagraph = doc.resolve(beforeParagraph);
126
129
  const beforeParagraphOffset = $beforeParagraph.parentOffset;
127
130
  const afterParagraphOffset = beforeParagraphOffset + paragraph.nodeSize;
128
- const sectionDepth = $from.depth - 1;
131
+ const sectionDepth = $from.depth - depth;
129
132
  const parentSection = $from.node(sectionDepth);
130
133
  const startIndex = $from.index(sectionDepth);
131
134
  const endIndex = $from.indexAfter(sectionDepth);
@@ -161,7 +164,7 @@ const buildOptions = (state, dispatch, view) => {
161
164
  const afterSectionTitle = $from.after($from.depth);
162
165
  const $afterSectionTitle = doc.resolve(afterSectionTitle);
163
166
  const afterSectionTitleOffset = $afterSectionTitle.parentOffset;
164
- const sectionDepth = $from.depth - 1;
167
+ const sectionDepth = $from.depth - depth;
165
168
  const section = $from.node(sectionDepth);
166
169
  const beforeSection = $from.before(sectionDepth);
167
170
  const afterSection = $from.after(sectionDepth);
@@ -207,7 +210,7 @@ const buildOptions = (state, dispatch, view) => {
207
210
  const parentElementType = parentElement.node.type;
208
211
  switch (parentElementType) {
209
212
  case parentElementType.schema.nodes.section: {
210
- const sectionDepth = Math.max(1, $from.depth - 1);
213
+ const sectionDepth = Math.max(1, $from.depth - depth);
211
214
  const parentSectionDepth = sectionDepth - 1;
212
215
  const minimumDepth = Math.max(1, parentSectionDepth);
213
216
  const beforeSection = $from.before(sectionDepth);
@@ -278,7 +281,7 @@ const buildOptions = (state, dispatch, view) => {
278
281
  return [{ options: typeOptions }, { options: sectionOptions }];
279
282
  }
280
283
  case parentElementType.schema.nodes.paragraph: {
281
- const sectionDepth = $from.depth - 1;
284
+ const sectionDepth = $from.depth - depth;
282
285
  const minimumDepth = Math.max(1, sectionDepth);
283
286
  let parentSectionDepth = 0;
284
287
  const typeOptions = [
@@ -17,6 +17,7 @@ import affiliations from '../views/affiliations';
17
17
  import authorNotes from '../views/author_notes';
18
18
  import bibliographyElement from '../views/bibliography_element';
19
19
  import blockquoteElement from '../views/blockquote_element_editable';
20
+ import boxElement from '../views/box_element';
20
21
  import citation from '../views/citation_editable';
21
22
  import contributors from '../views/contributors';
22
23
  import crossReference from '../views/cross_reference_editable';
@@ -51,6 +52,7 @@ export default (props, dispatch) => {
51
52
  title: title(props, dispatch),
52
53
  bibliography_element: bibliographyElement(props, dispatch),
53
54
  blockquote_element: blockquoteElement(props),
55
+ box_element: boxElement(props),
54
56
  citation: citation(props, dispatch),
55
57
  cross_reference: crossReference(props, dispatch),
56
58
  contributors: contributors(props, dispatch),
@@ -18,7 +18,7 @@ import { chainCommands, createParagraphNear, exitCode, joinDown, joinUp, lift, l
18
18
  import { redo, undo } from 'prosemirror-history';
19
19
  import { undoInputRule } from 'prosemirror-inputrules';
20
20
  import { goToNextCell } from 'prosemirror-tables';
21
- import { autoComplete, addToStart, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
21
+ import { addToStart, autoComplete, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
22
22
  const customKeymap = {
23
23
  Backspace: chainCommands(undoInputRule, ignoreAtomBlockNodeBackward, ignoreMetaNodeBackspaceCommand),
24
24
  Delete: ignoreAtomBlockNodeForward,
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { getListType, isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
16
+ import { getListType, isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
17
17
  import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
18
18
  import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralFootnote, insertTableFootnote, } from '../commands';
19
19
  import { FootnotesSelector } from '../components/views/FootnotesSelector';
@@ -24,6 +24,8 @@ import { getActualAttrs, isDeleted, isRejectedInsert, } from './track-changes-ut
24
24
  import { getChildOfType, isChildOfNodeTypes } from './utils';
25
25
  const popper = new PopperManager();
26
26
  const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
27
+ const isBoxElementSectionTitle = ($pos, node) => isSectionTitleNode(node) &&
28
+ $pos.node($pos.depth - 1).type === schema.nodes.box_element;
27
29
  export const sectionLevel = (depth) => {
28
30
  switch (depth) {
29
31
  case 1:
@@ -143,7 +145,8 @@ export class ContextMenu {
143
145
  const menu = document.createElement('div');
144
146
  menu.className = 'menu';
145
147
  const $pos = this.resolvePos();
146
- const type = this.node.type;
148
+ const isBox = isBoxElementSectionTitle($pos, this.node);
149
+ const type = isBox ? schema.nodes.box_element : this.node.type;
147
150
  if (type === schema.nodes.list) {
148
151
  menu.appendChild(this.createMenuSection((section) => {
149
152
  const actualAttrs = getActualAttrs(this.node);
@@ -331,14 +334,12 @@ export class ContextMenu {
331
334
  switch (nodeType.name) {
332
335
  case 'section_title': {
333
336
  const $pos = this.resolvePos();
334
- this.view.dispatch(this.view.state.tr
335
- .setMeta('fromContextMenu', true)
336
- .delete($pos.before(), $pos.after()));
337
+ this.view.dispatch(this.view.state.tr.delete($pos.before(), $pos.after()));
337
338
  break;
338
339
  }
339
- case 'bibliography_element': {
340
+ case 'box_element': {
340
341
  const $pos = this.resolvePos();
341
- this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth), $pos.after($pos.depth)));
342
+ this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth - 1), $pos.after($pos.depth - 1)));
342
343
  break;
343
344
  }
344
345
  default: {
@@ -23,7 +23,10 @@ export const sectionTitles = new Map([
23
23
  ['MPSectionCategory:conclusions', 'Conclusions'],
24
24
  ['MPSectionCategory:acknowledgement', 'Acknowledgments'],
25
25
  ['MPSectionCategory:availability', 'Availability'],
26
- ['MPSectionCategory:competing-interests', 'COI Statement'],
26
+ [
27
+ 'MPSectionCategory:competing-interests',
28
+ 'COI Statement|Competing Interests',
29
+ ],
27
30
  ['MPSectionCategory:con', 'Contributed-by information'],
28
31
  ['MPSectionCategory:ethics-statement', 'Ethics Statement'],
29
32
  ['MPSectionCategory:financial-disclosure', 'Financial Disclosure'],
@@ -84,6 +84,9 @@ export function buildPluginState(state, props) {
84
84
  decorations.push(Decoration.widget(pos + 1, (view) => createButton(view, props, node, pos, attrs.category, can === null || can === void 0 ? void 0 : can.editArticle)));
85
85
  }
86
86
  }
87
+ if (node.type === schema.nodes.box_element) {
88
+ return false;
89
+ }
87
90
  });
88
91
  return { decorations: DecorationSet.create(state.doc, decorations) };
89
92
  }
@@ -8,11 +8,13 @@ function cursorAtTheEndOfText(state, nodeSize, nodePos) {
8
8
  }
9
9
  const isUpperCase = (test) => test === test.toUpperCase() && test.length > 1;
10
10
  export function hasAutoCompletionSlack(parentSection, titleSection) {
11
+ var _a;
11
12
  const category = getActualAttrs(parentSection).category;
12
- const title = sectionTitles.get(category);
13
- if (category && title && titleSection.textContent) {
13
+ const titles = (_a = sectionTitles.get(category)) === null || _a === void 0 ? void 0 : _a.split('|');
14
+ if (category && (titles === null || titles === void 0 ? void 0 : titles.length) && titleSection.textContent) {
14
15
  const actualTextContent = getActualTextContent(titleSection.content);
15
- if (title.toLowerCase().startsWith(actualTextContent.toLowerCase())) {
16
+ const title = titles.find((t) => t.toLowerCase().startsWith(actualTextContent.toLowerCase()));
17
+ if (title) {
16
18
  const suggestionPart = title.slice(actualTextContent.length);
17
19
  const suggestion = isUpperCase(actualTextContent)
18
20
  ? suggestionPart.toUpperCase()
@@ -7,7 +7,8 @@ import { checkForCompletion } from './autocompletion';
7
7
  export const sectionTitleKey = new PluginKey('sectionNumbering');
8
8
  const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
9
9
  node.forEach((childNode, offset) => {
10
- if (childNode.type === schema.nodes.section &&
10
+ if ((childNode.type === schema.nodes.section ||
11
+ childNode.type === schema.nodes.box_element) &&
11
12
  !isRejectedInsert(childNode)) {
12
13
  numbering[numbering.length - 1] += 1;
13
14
  const sectionNumber = numbering.join('.');
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.2.11-LEAN-3966.0';
1
+ export const VERSION = '2.2.12';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import BlockView from './block_view';
17
+ import { createNodeView } from './creators';
18
+ export class BoxElementView extends BlockView {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.elementType = 'div';
22
+ this.createElement = () => {
23
+ this.contentDOM = document.createElement(this.elementType);
24
+ this.contentDOM.className = 'block box-element';
25
+ this.contentDOM.setAttribute('id', this.node.attrs.id);
26
+ this.dom.appendChild(this.contentDOM);
27
+ };
28
+ }
29
+ }
30
+ export default createNodeView(BoxElementView);
@@ -28,7 +28,10 @@ export class SectionTitleView extends BlockView {
28
28
  const sectionTitleState = sectionTitleKey.getState(this.view.state);
29
29
  const parentSection = findParentNodeOfTypeClosestToPos($pos, schema.nodes.section);
30
30
  const sectionNumber = sectionTitleState === null || sectionTitleState === void 0 ? void 0 : sectionTitleState.get(parentSection === null || parentSection === void 0 ? void 0 : parentSection.node.attrs.id);
31
- const level = $pos.depth > 1 ? $pos.depth - 1 : $pos.depth;
31
+ let level = $pos.depth > 1 ? $pos.depth - 1 : $pos.depth;
32
+ if (findParentNodeOfTypeClosestToPos($pos, schema.nodes.box_element)) {
33
+ level = level - 2;
34
+ }
32
35
  if (this.node.childCount) {
33
36
  this.contentDOM.classList.remove('empty-node');
34
37
  }
@@ -36,7 +39,7 @@ export class SectionTitleView extends BlockView {
36
39
  this.contentDOM.classList.add('empty-node');
37
40
  this.contentDOM.setAttribute('data-placeholder', `${sectionLevel(level)} heading`);
38
41
  }
39
- if (sectionTitleState) {
42
+ if (sectionTitleState && sectionNumber) {
40
43
  this.contentDOM.dataset.sectionNumber = sectionNumber;
41
44
  this.contentDOM.dataset.titleLevel = level.toString();
42
45
  }
@@ -53,6 +53,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
53
53
  destroy: () => void;
54
54
  handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
55
55
  } & import("../views/blockquote_element").BlockquoteElementView>;
56
+ box_element: import("../types").NodeViewCreator<import("../views/box_element").BoxElementView>;
56
57
  citation: import("../types").NodeViewCreator<import("../views/citation_editable").CitationEditableView>;
57
58
  cross_reference: import("../types").NodeViewCreator<import("../views/cross_reference_editable").CrossReferenceEditableView>;
58
59
  contributors: import("../types").NodeViewCreator<import("../views/contributors").ContributorsView>;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.2.11-LEAN-3966.0";
1
+ export declare const VERSION = "2.2.12";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * © 2019 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { BoxElementNode } from '@manuscripts/transform';
17
+ import BlockView from './block_view';
18
+ export declare class BoxElementView extends BlockView<BoxElementNode> {
19
+ elementType: string;
20
+ createElement: () => void;
21
+ }
22
+ declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<BoxElementView>;
23
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "2.2.11-LEAN-3966.0",
4
+ "version": "2.2.12",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -34,7 +34,7 @@
34
34
  "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.0.21",
36
36
  "@manuscripts/track-changes-plugin": "1.7.23",
37
- "@manuscripts/transform": "3.0.1-LEAN-3966.2",
37
+ "@manuscripts/transform": "3.0.1",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",
@@ -10,14 +10,24 @@
10
10
  content: attr(data-section-number) '. ';
11
11
  }
12
12
 
13
+ .ProseMirror > div.body .block-box_element .box-element section:not(.toc)
14
+ .block-section_title h1.empty-node[data-placeholder]::before {
15
+ content: attr(data-placeholder);
16
+ }
17
+
18
+ .ProseMirror > div.body .block-box_element .box-element section:not(.toc)
19
+ .block-section_title h1::before {
20
+ content: none;
21
+ }
22
+
13
23
  .ProseMirror > div .block-section_title > h1 {
14
24
  font-size: 16pt !important;
15
25
  font-style: normal !important;
16
26
  font-weight: bold !important;
17
27
  color: #000 !important;
18
28
  text-align: left;
19
- margin-top: 8pt !important;
20
- margin-bottom: 5pt !important;
29
+ padding-top: 8pt !important;
30
+ padding-bottom: 5pt !important;
21
31
  line-height: 1.5;
22
32
  text-indent: 0pt;
23
33
  display: inline;
@@ -60,8 +70,8 @@
60
70
  font-weight: normal !important;
61
71
  color: #353535 !important;
62
72
  text-align: left !important;
63
- margin-top: 10pt !important;
64
- margin-bottom: 10pt !important;
73
+ padding-top: 10pt !important;
74
+ padding-bottom: 10pt !important;
65
75
  line-height: 2 !important;
66
76
  text-indent: 0pt !important;
67
77
  }
@@ -131,6 +141,43 @@
131
141
  text-align: center !important;
132
142
  }
133
143
 
144
+ .ProseMirror .block-container.block-box_element {
145
+ grid-template-columns: auto;
146
+ }
147
+
148
+ .ProseMirror .block-container.block-box_element > .block.box-element {
149
+ position: relative;
150
+ display: grid;
151
+ grid-template-columns: auto;
152
+ }
153
+
154
+ .ProseMirror .box-element .block-container .block {
155
+ background: var(--box-element-bg-color);
156
+ padding-left: 12px;
157
+ border-left: 2px solid #E2E2E2;
158
+ border-right: 2px solid #E2E2E2;
159
+ }
160
+
161
+ .ProseMirror .box-element::after, .box-element > .block-section::before {
162
+ content: ' ';
163
+ margin-left: 52px;
164
+ margin-right: 52px;
165
+ border-top: 2px solid #E2E2E2;
166
+ height: 0;
167
+ }
168
+
169
+ .box-element > figcaption {
170
+ margin-left: 54px;
171
+ margin-right: 54px;
172
+ padding-bottom: 6px;
173
+ text-align: left;
174
+ }
175
+
176
+ .box-element section figcaption {
177
+ background: var(--box-element-bg-color);
178
+ }
179
+
180
+
134
181
  .unsupported-format-label {
135
182
  font-size: 140%;
136
183
  line-height: 1.3;
@@ -286,7 +333,6 @@ span.comment-marker {
286
333
  font-style: italic !important;
287
334
  font-weight: 400 !important;
288
335
  line-height: 16px !important;
289
- margin-top: 4px !important;
290
336
  }
291
337
 
292
338
  .ProseMirror .author-notes-container h1 {
@@ -398,9 +444,14 @@ span.comment-marker {
398
444
  .keywords > .block-section_title > .block-gutter {
399
445
  display: flex;
400
446
  justify-content: flex-end;
447
+ align-items: center;
401
448
  margin-top: 0;
402
449
  }
403
450
 
451
+ .block-box_element > .block-gutter {
452
+ margin-top: 14px;
453
+ }
454
+
404
455
  .author-notes > .block-section_title > .block,
405
456
  .keywords > .block-section_title > .block {
406
457
  align-items: center;
@@ -462,6 +513,7 @@ span.comment-marker {
462
513
  --common-color: #353535;
463
514
  --selected-pending-background-color: #ddf3fa;
464
515
  --selected-accepted-background-color: #f2f2f2;
516
+ --box-element-bg-color: #fafafa;
465
517
  }
466
518
  .ProseMirror ins,
467
519
  .ProseMirror del {
package/styles/Editor.css CHANGED
@@ -300,6 +300,10 @@
300
300
  text-align: left;
301
301
  }
302
302
 
303
+ .ProseMirror .block-table_element .block-gutter {
304
+ padding-top: 1em;
305
+ }
306
+
303
307
  .ProseMirror .caption-title:not(.empty-node) {
304
308
  font-weight: bold;
305
309
  }
@@ -666,7 +670,12 @@
666
670
  margin-top: 16px;
667
671
  }
668
672
 
669
- .ProseMirror .block-container:not(.block-section):hover .block-gutter {
673
+ .ProseMirror .block-container:not(.block-section, .block-box_element):hover .block-gutter {
674
+ opacity: 1;
675
+ z-index: 2;
676
+ }
677
+
678
+ .ProseMirror .block-box_element:hover > .block-gutter {
670
679
  opacity: 1;
671
680
  z-index: 2;
672
681
  }
@@ -1055,4 +1064,4 @@
1055
1064
  }
1056
1065
  .highlight {
1057
1066
  background-color: #ffeebf !important;
1058
- }
1067
+ }