@manuscripts/body-editor 2.2.21 → 2.3.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.
Files changed (57) hide show
  1. package/dist/cjs/commands.js +12 -13
  2. package/dist/cjs/components/keywords/AddKeywordInline.js +1 -2
  3. package/dist/cjs/components/outline/DraggableTree.js +0 -4
  4. package/dist/cjs/components/views/FootnotesSelector.js +2 -4
  5. package/dist/cjs/keys/list.js +1 -3
  6. package/dist/cjs/lib/context-menu.js +8 -11
  7. package/dist/cjs/lib/files.js +2 -2
  8. package/dist/cjs/lib/footnotes.js +1 -6
  9. package/dist/cjs/lib/track-changes-utils.js +5 -43
  10. package/dist/cjs/lib/view.js +1 -1
  11. package/dist/cjs/plugins/affiliations.js +1 -1
  12. package/dist/cjs/plugins/bibliography/bibliography-utils.js +1 -2
  13. package/dist/cjs/plugins/bibliography/index.js +2 -2
  14. package/dist/cjs/plugins/footnotes/index.js +5 -6
  15. package/dist/cjs/plugins/footnotes/widgets.js +1 -2
  16. package/dist/cjs/plugins/section_title/autocompletion.js +1 -1
  17. package/dist/cjs/plugins/section_title/index.js +2 -4
  18. package/dist/cjs/versions.js +1 -1
  19. package/dist/cjs/views/citation_editable.js +5 -5
  20. package/dist/cjs/views/cross_reference.js +2 -5
  21. package/dist/cjs/views/equation.js +1 -2
  22. package/dist/cjs/views/figure_editable.js +1 -2
  23. package/dist/cjs/views/inline_equation.js +4 -12
  24. package/dist/cjs/views/inline_footnote.js +5 -5
  25. package/dist/cjs/views/link_editable.js +5 -10
  26. package/dist/cjs/views/list.js +1 -2
  27. package/dist/cjs/views/section.js +1 -2
  28. package/dist/es/commands.js +13 -14
  29. package/dist/es/components/keywords/AddKeywordInline.js +2 -3
  30. package/dist/es/components/outline/DraggableTree.js +1 -5
  31. package/dist/es/components/views/FootnotesSelector.js +2 -4
  32. package/dist/es/keys/list.js +1 -3
  33. package/dist/es/lib/context-menu.js +9 -12
  34. package/dist/es/lib/files.js +3 -3
  35. package/dist/es/lib/footnotes.js +1 -6
  36. package/dist/es/lib/track-changes-utils.js +4 -39
  37. package/dist/es/lib/view.js +2 -2
  38. package/dist/es/plugins/affiliations.js +2 -2
  39. package/dist/es/plugins/bibliography/bibliography-utils.js +1 -2
  40. package/dist/es/plugins/bibliography/index.js +3 -3
  41. package/dist/es/plugins/footnotes/index.js +5 -6
  42. package/dist/es/plugins/footnotes/widgets.js +2 -3
  43. package/dist/es/plugins/section_title/autocompletion.js +2 -2
  44. package/dist/es/plugins/section_title/index.js +2 -4
  45. package/dist/es/versions.js +1 -1
  46. package/dist/es/views/citation_editable.js +6 -6
  47. package/dist/es/views/cross_reference.js +3 -6
  48. package/dist/es/views/equation.js +1 -2
  49. package/dist/es/views/figure_editable.js +1 -2
  50. package/dist/es/views/inline_equation.js +4 -12
  51. package/dist/es/views/inline_footnote.js +6 -6
  52. package/dist/es/views/link_editable.js +6 -11
  53. package/dist/es/views/list.js +1 -2
  54. package/dist/es/views/section.js +1 -2
  55. package/dist/types/lib/track-changes-utils.d.ts +0 -4
  56. package/dist/types/versions.d.ts +1 -1
  57. package/package.json +3 -3
@@ -90,7 +90,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
90
90
  this.activateModal({
91
91
  notes: Array.from(fnState.unusedFootnotes.values()).reduce((acc, n) => {
92
92
  const node = n[0];
93
- if (!(0, track_changes_utils_1.isDeleted)(node) && !(0, track_changes_utils_1.isRejectedInsert)(node)) {
93
+ if (!(0, track_changes_utils_1.isDeleted)(node)) {
94
94
  acc.push({
95
95
  node,
96
96
  });
@@ -99,7 +99,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
99
99
  }, []),
100
100
  onCancel: () => {
101
101
  const { tr } = this.view.state;
102
- if (!(0, track_changes_utils_1.getActualAttrs)(this.node).rids.length) {
102
+ if (this.node.attrs.rids.length) {
103
103
  this.view.dispatch(tr.delete(this.getPos(), this.getPos() + this.node.nodeSize));
104
104
  }
105
105
  this.destroy();
@@ -156,7 +156,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
156
156
  if (footnotesElement) {
157
157
  const tablesFootnoteLabels = (0, footnotes_1.buildTableFootnoteLabels)(tableElement.node);
158
158
  footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement, transform_1.schema.nodes.footnote)
159
- .filter(({ node }) => !(0, track_changes_utils_1.isDeleted)(node) && !(0, track_changes_utils_1.isRejectedInsert)(node))
159
+ .filter(({ node }) => !(0, track_changes_utils_1.isDeleted)(node))
160
160
  .map(({ node }) => ({
161
161
  node: node,
162
162
  index: tablesFootnoteLabels.get(node.attrs.id),
@@ -176,8 +176,8 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
176
176
  };
177
177
  this.onInsert = (notes) => {
178
178
  if (notes.length) {
179
- const contents = (0, track_changes_utils_1.getActualAttrs)(this.node)
180
- .contents.split(',')
179
+ const contents = this.node.attrs.contents
180
+ .split(',')
181
181
  .map((n) => parseInt(n));
182
182
  const rids = notes.map((note) => note.node.attrs.id);
183
183
  const { tr } = this.view.state;
@@ -36,13 +36,8 @@ class LinkEditableView extends link_1.LinkView {
36
36
  this.updateContents();
37
37
  };
38
38
  this.updateContents = () => {
39
- if ((0, track_changes_utils_1.isRejectedInsert)(this.node)) {
40
- this.dom.innerHTML = '';
41
- this.contentDOM = undefined;
42
- return;
43
- }
44
39
  this.contentDOM = this.dom;
45
- const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
40
+ const attrs = this.node.attrs;
46
41
  const href = attrs.href;
47
42
  const title = attrs.title;
48
43
  const classes = ['link', ...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked)];
@@ -64,7 +59,7 @@ class LinkEditableView extends link_1.LinkView {
64
59
  this.closeForm();
65
60
  };
66
61
  this.deselectNode = () => {
67
- const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
62
+ const attrs = this.node.attrs;
68
63
  if (!this.node.content.size || !attrs.href) {
69
64
  this.removeLink();
70
65
  }
@@ -74,7 +69,7 @@ class LinkEditableView extends link_1.LinkView {
74
69
  if (!this.props.getCapabilities().editArticle) {
75
70
  return;
76
71
  }
77
- const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
72
+ const attrs = this.node.attrs;
78
73
  const value = {
79
74
  href: attrs.href,
80
75
  title: attrs.title,
@@ -95,7 +90,7 @@ class LinkEditableView extends link_1.LinkView {
95
90
  }
96
91
  };
97
92
  this.handleCancel = () => {
98
- const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
93
+ const attrs = this.node.attrs;
99
94
  if (!this.node.content.size || !attrs.href) {
100
95
  this.removeLink();
101
96
  }
@@ -107,7 +102,7 @@ class LinkEditableView extends link_1.LinkView {
107
102
  };
108
103
  this.handleSave = (value) => {
109
104
  const tr = this.view.state.tr;
110
- const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
105
+ const attrs = this.node.attrs;
111
106
  const pos = this.getPos();
112
107
  if (value.href !== attrs.href || value.title !== attrs.title) {
113
108
  tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, this.node.attrs), { href: value.href, title: value.title }));
@@ -20,7 +20,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.listCallback = exports.ListView = void 0;
22
22
  const transform_1 = require("@manuscripts/transform");
23
- const track_changes_utils_1 = require("../lib/track-changes-utils");
24
23
  const block_view_1 = __importDefault(require("./block_view"));
25
24
  const creators_1 = require("./creators");
26
25
  const editable_block_1 = require("./editable_block");
@@ -30,7 +29,7 @@ class ListView extends block_view_1.default {
30
29
  this.elementType = 'ul';
31
30
  this.updateContents = () => {
32
31
  var _a;
33
- const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
32
+ const actualAttrs = this.node.attrs;
34
33
  if (this.contentDOM) {
35
34
  const type = actualAttrs.listStyleType;
36
35
  this.contentDOM.style.listStyleType = (0, transform_1.getListType)(type).style;
@@ -19,7 +19,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.SectionView = exports.handleSectionNumbering = void 0;
22
- const track_changes_utils_1 = require("../lib/track-changes-utils");
23
22
  const section_title_1 = require("../plugins/section_title");
24
23
  const block_view_1 = __importDefault(require("./block_view"));
25
24
  const creators_1 = require("./creators");
@@ -48,7 +47,7 @@ class SectionView extends block_view_1.default {
48
47
  };
49
48
  this.onUpdateContent = () => {
50
49
  const sectionTitles = section_title_1.sectionTitleKey.getState(this.view.state);
51
- const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
50
+ const attrs = this.node.attrs;
52
51
  if (this.contentDOM) {
53
52
  this.contentDOM.id = attrs.id;
54
53
  if (attrs.category) {
@@ -27,7 +27,7 @@ import { findBackmatter, findBibliographySection, findBody, insertSupplementsNod
27
27
  import { getNewFootnotePos } from './lib/footnotes';
28
28
  import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
29
29
  import { sectionTitles } from './lib/section-titles';
30
- import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
30
+ import { isDeleted } from './lib/track-changes-utils';
31
31
  import { findParentNodeWithId, getChildOfType, getMatchingChild, } from './lib/utils';
32
32
  import { setCommentSelection } from './plugins/comments';
33
33
  import { getEditorProps } from './plugins/editor-props';
@@ -47,7 +47,11 @@ export const addToStart = (state, dispatch) => {
47
47
  endOffset === parentSize) {
48
48
  const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
49
49
  .pos - (startOffset === 0 ? 1 : 0);
50
- const tr = state.tr.insert(side, $from.node().type.createAndFill());
50
+ const tr = state.tr;
51
+ const from = $from.node().type.createAndFill();
52
+ if (from) {
53
+ tr.insert(side, from);
54
+ }
51
55
  tr.setSelection(TextSelection.create(tr.doc, side + 1));
52
56
  dispatch(tr.scrollIntoView());
53
57
  return true;
@@ -168,8 +172,7 @@ export const insertGeneralFootnote = (tableElementNode, position, view, tableEle
168
172
  ? table.pos + table.node.nodeSize
169
173
  : tableColGroup.pos + tableColGroup.node.nodeSize);
170
174
  if (tableElementFooter === null || tableElementFooter === void 0 ? void 0 : tableElementFooter.length) {
171
- if (isDeleted(tableElementFooter[0].node) ||
172
- isRejectedInsert(tableElementFooter[0].node)) {
175
+ if (isDeleted(tableElementFooter[0].node)) {
173
176
  const tableElementFooterPos = tr.mapping.map(position + tableElementFooter[0].pos + 1);
174
177
  undoFootnoteDelete(tr, tableElementFooter[0], tableElementFooterPos);
175
178
  }
@@ -408,8 +411,7 @@ export const insertFootnote = (state, tr, footnote) => {
408
411
  else {
409
412
  const footnoteElement = findChildrenByType(footnotesSection.node, schema.nodes.footnotes_element).pop();
410
413
  if (footnoteElement) {
411
- if (isDeleted(footnoteElement.node) ||
412
- isRejectedInsert(footnoteElement.node)) {
414
+ if (isDeleted(footnoteElement.node)) {
413
415
  const footnoteElementPos = footnotesSection.pos + footnoteElement.pos + 1;
414
416
  undoFootnoteDelete(tr, footnoteElement, footnoteElementPos);
415
417
  const updatedAttrs = Object.assign(Object.assign({}, footnoteElement.node.attrs), { dataTracked: null });
@@ -456,9 +458,7 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
456
458
  return true;
457
459
  };
458
460
  export const insertGraphicalAbstract = (state, dispatch, view) => {
459
- const GraphicalAbstractSectionNode = findChildrenByType(state.doc, schema.nodes.graphical_abstract_section)[0];
460
- if (getChildOfType(state.doc, schema.nodes.graphical_abstract_section, true) &&
461
- !isRejectedInsert(GraphicalAbstractSectionNode.node)) {
461
+ if (getChildOfType(state.doc, schema.nodes.graphical_abstract_section, true)) {
462
462
  return false;
463
463
  }
464
464
  const abstracts = findChildrenByType(state.doc, schema.nodes.abstracts)[0];
@@ -992,7 +992,8 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
992
992
  else {
993
993
  const inlineFootnotes = findChildrenByType(tableElementNode, schema.nodes.inline_footnote);
994
994
  footnoteIndex =
995
- inlineFootnotes.filter(({ pos }) => !isRejectedInsert(tableElementNode) && position + pos <= insertedAt).length + 1;
995
+ inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length +
996
+ 1;
996
997
  const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
997
998
  rids: [footnote.attrs.id],
998
999
  contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
@@ -1002,8 +1003,7 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
1002
1003
  let insertionPos = position;
1003
1004
  const footnotesElement = findChildrenByType(tableElementNode, schema.nodes.footnotes_element).pop();
1004
1005
  if (footnotesElement) {
1005
- if (isDeleted(footnotesElement.node) ||
1006
- isRejectedInsert(footnotesElement.node)) {
1006
+ if (isDeleted(footnotesElement.node)) {
1007
1007
  const footnotesElementPos = tr.mapping.map(position + footnotesElement.pos + 1);
1008
1008
  undoFootnoteDelete(tr, footnotesElement, footnotesElementPos);
1009
1009
  }
@@ -1015,8 +1015,7 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
1015
1015
  const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
1016
1016
  const tableElementFooter = findChildrenByType(tableElementNode, schema.nodes.table_element_footer)[0];
1017
1017
  if (tableElementFooter) {
1018
- if (isDeleted(tableElementFooter.node) ||
1019
- isRejectedInsert(tableElementFooter.node)) {
1018
+ if (isDeleted(tableElementFooter.node)) {
1020
1019
  const tableElementFooterPos = tr.mapping.map(position + tableElementFooter.pos + 1);
1021
1020
  undoFootnoteDelete(tr, tableElementFooter, tableElementFooterPos);
1022
1021
  }
@@ -2,7 +2,7 @@ import { buildKeyword } from '@manuscripts/json-schema';
2
2
  import { Category, Dialog, PlusIcon } from '@manuscripts/style-guide';
3
3
  import React, { useCallback, useEffect, useRef, useState, } from 'react';
4
4
  import styled from 'styled-components';
5
- import { isDeleted, isRejectedInsert } from '../../lib/track-changes-utils';
5
+ import { isDeleted } from '../../lib/track-changes-utils';
6
6
  const AddNewKeyword = styled.div `
7
7
  position: relative;
8
8
  display: inline-block;
@@ -60,8 +60,7 @@ export const AddKeywordInline = ({ viewProps, getUpdatedNode }) => {
60
60
  const keywords = [];
61
61
  node.content.descendants((descNode) => {
62
62
  if (descNode.type === descNode.type.schema.nodes.keyword &&
63
- !isDeleted(descNode) &&
64
- !isRejectedInsert(descNode)) {
63
+ !isDeleted(descNode)) {
65
64
  keywords.push({
66
65
  id: descNode.attrs.id,
67
66
  contents: descNode.textContent,
@@ -5,7 +5,7 @@ import React, { useRef, useState } from 'react';
5
5
  import { useDrag, useDrop } from 'react-dnd';
6
6
  import { ContextMenu } from '../../lib/context-menu';
7
7
  import { getDropSide } from '../../lib/dnd';
8
- import { isDeleted, isRejectedInsert } from '../../lib/track-changes-utils';
8
+ import { isDeleted } from '../../lib/track-changes-utils';
9
9
  import { nodeTypeIcon } from '../../node-type-icons';
10
10
  import { Outline, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemNoArrow, OutlineItemPlaceholder, } from './Outline';
11
11
  const excludedTypes = [
@@ -133,11 +133,7 @@ export const DraggableTree = ({ tree, view, depth, can, }) => {
133
133
  }),
134
134
  });
135
135
  const isDeletedItem = isDeleted(node);
136
- const isRejectedItem = isRejectedInsert(node);
137
136
  const isTop = isManuscriptNode(parent);
138
- if (isRejectedItem) {
139
- return null;
140
- }
141
137
  const handleContextMenu = (e) => {
142
138
  e.preventDefault();
143
139
  e.stopPropagation();
@@ -16,7 +16,6 @@
16
16
  import { AddedIcon, AddIcon, AddNewIcon, ButtonGroup, IconTextButton, PrimaryButton, SecondaryButton, } from '@manuscripts/style-guide';
17
17
  import React, { useState } from 'react';
18
18
  import styled from 'styled-components';
19
- import { getActualAttrs } from '../../lib/track-changes-utils';
20
19
  const NotesContainer = styled.div `
21
20
  height: 90vh;
22
21
  max-height: 400px;
@@ -51,7 +50,7 @@ const AddNewFootnote = styled(ButtonGroup) `
51
50
  export const FootnotesSelector = ({ notes, inlineFootnote, onAdd, onInsert, onCancel, addNewLabel }) => {
52
51
  let selectedNotesMap;
53
52
  if (inlineFootnote) {
54
- const rids = getActualAttrs(inlineFootnote).rids;
53
+ const rids = inlineFootnote.attrs.rids;
55
54
  const selectedNotes = notes.filter(({ node }) => rids.includes(node.attrs.id));
56
55
  selectedNotesMap = new Map(selectedNotes.map(({ node }) => [node.attrs.id, node]));
57
56
  }
@@ -89,8 +88,7 @@ const FootnotesList = ({ notes, isSelected, onSelect, inlineFootnote }) => {
89
88
  const selectedNotes = [];
90
89
  const remainingNotes = [];
91
90
  notes.forEach((note) => {
92
- const isNoteSelected = inlineFootnote &&
93
- getActualAttrs(inlineFootnote).rids.includes(note.node.attrs.id);
91
+ const isNoteSelected = inlineFootnote && inlineFootnote.attrs.rids.includes(note.node.attrs.id);
94
92
  if (isNoteSelected) {
95
93
  selectedNotes.push(note);
96
94
  }
@@ -20,7 +20,6 @@ import { Fragment, Slice } from 'prosemirror-model';
20
20
  import { liftListItem, splitListItem, wrapInList, } from 'prosemirror-schema-list';
21
21
  import { ReplaceAroundStep } from 'prosemirror-transform';
22
22
  import { findParentNodeOfType } from 'prosemirror-utils';
23
- import { getActualAttrs } from '../lib/track-changes-utils';
24
23
  export const skipCommandTracking = (command) => (state, dispatch) => {
25
24
  return command(state, (tr) => {
26
25
  if (dispatch) {
@@ -72,8 +71,7 @@ export function sinkListItem(itemType) {
72
71
  }
73
72
  if (dispatch) {
74
73
  const nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
75
- const actualAttrs = getActualAttrs(parent);
76
- const listType = actualAttrs.listStyleType;
74
+ const listType = parent.attrs.listStyleType;
77
75
  const inner = Fragment.from(nestedBefore ? itemType.create() : null);
78
76
  const slice = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create({ listStyleType: listType }, inner)))), nestedBefore ? 3 : 1, 0);
79
77
  const before = range.start, after = range.end;
@@ -20,7 +20,7 @@ import { FootnotesSelector } from '../components/views/FootnotesSelector';
20
20
  import ReactSubView from '../views/ReactSubView';
21
21
  import { buildTableFootnoteLabels } from './footnotes';
22
22
  import { PopperManager } from './popper';
23
- import { getActualAttrs, isDeleted, isRejectedInsert, } from './track-changes-utils';
23
+ import { isDeleted } from './track-changes-utils';
24
24
  import { getChildOfType, isChildOfNodeTypes } from './utils';
25
25
  const popper = new PopperManager();
26
26
  const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
@@ -151,8 +151,8 @@ export class ContextMenu {
151
151
  const type = isBox ? schema.nodes.box_element : this.node.type;
152
152
  if (type === schema.nodes.list) {
153
153
  menu.appendChild(this.createMenuSection((section) => {
154
- const actualAttrs = getActualAttrs(this.node);
155
- const listType = getListType(actualAttrs.listStyleType).style;
154
+ const attrs = this.node.attrs;
155
+ const listType = getListType(attrs.listStyleType).style;
156
156
  if (listType === 'none' || listType === 'disc') {
157
157
  section.appendChild(this.createMenuItem('Change to Numbered List', () => {
158
158
  this.changeNodeType(null, 'order');
@@ -180,17 +180,16 @@ export class ContextMenu {
180
180
  if (type === schema.nodes.table_element) {
181
181
  const isInTable = hasParentNodeOfType(schema.nodes.table)(this.view.state.selection);
182
182
  const tableElementFooter = findChildrenByType(this.node, schema.nodes.table_element_footer);
183
- let isDeletedOrRejected = false;
183
+ let isDeletedInsert = false;
184
184
  const hasGeneralNote = tableElementFooter.length &&
185
185
  getChildOfType(tableElementFooter[0].node, schema.nodes.general_table_footnote, true);
186
186
  if (hasGeneralNote) {
187
187
  const generalFootnote = (_a = tableElementFooter[0]) === null || _a === void 0 ? void 0 : _a.node.firstChild;
188
188
  if (generalFootnote) {
189
- isDeletedOrRejected =
190
- isDeleted(generalFootnote) || isRejectedInsert(generalFootnote);
189
+ isDeletedInsert = isDeleted(generalFootnote);
191
190
  }
192
191
  }
193
- if (!hasGeneralNote || isDeletedOrRejected) {
192
+ if (!hasGeneralNote || isDeletedInsert) {
194
193
  menu.appendChild(this.createMenuSection((section) => {
195
194
  section.appendChild(this.createMenuItem('Add General Note', () => {
196
195
  insertGeneralFootnote(this.node, this.getPos(), this.view, tableElementFooter);
@@ -204,15 +203,14 @@ export class ContextMenu {
204
203
  const footnotesElementWithPos = findChildrenByType(this.node, schema.nodes.footnotes_element).pop();
205
204
  if (!footnotesElementWithPos ||
206
205
  !(footnotesElementWithPos === null || footnotesElementWithPos === void 0 ? void 0 : footnotesElementWithPos.node.content.childCount) ||
207
- isDeleted(footnotesElementWithPos.node) ||
208
- isRejectedInsert(footnotesElementWithPos.node)) {
206
+ isDeleted(footnotesElementWithPos.node)) {
209
207
  insertTableFootnote(this.node, this.getPos(), this.view);
210
208
  }
211
209
  else {
212
210
  const tablesFootnoteLabels = buildTableFootnoteLabels(this.node);
213
211
  const footnotesWithPos = findChildrenByType(footnotesElementWithPos.node, schema.nodes.footnote);
214
212
  const footnotes = footnotesWithPos
215
- .filter(({ node }) => !isDeleted(node) && !isRejectedInsert(node))
213
+ .filter(({ node }) => !isDeleted(node))
216
214
  .map(({ node }) => ({
217
215
  node: node,
218
216
  index: tablesFootnoteLabels.get(node.attrs.id),
@@ -236,8 +234,7 @@ export class ContextMenu {
236
234
  this.view.state.doc
237
235
  .slice(this.getPos(), insertedAt)
238
236
  .content.descendants((node) => {
239
- if (node.type === schema.nodes.inline_footnote &&
240
- !isRejectedInsert(node)) {
237
+ if (node.type === schema.nodes.inline_footnote) {
241
238
  inlineFootnoteIndex++;
242
239
  return false;
243
240
  }
@@ -1,7 +1,7 @@
1
1
  import { schema } from '@manuscripts/transform';
2
2
  import { findChildrenByType } from 'prosemirror-utils';
3
3
  import { findGraphicalAbstractFigureElement } from './doc';
4
- import { getActualAttrs, isHidden } from './track-changes-utils';
4
+ import { isHidden } from './track-changes-utils';
5
5
  const MISSING_FILE = {
6
6
  id: '',
7
7
  name: 'Missing file',
@@ -19,7 +19,7 @@ export const groupFiles = (doc, files) => {
19
19
  if (isHidden(figure.node)) {
20
20
  continue;
21
21
  }
22
- const src = getActualAttrs(figure.node).src;
22
+ const src = figure.node.attrs.src;
23
23
  if (!src) {
24
24
  continue;
25
25
  }
@@ -56,7 +56,7 @@ export const groupFiles = (doc, files) => {
56
56
  if (isHidden(node)) {
57
57
  return;
58
58
  }
59
- const href = getActualAttrs(node).href;
59
+ const href = node.attrs.href;
60
60
  let file = fileMap.get(href);
61
61
  if (file) {
62
62
  fileMap.delete(href);
@@ -17,13 +17,11 @@ import { skipTracking } from '@manuscripts/track-changes-plugin';
17
17
  import { isFootnoteNode, schema, } from '@manuscripts/transform';
18
18
  import { Fragment } from 'prosemirror-model';
19
19
  import { findChildren, findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
20
- import { isRejectedInsert } from './track-changes-utils';
21
20
  export const findTableInlineFootnoteIds = ($pos) => {
22
21
  var _a;
23
22
  const tableElement = (_a = findParentNodeClosestToPos($pos, (node) => node.type === schema.nodes.table_element)) === null || _a === void 0 ? void 0 : _a.node;
24
23
  return new Set(tableElement
25
24
  ? findChildren(tableElement, (node) => node.type === schema.nodes.inline_footnote)
26
- .filter(({ node }) => !isRejectedInsert(node))
27
25
  .map(({ node }) => node.attrs.rids)
28
26
  .flat()
29
27
  : []);
@@ -46,7 +44,6 @@ export const buildTableFootnoteLabels = (node) => {
46
44
  ]));
47
45
  let index = 0;
48
46
  findChildrenByType(node, schema.nodes.inline_footnote)
49
- .filter(({ node }) => !isRejectedInsert(node))
50
47
  .map(({ node }) => node.attrs.rids)
51
48
  .flat()
52
49
  .map((rid) => {
@@ -85,9 +82,7 @@ export const orderTableFootnotes = (tr, footnotesElementWithPos, position) => {
85
82
  };
86
83
  export const updateTableInlineFootnoteLabels = (tr, table) => {
87
84
  const labels = buildTableFootnoteLabels(table.node);
88
- findChildrenByType(table.node, schema.nodes.inline_footnote)
89
- .filter(({ node }) => !isRejectedInsert(node))
90
- .map(({ node, pos }) => {
85
+ findChildrenByType(table.node, schema.nodes.inline_footnote).map(({ node, pos }) => {
91
86
  const contents = node.attrs.rids
92
87
  .map((rid) => labels.get(rid))
93
88
  .join(',');
@@ -17,17 +17,10 @@ import { EditAttrsTrackingIcon } from '@manuscripts/style-guide';
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import { createElement } from 'react';
19
19
  import { renderToStaticMarkup } from 'react-dom/server';
20
- export function isRejectedInsert(node) {
21
- if (node.attrs.dataTracked) {
22
- const changes = node.attrs.dataTracked;
23
- return changes.some(({ operation, status }) => operation === 'insert' && status == 'rejected');
24
- }
25
- return false;
26
- }
27
20
  export function isDeleted(node) {
28
21
  if (node.attrs.dataTracked) {
29
22
  const changes = node.attrs.dataTracked;
30
- return changes.some(({ operation, status }) => operation === 'delete' && status !== 'rejected');
23
+ return changes.some(({ operation }) => operation === 'delete');
31
24
  }
32
25
  return false;
33
26
  }
@@ -74,24 +67,6 @@ export function isTracked(node) {
74
67
  }
75
68
  return false;
76
69
  }
77
- export function getActualAttrs(node) {
78
- var _a;
79
- const attrs = node.attrs;
80
- if ((_a = attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.length) {
81
- const changes = attrs.dataTracked.filter((c) => c.operation === 'set_attrs');
82
- const hasPendingAttrs = changes.some((c) => c.status === 'pending');
83
- if (hasPendingAttrs) {
84
- return attrs;
85
- }
86
- const rejected = changes
87
- .filter((c) => c.status === 'rejected')
88
- .sort((a, b) => b.statusUpdateAt - a.statusUpdateAt)[0];
89
- if (rejected && rejected.status === 'rejected') {
90
- return rejected.oldAttrs;
91
- }
92
- }
93
- return attrs;
94
- }
95
70
  export const getAttrsTrackingButton = (changeID) => {
96
71
  const el = document.createElement('button');
97
72
  el.className = 'attrs-popper-button';
@@ -100,7 +75,7 @@ export const getAttrsTrackingButton = (changeID) => {
100
75
  return el;
101
76
  };
102
77
  export function isHidden(node) {
103
- return isDeleted(node) || isRejectedInsert(node);
78
+ return isDeleted(node);
104
79
  }
105
80
  export function isDeletedText(node) {
106
81
  var _a, _b, _c, _d;
@@ -108,17 +83,7 @@ export function isDeletedText(node) {
108
83
  const deleteMark = node.marks.find((mark) => mark.type === schema.marks.tracked_delete);
109
84
  if (deleteMark &&
110
85
  ((_b = (_a = deleteMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked) === null || _b === void 0 ? void 0 : _b.status) &&
111
- ['pending', 'approved'].includes((_d = (_c = deleteMark.attrs) === null || _c === void 0 ? void 0 : _c.dataTracked) === null || _d === void 0 ? void 0 : _d.status)) {
112
- return true;
113
- }
114
- }
115
- return false;
116
- }
117
- export function isRejectedText(node) {
118
- var _a, _b;
119
- if (node.type === schema.nodes.text) {
120
- const insertMark = node.marks.find((mark) => mark.type === schema.marks.tracked_insert);
121
- if (insertMark && ((_b = (_a = insertMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked) === null || _b === void 0 ? void 0 : _b.status) === 'rejected') {
86
+ 'pending' === ((_d = (_c = deleteMark.attrs) === null || _c === void 0 ? void 0 : _c.dataTracked) === null || _d === void 0 ? void 0 : _d.status)) {
122
87
  return true;
123
88
  }
124
89
  }
@@ -131,7 +96,7 @@ export function getActualTextContent(fragment) {
131
96
  if (node.type !== schema.nodes.text) {
132
97
  finalContent += getContent(node.content);
133
98
  }
134
- if (!isDeletedText(node) && !isRejectedText(node)) {
99
+ if (!isDeletedText(node)) {
135
100
  finalContent += node.textContent;
136
101
  }
137
102
  });
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { schema, } from '@manuscripts/transform';
17
17
  import * as utils from 'prosemirror-utils';
18
- import { getActualAttrs, isHidden, sanitizeAttrsChange, } from './track-changes-utils';
18
+ import { isHidden, sanitizeAttrsChange } from './track-changes-utils';
19
19
  const metaNodeTypes = [
20
20
  schema.nodes.bibliography_item,
21
21
  schema.nodes.affiliation,
@@ -36,7 +36,7 @@ export const findChildrenByType = (view, type) => {
36
36
  return utils.findChildrenByType(doc, type).filter((n) => !isHidden(n.node));
37
37
  };
38
38
  export const findChildrenAttrsByType = (view, type) => {
39
- return findChildrenByType(view, type).map((n) => getActualAttrs(n.node));
39
+ return findChildrenByType(view, type).map((n) => n.node.attrs);
40
40
  };
41
41
  export const updateNodeAttrs = (view, type, attrs) => {
42
42
  const child = findChildByID(view, attrs.id);
@@ -18,7 +18,7 @@ import { isEqual } from 'lodash';
18
18
  import { Plugin, PluginKey } from 'prosemirror-state';
19
19
  import { Decoration, DecorationSet } from 'prosemirror-view';
20
20
  import { authorComparator, } from '../lib/authors';
21
- import { getActualAttrs, isDeleted, isPendingInsert, } from '../lib/track-changes-utils';
21
+ import { isDeleted, isPendingInsert } from '../lib/track-changes-utils';
22
22
  export const affiliationsKey = new PluginKey('affiliations');
23
23
  let id = 1;
24
24
  export const buildPluginState = (doc, $old) => {
@@ -27,7 +27,7 @@ export const buildPluginState = (doc, $old) => {
27
27
  const affiliations = [];
28
28
  const deletedContribId = new Set();
29
29
  doc.descendants((node, pos) => {
30
- const attrs = isDeleted(node) ? node.attrs : getActualAttrs(node);
30
+ const attrs = node.attrs;
31
31
  if (isAffiliationNode(node)) {
32
32
  nodes.push([node, pos]);
33
33
  affiliations.push(attrs);
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Decoration } from 'prosemirror-view';
17
- import { getActualAttrs } from '../../lib/track-changes-utils';
18
17
  export const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
19
18
  export const buildDecorations = (state, doc) => {
20
19
  const decorations = [];
@@ -66,7 +65,7 @@ export const buildDecorations = (state, doc) => {
66
65
  };
67
66
  export const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
68
67
  export const buildCitations = (citations) => citations
69
- .map((c) => getActualAttrs(c[0]))
68
+ .map((c) => c[0].attrs)
70
69
  .map((attrs) => ({
71
70
  citationID: attrs.id,
72
71
  citationItems: attrs.rids.map((rid) => ({
@@ -31,7 +31,7 @@ import { isEqual, pickBy } from 'lodash';
31
31
  import { Plugin, PluginKey } from 'prosemirror-state';
32
32
  import { findChildrenByType } from 'prosemirror-utils';
33
33
  import { DecorationSet } from 'prosemirror-view';
34
- import { getActualAttrs, isHidden, isRejectedInsert, } from '../../lib/track-changes-utils';
34
+ import { isHidden } from '../../lib/track-changes-utils';
35
35
  import { buildCitations, buildDecorations, } from './bibliography-utils';
36
36
  export const bibliographyKey = new PluginKey('bibliography');
37
37
  export default (props) => {
@@ -60,7 +60,7 @@ let version = 1;
60
60
  const buildBibliographyPluginState = (doc, csl, $old) => {
61
61
  const nodes = [];
62
62
  doc.descendants((node, pos) => {
63
- if (isCitationNode(node) && !isRejectedInsert(node)) {
63
+ if (isCitationNode(node)) {
64
64
  nodes.push([node, pos]);
65
65
  }
66
66
  });
@@ -114,7 +114,7 @@ const getBibliographyItemAttrs = (doc) => {
114
114
  const attrs = new Map();
115
115
  findChildrenByType(doc, schema.nodes.bibliography_item)
116
116
  .filter((n) => !isHidden(n.node))
117
- .map((n) => getActualAttrs(n.node))
117
+ .map((n) => n.node.attrs)
118
118
  .forEach((a) => attrs.set(a.id, a));
119
119
  return attrs;
120
120
  };
@@ -21,7 +21,6 @@ import { findParentNodeClosestToPos, findParentNodeOfType, } from 'prosemirror-u
21
21
  import { Decoration, DecorationSet } from 'prosemirror-view';
22
22
  import { isTextSelection } from '../../commands';
23
23
  import { findTableInlineFootnoteIds, getAlphaOrderIndices, } from '../../lib/footnotes';
24
- import { getActualAttrs } from '../../lib/track-changes-utils';
25
24
  import { placeholderWidget } from '../placeholder';
26
25
  import { deleteFootnoteWidget, labelWidget, uncitedFootnoteWidget, } from './widgets';
27
26
  export const footnotesKey = new PluginKey('footnotes');
@@ -51,7 +50,7 @@ export const buildPluginState = (doc) => {
51
50
  const labels = new Map();
52
51
  inlineFootnotes.sort((a, b) => a[1] - b[1]);
53
52
  inlineFootnotes.forEach(([node]) => {
54
- getActualAttrs(node).rids.forEach((rid) => {
53
+ node.attrs.rids.forEach((rid) => {
55
54
  labels.set(rid, getAlphaOrderIndices(index++));
56
55
  });
57
56
  });
@@ -59,7 +58,7 @@ export const buildPluginState = (doc) => {
59
58
  const unusedFootnotes = new Map(footnotes);
60
59
  inlineFootnotes.forEach(([node]) => {
61
60
  const footnote = node;
62
- getActualAttrs(footnote).rids.forEach((rid) => {
61
+ footnote.attrs.rids.forEach((rid) => {
63
62
  const currentFnNode = unusedFootnotes.get(rid);
64
63
  if (currentFnNode) {
65
64
  footnotesReordered.push(currentFnNode[0]);
@@ -93,8 +92,8 @@ export default (props) => {
93
92
  appendTransaction(transactions, oldState, newState) {
94
93
  const { inlineFootnotes: oldInlineFootnoteNodes } = footnotesKey.getState(oldState);
95
94
  const { inlineFootnotes: inlineFootnoteNodes, footnotes, labels, footnoteElement, unusedFootnotes, } = footnotesKey.getState(newState);
96
- const prevIds = oldInlineFootnoteNodes.map(([node]) => getActualAttrs(node).rids);
97
- const newIds = inlineFootnoteNodes.map(([node]) => getActualAttrs(node).rids);
95
+ const prevIds = oldInlineFootnoteNodes.map(([node]) => node.attrs.rids);
96
+ const newIds = inlineFootnoteNodes.map(([node]) => node.attrs.rids);
98
97
  const initTransaction = transactions.find((t) => t.getMeta('INIT'));
99
98
  if (!footnoteElement || (!initTransaction && isEqual(prevIds, newIds))) {
100
99
  return null;
@@ -103,7 +102,7 @@ export default (props) => {
103
102
  const footnotesReordered = [];
104
103
  inlineFootnoteNodes.forEach(([node, pos]) => {
105
104
  const footnote = node;
106
- const attrs = getActualAttrs(footnote);
105
+ const attrs = footnote.attrs;
107
106
  const contents = attrs.rids
108
107
  .map((rid) => {
109
108
  const currentFnNode = footnotes.get(rid);