@manuscripts/body-editor 1.7.30 → 1.7.31-LEAN-3321-0
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 +47 -1
- package/dist/cjs/components/views/DeleteFootnoteDialog.js +45 -0
- package/dist/cjs/configs/editor-plugins.js +1 -1
- package/dist/cjs/lib/context-menu.js +10 -2
- package/dist/cjs/plugins/footnotes/index.js +65 -1
- package/dist/es/assets.js +46 -0
- package/dist/es/components/views/DeleteFootnoteDialog.js +18 -0
- package/dist/es/configs/editor-plugins.js +1 -1
- package/dist/es/lib/context-menu.js +10 -2
- package/dist/es/plugins/footnotes/index.js +64 -3
- package/dist/types/assets.d.ts +1 -0
- package/dist/types/components/views/DeleteFootnoteDialog.d.ts +7 -0
- package/dist/types/configs/editor-plugins.d.ts +1 -1
- package/dist/types/plugins/footnotes/index.d.ts +2 -1
- package/package.json +4 -4
- package/styles/AdvancedEditor.css +3 -1
- package/styles/Editor.css +29 -3
package/dist/cjs/assets.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
|
|
18
|
+
exports.deleteIcon = exports.alertIcon = exports.editAttrsTrackingIcon = exports.commentIcon = exports.editIcon = void 0;
|
|
19
19
|
exports.editIcon = `
|
|
20
20
|
<svg
|
|
21
21
|
width="14"
|
|
@@ -118,3 +118,49 @@ exports.alertIcon = `
|
|
|
118
118
|
/>
|
|
119
119
|
</svg>
|
|
120
120
|
`;
|
|
121
|
+
exports.deleteIcon = `
|
|
122
|
+
<svg
|
|
123
|
+
width="13"
|
|
124
|
+
height="15"
|
|
125
|
+
viewBox="0 0 13 15"
|
|
126
|
+
fill="none"
|
|
127
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
128
|
+
>
|
|
129
|
+
<path
|
|
130
|
+
fill-rule="evenodd"
|
|
131
|
+
clip-rule="evenodd"
|
|
132
|
+
d="M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z"
|
|
133
|
+
fill="#C9C9C9"
|
|
134
|
+
/>
|
|
135
|
+
<path
|
|
136
|
+
fill-rule="evenodd"
|
|
137
|
+
clip-rule="evenodd"
|
|
138
|
+
d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z"
|
|
139
|
+
fill="#C9C9C9"
|
|
140
|
+
/>
|
|
141
|
+
<rect
|
|
142
|
+
y="2"
|
|
143
|
+
width="13"
|
|
144
|
+
height="3"
|
|
145
|
+
rx="1.5"
|
|
146
|
+
fill="#C9C9C9"
|
|
147
|
+
/>
|
|
148
|
+
<path
|
|
149
|
+
fill-rule="evenodd"
|
|
150
|
+
clip-rule="evenodd"
|
|
151
|
+
d="M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z"
|
|
152
|
+
fill="#C9C9C9"
|
|
153
|
+
/>
|
|
154
|
+
<path
|
|
155
|
+
fill-rule="evenodd"
|
|
156
|
+
clip-rule="evenodd"
|
|
157
|
+
d="M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z"
|
|
158
|
+
fill="#C9C9C9"
|
|
159
|
+
/>
|
|
160
|
+
<path
|
|
161
|
+
fill-rule="evenodd"
|
|
162
|
+
clip-rule="evenodd"
|
|
163
|
+
d="M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z"
|
|
164
|
+
fill="white"
|
|
165
|
+
/>
|
|
166
|
+
</svg>`;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DeleteFootnoteDialog = void 0;
|
|
27
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const DeleteFootnoteDialog = ({ footnoteType, footnoteMessage, handleDelete, }) => {
|
|
30
|
+
const [isOpen, setOpen] = (0, react_1.useState)(true);
|
|
31
|
+
return (react_1.default.createElement(style_guide_1.Dialog, { className: "delete-footnote-dialog", isOpen: isOpen, actions: {
|
|
32
|
+
primary: {
|
|
33
|
+
action: () => {
|
|
34
|
+
setOpen(false);
|
|
35
|
+
handleDelete();
|
|
36
|
+
},
|
|
37
|
+
title: 'Delete',
|
|
38
|
+
},
|
|
39
|
+
secondary: {
|
|
40
|
+
action: () => setOpen(false),
|
|
41
|
+
title: 'Cancel',
|
|
42
|
+
},
|
|
43
|
+
}, category: style_guide_1.Category.confirmation, header: `Delete ${footnoteType}`, message: `${footnoteMessage}` }));
|
|
44
|
+
};
|
|
45
|
+
exports.DeleteFootnoteDialog = DeleteFootnoteDialog;
|
|
@@ -69,7 +69,7 @@ exports.default = (props) => {
|
|
|
69
69
|
(0, prosemirror_tables_1.tableEditing)(),
|
|
70
70
|
(0, highlight_1.default)(props),
|
|
71
71
|
(0, selected_suggestion_ui_1.default)(props),
|
|
72
|
-
(0, footnotes_1.default)(),
|
|
72
|
+
(0, footnotes_1.default)(props),
|
|
73
73
|
(0, table_footnote_1.default)(),
|
|
74
74
|
];
|
|
75
75
|
if (props.collabProvider) {
|
|
@@ -142,7 +142,7 @@ class ContextMenu {
|
|
|
142
142
|
this.addPopperEventListeners();
|
|
143
143
|
};
|
|
144
144
|
this.showEditMenu = (target) => {
|
|
145
|
-
var _a;
|
|
145
|
+
var _a, _b;
|
|
146
146
|
const menu = document.createElement('div');
|
|
147
147
|
menu.className = 'menu';
|
|
148
148
|
const $pos = this.resolvePos();
|
|
@@ -176,9 +176,17 @@ class ContextMenu {
|
|
|
176
176
|
if (type === transform_1.schema.nodes.table_element) {
|
|
177
177
|
const isInTable = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table)(this.view.state.selection);
|
|
178
178
|
const tableElementFooter = (0, prosemirror_utils_1.findChildrenByType)(this.node, transform_1.schema.nodes.table_element_footer);
|
|
179
|
+
let isDeletedOrRejected = false;
|
|
179
180
|
const hasGeneralNote = tableElementFooter.length &&
|
|
180
181
|
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.paragraph;
|
|
181
|
-
if (
|
|
182
|
+
if (hasGeneralNote) {
|
|
183
|
+
const generalFootnote = (_b = tableElementFooter[0]) === null || _b === void 0 ? void 0 : _b.node.firstChild;
|
|
184
|
+
if (generalFootnote) {
|
|
185
|
+
isDeletedOrRejected =
|
|
186
|
+
(0, track_changes_utils_1.isDeleted)(generalFootnote) || (0, track_changes_utils_1.isRejectedInsert)(generalFootnote);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (!hasGeneralNote || isDeletedOrRejected) {
|
|
182
190
|
menu.appendChild(this.createMenuSection((section) => {
|
|
183
191
|
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
184
192
|
(0, commands_1.insertGeneralFootnote)(this.node, this.getPos(), this.view, tableElementFooter);
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
17
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
21
|
exports.uncitedFootnoteWidget = exports.buildPluginState = exports.footnotesKey = void 0;
|
|
19
22
|
const transform_1 = require("@manuscripts/transform");
|
|
@@ -22,7 +25,9 @@ const prosemirror_state_1 = require("prosemirror-state");
|
|
|
22
25
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
23
26
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
24
27
|
const assets_1 = require("../../assets");
|
|
28
|
+
const DeleteFootnoteDialog_1 = require("../../components/views/DeleteFootnoteDialog");
|
|
25
29
|
const utils_1 = require("../../lib/utils");
|
|
30
|
+
const ReactSubView_1 = __importDefault(require("../../views/ReactSubView"));
|
|
26
31
|
const placeholder_1 = require("../placeholder");
|
|
27
32
|
const footnotes_utils_1 = require("./footnotes-utils");
|
|
28
33
|
exports.footnotesKey = new prosemirror_state_1.PluginKey('footnotes');
|
|
@@ -68,7 +73,39 @@ const uncitedFootnoteWidget = () => () => {
|
|
|
68
73
|
return element;
|
|
69
74
|
};
|
|
70
75
|
exports.uncitedFootnoteWidget = uncitedFootnoteWidget;
|
|
71
|
-
|
|
76
|
+
const deleteFootnoteWidget = (node, props, footnoteType, footnoteMessage) => (view, getPos) => {
|
|
77
|
+
const deleteBtn = document.createElement('span');
|
|
78
|
+
deleteBtn.className = 'delete-icon';
|
|
79
|
+
deleteBtn.innerHTML = assets_1.deleteIcon;
|
|
80
|
+
deleteBtn.addEventListener('click', () => {
|
|
81
|
+
const handleDelete = () => {
|
|
82
|
+
const tr = view.state.tr;
|
|
83
|
+
const pos = getPos();
|
|
84
|
+
if (node.type === transform_1.schema.nodes.table_element_footer) {
|
|
85
|
+
if (!(0, utils_1.getChildOfType)(node, transform_1.schema.nodes.footnotes_element, true) &&
|
|
86
|
+
pos) {
|
|
87
|
+
tr.delete(pos - 1, pos + node.nodeSize);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
node.content.forEach((item) => {
|
|
91
|
+
if (item.type === transform_1.schema.nodes.paragraph && pos) {
|
|
92
|
+
tr.delete(pos - 1, pos + item.nodeSize + 1);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
view.dispatch(tr);
|
|
98
|
+
};
|
|
99
|
+
const componentProps = {
|
|
100
|
+
footnoteType: footnoteType,
|
|
101
|
+
footnoteMessage: footnoteMessage,
|
|
102
|
+
handleDelete: handleDelete,
|
|
103
|
+
};
|
|
104
|
+
(0, ReactSubView_1.default)(Object.assign(Object.assign({}, props), { dispatch: view.dispatch }), DeleteFootnoteDialog_1.DeleteFootnoteDialog, componentProps, node, () => getPos(), view);
|
|
105
|
+
});
|
|
106
|
+
return deleteBtn;
|
|
107
|
+
};
|
|
108
|
+
exports.default = (props) => {
|
|
72
109
|
return new prosemirror_state_1.Plugin({
|
|
73
110
|
key: exports.footnotesKey,
|
|
74
111
|
state: {
|
|
@@ -101,6 +138,7 @@ exports.default = () => {
|
|
|
101
138
|
decorations: (state) => {
|
|
102
139
|
const decorations = [];
|
|
103
140
|
const isInTableElementFooter = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table_element_footer)(state.selection);
|
|
141
|
+
const isInTableElement = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.table_element)(state.selection);
|
|
104
142
|
if (isInTableElementFooter) {
|
|
105
143
|
const parent = (0, utils_1.findParentNodeWithIdValue)(state.selection);
|
|
106
144
|
if (parent) {
|
|
@@ -111,6 +149,7 @@ exports.default = () => {
|
|
|
111
149
|
}
|
|
112
150
|
const { labels } = exports.footnotesKey.getState(state);
|
|
113
151
|
let tableInlineFootnoteIds = undefined;
|
|
152
|
+
const can = props.getCapabilities();
|
|
114
153
|
state.doc.descendants((node, pos, parent) => {
|
|
115
154
|
var _a;
|
|
116
155
|
if ((0, transform_1.isFootnoteNode)(node)) {
|
|
@@ -131,6 +170,31 @@ exports.default = () => {
|
|
|
131
170
|
decorations.push(prosemirror_view_1.Decoration.widget(pos + node.nodeSize - 1, (0, exports.uncitedFootnoteWidget)()));
|
|
132
171
|
}
|
|
133
172
|
}
|
|
173
|
+
if (can.editArticle) {
|
|
174
|
+
if (isInTableElement) {
|
|
175
|
+
const isGeneralFootnote = node.type === transform_1.schema.nodes.paragraph;
|
|
176
|
+
const footnote = (() => {
|
|
177
|
+
switch (node.type) {
|
|
178
|
+
case transform_1.schema.nodes.footnote:
|
|
179
|
+
return {
|
|
180
|
+
type: 'table footnote',
|
|
181
|
+
message: 'This action will entirely remove the table footnote from the list because it will no longer be used.',
|
|
182
|
+
};
|
|
183
|
+
default:
|
|
184
|
+
return {
|
|
185
|
+
type: 'table general note',
|
|
186
|
+
message: 'This action will entirely remove the table general note.',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
})();
|
|
190
|
+
if (isGeneralFootnote &&
|
|
191
|
+
(parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
|
|
192
|
+
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, deleteFootnoteWidget(parent, props, footnote.type, footnote.message), {
|
|
193
|
+
key: parent.attrs.id,
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
134
198
|
if (node.type === transform_1.schema.nodes.footnotes_element) {
|
|
135
199
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === transform_1.schema.nodes.table_element_footer) {
|
|
136
200
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
package/dist/es/assets.js
CHANGED
|
@@ -115,3 +115,49 @@ export const alertIcon = `
|
|
|
115
115
|
/>
|
|
116
116
|
</svg>
|
|
117
117
|
`;
|
|
118
|
+
export const deleteIcon = `
|
|
119
|
+
<svg
|
|
120
|
+
width="13"
|
|
121
|
+
height="15"
|
|
122
|
+
viewBox="0 0 13 15"
|
|
123
|
+
fill="none"
|
|
124
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
125
|
+
>
|
|
126
|
+
<path
|
|
127
|
+
fill-rule="evenodd"
|
|
128
|
+
clip-rule="evenodd"
|
|
129
|
+
d="M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z"
|
|
130
|
+
fill="#C9C9C9"
|
|
131
|
+
/>
|
|
132
|
+
<path
|
|
133
|
+
fill-rule="evenodd"
|
|
134
|
+
clip-rule="evenodd"
|
|
135
|
+
d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z"
|
|
136
|
+
fill="#C9C9C9"
|
|
137
|
+
/>
|
|
138
|
+
<rect
|
|
139
|
+
y="2"
|
|
140
|
+
width="13"
|
|
141
|
+
height="3"
|
|
142
|
+
rx="1.5"
|
|
143
|
+
fill="#C9C9C9"
|
|
144
|
+
/>
|
|
145
|
+
<path
|
|
146
|
+
fill-rule="evenodd"
|
|
147
|
+
clip-rule="evenodd"
|
|
148
|
+
d="M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z"
|
|
149
|
+
fill="#C9C9C9"
|
|
150
|
+
/>
|
|
151
|
+
<path
|
|
152
|
+
fill-rule="evenodd"
|
|
153
|
+
clip-rule="evenodd"
|
|
154
|
+
d="M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z"
|
|
155
|
+
fill="#C9C9C9"
|
|
156
|
+
/>
|
|
157
|
+
<path
|
|
158
|
+
fill-rule="evenodd"
|
|
159
|
+
clip-rule="evenodd"
|
|
160
|
+
d="M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z"
|
|
161
|
+
fill="white"
|
|
162
|
+
/>
|
|
163
|
+
</svg>`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Category, Dialog } from '@manuscripts/style-guide';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
export const DeleteFootnoteDialog = ({ footnoteType, footnoteMessage, handleDelete, }) => {
|
|
4
|
+
const [isOpen, setOpen] = useState(true);
|
|
5
|
+
return (React.createElement(Dialog, { className: "delete-footnote-dialog", isOpen: isOpen, actions: {
|
|
6
|
+
primary: {
|
|
7
|
+
action: () => {
|
|
8
|
+
setOpen(false);
|
|
9
|
+
handleDelete();
|
|
10
|
+
},
|
|
11
|
+
title: 'Delete',
|
|
12
|
+
},
|
|
13
|
+
secondary: {
|
|
14
|
+
action: () => setOpen(false),
|
|
15
|
+
title: 'Cancel',
|
|
16
|
+
},
|
|
17
|
+
}, category: Category.confirmation, header: `Delete ${footnoteType}`, message: `${footnoteMessage}` }));
|
|
18
|
+
};
|
|
@@ -135,7 +135,7 @@ export class ContextMenu {
|
|
|
135
135
|
this.addPopperEventListeners();
|
|
136
136
|
};
|
|
137
137
|
this.showEditMenu = (target) => {
|
|
138
|
-
var _a;
|
|
138
|
+
var _a, _b;
|
|
139
139
|
const menu = document.createElement('div');
|
|
140
140
|
menu.className = 'menu';
|
|
141
141
|
const $pos = this.resolvePos();
|
|
@@ -169,9 +169,17 @@ export class ContextMenu {
|
|
|
169
169
|
if (type === schema.nodes.table_element) {
|
|
170
170
|
const isInTable = hasParentNodeOfType(schema.nodes.table)(this.view.state.selection);
|
|
171
171
|
const tableElementFooter = findChildrenByType(this.node, schema.nodes.table_element_footer);
|
|
172
|
+
let isDeletedOrRejected = false;
|
|
172
173
|
const hasGeneralNote = tableElementFooter.length &&
|
|
173
174
|
((_a = tableElementFooter[0].node.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.paragraph;
|
|
174
|
-
if (
|
|
175
|
+
if (hasGeneralNote) {
|
|
176
|
+
const generalFootnote = (_b = tableElementFooter[0]) === null || _b === void 0 ? void 0 : _b.node.firstChild;
|
|
177
|
+
if (generalFootnote) {
|
|
178
|
+
isDeletedOrRejected =
|
|
179
|
+
isDeleted(generalFootnote) || isRejectedInsert(generalFootnote);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (!hasGeneralNote || isDeletedOrRejected) {
|
|
175
183
|
menu.appendChild(this.createMenuSection((section) => {
|
|
176
184
|
section.appendChild(this.createMenuItem('Add General Note', () => {
|
|
177
185
|
insertGeneralFootnote(this.node, this.getPos(), this.view, tableElementFooter);
|
|
@@ -18,8 +18,10 @@ import { isEqual } from 'lodash';
|
|
|
18
18
|
import { NodeSelection, Plugin, PluginKey } from 'prosemirror-state';
|
|
19
19
|
import { hasParentNodeOfType } from 'prosemirror-utils';
|
|
20
20
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
21
|
-
import { alertIcon } from '../../assets';
|
|
22
|
-
import {
|
|
21
|
+
import { alertIcon, deleteIcon } from '../../assets';
|
|
22
|
+
import { DeleteFootnoteDialog, } from '../../components/views/DeleteFootnoteDialog';
|
|
23
|
+
import { findParentNodeWithIdValue, getChildOfType } from '../../lib/utils';
|
|
24
|
+
import ReactSubView from '../../views/ReactSubView';
|
|
23
25
|
import { placeholderWidget } from '../placeholder';
|
|
24
26
|
import { findTableInlineFootnoteIds } from './footnotes-utils';
|
|
25
27
|
export const footnotesKey = new PluginKey('footnotes');
|
|
@@ -63,7 +65,39 @@ export const uncitedFootnoteWidget = () => () => {
|
|
|
63
65
|
element.innerHTML = alertIcon;
|
|
64
66
|
return element;
|
|
65
67
|
};
|
|
66
|
-
|
|
68
|
+
const deleteFootnoteWidget = (node, props, footnoteType, footnoteMessage) => (view, getPos) => {
|
|
69
|
+
const deleteBtn = document.createElement('span');
|
|
70
|
+
deleteBtn.className = 'delete-icon';
|
|
71
|
+
deleteBtn.innerHTML = deleteIcon;
|
|
72
|
+
deleteBtn.addEventListener('click', () => {
|
|
73
|
+
const handleDelete = () => {
|
|
74
|
+
const tr = view.state.tr;
|
|
75
|
+
const pos = getPos();
|
|
76
|
+
if (node.type === schema.nodes.table_element_footer) {
|
|
77
|
+
if (!getChildOfType(node, schema.nodes.footnotes_element, true) &&
|
|
78
|
+
pos) {
|
|
79
|
+
tr.delete(pos - 1, pos + node.nodeSize);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
node.content.forEach((item) => {
|
|
83
|
+
if (item.type === schema.nodes.paragraph && pos) {
|
|
84
|
+
tr.delete(pos - 1, pos + item.nodeSize + 1);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
view.dispatch(tr);
|
|
90
|
+
};
|
|
91
|
+
const componentProps = {
|
|
92
|
+
footnoteType: footnoteType,
|
|
93
|
+
footnoteMessage: footnoteMessage,
|
|
94
|
+
handleDelete: handleDelete,
|
|
95
|
+
};
|
|
96
|
+
ReactSubView(Object.assign(Object.assign({}, props), { dispatch: view.dispatch }), DeleteFootnoteDialog, componentProps, node, () => getPos(), view);
|
|
97
|
+
});
|
|
98
|
+
return deleteBtn;
|
|
99
|
+
};
|
|
100
|
+
export default (props) => {
|
|
67
101
|
return new Plugin({
|
|
68
102
|
key: footnotesKey,
|
|
69
103
|
state: {
|
|
@@ -96,6 +130,7 @@ export default () => {
|
|
|
96
130
|
decorations: (state) => {
|
|
97
131
|
const decorations = [];
|
|
98
132
|
const isInTableElementFooter = hasParentNodeOfType(schema.nodes.table_element_footer)(state.selection);
|
|
133
|
+
const isInTableElement = hasParentNodeOfType(schema.nodes.table_element)(state.selection);
|
|
99
134
|
if (isInTableElementFooter) {
|
|
100
135
|
const parent = findParentNodeWithIdValue(state.selection);
|
|
101
136
|
if (parent) {
|
|
@@ -106,6 +141,7 @@ export default () => {
|
|
|
106
141
|
}
|
|
107
142
|
const { labels } = footnotesKey.getState(state);
|
|
108
143
|
let tableInlineFootnoteIds = undefined;
|
|
144
|
+
const can = props.getCapabilities();
|
|
109
145
|
state.doc.descendants((node, pos, parent) => {
|
|
110
146
|
var _a;
|
|
111
147
|
if (isFootnoteNode(node)) {
|
|
@@ -126,6 +162,31 @@ export default () => {
|
|
|
126
162
|
decorations.push(Decoration.widget(pos + node.nodeSize - 1, uncitedFootnoteWidget()));
|
|
127
163
|
}
|
|
128
164
|
}
|
|
165
|
+
if (can.editArticle) {
|
|
166
|
+
if (isInTableElement) {
|
|
167
|
+
const isGeneralFootnote = node.type === schema.nodes.paragraph;
|
|
168
|
+
const footnote = (() => {
|
|
169
|
+
switch (node.type) {
|
|
170
|
+
case schema.nodes.footnote:
|
|
171
|
+
return {
|
|
172
|
+
type: 'table footnote',
|
|
173
|
+
message: 'This action will entirely remove the table footnote from the list because it will no longer be used.',
|
|
174
|
+
};
|
|
175
|
+
default:
|
|
176
|
+
return {
|
|
177
|
+
type: 'table general note',
|
|
178
|
+
message: 'This action will entirely remove the table general note.',
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
})();
|
|
182
|
+
if (isGeneralFootnote &&
|
|
183
|
+
(parent === null || parent === void 0 ? void 0 : parent.type) === schema.nodes.table_element_footer) {
|
|
184
|
+
decorations.push(Decoration.widget(pos + 1, deleteFootnoteWidget(parent, props, footnote.type, footnote.message), {
|
|
185
|
+
key: parent.attrs.id,
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
129
190
|
if (node.type === schema.nodes.footnotes_element) {
|
|
130
191
|
if ((parent === null || parent === void 0 ? void 0 : parent.type) === schema.nodes.table_element_footer) {
|
|
131
192
|
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
package/dist/types/assets.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export declare const editIcon = "\n <svg\n width=\"14\"\n height=\"14\"\n
|
|
|
17
17
|
export declare const commentIcon = "\n<svg\n width=\"20\"\n height=\"15\"\n viewBox=\"0 0 20 15\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M7.94841 4.18311C7.98238 3.9602 8 3.73191 8 3.49951C8 3.22073 7.97465 2.94787 7.92613 2.68311H13.5C14.8854 2.68311 16.25 3.6425 16.25 5.09977V9.02453L19.1086 12.9949C19.2731 13.2233 19.2958 13.5245 19.1675 13.775C19.0392 14.0255 18.7814 14.1831 18.5 14.1831H5.5C4.11463 14.1831 2.75 13.2237 2.75 11.7664V7.93729C2.9939 7.97821 3.24446 7.99951 3.5 7.99951C3.75553 7.99951 4.00609 7.97821 4.25 7.93729V11.7664C4.25 12.1508 4.67537 12.6831 5.5 12.6831H17.0358L14.8913 9.70467C14.7994 9.57703 14.75 9.42372 14.75 9.26644V5.09977C14.75 4.71538 14.3246 4.18311 13.5 4.18311H7.94841Z\"\n fill=\"#FFBD26\"\n />\n <path\n d=\"M11.5 6.99951H8.5\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M12 9.99951H7\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M3.5 1L3.5 6\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M6 3.5L1 3.5\"\n stroke=\"#FFBD26\"\n stroke-width=\"1.5\"\n stroke-miterlimit=\"10\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n";
|
|
18
18
|
export declare const editAttrsTrackingIcon = "\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M12 2L14 4L9 9L6 10L7 7L12 2Z\"\n stroke=\"#353535\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n 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\"\n stroke=\"#353535\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n";
|
|
19
19
|
export declare const alertIcon = "\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 12 12\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M6 12C2.68629 12 1.18852e-06 9.31371 1.47821e-06 6C1.7679e-06 2.68629 2.68629 1.39444e-07 6 4.29138e-07C9.31371 7.18831e-07 12 2.68629 12 6C12 9.31371 9.31371 12 6 12ZM6.74998 2.99996L6.75 6.37462C6.75 6.78819 6.41522 7.12243 6.00166 7.12334C5.58681 7.12426 5.25001 6.78821 5.25001 6.37335L5.25 3.00082C5.25 2.58629 5.58629 2.25037 6.00082 2.25083C6.4147 2.25128 6.74998 2.58607 6.74998 2.99996ZM6.75 8.99263C6.75 9.46884 6.47288 9.75 5.99853 9.75C5.52419 9.75 5.25 9.47179 5.25 8.99558C5.25 8.51937 5.52421 8.25 5.99855 8.25C6.47289 8.25 6.75 8.51642 6.75 8.99263Z\"\n fill=\"#FE8F1F\"\n />\n </svg>\n";
|
|
20
|
+
export declare const deleteIcon = "\n <svg \n width=\"13\" \n height=\"15\" \n viewBox=\"0 0 13 15\" \n fill=\"none\" \n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path \n fill-rule=\"evenodd\" \n clip-rule=\"evenodd\" \n d=\"M2.00001 3C2 3.00135 2 3.00269 2 3.00404V13.004C2 13.5563 2.44772 14.004 3 14.004H10C10.5523 14.004 11 13.5563 11 13.004V3.00404C11 3.00269 11 3.00135 11 3C11.5978 3.34581 12 3.99215 12 4.73244V13.004C12 14.1086 11.1046 15.004 10 15.004H3C1.89543 15.004 1 14.1086 1 13.004V4.73244C1 3.99215 1.4022 3.34581 2.00001 3Z\" \n fill=\"#C9C9C9\"\n />\n <path \n fill-rule=\"evenodd\" \n clip-rule=\"evenodd\" \n d=\"M4.5 0C3.67157 0 3 0.671573 3 1.5V3.5C3 4.32843 3.67157 5 4.5 5H8.5C9.32843 5 10 4.32843 10 3.5V1.5C10 0.671573 9.32843 0 8.5 0H4.5ZM9 1.5C9 1.22386 8.77614 1 8.5 1H4.5C4.22386 1 4 1.22386 4 1.5C4 1.77614 4.22386 2 4.5 2H8.5C8.77614 2 9 1.77614 9 1.5Z\" \n fill=\"#C9C9C9\"\n />\n <rect \n y=\"2\" \n width=\"13\" \n height=\"3\" \n rx=\"1.5\" \n fill=\"#C9C9C9\"\n />\n <path \n fill-rule=\"evenodd\" \n clip-rule=\"evenodd\" \n d=\"M8 7.5C8 7.22386 8.22386 7 8.5 7C8.77614 7 9 7.22386 9 7.5V11.5C9 11.7761 8.77614 12 8.5 12C8.22386 12 8 11.7761 8 11.5V7.5Z\" \n fill=\"#C9C9C9\"\n />\n <path \n fill-rule=\"evenodd\" \n clip-rule=\"evenodd\" \n d=\"M4 7.5C4 7.22386 4.22386 7 4.5 7C4.77614 7 5 7.22386 5 7.5V11.5C5 11.7761 4.77614 12 4.5 12C4.22386 12 4 11.7761 4 11.5V7.5Z\" \n fill=\"#C9C9C9\"\n />\n <path \n fill-rule=\"evenodd\" \n clip-rule=\"evenodd\" \n d=\"M11.5 3C11.7761 3 12 3.22386 12 3.5C12 3.77614 11.7761 4 11.5 4L1.5 4C1.22386 4 1 3.77614 1 3.5C1 3.22386 1.22386 3 1.5 3L11.5 3Z\" \n fill=\"white\"\n />\n</svg>";
|
|
@@ -22,7 +22,7 @@ import { Plugin } from 'prosemirror-state';
|
|
|
22
22
|
import { CollabProvider } from '../classes/collabProvider';
|
|
23
23
|
import { PopperManager } from '../lib/popper';
|
|
24
24
|
import { CSLProps } from './ManuscriptsEditor';
|
|
25
|
-
interface PluginProps {
|
|
25
|
+
export interface PluginProps {
|
|
26
26
|
getManuscript: () => Manuscript;
|
|
27
27
|
setComment: (comment?: CommentAnnotation) => void;
|
|
28
28
|
setSelectedComment: (id?: string) => void;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { InlineFootnoteNode, ManuscriptNode } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
18
|
+
import { PluginProps } from '../../configs/editor-plugins';
|
|
18
19
|
interface PluginState {
|
|
19
20
|
nodes: [InlineFootnoteNode, number][];
|
|
20
21
|
labels: Map<string, string>;
|
|
@@ -22,5 +23,5 @@ interface PluginState {
|
|
|
22
23
|
export declare const footnotesKey: PluginKey<PluginState>;
|
|
23
24
|
export declare const buildPluginState: (doc: ManuscriptNode) => PluginState;
|
|
24
25
|
export declare const uncitedFootnoteWidget: () => () => HTMLSpanElement;
|
|
25
|
-
declare const _default: () => Plugin<PluginState>;
|
|
26
|
+
declare const _default: (props: PluginProps) => Plugin<PluginState>;
|
|
26
27
|
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.7.
|
|
4
|
+
"version": "1.7.31-LEAN-3321-0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"@manuscripts/assets": "^0.6.4",
|
|
32
32
|
"@manuscripts/json-schema": "^2.2.7",
|
|
33
33
|
"@manuscripts/library": "^1.3.6",
|
|
34
|
-
"@manuscripts/style-guide": "1.8.4",
|
|
34
|
+
"@manuscripts/style-guide": "1.8.4-LEAN-3321-0",
|
|
35
35
|
"@manuscripts/track-changes-plugin": "1.7.8",
|
|
36
|
-
"@manuscripts/transform": "
|
|
36
|
+
"@manuscripts/transform": "2.1.10-LEAN-3321",
|
|
37
37
|
"astrocite-eutils": "^0.16.4",
|
|
38
38
|
"axios": "^1.6.7",
|
|
39
39
|
"mathjax-full": "^3.2.2",
|
|
@@ -112,4 +112,4 @@
|
|
|
112
112
|
"@types/react": "^17.0.2",
|
|
113
113
|
"prosemirror-tables": "^1.3.5"
|
|
114
114
|
}
|
|
115
|
-
}
|
|
115
|
+
}
|
|
@@ -723,12 +723,14 @@ Next levels are shifted 'up' by 1
|
|
|
723
723
|
background: var(--accepted-bg-color);
|
|
724
724
|
text-decoration: none;
|
|
725
725
|
}
|
|
726
|
-
|
|
726
|
+
.ProseMirror .deleted.pending::before,
|
|
727
727
|
.ProseMirror .deleted.pending {
|
|
728
728
|
background: var(--pending-bg-color);
|
|
729
729
|
color: var(--deleted-color);
|
|
730
730
|
text-decoration: line-through;
|
|
731
731
|
}
|
|
732
|
+
|
|
733
|
+
.ProseMirror .deleted.accepted::before,
|
|
732
734
|
.ProseMirror .deleted.accepted {
|
|
733
735
|
background: var(--accepted-bg-color);
|
|
734
736
|
color: var(--deleted-color);
|
package/styles/Editor.css
CHANGED
|
@@ -942,13 +942,12 @@
|
|
|
942
942
|
vertical-align: super;
|
|
943
943
|
font-size: 75%;
|
|
944
944
|
}
|
|
945
|
-
|
|
946
945
|
.ProseMirror .table-footer {
|
|
947
946
|
font-size: 14px;
|
|
948
947
|
padding-top: 8px;
|
|
949
948
|
}
|
|
950
949
|
|
|
951
|
-
.ProseMirror .table-footnotes-element:not(:first-child)::before {
|
|
950
|
+
.ProseMirror .table-footnotes-element:has(> div):not(:first-child)::before {
|
|
952
951
|
content: '';
|
|
953
952
|
border-bottom: 1px dashed #C9C9C9;
|
|
954
953
|
display: block;
|
|
@@ -958,6 +957,20 @@
|
|
|
958
957
|
.ProseMirror .table-footnotes-element {
|
|
959
958
|
counter-reset: table_footnote;
|
|
960
959
|
}
|
|
960
|
+
.table-footer .delete-icon {
|
|
961
|
+
display: none;
|
|
962
|
+
position: absolute;
|
|
963
|
+
right: -20px;
|
|
964
|
+
top: -13px;
|
|
965
|
+
cursor: pointer;
|
|
966
|
+
z-index: 1;
|
|
967
|
+
}
|
|
968
|
+
.table-footer .delete-icon:hover svg path {
|
|
969
|
+
fill: #353535;
|
|
970
|
+
}
|
|
971
|
+
.ProseMirror .table-footnotes-element > div {
|
|
972
|
+
position: relative;
|
|
973
|
+
}
|
|
961
974
|
|
|
962
975
|
.ProseMirror .table-footnotes-element > div:not(:has(.unctied-table-footnote)) p::before {
|
|
963
976
|
counter-increment: table_footnote;
|
|
@@ -979,9 +992,14 @@
|
|
|
979
992
|
background-color: #f2fbfc;
|
|
980
993
|
padding: 4px;
|
|
981
994
|
}
|
|
995
|
+
|
|
996
|
+
.ProseMirror .table-footer .footnote-selected .delete-icon ,.ProseMirror .table-footer .footnote-selected .deleted.rejected .delete-icon {
|
|
997
|
+
display: block;
|
|
998
|
+
}
|
|
982
999
|
.table-footer > div > p {
|
|
983
1000
|
padding-bottom: 10px;
|
|
984
1001
|
}
|
|
1002
|
+
|
|
985
1003
|
.ProseMirror .table-footnotes-element .footnote-selected {
|
|
986
1004
|
border: 1px solid #bce7f6;
|
|
987
1005
|
}
|
|
@@ -989,8 +1007,16 @@
|
|
|
989
1007
|
border-left: 1px solid #bce7f6;
|
|
990
1008
|
border-right: 1px solid #bce7f6;
|
|
991
1009
|
}
|
|
1010
|
+
.table-footer > div:has(> p.footnote-selected) > p:first-child .delete-icon {
|
|
1011
|
+
z-index: 2;
|
|
1012
|
+
display: block;
|
|
1013
|
+
}
|
|
992
1014
|
.table-footer > div:has(> p.footnote-selected) > p:first-child {
|
|
993
1015
|
border-top: 1px solid #bce7f6;
|
|
1016
|
+
position: relative;
|
|
1017
|
+
}
|
|
1018
|
+
.table-footer > div:has(> p.footnote-selected) > p:last-of-type {
|
|
1019
|
+
border-bottom: 1px solid #bce7f6;
|
|
994
1020
|
}
|
|
995
1021
|
.table-footer > div:has(> p.footnote-selected) > p:last-child {
|
|
996
1022
|
border-bottom: 1px solid #bce7f6;
|
|
@@ -1032,4 +1058,4 @@
|
|
|
1032
1058
|
}
|
|
1033
1059
|
.highlight {
|
|
1034
1060
|
background-color: #ffeebf !important;
|
|
1035
|
-
}
|
|
1061
|
+
}
|