@manuscripts/body-editor 2.8.75-LEAN-4574.1 → 2.8.76

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 (72) hide show
  1. package/dist/cjs/clipboard.js +2 -23
  2. package/dist/cjs/components/references/ImportBibliographyForm.js +8 -8
  3. package/dist/cjs/components/references/ReferenceForm/PersonDropDown.js +2 -2
  4. package/dist/cjs/components/references/ReferenceForm/ReferenceForm.js +31 -42
  5. package/dist/cjs/components/references/ReferenceForm/config.js +13 -1
  6. package/dist/cjs/components/views/TableCellContextMenu.js +12 -11
  7. package/dist/cjs/index.js +1 -2
  8. package/dist/cjs/lib/context-menu.js +12 -8
  9. package/dist/cjs/lib/crossref.js +32 -1
  10. package/dist/cjs/lib/references.js +1 -67
  11. package/dist/cjs/lib/utils.js +3 -1
  12. package/dist/cjs/plugins/bibliography/bibliography-utils.js +84 -0
  13. package/dist/cjs/plugins/bibliography/index.js +128 -0
  14. package/dist/cjs/plugins/tables-cursor-fix.js +4 -1
  15. package/dist/cjs/versions.js +1 -1
  16. package/dist/cjs/views/bibliography_element.js +1 -1
  17. package/dist/cjs/views/bullet_list.js +44 -0
  18. package/dist/cjs/views/bullet_list_editable.js +21 -0
  19. package/dist/cjs/views/list.js +6 -23
  20. package/dist/cjs/views/ordered_list.js +53 -0
  21. package/dist/cjs/views/ordered_list_editable.js +21 -0
  22. package/dist/cjs/views/table_element.js +0 -1
  23. package/dist/es/clipboard.js +2 -22
  24. package/dist/es/components/references/ImportBibliographyForm.js +8 -8
  25. package/dist/es/components/references/ReferenceForm/PersonDropDown.js +2 -2
  26. package/dist/es/components/references/ReferenceForm/ReferenceForm.js +30 -41
  27. package/dist/es/components/references/ReferenceForm/config.js +12 -0
  28. package/dist/es/components/views/TableCellContextMenu.js +12 -11
  29. package/dist/es/index.js +1 -1
  30. package/dist/es/lib/context-menu.js +13 -9
  31. package/dist/es/lib/crossref.js +32 -1
  32. package/dist/es/lib/references.js +0 -42
  33. package/dist/es/lib/utils.js +3 -1
  34. package/dist/es/plugins/bibliography/bibliography-utils.js +77 -0
  35. package/dist/es/plugins/bibliography/index.js +124 -0
  36. package/dist/es/plugins/tables-cursor-fix.js +4 -1
  37. package/dist/es/versions.js +1 -1
  38. package/dist/es/views/bibliography_element.js +1 -1
  39. package/dist/es/views/bullet_list.js +36 -0
  40. package/dist/es/views/bullet_list_editable.js +19 -0
  41. package/dist/es/views/citation_editable.js +1 -1
  42. package/dist/es/views/list.js +5 -21
  43. package/dist/es/views/ordered_list.js +45 -0
  44. package/dist/es/views/ordered_list_editable.js +19 -0
  45. package/dist/es/views/table_element.js +0 -1
  46. package/dist/types/clipboard.d.ts +0 -1
  47. package/dist/types/components/references/BibliographyItemSource.d.ts +1 -1
  48. package/dist/types/components/references/CitationEditor.d.ts +1 -1
  49. package/dist/types/components/references/CitationViewer.d.ts +1 -1
  50. package/dist/types/components/references/ReferenceForm/PersonDropDown.d.ts +4 -4
  51. package/dist/types/components/references/ReferenceForm/ReferenceForm.d.ts +1 -1
  52. package/dist/types/components/references/ReferenceForm/config.d.ts +1 -0
  53. package/dist/types/components/references/ReferenceLine.d.ts +1 -1
  54. package/dist/types/components/references/ReferenceSearch.d.ts +1 -1
  55. package/dist/types/components/references/ReferenceSearchResults.d.ts +1 -1
  56. package/dist/types/components/references/ReferenceSearchSection.d.ts +1 -1
  57. package/dist/types/components/references/ReferencesModal.d.ts +1 -1
  58. package/dist/types/index.d.ts +1 -1
  59. package/dist/types/lib/context-menu.d.ts +1 -0
  60. package/dist/types/lib/references.d.ts +4 -3
  61. package/dist/types/plugins/bibliography/bibliography-utils.d.ts +25 -0
  62. package/dist/types/plugins/{bibliography.d.ts → bibliography/index.d.ts} +9 -9
  63. package/dist/types/versions.d.ts +1 -1
  64. package/dist/types/views/bullet_list.d.ts +25 -0
  65. package/dist/types/views/bullet_list_editable.d.ts +44 -0
  66. package/dist/types/views/list.d.ts +1 -2
  67. package/dist/types/views/ordered_list.d.ts +30 -0
  68. package/dist/types/views/ordered_list_editable.d.ts +44 -0
  69. package/dist/types/views/table_element.d.ts +0 -1
  70. package/package.json +3 -11
  71. package/dist/cjs/plugins/bibliography.js +0 -177
  72. package/dist/es/plugins/bibliography.js +0 -149
@@ -1,149 +0,0 @@
1
- /*!
2
- * © 2019 Atypon Systems LLC
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { buildCiteprocCitation, isBibliographyElementNode, isBibliographyItemNode, isCitationNode, } from '@manuscripts/transform';
17
- import * as Citeproc from 'citeproc';
18
- import { isEqual } from 'lodash';
19
- import { Plugin, PluginKey } from 'prosemirror-state';
20
- import { Decoration, DecorationSet } from 'prosemirror-view';
21
- export const bibliographyKey = new PluginKey('bibliography');
22
- export default (props) => {
23
- return new Plugin({
24
- key: bibliographyKey,
25
- state: {
26
- init(config, instance) {
27
- return buildBibliographyPluginState(instance.doc, props.cslProps);
28
- },
29
- apply(tr, value) {
30
- if (!tr.steps.length) {
31
- return value;
32
- }
33
- return buildBibliographyPluginState(tr.doc, props.cslProps, value);
34
- },
35
- },
36
- props: {
37
- decorations(state) {
38
- const bib = getBibliographyPluginState(state);
39
- return DecorationSet.create(state.doc, bib ? buildDecorations(bib, state.doc) : []);
40
- },
41
- },
42
- });
43
- };
44
- let version = 1;
45
- const buildBibliographyPluginState = (doc, csl, $old) => {
46
- const nodesMap = new Map();
47
- const bibliographyItems = new Map();
48
- doc.descendants((node, pos) => {
49
- if (isCitationNode(node)) {
50
- nodesMap.set(node.attrs.id, [node, pos]);
51
- }
52
- if (isBibliographyItemNode(node)) {
53
- bibliographyItems.set(node.attrs.id, node.attrs);
54
- }
55
- });
56
- const nodes = Array.from(nodesMap.values());
57
- const citations = nodes.map(([node]) => buildCiteprocCitation(node.attrs));
58
- const $new = {
59
- citationNodes: nodes,
60
- citations,
61
- bibliographyItems,
62
- };
63
- if (!csl.style) {
64
- return $new;
65
- }
66
- if ($old &&
67
- isEqual(citations, $old.citations) &&
68
- isEqual(bibliographyItems, $old.bibliographyItems)) {
69
- $new.version = $old.version;
70
- $new.citationCounts = $old.citationCounts;
71
- $new.engine = $old.engine;
72
- $new.renderedCitations = $old.renderedCitations;
73
- }
74
- else {
75
- const citationCounts = new Map();
76
- const rids = nodes.flatMap((e) => e[0].attrs.rids);
77
- rids.forEach((rid) => {
78
- const count = citationCounts.get(rid) || 0;
79
- citationCounts.set(rid, count + 1);
80
- });
81
- const engine = new Citeproc.Engine({
82
- retrieveLocale: () => csl.locale,
83
- retrieveItem: (id) => {
84
- const item = bibliographyItems.get(id);
85
- if (!item) {
86
- throw Error(`Missing bibliography item with id ${id}`);
87
- }
88
- return item;
89
- },
90
- }, csl.style, 'en-US');
91
- const citationTexts = engine.rebuildProcessorState(nodes.map(([node]) => buildCiteprocCitation(node.attrs)));
92
- $new.version = String(version++);
93
- $new.citationCounts = citationCounts;
94
- $new.engine = engine;
95
- $new.renderedCitations = new Map(citationTexts.map((i) => [i[0], i[2]]));
96
- }
97
- return $new;
98
- };
99
- export const buildDecorations = (state, doc) => {
100
- const decorations = [];
101
- let hasMissingItems = false;
102
- for (const [node, pos] of state.citationNodes) {
103
- const rids = node.attrs.rids;
104
- if (rids.length) {
105
- for (const rid of rids) {
106
- if (!state.bibliographyItems.has(rid)) {
107
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
108
- class: 'citation-missing',
109
- }));
110
- hasMissingItems = true;
111
- }
112
- }
113
- }
114
- else {
115
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
116
- class: 'citation-empty',
117
- }));
118
- }
119
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
120
- version: state.version,
121
- }));
122
- }
123
- if (hasMissingItems) {
124
- doc.descendants((node, pos) => {
125
- if (isBibliographyElementNode(node)) {
126
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
127
- missing: 'true',
128
- }));
129
- decorations.push(Decoration.widget(pos, () => {
130
- const el = document.createElement('div');
131
- el.className = 'bibliography-missing';
132
- el.textContent = `The bibliography could not be generated, due to a missing library item.`;
133
- return el;
134
- }));
135
- }
136
- });
137
- }
138
- doc.descendants((node, pos) => {
139
- if (isBibliographyElementNode(node)) {
140
- decorations.push(Decoration.node(pos, pos + node.nodeSize, {
141
- version: state.version,
142
- }));
143
- }
144
- });
145
- return decorations;
146
- };
147
- export const getBibliographyPluginState = (state) => {
148
- return bibliographyKey.getState(state);
149
- };