@manuscripts/body-editor 1.5.16 → 1.6.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.
- package/dist/cjs/commands.js +53 -132
- package/dist/cjs/components/outline/DraggableTree.js +33 -25
- package/dist/cjs/components/toolbar/OrderListSelector.js +3 -11
- package/dist/cjs/configs/editor-plugins.js +2 -2
- package/dist/cjs/configs/editor-views.js +4 -6
- package/dist/cjs/lib/context-menu.js +6 -5
- package/dist/cjs/node-type-icons.js +0 -1
- package/dist/cjs/plugins/bibliography/bibliography-utils.js +60 -47
- package/dist/cjs/plugins/bibliography/index.js +48 -63
- package/dist/cjs/plugins/comment_annotation.js +2 -2
- package/dist/cjs/plugins/footnotes/index.js +19 -10
- package/dist/cjs/plugins/persist.js +21 -31
- package/dist/cjs/plugins/sections.js +1 -2
- package/dist/cjs/plugins/toc.js +28 -23
- package/dist/cjs/views/bibliography_element.js +20 -38
- package/dist/cjs/views/citation.js +29 -26
- package/dist/cjs/views/citation_editable.js +25 -44
- package/dist/cjs/views/{contributors_section.js → contributors.js} +4 -4
- package/dist/cjs/views/cross_reference.js +7 -36
- package/dist/cjs/views/cross_reference_editable.js +6 -14
- package/dist/cjs/views/editable_block.js +2 -2
- package/dist/cjs/views/{meta_section.js → empty.js} +3 -3
- package/dist/cjs/views/section_title.js +1 -16
- package/dist/es/commands.js +55 -110
- package/dist/es/components/outline/DraggableTree.js +33 -25
- package/dist/es/components/toolbar/OrderListSelector.js +4 -12
- package/dist/es/configs/editor-plugins.js +2 -2
- package/dist/es/configs/editor-views.js +4 -6
- package/dist/es/lib/context-menu.js +7 -6
- package/dist/es/node-type-icons.js +0 -1
- package/dist/es/plugins/bibliography/bibliography-utils.js +56 -45
- package/dist/es/plugins/bibliography/index.js +49 -65
- package/dist/es/plugins/comment_annotation.js +2 -2
- package/dist/es/plugins/footnotes/index.js +20 -11
- package/dist/es/plugins/persist.js +22 -32
- package/dist/es/plugins/sections.js +2 -3
- package/dist/es/plugins/toc.js +29 -24
- package/dist/es/views/bibliography_element.js +21 -39
- package/dist/es/views/citation.js +31 -28
- package/dist/es/views/citation_editable.js +28 -47
- package/dist/es/views/{contributors_section.js → contributors.js} +2 -2
- package/dist/es/views/cross_reference.js +7 -33
- package/dist/es/views/cross_reference_editable.js +6 -14
- package/dist/es/views/editable_block.js +3 -3
- package/dist/es/views/{meta_section.js → empty.js} +3 -3
- package/dist/es/views/section_title.js +0 -14
- package/dist/types/commands.d.ts +1 -2
- package/dist/types/components/outline/DraggableTree.d.ts +1 -2
- package/dist/types/configs/ManuscriptsEditor.d.ts +1 -10
- package/dist/types/configs/editor-plugins.d.ts +1 -5
- package/dist/types/configs/editor-views.d.ts +5 -6
- package/dist/types/lib/context-menu.d.ts +0 -1
- package/dist/types/plugins/bibliography/bibliography-utils.d.ts +10 -7
- package/dist/types/plugins/bibliography/index.d.ts +21 -3
- package/dist/types/views/bibliography_element.d.ts +1 -0
- package/dist/types/views/citation.d.ts +3 -4
- package/dist/types/views/citation_editable.d.ts +2 -8
- package/dist/types/views/{contributors_section.d.ts → contributors.d.ts} +3 -3
- package/dist/types/views/cross_reference.d.ts +0 -5
- package/dist/types/views/{meta_section.d.ts → empty.d.ts} +2 -2
- package/dist/types/views/section_title.d.ts +0 -2
- package/package.json +4 -22
- package/styles/AdvancedEditor.css +30 -34
- package/dist/cjs/plugins/auxiliary_object_order.js +0 -49
- package/dist/cjs/plugins/bibliography/types.js +0 -17
- package/dist/cjs/plugins/footnotes/footnotes-utils.js +0 -52
- package/dist/cjs/views/bibliography_item.js +0 -138
- package/dist/cjs/views/bibliography_item_editable.js +0 -20
- package/dist/es/plugins/auxiliary_object_order.js +0 -46
- package/dist/es/plugins/bibliography/types.js +0 -16
- package/dist/es/plugins/footnotes/footnotes-utils.js +0 -46
- package/dist/es/views/bibliography_item.js +0 -131
- package/dist/es/views/bibliography_item_editable.js +0 -18
- package/dist/types/plugins/auxiliary_object_order.d.ts +0 -12
- package/dist/types/plugins/bibliography/types.d.ts +0 -40
- package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -25
- package/dist/types/views/bibliography_item.d.ts +0 -34
- package/dist/types/views/bibliography_item_editable.d.ts +0 -18
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2022 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
27
|
-
var t = {};
|
|
28
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
29
|
-
t[p] = s[p];
|
|
30
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
31
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
32
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
33
|
-
t[p[i]] = s[p[i]];
|
|
34
|
-
}
|
|
35
|
-
return t;
|
|
36
|
-
};
|
|
37
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.BibliographyItemView = void 0;
|
|
42
|
-
const library_1 = require("@manuscripts/library");
|
|
43
|
-
const transform_1 = require("@manuscripts/transform");
|
|
44
|
-
const react_1 = __importDefault(require("react"));
|
|
45
|
-
const assets_1 = require("../assets");
|
|
46
|
-
const dompurify_1 = require("../lib/dompurify");
|
|
47
|
-
const bibliography_utils_1 = require("../plugins/bibliography/bibliography-utils");
|
|
48
|
-
const base_node_view_1 = require("./base_node_view");
|
|
49
|
-
const creators_1 = require("./creators");
|
|
50
|
-
const createBibliography = (items, cslProps) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
const { style, locale } = cslProps;
|
|
52
|
-
if (!style) {
|
|
53
|
-
throw new Error(`CSL Style not found`);
|
|
54
|
-
}
|
|
55
|
-
const [bibmeta, bibliographyItems] = library_1.CitationProvider.makeBibliographyFromCitations(items, style, locale);
|
|
56
|
-
if (bibmeta.bibliography_errors.length) {
|
|
57
|
-
console.error(bibmeta.bibliography_errors);
|
|
58
|
-
}
|
|
59
|
-
return (0, library_1.createBibliographyElementContents)(bibliographyItems);
|
|
60
|
-
});
|
|
61
|
-
class BibliographyItemView extends base_node_view_1.BaseNodeView {
|
|
62
|
-
constructor() {
|
|
63
|
-
super(...arguments);
|
|
64
|
-
this.showPopper = (referenceID) => {
|
|
65
|
-
const { renderReactComponent, components: { ReferencesEditor }, } = this.props;
|
|
66
|
-
const handleSave = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
const _a = data, { _id: id, 'container-title': containerTitle, DOI: doi } = _a, rest = __rest(_a, ["_id", 'container-title', "DOI"]);
|
|
68
|
-
this.updateNodeAttrs(Object.assign({ id,
|
|
69
|
-
containerTitle,
|
|
70
|
-
doi }, rest));
|
|
71
|
-
});
|
|
72
|
-
if (!this.popperContainer) {
|
|
73
|
-
this.popperContainer = document.createElement('div');
|
|
74
|
-
this.popperContainer.className = 'references';
|
|
75
|
-
}
|
|
76
|
-
renderReactComponent(react_1.default.createElement(ReferencesEditor, { saveModel: handleSave, deleteModel: this.deleteNode, modelMap: (0, bibliography_utils_1.getReferencesModelMap)(this.view.state.doc, true), referenceID: referenceID }), this.popperContainer);
|
|
77
|
-
this.props.popper.show(this.dom, this.popperContainer, 'right');
|
|
78
|
-
};
|
|
79
|
-
this.initialise = () => {
|
|
80
|
-
this.createDOM();
|
|
81
|
-
this.updateContents();
|
|
82
|
-
};
|
|
83
|
-
this.createDOM = () => {
|
|
84
|
-
this.dom = document.createElement('div');
|
|
85
|
-
this.dom.className = 'bib-item';
|
|
86
|
-
this.dom.setAttribute('id', this.node.attrs.id);
|
|
87
|
-
this.dom.setAttribute('contenteditable', 'false');
|
|
88
|
-
this.contentDOM = document.createElement('div');
|
|
89
|
-
this.dom.appendChild(this.contentDOM);
|
|
90
|
-
};
|
|
91
|
-
this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const reference = (0, bibliography_utils_1.getNodeModel)(this.node);
|
|
93
|
-
if (reference && this.contentDOM) {
|
|
94
|
-
const bibliography = yield createBibliography([reference], this.props.cslProps);
|
|
95
|
-
try {
|
|
96
|
-
const fragment = (0, dompurify_1.sanitize)(bibliography.outerHTML);
|
|
97
|
-
const oldBibliography = this.contentDOM.querySelector('.csl-bib-body');
|
|
98
|
-
if (oldBibliography) {
|
|
99
|
-
this.contentDOM.replaceChild(fragment, oldBibliography);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
this.contentDOM.appendChild(fragment);
|
|
103
|
-
}
|
|
104
|
-
const doubleButton = document.createElement('div');
|
|
105
|
-
const editButton = document.createElement('button');
|
|
106
|
-
const commentButton = document.createElement('button');
|
|
107
|
-
doubleButton.className = 'bibliography-double-button';
|
|
108
|
-
editButton.className = 'bibliography-edit-button';
|
|
109
|
-
commentButton.className = 'bibliography-comment-button';
|
|
110
|
-
commentButton.addEventListener('click', (e) => {
|
|
111
|
-
e.preventDefault();
|
|
112
|
-
this.props.setComment((0, transform_1.buildComment)(this.node.attrs.id));
|
|
113
|
-
});
|
|
114
|
-
editButton.addEventListener('click', (e) => {
|
|
115
|
-
e.preventDefault();
|
|
116
|
-
this.showPopper(this.node.attrs.id);
|
|
117
|
-
this.popperContainer = undefined;
|
|
118
|
-
});
|
|
119
|
-
editButton.innerHTML = assets_1.editIcon;
|
|
120
|
-
commentButton.innerHTML = assets_1.commentIcon;
|
|
121
|
-
doubleButton.append(editButton, commentButton);
|
|
122
|
-
if (this.props.getCapabilities().seeReferencesButtons &&
|
|
123
|
-
!this.dom.querySelector('.bibliography-double-button')) {
|
|
124
|
-
this.dom.appendChild(doubleButton);
|
|
125
|
-
}
|
|
126
|
-
editButton.disabled = !this.props.getCapabilities().editCitationsAndRefs;
|
|
127
|
-
}
|
|
128
|
-
catch (e) {
|
|
129
|
-
console.error(e);
|
|
130
|
-
window.alert('There was an error loading the HTML purifier, please reload to try again');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
this.ignoreMutation = () => true;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.BibliographyItemView = BibliographyItemView;
|
|
138
|
-
exports.default = (0, creators_1.createNodeView)(BibliographyItemView);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* © 2019 Atypon Systems LLC
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
const bibliography_item_1 = require("./bibliography_item");
|
|
19
|
-
const creators_1 = require("./creators");
|
|
20
|
-
exports.default = (0, creators_1.createEditableNodeView)(bibliography_item_1.BibliographyItemView);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { ObjectTypes } from '@manuscripts/json-schema';
|
|
2
|
-
import { buildElementsOrder, getElementsOrder, getModelsByType, } from '@manuscripts/transform';
|
|
3
|
-
import { isEqual } from 'lodash-es';
|
|
4
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
5
|
-
import { modelsKey as modelMapKey } from './models';
|
|
6
|
-
export const modelsKey = new PluginKey('auxiliary_elements_order');
|
|
7
|
-
export default (props) => new Plugin({
|
|
8
|
-
key: modelsKey,
|
|
9
|
-
state: {
|
|
10
|
-
init: () => getAuxiliaryObjects(props.getModelMap()),
|
|
11
|
-
apply: (tr, value, oldState, newState) => {
|
|
12
|
-
const state = modelsKey.getState(newState);
|
|
13
|
-
if (!state) {
|
|
14
|
-
return getAuxiliaryObjects(props.getModelMap());
|
|
15
|
-
}
|
|
16
|
-
return state;
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
appendTransaction(transactions, oldState, newState) {
|
|
20
|
-
if (!transactions.some((transaction) => transaction.docChanged)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
let state = modelsKey.getState(newState);
|
|
24
|
-
if (!state) {
|
|
25
|
-
state = getAuxiliaryObjects(props.getModelMap());
|
|
26
|
-
}
|
|
27
|
-
const elementsOrder = getElementsOrder(newState.doc).reduce((elements, obj) => (Object.assign(Object.assign({}, elements), { [obj.elementType]: obj.elements })), {});
|
|
28
|
-
const stateElementsOrder = Object.values(state).reduce((elements, obj) => (Object.assign(Object.assign({}, elements), { [obj.elementType]: obj.elements })), {});
|
|
29
|
-
if (!isEqual(stateElementsOrder, elementsOrder)) {
|
|
30
|
-
let tr;
|
|
31
|
-
Object.entries(elementsOrder).map(([key, elements]) => {
|
|
32
|
-
const model = state[key] ||
|
|
33
|
-
buildElementsOrder(key);
|
|
34
|
-
if (!isEqual(model.elements, elements)) {
|
|
35
|
-
tr = (tr || newState.tr).setMeta(modelMapKey, {
|
|
36
|
-
['UPDATE']: [Object.assign(Object.assign({}, model), { elements })],
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
tr === null || tr === void 0 ? void 0 : tr.setMeta('origin', modelsKey);
|
|
41
|
-
return tr;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
const getAuxiliaryObjects = (modelMap) => getModelsByType(modelMap, ObjectTypes.ElementsOrder).reduce((obj, value) => (Object.assign(Object.assign({}, obj), { [value.elementType]: value })), {});
|
|
@@ -1,16 +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
|
-
export {};
|
|
@@ -1,46 +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 { isFootnoteNode, isFootnotesElementNode, } from '@manuscripts/transform';
|
|
17
|
-
import { footnotesKey } from './index';
|
|
18
|
-
export function getNewFootnoteNumbering(insertedAt, state) {
|
|
19
|
-
var _a;
|
|
20
|
-
const currentInlineFootnotes = ((_a = footnotesKey.getState(state)) === null || _a === void 0 ? void 0 : _a.nodes) || [];
|
|
21
|
-
return currentInlineFootnotes.filter((n) => n[1] <= insertedAt).length + 1;
|
|
22
|
-
}
|
|
23
|
-
export const findFootnotesElement = (doc) => {
|
|
24
|
-
let nodePos = undefined;
|
|
25
|
-
doc.descendants((node, pos) => {
|
|
26
|
-
if (isFootnotesElementNode(node)) {
|
|
27
|
-
nodePos = { node, pos };
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return nodePos;
|
|
31
|
-
};
|
|
32
|
-
export function getNewFootnoteElementPos(footnotesElementAndPos, numbering) {
|
|
33
|
-
let foundPos = footnotesElementAndPos.pos + footnotesElementAndPos.node.nodeSize - 1;
|
|
34
|
-
let selectionPos = foundPos + 2;
|
|
35
|
-
let currentNumber = 1;
|
|
36
|
-
footnotesElementAndPos.node.descendants((node, pos) => {
|
|
37
|
-
if (isFootnoteNode(node)) {
|
|
38
|
-
if (numbering === currentNumber) {
|
|
39
|
-
foundPos = footnotesElementAndPos.pos + pos + 1;
|
|
40
|
-
selectionPos = foundPos + 1;
|
|
41
|
-
}
|
|
42
|
-
currentNumber += 1;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
return [foundPos, selectionPos];
|
|
46
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2022 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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
-
var t = {};
|
|
27
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
-
t[p] = s[p];
|
|
29
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
-
t[p[i]] = s[p[i]];
|
|
33
|
-
}
|
|
34
|
-
return t;
|
|
35
|
-
};
|
|
36
|
-
import { CitationProvider, createBibliographyElementContents, } from '@manuscripts/library';
|
|
37
|
-
import { buildComment } from '@manuscripts/transform';
|
|
38
|
-
import React from 'react';
|
|
39
|
-
import { commentIcon, editIcon } from '../assets';
|
|
40
|
-
import { sanitize } from '../lib/dompurify';
|
|
41
|
-
import { getNodeModel, getReferencesModelMap, } from '../plugins/bibliography/bibliography-utils';
|
|
42
|
-
import { BaseNodeView } from './base_node_view';
|
|
43
|
-
import { createNodeView } from './creators';
|
|
44
|
-
const createBibliography = (items, cslProps) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
const { style, locale } = cslProps;
|
|
46
|
-
if (!style) {
|
|
47
|
-
throw new Error(`CSL Style not found`);
|
|
48
|
-
}
|
|
49
|
-
const [bibmeta, bibliographyItems] = CitationProvider.makeBibliographyFromCitations(items, style, locale);
|
|
50
|
-
if (bibmeta.bibliography_errors.length) {
|
|
51
|
-
console.error(bibmeta.bibliography_errors);
|
|
52
|
-
}
|
|
53
|
-
return createBibliographyElementContents(bibliographyItems);
|
|
54
|
-
});
|
|
55
|
-
export class BibliographyItemView extends BaseNodeView {
|
|
56
|
-
constructor() {
|
|
57
|
-
super(...arguments);
|
|
58
|
-
this.showPopper = (referenceID) => {
|
|
59
|
-
const { renderReactComponent, components: { ReferencesEditor }, } = this.props;
|
|
60
|
-
const handleSave = (data) => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const _a = data, { _id: id, 'container-title': containerTitle, DOI: doi } = _a, rest = __rest(_a, ["_id", 'container-title', "DOI"]);
|
|
62
|
-
this.updateNodeAttrs(Object.assign({ id,
|
|
63
|
-
containerTitle,
|
|
64
|
-
doi }, rest));
|
|
65
|
-
});
|
|
66
|
-
if (!this.popperContainer) {
|
|
67
|
-
this.popperContainer = document.createElement('div');
|
|
68
|
-
this.popperContainer.className = 'references';
|
|
69
|
-
}
|
|
70
|
-
renderReactComponent(React.createElement(ReferencesEditor, { saveModel: handleSave, deleteModel: this.deleteNode, modelMap: getReferencesModelMap(this.view.state.doc, true), referenceID: referenceID }), this.popperContainer);
|
|
71
|
-
this.props.popper.show(this.dom, this.popperContainer, 'right');
|
|
72
|
-
};
|
|
73
|
-
this.initialise = () => {
|
|
74
|
-
this.createDOM();
|
|
75
|
-
this.updateContents();
|
|
76
|
-
};
|
|
77
|
-
this.createDOM = () => {
|
|
78
|
-
this.dom = document.createElement('div');
|
|
79
|
-
this.dom.className = 'bib-item';
|
|
80
|
-
this.dom.setAttribute('id', this.node.attrs.id);
|
|
81
|
-
this.dom.setAttribute('contenteditable', 'false');
|
|
82
|
-
this.contentDOM = document.createElement('div');
|
|
83
|
-
this.dom.appendChild(this.contentDOM);
|
|
84
|
-
};
|
|
85
|
-
this.updateContents = () => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
const reference = getNodeModel(this.node);
|
|
87
|
-
if (reference && this.contentDOM) {
|
|
88
|
-
const bibliography = yield createBibliography([reference], this.props.cslProps);
|
|
89
|
-
try {
|
|
90
|
-
const fragment = sanitize(bibliography.outerHTML);
|
|
91
|
-
const oldBibliography = this.contentDOM.querySelector('.csl-bib-body');
|
|
92
|
-
if (oldBibliography) {
|
|
93
|
-
this.contentDOM.replaceChild(fragment, oldBibliography);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
this.contentDOM.appendChild(fragment);
|
|
97
|
-
}
|
|
98
|
-
const doubleButton = document.createElement('div');
|
|
99
|
-
const editButton = document.createElement('button');
|
|
100
|
-
const commentButton = document.createElement('button');
|
|
101
|
-
doubleButton.className = 'bibliography-double-button';
|
|
102
|
-
editButton.className = 'bibliography-edit-button';
|
|
103
|
-
commentButton.className = 'bibliography-comment-button';
|
|
104
|
-
commentButton.addEventListener('click', (e) => {
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
this.props.setComment(buildComment(this.node.attrs.id));
|
|
107
|
-
});
|
|
108
|
-
editButton.addEventListener('click', (e) => {
|
|
109
|
-
e.preventDefault();
|
|
110
|
-
this.showPopper(this.node.attrs.id);
|
|
111
|
-
this.popperContainer = undefined;
|
|
112
|
-
});
|
|
113
|
-
editButton.innerHTML = editIcon;
|
|
114
|
-
commentButton.innerHTML = commentIcon;
|
|
115
|
-
doubleButton.append(editButton, commentButton);
|
|
116
|
-
if (this.props.getCapabilities().seeReferencesButtons &&
|
|
117
|
-
!this.dom.querySelector('.bibliography-double-button')) {
|
|
118
|
-
this.dom.appendChild(doubleButton);
|
|
119
|
-
}
|
|
120
|
-
editButton.disabled = !this.props.getCapabilities().editCitationsAndRefs;
|
|
121
|
-
}
|
|
122
|
-
catch (e) {
|
|
123
|
-
console.error(e);
|
|
124
|
-
window.alert('There was an error loading the HTML purifier, please reload to try again');
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
this.ignoreMutation = () => true;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
export default createNodeView(BibliographyItemView);
|
|
@@ -1,18 +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 { BibliographyItemView } from './bibliography_item';
|
|
17
|
-
import { createEditableNodeView } from './creators';
|
|
18
|
-
export default createEditableNodeView(BibliographyItemView);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ElementsOrder, Model } from '@manuscripts/json-schema';
|
|
2
|
-
import { AuxiliaryObjects } from '@manuscripts/transform';
|
|
3
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
4
|
-
interface Props {
|
|
5
|
-
getModelMap: () => Map<string, Model>;
|
|
6
|
-
}
|
|
7
|
-
type AuxiliaryObjectsOrder = {
|
|
8
|
-
[key in AuxiliaryObjects]: ElementsOrder;
|
|
9
|
-
};
|
|
10
|
-
export declare const modelsKey: PluginKey<AuxiliaryObjectsOrder>;
|
|
11
|
-
declare const _default: (props: Props) => Plugin<AuxiliaryObjectsOrder>;
|
|
12
|
-
export default _default;
|
|
@@ -1,40 +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 { BibliographyItem } from '@manuscripts/json-schema';
|
|
17
|
-
import { CitationNodes, CitationProvider } from '@manuscripts/library';
|
|
18
|
-
import { CSLProps } from '../../configs/ManuscriptsEditor';
|
|
19
|
-
import { PopperManager } from '../../lib/popper';
|
|
20
|
-
export interface CiteProcCitation {
|
|
21
|
-
citationItems: Array<{
|
|
22
|
-
id: string;
|
|
23
|
-
}>;
|
|
24
|
-
properties?: {
|
|
25
|
-
noteIndex?: number;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export interface PluginState {
|
|
29
|
-
citationNodes: CitationNodes;
|
|
30
|
-
citations: CiteProcCitation[];
|
|
31
|
-
bibliographyItems: BibliographyItem[];
|
|
32
|
-
triggerUpdate?: boolean;
|
|
33
|
-
}
|
|
34
|
-
export interface BibliographyProps {
|
|
35
|
-
getCitationProvider: () => CitationProvider | undefined;
|
|
36
|
-
getLibraryItem: (id: string) => BibliographyItem | undefined;
|
|
37
|
-
cslProps: CSLProps;
|
|
38
|
-
popper: PopperManager;
|
|
39
|
-
setCiteprocCitations: (citations: Map<string, string>) => void;
|
|
40
|
-
}
|
|
@@ -1,25 +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 { FootnotesElementNode, ManuscriptNode } from '@manuscripts/transform';
|
|
17
|
-
import { EditorState } from 'prosemirror-state';
|
|
18
|
-
export declare function getNewFootnoteNumbering(insertedAt: number, state: EditorState): number;
|
|
19
|
-
interface NodePos {
|
|
20
|
-
node: FootnotesElementNode;
|
|
21
|
-
pos: number;
|
|
22
|
-
}
|
|
23
|
-
export declare const findFootnotesElement: (doc: ManuscriptNode) => NodePos | undefined;
|
|
24
|
-
export declare function getNewFootnoteElementPos(footnotesElementAndPos: NodePos, numbering: number): number[];
|
|
25
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* © 2022 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 { CommentAnnotation } from '@manuscripts/json-schema';
|
|
17
|
-
import { ManuscriptNodeView } from '@manuscripts/transform';
|
|
18
|
-
import React from 'react';
|
|
19
|
-
import { BaseNodeProps, BaseNodeView } from './base_node_view';
|
|
20
|
-
import { EditableBlockProps } from './editable_block';
|
|
21
|
-
interface BibliographyItemViewProps extends BaseNodeProps {
|
|
22
|
-
setComment: (comment?: CommentAnnotation) => void;
|
|
23
|
-
components: Record<string, React.ComponentType<any>>;
|
|
24
|
-
}
|
|
25
|
-
export declare class BibliographyItemView<PropsType extends BibliographyItemViewProps & EditableBlockProps> extends BaseNodeView<PropsType> implements ManuscriptNodeView {
|
|
26
|
-
protected popperContainer?: HTMLDivElement;
|
|
27
|
-
showPopper: (referenceID: string) => void;
|
|
28
|
-
initialise: () => void;
|
|
29
|
-
createDOM: () => void;
|
|
30
|
-
updateContents: () => Promise<void>;
|
|
31
|
-
ignoreMutation: () => boolean;
|
|
32
|
-
}
|
|
33
|
-
declare const _default: (props: BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<BibliographyItemView<any>>;
|
|
34
|
-
export default _default;
|
|
@@ -1,18 +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 { BibliographyItemView } from './bibliography_item';
|
|
17
|
-
declare const _default: (props: import("./editable_block").EditableBlockProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<BibliographyItemView<any>>;
|
|
18
|
-
export default _default;
|