@manuscripts/body-editor 2.6.14 → 2.6.16

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.
@@ -516,32 +516,36 @@ const insertGraphicalAbstract = (state, dispatch, view) => {
516
516
  };
517
517
  exports.insertGraphicalAbstract = insertGraphicalAbstract;
518
518
  const insertSection = (subsection = false) => (state, dispatch, view) => {
519
- const selection = state.selection;
520
- if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.bibliography_section)(selection) ||
521
- (!subsection && (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection))) {
519
+ const nodes = transform_1.schema.nodes;
520
+ const $pos = state.selection.$from;
521
+ let pos;
522
+ if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.bibliography_section)) {
522
523
  return false;
523
524
  }
524
- let pos;
525
- if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(selection) || subsection) {
526
- pos = subsection
527
- ? (0, exports.findPosBeforeFirstSubsection)(state.selection.$from) ||
528
- findPosAfterParentSection(state.selection.$from)
529
- : findPosAfterParentSection(state.selection.$from);
525
+ else if (subsection) {
526
+ pos =
527
+ (0, exports.findPosBeforeFirstSubsection)($pos) || findPosAfterParentSection($pos);
528
+ if (!pos) {
529
+ return false;
530
+ }
531
+ pos -= 1;
530
532
  }
531
- else {
532
- const body = (0, doc_1.findBody)(state.doc);
533
- pos = body.pos + body.node.content.size + 1;
533
+ else if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.box_element)) {
534
+ return false;
535
+ }
536
+ else if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.body)) {
537
+ pos = findPosAfterParentSection($pos);
534
538
  }
535
539
  if (!pos) {
536
- return false;
540
+ const body = (0, doc_1.findBody)(state.doc);
541
+ pos = body.pos + body.node.content.size + 1;
537
542
  }
538
- const section = transform_1.schema.nodes.section.createAndFill({
543
+ const section = nodes.section.createAndFill({
539
544
  category: subsection ? 'MPSectionCategory:subsection' : '',
540
545
  });
541
- const diff = subsection ? -1 : 0;
542
- const tr = state.tr.insert(pos + diff, section);
546
+ const tr = state.tr.insert(pos, section);
543
547
  if (dispatch) {
544
- const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + diff + 2);
548
+ const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 2);
545
549
  view === null || view === void 0 ? void 0 : view.focus();
546
550
  dispatch(tr.setSelection(selection).scrollIntoView());
547
551
  }
@@ -26,7 +26,7 @@ exports.default = () => {
26
26
  const decorations = [];
27
27
  state.doc.descendants((node, pos, parent) => {
28
28
  if (parent &&
29
- (0, transform_1.isSectionNodeType)(parent.type) &&
29
+ ((0, transform_1.isSectionNodeType)(parent.type) || parent.type === transform_1.schema.nodes.body) &&
30
30
  node.type !== section) {
31
31
  decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
32
32
  element: true,
@@ -34,6 +34,9 @@ const getParagraphPlaceholderText = (parent) => {
34
34
  if (!parent || parent.textContent.length) {
35
35
  return;
36
36
  }
37
+ if (parent.type === transform_1.schema.nodes.body) {
38
+ return 'Paragraph';
39
+ }
37
40
  if ((0, transform_1.isFootnoteNode)(parent) || (0, transform_1.isGeneralTableFootnoteNode)(parent)) {
38
41
  return 'Type new footnote here';
39
42
  }
@@ -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.6.14';
4
+ exports.VERSION = '2.6.16';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -59,7 +59,7 @@ class BlockView extends base_node_view_1.BaseNodeView {
59
59
  }
60
60
  else {
61
61
  this.dom.removeAttribute('data-track-status');
62
- this.dom.removeAttribute('data-track-type');
62
+ this.dom.removeAttribute('data-track-op');
63
63
  }
64
64
  for (const [key, target] of Object.entries(this.viewAttributes)) {
65
65
  if (key in this.node.attrs) {
@@ -34,7 +34,7 @@ class EquationElementView extends block_view_1.default {
34
34
  }
35
35
  else {
36
36
  this.dom.removeAttribute('data-track-status');
37
- this.dom.removeAttribute('data-track-type');
37
+ this.dom.removeAttribute('data-track-op');
38
38
  }
39
39
  };
40
40
  }
@@ -40,7 +40,7 @@ class ListView extends block_view_1.default {
40
40
  }
41
41
  else {
42
42
  this.dom.removeAttribute('data-track-status');
43
- this.dom.removeAttribute('data-track-type');
43
+ this.dom.removeAttribute('data-track-op');
44
44
  }
45
45
  };
46
46
  }
@@ -487,32 +487,36 @@ export const insertGraphicalAbstract = (state, dispatch, view) => {
487
487
  return true;
488
488
  };
489
489
  export const insertSection = (subsection = false) => (state, dispatch, view) => {
490
- const selection = state.selection;
491
- if (hasParentNodeOfType(schema.nodes.bibliography_section)(selection) ||
492
- (!subsection && hasParentNodeOfType(schema.nodes.box_element)(selection))) {
490
+ const nodes = schema.nodes;
491
+ const $pos = state.selection.$from;
492
+ let pos;
493
+ if (findParentNodeOfTypeClosestToPos($pos, nodes.bibliography_section)) {
493
494
  return false;
494
495
  }
495
- let pos;
496
- if (hasParentNodeOfType(schema.nodes.body)(selection) || subsection) {
497
- pos = subsection
498
- ? findPosBeforeFirstSubsection(state.selection.$from) ||
499
- findPosAfterParentSection(state.selection.$from)
500
- : findPosAfterParentSection(state.selection.$from);
496
+ else if (subsection) {
497
+ pos =
498
+ findPosBeforeFirstSubsection($pos) || findPosAfterParentSection($pos);
499
+ if (!pos) {
500
+ return false;
501
+ }
502
+ pos -= 1;
501
503
  }
502
- else {
503
- const body = findBody(state.doc);
504
- pos = body.pos + body.node.content.size + 1;
504
+ else if (findParentNodeOfTypeClosestToPos($pos, nodes.box_element)) {
505
+ return false;
506
+ }
507
+ else if (findParentNodeOfTypeClosestToPos($pos, nodes.body)) {
508
+ pos = findPosAfterParentSection($pos);
505
509
  }
506
510
  if (!pos) {
507
- return false;
511
+ const body = findBody(state.doc);
512
+ pos = body.pos + body.node.content.size + 1;
508
513
  }
509
- const section = schema.nodes.section.createAndFill({
514
+ const section = nodes.section.createAndFill({
510
515
  category: subsection ? 'MPSectionCategory:subsection' : '',
511
516
  });
512
- const diff = subsection ? -1 : 0;
513
- const tr = state.tr.insert(pos + diff, section);
517
+ const tr = state.tr.insert(pos, section);
514
518
  if (dispatch) {
515
- const selection = TextSelection.create(tr.doc, pos + diff + 2);
519
+ const selection = TextSelection.create(tr.doc, pos + 2);
516
520
  view === null || view === void 0 ? void 0 : view.focus();
517
521
  dispatch(tr.setSelection(selection).scrollIntoView());
518
522
  }
@@ -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 { isSectionNodeType } from '@manuscripts/transform';
16
+ import { isSectionNodeType, schema } from '@manuscripts/transform';
17
17
  import { Plugin } from 'prosemirror-state';
18
18
  import { Decoration, DecorationSet } from 'prosemirror-view';
19
19
  export default () => {
@@ -24,7 +24,7 @@ export default () => {
24
24
  const decorations = [];
25
25
  state.doc.descendants((node, pos, parent) => {
26
26
  if (parent &&
27
- isSectionNodeType(parent.type) &&
27
+ (isSectionNodeType(parent.type) || parent.type === schema.nodes.body) &&
28
28
  node.type !== section) {
29
29
  decorations.push(Decoration.node(pos, pos + node.nodeSize, {}, {
30
30
  element: true,
@@ -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 { isFootnoteNode, isGeneralTableFootnoteNode, } from '@manuscripts/transform';
16
+ import { isFootnoteNode, isGeneralTableFootnoteNode, schema, } from '@manuscripts/transform';
17
17
  import { Plugin, TextSelection } from 'prosemirror-state';
18
18
  import { Decoration, DecorationSet } from 'prosemirror-view';
19
19
  const placeholderWidget = (placeholder) => (view, getPos) => {
@@ -32,6 +32,9 @@ const getParagraphPlaceholderText = (parent) => {
32
32
  if (!parent || parent.textContent.length) {
33
33
  return;
34
34
  }
35
+ if (parent.type === schema.nodes.body) {
36
+ return 'Paragraph';
37
+ }
35
38
  if (isFootnoteNode(parent) || isGeneralTableFootnoteNode(parent)) {
36
39
  return 'Type new footnote here';
37
40
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.6.14';
1
+ export const VERSION = '2.6.16';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -57,7 +57,7 @@ export default class BlockView extends BaseNodeView {
57
57
  }
58
58
  else {
59
59
  this.dom.removeAttribute('data-track-status');
60
- this.dom.removeAttribute('data-track-type');
60
+ this.dom.removeAttribute('data-track-op');
61
61
  }
62
62
  for (const [key, target] of Object.entries(this.viewAttributes)) {
63
63
  if (key in this.node.attrs) {
@@ -28,7 +28,7 @@ export class EquationElementView extends BlockView {
28
28
  }
29
29
  else {
30
30
  this.dom.removeAttribute('data-track-status');
31
- this.dom.removeAttribute('data-track-type');
31
+ this.dom.removeAttribute('data-track-op');
32
32
  }
33
33
  };
34
34
  }
@@ -34,7 +34,7 @@ export class ListView extends BlockView {
34
34
  }
35
35
  else {
36
36
  this.dom.removeAttribute('data-track-status');
37
- this.dom.removeAttribute('data-track-type');
37
+ this.dom.removeAttribute('data-track-op');
38
38
  }
39
39
  };
40
40
  }
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.6.14";
1
+ export declare const VERSION = "2.6.16";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
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.6.14",
4
+ "version": "2.6.16",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -33,8 +33,8 @@
33
33
  "@manuscripts/json-schema": "2.2.11",
34
34
  "@manuscripts/library": "1.3.11",
35
35
  "@manuscripts/style-guide": "2.0.23",
36
- "@manuscripts/track-changes-plugin": "1.8.1",
37
- "@manuscripts/transform": "3.0.18",
36
+ "@manuscripts/track-changes-plugin": "1.8.3",
37
+ "@manuscripts/transform": "3.0.19",
38
38
  "@popperjs/core": "^2.11.8",
39
39
  "astrocite-eutils": "^0.16.4",
40
40
  "codemirror": "^5.58.1",