@manuscripts/body-editor 1.7.26 → 1.7.28-LEAN-3418

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 (34) hide show
  1. package/dist/cjs/commands.js +21 -19
  2. package/dist/cjs/components/views/FigureDropdown.js +1 -1
  3. package/dist/cjs/configs/editor-plugins.js +2 -0
  4. package/dist/cjs/lib/context-menu.js +26 -15
  5. package/dist/cjs/menus.js +38 -25
  6. package/dist/cjs/plugins/footnotes/footnotes-utils.js +67 -1
  7. package/dist/cjs/plugins/table-footnote.js +43 -0
  8. package/dist/cjs/toolbar.js +6 -2
  9. package/dist/cjs/views/bullet_list.js +9 -0
  10. package/dist/cjs/views/citation_editable.js +1 -0
  11. package/dist/cjs/views/contributors.js +53 -14
  12. package/dist/cjs/views/link_editable.js +1 -5
  13. package/dist/cjs/views/ordered_list.js +1 -0
  14. package/dist/es/commands.js +21 -19
  15. package/dist/es/components/views/FigureDropdown.js +1 -1
  16. package/dist/es/configs/editor-plugins.js +2 -0
  17. package/dist/es/lib/context-menu.js +27 -16
  18. package/dist/es/menus.js +39 -26
  19. package/dist/es/plugins/footnotes/footnotes-utils.js +64 -2
  20. package/dist/es/plugins/table-footnote.js +41 -0
  21. package/dist/es/toolbar.js +6 -2
  22. package/dist/es/views/bullet_list.js +9 -0
  23. package/dist/es/views/citation_editable.js +1 -0
  24. package/dist/es/views/contributors.js +55 -16
  25. package/dist/es/views/link_editable.js +1 -5
  26. package/dist/es/views/ordered_list.js +1 -0
  27. package/dist/types/commands.d.ts +2 -1
  28. package/dist/types/plugins/footnotes/footnotes-utils.d.ts +7 -0
  29. package/dist/types/plugins/table-footnote.d.ts +3 -0
  30. package/dist/types/views/bullet_list.d.ts +1 -0
  31. package/dist/types/views/contributors.d.ts +6 -2
  32. package/dist/types/views/ordered_list.d.ts +1 -1
  33. package/package.json +6 -6
  34. package/styles/AdvancedEditor.css +30 -21
@@ -26,6 +26,7 @@ import { isNodeOfType, nearestAncestor } from './lib/helpers';
26
26
  import { isDeleted, isRejectedInsert } from './lib/track-changes-utils';
27
27
  import { findParentNodeWithId, getChildOfType } from './lib/utils';
28
28
  import { commentAnnotation } from './plugins/comment_annotation';
29
+ import { getNewFootnotePos } from './plugins/footnotes/footnotes-utils';
29
30
  import { highlightKey, SET_COMMENT } from './plugins/highlight';
30
31
  export const markActive = (type) => (state) => {
31
32
  const { from, $from, to, empty } = state.selection;
@@ -689,37 +690,38 @@ export const updateCommentAnnotationState = (state, dispatch) => {
689
690
  dispatch(tr);
690
691
  }
691
692
  };
692
- export const insertTableFootnote = (node, position, state, dispatch) => {
693
+ export const insertTableFootnote = (node, position, view) => {
693
694
  var _a;
695
+ const { state, dispatch } = view;
694
696
  const footnote = state.schema.nodes.footnote.createAndFill({
695
697
  id: generateID(ObjectTypes.Footnote),
696
698
  kind: 'footnote',
697
699
  });
698
700
  const insertedAt = state.selection.to;
699
701
  const inlineFootnotes = findChildrenByType(node, schema.nodes.inline_footnote);
700
- const labels = inlineFootnotes.map((nodeWithPos) => nodeWithPos.node.attrs.contents);
702
+ const footnoteIndex = inlineFootnotes.filter(({ pos }) => position + pos <= insertedAt).length + 1;
701
703
  const inlineFootnoteNode = state.schema.nodes.inline_footnote.create({
702
704
  rids: [footnote.attrs.id],
703
- contents: labels.length ? Math.max(...labels) + 1 : 1,
705
+ contents: footnoteIndex === -1 ? inlineFootnotes.length : footnoteIndex,
704
706
  });
705
707
  const tr = state.tr;
706
708
  tr.insert(insertedAt, inlineFootnoteNode);
707
- let insertionPos;
709
+ let insertionPos = position;
708
710
  const footnotesElement = findChildrenByType(node, schema.nodes.footnotes_element).pop();
709
711
  if (footnotesElement &&
710
712
  !isDeleted(footnotesElement.node) &&
711
713
  !isRejectedInsert(footnotesElement.node)) {
712
- const pos = footnotesElement.pos;
713
- insertionPos = position + pos + footnotesElement.node.nodeSize + 1;
714
+ const footnotePos = getNewFootnotePos(footnotesElement, footnoteIndex);
715
+ insertionPos = tr.mapping.map(position + footnotePos);
714
716
  tr.insert(insertionPos, footnote);
715
717
  }
716
718
  else {
717
719
  const footnoteElement = state.schema.nodes.footnotes_element.create({}, footnote);
718
- const tableElementFooter = findChildrenByType(node, schema.nodes.table_element_footer);
719
- if (tableElementFooter.length) {
720
- const pos = tableElementFooter[0].pos;
721
- insertionPos = position + pos + tableElementFooter[0].node.nodeSize + 1;
722
- tr.insert(insertionPos, footnoteElement);
720
+ const tableElementFooter = findChildrenByType(node, schema.nodes.table_element_footer)[0];
721
+ if (tableElementFooter) {
722
+ const pos = tableElementFooter.pos;
723
+ insertionPos = position + pos + tableElementFooter.node.nodeSize;
724
+ tr.insert(tr.mapping.map(insertionPos), footnoteElement);
723
725
  }
724
726
  else {
725
727
  const tableElementFooter = schema.nodes.table_element_footer.create({
@@ -728,20 +730,20 @@ export const insertTableFootnote = (node, position, state, dispatch) => {
728
730
  const tableColGroup = findChildrenByType(node, schema.nodes.table_colgroup)[0];
729
731
  if (tableColGroup) {
730
732
  insertionPos =
731
- position + tableColGroup.pos + tableColGroup.node.nodeSize + 2;
732
- tr.insert(insertionPos, tableElementFooter);
733
+ position + tableColGroup.pos + tableColGroup.node.nodeSize;
734
+ tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
733
735
  }
734
736
  else {
735
737
  const tableSize = (_a = node.content.firstChild) === null || _a === void 0 ? void 0 : _a.nodeSize;
736
738
  if (tableSize) {
737
- insertionPos = position + tableSize + 2;
738
- tr.insert(insertionPos, tableElementFooter);
739
+ insertionPos = position + tableSize;
740
+ tr.insert(tr.mapping.map(insertionPos), tableElementFooter);
739
741
  }
740
742
  }
741
743
  }
742
744
  }
743
- if (dispatch && insertionPos) {
744
- const nodeSelection = NodeSelection.create(tr.doc, insertionPos);
745
- dispatch(tr.setSelection(nodeSelection));
746
- }
745
+ dispatch(tr);
746
+ const textSelection = TextSelection.near(view.state.tr.doc.resolve(insertionPos + 1));
747
+ view.focus();
748
+ dispatch(view.state.tr.setSelection(textSelection).scrollIntoView());
747
749
  };
@@ -52,7 +52,7 @@ const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft
52
52
  " ",
53
53
  React.createElement(TriangleCollapsed, null)),
54
54
  isOpen && (React.createElement(NestedListDropdownList, { direction: 'right', moveLeft: moveLeft, width: 192, onClick: (e) => {
55
- toggleOpen(e);
55
+ toggleOpen();
56
56
  parentToggleOpen(e);
57
57
  } }, list))));
58
58
  };
@@ -33,6 +33,7 @@ import persist from '../plugins/persist';
33
33
  import placeholder from '../plugins/placeholder';
34
34
  import sections from '../plugins/sections';
35
35
  import selected_suggestion_ui from '../plugins/selected-suggestion-ui';
36
+ import table_footnote from '../plugins/table-footnote';
36
37
  import table_editing_fix from '../plugins/tables-cursor-fix';
37
38
  import toc from '../plugins/toc';
38
39
  import rules from '../rules';
@@ -64,6 +65,7 @@ export default (props) => {
64
65
  highlights(props),
65
66
  selected_suggestion_ui(props),
66
67
  footnotes(),
68
+ table_footnote(),
67
69
  ];
68
70
  if (props.collabProvider) {
69
71
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
@@ -13,10 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { TableFootnotesSelector } from '@manuscripts/style-guide';
16
+ import { TableFootnotesSelector, } from '@manuscripts/style-guide';
17
17
  import { isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
18
18
  import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
19
19
  import { addComment, createBlock, insertGeneralFootnote, insertTableFootnote, } from '../commands';
20
+ import { buildTableFootnoteLabels } from '../plugins/footnotes/footnotes-utils';
20
21
  import ReactSubView from '../views/ReactSubView';
21
22
  import { PopperManager } from './popper';
22
23
  import { isDeleted, isRejectedInsert } from './track-changes-utils';
@@ -180,35 +181,45 @@ export class ContextMenu {
180
181
  if (isInTable) {
181
182
  menu.appendChild(this.createMenuSection((section) => {
182
183
  section.appendChild(this.createMenuItem('Add Reference Note', () => {
183
- var _a, _b;
184
- const footnotesElement = (_a = findChildrenByType(this.node, schema.nodes.footnotes_element).pop()) === null || _a === void 0 ? void 0 : _a.node;
185
- if (!footnotesElement ||
186
- isDeleted(footnotesElement) ||
187
- isRejectedInsert(footnotesElement)) {
188
- const { state, dispatch } = this.view;
189
- insertTableFootnote(this.node, this.getPos(), state, dispatch);
184
+ var _a;
185
+ const footnotesElementWithPos = findChildrenByType(this.node, schema.nodes.footnotes_element).pop();
186
+ if (!footnotesElementWithPos ||
187
+ isDeleted(footnotesElementWithPos.node) ||
188
+ isRejectedInsert(footnotesElementWithPos.node)) {
189
+ insertTableFootnote(this.node, this.getPos(), this.view);
190
190
  }
191
191
  else {
192
- const footnotes = findChildrenByType(footnotesElement, schema.nodes.footnote).map((nodeWithPos) => {
193
- return nodeWithPos.node;
194
- });
192
+ const tablesFootnoteLabels = buildTableFootnoteLabels(this.node);
193
+ const footnotesWithPos = findChildrenByType(footnotesElementWithPos.node, schema.nodes.footnote);
194
+ const footnotes = footnotesWithPos.map((nodeWithPos) => ({
195
+ node: nodeWithPos.node,
196
+ index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
197
+ }));
195
198
  const targetDom = this.view.domAtPos(this.view.state.selection.from);
196
199
  if (targetDom.node instanceof Element && this.props) {
197
200
  const popperContainer = ReactSubView(Object.assign(Object.assign({}, this.props), { dispatch: this.view.dispatch }), TableFootnotesSelector, {
198
201
  notes: footnotes,
199
202
  onAdd: () => {
200
203
  var _a;
201
- const { state, dispatch } = this.view;
202
- insertTableFootnote(this.node, this.getPos(), state, dispatch);
204
+ insertTableFootnote(this.node, this.getPos(), this.view);
203
205
  (_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
204
206
  },
205
207
  onInsert: (notes) => {
206
208
  var _a;
207
209
  const insertedAt = this.view.state.selection.to;
210
+ let inlineFootnoteIndex = 1;
211
+ this.view.state.doc
212
+ .slice(this.getPos(), insertedAt)
213
+ .content.descendants((node) => {
214
+ if (node.type === schema.nodes.inline_footnote) {
215
+ inlineFootnoteIndex++;
216
+ return false;
217
+ }
218
+ });
208
219
  const node = this.view.state.schema.nodes.inline_footnote.create({
209
- rids: notes.map((note) => note.attrs.id),
220
+ rids: notes.map(({ node }) => node.attrs.id),
210
221
  contents: notes
211
- .map((note) => footnotes.indexOf(note) + 1)
222
+ .map(({ index }) => index ? index : inlineFootnoteIndex)
212
223
  .join(),
213
224
  });
214
225
  const tr = this.view.state.tr;
@@ -221,7 +232,7 @@ export class ContextMenu {
221
232
  (_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.destroy();
222
233
  },
223
234
  }, this.node, this.getPos, this.view, 'table-footnote-editor');
224
- (_b = this.props) === null || _b === void 0 ? void 0 : _b.popper.show(targetDom.node, popperContainer, 'bottom-end');
235
+ (_a = this.props) === null || _a === void 0 ? void 0 : _a.popper.show(targetDom.node, popperContainer, 'bottom-end');
225
236
  }
226
237
  }
227
238
  }));
package/dist/es/menus.js CHANGED
@@ -16,10 +16,8 @@
16
16
  import { schema } from '@manuscripts/transform';
17
17
  import { toggleMark } from 'prosemirror-commands';
18
18
  import { redo, undo } from 'prosemirror-history';
19
- import { wrapInList } from 'prosemirror-schema-list';
20
19
  import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, } from 'prosemirror-tables';
21
- import { addComment, blockActive, canInsert, ifInTableBody, insertBlock, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertLink, insertSection, markActive, } from './commands';
22
- import { skipCommandTracking } from './keys/list';
20
+ import { addComment, blockActive, canInsert, ifInTableBody, insertBlock, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertLink, insertList, insertSection, markActive, } from './commands';
23
21
  import { deleteClosestParentElement, findClosestParentElementNodeName, } from './lib/hierarchy';
24
22
  export const getEditorMenus = (editor) => {
25
23
  const { isCommandValid, state } = editor;
@@ -106,29 +104,6 @@ export const getEditorMenus = (editor) => {
106
104
  {
107
105
  role: 'separator',
108
106
  },
109
- {
110
- id: 'insert-ordered-list',
111
- label: 'Numbered List',
112
- shortcut: {
113
- mac: 'Option+CommandOrControl+O',
114
- pc: 'CommandOrControl+Option+O',
115
- },
116
- isEnabled: isCommandValid(wrapInList(schema.nodes.ordered_list)),
117
- run: doCommand(skipCommandTracking(wrapInList(schema.nodes.ordered_list))),
118
- },
119
- {
120
- id: 'insert-bullet-list',
121
- label: 'Bullet List',
122
- shortcut: {
123
- mac: 'Option+CommandOrControl+K',
124
- pc: 'CommandOrControl+Option+K',
125
- },
126
- isEnabled: isCommandValid(wrapInList(schema.nodes.bullet_list)),
127
- run: doCommand(skipCommandTracking(wrapInList(schema.nodes.bullet_list))),
128
- },
129
- {
130
- role: 'separator',
131
- },
132
107
  {
133
108
  id: 'insert-blockquote',
134
109
  label: 'Block Quote',
@@ -319,6 +294,44 @@ export const getEditorMenus = (editor) => {
319
294
  {
320
295
  role: 'separator',
321
296
  },
297
+ {
298
+ id: 'insert-bullet-list',
299
+ label: 'Bullet List',
300
+ isEnabled: isCommandValid(insertList(schema.nodes.bullet_list)),
301
+ submenu: [
302
+ {
303
+ id: 'bullet-list-context-menu',
304
+ label: '',
305
+ isEnabled: true,
306
+ options: {
307
+ bullet: doCommand(insertList(schema.nodes.bullet_list, 'bullet')),
308
+ simple: doCommand(insertList(schema.nodes.bullet_list, 'simple')),
309
+ },
310
+ },
311
+ ],
312
+ },
313
+ {
314
+ id: 'insert-ordered-list',
315
+ label: 'Ordered List',
316
+ isEnabled: isCommandValid(insertList(schema.nodes.ordered_list)),
317
+ submenu: [
318
+ {
319
+ id: 'ordered-list-context-menu',
320
+ label: '',
321
+ isEnabled: true,
322
+ options: {
323
+ order: doCommand(insertList(schema.nodes.ordered_list, 'order')),
324
+ 'alpha-upper': doCommand(insertList(schema.nodes.ordered_list, 'alpha-upper')),
325
+ 'alpha-lower': doCommand(insertList(schema.nodes.ordered_list, 'alpha-lower')),
326
+ 'roman-upper': doCommand(insertList(schema.nodes.ordered_list, 'roman-upper')),
327
+ 'roman-lower': doCommand(insertList(schema.nodes.ordered_list, 'roman-lower')),
328
+ },
329
+ },
330
+ ],
331
+ },
332
+ {
333
+ role: 'separator',
334
+ },
322
335
  {
323
336
  id: 'format-table',
324
337
  label: 'Table',
@@ -13,8 +13,10 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { schema } from '@manuscripts/transform';
17
- import { findChildren, findParentNodeClosestToPos } from 'prosemirror-utils';
16
+ import { skipTracking } from '@manuscripts/track-changes-plugin';
17
+ import { isFootnoteNode, schema, } from '@manuscripts/transform';
18
+ import { Fragment } from 'prosemirror-model';
19
+ import { findChildren, findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
18
20
  export const findTableInlineFootnoteIds = ($pos) => {
19
21
  var _a;
20
22
  const tableElement = (_a = findParentNodeClosestToPos($pos, (node) => node.type === schema.nodes.table_element)) === null || _a === void 0 ? void 0 : _a.node.firstChild;
@@ -24,3 +26,63 @@ export const findTableInlineFootnoteIds = ($pos) => {
24
26
  .flat()
25
27
  : []);
26
28
  };
29
+ export const getNewFootnotePos = (footnotesElement, footnoteIndex) => {
30
+ let newFootnotePos = footnotesElement.pos + footnotesElement.node.nodeSize - 1;
31
+ footnotesElement.node.descendants((node, pos, parent, index) => {
32
+ if (isFootnoteNode(node)) {
33
+ if (footnoteIndex === ++index) {
34
+ newFootnotePos = footnotesElement.pos + pos + (index === 1 ? 2 : 1);
35
+ }
36
+ }
37
+ });
38
+ return newFootnotePos;
39
+ };
40
+ export const buildTableFootnoteLabels = (node) => {
41
+ const labels = new Map(findChildrenByType(node, schema.nodes.footnote).map((node) => [
42
+ node.node.attrs.id,
43
+ undefined,
44
+ ]));
45
+ let index = 0;
46
+ findChildrenByType(node, schema.nodes.inline_footnote)
47
+ .map(({ node }) => node.attrs.rids)
48
+ .flat()
49
+ .map((rid) => {
50
+ if (!labels.get(rid)) {
51
+ labels.set(rid, String(++index));
52
+ }
53
+ });
54
+ return labels;
55
+ };
56
+ export const orderTableFootnotes = (tr, footnotesElementWithPos, position) => {
57
+ const tablesFootnoteLabels = buildTableFootnoteLabels(tr.doc.nodeAt(tr.mapping.map(position)));
58
+ const footnotes = findChildrenByType(footnotesElementWithPos.node, schema.nodes.footnote).map((nodeWithPos) => ({
59
+ node: nodeWithPos.node,
60
+ index: tablesFootnoteLabels.get(nodeWithPos.node.attrs.id),
61
+ }));
62
+ const orderedFootnotes = [...footnotes]
63
+ .sort((a, b) => {
64
+ if (a.index !== undefined && b.index !== undefined) {
65
+ return Number.parseInt(a.index) - Number.parseInt(b.index);
66
+ }
67
+ else {
68
+ return a.index === undefined ? 1 : -1;
69
+ }
70
+ })
71
+ .map(({ node }) => node);
72
+ const { node: footnotesElement, pos } = footnotesElementWithPos;
73
+ const footnoteElementPos = position + pos;
74
+ return skipTracking(tr.replaceWith(tr.mapping.map(footnoteElementPos), tr.mapping.map(footnoteElementPos + footnotesElement.nodeSize), Fragment.fromArray(orderedFootnotes)));
75
+ };
76
+ export const updateTableInlineFootnoteLabels = (tr, table) => {
77
+ const labels = buildTableFootnoteLabels(table.node);
78
+ findChildrenByType(table.node, schema.nodes.inline_footnote).map(({ node, pos }) => {
79
+ const contents = node.attrs.rids
80
+ .map((rid) => labels.get(rid))
81
+ .join(',');
82
+ if (contents !== node.attrs.contents &&
83
+ tr.doc.nodeAt(tr.mapping.map(table.pos + pos + 1))) {
84
+ tr.setNodeMarkup(tr.mapping.map(table.pos + pos + 1), undefined, Object.assign(Object.assign({}, node.attrs), { rids: node.attrs.rids, contents }));
85
+ }
86
+ });
87
+ return tr;
88
+ };
@@ -0,0 +1,41 @@
1
+ import { schema } from '@manuscripts/transform';
2
+ import { Plugin } from 'prosemirror-state';
3
+ import { ReplaceStep } from 'prosemirror-transform';
4
+ import { findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
5
+ import { orderTableFootnotes, updateTableInlineFootnoteLabels, } from './footnotes/footnotes-utils';
6
+ const isInlineFootnoteChange = (step, oldState, newState) => {
7
+ var _a, _b;
8
+ return step.slice.size > 0
9
+ ? ((_a = newState.doc.nodeAt(step.from)) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.inline_footnote
10
+ : ((_b = oldState.doc.nodeAt(step.from)) === null || _b === void 0 ? void 0 : _b.type) === schema.nodes.inline_footnote;
11
+ };
12
+ export default () => {
13
+ return new Plugin({
14
+ appendTransaction(transactions, oldState, newState) {
15
+ const tableInlineFootnoteChange = transactions.find((tr) => tr.steps.find((s) => {
16
+ var _a;
17
+ if (s instanceof ReplaceStep) {
18
+ const step = s;
19
+ const $pos = oldState.doc.resolve(step.from);
20
+ return (((_a = $pos.node($pos.depth - 2)) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.table &&
21
+ isInlineFootnoteChange(step, oldState, newState));
22
+ }
23
+ }));
24
+ if (!tableInlineFootnoteChange) {
25
+ return null;
26
+ }
27
+ const step = tableInlineFootnoteChange.steps[0];
28
+ const tr = newState.tr;
29
+ const $pos = newState.doc.resolve(step.from);
30
+ const table = findParentNodeClosestToPos($pos, (node) => node.type === schema.nodes.table_element);
31
+ const footnotesElementWithPos = table &&
32
+ findChildrenByType(table.node, schema.nodes.footnotes_element).pop();
33
+ if (!table || !footnotesElementWithPos) {
34
+ return null;
35
+ }
36
+ updateTableInlineFootnoteLabels(tr, table);
37
+ orderTableFootnotes(tr, footnotesElementWithPos, tr.mapping.map(table.pos));
38
+ return tr;
39
+ },
40
+ });
41
+ };
@@ -62,8 +62,12 @@ export const toolbar = {
62
62
  title: 'Wrap in bullet list',
63
63
  content: icons.bullet_list,
64
64
  isActive: blockActive(schema.nodes.bullet_list),
65
- isEnabled: insertList(schema.nodes.bullet_list),
66
- run: insertList(schema.nodes.bullet_list),
65
+ isEnabled: insertList(schema.nodes.bullet_list, 'bullet'),
66
+ run: insertList(schema.nodes.bullet_list, 'bullet'),
67
+ options: {
68
+ bullet: insertList(schema.nodes.bullet_list, 'bullet'),
69
+ simple: insertList(schema.nodes.bullet_list, 'simple'),
70
+ },
67
71
  },
68
72
  ordered_list: {
69
73
  title: 'Wrap in ordered list',
@@ -15,13 +15,22 @@
15
15
  */
16
16
  import BlockView from './block_view';
17
17
  import { createNodeOrElementView } from './creators';
18
+ import { JATS_HTML_LIST_STYLE_MAPPING } from './ordered_list';
18
19
  export class BulletListView extends BlockView {
19
20
  constructor() {
20
21
  super(...arguments);
21
22
  this.elementType = 'ul';
23
+ this.updateContents = () => {
24
+ if (this.contentDOM) {
25
+ const type = this.node.attrs.listStyleType || 'bullet';
26
+ this.contentDOM.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
27
+ }
28
+ };
22
29
  }
23
30
  }
24
31
  export const bulletListCallback = (node, dom) => {
25
32
  dom.classList.add('list');
33
+ const type = node.attrs.listStyleType || 'bullet';
34
+ dom.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
26
35
  };
27
36
  export default createNodeOrElementView(BulletListView, 'ul', bulletListCallback);
@@ -68,6 +68,7 @@ export class CitationEditableView extends CitationView {
68
68
  this.props.popper.destroy();
69
69
  };
70
70
  this.showContextMenu = () => {
71
+ this.props.popper.destroy();
71
72
  const componentProps = {
72
73
  actions: [
73
74
  { label: 'Edit', action: this.handleEdit, icon: 'EditIcon' },
@@ -13,14 +13,16 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { SecondaryButton } from '@manuscripts/style-guide';
16
+ import { ContextMenu, SecondaryButton, } from '@manuscripts/style-guide';
17
+ import { CHANGE_STATUS } from '@manuscripts/track-changes-plugin';
17
18
  import { isContributorNode, schema, } from '@manuscripts/transform';
19
+ import { NodeSelection } from 'prosemirror-state';
18
20
  import { AuthorsModal, } from '../components/authors/AuthorsModal';
19
21
  import { authorLabel } from '../lib/authors';
20
22
  import { getActualAttrs } from '../lib/track-changes-utils';
21
23
  import { deleteNode, findChildByID, findChildByType, findChildrenAttrsByType, updateNodeAttrs, } from '../lib/view';
22
24
  import { affiliationsKey } from '../plugins/affiliations';
23
- import { selectedSuggestionKey } from '../plugins/selected-suggestion-ui';
25
+ import { CLEAR_SUGGESTION_ID, selectedSuggestionKey, SET_SUGGESTION_ID, } from '../plugins/selected-suggestion-ui';
24
26
  import BlockView from './block_view';
25
27
  import { createNodeView } from './creators';
26
28
  import ReactSubView from './ReactSubView';
@@ -73,7 +75,9 @@ export class ContributorsView extends BlockView {
73
75
  const pluginState = affiliationsKey.getState(this.view.state);
74
76
  const attrs = node.attrs;
75
77
  const displayAttr = getActualAttrs(node);
78
+ const containerWrapper = document.createElement('div');
76
79
  const container = document.createElement('button');
80
+ containerWrapper.classList.add('contributor-wrapper');
77
81
  container.classList.add('contributor');
78
82
  container.setAttribute('id', attrs.id);
79
83
  container.setAttribute('contenteditable', 'false');
@@ -89,9 +93,12 @@ export class ContributorsView extends BlockView {
89
93
  }
90
94
  const can = this.props.getCapabilities();
91
95
  const disableEditButton = !can.editMetadata;
92
- const { isCorresponding, email } = displayAttr;
96
+ const { isCorresponding, email, id } = displayAttr;
93
97
  if (!disableEditButton) {
94
- container.addEventListener('click', this.handleClick);
98
+ container.addEventListener('click', () => {
99
+ const dataTracked = attrs.dataTracked;
100
+ this.onClickHandler(id, dataTracked ? dataTracked[0] : undefined);
101
+ });
95
102
  }
96
103
  const name = authorLabel(displayAttr);
97
104
  container.innerHTML =
@@ -119,7 +126,8 @@ export class ContributorsView extends BlockView {
119
126
  if (selectedAuthor && selectedAuthor === attrs.id) {
120
127
  container.classList.add('selected-suggestion');
121
128
  }
122
- return container;
129
+ containerWrapper.appendChild(container);
130
+ return containerWrapper;
123
131
  };
124
132
  this.isJointFirstAuthor = (authors, index) => {
125
133
  const author = index === 0 ? authors[index] : authors[index - 1];
@@ -137,11 +145,14 @@ export class ContributorsView extends BlockView {
137
145
  this.dom = document.createElement('div');
138
146
  this.dom.classList.add('block-container', `block-${this.node.type.name}`);
139
147
  };
148
+ this.deselectNode = () => {
149
+ this.props.popper.destroy();
150
+ };
140
151
  this.createEditButton = () => {
141
152
  const can = this.props.getCapabilities();
142
153
  const button = ReactSubView(this.props, SecondaryButton, {
143
154
  mini: true,
144
- onClick: this.handleClick,
155
+ onClick: () => this.handleEdit(''),
145
156
  className: 'edit-authors-button',
146
157
  disabled: !can.editMetadata,
147
158
  children: 'Edit Authors',
@@ -161,17 +172,45 @@ export class ContributorsView extends BlockView {
161
172
  }
162
173
  }
163
174
  };
164
- this.handleClick = (e) => {
165
- var _a, _b;
166
- e.stopPropagation();
175
+ this.onClickHandler = (elementId, dataTracked) => {
176
+ var _a;
177
+ this.props.popper.destroy();
178
+ const isSelectedSuggestion = !!((_a = selectedSuggestionKey
179
+ .getState(this.view.state)) === null || _a === void 0 ? void 0 : _a.find(this.getPos(), this.getPos() + this.node.nodeSize).length);
180
+ const { tr } = this.view.state;
181
+ tr.setSelection(NodeSelection.create(this.view.state.doc, this.getPos()));
182
+ if (dataTracked && dataTracked.status !== CHANGE_STATUS.rejected) {
183
+ tr.setMeta(SET_SUGGESTION_ID, dataTracked.id);
184
+ }
185
+ else {
186
+ if (isSelectedSuggestion) {
187
+ tr.setMeta(CLEAR_SUGGESTION_ID, true);
188
+ }
189
+ }
190
+ this.view.dispatch(tr);
191
+ this.showContextMenu(elementId);
192
+ };
193
+ this.showContextMenu = (elementId) => {
194
+ this.props.popper.destroy();
195
+ const element = document.getElementById(elementId);
196
+ const componentProps = {
197
+ actions: [
198
+ {
199
+ label: 'Edit',
200
+ action: () => this.handleEdit(elementId),
201
+ icon: 'EditIcon',
202
+ },
203
+ ],
204
+ };
205
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
206
+ this.props.popper.show(element, this.contextMenu, 'right-start');
207
+ };
208
+ this.handleEdit = (id) => {
209
+ var _a;
210
+ this.props.popper.destroy();
167
211
  const contributors = findChildrenAttrsByType(this.view, schema.nodes.contributor);
168
212
  const affiliations = findChildrenAttrsByType(this.view, schema.nodes.affiliation);
169
- let author = undefined;
170
- const target = e.target;
171
- if (target) {
172
- const id = (_a = target.closest('.contributor')) === null || _a === void 0 ? void 0 : _a.getAttribute('id');
173
- author = contributors.filter((a) => a.id === id)[0];
174
- }
213
+ const author = id ? contributors.filter((a) => a.id === id)[0] : undefined;
175
214
  const componentProps = {
176
215
  author,
177
216
  authors: contributors,
@@ -180,7 +219,7 @@ export class ContributorsView extends BlockView {
180
219
  onDeleteAuthor: this.handleDeleteAuthor,
181
220
  onSaveAffiliation: this.handleSaveAffiliation,
182
221
  };
183
- (_b = this.popper) === null || _b === void 0 ? void 0 : _b.remove();
222
+ (_a = this.popper) === null || _a === void 0 ? void 0 : _a.remove();
184
223
  this.popper = ReactSubView(this.props, AuthorsModal, componentProps, this.node, this.getPos, this.view);
185
224
  this.container.appendChild(this.popper);
186
225
  };
@@ -37,10 +37,6 @@ export class LinkEditableView extends LinkView {
37
37
  if (!this.props.getCapabilities().editArticle) {
38
38
  return;
39
39
  }
40
- if (!this.popperContainer) {
41
- this.popperContainer = document.createElement('div');
42
- this.popperContainer.className = 'link-editor';
43
- }
44
40
  const originalValue = {
45
41
  href: this.node.attrs.href,
46
42
  title: this.node.attrs.title,
@@ -52,7 +48,7 @@ export class LinkEditableView extends LinkView {
52
48
  handleRemove: this.handleRemove,
53
49
  handleSave: this.handleSave,
54
50
  };
55
- this.popperContainer = ReactSubView(this.props, LinkForm, componentProps, this.node, this.getPos, this.view);
51
+ this.popperContainer = ReactSubView(this.props, LinkForm, componentProps, this.node, this.getPos, this.view, 'link-editor');
56
52
  this.props.popper.show(this.dom, this.popperContainer, 'bottom');
57
53
  };
58
54
  this.handleCancel = () => {
@@ -16,6 +16,7 @@
16
16
  import BlockView from './block_view';
17
17
  import { createNodeOrElementView } from './creators';
18
18
  export const JATS_HTML_LIST_STYLE_MAPPING = {
19
+ simple: 'none',
19
20
  bullet: 'disc',
20
21
  order: 'decimal',
21
22
  'alpha-lower': 'lower-alpha',
@@ -19,6 +19,7 @@ import { ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, Manusc
19
19
  import { ResolvedPos } from 'prosemirror-model';
20
20
  import { Command, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
21
21
  import { NodeWithPos } from 'prosemirror-utils';
22
+ import { EditorView } from 'prosemirror-view';
22
23
  import { EditorAction } from './types';
23
24
  export type Dispatch = (tr: ManuscriptTransaction) => void;
24
25
  export declare const markActive: (type: ManuscriptMarkType) => (state: ManuscriptEditorState) => boolean;
@@ -56,4 +57,4 @@ export declare const deleteHighlightMarkers: (rid: string) => Command;
56
57
  export declare function addComment(state: ManuscriptEditorState, dispatch?: Dispatch): boolean;
57
58
  export declare function addComment(state: ManuscriptEditorState, dispatch?: Dispatch, viewNode?: ManuscriptNode, resolvePos?: ResolvedPos): boolean;
58
59
  export declare const updateCommentAnnotationState: (state: ManuscriptEditorState, dispatch?: Dispatch) => void;
59
- export declare const insertTableFootnote: (node: ManuscriptNode, position: number, state: ManuscriptEditorState, dispatch?: Dispatch) => void;
60
+ export declare const insertTableFootnote: (node: ManuscriptNode, position: number, view: EditorView) => void;
@@ -13,5 +13,12 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { ManuscriptNode } from '@manuscripts/transform';
16
17
  import { ResolvedPos } from 'prosemirror-model';
18
+ import { Transaction } from 'prosemirror-state';
19
+ import { ContentNodeWithPos, NodeWithPos } from 'prosemirror-utils';
17
20
  export declare const findTableInlineFootnoteIds: ($pos: ResolvedPos) => Set<string>;
21
+ export declare const getNewFootnotePos: (footnotesElement: NodeWithPos, footnoteIndex: number) => number;
22
+ export declare const buildTableFootnoteLabels: (node: ManuscriptNode) => Map<string, string | undefined>;
23
+ export declare const orderTableFootnotes: (tr: Transaction, footnotesElementWithPos: NodeWithPos, position: number) => Transaction;
24
+ export declare const updateTableInlineFootnoteLabels: (tr: Transaction, table: ContentNodeWithPos) => Transaction;
@@ -0,0 +1,3 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ declare const _default: () => Plugin<any>;
3
+ export default _default;