@manuscripts/body-editor 3.5.3 → 3.5.4

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/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',
@@ -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.4';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
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',
@@ -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.4';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.5.3";
1
+ export declare const VERSION = "3.5.4";
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.4",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -1423,6 +1423,11 @@ th:hover > .table-context-menu-button,
1423
1423
  opacity: 1;
1424
1424
  }
1425
1425
 
1426
+ .ProseMirror .block-container:hover .section-category-button.disabled {
1427
+ opacity: 0.2;
1428
+ cursor: not-allowed;
1429
+ }
1430
+
1426
1431
  .section-category.menu .menu-item.selected:after {
1427
1432
  top: 10.5px;
1428
1433
  right: 19px;