@manuscripts/body-editor 2.7.32-LEAN-4096.0 → 2.7.32

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.
Files changed (58) hide show
  1. package/dist/cjs/commands.js +2 -2
  2. package/dist/cjs/components/views/FigureDropdown.js +45 -12
  3. package/dist/cjs/configs/editor-plugins.js +0 -2
  4. package/dist/cjs/index.js +0 -1
  5. package/dist/cjs/lib/context-menu.js +4 -71
  6. package/dist/cjs/lib/view.js +1 -3
  7. package/dist/cjs/versions.js +1 -1
  8. package/dist/cjs/views/ReactSubView.js +4 -4
  9. package/dist/cjs/views/affiliations.js +1 -1
  10. package/dist/cjs/views/award.js +3 -3
  11. package/dist/cjs/views/bibliography_element.js +2 -2
  12. package/dist/cjs/views/citation_editable.js +3 -3
  13. package/dist/cjs/views/contributors.js +2 -2
  14. package/dist/cjs/views/cross_reference_editable.js +1 -1
  15. package/dist/cjs/views/embed.js +1 -1
  16. package/dist/cjs/views/figure_editable.js +9 -99
  17. package/dist/cjs/views/figure_element.js +79 -0
  18. package/dist/cjs/views/inline_footnote.js +3 -6
  19. package/dist/cjs/views/keyword.js +1 -1
  20. package/dist/cjs/views/keyword_group.js +1 -1
  21. package/dist/cjs/views/link_editable.js +1 -1
  22. package/dist/cjs/views/table_cell.js +1 -1
  23. package/dist/es/commands.js +2 -2
  24. package/dist/es/components/views/FigureDropdown.js +44 -12
  25. package/dist/es/configs/editor-plugins.js +0 -2
  26. package/dist/es/index.js +0 -1
  27. package/dist/es/lib/context-menu.js +5 -72
  28. package/dist/es/lib/view.js +1 -3
  29. package/dist/es/versions.js +1 -1
  30. package/dist/es/views/ReactSubView.js +4 -4
  31. package/dist/es/views/affiliations.js +1 -1
  32. package/dist/es/views/award.js +3 -3
  33. package/dist/es/views/bibliography_element.js +2 -2
  34. package/dist/es/views/citation_editable.js +3 -3
  35. package/dist/es/views/contributors.js +2 -2
  36. package/dist/es/views/cross_reference_editable.js +1 -1
  37. package/dist/es/views/embed.js +1 -1
  38. package/dist/es/views/figure_editable.js +9 -99
  39. package/dist/es/views/figure_element.js +79 -0
  40. package/dist/es/views/inline_footnote.js +3 -6
  41. package/dist/es/views/keyword.js +1 -1
  42. package/dist/es/views/keyword_group.js +1 -1
  43. package/dist/es/views/link_editable.js +1 -1
  44. package/dist/es/views/table_cell.js +1 -1
  45. package/dist/types/components/views/FigureDropdown.d.ts +1 -0
  46. package/dist/types/index.d.ts +0 -1
  47. package/dist/types/lib/context-menu.d.ts +0 -3
  48. package/dist/types/versions.d.ts +1 -1
  49. package/dist/types/views/ReactSubView.d.ts +1 -1
  50. package/dist/types/views/figure_editable.d.ts +0 -9
  51. package/dist/types/views/figure_element.d.ts +3 -0
  52. package/package.json +2 -2
  53. package/styles/AdvancedEditor.css +5 -17
  54. package/styles/Editor.css +1 -10
  55. package/styles/popper.css +11 -33
  56. package/dist/cjs/plugins/inspector-tabs.js +0 -84
  57. package/dist/es/plugins/inspector-tabs.js +0 -81
  58. package/dist/types/plugins/inspector-tabs.d.ts +0 -35
@@ -14,13 +14,28 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
17
26
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
28
  };
20
29
  Object.defineProperty(exports, "__esModule", { value: true });
21
30
  exports.FigureElementView = void 0;
31
+ const transform_1 = require("@manuscripts/transform");
32
+ const FigureDropdown_1 = require("../components/views/FigureDropdown");
33
+ const files_1 = require("../lib/files");
34
+ const utils_1 = require("../lib/utils");
22
35
  const block_view_1 = __importDefault(require("./block_view"));
23
36
  const creators_1 = require("./creators");
37
+ const figure_uploader_1 = require("./figure_uploader");
38
+ const ReactSubView_1 = __importDefault(require("./ReactSubView"));
24
39
  class FigureElementView extends block_view_1.default {
25
40
  constructor() {
26
41
  super(...arguments);
@@ -35,6 +50,70 @@ class FigureElementView extends block_view_1.default {
35
50
  this.container.appendChild(this.contentDOM);
36
51
  };
37
52
  }
53
+ updateContents() {
54
+ var _a;
55
+ super.updateContents();
56
+ if (!this.contentDOM) {
57
+ throw new Error('No contentDOM');
58
+ }
59
+ const can = this.props.getCapabilities();
60
+ let handleUpload = () => {
61
+ };
62
+ const hasUploadedImage = !!(0, utils_1.getMatchingChild)(this.node, (node) => node.type === transform_1.schema.nodes.figure && node.attrs.src);
63
+ const handleAdd = (file) => __awaiter(this, void 0, void 0, function* () {
64
+ const { state: { tr, schema, selection }, dispatch, } = this.view;
65
+ const src = file.id;
66
+ const figure = (0, utils_1.getMatchingChild)(this.node, (node) => node.type === schema.nodes.figure);
67
+ if (figure === null || figure === void 0 ? void 0 : figure.attrs.src) {
68
+ const figure = schema.nodes.figure.createAndFill({
69
+ src,
70
+ }, []);
71
+ let position = 0;
72
+ this.node.forEach((node, pos) => {
73
+ if (node.type === schema.nodes.figure) {
74
+ position = pos + node.nodeSize;
75
+ }
76
+ });
77
+ dispatch(tr.insert(this.getPos() + position + 1, figure));
78
+ }
79
+ else if (figure) {
80
+ tr.setNodeMarkup(this.getPos() + 1, undefined, Object.assign(Object.assign({}, figure.attrs), { src })).setSelection(selection.map(tr.doc, tr.mapping));
81
+ dispatch(tr);
82
+ }
83
+ this.deleteSupplementNode(file);
84
+ });
85
+ if (can.uploadFile) {
86
+ const upload = (file) => __awaiter(this, void 0, void 0, function* () {
87
+ const result = yield this.props.fileManagement.upload(file);
88
+ yield handleAdd(result);
89
+ });
90
+ handleUpload = (0, figure_uploader_1.figureUploader)(upload);
91
+ }
92
+ if (this.props.dispatch && this.props.theme) {
93
+ const files = this.props.getFiles();
94
+ const doc = this.view.state.doc;
95
+ const componentProps = {
96
+ can: can,
97
+ files: (0, files_1.groupFiles)(doc, files),
98
+ onUpload: handleUpload,
99
+ onAdd: handleAdd,
100
+ hasUploadedImage: hasUploadedImage,
101
+ };
102
+ (_a = this.reactTools) === null || _a === void 0 ? void 0 : _a.remove();
103
+ this.reactTools = (0, ReactSubView_1.default)(this.props, FigureDropdown_1.FigureElementOptions, componentProps, this.node, this.getPos, this.view);
104
+ this.dom.insertBefore(this.reactTools, this.dom.firstChild);
105
+ }
106
+ }
107
+ deleteSupplementNode(file) {
108
+ const tr = this.view.state.tr;
109
+ this.view.state.doc.descendants((node, pos) => {
110
+ if (node.type === transform_1.schema.nodes.supplement &&
111
+ node.attrs.href === file.id) {
112
+ tr.delete(pos, pos + node.nodeSize);
113
+ }
114
+ });
115
+ this.view.dispatch(tr);
116
+ }
38
117
  }
39
118
  exports.FigureElementView = FigureElementView;
40
119
  exports.default = (0, creators_1.createNodeView)(FigureElementView);
@@ -58,7 +58,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
58
58
  },
59
59
  ],
60
60
  };
61
- this.props.popper.show(this.dom, (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']), 'right-start', false);
61
+ this.props.popper.show(this.dom, (0, ReactSubView_1.default)(this.props, style_guide_1.ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu'), 'right-start', false);
62
62
  };
63
63
  this.handleClick = () => {
64
64
  if ((0, track_changes_utils_1.isDeleted)(this.node)) {
@@ -94,10 +94,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
94
94
  if (!fn) {
95
95
  return [];
96
96
  }
97
- const rids = this.node.attrs.rids;
98
- const footnotes = fn.footnotes
99
- .map((n) => n[0])
100
- .filter((n) => fn.unusedFootnoteIDs.has(n.attrs.id) || rids.includes(n.attrs.id));
97
+ const footnotes = fn.footnotes.map((n) => n[0]);
101
98
  const props = {
102
99
  footnotes,
103
100
  inlineFootnote: this.node,
@@ -106,7 +103,7 @@ class InlineFootnoteView extends base_node_view_1.BaseNodeView {
106
103
  onAdd: this.handleAdd,
107
104
  onInsert: this.handleInsert,
108
105
  };
109
- this.popperContainer = (0, ReactSubView_1.default)(this.props, FootnotesSelector_1.FootnotesSelector, props, this.node, this.getPos, this.view, ['footnote-editor']);
106
+ this.popperContainer = (0, ReactSubView_1.default)(this.props, FootnotesSelector_1.FootnotesSelector, props, this.node, this.getPos, this.view, 'footnote-editor');
110
107
  this.props.popper.show(this.dom, this.popperContainer, 'auto', false);
111
108
  };
112
109
  this.initialise = () => {
@@ -58,7 +58,7 @@ class KeywordView extends base_node_view_1.BaseNodeView {
58
58
  keyword: keyword.textContent,
59
59
  handleDelete: handleDelete,
60
60
  };
61
- this.dialog = (0, ReactSubView_1.default)(this.props, DeleteKeywordDialog_1.DeleteKeywordDialog, componentProps, this.node, this.getPos, this.view, ['keywords-delete']);
61
+ this.dialog = (0, ReactSubView_1.default)(this.props, DeleteKeywordDialog_1.DeleteKeywordDialog, componentProps, this.node, this.getPos, this.view, 'keywords-delete');
62
62
  if (this.dialog) {
63
63
  this.dom.appendChild(this.dialog);
64
64
  }
@@ -37,7 +37,7 @@ class KeywordGroupView extends block_view_1.default {
37
37
  this.contentDOM.setAttribute('contenteditable', 'false');
38
38
  this.element.appendChild(this.contentDOM);
39
39
  if (this.props.getCapabilities().editArticle) {
40
- this.addingTools = (0, ReactSubView_1.default)(this.props, AddKeywordInline_1.AddKeywordInline, { getUpdatedNode: () => this.node }, this.node, this.getPos, this.view, ['keywords-editor']);
40
+ this.addingTools = (0, ReactSubView_1.default)(this.props, AddKeywordInline_1.AddKeywordInline, { getUpdatedNode: () => this.node }, this.node, this.getPos, this.view, 'keywords-editor');
41
41
  }
42
42
  if (this.addingTools) {
43
43
  this.element.appendChild(this.addingTools);
@@ -71,7 +71,7 @@ class LinkEditableView extends link_1.LinkView {
71
71
  onRemove: this.handleRemove,
72
72
  onSave: this.handleSave,
73
73
  };
74
- this.popperContainer = (0, ReactSubView_1.default)(this.props, LinkForm_1.LinkForm, componentProps, this.node, this.getPos, this.view, ['link-editor']);
74
+ this.popperContainer = (0, ReactSubView_1.default)(this.props, LinkForm_1.LinkForm, componentProps, this.node, this.getPos, this.view, 'link-editor');
75
75
  this.props.popper.show(this.dom, this.popperContainer, 'bottom');
76
76
  };
77
77
  this.handleClick = (e) => {
@@ -79,7 +79,7 @@ class TableCellView extends block_view_1.default {
79
79
  contextMenuButton.classList.toggle('open-context-menu');
80
80
  },
81
81
  onCancelColumnDialog: () => this.addOutClickListener(contextMenuButton),
82
- }, this.view.state.selection.$from.node(), this.getPos, this.view, ['table-cell-context-menu']);
82
+ }, this.view.state.selection.$from.node(), this.getPos, this.view, 'table-cell-context-menu');
83
83
  contextMenuButton.classList.toggle('open-context-menu');
84
84
  this.props.popper.show(contextMenuButton, contextMenu, 'right', false);
85
85
  this.addOutClickListener(contextMenuButton);
@@ -428,8 +428,8 @@ export const insertInlineFootnote = (state, dispatch) => {
428
428
  const tr = state.tr;
429
429
  const container = findFootnotesContainerNode(state.doc, pos);
430
430
  const fn = getFootnotesElementState(state, container.node.attrs.id);
431
- const hasUnusedFootnotes = fn && fn.unusedFootnoteIDs.size > 0;
432
- const footnote = !hasUnusedFootnotes && createFootnote();
431
+ const hasFootnotes = fn && fn.footnotes.filter((fn) => !isDeleted(fn[0])).length > 0;
432
+ const footnote = !hasFootnotes && createFootnote();
433
433
  const node = schema.nodes.inline_footnote.create({
434
434
  rids: footnote ? [footnote.attrs.id] : [],
435
435
  });
@@ -1,39 +1,53 @@
1
- import { DotsIcon, DropdownList, getFileIcon, IconButton, IconTextButton, isImageFile, TriangleCollapsedIcon, UploadIcon, useDropdown, } from '@manuscripts/style-guide';
1
+ import { AddIcon, AttachIcon, DotsIcon, DropdownList, getFileIcon, IconButton, IconTextButton, isImageFile, RoundIconButton, TriangleCollapsedIcon, UploadIcon, useDropdown, } from '@manuscripts/style-guide';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
- export const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
4
+ export const FigureElementOptions = ({ can, files, onAdd, onUpload, hasUploadedImage, }) => {
5
5
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
6
6
  const supplements = files.supplements
7
7
  .map((s) => s.file)
8
8
  .filter((f) => isImageFile(f.name));
9
+ const others = files.others.filter((f) => isImageFile(f.name));
10
+ return (React.createElement(FilesDropdownWrapper, { onClick: toggleOpen, ref: wrapperRef },
11
+ React.createElement(FilesButton, { disabled: hasUploadedImage },
12
+ React.createElement(AttachIcon, null)),
13
+ isOpen && (React.createElement(DropdownList, { direction: 'left', width: 208, height: 187, onClick: toggleOpen, top: 7 },
14
+ React.createElement(NestedDropdown, { disabled: !can.replaceFile || supplements.length < 1, parentToggleOpen: toggleOpen, buttonText: 'Supplements', list: React.createElement(React.Fragment, null, supplements.map((file) => (React.createElement(ListItemButton, { key: file.id, onClick: () => onAdd(file) },
15
+ getFileIcon(file.name),
16
+ React.createElement(ListItemText, null, file.name))))) }),
17
+ React.createElement(NestedDropdown, { disabled: !can.replaceFile || others.length < 1, parentToggleOpen: toggleOpen, buttonText: 'Other files', list: React.createElement(React.Fragment, null, others.map((file) => (React.createElement(ListItemButton, { key: file.id, onClick: () => onAdd(file) },
18
+ getFileIcon(file.name),
19
+ React.createElement(ListItemText, null, file.name))))) }),
20
+ React.createElement(UploadButton, { onClick: onUpload, disabled: !can.uploadFile },
21
+ React.createElement(AddIcon, null),
22
+ " New file...")))));
23
+ };
24
+ export const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
25
+ const { isOpen, toggleOpen, wrapperRef } = useDropdown();
9
26
  const otherFiles = files.others.filter((f) => isImageFile(f.name));
10
27
  const showDownload = onDownload && can.downloadFiles;
11
28
  const showUpload = onUpload && can.uploadFile;
12
29
  const showDetach = onDetach && can.detachFile;
13
30
  const showReplace = onReplace && can.replaceFile;
14
- const replaceBtnText = onDownload ? 'Replace' : 'Choose file';
15
31
  return (React.createElement(DropdownWrapper, { ref: wrapperRef },
16
32
  React.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
17
33
  React.createElement(DotsIcon, null)),
18
34
  isOpen && (React.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
19
- React.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: replaceBtnText, moveLeft: true, list: React.createElement(React.Fragment, null,
20
- supplements.map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
21
- getFileIcon(file.name),
22
- React.createElement(ListItemText, null, file.name)))),
35
+ React.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
36
+ React.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: 'Replace', moveLeft: true, list: React.createElement(React.Fragment, null,
23
37
  otherFiles.map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
24
38
  getFileIcon(file.name),
25
39
  React.createElement(ListItemText, null, file.name)))),
26
40
  React.createElement(UploadButton, { onClick: onUpload, disabled: !showUpload },
27
41
  React.createElement(UploadIcon, null),
28
42
  " Upload new...")) }),
29
- React.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
30
43
  React.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach")))));
31
44
  };
32
45
  const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft }) => {
33
46
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
34
47
  return (React.createElement(DropdownWrapper, { ref: wrapperRef },
35
48
  React.createElement(NestedListButton, { onClick: toggleOpen, disabled: disabled },
36
- React.createElement("div", null, buttonText),
49
+ buttonText,
50
+ " ",
37
51
  React.createElement(TriangleCollapsedIcon, null)),
38
52
  isOpen && (React.createElement(NestedListDropdownList, { direction: 'right', moveLeft: moveLeft, width: 192, onClick: (e) => {
39
53
  toggleOpen();
@@ -53,6 +67,9 @@ const OptionsButton = styled(IconButton) `
53
67
  margin: ${(props) => props.theme.grid.unit}px;
54
68
  visibility: hidden;
55
69
  background: white;
70
+ position: absolute;
71
+ top: -4px;
72
+ right: 4%;
56
73
 
57
74
  &:hover {
58
75
  background: #f2fbfc !important;
@@ -94,15 +111,30 @@ const ListItemText = styled.div `
94
111
  text-overflow: ellipsis;
95
112
  text-align: start;
96
113
  `;
114
+ const FilesButton = styled(RoundIconButton) `
115
+ path {
116
+ stroke: #6e6e6e;
117
+ }
118
+
119
+ &:active,
120
+ &:focus {
121
+ path {
122
+ stroke: #1a9bc7;
123
+ }
124
+ }
125
+ `;
126
+ const FilesDropdownWrapper = styled.div `
127
+ position: absolute;
128
+ top: 8px;
129
+ left: 70px;
130
+ z-index: 1;
131
+ `;
97
132
  const NestedListButton = styled(ListItemButton) `
98
133
  width: 100%;
99
134
  &:active,
100
135
  &:focus {
101
136
  background: #f2fbfc;
102
137
  }
103
- svg {
104
- margin-right: 0;
105
- }
106
138
  `;
107
139
  const NestedListDropdownList = styled(DropdownList) `
108
140
  top: 0;
@@ -29,7 +29,6 @@ import doi from '../plugins/doi';
29
29
  import editorProps from '../plugins/editor-props';
30
30
  import elements from '../plugins/elements';
31
31
  import footnotes from '../plugins/footnotes';
32
- import inspector_tabs from '../plugins/inspector-tabs';
33
32
  import objects from '../plugins/objects';
34
33
  import paragraphs from '../plugins/paragraphs';
35
34
  import persist from '../plugins/persist';
@@ -71,7 +70,6 @@ export default (props) => {
71
70
  doi(),
72
71
  section_category(props),
73
72
  cross_references(),
74
- inspector_tabs(),
75
73
  ];
76
74
  if (props.collabProvider) {
77
75
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
package/dist/es/index.js CHANGED
@@ -39,4 +39,3 @@ export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
39
39
  export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
40
40
  export { metadata } from './lib/references';
41
41
  export { authorLabel, affiliationLabel, } from './lib/authors';
42
- export * from './plugins/inspector-tabs';
@@ -13,16 +13,11 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ImageDefaultIcon, ImageLeftIcon, ImageRightIcon, TriangleCollapsedIcon, } from '@manuscripts/style-guide';
17
16
  import { getListType, isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
18
17
  import { findChildrenByType } from 'prosemirror-utils';
19
- import { createElement } from 'react';
20
- import { renderToStaticMarkup } from 'react-dom/server';
21
18
  import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralTableFootnote, insertInlineTableFootnote, isCommentingAllowed, } from '../commands';
22
- import { figurePositions } from '../views/figure_editable';
23
19
  import { PopperManager } from './popper';
24
- import { getMatchingChild, isChildOfNodeTypes, isSelectionInNode, } from './utils';
25
- import { updateNodeAttrs } from './view';
20
+ import { isChildOfNodeTypes, isSelectionInNode } from './utils';
26
21
  const popper = new PopperManager();
27
22
  const readonlyTypes = [
28
23
  schema.nodes.keywords,
@@ -43,7 +38,6 @@ const hasAny = (set, ...items) => {
43
38
  return items.some((i) => set.has(i));
44
39
  };
45
40
  export const contextMenuBtnClass = 'btn-context-menu';
46
- const contextSubmenuBtnClass = 'context-submenu-trigger';
47
41
  export class ContextMenu {
48
42
  constructor(node, view, getPos) {
49
43
  this.showAddMenu = (target, after) => {
@@ -152,36 +146,6 @@ export class ContextMenu {
152
146
  const $pos = this.resolvePos();
153
147
  const isBox = isBoxElementSectionTitle($pos, this.node);
154
148
  const type = isBox ? schema.nodes.box_element : this.node.type;
155
- if (type === schema.nodes.figure_element ||
156
- type === schema.nodes.image_element) {
157
- const figure = getMatchingChild(this.node, (node) => node.type === schema.nodes.figure);
158
- if (figure) {
159
- const attrType = figure.attrs.type;
160
- const submenuOptions = [
161
- {
162
- title: 'Left',
163
- action: () => updateNodeAttrs(this.view, schema.nodes.figure, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.left })),
164
- Icon: ImageLeftIcon,
165
- selected: attrType === figurePositions.left,
166
- },
167
- {
168
- title: 'Default',
169
- action: () => updateNodeAttrs(this.view, schema.nodes.figure, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.default })),
170
- Icon: ImageDefaultIcon,
171
- selected: !attrType,
172
- },
173
- {
174
- title: 'Right',
175
- action: () => updateNodeAttrs(this.view, schema.nodes.figure, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.right })),
176
- Icon: ImageRightIcon,
177
- selected: attrType === figurePositions.right,
178
- },
179
- ];
180
- const submenuLabel = 'Position';
181
- const submenu = this.createSubmenu(submenuLabel, submenuOptions);
182
- menu.appendChild(submenu);
183
- }
184
- }
185
149
  if (type === schema.nodes.list) {
186
150
  menu.appendChild(this.createMenuSection((section) => {
187
151
  const attrs = this.node.attrs;
@@ -245,48 +209,22 @@ export class ContextMenu {
245
209
  popper.show(target, menu, 'right', true);
246
210
  this.addPopperEventListeners();
247
211
  };
248
- this.createSubmenuTrigger = (contents) => {
249
- const item = document.createElement('div');
250
- item.className = 'menu-item';
251
- const textNode = document.createTextNode(contents);
252
- item.innerHTML = renderToStaticMarkup(createElement(TriangleCollapsedIcon));
253
- item.prepend(textNode);
254
- item.classList.add(contextSubmenuBtnClass);
255
- item.addEventListener('mousedown', this.toggleSubmenu);
256
- return item;
257
- };
258
- this.createMenuItem = (contents, handler, Icon = null, selected = false) => {
212
+ this.createMenuItem = (contents, handler) => {
259
213
  const item = document.createElement('div');
260
214
  item.className = 'menu-item';
261
- selected && item.classList.add('selected');
262
- if (Icon) {
263
- item.innerHTML = renderToStaticMarkup(createElement(Icon));
264
- }
265
- const textNode = document.createTextNode(contents);
266
- item.appendChild(textNode);
215
+ item.textContent = contents;
267
216
  item.addEventListener('mousedown', (event) => {
268
217
  event.preventDefault();
269
218
  handler(event);
270
219
  });
271
220
  return item;
272
221
  };
273
- this.createMenuSection = (createMenuItems, isSubmenu = false) => {
222
+ this.createMenuSection = (createMenuItems) => {
274
223
  const section = document.createElement('div');
275
224
  section.className = 'menu-section';
276
- isSubmenu && section.classList.add('menu');
277
225
  createMenuItems(section);
278
226
  return section;
279
227
  };
280
- this.createSubmenu = (submenuLabel, items) => {
281
- const submenu = document.createElement('div');
282
- submenu.classList.add('menu-section', 'context-submenu');
283
- submenu.append(this.createSubmenuTrigger(submenuLabel), this.createMenuSection((section) => {
284
- items.forEach(({ title, action, Icon, selected }) => {
285
- section.appendChild(this.createMenuItem(title, action, Icon, selected));
286
- });
287
- }, true));
288
- return submenu;
289
- };
290
228
  this.insertableTypes = (after, insertPos, endPos) => {
291
229
  const { nodes } = schema;
292
230
  const insertable = new Set();
@@ -348,8 +286,7 @@ export class ContextMenu {
348
286
  this.addPopperEventListeners = () => {
349
287
  const mouseListener = (event) => {
350
288
  const target = event.target;
351
- if (target.classList.contains(contextMenuBtnClass) ||
352
- target.classList.contains(contextSubmenuBtnClass)) {
289
+ if (target.classList.contains(contextMenuBtnClass)) {
353
290
  return;
354
291
  }
355
292
  window.requestAnimationFrame(() => {
@@ -381,10 +318,6 @@ export class ContextMenu {
381
318
  }
382
319
  return this.node;
383
320
  };
384
- this.toggleSubmenu = (ev) => {
385
- const submenu = ev.target.nextElementSibling;
386
- submenu === null || submenu === void 0 ? void 0 : submenu.classList.toggle('show');
387
- };
388
321
  this.node = node;
389
322
  this.view = view;
390
323
  this.getPos = getPos;
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { schema, } from '@manuscripts/transform';
17
- import { NodeSelection } from 'prosemirror-state';
18
17
  import * as utils from 'prosemirror-utils';
19
18
  import { isHidden, sanitizeAttrsChange } from './track-changes-utils';
20
19
  const metaNodeTypes = [
@@ -45,8 +44,7 @@ export const updateNodeAttrs = (view, type, attrs) => {
45
44
  const copy = sanitizeAttrsChange(attrs, child.node.attrs);
46
45
  delete copy.dataTracked;
47
46
  const pos = child.pos;
48
- const tr = view.state.tr;
49
- tr.setNodeMarkup(pos, undefined, copy).setSelection(NodeSelection.create(tr.doc, pos));
47
+ const tr = view.state.tr.setNodeMarkup(pos, undefined, copy);
50
48
  if (metaNodeTypes.includes(type)) {
51
49
  tr.setMeta(updateMetaNode, true);
52
50
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.32-LEAN-4096.0';
1
+ export const VERSION = '2.7.32';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -16,12 +16,12 @@
16
16
  import React from 'react';
17
17
  import { createRoot } from 'react-dom/client';
18
18
  import { ThemeProvider } from 'styled-components';
19
- function createSubView(props, Component, componentProps, node, getPos, view, classNames = []) {
19
+ function createSubView(props, Component, componentProps, node, getPos, view, classNames = '') {
20
20
  const container = document.createElement('div');
21
21
  container.classList.add('tools-panel');
22
- if (classNames.length) {
23
- container.classList.add(...classNames);
24
- container.setAttribute('data-cy', classNames[0]);
22
+ if (classNames) {
23
+ container.classList.add(classNames);
24
+ container.setAttribute('data-cy', classNames);
25
25
  }
26
26
  container.setAttribute('contenteditable', 'false');
27
27
  const Wrapped = () => {
@@ -98,7 +98,7 @@ export class AffiliationsView extends BlockView {
98
98
  action: () => this.handleEdit(),
99
99
  icon: 'Edit',
100
100
  });
101
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
101
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
102
102
  return this.contextMenu;
103
103
  }
104
104
  return undefined;
@@ -74,7 +74,7 @@ export class AwardView extends BlockView {
74
74
  },
75
75
  ],
76
76
  };
77
- this.props.popper.show(this.contentDOM, ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']), 'right-start', false);
77
+ this.props.popper.show(this.contentDOM, ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu'), 'right-start', false);
78
78
  };
79
79
  this.showAwardModal = (award) => {
80
80
  var _a, _b;
@@ -85,7 +85,7 @@ export class AwardView extends BlockView {
85
85
  onSaveAward: this.handleSaveAward,
86
86
  onCancelAward: this.handleCancelAward,
87
87
  };
88
- this.popperContainer = ReactSubView(this.props, AwardModal, componentProps, this.node, this.getPos, this.view, ['award-editor']);
88
+ this.popperContainer = ReactSubView(this.props, AwardModal, componentProps, this.node, this.getPos, this.view, 'award-editor');
89
89
  this.props.popper.show(this.dom, this.popperContainer, 'auto', false);
90
90
  };
91
91
  this.showDeleteAwardDialog = () => {
@@ -94,7 +94,7 @@ export class AwardView extends BlockView {
94
94
  const componentProps = {
95
95
  handleDelete: this.handleDeleteAward,
96
96
  };
97
- this.popperContainer = ReactSubView(this.props, DeleteAwardDialog, componentProps, this.node, this.getPos, this.view, ['award-editor']);
97
+ this.popperContainer = ReactSubView(this.props, DeleteAwardDialog, componentProps, this.node, this.getPos, this.view, 'award-editor');
98
98
  this.props.popper.show(this.dom, this.popperContainer, 'auto', false);
99
99
  };
100
100
  this.handleSaveAward = (award) => {
@@ -119,7 +119,7 @@ export class BibliographyElementBlockView extends BlockView {
119
119
  onSave: this.handleSave,
120
120
  onDelete: this.handleDelete,
121
121
  };
122
- this.editor = ReactSubView(this.props, ReferencesEditor, componentProps, this.node, this.getPos, this.view, ['references-editor']);
122
+ this.editor = ReactSubView(this.props, ReferencesEditor, componentProps, this.node, this.getPos, this.view, 'references-editor');
123
123
  this.props.popper.show(this.dom, this.editor, 'right');
124
124
  }
125
125
  handleEdit(citationID) {
@@ -145,7 +145,7 @@ export class BibliographyElementBlockView extends BlockView {
145
145
  action: () => handleComment(item, this.view),
146
146
  icon: 'AddComment',
147
147
  });
148
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
148
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
149
149
  this.props.popper.show(element, this.contextMenu, 'right-start');
150
150
  }
151
151
  updateContents() {
@@ -87,7 +87,7 @@ export class CitationEditableView extends CitationView {
87
87
  const componentProps = {
88
88
  actions,
89
89
  };
90
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
90
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
91
91
  this.props.popper.show(this.dom, this.contextMenu, 'right-start', false);
92
92
  };
93
93
  this.showPopper = () => {
@@ -115,14 +115,14 @@ export class CitationEditableView extends CitationView {
115
115
  onCancel: this.handleCancel,
116
116
  canEdit: can.editCitationsAndRefs,
117
117
  };
118
- this.editor = ReactSubView(this.props, CitationEditor, componentProps, this.node, this.getPos, this.view, ['citation-editor']);
118
+ this.editor = ReactSubView(this.props, CitationEditor, componentProps, this.node, this.getPos, this.view, 'citation-editor');
119
119
  }
120
120
  else {
121
121
  const componentProps = {
122
122
  rids,
123
123
  items,
124
124
  };
125
- this.editor = ReactSubView(this.props, CitationViewer, componentProps, this.node, this.getPos, this.view, ['citation-editor']);
125
+ this.editor = ReactSubView(this.props, CitationViewer, componentProps, this.node, this.getPos, this.view, 'citation-editor');
126
126
  }
127
127
  this.props.popper.show(this.dom, this.editor, 'auto');
128
128
  };
@@ -132,7 +132,7 @@ export class ContributorsView extends BlockView {
132
132
  action: () => this.handleEdit(''),
133
133
  icon: 'Edit',
134
134
  });
135
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
135
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
136
136
  return this.contextMenu;
137
137
  }
138
138
  return undefined;
@@ -196,7 +196,7 @@ export class ContributorsView extends BlockView {
196
196
  },
197
197
  ],
198
198
  };
199
- this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['context-menu']);
199
+ this.contextMenu = ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu');
200
200
  this.props.popper.show(element, this.contextMenu, 'right-start');
201
201
  };
202
202
  this.handleEdit = (id, addNew) => {
@@ -46,7 +46,7 @@ export class CrossReferenceEditableView extends CrossReferenceView {
46
46
  currentTargetId: rids[0],
47
47
  currentCustomLabel: this.node.attrs.label,
48
48
  };
49
- this.popperContainer = ReactSubView(this.props, CrossReferenceItems, componentProps, this.node, this.getPos, this.view, ['cross-reference-editor']);
49
+ this.popperContainer = ReactSubView(this.props, CrossReferenceItems, componentProps, this.node, this.getPos, this.view, 'cross-reference-editor');
50
50
  this.props.popper.show(this.dom, this.popperContainer, 'auto');
51
51
  };
52
52
  this.destroy = () => {
@@ -68,7 +68,7 @@ export class EmbedMediaView extends BlockView {
68
68
  },
69
69
  ],
70
70
  };
71
- preview.appendChild(ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, ['embed-context-menu']));
71
+ preview.appendChild(ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'embed-context-menu'));
72
72
  };
73
73
  }
74
74
  updateContents() {