@manuscripts/body-editor 3.2.14 → 3.2.15

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.
@@ -34,6 +34,7 @@ const dnd_1 = require("../../lib/dnd");
34
34
  const track_changes_utils_1 = require("../../lib/track-changes-utils");
35
35
  const utils_1 = require("../../lib/utils");
36
36
  const node_type_icons_1 = require("../../node-type-icons");
37
+ const section_title_1 = require("../../plugins/section_title");
37
38
  const Outline_1 = require("./Outline");
38
39
  const excludedTypes = [
39
40
  transform_1.schema.nodes.table,
@@ -104,13 +105,22 @@ const DraggableTree = ({ tree, view, depth, can, }) => {
104
105
  ? (0, utils_1.isBodyLocked)(view.state) || !can?.editArticle
105
106
  : true;
106
107
  const { node, items, parent } = tree;
108
+ const sectionTitleState = view
109
+ ? section_title_1.sectionTitleKey.getState(view.state)
110
+ : undefined;
107
111
  const itemText = (node) => {
108
112
  const text = (0, transform_1.nodeTitle)(node);
113
+ let sectionNumber = node.type.name === 'section' && sectionTitleState
114
+ ? sectionTitleState.get(node.attrs.id) ?? ''
115
+ : '';
116
+ sectionNumber = sectionNumber ? `${sectionNumber}.` : '';
109
117
  if (text) {
110
- return text.trim();
118
+ return `${sectionNumber}${sectionNumber ? ' ' : ''}${text.trim()}`;
111
119
  }
112
120
  const placeholder = (0, transform_1.nodeTitlePlaceholder)(node.type);
113
- return react_1.default.createElement(Outline_1.OutlineItemPlaceholder, null, placeholder);
121
+ return (react_1.default.createElement(Outline_1.OutlineItemPlaceholder, null,
122
+ sectionNumber && `${sectionNumber} `,
123
+ placeholder));
114
124
  };
115
125
  const toggleOpen = () => {
116
126
  setOpen(!isOpen);
@@ -59,6 +59,6 @@ const ManuscriptOutline = (props) => {
59
59
  setValues(undefined);
60
60
  }
61
61
  }, [debouncedProps, props.can]);
62
- return values ? react_1.default.createElement(DraggableTree_1.DraggableTree, { ...values, depth: 0 }) : null;
62
+ return values && values.view ? react_1.default.createElement(DraggableTree_1.DraggableTree, { ...values, depth: 0 }) : null;
63
63
  };
64
64
  exports.ManuscriptOutline = ManuscriptOutline;
@@ -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.14';
4
+ exports.VERSION = '3.2.15';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -8,6 +8,7 @@ import { getDropSide } from '../../lib/dnd';
8
8
  import { isDeleted } from '../../lib/track-changes-utils';
9
9
  import { isBodyLocked } from '../../lib/utils';
10
10
  import { nodeTypeIcon } from '../../node-type-icons';
11
+ import { sectionTitleKey } from '../../plugins/section_title';
11
12
  import { Outline, OutlineItem, OutlineItemArrow, OutlineItemIcon, OutlineItemLink, OutlineItemLinkText, OutlineItemNoArrow, OutlineItemPlaceholder, } from './Outline';
12
13
  const excludedTypes = [
13
14
  schema.nodes.table,
@@ -77,13 +78,22 @@ export const DraggableTree = ({ tree, view, depth, can, }) => {
77
78
  ? isBodyLocked(view.state) || !can?.editArticle
78
79
  : true;
79
80
  const { node, items, parent } = tree;
81
+ const sectionTitleState = view
82
+ ? sectionTitleKey.getState(view.state)
83
+ : undefined;
80
84
  const itemText = (node) => {
81
85
  const text = nodeTitle(node);
86
+ let sectionNumber = node.type.name === 'section' && sectionTitleState
87
+ ? sectionTitleState.get(node.attrs.id) ?? ''
88
+ : '';
89
+ sectionNumber = sectionNumber ? `${sectionNumber}.` : '';
82
90
  if (text) {
83
- return text.trim();
91
+ return `${sectionNumber}${sectionNumber ? ' ' : ''}${text.trim()}`;
84
92
  }
85
93
  const placeholder = nodeTitlePlaceholder(node.type);
86
- return React.createElement(OutlineItemPlaceholder, null, placeholder);
94
+ return (React.createElement(OutlineItemPlaceholder, null,
95
+ sectionNumber && `${sectionNumber} `,
96
+ placeholder));
87
97
  };
88
98
  const toggleOpen = () => {
89
99
  setOpen(!isOpen);
@@ -33,5 +33,5 @@ export const ManuscriptOutline = (props) => {
33
33
  setValues(undefined);
34
34
  }
35
35
  }, [debouncedProps, props.can]);
36
- return values ? React.createElement(DraggableTree, { ...values, depth: 0 }) : null;
36
+ return values && values.view ? React.createElement(DraggableTree, { ...values, depth: 0 }) : null;
37
37
  };
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.14';
1
+ export const VERSION = '3.2.15';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.14";
1
+ export declare const VERSION = "3.2.15";
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.14",
4
+ "version": "3.2.15",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",