@manuscripts/body-editor 3.8.10 → 3.8.12

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.
@@ -40,7 +40,7 @@ exports.Label = exports.Block = exports.BlockItem = exports.StyleBlock = exports
40
40
  const style_guide_1 = require("@manuscripts/style-guide");
41
41
  const react_1 = __importStar(require("react"));
42
42
  const styled_components_1 = __importDefault(require("styled-components"));
43
- const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
43
+ const ListMenuItem = ({ menu, handleClick, close, }) => {
44
44
  const styleRefs = (0, react_1.useRef)([]);
45
45
  (0, react_1.useEffect)(() => {
46
46
  if (menu.isOpen && styleRefs.current.length > 0) {
@@ -53,7 +53,7 @@ const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
53
53
  const styles = menu.submenu.map((m) => m.id);
54
54
  const handleStyleClick = (s, i) => {
55
55
  handleClick([i]);
56
- closeAll();
56
+ close();
57
57
  };
58
58
  const handleKeyDown = (e) => {
59
59
  const items = styleRefs.current.filter(Boolean);
@@ -76,7 +76,7 @@ const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
76
76
  items[(currentIndex - 1 + items.length) % items.length]?.focus();
77
77
  break;
78
78
  case 'Escape':
79
- closeAll();
79
+ close();
80
80
  break;
81
81
  case 'Enter': {
82
82
  const el = document.activeElement;
@@ -86,7 +86,7 @@ const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
86
86
  }
87
87
  };
88
88
  return (react_1.default.createElement(style_guide_1.SubmenuContainer, null,
89
- react_1.default.createElement(style_guide_1.SubmenuLabel, { menu: menu, handleClick: handleClick, closeAll: closeAll }),
89
+ react_1.default.createElement(style_guide_1.SubmenuLabel, { menu: menu, handleClick: handleClick, close: close }),
90
90
  menu.isOpen && (react_1.default.createElement(style_guide_1.NestedSubmenusContainer, { onKeyDown: handleKeyDown },
91
91
  react_1.default.createElement(exports.ListStyles, { styles: styles, onClick: handleStyleClick, styleRefs: styleRefs })))));
92
92
  };
@@ -79,7 +79,7 @@ exports.default = (props) => {
79
79
  (0, comments_1.default)(),
80
80
  (0, paragraphs_1.default)(),
81
81
  (0, placeholder_1.default)(),
82
- (0, add_subtitle_1.default)(),
82
+ (0, add_subtitle_1.default)(props),
83
83
  (0, translations_1.default)(props),
84
84
  (0, prosemirror_tables_1.tableEditing)(),
85
85
  (0, selected_suggestion_1.default)(),
@@ -31,9 +31,13 @@ const createAddSubtitleButton = (handler) => {
31
31
  });
32
32
  return button;
33
33
  };
34
- exports.default = () => new prosemirror_state_1.Plugin({
34
+ exports.default = (props) => new prosemirror_state_1.Plugin({
35
35
  props: {
36
36
  decorations: (state) => {
37
+ const can = props.getCapabilities();
38
+ if (!can.editArticle) {
39
+ return prosemirror_view_1.DecorationSet.empty;
40
+ }
37
41
  let titleHasContent = false;
38
42
  let titlePos = -1;
39
43
  let hasSubtitles = false;
@@ -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.8.10';
4
+ exports.VERSION = '3.8.12';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -1,7 +1,7 @@
1
1
  import { NestedSubmenusContainer, SubmenuContainer, SubmenuLabel, } from '@manuscripts/style-guide';
2
2
  import React, { useEffect, useRef } from 'react';
3
3
  import styled from 'styled-components';
4
- export const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
4
+ export const ListMenuItem = ({ menu, handleClick, close, }) => {
5
5
  const styleRefs = useRef([]);
6
6
  useEffect(() => {
7
7
  if (menu.isOpen && styleRefs.current.length > 0) {
@@ -14,7 +14,7 @@ export const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
14
14
  const styles = menu.submenu.map((m) => m.id);
15
15
  const handleStyleClick = (s, i) => {
16
16
  handleClick([i]);
17
- closeAll();
17
+ close();
18
18
  };
19
19
  const handleKeyDown = (e) => {
20
20
  const items = styleRefs.current.filter(Boolean);
@@ -37,7 +37,7 @@ export const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
37
37
  items[(currentIndex - 1 + items.length) % items.length]?.focus();
38
38
  break;
39
39
  case 'Escape':
40
- closeAll();
40
+ close();
41
41
  break;
42
42
  case 'Enter': {
43
43
  const el = document.activeElement;
@@ -47,7 +47,7 @@ export const ListMenuItem = ({ menu, handleClick, closeAll, }) => {
47
47
  }
48
48
  };
49
49
  return (React.createElement(SubmenuContainer, null,
50
- React.createElement(SubmenuLabel, { menu: menu, handleClick: handleClick, closeAll: closeAll }),
50
+ React.createElement(SubmenuLabel, { menu: menu, handleClick: handleClick, close: close }),
51
51
  menu.isOpen && (React.createElement(NestedSubmenusContainer, { onKeyDown: handleKeyDown },
52
52
  React.createElement(ListStyles, { styles: styles, onClick: handleStyleClick, styleRefs: styleRefs })))));
53
53
  };
@@ -74,7 +74,7 @@ export default (props) => {
74
74
  comments(),
75
75
  paragraphs(),
76
76
  placeholder(),
77
- add_subtitle(),
77
+ add_subtitle(props),
78
78
  translations(props),
79
79
  tableEditing(),
80
80
  selected_suggestion(),
@@ -29,9 +29,13 @@ const createAddSubtitleButton = (handler) => {
29
29
  });
30
30
  return button;
31
31
  };
32
- export default () => new Plugin({
32
+ export default (props) => new Plugin({
33
33
  props: {
34
34
  decorations: (state) => {
35
+ const can = props.getCapabilities();
36
+ if (!can.editArticle) {
37
+ return DecorationSet.empty;
38
+ }
35
39
  let titleHasContent = false;
36
40
  let titlePos = -1;
37
41
  let hasSubtitles = false;
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.8.10';
1
+ export const VERSION = '3.8.12';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -14,5 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { Plugin } from 'prosemirror-state';
17
- declare const _default: () => Plugin<null>;
17
+ import { EditorProps } from '../configs/ManuscriptsEditor';
18
+ declare const _default: (props: EditorProps) => Plugin<null>;
18
19
  export default _default;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.8.10";
1
+ export declare const VERSION = "3.8.12";
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.8.10",
4
+ "version": "3.8.12",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -38,7 +38,7 @@
38
38
  "@citation-js/plugin-ris": "0.7.18",
39
39
  "@iarna/word-count": "1.1.2",
40
40
  "@manuscripts/json-schema": "2.2.12",
41
- "@manuscripts/style-guide": "3.4.1",
41
+ "@manuscripts/style-guide": "3.4.2",
42
42
  "@manuscripts/track-changes-plugin": "2.2.3",
43
43
  "@manuscripts/transform": "4.3.18",
44
44
  "@popperjs/core": "2.11.8",