@manuscripts/body-editor 2.7.8 → 2.7.9-LEAN-4096.1

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 (35) hide show
  1. package/dist/cjs/components/views/FigureDropdown.js +2 -44
  2. package/dist/cjs/configs/editor-plugins.js +2 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/lib/context-menu.js +71 -4
  5. package/dist/cjs/lib/utils.js +16 -1
  6. package/dist/cjs/plugins/inspector-actions.js +70 -0
  7. package/dist/cjs/versions.js +1 -1
  8. package/dist/cjs/views/ReactSubView.js +4 -1
  9. package/dist/cjs/views/figure.js +7 -1
  10. package/dist/cjs/views/figure_editable.js +79 -3
  11. package/dist/cjs/views/figure_element.js +0 -79
  12. package/dist/es/components/views/FigureDropdown.js +2 -43
  13. package/dist/es/configs/editor-plugins.js +2 -0
  14. package/dist/es/index.js +1 -0
  15. package/dist/es/lib/context-menu.js +72 -5
  16. package/dist/es/lib/utils.js +14 -0
  17. package/dist/es/plugins/inspector-actions.js +67 -0
  18. package/dist/es/versions.js +1 -1
  19. package/dist/es/views/ReactSubView.js +4 -1
  20. package/dist/es/views/figure.js +6 -0
  21. package/dist/es/views/figure_editable.js +81 -5
  22. package/dist/es/views/figure_element.js +0 -79
  23. package/dist/types/components/views/FigureDropdown.d.ts +0 -1
  24. package/dist/types/index.d.ts +1 -0
  25. package/dist/types/lib/context-menu.d.ts +3 -0
  26. package/dist/types/lib/utils.d.ts +3 -2
  27. package/dist/types/plugins/inspector-actions.d.ts +26 -0
  28. package/dist/types/versions.d.ts +1 -1
  29. package/dist/types/views/figure.d.ts +5 -0
  30. package/dist/types/views/figure_editable.d.ts +4 -0
  31. package/dist/types/views/figure_element.d.ts +0 -3
  32. package/package.json +2 -2
  33. package/styles/AdvancedEditor.css +17 -6
  34. package/styles/Editor.css +9 -0
  35. package/styles/popper.css +35 -4
@@ -1,26 +1,6 @@
1
- import { AddIcon, AttachIcon, DotsIcon, DropdownList, getFileIcon, IconButton, IconTextButton, isImageFile, RoundIconButton, TriangleCollapsedIcon, UploadIcon, useDropdown, } from '@manuscripts/style-guide';
1
+ import { DotsIcon, DropdownList, getFileIcon, IconButton, IconTextButton, isImageFile, TriangleCollapsedIcon, UploadIcon, useDropdown, } from '@manuscripts/style-guide';
2
2
  import React from 'react';
3
3
  import styled from 'styled-components';
4
- export const FigureElementOptions = ({ can, files, onAdd, onUpload, hasUploadedImage, }) => {
5
- const { isOpen, toggleOpen, wrapperRef } = useDropdown();
6
- const supplements = files.supplements
7
- .map((s) => s.file)
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
4
  export const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onReplace, }) => {
25
5
  const { isOpen, toggleOpen, wrapperRef } = useDropdown();
26
6
  const otherFiles = files.others.filter((f) => isImageFile(f.name));
@@ -32,7 +12,6 @@ export const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onRe
32
12
  React.createElement(OptionsButton, { className: 'options-button', onClick: toggleOpen },
33
13
  React.createElement(DotsIcon, null)),
34
14
  isOpen && (React.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
35
- React.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
36
15
  React.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: 'Replace', moveLeft: true, list: React.createElement(React.Fragment, null,
37
16
  otherFiles.map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
38
17
  getFileIcon(file.name),
@@ -40,6 +19,7 @@ export const FigureOptions = ({ can, files, onDownload, onUpload, onDetach, onRe
40
19
  React.createElement(UploadButton, { onClick: onUpload, disabled: !showUpload },
41
20
  React.createElement(UploadIcon, null),
42
21
  " Upload new...")) }),
22
+ React.createElement(ListItemButton, { onClick: onDownload, disabled: !showDownload }, "Download"),
43
23
  React.createElement(ListItemButton, { onClick: onDetach, disabled: !showDetach }, "Detach")))));
44
24
  };
45
25
  const NestedDropdown = ({ parentToggleOpen, buttonText, disabled, list, moveLeft }) => {
@@ -67,9 +47,6 @@ const OptionsButton = styled(IconButton) `
67
47
  margin: ${(props) => props.theme.grid.unit}px;
68
48
  visibility: hidden;
69
49
  background: white;
70
- position: absolute;
71
- top: -4px;
72
- right: 4%;
73
50
 
74
51
  &:hover {
75
52
  background: #f2fbfc !important;
@@ -111,24 +88,6 @@ const ListItemText = styled.div `
111
88
  text-overflow: ellipsis;
112
89
  text-align: start;
113
90
  `;
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
- `;
132
91
  const NestedListButton = styled(ListItemButton) `
133
92
  width: 100%;
134
93
  &:active,
@@ -29,6 +29,7 @@ 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 inspectorActionPlugin from '../plugins/inspector-actions';
32
33
  import objects from '../plugins/objects';
33
34
  import paragraphs from '../plugins/paragraphs';
34
35
  import persist from '../plugins/persist';
@@ -70,6 +71,7 @@ export default (props) => {
70
71
  doi(),
71
72
  section_category(props),
72
73
  cross_references(),
74
+ inspectorActionPlugin(),
73
75
  ];
74
76
  if (props.collabProvider) {
75
77
  allPlugins.push(collab({ version: props.collabProvider.currentVersion }));
package/dist/es/index.js CHANGED
@@ -39,3 +39,4 @@ 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-actions';
@@ -13,11 +13,15 @@
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';
16
17
  import { getListType, isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
17
18
  import { findChildrenByType } from 'prosemirror-utils';
19
+ import { createElement } from 'react';
20
+ import { renderToStaticMarkup } from 'react-dom/server';
18
21
  import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralTableFootnote, insertInlineTableFootnote, } from '../commands';
22
+ import { figurePositions } from '../views/figure';
19
23
  import { PopperManager } from './popper';
20
- import { isChildOfNodeTypes, isSelectionInNode } from './utils';
24
+ import { getMatchingChild, isChildOfNodeTypes, isSelectionInNode, updateNodeAttributes, } from './utils';
21
25
  const popper = new PopperManager();
22
26
  const readonlyTypes = [
23
27
  schema.nodes.keywords,
@@ -38,6 +42,8 @@ const hasAny = (set, ...items) => {
38
42
  return items.some((i) => set.has(i));
39
43
  };
40
44
  export const contextMenuBtnClass = 'btn-context-menu';
45
+ const contextSubmenuBtnClass = 'context-submenu-trigger';
46
+ const contextSubmenuClass = 'context-submenu';
41
47
  export class ContextMenu {
42
48
  constructor(node, view, getPos, actions = {}) {
43
49
  this.showAddMenu = (target, after) => {
@@ -146,6 +152,36 @@ export class ContextMenu {
146
152
  const $pos = this.resolvePos();
147
153
  const isBox = isBoxElementSectionTitle($pos, this.node);
148
154
  const type = isBox ? schema.nodes.box_element : this.node.type;
155
+ if (type === schema.nodes.figure_element) {
156
+ const figure = getMatchingChild(this.node, (node) => node.type === schema.nodes.figure);
157
+ if (figure) {
158
+ const attrType = figure.attrs.type;
159
+ const { state, dispatch } = this.view;
160
+ const submenuOptions = [
161
+ {
162
+ title: 'Left',
163
+ action: () => updateNodeAttributes(state, dispatch, figure.attrs.id, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.left })),
164
+ Icon: ImageLeftIcon,
165
+ selected: attrType === figurePositions.left,
166
+ },
167
+ {
168
+ title: 'Default',
169
+ action: () => updateNodeAttributes(state, dispatch, figure.attrs.id, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.default })),
170
+ Icon: ImageDefaultIcon,
171
+ selected: !attrType,
172
+ },
173
+ {
174
+ title: 'Right',
175
+ action: () => updateNodeAttributes(state, dispatch, figure.attrs.id, 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
+ }
149
185
  if (type === schema.nodes.list) {
150
186
  menu.appendChild(this.createMenuSection((section) => {
151
187
  const attrs = this.node.attrs;
@@ -210,22 +246,48 @@ export class ContextMenu {
210
246
  popper.show(target, menu, 'right', true);
211
247
  this.addPopperEventListeners();
212
248
  };
213
- this.createMenuItem = (contents, handler) => {
249
+ this.createSubmenuTrigger = (contents) => {
250
+ const item = document.createElement('div');
251
+ item.className = 'menu-item';
252
+ const textNode = document.createTextNode(contents);
253
+ item.innerHTML = renderToStaticMarkup(createElement(TriangleCollapsedIcon));
254
+ item.prepend(textNode);
255
+ item.classList.add(contextSubmenuBtnClass);
256
+ item.addEventListener('mousedown', this.toggleSubmenu);
257
+ return item;
258
+ };
259
+ this.createMenuItem = (contents, handler, Icon = null, selected = false) => {
214
260
  const item = document.createElement('div');
215
261
  item.className = 'menu-item';
216
- item.textContent = contents;
262
+ selected && item.classList.add('selected');
263
+ if (Icon) {
264
+ item.innerHTML = renderToStaticMarkup(createElement(Icon));
265
+ }
266
+ const textNode = document.createTextNode(contents);
267
+ item.appendChild(textNode);
217
268
  item.addEventListener('mousedown', (event) => {
218
269
  event.preventDefault();
219
270
  handler(event);
220
271
  });
221
272
  return item;
222
273
  };
223
- this.createMenuSection = (createMenuItems) => {
274
+ this.createMenuSection = (createMenuItems, isSubmenu = false) => {
224
275
  const section = document.createElement('div');
225
276
  section.className = 'menu-section';
277
+ isSubmenu && section.classList.add('menu');
226
278
  createMenuItems(section);
227
279
  return section;
228
280
  };
281
+ this.createSubmenu = (submenuLabel, items) => {
282
+ const submenu = document.createElement('div');
283
+ submenu.classList.add('menu-section', contextSubmenuClass);
284
+ submenu.append(this.createSubmenuTrigger(submenuLabel), this.createMenuSection((section) => {
285
+ items.forEach(({ title, action, Icon, selected }) => {
286
+ section.appendChild(this.createMenuItem(title, action, Icon, selected));
287
+ });
288
+ }, true));
289
+ return submenu;
290
+ };
229
291
  this.insertableTypes = (after, insertPos, endPos) => {
230
292
  const { nodes } = schema;
231
293
  const insertable = new Set();
@@ -287,7 +349,8 @@ export class ContextMenu {
287
349
  this.addPopperEventListeners = () => {
288
350
  const mouseListener = (event) => {
289
351
  const target = event.target;
290
- if (target.classList.contains(contextMenuBtnClass)) {
352
+ if (target.classList.contains(contextMenuBtnClass) ||
353
+ target.classList.contains(contextSubmenuBtnClass)) {
291
354
  return;
292
355
  }
293
356
  window.requestAnimationFrame(() => {
@@ -319,6 +382,10 @@ export class ContextMenu {
319
382
  }
320
383
  return this.node;
321
384
  };
385
+ this.toggleSubmenu = (ev) => {
386
+ const submenu = ev.target.nextElementSibling;
387
+ submenu === null || submenu === void 0 ? void 0 : submenu.classList.toggle('show');
388
+ };
322
389
  this.node = node;
323
390
  this.view = view;
324
391
  this.getPos = getPos;
@@ -75,3 +75,17 @@ export const createHeader = (typeName, text) => {
75
75
  header.textContent = text;
76
76
  return header;
77
77
  };
78
+ export const updateNodeAttributes = (state, dispatch, id, attrs) => {
79
+ let nodePosition = -1;
80
+ state.doc.descendants((node, pos) => {
81
+ if (node.attrs.id === id) {
82
+ nodePosition = pos;
83
+ return true;
84
+ }
85
+ });
86
+ if (nodePosition !== -1) {
87
+ dispatch(state.tr.setNodeMarkup(nodePosition, null, attrs));
88
+ return true;
89
+ }
90
+ return false;
91
+ };
@@ -0,0 +1,67 @@
1
+ /*!
2
+ * © 2022 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Plugin, PluginKey } from 'prosemirror-state';
17
+ export const inspectorActionPluginKey = new PluginKey('inspectorActionPlugin');
18
+ export default () => {
19
+ return new Plugin({
20
+ key: inspectorActionPluginKey,
21
+ state: {
22
+ init: () => ({
23
+ inspectorOpenTabs: {
24
+ primaryTab: null,
25
+ secondaryTab: null,
26
+ },
27
+ }),
28
+ apply: (tr, value) => {
29
+ const meta = tr.getMeta(inspectorActionPluginKey);
30
+ if (meta && meta.inspectorOpenTabs !== undefined) {
31
+ return Object.assign(Object.assign({}, value), { inspectorOpenTabs: meta.inspectorOpenTabs });
32
+ }
33
+ return value;
34
+ },
35
+ },
36
+ props: {
37
+ handleClick: (view, pos, event) => {
38
+ const target = event.target;
39
+ const inspectorOpenTabs = {
40
+ primaryTab: null,
41
+ secondaryTab: null,
42
+ };
43
+ switch (target.dataset.action) {
44
+ case 'open-other-files':
45
+ event.stopPropagation();
46
+ inspectorOpenTabs.primaryTab = 'files';
47
+ inspectorOpenTabs.secondaryTab = 'other-files';
48
+ break;
49
+ case 'open-supplement-files':
50
+ event.stopPropagation();
51
+ inspectorOpenTabs.primaryTab = 'files';
52
+ inspectorOpenTabs.secondaryTab = 'supplements-files';
53
+ break;
54
+ default:
55
+ break;
56
+ }
57
+ if (inspectorOpenTabs) {
58
+ const tr = view.state.tr.setMeta(inspectorActionPluginKey, {
59
+ inspectorOpenTabs,
60
+ });
61
+ view.dispatch(tr);
62
+ }
63
+ return false;
64
+ },
65
+ },
66
+ });
67
+ };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.8';
1
+ export const VERSION = '2.7.9-LEAN-4096.1';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -20,7 +20,10 @@ function createSubView(props, Component, componentProps, node, getPos, view, cla
20
20
  const container = document.createElement('div');
21
21
  container.classList.add('tools-panel');
22
22
  if (classNames) {
23
- container.classList.add(classNames);
23
+ const names = classNames.split(', ');
24
+ names.forEach((name) => {
25
+ container.classList.add(name);
26
+ });
24
27
  container.setAttribute('data-cy', classNames);
25
28
  }
26
29
  container.setAttribute('contenteditable', 'false');
@@ -15,6 +15,12 @@
15
15
  */
16
16
  import { BaseNodeView } from './base_node_view';
17
17
  import { createNodeView } from './creators';
18
+ export var figurePositions;
19
+ (function (figurePositions) {
20
+ figurePositions["left"] = "half-left";
21
+ figurePositions["right"] = "half-right";
22
+ figurePositions["default"] = "";
23
+ })(figurePositions || (figurePositions = {}));
18
24
  export class FigureView extends BaseNodeView {
19
25
  constructor() {
20
26
  super(...arguments);
@@ -22,13 +22,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
24
  };
25
- import { FileCorruptedIcon } from '@manuscripts/style-guide';
25
+ import { ContextMenu, FileCorruptedIcon, ImageDefaultIcon, ImageLeftIcon, ImageRightIcon, } from '@manuscripts/style-guide';
26
26
  import { createElement } from 'react';
27
27
  import { renderToStaticMarkup } from 'react-dom/server';
28
28
  import { FigureOptions, } from '../components/views/FigureDropdown';
29
29
  import { groupFiles } from '../lib/files';
30
+ import { updateNodeAttributes } from '../lib/utils';
30
31
  import { createEditableNodeView } from './creators';
31
- import { FigureView } from './figure';
32
+ import { figurePositions, FigureView } from './figure';
32
33
  import { figureUploader } from './figure_uploader';
33
34
  import ReactSubView from './ReactSubView';
34
35
  export class FigureEditableView extends FigureView {
@@ -78,11 +79,76 @@ export class FigureEditableView extends FigureView {
78
79
  element.classList.add('figure', 'placeholder');
79
80
  const instructions = document.createElement('div');
80
81
  instructions.classList.add('instructions');
81
- instructions.textContent = 'Click to select an image file';
82
- instructions.style.pointerEvents = 'none';
82
+ instructions.innerHTML = `
83
+ <p>Drag or click here to upload image <br>
84
+ or drag items here from the file inspector tabs <br>
85
+ <a data-action='open-other-files'>Other file</a> |
86
+ <a data-action='open-supplement-files'>Supplements</a></p>
87
+ `;
83
88
  element.appendChild(instructions);
84
89
  return element;
85
90
  };
91
+ this.createPositionMenuWrapper = () => {
92
+ this.positionMenuWrapper = document.createElement('div');
93
+ this.positionMenuWrapper.classList.add('position-menu');
94
+ const positionMenuButton = document.createElement('div');
95
+ positionMenuButton.classList.add('position-menu-button');
96
+ let icon;
97
+ switch (this.figurePosition) {
98
+ case figurePositions.left:
99
+ icon = ImageLeftIcon;
100
+ break;
101
+ case figurePositions.right:
102
+ icon = ImageRightIcon;
103
+ break;
104
+ default:
105
+ icon = ImageDefaultIcon;
106
+ break;
107
+ }
108
+ if (icon) {
109
+ positionMenuButton.innerHTML = renderToStaticMarkup(createElement(icon));
110
+ }
111
+ positionMenuButton.addEventListener('click', this.showPositionMenu);
112
+ this.positionMenuWrapper.appendChild(positionMenuButton);
113
+ return this.positionMenuWrapper;
114
+ };
115
+ this.showPositionMenu = () => {
116
+ this.props.popper.destroy();
117
+ const { state, dispatch } = this.view;
118
+ const figure = this.node;
119
+ const componentProps = {
120
+ actions: [
121
+ {
122
+ label: 'Left',
123
+ action: () => {
124
+ this.props.popper.destroy();
125
+ updateNodeAttributes(state, dispatch, figure.attrs.id, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.left }));
126
+ },
127
+ icon: 'ImageLeft',
128
+ selected: this.figurePosition === figurePositions.left,
129
+ },
130
+ {
131
+ label: 'Default',
132
+ action: () => {
133
+ this.props.popper.destroy();
134
+ updateNodeAttributes(state, dispatch, figure.attrs.id, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.default }));
135
+ },
136
+ icon: 'ImageDefault',
137
+ selected: !this.figurePosition,
138
+ },
139
+ {
140
+ label: 'Right',
141
+ action: () => {
142
+ this.props.popper.destroy();
143
+ updateNodeAttributes(state, dispatch, figure.attrs.id, Object.assign(Object.assign({}, figure.attrs), { type: figurePositions.right }));
144
+ },
145
+ icon: 'ImageRight',
146
+ selected: this.figurePosition === figurePositions.right,
147
+ },
148
+ ],
149
+ };
150
+ this.props.popper.show(this.positionMenuWrapper, ReactSubView(this.props, ContextMenu, componentProps, this.node, this.getPos, this.view, 'context-menu, position-menu'), 'left', false);
151
+ };
86
152
  }
87
153
  updateContents() {
88
154
  var _a;
@@ -91,6 +157,7 @@ export class FigureEditableView extends FigureView {
91
157
  const src = attrs.src;
92
158
  const files = this.props.getFiles();
93
159
  const file = src && files.filter((f) => f.id === src)[0];
160
+ this.figurePosition = attrs.type;
94
161
  this.container.innerHTML = '';
95
162
  const can = this.props.getCapabilities();
96
163
  const link = file && this.props.fileManagement.previewLink(file);
@@ -122,7 +189,15 @@ export class FigureEditableView extends FigureView {
122
189
  this.setSrc(result.id);
123
190
  });
124
191
  handleUpload = figureUploader(upload);
125
- img.addEventListener('click', handleUpload);
192
+ const handlePlaceholderClick = (event) => {
193
+ const target = event.target;
194
+ if (target.dataset && target.dataset.action) {
195
+ return;
196
+ }
197
+ const triggerUpload = figureUploader(upload);
198
+ triggerUpload();
199
+ };
200
+ img.addEventListener('click', handlePlaceholderClick);
126
201
  img.addEventListener('mouseenter', () => {
127
202
  img.classList.toggle('over', true);
128
203
  });
@@ -170,6 +245,7 @@ export class FigureEditableView extends FigureView {
170
245
  this.reactTools = ReactSubView(this.props, FigureOptions, componentProps, this.node, this.getPos, this.view);
171
246
  this.dom.insertBefore(this.reactTools, this.dom.firstChild);
172
247
  }
248
+ this.container.appendChild(this.createPositionMenuWrapper());
173
249
  }
174
250
  }
175
251
  export default createEditableNodeView(FigureEditableView);
@@ -13,23 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- import { schema } from '@manuscripts/transform';
26
- import { FigureElementOptions, } from '../components/views/FigureDropdown';
27
- import { groupFiles } from '../lib/files';
28
- import { getMatchingChild } from '../lib/utils';
29
16
  import BlockView from './block_view';
30
17
  import { createNodeView } from './creators';
31
- import { figureUploader } from './figure_uploader';
32
- import ReactSubView from './ReactSubView';
33
18
  export class FigureElementView extends BlockView {
34
19
  constructor() {
35
20
  super(...arguments);
@@ -44,69 +29,5 @@ export class FigureElementView extends BlockView {
44
29
  this.container.appendChild(this.contentDOM);
45
30
  };
46
31
  }
47
- updateContents() {
48
- var _a;
49
- super.updateContents();
50
- if (!this.contentDOM) {
51
- throw new Error('No contentDOM');
52
- }
53
- const can = this.props.getCapabilities();
54
- let handleUpload = () => {
55
- };
56
- const hasUploadedImage = !!getMatchingChild(this.node, (node) => node.type === schema.nodes.figure && node.attrs.src);
57
- const handleAdd = (file) => __awaiter(this, void 0, void 0, function* () {
58
- const { state: { tr, schema, selection }, dispatch, } = this.view;
59
- const src = file.id;
60
- const figure = getMatchingChild(this.node, (node) => node.type === schema.nodes.figure);
61
- if (figure === null || figure === void 0 ? void 0 : figure.attrs.src) {
62
- const figure = schema.nodes.figure.createAndFill({
63
- src,
64
- }, []);
65
- let position = 0;
66
- this.node.forEach((node, pos) => {
67
- if (node.type === schema.nodes.figure) {
68
- position = pos + node.nodeSize;
69
- }
70
- });
71
- dispatch(tr.insert(this.getPos() + position + 1, figure));
72
- }
73
- else if (figure) {
74
- tr.setNodeMarkup(this.getPos() + 1, undefined, Object.assign(Object.assign({}, figure.attrs), { src })).setSelection(selection.map(tr.doc, tr.mapping));
75
- dispatch(tr);
76
- }
77
- this.deleteSupplementNode(file);
78
- });
79
- if (can.uploadFile) {
80
- const upload = (file) => __awaiter(this, void 0, void 0, function* () {
81
- const result = yield this.props.fileManagement.upload(file);
82
- yield handleAdd(result);
83
- });
84
- handleUpload = figureUploader(upload);
85
- }
86
- if (this.props.dispatch && this.props.theme) {
87
- const files = this.props.getFiles();
88
- const doc = this.view.state.doc;
89
- const componentProps = {
90
- can: can,
91
- files: groupFiles(doc, files),
92
- onUpload: handleUpload,
93
- onAdd: handleAdd,
94
- hasUploadedImage: hasUploadedImage,
95
- };
96
- (_a = this.reactTools) === null || _a === void 0 ? void 0 : _a.remove();
97
- this.reactTools = ReactSubView(this.props, FigureElementOptions, componentProps, this.node, this.getPos, this.view);
98
- this.dom.insertBefore(this.reactTools, this.dom.firstChild);
99
- }
100
- }
101
- deleteSupplementNode(file) {
102
- const tr = this.view.state.tr;
103
- this.view.state.doc.descendants((node, pos) => {
104
- if (node.type === schema.nodes.supplement &&
105
- node.attrs.href === file.id) {
106
- tr.delete(pos, pos + node.nodeSize);
107
- }
108
- });
109
- this.view.dispatch(tr);
110
- }
111
32
  }
112
33
  export default createNodeView(FigureElementView);
@@ -16,5 +16,4 @@ export interface FigureElementOptionsProps extends FigureDropdownProps {
16
16
  onUpload: () => void;
17
17
  hasUploadedImage: boolean;
18
18
  }
19
- export declare const FigureElementOptions: React.FC<FigureElementOptionsProps>;
20
19
  export declare const FigureOptions: React.FC<FigureOptionsProps>;
@@ -40,3 +40,4 @@ export { footnotesKey as footnotesPluginKey } from './plugins/footnotes';
40
40
  export { bibliographyKey as bibliographyPluginKey } from './plugins/bibliography';
41
41
  export { metadata, BibliographyItemAttrs } from './lib/references';
42
42
  export { authorLabel, affiliationLabel, AffiliationAttrs, ContributorAttrs, } from './lib/authors';
43
+ export * from './plugins/inspector-actions';
@@ -27,8 +27,10 @@ export declare class ContextMenu {
27
27
  constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number, actions?: Actions);
28
28
  showAddMenu: (target: Element, after: boolean) => void;
29
29
  showEditMenu: (target: Element) => void;
30
+ private createSubmenuTrigger;
30
31
  private createMenuItem;
31
32
  private createMenuSection;
33
+ private createSubmenu;
32
34
  private insertableTypes;
33
35
  private changeNodeType;
34
36
  private deleteNode;
@@ -36,5 +38,6 @@ export declare class ContextMenu {
36
38
  private addPopperEventListeners;
37
39
  private trimTitle;
38
40
  private getCommentTarget;
41
+ private toggleSubmenu;
39
42
  }
40
43
  export {};
@@ -13,8 +13,8 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
17
- import { Node as ProseMirrorNode, NodeType } from 'prosemirror-model';
16
+ import { ManuscriptNode, ManuscriptNodeType, ManuscriptTransaction } from '@manuscripts/transform';
17
+ import { Attrs, Node as ProseMirrorNode, NodeType } from 'prosemirror-model';
18
18
  import { EditorState, Selection } from 'prosemirror-state';
19
19
  export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
20
20
  export declare const getMatchingChild: (parent: ManuscriptNode, matcher: (node: ManuscriptNode) => boolean, deep?: boolean) => ManuscriptNode | undefined;
@@ -27,3 +27,4 @@ export declare const findParentElement: (selection: Selection, validIds?: string
27
27
  export declare const isChildOfNodeTypes: (doc: ManuscriptNode, pos: number, parentNodeTypes: NodeType[]) => boolean;
28
28
  export declare const isSelectionInNode: (state: EditorState, targetNode: ProseMirrorNode) => boolean;
29
29
  export declare const createHeader: (typeName: string, text: string) => HTMLHeadingElement;
30
+ export declare const updateNodeAttributes: (state: EditorState, dispatch: (tr: ManuscriptTransaction) => void, id: string, attrs: Attrs) => boolean;
@@ -0,0 +1,26 @@
1
+ /*!
2
+ * © 2022 Atypon Systems LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Plugin, PluginKey } from 'prosemirror-state';
17
+ export declare const inspectorActionPluginKey: PluginKey<any>;
18
+ interface InspectorOpenTabs {
19
+ primaryTab: string | null;
20
+ secondaryTab: string | null;
21
+ }
22
+ interface PluginState {
23
+ inspectorOpenTabs: InspectorOpenTabs;
24
+ }
25
+ declare const _default: () => Plugin<PluginState>;
26
+ export default _default;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.8";
1
+ export declare const VERSION = "2.7.9-LEAN-4096.1";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";