@manuscripts/body-editor 3.6.4 → 3.6.6

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.
@@ -722,16 +722,22 @@ const insertGraphicalAbstract = (category) => (state, dispatch, view) => {
722
722
  };
723
723
  exports.insertGraphicalAbstract = insertGraphicalAbstract;
724
724
  const insertContributors = (state, dispatch, view) => {
725
- if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.contributors, true)) {
725
+ const tr = state.tr;
726
+ let contributors = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.contributors)[0];
727
+ if (contributors?.node.childCount) {
726
728
  return false;
727
729
  }
728
- const pos = (0, utils_1.findInsertionPosition)(transform_1.schema.nodes.contributors, state.doc);
729
- const contributors = state.schema.nodes.contributors.create({
730
- id: '',
731
- });
732
- const tr = state.tr.insert(pos, contributors);
730
+ if (!contributors) {
731
+ const title = (0, utils_1.getLastTitleNode)(state);
732
+ const pos = title.pos + title.node.nodeSize;
733
+ const contributorsNode = state.schema.nodes.contributors.create({
734
+ id: '',
735
+ });
736
+ tr.insert(pos, contributorsNode);
737
+ contributors = { node: contributorsNode, pos };
738
+ }
733
739
  if (dispatch) {
734
- const selection = prosemirror_state_1.NodeSelection.create(tr.doc, pos);
740
+ const selection = prosemirror_state_1.NodeSelection.create(tr.doc, contributors.pos);
735
741
  if (view) {
736
742
  view.focus();
737
743
  }
@@ -741,16 +747,22 @@ const insertContributors = (state, dispatch, view) => {
741
747
  };
742
748
  exports.insertContributors = insertContributors;
743
749
  const insertAffiliation = (state, dispatch, view) => {
744
- if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.affiliations, true)) {
750
+ const tr = state.tr;
751
+ let affiliations = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.affiliations)[0];
752
+ if (affiliations?.node.childCount) {
745
753
  return false;
746
754
  }
747
- const pos = (0, utils_1.findInsertionPosition)(transform_1.schema.nodes.affiliations, state.doc);
748
- const affiliations = state.schema.nodes.affiliations.create({
749
- id: '',
750
- });
751
- const tr = state.tr.insert(pos, affiliations);
755
+ if (!affiliations) {
756
+ const title = (0, utils_1.getLastTitleNode)(state);
757
+ const pos = title.pos + title.node.nodeSize;
758
+ const affiliationsNode = state.schema.nodes.affiliations.create({
759
+ id: '',
760
+ });
761
+ tr.insert(pos, affiliationsNode);
762
+ affiliations = { node: affiliationsNode, pos };
763
+ }
752
764
  if (dispatch) {
753
- const selection = prosemirror_state_1.NodeSelection.create(tr.doc, pos);
765
+ const selection = prosemirror_state_1.NodeSelection.create(tr.doc, affiliations.pos);
754
766
  if (view) {
755
767
  view.focus();
756
768
  }
@@ -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 = '3.6.4';
4
+ exports.VERSION = '3.6.6';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -137,7 +137,11 @@ class AffiliationsView extends block_view_1.default {
137
137
  return contextMenu ? [contextMenu] : [];
138
138
  };
139
139
  this.selectNode = () => {
140
+ const selectedMarker = document.querySelector('.comment-marker.selected-comment');
140
141
  this.dom.classList.add('ProseMirror-selectednode');
142
+ if (!(0, track_changes_utils_1.isDeleted)(this.node) && !selectedMarker) {
143
+ this.handleEdit('', true);
144
+ }
141
145
  };
142
146
  this.handleUpdateAuthors = (authors) => {
143
147
  authors.forEach((author) => {
@@ -28,7 +28,7 @@ import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, }
28
28
  import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
29
29
  import { templateAllows } from './lib/template';
30
30
  import { isDeleted } from './lib/track-changes-utils';
31
- import { findInsertionPosition, findParentNodeWithId, getChildOfType, getInsertPos, isBodyLocked, } from './lib/utils';
31
+ import { findInsertionPosition, findParentNodeWithId, getChildOfType, getInsertPos, getLastTitleNode, isBodyLocked, } from './lib/utils';
32
32
  import { expandAccessibilitySection } from './plugins/accessibility_element';
33
33
  import { setCommentSelection } from './plugins/comments';
34
34
  import { getEditorProps } from './plugins/editor-props';
@@ -687,16 +687,22 @@ export const insertGraphicalAbstract = (category) => (state, dispatch, view) =>
687
687
  return true;
688
688
  };
689
689
  export const insertContributors = (state, dispatch, view) => {
690
- if (getChildOfType(state.doc, schema.nodes.contributors, true)) {
690
+ const tr = state.tr;
691
+ let contributors = findChildrenByType(state.doc, schema.nodes.contributors)[0];
692
+ if (contributors?.node.childCount) {
691
693
  return false;
692
694
  }
693
- const pos = findInsertionPosition(schema.nodes.contributors, state.doc);
694
- const contributors = state.schema.nodes.contributors.create({
695
- id: '',
696
- });
697
- const tr = state.tr.insert(pos, contributors);
695
+ if (!contributors) {
696
+ const title = getLastTitleNode(state);
697
+ const pos = title.pos + title.node.nodeSize;
698
+ const contributorsNode = state.schema.nodes.contributors.create({
699
+ id: '',
700
+ });
701
+ tr.insert(pos, contributorsNode);
702
+ contributors = { node: contributorsNode, pos };
703
+ }
698
704
  if (dispatch) {
699
- const selection = NodeSelection.create(tr.doc, pos);
705
+ const selection = NodeSelection.create(tr.doc, contributors.pos);
700
706
  if (view) {
701
707
  view.focus();
702
708
  }
@@ -705,16 +711,22 @@ export const insertContributors = (state, dispatch, view) => {
705
711
  return true;
706
712
  };
707
713
  export const insertAffiliation = (state, dispatch, view) => {
708
- if (getChildOfType(state.doc, schema.nodes.affiliations, true)) {
714
+ const tr = state.tr;
715
+ let affiliations = findChildrenByType(state.doc, schema.nodes.affiliations)[0];
716
+ if (affiliations?.node.childCount) {
709
717
  return false;
710
718
  }
711
- const pos = findInsertionPosition(schema.nodes.affiliations, state.doc);
712
- const affiliations = state.schema.nodes.affiliations.create({
713
- id: '',
714
- });
715
- const tr = state.tr.insert(pos, affiliations);
719
+ if (!affiliations) {
720
+ const title = getLastTitleNode(state);
721
+ const pos = title.pos + title.node.nodeSize;
722
+ const affiliationsNode = state.schema.nodes.affiliations.create({
723
+ id: '',
724
+ });
725
+ tr.insert(pos, affiliationsNode);
726
+ affiliations = { node: affiliationsNode, pos };
727
+ }
716
728
  if (dispatch) {
717
- const selection = NodeSelection.create(tr.doc, pos);
729
+ const selection = NodeSelection.create(tr.doc, affiliations.pos);
718
730
  if (view) {
719
731
  view.focus();
720
732
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.6.4';
1
+ export const VERSION = '3.6.6';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -131,7 +131,11 @@ export class AffiliationsView extends BlockView {
131
131
  return contextMenu ? [contextMenu] : [];
132
132
  };
133
133
  this.selectNode = () => {
134
+ const selectedMarker = document.querySelector('.comment-marker.selected-comment');
134
135
  this.dom.classList.add('ProseMirror-selectednode');
136
+ if (!isDeleted(this.node) && !selectedMarker) {
137
+ this.handleEdit('', true);
138
+ }
135
139
  };
136
140
  this.handleUpdateAuthors = (authors) => {
137
141
  authors.forEach((author) => {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.6.4";
1
+ export declare const VERSION = "3.6.6";
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": "3.6.4",
4
+ "version": "3.6.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -41,7 +41,7 @@
41
41
  "@manuscripts/json-schema": "2.2.12",
42
42
  "@manuscripts/style-guide": "3.3.2",
43
43
  "@manuscripts/track-changes-plugin": "2.1.0",
44
- "@manuscripts/transform": "4.3.4",
44
+ "@manuscripts/transform": "4.3.5",
45
45
  "@popperjs/core": "2.11.8",
46
46
  "citeproc": "2.4.63",
47
47
  "codemirror": "5.65.19",
@@ -407,6 +407,9 @@ ProseMirror .block-embed .position-menu {
407
407
  .ProseMirror .block-contributors {
408
408
  grid-template-columns: 52px auto 65px;
409
409
  }
410
+ .ProseMirror .block-contributors.empty-node, .ProseMirror .block-affiliations.empty-node {
411
+ display: none !important;
412
+ }
410
413
  .ProseMirror .block-affiliations {
411
414
  grid-template-columns: 52px auto 100px;
412
415
  }