@manuscripts/body-editor 3.5.4 → 3.5.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.
- package/dist/cjs/commands.js +8 -14
- package/dist/cjs/lib/doc.js +2 -2
- package/dist/cjs/menus.js +2 -1
- package/dist/cjs/plugins/placeholder.js +15 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/abstracts.js +1 -3
- package/dist/cjs/views/section_title.js +0 -9
- package/dist/es/commands.js +8 -14
- package/dist/es/lib/doc.js +2 -2
- package/dist/es/menus.js +2 -1
- package/dist/es/plugins/placeholder.js +15 -0
- package/dist/es/versions.js +1 -1
- package/dist/es/views/abstracts.js +1 -3
- package/dist/es/views/section_title.js +0 -9
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +0 -18
- package/styles/Editor.css +15 -0
package/dist/cjs/commands.js
CHANGED
|
@@ -118,6 +118,10 @@ const canInsert = (type) => (state) => {
|
|
|
118
118
|
(0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection))) {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
|
+
if (type === transform_1.schema.nodes.hero_image &&
|
|
122
|
+
(0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.hero_image, true)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
121
125
|
const initDepth = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection)?.depth ||
|
|
122
126
|
0;
|
|
123
127
|
for (let d = $from.depth; d >= initDepth; d--) {
|
|
@@ -579,7 +583,7 @@ const insertBoxElement = (state, dispatch) => {
|
|
|
579
583
|
const tr = state.tr.insert(position, node);
|
|
580
584
|
const sectionTitlePosition = position + 4;
|
|
581
585
|
tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, sectionTitlePosition));
|
|
582
|
-
dispatch(tr);
|
|
586
|
+
dispatch(tr.scrollIntoView());
|
|
583
587
|
}
|
|
584
588
|
return true;
|
|
585
589
|
};
|
|
@@ -769,15 +773,8 @@ const insertKeywords = (state, dispatch, view) => {
|
|
|
769
773
|
if ((0, utils_1.getChildOfType)(state.doc, transform_1.schema.nodes.keywords, true)) {
|
|
770
774
|
return false;
|
|
771
775
|
}
|
|
772
|
-
const supplements = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.supplements)[0];
|
|
773
776
|
const abstracts = (0, prosemirror_utils_1.findChildrenByType)(state.doc, state.schema.nodes.abstracts)[0];
|
|
774
|
-
|
|
775
|
-
if (supplements) {
|
|
776
|
-
pos = supplements.pos + supplements.node.nodeSize;
|
|
777
|
-
}
|
|
778
|
-
else {
|
|
779
|
-
pos = abstracts.pos;
|
|
780
|
-
}
|
|
777
|
+
const pos = abstracts.pos;
|
|
781
778
|
const keywords = transform_1.schema.nodes.keywords.createAndFill({}, [
|
|
782
779
|
transform_1.schema.nodes.section_title.create({}, transform_1.schema.text('Keywords')),
|
|
783
780
|
transform_1.schema.nodes.keywords_element.create({}, [
|
|
@@ -1292,11 +1289,8 @@ const createHeroImage = (attrs) => transform_1.schema.nodes.hero_image.create({
|
|
|
1292
1289
|
transform_1.schema.nodes.long_desc.create(),
|
|
1293
1290
|
]);
|
|
1294
1291
|
const insertHeroImage = () => (state, dispatch, view) => {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
}
|
|
1298
|
-
const backmatter = (0, doc_1.findBackmatter)(state.doc);
|
|
1299
|
-
const position = backmatter.pos + backmatter.node.content.size + 1;
|
|
1292
|
+
const comments = (0, prosemirror_utils_1.findChildrenByType)(state.doc, transform_1.schema.nodes.comments)[0];
|
|
1293
|
+
const position = comments.pos;
|
|
1300
1294
|
view?.focus();
|
|
1301
1295
|
(0, exports.createBlock)(transform_1.schema.nodes.hero_image, position, state, dispatch);
|
|
1302
1296
|
return true;
|
package/dist/cjs/lib/doc.js
CHANGED
|
@@ -37,8 +37,8 @@ const insertSupplementsNode = (tr) => {
|
|
|
37
37
|
if (supplements) {
|
|
38
38
|
return supplements;
|
|
39
39
|
}
|
|
40
|
-
const
|
|
41
|
-
const pos =
|
|
40
|
+
const backmatter = (0, exports.findBackmatter)(doc);
|
|
41
|
+
const pos = backmatter.pos + backmatter.node.content.size + 1;
|
|
42
42
|
const node = transform_1.schema.nodes.supplements.createAndFill();
|
|
43
43
|
tr.insert(pos, node);
|
|
44
44
|
return {
|
package/dist/cjs/menus.js
CHANGED
|
@@ -256,7 +256,8 @@ const getEditorMenus = (editor) => {
|
|
|
256
256
|
{
|
|
257
257
|
id: 'insert-hero-image',
|
|
258
258
|
label: 'Hero Image',
|
|
259
|
-
isEnabled: (0, utils_1.isEditAllowed)(state) &&
|
|
259
|
+
isEnabled: (0, utils_1.isEditAllowed)(state) &&
|
|
260
|
+
isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.hero_image)),
|
|
260
261
|
run: doCommand((0, commands_1.insertHeroImage)()),
|
|
261
262
|
isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.hero_image),
|
|
262
263
|
},
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const transform_1 = require("@manuscripts/transform");
|
|
19
19
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
20
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
20
21
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
21
22
|
const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
22
23
|
const element = document.createElement('span');
|
|
@@ -55,6 +56,9 @@ const getParagraphPlaceholderText = (parent, node) => {
|
|
|
55
56
|
if ((0, transform_1.isFootnoteNode)(parent) || (0, transform_1.isGeneralTableFootnoteNode)(parent)) {
|
|
56
57
|
return 'Type new footnote here';
|
|
57
58
|
}
|
|
59
|
+
if (parent.type === transform_1.schema.nodes.trans_abstract) {
|
|
60
|
+
return 'Type here';
|
|
61
|
+
}
|
|
58
62
|
};
|
|
59
63
|
exports.default = () => new prosemirror_state_1.Plugin({
|
|
60
64
|
props: {
|
|
@@ -71,6 +75,17 @@ exports.default = () => new prosemirror_state_1.Plugin({
|
|
|
71
75
|
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, placeholderWidget(text)));
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
else if (node.type === node.type.schema.nodes.section_title) {
|
|
79
|
+
const $pos = state.doc.resolve(pos);
|
|
80
|
+
let placeholderText = 'Type heading here';
|
|
81
|
+
if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, transform_1.schema.nodes.box_element)) {
|
|
82
|
+
placeholderText = 'Optional box title...';
|
|
83
|
+
}
|
|
84
|
+
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, placeholderWidget(placeholderText)));
|
|
85
|
+
}
|
|
86
|
+
else if (node.type === node.type.schema.nodes.trans_abstract) {
|
|
87
|
+
decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, placeholderWidget('Type new abstract title here')));
|
|
88
|
+
}
|
|
74
89
|
else {
|
|
75
90
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {
|
|
76
91
|
class: 'empty-node',
|
package/dist/cjs/versions.js
CHANGED
|
@@ -29,9 +29,7 @@ class AbstractsView extends base_node_view_1.BaseNodeView {
|
|
|
29
29
|
const { schema } = state;
|
|
30
30
|
const documentLanguage = state.doc.attrs.primaryLanguageCode || 'en';
|
|
31
31
|
const sectionTitle = schema.nodes.section_title.create();
|
|
32
|
-
const paragraph = schema.nodes.paragraph.create(
|
|
33
|
-
placeholder: 'Type here',
|
|
34
|
-
});
|
|
32
|
+
const paragraph = schema.nodes.paragraph.create();
|
|
35
33
|
const transAbstractNode = schema.nodes.trans_abstract.create({
|
|
36
34
|
lang: documentLanguage,
|
|
37
35
|
}, [sectionTitle, paragraph]);
|
|
@@ -58,15 +58,6 @@ class SectionTitleView extends block_view_1.default {
|
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
this.contentDOM.classList.add('empty-node');
|
|
61
|
-
if ($pos.node($pos.depth - 1).type === transform_1.schema.nodes.box_element) {
|
|
62
|
-
this.contentDOM.setAttribute('data-placeholder', `Optional box title...`);
|
|
63
|
-
}
|
|
64
|
-
else if ($pos.node($pos.depth).type === transform_1.schema.nodes.trans_abstract) {
|
|
65
|
-
this.contentDOM.setAttribute('data-placeholder', `Type new abstract title here`);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.contentDOM.setAttribute('data-placeholder', `Type heading here`);
|
|
69
|
-
}
|
|
70
61
|
}
|
|
71
62
|
if (sectionTitleState && sectionNumber) {
|
|
72
63
|
this.contentDOM.dataset.sectionNumber = sectionNumber;
|
package/dist/es/commands.js
CHANGED
|
@@ -110,6 +110,10 @@ export const canInsert = (type) => (state) => {
|
|
|
110
110
|
hasParentNodeOfType(schema.nodes.box_element)(state.selection))) {
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
113
|
+
if (type === schema.nodes.hero_image &&
|
|
114
|
+
getChildOfType(state.doc, schema.nodes.hero_image, true)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
113
117
|
const initDepth = findParentNodeOfType(schema.nodes.box_element)(state.selection)?.depth ||
|
|
114
118
|
0;
|
|
115
119
|
for (let d = $from.depth; d >= initDepth; d--) {
|
|
@@ -549,7 +553,7 @@ export const insertBoxElement = (state, dispatch) => {
|
|
|
549
553
|
const tr = state.tr.insert(position, node);
|
|
550
554
|
const sectionTitlePosition = position + 4;
|
|
551
555
|
tr.setSelection(TextSelection.create(tr.doc, sectionTitlePosition));
|
|
552
|
-
dispatch(tr);
|
|
556
|
+
dispatch(tr.scrollIntoView());
|
|
553
557
|
}
|
|
554
558
|
return true;
|
|
555
559
|
};
|
|
@@ -731,15 +735,8 @@ export const insertKeywords = (state, dispatch, view) => {
|
|
|
731
735
|
if (getChildOfType(state.doc, schema.nodes.keywords, true)) {
|
|
732
736
|
return false;
|
|
733
737
|
}
|
|
734
|
-
const supplements = findChildrenByType(state.doc, state.schema.nodes.supplements)[0];
|
|
735
738
|
const abstracts = findChildrenByType(state.doc, state.schema.nodes.abstracts)[0];
|
|
736
|
-
|
|
737
|
-
if (supplements) {
|
|
738
|
-
pos = supplements.pos + supplements.node.nodeSize;
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
pos = abstracts.pos;
|
|
742
|
-
}
|
|
739
|
+
const pos = abstracts.pos;
|
|
743
740
|
const keywords = schema.nodes.keywords.createAndFill({}, [
|
|
744
741
|
schema.nodes.section_title.create({}, schema.text('Keywords')),
|
|
745
742
|
schema.nodes.keywords_element.create({}, [
|
|
@@ -1233,11 +1230,8 @@ const createHeroImage = (attrs) => schema.nodes.hero_image.create({
|
|
|
1233
1230
|
schema.nodes.long_desc.create(),
|
|
1234
1231
|
]);
|
|
1235
1232
|
export const insertHeroImage = () => (state, dispatch, view) => {
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
}
|
|
1239
|
-
const backmatter = findBackmatter(state.doc);
|
|
1240
|
-
const position = backmatter.pos + backmatter.node.content.size + 1;
|
|
1233
|
+
const comments = findChildrenByType(state.doc, schema.nodes.comments)[0];
|
|
1234
|
+
const position = comments.pos;
|
|
1241
1235
|
view?.focus();
|
|
1242
1236
|
createBlock(schema.nodes.hero_image, position, state, dispatch);
|
|
1243
1237
|
return true;
|
package/dist/es/lib/doc.js
CHANGED
|
@@ -33,8 +33,8 @@ export const insertSupplementsNode = (tr) => {
|
|
|
33
33
|
if (supplements) {
|
|
34
34
|
return supplements;
|
|
35
35
|
}
|
|
36
|
-
const
|
|
37
|
-
const pos =
|
|
36
|
+
const backmatter = findBackmatter(doc);
|
|
37
|
+
const pos = backmatter.pos + backmatter.node.content.size + 1;
|
|
38
38
|
const node = schema.nodes.supplements.createAndFill();
|
|
39
39
|
tr.insert(pos, node);
|
|
40
40
|
return {
|
package/dist/es/menus.js
CHANGED
|
@@ -253,7 +253,8 @@ export const getEditorMenus = (editor) => {
|
|
|
253
253
|
{
|
|
254
254
|
id: 'insert-hero-image',
|
|
255
255
|
label: 'Hero Image',
|
|
256
|
-
isEnabled: isEditAllowed(state) &&
|
|
256
|
+
isEnabled: isEditAllowed(state) &&
|
|
257
|
+
isCommandValid(canInsert(schema.nodes.hero_image)),
|
|
257
258
|
run: doCommand(insertHeroImage()),
|
|
258
259
|
isHidden: !templateAllows(state, schema.nodes.hero_image),
|
|
259
260
|
},
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { isFootnoteNode, isGeneralTableFootnoteNode, isPullquoteElement, schema, } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
18
|
+
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
18
19
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
20
|
const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
20
21
|
const element = document.createElement('span');
|
|
@@ -53,6 +54,9 @@ const getParagraphPlaceholderText = (parent, node) => {
|
|
|
53
54
|
if (isFootnoteNode(parent) || isGeneralTableFootnoteNode(parent)) {
|
|
54
55
|
return 'Type new footnote here';
|
|
55
56
|
}
|
|
57
|
+
if (parent.type === schema.nodes.trans_abstract) {
|
|
58
|
+
return 'Type here';
|
|
59
|
+
}
|
|
56
60
|
};
|
|
57
61
|
export default () => new Plugin({
|
|
58
62
|
props: {
|
|
@@ -69,6 +73,17 @@ export default () => new Plugin({
|
|
|
69
73
|
decorations.push(Decoration.widget(pos + 1, placeholderWidget(text)));
|
|
70
74
|
}
|
|
71
75
|
}
|
|
76
|
+
else if (node.type === node.type.schema.nodes.section_title) {
|
|
77
|
+
const $pos = state.doc.resolve(pos);
|
|
78
|
+
let placeholderText = 'Type heading here';
|
|
79
|
+
if (findParentNodeOfTypeClosestToPos($pos, schema.nodes.box_element)) {
|
|
80
|
+
placeholderText = 'Optional box title...';
|
|
81
|
+
}
|
|
82
|
+
decorations.push(Decoration.widget(pos + 1, placeholderWidget(placeholderText)));
|
|
83
|
+
}
|
|
84
|
+
else if (node.type === node.type.schema.nodes.trans_abstract) {
|
|
85
|
+
decorations.push(Decoration.widget(pos + 1, placeholderWidget('Type new abstract title here')));
|
|
86
|
+
}
|
|
72
87
|
else {
|
|
73
88
|
decorations.push(Decoration.node(pos, pos + node.nodeSize, {
|
|
74
89
|
class: 'empty-node',
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '3.5.
|
|
1
|
+
export const VERSION = '3.5.6';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -26,9 +26,7 @@ export class AbstractsView extends BaseNodeView {
|
|
|
26
26
|
const { schema } = state;
|
|
27
27
|
const documentLanguage = state.doc.attrs.primaryLanguageCode || 'en';
|
|
28
28
|
const sectionTitle = schema.nodes.section_title.create();
|
|
29
|
-
const paragraph = schema.nodes.paragraph.create(
|
|
30
|
-
placeholder: 'Type here',
|
|
31
|
-
});
|
|
29
|
+
const paragraph = schema.nodes.paragraph.create();
|
|
32
30
|
const transAbstractNode = schema.nodes.trans_abstract.create({
|
|
33
31
|
lang: documentLanguage,
|
|
34
32
|
}, [sectionTitle, paragraph]);
|
|
@@ -52,15 +52,6 @@ export class SectionTitleView extends BlockView {
|
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
54
|
this.contentDOM.classList.add('empty-node');
|
|
55
|
-
if ($pos.node($pos.depth - 1).type === schema.nodes.box_element) {
|
|
56
|
-
this.contentDOM.setAttribute('data-placeholder', `Optional box title...`);
|
|
57
|
-
}
|
|
58
|
-
else if ($pos.node($pos.depth).type === schema.nodes.trans_abstract) {
|
|
59
|
-
this.contentDOM.setAttribute('data-placeholder', `Type new abstract title here`);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.contentDOM.setAttribute('data-placeholder', `Type heading here`);
|
|
63
|
-
}
|
|
64
55
|
}
|
|
65
56
|
if (sectionTitleState && sectionNumber) {
|
|
66
57
|
this.contentDOM.dataset.sectionNumber = sectionNumber;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "3.5.
|
|
1
|
+
export declare const VERSION = "3.5.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": "3.5.
|
|
4
|
+
"version": "3.5.6",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@manuscripts/json-schema": "2.2.12",
|
|
42
42
|
"@manuscripts/style-guide": "3.3.0",
|
|
43
43
|
"@manuscripts/track-changes-plugin": "2.0.12",
|
|
44
|
-
"@manuscripts/transform": "4.2.
|
|
44
|
+
"@manuscripts/transform": "4.2.15",
|
|
45
45
|
"@popperjs/core": "2.11.8",
|
|
46
46
|
"citeproc": "2.4.63",
|
|
47
47
|
"codemirror": "5.65.19",
|
|
@@ -32,28 +32,10 @@
|
|
|
32
32
|
-webkit-appearance: none;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.ProseMirror
|
|
36
|
-
> div.body
|
|
37
|
-
section:not(.toc)
|
|
38
|
-
.block-section_title
|
|
39
|
-
h1.empty-node[data-placeholder]::before {
|
|
40
|
-
content: attr(data-section-number) '. ' attr(data-placeholder);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
35
|
.ProseMirror > div.body section:not(.toc) .block-section_title h1::before {
|
|
44
36
|
content: attr(data-section-number) '. ';
|
|
45
37
|
}
|
|
46
38
|
|
|
47
|
-
.ProseMirror
|
|
48
|
-
> div.body
|
|
49
|
-
.block-box_element
|
|
50
|
-
.box-element
|
|
51
|
-
section:not(.toc)
|
|
52
|
-
.block-section_title
|
|
53
|
-
h1.empty-node[data-placeholder]::before {
|
|
54
|
-
content: attr(data-placeholder);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
39
|
.ProseMirror
|
|
58
40
|
> div.body
|
|
59
41
|
.block-box_element
|
package/styles/Editor.css
CHANGED
|
@@ -297,6 +297,21 @@
|
|
|
297
297
|
content: 'Caption Title...';
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
.ProseMirror .block-box_element .caption-title.empty-node::before {
|
|
301
|
+
content: none;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.ProseMirror .block-box_element label.caption-title.placeholder.empty-node {
|
|
305
|
+
display: inline-flex;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.ProseMirror .block-box_element .caption-title.empty-node::after {
|
|
309
|
+
content: 'Caption Title...';
|
|
310
|
+
color: #999;
|
|
311
|
+
font-style: italic;
|
|
312
|
+
pointer-events: none;
|
|
313
|
+
}
|
|
314
|
+
|
|
300
315
|
.ProseMirror .caption-description.empty-node::before {
|
|
301
316
|
content: 'Caption...';
|
|
302
317
|
}
|