@manuscripts/body-editor 2.2.10 → 2.2.11-LEAN-3969.0
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 +7 -2
- package/dist/cjs/components/toolbar/LevelSelector.js +8 -4
- package/dist/cjs/configs/editor-views.js +2 -0
- package/dist/cjs/lib/context-menu.js +7 -6
- package/dist/cjs/plugins/section-category/section-category-utils.js +3 -0
- package/dist/cjs/plugins/section_title/index.js +2 -1
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/box_element.js +37 -0
- package/dist/cjs/views/section_title.js +5 -2
- package/dist/es/commands.js +7 -2
- package/dist/es/components/toolbar/LevelSelector.js +8 -4
- package/dist/es/configs/editor-views.js +2 -0
- package/dist/es/keys/misc.js +1 -1
- package/dist/es/lib/context-menu.js +8 -7
- package/dist/es/plugins/section-category/section-category-utils.js +3 -0
- package/dist/es/plugins/section_title/index.js +2 -1
- package/dist/es/versions.js +1 -1
- package/dist/es/views/box_element.js +30 -0
- package/dist/es/views/section_title.js +5 -2
- package/dist/types/configs/editor-views.d.ts +1 -0
- package/dist/types/versions.d.ts +1 -1
- package/dist/types/views/box_element.d.ts +23 -0
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +51 -5
- package/styles/Editor.css +8 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -86,11 +86,14 @@ const blockActive = (type) => (state) => {
|
|
|
86
86
|
};
|
|
87
87
|
exports.blockActive = blockActive;
|
|
88
88
|
const canInsert = (type) => (state) => {
|
|
89
|
+
var _a;
|
|
89
90
|
const { $from, $to } = state.selection;
|
|
90
91
|
if ($from.node().type === transform_1.schema.nodes.title && $from.pos === $to.pos) {
|
|
91
92
|
return false;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
+
const initDepth = ((_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) ||
|
|
95
|
+
0;
|
|
96
|
+
for (let d = $from.depth; d >= initDepth; d--) {
|
|
94
97
|
const index = $from.index(d);
|
|
95
98
|
if ($from.node(d).canReplaceWith(index, index, type)) {
|
|
96
99
|
return true;
|
|
@@ -504,7 +507,8 @@ const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
|
504
507
|
exports.insertGraphicalAbstract = insertGraphicalAbstract;
|
|
505
508
|
const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
506
509
|
const selection = state.selection;
|
|
507
|
-
if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.bibliography_section)(selection)
|
|
510
|
+
if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.bibliography_section)(selection) ||
|
|
511
|
+
(!subsection && (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection))) {
|
|
508
512
|
return false;
|
|
509
513
|
}
|
|
510
514
|
let pos;
|
|
@@ -924,6 +928,7 @@ const isCommentingAllowed = (type) => type === transform_1.schema.nodes.title ||
|
|
|
924
928
|
type === transform_1.schema.nodes.bibliography_item ||
|
|
925
929
|
type === transform_1.schema.nodes.footnotes_section ||
|
|
926
930
|
type === transform_1.schema.nodes.bibliography_section ||
|
|
931
|
+
type === transform_1.schema.nodes.box_element ||
|
|
927
932
|
type === transform_1.schema.nodes.graphical_abstract_section ||
|
|
928
933
|
type === transform_1.schema.nodes.keyword_group ||
|
|
929
934
|
type === transform_1.schema.nodes.paragraph ||
|
|
@@ -22,6 +22,7 @@ exports.LevelSelector = void 0;
|
|
|
22
22
|
const transform_1 = require("@manuscripts/transform");
|
|
23
23
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
24
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
25
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
25
26
|
const react_1 = __importDefault(require("react"));
|
|
26
27
|
const react_select_1 = __importDefault(require("react-select"));
|
|
27
28
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
@@ -40,7 +41,9 @@ const optionName = (nodeType, depth, listType) => {
|
|
|
40
41
|
const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
|
|
41
42
|
const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: (0, node_type_icons_1.nodeTypeIcon)(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth, props.listType)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
|
|
42
43
|
const buildOptions = (state, dispatch, view) => {
|
|
44
|
+
var _a;
|
|
43
45
|
const { doc, selection: { $from, $to }, schema, tr, } = state;
|
|
46
|
+
doc.resolve($from.index($from.depth - 1));
|
|
44
47
|
const { nodes } = schema;
|
|
45
48
|
if (!$from.sameParent($to)) {
|
|
46
49
|
return [];
|
|
@@ -49,6 +52,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
49
52
|
if (!parentElement) {
|
|
50
53
|
return [];
|
|
51
54
|
}
|
|
55
|
+
const depth = ((_a = (0, prosemirror_utils_1.findParentNodeOfType)(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) || 1;
|
|
52
56
|
const moveParagraphToNewSubsection = () => {
|
|
53
57
|
const paragraph = $from.node($from.depth);
|
|
54
58
|
const beforeParagraph = $from.before($from.depth);
|
|
@@ -131,7 +135,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
131
135
|
const $beforeParagraph = doc.resolve(beforeParagraph);
|
|
132
136
|
const beforeParagraphOffset = $beforeParagraph.parentOffset;
|
|
133
137
|
const afterParagraphOffset = beforeParagraphOffset + paragraph.nodeSize;
|
|
134
|
-
const sectionDepth = $from.depth -
|
|
138
|
+
const sectionDepth = $from.depth - depth;
|
|
135
139
|
const parentSection = $from.node(sectionDepth);
|
|
136
140
|
const startIndex = $from.index(sectionDepth);
|
|
137
141
|
const endIndex = $from.indexAfter(sectionDepth);
|
|
@@ -167,7 +171,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
167
171
|
const afterSectionTitle = $from.after($from.depth);
|
|
168
172
|
const $afterSectionTitle = doc.resolve(afterSectionTitle);
|
|
169
173
|
const afterSectionTitleOffset = $afterSectionTitle.parentOffset;
|
|
170
|
-
const sectionDepth = $from.depth -
|
|
174
|
+
const sectionDepth = $from.depth - depth;
|
|
171
175
|
const section = $from.node(sectionDepth);
|
|
172
176
|
const beforeSection = $from.before(sectionDepth);
|
|
173
177
|
const afterSection = $from.after(sectionDepth);
|
|
@@ -213,7 +217,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
213
217
|
const parentElementType = parentElement.node.type;
|
|
214
218
|
switch (parentElementType) {
|
|
215
219
|
case parentElementType.schema.nodes.section: {
|
|
216
|
-
const sectionDepth = Math.max(1, $from.depth -
|
|
220
|
+
const sectionDepth = Math.max(1, $from.depth - depth);
|
|
217
221
|
const parentSectionDepth = sectionDepth - 1;
|
|
218
222
|
const minimumDepth = Math.max(1, parentSectionDepth);
|
|
219
223
|
const beforeSection = $from.before(sectionDepth);
|
|
@@ -284,7 +288,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
284
288
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
285
289
|
}
|
|
286
290
|
case parentElementType.schema.nodes.paragraph: {
|
|
287
|
-
const sectionDepth = $from.depth -
|
|
291
|
+
const sectionDepth = $from.depth - depth;
|
|
288
292
|
const minimumDepth = Math.max(1, sectionDepth);
|
|
289
293
|
let parentSectionDepth = 0;
|
|
290
294
|
const typeOptions = [
|
|
@@ -22,6 +22,7 @@ const affiliations_1 = __importDefault(require("../views/affiliations"));
|
|
|
22
22
|
const author_notes_1 = __importDefault(require("../views/author_notes"));
|
|
23
23
|
const bibliography_element_1 = __importDefault(require("../views/bibliography_element"));
|
|
24
24
|
const blockquote_element_editable_1 = __importDefault(require("../views/blockquote_element_editable"));
|
|
25
|
+
const box_element_1 = __importDefault(require("../views/box_element"));
|
|
25
26
|
const citation_editable_1 = __importDefault(require("../views/citation_editable"));
|
|
26
27
|
const contributors_1 = __importDefault(require("../views/contributors"));
|
|
27
28
|
const cross_reference_editable_1 = __importDefault(require("../views/cross_reference_editable"));
|
|
@@ -56,6 +57,7 @@ exports.default = (props, dispatch) => {
|
|
|
56
57
|
title: (0, title_editable_1.default)(props, dispatch),
|
|
57
58
|
bibliography_element: (0, bibliography_element_1.default)(props, dispatch),
|
|
58
59
|
blockquote_element: (0, blockquote_element_editable_1.default)(props),
|
|
60
|
+
box_element: (0, box_element_1.default)(props),
|
|
59
61
|
citation: (0, citation_editable_1.default)(props, dispatch),
|
|
60
62
|
cross_reference: (0, cross_reference_editable_1.default)(props, dispatch),
|
|
61
63
|
contributors: (0, contributors_1.default)(props, dispatch),
|
|
@@ -30,6 +30,8 @@ const track_changes_utils_1 = require("./track-changes-utils");
|
|
|
30
30
|
const utils_1 = require("./utils");
|
|
31
31
|
const popper = new popper_1.PopperManager();
|
|
32
32
|
const readonlyTypes = [transform_1.schema.nodes.keywords, transform_1.schema.nodes.bibliography_element];
|
|
33
|
+
const isBoxElementSectionTitle = ($pos, node) => (0, transform_1.isSectionTitleNode)(node) &&
|
|
34
|
+
$pos.node($pos.depth - 1).type === transform_1.schema.nodes.box_element;
|
|
33
35
|
const sectionLevel = (depth) => {
|
|
34
36
|
switch (depth) {
|
|
35
37
|
case 1:
|
|
@@ -150,7 +152,8 @@ class ContextMenu {
|
|
|
150
152
|
const menu = document.createElement('div');
|
|
151
153
|
menu.className = 'menu';
|
|
152
154
|
const $pos = this.resolvePos();
|
|
153
|
-
const
|
|
155
|
+
const isBox = isBoxElementSectionTitle($pos, this.node);
|
|
156
|
+
const type = isBox ? transform_1.schema.nodes.box_element : this.node.type;
|
|
154
157
|
if (type === transform_1.schema.nodes.list) {
|
|
155
158
|
menu.appendChild(this.createMenuSection((section) => {
|
|
156
159
|
const actualAttrs = (0, track_changes_utils_1.getActualAttrs)(this.node);
|
|
@@ -338,14 +341,12 @@ class ContextMenu {
|
|
|
338
341
|
switch (nodeType.name) {
|
|
339
342
|
case 'section_title': {
|
|
340
343
|
const $pos = this.resolvePos();
|
|
341
|
-
this.view.dispatch(this.view.state.tr
|
|
342
|
-
.setMeta('fromContextMenu', true)
|
|
343
|
-
.delete($pos.before(), $pos.after()));
|
|
344
|
+
this.view.dispatch(this.view.state.tr.delete($pos.before(), $pos.after()));
|
|
344
345
|
break;
|
|
345
346
|
}
|
|
346
|
-
case '
|
|
347
|
+
case 'box_element': {
|
|
347
348
|
const $pos = this.resolvePos();
|
|
348
|
-
this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth), $pos.after($pos.depth)));
|
|
349
|
+
this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth - 1), $pos.after($pos.depth - 1)));
|
|
349
350
|
break;
|
|
350
351
|
}
|
|
351
352
|
default: {
|
|
@@ -87,6 +87,9 @@ function buildPluginState(state, props) {
|
|
|
87
87
|
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => createButton(view, props, node, pos, attrs.category, can === null || can === void 0 ? void 0 : can.editArticle)));
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
if (node.type === transform_1.schema.nodes.box_element) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
90
93
|
});
|
|
91
94
|
return { decorations: prosemirror_view_1.DecorationSet.create(state.doc, decorations) };
|
|
92
95
|
}
|
|
@@ -10,7 +10,8 @@ const autocompletion_1 = require("./autocompletion");
|
|
|
10
10
|
exports.sectionTitleKey = new prosemirror_state_1.PluginKey('sectionNumbering');
|
|
11
11
|
const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
|
|
12
12
|
node.forEach((childNode, offset) => {
|
|
13
|
-
if (childNode.type === transform_1.schema.nodes.section
|
|
13
|
+
if ((childNode.type === transform_1.schema.nodes.section ||
|
|
14
|
+
childNode.type === transform_1.schema.nodes.box_element) &&
|
|
14
15
|
!(0, track_changes_utils_1.isRejectedInsert)(childNode)) {
|
|
15
16
|
numbering[numbering.length - 1] += 1;
|
|
16
17
|
const sectionNumber = numbering.join('.');
|
package/dist/cjs/versions.js
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* © 2019 Atypon Systems LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.BoxElementView = void 0;
|
|
22
|
+
const block_view_1 = __importDefault(require("./block_view"));
|
|
23
|
+
const creators_1 = require("./creators");
|
|
24
|
+
class BoxElementView extends block_view_1.default {
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.elementType = 'div';
|
|
28
|
+
this.createElement = () => {
|
|
29
|
+
this.contentDOM = document.createElement(this.elementType);
|
|
30
|
+
this.contentDOM.className = 'block box-element';
|
|
31
|
+
this.contentDOM.setAttribute('id', this.node.attrs.id);
|
|
32
|
+
this.dom.appendChild(this.contentDOM);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.BoxElementView = BoxElementView;
|
|
37
|
+
exports.default = (0, creators_1.createNodeView)(BoxElementView);
|
|
@@ -34,7 +34,10 @@ class SectionTitleView extends block_view_1.default {
|
|
|
34
34
|
const sectionTitleState = section_title_1.sectionTitleKey.getState(this.view.state);
|
|
35
35
|
const parentSection = (0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, transform_1.schema.nodes.section);
|
|
36
36
|
const sectionNumber = sectionTitleState === null || sectionTitleState === void 0 ? void 0 : sectionTitleState.get(parentSection === null || parentSection === void 0 ? void 0 : parentSection.node.attrs.id);
|
|
37
|
-
|
|
37
|
+
let level = $pos.depth > 1 ? $pos.depth - 1 : $pos.depth;
|
|
38
|
+
if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, transform_1.schema.nodes.box_element)) {
|
|
39
|
+
level = level - 2;
|
|
40
|
+
}
|
|
38
41
|
if (this.node.childCount) {
|
|
39
42
|
this.contentDOM.classList.remove('empty-node');
|
|
40
43
|
}
|
|
@@ -42,7 +45,7 @@ class SectionTitleView extends block_view_1.default {
|
|
|
42
45
|
this.contentDOM.classList.add('empty-node');
|
|
43
46
|
this.contentDOM.setAttribute('data-placeholder', `${(0, context_menu_1.sectionLevel)(level)} heading`);
|
|
44
47
|
}
|
|
45
|
-
if (sectionTitleState) {
|
|
48
|
+
if (sectionTitleState && sectionNumber) {
|
|
46
49
|
this.contentDOM.dataset.sectionNumber = sectionNumber;
|
|
47
50
|
this.contentDOM.dataset.titleLevel = level.toString();
|
|
48
51
|
}
|
package/dist/es/commands.js
CHANGED
|
@@ -79,11 +79,14 @@ export const blockActive = (type) => (state) => {
|
|
|
79
79
|
return false;
|
|
80
80
|
};
|
|
81
81
|
export const canInsert = (type) => (state) => {
|
|
82
|
+
var _a;
|
|
82
83
|
const { $from, $to } = state.selection;
|
|
83
84
|
if ($from.node().type === schema.nodes.title && $from.pos === $to.pos) {
|
|
84
85
|
return false;
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
const initDepth = ((_a = findParentNodeOfType(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) ||
|
|
88
|
+
0;
|
|
89
|
+
for (let d = $from.depth; d >= initDepth; d--) {
|
|
87
90
|
const index = $from.index(d);
|
|
88
91
|
if ($from.node(d).canReplaceWith(index, index, type)) {
|
|
89
92
|
return true;
|
|
@@ -476,7 +479,8 @@ export const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
|
476
479
|
};
|
|
477
480
|
export const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
478
481
|
const selection = state.selection;
|
|
479
|
-
if (hasParentNodeOfType(schema.nodes.bibliography_section)(selection)
|
|
482
|
+
if (hasParentNodeOfType(schema.nodes.bibliography_section)(selection) ||
|
|
483
|
+
(!subsection && hasParentNodeOfType(schema.nodes.box_element)(selection))) {
|
|
480
484
|
return false;
|
|
481
485
|
}
|
|
482
486
|
let pos;
|
|
@@ -880,6 +884,7 @@ const isCommentingAllowed = (type) => type === schema.nodes.title ||
|
|
|
880
884
|
type === schema.nodes.bibliography_item ||
|
|
881
885
|
type === schema.nodes.footnotes_section ||
|
|
882
886
|
type === schema.nodes.bibliography_section ||
|
|
887
|
+
type === schema.nodes.box_element ||
|
|
883
888
|
type === schema.nodes.graphical_abstract_section ||
|
|
884
889
|
type === schema.nodes.keyword_group ||
|
|
885
890
|
type === schema.nodes.paragraph ||
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { generateNodeID, getListType, isSectionNodeType, nodeNames, } from '@manuscripts/transform';
|
|
17
17
|
import { Fragment } from 'prosemirror-model';
|
|
18
18
|
import { TextSelection } from 'prosemirror-state';
|
|
19
|
+
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
19
20
|
import React from 'react';
|
|
20
21
|
import Select from 'react-select';
|
|
21
22
|
import styled from 'styled-components';
|
|
@@ -34,7 +35,9 @@ const optionName = (nodeType, depth, listType) => {
|
|
|
34
35
|
const titleCase = (text) => text.replace(/\b([a-z])/g, (match) => match.toUpperCase());
|
|
35
36
|
const buildOption = (props) => (Object.assign(Object.assign({}, props), { icon: nodeTypeIcon(props.nodeType, props.listType), label: titleCase(optionName(props.nodeType, props.depth, props.listType)), isDisabled: Boolean(props.isDisabled), isSelected: Boolean(props.isSelected), isFocused: Boolean(props.isFocused) }));
|
|
36
37
|
const buildOptions = (state, dispatch, view) => {
|
|
38
|
+
var _a;
|
|
37
39
|
const { doc, selection: { $from, $to }, schema, tr, } = state;
|
|
40
|
+
doc.resolve($from.index($from.depth - 1));
|
|
38
41
|
const { nodes } = schema;
|
|
39
42
|
if (!$from.sameParent($to)) {
|
|
40
43
|
return [];
|
|
@@ -43,6 +46,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
43
46
|
if (!parentElement) {
|
|
44
47
|
return [];
|
|
45
48
|
}
|
|
49
|
+
const depth = ((_a = findParentNodeOfType(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) || 1;
|
|
46
50
|
const moveParagraphToNewSubsection = () => {
|
|
47
51
|
const paragraph = $from.node($from.depth);
|
|
48
52
|
const beforeParagraph = $from.before($from.depth);
|
|
@@ -125,7 +129,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
125
129
|
const $beforeParagraph = doc.resolve(beforeParagraph);
|
|
126
130
|
const beforeParagraphOffset = $beforeParagraph.parentOffset;
|
|
127
131
|
const afterParagraphOffset = beforeParagraphOffset + paragraph.nodeSize;
|
|
128
|
-
const sectionDepth = $from.depth -
|
|
132
|
+
const sectionDepth = $from.depth - depth;
|
|
129
133
|
const parentSection = $from.node(sectionDepth);
|
|
130
134
|
const startIndex = $from.index(sectionDepth);
|
|
131
135
|
const endIndex = $from.indexAfter(sectionDepth);
|
|
@@ -161,7 +165,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
161
165
|
const afterSectionTitle = $from.after($from.depth);
|
|
162
166
|
const $afterSectionTitle = doc.resolve(afterSectionTitle);
|
|
163
167
|
const afterSectionTitleOffset = $afterSectionTitle.parentOffset;
|
|
164
|
-
const sectionDepth = $from.depth -
|
|
168
|
+
const sectionDepth = $from.depth - depth;
|
|
165
169
|
const section = $from.node(sectionDepth);
|
|
166
170
|
const beforeSection = $from.before(sectionDepth);
|
|
167
171
|
const afterSection = $from.after(sectionDepth);
|
|
@@ -207,7 +211,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
207
211
|
const parentElementType = parentElement.node.type;
|
|
208
212
|
switch (parentElementType) {
|
|
209
213
|
case parentElementType.schema.nodes.section: {
|
|
210
|
-
const sectionDepth = Math.max(1, $from.depth -
|
|
214
|
+
const sectionDepth = Math.max(1, $from.depth - depth);
|
|
211
215
|
const parentSectionDepth = sectionDepth - 1;
|
|
212
216
|
const minimumDepth = Math.max(1, parentSectionDepth);
|
|
213
217
|
const beforeSection = $from.before(sectionDepth);
|
|
@@ -278,7 +282,7 @@ const buildOptions = (state, dispatch, view) => {
|
|
|
278
282
|
return [{ options: typeOptions }, { options: sectionOptions }];
|
|
279
283
|
}
|
|
280
284
|
case parentElementType.schema.nodes.paragraph: {
|
|
281
|
-
const sectionDepth = $from.depth -
|
|
285
|
+
const sectionDepth = $from.depth - depth;
|
|
282
286
|
const minimumDepth = Math.max(1, sectionDepth);
|
|
283
287
|
let parentSectionDepth = 0;
|
|
284
288
|
const typeOptions = [
|
|
@@ -17,6 +17,7 @@ import affiliations from '../views/affiliations';
|
|
|
17
17
|
import authorNotes from '../views/author_notes';
|
|
18
18
|
import bibliographyElement from '../views/bibliography_element';
|
|
19
19
|
import blockquoteElement from '../views/blockquote_element_editable';
|
|
20
|
+
import boxElement from '../views/box_element';
|
|
20
21
|
import citation from '../views/citation_editable';
|
|
21
22
|
import contributors from '../views/contributors';
|
|
22
23
|
import crossReference from '../views/cross_reference_editable';
|
|
@@ -51,6 +52,7 @@ export default (props, dispatch) => {
|
|
|
51
52
|
title: title(props, dispatch),
|
|
52
53
|
bibliography_element: bibliographyElement(props, dispatch),
|
|
53
54
|
blockquote_element: blockquoteElement(props),
|
|
55
|
+
box_element: boxElement(props),
|
|
54
56
|
citation: citation(props, dispatch),
|
|
55
57
|
cross_reference: crossReference(props, dispatch),
|
|
56
58
|
contributors: contributors(props, dispatch),
|
package/dist/es/keys/misc.js
CHANGED
|
@@ -18,7 +18,7 @@ import { chainCommands, createParagraphNear, exitCode, joinDown, joinUp, lift, l
|
|
|
18
18
|
import { redo, undo } from 'prosemirror-history';
|
|
19
19
|
import { undoInputRule } from 'prosemirror-inputrules';
|
|
20
20
|
import { goToNextCell } from 'prosemirror-tables';
|
|
21
|
-
import {
|
|
21
|
+
import { addToStart, autoComplete, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
|
|
22
22
|
const customKeymap = {
|
|
23
23
|
Backspace: chainCommands(undoInputRule, ignoreAtomBlockNodeBackward, ignoreMetaNodeBackspaceCommand),
|
|
24
24
|
Delete: ignoreAtomBlockNodeForward,
|
|
@@ -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 { getListType, isInBibliographySection, nodeNames, schema, } from '@manuscripts/transform';
|
|
16
|
+
import { getListType, isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { findChildrenByType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
18
18
|
import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralFootnote, insertTableFootnote, } from '../commands';
|
|
19
19
|
import { FootnotesSelector } from '../components/views/FootnotesSelector';
|
|
@@ -24,6 +24,8 @@ import { getActualAttrs, isDeleted, isRejectedInsert, } from './track-changes-ut
|
|
|
24
24
|
import { getChildOfType, isChildOfNodeTypes } from './utils';
|
|
25
25
|
const popper = new PopperManager();
|
|
26
26
|
const readonlyTypes = [schema.nodes.keywords, schema.nodes.bibliography_element];
|
|
27
|
+
const isBoxElementSectionTitle = ($pos, node) => isSectionTitleNode(node) &&
|
|
28
|
+
$pos.node($pos.depth - 1).type === schema.nodes.box_element;
|
|
27
29
|
export const sectionLevel = (depth) => {
|
|
28
30
|
switch (depth) {
|
|
29
31
|
case 1:
|
|
@@ -143,7 +145,8 @@ export class ContextMenu {
|
|
|
143
145
|
const menu = document.createElement('div');
|
|
144
146
|
menu.className = 'menu';
|
|
145
147
|
const $pos = this.resolvePos();
|
|
146
|
-
const
|
|
148
|
+
const isBox = isBoxElementSectionTitle($pos, this.node);
|
|
149
|
+
const type = isBox ? schema.nodes.box_element : this.node.type;
|
|
147
150
|
if (type === schema.nodes.list) {
|
|
148
151
|
menu.appendChild(this.createMenuSection((section) => {
|
|
149
152
|
const actualAttrs = getActualAttrs(this.node);
|
|
@@ -331,14 +334,12 @@ export class ContextMenu {
|
|
|
331
334
|
switch (nodeType.name) {
|
|
332
335
|
case 'section_title': {
|
|
333
336
|
const $pos = this.resolvePos();
|
|
334
|
-
this.view.dispatch(this.view.state.tr
|
|
335
|
-
.setMeta('fromContextMenu', true)
|
|
336
|
-
.delete($pos.before(), $pos.after()));
|
|
337
|
+
this.view.dispatch(this.view.state.tr.delete($pos.before(), $pos.after()));
|
|
337
338
|
break;
|
|
338
339
|
}
|
|
339
|
-
case '
|
|
340
|
+
case 'box_element': {
|
|
340
341
|
const $pos = this.resolvePos();
|
|
341
|
-
this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth), $pos.after($pos.depth)));
|
|
342
|
+
this.view.dispatch(this.view.state.tr.delete($pos.before($pos.depth - 1), $pos.after($pos.depth - 1)));
|
|
342
343
|
break;
|
|
343
344
|
}
|
|
344
345
|
default: {
|
|
@@ -84,6 +84,9 @@ export function buildPluginState(state, props) {
|
|
|
84
84
|
decorations.push(Decoration.widget(pos + 1, (view) => createButton(view, props, node, pos, attrs.category, can === null || can === void 0 ? void 0 : can.editArticle)));
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
if (node.type === schema.nodes.box_element) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
87
90
|
});
|
|
88
91
|
return { decorations: DecorationSet.create(state.doc, decorations) };
|
|
89
92
|
}
|
|
@@ -7,7 +7,8 @@ import { checkForCompletion } from './autocompletion';
|
|
|
7
7
|
export const sectionTitleKey = new PluginKey('sectionNumbering');
|
|
8
8
|
const calculateSectionLevels = (node, startPos, sectionNumberMap, numbering = [0]) => {
|
|
9
9
|
node.forEach((childNode, offset) => {
|
|
10
|
-
if (childNode.type === schema.nodes.section
|
|
10
|
+
if ((childNode.type === schema.nodes.section ||
|
|
11
|
+
childNode.type === schema.nodes.box_element) &&
|
|
11
12
|
!isRejectedInsert(childNode)) {
|
|
12
13
|
numbering[numbering.length - 1] += 1;
|
|
13
14
|
const sectionNumber = numbering.join('.');
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.2.
|
|
1
|
+
export const VERSION = '2.2.11-LEAN-3969.0';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import BlockView from './block_view';
|
|
17
|
+
import { createNodeView } from './creators';
|
|
18
|
+
export class BoxElementView extends BlockView {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.elementType = 'div';
|
|
22
|
+
this.createElement = () => {
|
|
23
|
+
this.contentDOM = document.createElement(this.elementType);
|
|
24
|
+
this.contentDOM.className = 'block box-element';
|
|
25
|
+
this.contentDOM.setAttribute('id', this.node.attrs.id);
|
|
26
|
+
this.dom.appendChild(this.contentDOM);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export default createNodeView(BoxElementView);
|
|
@@ -28,7 +28,10 @@ export class SectionTitleView extends BlockView {
|
|
|
28
28
|
const sectionTitleState = sectionTitleKey.getState(this.view.state);
|
|
29
29
|
const parentSection = findParentNodeOfTypeClosestToPos($pos, schema.nodes.section);
|
|
30
30
|
const sectionNumber = sectionTitleState === null || sectionTitleState === void 0 ? void 0 : sectionTitleState.get(parentSection === null || parentSection === void 0 ? void 0 : parentSection.node.attrs.id);
|
|
31
|
-
|
|
31
|
+
let level = $pos.depth > 1 ? $pos.depth - 1 : $pos.depth;
|
|
32
|
+
if (findParentNodeOfTypeClosestToPos($pos, schema.nodes.box_element)) {
|
|
33
|
+
level = level - 2;
|
|
34
|
+
}
|
|
32
35
|
if (this.node.childCount) {
|
|
33
36
|
this.contentDOM.classList.remove('empty-node');
|
|
34
37
|
}
|
|
@@ -36,7 +39,7 @@ export class SectionTitleView extends BlockView {
|
|
|
36
39
|
this.contentDOM.classList.add('empty-node');
|
|
37
40
|
this.contentDOM.setAttribute('data-placeholder', `${sectionLevel(level)} heading`);
|
|
38
41
|
}
|
|
39
|
-
if (sectionTitleState) {
|
|
42
|
+
if (sectionTitleState && sectionNumber) {
|
|
40
43
|
this.contentDOM.dataset.sectionNumber = sectionNumber;
|
|
41
44
|
this.contentDOM.dataset.titleLevel = level.toString();
|
|
42
45
|
}
|
|
@@ -53,6 +53,7 @@ declare const _default: (props: EditorProps, dispatch: Dispatch) => {
|
|
|
53
53
|
destroy: () => void;
|
|
54
54
|
handleDecorations: (decorations: readonly import("prosemirror-view").Decoration[]) => void;
|
|
55
55
|
} & import("../views/blockquote_element").BlockquoteElementView>;
|
|
56
|
+
box_element: import("../types").NodeViewCreator<import("../views/box_element").BoxElementView>;
|
|
56
57
|
citation: import("../types").NodeViewCreator<import("../views/citation_editable").CitationEditableView>;
|
|
57
58
|
cross_reference: import("../types").NodeViewCreator<import("../views/cross_reference_editable").CrossReferenceEditableView>;
|
|
58
59
|
contributors: import("../types").NodeViewCreator<import("../views/contributors").ContributorsView>;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.2.
|
|
1
|
+
export declare const VERSION = "2.2.11-LEAN-3969.0";
|
|
2
2
|
export declare const MATHJAX_VERSION = "3.2.2";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* © 2019 Atypon Systems LLC
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { ManuscriptNode } from '@manuscripts/transform';
|
|
17
|
+
import BlockView from './block_view';
|
|
18
|
+
export declare class BoxElementView extends BlockView<ManuscriptNode> {
|
|
19
|
+
elementType: string;
|
|
20
|
+
createElement: () => void;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: (props: import("./base_node_view").BaseNodeProps, dispatch?: import("..").Dispatch | undefined) => import("../types").NodeViewCreator<BoxElementView>;
|
|
23
|
+
export default _default;
|
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.2.
|
|
4
|
+
"version": "2.2.11-LEAN-3969.0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
35
|
"@manuscripts/style-guide": "2.0.21",
|
|
36
36
|
"@manuscripts/track-changes-plugin": "1.7.23",
|
|
37
|
-
"@manuscripts/transform": "3.0.0",
|
|
37
|
+
"@manuscripts/transform": "3.0.1-LEAN-3969.0",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|
|
@@ -10,14 +10,24 @@
|
|
|
10
10
|
content: attr(data-section-number) '. ';
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
.ProseMirror > div.body .block-box_element .box-element section:not(.toc)
|
|
14
|
+
.block-section_title h1.empty-node[data-placeholder]::before {
|
|
15
|
+
content: attr(data-placeholder);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ProseMirror > div.body .block-box_element .box-element section:not(.toc)
|
|
19
|
+
.block-section_title h1::before {
|
|
20
|
+
content: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
.ProseMirror > div .block-section_title > h1 {
|
|
14
24
|
font-size: 16pt !important;
|
|
15
25
|
font-style: normal !important;
|
|
16
26
|
font-weight: bold !important;
|
|
17
27
|
color: #000 !important;
|
|
18
28
|
text-align: left;
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
padding-top: 8pt !important;
|
|
30
|
+
padding-bottom: 5pt !important;
|
|
21
31
|
line-height: 1.5;
|
|
22
32
|
text-indent: 0pt;
|
|
23
33
|
display: inline;
|
|
@@ -60,8 +70,8 @@
|
|
|
60
70
|
font-weight: normal !important;
|
|
61
71
|
color: #353535 !important;
|
|
62
72
|
text-align: left !important;
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
padding-top: 10pt !important;
|
|
74
|
+
padding-bottom: 10pt !important;
|
|
65
75
|
line-height: 2 !important;
|
|
66
76
|
text-indent: 0pt !important;
|
|
67
77
|
}
|
|
@@ -131,6 +141,37 @@
|
|
|
131
141
|
text-align: center !important;
|
|
132
142
|
}
|
|
133
143
|
|
|
144
|
+
.ProseMirror .block-container.block-box_element {
|
|
145
|
+
grid-template-columns: auto;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.ProseMirror .block-container.block-box_element > .block.box-element {
|
|
149
|
+
position: relative;
|
|
150
|
+
display: grid;
|
|
151
|
+
grid-template-columns: auto;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.ProseMirror .box-element .block-container .block {
|
|
155
|
+
background: #FAFAFA;
|
|
156
|
+
padding-left: 12px;
|
|
157
|
+
border-left: 2px solid #E2E2E2;
|
|
158
|
+
border-right: 2px solid #E2E2E2;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.ProseMirror .box-element::after {
|
|
162
|
+
content: ' ';
|
|
163
|
+
margin-left: 52px;
|
|
164
|
+
margin-right: 52px;
|
|
165
|
+
border-top: 2px solid #E2E2E2;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.box-element figcaption {
|
|
169
|
+
margin-left: 54px;
|
|
170
|
+
margin-right: 54px;
|
|
171
|
+
padding-bottom: 6px;
|
|
172
|
+
border-bottom: 2px solid #E2E2E2;
|
|
173
|
+
}
|
|
174
|
+
|
|
134
175
|
.unsupported-format-label {
|
|
135
176
|
font-size: 140%;
|
|
136
177
|
line-height: 1.3;
|
|
@@ -395,12 +436,17 @@ span.comment-marker {
|
|
|
395
436
|
width: auto;
|
|
396
437
|
}
|
|
397
438
|
.author-notes > .block-section_title > .block-gutter,
|
|
398
|
-
.keywords > .block-section_title > .block-gutter
|
|
439
|
+
.keywords > .block-section_title > .block-gutter,
|
|
440
|
+
.block-box_element > .block-gutter {
|
|
399
441
|
display: flex;
|
|
400
442
|
justify-content: flex-end;
|
|
401
443
|
margin-top: 0;
|
|
402
444
|
}
|
|
403
445
|
|
|
446
|
+
.block-box_element > .block-gutter {
|
|
447
|
+
margin-top: 14px;
|
|
448
|
+
}
|
|
449
|
+
|
|
404
450
|
.author-notes > .block-section_title > .block,
|
|
405
451
|
.keywords > .block-section_title > .block {
|
|
406
452
|
align-items: center;
|
package/styles/Editor.css
CHANGED
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
word-wrap: break-word;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
.ProseMirror .block-table_element figcaption {
|
|
299
|
+
.ProseMirror .block-table_element figcaption, .block-box_element figcaption {
|
|
300
300
|
text-align: left;
|
|
301
301
|
}
|
|
302
302
|
|
|
@@ -666,7 +666,12 @@
|
|
|
666
666
|
margin-top: 16px;
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
-
.ProseMirror .block-container:not(.block-section):hover .block-gutter {
|
|
669
|
+
.ProseMirror .block-container:not(.block-section, .block-box_element):hover .block-gutter {
|
|
670
|
+
opacity: 1;
|
|
671
|
+
z-index: 2;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.ProseMirror .block-box_element:hover > .block-gutter {
|
|
670
675
|
opacity: 1;
|
|
671
676
|
z-index: 2;
|
|
672
677
|
}
|
|
@@ -1055,4 +1060,4 @@
|
|
|
1055
1060
|
}
|
|
1056
1061
|
.highlight {
|
|
1057
1062
|
background-color: #ffeebf !important;
|
|
1058
|
-
}
|
|
1063
|
+
}
|