@manuscripts/body-editor 1.6.17 → 1.6.18-LEAN-3281-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.
@@ -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
  }
@@ -103,7 +103,7 @@ const getCitation = (node) => {
103
103
  };
104
104
  exports.getCitation = getCitation;
105
105
  const getBibliographyItem = (node) => {
106
- const attrs = getEffectiveAttrs(node);
106
+ const attrs = getEffectiveAttrs(node, true);
107
107
  if (!attrs) {
108
108
  return undefined;
109
109
  }
@@ -113,9 +113,15 @@ const getBibliographyItem = (node) => {
113
113
  };
114
114
  exports.getBibliographyItem = getBibliographyItem;
115
115
  const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
116
- const getEffectiveAttrs = (node) => {
116
+ const getEffectiveAttrs = (node, excludeDeletedNode) => {
117
117
  const _a = node.attrs, { dataTracked } = _a, attrs = __rest(_a, ["dataTracked"]);
118
118
  const nodeChange = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.reduce(getLatest);
119
+ const isDeleted = nodeChange &&
120
+ nodeChange.operation === track_changes_plugin_1.CHANGE_OPERATION.delete &&
121
+ nodeChange.status !== track_changes_plugin_1.CHANGE_STATUS.rejected;
122
+ if (isDeleted && excludeDeletedNode) {
123
+ return undefined;
124
+ }
119
125
  const isRejected = nodeChange &&
120
126
  nodeChange.operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes &&
121
127
  nodeChange.status === track_changes_plugin_1.CHANGE_STATUS.rejected;
@@ -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
  }
@@ -97,7 +97,7 @@ export const getCitation = (node) => {
97
97
  };
98
98
  };
99
99
  export const getBibliographyItem = (node) => {
100
- const attrs = getEffectiveAttrs(node);
100
+ const attrs = getEffectiveAttrs(node, true);
101
101
  if (!attrs) {
102
102
  return undefined;
103
103
  }
@@ -106,9 +106,15 @@ export const getBibliographyItem = (node) => {
106
106
  return pickBy(item, (v) => v !== undefined);
107
107
  };
108
108
  const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
109
- const getEffectiveAttrs = (node) => {
109
+ const getEffectiveAttrs = (node, excludeDeletedNode) => {
110
110
  const _a = node.attrs, { dataTracked } = _a, attrs = __rest(_a, ["dataTracked"]);
111
111
  const nodeChange = dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.reduce(getLatest);
112
+ const isDeleted = nodeChange &&
113
+ nodeChange.operation === CHANGE_OPERATION.delete &&
114
+ nodeChange.status !== CHANGE_STATUS.rejected;
115
+ if (isDeleted && excludeDeletedNode) {
116
+ return undefined;
117
+ }
112
118
  const isRejected = nodeChange &&
113
119
  nodeChange.operation === CHANGE_OPERATION.set_node_attributes &&
114
120
  nodeChange.status === CHANGE_STATUS.rejected;
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-LEAN-3281-0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -31,7 +31,7 @@
31
31
  "@manuscripts/assets": "^0.6.4",
32
32
  "@manuscripts/json-schema": "^2.2.2",
33
33
  "@manuscripts/library": "1.3.2",
34
- "@manuscripts/style-guide": "1.7.0",
34
+ "@manuscripts/style-guide": "1.7.1-LEAN-3281-0",
35
35
  "@manuscripts/track-changes-plugin": "^1.7.5",
36
36
  "@manuscripts/transform": "2.0.4",
37
37
  "astrocite-eutils": "^0.16.4",