@manuscripts/body-editor 3.2.13 → 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.
- package/dist/cjs/commands.js +2 -2
- package/dist/cjs/components/outline/DraggableTree.js +12 -2
- package/dist/cjs/components/outline/ManuscriptOutline.js +1 -1
- package/dist/cjs/lib/utils.js +10 -1
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +3 -3
- package/dist/es/components/outline/DraggableTree.js +12 -2
- package/dist/es/components/outline/ManuscriptOutline.js +1 -1
- package/dist/es/lib/utils.js +8 -0
- package/dist/es/versions.js +1 -1
- package/dist/types/lib/utils.d.ts +5 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/commands.js
CHANGED
|
@@ -689,7 +689,7 @@ const insertContributors = (state, dispatch, view) => {
|
|
|
689
689
|
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.contributors, true)) {
|
|
690
690
|
return false;
|
|
691
691
|
}
|
|
692
|
-
const title = (0,
|
|
692
|
+
const title = (0, utils_1.getLastTitleNode)(state);
|
|
693
693
|
const pos = title.pos + title.node.nodeSize;
|
|
694
694
|
const contributors = state.schema.nodes.contributors.create({
|
|
695
695
|
id: '',
|
|
@@ -709,7 +709,7 @@ const insertAffiliation = (state, dispatch, view) => {
|
|
|
709
709
|
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.affiliations, true)) {
|
|
710
710
|
return false;
|
|
711
711
|
}
|
|
712
|
-
const title = (0,
|
|
712
|
+
const title = (0, utils_1.getLastTitleNode)(state);
|
|
713
713
|
let pos = title.pos + title.node.nodeSize;
|
|
714
714
|
const contributors = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.contributors)[0];
|
|
715
715
|
if (contributors) {
|
|
@@ -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,
|
|
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;
|
package/dist/cjs/lib/utils.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getInsertPos = exports.createToggleButton = exports.isEditAllowed = exports.isBodyLocked = exports.cleanItemValues = exports.shouldRenderField = exports.hasParent = exports.isNotNull = exports.createHeader = exports.isSelectionInBody = exports.isSelectionInNode = exports.isChildOfNodeTypes = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
|
|
18
|
+
exports.getLastTitleNode = exports.getInsertPos = exports.createToggleButton = exports.isEditAllowed = exports.isBodyLocked = exports.cleanItemValues = exports.shouldRenderField = exports.hasParent = exports.isNotNull = exports.createHeader = exports.isSelectionInBody = exports.isSelectionInNode = exports.isChildOfNodeTypes = exports.findParentElement = exports.findParentSection = exports.findParentNodeWithIdValue = exports.findParentNodeWithId = exports.getChildOfType = exports.getMatchingDescendant = exports.getMatchingChild = exports.iterateChildren = void 0;
|
|
19
19
|
const transform_1 = require("@manuscripts/transform");
|
|
20
20
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
21
21
|
const config_1 = require("../components/references/ReferenceForm/config");
|
|
@@ -170,3 +170,12 @@ const getInsertPos = (type, parent, pos) => {
|
|
|
170
170
|
return insertPos;
|
|
171
171
|
};
|
|
172
172
|
exports.getInsertPos = getInsertPos;
|
|
173
|
+
const getLastTitleNode = (state) => {
|
|
174
|
+
const altTitleNode = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.alt_titles)[0];
|
|
175
|
+
if (altTitleNode) {
|
|
176
|
+
return altTitleNode;
|
|
177
|
+
}
|
|
178
|
+
const titleNode = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.title)[0];
|
|
179
|
+
return titleNode;
|
|
180
|
+
};
|
|
181
|
+
exports.getLastTitleNode = getLastTitleNode;
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -27,7 +27,7 @@ import { findAbstractsNode, findBackmatter, findBibliographySection, findBody, f
|
|
|
27
27
|
import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, } from './lib/footnotes';
|
|
28
28
|
import { findWordBoundaries, isNodeOfType, nearestAncestor, } from './lib/helpers';
|
|
29
29
|
import { isDeleted } from './lib/track-changes-utils';
|
|
30
|
-
import { findParentNodeWithId, getChildOfType, getInsertPos, isBodyLocked, } from './lib/utils';
|
|
30
|
+
import { findParentNodeWithId, getChildOfType, getInsertPos, getLastTitleNode, isBodyLocked, } from './lib/utils';
|
|
31
31
|
import { expandAccessibilitySection } from './plugins/accessibility_element';
|
|
32
32
|
import { setCommentSelection } from './plugins/comments';
|
|
33
33
|
import { getEditorProps } from './plugins/editor-props';
|
|
@@ -654,7 +654,7 @@ export const insertContributors = (state, dispatch, view) => {
|
|
|
654
654
|
if (getChildOfType(state.doc, schema.nodes.contributors, true)) {
|
|
655
655
|
return false;
|
|
656
656
|
}
|
|
657
|
-
const title =
|
|
657
|
+
const title = getLastTitleNode(state);
|
|
658
658
|
const pos = title.pos + title.node.nodeSize;
|
|
659
659
|
const contributors = state.schema.nodes.contributors.create({
|
|
660
660
|
id: '',
|
|
@@ -673,7 +673,7 @@ export const insertAffiliation = (state, dispatch, view) => {
|
|
|
673
673
|
if (getChildOfType(state.doc, schema.nodes.affiliations, true)) {
|
|
674
674
|
return false;
|
|
675
675
|
}
|
|
676
|
-
const title =
|
|
676
|
+
const title = getLastTitleNode(state);
|
|
677
677
|
let pos = title.pos + title.node.nodeSize;
|
|
678
678
|
const contributors = findChildrenByType(state.doc, state.schema.nodes.contributors)[0];
|
|
679
679
|
if (contributors) {
|
|
@@ -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,
|
|
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
|
};
|
package/dist/es/lib/utils.js
CHANGED
|
@@ -150,3 +150,11 @@ export const getInsertPos = (type, parent, pos) => {
|
|
|
150
150
|
});
|
|
151
151
|
return insertPos;
|
|
152
152
|
};
|
|
153
|
+
export const getLastTitleNode = (state) => {
|
|
154
|
+
const altTitleNode = findChildrenByType(state.doc, state.schema.nodes.alt_titles)[0];
|
|
155
|
+
if (altTitleNode) {
|
|
156
|
+
return altTitleNode;
|
|
157
|
+
}
|
|
158
|
+
const titleNode = findChildrenByType(state.doc, state.schema.nodes.title)[0];
|
|
159
|
+
return titleNode;
|
|
160
|
+
};
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.2.
|
|
1
|
+
export const VERSION = '3.2.15';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { BibliographyItemAttrs, BibliographyItemType, ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
|
|
16
|
+
import { BibliographyItemAttrs, BibliographyItemType, ManuscriptEditorState, ManuscriptNode, ManuscriptNodeType } from '@manuscripts/transform';
|
|
17
17
|
import { Node as ProseMirrorNode, NodeType, ResolvedPos } from 'prosemirror-model';
|
|
18
18
|
import { EditorState, Selection } from 'prosemirror-state';
|
|
19
19
|
export declare function iterateChildren(node: ManuscriptNode, recurse?: boolean): Iterable<ManuscriptNode>;
|
|
@@ -36,3 +36,7 @@ export declare const isBodyLocked: (state: EditorState) => boolean;
|
|
|
36
36
|
export declare const isEditAllowed: (state: EditorState) => boolean;
|
|
37
37
|
export declare const createToggleButton: (listener: () => void) => HTMLButtonElement;
|
|
38
38
|
export declare const getInsertPos: (type: ManuscriptNodeType, parent: ManuscriptNode, pos: number) => number;
|
|
39
|
+
export declare const getLastTitleNode: (state: ManuscriptEditorState) => {
|
|
40
|
+
node: ProseMirrorNode;
|
|
41
|
+
pos: number;
|
|
42
|
+
};
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.2.
|
|
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.
|
|
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",
|