@manuscripts/body-editor 1.9.7-LEAN-3136 → 1.9.9
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 +4 -16
- package/dist/cjs/components/outline/DraggableTree.js +1 -1
- package/dist/cjs/configs/ManuscriptsEditor.js +14 -20
- package/dist/cjs/configs/editor-views.js +1 -1
- package/dist/cjs/keys/list.js +13 -2
- package/dist/cjs/plugins/affiliations.js +0 -3
- package/dist/cjs/plugins/bibliography/index.js +1 -1
- package/dist/cjs/plugins/footnotes/footnotes-utils.js +1 -33
- package/dist/cjs/plugins/footnotes/index.js +26 -77
- package/dist/cjs/plugins/highlight/index.js +5 -6
- package/dist/cjs/plugins/selected-suggestion-ui.js +4 -8
- package/dist/cjs/plugins/table-footnote.js +0 -3
- package/dist/cjs/views/base_node_view.js +1 -1
- package/dist/cjs/views/bibliography_element.js +0 -6
- package/dist/cjs/views/citation.js +0 -3
- package/dist/cjs/views/citation_editable.js +0 -6
- package/dist/cjs/views/footnotes_element.js +1 -3
- package/dist/cjs/views/inline_footnote.js +2 -17
- package/dist/es/commands.js +5 -17
- package/dist/es/components/outline/DraggableTree.js +1 -1
- package/dist/es/configs/ManuscriptsEditor.js +14 -20
- package/dist/es/configs/editor-views.js +1 -1
- package/dist/es/keys/list.js +13 -2
- package/dist/es/plugins/affiliations.js +0 -3
- package/dist/es/plugins/bibliography/index.js +1 -1
- package/dist/es/plugins/footnotes/footnotes-utils.js +0 -31
- package/dist/es/plugins/footnotes/index.js +27 -78
- package/dist/es/plugins/highlight/index.js +5 -6
- package/dist/es/plugins/selected-suggestion-ui.js +4 -8
- package/dist/es/plugins/table-footnote.js +0 -3
- package/dist/es/views/base_node_view.js +1 -1
- package/dist/es/views/bibliography_element.js +0 -6
- package/dist/es/views/citation.js +0 -3
- package/dist/es/views/citation_editable.js +0 -6
- package/dist/es/views/footnotes_element.js +1 -3
- package/dist/es/views/inline_footnote.js +2 -17
- package/dist/types/plugins/bibliography/index.d.ts +1 -1
- package/dist/types/plugins/footnotes/footnotes-utils.d.ts +0 -1
- package/dist/types/plugins/footnotes/index.d.ts +3 -5
- package/dist/types/views/footnotes_element.d.ts +3 -3
- package/package.json +3 -3
- package/styles/AdvancedEditor.css +8 -6
- package/styles/Editor.css +3 -7
|
@@ -64,7 +64,7 @@ export default (props, dispatch) => {
|
|
|
64
64
|
footnote: footnote(props),
|
|
65
65
|
footnotes_element: footnotesElement(props),
|
|
66
66
|
inline_equation: inlineEquation(props),
|
|
67
|
-
inline_footnote: inlineFootnote(props
|
|
67
|
+
inline_footnote: inlineFootnote(props),
|
|
68
68
|
keyword: keyword(props, dispatch),
|
|
69
69
|
keyword_group: keywordGroup(props, dispatch),
|
|
70
70
|
link: link(props, dispatch),
|
package/dist/es/keys/list.js
CHANGED
|
@@ -15,15 +15,25 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
|
17
17
|
import { schema } from '@manuscripts/transform';
|
|
18
|
+
import { chainCommands, deleteSelection, joinBackward, } from 'prosemirror-commands';
|
|
19
|
+
import { undoInputRule } from 'prosemirror-inputrules';
|
|
18
20
|
import { liftListItem, sinkListItem, splitListItem, wrapInList, } from 'prosemirror-schema-list';
|
|
21
|
+
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
19
22
|
export const skipCommandTracking = (command) => (state, dispatch) => {
|
|
20
|
-
command(state, (tr) => {
|
|
23
|
+
return command(state, (tr) => {
|
|
21
24
|
if (dispatch) {
|
|
22
25
|
skipTracking(tr);
|
|
23
26
|
dispatch(tr);
|
|
24
27
|
}
|
|
25
28
|
});
|
|
26
|
-
|
|
29
|
+
};
|
|
30
|
+
const listItemBackward = (state, dispatch) => {
|
|
31
|
+
const { selection } = state;
|
|
32
|
+
const isListItem = findParentNodeOfType(schema.nodes.list_item)(selection);
|
|
33
|
+
if (isListItem) {
|
|
34
|
+
return joinBackward(state, dispatch);
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
27
37
|
};
|
|
28
38
|
const liftToOuterList = (itemType) => {
|
|
29
39
|
return function (state, dispatch) {
|
|
@@ -51,5 +61,6 @@ const listKeymap = {
|
|
|
51
61
|
'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.bullet_list)),
|
|
52
62
|
'Shift-Tab': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
|
|
53
63
|
Tab: skipCommandTracking(sinkListItem(schema.nodes.list_item)),
|
|
64
|
+
Backspace: skipCommandTracking(chainCommands(undoInputRule, listItemBackward, deleteSelection)),
|
|
54
65
|
};
|
|
55
66
|
export default listKeymap;
|
|
@@ -70,9 +70,6 @@ export default () => {
|
|
|
70
70
|
},
|
|
71
71
|
appendTransaction(transactions, oldState, newState) {
|
|
72
72
|
const { indexedAffiliationIds } = affiliationsKey.getState(newState);
|
|
73
|
-
if (!transactions.find((tr) => tr.docChanged)) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
73
|
const oldPluginState = affiliationsKey.getState(oldState);
|
|
77
74
|
const { tr } = newState;
|
|
78
75
|
const affiliations = [];
|
|
@@ -51,7 +51,7 @@ export default (props) => {
|
|
|
51
51
|
props: {
|
|
52
52
|
decorations(state) {
|
|
53
53
|
const bib = getBibliographyPluginState(state);
|
|
54
|
-
return DecorationSet.create(state.doc,
|
|
54
|
+
return DecorationSet.create(state.doc, buildDecorations(bib, state.doc));
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
});
|
|
@@ -104,34 +104,3 @@ export const getInlineFootnotes = (id, targetNode) => {
|
|
|
104
104
|
});
|
|
105
105
|
return inlineFootnotes;
|
|
106
106
|
};
|
|
107
|
-
export function getAlphaOrderIndices(index) {
|
|
108
|
-
const unicodeInterval = [97, 123];
|
|
109
|
-
const places = unicodeInterval[1] - unicodeInterval[0];
|
|
110
|
-
function getClassCount(n, order) {
|
|
111
|
-
return n * Math.pow(places, order - 1);
|
|
112
|
-
}
|
|
113
|
-
let indices = null;
|
|
114
|
-
for (;;) {
|
|
115
|
-
let current = index;
|
|
116
|
-
let position = 1;
|
|
117
|
-
while (current >= places) {
|
|
118
|
-
current = current / places;
|
|
119
|
-
position++;
|
|
120
|
-
}
|
|
121
|
-
const newIndex = Math.floor(current);
|
|
122
|
-
indices = indices ? indices : new Array(position).fill(0);
|
|
123
|
-
indices.splice(indices.length - position, 1, newIndex);
|
|
124
|
-
index -= getClassCount(newIndex, position);
|
|
125
|
-
if (position === 1) {
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return (indices || [])
|
|
130
|
-
.map((v, i, array) => {
|
|
131
|
-
if (array.length > 1 && i !== array.length - 1) {
|
|
132
|
-
return String.fromCodePoint(v + unicodeInterval[0] - 1);
|
|
133
|
-
}
|
|
134
|
-
return String.fromCodePoint(v + unicodeInterval[0]);
|
|
135
|
-
})
|
|
136
|
-
.join('');
|
|
137
|
-
}
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import { isFootnoteNode, isFootnotesElementNode, isFootnotesSectionNode, isInlineFootnoteNode, schema, } from '@manuscripts/transform';
|
|
16
|
+
import { isFootnoteNode, isInlineFootnoteNode, schema, } from '@manuscripts/transform';
|
|
18
17
|
import { isEqual } from 'lodash';
|
|
19
|
-
import { NodeSelection, Plugin, PluginKey
|
|
18
|
+
import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
|
|
20
19
|
import { findParentNodeClosestToPos, findParentNodeOfType, } from 'prosemirror-utils';
|
|
21
20
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
22
21
|
import { alertIcon, deleteIcon } from '../../assets';
|
|
@@ -24,12 +23,29 @@ import { DeleteFootnoteDialog, } from '../../components/views/DeleteFootnoteDial
|
|
|
24
23
|
import { findParentNodeWithIdValue, getChildOfType } from '../../lib/utils';
|
|
25
24
|
import ReactSubView from '../../views/ReactSubView';
|
|
26
25
|
import { placeholderWidget } from '../placeholder';
|
|
27
|
-
import { findTableInlineFootnoteIds,
|
|
26
|
+
import { findTableInlineFootnoteIds, getInlineFootnotes, } from './footnotes-utils';
|
|
28
27
|
export const footnotesKey = new PluginKey('footnotes');
|
|
28
|
+
export const buildPluginState = (doc) => {
|
|
29
|
+
const nodes = [];
|
|
30
|
+
let index = 0;
|
|
31
|
+
const labels = new Map();
|
|
32
|
+
doc.descendants((node, pos, parentNode) => {
|
|
33
|
+
if (isInlineFootnoteNode(node) &&
|
|
34
|
+
parentNode &&
|
|
35
|
+
parentNode.type !== schema.nodes.table_cell &&
|
|
36
|
+
parentNode.type !== schema.nodes.table_header) {
|
|
37
|
+
nodes.push([node, pos]);
|
|
38
|
+
node.attrs.rids.forEach((rid) => {
|
|
39
|
+
labels.set(rid, String(++index));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return { nodes, labels };
|
|
44
|
+
};
|
|
29
45
|
const scrollToInlineFootnote = (rid, view) => {
|
|
30
46
|
view.state.doc.descendants((node, pos) => {
|
|
31
47
|
const footnote = node;
|
|
32
|
-
if (
|
|
48
|
+
if (footnote.attrs.rids.includes(rid)) {
|
|
33
49
|
const selection = NodeSelection.create(view.state.doc, pos);
|
|
34
50
|
view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
|
|
35
51
|
}
|
|
@@ -39,7 +55,7 @@ const labelWidget = (label, id) => (view) => {
|
|
|
39
55
|
const element = document.createElement('span');
|
|
40
56
|
element.className = 'footnote-label';
|
|
41
57
|
element.textContent = label;
|
|
42
|
-
element.addEventListener('
|
|
58
|
+
element.addEventListener('click', () => {
|
|
43
59
|
scrollToInlineFootnote(id, view);
|
|
44
60
|
});
|
|
45
61
|
return element;
|
|
@@ -113,38 +129,6 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
|
|
|
113
129
|
});
|
|
114
130
|
return deleteBtn;
|
|
115
131
|
};
|
|
116
|
-
export const buildPluginState = (doc) => {
|
|
117
|
-
const inlineFootnotes = [];
|
|
118
|
-
const footnotes = new Map();
|
|
119
|
-
let footnoteElement;
|
|
120
|
-
doc.descendants((node, pos, parentNode) => {
|
|
121
|
-
if (isFootnotesSectionNode(node)) {
|
|
122
|
-
node.descendants((node, childPos) => {
|
|
123
|
-
if (isFootnotesElementNode(node)) {
|
|
124
|
-
footnoteElement = [node, pos + childPos];
|
|
125
|
-
}
|
|
126
|
-
if (isFootnoteNode(node)) {
|
|
127
|
-
footnotes.set(node.attrs.id, [node, pos + childPos]);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
if (isInlineFootnoteNode(node) &&
|
|
132
|
-
parentNode &&
|
|
133
|
-
parentNode.type !== schema.nodes.table_cell &&
|
|
134
|
-
parentNode.type !== schema.nodes.table_header) {
|
|
135
|
-
inlineFootnotes.push([node, pos]);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
let index = 0;
|
|
139
|
-
const labels = new Map();
|
|
140
|
-
inlineFootnotes.sort((a, b) => a[1] - b[1]);
|
|
141
|
-
inlineFootnotes.forEach(([node]) => {
|
|
142
|
-
node.attrs.rids.forEach((rid) => {
|
|
143
|
-
labels.set(rid, getAlphaOrderIndices(index++));
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
return { inlineFootnotes, labels, footnotes, footnoteElement };
|
|
147
|
-
};
|
|
148
132
|
export default (props) => {
|
|
149
133
|
return new Plugin({
|
|
150
134
|
key: footnotesKey,
|
|
@@ -153,60 +137,25 @@ export default (props) => {
|
|
|
153
137
|
return buildPluginState(instance.doc);
|
|
154
138
|
},
|
|
155
139
|
apply(tr, value, oldState, newState) {
|
|
156
|
-
const prevState = footnotesKey.getState(oldState);
|
|
157
|
-
if (!tr.docChanged && prevState) {
|
|
158
|
-
return prevState;
|
|
159
|
-
}
|
|
160
140
|
return buildPluginState(newState.doc);
|
|
161
141
|
},
|
|
162
142
|
},
|
|
163
143
|
appendTransaction(transactions, oldState, newState) {
|
|
164
|
-
const {
|
|
165
|
-
const {
|
|
166
|
-
|
|
167
|
-
const newIds = inlineFootnoteNodes.map(([node]) => node.attrs.rids);
|
|
168
|
-
const initTransaction = transactions.find((t) => t.getMeta('INIT'));
|
|
169
|
-
if (!footnoteElement || (!initTransaction && isEqual(prevIds, newIds))) {
|
|
144
|
+
const { nodes: oldInlineFootnoteNodes } = footnotesKey.getState(oldState);
|
|
145
|
+
const { nodes: inlineFootnoteNodes, labels } = footnotesKey.getState(newState);
|
|
146
|
+
if (isEqual(inlineFootnoteNodes, oldInlineFootnoteNodes)) {
|
|
170
147
|
return null;
|
|
171
148
|
}
|
|
172
149
|
const { tr } = newState;
|
|
173
|
-
const footnotesReordered = [];
|
|
174
|
-
const footnotesRest = new Map(footnotes);
|
|
175
150
|
inlineFootnoteNodes.forEach(([node, pos]) => {
|
|
176
151
|
const footnote = node;
|
|
177
152
|
const contents = footnote.attrs.rids
|
|
178
|
-
.map((rid) =>
|
|
179
|
-
const currentfNode = footnotesRest.get(rid);
|
|
180
|
-
if (currentfNode) {
|
|
181
|
-
footnotesReordered.push(currentfNode[0]);
|
|
182
|
-
footnotesRest.delete(rid);
|
|
183
|
-
}
|
|
184
|
-
return labels.get(rid);
|
|
185
|
-
})
|
|
153
|
+
.map((rid) => labels.get(rid))
|
|
186
154
|
.join('');
|
|
187
155
|
if (footnote.attrs.contents !== contents) {
|
|
188
156
|
tr.setNodeMarkup(pos, undefined, Object.assign(Object.assign({}, footnote.attrs), { rids: footnote.attrs.rids, contents }));
|
|
189
157
|
}
|
|
190
158
|
});
|
|
191
|
-
footnotesRest.forEach(([node]) => footnotesReordered.push(node));
|
|
192
|
-
const newFElement = schema.nodes.footnotes_element.create(footnoteElement[0].attrs, footnotesReordered);
|
|
193
|
-
if (newFElement && footnotes.size > 0) {
|
|
194
|
-
tr.replaceWith(footnoteElement[1], footnoteElement[1] + footnoteElement[0].nodeSize, newFElement);
|
|
195
|
-
}
|
|
196
|
-
const prevSelection = newState.selection;
|
|
197
|
-
const selectedFootnote = findParentNodeClosestToPos(prevSelection.$anchor, (node) => isFootnoteNode(node));
|
|
198
|
-
if (selectedFootnote && footnotes.size > 0) {
|
|
199
|
-
let newFootnotePos = 0;
|
|
200
|
-
for (let i = 0; i < footnotesReordered.length; i++) {
|
|
201
|
-
const node = footnotesReordered[i];
|
|
202
|
-
newFootnotePos += node.nodeSize;
|
|
203
|
-
if (node.attrs.id === selectedFootnote.node.attrs.id) {
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
tr.setSelection(TextSelection.create(tr.doc, footnoteElement[1] + newFootnotePos));
|
|
208
|
-
}
|
|
209
|
-
skipTracking(tr);
|
|
210
159
|
return tr;
|
|
211
160
|
},
|
|
212
161
|
props: {
|
|
@@ -249,7 +198,7 @@ export default (props) => {
|
|
|
249
198
|
}
|
|
250
199
|
}
|
|
251
200
|
if (!((_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.textContent)) {
|
|
252
|
-
decorations.push(Decoration.widget(pos + 2, placeholderWidget('
|
|
201
|
+
decorations.push(Decoration.widget(pos + 2, placeholderWidget('Add new note here')));
|
|
253
202
|
}
|
|
254
203
|
if (tableInlineFootnoteIds &&
|
|
255
204
|
!tableInlineFootnoteIds.has(node.attrs.id)) {
|
|
@@ -56,13 +56,12 @@ export default (props) => {
|
|
|
56
56
|
key: highlightKey,
|
|
57
57
|
state: {
|
|
58
58
|
init: (tr, state) => buildPluginState(state.doc),
|
|
59
|
-
apply: (tr
|
|
59
|
+
apply: (tr) => {
|
|
60
60
|
const meta = tr.getMeta(highlightKey);
|
|
61
|
-
if (meta
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return value;
|
|
61
|
+
if (meta) {
|
|
62
|
+
if (SET_COMMENT in meta) {
|
|
63
|
+
props.setComment(meta[SET_COMMENT]);
|
|
64
|
+
}
|
|
66
65
|
}
|
|
67
66
|
return buildPluginState(tr.doc);
|
|
68
67
|
},
|
|
@@ -91,6 +91,7 @@ export default (props) => new Plugin({
|
|
|
91
91
|
return buildSelectedSuggestionDecoration(suggestionId, state, props);
|
|
92
92
|
}
|
|
93
93
|
if (tr.getMeta(CLEAR_SUGGESTION_ID)) {
|
|
94
|
+
props.setEditorSelectedSuggestion(undefined);
|
|
94
95
|
return DecorationSet.empty;
|
|
95
96
|
}
|
|
96
97
|
return value;
|
|
@@ -101,11 +102,8 @@ export default (props) => new Plugin({
|
|
|
101
102
|
const nodeClicked = view.state.doc.nodeAt(pos);
|
|
102
103
|
const trackChangesData = nodeClicked && getTrackChangesData(nodeClicked);
|
|
103
104
|
if (!trackChangesData) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
view.dispatch(newTr);
|
|
107
|
-
props.setEditorSelectedSuggestion(undefined);
|
|
108
|
-
});
|
|
105
|
+
view.dispatch(view.state.tr.setMeta(CLEAR_SUGGESTION_ID, true));
|
|
106
|
+
props.setEditorSelectedSuggestion(undefined);
|
|
109
107
|
}
|
|
110
108
|
},
|
|
111
109
|
decorations: (state) => selectedSuggestionKey.getState(state),
|
|
@@ -121,9 +119,7 @@ const buildSelectedSuggestionDecoration = (suggestionId, state, props) => {
|
|
|
121
119
|
decorations.push(decoration(change.from, change.to, {
|
|
122
120
|
class: 'selected-suggestion',
|
|
123
121
|
}));
|
|
124
|
-
|
|
125
|
-
props.setEditorSelectedSuggestion(change.id);
|
|
126
|
-
}, 0);
|
|
122
|
+
props.setEditorSelectedSuggestion(change.id);
|
|
127
123
|
}
|
|
128
124
|
return DecorationSet.create(state.doc, decorations);
|
|
129
125
|
};
|
|
@@ -12,9 +12,6 @@ const isInlineFootnoteChange = (step, oldState, newState) => {
|
|
|
12
12
|
export default () => {
|
|
13
13
|
return new Plugin({
|
|
14
14
|
appendTransaction(transactions, oldState, newState) {
|
|
15
|
-
if (!transactions.find((tr) => tr.docChanged)) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
15
|
const tableInlineFootnoteChange = transactions.find((tr) => tr.steps.find((s, i) => {
|
|
19
16
|
var _a;
|
|
20
17
|
if (s instanceof ReplaceStep) {
|
|
@@ -59,7 +59,7 @@ export class BaseNodeView {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
setDomAttrs(node, element, omit = [
|
|
62
|
+
setDomAttrs(node, element, omit = []) {
|
|
63
63
|
Object.keys(node.attrs || {}).forEach((attr) => {
|
|
64
64
|
if (!omit.includes(attr)) {
|
|
65
65
|
element.setAttribute(attr, node.attrs[attr]);
|
|
@@ -43,9 +43,6 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
43
43
|
this.showPopper = (id) => {
|
|
44
44
|
this.props.popper.destroy();
|
|
45
45
|
const bib = getBibliographyPluginState(this.view.state);
|
|
46
|
-
if (!bib) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
46
|
const componentProps = {
|
|
50
47
|
items: Array.from(bib.bibliographyItems.values()),
|
|
51
48
|
citationCounts: bib.citationCounts,
|
|
@@ -137,9 +134,6 @@ export class BibliographyElementBlockView extends BlockView {
|
|
|
137
134
|
const can = this.props.getCapabilities();
|
|
138
135
|
const wrapper = document.createElement('div');
|
|
139
136
|
wrapper.classList.add('contents');
|
|
140
|
-
if (!bib) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
137
|
const [meta, bibliography] = bib.provider.makeBibliography();
|
|
144
138
|
for (let i = 0; i < bibliography.length; i++) {
|
|
145
139
|
const id = meta.entry_ids[i];
|
|
@@ -37,9 +37,6 @@ export class CitationView extends BaseNodeView {
|
|
|
37
37
|
};
|
|
38
38
|
this.updateContents = () => {
|
|
39
39
|
const bib = getBibliographyPluginState(this.view.state);
|
|
40
|
-
if (!bib) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
40
|
const classes = [
|
|
44
41
|
'citation',
|
|
45
42
|
...getChangeClasses(this.node.attrs.dataTracked),
|
|
@@ -84,9 +84,6 @@ export class CitationEditableView extends CitationView {
|
|
|
84
84
|
this.showPopper = () => {
|
|
85
85
|
this.props.popper.destroy();
|
|
86
86
|
const bib = getBibliographyPluginState(this.view.state);
|
|
87
|
-
if (!bib) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
87
|
const can = this.props.getCapabilities();
|
|
91
88
|
const attrs = getActualAttrs(this.node);
|
|
92
89
|
const rids = attrs.rids;
|
|
@@ -149,9 +146,6 @@ export class CitationEditableView extends CitationView {
|
|
|
149
146
|
};
|
|
150
147
|
this.handleCite = (items) => {
|
|
151
148
|
const bib = getBibliographyPluginState(this.view.state);
|
|
152
|
-
if (!bib) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
149
|
const attrs = getActualAttrs(this.node);
|
|
156
150
|
const rids = [...attrs.rids];
|
|
157
151
|
items = items.filter((i) => !rids.includes(i.id));
|
|
@@ -22,9 +22,7 @@ export class FootnotesElementView extends BlockView {
|
|
|
22
22
|
this.elementType = 'div';
|
|
23
23
|
this.checkEditability = () => {
|
|
24
24
|
var _a, _b;
|
|
25
|
-
const editable = this.
|
|
26
|
-
? 'true'
|
|
27
|
-
: 'false';
|
|
25
|
+
const editable = this.node.childCount ? 'true' : 'false';
|
|
28
26
|
(_a = this.contentDOM) === null || _a === void 0 ? void 0 : _a.setAttribute('contenteditable', editable);
|
|
29
27
|
(_b = this.dom) === null || _b === void 0 ? void 0 : _b.setAttribute('contenteditable', editable);
|
|
30
28
|
};
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { TableFootnotesSelector, } from '@manuscripts/style-guide';
|
|
17
17
|
import { schema, } from '@manuscripts/transform';
|
|
18
|
-
import { TextSelection } from 'prosemirror-state';
|
|
19
18
|
import { findChildrenByType, findParentNodeClosestToPos, } from 'prosemirror-utils';
|
|
20
19
|
import { insertTableFootnote } from '../commands';
|
|
21
20
|
import { getChangeClasses, isDeleted, isRejectedInsert, } from '../lib/track-changes-utils';
|
|
@@ -28,7 +27,6 @@ export class InlineFootnoteView extends BaseNodeView {
|
|
|
28
27
|
super(...arguments);
|
|
29
28
|
this.findParentTableElement = () => findParentNodeClosestToPos(this.view.state.doc.resolve(this.getPos()), (node) => node.type === schema.nodes.table_element);
|
|
30
29
|
this.handleClick = () => {
|
|
31
|
-
var _a;
|
|
32
30
|
if (isDeleted(this.node)) {
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
@@ -45,24 +43,11 @@ export class InlineFootnoteView extends BaseNodeView {
|
|
|
45
43
|
this.props.popper.show(this.dom, this.popperContainer, 'bottom-end');
|
|
46
44
|
}
|
|
47
45
|
else {
|
|
48
|
-
|
|
49
|
-
let nodePos = undefined;
|
|
50
|
-
this.view.state.doc.descendants((node, pos) => {
|
|
51
|
-
if (node.attrs.id === this.node.attrs.rids[0]) {
|
|
52
|
-
nodePos = pos;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
if (nodePos && this.props.dispatch) {
|
|
56
|
-
const sel = TextSelection.near(this.view.state.doc.resolve(nodePos + 1));
|
|
57
|
-
this.props.dispatch(this.view.state.tr.setSelection(sel).scrollIntoView());
|
|
58
|
-
}
|
|
59
|
-
}
|
|
46
|
+
this.props.history.push(Object.assign(Object.assign({}, this.props.history.location), { hash: '#' + this.node.attrs.rid }));
|
|
60
47
|
}
|
|
61
48
|
};
|
|
62
49
|
this.updateContents = () => {
|
|
63
|
-
|
|
64
|
-
this.dom.setAttribute('rids', node.attrs.rids.join(','));
|
|
65
|
-
this.dom.setAttribute('contents', node.attrs.contents);
|
|
50
|
+
this.setDomAttrs(this.node, this.dom);
|
|
66
51
|
this.dom.className = [
|
|
67
52
|
'footnote',
|
|
68
53
|
...getChangeClasses(this.node.attrs.dataTracked),
|
|
@@ -36,4 +36,4 @@ export interface BibliographyProps {
|
|
|
36
36
|
}
|
|
37
37
|
declare const _default: (props: BibliographyProps) => Plugin<PluginState>;
|
|
38
38
|
export default _default;
|
|
39
|
-
export declare const getBibliographyPluginState: (state: EditorState) => PluginState
|
|
39
|
+
export declare const getBibliographyPluginState: (state: EditorState) => PluginState;
|
|
@@ -13,17 +13,15 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { InlineFootnoteNode, ManuscriptNode } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
18
18
|
import { PluginProps } from '../../configs/editor-plugins';
|
|
19
19
|
interface PluginState {
|
|
20
|
-
|
|
20
|
+
nodes: [InlineFootnoteNode, number][];
|
|
21
21
|
labels: Map<string, string>;
|
|
22
|
-
footnotes: Map<string, [FootnoteNode, number]>;
|
|
23
|
-
footnoteElement?: [FootnotesElementNode, number];
|
|
24
22
|
}
|
|
25
23
|
export declare const footnotesKey: PluginKey<PluginState>;
|
|
26
|
-
export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
|
|
27
24
|
export declare const buildPluginState: (doc: ManuscriptNode) => PluginState;
|
|
25
|
+
export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
|
|
28
26
|
declare const _default: (props: PluginProps) => Plugin<PluginState>;
|
|
29
27
|
export default _default;
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
import { BaseNodeProps } from './base_node_view';
|
|
16
17
|
import BlockView from './block_view';
|
|
17
|
-
|
|
18
|
-
export declare class FootnotesElementView<Props extends EditableBlockProps> extends BlockView<Props> {
|
|
18
|
+
export declare class FootnotesElementView<PropsType extends BaseNodeProps> extends BlockView<PropsType> {
|
|
19
19
|
elementType: string;
|
|
20
20
|
onUpdateContent(): void;
|
|
21
21
|
checkEditability: () => void;
|
|
22
22
|
}
|
|
23
|
-
declare const _default: (props:
|
|
23
|
+
declare const _default: (props: BaseNodeProps) => import("../types").NodeViewCreator<FootnotesElementView<any>>;
|
|
24
24
|
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.9.
|
|
4
|
+
"version": "1.9.9",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@manuscripts/json-schema": "^2.2.7",
|
|
33
33
|
"@manuscripts/library": "^1.3.6",
|
|
34
34
|
"@manuscripts/style-guide": "1.12.4",
|
|
35
|
-
"@manuscripts/track-changes-plugin": "1.7.10
|
|
35
|
+
"@manuscripts/track-changes-plugin": "1.7.10",
|
|
36
36
|
"@manuscripts/transform": "2.3.3",
|
|
37
37
|
"astrocite-eutils": "^0.16.4",
|
|
38
38
|
"mathjax-full": "^3.2.2",
|
|
@@ -111,4 +111,4 @@
|
|
|
111
111
|
"@types/react": "^17.0.2",
|
|
112
112
|
"prosemirror-tables": "^1.3.5"
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|
|
@@ -686,12 +686,12 @@ Next levels are shifted 'up' by 1
|
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
.selected-suggestion {
|
|
689
|
-
background: #
|
|
689
|
+
background: #BCE7F6 !important;
|
|
690
690
|
}
|
|
691
691
|
|
|
692
692
|
.selected-suggestion {
|
|
693
693
|
border-width: 2px 0 2px 0 !important;
|
|
694
|
-
border-color: #
|
|
694
|
+
border-color: #20AEDF !important;
|
|
695
695
|
border-radius: 3px !important;
|
|
696
696
|
border-style: solid !important;
|
|
697
697
|
}
|
|
@@ -795,14 +795,14 @@ Next levels are shifted 'up' by 1
|
|
|
795
795
|
display: flex;
|
|
796
796
|
justify-content: space-between;
|
|
797
797
|
align-items: flex-start;
|
|
798
|
-
gap: 0
|
|
798
|
+
gap: 0 .5em;
|
|
799
799
|
}
|
|
800
800
|
.contributors-list {
|
|
801
801
|
display: flex;
|
|
802
802
|
max-width: 100%;
|
|
803
803
|
flex: 0 1 auto;
|
|
804
804
|
flex-wrap: wrap;
|
|
805
|
-
gap: 0
|
|
805
|
+
gap: 0 .25em;
|
|
806
806
|
}
|
|
807
807
|
.contributors .tools-panel {
|
|
808
808
|
position: initial;
|
|
@@ -825,7 +825,7 @@ Next levels are shifted 'up' by 1
|
|
|
825
825
|
left: 0;
|
|
826
826
|
top: -8px;
|
|
827
827
|
width: auto;
|
|
828
|
-
height: auto;
|
|
828
|
+
height: auto;
|
|
829
829
|
}
|
|
830
830
|
.contributor {
|
|
831
831
|
position: relative;
|
|
@@ -864,6 +864,8 @@ Next levels are shifted 'up' by 1
|
|
|
864
864
|
vertical-align: top;
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
+
|
|
868
|
+
|
|
867
869
|
.contributor-note {
|
|
868
870
|
display: inline-block;
|
|
869
871
|
font-size: 0.75em;
|
|
@@ -891,4 +893,4 @@ Next levels are shifted 'up' by 1
|
|
|
891
893
|
|
|
892
894
|
* {
|
|
893
895
|
scroll-behavior: smooth;
|
|
894
|
-
}
|
|
896
|
+
}
|
package/styles/Editor.css
CHANGED
|
@@ -937,14 +937,13 @@
|
|
|
937
937
|
|
|
938
938
|
.ProseMirror .footnote::before {
|
|
939
939
|
content: attr(contents);
|
|
940
|
+
display: inline-block;
|
|
940
941
|
position: relative;
|
|
941
942
|
cursor: pointer;
|
|
942
943
|
vertical-align: super;
|
|
943
|
-
z-index: 1;
|
|
944
944
|
font-size: 75%;
|
|
945
945
|
color: #0d79d0;
|
|
946
946
|
}
|
|
947
|
-
|
|
948
947
|
.ProseMirror .table-footer {
|
|
949
948
|
font-size: 14px;
|
|
950
949
|
padding-top: 8px;
|
|
@@ -952,7 +951,7 @@
|
|
|
952
951
|
|
|
953
952
|
.ProseMirror .table-footnotes-element:has(> div):not(:first-child)::before {
|
|
954
953
|
content: '';
|
|
955
|
-
border-bottom: 1px dashed #
|
|
954
|
+
border-bottom: 1px dashed #C9C9C9;
|
|
956
955
|
display: block;
|
|
957
956
|
margin-bottom: 8px;
|
|
958
957
|
}
|
|
@@ -976,10 +975,7 @@
|
|
|
976
975
|
position: relative;
|
|
977
976
|
}
|
|
978
977
|
|
|
979
|
-
.ProseMirror
|
|
980
|
-
.table-footnotes-element
|
|
981
|
-
> div:not(:has(.unctied-table-footnote))
|
|
982
|
-
p::before {
|
|
978
|
+
.ProseMirror .table-footnotes-element > div:not(:has(.unctied-table-footnote)) p::before {
|
|
983
979
|
counter-increment: table_footnote;
|
|
984
980
|
content: counter(table_footnote);
|
|
985
981
|
display: inline-block;
|