@manuscripts/body-editor 1.11.8-LEAN-3572.0 → 1.11.8
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/configs/editor-plugins.js +2 -0
- package/dist/cjs/lib/comments.js +1 -1
- package/dist/cjs/plugins/comments.js +17 -21
- package/dist/cjs/plugins/doi.js +63 -0
- package/dist/es/configs/editor-plugins.js +2 -0
- package/dist/es/lib/comments.js +1 -1
- package/dist/es/plugins/comments.js +17 -21
- package/dist/es/plugins/doi.js +61 -0
- package/dist/types/lib/comments.d.ts +3 -5
- package/dist/types/plugins/doi.d.ts +19 -0
- package/package.json +3 -3
- package/styles/AdvancedEditor.css +7 -0
|
@@ -29,6 +29,7 @@ const keys_1 = __importDefault(require("../keys"));
|
|
|
29
29
|
const affiliations_1 = __importDefault(require("../plugins/affiliations"));
|
|
30
30
|
const bibliography_1 = __importDefault(require("../plugins/bibliography"));
|
|
31
31
|
const comments_1 = __importDefault(require("../plugins/comments"));
|
|
32
|
+
const doi_1 = __importDefault(require("../plugins/doi"));
|
|
32
33
|
const editor_props_1 = __importDefault(require("../plugins/editor-props"));
|
|
33
34
|
const elements_1 = __importDefault(require("../plugins/elements"));
|
|
34
35
|
const footnotes_1 = __importDefault(require("../plugins/footnotes"));
|
|
@@ -71,6 +72,7 @@ exports.default = (props) => {
|
|
|
71
72
|
(0, footnotes_1.default)(props),
|
|
72
73
|
(0, table_footnote_1.default)(),
|
|
73
74
|
(0, editor_props_1.default)(props),
|
|
75
|
+
(0, doi_1.default)(),
|
|
74
76
|
];
|
|
75
77
|
if (props.collabProvider) {
|
|
76
78
|
allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
|
package/dist/cjs/lib/comments.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createCommentMarker = exports.getCommentRange = exports.getCommentKey = exports.isNodeComment = void 0;
|
|
4
|
-
const isNodeComment = (
|
|
4
|
+
const isNodeComment = (comment) => !comment.range;
|
|
5
5
|
exports.isNodeComment = isNodeComment;
|
|
6
6
|
const getCommentKey = (comment, range, target) => {
|
|
7
7
|
if (!range) {
|
|
@@ -90,12 +90,13 @@ const findCommentRanges = (doc) => {
|
|
|
90
90
|
return ranges;
|
|
91
91
|
};
|
|
92
92
|
const findComments = (doc) => {
|
|
93
|
-
const
|
|
93
|
+
const nodes = (0, prosemirror_utils_1.findChildrenByType)(doc, transform_1.schema.nodes.comment);
|
|
94
94
|
const commentsByTarget = new Map();
|
|
95
|
-
for (const
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
commentsByTarget.
|
|
95
|
+
for (const { node } of nodes) {
|
|
96
|
+
const attrs = node.attrs;
|
|
97
|
+
const targetID = attrs.target;
|
|
98
|
+
const comments = commentsByTarget.get(targetID) || [];
|
|
99
|
+
commentsByTarget.set(targetID, [...comments, attrs]);
|
|
99
100
|
}
|
|
100
101
|
return commentsByTarget;
|
|
101
102
|
};
|
|
@@ -117,32 +118,27 @@ const buildPluginState = (doc, selection) => {
|
|
|
117
118
|
const nodeComments = [];
|
|
118
119
|
const highlightComments = [];
|
|
119
120
|
const pointComments = [];
|
|
120
|
-
comments
|
|
121
|
-
.map((c) => {
|
|
122
|
-
const attrs = c.node.attrs;
|
|
121
|
+
for (const attrs of comments) {
|
|
123
122
|
const id = attrs.id;
|
|
124
123
|
const range = ranges.get(id);
|
|
125
124
|
const key = (0, comments_1.getCommentKey)(attrs, range, node);
|
|
126
|
-
|
|
125
|
+
const comment = {
|
|
127
126
|
key,
|
|
128
|
-
|
|
129
|
-
pos: c.pos,
|
|
127
|
+
attrs,
|
|
130
128
|
target,
|
|
131
129
|
range,
|
|
132
130
|
};
|
|
133
|
-
|
|
134
|
-
.
|
|
135
|
-
|
|
136
|
-
if (!c.range) {
|
|
137
|
-
nodeComments.push(c);
|
|
131
|
+
allComments.push(comment);
|
|
132
|
+
if (!comment.range) {
|
|
133
|
+
nodeComments.push(comment);
|
|
138
134
|
}
|
|
139
|
-
else if (
|
|
140
|
-
highlightComments.push(
|
|
135
|
+
else if (comment.range.size) {
|
|
136
|
+
highlightComments.push(comment);
|
|
141
137
|
}
|
|
142
138
|
else {
|
|
143
|
-
pointComments.push(
|
|
139
|
+
pointComments.push(comment);
|
|
144
140
|
}
|
|
145
|
-
}
|
|
141
|
+
}
|
|
146
142
|
for (const comment of highlightComments) {
|
|
147
143
|
const key = comment.key;
|
|
148
144
|
const range = comment.range;
|
|
@@ -165,7 +161,7 @@ const buildPluginState = (doc, selection) => {
|
|
|
165
161
|
});
|
|
166
162
|
return {
|
|
167
163
|
decorations: prosemirror_view_1.DecorationSet.create(doc, decorations),
|
|
168
|
-
comments: new Map(allComments.map((c) => [c.
|
|
164
|
+
comments: new Map(allComments.map((c) => [c.attrs.id, c])),
|
|
169
165
|
commentsByKey: groupByKey(allComments),
|
|
170
166
|
selection,
|
|
171
167
|
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2024 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 prosemirror_state_1 = require("prosemirror-state");
|
|
19
|
+
const prosemirror_view_1 = require("prosemirror-view");
|
|
20
|
+
exports.default = () => {
|
|
21
|
+
return new prosemirror_state_1.Plugin({
|
|
22
|
+
state: {
|
|
23
|
+
init(_, { doc }) {
|
|
24
|
+
if (doc.attrs.doi) {
|
|
25
|
+
const decorations = createDecoration(doc);
|
|
26
|
+
return prosemirror_view_1.DecorationSet.create(doc, decorations);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
apply(tr, oldDecorationSet, oldState, newState) {
|
|
30
|
+
if (tr.docChanged && newState.doc.attrs.doi) {
|
|
31
|
+
const decorations = createDecoration(newState.doc);
|
|
32
|
+
return prosemirror_view_1.DecorationSet.create(newState.doc, decorations);
|
|
33
|
+
}
|
|
34
|
+
return oldDecorationSet;
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
props: {
|
|
38
|
+
decorations(state) {
|
|
39
|
+
return this.getState(state);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
function getPosition(doc) {
|
|
45
|
+
const positions = [];
|
|
46
|
+
const possibleNodesTypes = ['keywords', 'supplements', 'abstracts', 'body'];
|
|
47
|
+
doc.descendants((node, pos) => {
|
|
48
|
+
if (possibleNodesTypes.includes(node.type.name)) {
|
|
49
|
+
positions.push(pos);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const position = positions.length === 0 ? 0 : Math.min(...positions);
|
|
53
|
+
return position;
|
|
54
|
+
}
|
|
55
|
+
function createDecoration(doc) {
|
|
56
|
+
const decoration = prosemirror_view_1.Decoration.widget(getPosition(doc), () => {
|
|
57
|
+
const doiContainer = document.createElement('div');
|
|
58
|
+
doiContainer.classList.add('doi-container', 'block');
|
|
59
|
+
doiContainer.innerHTML = `<p>DOI: https://doi.org/${doc.attrs.doi}</p>`;
|
|
60
|
+
return doiContainer;
|
|
61
|
+
});
|
|
62
|
+
return [decoration];
|
|
63
|
+
}
|
|
@@ -24,6 +24,7 @@ import keys from '../keys';
|
|
|
24
24
|
import affiliations from '../plugins/affiliations';
|
|
25
25
|
import bibliography from '../plugins/bibliography';
|
|
26
26
|
import comments from '../plugins/comments';
|
|
27
|
+
import doi from '../plugins/doi';
|
|
27
28
|
import editorProps from '../plugins/editor-props';
|
|
28
29
|
import elements from '../plugins/elements';
|
|
29
30
|
import footnotes from '../plugins/footnotes';
|
|
@@ -66,6 +67,7 @@ export default (props) => {
|
|
|
66
67
|
footnotes(props),
|
|
67
68
|
table_footnote(),
|
|
68
69
|
editorProps(props),
|
|
70
|
+
doi(),
|
|
69
71
|
];
|
|
70
72
|
if (props.collabProvider) {
|
|
71
73
|
allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
|
package/dist/es/lib/comments.js
CHANGED
|
@@ -85,12 +85,13 @@ const findCommentRanges = (doc) => {
|
|
|
85
85
|
return ranges;
|
|
86
86
|
};
|
|
87
87
|
const findComments = (doc) => {
|
|
88
|
-
const
|
|
88
|
+
const nodes = findChildrenByType(doc, schema.nodes.comment);
|
|
89
89
|
const commentsByTarget = new Map();
|
|
90
|
-
for (const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
commentsByTarget.
|
|
90
|
+
for (const { node } of nodes) {
|
|
91
|
+
const attrs = node.attrs;
|
|
92
|
+
const targetID = attrs.target;
|
|
93
|
+
const comments = commentsByTarget.get(targetID) || [];
|
|
94
|
+
commentsByTarget.set(targetID, [...comments, attrs]);
|
|
94
95
|
}
|
|
95
96
|
return commentsByTarget;
|
|
96
97
|
};
|
|
@@ -112,32 +113,27 @@ const buildPluginState = (doc, selection) => {
|
|
|
112
113
|
const nodeComments = [];
|
|
113
114
|
const highlightComments = [];
|
|
114
115
|
const pointComments = [];
|
|
115
|
-
comments
|
|
116
|
-
.map((c) => {
|
|
117
|
-
const attrs = c.node.attrs;
|
|
116
|
+
for (const attrs of comments) {
|
|
118
117
|
const id = attrs.id;
|
|
119
118
|
const range = ranges.get(id);
|
|
120
119
|
const key = getCommentKey(attrs, range, node);
|
|
121
|
-
|
|
120
|
+
const comment = {
|
|
122
121
|
key,
|
|
123
|
-
|
|
124
|
-
pos: c.pos,
|
|
122
|
+
attrs,
|
|
125
123
|
target,
|
|
126
124
|
range,
|
|
127
125
|
};
|
|
128
|
-
|
|
129
|
-
.
|
|
130
|
-
|
|
131
|
-
if (!c.range) {
|
|
132
|
-
nodeComments.push(c);
|
|
126
|
+
allComments.push(comment);
|
|
127
|
+
if (!comment.range) {
|
|
128
|
+
nodeComments.push(comment);
|
|
133
129
|
}
|
|
134
|
-
else if (
|
|
135
|
-
highlightComments.push(
|
|
130
|
+
else if (comment.range.size) {
|
|
131
|
+
highlightComments.push(comment);
|
|
136
132
|
}
|
|
137
133
|
else {
|
|
138
|
-
pointComments.push(
|
|
134
|
+
pointComments.push(comment);
|
|
139
135
|
}
|
|
140
|
-
}
|
|
136
|
+
}
|
|
141
137
|
for (const comment of highlightComments) {
|
|
142
138
|
const key = comment.key;
|
|
143
139
|
const range = comment.range;
|
|
@@ -160,7 +156,7 @@ const buildPluginState = (doc, selection) => {
|
|
|
160
156
|
});
|
|
161
157
|
return {
|
|
162
158
|
decorations: DecorationSet.create(doc, decorations),
|
|
163
|
-
comments: new Map(allComments.map((c) => [c.
|
|
159
|
+
comments: new Map(allComments.map((c) => [c.attrs.id, c])),
|
|
164
160
|
commentsByKey: groupByKey(allComments),
|
|
165
161
|
selection,
|
|
166
162
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2024 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 { Plugin } from 'prosemirror-state';
|
|
17
|
+
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
18
|
+
export default () => {
|
|
19
|
+
return new Plugin({
|
|
20
|
+
state: {
|
|
21
|
+
init(_, { doc }) {
|
|
22
|
+
if (doc.attrs.doi) {
|
|
23
|
+
const decorations = createDecoration(doc);
|
|
24
|
+
return DecorationSet.create(doc, decorations);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
apply(tr, oldDecorationSet, oldState, newState) {
|
|
28
|
+
if (tr.docChanged && newState.doc.attrs.doi) {
|
|
29
|
+
const decorations = createDecoration(newState.doc);
|
|
30
|
+
return DecorationSet.create(newState.doc, decorations);
|
|
31
|
+
}
|
|
32
|
+
return oldDecorationSet;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
props: {
|
|
36
|
+
decorations(state) {
|
|
37
|
+
return this.getState(state);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
function getPosition(doc) {
|
|
43
|
+
const positions = [];
|
|
44
|
+
const possibleNodesTypes = ['keywords', 'supplements', 'abstracts', 'body'];
|
|
45
|
+
doc.descendants((node, pos) => {
|
|
46
|
+
if (possibleNodesTypes.includes(node.type.name)) {
|
|
47
|
+
positions.push(pos);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const position = positions.length === 0 ? 0 : Math.min(...positions);
|
|
51
|
+
return position;
|
|
52
|
+
}
|
|
53
|
+
function createDecoration(doc) {
|
|
54
|
+
const decoration = Decoration.widget(getPosition(doc), () => {
|
|
55
|
+
const doiContainer = document.createElement('div');
|
|
56
|
+
doiContainer.classList.add('doi-container', 'block');
|
|
57
|
+
doiContainer.innerHTML = `<p>DOI: https://doi.org/${doc.attrs.doi}</p>`;
|
|
58
|
+
return doiContainer;
|
|
59
|
+
});
|
|
60
|
+
return [decoration];
|
|
61
|
+
}
|
|
@@ -5,14 +5,12 @@ export type HighlightMarkerAttrs = HighlightMarkerNode['attrs'];
|
|
|
5
5
|
export type Comment = NodeComment | InlineComment;
|
|
6
6
|
export type NodeComment = {
|
|
7
7
|
key: CommentKey;
|
|
8
|
-
|
|
9
|
-
pos: number;
|
|
8
|
+
attrs: CommentAttrs;
|
|
10
9
|
target: NodeWithPos;
|
|
11
10
|
};
|
|
12
11
|
export type InlineComment = {
|
|
13
12
|
key: CommentKey;
|
|
14
|
-
|
|
15
|
-
pos: number;
|
|
13
|
+
attrs: CommentAttrs;
|
|
16
14
|
target: NodeWithPos;
|
|
17
15
|
range: CommentRange;
|
|
18
16
|
};
|
|
@@ -26,7 +24,7 @@ export type CommentSelection = {
|
|
|
26
24
|
id: string;
|
|
27
25
|
isNew: boolean;
|
|
28
26
|
};
|
|
29
|
-
export declare const isNodeComment: (
|
|
27
|
+
export declare const isNodeComment: (comment: any) => comment is NodeComment;
|
|
30
28
|
export declare const getCommentKey: (comment: CommentAttrs, range: CommentRange | undefined, target: ManuscriptNode) => CommentKey;
|
|
31
29
|
export declare const getCommentRange: (comment: CommentAttrs) => {
|
|
32
30
|
pos: number;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2024 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 { Plugin } from 'prosemirror-state';
|
|
17
|
+
import { DecorationSet } from 'prosemirror-view';
|
|
18
|
+
declare const _default: () => Plugin<DecorationSet | undefined>;
|
|
19
|
+
export default _default;
|
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": "1.11.8
|
|
4
|
+
"version": "1.11.8",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@iarna/word-count": "^1.1.2",
|
|
31
31
|
"@manuscripts/json-schema": "2.2.8",
|
|
32
32
|
"@manuscripts/library": "1.3.7",
|
|
33
|
-
"@manuscripts/style-guide": "1.12.16
|
|
33
|
+
"@manuscripts/style-guide": "1.12.16",
|
|
34
34
|
"@manuscripts/track-changes-plugin": "1.7.13",
|
|
35
|
-
"@manuscripts/transform": "2.3.
|
|
35
|
+
"@manuscripts/transform": "2.3.9",
|
|
36
36
|
"astrocite-eutils": "^0.16.4",
|
|
37
37
|
"mathjax-full": "^3.2.2",
|
|
38
38
|
"codemirror": "^5.58.1",
|