@manuscripts/body-editor 3.17.3 → 3.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/cjs/commands.js +13 -19
  2. package/dist/cjs/components/references/ReferenceLine.js +14 -1
  3. package/dist/cjs/components/references/ReferencesModal.js +155 -131
  4. package/dist/cjs/configs/editor-views.js +1 -0
  5. package/dist/cjs/icons.js +2 -2
  6. package/dist/cjs/lib/context-menu.js +4 -1
  7. package/dist/cjs/lib/normalize.js +31 -1
  8. package/dist/cjs/lib/paste.js +0 -1
  9. package/dist/cjs/menus.js +1 -1
  10. package/dist/cjs/node-type-icons.js +1 -0
  11. package/dist/cjs/plugins/add-subtitle.js +1 -1
  12. package/dist/cjs/plugins/bibliography.js +7 -1
  13. package/dist/cjs/plugins/section_category.js +5 -2
  14. package/dist/cjs/plugins/translations.js +9 -21
  15. package/dist/cjs/versions.js +1 -1
  16. package/dist/cjs/views/bibliography_element.js +44 -2
  17. package/dist/cjs/views/figure_element.js +1 -1
  18. package/dist/cjs/views/headshot_grid.js +1 -1
  19. package/dist/es/commands.js +13 -19
  20. package/dist/es/components/references/ReferenceLine.js +14 -1
  21. package/dist/es/components/references/ReferencesModal.js +156 -132
  22. package/dist/es/configs/editor-views.js +1 -0
  23. package/dist/es/icons.js +1 -1
  24. package/dist/es/lib/context-menu.js +4 -1
  25. package/dist/es/lib/normalize.js +30 -1
  26. package/dist/es/lib/paste.js +0 -1
  27. package/dist/es/menus.js +1 -1
  28. package/dist/es/node-type-icons.js +1 -0
  29. package/dist/es/plugins/add-subtitle.js +2 -2
  30. package/dist/es/plugins/bibliography.js +7 -1
  31. package/dist/es/plugins/section_category.js +6 -3
  32. package/dist/es/plugins/translations.js +11 -23
  33. package/dist/es/versions.js +1 -1
  34. package/dist/es/views/bibliography_element.js +45 -3
  35. package/dist/es/views/figure_element.js +2 -2
  36. package/dist/es/views/headshot_grid.js +2 -2
  37. package/dist/types/commands.d.ts +2 -2
  38. package/dist/types/components/references/ReferenceLine.d.ts +1 -0
  39. package/dist/types/icons.d.ts +1 -1
  40. package/dist/types/lib/normalize.d.ts +30 -1
  41. package/dist/types/versions.d.ts +1 -1
  42. package/dist/types/views/bibliography_element.d.ts +5 -1
  43. package/package.json +2 -2
  44. package/src/commands.ts +22 -35
  45. package/src/components/references/ReferenceLine.tsx +16 -1
  46. package/src/components/references/ReferencesModal.tsx +178 -140
  47. package/src/configs/editor-views.ts +1 -0
  48. package/src/icons.ts +1 -1
  49. package/src/lib/context-menu.ts +4 -1
  50. package/src/lib/normalize.ts +36 -1
  51. package/src/lib/paste.ts +0 -1
  52. package/src/menus.tsx +1 -1
  53. package/src/node-type-icons.tsx +1 -0
  54. package/src/plugins/add-subtitle.ts +2 -2
  55. package/src/plugins/bibliography.ts +10 -3
  56. package/src/plugins/section_category.ts +7 -2
  57. package/src/plugins/translations.ts +18 -29
  58. package/src/versions.ts +1 -1
  59. package/src/views/bibliography_element.ts +61 -4
  60. package/src/views/figure_element.ts +2 -2
  61. package/src/views/headshot_grid.ts +2 -2
  62. package/styles/AdvancedEditor.css +29 -2
  63. package/styles/Editor.css +7 -0
@@ -259,7 +259,10 @@ export class ContextMenu {
259
259
  menu.appendChild(this.createMenuSection((section) => {
260
260
  let nodeName = nodeNames.get(type) || '';
261
261
  if (type === schema.nodes.section_title) {
262
- nodeName = nodeNames.get(schema.nodes.section);
262
+ const containerType = $pos.parent.type;
263
+ nodeName =
264
+ nodeNames.get(containerType) ??
265
+ nodeNames.get(schema.nodes.section);
263
266
  }
264
267
  section.appendChild(this.createMenuItem(`Delete ${nodeName}`, () => {
265
268
  this.deleteNode(type);
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { generateNodeID, schema } from '@manuscripts/transform';
16
+ import { generateNodeID, schema, } from '@manuscripts/transform';
17
17
  const trim = (value) => (value ?? '').trim();
18
18
  export const normalizeAffiliation = (a) => ({
19
19
  ...a,
@@ -56,3 +56,32 @@ export const checkID = (attrs, nodeType) => {
56
56
  id: attrs.id || generateNodeID(schema.nodes[nodeType]),
57
57
  };
58
58
  };
59
+ export const normalizeBlblioItem = (item) => ({
60
+ id: item.id,
61
+ type: item.type,
62
+ author: item.author || [],
63
+ editor: item.editor || [],
64
+ issued: item.issued,
65
+ ['container-title']: item['container-title'] || '',
66
+ ['collection-title']: item['collection-title'] || '',
67
+ DOI: item.DOI || '',
68
+ URL: item.URL || '',
69
+ volume: item.volume || '',
70
+ issue: item.issue || '',
71
+ supplement: item.supplement || '',
72
+ edition: item.edition || '',
73
+ page: item.page || '',
74
+ ['number-of-pages']: item['number-of-pages'] || '',
75
+ title: item.title || '',
76
+ literal: item.literal || '',
77
+ std: item.std || '',
78
+ publisher: item.publisher || '',
79
+ ['publisher-place']: item['publisher-place'] || '',
80
+ event: item.event || '',
81
+ ['event-place']: item['event-place'] || '',
82
+ ['event-date']: item['event-date'],
83
+ institution: item.institution || '',
84
+ locator: item.locator || '',
85
+ accessed: item.accessed,
86
+ comment: item.comment || '',
87
+ });
@@ -71,7 +71,6 @@ export const transformPastedHTML = (html) => {
71
71
  const doc = new DOMParser().parseFromString(html, 'text/html');
72
72
  wrapHeadingWithSection(doc);
73
73
  wrapTableWithFigure(doc);
74
- console.log(doc.body.innerHTML);
75
74
  return doc.body.innerHTML;
76
75
  };
77
76
  const wrapHeadingWithSection = (doc) => {
package/dist/es/menus.js CHANGED
@@ -486,7 +486,7 @@ export const getEditorMenus = (editor) => {
486
486
  };
487
487
  const ABSTRACT_ID = 'abstract';
488
488
  const abstractSection = allAbstractsCategories.find((s) => s.id === ABSTRACT_ID);
489
- const ABSTRACT_GRAPHICAL_ID = 'abstract-graphical';
489
+ const ABSTRACT_GRAPHICAL_ID = 'graphical';
490
490
  const graphicalAbstractSection = allAbstractsCategories.find((s) => s.id === ABSTRACT_GRAPHICAL_ID);
491
491
  const abstractsSubmenuList = allAbstractsCategories.filter((c) => c.id !== ABSTRACT_ID && c.id !== ABSTRACT_GRAPHICAL_ID);
492
492
  const metadata = {
@@ -32,6 +32,7 @@ const icons = new Map([
32
32
  [nodes.paragraph, OutlineParagraphIcon],
33
33
  [nodes.pullquote_element, OutlinePullQuoteIcon],
34
34
  [nodes.section, OutlineSectionIcon],
35
+ [nodes.abstract, OutlineSectionIcon],
35
36
  [nodes.table_element, OutlineTableIcon],
36
37
  [nodes.graphical_abstract_section, OutlineSectionIcon],
37
38
  [nodes.trans_graphical_abstract, OutlineSectionIcon],
@@ -17,13 +17,13 @@ import { schema } from '@manuscripts/transform';
17
17
  import { Plugin, TextSelection } from 'prosemirror-state';
18
18
  import { Decoration, DecorationSet } from 'prosemirror-view';
19
19
  import { v4 as uuidv4 } from 'uuid';
20
- import { addAuthorIcon } from '../icons';
20
+ import { addIcon } from '../icons';
21
21
  import { handleEnterKey } from '../lib/navigation-utils';
22
22
  import { findInsertionPosition } from '../lib/utils';
23
23
  const createAddSubtitleButton = (handler) => {
24
24
  const button = document.createElement('span');
25
25
  button.className = 'add-subtitle';
26
- button.innerHTML = `${addAuthorIcon} <span class="add-subtitle-text">Add subtitle</span>`;
26
+ button.innerHTML = `${addIcon} <span class="add-subtitle-text">Add subtitle</span>`;
27
27
  button.tabIndex = 0;
28
28
  const activate = (event) => {
29
29
  event.preventDefault();
@@ -88,7 +88,13 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
88
88
  return item;
89
89
  },
90
90
  }, csl.style, 'en-US');
91
- const citationTexts = engine.rebuildProcessorState(nodes.map(([node]) => buildCiteprocCitation(node.attrs)));
91
+ const uncitedIds = [];
92
+ bibliographyItems.forEach((item, id) => {
93
+ if (!rids.includes(id)) {
94
+ uncitedIds.push(id);
95
+ }
96
+ });
97
+ const citationTexts = engine.rebuildProcessorState(nodes.map(([node]) => buildCiteprocCitation(node.attrs)), 'html', uncitedIds);
92
98
  $new.version = String(version++);
93
99
  $new.citationCounts = citationCounts;
94
100
  $new.engine = engine;
@@ -1,4 +1,4 @@
1
- import { getGroupCategories, isSectionNode, schema, } from '@manuscripts/transform';
1
+ import { getGroupCategories, isAbstractNode, isSectionNode, schema, } from '@manuscripts/transform';
2
2
  import { Plugin, PluginKey } from 'prosemirror-state';
3
3
  import { findChildrenByType, findParentNodeOfTypeClosestToPos, } from 'prosemirror-utils';
4
4
  import { Decoration, DecorationSet } from 'prosemirror-view';
@@ -79,7 +79,7 @@ const buildPluginState = (state, props) => {
79
79
  if (node.type === schema.nodes.box_element) {
80
80
  return false;
81
81
  }
82
- if (isSectionNode(node)) {
82
+ if (isSectionNode(node) || isAbstractNode(node)) {
83
83
  const categoryID = node.attrs.category;
84
84
  const category = categories.get(categoryID);
85
85
  const $pos = state.doc.resolve(pos);
@@ -97,7 +97,10 @@ const buildPluginState = (state, props) => {
97
97
  return { decorations: DecorationSet.create(state.doc, decorations) };
98
98
  };
99
99
  const getUsedSectionCategoryIDs = (state) => {
100
- const sections = findChildrenByType(state.doc, schema.nodes.section);
100
+ const sections = [
101
+ ...findChildrenByType(state.doc, schema.nodes.section),
102
+ ...findChildrenByType(state.doc, schema.nodes.abstract),
103
+ ];
101
104
  const used = new Set();
102
105
  sections.forEach(({ node }) => {
103
106
  if (node.attrs.category) {
@@ -13,14 +13,14 @@
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';
16
+ import { isAbstractNode, isGraphicalAbstractSectionNode, isTransAbstractNode, isTransGraphicalAbstractNode, schema, } from '@manuscripts/transform';
17
17
  import { Plugin } from 'prosemirror-state';
18
18
  import { Decoration, DecorationSet } from 'prosemirror-view';
19
19
  import { insertTransAbstract, insertTransGraphicalAbstract } from '../commands';
20
- import { addAuthorIcon, translateIcon } from '../icons';
20
+ import { addIcon, translateIcon } from '../icons';
21
21
  import { getLanguage, getLanguageLabel } from '../lib/languages';
22
+ import { createKeyboardInteraction, handleEnterKey, } from '../lib/navigation-utils';
22
23
  import { templateAllows } from '../lib/template';
23
- import { handleEnterKey, createKeyboardInteraction, } from '../lib/navigation-utils';
24
24
  const createMenuItem = (props, contents, handler, isSelected = false, tabIndex) => {
25
25
  const item = document.createElement('div');
26
26
  item.className = `menu-item ${isSelected ? 'selected' : ''}`;
@@ -58,10 +58,6 @@ const createLanguageMenu = (props, selectedCode, onSelect) => {
58
58
  });
59
59
  return { menu, destroy };
60
60
  };
61
- const getInsertionPos = (doc, nodePos) => {
62
- const node = doc.nodeAt(nodePos);
63
- return node ? nodePos + node.nodeSize : null;
64
- };
65
61
  export default (props) => new Plugin({
66
62
  props: {
67
63
  decorations: (state) => {
@@ -72,14 +68,11 @@ export default (props) => new Plugin({
72
68
  const canEditTransGraphicalAbstract = can.editArticle &&
73
69
  templateAllows(state, schema.nodes.trans_graphical_abstract);
74
70
  const widgets = [];
75
- state.doc.descendants((node, pos, parent) => {
76
- const isAbstractSection = (node.type === schema.nodes.section ||
77
- node.type === schema.nodes.graphical_abstract_section) &&
78
- parent?.type === schema.nodes.abstracts;
71
+ state.doc.descendants((node, pos) => {
72
+ const isAbstractSection = isAbstractNode(node) || isGraphicalAbstractSectionNode(node);
79
73
  if (isAbstractSection) {
80
- const isGraphical = node.type === schema.nodes.graphical_abstract_section;
81
74
  const category = props.sectionCategories.get(node.attrs.category);
82
- const canEdit = isGraphical
75
+ const canEdit = isGraphicalAbstractSectionNode(node)
83
76
  ? canEditTransGraphicalAbstract &&
84
77
  category &&
85
78
  insertTransGraphicalAbstract(category)(state)
@@ -90,19 +83,15 @@ export default (props) => new Plugin({
90
83
  $span.tabIndex = 0;
91
84
  $span.className = 'add-trans-abstract';
92
85
  $span.title = 'Add translation';
93
- $span.innerHTML = `${addAuthorIcon} <span class="add-trans-abstract-text">Add translation</span>`;
86
+ $span.innerHTML = `${addIcon} <span class="add-trans-abstract-text">Add translation</span>`;
94
87
  const handleActivate = (event) => {
95
88
  event.preventDefault();
96
89
  event.stopPropagation();
97
- const insertPos = getInsertionPos(view.state.doc, pos);
98
- if (insertPos == null) {
99
- return;
100
- }
101
- if (isGraphical && category) {
102
- insertTransGraphicalAbstract(category, insertPos)(view.state, view.dispatch, view);
90
+ if (isGraphicalAbstractSectionNode(node) && category) {
91
+ insertTransGraphicalAbstract(category)(view.state, view.dispatch, view);
103
92
  }
104
93
  else {
105
- insertTransAbstract(view.state, view.dispatch, node.attrs.category, insertPos);
94
+ insertTransAbstract(view.state, view.dispatch, node.attrs.category);
106
95
  }
107
96
  };
108
97
  $span.addEventListener('mousedown', handleActivate);
@@ -111,8 +100,7 @@ export default (props) => new Plugin({
111
100
  }, { key: `add-trans-${node.attrs.id}-${pos}` }));
112
101
  }
113
102
  }
114
- const isTransNode = node.type === schema.nodes.trans_abstract ||
115
- node.type === schema.nodes.trans_graphical_abstract;
103
+ const isTransNode = isTransAbstractNode(node) || isTransGraphicalAbstractNode(node);
116
104
  if (isTransNode) {
117
105
  const canEdit = node.type === schema.nodes.trans_abstract
118
106
  ? canEditTransAbstract
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.17.3';
1
+ export const VERSION = '3.18.0';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { ContextMenu } from '@manuscripts/style-guide';
17
+ import { isCitationNode, } from '@manuscripts/transform';
17
18
  import { NodeSelection } from 'prosemirror-state';
18
19
  import { ReferencesEditor, } from '../components/references/ReferencesEditor';
19
20
  import { createCommentMarker, handleComment } from '../lib/comments';
@@ -21,13 +22,14 @@ import { handleEnterKey } from '../lib/navigation-utils';
21
22
  import { findNodeByID } from '../lib/doc';
22
23
  import { sanitize } from '../lib/dompurify';
23
24
  import { deleteNode, findChildByID, saveBibliographyItem } from '../lib/view';
24
- import { getBibliographyPluginState } from '../plugins/bibliography';
25
+ import { getBibliographyPluginState, } from '../plugins/bibliography';
25
26
  import { commentsKey, setCommentSelection } from '../plugins/comments';
26
27
  import { selectedSuggestionKey } from '../plugins/selected-suggestion';
27
28
  import BlockView from './block_view';
28
29
  import { createNodeView } from './creators';
29
30
  import ReactSubView from './ReactSubView';
30
31
  import { addTrackChangesAttributes, addTrackChangesClassNames, } from '@manuscripts/track-changes-plugin';
32
+ import { addIcon } from '../icons';
31
33
  export class BibliographyElementBlockView extends BlockView {
32
34
  constructor() {
33
35
  super(...arguments);
@@ -132,7 +134,7 @@ export class BibliographyElementBlockView extends BlockView {
132
134
  const componentProps = {
133
135
  items: Array.from(bib.bibliographyItems.values()),
134
136
  citationCounts: bib.citationCounts,
135
- item: bib.bibliographyItems.get(id),
137
+ item: id ? bib.bibliographyItems.get(id) : undefined,
136
138
  onSave: this.handleSave,
137
139
  onDelete: this.handleDelete,
138
140
  };
@@ -175,7 +177,18 @@ export class BibliographyElementBlockView extends BlockView {
175
177
  return;
176
178
  }
177
179
  this.version = bib.version;
180
+ this.renderBibs(bib);
181
+ this.createInlineModalButton();
182
+ this.updateSelections();
183
+ }
184
+ renderBibs(bib) {
178
185
  const nodes = new Map();
186
+ const rids = [];
187
+ this.view.state.doc.descendants((node) => {
188
+ if (isCitationNode(node)) {
189
+ rids.push(...node.attrs.rids);
190
+ }
191
+ });
179
192
  this.node.descendants((node) => {
180
193
  const id = node.attrs.id;
181
194
  nodes.set(id, node);
@@ -213,6 +226,12 @@ export class BibliographyElementBlockView extends BlockView {
213
226
  element.tabIndex = 0;
214
227
  const comment = createCommentMarker('div', id);
215
228
  element.prepend(comment);
229
+ if (!rids.includes(id)) {
230
+ const uncitedMarker = document.createElement('span');
231
+ uncitedMarker.innerHTML = 'UNCITED';
232
+ uncitedMarker.classList.add('uncited-reference-marker');
233
+ element.prepend(uncitedMarker);
234
+ }
216
235
  addTrackChangesAttributes(node.attrs, element);
217
236
  addTrackChangesClassNames(node.attrs, element);
218
237
  wrapper.append(element);
@@ -230,7 +249,30 @@ export class BibliographyElementBlockView extends BlockView {
230
249
  else {
231
250
  this.container.appendChild(wrapper);
232
251
  }
233
- this.updateSelections();
252
+ }
253
+ createInlineModalButton() {
254
+ const can = this.props.getCapabilities();
255
+ if (!can.editCitationsAndRefs) {
256
+ if (this.inlineModalButton) {
257
+ this.inlineModalButton.remove();
258
+ this.inlineModalButton = null;
259
+ }
260
+ return;
261
+ }
262
+ if (this.inlineModalButton) {
263
+ return;
264
+ }
265
+ const $span = document.createElement('span');
266
+ $span.tabIndex = 0;
267
+ $span.className = 'add-new-reference add-trans-abstract';
268
+ $span.title = 'Add New Reference';
269
+ $span.innerHTML = `${addIcon} <span type="button" tabindex="0" class="add-new-reference-text">Add new reference</span>`;
270
+ $span.addEventListener('click', (e) => {
271
+ this.showPopper();
272
+ });
273
+ $span.addEventListener('keydown', handleEnterKey(() => this.showPopper()));
274
+ this.inlineModalButton = $span;
275
+ this.dom.appendChild($span);
234
276
  }
235
277
  }
236
278
  export default createNodeView(BibliographyElementBlockView);
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { schema } from '@manuscripts/transform';
17
17
  import { TextSelection } from 'prosemirror-state';
18
- import { addAuthorIcon } from '../icons';
18
+ import { addIcon } from '../icons';
19
19
  import { handleEnterKey } from '../lib/navigation-utils';
20
20
  import { createNodeView } from './creators';
21
21
  import { ImageElementView } from './image_element';
@@ -68,7 +68,7 @@ export class FigureElementView extends ImageElementView {
68
68
  if (this.props.getCapabilities()?.editArticle) {
69
69
  this.addFigureBtn = Object.assign(document.createElement('button'), {
70
70
  className: 'add-button',
71
- innerHTML: addAuthorIcon,
71
+ innerHTML: addIcon,
72
72
  title: 'Add figure',
73
73
  });
74
74
  this.addFigureBtn.addEventListener('click', () => this.addFigure());
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { schema, } from '@manuscripts/transform';
17
17
  import { TextSelection } from 'prosemirror-state';
18
- import { addAuthorIcon } from '../icons';
18
+ import { addIcon } from '../icons';
19
19
  import { createKeyboardInteraction, handleEnterKey, } from '../lib/navigation-utils';
20
20
  import BlockView from './block_view';
21
21
  import { createNodeView } from './creators';
@@ -45,7 +45,7 @@ export class HeadshotGridView extends BlockView {
45
45
  this.addHeadshotButton.classList.add('add-headshot-element-button');
46
46
  this.addHeadshotButton.setAttribute('data-cy', 'headshot-add');
47
47
  this.addHeadshotButton.contentEditable = 'false';
48
- this.addHeadshotButton.innerHTML = addAuthorIcon;
48
+ this.addHeadshotButton.innerHTML = addIcon;
49
49
  const buttonText = document.createElement('span');
50
50
  buttonText.classList.add('add-headshot-element-text');
51
51
  buttonText.innerText = 'Add Headshot';
@@ -67,8 +67,8 @@ export declare const insertKeywords: (state: ManuscriptEditorState, dispatch?: D
67
67
  export declare const insertList: (type: ManuscriptNodeType, style?: string) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
68
68
  export declare const insertBibliographySection: () => boolean;
69
69
  export declare const insertTOCSection: () => boolean;
70
- export declare const insertTransAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch, category?: string, insertAfterPos?: number) => boolean;
71
- export declare const insertTransGraphicalAbstract: (category: SectionCategory, insertAfterPos?: number) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
70
+ export declare const insertTransAbstract: (state: ManuscriptEditorState, dispatch?: Dispatch, category?: string) => boolean;
71
+ export declare const insertTransGraphicalAbstract: (category: SectionCategory) => (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => boolean;
72
72
  export declare const isAtStartOfTextBlock: (state: ManuscriptEditorState, $cursor: ResolvedPos, view?: ManuscriptEditorView) => boolean;
73
73
  export declare const isTextSelection: (selection: Selection) => selection is ManuscriptTextSelection;
74
74
  export declare const ignoreAtomBlockNodeBackward: (state: ManuscriptEditorState, dispatch?: Dispatch, view?: ManuscriptEditorView) => boolean;
@@ -19,4 +19,5 @@ export declare const Metadata: import("styled-components/dist/types").IStyledCom
19
19
  export declare const MetadataContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never> & Partial<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>>> & string;
20
20
  export declare const ReferenceLine: React.FC<{
21
21
  item: BibliographyItemAttrs;
22
+ showUncited?: boolean;
22
23
  }>;
@@ -1,4 +1,4 @@
1
- export declare const addAuthorIcon: string;
1
+ export declare const addIcon: string;
2
2
  export declare const arrowDown: string;
3
3
  export declare const arrowUp: string;
4
4
  export declare const alertIcon: string;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { Nodes } from '@manuscripts/transform';
16
+ import { BibliographyItemAttrs, Nodes } from '@manuscripts/transform';
17
17
  import { AffiliationAttrs, ContributorAttrs } from './authors';
18
18
  export declare const normalizeAffiliation: (a: AffiliationAttrs) => AffiliationAttrs;
19
19
  export declare const normalizeAuthor: (author: ContributorAttrs) => ContributorAttrs;
@@ -23,4 +23,33 @@ type WithID = {
23
23
  export declare const checkID: <T extends WithID>(attrs: T, nodeType: Nodes) => T & {
24
24
  id: string;
25
25
  };
26
+ export declare const normalizeBlblioItem: (item: BibliographyItemAttrs) => {
27
+ id: string;
28
+ type: import("@manuscripts/transform").BibliographyItemType;
29
+ author: import("csl").Person[];
30
+ editor: import("csl").Person[];
31
+ issued: import("csl").Date | undefined;
32
+ "container-title": string;
33
+ "collection-title": string;
34
+ DOI: string;
35
+ URL: string;
36
+ volume: string;
37
+ issue: string;
38
+ supplement: string;
39
+ edition: string;
40
+ page: string;
41
+ "number-of-pages": string;
42
+ title: string;
43
+ literal: string;
44
+ std: string;
45
+ publisher: string;
46
+ "publisher-place": string;
47
+ event: string;
48
+ "event-place": string;
49
+ "event-date": import("csl").Date | undefined;
50
+ institution: string;
51
+ locator: string;
52
+ accessed: import("csl").Date | undefined;
53
+ comment: string;
54
+ };
26
55
  export {};
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.17.3";
1
+ export declare const VERSION = "3.18.0";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { BibliographyElementNode } from '@manuscripts/transform';
17
+ import { PluginState } from '../plugins/bibliography';
17
18
  import { Trackable } from '../types';
18
19
  import BlockView from './block_view';
19
20
  export declare class BibliographyElementBlockView extends BlockView<Trackable<BibliographyElementNode>> {
@@ -21,7 +22,7 @@ export declare class BibliographyElementBlockView extends BlockView<Trackable<Bi
21
22
  private editor;
22
23
  private contextMenu;
23
24
  private version;
24
- showPopper(id: string): void;
25
+ showPopper(id?: string): void;
25
26
  stopEvent: () => boolean;
26
27
  ignoreMutation: () => boolean;
27
28
  private handleEdit;
@@ -31,6 +32,9 @@ export declare class BibliographyElementBlockView extends BlockView<Trackable<Bi
31
32
  private handleClick;
32
33
  private handleKeyDown;
33
34
  updateContents(): void;
35
+ renderBibs(bib: PluginState): void;
36
+ inlineModalButton: HTMLSpanElement | null;
37
+ createInlineModalButton(): void;
34
38
  createElement: () => void;
35
39
  private handleSave;
36
40
  private handleDelete;
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": "3.17.3",
4
+ "version": "3.18.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -43,7 +43,7 @@
43
43
  "@iarna/word-count": "1.1.2",
44
44
  "@manuscripts/style-guide": "3.7.2",
45
45
  "@manuscripts/track-changes-plugin": "2.4.0",
46
- "@manuscripts/transform": "4.5.2",
46
+ "@manuscripts/transform": "4.5.4",
47
47
  "@popperjs/core": "2.11.8",
48
48
  "citeproc": "2.4.63",
49
49
  "codemirror": "5.65.19",
package/src/commands.ts CHANGED
@@ -1143,24 +1143,20 @@ export const insertAbstractSection =
1143
1143
  return false
1144
1144
  }
1145
1145
  const abstracts = findAbstractsNode(state.doc)
1146
- const sections = findChildrenByType(abstracts.node, schema.nodes.section)
1147
- // Check if the section already exists
1148
- if (sections.some((s) => s.node.attrs.category === category.id)) {
1146
+ const abstractNodes = findChildrenByType(
1147
+ abstracts.node,
1148
+ schema.nodes.abstract
1149
+ )
1150
+ if (abstractNodes.some((s) => s.node.attrs.category === category.id)) {
1149
1151
  return false
1150
1152
  }
1151
1153
 
1152
- // check if graphical abstract node exist to insert before it.
1153
- const ga = findChildrenByType(
1154
- state.doc,
1155
- schema.nodes.graphical_abstract_section
1156
- )[0]
1157
-
1158
- let pos = ga ? ga.pos : abstracts.pos + abstracts.node.content.size + 1
1159
- if (category.id === 'abstract') {
1160
- pos = abstracts.pos + 1
1161
- }
1154
+ const pos =
1155
+ findInsertionPosition(schema.nodes.abstract, abstracts.node) +
1156
+ abstracts.pos +
1157
+ 1
1162
1158
 
1163
- const node = schema.nodes.section.create({ category: category.id }, [
1159
+ const node = schema.nodes.abstract.create({ category: category.id }, [
1164
1160
  schema.nodes.section_title.create({}, schema.text(category.titles[0])),
1165
1161
  schema.nodes.paragraph.create({ placeholder: 'Type abstract here...' }),
1166
1162
  ])
@@ -1238,15 +1234,13 @@ export const insertGraphicalAbstract =
1238
1234
  return false
1239
1235
  }
1240
1236
 
1241
- const ga = findChildrenByType(
1242
- state.doc,
1243
- schema.nodes.graphical_abstract_section
1244
- )[0]
1245
-
1246
- // insert at the end of abstracts section
1247
- let pos = abstracts.pos + abstracts.node.content.size + 1
1248
- // abstract-key-image insert before abstract-graphical
1249
- pos = ga && category.id === 'abstract-key-image' ? ga.pos : pos
1237
+ const pos =
1238
+ findInsertionPosition(
1239
+ schema.nodes.graphical_abstract_section,
1240
+ abstracts.node
1241
+ ) +
1242
+ abstracts.pos +
1243
+ 1
1250
1244
 
1251
1245
  const node = schema.nodes.graphical_abstract_section.createAndFill(
1252
1246
  { category: category.id },
@@ -1537,8 +1531,7 @@ export const insertTOCSection = () => {
1537
1531
  export const insertTransAbstract = (
1538
1532
  state: ManuscriptEditorState,
1539
1533
  dispatch?: Dispatch,
1540
- category?: string,
1541
- insertAfterPos?: number
1534
+ category?: string
1542
1535
  ) => {
1543
1536
  if (!templateAllows(state, schema.nodes.trans_abstract)) {
1544
1537
  return false
@@ -1566,11 +1559,8 @@ export const insertTransAbstract = (
1566
1559
  )
1567
1560
 
1568
1561
  const abstracts = findAbstractsNode(state.doc)
1569
-
1570
- const pos =
1571
- insertAfterPos != null
1572
- ? insertAfterPos
1573
- : abstracts.pos + abstracts.node.nodeSize - 1
1562
+ // append at the end of the abstracts node, not just the first valid-but-earlier slot.
1563
+ const pos = abstracts.node.content.size + abstracts.pos + 1
1574
1564
  const tr = state.tr.insert(pos, node)
1575
1565
 
1576
1566
  const selection = TextSelection.create(tr.doc, pos + 1)
@@ -1581,7 +1571,7 @@ export const insertTransAbstract = (
1581
1571
  }
1582
1572
 
1583
1573
  export const insertTransGraphicalAbstract =
1584
- (category: SectionCategory, insertAfterPos?: number) =>
1574
+ (category: SectionCategory) =>
1585
1575
  (state: ManuscriptEditorState, dispatch?: Dispatch, view?: EditorView) => {
1586
1576
  if (!templateAllows(state, schema.nodes.trans_graphical_abstract)) {
1587
1577
  return false
@@ -1593,10 +1583,7 @@ export const insertTransGraphicalAbstract =
1593
1583
  const lang = state.doc.attrs.primaryLanguageCode || 'en'
1594
1584
 
1595
1585
  const abstracts = findAbstractsNode(state.doc)
1596
- const pos =
1597
- insertAfterPos != null
1598
- ? insertAfterPos
1599
- : abstracts.pos + abstracts.node.content.size + 1
1586
+ const pos = abstracts.node.content.size + abstracts.pos + 1
1600
1587
 
1601
1588
  const node = schema.nodes.trans_graphical_abstract.createAndFill(
1602
1589
  {
@@ -28,16 +28,31 @@ export const Metadata = styled.div`
28
28
  `
29
29
 
30
30
  export const MetadataContainer = styled.div`
31
+ position: relative;
31
32
  flex: 1;
32
33
  `
33
34
 
34
35
  export const ReferenceLine: React.FC<{
35
36
  item: BibliographyItemAttrs
36
- }> = ({ item }) => (
37
+ showUncited?: boolean
38
+ }> = ({ item, showUncited }) => (
37
39
  <MetadataContainer>
40
+ {showUncited && <UncitedBadge>UNCITED</UncitedBadge>}
38
41
  <div data-cy={'reference-title'}>
39
42
  {item.title || item.literal || 'Untitled'}
40
43
  </div>
41
44
  <Metadata>{metadata(item)}</Metadata>
42
45
  </MetadataContainer>
43
46
  )
47
+
48
+ const UncitedBadge = styled.span`
49
+ padding: 1px 6px;
50
+ display: flex;
51
+ margin-bottom: 2px;
52
+ max-width: max-content;
53
+ border-radius: 4px;
54
+ color: #353535;
55
+ background-color: #f7b314;
56
+ font-size: 10px;
57
+ font-weight: 500;
58
+ `