@manuscripts/body-editor 3.6.20 → 3.6.22

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.
@@ -44,6 +44,7 @@ const prosemirror_tables_1 = require("prosemirror-tables");
44
44
  const react_1 = __importStar(require("react"));
45
45
  const styled_components_1 = __importDefault(require("styled-components"));
46
46
  const commands_1 = require("../../commands");
47
+ const editor_props_1 = require("../../plugins/editor-props");
47
48
  const getSelectedCellsCount = (state) => {
48
49
  const { selection } = state;
49
50
  const selectedCells = { rows: 1, columns: 1 };
@@ -80,6 +81,15 @@ const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
80
81
  const rows = count.rows > 1 ? `${count.rows} rows` : `row`;
81
82
  const columns = count.columns > 1 ? `${count.columns} columns` : `column`;
82
83
  const headerPosition = isHeaderCellSelected(view.state) ? 'below' : 'above';
84
+ const showWarningForTCPlugin = (action, command) => {
85
+ const props = (0, editor_props_1.getEditorProps)(view.state);
86
+ if (!props.getCapabilities().editWithoutTracking) {
87
+ action(command);
88
+ }
89
+ else {
90
+ runCommand(command(), true);
91
+ }
92
+ };
83
93
  return (react_1.default.createElement(MenuDropdownList, { className: 'table-ctx' },
84
94
  react_1.default.createElement(ActionButton, { disabled: isHeaderCellSelected(view.state), onClick: () => runCommand((0, commands_1.addRows)('top')) },
85
95
  react_1.default.createElement(style_guide_1.PlusIcon, null),
@@ -91,12 +101,12 @@ const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
91
101
  " Insert ",
92
102
  rows,
93
103
  " below"),
94
- react_1.default.createElement(ActionButton, { onClick: () => setColumnAction(() => (0, commands_1.addColumns)('left')) },
104
+ react_1.default.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setColumnAction, () => (0, commands_1.addColumns)('left')) },
95
105
  react_1.default.createElement(style_guide_1.PlusIcon, null),
96
106
  " Insert ",
97
107
  columns,
98
108
  " to the left"),
99
- react_1.default.createElement(ActionButton, { onClick: () => setColumnAction(() => (0, commands_1.addColumns)('right')) },
109
+ react_1.default.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setColumnAction, () => (0, commands_1.addColumns)('right')) },
100
110
  react_1.default.createElement(style_guide_1.PlusIcon, null),
101
111
  " Insert ",
102
112
  columns,
@@ -107,13 +117,13 @@ const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
107
117
  " Insert header row ",
108
118
  headerPosition),
109
119
  react_1.default.createElement(Separator, null),
110
- react_1.default.createElement(ActionButton, { onClick: () => setRowDeleteAction(() => prosemirror_tables_1.deleteRow) },
120
+ react_1.default.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setRowDeleteAction, () => prosemirror_tables_1.deleteRow) },
111
121
  react_1.default.createElement(GrayDeleteIcon, null),
112
122
  " Delete",
113
123
  isHeaderCellSelected(view.state) ? ' header ' : '',
114
124
  " ",
115
125
  rows),
116
- react_1.default.createElement(ActionButton, { onClick: () => setColumnAction(() => prosemirror_tables_1.deleteColumn) },
126
+ react_1.default.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setColumnAction, () => prosemirror_tables_1.deleteColumn) },
117
127
  react_1.default.createElement(GrayDeleteIcon, null),
118
128
  " Delete ",
119
129
  columns),
@@ -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.6.20';
4
+ exports.VERSION = '3.6.22';
5
5
  exports.MATHJAX_VERSION = '3.2.2';
@@ -17,7 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.FigureEditableView = void 0;
19
19
  const transform_1 = require("@manuscripts/transform");
20
- const prosemirror_state_1 = require("prosemirror-state");
21
20
  const prosemirror_utils_1 = require("prosemirror-utils");
22
21
  const icons_1 = require("../icons");
23
22
  const media_1 = require("../lib/media");
@@ -40,7 +39,6 @@ class FigureEditableView extends figure_1.FigureView {
40
39
  ...this.node.attrs,
41
40
  src: src,
42
41
  });
43
- tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, pos));
44
42
  this.view.dispatch(tr);
45
43
  };
46
44
  this.createUnsupportedFormat = (name) => {
@@ -5,6 +5,7 @@ import { CellSelection, deleteColumn, deleteRow, mergeCells, selectedRect, split
5
5
  import React, { useState } from 'react';
6
6
  import styled from 'styled-components';
7
7
  import { addColumns, addHeaderRow, addRows } from '../../commands';
8
+ import { getEditorProps } from '../../plugins/editor-props';
8
9
  const getSelectedCellsCount = (state) => {
9
10
  const { selection } = state;
10
11
  const selectedCells = { rows: 1, columns: 1 };
@@ -41,6 +42,15 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
41
42
  const rows = count.rows > 1 ? `${count.rows} rows` : `row`;
42
43
  const columns = count.columns > 1 ? `${count.columns} columns` : `column`;
43
44
  const headerPosition = isHeaderCellSelected(view.state) ? 'below' : 'above';
45
+ const showWarningForTCPlugin = (action, command) => {
46
+ const props = getEditorProps(view.state);
47
+ if (!props.getCapabilities().editWithoutTracking) {
48
+ action(command);
49
+ }
50
+ else {
51
+ runCommand(command(), true);
52
+ }
53
+ };
44
54
  return (React.createElement(MenuDropdownList, { className: 'table-ctx' },
45
55
  React.createElement(ActionButton, { disabled: isHeaderCellSelected(view.state), onClick: () => runCommand(addRows('top')) },
46
56
  React.createElement(PlusIcon, null),
@@ -52,12 +62,12 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
52
62
  " Insert ",
53
63
  rows,
54
64
  " below"),
55
- React.createElement(ActionButton, { onClick: () => setColumnAction(() => addColumns('left')) },
65
+ React.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setColumnAction, () => addColumns('left')) },
56
66
  React.createElement(PlusIcon, null),
57
67
  " Insert ",
58
68
  columns,
59
69
  " to the left"),
60
- React.createElement(ActionButton, { onClick: () => setColumnAction(() => addColumns('right')) },
70
+ React.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setColumnAction, () => addColumns('right')) },
61
71
  React.createElement(PlusIcon, null),
62
72
  " Insert ",
63
73
  columns,
@@ -68,13 +78,13 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
68
78
  " Insert header row ",
69
79
  headerPosition),
70
80
  React.createElement(Separator, null),
71
- React.createElement(ActionButton, { onClick: () => setRowDeleteAction(() => deleteRow) },
81
+ React.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setRowDeleteAction, () => deleteRow) },
72
82
  React.createElement(GrayDeleteIcon, null),
73
83
  " Delete",
74
84
  isHeaderCellSelected(view.state) ? ' header ' : '',
75
85
  " ",
76
86
  rows),
77
- React.createElement(ActionButton, { onClick: () => setColumnAction(() => deleteColumn) },
87
+ React.createElement(ActionButton, { onClick: () => showWarningForTCPlugin(setColumnAction, () => deleteColumn) },
78
88
  React.createElement(GrayDeleteIcon, null),
79
89
  " Delete ",
80
90
  columns),
@@ -1,2 +1,2 @@
1
- export const VERSION = '3.6.20';
1
+ export const VERSION = '3.6.22';
2
2
  export const MATHJAX_VERSION = '3.2.2';
@@ -14,7 +14,6 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { schema } from '@manuscripts/transform';
17
- import { NodeSelection } from 'prosemirror-state';
18
17
  import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
19
18
  import { draggableIcon } from '../icons';
20
19
  import { addInteractionHandlers, createFileHandlers, createFileUploader, createMediaPlaceholder, createReactTools, createUnsupportedFormat, MediaType, } from '../lib/media';
@@ -37,7 +36,6 @@ export class FigureEditableView extends FigureView {
37
36
  ...this.node.attrs,
38
37
  src: src,
39
38
  });
40
- tr.setSelection(NodeSelection.create(tr.doc, pos));
41
39
  this.view.dispatch(tr);
42
40
  };
43
41
  this.createUnsupportedFormat = (name) => {
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "3.6.20";
1
+ export declare const VERSION = "3.6.22";
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.6.20",
4
+ "version": "3.6.22",
5
5
  "repository": "github:Atypon-OpenSource/manuscripts-body-editor",
6
6
  "license": "Apache-2.0",
7
7
  "main": "dist/cjs",