@manuscripts/body-editor 3.2.18 → 3.2.20

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.
@@ -112,6 +112,11 @@ const canInsert = (type) => (state) => {
112
112
  return false;
113
113
  }
114
114
  }
115
+ if (type === transform_1.schema.nodes.box_element &&
116
+ (!(0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(state.selection) ||
117
+ (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection))) {
118
+ return false;
119
+ }
115
120
  const initDepth = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection)?.depth ||
116
121
  0;
117
122
  for (let d = $from.depth; d >= initDepth; d--) {
@@ -540,19 +545,20 @@ const reinstateNode = (tr, node, pos) => {
540
545
  };
541
546
  const insertBoxElement = (state, dispatch) => {
542
547
  const selection = state.selection;
543
- const isBody = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(selection);
544
- const isBoxText = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection);
548
+ const { nodes } = transform_1.schema;
549
+ const isBody = (0, prosemirror_utils_1.hasParentNodeOfType)(nodes.body)(selection);
550
+ const isBoxText = (0, prosemirror_utils_1.hasParentNodeOfType)(nodes.box_element)(selection);
545
551
  if (!isBody || isBoxText) {
546
552
  return false;
547
553
  }
548
554
  const position = findBlockInsertPosition(state);
549
- const paragraph = transform_1.schema.nodes.paragraph.create({});
550
- const section = transform_1.schema.nodes.section.createAndFill({}, [
551
- transform_1.schema.nodes.section_title.create(),
555
+ const paragraph = nodes.paragraph.create({});
556
+ const section = nodes.section.createAndFill({}, [
557
+ nodes.section_title.create(),
552
558
  paragraph,
553
559
  ]);
554
- const node = transform_1.schema.nodes.box_element.createAndFill({}, [
555
- transform_1.schema.nodes.figcaption.create({}, [transform_1.schema.nodes.caption_title.create()]),
560
+ const node = nodes.box_element.createAndFill({}, [
561
+ nodes.figcaption.create({}, [nodes.caption_title.create()]),
556
562
  section,
557
563
  ]);
558
564
  if (position && dispatch) {
@@ -67,7 +67,7 @@ const OptionsButton = (0, styled_components_1.default)(style_guide_1.IconButton)
67
67
  height: ${(props) => props.theme.grid.unit * 6}px;
68
68
  margin: ${(props) => props.theme.grid.unit}px;
69
69
  visibility: hidden;
70
- background: white;
70
+ background: #ffffff;
71
71
 
72
72
  &:hover {
73
73
  background: #f2fbfc !important;
@@ -98,8 +98,8 @@ const ListItemButton = (0, styled_components_1.default)(style_guide_1.IconTextBu
98
98
  }
99
99
 
100
100
  &:is([disabled]) {
101
- background: white !important;
102
- color: #353535 !important;
101
+ background: #ffffff;
102
+ color: #353535;
103
103
  opacity: 0.4;
104
104
  }
105
105
  `;
@@ -138,6 +138,11 @@ const ActionButton = (0, styled_components_1.default)(style_guide_1.IconTextButt
138
138
  :hover {
139
139
  background: #f2fbfc;
140
140
  }
141
+ :disabled {
142
+ color: #353535;
143
+ background-color: #ffffff;
144
+ opacity: 0.4;
145
+ }
141
146
  `;
142
147
  const Separator = styled_components_1.default.div `
143
148
  height: 0;
package/dist/cjs/menus.js CHANGED
@@ -216,7 +216,8 @@ const getEditorMenus = (editor) => {
216
216
  mac: 'Option+CommandOrControl+B',
217
217
  pc: 'CommandOrControl+Option+B',
218
218
  },
219
- isEnabled: (0, utils_1.isEditAllowed)(state) && isCommandValid(commands_1.insertBoxElement),
219
+ isEnabled: (0, utils_1.isEditAllowed)(state) &&
220
+ isCommandValid((0, commands_1.canInsert)(transform_1.schema.nodes.box_element)),
220
221
  run: doCommand(commands_1.insertBoxElement),
221
222
  },
222
223
  {
@@ -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.2.18';
4
+ exports.VERSION = '3.2.20';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -104,6 +104,11 @@ export const canInsert = (type) => (state) => {
104
104
  return false;
105
105
  }
106
106
  }
107
+ if (type === schema.nodes.box_element &&
108
+ (!hasParentNodeOfType(schema.nodes.body)(state.selection) ||
109
+ hasParentNodeOfType(schema.nodes.box_element)(state.selection))) {
110
+ return false;
111
+ }
107
112
  const initDepth = findParentNodeOfType(schema.nodes.box_element)(state.selection)?.depth ||
108
113
  0;
109
114
  for (let d = $from.depth; d >= initDepth; d--) {
@@ -510,19 +515,20 @@ const reinstateNode = (tr, node, pos) => {
510
515
  };
511
516
  export const insertBoxElement = (state, dispatch) => {
512
517
  const selection = state.selection;
513
- const isBody = hasParentNodeOfType(schema.nodes.body)(selection);
514
- const isBoxText = hasParentNodeOfType(schema.nodes.box_element)(selection);
518
+ const { nodes } = schema;
519
+ const isBody = hasParentNodeOfType(nodes.body)(selection);
520
+ const isBoxText = hasParentNodeOfType(nodes.box_element)(selection);
515
521
  if (!isBody || isBoxText) {
516
522
  return false;
517
523
  }
518
524
  const position = findBlockInsertPosition(state);
519
- const paragraph = schema.nodes.paragraph.create({});
520
- const section = schema.nodes.section.createAndFill({}, [
521
- schema.nodes.section_title.create(),
525
+ const paragraph = nodes.paragraph.create({});
526
+ const section = nodes.section.createAndFill({}, [
527
+ nodes.section_title.create(),
522
528
  paragraph,
523
529
  ]);
524
- const node = schema.nodes.box_element.createAndFill({}, [
525
- schema.nodes.figcaption.create({}, [schema.nodes.caption_title.create()]),
530
+ const node = nodes.box_element.createAndFill({}, [
531
+ nodes.figcaption.create({}, [nodes.caption_title.create()]),
526
532
  section,
527
533
  ]);
528
534
  if (position && dispatch) {
@@ -60,7 +60,7 @@ const OptionsButton = styled(IconButton) `
60
60
  height: ${(props) => props.theme.grid.unit * 6}px;
61
61
  margin: ${(props) => props.theme.grid.unit}px;
62
62
  visibility: hidden;
63
- background: white;
63
+ background: #ffffff;
64
64
 
65
65
  &:hover {
66
66
  background: #f2fbfc !important;
@@ -91,8 +91,8 @@ const ListItemButton = styled(IconTextButton) `
91
91
  }
92
92
 
93
93
  &:is([disabled]) {
94
- background: white !important;
95
- color: #353535 !important;
94
+ background: #ffffff;
95
+ color: #353535;
96
96
  opacity: 0.4;
97
97
  }
98
98
  `;
@@ -108,6 +108,11 @@ const ActionButton = styled(IconTextButton) `
108
108
  :hover {
109
109
  background: #f2fbfc;
110
110
  }
111
+ :disabled {
112
+ color: #353535;
113
+ background-color: #ffffff;
114
+ opacity: 0.4;
115
+ }
111
116
  `;
112
117
  const Separator = styled.div `
113
118
  height: 0;
package/dist/es/menus.js CHANGED
@@ -213,7 +213,8 @@ export const getEditorMenus = (editor) => {
213
213
  mac: 'Option+CommandOrControl+B',
214
214
  pc: 'CommandOrControl+Option+B',
215
215
  },
216
- isEnabled: isEditAllowed(state) && isCommandValid(insertBoxElement),
216
+ isEnabled: isEditAllowed(state) &&
217
+ isCommandValid(canInsert(schema.nodes.box_element)),
217
218
  run: doCommand(insertBoxElement),
218
219
  },
219
220
  {
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.2.18';
1
+ export const VERSION = '3.2.20';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.2.18";
1
+ export declare const VERSION = "3.2.20";
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.2.18",
4
+ "version": "3.2.20",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -38,7 +38,7 @@
38
38
  "@citation-js/plugin-pubmed": "0.3.0",
39
39
  "@citation-js/plugin-ris": "0.7.18",
40
40
  "@manuscripts/json-schema": "2.2.12",
41
- "@manuscripts/style-guide": "3.1.4",
41
+ "@manuscripts/style-guide": "3.1.5",
42
42
  "@manuscripts/track-changes-plugin": "2.0.3",
43
43
  "@manuscripts/transform": "4.2.4",
44
44
  "@popperjs/core": "2.11.8",