@manuscripts/body-editor 1.7.16 → 1.7.17
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/plugins/affiliations.js +8 -13
- package/dist/cjs/plugins/bibliography/bibliography-utils.js +5 -6
- package/dist/cjs/plugins/bibliography/index.js +3 -0
- package/dist/cjs/plugins/selected-suggestion-ui.js +1 -2
- package/dist/es/plugins/affiliations.js +8 -13
- package/dist/es/plugins/bibliography/bibliography-utils.js +5 -6
- package/dist/es/plugins/bibliography/index.js +3 -0
- package/dist/es/plugins/selected-suggestion-ui.js +1 -2
- package/dist/types/plugins/affiliations.d.ts +1 -0
- package/dist/types/plugins/bibliography/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ const prosemirror_state_1 = require("prosemirror-state");
|
|
|
21
21
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
22
22
|
const track_changes_utils_1 = require("../lib/track-changes-utils");
|
|
23
23
|
exports.affiliationsKey = new prosemirror_state_1.PluginKey('affiliations');
|
|
24
|
+
let id = 1;
|
|
24
25
|
const buildPluginState = (doc) => {
|
|
25
26
|
const contributors = [];
|
|
26
27
|
const affiliations = [];
|
|
@@ -47,13 +48,13 @@ const buildPluginState = (doc) => {
|
|
|
47
48
|
});
|
|
48
49
|
const indexedAffiliationIds = new Map([...iAffiliations].map((id, i) => [id, i + 1]));
|
|
49
50
|
return {
|
|
51
|
+
version: String(id++),
|
|
50
52
|
indexedAffiliationIds,
|
|
51
53
|
contributors,
|
|
52
54
|
affiliations,
|
|
53
55
|
};
|
|
54
56
|
};
|
|
55
57
|
exports.buildPluginState = buildPluginState;
|
|
56
|
-
let count = 0;
|
|
57
58
|
exports.default = () => {
|
|
58
59
|
return new prosemirror_state_1.Plugin({
|
|
59
60
|
key: exports.affiliationsKey,
|
|
@@ -98,19 +99,13 @@ exports.default = () => {
|
|
|
98
99
|
props: {
|
|
99
100
|
decorations: (state) => {
|
|
100
101
|
const decorations = [];
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
const aff = exports.affiliationsKey.getState(state);
|
|
103
|
+
const nodes = [...aff.contributors, ...aff.affiliations];
|
|
104
|
+
nodes.forEach(([node, pos]) => {
|
|
105
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
106
|
+
version: aff.version,
|
|
107
|
+
}));
|
|
106
108
|
});
|
|
107
|
-
if (allNodes.length) {
|
|
108
|
-
allNodes.forEach(([node, pos]) => {
|
|
109
|
-
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
110
|
-
refresh: count++,
|
|
111
|
-
}));
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
109
|
return prosemirror_view_1.DecorationSet.create(state.doc, decorations);
|
|
115
110
|
},
|
|
116
111
|
},
|
|
@@ -34,7 +34,6 @@ const lodash_1 = require("lodash");
|
|
|
34
34
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
35
35
|
const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
|
|
36
36
|
exports.isBibliographyElement = isBibliographyElement;
|
|
37
|
-
let count = 0;
|
|
38
37
|
const buildDecorations = (state, doc) => {
|
|
39
38
|
const decorations = [];
|
|
40
39
|
let hasMissingItems = false;
|
|
@@ -56,14 +55,14 @@ const buildDecorations = (state, doc) => {
|
|
|
56
55
|
}));
|
|
57
56
|
}
|
|
58
57
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
59
|
-
|
|
58
|
+
version: state.version,
|
|
60
59
|
}));
|
|
61
60
|
}
|
|
62
61
|
if (hasMissingItems) {
|
|
63
62
|
doc.descendants((node, pos) => {
|
|
64
63
|
if ((0, exports.isBibliographyElement)(node)) {
|
|
65
|
-
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
66
|
-
missing: true,
|
|
64
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
65
|
+
missing: 'true',
|
|
67
66
|
}));
|
|
68
67
|
decorations.push(prosemirror_view_1.Decoration.widget(pos, () => {
|
|
69
68
|
const el = document.createElement('div');
|
|
@@ -76,8 +75,8 @@ const buildDecorations = (state, doc) => {
|
|
|
76
75
|
}
|
|
77
76
|
doc.descendants((node, pos) => {
|
|
78
77
|
if ((0, exports.isBibliographyElement)(node)) {
|
|
79
|
-
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
80
|
-
|
|
78
|
+
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
79
|
+
version: state.version,
|
|
81
80
|
}));
|
|
82
81
|
}
|
|
83
82
|
});
|
|
@@ -46,6 +46,7 @@ exports.default = (props) => {
|
|
|
46
46
|
},
|
|
47
47
|
});
|
|
48
48
|
};
|
|
49
|
+
let version = 1;
|
|
49
50
|
const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
50
51
|
const nodes = [];
|
|
51
52
|
doc.descendants((node, pos) => {
|
|
@@ -66,6 +67,7 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
|
66
67
|
if ($old &&
|
|
67
68
|
(0, lodash_1.isEqual)(citations, $old.citations) &&
|
|
68
69
|
(0, lodash_1.isEqual)(bibliographyItemMap, $old.bibliographyItems)) {
|
|
70
|
+
$new.version = $old.version;
|
|
69
71
|
$new.citationCounts = $old.citationCounts;
|
|
70
72
|
$new.provider = $old.provider;
|
|
71
73
|
$new.renderedCitations = $old.renderedCitations;
|
|
@@ -83,6 +85,7 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
|
83
85
|
locale: csl.locale,
|
|
84
86
|
});
|
|
85
87
|
const citationTexts = provider.rebuildState((0, bibliography_utils_1.buildCitations)(nodes));
|
|
88
|
+
$new.version = String(version++);
|
|
86
89
|
$new.citationCounts = citationCounts;
|
|
87
90
|
$new.provider = provider;
|
|
88
91
|
$new.renderedCitations = new Map(citationTexts.map((i) => [i[0], i[2]]));
|
|
@@ -93,8 +93,7 @@ exports.default = (props) => new prosemirror_state_1.Plugin({
|
|
|
93
93
|
if (suggestionId) {
|
|
94
94
|
return buildSelectedSuggestionDecoration(suggestionId, state, props);
|
|
95
95
|
}
|
|
96
|
-
if (tr.getMeta(CLEAR_SUGGESTION_ID)
|
|
97
|
-
tr.getMeta('track-changes-refresh-changes')) {
|
|
96
|
+
if (tr.getMeta(CLEAR_SUGGESTION_ID)) {
|
|
98
97
|
props.setEditorSelectedSuggestion(undefined);
|
|
99
98
|
return prosemirror_view_1.DecorationSet.empty;
|
|
100
99
|
}
|
|
@@ -18,6 +18,7 @@ import { Plugin, PluginKey } from 'prosemirror-state';
|
|
|
18
18
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
19
|
import { getActualAttrs, isDeleted, isPendingInsert, } from '../lib/track-changes-utils';
|
|
20
20
|
export const affiliationsKey = new PluginKey('affiliations');
|
|
21
|
+
let id = 1;
|
|
21
22
|
export const buildPluginState = (doc) => {
|
|
22
23
|
const contributors = [];
|
|
23
24
|
const affiliations = [];
|
|
@@ -44,12 +45,12 @@ export const buildPluginState = (doc) => {
|
|
|
44
45
|
});
|
|
45
46
|
const indexedAffiliationIds = new Map([...iAffiliations].map((id, i) => [id, i + 1]));
|
|
46
47
|
return {
|
|
48
|
+
version: String(id++),
|
|
47
49
|
indexedAffiliationIds,
|
|
48
50
|
contributors,
|
|
49
51
|
affiliations,
|
|
50
52
|
};
|
|
51
53
|
};
|
|
52
|
-
let count = 0;
|
|
53
54
|
export default () => {
|
|
54
55
|
return new Plugin({
|
|
55
56
|
key: affiliationsKey,
|
|
@@ -94,19 +95,13 @@ export default () => {
|
|
|
94
95
|
props: {
|
|
95
96
|
decorations: (state) => {
|
|
96
97
|
const decorations = [];
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
const aff = affiliationsKey.getState(state);
|
|
99
|
+
const nodes = [...aff.contributors, ...aff.affiliations];
|
|
100
|
+
nodes.forEach(([node, pos]) => {
|
|
101
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
102
|
+
version: aff.version,
|
|
103
|
+
}));
|
|
102
104
|
});
|
|
103
|
-
if (allNodes.length) {
|
|
104
|
-
allNodes.forEach(([node, pos]) => {
|
|
105
|
-
decorations.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
106
|
-
refresh: count++,
|
|
107
|
-
}));
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
105
|
return DecorationSet.create(state.doc, decorations);
|
|
111
106
|
},
|
|
112
107
|
},
|
|
@@ -30,7 +30,6 @@ import { schema, } from '@manuscripts/transform';
|
|
|
30
30
|
import { pickBy } from 'lodash';
|
|
31
31
|
import { Decoration } from 'prosemirror-view';
|
|
32
32
|
export const isBibliographyElement = (node) => node.type === node.type.schema.nodes.bibliography_element;
|
|
33
|
-
let count = 0;
|
|
34
33
|
export const buildDecorations = (state, doc) => {
|
|
35
34
|
const decorations = [];
|
|
36
35
|
let hasMissingItems = false;
|
|
@@ -52,14 +51,14 @@ export const buildDecorations = (state, doc) => {
|
|
|
52
51
|
}));
|
|
53
52
|
}
|
|
54
53
|
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
55
|
-
|
|
54
|
+
version: state.version,
|
|
56
55
|
}));
|
|
57
56
|
}
|
|
58
57
|
if (hasMissingItems) {
|
|
59
58
|
doc.descendants((node, pos) => {
|
|
60
59
|
if (isBibliographyElement(node)) {
|
|
61
|
-
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
62
|
-
missing: true,
|
|
60
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
61
|
+
missing: 'true',
|
|
63
62
|
}));
|
|
64
63
|
decorations.push(Decoration.widget(pos, () => {
|
|
65
64
|
const el = document.createElement('div');
|
|
@@ -72,8 +71,8 @@ export const buildDecorations = (state, doc) => {
|
|
|
72
71
|
}
|
|
73
72
|
doc.descendants((node, pos) => {
|
|
74
73
|
if (isBibliographyElement(node)) {
|
|
75
|
-
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
76
|
-
|
|
74
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
75
|
+
version: state.version,
|
|
77
76
|
}));
|
|
78
77
|
}
|
|
79
78
|
});
|
|
@@ -43,6 +43,7 @@ export default (props) => {
|
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
+
let version = 1;
|
|
46
47
|
const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
47
48
|
const nodes = [];
|
|
48
49
|
doc.descendants((node, pos) => {
|
|
@@ -63,6 +64,7 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
|
63
64
|
if ($old &&
|
|
64
65
|
isEqual(citations, $old.citations) &&
|
|
65
66
|
isEqual(bibliographyItemMap, $old.bibliographyItems)) {
|
|
67
|
+
$new.version = $old.version;
|
|
66
68
|
$new.citationCounts = $old.citationCounts;
|
|
67
69
|
$new.provider = $old.provider;
|
|
68
70
|
$new.renderedCitations = $old.renderedCitations;
|
|
@@ -80,6 +82,7 @@ const buildBibliographyPluginState = (doc, csl, $old) => {
|
|
|
80
82
|
locale: csl.locale,
|
|
81
83
|
});
|
|
82
84
|
const citationTexts = provider.rebuildState(buildCitations(nodes));
|
|
85
|
+
$new.version = String(version++);
|
|
83
86
|
$new.citationCounts = citationCounts;
|
|
84
87
|
$new.provider = provider;
|
|
85
88
|
$new.renderedCitations = new Map(citationTexts.map((i) => [i[0], i[2]]));
|
|
@@ -90,8 +90,7 @@ export default (props) => new Plugin({
|
|
|
90
90
|
if (suggestionId) {
|
|
91
91
|
return buildSelectedSuggestionDecoration(suggestionId, state, props);
|
|
92
92
|
}
|
|
93
|
-
if (tr.getMeta(CLEAR_SUGGESTION_ID)
|
|
94
|
-
tr.getMeta('track-changes-refresh-changes')) {
|
|
93
|
+
if (tr.getMeta(CLEAR_SUGGESTION_ID)) {
|
|
95
94
|
props.setEditorSelectedSuggestion(undefined);
|
|
96
95
|
return DecorationSet.empty;
|
|
97
96
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { AffiliationNode, ContributorNode, ManuscriptNode } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
18
18
|
interface PluginState {
|
|
19
|
+
version: string;
|
|
19
20
|
indexedAffiliationIds: Map<string, number>;
|
|
20
21
|
contributors: Array<[ContributorNode, number]>;
|
|
21
22
|
affiliations: Array<[AffiliationNode, number]>;
|
|
@@ -22,6 +22,7 @@ import { PopperManager } from '../../lib/popper';
|
|
|
22
22
|
import { CitationNodes } from './bibliography-utils';
|
|
23
23
|
export declare const bibliographyKey: PluginKey<PluginState>;
|
|
24
24
|
export interface PluginState {
|
|
25
|
+
version: string;
|
|
25
26
|
citationNodes: CitationNodes;
|
|
26
27
|
citations: CiteProc.Citation[];
|
|
27
28
|
bibliographyItems: Map<string, BibliographyItem>;
|
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.7.
|
|
4
|
+
"version": "1.7.17",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|