@manuscripts/body-editor 1.7.27 → 1.7.28-LEAN-3417-1

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.
@@ -29,6 +29,7 @@ const helpers_1 = require("./lib/helpers");
29
29
  const track_changes_utils_1 = require("./lib/track-changes-utils");
30
30
  const utils_1 = require("./lib/utils");
31
31
  const comment_annotation_1 = require("./plugins/comment_annotation");
32
+ const footnotes_utils_1 = require("./plugins/footnotes/footnotes-utils");
32
33
  const highlight_1 = require("./plugins/highlight");
33
34
  const markActive = (type) => (state) => {
34
35
  const { from, $from, to, empty } = state.selection;
@@ -726,37 +727,38 @@ const updateCommentAnnotationState = (state, dispatch) => {
726
727
  }
727
728
  };
728
729
  exports.updateCommentAnnotationState = updateCommentAnnotationState;
729
- const insertTableFootnote = (node, position, state, dispatch) => {
730
+ const insertTableFootnote = (node, position, view) => {
730
731
  var _a;
732
+ const { state, dispatch } = view;
731
733
  const footnote = state.schema.nodes.footnote.createAndFill({
732
734
  id: (0, transform_1.generateID)(json_schema_1.ObjectTypes.Footnote),
733
735
  kind: 'footnote',
734
736
  });
735
737
  const insertedAt = state.selection.to;
736
738
  const inlineFootnotes = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote);
737
- const labels = inlineFootnotes.map((nodeWithPos) => nodeWithPos.node.attrs.contents);
739
+ const footnoteIndex = inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length + 1;
738
740
  const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
739
741
  rids: [footnote.attrs.id],
740
- contents: labels.length ? Math.max(...labels) + 1 : 1,
742
+ contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
741
743
  });
742
744
  const tr = state.tr;
743
745
  tr.insert(insertedAt, inlineFootnoteNode);
744
- let insertionPos;
746
+ let insertionPos = position;
745
747
  const footnotesElement = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnotes_element).pop();
746
748
  if (footnotesElement &&
747
749
  !(0, track_changes_utils_1.isDeleted)(footnotesElement.node) &&
748
750
  !(0, track_changes_utils_1.isRejectedInsert)(footnotesElement.node)) {
749
- const pos = footnotesElement.pos;
750
- insertionPos = position + pos + footnotesElement.node.nodeSize + 1;
751
+ const footnotePos = (0, footnotes_utils_1.getNewFootnotePos)(footnotesElement, footnoteIndex);
752
+ insertionPos = tr.mapping.map(position + footnotePos);
751
753
  tr.insert(insertionPos, footnote);
752
754
  }
753
755
  else {
754
756
  const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
755
- const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_element_footer);
756
- if (tableElementFooter.length) {
757
- const pos = tableElementFooter[0].pos;
758
- insertionPos = position + pos + tableElementFooter[0].node.nodeSize + 1;
759
- tr.insert(insertionPos, footnoteElement);
757
+ const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_element_footer)[0];
758
+ if (tableElementFooter) {
759
+ const pos = tableElementFooter.pos;
760
+ insertionPos = position + pos + tableElementFooter.node.nodeSize;
761
+ tr.insert(tr.mapping.map(insertionPos), footnoteElement);
760
762
  }
761
763
  else {
762
764
  const tableElementFooter = transform_1.schema.nodes.table_element_footer.create({
@@ -765,21 +767,21 @@ const insertTableFootnote = (node, position, state, dispatch) => {
765
767
  const tableColGroup = (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.table_colgroup)[0];
766
768
  if (tableColGroup) {
767
769
  insertionPos =
768
- position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
769
- tr.insert(insertionPos, tableElementFooter);
770
+ position + tableColGroup.pos + tableColGroup.node.nodeSize;
771
+ tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
770
772
  }
771
773
  else {
772
774
  const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
773
775
  if (tableSize) {
774
- insertionPos = position + tableSize + 2;
775
- tr.insert(insertionPos, tableElementFooter);
776
+ insertionPos = position + tableSize;
777
+ tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
776
778
  }
777
779
  }
778
780
  }
779
781
  }
780
- if (dispatch && insertionPos) {
781
- const nodeSelection = prosemirror_state_1.NodeSelection.create(tr.doc, insertionPos);
782
- dispatch(tr.setSelection(nodeSelection));
783
- }
782
+ dispatch(tr);
783
+ const textSelection = prosemirror_state_1.TextSelection.near(view.state.tr.doc.resolve(insertionPos + 1));
784
+ view.focus();
785
+ dispatch(view.state.tr.setSelection(textSelection).scrollIntoView());
784
786
  };
785
787
  exports.insertTableFootnote = insertTableFootnote;
@@ -60,7 +60,7 @@ const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft
60
60
  " ",
61
61
  react_1.default.createElement(TriangleCollapsed_1.default, null)),
62
62
  isOpen && (react_1.default.createElement(NestedListDropdownList, { direction: 'right', moveLeft: moveLeft, width: 192, onClick: (e) => {
63
- toggleOpen(e);
63
+ toggleOpen();
64
64
  parentToggleOpen(e);
65
65
  } }, list))));
66
66
  };
@@ -38,6 +38,7 @@ const persist_1 = __importDefault(require("../plugins/persist"));
38
38
  const placeholder_1 = __importDefault(require("../plugins/placeholder"));
39
39
  const sections_1 = __importDefault(require("../plugins/sections"));
40
40
  const selected_suggestion_ui_1 = __importDefault(require("../plugins/selected-suggestion-ui"));
41
+ const table_footnote_1 = __importDefault(require("../plugins/table-footnote"));
41
42
  const tables_cursor_fix_1 = __importDefault(require("../plugins/tables-cursor-fix"));
42
43
  const toc_1 = __importDefault(require("../plugins/toc"));
43
44
  const rules_1 = __importDefault(require("../rules"));
@@ -69,6 +70,7 @@ exports.default = (props) => {
69
70
  (0, highlight_1.default)(props),
70
71
  (0, selected_suggestion_ui_1.default)(props),
71
72
  (0, footnotes_1.default)(),
73
+ (0, table_footnote_1.default)(),
72
74
  ];
73
75
  if (props.collabProvider) {
74
76
  allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
@@ -23,6 +23,7 @@ const style_guide_1 = require("@manuscripts/style-guide");
23
23
  const transform_1 = require("@manuscripts/transform");
24
24
  const prosemirror_utils_1 = require("prosemirror-utils");
25
25
  const commands_1 = require("../commands");
26
+ const footnotes_utils_1 = require("../plugins/footnotes/footnotes-utils");
26
27
  const ReactSubView_1 = __importDefault(require("../views/ReactSubView"));
27
28
  const popper_1 = require("./popper");
28
29
  const track_changes_utils_1 = require("./track-changes-utils");
@@ -187,35 +188,45 @@ class ContextMenu {
187
188
  if (isInTable) {
188
189
  menu.appendChild(this.createMenuSection((section) => {
189
190
  section.appendChild(this.createMenuItem('Add Reference Note', () => {
190
- var _a, _b;
191
- const footnotesElement = (_a = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
192
- if (!footnotesElement ||
193
- (0, track_changes_utils_1.isDeleted)(footnotesElement) ||
194
- (0, track_changes_utils_1.isRejectedInsert)(footnotesElement)) {
195
- const { state, dispatch } = this.view;
196
- (0, commands_1.insertTableFootnote)(this.node, this.getPos(), state, dispatch);
191
+ var _a;
192
+ const footnotesElementWithPos = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.footnotes_element).pop();
193
+ if (!footnotesElementWithPos ||
194
+ (0, track_changes_utils_1.isDeleted)(footnotesElementWithPos.node) ||
195
+ (0, track_changes_utils_1.isRejectedInsert)(footnotesElementWithPos.node)) {
196
+ (0, commands_1.insertTableFootnote)(this.node, this.getPos(), this.view);
197
197
  }
198
198
  else {
199
- const footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElement, transform_1.schema.nodes.footnote).map((nodeWithPos) => {
200
- return nodeWithPos.node;
201
- });
199
+ const tablesFootnoteLabels = (0, footnotes_utils_1.buildTableFootnoteLabels)(this.node);
200
+ const footnotesWithPos = (0, prosemirror_utils_1.findChildrenByType)(footnotesElementWithPos.node, transform_1.schema.nodes.footnote);
201
+ const footnotes = footnotesWithPos.map((nodeWithPos) => ({
202
+ node: nodeWithPos.node,
203
+ index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
204
+ }));
202
205
  const targetDom = this.view.domAtPos(this.view.state.selection.from);
203
206
  if (targetDom.node instanceof Element && this.props) {
204
207
  const popperContainer = (0, ReactSubView_1.default)(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), style_guide_1.TableFootnotesSelector, {
205
208
  notes: footnotes,
206
209
  onAdd: () => {
207
210
  var _a;
208
- const { state, dispatch } = this.view;
209
- (0, commands_1.insertTableFootnote)(this.node, this.getPos(), state, dispatch);
211
+ (0, commands_1.insertTableFootnote)(this.node, this.getPos(), this.view);
210
212
  (_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
211
213
  },
212
214
  onInsert: (notes) => {
213
215
  var _a;
214
216
  const insertedAt = this.view.state.selection.to;
217
+ let inlineFootnoteIndex = 1;
218
+ this.view.state.doc
219
+ .slice(this.getPos(), insertedAt)
220
+ .content.descendants((node) => {
221
+ if (node.type === transform_1.schema.nodes.inline_footnote) {
222
+ inlineFootnoteIndex++;
223
+ return false;
224
+ }
225
+ });
215
226
  const node = this.view.state.schema.nodes.inline_footnote.create({
216
- rids: notes.map((note) => note.attrs.id),
227
+ rids: notes.map(({ node }) => node.attrs.id),
217
228
  contents: notes
218
- .map((note) => footnotes.indexOf(note) + 1)
229
+ .map(({ index }) => index ? index : inlineFootnoteIndex)
219
230
  .join(),
220
231
  });
221
232
  const tr = this.view.state.tr;
@@ -228,7 +239,7 @@ class ContextMenu {
228
239
  (_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
229
240
  },
230
241
  }, this.node, this.getPos, this.view, 'table-footnote-editor');
231
- (_b = this.props) === null || _b === void 0 ? void 0 : _b.popper.show(targetDom.node, popperContainer, 'bottom-end');
242
+ (_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.show(targetDom.node, popperContainer, 'bottom-end');
232
243
  }
233
244
  }
234
245
  }));
package/dist/cjs/menus.js CHANGED
@@ -19,10 +19,8 @@ exports.getEditorMenus = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
20
  const prosemirror_commands_1 = require("prosemirror-commands");
21
21
  const prosemirror_history_1 = require("prosemirror-history");
22
- const prosemirror_schema_list_1 = require("prosemirror-schema-list");
23
22
  const prosemirror_tables_1 = require("prosemirror-tables");
24
23
  const commands_1 = require("./commands");
25
- const list_1 = require("./keys/list");
26
24
  const hierarchy_1 = require("./lib/hierarchy");
27
25
  const getEditorMenus = (editor) => {
28
26
  const { isCommandValid, state } = editor;
@@ -109,29 +107,6 @@ const getEditorMenus = (editor) => {
109
107
  {
110
108
  role: 'separator',
111
109
  },
112
- {
113
- id: 'insert-ordered-list',
114
- label: 'Numbered List',
115
- shortcut: {
116
- mac: 'Option+CommandOrControl+O',
117
- pc: 'CommandOrControl+Option+O',
118
- },
119
- isEnabled: isCommandValid((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.ordered_list)),
120
- run: doCommand((0, list_1.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.ordered_list))),
121
- },
122
- {
123
- id: 'insert-bullet-list',
124
- label: 'Bullet List',
125
- shortcut: {
126
- mac: 'Option+CommandOrControl+K',
127
- pc: 'CommandOrControl+Option+K',
128
- },
129
- isEnabled: isCommandValid((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.bullet_list)),
130
- run: doCommand((0, list_1.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.bullet_list))),
131
- },
132
- {
133
- role: 'separator',
134
- },
135
110
  {
136
111
  id: 'insert-blockquote',
137
112
  label: 'Block Quote',
@@ -322,6 +297,44 @@ const getEditorMenus = (editor) => {
322
297
  {
323
298
  role: 'separator',
324
299
  },
300
+ {
301
+ id: 'insert-bullet-list',
302
+ label: 'Bullet List',
303
+ isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.bullet_list)),
304
+ submenu: [
305
+ {
306
+ id: 'bullet-list-context-menu',
307
+ label: '',
308
+ isEnabled: true,
309
+ options: {
310
+ bullet: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet')),
311
+ simple: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'simple')),
312
+ },
313
+ },
314
+ ],
315
+ },
316
+ {
317
+ id: 'insert-ordered-list',
318
+ label: 'Ordered List',
319
+ isEnabled: isCommandValid((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list)),
320
+ submenu: [
321
+ {
322
+ id: 'ordered-list-context-menu',
323
+ label: '',
324
+ isEnabled: true,
325
+ options: {
326
+ order: doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'order')),
327
+ 'alpha-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-upper')),
328
+ 'alpha-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'alpha-lower')),
329
+ 'roman-upper': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-upper')),
330
+ 'roman-lower': doCommand((0, commands_1.insertList)(transform_1.schema.nodes.ordered_list, 'roman-lower')),
331
+ },
332
+ },
333
+ ],
334
+ },
335
+ {
336
+ role: 'separator',
337
+ },
325
338
  {
326
339
  id: 'format-table',
327
340
  label: 'Table',
@@ -15,8 +15,10 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.findTableInlineFootnoteIds = void 0;
18
+ exports.updateTableInlineFootnoteLabels = exports.orderTableFootnotes = exports.buildTableFootnoteLabels = exports.getNewFootnotePos = exports.findTableInlineFootnoteIds = void 0;
19
+ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
19
20
  const transform_1 = require("@manuscripts/transform");
21
+ const prosemirror_model_1 = require("prosemirror-model");
20
22
  const prosemirror_utils_1 = require("prosemirror-utils");
21
23
  const findTableInlineFootnoteIds = ($pos) => {
22
24
  var _a;
@@ -28,3 +30,67 @@ const findTableInlineFootnoteIds = ($pos) => {
28
30
  : []);
29
31
  };
30
32
  exports.findTableInlineFootnoteIds = findTableInlineFootnoteIds;
33
+ const getNewFootnotePos = (footnotesElement, footnoteIndex) => {
34
+ let newFootnotePos = footnotesElement.pos + footnotesElement.node.nodeSize - 1;
35
+ footnotesElement.node.descendants((node, pos, parent, index) => {
36
+ if ((0, transform_1.isFootnoteNode)(node)) {
37
+ if (footnoteIndex === ++index) {
38
+ newFootnotePos = footnotesElement.pos + pos + (index === 1 ? 2 : 1);
39
+ }
40
+ }
41
+ });
42
+ return newFootnotePos;
43
+ };
44
+ exports.getNewFootnotePos = getNewFootnotePos;
45
+ const buildTableFootnoteLabels = (node) => {
46
+ const labels = new Map((0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.footnote).map((node) => [
47
+ node.node.attrs.id,
48
+ undefined,
49
+ ]));
50
+ let index = 0;
51
+ (0, prosemirror_utils_1.findChildrenByType)(node, transform_1.schema.nodes.inline_footnote)
52
+ .map(({ node }) => node.attrs.rids)
53
+ .flat()
54
+ .map((rid) => {
55
+ if (!labels.get(rid)) {
56
+ labels.set(rid, String(++index));
57
+ }
58
+ });
59
+ return labels;
60
+ };
61
+ exports.buildTableFootnoteLabels = buildTableFootnoteLabels;
62
+ const orderTableFootnotes = (tr, footnotesElementWithPos, position) => {
63
+ const tablesFootnoteLabels = (0, exports.buildTableFootnoteLabels)(tr.doc.nodeAt(tr.mapping.map(position)));
64
+ const footnotes = (0, prosemirror_utils_1.findChildrenByType)(footnotesElementWithPos.node, transform_1.schema.nodes.footnote).map((nodeWithPos) => ({
65
+ node: nodeWithPos.node,
66
+ index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
67
+ }));
68
+ const orderedFootnotes = [...footnotes]
69
+ .sort((a, b) => {
70
+ if (a.index !== undefined && b.index !== undefined) {
71
+ return Number.parseInt(a.index) - Number.parseInt(b.index);
72
+ }
73
+ else {
74
+ return a.index === undefined ? 1 : -1;
75
+ }
76
+ })
77
+ .map(({ node }) => node);
78
+ const { node: footnotesElement, pos } = footnotesElementWithPos;
79
+ const footnoteElementPos = position + pos;
80
+ return (0, track_changes_plugin_1.skipTracking)(tr.replaceWith(tr.mapping.map(footnoteElementPos), tr.mapping.map(footnoteElementPos + footnotesElement.nodeSize), prosemirror_model_1.Fragment.fromArray(orderedFootnotes)));
81
+ };
82
+ exports.orderTableFootnotes = orderTableFootnotes;
83
+ const updateTableInlineFootnoteLabels = (tr, table) => {
84
+ const labels = (0, exports.buildTableFootnoteLabels)(table.node);
85
+ (0, prosemirror_utils_1.findChildrenByType)(table.node, transform_1.schema.nodes.inline_footnote).map(({ node, pos }) => {
86
+ const contents = node.attrs.rids
87
+ .map((rid) => labels.get(rid))
88
+ .join(',');
89
+ if (contents !== node.attrs.contents &&
90
+ tr.doc.nodeAt(tr.mapping.map(table.pos + pos + 1))) {
91
+ tr.setNodeMarkup(tr.mapping.map(table.pos + pos + 1), undefined, Object.assign(Object.assign({}, node.attrs), { rids: node.attrs.rids, contents }));
92
+ }
93
+ });
94
+ return tr;
95
+ };
96
+ exports.updateTableInlineFootnoteLabels = updateTableInlineFootnoteLabels;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const transform_1 = require("@manuscripts/transform");
4
+ const prosemirror_state_1 = require("prosemirror-state");
5
+ const prosemirror_transform_1 = require("prosemirror-transform");
6
+ const prosemirror_utils_1 = require("prosemirror-utils");
7
+ const footnotes_utils_1 = require("./footnotes/footnotes-utils");
8
+ const isInlineFootnoteChange = (step, oldState, newState) => {
9
+ var _a, _b;
10
+ return step.slice.size > 0
11
+ ? ((_a = newState.doc.nodeAt(step.from)) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.inline_footnote
12
+ : ((_b = oldState.doc.nodeAt(step.from)) === null || _b === void 0 ? void 0 : _b.type) === transform_1.schema.nodes.inline_footnote;
13
+ };
14
+ exports.default = () => {
15
+ return new prosemirror_state_1.Plugin({
16
+ appendTransaction(transactions, oldState, newState) {
17
+ const tableInlineFootnoteChange = transactions.find((tr) => tr.steps.find((s) => {
18
+ var _a;
19
+ if (s instanceof prosemirror_transform_1.ReplaceStep) {
20
+ const step = s;
21
+ const $pos = oldState.doc.resolve(step.from);
22
+ return (((_a = $pos.node($pos.depth - 2)) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.table &&
23
+ isInlineFootnoteChange(step, oldState, newState));
24
+ }
25
+ }));
26
+ if (!tableInlineFootnoteChange) {
27
+ return null;
28
+ }
29
+ const step = tableInlineFootnoteChange.steps[0];
30
+ const tr = newState.tr;
31
+ const $pos = newState.doc.resolve(step.from);
32
+ const table = (0, prosemirror_utils_1.findParentNodeClosestToPos)($pos, (node) => node.type === transform_1.schema.nodes.table_element);
33
+ const footnotesElementWithPos = table &&
34
+ (0, prosemirror_utils_1.findChildrenByType)(table.node, transform_1.schema.nodes.footnotes_element).pop();
35
+ if (!table || !footnotesElementWithPos) {
36
+ return null;
37
+ }
38
+ (0, footnotes_utils_1.updateTableInlineFootnoteLabels)(tr, table);
39
+ (0, footnotes_utils_1.orderTableFootnotes)(tr, footnotesElementWithPos, tr.mapping.map(table.pos));
40
+ return tr;
41
+ },
42
+ });
43
+ };
@@ -68,8 +68,12 @@ exports.toolbar = {
68
68
  title: 'Wrap in bullet list',
69
69
  content: icons_1.default.bullet_list,
70
70
  isActive: (0, commands_1.blockActive)(transform_1.schema.nodes.bullet_list),
71
- isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list),
72
- run: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list),
71
+ isEnabled: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
72
+ run: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
73
+ options: {
74
+ bullet: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'bullet'),
75
+ simple: (0, commands_1.insertList)(transform_1.schema.nodes.bullet_list, 'simple'),
76
+ },
73
77
  },
74
78
  ordered_list: {
75
79
  title: 'Wrap in ordered list',
@@ -21,15 +21,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.bulletListCallback = exports.BulletListView = void 0;
22
22
  const block_view_1 = __importDefault(require("./block_view"));
23
23
  const creators_1 = require("./creators");
24
+ const ordered_list_1 = require("./ordered_list");
24
25
  class BulletListView extends block_view_1.default {
25
26
  constructor() {
26
27
  super(...arguments);
27
28
  this.elementType = 'ul';
29
+ this.updateContents = () => {
30
+ if (this.contentDOM) {
31
+ const type = this.node.attrs.listStyleType || 'bullet';
32
+ this.contentDOM.style.listStyleType = ordered_list_1.JATS_HTML_LIST_STYLE_MAPPING[type];
33
+ }
34
+ };
28
35
  }
29
36
  }
30
37
  exports.BulletListView = BulletListView;
31
38
  const bulletListCallback = (node, dom) => {
32
39
  dom.classList.add('list');
40
+ const type = node.attrs.listStyleType || 'bullet';
41
+ dom.style.listStyleType = ordered_list_1.JATS_HTML_LIST_STYLE_MAPPING[type];
33
42
  };
34
43
  exports.bulletListCallback = bulletListCallback;
35
44
  exports.default = (0, creators_1.createNodeOrElementView)(BulletListView, 'ul', exports.bulletListCallback);
@@ -74,6 +74,7 @@ class CitationEditableView extends citation_1.CitationView {
74
74
  this.props.popper.destroy();
75
75
  };
76
76
  this.showContextMenu = () => {
77
+ this.props.popper.destroy();
77
78
  const componentProps = {
78
79
  actions: [
79
80
  { label: 'Edit', action: this.handleEdit, icon: 'EditIcon' },
@@ -20,7 +20,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.ContributorsView = void 0;
22
22
  const style_guide_1 = require("@manuscripts/style-guide");
23
+ const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
23
24
  const transform_1 = require("@manuscripts/transform");
25
+ const prosemirror_state_1 = require("prosemirror-state");
24
26
  const AuthorsModal_1 = require("../components/authors/AuthorsModal");
25
27
  const authors_1 = require("../lib/authors");
26
28
  const track_changes_utils_1 = require("../lib/track-changes-utils");
@@ -79,7 +81,9 @@ class ContributorsView extends block_view_1.default {
79
81
  const pluginState = affiliations_1.affiliationsKey.getState(this.view.state);
80
82
  const attrs = node.attrs;
81
83
  const displayAttr = (0, track_changes_utils_1.getActualAttrs)(node);
84
+ const containerWrapper = document.createElement('div');
82
85
  const container = document.createElement('button');
86
+ containerWrapper.classList.add('contributor-wrapper');
83
87
  container.classList.add('contributor');
84
88
  container.setAttribute('id', attrs.id);
85
89
  container.setAttribute('contenteditable', 'false');
@@ -95,9 +99,12 @@ class ContributorsView extends block_view_1.default {
95
99
  }
96
100
  const can = this.props.getCapabilities();
97
101
  const disableEditButton = !can.editMetadata;
98
- const { isCorresponding, email } = displayAttr;
102
+ const { isCorresponding, email, id } = displayAttr;
99
103
  if (!disableEditButton) {
100
- container.addEventListener('click', this.handleClick);
104
+ container.addEventListener('click', () => {
105
+ const dataTracked = attrs.dataTracked;
106
+ this.onClickHandler(id, dataTracked ? dataTracked[0] : undefined);
107
+ });
101
108
  }
102
109
  const name = (0, authors_1.authorLabel)(displayAttr);
103
110
  container.innerHTML =
@@ -125,7 +132,8 @@ class ContributorsView extends block_view_1.default {
125
132
  if (selectedAuthor && selectedAuthor === attrs.id) {
126
133
  container.classList.add('selected-suggestion');
127
134
  }
128
- return container;
135
+ containerWrapper.appendChild(container);
136
+ return containerWrapper;
129
137
  };
130
138
  this.isJointFirstAuthor = (authors, index) => {
131
139
  const author = index === 0 ? authors[index] : authors[index - 1];
@@ -143,11 +151,14 @@ class ContributorsView extends block_view_1.default {
143
151
  this.dom = document.createElement('div');
144
152
  this.dom.classList.add('block-container', `block-${this.node.type.name}`);
145
153
  };
154
+ this.deselectNode = () => {
155
+ this.props.popper.destroy();
156
+ };
146
157
  this.createEditButton = () => {
147
158
  const can = this.props.getCapabilities();
148
159
  const button = (0, ReactSubView_1.default)(this.props, style_guide_1.SecondaryButton, {
149
160
  mini: true,
150
- onClick: this.handleClick,
161
+ onClick: () => this.handleEdit(''),
151
162
  className: 'edit-authors-button',
152
163
  disabled: !can.editMetadata,
153
164
  children: 'Edit Authors',
@@ -167,17 +178,45 @@ class ContributorsView extends block_view_1.default {
167
178
  }
168
179
  }
169
180
  };
170
- this.handleClick = (e) => {
171
- var _a, _b;
172
- e.stopPropagation();
181
+ this.onClickHandler = (elementId, dataTracked) => {
182
+ var _a;
183
+ this.props.popper.destroy();
184
+ const isSelectedSuggestion = !!((_a = selected_suggestion_ui_1.selectedSuggestionKey
185
+ .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
186
+ const { tr } = this.view.state;
187
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(this.view.state.doc, this.getPos()));
188
+ if (dataTracked && dataTracked.status !== track_changes_plugin_1.CHANGE_STATUS.rejected) {
189
+ tr.setMeta(selected_suggestion_ui_1.SET_SUGGESTION_ID, dataTracked.id);
190
+ }
191
+ else {
192
+ if (isSelectedSuggestion) {
193
+ tr.setMeta(selected_suggestion_ui_1.CLEAR_SUGGESTION_ID, true);
194
+ }
195
+ }
196
+ this.view.dispatch(tr);
197
+ this.showContextMenu(elementId);
198
+ };
199
+ this.showContextMenu = (elementId) => {
200
+ this.props.popper.destroy();
201
+ const element = document.getElementById(elementId);
202
+ const componentProps = {
203
+ actions: [
204
+ {
205
+ label: 'Edit',
206
+ action: () => this.handleEdit(elementId),
207
+ icon: 'EditIcon',
208
+ },
209
+ ],
210
+ };
211
+ this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
212
+ this.props.popper.show(element, this.contextMenu, 'right-start');
213
+ };
214
+ this.handleEdit = (id) => {
215
+ var _a;
216
+ this.props.popper.destroy();
173
217
  const contributors = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.contributor);
174
218
  const affiliations = (0, view_1.findChildrenAttrsByType)(this.view, transform_1.schema.nodes.affiliation);
175
- let author = undefined;
176
- const target = e.target;
177
- if (target) {
178
- const id = (_a = target.closest('.contributor')) === null || _a === void 0 ? void 0 : _a.getAttribute('id');
179
- author = contributors.filter((a) => a.id === id)[0];
180
- }
219
+ const author = id ? contributors.filter((a) => a.id === id)[0] : undefined;
181
220
  const componentProps = {
182
221
  author,
183
222
  authors: contributors,
@@ -186,7 +225,7 @@ class ContributorsView extends block_view_1.default {
186
225
  onDeleteAuthor: this.handleDeleteAuthor,
187
226
  onSaveAffiliation: this.handleSaveAffiliation,
188
227
  };
189
- (_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
228
+ (_a = this.popper) === null || _a === void 0 ? void 0 : _a.remove();
190
229
  this.popper = (0, ReactSubView_1.default)(this.props, AuthorsModal_1.AuthorsModal, componentProps, this.node, this.getPos, this.view);
191
230
  this.container.appendChild(this.popper);
192
231
  };
@@ -22,6 +22,7 @@ exports.orderedListCallback = exports.OrderedListView = exports.JATS_HTML_LIST_S
22
22
  const block_view_1 = __importDefault(require("./block_view"));
23
23
  const creators_1 = require("./creators");
24
24
  exports.JATS_HTML_LIST_STYLE_MAPPING = {
25
+ simple: 'none',
25
26
  bullet: 'disc',
26
27
  order: 'decimal',
27
28
  'alpha-lower': 'lower-alpha',