@manuscripts/body-editor 2.7.32 → 2.7.33
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/components/views/FigureDropdown.js +12 -45
- package/dist/cjs/configs/editor-plugins.js +2 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/lib/context-menu.js +71 -4
- package/dist/cjs/lib/view.js +3 -1
- package/dist/cjs/plugins/inspector-tabs.js +84 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/ReactSubView.js +4 -4
- package/dist/cjs/views/affiliations.js +1 -1
- package/dist/cjs/views/award.js +3 -3
- package/dist/cjs/views/bibliography_element.js +2 -2
- package/dist/cjs/views/citation_editable.js +3 -3
- package/dist/cjs/views/contributors.js +2 -2
- package/dist/cjs/views/cross_reference_editable.js +1 -1
- package/dist/cjs/views/embed.js +1 -1
- package/dist/cjs/views/figure_editable.js +99 -9
- package/dist/cjs/views/figure_element.js +0 -79
- package/dist/cjs/views/inline_footnote.js +2 -2
- package/dist/cjs/views/keyword.js +1 -1
- package/dist/cjs/views/keyword_group.js +1 -1
- package/dist/cjs/views/link_editable.js +1 -1
- package/dist/cjs/views/table_cell.js +1 -1
- package/dist/es/components/views/FigureDropdown.js +12 -44
- package/dist/es/configs/editor-plugins.js +2 -0
- package/dist/es/index.js +1 -0
- package/dist/es/lib/context-menu.js +72 -5
- package/dist/es/lib/view.js +3 -1
- package/dist/es/plugins/inspector-tabs.js +81 -0
- package/dist/es/versions.js +1 -1
- package/dist/es/views/ReactSubView.js +4 -4
- package/dist/es/views/affiliations.js +1 -1
- package/dist/es/views/award.js +3 -3
- package/dist/es/views/bibliography_element.js +2 -2
- package/dist/es/views/citation_editable.js +3 -3
- package/dist/es/views/contributors.js +2 -2
- package/dist/es/views/cross_reference_editable.js +1 -1
- package/dist/es/views/embed.js +1 -1
- package/dist/es/views/figure_editable.js +99 -9
- package/dist/es/views/figure_element.js +0 -79
- package/dist/es/views/inline_footnote.js +2 -2
- package/dist/es/views/keyword.js +1 -1
- package/dist/es/views/keyword_group.js +1 -1
- package/dist/es/views/link_editable.js +1 -1
- package/dist/es/views/table_cell.js +1 -1
- package/dist/types/components/views/FigureDropdown.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/context-menu.d.ts +3 -0
- package/dist/types/plugins/inspector-tabs.d.ts +35 -0
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/ReactSubView.d.ts +1 -1
- package/dist/types/views/figure_editable.d.ts +9 -0
- package/dist/types/views/figure_element.d.ts +0 -3
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +17 -5
- package/styles/Editor.css +10 -1
- package/styles/popper.css +33 -11
|
@@ -3,50 +3,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.FigureOptions =
|
|
6
|
+
exports.FigureOptions = void 0;
|
|
7
7
|
const style_guide_1 = require("@manuscripts/style-guide");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
10
|
-
const
|
|
10
|
+
const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
|
|
11
11
|
const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
|
|
12
12
|
const supplements = files.supplements
|
|
13
13
|
.map((s) => s.file)
|
|
14
14
|
.filter((f) => (0, style_guide_1.isImageFile)(f.name));
|
|
15
|
-
const others = files.others.filter((f) => (0, style_guide_1.isImageFile)(f.name));
|
|
16
|
-
return (react_1.default.createElement(FilesDropdownWrapper, { onClick: toggleOpen, ref: wrapperRef },
|
|
17
|
-
react_1.default.createElement(FilesButton, { disabled: hasUploadedImage },
|
|
18
|
-
react_1.default.createElement(style_guide_1.AttachIcon, null)),
|
|
19
|
-
isOpen && (react_1.default.createElement(style_guide_1.DropdownList, { direction: 'left', width: 208, height: 187, onClick: toggleOpen, top: 7 },
|
|
20
|
-
react_1.default.createElement(NestedDropdown, { disabled: !can.replaceFile || supplements.length < 1, parentToggleOpen: toggleOpen, buttonText: 'Supplements', list: react_1.default.createElement(react_1.default.Fragment, null, supplements.map((file) => (react_1.default.createElement(ListItemButton, { key: file.id, onClick: () => onAdd(file) },
|
|
21
|
-
(0, style_guide_1.getFileIcon)(file.name),
|
|
22
|
-
react_1.default.createElement(ListItemText, null, file.name))))) }),
|
|
23
|
-
react_1.default.createElement(NestedDropdown, { disabled: !can.replaceFile || others.length < 1, parentToggleOpen: toggleOpen, buttonText: 'Other files', list: react_1.default.createElement(react_1.default.Fragment, null, others.map((file) => (react_1.default.createElement(ListItemButton, { key: file.id, onClick: () => onAdd(file) },
|
|
24
|
-
(0, style_guide_1.getFileIcon)(file.name),
|
|
25
|
-
react_1.default.createElement(ListItemText, null, file.name))))) }),
|
|
26
|
-
react_1.default.createElement(UploadButton, { onClick: onUpload, disabled: !can.uploadFile },
|
|
27
|
-
react_1.default.createElement(style_guide_1.AddIcon, null),
|
|
28
|
-
" New file...")))));
|
|
29
|
-
};
|
|
30
|
-
exports.FigureElementOptions = FigureElementOptions;
|
|
31
|
-
const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
|
|
32
|
-
const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
|
|
33
15
|
const otherFiles = files.others.filter((f) => (0, style_guide_1.isImageFile)(f.name));
|
|
34
16
|
const showDownload = onDownload && can.downloadFiles;
|
|
35
17
|
const showUpload = onUpload && can.uploadFile;
|
|
36
18
|
const showDetach = onDetach && can.detachFile;
|
|
37
19
|
const showReplace = onReplace && can.replaceFile;
|
|
20
|
+
const replaceBtnText = onDownload ? 'Replace' : 'Choose file';
|
|
38
21
|
return (react_1.default.createElement(DropdownWrapper, { ref: wrapperRef },
|
|
39
22
|
react_1.default.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
|
|
40
23
|
react_1.default.createElement(style_guide_1.DotsIcon, null)),
|
|
41
24
|
isOpen && (react_1.default.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
|
|
42
|
-
react_1.default.createElement(
|
|
43
|
-
|
|
25
|
+
react_1.default.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: replaceBtnText, moveLeft: true, list: react_1.default.createElement(react_1.default.Fragment, null,
|
|
26
|
+
supplements.map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
|
|
27
|
+
(0, style_guide_1.getFileIcon)(file.name),
|
|
28
|
+
react_1.default.createElement(ListItemText, null, file.name)))),
|
|
44
29
|
otherFiles.map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
|
|
45
30
|
(0, style_guide_1.getFileIcon)(file.name),
|
|
46
31
|
react_1.default.createElement(ListItemText, null, file.name)))),
|
|
47
32
|
react_1.default.createElement(UploadButton, { onClick: onUpload, disabled: !showUpload },
|
|
48
33
|
react_1.default.createElement(style_guide_1.UploadIcon, null),
|
|
49
34
|
" Upload new...")) }),
|
|
35
|
+
react_1.default.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
|
|
50
36
|
react_1.default.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach")))));
|
|
51
37
|
};
|
|
52
38
|
exports.FigureOptions = FigureOptions;
|
|
@@ -54,8 +40,7 @@ const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft
|
|
|
54
40
|
const { isOpen, toggleOpen, wrapperRef } = (0, style_guide_1.useDropdown)();
|
|
55
41
|
return (react_1.default.createElement(DropdownWrapper, { ref: wrapperRef },
|
|
56
42
|
react_1.default.createElement(NestedListButton, { onClick: toggleOpen, disabled: disabled },
|
|
57
|
-
buttonText,
|
|
58
|
-
" ",
|
|
43
|
+
react_1.default.createElement("div", null, buttonText),
|
|
59
44
|
react_1.default.createElement(style_guide_1.TriangleCollapsedIcon, null)),
|
|
60
45
|
isOpen && (react_1.default.createElement(NestedListDropdownList, { direction: 'right', moveLeft: moveLeft, width: 192, onClick: (e) => {
|
|
61
46
|
toggleOpen();
|
|
@@ -75,9 +60,6 @@ const OptionsButton = (0, styled_components_1.default)(style_guide_1.IconButton)
|
|
|
75
60
|
margin: ${(props) => props.theme.grid.unit}px;
|
|
76
61
|
visibility: hidden;
|
|
77
62
|
background: white;
|
|
78
|
-
position: absolute;
|
|
79
|
-
top: -4px;
|
|
80
|
-
right: 4%;
|
|
81
63
|
|
|
82
64
|
&:hover {
|
|
83
65
|
background: #f2fbfc !important;
|
|
@@ -119,30 +101,15 @@ const ListItemText = styled_components_1.default.div `
|
|
|
119
101
|
text-overflow: ellipsis;
|
|
120
102
|
text-align: start;
|
|
121
103
|
`;
|
|
122
|
-
const FilesButton = (0, styled_components_1.default)(style_guide_1.RoundIconButton) `
|
|
123
|
-
path {
|
|
124
|
-
stroke: #6e6e6e;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
&:active,
|
|
128
|
-
&:focus {
|
|
129
|
-
path {
|
|
130
|
-
stroke: #1a9bc7;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
`;
|
|
134
|
-
const FilesDropdownWrapper = styled_components_1.default.div `
|
|
135
|
-
position: absolute;
|
|
136
|
-
top: 8px;
|
|
137
|
-
left: 70px;
|
|
138
|
-
z-index: 1;
|
|
139
|
-
`;
|
|
140
104
|
const NestedListButton = (0, styled_components_1.default)(ListItemButton) `
|
|
141
105
|
width: 100%;
|
|
142
106
|
&:active,
|
|
143
107
|
&:focus {
|
|
144
108
|
background: #f2fbfc;
|
|
145
109
|
}
|
|
110
|
+
svg {
|
|
111
|
+
margin-right: 0;
|
|
112
|
+
}
|
|
146
113
|
`;
|
|
147
114
|
const NestedListDropdownList = (0, styled_components_1.default)(style_guide_1.DropdownList) `
|
|
148
115
|
top: 0;
|
|
@@ -34,6 +34,7 @@ const doi_1 = __importDefault(require("../plugins/doi"));
|
|
|
34
34
|
const editor_props_1 = __importDefault(require("../plugins/editor-props"));
|
|
35
35
|
const elements_1 = __importDefault(require("../plugins/elements"));
|
|
36
36
|
const footnotes_1 = __importDefault(require("../plugins/footnotes"));
|
|
37
|
+
const inspector_tabs_1 = __importDefault(require("../plugins/inspector-tabs"));
|
|
37
38
|
const objects_1 = __importDefault(require("../plugins/objects"));
|
|
38
39
|
const paragraphs_1 = __importDefault(require("../plugins/paragraphs"));
|
|
39
40
|
const persist_1 = __importDefault(require("../plugins/persist"));
|
|
@@ -75,6 +76,7 @@ exports.default = (props) => {
|
|
|
75
76
|
(0, doi_1.default)(),
|
|
76
77
|
(0, section_category_1.default)(props),
|
|
77
78
|
(0, cross_references_1.default)(),
|
|
79
|
+
(0, inspector_tabs_1.default)(),
|
|
78
80
|
];
|
|
79
81
|
if (props.collabProvider) {
|
|
80
82
|
allPlugins.push((0, prosemirror_collab_1.collab)({ version: props.collabProvider.currentVersion }));
|
package/dist/cjs/index.js
CHANGED
|
@@ -68,3 +68,4 @@ Object.defineProperty(exports, "metadata", { enumerable: true, get: function ()
|
|
|
68
68
|
var authors_1 = require("./lib/authors");
|
|
69
69
|
Object.defineProperty(exports, "authorLabel", { enumerable: true, get: function () { return authors_1.authorLabel; } });
|
|
70
70
|
Object.defineProperty(exports, "affiliationLabel", { enumerable: true, get: function () { return authors_1.affiliationLabel; } });
|
|
71
|
+
__exportStar(require("./plugins/inspector-tabs"), exports);
|
|
@@ -16,11 +16,16 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.ContextMenu = exports.contextMenuBtnClass = exports.sectionLevel = void 0;
|
|
19
|
+
const style_guide_1 = require("@manuscripts/style-guide");
|
|
19
20
|
const transform_1 = require("@manuscripts/transform");
|
|
20
21
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
22
|
+
const react_1 = require("react");
|
|
23
|
+
const server_1 = require("react-dom/server");
|
|
21
24
|
const commands_1 = require("../commands");
|
|
25
|
+
const figure_editable_1 = require("../views/figure_editable");
|
|
22
26
|
const popper_1 = require("./popper");
|
|
23
27
|
const utils_1 = require("./utils");
|
|
28
|
+
const view_1 = require("./view");
|
|
24
29
|
const popper = new popper_1.PopperManager();
|
|
25
30
|
const readonlyTypes = [
|
|
26
31
|
transform_1.schema.nodes.keywords,
|
|
@@ -42,6 +47,7 @@ const hasAny = (set, ...items) => {
|
|
|
42
47
|
return items.some((i) => set.has(i));
|
|
43
48
|
};
|
|
44
49
|
exports.contextMenuBtnClass = 'btn-context-menu';
|
|
50
|
+
const contextSubmenuBtnClass = 'context-submenu-trigger';
|
|
45
51
|
class ContextMenu {
|
|
46
52
|
constructor(node, view, getPos) {
|
|
47
53
|
this.showAddMenu = (target, after) => {
|
|
@@ -150,6 +156,36 @@ class ContextMenu {
|
|
|
150
156
|
const $pos = this.resolvePos();
|
|
151
157
|
const isBox = isBoxElementSectionTitle($pos, this.node);
|
|
152
158
|
const type = isBox ? transform_1.schema.nodes.box_element : this.node.type;
|
|
159
|
+
if (type === transform_1.schema.nodes.figure_element ||
|
|
160
|
+
type === transform_1.schema.nodes.image_element) {
|
|
161
|
+
const figure = (0, utils_1.getMatchingChild)(this.node, (node) => node.type === transform_1.schema.nodes.figure);
|
|
162
|
+
if (figure) {
|
|
163
|
+
const attrType = figure.attrs.type;
|
|
164
|
+
const submenuOptions = [
|
|
165
|
+
{
|
|
166
|
+
title: 'Left',
|
|
167
|
+
action: () => (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.figure, Object.assign(Object.assign({}, figure.attrs), { type: figure_editable_1.figurePositions.left })),
|
|
168
|
+
Icon: style_guide_1.ImageLeftIcon,
|
|
169
|
+
selected: attrType === figure_editable_1.figurePositions.left,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
title: 'Default',
|
|
173
|
+
action: () => (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.figure, Object.assign(Object.assign({}, figure.attrs), { type: figure_editable_1.figurePositions.default })),
|
|
174
|
+
Icon: style_guide_1.ImageDefaultIcon,
|
|
175
|
+
selected: !attrType,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
title: 'Right',
|
|
179
|
+
action: () => (0, view_1.updateNodeAttrs)(this.view, transform_1.schema.nodes.figure, Object.assign(Object.assign({}, figure.attrs), { type: figure_editable_1.figurePositions.right })),
|
|
180
|
+
Icon: style_guide_1.ImageRightIcon,
|
|
181
|
+
selected: attrType === figure_editable_1.figurePositions.right,
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
const submenuLabel = 'Position';
|
|
185
|
+
const submenu = this.createSubmenu(submenuLabel, submenuOptions);
|
|
186
|
+
menu.appendChild(submenu);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
153
189
|
if (type === transform_1.schema.nodes.list) {
|
|
154
190
|
menu.appendChild(this.createMenuSection((section) => {
|
|
155
191
|
const attrs = this.node.attrs;
|
|
@@ -213,22 +249,48 @@ class ContextMenu {
|
|
|
213
249
|
popper.show(target, menu, 'right', true);
|
|
214
250
|
this.addPopperEventListeners();
|
|
215
251
|
};
|
|
216
|
-
this.
|
|
252
|
+
this.createSubmenuTrigger = (contents) => {
|
|
253
|
+
const item = document.createElement('div');
|
|
254
|
+
item.className = 'menu-item';
|
|
255
|
+
const textNode = document.createTextNode(contents);
|
|
256
|
+
item.innerHTML = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(style_guide_1.TriangleCollapsedIcon));
|
|
257
|
+
item.prepend(textNode);
|
|
258
|
+
item.classList.add(contextSubmenuBtnClass);
|
|
259
|
+
item.addEventListener('mousedown', this.toggleSubmenu);
|
|
260
|
+
return item;
|
|
261
|
+
};
|
|
262
|
+
this.createMenuItem = (contents, handler, Icon = null, selected = false) => {
|
|
217
263
|
const item = document.createElement('div');
|
|
218
264
|
item.className = 'menu-item';
|
|
219
|
-
item.
|
|
265
|
+
selected && item.classList.add('selected');
|
|
266
|
+
if (Icon) {
|
|
267
|
+
item.innerHTML = (0, server_1.renderToStaticMarkup)((0, react_1.createElement)(Icon));
|
|
268
|
+
}
|
|
269
|
+
const textNode = document.createTextNode(contents);
|
|
270
|
+
item.appendChild(textNode);
|
|
220
271
|
item.addEventListener('mousedown', (event) => {
|
|
221
272
|
event.preventDefault();
|
|
222
273
|
handler(event);
|
|
223
274
|
});
|
|
224
275
|
return item;
|
|
225
276
|
};
|
|
226
|
-
this.createMenuSection = (createMenuItems) => {
|
|
277
|
+
this.createMenuSection = (createMenuItems, isSubmenu = false) => {
|
|
227
278
|
const section = document.createElement('div');
|
|
228
279
|
section.className = 'menu-section';
|
|
280
|
+
isSubmenu && section.classList.add('menu');
|
|
229
281
|
createMenuItems(section);
|
|
230
282
|
return section;
|
|
231
283
|
};
|
|
284
|
+
this.createSubmenu = (submenuLabel, items) => {
|
|
285
|
+
const submenu = document.createElement('div');
|
|
286
|
+
submenu.classList.add('menu-section', 'context-submenu');
|
|
287
|
+
submenu.append(this.createSubmenuTrigger(submenuLabel), this.createMenuSection((section) => {
|
|
288
|
+
items.forEach(({ title, action, Icon, selected }) => {
|
|
289
|
+
section.appendChild(this.createMenuItem(title, action, Icon, selected));
|
|
290
|
+
});
|
|
291
|
+
}, true));
|
|
292
|
+
return submenu;
|
|
293
|
+
};
|
|
232
294
|
this.insertableTypes = (after, insertPos, endPos) => {
|
|
233
295
|
const { nodes } = transform_1.schema;
|
|
234
296
|
const insertable = new Set();
|
|
@@ -290,7 +352,8 @@ class ContextMenu {
|
|
|
290
352
|
this.addPopperEventListeners = () => {
|
|
291
353
|
const mouseListener = (event) => {
|
|
292
354
|
const target = event.target;
|
|
293
|
-
if (target.classList.contains(exports.contextMenuBtnClass)
|
|
355
|
+
if (target.classList.contains(exports.contextMenuBtnClass) ||
|
|
356
|
+
target.classList.contains(contextSubmenuBtnClass)) {
|
|
294
357
|
return;
|
|
295
358
|
}
|
|
296
359
|
window.requestAnimationFrame(() => {
|
|
@@ -322,6 +385,10 @@ class ContextMenu {
|
|
|
322
385
|
}
|
|
323
386
|
return this.node;
|
|
324
387
|
};
|
|
388
|
+
this.toggleSubmenu = (ev) => {
|
|
389
|
+
const submenu = ev.target.nextElementSibling;
|
|
390
|
+
submenu === null || submenu === void 0 ? void 0 : submenu.classList.toggle('show');
|
|
391
|
+
};
|
|
325
392
|
this.node = node;
|
|
326
393
|
this.view = view;
|
|
327
394
|
this.getPos = getPos;
|
package/dist/cjs/lib/view.js
CHANGED
|
@@ -40,6 +40,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.deleteNode = exports.updateNodeAttrs = exports.findChildrenAttrsByType = exports.findChildrenByType = exports.findChildByType = exports.findChildByID = void 0;
|
|
42
42
|
const transform_1 = require("@manuscripts/transform");
|
|
43
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
43
44
|
const utils = __importStar(require("prosemirror-utils"));
|
|
44
45
|
const track_changes_utils_1 = require("./track-changes-utils");
|
|
45
46
|
const metaNodeTypes = [
|
|
@@ -74,7 +75,8 @@ const updateNodeAttrs = (view, type, attrs) => {
|
|
|
74
75
|
const copy = (0, track_changes_utils_1.sanitizeAttrsChange)(attrs, child.node.attrs);
|
|
75
76
|
delete copy.dataTracked;
|
|
76
77
|
const pos = child.pos;
|
|
77
|
-
const tr = view.state.tr
|
|
78
|
+
const tr = view.state.tr;
|
|
79
|
+
tr.setNodeMarkup(pos, undefined, copy).setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
|
|
78
80
|
if (metaNodeTypes.includes(type)) {
|
|
79
81
|
tr.setMeta(updateMetaNode, true);
|
|
80
82
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2025 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.InspectorSecondaryTabsFiles = exports.InspectorPrimaryTabs = exports.inspectorTabsKey = void 0;
|
|
19
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
20
|
+
exports.inspectorTabsKey = new prosemirror_state_1.PluginKey('inspector_tabs');
|
|
21
|
+
var InspectorPrimaryTabs;
|
|
22
|
+
(function (InspectorPrimaryTabs) {
|
|
23
|
+
InspectorPrimaryTabs[InspectorPrimaryTabs["Comments"] = 0] = "Comments";
|
|
24
|
+
InspectorPrimaryTabs[InspectorPrimaryTabs["History"] = 1] = "History";
|
|
25
|
+
InspectorPrimaryTabs[InspectorPrimaryTabs["Files"] = 2] = "Files";
|
|
26
|
+
})(InspectorPrimaryTabs = exports.InspectorPrimaryTabs || (exports.InspectorPrimaryTabs = {}));
|
|
27
|
+
var InspectorSecondaryTabsFiles;
|
|
28
|
+
(function (InspectorSecondaryTabsFiles) {
|
|
29
|
+
InspectorSecondaryTabsFiles[InspectorSecondaryTabsFiles["SupplementsFiles"] = 1] = "SupplementsFiles";
|
|
30
|
+
InspectorSecondaryTabsFiles[InspectorSecondaryTabsFiles["OtherFiles"] = 2] = "OtherFiles";
|
|
31
|
+
})(InspectorSecondaryTabsFiles = exports.InspectorSecondaryTabsFiles || (exports.InspectorSecondaryTabsFiles = {}));
|
|
32
|
+
exports.default = () => {
|
|
33
|
+
return new prosemirror_state_1.Plugin({
|
|
34
|
+
key: exports.inspectorTabsKey,
|
|
35
|
+
state: {
|
|
36
|
+
init: () => ({
|
|
37
|
+
inspectorOpenTabs: {
|
|
38
|
+
primaryTab: null,
|
|
39
|
+
secondaryTab: null,
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
apply: (tr, value) => {
|
|
43
|
+
const meta = tr.getMeta(exports.inspectorTabsKey);
|
|
44
|
+
if (meta && meta.inspectorOpenTabs !== undefined) {
|
|
45
|
+
return Object.assign(Object.assign({}, value), { inspectorOpenTabs: meta.inspectorOpenTabs });
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
props: {
|
|
51
|
+
handleClick: (view, pos, event) => {
|
|
52
|
+
const target = event.target;
|
|
53
|
+
const inspectorOpenTabs = {
|
|
54
|
+
primaryTab: null,
|
|
55
|
+
secondaryTab: null,
|
|
56
|
+
};
|
|
57
|
+
switch (target.dataset.action) {
|
|
58
|
+
case 'open-other-files':
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
inspectorOpenTabs.primaryTab = InspectorPrimaryTabs.Files;
|
|
61
|
+
inspectorOpenTabs.secondaryTab =
|
|
62
|
+
InspectorSecondaryTabsFiles.OtherFiles;
|
|
63
|
+
break;
|
|
64
|
+
case 'open-supplement-files':
|
|
65
|
+
event.stopPropagation();
|
|
66
|
+
inspectorOpenTabs.primaryTab = InspectorPrimaryTabs.Files;
|
|
67
|
+
inspectorOpenTabs.secondaryTab =
|
|
68
|
+
InspectorSecondaryTabsFiles.SupplementsFiles;
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
if (inspectorOpenTabs.primaryTab != null ||
|
|
74
|
+
inspectorOpenTabs.secondaryTab != null) {
|
|
75
|
+
const tr = view.state.tr.setMeta(exports.inspectorTabsKey, {
|
|
76
|
+
inspectorOpenTabs,
|
|
77
|
+
});
|
|
78
|
+
view.dispatch(tr);
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
};
|
package/dist/cjs/versions.js
CHANGED
|
@@ -21,12 +21,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
21
21
|
const react_1 = __importDefault(require("react"));
|
|
22
22
|
const client_1 = require("react-dom/client");
|
|
23
23
|
const styled_components_1 = require("styled-components");
|
|
24
|
-
function createSubView(props, Component, componentProps, node, getPos, view, classNames =
|
|
24
|
+
function createSubView(props, Component, componentProps, node, getPos, view, classNames = []) {
|
|
25
25
|
const container = document.createElement('div');
|
|
26
26
|
container.classList.add('tools-panel');
|
|
27
|
-
if (classNames) {
|
|
28
|
-
container.classList.add(classNames);
|
|
29
|
-
container.setAttribute('data-cy', classNames);
|
|
27
|
+
if (classNames.length) {
|
|
28
|
+
container.classList.add(...classNames);
|
|
29
|
+
container.setAttribute('data-cy', classNames[0]);
|
|
30
30
|
}
|
|
31
31
|
container.setAttribute('contenteditable', 'false');
|
|
32
32
|
const Wrapped = () => {
|
|
@@ -104,7 +104,7 @@ class AffiliationsView extends block_view_1.default {
|
|
|
104
104
|
action: () => this.handleEdit(),
|
|
105
105
|
icon: 'Edit',
|
|
106
106
|
});
|
|
107
|
-
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
107
|
+
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
|
|
108
108
|
return this.contextMenu;
|
|
109
109
|
}
|
|
110
110
|
return undefined;
|
package/dist/cjs/views/award.js
CHANGED
|
@@ -80,7 +80,7 @@ class AwardView extends block_view_1.default {
|
|
|
80
80
|
},
|
|
81
81
|
],
|
|
82
82
|
};
|
|
83
|
-
this.props.popper.show(this.contentDOM, (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu'), 'right-start', false);
|
|
83
|
+
this.props.popper.show(this.contentDOM, (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']), 'right-start', false);
|
|
84
84
|
};
|
|
85
85
|
this.showAwardModal = (award) => {
|
|
86
86
|
var _a, _b;
|
|
@@ -91,7 +91,7 @@ class AwardView extends block_view_1.default {
|
|
|
91
91
|
onSaveAward: this.handleSaveAward,
|
|
92
92
|
onCancelAward: this.handleCancelAward,
|
|
93
93
|
};
|
|
94
|
-
this.popperContainer = (0, ReactSubView_1.default)(this.props, AwardModal_1.AwardModal, componentProps, this.node, this.getPos, this.view, 'award-editor');
|
|
94
|
+
this.popperContainer = (0, ReactSubView_1.default)(this.props, AwardModal_1.AwardModal, componentProps, this.node, this.getPos, this.view, ['award-editor']);
|
|
95
95
|
this.props.popper.show(this.dom, this.popperContainer, 'auto', false);
|
|
96
96
|
};
|
|
97
97
|
this.showDeleteAwardDialog = () => {
|
|
@@ -100,7 +100,7 @@ class AwardView extends block_view_1.default {
|
|
|
100
100
|
const componentProps = {
|
|
101
101
|
handleDelete: this.handleDeleteAward,
|
|
102
102
|
};
|
|
103
|
-
this.popperContainer = (0, ReactSubView_1.default)(this.props, DeleteAwardDiaolog_1.DeleteAwardDialog, componentProps, this.node, this.getPos, this.view, 'award-editor');
|
|
103
|
+
this.popperContainer = (0, ReactSubView_1.default)(this.props, DeleteAwardDiaolog_1.DeleteAwardDialog, componentProps, this.node, this.getPos, this.view, ['award-editor']);
|
|
104
104
|
this.props.popper.show(this.dom, this.popperContainer, 'auto', false);
|
|
105
105
|
};
|
|
106
106
|
this.handleSaveAward = (award) => {
|
|
@@ -125,7 +125,7 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
125
125
|
onSave: this.handleSave,
|
|
126
126
|
onDelete: this.handleDelete,
|
|
127
127
|
};
|
|
128
|
-
this.editor = (0, ReactSubView_1.default)(this.props, ReferencesEditor_1.ReferencesEditor, componentProps, this.node, this.getPos, this.view, 'references-editor');
|
|
128
|
+
this.editor = (0, ReactSubView_1.default)(this.props, ReferencesEditor_1.ReferencesEditor, componentProps, this.node, this.getPos, this.view, ['references-editor']);
|
|
129
129
|
this.props.popper.show(this.dom, this.editor, 'right');
|
|
130
130
|
}
|
|
131
131
|
handleEdit(citationID) {
|
|
@@ -151,7 +151,7 @@ class BibliographyElementBlockView extends block_view_1.default {
|
|
|
151
151
|
action: () => (0, comments_1.handleComment)(item, this.view),
|
|
152
152
|
icon: 'AddComment',
|
|
153
153
|
});
|
|
154
|
-
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
154
|
+
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
|
|
155
155
|
this.props.popper.show(element, this.contextMenu, 'right-start');
|
|
156
156
|
}
|
|
157
157
|
updateContents() {
|
|
@@ -93,7 +93,7 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
93
93
|
const componentProps = {
|
|
94
94
|
actions,
|
|
95
95
|
};
|
|
96
|
-
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
96
|
+
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
|
|
97
97
|
this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
|
|
98
98
|
};
|
|
99
99
|
this.showPopper = () => {
|
|
@@ -121,14 +121,14 @@ class CitationEditableView extends citation_1.CitationView {
|
|
|
121
121
|
onCancel: this.handleCancel,
|
|
122
122
|
canEdit: can.editCitationsAndRefs,
|
|
123
123
|
};
|
|
124
|
-
this.editor = (0, ReactSubView_1.default)(this.props, CitationEditor_1.CitationEditor, componentProps, this.node, this.getPos, this.view, 'citation-editor');
|
|
124
|
+
this.editor = (0, ReactSubView_1.default)(this.props, CitationEditor_1.CitationEditor, componentProps, this.node, this.getPos, this.view, ['citation-editor']);
|
|
125
125
|
}
|
|
126
126
|
else {
|
|
127
127
|
const componentProps = {
|
|
128
128
|
rids,
|
|
129
129
|
items,
|
|
130
130
|
};
|
|
131
|
-
this.editor = (0, ReactSubView_1.default)(this.props, CitationViewer_1.CitationViewer, componentProps, this.node, this.getPos, this.view, 'citation-editor');
|
|
131
|
+
this.editor = (0, ReactSubView_1.default)(this.props, CitationViewer_1.CitationViewer, componentProps, this.node, this.getPos, this.view, ['citation-editor']);
|
|
132
132
|
}
|
|
133
133
|
this.props.popper.show(this.dom, this.editor, 'auto');
|
|
134
134
|
};
|
|
@@ -138,7 +138,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
138
138
|
action: () => this.handleEdit(''),
|
|
139
139
|
icon: 'Edit',
|
|
140
140
|
});
|
|
141
|
-
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
141
|
+
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
|
|
142
142
|
return this.contextMenu;
|
|
143
143
|
}
|
|
144
144
|
return undefined;
|
|
@@ -202,7 +202,7 @@ class ContributorsView extends block_view_1.default {
|
|
|
202
202
|
},
|
|
203
203
|
],
|
|
204
204
|
};
|
|
205
|
-
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
|
|
205
|
+
this.contextMenu = (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
|
|
206
206
|
this.props.popper.show(element, this.contextMenu, 'right-start');
|
|
207
207
|
};
|
|
208
208
|
this.handleEdit = (id, addNew) => {
|
|
@@ -52,7 +52,7 @@ class CrossReferenceEditableView extends cross_reference_1.CrossReferenceView {
|
|
|
52
52
|
currentTargetId: rids[0],
|
|
53
53
|
currentCustomLabel: this.node.attrs.label,
|
|
54
54
|
};
|
|
55
|
-
this.popperContainer = (0, ReactSubView_1.default)(this.props, CrossReferenceItems_1.CrossReferenceItems, componentProps, this.node, this.getPos, this.view, 'cross-reference-editor');
|
|
55
|
+
this.popperContainer = (0, ReactSubView_1.default)(this.props, CrossReferenceItems_1.CrossReferenceItems, componentProps, this.node, this.getPos, this.view, ['cross-reference-editor']);
|
|
56
56
|
this.props.popper.show(this.dom, this.popperContainer, 'auto');
|
|
57
57
|
};
|
|
58
58
|
this.destroy = () => {
|
package/dist/cjs/views/embed.js
CHANGED
|
@@ -74,7 +74,7 @@ class EmbedMediaView extends block_view_1.default {
|
|
|
74
74
|
},
|
|
75
75
|
],
|
|
76
76
|
};
|
|
77
|
-
preview.appendChild((0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'embed-context-menu'));
|
|
77
|
+
preview.appendChild((0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['embed-context-menu']));
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
updateContents() {
|