@manuscripts/body-editor 1.7.3 → 1.7.5
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/assets.js +25 -1
- package/dist/cjs/configs/editor-plugins.js +2 -4
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/lib/track-changes-utils.js +13 -4
- package/dist/cjs/plugins/comment_annotation.js +2 -1
- package/dist/cjs/plugins/highlight/findHighlightMarkers.js +1 -7
- package/dist/cjs/plugins/selected-suggestion-ui.js +129 -0
- package/dist/cjs/views/affiliation.js +2 -1
- package/dist/cjs/views/bibliography_element.js +23 -6
- package/dist/cjs/views/citation.js +4 -1
- package/dist/cjs/views/contributors.js +14 -3
- package/dist/cjs/views/cross_reference.js +4 -1
- package/dist/cjs/views/keyword.js +17 -7
- package/dist/es/assets.js +24 -0
- package/dist/es/configs/editor-plugins.js +2 -4
- package/dist/es/index.js +1 -0
- package/dist/es/lib/track-changes-utils.js +11 -3
- package/dist/es/plugins/comment_annotation.js +2 -1
- package/dist/es/plugins/highlight/findHighlightMarkers.js +2 -8
- package/dist/es/plugins/selected-suggestion-ui.js +126 -0
- package/dist/es/views/affiliation.js +2 -1
- package/dist/es/views/bibliography_element.js +22 -5
- package/dist/es/views/citation.js +4 -1
- package/dist/es/views/contributors.js +14 -3
- package/dist/es/views/cross_reference.js +4 -1
- package/dist/es/views/keyword.js +17 -7
- package/dist/types/assets.d.ts +1 -0
- package/dist/types/configs/editor-plugins.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/track-changes-utils.d.ts +3 -1
- package/dist/types/plugins/{track-changes-ui.d.ts → selected-suggestion-ui.d.ts} +7 -5
- package/dist/types/views/affiliation.d.ts +0 -1
- package/dist/types/views/base_node_view.d.ts +1 -0
- package/dist/types/views/bibliography_element.d.ts +1 -0
- package/dist/types/views/contributors.d.ts +1 -1
- package/package.json +1 -1
- package/styles/AdvancedEditor.css +18 -3
- package/styles/Editor.css +2 -2
- package/dist/cjs/plugins/track-changes-ui.js +0 -104
- package/dist/cjs/plugins/tracking-mark.js +0 -123
- package/dist/es/plugins/track-changes-ui.js +0 -102
- package/dist/es/plugins/tracking-mark.js +0 -118
- package/dist/types/plugins/tracking-mark.d.ts +0 -7
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMarkDecoration = exports.getAttrsTrackingButton = void 0;
|
|
4
|
-
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
5
|
-
const transform_1 = require("@manuscripts/transform");
|
|
6
|
-
const prosemirror_state_1 = require("prosemirror-state");
|
|
7
|
-
const prosemirror_view_1 = require("prosemirror-view");
|
|
8
|
-
exports.default = () => new prosemirror_state_1.Plugin({
|
|
9
|
-
state: {
|
|
10
|
-
init: (tr, state) => {
|
|
11
|
-
return prosemirror_view_1.DecorationSet.create(state.doc, buildDecorations(state));
|
|
12
|
-
},
|
|
13
|
-
apply: (tr, decorationSet, oldState, newState) => {
|
|
14
|
-
const meta = tr.getMeta('track-changes-set-change-statuses');
|
|
15
|
-
if (meta) {
|
|
16
|
-
return prosemirror_view_1.DecorationSet.create(newState.doc, buildDecorations(newState));
|
|
17
|
-
}
|
|
18
|
-
return decorationSet;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
props: {
|
|
22
|
-
decorations: (state) => {
|
|
23
|
-
return prosemirror_view_1.DecorationSet.create(state.doc, buildDecorations(state));
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
const buildDecorations = (state) => {
|
|
28
|
-
var _a;
|
|
29
|
-
const changeSet = (_a = track_changes_plugin_1.trackChangesPluginKey.getState(state)) === null || _a === void 0 ? void 0 : _a.changeSet;
|
|
30
|
-
if (!changeSet) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
const metaNodeChanges = [
|
|
34
|
-
...changeSet.nodeChanges,
|
|
35
|
-
...changeSet.nodeAttrChanges,
|
|
36
|
-
].filter(({ nodeType }) => nodeType === transform_1.schema.nodes.bibliography_item.name);
|
|
37
|
-
const decorations = [];
|
|
38
|
-
metaNodeChanges.map((change) => {
|
|
39
|
-
const markDecoration = (0, exports.getMarkDecoration)(change.dataTracked);
|
|
40
|
-
decorations.push(prosemirror_view_1.Decoration.node(change.from, change.to, markDecoration, { id: change.id }));
|
|
41
|
-
if (change.type === 'node-attr-change' &&
|
|
42
|
-
change.dataTracked.status === track_changes_plugin_1.CHANGE_STATUS.pending &&
|
|
43
|
-
change.dataTracked.operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes) {
|
|
44
|
-
decorations.push(prosemirror_view_1.Decoration.widget(change.from + 1, (0, exports.getAttrsTrackingButton)(change.id), {
|
|
45
|
-
key: change.id,
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return decorations;
|
|
50
|
-
};
|
|
51
|
-
const getAttrsTrackingButton = (changeID) => {
|
|
52
|
-
const el = document.createElement('button');
|
|
53
|
-
el.className = 'attrs-popper-button';
|
|
54
|
-
el.value = changeID;
|
|
55
|
-
el.innerHTML = editIcon;
|
|
56
|
-
return el;
|
|
57
|
-
};
|
|
58
|
-
exports.getAttrsTrackingButton = getAttrsTrackingButton;
|
|
59
|
-
const editIcon = `
|
|
60
|
-
<svg
|
|
61
|
-
width="16"
|
|
62
|
-
height="16"
|
|
63
|
-
viewBox="0 0 16 16"
|
|
64
|
-
fill="none"
|
|
65
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
66
|
-
>
|
|
67
|
-
<path
|
|
68
|
-
d="M12 2L14 4L9 9L6 10L7 7L12 2Z"
|
|
69
|
-
stroke="#353535"
|
|
70
|
-
stroke-width="1.5"
|
|
71
|
-
stroke-linecap="round"
|
|
72
|
-
stroke-linejoin="round"
|
|
73
|
-
/>
|
|
74
|
-
<path
|
|
75
|
-
d="M13 10V11.5C13 12.328 12.328 13 11.5 13H4.5C3.672 13 3 12.328 3 11.5V4.5C3 3.672 3.672 3 4.5 3H6"
|
|
76
|
-
stroke="#353535"
|
|
77
|
-
stroke-width="1.5"
|
|
78
|
-
stroke-linecap="round"
|
|
79
|
-
stroke-linejoin="round"
|
|
80
|
-
/>
|
|
81
|
-
</svg>
|
|
82
|
-
`;
|
|
83
|
-
const getMarkDecoration = (dataTracked, htmlNode) => {
|
|
84
|
-
const style = (htmlNode === null || htmlNode === void 0 ? void 0 : htmlNode.style) || {};
|
|
85
|
-
let className = undefined;
|
|
86
|
-
const { status, operation } = dataTracked;
|
|
87
|
-
if ((operation === track_changes_plugin_1.CHANGE_OPERATION.delete ||
|
|
88
|
-
operation === track_changes_plugin_1.CHANGE_OPERATION.insert ||
|
|
89
|
-
operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes) &&
|
|
90
|
-
status === track_changes_plugin_1.CHANGE_STATUS.pending) {
|
|
91
|
-
style.background = '#ddf3fa';
|
|
92
|
-
}
|
|
93
|
-
if ((operation === track_changes_plugin_1.CHANGE_OPERATION.insert ||
|
|
94
|
-
operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes) &&
|
|
95
|
-
status === track_changes_plugin_1.CHANGE_STATUS.accepted) {
|
|
96
|
-
style.background = '#bffca7';
|
|
97
|
-
}
|
|
98
|
-
if (operation === track_changes_plugin_1.CHANGE_OPERATION.delete &&
|
|
99
|
-
status === track_changes_plugin_1.CHANGE_STATUS.pending) {
|
|
100
|
-
style.textDecoration = 'line-through';
|
|
101
|
-
}
|
|
102
|
-
if ((operation === track_changes_plugin_1.CHANGE_OPERATION.insert &&
|
|
103
|
-
status === track_changes_plugin_1.CHANGE_STATUS.rejected) ||
|
|
104
|
-
(operation === track_changes_plugin_1.CHANGE_OPERATION.delete && status === track_changes_plugin_1.CHANGE_STATUS.accepted)) {
|
|
105
|
-
style.display = 'none';
|
|
106
|
-
}
|
|
107
|
-
const showAttrsPopper = status === track_changes_plugin_1.CHANGE_STATUS.pending &&
|
|
108
|
-
operation === track_changes_plugin_1.CHANGE_OPERATION.set_node_attributes;
|
|
109
|
-
if (showAttrsPopper) {
|
|
110
|
-
className = 'attrs-track-mark';
|
|
111
|
-
if (htmlNode) {
|
|
112
|
-
htmlNode.className = 'attrs-track-mark';
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
class: className,
|
|
117
|
-
style: `background: ${style.background};
|
|
118
|
-
text-decoration: ${style.textDecoration};
|
|
119
|
-
display: ${style.display};
|
|
120
|
-
position: relative;`,
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
exports.getMarkDecoration = getMarkDecoration;
|
|
@@ -1,102 +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 { trackChangesPluginKey, } from '@manuscripts/track-changes-plugin';
|
|
17
|
-
import { Plugin } from 'prosemirror-state';
|
|
18
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
|
-
const ACCEPT_BUTTON_XLINK = '#track-changes-action-accept';
|
|
20
|
-
const REJECT_BUTTON_XLINK = '#track-changes-action-reject';
|
|
21
|
-
const BASE_CLASS = 'track-changes';
|
|
22
|
-
var CLASSES;
|
|
23
|
-
(function (CLASSES) {
|
|
24
|
-
CLASSES["focused"] = "focused";
|
|
25
|
-
CLASSES["control"] = "control";
|
|
26
|
-
})(CLASSES || (CLASSES = {}));
|
|
27
|
-
const createControl = (change, action, xLink) => {
|
|
28
|
-
return `
|
|
29
|
-
<button type="button" data-action="${action}" data-changeid="${change.id}">
|
|
30
|
-
<svg><use href="${xLink}"></use></svg>
|
|
31
|
-
</button>
|
|
32
|
-
`;
|
|
33
|
-
};
|
|
34
|
-
const getClassnames = (...types) => {
|
|
35
|
-
return [BASE_CLASS].concat(types.filter(Boolean).map((type) => `${BASE_CLASS}--${type}`));
|
|
36
|
-
};
|
|
37
|
-
const addClassnamesToEl = (el, ...types) => {
|
|
38
|
-
getClassnames(...types).forEach((classname) => el.classList.add(classname));
|
|
39
|
-
};
|
|
40
|
-
const geControlsPosition = (change) => {
|
|
41
|
-
const NODE_OFFSET = {
|
|
42
|
-
'text-change': 0,
|
|
43
|
-
'wrap-change': 0,
|
|
44
|
-
'mark-change': 0,
|
|
45
|
-
'node-attr-change': 0,
|
|
46
|
-
'node-change-keyword': 1,
|
|
47
|
-
};
|
|
48
|
-
const offset = (change.type === 'node-change'
|
|
49
|
-
? NODE_OFFSET[`${change.type}-${change.nodeType}`]
|
|
50
|
-
: NODE_OFFSET[change.type]) || 0;
|
|
51
|
-
return change.to - offset;
|
|
52
|
-
};
|
|
53
|
-
const createControls = (change) => {
|
|
54
|
-
return Decoration.widget(geControlsPosition(change), () => {
|
|
55
|
-
const el = document.createElement('div');
|
|
56
|
-
addClassnamesToEl(el, CLASSES.control);
|
|
57
|
-
el.dataset.changeid = change.id;
|
|
58
|
-
el.innerHTML =
|
|
59
|
-
createControl(change, 'reject', REJECT_BUTTON_XLINK) +
|
|
60
|
-
createControl(change, 'accept', ACCEPT_BUTTON_XLINK);
|
|
61
|
-
return el;
|
|
62
|
-
}, { side: -1 });
|
|
63
|
-
};
|
|
64
|
-
const decorateChanges = (state) => {
|
|
65
|
-
const pluginState = trackChangesPluginKey.getState(state);
|
|
66
|
-
if (!pluginState) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
const { pending } = pluginState.changeSet;
|
|
70
|
-
return pending.reduce((decorations, change) => {
|
|
71
|
-
if (change.id === null) {
|
|
72
|
-
return decorations;
|
|
73
|
-
}
|
|
74
|
-
return [...decorations, createControls(change)];
|
|
75
|
-
}, []);
|
|
76
|
-
};
|
|
77
|
-
const getTrackChangesData = (node) => {
|
|
78
|
-
var _a;
|
|
79
|
-
const trackChangesMark = node.marks.find((mark) => (mark.type.name === 'tracked_insert' ||
|
|
80
|
-
mark.type.name === 'tracked_delete') &&
|
|
81
|
-
mark.attrs.dataTracked);
|
|
82
|
-
return (_a = trackChangesMark === null || trackChangesMark === void 0 ? void 0 : trackChangesMark.attrs) === null || _a === void 0 ? void 0 : _a.dataTracked;
|
|
83
|
-
};
|
|
84
|
-
export default (props) => new Plugin({
|
|
85
|
-
props: {
|
|
86
|
-
handleClick(view, pos) {
|
|
87
|
-
if (props.setEditorSelectedSuggestion) {
|
|
88
|
-
const nodeClicked = view.state.doc.nodeAt(pos);
|
|
89
|
-
const trackChangesData = nodeClicked && getTrackChangesData(nodeClicked);
|
|
90
|
-
if (trackChangesData) {
|
|
91
|
-
props.setEditorSelectedSuggestion(trackChangesData.id);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
props.setEditorSelectedSuggestion(undefined);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
decorations: (state) => {
|
|
99
|
-
return DecorationSet.create(state.doc, decorateChanges(state));
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { CHANGE_OPERATION, CHANGE_STATUS, trackChangesPluginKey, } from '@manuscripts/track-changes-plugin';
|
|
2
|
-
import { schema } from '@manuscripts/transform';
|
|
3
|
-
import { Plugin } from 'prosemirror-state';
|
|
4
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
5
|
-
export default () => new Plugin({
|
|
6
|
-
state: {
|
|
7
|
-
init: (tr, state) => {
|
|
8
|
-
return DecorationSet.create(state.doc, buildDecorations(state));
|
|
9
|
-
},
|
|
10
|
-
apply: (tr, decorationSet, oldState, newState) => {
|
|
11
|
-
const meta = tr.getMeta('track-changes-set-change-statuses');
|
|
12
|
-
if (meta) {
|
|
13
|
-
return DecorationSet.create(newState.doc, buildDecorations(newState));
|
|
14
|
-
}
|
|
15
|
-
return decorationSet;
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
props: {
|
|
19
|
-
decorations: (state) => {
|
|
20
|
-
return DecorationSet.create(state.doc, buildDecorations(state));
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
const buildDecorations = (state) => {
|
|
25
|
-
var _a;
|
|
26
|
-
const changeSet = (_a = trackChangesPluginKey.getState(state)) === null || _a === void 0 ? void 0 : _a.changeSet;
|
|
27
|
-
if (!changeSet) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
const metaNodeChanges = [
|
|
31
|
-
...changeSet.nodeChanges,
|
|
32
|
-
...changeSet.nodeAttrChanges,
|
|
33
|
-
].filter(({ nodeType }) => nodeType === schema.nodes.bibliography_item.name);
|
|
34
|
-
const decorations = [];
|
|
35
|
-
metaNodeChanges.map((change) => {
|
|
36
|
-
const markDecoration = getMarkDecoration(change.dataTracked);
|
|
37
|
-
decorations.push(Decoration.node(change.from, change.to, markDecoration, { id: change.id }));
|
|
38
|
-
if (change.type === 'node-attr-change' &&
|
|
39
|
-
change.dataTracked.status === CHANGE_STATUS.pending &&
|
|
40
|
-
change.dataTracked.operation === CHANGE_OPERATION.set_node_attributes) {
|
|
41
|
-
decorations.push(Decoration.widget(change.from + 1, getAttrsTrackingButton(change.id), {
|
|
42
|
-
key: change.id,
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return decorations;
|
|
47
|
-
};
|
|
48
|
-
export const getAttrsTrackingButton = (changeID) => {
|
|
49
|
-
const el = document.createElement('button');
|
|
50
|
-
el.className = 'attrs-popper-button';
|
|
51
|
-
el.value = changeID;
|
|
52
|
-
el.innerHTML = editIcon;
|
|
53
|
-
return el;
|
|
54
|
-
};
|
|
55
|
-
const editIcon = `
|
|
56
|
-
<svg
|
|
57
|
-
width="16"
|
|
58
|
-
height="16"
|
|
59
|
-
viewBox="0 0 16 16"
|
|
60
|
-
fill="none"
|
|
61
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
62
|
-
>
|
|
63
|
-
<path
|
|
64
|
-
d="M12 2L14 4L9 9L6 10L7 7L12 2Z"
|
|
65
|
-
stroke="#353535"
|
|
66
|
-
stroke-width="1.5"
|
|
67
|
-
stroke-linecap="round"
|
|
68
|
-
stroke-linejoin="round"
|
|
69
|
-
/>
|
|
70
|
-
<path
|
|
71
|
-
d="M13 10V11.5C13 12.328 12.328 13 11.5 13H4.5C3.672 13 3 12.328 3 11.5V4.5C3 3.672 3.672 3 4.5 3H6"
|
|
72
|
-
stroke="#353535"
|
|
73
|
-
stroke-width="1.5"
|
|
74
|
-
stroke-linecap="round"
|
|
75
|
-
stroke-linejoin="round"
|
|
76
|
-
/>
|
|
77
|
-
</svg>
|
|
78
|
-
`;
|
|
79
|
-
export const getMarkDecoration = (dataTracked, htmlNode) => {
|
|
80
|
-
const style = (htmlNode === null || htmlNode === void 0 ? void 0 : htmlNode.style) || {};
|
|
81
|
-
let className = undefined;
|
|
82
|
-
const { status, operation } = dataTracked;
|
|
83
|
-
if ((operation === CHANGE_OPERATION.delete ||
|
|
84
|
-
operation === CHANGE_OPERATION.insert ||
|
|
85
|
-
operation === CHANGE_OPERATION.set_node_attributes) &&
|
|
86
|
-
status === CHANGE_STATUS.pending) {
|
|
87
|
-
style.background = '#ddf3fa';
|
|
88
|
-
}
|
|
89
|
-
if ((operation === CHANGE_OPERATION.insert ||
|
|
90
|
-
operation === CHANGE_OPERATION.set_node_attributes) &&
|
|
91
|
-
status === CHANGE_STATUS.accepted) {
|
|
92
|
-
style.background = '#bffca7';
|
|
93
|
-
}
|
|
94
|
-
if (operation === CHANGE_OPERATION.delete &&
|
|
95
|
-
status === CHANGE_STATUS.pending) {
|
|
96
|
-
style.textDecoration = 'line-through';
|
|
97
|
-
}
|
|
98
|
-
if ((operation === CHANGE_OPERATION.insert &&
|
|
99
|
-
status === CHANGE_STATUS.rejected) ||
|
|
100
|
-
(operation === CHANGE_OPERATION.delete && status === CHANGE_STATUS.accepted)) {
|
|
101
|
-
style.display = 'none';
|
|
102
|
-
}
|
|
103
|
-
const showAttrsPopper = status === CHANGE_STATUS.pending &&
|
|
104
|
-
operation === CHANGE_OPERATION.set_node_attributes;
|
|
105
|
-
if (showAttrsPopper) {
|
|
106
|
-
className = 'attrs-track-mark';
|
|
107
|
-
if (htmlNode) {
|
|
108
|
-
htmlNode.className = 'attrs-track-mark';
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
class: className,
|
|
113
|
-
style: `background: ${style.background};
|
|
114
|
-
text-decoration: ${style.textDecoration};
|
|
115
|
-
display: ${style.display};
|
|
116
|
-
position: relative;`,
|
|
117
|
-
};
|
|
118
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TrackedAttrs } from '@manuscripts/track-changes-plugin';
|
|
2
|
-
import { Plugin } from 'prosemirror-state';
|
|
3
|
-
import { DecorationAttrs, DecorationSet } from 'prosemirror-view';
|
|
4
|
-
declare const _default: () => Plugin<DecorationSet>;
|
|
5
|
-
export default _default;
|
|
6
|
-
export declare const getAttrsTrackingButton: (changeID: string) => HTMLButtonElement;
|
|
7
|
-
export declare const getMarkDecoration: (dataTracked: TrackedAttrs, htmlNode?: HTMLElement) => DecorationAttrs;
|