@manuscripts/body-editor 1.6.17 → 1.6.18

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.
@@ -287,9 +287,9 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
287
287
  });
288
288
  const tr = state.tr;
289
289
  tr.insert(insertedAt, node);
290
- const elements = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_element);
290
+ const footnotesSection = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.footnotes_section)[0];
291
291
  let selectionPos;
292
- if (!elements.length) {
292
+ if (!footnotesSection) {
293
293
  const section = state.schema.nodes.footnotes_section.create({}, [
294
294
  state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
295
295
  state.schema.nodes.footnotes_element.create({}, footnote),
@@ -299,8 +299,11 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
299
299
  selectionPos = backmatter.pos + section.nodeSize - 3;
300
300
  }
301
301
  else {
302
- const element = elements[0];
303
- const pos = element.pos + element.node.nodeSize - 1;
302
+ const footnoteElement = (0, prosemirror_utils_1.findChildrenByType)(footnotesSection.node, transform_1.schema.nodes.footnotes_element);
303
+ const pos = footnotesSection.pos +
304
+ footnoteElement[0].pos +
305
+ footnoteElement[0].node.nodeSize -
306
+ 1;
304
307
  tr.insert(pos, footnote);
305
308
  selectionPos = pos + 2;
306
309
  }
@@ -269,9 +269,9 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
269
269
  });
270
270
  const tr = state.tr;
271
271
  tr.insert(insertedAt, node);
272
- const elements = findChildrenByType(tr.doc, schema.nodes.footnotes_element);
272
+ const footnotesSection = findChildrenByType(tr.doc, schema.nodes.footnotes_section)[0];
273
273
  let selectionPos;
274
- if (!elements.length) {
274
+ if (!footnotesSection) {
275
275
  const section = state.schema.nodes.footnotes_section.create({}, [
276
276
  state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
277
277
  state.schema.nodes.footnotes_element.create({}, footnote),
@@ -281,8 +281,11 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
281
281
  selectionPos = backmatter.pos + section.nodeSize - 3;
282
282
  }
283
283
  else {
284
- const element = elements[0];
285
- const pos = element.pos + element.node.nodeSize - 1;
284
+ const footnoteElement = findChildrenByType(footnotesSection.node, schema.nodes.footnotes_element);
285
+ const pos = footnotesSection.pos +
286
+ footnoteElement[0].pos +
287
+ footnoteElement[0].node.nodeSize -
288
+ 1;
286
289
  tr.insert(pos, footnote);
287
290
  selectionPos = pos + 2;
288
291
  }
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": "1.6.17",
4
+ "version": "1.6.18",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",