@manuscripts/body-editor 3.5.4 → 3.5.5

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.
@@ -579,7 +579,7 @@ const insertBoxElement = (state, dispatch) => {
579
579
  const tr = state.tr.insert(position, node);
580
580
  const sectionTitlePosition = position + 4;
581
581
  tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, sectionTitlePosition));
582
- dispatch(tr);
582
+ dispatch(tr.scrollIntoView());
583
583
  }
584
584
  return true;
585
585
  };
@@ -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',
@@ -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.5.4';
4
+ exports.VERSION = '3.5.5';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -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;
@@ -549,7 +549,7 @@ export const insertBoxElement = (state, dispatch) => {
549
549
  const tr = state.tr.insert(position, node);
550
550
  const sectionTitlePosition = position + 4;
551
551
  tr.setSelection(TextSelection.create(tr.doc, sectionTitlePosition));
552
- dispatch(tr);
552
+ dispatch(tr.scrollIntoView());
553
553
  }
554
554
  return true;
555
555
  };
@@ -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',
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.5.4';
1
+ export const VERSION = '3.5.5';
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;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.5.4";
1
+ export declare const VERSION = "3.5.5";
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",
4
+ "version": "3.5.5",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -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
  }