@manuscripts/body-editor 3.2.13 → 3.2.14

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.
@@ -689,7 +689,7 @@ const insertContributors = (state, dispatch, view) => {
689
689
  if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.contributors, true)) {
690
690
  return false;
691
691
  }
692
- const title = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.title)[0];
692
+ const title = (0, utils_1.getLastTitleNode)(state);
693
693
  const pos = title.pos + title.node.nodeSize;
694
694
  const contributors = state.schema.nodes.contributors.create({
695
695
  id: '',
@@ -709,7 +709,7 @@ const insertAffiliation = (state, dispatch, view) => {
709
709
  if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.affiliations, true)) {
710
710
  return false;
711
711
  }
712
- const title = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.title)[0];
712
+ const title = (0, utils_1.getLastTitleNode)(state);
713
713
  let pos = title.pos + title.node.nodeSize;
714
714
  const contributors = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.contributors)[0];
715
715
  if (contributors) {
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getInsertPos = exports.createToggleButton = exports.isEditAllowed = exports.isBodyLocked = exports.cleanItemValues = exports.shouldRenderField = exports.hasParent = exports.isNotNull = exports.createHeader = exports.isSelectionInBody = exports.isSelectionInNode = exports.isChildOfNodeTypes = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
18
+ exports.getLastTitleNode = exports.getInsertPos = exports.createToggleButton = exports.isEditAllowed = exports.isBodyLocked = exports.cleanItemValues = exports.shouldRenderField = exports.hasParent = exports.isNotNull = exports.createHeader = exports.isSelectionInBody = exports.isSelectionInNode = exports.isChildOfNodeTypes = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const prosemirror_utils_1 = require("prosemirror-utils");
21
21
  const config_1 = require("../components/references/ReferenceForm/config");
@@ -170,3 +170,12 @@ const getInsertPos = (type, parent, pos) => {
170
170
  return insertPos;
171
171
  };
172
172
  exports.getInsertPos = getInsertPos;
173
+ const getLastTitleNode = (state) => {
174
+ const altTitleNode = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.alt_titles)[0];
175
+ if (altTitleNode) {
176
+ return altTitleNode;
177
+ }
178
+ const titleNode = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.title)[0];
179
+ return titleNode;
180
+ };
181
+ exports.getLastTitleNode = getLastTitleNode;
@@ -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.2.13';
4
+ exports.VERSION = '3.2.14';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -27,7 +27,7 @@ import { findAbstractsNode, findBackmatter, findBibliographySection, findBody, f
27
27
  import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, } from './lib/footnotes';
28
28
  import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
29
29
  import { isDeleted } from './lib/track-changes-utils';
30
- import { findParentNodeWithId, getChildOfType, getInsertPos, isBodyLocked, } from './lib/utils';
30
+ import { findParentNodeWithId, getChildOfType, getInsertPos, getLastTitleNode, isBodyLocked, } from './lib/utils';
31
31
  import { expandAccessibilitySection } from './plugins/accessibility_element';
32
32
  import { setCommentSelection } from './plugins/comments';
33
33
  import { getEditorProps } from './plugins/editor-props';
@@ -654,7 +654,7 @@ export const insertContributors = (state, dispatch, view) => {
654
654
  if (getChildOfType(state.doc, schema.nodes.contributors, true)) {
655
655
  return false;
656
656
  }
657
- const title = findChildrenByType(state.doc, state.schema.nodes.title)[0];
657
+ const title = getLastTitleNode(state);
658
658
  const pos = title.pos + title.node.nodeSize;
659
659
  const contributors = state.schema.nodes.contributors.create({
660
660
  id: '',
@@ -673,7 +673,7 @@ export const insertAffiliation = (state, dispatch, view) => {
673
673
  if (getChildOfType(state.doc, schema.nodes.affiliations, true)) {
674
674
  return false;
675
675
  }
676
- const title = findChildrenByType(state.doc, state.schema.nodes.title)[0];
676
+ const title = getLastTitleNode(state);
677
677
  let pos = title.pos + title.node.nodeSize;
678
678
  const contributors = findChildrenByType(state.doc, state.schema.nodes.contributors)[0];
679
679
  if (contributors) {
@@ -150,3 +150,11 @@ export const getInsertPos = (type, parent, pos) => {
150
150
  });
151
151
  return insertPos;
152
152
  };
153
+ export const getLastTitleNode = (state) => {
154
+ const altTitleNode = findChildrenByType(state.doc, state.schema.nodes.alt_titles)[0];
155
+ if (altTitleNode) {
156
+ return altTitleNode;
157
+ }
158
+ const titleNode = findChildrenByType(state.doc, state.schema.nodes.title)[0];
159
+ return titleNode;
160
+ };
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.13';
1
+ export const VERSION = '3.2.14';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -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 { BibliographyItemAttrs, BibliographyItemType, ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
16
+ import { BibliographyItemAttrs, BibliographyItemType, ManuscriptEditorState, ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
17
17
  import { Node as ProseMirrorNode, NodeType, ResolvedPos } from 'prosemirror-model';
18
18
  import { EditorState, Selection } from 'prosemirror-state';
19
19
  export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
@@ -36,3 +36,7 @@ export declare const isBodyLocked: (state: EditorState) => boolean;
36
36
  export declare const isEditAllowed: (state: EditorState) => boolean;
37
37
  export declare const createToggleButton: (listener: () => void) => HTMLButtonElement;
38
38
  export declare const getInsertPos: (type: ManuscriptNodeType, parent: ManuscriptNode, pos: number) => number;
39
+ export declare const getLastTitleNode: (state: ManuscriptEditorState) => {
40
+ node: ProseMirrorNode;
41
+ pos: number;
42
+ };
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.13";
1
+ export declare const VERSION = "3.2.14";
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.2.13",
4
+ "version": "3.2.14",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",