@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.
- package/dist/cjs/clipboard.js +2 -23
- package/dist/cjs/components/references/ImportBibliographyForm.js +8 -8
- package/dist/cjs/components/references/ReferenceForm/PersonDropDown.js +2 -2
- package/dist/cjs/components/references/ReferenceForm/ReferenceForm.js +31 -42
- package/dist/cjs/components/references/ReferenceForm/config.js +13 -1
- package/dist/cjs/components/views/TableCellContextMenu.js +12 -11
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/lib/context-menu.js +12 -8
- package/dist/cjs/lib/crossref.js +32 -1
- package/dist/cjs/lib/references.js +1 -67
- package/dist/cjs/lib/utils.js +3 -1
- package/dist/cjs/plugins/bibliography/bibliography-utils.js +84 -0
- package/dist/cjs/plugins/bibliography/index.js +128 -0
- package/dist/cjs/plugins/tables-cursor-fix.js +4 -1
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/bibliography_element.js +1 -1
- package/dist/cjs/views/bullet_list.js +44 -0
- package/dist/cjs/views/bullet_list_editable.js +21 -0
- package/dist/cjs/views/list.js +6 -23
- package/dist/cjs/views/ordered_list.js +53 -0
- package/dist/cjs/views/ordered_list_editable.js +21 -0
- package/dist/cjs/views/table_element.js +0 -1
- package/dist/es/clipboard.js +2 -22
- package/dist/es/components/references/ImportBibliographyForm.js +8 -8
- package/dist/es/components/references/ReferenceForm/PersonDropDown.js +2 -2
- package/dist/es/components/references/ReferenceForm/ReferenceForm.js +30 -41
- package/dist/es/components/references/ReferenceForm/config.js +12 -0
- package/dist/es/components/views/TableCellContextMenu.js +12 -11
- package/dist/es/index.js +1 -1
- package/dist/es/lib/context-menu.js +13 -9
- package/dist/es/lib/crossref.js +32 -1
- package/dist/es/lib/references.js +0 -42
- package/dist/es/lib/utils.js +3 -1
- package/dist/es/plugins/bibliography/bibliography-utils.js +77 -0
- package/dist/es/plugins/bibliography/index.js +124 -0
- package/dist/es/plugins/tables-cursor-fix.js +4 -1
- package/dist/es/versions.js +1 -1
- package/dist/es/views/bibliography_element.js +1 -1
- package/dist/es/views/bullet_list.js +36 -0
- package/dist/es/views/bullet_list_editable.js +19 -0
- package/dist/es/views/citation_editable.js +1 -1
- package/dist/es/views/list.js +5 -21
- package/dist/es/views/ordered_list.js +45 -0
- package/dist/es/views/ordered_list_editable.js +19 -0
- package/dist/es/views/table_element.js +0 -1
- package/dist/types/clipboard.d.ts +0 -1
- package/dist/types/components/references/BibliographyItemSource.d.ts +1 -1
- package/dist/types/components/references/CitationEditor.d.ts +1 -1
- package/dist/types/components/references/CitationViewer.d.ts +1 -1
- package/dist/types/components/references/ReferenceForm/PersonDropDown.d.ts +4 -4
- package/dist/types/components/references/ReferenceForm/ReferenceForm.d.ts +1 -1
- package/dist/types/components/references/ReferenceForm/config.d.ts +1 -0
- package/dist/types/components/references/ReferenceLine.d.ts +1 -1
- package/dist/types/components/references/ReferenceSearch.d.ts +1 -1
- package/dist/types/components/references/ReferenceSearchResults.d.ts +1 -1
- package/dist/types/components/references/ReferenceSearchSection.d.ts +1 -1
- package/dist/types/components/references/ReferencesModal.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/context-menu.d.ts +1 -0
- package/dist/types/lib/references.d.ts +4 -3
- package/dist/types/plugins/bibliography/bibliography-utils.d.ts +25 -0
- package/dist/types/plugins/{bibliography.d.ts → bibliography/index.d.ts} +9 -9
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/bullet_list.d.ts +25 -0
- package/dist/types/views/bullet_list_editable.d.ts +44 -0
- package/dist/types/views/list.d.ts +1 -2
- package/dist/types/views/ordered_list.d.ts +30 -0
- package/dist/types/views/ordered_list_editable.d.ts +44 -0
- package/dist/types/views/table_element.d.ts +0 -1
- package/package.json +3 -11
- package/dist/cjs/plugins/bibliography.js +0 -177
- package/dist/es/plugins/bibliography.js +0 -149
package/dist/es/index.js
CHANGED
|
@@ -39,5 +39,5 @@ export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
|
|
|
39
39
|
export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
|
|
40
40
|
export { searchReplaceKey as searchReplacePluginKey, } from './plugins/search-replace';
|
|
41
41
|
export { getNewMatch, getClosestMatch } from './plugins/search-replace/lib';
|
|
42
|
-
export { metadata
|
|
42
|
+
export { metadata } from './lib/references';
|
|
43
43
|
export { authorLabel, affiliationLabel, } from './lib/authors';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ImageDefaultIcon, ImageLeftIcon, ImageRightIcon, TriangleCollapsedIcon, } from '@manuscripts/style-guide';
|
|
17
|
-
import { isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
|
|
17
|
+
import { getListType, isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
|
|
18
18
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
19
19
|
import { createElement } from 'react';
|
|
20
20
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
@@ -185,20 +185,17 @@ export class ContextMenu {
|
|
|
185
185
|
}
|
|
186
186
|
if (type === schema.nodes.list) {
|
|
187
187
|
menu.appendChild(this.createMenuSection((section) => {
|
|
188
|
-
const
|
|
189
|
-
|
|
188
|
+
const attrs = this.node.attrs;
|
|
189
|
+
const listType = getListType(attrs.listStyleType).style;
|
|
190
|
+
if (listType === 'none' || listType === 'disc') {
|
|
190
191
|
section.appendChild(this.createMenuItem('Change to Numbered List', () => {
|
|
191
|
-
|
|
192
|
-
tr.setNodeAttribute(this.getPos(), 'listStyleType', 'order');
|
|
193
|
-
this.view.dispatch(tr);
|
|
192
|
+
this.changeNodeType(null, 'order');
|
|
194
193
|
popper.destroy();
|
|
195
194
|
}));
|
|
196
195
|
}
|
|
197
196
|
else {
|
|
198
197
|
section.appendChild(this.createMenuItem('Change to Bulleted list', () => {
|
|
199
|
-
|
|
200
|
-
tr.setNodeAttribute(this.getPos(), 'listStyleType', 'bullet');
|
|
201
|
-
this.view.dispatch(tr);
|
|
198
|
+
this.changeNodeType(null, 'bullet');
|
|
202
199
|
popper.destroy();
|
|
203
200
|
}));
|
|
204
201
|
}
|
|
@@ -343,6 +340,13 @@ export class ContextMenu {
|
|
|
343
340
|
checkNode('pullquote_element');
|
|
344
341
|
return insertable;
|
|
345
342
|
};
|
|
343
|
+
this.changeNodeType = (nodeType, listType) => {
|
|
344
|
+
this.view.dispatch(this.view.state.tr.setNodeMarkup(this.getPos(), nodeType, {
|
|
345
|
+
id: this.node.attrs.id,
|
|
346
|
+
listStyleType: listType,
|
|
347
|
+
}));
|
|
348
|
+
popper.destroy();
|
|
349
|
+
};
|
|
346
350
|
this.deleteNode = (nodeType) => {
|
|
347
351
|
switch (nodeType.name) {
|
|
348
352
|
case 'section_title': {
|
package/dist/es/lib/crossref.js
CHANGED
|
@@ -22,6 +22,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
22
22
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
+
import { buildBibliographicDate, buildBibliographicName, generateID, ObjectTypes, } from '@manuscripts/json-schema';
|
|
26
|
+
import { fixCSLData } from '@manuscripts/library';
|
|
25
27
|
import { BibliographyItemSearch, } from '../components/references/BibliographyItemSource';
|
|
26
28
|
const search = (query, limit) => {
|
|
27
29
|
const controller = new AbortController();
|
|
@@ -46,10 +48,39 @@ const searchAsync = (params, controller) => __awaiter(void 0, void 0, void 0, fu
|
|
|
46
48
|
const items = data.message.items;
|
|
47
49
|
const total = data.message['total-results'];
|
|
48
50
|
return {
|
|
49
|
-
items,
|
|
51
|
+
items: items.map((i) => parseCSLData(fixCSLData(i))),
|
|
50
52
|
total,
|
|
51
53
|
};
|
|
52
54
|
});
|
|
55
|
+
const parseCSLData = (data) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
return ({
|
|
58
|
+
id: generateID(ObjectTypes.BibliographyItem),
|
|
59
|
+
type: data.type,
|
|
60
|
+
author: (_a = data.author) === null || _a === void 0 ? void 0 : _a.map(buildBibliographicName),
|
|
61
|
+
issued: buildBibliographicDate(data.issued),
|
|
62
|
+
'container-title': data['container-title'],
|
|
63
|
+
DOI: data.DOI,
|
|
64
|
+
volume: data.volume ? String(data.volume) : undefined,
|
|
65
|
+
issue: data.issue ? String(data.issue) : undefined,
|
|
66
|
+
page: data.page,
|
|
67
|
+
title: data.title,
|
|
68
|
+
editor: (_b = data.editor) === null || _b === void 0 ? void 0 : _b.map(buildBibliographicName),
|
|
69
|
+
edition: data.edition ? String(data.edition) : undefined,
|
|
70
|
+
'collection-title': data['collection-title'],
|
|
71
|
+
'publisher-place': data['publisher-place'],
|
|
72
|
+
publisher: data.publisher,
|
|
73
|
+
event: data.event,
|
|
74
|
+
'event-date': buildBibliographicDate(data['event-date']),
|
|
75
|
+
'event-place': data['event-place'],
|
|
76
|
+
URL: data.URL,
|
|
77
|
+
accessed: buildBibliographicDate(data.accessed),
|
|
78
|
+
'number-of-pages': data['number-of-pages']
|
|
79
|
+
? String(data['number-of-pages'])
|
|
80
|
+
: undefined,
|
|
81
|
+
locator: data.locator,
|
|
82
|
+
});
|
|
83
|
+
};
|
|
53
84
|
export const Crossref = {
|
|
54
85
|
id: 'crossref',
|
|
55
86
|
label: 'External sources',
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { Cite } from '@citation-js/core';
|
|
11
1
|
export const metadata = (item) => {
|
|
12
2
|
return [authors(item), item['container-title'], issuedYear(item)]
|
|
13
3
|
.filter(Boolean)
|
|
@@ -36,35 +26,3 @@ export const authors = (item) => {
|
|
|
36
26
|
}
|
|
37
27
|
return authors.join(', ');
|
|
38
28
|
};
|
|
39
|
-
const loadCitationJsPlugins = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
try {
|
|
41
|
-
yield Promise.all([
|
|
42
|
-
import('@citation-js/plugin-bibtex'),
|
|
43
|
-
import('@citation-js/plugin-ris'),
|
|
44
|
-
import('@citation-js/plugin-doi'),
|
|
45
|
-
import('@citation-js/plugin-csl'),
|
|
46
|
-
import('@citation-js/plugin-pubmed'),
|
|
47
|
-
import('@citation-js/plugin-enw'),
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
console.error('Failed to load citation plugins:', error);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
export const importBibliographyItems = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
yield loadCitationJsPlugins();
|
|
56
|
-
const cite = yield Cite.async(data.trim());
|
|
57
|
-
return cite.data;
|
|
58
|
-
});
|
|
59
|
-
export const bibliographyItemTypes = [
|
|
60
|
-
['article-journal', 'Journal Article'],
|
|
61
|
-
['book', 'Book'],
|
|
62
|
-
['chapter', 'Chapter'],
|
|
63
|
-
['confproc', 'Conference Paper'],
|
|
64
|
-
['thesis', 'Thesis'],
|
|
65
|
-
['webpage', 'Web Page'],
|
|
66
|
-
['other', 'Other'],
|
|
67
|
-
['standard', 'Standard'],
|
|
68
|
-
['dataset', 'Dataset'],
|
|
69
|
-
['preprint', 'Preprint'],
|
|
70
|
-
];
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -109,10 +109,12 @@ export const cleanItemValues = (item) => {
|
|
|
109
109
|
break;
|
|
110
110
|
case 'author':
|
|
111
111
|
case 'editor':
|
|
112
|
+
cleanedItem[key] = [];
|
|
113
|
+
break;
|
|
112
114
|
case 'issued':
|
|
113
115
|
case 'accessed':
|
|
114
116
|
case 'event-date':
|
|
115
|
-
cleanedItem[key] =
|
|
117
|
+
cleanedItem[key] = {};
|
|
116
118
|
break;
|
|
117
119
|
default:
|
|
118
120
|
cleanedItem[key] = '';
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { Decoration } from 'prosemirror-view';
|
|
17
|
+
export const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
|
|
18
|
+
export const buildDecorations = (state, doc) => {
|
|
19
|
+
const decorations = [];
|
|
20
|
+
let hasMissingItems = false;
|
|
21
|
+
for (const [node, pos] of state.citationNodes) {
|
|
22
|
+
const rids = node.attrs.rids;
|
|
23
|
+
if (rids.length) {
|
|
24
|
+
for (const rid of rids) {
|
|
25
|
+
if (!state.bibliographyItems.has(rid)) {
|
|
26
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
27
|
+
class: 'citation-missing',
|
|
28
|
+
}));
|
|
29
|
+
hasMissingItems = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
35
|
+
class: 'citation-empty',
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
39
|
+
version: state.version,
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
if (hasMissingItems) {
|
|
43
|
+
doc.descendants((node, pos) => {
|
|
44
|
+
if (isBibliographyElement(node)) {
|
|
45
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
46
|
+
missing: 'true',
|
|
47
|
+
}));
|
|
48
|
+
decorations.push(Decoration.widget(pos, () => {
|
|
49
|
+
const el = document.createElement('div');
|
|
50
|
+
el.className = 'bibliography-missing';
|
|
51
|
+
el.textContent = `The bibliography could not be generated, due to a missing library item.`;
|
|
52
|
+
return el;
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
doc.descendants((node, pos) => {
|
|
58
|
+
if (isBibliographyElement(node)) {
|
|
59
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
60
|
+
version: state.version,
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return decorations;
|
|
65
|
+
};
|
|
66
|
+
export const getLatest = (a, b) => a.updatedAt > b.updatedAt ? a : b;
|
|
67
|
+
export const buildCitations = (citations) => citations
|
|
68
|
+
.map((c) => c[0].attrs)
|
|
69
|
+
.map((attrs) => ({
|
|
70
|
+
citationID: attrs.id,
|
|
71
|
+
citationItems: attrs.rids.map((rid) => ({
|
|
72
|
+
id: rid,
|
|
73
|
+
})),
|
|
74
|
+
properties: {
|
|
75
|
+
noteIndex: 0,
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
27
|
+
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
28
|
+
import { CitationProvider } from '@manuscripts/library';
|
|
29
|
+
import { isCitationNode, schema, } from '@manuscripts/transform';
|
|
30
|
+
import { isEqual, pickBy } from 'lodash';
|
|
31
|
+
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
32
|
+
import { findChildrenByType } from 'prosemirror-utils';
|
|
33
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
34
|
+
import { isHidden } from '../../lib/track-changes-utils';
|
|
35
|
+
import { buildCitations, buildDecorations, } from './bibliography-utils';
|
|
36
|
+
export const bibliographyKey = new PluginKey('bibliography');
|
|
37
|
+
export default (props) => {
|
|
38
|
+
return new Plugin({
|
|
39
|
+
key: bibliographyKey,
|
|
40
|
+
state: {
|
|
41
|
+
init(config, instance) {
|
|
42
|
+
return buildBibliographyPluginState(instance.doc, props.cslProps);
|
|
43
|
+
},
|
|
44
|
+
apply(tr, value) {
|
|
45
|
+
if (!tr.steps.length) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
return buildBibliographyPluginState(tr.doc, props.cslProps, value);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
props: {
|
|
52
|
+
decorations(state) {
|
|
53
|
+
const bib = getBibliographyPluginState(state);
|
|
54
|
+
return DecorationSet.create(state.doc, bib ? buildDecorations(bib, state.doc) : []);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
let version = 1;
|
|
60
|
+
const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
61
|
+
const nodesMap = new Map();
|
|
62
|
+
doc.descendants((node, pos) => {
|
|
63
|
+
if (isCitationNode(node)) {
|
|
64
|
+
nodesMap.set(node.attrs.id, [node, pos]);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const nodes = Array.from(nodesMap.values());
|
|
68
|
+
const bibliographyItems = getBibliographyItemAttrs(doc);
|
|
69
|
+
const citations = buildCitations(nodes);
|
|
70
|
+
const $new = {
|
|
71
|
+
citationNodes: nodes,
|
|
72
|
+
citations,
|
|
73
|
+
bibliographyItems,
|
|
74
|
+
};
|
|
75
|
+
if (!csl.style) {
|
|
76
|
+
return $new;
|
|
77
|
+
}
|
|
78
|
+
if ($old &&
|
|
79
|
+
isEqual(citations, $old.citations) &&
|
|
80
|
+
isEqual(bibliographyItems, $old.bibliographyItems)) {
|
|
81
|
+
$new.version = $old.version;
|
|
82
|
+
$new.citationCounts = $old.citationCounts;
|
|
83
|
+
$new.provider = $old.provider;
|
|
84
|
+
$new.renderedCitations = $old.renderedCitations;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const citationCounts = new Map();
|
|
88
|
+
const rids = nodes.flatMap((e) => e[0].attrs.rids);
|
|
89
|
+
rids.forEach((rid) => {
|
|
90
|
+
const count = citationCounts.get(rid) || 0;
|
|
91
|
+
citationCounts.set(rid, count + 1);
|
|
92
|
+
});
|
|
93
|
+
const provider = new CitationProvider({
|
|
94
|
+
getLibraryItem: (id) => getBibliographyItem(bibliographyItems.get(id)),
|
|
95
|
+
citationStyle: csl.style || '',
|
|
96
|
+
locale: csl.locale,
|
|
97
|
+
});
|
|
98
|
+
const citationTexts = provider.rebuildState(buildCitations(nodes));
|
|
99
|
+
$new.version = String(version++);
|
|
100
|
+
$new.citationCounts = citationCounts;
|
|
101
|
+
$new.provider = provider;
|
|
102
|
+
$new.renderedCitations = new Map(citationTexts.map((i) => [i[0], i[2]]));
|
|
103
|
+
}
|
|
104
|
+
return $new;
|
|
105
|
+
};
|
|
106
|
+
const getBibliographyItem = (attrs) => {
|
|
107
|
+
if (!attrs) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const { id } = attrs, rest = __rest(attrs, ["id"]);
|
|
111
|
+
const item = Object.assign({ _id: id, objectType: ObjectTypes.BibliographyItem }, rest);
|
|
112
|
+
return pickBy(item, (v) => v !== undefined);
|
|
113
|
+
};
|
|
114
|
+
const getBibliographyItemAttrs = (doc) => {
|
|
115
|
+
const attrs = new Map();
|
|
116
|
+
findChildrenByType(doc, schema.nodes.bibliography_item)
|
|
117
|
+
.filter((n) => !isHidden(n.node))
|
|
118
|
+
.map((n) => n.node.attrs)
|
|
119
|
+
.forEach((a) => attrs.set(a.id, a));
|
|
120
|
+
return attrs;
|
|
121
|
+
};
|
|
122
|
+
export const getBibliographyPluginState = (state) => {
|
|
123
|
+
return bibliographyKey.getState(state);
|
|
124
|
+
};
|
|
@@ -42,7 +42,10 @@ export default () => {
|
|
|
42
42
|
const isTableShapeSelected = (state) => {
|
|
43
43
|
if (state.selection instanceof CellSelection) {
|
|
44
44
|
const rect = selectedRect(state);
|
|
45
|
-
return rect.
|
|
45
|
+
return (rect.left === 0 &&
|
|
46
|
+
rect.top === 0 &&
|
|
47
|
+
rect.right === rect.map.width &&
|
|
48
|
+
rect.bottom === rect.map.height);
|
|
46
49
|
}
|
|
47
50
|
return false;
|
|
48
51
|
};
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.8.
|
|
1
|
+
export const VERSION = '2.8.76';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -167,7 +167,7 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
167
167
|
const wrapper = document.createElement('div');
|
|
168
168
|
wrapper.classList.add('contents');
|
|
169
169
|
wrapper.addEventListener('click', this.handleClick);
|
|
170
|
-
const [meta, bibliography] = bib.
|
|
170
|
+
const [meta, bibliography] = bib.provider.makeBibliography();
|
|
171
171
|
for (let i = 0; i < bibliography.length; i++) {
|
|
172
172
|
const id = meta.entry_ids[i][0];
|
|
173
173
|
const fragment = bibliography[i];
|
|
@@ -0,0 +1,36 @@
|
|
|
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 BlockView from './block_view';
|
|
17
|
+
import { createNodeOrElementView } from './creators';
|
|
18
|
+
import { JATS_HTML_LIST_STYLE_MAPPING } from './ordered_list';
|
|
19
|
+
export class BulletListView extends BlockView {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.elementType = 'ul';
|
|
23
|
+
}
|
|
24
|
+
updateContents() {
|
|
25
|
+
super.updateContents();
|
|
26
|
+
if (this.contentDOM) {
|
|
27
|
+
const type = this.node.attrs.listStyleType || 'bullet';
|
|
28
|
+
this.contentDOM.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const bulletListCallback = (node, dom) => {
|
|
33
|
+
const type = node.attrs.listStyleType || 'bullet';
|
|
34
|
+
dom.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
|
|
35
|
+
};
|
|
36
|
+
export default createNodeOrElementView(BulletListView, 'ul', bulletListCallback);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { bulletListCallback, BulletListView } from './bullet_list';
|
|
17
|
+
import { createNodeOrElementView } from './creators';
|
|
18
|
+
import { EditableBlock } from './editable_block';
|
|
19
|
+
export default createNodeOrElementView(EditableBlock(BulletListView), 'ul', bulletListCallback);
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { ContextMenu } from '@manuscripts/style-guide';
|
|
17
|
-
import { schema
|
|
17
|
+
import { schema } from '@manuscripts/transform';
|
|
18
18
|
import { TextSelection } from 'prosemirror-state';
|
|
19
19
|
import { findChildrenByType } from 'prosemirror-utils';
|
|
20
20
|
import { CitationEditor, } from '../components/references/CitationEditor';
|
package/dist/es/views/list.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { getListType, } from '@manuscripts/transform';
|
|
16
17
|
import BlockView from './block_view';
|
|
17
18
|
import { createNodeOrElementView } from './creators';
|
|
18
19
|
import { EditableBlock } from './editable_block';
|
|
@@ -23,33 +24,16 @@ export class ListView extends BlockView {
|
|
|
23
24
|
}
|
|
24
25
|
updateContents() {
|
|
25
26
|
super.updateContents();
|
|
27
|
+
const actualAttrs = this.node.attrs;
|
|
26
28
|
if (this.contentDOM) {
|
|
27
|
-
const type =
|
|
28
|
-
this.contentDOM.style.listStyleType =
|
|
29
|
+
const type = actualAttrs.listStyleType;
|
|
30
|
+
this.contentDOM.style.listStyleType = getListType(type).style;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
export const listCallback = (node, dom) => {
|
|
33
35
|
dom.classList.add('list');
|
|
34
36
|
const type = node.attrs.listStyleType;
|
|
35
|
-
dom.style.listStyleType =
|
|
37
|
+
dom.style.listStyleType = getListType(type).style;
|
|
36
38
|
};
|
|
37
39
|
export default createNodeOrElementView(EditableBlock(ListView), 'ul', listCallback);
|
|
38
|
-
export const getCssListStyleType = (type) => {
|
|
39
|
-
switch (type) {
|
|
40
|
-
case 'bullet':
|
|
41
|
-
return 'disc';
|
|
42
|
-
case 'order':
|
|
43
|
-
return 'decimal';
|
|
44
|
-
case 'alpha-lower':
|
|
45
|
-
return 'lower-alpha';
|
|
46
|
-
case 'alpha-upper':
|
|
47
|
-
return 'upper-alpha';
|
|
48
|
-
case 'roman-lower':
|
|
49
|
-
return 'lower-roman';
|
|
50
|
-
case 'roman-upper':
|
|
51
|
-
return 'upper-roman';
|
|
52
|
-
case 'simple':
|
|
53
|
-
return 'none';
|
|
54
|
-
}
|
|
55
|
-
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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 BlockView from './block_view';
|
|
17
|
+
import { createNodeOrElementView } from './creators';
|
|
18
|
+
export const JATS_HTML_LIST_STYLE_MAPPING = {
|
|
19
|
+
simple: 'none',
|
|
20
|
+
bullet: 'disc',
|
|
21
|
+
order: 'decimal',
|
|
22
|
+
'alpha-lower': 'lower-alpha',
|
|
23
|
+
'alpha-upper': 'upper-alpha',
|
|
24
|
+
'roman-lower': 'lower-roman',
|
|
25
|
+
'roman-upper': 'upper-roman',
|
|
26
|
+
};
|
|
27
|
+
export class OrderedListView extends BlockView {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this.elementType = 'ol';
|
|
31
|
+
}
|
|
32
|
+
updateContents() {
|
|
33
|
+
super.updateContents();
|
|
34
|
+
if (this.contentDOM) {
|
|
35
|
+
const type = this.node.attrs.listStyleType || 'order';
|
|
36
|
+
this.contentDOM.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const orderedListCallback = (node, dom) => {
|
|
41
|
+
dom.classList.add('list');
|
|
42
|
+
const type = node.attrs.listStyleType || 'order';
|
|
43
|
+
dom.style.listStyleType = JATS_HTML_LIST_STYLE_MAPPING[type];
|
|
44
|
+
};
|
|
45
|
+
export default createNodeOrElementView(OrderedListView, 'ol', orderedListCallback);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 { createNodeOrElementView } from './creators';
|
|
17
|
+
import { EditableBlock } from './editable_block';
|
|
18
|
+
import { orderedListCallback, OrderedListView } from './ordered_list';
|
|
19
|
+
export default createNodeOrElementView(EditableBlock(OrderedListView), 'ol', orderedListCallback);
|
|
@@ -19,7 +19,6 @@ export class TableElementView extends BlockView {
|
|
|
19
19
|
constructor() {
|
|
20
20
|
super(...arguments);
|
|
21
21
|
this.elementType = 'figure';
|
|
22
|
-
this.ignoreMutation = () => true;
|
|
23
22
|
this.createElement = () => {
|
|
24
23
|
this.contentDOM = document.createElement('figure');
|
|
25
24
|
this.contentDOM.classList.add('block');
|
|
@@ -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 { BibliographyItemAttrs } from '
|
|
16
|
+
import { BibliographyItemAttrs } from '../../lib/references';
|
|
17
17
|
export interface BibliographyItemSource {
|
|
18
18
|
id: string;
|
|
19
19
|
label: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BibliographyItemAttrs } from '@manuscripts/transform';
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import { BibliographyItemAttrs } from '../../lib/references';
|
|
3
3
|
import { BibliographyItemSource } from './BibliographyItemSource';
|
|
4
4
|
export interface CitationEditorProps {
|
|
5
5
|
query?: string;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItemAttrs } from '@manuscripts/transform';
|
|
17
16
|
import React from 'react';
|
|
17
|
+
import { BibliographyItemAttrs } from '../../lib/references';
|
|
18
18
|
export declare const CitedItems: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
19
19
|
export declare const CitedItem: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
20
20
|
export interface CitationViewerProps {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { BibliographicName } from '@manuscripts/json-schema';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
|
|
4
|
-
person:
|
|
5
|
-
isNew: boolean;
|
|
3
|
+
type PersonDropDownProps = {
|
|
4
|
+
person: BibliographicName;
|
|
6
5
|
index: number;
|
|
7
6
|
remove: (index: number) => void;
|
|
8
7
|
onChange: (e: React.ChangeEvent) => void;
|
|
9
8
|
type: 'author' | 'editor';
|
|
10
9
|
};
|
|
11
10
|
export declare const PersonDropDown: (props: PersonDropDownProps) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItemAttrs } from '@manuscripts/transform';
|
|
17
16
|
import React, { MutableRefObject } from 'react';
|
|
17
|
+
import { BibliographyItemAttrs } from '../../../lib/references';
|
|
18
18
|
export interface ReferenceFormActions {
|
|
19
19
|
reset: () => void;
|
|
20
20
|
}
|