@manuscripts/body-editor 2.0.6-LEAN-2165.1 → 2.0.6

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.
@@ -455,6 +455,10 @@ exports.insertSection = insertSection;
455
455
  const insertBackMatterSection = (category) => (state, dispatch, view) => {
456
456
  const bibliographySection = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.bibliography_section)[0];
457
457
  const backmatter = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.backmatter)[0];
458
+ const backmatterSections = (0, prosemirror_utils_1.findChildrenByType)(backmatter.node, transform_1.schema.nodes.section, true);
459
+ if (backmatterSections.some((section) => section.node.attrs.category === category)) {
460
+ return false;
461
+ }
458
462
  let pos;
459
463
  if (bibliographySection) {
460
464
  pos = bibliographySection.pos;
@@ -7,13 +7,12 @@ exports.FigureOptions = exports.FigureElementOptions = 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 FigureElementOptions = ({ can, files, onAdd, onUpload, onAddNewFile, }) => {
10
+ const FigureElementOptions = ({ can, files, onAdd, onUpload, }) => {
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
15
  const others = files.others.filter((f) => (0, style_guide_1.isImageFile)(f.name));
16
- const showAddFile = onAddNewFile ? onAddNewFile() : false;
17
16
  return (react_1.default.createElement(FilesDropdownWrapper, { onClick: toggleOpen, ref: wrapperRef },
18
17
  react_1.default.createElement(FilesButton, null,
19
18
  react_1.default.createElement(style_guide_1.AttachIcon, null)),
@@ -24,7 +23,7 @@ const FigureElementOptions = ({ can, files, onAdd, onUpload, onAddNewFile, }) =>
24
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) },
25
24
  (0, style_guide_1.getFileIcon)(file.name),
26
25
  react_1.default.createElement(ListItemText, null, file.name))))) }),
27
- react_1.default.createElement(UploadButton, { onClick: onUpload, disabled: showAddFile || !can.uploadFile },
26
+ react_1.default.createElement(UploadButton, { onClick: onUpload, disabled: !can.uploadFile },
28
27
  react_1.default.createElement(style_guide_1.AddIcon, null),
29
28
  " New file...")))));
30
29
  };
@@ -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 = '2.0.6-LEAN-2165.1';
4
+ exports.VERSION = '2.0.6';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -64,15 +64,6 @@ class FigureElementView extends block_view_1.default {
64
64
  this.dom.removeAttribute('data-track-status');
65
65
  this.dom.removeAttribute('data-track-op');
66
66
  }
67
- const handleNewFile = () => {
68
- let figureUploaded = false;
69
- this.node.content.forEach((file) => {
70
- if (file.attrs.src) {
71
- figureUploaded = true;
72
- }
73
- });
74
- return figureUploaded;
75
- };
76
67
  this.contentDOM.setAttribute('data-figure-style', figureStyle);
77
68
  this.contentDOM.setAttribute('data-figure-layout', figureLayout);
78
69
  this.contentDOM.setAttribute('data-alignment', alignment);
@@ -124,7 +115,6 @@ class FigureElementView extends block_view_1.default {
124
115
  files: (0, files_1.groupFiles)(doc, files),
125
116
  onUpload: handleUpload,
126
117
  onAdd: handleAdd,
127
- onAddNewFile: handleNewFile,
128
118
  };
129
119
  this.reactTools = (0, ReactSubView_1.default)(this.props, FigureDropdown_1.FigureElementOptions, componentProps, this.node, this.getPos, this.view);
130
120
  (_b = this.reactTools) === null || _b === void 0 ? void 0 : _b.remove();
@@ -430,6 +430,10 @@ export const insertSection = (subsection = false) => (state, dispatch, view) =>
430
430
  export const insertBackMatterSection = (category) => (state, dispatch, view) => {
431
431
  const bibliographySection = findChildrenByType(state.doc, schema.nodes.bibliography_section)[0];
432
432
  const backmatter = findChildrenByType(state.doc, schema.nodes.backmatter)[0];
433
+ const backmatterSections = findChildrenByType(backmatter.node, schema.nodes.section, true);
434
+ if (backmatterSections.some((section) => section.node.attrs.category === category)) {
435
+ return false;
436
+ }
433
437
  let pos;
434
438
  if (bibliographySection) {
435
439
  pos = bibliographySection.pos;
@@ -1,13 +1,12 @@
1
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 FigureElementOptions = ({ can, files, onAdd, onUpload, onAddNewFile, }) => {
4
+ export const FigureElementOptions = ({ can, files, onAdd, onUpload, }) => {
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
9
  const others = files.others.filter((f) => isImageFile(f.name));
10
- const showAddFile = onAddNewFile ? onAddNewFile() : false;
11
10
  return (React.createElement(FilesDropdownWrapper, { onClick: toggleOpen, ref: wrapperRef },
12
11
  React.createElement(FilesButton, null,
13
12
  React.createElement(AttachIcon, null)),
@@ -18,7 +17,7 @@ export const FigureElementOptions = ({ can, files, onAdd, onUpload, onAddNewFile
18
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) },
19
18
  getFileIcon(file.name),
20
19
  React.createElement(ListItemText, null, file.name))))) }),
21
- React.createElement(UploadButton, { onClick: onUpload, disabled: showAddFile || !can.uploadFile },
20
+ React.createElement(UploadButton, { onClick: onUpload, disabled: !can.uploadFile },
22
21
  React.createElement(AddIcon, null),
23
22
  " New file...")))));
24
23
  };
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.0.6-LEAN-2165.1';
1
+ export const VERSION = '2.0.6';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -58,15 +58,6 @@ export class FigureElementView extends BlockView {
58
58
  this.dom.removeAttribute('data-track-status');
59
59
  this.dom.removeAttribute('data-track-op');
60
60
  }
61
- const handleNewFile = () => {
62
- let figureUploaded = false;
63
- this.node.content.forEach((file) => {
64
- if (file.attrs.src) {
65
- figureUploaded = true;
66
- }
67
- });
68
- return figureUploaded;
69
- };
70
61
  this.contentDOM.setAttribute('data-figure-style', figureStyle);
71
62
  this.contentDOM.setAttribute('data-figure-layout', figureLayout);
72
63
  this.contentDOM.setAttribute('data-alignment', alignment);
@@ -118,7 +109,6 @@ export class FigureElementView extends BlockView {
118
109
  files: groupFiles(doc, files),
119
110
  onUpload: handleUpload,
120
111
  onAdd: handleAdd,
121
- onAddNewFile: handleNewFile,
122
112
  };
123
113
  this.reactTools = ReactSubView(this.props, FigureElementOptions, componentProps, this.node, this.getPos, this.view);
124
114
  (_b = this.reactTools) === null || _b === void 0 ? void 0 : _b.remove();
@@ -14,7 +14,6 @@ export interface FigureOptionsProps extends FigureDropdownProps {
14
14
  export interface FigureElementOptionsProps extends FigureDropdownProps {
15
15
  onAdd: (file: FileAttachment) => Promise<void>;
16
16
  onUpload: () => void;
17
- onAddNewFile?: () => boolean;
18
17
  }
19
18
  export declare const FigureElementOptions: React.FC<FigureElementOptionsProps>;
20
19
  export declare const FigureOptions: React.FC<FigureOptionsProps>;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.6-LEAN-2165.1";
1
+ export declare const VERSION = "2.0.6";
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": "2.0.6-LEAN-2165.1",
4
+ "version": "2.0.6",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",