@manuscripts/body-editor 3.18.2 → 3.18.3

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.
@@ -16,7 +16,7 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.isAtEndOfTextBlock = exports.ignoreMetaNodeBackspaceCommand = exports.ignoreAtomBlockNodeBackward = exports.isTextSelection = exports.isAtStartOfTextBlock = exports.insertTransGraphicalAbstract = exports.insertTransAbstract = exports.insertTOCSection = exports.insertBibliographySection = exports.insertList = exports.insertKeywords = exports.insertAward = exports.insertAffiliation = exports.insertContributors = exports.insertGraphicalAbstract = exports.insertBackmatterSection = exports.insertAbstractSection = exports.insertSection = exports.insertHeadshotGrid = exports.insertBoxElement = exports.insertInlineFootnote = exports.insertFootnotesElement = exports.insertTableElementFooter = exports.insertInlineEquation = exports.insertCrossReference = exports.canInsertCrossReference = exports.insertInlineCitation = exports.insertLink = exports.insertSectionLabel = exports.findPosBeforeFirstSubsection = exports.insertBreak = exports.deleteBlock = exports.insertBlock = exports.insertAttachment = exports.updateSupplementWeblink = exports.convertLinkToSupplementWeblink = exports.insertSupplementWeblink = exports.insertSupplement = exports.insertTable = exports.insertEmbed = exports.insertFigure = exports.insertGeneralTableFootnote = exports.insertInlineTableFootnote = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
19
- exports.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = void 0;
19
+ exports.paste = exports.copySelection = exports.exitEditorToContainer = exports.ignoreEnterInSubtitles = exports.insertHeroImage = exports.activateSearchReplace = exports.activateSearch = exports.autoComplete = exports.addColumns = exports.addHeaderRow = exports.addRows = exports.addInlineComment = exports.canInsertInlineComment = exports.addNodeComment = exports.createAndFillTableElement = exports.selectAllIsolating = exports.ignoreAtomBlockNodeForward = void 0;
20
20
  const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
21
21
  const transform_1 = require("@manuscripts/transform");
22
22
  const prosemirror_model_1 = require("prosemirror-model");
@@ -1289,12 +1289,17 @@ const addNodeComment = (node, state, dispatch) => {
1289
1289
  return false;
1290
1290
  };
1291
1291
  exports.addNodeComment = addNodeComment;
1292
+ const canInsertInlineComment = ($pos) => $pos.parent.canReplaceWith($pos.index(), $pos.index(), transform_1.schema.nodes.highlight_marker);
1293
+ exports.canInsertInlineComment = canInsertInlineComment;
1292
1294
  const addInlineComment = (state, dispatch) => {
1293
1295
  const selection = state.selection;
1294
1296
  const node = getParentNode(selection);
1295
1297
  if (!node) {
1296
1298
  return false;
1297
1299
  }
1300
+ if (!(0, exports.canInsertInlineComment)(selection.$from)) {
1301
+ return false;
1302
+ }
1298
1303
  let from = selection.from;
1299
1304
  let to = selection.to;
1300
1305
  if (from === to) {
@@ -116,7 +116,7 @@ exports.toolbar = {
116
116
  comment: {
117
117
  title: 'Insert comment',
118
118
  content: react_1.default.createElement(style_guide_1.AddCommentIcon, null),
119
- isEnabled: isEnabled((0, commands_1.canInsert)(transform_1.schema.nodes.highlight_marker)),
119
+ isEnabled: isEnabled((state) => (0, commands_1.canInsertInlineComment)(state.selection.$from)),
120
120
  run: commands_1.addInlineComment,
121
121
  },
122
122
  cross_reference: {
@@ -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.18.2';
4
+ exports.VERSION = '3.18.3';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -1231,12 +1231,16 @@ export const addNodeComment = (node, state, dispatch) => {
1231
1231
  }
1232
1232
  return false;
1233
1233
  };
1234
+ export const canInsertInlineComment = ($pos) => $pos.parent.canReplaceWith($pos.index(), $pos.index(), schema.nodes.highlight_marker);
1234
1235
  export const addInlineComment = (state, dispatch) => {
1235
1236
  const selection = state.selection;
1236
1237
  const node = getParentNode(selection);
1237
1238
  if (!node) {
1238
1239
  return false;
1239
1240
  }
1241
+ if (!canInsertInlineComment(selection.$from)) {
1242
+ return false;
1243
+ }
1240
1244
  let from = selection.from;
1241
1245
  let to = selection.to;
1242
1246
  if (from === to) {
@@ -17,7 +17,7 @@ import { AddCommentIcon, FileImageIcon, LinkIcon, OutlineBlockQuoteIcon, Outline
17
17
  import { schema } from '@manuscripts/transform';
18
18
  import { toggleMark } from 'prosemirror-commands';
19
19
  import React from 'react';
20
- import { addInlineComment, blockActive, canInsert, canInsertCrossReference, insertBlock, insertBoxElement, insertCrossReference, insertEmbed, insertInlineCitation, insertLink, insertList, markActive, } from './commands';
20
+ import { addInlineComment, blockActive, canInsert, canInsertCrossReference, canInsertInlineComment, insertBlock, insertBoxElement, insertCrossReference, insertEmbed, insertInlineCitation, insertLink, insertList, markActive, } from './commands';
21
21
  import { changeIndentation, isIndentationAllowed, } from './components/toolbar/helpers';
22
22
  import { openInsertTableDialog } from './components/toolbar/InsertTableDialog';
23
23
  import { openInsertSpecialCharacterDialog } from './components/views/InsertSpecialCharacter';
@@ -110,7 +110,7 @@ export const toolbar = {
110
110
  comment: {
111
111
  title: 'Insert comment',
112
112
  content: React.createElement(AddCommentIcon, null),
113
- isEnabled: isEnabled(canInsert(schema.nodes.highlight_marker)),
113
+ isEnabled: isEnabled((state) => canInsertInlineComment(state.selection.$from)),
114
114
  run: addInlineComment,
115
115
  },
116
116
  cross_reference: {
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.18.2';
1
+ export const VERSION = '3.18.3';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -83,6 +83,7 @@ export type TableConfig = {
83
83
  };
84
84
  export declare const createAndFillTableElement: (attrs?: Attrs, config?: TableConfig) => import("prosemirror-model").Node;
85
85
  export declare const addNodeComment: (node: ManuscriptNode, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
86
+ export declare const canInsertInlineComment: ($pos: ResolvedPos) => boolean;
86
87
  export declare const addInlineComment: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
87
88
  export declare const addRows: (direction: "top" | "bottom") => (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
88
89
  export declare const addHeaderRow: (direction: "above" | "below") => (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.18.2";
1
+ export declare const VERSION = "3.18.3";
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.18.2",
4
+ "version": "3.18.3",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",
package/src/commands.ts CHANGED
@@ -1942,6 +1942,13 @@ export const addNodeComment = (
1942
1942
  return false
1943
1943
  }
1944
1944
 
1945
+ export const canInsertInlineComment = ($pos: ResolvedPos) =>
1946
+ $pos.parent.canReplaceWith(
1947
+ $pos.index(),
1948
+ $pos.index(),
1949
+ schema.nodes.highlight_marker
1950
+ )
1951
+
1945
1952
  export const addInlineComment = (
1946
1953
  state: ManuscriptEditorState,
1947
1954
  dispatch?: Dispatch
@@ -1951,6 +1958,11 @@ export const addInlineComment = (
1951
1958
  if (!node) {
1952
1959
  return false
1953
1960
  }
1961
+
1962
+ if (!canInsertInlineComment(selection.$from)) {
1963
+ return false
1964
+ }
1965
+
1954
1966
  let from = selection.from
1955
1967
  let to = selection.to
1956
1968
 
package/src/toolbar.tsx CHANGED
@@ -49,6 +49,7 @@ import {
49
49
  blockActive,
50
50
  canInsert,
51
51
  canInsertCrossReference,
52
+ canInsertInlineComment,
52
53
  Dispatch,
53
54
  insertBlock,
54
55
  insertBoxElement,
@@ -179,7 +180,9 @@ export const toolbar: ToolbarConfig = {
179
180
  comment: {
180
181
  title: 'Insert comment',
181
182
  content: <AddCommentIcon />,
182
- isEnabled: isEnabled(canInsert(schema.nodes.highlight_marker)), // TODO: check both ends of selection
183
+ isEnabled: isEnabled((state) =>
184
+ canInsertInlineComment(state.selection.$from)
185
+ ),
183
186
  run: addInlineComment,
184
187
  },
185
188
  cross_reference: {
package/src/versions.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  //THIS FILE WAS GENERATED BY versions.mjs
2
- export const VERSION = '3.18.2';
2
+ export const VERSION = '3.18.3';
3
3
  export const MATHJAX_VERSION = '3.2.2';