@manuscripts/body-editor 2.0.26 → 2.0.27-LEAN-3884.0

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.
@@ -236,6 +236,24 @@ const insertBreak = (state, dispatch) => {
236
236
  };
237
237
  exports.insertBreak = insertBreak;
238
238
  const selectedText = () => (window.getSelection() || '').toString();
239
+ const findPosBeforeFirstSubsection = ($pos) => {
240
+ let posBeforeFirstSubsection = null;
241
+ for (let d = $pos.depth; d >= 0; d--) {
242
+ const parentNode = $pos.node(d);
243
+ if ((0, transform_1.isSectionNodeType)(parentNode.type)) {
244
+ const parentStartPos = $pos.start(d);
245
+ parentNode.descendants((node, pos) => {
246
+ if (node.type === transform_1.schema.nodes.section &&
247
+ posBeforeFirstSubsection === null) {
248
+ posBeforeFirstSubsection = parentStartPos + pos;
249
+ }
250
+ return posBeforeFirstSubsection === null;
251
+ });
252
+ break;
253
+ }
254
+ }
255
+ return posBeforeFirstSubsection;
256
+ };
239
257
  const findPosAfterParentSection = ($pos) => {
240
258
  for (let d = $pos.depth; d >= 0; d--) {
241
259
  const node = $pos.node(d);
@@ -430,7 +448,10 @@ const insertSection = (subsection = false) => (state, dispatch, view) => {
430
448
  }
431
449
  let pos;
432
450
  if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(selection) || subsection) {
433
- pos = findPosAfterParentSection(state.selection.$from);
451
+ pos = subsection
452
+ ? findPosBeforeFirstSubsection(state.selection.$from) ||
453
+ findPosAfterParentSection(state.selection.$from)
454
+ : findPosAfterParentSection(state.selection.$from);
434
455
  }
435
456
  else {
436
457
  const body = (0, doc_1.findBody)(state.doc);
@@ -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.0.26';
4
+ exports.VERSION = '2.0.27-LEAN-3884.0';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -221,6 +221,24 @@ export const insertBreak = (state, dispatch) => {
221
221
  return true;
222
222
  };
223
223
  const selectedText = () => (window.getSelection() || '').toString();
224
+ const findPosBeforeFirstSubsection = ($pos) => {
225
+ let posBeforeFirstSubsection = null;
226
+ for (let d = $pos.depth; d >= 0; d--) {
227
+ const parentNode = $pos.node(d);
228
+ if (isSectionNodeType(parentNode.type)) {
229
+ const parentStartPos = $pos.start(d);
230
+ parentNode.descendants((node, pos) => {
231
+ if (node.type === schema.nodes.section &&
232
+ posBeforeFirstSubsection === null) {
233
+ posBeforeFirstSubsection = parentStartPos + pos;
234
+ }
235
+ return posBeforeFirstSubsection === null;
236
+ });
237
+ break;
238
+ }
239
+ }
240
+ return posBeforeFirstSubsection;
241
+ };
224
242
  const findPosAfterParentSection = ($pos) => {
225
243
  for (let d = $pos.depth; d >= 0; d--) {
226
244
  const node = $pos.node(d);
@@ -406,7 +424,10 @@ export const insertSection = (subsection = false) => (state, dispatch, view) =>
406
424
  }
407
425
  let pos;
408
426
  if (hasParentNodeOfType(schema.nodes.body)(selection) || subsection) {
409
- pos = findPosAfterParentSection(state.selection.$from);
427
+ pos = subsection
428
+ ? findPosBeforeFirstSubsection(state.selection.$from) ||
429
+ findPosAfterParentSection(state.selection.$from)
430
+ : findPosAfterParentSection(state.selection.$from);
410
431
  }
411
432
  else {
412
433
  const body = findBody(state.doc);
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.0.26';
1
+ export const VERSION = '2.0.27-LEAN-3884.0';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.26";
1
+ export declare const VERSION = "2.0.27-LEAN-3884.0";
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.0.26",
4
+ "version": "2.0.27-LEAN-3884.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",