@manuscripts/body-editor 3.5.3 → 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
  };
package/dist/cjs/menus.js CHANGED
@@ -129,6 +129,7 @@ const getEditorMenus = (editor) => {
129
129
  label: 'Abstract Types',
130
130
  isEnabled: true,
131
131
  submenu: allAbstractsCategories.map(insertAbstractsSectionMenu),
132
+ isHidden: !allAbstractsCategories.length,
132
133
  },
133
134
  {
134
135
  id: 'insert-contributors',
@@ -165,7 +166,8 @@ const getEditorMenus = (editor) => {
165
166
  label: 'Author Notes',
166
167
  isEnabled: true,
167
168
  submenu: categories.map(insertBackmatterSectionMenu),
168
- isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.author_notes),
169
+ isHidden: !(0, template_1.templateAllows)(state, transform_1.schema.nodes.author_notes) ||
170
+ !categories.length,
169
171
  },
170
172
  {
171
173
  id: 'insert-section',
@@ -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',
@@ -31,7 +31,7 @@ function createMenu(currentCategory, categories, usedCategoryIDs, onSelect) {
31
31
  });
32
32
  return menu;
33
33
  }
34
- function createButton(view, pos, currentCategory, categories, usedCategoryIDs, canEdit = true) {
34
+ function createButton(view, pos, currentCategory, categories, usedCategoryIDs, canEdit = true, disabled) {
35
35
  const handleSelect = (category) => {
36
36
  const tr = view.state.tr;
37
37
  tr.setNodeAttribute(pos, 'category', category.id);
@@ -45,7 +45,10 @@ function createButton(view, pos, currentCategory, categories, usedCategoryIDs, c
45
45
  if (currentCategory) {
46
46
  button.classList.add('assigned');
47
47
  }
48
- if (canEdit) {
48
+ if (disabled) {
49
+ button.classList.add('disabled');
50
+ }
51
+ else if (canEdit) {
49
52
  button.addEventListener('mousedown', () => {
50
53
  popper.destroy();
51
54
  const menu = createMenu(currentCategory, categories, usedCategoryIDs, handleSelect);
@@ -89,7 +92,7 @@ function buildPluginState(state, props) {
89
92
  const $pos = state.doc.resolve(pos);
90
93
  const group = getGroup($pos);
91
94
  const groupCategories = (0, transform_1.getGroupCategories)(categories, group);
92
- decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => createButton(view, pos, category, groupCategories, usedCategoryIDs, can?.editArticle)));
95
+ decorations.push(prosemirror_view_1.Decoration.widget(pos + 1, (view) => createButton(view, pos, category, groupCategories, usedCategoryIDs, can?.editArticle, categories.size === 0)));
93
96
  return false;
94
97
  }
95
98
  });
@@ -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.3';
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
  };
package/dist/es/menus.js CHANGED
@@ -126,6 +126,7 @@ export const getEditorMenus = (editor) => {
126
126
  label: 'Abstract Types',
127
127
  isEnabled: true,
128
128
  submenu: allAbstractsCategories.map(insertAbstractsSectionMenu),
129
+ isHidden: !allAbstractsCategories.length,
129
130
  },
130
131
  {
131
132
  id: 'insert-contributors',
@@ -162,7 +163,8 @@ export const getEditorMenus = (editor) => {
162
163
  label: 'Author Notes',
163
164
  isEnabled: true,
164
165
  submenu: categories.map(insertBackmatterSectionMenu),
165
- isHidden: !templateAllows(state, schema.nodes.author_notes),
166
+ isHidden: !templateAllows(state, schema.nodes.author_notes) ||
167
+ !categories.length,
166
168
  },
167
169
  {
168
170
  id: 'insert-section',
@@ -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',
@@ -28,7 +28,7 @@ function createMenu(currentCategory, categories, usedCategoryIDs, onSelect) {
28
28
  });
29
29
  return menu;
30
30
  }
31
- function createButton(view, pos, currentCategory, categories, usedCategoryIDs, canEdit = true) {
31
+ function createButton(view, pos, currentCategory, categories, usedCategoryIDs, canEdit = true, disabled) {
32
32
  const handleSelect = (category) => {
33
33
  const tr = view.state.tr;
34
34
  tr.setNodeAttribute(pos, 'category', category.id);
@@ -42,7 +42,10 @@ function createButton(view, pos, currentCategory, categories, usedCategoryIDs, c
42
42
  if (currentCategory) {
43
43
  button.classList.add('assigned');
44
44
  }
45
- if (canEdit) {
45
+ if (disabled) {
46
+ button.classList.add('disabled');
47
+ }
48
+ else if (canEdit) {
46
49
  button.addEventListener('mousedown', () => {
47
50
  popper.destroy();
48
51
  const menu = createMenu(currentCategory, categories, usedCategoryIDs, handleSelect);
@@ -86,7 +89,7 @@ export function buildPluginState(state, props) {
86
89
  const $pos = state.doc.resolve(pos);
87
90
  const group = getGroup($pos);
88
91
  const groupCategories = getGroupCategories(categories, group);
89
- decorations.push(Decoration.widget(pos + 1, (view) => createButton(view, pos, category, groupCategories, usedCategoryIDs, can?.editArticle)));
92
+ decorations.push(Decoration.widget(pos + 1, (view) => createButton(view, pos, category, groupCategories, usedCategoryIDs, can?.editArticle, categories.size === 0)));
90
93
  return false;
91
94
  }
92
95
  });
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.5.3';
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.3";
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.3",
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
@@ -1423,6 +1405,11 @@ th:hover > .table-context-menu-button,
1423
1405
  opacity: 1;
1424
1406
  }
1425
1407
 
1408
+ .ProseMirror .block-container:hover .section-category-button.disabled {
1409
+ opacity: 0.2;
1410
+ cursor: not-allowed;
1411
+ }
1412
+
1426
1413
  .section-category.menu .menu-item.selected:after {
1427
1414
  top: 10.5px;
1428
1415
  right: 19px;
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
  }