@manuscripts/body-editor 2.6.18 → 2.6.19
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.
- package/dist/cjs/commands.js +17 -1
- package/dist/cjs/components/views/TableCellContextMenu.js +13 -7
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +18 -3
- package/dist/es/components/views/TableCellContextMenu.js +14 -8
- package/dist/es/versions.js +1 -1
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/versions.d.ts +1 -1
- package/package.json +1 -1
- package/styles/Editor.css +6 -2
package/dist/cjs/commands.js
CHANGED
|
@@ -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.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.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.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = exports.addToStart = void 0;
|
|
18
|
+
exports.autoComplete = exports.mergeCellsWithSpace = 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.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.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");
|
|
@@ -1045,6 +1045,22 @@ const addRows = (direction) => (state, dispatch) => {
|
|
|
1045
1045
|
return true;
|
|
1046
1046
|
};
|
|
1047
1047
|
exports.addRows = addRows;
|
|
1048
|
+
const addHeaderRow = (direction) => (state, dispatch) => {
|
|
1049
|
+
if (dispatch) {
|
|
1050
|
+
const { tr } = state;
|
|
1051
|
+
const rect = (0, prosemirror_tables_1.selectedRect)(state);
|
|
1052
|
+
const addRowStep = (0, prosemirror_tables_1.addRow)(state.tr, rect, rect[direction === 'below' ? 'bottom' : 'top']).steps.pop();
|
|
1053
|
+
if (addRowStep && addRowStep instanceof prosemirror_transform_1.ReplaceStep) {
|
|
1054
|
+
const { from, to, slice } = addRowStep;
|
|
1055
|
+
const cells = (0, prosemirror_utils_1.flatten)(slice.content.firstChild);
|
|
1056
|
+
const row = transform_1.schema.nodes.table_row.create(undefined, cells.map((cell) => transform_1.schema.nodes.table_header.create(cell.node.attrs, cell.node.content)));
|
|
1057
|
+
tr.step(new prosemirror_transform_1.ReplaceStep(from, to, new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from(row), slice.openStart, slice.openEnd)));
|
|
1058
|
+
dispatch(tr);
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
return true;
|
|
1062
|
+
};
|
|
1063
|
+
exports.addHeaderRow = addHeaderRow;
|
|
1048
1064
|
const addColumns = (direction) => (state, dispatch) => {
|
|
1049
1065
|
if (dispatch) {
|
|
1050
1066
|
const { tr } = state;
|
|
@@ -42,11 +42,7 @@ const getSelectedCellsCount = (state) => {
|
|
|
42
42
|
selectedCells.rows = rect.bottom - rect.top;
|
|
43
43
|
selectedCells.columns = rect.right - rect.left;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
rows: rows > 1 ? `${rows} rows` : `row`,
|
|
48
|
-
columns: columns > 1 ? `${columns} columns` : `column`,
|
|
49
|
-
};
|
|
45
|
+
return selectedCells;
|
|
50
46
|
};
|
|
51
47
|
const isHeaderCellSelected = (state) => {
|
|
52
48
|
var _a;
|
|
@@ -76,7 +72,10 @@ const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
|
|
|
76
72
|
const [columnAction, setColumnAction] = (0, react_1.useState)();
|
|
77
73
|
const isCellSelectionMerged = (0, prosemirror_tables_1.mergeCells)(view.state);
|
|
78
74
|
const isCellSelectionSplittable = (0, prosemirror_tables_1.splitCell)(view.state);
|
|
79
|
-
const
|
|
75
|
+
const count = getSelectedCellsCount(view.state);
|
|
76
|
+
const rows = count.rows > 1 ? `${count.rows} rows` : `row`;
|
|
77
|
+
const columns = count.columns > 1 ? `${count.columns} columns` : `column`;
|
|
78
|
+
const headerPosition = isHeaderCellSelected(view.state) ? 'below' : 'above';
|
|
80
79
|
return (react_1.default.createElement(MenuDropdownList, { className: 'table-ctx' },
|
|
81
80
|
react_1.default.createElement(ActionButton, { disabled: isHeaderCellSelected(view.state), onClick: () => runCommand((0, commands_1.addRows)('top')) },
|
|
82
81
|
react_1.default.createElement(style_guide_1.PlusIcon, null),
|
|
@@ -99,9 +98,16 @@ const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
|
|
|
99
98
|
columns,
|
|
100
99
|
" to the right"),
|
|
101
100
|
react_1.default.createElement(Separator, null),
|
|
101
|
+
react_1.default.createElement(ActionButton, { disabled: count.rows !== 1, onClick: () => runCommand((0, commands_1.addHeaderRow)(headerPosition)) },
|
|
102
|
+
react_1.default.createElement(style_guide_1.PlusIcon, null),
|
|
103
|
+
" Insert header row ",
|
|
104
|
+
headerPosition),
|
|
105
|
+
react_1.default.createElement(Separator, null),
|
|
102
106
|
react_1.default.createElement(ActionButton, { onClick: () => runCommand(prosemirror_tables_1.deleteRow) },
|
|
103
107
|
react_1.default.createElement(GrayDeleteIcon, null),
|
|
104
|
-
" Delete
|
|
108
|
+
" Delete",
|
|
109
|
+
isHeaderCellSelected(view.state) ? ' header ' : '',
|
|
110
|
+
" ",
|
|
105
111
|
rows),
|
|
106
112
|
react_1.default.createElement(ActionButton, { onClick: () => setColumnAction(() => prosemirror_tables_1.deleteColumn) },
|
|
107
113
|
react_1.default.createElement(GrayDeleteIcon, null),
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
import { buildContribution } from '@manuscripts/json-schema';
|
|
17
17
|
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
|
18
18
|
import { generateNodeID, isElementNodeType, isListNode, isSectionNodeType, isTableElementNode, schema, } from '@manuscripts/transform';
|
|
19
|
-
import { Fragment, NodeRange, } from 'prosemirror-model';
|
|
19
|
+
import { Fragment, NodeRange, Slice, } from 'prosemirror-model';
|
|
20
20
|
import { wrapInList } from 'prosemirror-schema-list';
|
|
21
21
|
import { NodeSelection, TextSelection, } from 'prosemirror-state';
|
|
22
22
|
import { addColSpan, addColumnAfter, addColumnBefore, addRow, CellSelection, selectedRect, } from 'prosemirror-tables';
|
|
23
|
-
import { findWrapping, liftTarget, ReplaceAroundStep, } from 'prosemirror-transform';
|
|
24
|
-
import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, } from 'prosemirror-utils';
|
|
23
|
+
import { findWrapping, liftTarget, ReplaceAroundStep, ReplaceStep, } from 'prosemirror-transform';
|
|
24
|
+
import { findChildrenByType, findParentNodeOfType, findParentNodeOfTypeClosestToPos, flatten, hasParentNodeOfType, } from 'prosemirror-utils';
|
|
25
25
|
import { getCommentKey, getCommentRange } from './lib/comments';
|
|
26
26
|
import { findBackmatter, findBibliographySection, findBody, insertFootnotesSection, insertSupplementsNode, } from './lib/doc';
|
|
27
27
|
import { createFootnote, findFootnotesContainerNode, getFootnotesElementState, } from './lib/footnotes';
|
|
@@ -997,6 +997,21 @@ export const addRows = (direction) => (state, dispatch) => {
|
|
|
997
997
|
}
|
|
998
998
|
return true;
|
|
999
999
|
};
|
|
1000
|
+
export const addHeaderRow = (direction) => (state, dispatch) => {
|
|
1001
|
+
if (dispatch) {
|
|
1002
|
+
const { tr } = state;
|
|
1003
|
+
const rect = selectedRect(state);
|
|
1004
|
+
const addRowStep = addRow(state.tr, rect, rect[direction === 'below' ? 'bottom' : 'top']).steps.pop();
|
|
1005
|
+
if (addRowStep && addRowStep instanceof ReplaceStep) {
|
|
1006
|
+
const { from, to, slice } = addRowStep;
|
|
1007
|
+
const cells = flatten(slice.content.firstChild);
|
|
1008
|
+
const row = schema.nodes.table_row.create(undefined, cells.map((cell) => schema.nodes.table_header.create(cell.node.attrs, cell.node.content)));
|
|
1009
|
+
tr.step(new ReplaceStep(from, to, new Slice(Fragment.from(row), slice.openStart, slice.openEnd)));
|
|
1010
|
+
dispatch(tr);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return true;
|
|
1014
|
+
};
|
|
1000
1015
|
export const addColumns = (direction) => (state, dispatch) => {
|
|
1001
1016
|
if (dispatch) {
|
|
1002
1017
|
const { tr } = state;
|
|
@@ -4,7 +4,7 @@ import { schema } from '@manuscripts/transform';
|
|
|
4
4
|
import { CellSelection, deleteColumn, deleteRow, mergeCells, selectedRect, splitCell, } from 'prosemirror-tables';
|
|
5
5
|
import React, { useState } from 'react';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
|
-
import { addColumns, addRows, mergeCellsWithSpace } from '../../commands';
|
|
7
|
+
import { addColumns, addHeaderRow, addRows, mergeCellsWithSpace, } from '../../commands';
|
|
8
8
|
const getSelectedCellsCount = (state) => {
|
|
9
9
|
const { selection } = state;
|
|
10
10
|
const selectedCells = { rows: 1, columns: 1 };
|
|
@@ -13,11 +13,7 @@ const getSelectedCellsCount = (state) => {
|
|
|
13
13
|
selectedCells.rows = rect.bottom - rect.top;
|
|
14
14
|
selectedCells.columns = rect.right - rect.left;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
rows: rows > 1 ? `${rows} rows` : `row`,
|
|
19
|
-
columns: columns > 1 ? `${columns} columns` : `column`,
|
|
20
|
-
};
|
|
16
|
+
return selectedCells;
|
|
21
17
|
};
|
|
22
18
|
const isHeaderCellSelected = (state) => {
|
|
23
19
|
var _a;
|
|
@@ -47,7 +43,10 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
|
|
|
47
43
|
const [columnAction, setColumnAction] = useState();
|
|
48
44
|
const isCellSelectionMerged = mergeCells(view.state);
|
|
49
45
|
const isCellSelectionSplittable = splitCell(view.state);
|
|
50
|
-
const
|
|
46
|
+
const count = getSelectedCellsCount(view.state);
|
|
47
|
+
const rows = count.rows > 1 ? `${count.rows} rows` : `row`;
|
|
48
|
+
const columns = count.columns > 1 ? `${count.columns} columns` : `column`;
|
|
49
|
+
const headerPosition = isHeaderCellSelected(view.state) ? 'below' : 'above';
|
|
51
50
|
return (React.createElement(MenuDropdownList, { className: 'table-ctx' },
|
|
52
51
|
React.createElement(ActionButton, { disabled: isHeaderCellSelected(view.state), onClick: () => runCommand(addRows('top')) },
|
|
53
52
|
React.createElement(PlusIcon, null),
|
|
@@ -70,9 +69,16 @@ export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
|
|
|
70
69
|
columns,
|
|
71
70
|
" to the right"),
|
|
72
71
|
React.createElement(Separator, null),
|
|
72
|
+
React.createElement(ActionButton, { disabled: count.rows !== 1, onClick: () => runCommand(addHeaderRow(headerPosition)) },
|
|
73
|
+
React.createElement(PlusIcon, null),
|
|
74
|
+
" Insert header row ",
|
|
75
|
+
headerPosition),
|
|
76
|
+
React.createElement(Separator, null),
|
|
73
77
|
React.createElement(ActionButton, { onClick: () => runCommand(deleteRow) },
|
|
74
78
|
React.createElement(GrayDeleteIcon, null),
|
|
75
|
-
" Delete
|
|
79
|
+
" Delete",
|
|
80
|
+
isHeaderCellSelected(view.state) ? ' header ' : '',
|
|
81
|
+
" ",
|
|
76
82
|
rows),
|
|
77
83
|
React.createElement(ActionButton, { onClick: () => setColumnAction(() => deleteColumn) },
|
|
78
84
|
React.createElement(GrayDeleteIcon, null),
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.6.
|
|
1
|
+
export const VERSION = '2.6.19';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export declare const createAndFillTableElement: (state: ManuscriptEditorState, c
|
|
|
73
73
|
export declare const addNodeComment: (node: ManuscriptNode, state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
74
74
|
export declare const addInlineComment: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
75
75
|
export declare const addRows: (direction: 'top' | 'bottom') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
76
|
+
export declare const addHeaderRow: (direction: 'above' | 'below') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
76
77
|
export declare const addColumns: (direction: 'right' | 'left') => (state: EditorState, dispatch?: ((tr: Transaction) => void) | undefined) => boolean;
|
|
77
78
|
export declare function mergeCellsWithSpace(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
78
79
|
export declare const autoComplete: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.6.
|
|
1
|
+
export declare const VERSION = "2.6.19";
|
|
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.6.
|
|
4
|
+
"version": "2.6.19",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
package/styles/Editor.css
CHANGED
|
@@ -133,14 +133,18 @@
|
|
|
133
133
|
padding: 10px;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
.ProseMirror tr
|
|
136
|
+
.ProseMirror tr th {
|
|
137
137
|
border-top: 1px solid #000;
|
|
138
138
|
border-bottom: 1px solid #000;
|
|
139
|
-
background: #
|
|
139
|
+
background: #E2E2E2;
|
|
140
140
|
text-align: left;
|
|
141
141
|
font-weight: bold;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
.ProseMirror tr th:not(:last-child) {
|
|
145
|
+
border-right: 1px solid #C9C9C9;
|
|
146
|
+
}
|
|
147
|
+
|
|
144
148
|
.ProseMirror tr td {
|
|
145
149
|
border-top: 1px solid #000;
|
|
146
150
|
border-bottom: 1px solid #000;
|