@manuscripts/body-editor 2.7.30 → 2.7.31

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,8 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.addColumns = exports.addHeaderRow = exports.addRows = 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.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertAbstract = exports.insertBackmatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = 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.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.insertEmbed = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
- exports.autoComplete = void 0;
18
+ exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.isCommentingAllowed = 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.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertAbstract = exports.insertBackmatterSection = exports.insertSection = exports.insertGraphicalAbstract = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = 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.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.insertEmbed = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
+ exports.autoComplete = exports.addColumns = void 0;
20
20
  const json_schema_1 = require("@manuscripts/json-schema");
21
21
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
22
22
  const transform_1 = require("@manuscripts/transform");
@@ -1020,9 +1020,11 @@ const isCommentingAllowed = (type) => type === transform_1.schema.nodes.title ||
1020
1020
  type === transform_1.schema.nodes.table_element ||
1021
1021
  type === transform_1.schema.nodes.embed ||
1022
1022
  type === transform_1.schema.nodes.affiliations ||
1023
- type === transform_1.schema.nodes.contributors;
1023
+ type === transform_1.schema.nodes.contributors ||
1024
+ type === transform_1.schema.nodes.image_element;
1025
+ exports.isCommentingAllowed = isCommentingAllowed;
1024
1026
  const addNodeComment = (node, state, dispatch) => {
1025
- if (!isCommentingAllowed(node.type)) {
1027
+ if (!(0, exports.isCommentingAllowed)(node.type)) {
1026
1028
  return false;
1027
1029
  }
1028
1030
  const props = (0, editor_props_1.getEditorProps)(state);
@@ -1051,7 +1053,7 @@ exports.addNodeComment = addNodeComment;
1051
1053
  const addInlineComment = (state, dispatch) => {
1052
1054
  const selection = state.selection;
1053
1055
  const node = getParentNode(selection);
1054
- if (!node || !isCommentingAllowed(node.type)) {
1056
+ if (!node || !(0, exports.isCommentingAllowed)(node.type)) {
1055
1057
  return false;
1056
1058
  }
1057
1059
  let from = selection.from;
@@ -43,7 +43,7 @@ const hasAny = (set, ...items) => {
43
43
  };
44
44
  exports.contextMenuBtnClass = 'btn-context-menu';
45
45
  class ContextMenu {
46
- constructor(node, view, getPos, actions = {}) {
46
+ constructor(node, view, getPos) {
47
47
  this.showAddMenu = (target, after) => {
48
48
  const menu = document.createElement('div');
49
49
  menu.className = 'menu';
@@ -168,12 +168,11 @@ class ContextMenu {
168
168
  }
169
169
  }));
170
170
  }
171
- const { addComment } = this.actions;
172
- if (addComment) {
171
+ const commentTarget = this.getCommentTarget();
172
+ if ((0, commands_1.isCommentingAllowed)(commentTarget.type)) {
173
173
  menu.appendChild(this.createMenuSection((section) => {
174
174
  section.appendChild(this.createMenuItem('Comment', () => {
175
- const target = this.getCommentTarget();
176
- (0, commands_1.addNodeComment)(target, this.view.state, this.view.dispatch);
175
+ (0, commands_1.addNodeComment)(commentTarget, this.view.state, this.view.dispatch);
177
176
  popper.destroy();
178
177
  }));
179
178
  }));
@@ -326,7 +325,6 @@ class ContextMenu {
326
325
  this.node = node;
327
326
  this.view = view;
328
327
  this.getPos = getPos;
329
- this.actions = actions;
330
328
  }
331
329
  }
332
330
  exports.ContextMenu = ContextMenu;
@@ -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.7.30';
4
+ exports.VERSION = '2.7.31';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -28,9 +28,7 @@ const EditableBlock = (Base) => {
28
28
  constructor() {
29
29
  super(...arguments);
30
30
  this.createMenu = () => {
31
- return new context_menu_1.ContextMenu(this.node, this.view, this.getPos, {
32
- addComment: true,
33
- });
31
+ return new context_menu_1.ContextMenu(this.node, this.view, this.getPos);
34
32
  };
35
33
  }
36
34
  gutterButtons() {
@@ -956,7 +956,7 @@ const getParentNode = (selection) => {
956
956
  }
957
957
  return node;
958
958
  };
959
- const isCommentingAllowed = (type) => type === schema.nodes.title ||
959
+ export const isCommentingAllowed = (type) => type === schema.nodes.title ||
960
960
  type === schema.nodes.section ||
961
961
  type === schema.nodes.citation ||
962
962
  type === schema.nodes.bibliography_item ||
@@ -971,7 +971,8 @@ const isCommentingAllowed = (type) => type === schema.nodes.title ||
971
971
  type === schema.nodes.table_element ||
972
972
  type === schema.nodes.embed ||
973
973
  type === schema.nodes.affiliations ||
974
- type === schema.nodes.contributors;
974
+ type === schema.nodes.contributors ||
975
+ type === schema.nodes.image_element;
975
976
  export const addNodeComment = (node, state, dispatch) => {
976
977
  if (!isCommentingAllowed(node.type)) {
977
978
  return false;
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { getListType, isInBibliographySection, isSectionTitleNode, nodeNames, schema, } from '@manuscripts/transform';
17
17
  import { findChildrenByType } from 'prosemirror-utils';
18
- import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralTableFootnote, insertInlineTableFootnote, } from '../commands';
18
+ import { addNodeComment, createBlock, findPosBeforeFirstSubsection, insertGeneralTableFootnote, insertInlineTableFootnote, isCommentingAllowed, } from '../commands';
19
19
  import { PopperManager } from './popper';
20
20
  import { isChildOfNodeTypes, isSelectionInNode } from './utils';
21
21
  const popper = new PopperManager();
@@ -39,7 +39,7 @@ const hasAny = (set, ...items) => {
39
39
  };
40
40
  export const contextMenuBtnClass = 'btn-context-menu';
41
41
  export class ContextMenu {
42
- constructor(node, view, getPos, actions = {}) {
42
+ constructor(node, view, getPos) {
43
43
  this.showAddMenu = (target, after) => {
44
44
  const menu = document.createElement('div');
45
45
  menu.className = 'menu';
@@ -164,12 +164,11 @@ export class ContextMenu {
164
164
  }
165
165
  }));
166
166
  }
167
- const { addComment } = this.actions;
168
- if (addComment) {
167
+ const commentTarget = this.getCommentTarget();
168
+ if (isCommentingAllowed(commentTarget.type)) {
169
169
  menu.appendChild(this.createMenuSection((section) => {
170
170
  section.appendChild(this.createMenuItem('Comment', () => {
171
- const target = this.getCommentTarget();
172
- addNodeComment(target, this.view.state, this.view.dispatch);
171
+ addNodeComment(commentTarget, this.view.state, this.view.dispatch);
173
172
  popper.destroy();
174
173
  }));
175
174
  }));
@@ -322,6 +321,5 @@ export class ContextMenu {
322
321
  this.node = node;
323
322
  this.view = view;
324
323
  this.getPos = getPos;
325
- this.actions = actions;
326
324
  }
327
325
  }
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.7.30';
1
+ export const VERSION = '2.7.31';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -25,9 +25,7 @@ export const EditableBlock = (Base) => {
25
25
  constructor() {
26
26
  super(...arguments);
27
27
  this.createMenu = () => {
28
- return new ContextMenu(this.node, this.view, this.getPos, {
29
- addComment: true,
30
- });
28
+ return new ContextMenu(this.node, this.view, this.getPos);
31
29
  };
32
30
  }
33
31
  gutterButtons() {
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { FootnotesElementNode, ManuscriptEditorState, ManuscriptEditorView, ManuscriptMarkType, ManuscriptNode, ManuscriptNodeType, ManuscriptResolvedPos, ManuscriptTransaction, SectionCategory } from '@manuscripts/transform';
17
- import { Attrs, ResolvedPos } from 'prosemirror-model';
17
+ import { Attrs, NodeType, ResolvedPos } from 'prosemirror-model';
18
18
  import { EditorState, NodeSelection, Selection, TextSelection, Transaction } from 'prosemirror-state';
19
19
  import { EditorView } from 'prosemirror-view';
20
20
  import { FileAttachment } from './lib/files';
@@ -73,6 +73,7 @@ export type TableConfig = {
73
73
  includeHeader: boolean;
74
74
  };
75
75
  export declare const createAndFillTableElement: (state: ManuscriptEditorState, config?: TableConfig) => import("prosemirror-model").Node;
76
+ export declare const isCommentingAllowed: (type: NodeType) => boolean;
76
77
  export declare const addNodeComment: (node: ManuscriptNode, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
77
78
  export declare const addInlineComment: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
78
79
  export declare const addRows: (direction: 'top' | 'bottom') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
@@ -15,16 +15,12 @@
15
15
  */
16
16
  import { ManuscriptEditorView, ManuscriptNode } from '@manuscripts/transform';
17
17
  export declare const sectionLevel: (depth: number) => string;
18
- interface Actions {
19
- addComment?: boolean;
20
- }
21
18
  export declare const contextMenuBtnClass = "btn-context-menu";
22
19
  export declare class ContextMenu {
23
20
  private readonly node;
24
21
  private readonly view;
25
22
  private readonly getPos;
26
- private readonly actions;
27
- constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number, actions?: Actions);
23
+ constructor(node: ManuscriptNode, view: ManuscriptEditorView, getPos: () => number);
28
24
  showAddMenu: (target: Element, after: boolean) => void;
29
25
  showEditMenu: (target: Element) => void;
30
26
  private createMenuItem;
@@ -37,4 +33,3 @@ export declare class ContextMenu {
37
33
  private trimTitle;
38
34
  private getCommentTarget;
39
35
  }
40
- export {};
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.7.30";
1
+ export declare const VERSION = "2.7.31";
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.7.30",
4
+ "version": "2.7.31",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",