@manuscripts/body-editor 3.2.8 → 3.2.10

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.
@@ -30,7 +30,7 @@ const FigureOptions = ({ can, getDoc, getFiles, onDownload, onUpload, onDetach,
30
30
  react_1.default.createElement(style_guide_1.DotsIcon, null)),
31
31
  isOpen && (react_1.default.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
32
32
  react_1.default.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: replaceBtnText, moveLeft: true, list: react_1.default.createElement(react_1.default.Fragment, null,
33
- getSupplements(getFiles, getDoc, groupFiles).map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
33
+ getSupplements(getFiles, getDoc, groupFiles).map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file, true) },
34
34
  (0, style_guide_1.getFileIcon)(file.name),
35
35
  react_1.default.createElement(ListItemText, null, file.name)))),
36
36
  getOtherFiles(getFiles, getDoc, groupFiles).map((file, index) => (react_1.default.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MATHJAX_VERSION = exports.VERSION = void 0;
4
- exports.VERSION = '3.2.8';
4
+ exports.VERSION = '3.2.10';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -259,8 +259,24 @@ class FigureEditableView extends figure_1.FigureView {
259
259
  };
260
260
  }
261
261
  if (can.replaceFile) {
262
- handleReplace = (file) => {
262
+ handleReplace = (file, isSupplement = false) => {
263
263
  this.setSrc(file.id);
264
+ if (isSupplement) {
265
+ const tr = this.view.state.tr;
266
+ this.view.state.doc.descendants((node, pos) => {
267
+ if (node.type === node.type.schema.nodes.supplement) {
268
+ const href = node.attrs.href;
269
+ if (href === file.id) {
270
+ tr.delete(pos, pos + node.nodeSize);
271
+ this.view.dispatch(tr);
272
+ }
273
+ }
274
+ if (node.type !== node.type.schema.nodes.supplements &&
275
+ node.type !== node.type.schema.nodes.manuscript) {
276
+ return false;
277
+ }
278
+ });
279
+ }
264
280
  };
265
281
  }
266
282
  if (can.uploadFile) {
@@ -24,7 +24,7 @@ export const FigureOptions = ({ can, getDoc, getFiles, onDownload, onUpload, onD
24
24
  React.createElement(DotsIcon, null)),
25
25
  isOpen && (React.createElement(OptionsDropdownList, { direction: 'right', width: 128, top: 5 },
26
26
  React.createElement(NestedDropdown, { disabled: !showReplace, parentToggleOpen: toggleOpen, buttonText: replaceBtnText, moveLeft: true, list: React.createElement(React.Fragment, null,
27
- getSupplements(getFiles, getDoc, groupFiles).map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
27
+ getSupplements(getFiles, getDoc, groupFiles).map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file, true) },
28
28
  getFileIcon(file.name),
29
29
  React.createElement(ListItemText, null, file.name)))),
30
30
  getOtherFiles(getFiles, getDoc, groupFiles).map((file, index) => (React.createElement(ListItemButton, { key: file.id, id: index.toString(), onClick: () => onReplace && onReplace(file) },
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.8';
1
+ export const VERSION = '3.2.10';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -253,8 +253,24 @@ export class FigureEditableView extends FigureView {
253
253
  };
254
254
  }
255
255
  if (can.replaceFile) {
256
- handleReplace = (file) => {
256
+ handleReplace = (file, isSupplement = false) => {
257
257
  this.setSrc(file.id);
258
+ if (isSupplement) {
259
+ const tr = this.view.state.tr;
260
+ this.view.state.doc.descendants((node, pos) => {
261
+ if (node.type === node.type.schema.nodes.supplement) {
262
+ const href = node.attrs.href;
263
+ if (href === file.id) {
264
+ tr.delete(pos, pos + node.nodeSize);
265
+ this.view.dispatch(tr);
266
+ }
267
+ }
268
+ if (node.type !== node.type.schema.nodes.supplements &&
269
+ node.type !== node.type.schema.nodes.manuscript) {
270
+ return false;
271
+ }
272
+ });
273
+ }
258
274
  };
259
275
  }
260
276
  if (can.uploadFile) {
@@ -10,7 +10,7 @@ export interface FigureOptionsProps extends FigureDropdownProps {
10
10
  onDownload?: () => void;
11
11
  onUpload?: () => void;
12
12
  onDetach?: () => void;
13
- onReplace?: (file: FileAttachment) => void;
13
+ onReplace?: (file: FileAttachment, isSupplement?: boolean) => void;
14
14
  getDoc: () => ManuscriptNode;
15
15
  onDelete?: () => void;
16
16
  }
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.8";
1
+ export declare const VERSION = "3.2.10";
2
2
  export declare const MATHJAX_VERSION = "3.2.2";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@manuscripts/body-editor",
3
3
  "description": "Prosemirror components for editing and viewing manuscripts",
4
- "version": "3.2.8",
4
+ "version": "3.2.10",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",