@manuscripts/body-editor 2.3.2 → 2.5.0

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.
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.autoComplete = exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.insertTableFootnote = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertContributors = exports.insertAbstract = exports.insertBackMatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertTable = exports.insertFigure = exports.insertGeneralFootnote = exports.undoFootnoteDelete = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
18
+ exports.autoComplete = exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.insertBoxElement = exports.insertTableFootnote = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertContributors = exports.insertAbstract = exports.insertBackMatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = exports.insertInlineEquation = exports.insertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertSupplement = exports.insertTable = exports.insertFigure = exports.insertGeneralFootnote = exports.undoFootnoteDelete = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
19
  const json_schema_1 = require("@manuscripts/json-schema");
20
20
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
21
21
  const transform_1 = require("@manuscripts/transform");
@@ -92,7 +92,8 @@ exports.blockActive = blockActive;
92
92
  const canInsert = (type) => (state) => {
93
93
  var _a;
94
94
  const { $from, $to } = state.selection;
95
- if ($from.node().type === transform_1.schema.nodes.title && $from.pos === $to.pos) {
95
+ if (($from.node().type === transform_1.schema.nodes.title || $from.node().type === transform_1.schema.nodes.section_title) &&
96
+ $from.pos === $to.pos) {
96
97
  return false;
97
98
  }
98
99
  const initDepth = ((_a = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) ||
@@ -1092,6 +1093,30 @@ const insertTableFootnote = (tableElementNode, position, view, inlineFootnote) =
1092
1093
  dispatch(view.state.tr.setSelection(textSelection).scrollIntoView());
1093
1094
  };
1094
1095
  exports.insertTableFootnote = insertTableFootnote;
1096
+ const insertBoxElement = (state, dispatch) => {
1097
+ const selection = state.selection;
1098
+ const isBody = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(selection);
1099
+ const isBoxText = (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection);
1100
+ if (!isBody || isBoxText) {
1101
+ return false;
1102
+ }
1103
+ const position = findBlockInsertPosition(state);
1104
+ const paragraph = transform_1.schema.nodes.paragraph.create({});
1105
+ const section = transform_1.schema.nodes.section.createAndFill({}, [
1106
+ transform_1.schema.nodes.section_title.create(),
1107
+ paragraph,
1108
+ ]);
1109
+ const BoxElementNode = transform_1.schema.nodes.box_element.createAndFill({}, [
1110
+ transform_1.schema.nodes.figcaption.create({}, [transform_1.schema.nodes.caption_title.create()]),
1111
+ section,
1112
+ ]);
1113
+ if (position && dispatch) {
1114
+ const tr = state.tr.insert(position, BoxElementNode);
1115
+ dispatch(tr);
1116
+ }
1117
+ return true;
1118
+ };
1119
+ exports.insertBoxElement = insertBoxElement;
1095
1120
  const addRows = (direction) => (state, dispatch) => {
1096
1121
  if (dispatch) {
1097
1122
  const { tr } = state;
package/dist/cjs/menus.js CHANGED
@@ -203,6 +203,16 @@ const getEditorMenus = (editor) => {
203
203
  {
204
204
  role: 'separator',
205
205
  },
206
+ {
207
+ id: 'insert-boxed-text',
208
+ label: 'Boxed Text',
209
+ shortcut: {
210
+ mac: 'Option+CommandOrControl+B',
211
+ pc: 'CommandOrControl+Option+B',
212
+ },
213
+ isEnabled: isCommandValid(commands_1.insertBoxElement),
214
+ run: doCommand(commands_1.insertBoxElement),
215
+ },
206
216
  {
207
217
  id: 'insert-figure-element',
208
218
  label: 'Figure Panel',
@@ -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 = '2.3.2';
4
+ exports.VERSION = '2.5.0';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -43,7 +43,12 @@ class SectionTitleView extends block_view_1.default {
43
43
  }
44
44
  else {
45
45
  this.contentDOM.classList.add('empty-node');
46
- this.contentDOM.setAttribute('data-placeholder', `${(0, context_menu_1.sectionLevel)(level)} heading`);
46
+ if ($pos.node($pos.depth - 1).type === transform_1.schema.nodes.box_element) {
47
+ this.contentDOM.setAttribute('data-placeholder', `Optional box title...`);
48
+ }
49
+ else {
50
+ this.contentDOM.setAttribute('data-placeholder', `${(0, context_menu_1.sectionLevel)(level)} heading`);
51
+ }
47
52
  }
48
53
  if (sectionTitleState && sectionNumber) {
49
54
  this.contentDOM.dataset.sectionNumber = sectionNumber;
@@ -85,7 +85,8 @@ export const blockActive = (type) => (state) => {
85
85
  export const canInsert = (type) => (state) => {
86
86
  var _a;
87
87
  const { $from, $to } = state.selection;
88
- if ($from.node().type === schema.nodes.title && $from.pos === $to.pos) {
88
+ if (($from.node().type === schema.nodes.title || $from.node().type === schema.nodes.section_title) &&
89
+ $from.pos === $to.pos) {
89
90
  return false;
90
91
  }
91
92
  const initDepth = ((_a = findParentNodeOfType(schema.nodes.box_element)(state.selection)) === null || _a === void 0 ? void 0 : _a.depth) ||
@@ -1045,6 +1046,29 @@ export const insertTableFootnote = (tableElementNode, position, view, inlineFoot
1045
1046
  view.focus();
1046
1047
  dispatch(view.state.tr.setSelection(textSelection).scrollIntoView());
1047
1048
  };
1049
+ export const insertBoxElement = (state, dispatch) => {
1050
+ const selection = state.selection;
1051
+ const isBody = hasParentNodeOfType(schema.nodes.body)(selection);
1052
+ const isBoxText = hasParentNodeOfType(schema.nodes.box_element)(selection);
1053
+ if (!isBody || isBoxText) {
1054
+ return false;
1055
+ }
1056
+ const position = findBlockInsertPosition(state);
1057
+ const paragraph = schema.nodes.paragraph.create({});
1058
+ const section = schema.nodes.section.createAndFill({}, [
1059
+ schema.nodes.section_title.create(),
1060
+ paragraph,
1061
+ ]);
1062
+ const BoxElementNode = schema.nodes.box_element.createAndFill({}, [
1063
+ schema.nodes.figcaption.create({}, [schema.nodes.caption_title.create()]),
1064
+ section,
1065
+ ]);
1066
+ if (position && dispatch) {
1067
+ const tr = state.tr.insert(position, BoxElementNode);
1068
+ dispatch(tr);
1069
+ }
1070
+ return true;
1071
+ };
1048
1072
  export const addRows = (direction) => (state, dispatch) => {
1049
1073
  if (dispatch) {
1050
1074
  const { tr } = state;
package/dist/es/menus.js CHANGED
@@ -16,7 +16,7 @@
16
16
  import { schema } from '@manuscripts/transform';
17
17
  import { toggleMark } from 'prosemirror-commands';
18
18
  import { redo, undo } from 'prosemirror-history';
19
- import { addInlineComment, blockActive, canInsert, insertAbstract, insertBackMatterSection, insertBlock, insertContributors, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, } from './commands';
19
+ import { addInlineComment, blockActive, canInsert, insertAbstract, insertBackMatterSection, insertBlock, insertBoxElement, insertContributors, insertCrossReference, insertGraphicalAbstract, insertInlineCitation, insertInlineEquation, insertInlineFootnote, insertKeywords, insertLink, insertList, insertSection, markActive, } from './commands';
20
20
  import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
21
21
  import { ListMenuItem } from './components/toolbar/ListMenuItem';
22
22
  import { deleteClosestParentElement, findClosestParentElementNodeName, } from './lib/hierarchy';
@@ -200,6 +200,16 @@ export const getEditorMenus = (editor) => {
200
200
  {
201
201
  role: 'separator',
202
202
  },
203
+ {
204
+ id: 'insert-boxed-text',
205
+ label: 'Boxed Text',
206
+ shortcut: {
207
+ mac: 'Option+CommandOrControl+B',
208
+ pc: 'CommandOrControl+Option+B',
209
+ },
210
+ isEnabled: isCommandValid(insertBoxElement),
211
+ run: doCommand(insertBoxElement),
212
+ },
203
213
  {
204
214
  id: 'insert-figure-element',
205
215
  label: 'Figure Panel',
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.3.2';
1
+ export const VERSION = '2.5.0';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -37,7 +37,12 @@ export class SectionTitleView extends BlockView {
37
37
  }
38
38
  else {
39
39
  this.contentDOM.classList.add('empty-node');
40
- this.contentDOM.setAttribute('data-placeholder', `${sectionLevel(level)} heading`);
40
+ if ($pos.node($pos.depth - 1).type === schema.nodes.box_element) {
41
+ this.contentDOM.setAttribute('data-placeholder', `Optional box title...`);
42
+ }
43
+ else {
44
+ this.contentDOM.setAttribute('data-placeholder', `${sectionLevel(level)} heading`);
45
+ }
41
46
  }
42
47
  if (sectionTitleState && sectionNumber) {
43
48
  this.contentDOM.dataset.sectionNumber = sectionNumber;
@@ -74,6 +74,7 @@ interface NodeWithPosition {
74
74
  pos: number;
75
75
  }
76
76
  export declare const insertTableFootnote: (tableElementNode: ManuscriptNode, position: number, view: EditorView, inlineFootnote?: NodeWithPosition) => void;
77
+ export declare const insertBoxElement: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
77
78
  export declare const addRows: (direction: 'top' | 'bottom') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
78
79
  export declare const addColumns: (direction: 'right' | 'left') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
79
80
  export declare function mergeCellsWithSpace(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.3.2";
1
+ export declare const VERSION = "2.5.0";
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": "2.3.2",
4
+ "version": "2.5.0",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
@@ -173,11 +173,19 @@
173
173
  text-align: left;
174
174
  }
175
175
 
176
+ .ProseMirror .box-element .block-section_title h1.empty-node[data-placeholder]::before {
177
+ font-style: italic !important;
178
+ font-weight: 400 !important;
179
+ line-height: 24px;
180
+ letter-spacing: -0.369px;
181
+ font-size: 13.5pt ;
182
+ }
183
+ .ProseMirror .box-element .block-section:first-of-type > section:first-of-type > .block-section_title:first-of-type > h1.empty-node[data-placeholder]::before {
184
+ font-size: 16pt ;
185
+ }
176
186
  .box-element section figcaption {
177
187
  background: var(--box-element-bg-color);
178
188
  }
179
-
180
-
181
189
  .unsupported-format-label {
182
190
  font-size: 140%;
183
191
  line-height: 1.3;
@@ -451,7 +459,6 @@ span.comment-marker {
451
459
  .block-box_element > .block-gutter {
452
460
  margin-top: 14px;
453
461
  }
454
-
455
462
  .author-notes > .block-section_title > .block,
456
463
  .keywords > .block-section_title > .block {
457
464
  align-items: center;