@manuscripts/body-editor 1.13.21 → 1.13.23
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/footnotes/index.js +18 -23
- package/dist/cjs/plugins/selected-suggestion.js +2 -2
- package/dist/es/plugins/footnotes/index.js +19 -24
- package/dist/es/plugins/selected-suggestion.js +2 -2
- package/package.json +4 -4
- package/styles/AdvancedEditor.css +3 -3
- package/styles/Editor.css +9 -10
|
@@ -58,7 +58,7 @@ const uncitedFootnoteWidget = () => () => {
|
|
|
58
58
|
return element;
|
|
59
59
|
};
|
|
60
60
|
exports.uncitedFootnoteWidget = uncitedFootnoteWidget;
|
|
61
|
-
const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) => {
|
|
61
|
+
const deleteFootnoteWidget = (node, props, id, tableElement, tableElementFooter) => (view, getPos) => {
|
|
62
62
|
const deleteBtn = document.createElement('span');
|
|
63
63
|
deleteBtn.className = 'delete-icon';
|
|
64
64
|
deleteBtn.innerHTML = assets_1.deleteIcon;
|
|
@@ -75,17 +75,14 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
|
|
|
75
75
|
const handleDelete = () => {
|
|
76
76
|
let tr = view.state.tr;
|
|
77
77
|
const pos = getPos();
|
|
78
|
-
if (node.type === transform_1.schema.nodes.
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
if (node.type === transform_1.schema.nodes.general_table_footnote && pos) {
|
|
79
|
+
if (tableElementFooter &&
|
|
80
|
+
!(0, utils_1.getChildOfType)(tableElementFooter.node, transform_1.schema.nodes.footnotes_element, true) &&
|
|
81
|
+
tableElementFooter.pos) {
|
|
82
|
+
tr.delete(tableElementFooter.pos - 1, tableElementFooter.pos + tableElementFooter.node.nodeSize);
|
|
82
83
|
}
|
|
83
84
|
else {
|
|
84
|
-
|
|
85
|
-
if (item.type === transform_1.schema.nodes.general_table_footnote && pos) {
|
|
86
|
-
tr.delete(pos - 1, pos + item.nodeSize + 1);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
85
|
+
tr.delete(pos - 1, pos + node.nodeSize + 1);
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
if (node.type === transform_1.schema.nodes.footnote && pos) {
|
|
@@ -237,27 +234,25 @@ exports.default = (props) => {
|
|
|
237
234
|
props: {
|
|
238
235
|
decorations: (state) => {
|
|
239
236
|
const decorations = [];
|
|
240
|
-
const
|
|
237
|
+
const generalFootnote = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.general_table_footnote)(state.selection);
|
|
241
238
|
const tableElement = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element)(state.selection);
|
|
239
|
+
const tableElementFooter = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element_footer)(state.selection);
|
|
242
240
|
const footnote = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.footnote)(state.selection);
|
|
243
241
|
let targetNode;
|
|
244
242
|
if (footnote) {
|
|
245
243
|
targetNode = footnote;
|
|
246
244
|
}
|
|
247
|
-
else if (
|
|
248
|
-
targetNode =
|
|
245
|
+
else if (generalFootnote) {
|
|
246
|
+
targetNode = generalFootnote;
|
|
249
247
|
}
|
|
250
248
|
const can = props.getCapabilities();
|
|
251
|
-
if (targetNode && can.editArticle) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
key: targetNode.node.attrs.id,
|
|
259
|
-
}));
|
|
260
|
-
}
|
|
249
|
+
if (targetNode && can.editArticle && (0, commands_1.isTextSelection)(state.selection)) {
|
|
250
|
+
decorations.push(prosemirror_view_1.Decoration.node(targetNode.pos, targetNode.pos + targetNode.node.nodeSize, {
|
|
251
|
+
class: 'footnote-selected',
|
|
252
|
+
}));
|
|
253
|
+
decorations.push(prosemirror_view_1.Decoration.widget(targetNode.pos + 1, deleteFootnoteWidget(targetNode.node, props, targetNode.node.attrs.id, tableElement, tableElementFooter), {
|
|
254
|
+
key: targetNode.node.attrs.id,
|
|
255
|
+
}));
|
|
261
256
|
}
|
|
262
257
|
const { labels } = exports.footnotesKey.getState(state);
|
|
263
258
|
let tableInlineFootnoteIds = undefined;
|
|
@@ -83,8 +83,8 @@ const buildNodeDecoration = (doc, selection) => {
|
|
|
83
83
|
const from = selection.from;
|
|
84
84
|
const to = selection.to;
|
|
85
85
|
const inline = node.type === transform_1.schema.nodes.keyword || node.isInline;
|
|
86
|
-
const
|
|
87
|
-
|
|
86
|
+
const decorationType = inline ? prosemirror_view_1.Decoration.inline : prosemirror_view_1.Decoration.node;
|
|
87
|
+
const decoration = decorationType(from, to, {
|
|
88
88
|
class: 'selected-suggestion',
|
|
89
89
|
});
|
|
90
90
|
return {
|
|
@@ -22,7 +22,7 @@ import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
|
22
22
|
import { alertIcon, deleteIcon } from '../../assets';
|
|
23
23
|
import { isTextSelection } from '../../commands';
|
|
24
24
|
import { DeleteFootnoteDialog, } from '../../components/views/DeleteFootnoteDialog';
|
|
25
|
-
import {
|
|
25
|
+
import { getChildOfType } from '../../lib/utils';
|
|
26
26
|
import ReactSubView from '../../views/ReactSubView';
|
|
27
27
|
import { placeholderWidget } from '../placeholder';
|
|
28
28
|
import { findTableInlineFootnoteIds, getAlphaOrderIndices, getInlineFootnotes, } from './footnotes-utils';
|
|
@@ -51,7 +51,7 @@ export const uncitedFootnoteWidget = () => () => {
|
|
|
51
51
|
element.innerHTML = alertIcon;
|
|
52
52
|
return element;
|
|
53
53
|
};
|
|
54
|
-
const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) => {
|
|
54
|
+
const deleteFootnoteWidget = (node, props, id, tableElement, tableElementFooter) => (view, getPos) => {
|
|
55
55
|
const deleteBtn = document.createElement('span');
|
|
56
56
|
deleteBtn.className = 'delete-icon';
|
|
57
57
|
deleteBtn.innerHTML = deleteIcon;
|
|
@@ -68,17 +68,14 @@ const deleteFootnoteWidget = (node, props, id, tableElement) => (view, getPos) =
|
|
|
68
68
|
const handleDelete = () => {
|
|
69
69
|
let tr = view.state.tr;
|
|
70
70
|
const pos = getPos();
|
|
71
|
-
if (node.type === schema.nodes.
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
if (node.type === schema.nodes.general_table_footnote && pos) {
|
|
72
|
+
if (tableElementFooter &&
|
|
73
|
+
!getChildOfType(tableElementFooter.node, schema.nodes.footnotes_element, true) &&
|
|
74
|
+
tableElementFooter.pos) {
|
|
75
|
+
tr.delete(tableElementFooter.pos - 1, tableElementFooter.pos + tableElementFooter.node.nodeSize);
|
|
75
76
|
}
|
|
76
77
|
else {
|
|
77
|
-
|
|
78
|
-
if (item.type === schema.nodes.general_table_footnote && pos) {
|
|
79
|
-
tr.delete(pos - 1, pos + item.nodeSize + 1);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
78
|
+
tr.delete(pos - 1, pos + node.nodeSize + 1);
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
if (node.type === schema.nodes.footnote && pos) {
|
|
@@ -229,27 +226,25 @@ export default (props) => {
|
|
|
229
226
|
props: {
|
|
230
227
|
decorations: (state) => {
|
|
231
228
|
const decorations = [];
|
|
232
|
-
const
|
|
229
|
+
const generalFootnote = findParentNodeOfType(schema.nodes.general_table_footnote)(state.selection);
|
|
233
230
|
const tableElement = findParentNodeOfType(schema.nodes.table_element)(state.selection);
|
|
231
|
+
const tableElementFooter = findParentNodeOfType(schema.nodes.table_element_footer)(state.selection);
|
|
234
232
|
const footnote = findParentNodeOfType(schema.nodes.footnote)(state.selection);
|
|
235
233
|
let targetNode;
|
|
236
234
|
if (footnote) {
|
|
237
235
|
targetNode = footnote;
|
|
238
236
|
}
|
|
239
|
-
else if (
|
|
240
|
-
targetNode =
|
|
237
|
+
else if (generalFootnote) {
|
|
238
|
+
targetNode = generalFootnote;
|
|
241
239
|
}
|
|
242
240
|
const can = props.getCapabilities();
|
|
243
|
-
if (targetNode && can.editArticle) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
key: targetNode.node.attrs.id,
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
241
|
+
if (targetNode && can.editArticle && isTextSelection(state.selection)) {
|
|
242
|
+
decorations.push(Decoration.node(targetNode.pos, targetNode.pos + targetNode.node.nodeSize, {
|
|
243
|
+
class: 'footnote-selected',
|
|
244
|
+
}));
|
|
245
|
+
decorations.push(Decoration.widget(targetNode.pos + 1, deleteFootnoteWidget(targetNode.node, props, targetNode.node.attrs.id, tableElement, tableElementFooter), {
|
|
246
|
+
key: targetNode.node.attrs.id,
|
|
247
|
+
}));
|
|
253
248
|
}
|
|
254
249
|
const { labels } = footnotesKey.getState(state);
|
|
255
250
|
let tableInlineFootnoteIds = undefined;
|
|
@@ -80,8 +80,8 @@ const buildNodeDecoration = (doc, selection) => {
|
|
|
80
80
|
const from = selection.from;
|
|
81
81
|
const to = selection.to;
|
|
82
82
|
const inline = node.type === schema.nodes.keyword || node.isInline;
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const decorationType = inline ? Decoration.inline : Decoration.node;
|
|
84
|
+
const decoration = decorationType(from, to, {
|
|
85
85
|
class: 'selected-suggestion',
|
|
86
86
|
});
|
|
87
87
|
return {
|
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.13.
|
|
4
|
+
"version": "1.13.23",
|
|
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.10",
|
|
32
32
|
"@manuscripts/library": "1.3.10",
|
|
33
|
-
"@manuscripts/style-guide": "1.13.
|
|
33
|
+
"@manuscripts/style-guide": "1.13.15",
|
|
34
34
|
"@manuscripts/track-changes-plugin": "1.7.14",
|
|
35
|
-
"@manuscripts/transform": "2.3.
|
|
35
|
+
"@manuscripts/transform": "2.3.21",
|
|
36
36
|
"@popperjs/core": "^2.11.8",
|
|
37
37
|
"astrocite-eutils": "^0.16.4",
|
|
38
38
|
"codemirror": "^5.58.1",
|
|
@@ -110,4 +110,4 @@
|
|
|
110
110
|
"@types/react": "^17.0.2",
|
|
111
111
|
"prosemirror-tables": "^1.3.5"
|
|
112
112
|
}
|
|
113
|
-
}
|
|
113
|
+
}
|
|
@@ -335,9 +335,9 @@ Next levels are shifted 'up' by 1
|
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
.ProseMirror .figure-block > figure {
|
|
338
|
-
border-color: #000
|
|
339
|
-
border-style: none
|
|
340
|
-
border-width: 0pt
|
|
338
|
+
border-color: #000;
|
|
339
|
+
border-style: none;
|
|
340
|
+
border-width: 0pt;
|
|
341
341
|
position: relative;
|
|
342
342
|
grid-column: 1/-1;
|
|
343
343
|
}
|
package/styles/Editor.css
CHANGED
|
@@ -969,24 +969,23 @@
|
|
|
969
969
|
.table-footer > div {
|
|
970
970
|
position: relative;
|
|
971
971
|
}
|
|
972
|
-
|
|
972
|
+
.general-table-footnote, .table-footnotes-element div {
|
|
973
|
+
padding: 4px;
|
|
974
|
+
}
|
|
973
975
|
.general-table-footnote > p {
|
|
974
976
|
padding-bottom: 8px;
|
|
975
977
|
}
|
|
976
978
|
|
|
977
|
-
.general-table-footnote:has(> p.footnote-selected) > p:last-child {
|
|
978
|
-
padding-bottom: 0;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
979
|
.ProseMirror .table-footnotes-element .footnote-selected,
|
|
982
980
|
.ProseMirror .block-footnotes_element .footnote-selected,
|
|
983
|
-
.ProseMirror .general-table-footnote
|
|
981
|
+
.ProseMirror .general-table-footnote.footnote-selected
|
|
984
982
|
{
|
|
985
983
|
background-color: #f2fbfc;
|
|
986
|
-
padding: 4px;
|
|
987
984
|
border: 1px solid #bce7f6;
|
|
988
985
|
}
|
|
989
|
-
|
|
986
|
+
.ProseMirror .table-footer .inserted.pending {
|
|
987
|
+
margin-bottom: 5px;
|
|
988
|
+
}
|
|
990
989
|
.ProseMirror .footnote-label {
|
|
991
990
|
vertical-align: super;
|
|
992
991
|
font-size: 75%;
|
|
@@ -1002,7 +1001,7 @@
|
|
|
1002
1001
|
display: flex;
|
|
1003
1002
|
position: absolute;
|
|
1004
1003
|
margin-right: 4px;
|
|
1005
|
-
top:
|
|
1004
|
+
top: 15%;
|
|
1006
1005
|
right: 100%;
|
|
1007
1006
|
}
|
|
1008
1007
|
|
|
@@ -1028,4 +1027,4 @@
|
|
|
1028
1027
|
}
|
|
1029
1028
|
.highlight {
|
|
1030
1029
|
background-color: #ffeebf !important;
|
|
1031
|
-
}
|
|
1030
|
+
}
|