@manuscripts/body-editor 1.9.7-LEAN-3136 → 1.9.7

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 (39) hide show
  1. package/dist/cjs/commands.js +4 -16
  2. package/dist/cjs/configs/ManuscriptsEditor.js +14 -20
  3. package/dist/cjs/configs/editor-views.js +1 -1
  4. package/dist/cjs/plugins/affiliations.js +0 -3
  5. package/dist/cjs/plugins/bibliography/index.js +1 -1
  6. package/dist/cjs/plugins/footnotes/footnotes-utils.js +1 -33
  7. package/dist/cjs/plugins/footnotes/index.js +26 -77
  8. package/dist/cjs/plugins/highlight/index.js +5 -6
  9. package/dist/cjs/plugins/selected-suggestion-ui.js +4 -8
  10. package/dist/cjs/plugins/table-footnote.js +0 -3
  11. package/dist/cjs/views/base_node_view.js +1 -1
  12. package/dist/cjs/views/bibliography_element.js +0 -6
  13. package/dist/cjs/views/citation.js +0 -3
  14. package/dist/cjs/views/citation_editable.js +0 -6
  15. package/dist/cjs/views/footnotes_element.js +1 -3
  16. package/dist/cjs/views/inline_footnote.js +2 -17
  17. package/dist/es/commands.js +5 -17
  18. package/dist/es/configs/ManuscriptsEditor.js +14 -20
  19. package/dist/es/configs/editor-views.js +1 -1
  20. package/dist/es/plugins/affiliations.js +0 -3
  21. package/dist/es/plugins/bibliography/index.js +1 -1
  22. package/dist/es/plugins/footnotes/footnotes-utils.js +0 -31
  23. package/dist/es/plugins/footnotes/index.js +27 -78
  24. package/dist/es/plugins/highlight/index.js +5 -6
  25. package/dist/es/plugins/selected-suggestion-ui.js +4 -8
  26. package/dist/es/plugins/table-footnote.js +0 -3
  27. package/dist/es/views/base_node_view.js +1 -1
  28. package/dist/es/views/bibliography_element.js +0 -6
  29. package/dist/es/views/citation.js +0 -3
  30. package/dist/es/views/citation_editable.js +0 -6
  31. package/dist/es/views/footnotes_element.js +1 -3
  32. package/dist/es/views/inline_footnote.js +2 -17
  33. package/dist/types/plugins/bibliography/index.d.ts +1 -1
  34. package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -1
  35. package/dist/types/plugins/footnotes/index.d.ts +3 -5
  36. package/dist/types/views/footnotes_element.d.ts +3 -3
  37. package/package.json +2 -2
  38. package/styles/AdvancedEditor.css +8 -6
  39. package/styles/Editor.css +3 -7
@@ -327,24 +327,12 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
327
327
  let selectionPos;
328
328
  if (!footnotesSection) {
329
329
  const section = state.schema.nodes.footnotes_section.create({}, [
330
- state.schema.nodes.section_title.create({}, state.schema.text('Footnotes')),
330
+ state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
331
331
  state.schema.nodes.footnotes_element.create({}, footnote),
332
332
  ]);
333
333
  const backmatter = (0, prosemirror_utils_1.findChildrenByType)(tr.doc, transform_1.schema.nodes.backmatter)[0];
334
- const sectionPos = backmatter.pos + 1;
335
- tr.insert(sectionPos, section);
336
- let footnotePos = 0;
337
- section.descendants((n, pos) => {
338
- if ((0, transform_1.isFootnoteNode)(n)) {
339
- footnotePos = pos;
340
- n.descendants((childNode, childPos) => {
341
- if ((0, transform_1.isParagraphNode)(childNode)) {
342
- footnotePos += childPos;
343
- }
344
- });
345
- }
346
- });
347
- selectionPos = sectionPos + footnotePos;
334
+ tr.insert(backmatter.pos + 1, section);
335
+ selectionPos = backmatter.pos + section.nodeSize - 3;
348
336
  }
349
337
  else {
350
338
  const footnoteElement = (0, prosemirror_utils_1.findChildrenByType)(footnotesSection.node, transform_1.schema.nodes.footnotes_element);
@@ -356,7 +344,7 @@ const insertInlineFootnote = (kind) => (state, dispatch) => {
356
344
  selectionPos = pos + 2;
357
345
  }
358
346
  if (dispatch && selectionPos) {
359
- const selection = prosemirror_state_1.TextSelection.near(tr.doc.resolve(selectionPos));
347
+ const selection = prosemirror_state_1.TextSelection.create(tr.doc, selectionPos);
360
348
  dispatch(tr.setSelection(selection).scrollIntoView());
361
349
  }
362
350
  return true;
@@ -32,24 +32,18 @@ const createEditorState = (props) => prosemirror_state_1.EditorState.create({
32
32
  plugins: (0, editor_plugins_1.default)(props),
33
33
  });
34
34
  exports.createEditorState = createEditorState;
35
- const createEditorView = (props, root, state, dispatch) => {
36
- const view = new prosemirror_view_1.EditorView(root, {
37
- state,
38
- editable: () => props.getCapabilities().editArticle,
39
- scrollMargin: {
40
- top: 100,
41
- bottom: 100,
42
- left: 0,
43
- right: 0,
44
- },
45
- dispatchTransaction: dispatch,
46
- nodeViews: (0, editor_views_1.default)(props, dispatch),
47
- attributes: props.attributes,
48
- transformPasted: paste_1.transformPasted,
49
- });
50
- const tr = view.state.tr.setMeta('INIT', true);
51
- const nextState = view.state.apply(tr);
52
- view.updateState(nextState);
53
- return view;
54
- };
35
+ const createEditorView = (props, root, state, dispatch) => new prosemirror_view_1.EditorView(root, {
36
+ state,
37
+ editable: () => props.getCapabilities().editArticle,
38
+ scrollMargin: {
39
+ top: 100,
40
+ bottom: 100,
41
+ left: 0,
42
+ right: 0,
43
+ },
44
+ dispatchTransaction: dispatch,
45
+ nodeViews: (0, editor_views_1.default)(props, dispatch),
46
+ attributes: props.attributes,
47
+ transformPasted: paste_1.transformPasted,
48
+ });
55
49
  exports.createEditorView = createEditorView;
@@ -69,7 +69,7 @@ exports.default = (props, dispatch) => {
69
69
  footnote: (0, footnote_editable_1.default)(props),
70
70
  footnotes_element: (0, footnotes_element_1.default)(props),
71
71
  inline_equation: (0, inline_equation_editable_1.default)(props),
72
- inline_footnote: (0, inline_footnote_editable_1.default)(props, dispatch),
72
+ inline_footnote: (0, inline_footnote_editable_1.default)(props),
73
73
  keyword: (0, keyword_1.default)(props, dispatch),
74
74
  keyword_group: (0, keyword_group_1.default)(props, dispatch),
75
75
  link: (0, link_editable_1.default)(props, dispatch),
@@ -74,9 +74,6 @@ exports.default = () => {
74
74
  },
75
75
  appendTransaction(transactions, oldState, newState) {
76
76
  const { indexedAffiliationIds } = exports.affiliationsKey.getState(newState);
77
- if (!transactions.find((tr) => tr.docChanged)) {
78
- return;
79
- }
80
77
  const oldPluginState = exports.affiliationsKey.getState(oldState);
81
78
  const { tr } = newState;
82
79
  const affiliations = [];
@@ -54,7 +54,7 @@ exports.default = (props) => {
54
54
  props: {
55
55
  decorations(state) {
56
56
  const bib = (0, exports.getBibliographyPluginState)(state);
57
- return prosemirror_view_1.DecorationSet.create(state.doc, bib ? (0, bibliography_utils_1.buildDecorations)(bib, state.doc) : []);
57
+ return prosemirror_view_1.DecorationSet.create(state.doc, (0, bibliography_utils_1.buildDecorations)(bib, state.doc));
58
58
  },
59
59
  },
60
60
  });
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getAlphaOrderIndices = exports.getInlineFootnotes = exports.updateTableInlineFootnoteLabels = exports.orderTableFootnotes = exports.buildTableFootnoteLabels = exports.getNewFootnotePos = exports.findTableInlineFootnoteIds = void 0;
18
+ exports.getInlineFootnotes = exports.updateTableInlineFootnoteLabels = exports.orderTableFootnotes = exports.buildTableFootnoteLabels = exports.getNewFootnotePos = exports.findTableInlineFootnoteIds = void 0;
19
19
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
20
20
  const transform_1 = require("@manuscripts/transform");
21
21
  const prosemirror_model_1 = require("prosemirror-model");
@@ -113,35 +113,3 @@ const getInlineFootnotes = (id, targetNode) => {
113
113
  return inlineFootnotes;
114
114
  };
115
115
  exports.getInlineFootnotes = getInlineFootnotes;
116
- function getAlphaOrderIndices(index) {
117
- const unicodeInterval = [97, 123];
118
- const places = unicodeInterval[1] - unicodeInterval[0];
119
- function getClassCount(n, order) {
120
- return n * Math.pow(places, order - 1);
121
- }
122
- let indices = null;
123
- for (;;) {
124
- let current = index;
125
- let position = 1;
126
- while (current >= places) {
127
- current = current / places;
128
- position++;
129
- }
130
- const newIndex = Math.floor(current);
131
- indices = indices ? indices : new Array(position).fill(0);
132
- indices.splice(indices.length - position, 1, newIndex);
133
- index -= getClassCount(newIndex, position);
134
- if (position === 1) {
135
- break;
136
- }
137
- }
138
- return (indices || [])
139
- .map((v, i, array) => {
140
- if (array.length > 1 && i !== array.length - 1) {
141
- return String.fromCodePoint(v + unicodeInterval[0] - 1);
142
- }
143
- return String.fromCodePoint(v + unicodeInterval[0]);
144
- })
145
- .join('');
146
- }
147
- exports.getAlphaOrderIndices = getAlphaOrderIndices;
@@ -18,8 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.buildPluginState = exports.uncitedFootnoteWidget = exports.footnotesKey = void 0;
22
- const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
21
+ exports.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
23
22
  const transform_1 = require("@manuscripts/transform");
24
23
  const lodash_1 = require("lodash");
25
24
  const prosemirror_state_1 = require("prosemirror-state");
@@ -32,10 +31,28 @@ const ReactSubView_1 = __importDefault(require("../../views/ReactSubView"));
32
31
  const placeholder_1 = require("../placeholder");
33
32
  const footnotes_utils_1 = require("./footnotes-utils");
34
33
  exports.footnotesKey = new prosemirror_state_1.PluginKey('footnotes');
34
+ const buildPluginState = (doc) => {
35
+ const nodes = [];
36
+ let index = 0;
37
+ const labels = new Map();
38
+ doc.descendants((node, pos, parentNode) => {
39
+ if ((0, transform_1.isInlineFootnoteNode)(node) &&
40
+ parentNode &&
41
+ parentNode.type !== transform_1.schema.nodes.table_cell &&
42
+ parentNode.type !== transform_1.schema.nodes.table_header) {
43
+ nodes.push([node, pos]);
44
+ node.attrs.rids.forEach((rid) => {
45
+ labels.set(rid, String(++index));
46
+ });
47
+ }
48
+ });
49
+ return { nodes, labels };
50
+ };
51
+ exports.buildPluginState = buildPluginState;
35
52
  const scrollToInlineFootnote = (rid, view) => {
36
53
  view.state.doc.descendants((node, pos) => {
37
54
  const footnote = node;
38
- if ((0, transform_1.isInlineFootnoteNode)(node) && footnote.attrs.rids.includes(rid)) {
55
+ if (footnote.attrs.rids.includes(rid)) {
39
56
  const selection = prosemirror_state_1.NodeSelection.create(view.state.doc, pos);
40
57
  view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
41
58
  }
@@ -45,7 +62,7 @@ const labelWidget = (label, id) => (view) => {
45
62
  const element = document.createElement('span');
46
63
  element.className = 'footnote-label';
47
64
  element.textContent = label;
48
- element.addEventListener('mousedown', () => {
65
+ element.addEventListener('click', () => {
49
66
  scrollToInlineFootnote(id, view);
50
67
  });
51
68
  return element;
@@ -120,39 +137,6 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
120
137
  });
121
138
  return deleteBtn;
122
139
  };
123
- const buildPluginState = (doc) => {
124
- const inlineFootnotes = [];
125
- const footnotes = new Map();
126
- let footnoteElement;
127
- doc.descendants((node, pos, parentNode) => {
128
- if ((0, transform_1.isFootnotesSectionNode)(node)) {
129
- node.descendants((node, childPos) => {
130
- if ((0, transform_1.isFootnotesElementNode)(node)) {
131
- footnoteElement = [node, pos + childPos];
132
- }
133
- if ((0, transform_1.isFootnoteNode)(node)) {
134
- footnotes.set(node.attrs.id, [node, pos + childPos]);
135
- }
136
- });
137
- }
138
- if ((0, transform_1.isInlineFootnoteNode)(node) &&
139
- parentNode &&
140
- parentNode.type !== transform_1.schema.nodes.table_cell &&
141
- parentNode.type !== transform_1.schema.nodes.table_header) {
142
- inlineFootnotes.push([node, pos]);
143
- }
144
- });
145
- let index = 0;
146
- const labels = new Map();
147
- inlineFootnotes.sort((a, b) => a[1] - b[1]);
148
- inlineFootnotes.forEach(([node]) => {
149
- node.attrs.rids.forEach((rid) => {
150
- labels.set(rid, (0, footnotes_utils_1.getAlphaOrderIndices)(index++));
151
- });
152
- });
153
- return { inlineFootnotes, labels, footnotes, footnoteElement };
154
- };
155
- exports.buildPluginState = buildPluginState;
156
140
  exports.default = (props) => {
157
141
  return new prosemirror_state_1.Plugin({
158
142
  key: exports.footnotesKey,
@@ -161,60 +145,25 @@ exports.default = (props) => {
161
145
  return (0, exports.buildPluginState)(instance.doc);
162
146
  },
163
147
  apply(tr, value, oldState, newState) {
164
- const prevState = exports.footnotesKey.getState(oldState);
165
- if (!tr.docChanged && prevState) {
166
- return prevState;
167
- }
168
148
  return (0, exports.buildPluginState)(newState.doc);
169
149
  },
170
150
  },
171
151
  appendTransaction(transactions, oldState, newState) {
172
- const { inlineFootnotes: oldInlineFootnoteNodes } = exports.footnotesKey.getState(oldState);
173
- const { inlineFootnotes: inlineFootnoteNodes, footnotes, labels, footnoteElement, } = exports.footnotesKey.getState(newState);
174
- const prevIds = oldInlineFootnoteNodes.map(([node]) => node.attrs.rids);
175
- const newIds = inlineFootnoteNodes.map(([node]) => node.attrs.rids);
176
- const initTransaction = transactions.find((t) => t.getMeta('INIT'));
177
- if (!footnoteElement || (!initTransaction && (0, lodash_1.isEqual)(prevIds, newIds))) {
152
+ const { nodes: oldInlineFootnoteNodes } = exports.footnotesKey.getState(oldState);
153
+ const { nodes: inlineFootnoteNodes, labels } = exports.footnotesKey.getState(newState);
154
+ if ((0, lodash_1.isEqual)(inlineFootnoteNodes, oldInlineFootnoteNodes)) {
178
155
  return null;
179
156
  }
180
157
  const { tr } = newState;
181
- const footnotesReordered = [];
182
- const footnotesRest = new Map(footnotes);
183
158
  inlineFootnoteNodes.forEach(([node, pos]) => {
184
159
  const footnote = node;
185
160
  const contents = footnote.attrs.rids
186
- .map((rid) => {
187
- const currentfNode = footnotesRest.get(rid);
188
- if (currentfNode) {
189
- footnotesReordered.push(currentfNode[0]);
190
- footnotesRest.delete(rid);
191
- }
192
- return labels.get(rid);
193
- })
161
+ .map((rid) => labels.get(rid))
194
162
  .join('');
195
163
  if (footnote.attrs.contents !== contents) {
196
164
  tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, footnote.attrs), { rids: footnote.attrs.rids, contents }));
197
165
  }
198
166
  });
199
- footnotesRest.forEach(([node]) => footnotesReordered.push(node));
200
- const newFElement = transform_1.schema.nodes.footnotes_element.create(footnoteElement[0].attrs, footnotesReordered);
201
- if (newFElement && footnotes.size > 0) {
202
- tr.replaceWith(footnoteElement[1], footnoteElement[1] + footnoteElement[0].nodeSize, newFElement);
203
- }
204
- const prevSelection = newState.selection;
205
- const selectedFootnote = (0, prosemirror_utils_1.findParentNodeClosestToPos)(prevSelection.$anchor, (node) => (0, transform_1.isFootnoteNode)(node));
206
- if (selectedFootnote && footnotes.size > 0) {
207
- let newFootnotePos = 0;
208
- for (let i = 0; i < footnotesReordered.length; i++) {
209
- const node = footnotesReordered[i];
210
- newFootnotePos += node.nodeSize;
211
- if (node.attrs.id === selectedFootnote.node.attrs.id) {
212
- break;
213
- }
214
- }
215
- tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, footnoteElement[1] + newFootnotePos));
216
- }
217
- (0, track_changes_plugin_1.skipTracking)(tr);
218
167
  return tr;
219
168
  },
220
169
  props: {
@@ -257,7 +206,7 @@ exports.default = (props) => {
257
206
  }
258
207
  }
259
208
  if (!((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent)) {
260
- decorations.push(prosemirror_view_1.Decoration.widget(pos + 2, (0, placeholder_1.placeholderWidget)('Type new footnote here')));
209
+ decorations.push(prosemirror_view_1.Decoration.widget(pos + 2, (0, placeholder_1.placeholderWidget)('Add new note here')));
261
210
  }
262
211
  if (tableInlineFootnoteIds &&
263
212
  !tableInlineFootnoteIds.has(node.attrs.id)) {
@@ -62,13 +62,12 @@ exports.default = (props) => {
62
62
  key: exports.highlightKey,
63
63
  state: {
64
64
  init: (tr, state) => buildPluginState(state.doc),
65
- apply: (tr, value) => {
65
+ apply: (tr) => {
66
66
  const meta = tr.getMeta(exports.highlightKey);
67
- if (meta && exports.SET_COMMENT in meta) {
68
- props.setComment(meta[exports.SET_COMMENT]);
69
- }
70
- else if (!tr.docChanged || tr.step.length === 0) {
71
- return value;
67
+ if (meta) {
68
+ if (exports.SET_COMMENT in meta) {
69
+ props.setComment(meta[exports.SET_COMMENT]);
70
+ }
72
71
  }
73
72
  return buildPluginState(tr.doc);
74
73
  },
@@ -94,6 +94,7 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
94
94
  return buildSelectedSuggestionDecoration(suggestionId, state, props);
95
95
  }
96
96
  if (tr.getMeta(exports.CLEAR_SUGGESTION_ID)) {
97
+ props.setEditorSelectedSuggestion(undefined);
97
98
  return prosemirror_view_1.DecorationSet.empty;
98
99
  }
99
100
  return value;
@@ -104,11 +105,8 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
104
105
  const nodeClicked = view.state.doc.nodeAt(pos);
105
106
  const trackChangesData = nodeClicked && getTrackChangesData(nodeClicked);
106
107
  if (!trackChangesData) {
107
- setTimeout(() => {
108
- const newTr = view.state.tr.setMeta(exports.CLEAR_SUGGESTION_ID, true);
109
- view.dispatch(newTr);
110
- props.setEditorSelectedSuggestion(undefined);
111
- });
108
+ view.dispatch(view.state.tr.setMeta(exports.CLEAR_SUGGESTION_ID, true));
109
+ props.setEditorSelectedSuggestion(undefined);
112
110
  }
113
111
  },
114
112
  decorations: (state) => exports.selectedSuggestionKey.getState(state),
@@ -124,9 +122,7 @@ const buildSelectedSuggestionDecoration = (suggestionId, state, props) => {
124
122
  decorations.push(decoration(change.from, change.to, {
125
123
  class: 'selected-suggestion',
126
124
  }));
127
- setTimeout(() => {
128
- props.setEditorSelectedSuggestion(change.id);
129
- }, 0);
125
+ props.setEditorSelectedSuggestion(change.id);
130
126
  }
131
127
  return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
132
128
  };
@@ -14,9 +14,6 @@ const isInlineFootnoteChange = (step, oldState, newState) => {
14
14
  exports.default = () => {
15
15
  return new prosemirror_state_1.Plugin({
16
16
  appendTransaction(transactions, oldState, newState) {
17
- if (!transactions.find((tr) => tr.docChanged)) {
18
- return null;
19
- }
20
17
  const tableInlineFootnoteChange = transactions.find((tr) => tr.steps.find((s, i) => {
21
18
  var _a;
22
19
  if (s instanceof prosemirror_transform_1.ReplaceStep) {
@@ -62,7 +62,7 @@ class BaseNodeView {
62
62
  }
63
63
  };
64
64
  }
65
- setDomAttrs(node, element, omit = ['contents']) {
65
+ setDomAttrs(node, element, omit = []) {
66
66
  Object.keys(node.attrs || {}).forEach((attr) => {
67
67
  if (!omit.includes(attr)) {
68
68
  element.setAttribute(attr, node.attrs[attr]);
@@ -49,9 +49,6 @@ class BibliographyElementBlockView extends block_view_1.default {
49
49
  this.showPopper = (id) => {
50
50
  this.props.popper.destroy();
51
51
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
52
- if (!bib) {
53
- return;
54
- }
55
52
  const componentProps = {
56
53
  items: Array.from(bib.bibliographyItems.values()),
57
54
  citationCounts: bib.citationCounts,
@@ -143,9 +140,6 @@ class BibliographyElementBlockView extends block_view_1.default {
143
140
  const can = this.props.getCapabilities();
144
141
  const wrapper = document.createElement('div');
145
142
  wrapper.classList.add('contents');
146
- if (!bib) {
147
- return;
148
- }
149
143
  const [meta, bibliography] = bib.provider.makeBibliography();
150
144
  for (let i = 0; i < bibliography.length; i++) {
151
145
  const id = meta.entry_ids[i];
@@ -40,9 +40,6 @@ class CitationView extends base_node_view_1.BaseNodeView {
40
40
  };
41
41
  this.updateContents = () => {
42
42
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
43
- if (!bib) {
44
- return;
45
- }
46
43
  const classes = [
47
44
  'citation',
48
45
  ...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
@@ -90,9 +90,6 @@ class CitationEditableView extends citation_1.CitationView {
90
90
  this.showPopper = () => {
91
91
  this.props.popper.destroy();
92
92
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
93
- if (!bib) {
94
- return;
95
- }
96
93
  const can = this.props.getCapabilities();
97
94
  const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
98
95
  const rids = attrs.rids;
@@ -155,9 +152,6 @@ class CitationEditableView extends citation_1.CitationView {
155
152
  };
156
153
  this.handleCite = (items) => {
157
154
  const bib = (0, bibliography_1.getBibliographyPluginState)(this.view.state);
158
- if (!bib) {
159
- return;
160
- }
161
155
  const attrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
162
156
  const rids = [...attrs.rids];
163
157
  items = items.filter((i) => !rids.includes(i.id));
@@ -28,9 +28,7 @@ class FootnotesElementView extends block_view_1.default {
28
28
  this.elementType = 'div';
29
29
  this.checkEditability = () => {
30
30
  var _a, _b;
31
- const editable = this.props.getCapabilities().editArticle && this.node.childCount
32
- ? 'true'
33
- : 'false';
31
+ const editable = this.node.childCount ? 'true' : 'false';
34
32
  (_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.setAttribute('contenteditable', editable);
35
33
  (_b = this.dom) === null || _b === void 0 ? void 0 : _b.setAttribute('contenteditable', editable);
36
34
  };
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.InlineFootnoteView = void 0;
22
22
  const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const transform_1 = require("@manuscripts/transform");
24
- const prosemirror_state_1 = require("prosemirror-state");
25
24
  const prosemirror_utils_1 = require("prosemirror-utils");
26
25
  const commands_1 = require("../commands");
27
26
  const track_changes_utils_1 = require("../lib/track-changes-utils");
@@ -34,7 +33,6 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
34
33
  super(...arguments);
35
34
  this.findParentTableElement = () => (0, prosemirror_utils_1.findParentNodeClosestToPos)(this.view.state.doc.resolve(this.getPos()), (node) => node.type === transform_1.schema.nodes.table_element);
36
35
  this.handleClick = () => {
37
- var _a;
38
36
  if ((0, track_changes_utils_1.isDeleted)(this.node)) {
39
37
  return;
40
38
  }
@@ -51,24 +49,11 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
51
49
  this.props.popper.show(this.dom, this.popperContainer, 'bottom-end');
52
50
  }
53
51
  else {
54
- if ((_a = this.node.attrs.rids) === null || _a === void 0 ? void 0 : _a.length) {
55
- let nodePos = undefined;
56
- this.view.state.doc.descendants((node, pos) => {
57
- if (node.attrs.id === this.node.attrs.rids[0]) {
58
- nodePos = pos;
59
- }
60
- });
61
- if (nodePos && this.props.dispatch) {
62
- const sel = prosemirror_state_1.TextSelection.near(this.view.state.doc.resolve(nodePos + 1));
63
- this.props.dispatch(this.view.state.tr.setSelection(sel).scrollIntoView());
64
- }
65
- }
52
+ this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
66
53
  }
67
54
  };
68
55
  this.updateContents = () => {
69
- const node = this.node;
70
- this.dom.setAttribute('rids', node.attrs.rids.join(','));
71
- this.dom.setAttribute('contents', node.attrs.contents);
56
+ this.setDomAttrs(this.node, this.dom);
72
57
  this.dom.className = [
73
58
  'footnote',
74
59
  ...(0, track_changes_utils_1.getChangeClasses)(this.node.attrs.dataTracked),
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { ObjectTypes } from '@manuscripts/json-schema';
17
17
  import { skipTracking } from '@manuscripts/track-changes-plugin';
18
- import { buildComment, generateID, isElementNodeType, isFootnoteNode, isInBibliographySection, isListNode, isParagraphNode, isSectionNodeType, schema, } from '@manuscripts/transform';
18
+ import { buildComment, generateID, isElementNodeType, isInBibliographySection, isListNode, isSectionNodeType, schema, } from '@manuscripts/transform';
19
19
  import { NodeRange } from 'prosemirror-model';
20
20
  import { wrapInList } from 'prosemirror-schema-list';
21
21
  import { NodeSelection, TextSelection, } from 'prosemirror-state';
@@ -308,24 +308,12 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
308
308
  let selectionPos;
309
309
  if (!footnotesSection) {
310
310
  const section = state.schema.nodes.footnotes_section.create({}, [
311
- state.schema.nodes.section_title.create({}, state.schema.text('Footnotes')),
311
+ state.schema.nodes.section_title.create({}, state.schema.text('Notes')),
312
312
  state.schema.nodes.footnotes_element.create({}, footnote),
313
313
  ]);
314
314
  const backmatter = findChildrenByType(tr.doc, schema.nodes.backmatter)[0];
315
- const sectionPos = backmatter.pos + 1;
316
- tr.insert(sectionPos, section);
317
- let footnotePos = 0;
318
- section.descendants((n, pos) => {
319
- if (isFootnoteNode(n)) {
320
- footnotePos = pos;
321
- n.descendants((childNode, childPos) => {
322
- if (isParagraphNode(childNode)) {
323
- footnotePos += childPos;
324
- }
325
- });
326
- }
327
- });
328
- selectionPos = sectionPos + footnotePos;
315
+ tr.insert(backmatter.pos + 1, section);
316
+ selectionPos = backmatter.pos + section.nodeSize - 3;
329
317
  }
330
318
  else {
331
319
  const footnoteElement = findChildrenByType(footnotesSection.node, schema.nodes.footnotes_element);
@@ -337,7 +325,7 @@ export const insertInlineFootnote = (kind) => (state, dispatch) => {
337
325
  selectionPos = pos + 2;
338
326
  }
339
327
  if (dispatch && selectionPos) {
340
- const selection = TextSelection.near(tr.doc.resolve(selectionPos));
328
+ const selection = TextSelection.create(tr.doc, selectionPos);
341
329
  dispatch(tr.setSelection(selection).scrollIntoView());
342
330
  }
343
331
  return true;
@@ -25,23 +25,17 @@ export const createEditorState = (props) => EditorState.create({
25
25
  schema,
26
26
  plugins: plugins(props),
27
27
  });
28
- export const createEditorView = (props, root, state, dispatch) => {
29
- const view = new EditorView(root, {
30
- state,
31
- editable: () => props.getCapabilities().editArticle,
32
- scrollMargin: {
33
- top: 100,
34
- bottom: 100,
35
- left: 0,
36
- right: 0,
37
- },
38
- dispatchTransaction: dispatch,
39
- nodeViews: views(props, dispatch),
40
- attributes: props.attributes,
41
- transformPasted,
42
- });
43
- const tr = view.state.tr.setMeta('INIT', true);
44
- const nextState = view.state.apply(tr);
45
- view.updateState(nextState);
46
- return view;
47
- };
28
+ export const createEditorView = (props, root, state, dispatch) => new EditorView(root, {
29
+ state,
30
+ editable: () => props.getCapabilities().editArticle,
31
+ scrollMargin: {
32
+ top: 100,
33
+ bottom: 100,
34
+ left: 0,
35
+ right: 0,
36
+ },
37
+ dispatchTransaction: dispatch,
38
+ nodeViews: views(props, dispatch),
39
+ attributes: props.attributes,
40
+ transformPasted,
41
+ });
@@ -64,7 +64,7 @@ export default (props, dispatch) => {
64
64
  footnote: footnote(props),
65
65
  footnotes_element: footnotesElement(props),
66
66
  inline_equation: inlineEquation(props),
67
- inline_footnote: inlineFootnote(props, dispatch),
67
+ inline_footnote: inlineFootnote(props),
68
68
  keyword: keyword(props, dispatch),
69
69
  keyword_group: keywordGroup(props, dispatch),
70
70
  link: link(props, dispatch),
@@ -70,9 +70,6 @@ export default () => {
70
70
  },
71
71
  appendTransaction(transactions, oldState, newState) {
72
72
  const { indexedAffiliationIds } = affiliationsKey.getState(newState);
73
- if (!transactions.find((tr) => tr.docChanged)) {
74
- return;
75
- }
76
73
  const oldPluginState = affiliationsKey.getState(oldState);
77
74
  const { tr } = newState;
78
75
  const affiliations = [];
@@ -51,7 +51,7 @@ export default (props) => {
51
51
  props: {
52
52
  decorations(state) {
53
53
  const bib = getBibliographyPluginState(state);
54
- return DecorationSet.create(state.doc, bib ? buildDecorations(bib, state.doc) : []);
54
+ return DecorationSet.create(state.doc, buildDecorations(bib, state.doc));
55
55
  },
56
56
  },
57
57
  });
@@ -104,34 +104,3 @@ export const getInlineFootnotes = (id, targetNode) => {
104
104
  });
105
105
  return inlineFootnotes;
106
106
  };
107
- export function getAlphaOrderIndices(index) {
108
- const unicodeInterval = [97, 123];
109
- const places = unicodeInterval[1] - unicodeInterval[0];
110
- function getClassCount(n, order) {
111
- return n * Math.pow(places, order - 1);
112
- }
113
- let indices = null;
114
- for (;;) {
115
- let current = index;
116
- let position = 1;
117
- while (current >= places) {
118
- current = current / places;
119
- position++;
120
- }
121
- const newIndex = Math.floor(current);
122
- indices = indices ? indices : new Array(position).fill(0);
123
- indices.splice(indices.length - position, 1, newIndex);
124
- index -= getClassCount(newIndex, position);
125
- if (position === 1) {
126
- break;
127
- }
128
- }
129
- return (indices || [])
130
- .map((v, i, array) => {
131
- if (array.length > 1 && i !== array.length - 1) {
132
- return String.fromCodePoint(v + unicodeInterval[0] - 1);
133
- }
134
- return String.fromCodePoint(v + unicodeInterval[0]);
135
- })
136
- .join('');
137
- }
@@ -13,10 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { skipTracking } from '@manuscripts/track-changes-plugin';
17
- import { isFootnoteNode, isFootnotesElementNode, isFootnotesSectionNode, isInlineFootnoteNode, schema, } from '@manuscripts/transform';
16
+ import { isFootnoteNode, isInlineFootnoteNode, schema, } from '@manuscripts/transform';
18
17
  import { isEqual } from 'lodash';
19
- import { NodeSelection, Plugin, PluginKey, TextSelection, } from 'prosemirror-state';
18
+ import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
20
19
  import { findParentNodeClosestToPos, findParentNodeOfType, } from 'prosemirror-utils';
21
20
  import { Decoration, DecorationSet } from 'prosemirror-view';
22
21
  import { alertIcon, deleteIcon } from '../../assets';
@@ -24,12 +23,29 @@ import { DeleteFootnoteDialog, } from '../../components/views/DeleteFootnoteDial
24
23
  import { findParentNodeWithIdValue, getChildOfType } from '../../lib/utils';
25
24
  import ReactSubView from '../../views/ReactSubView';
26
25
  import { placeholderWidget } from '../placeholder';
27
- import { findTableInlineFootnoteIds, getAlphaOrderIndices, getInlineFootnotes, } from './footnotes-utils';
26
+ import { findTableInlineFootnoteIds, getInlineFootnotes, } from './footnotes-utils';
28
27
  export const footnotesKey = new PluginKey('footnotes');
28
+ export const buildPluginState = (doc) => {
29
+ const nodes = [];
30
+ let index = 0;
31
+ const labels = new Map();
32
+ doc.descendants((node, pos, parentNode) => {
33
+ if (isInlineFootnoteNode(node) &&
34
+ parentNode &&
35
+ parentNode.type !== schema.nodes.table_cell &&
36
+ parentNode.type !== schema.nodes.table_header) {
37
+ nodes.push([node, pos]);
38
+ node.attrs.rids.forEach((rid) => {
39
+ labels.set(rid, String(++index));
40
+ });
41
+ }
42
+ });
43
+ return { nodes, labels };
44
+ };
29
45
  const scrollToInlineFootnote = (rid, view) => {
30
46
  view.state.doc.descendants((node, pos) => {
31
47
  const footnote = node;
32
- if (isInlineFootnoteNode(node) && footnote.attrs.rids.includes(rid)) {
48
+ if (footnote.attrs.rids.includes(rid)) {
33
49
  const selection = NodeSelection.create(view.state.doc, pos);
34
50
  view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
35
51
  }
@@ -39,7 +55,7 @@ const labelWidget = (label, id) => (view) => {
39
55
  const element = document.createElement('span');
40
56
  element.className = 'footnote-label';
41
57
  element.textContent = label;
42
- element.addEventListener('mousedown', () => {
58
+ element.addEventListener('click', () => {
43
59
  scrollToInlineFootnote(id, view);
44
60
  });
45
61
  return element;
@@ -113,38 +129,6 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
113
129
  });
114
130
  return deleteBtn;
115
131
  };
116
- export const buildPluginState = (doc) => {
117
- const inlineFootnotes = [];
118
- const footnotes = new Map();
119
- let footnoteElement;
120
- doc.descendants((node, pos, parentNode) => {
121
- if (isFootnotesSectionNode(node)) {
122
- node.descendants((node, childPos) => {
123
- if (isFootnotesElementNode(node)) {
124
- footnoteElement = [node, pos + childPos];
125
- }
126
- if (isFootnoteNode(node)) {
127
- footnotes.set(node.attrs.id, [node, pos + childPos]);
128
- }
129
- });
130
- }
131
- if (isInlineFootnoteNode(node) &&
132
- parentNode &&
133
- parentNode.type !== schema.nodes.table_cell &&
134
- parentNode.type !== schema.nodes.table_header) {
135
- inlineFootnotes.push([node, pos]);
136
- }
137
- });
138
- let index = 0;
139
- const labels = new Map();
140
- inlineFootnotes.sort((a, b) => a[1] - b[1]);
141
- inlineFootnotes.forEach(([node]) => {
142
- node.attrs.rids.forEach((rid) => {
143
- labels.set(rid, getAlphaOrderIndices(index++));
144
- });
145
- });
146
- return { inlineFootnotes, labels, footnotes, footnoteElement };
147
- };
148
132
  export default (props) => {
149
133
  return new Plugin({
150
134
  key: footnotesKey,
@@ -153,60 +137,25 @@ export default (props) => {
153
137
  return buildPluginState(instance.doc);
154
138
  },
155
139
  apply(tr, value, oldState, newState) {
156
- const prevState = footnotesKey.getState(oldState);
157
- if (!tr.docChanged && prevState) {
158
- return prevState;
159
- }
160
140
  return buildPluginState(newState.doc);
161
141
  },
162
142
  },
163
143
  appendTransaction(transactions, oldState, newState) {
164
- const { inlineFootnotes: oldInlineFootnoteNodes } = footnotesKey.getState(oldState);
165
- const { inlineFootnotes: inlineFootnoteNodes, footnotes, labels, footnoteElement, } = footnotesKey.getState(newState);
166
- const prevIds = oldInlineFootnoteNodes.map(([node]) => node.attrs.rids);
167
- const newIds = inlineFootnoteNodes.map(([node]) => node.attrs.rids);
168
- const initTransaction = transactions.find((t) => t.getMeta('INIT'));
169
- if (!footnoteElement || (!initTransaction && isEqual(prevIds, newIds))) {
144
+ const { nodes: oldInlineFootnoteNodes } = footnotesKey.getState(oldState);
145
+ const { nodes: inlineFootnoteNodes, labels } = footnotesKey.getState(newState);
146
+ if (isEqual(inlineFootnoteNodes, oldInlineFootnoteNodes)) {
170
147
  return null;
171
148
  }
172
149
  const { tr } = newState;
173
- const footnotesReordered = [];
174
- const footnotesRest = new Map(footnotes);
175
150
  inlineFootnoteNodes.forEach(([node, pos]) => {
176
151
  const footnote = node;
177
152
  const contents = footnote.attrs.rids
178
- .map((rid) => {
179
- const currentfNode = footnotesRest.get(rid);
180
- if (currentfNode) {
181
- footnotesReordered.push(currentfNode[0]);
182
- footnotesRest.delete(rid);
183
- }
184
- return labels.get(rid);
185
- })
153
+ .map((rid) => labels.get(rid))
186
154
  .join('');
187
155
  if (footnote.attrs.contents !== contents) {
188
156
  tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, footnote.attrs), { rids: footnote.attrs.rids, contents }));
189
157
  }
190
158
  });
191
- footnotesRest.forEach(([node]) => footnotesReordered.push(node));
192
- const newFElement = schema.nodes.footnotes_element.create(footnoteElement[0].attrs, footnotesReordered);
193
- if (newFElement && footnotes.size > 0) {
194
- tr.replaceWith(footnoteElement[1], footnoteElement[1] + footnoteElement[0].nodeSize, newFElement);
195
- }
196
- const prevSelection = newState.selection;
197
- const selectedFootnote = findParentNodeClosestToPos(prevSelection.$anchor, (node) => isFootnoteNode(node));
198
- if (selectedFootnote && footnotes.size > 0) {
199
- let newFootnotePos = 0;
200
- for (let i = 0; i < footnotesReordered.length; i++) {
201
- const node = footnotesReordered[i];
202
- newFootnotePos += node.nodeSize;
203
- if (node.attrs.id === selectedFootnote.node.attrs.id) {
204
- break;
205
- }
206
- }
207
- tr.setSelection(TextSelection.create(tr.doc, footnoteElement[1] + newFootnotePos));
208
- }
209
- skipTracking(tr);
210
159
  return tr;
211
160
  },
212
161
  props: {
@@ -249,7 +198,7 @@ export default (props) => {
249
198
  }
250
199
  }
251
200
  if (!((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent)) {
252
- decorations.push(Decoration.widget(pos + 2, placeholderWidget('Type new footnote here')));
201
+ decorations.push(Decoration.widget(pos + 2, placeholderWidget('Add new note here')));
253
202
  }
254
203
  if (tableInlineFootnoteIds &&
255
204
  !tableInlineFootnoteIds.has(node.attrs.id)) {
@@ -56,13 +56,12 @@ export default (props) => {
56
56
  key: highlightKey,
57
57
  state: {
58
58
  init: (tr, state) => buildPluginState(state.doc),
59
- apply: (tr, value) => {
59
+ apply: (tr) => {
60
60
  const meta = tr.getMeta(highlightKey);
61
- if (meta && SET_COMMENT in meta) {
62
- props.setComment(meta[SET_COMMENT]);
63
- }
64
- else if (!tr.docChanged || tr.step.length === 0) {
65
- return value;
61
+ if (meta) {
62
+ if (SET_COMMENT in meta) {
63
+ props.setComment(meta[SET_COMMENT]);
64
+ }
66
65
  }
67
66
  return buildPluginState(tr.doc);
68
67
  },
@@ -91,6 +91,7 @@ export default (props) => new Plugin({
91
91
  return buildSelectedSuggestionDecoration(suggestionId, state, props);
92
92
  }
93
93
  if (tr.getMeta(CLEAR_SUGGESTION_ID)) {
94
+ props.setEditorSelectedSuggestion(undefined);
94
95
  return DecorationSet.empty;
95
96
  }
96
97
  return value;
@@ -101,11 +102,8 @@ export default (props) => new Plugin({
101
102
  const nodeClicked = view.state.doc.nodeAt(pos);
102
103
  const trackChangesData = nodeClicked && getTrackChangesData(nodeClicked);
103
104
  if (!trackChangesData) {
104
- setTimeout(() => {
105
- const newTr = view.state.tr.setMeta(CLEAR_SUGGESTION_ID, true);
106
- view.dispatch(newTr);
107
- props.setEditorSelectedSuggestion(undefined);
108
- });
105
+ view.dispatch(view.state.tr.setMeta(CLEAR_SUGGESTION_ID, true));
106
+ props.setEditorSelectedSuggestion(undefined);
109
107
  }
110
108
  },
111
109
  decorations: (state) => selectedSuggestionKey.getState(state),
@@ -121,9 +119,7 @@ const buildSelectedSuggestionDecoration = (suggestionId, state, props) => {
121
119
  decorations.push(decoration(change.from, change.to, {
122
120
  class: 'selected-suggestion',
123
121
  }));
124
- setTimeout(() => {
125
- props.setEditorSelectedSuggestion(change.id);
126
- }, 0);
122
+ props.setEditorSelectedSuggestion(change.id);
127
123
  }
128
124
  return DecorationSet.create(state.doc, decorations);
129
125
  };
@@ -12,9 +12,6 @@ const isInlineFootnoteChange = (step, oldState, newState) => {
12
12
  export default () => {
13
13
  return new Plugin({
14
14
  appendTransaction(transactions, oldState, newState) {
15
- if (!transactions.find((tr) => tr.docChanged)) {
16
- return null;
17
- }
18
15
  const tableInlineFootnoteChange = transactions.find((tr) => tr.steps.find((s, i) => {
19
16
  var _a;
20
17
  if (s instanceof ReplaceStep) {
@@ -59,7 +59,7 @@ export class BaseNodeView {
59
59
  }
60
60
  };
61
61
  }
62
- setDomAttrs(node, element, omit = ['contents']) {
62
+ setDomAttrs(node, element, omit = []) {
63
63
  Object.keys(node.attrs || {}).forEach((attr) => {
64
64
  if (!omit.includes(attr)) {
65
65
  element.setAttribute(attr, node.attrs[attr]);
@@ -43,9 +43,6 @@ export class BibliographyElementBlockView extends BlockView {
43
43
  this.showPopper = (id) => {
44
44
  this.props.popper.destroy();
45
45
  const bib = getBibliographyPluginState(this.view.state);
46
- if (!bib) {
47
- return;
48
- }
49
46
  const componentProps = {
50
47
  items: Array.from(bib.bibliographyItems.values()),
51
48
  citationCounts: bib.citationCounts,
@@ -137,9 +134,6 @@ export class BibliographyElementBlockView extends BlockView {
137
134
  const can = this.props.getCapabilities();
138
135
  const wrapper = document.createElement('div');
139
136
  wrapper.classList.add('contents');
140
- if (!bib) {
141
- return;
142
- }
143
137
  const [meta, bibliography] = bib.provider.makeBibliography();
144
138
  for (let i = 0; i < bibliography.length; i++) {
145
139
  const id = meta.entry_ids[i];
@@ -37,9 +37,6 @@ export class CitationView extends BaseNodeView {
37
37
  };
38
38
  this.updateContents = () => {
39
39
  const bib = getBibliographyPluginState(this.view.state);
40
- if (!bib) {
41
- return;
42
- }
43
40
  const classes = [
44
41
  'citation',
45
42
  ...getChangeClasses(this.node.attrs.dataTracked),
@@ -84,9 +84,6 @@ export class CitationEditableView extends CitationView {
84
84
  this.showPopper = () => {
85
85
  this.props.popper.destroy();
86
86
  const bib = getBibliographyPluginState(this.view.state);
87
- if (!bib) {
88
- return;
89
- }
90
87
  const can = this.props.getCapabilities();
91
88
  const attrs = getActualAttrs(this.node);
92
89
  const rids = attrs.rids;
@@ -149,9 +146,6 @@ export class CitationEditableView extends CitationView {
149
146
  };
150
147
  this.handleCite = (items) => {
151
148
  const bib = getBibliographyPluginState(this.view.state);
152
- if (!bib) {
153
- return;
154
- }
155
149
  const attrs = getActualAttrs(this.node);
156
150
  const rids = [...attrs.rids];
157
151
  items = items.filter((i) => !rids.includes(i.id));
@@ -22,9 +22,7 @@ export class FootnotesElementView extends BlockView {
22
22
  this.elementType = 'div';
23
23
  this.checkEditability = () => {
24
24
  var _a, _b;
25
- const editable = this.props.getCapabilities().editArticle && this.node.childCount
26
- ? 'true'
27
- : 'false';
25
+ const editable = this.node.childCount ? 'true' : 'false';
28
26
  (_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.setAttribute('contenteditable', editable);
29
27
  (_b = this.dom) === null || _b === void 0 ? void 0 : _b.setAttribute('contenteditable', editable);
30
28
  };
@@ -15,7 +15,6 @@
15
15
  */
16
16
  import { TableFootnotesSelector, } from '@manuscripts/style-guide';
17
17
  import { schema, } from '@manuscripts/transform';
18
- import { TextSelection } from 'prosemirror-state';
19
18
  import { findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
20
19
  import { insertTableFootnote } from '../commands';
21
20
  import { getChangeClasses, isDeleted, isRejectedInsert, } from '../lib/track-changes-utils';
@@ -28,7 +27,6 @@ export class InlineFootnoteView extends BaseNodeView {
28
27
  super(...arguments);
29
28
  this.findParentTableElement = () => findParentNodeClosestToPos(this.view.state.doc.resolve(this.getPos()), (node) => node.type === schema.nodes.table_element);
30
29
  this.handleClick = () => {
31
- var _a;
32
30
  if (isDeleted(this.node)) {
33
31
  return;
34
32
  }
@@ -45,24 +43,11 @@ export class InlineFootnoteView extends BaseNodeView {
45
43
  this.props.popper.show(this.dom, this.popperContainer, 'bottom-end');
46
44
  }
47
45
  else {
48
- if ((_a = this.node.attrs.rids) === null || _a === void 0 ? void 0 : _a.length) {
49
- let nodePos = undefined;
50
- this.view.state.doc.descendants((node, pos) => {
51
- if (node.attrs.id === this.node.attrs.rids[0]) {
52
- nodePos = pos;
53
- }
54
- });
55
- if (nodePos && this.props.dispatch) {
56
- const sel = TextSelection.near(this.view.state.doc.resolve(nodePos + 1));
57
- this.props.dispatch(this.view.state.tr.setSelection(sel).scrollIntoView());
58
- }
59
- }
46
+ this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
60
47
  }
61
48
  };
62
49
  this.updateContents = () => {
63
- const node = this.node;
64
- this.dom.setAttribute('rids', node.attrs.rids.join(','));
65
- this.dom.setAttribute('contents', node.attrs.contents);
50
+ this.setDomAttrs(this.node, this.dom);
66
51
  this.dom.className = [
67
52
  'footnote',
68
53
  ...getChangeClasses(this.node.attrs.dataTracked),
@@ -36,4 +36,4 @@ export interface BibliographyProps {
36
36
  }
37
37
  declare const _default: (props: BibliographyProps) => Plugin<PluginState>;
38
38
  export default _default;
39
- export declare const getBibliographyPluginState: (state: EditorState) => PluginState | undefined;
39
+ export declare const getBibliographyPluginState: (state: EditorState) => PluginState;
@@ -27,5 +27,4 @@ interface InlineFootnote {
27
27
  pos: number;
28
28
  }
29
29
  export declare const getInlineFootnotes: (id: string, targetNode: ManuscriptNode) => InlineFootnote[];
30
- export declare function getAlphaOrderIndices(index: number): string;
31
30
  export {};
@@ -13,17 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { FootnoteNode, FootnotesElementNode, InlineFootnoteNode, ManuscriptNode } from '@manuscripts/transform';
16
+ import { InlineFootnoteNode, ManuscriptNode } from '@manuscripts/transform';
17
17
  import { Plugin, PluginKey } from 'prosemirror-state';
18
18
  import { PluginProps } from '../../configs/editor-plugins';
19
19
  interface PluginState {
20
- inlineFootnotes: [InlineFootnoteNode, number][];
20
+ nodes: [InlineFootnoteNode, number][];
21
21
  labels: Map<string, string>;
22
- footnotes: Map<string, [FootnoteNode, number]>;
23
- footnoteElement?: [FootnotesElementNode, number];
24
22
  }
25
23
  export declare const footnotesKey: PluginKey<PluginState>;
26
- export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
27
24
  export declare const buildPluginState: (doc: ManuscriptNode) => PluginState;
25
+ export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
28
26
  declare const _default: (props: PluginProps) => Plugin<PluginState>;
29
27
  export default _default;
@@ -13,12 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { BaseNodeProps } from './base_node_view';
16
17
  import BlockView from './block_view';
17
- import { EditableBlockProps } from './editable_block';
18
- export declare class FootnotesElementView<Props extends EditableBlockProps> extends BlockView<Props> {
18
+ export declare class FootnotesElementView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
19
19
  elementType: string;
20
20
  onUpdateContent(): void;
21
21
  checkEditability: () => void;
22
22
  }
23
- declare const _default: (props: import("./base_node_view").BaseNodeProps) => import("../types").NodeViewCreator<FootnotesElementView<any>>;
23
+ declare const _default: (props: BaseNodeProps) => import("../types").NodeViewCreator<FootnotesElementView<any>>;
24
24
  export default _default;
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.9.7-LEAN-3136",
4
+ "version": "1.9.7",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -32,7 +32,7 @@
32
32
  "@manuscripts/json-schema": "^2.2.7",
33
33
  "@manuscripts/library": "^1.3.6",
34
34
  "@manuscripts/style-guide": "1.12.4",
35
- "@manuscripts/track-changes-plugin": "1.7.10-LEAN-3136-2MB-3",
35
+ "@manuscripts/track-changes-plugin": "1.7.10",
36
36
  "@manuscripts/transform": "2.3.3",
37
37
  "astrocite-eutils": "^0.16.4",
38
38
  "mathjax-full": "^3.2.2",
@@ -686,12 +686,12 @@ Next levels are shifted 'up' by 1
686
686
  }
687
687
 
688
688
  .selected-suggestion {
689
- background: #bce7f6 !important;
689
+ background: #BCE7F6 !important;
690
690
  }
691
691
 
692
692
  .selected-suggestion {
693
693
  border-width: 2px 0 2px 0 !important;
694
- border-color: #20aedf !important;
694
+ border-color: #20AEDF !important;
695
695
  border-radius: 3px !important;
696
696
  border-style: solid !important;
697
697
  }
@@ -795,14 +795,14 @@ Next levels are shifted 'up' by 1
795
795
  display: flex;
796
796
  justify-content: space-between;
797
797
  align-items: flex-start;
798
- gap: 0 0.5em;
798
+ gap: 0 .5em;
799
799
  }
800
800
  .contributors-list {
801
801
  display: flex;
802
802
  max-width: 100%;
803
803
  flex: 0 1 auto;
804
804
  flex-wrap: wrap;
805
- gap: 0 0.25em;
805
+ gap: 0 .25em;
806
806
  }
807
807
  .contributors .tools-panel {
808
808
  position: initial;
@@ -825,7 +825,7 @@ Next levels are shifted 'up' by 1
825
825
  left: 0;
826
826
  top: -8px;
827
827
  width: auto;
828
- height: auto;
828
+ height: auto;
829
829
  }
830
830
  .contributor {
831
831
  position: relative;
@@ -864,6 +864,8 @@ Next levels are shifted 'up' by 1
864
864
  vertical-align: top;
865
865
  }
866
866
 
867
+
868
+
867
869
  .contributor-note {
868
870
  display: inline-block;
869
871
  font-size: 0.75em;
@@ -891,4 +893,4 @@ Next levels are shifted 'up' by 1
891
893
 
892
894
  * {
893
895
  scroll-behavior: smooth;
894
- }
896
+ }
package/styles/Editor.css CHANGED
@@ -937,14 +937,13 @@
937
937
 
938
938
  .ProseMirror .footnote::before {
939
939
  content: attr(contents);
940
+ display: inline-block;
940
941
  position: relative;
941
942
  cursor: pointer;
942
943
  vertical-align: super;
943
- z-index: 1;
944
944
  font-size: 75%;
945
945
  color: #0d79d0;
946
946
  }
947
-
948
947
  .ProseMirror .table-footer {
949
948
  font-size: 14px;
950
949
  padding-top: 8px;
@@ -952,7 +951,7 @@
952
951
 
953
952
  .ProseMirror .table-footnotes-element:has(> div):not(:first-child)::before {
954
953
  content: '';
955
- border-bottom: 1px dashed #c9c9c9;
954
+ border-bottom: 1px dashed #C9C9C9;
956
955
  display: block;
957
956
  margin-bottom: 8px;
958
957
  }
@@ -976,10 +975,7 @@
976
975
  position: relative;
977
976
  }
978
977
 
979
- .ProseMirror
980
- .table-footnotes-element
981
- > div:not(:has(.unctied-table-footnote))
982
- p::before {
978
+ .ProseMirror .table-footnotes-element > div:not(:has(.unctied-table-footnote)) p::before {
983
979
  counter-increment: table_footnote;
984
980
  content: counter(table_footnote);
985
981
  display: inline-block;