@manuscripts/body-editor 2.6.9-LEAN-4097.0 → 2.6.9
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 -21
- package/dist/cjs/components/views/TableCellContextMenu.js +11 -4
- package/dist/cjs/plugins/elements.js +1 -1
- package/dist/cjs/plugins/placeholder.js +0 -3
- package/dist/cjs/versions.js +1 -1
- package/dist/es/commands.js +17 -21
- package/dist/es/components/views/TableCellContextMenu.js +11 -4
- package/dist/es/plugins/elements.js +2 -2
- package/dist/es/plugins/placeholder.js +1 -4
- package/dist/es/versions.js +1 -1
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -516,36 +516,32 @@ const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
|
516
516
|
};
|
|
517
517
|
exports.insertGraphicalAbstract = insertGraphicalAbstract;
|
|
518
518
|
const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.bibliography_section)) {
|
|
523
|
-
return false;
|
|
524
|
-
}
|
|
525
|
-
else if (subsection) {
|
|
526
|
-
pos =
|
|
527
|
-
(0, exports.findPosBeforeFirstSubsection)($pos) || findPosAfterParentSection($pos);
|
|
528
|
-
if (!pos) {
|
|
529
|
-
return false;
|
|
530
|
-
}
|
|
531
|
-
pos -= 1;
|
|
532
|
-
}
|
|
533
|
-
else if ((0, prosemirror_utils_1.findParentNodeOfTypeClosestToPos)($pos, nodes.box_element)) {
|
|
519
|
+
const selection = state.selection;
|
|
520
|
+
if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.bibliography_section)(selection) ||
|
|
521
|
+
(!subsection && (0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.box_element)(selection))) {
|
|
534
522
|
return false;
|
|
535
523
|
}
|
|
536
|
-
|
|
537
|
-
|
|
524
|
+
let pos;
|
|
525
|
+
if ((0, prosemirror_utils_1.hasParentNodeOfType)(transform_1.schema.nodes.body)(selection) || subsection) {
|
|
526
|
+
pos = subsection
|
|
527
|
+
? (0, exports.findPosBeforeFirstSubsection)(state.selection.$from) ||
|
|
528
|
+
findPosAfterParentSection(state.selection.$from)
|
|
529
|
+
: findPosAfterParentSection(state.selection.$from);
|
|
538
530
|
}
|
|
539
|
-
|
|
531
|
+
else {
|
|
540
532
|
const body = (0, doc_1.findBody)(state.doc);
|
|
541
533
|
pos = body.pos + body.node.content.size + 1;
|
|
542
534
|
}
|
|
543
|
-
|
|
535
|
+
if (!pos) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
const section = transform_1.schema.nodes.section.createAndFill({
|
|
544
539
|
category: subsection ? 'MPSectionCategory:subsection' : '',
|
|
545
540
|
});
|
|
546
|
-
const
|
|
541
|
+
const diff = subsection ? -1 : 0;
|
|
542
|
+
const tr = state.tr.insert(pos + diff, section);
|
|
547
543
|
if (dispatch) {
|
|
548
|
-
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + 2);
|
|
544
|
+
const selection = prosemirror_state_1.TextSelection.create(tr.doc, pos + diff + 2);
|
|
549
545
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
550
546
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
551
547
|
}
|
|
@@ -48,6 +48,16 @@ const getSelectedCellsCount = (state) => {
|
|
|
48
48
|
columns: columns > 1 ? `${columns} columns` : `column`,
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
|
+
const isHeaderCellSelected = (state) => {
|
|
52
|
+
var _a;
|
|
53
|
+
if (state.selection instanceof prosemirror_tables_1.CellSelection) {
|
|
54
|
+
const anchorNode = state.selection.$anchorCell.node(state.selection.$anchorCell.depth).firstChild;
|
|
55
|
+
const headNode = state.selection.$headCell.node(state.selection.$headCell.depth).firstChild;
|
|
56
|
+
return ((anchorNode === null || anchorNode === void 0 ? void 0 : anchorNode.type) === transform_1.schema.nodes.table_header ||
|
|
57
|
+
(headNode === null || headNode === void 0 ? void 0 : headNode.type) === transform_1.schema.nodes.table_header);
|
|
58
|
+
}
|
|
59
|
+
return (((_a = state.doc.nodeAt(state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.table_header);
|
|
60
|
+
};
|
|
51
61
|
const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (react_1.default.createElement(style_guide_1.Dialog, { isOpen: isOpen, category: style_guide_1.Category.confirmation, header: "This change can't be tracked", message: "This column action won't be marked as chnage. Do you want to continue?", actions: {
|
|
52
62
|
primary: {
|
|
53
63
|
action: primaryAction,
|
|
@@ -59,19 +69,16 @@ const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) =
|
|
|
59
69
|
},
|
|
60
70
|
} }));
|
|
61
71
|
const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
|
|
62
|
-
var _a;
|
|
63
72
|
const runCommand = (command, noTracking) => {
|
|
64
73
|
command(view.state, (tr) => view.dispatch((noTracking && (0, track_changes_plugin_1.skipTracking)(tr)) || tr));
|
|
65
74
|
close();
|
|
66
75
|
};
|
|
67
76
|
const [columnAction, setColumnAction] = (0, react_1.useState)();
|
|
68
|
-
const isHeaderCellSelected = ((_a = view.state.doc.nodeAt(view.state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) ===
|
|
69
|
-
transform_1.schema.nodes.table_header;
|
|
70
77
|
const isCellSelectionMerged = (0, prosemirror_tables_1.mergeCells)(view.state);
|
|
71
78
|
const isCellSelectionSplittable = (0, prosemirror_tables_1.splitCell)(view.state);
|
|
72
79
|
const { rows, columns } = getSelectedCellsCount(view.state);
|
|
73
80
|
return (react_1.default.createElement(MenuDropdownList, { className: 'table-ctx' },
|
|
74
|
-
react_1.default.createElement(ActionButton, { disabled: isHeaderCellSelected, onClick: () => runCommand((0, commands_1.addRows)('top')) },
|
|
81
|
+
react_1.default.createElement(ActionButton, { disabled: isHeaderCellSelected(view.state), onClick: () => runCommand((0, commands_1.addRows)('top')) },
|
|
75
82
|
react_1.default.createElement(style_guide_1.PlusIcon, null),
|
|
76
83
|
" Insert ",
|
|
77
84
|
rows,
|
|
@@ -26,7 +26,7 @@ exports.default = () => {
|
|
|
26
26
|
const decorations = [];
|
|
27
27
|
state.doc.descendants((node, pos, parent) => {
|
|
28
28
|
if (parent &&
|
|
29
|
-
(
|
|
29
|
+
(0, transform_1.isSectionNodeType)(parent.type) &&
|
|
30
30
|
node.type !== section) {
|
|
31
31
|
decorations.push(prosemirror_view_1.Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
32
32
|
element: true,
|
|
@@ -34,9 +34,6 @@ const getParagraphPlaceholderText = (parent) => {
|
|
|
34
34
|
if (!parent || parent.textContent.length) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
if (parent.type === transform_1.schema.nodes.body) {
|
|
38
|
-
return 'Paragraph';
|
|
39
|
-
}
|
|
40
37
|
if ((0, transform_1.isFootnoteNode)(parent) || (0, transform_1.isGeneralTableFootnoteNode)(parent)) {
|
|
41
38
|
return 'Type new footnote here';
|
|
42
39
|
}
|
package/dist/cjs/versions.js
CHANGED
package/dist/es/commands.js
CHANGED
|
@@ -487,36 +487,32 @@ export const insertGraphicalAbstract = (state, dispatch, view) => {
|
|
|
487
487
|
return true;
|
|
488
488
|
};
|
|
489
489
|
export const insertSection = (subsection = false) => (state, dispatch, view) => {
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
if (findParentNodeOfTypeClosestToPos($pos, nodes.bibliography_section)) {
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
else if (subsection) {
|
|
497
|
-
pos =
|
|
498
|
-
findPosBeforeFirstSubsection($pos) || findPosAfterParentSection($pos);
|
|
499
|
-
if (!pos) {
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
pos -= 1;
|
|
503
|
-
}
|
|
504
|
-
else if (findParentNodeOfTypeClosestToPos($pos, nodes.box_element)) {
|
|
490
|
+
const selection = state.selection;
|
|
491
|
+
if (hasParentNodeOfType(schema.nodes.bibliography_section)(selection) ||
|
|
492
|
+
(!subsection && hasParentNodeOfType(schema.nodes.box_element)(selection))) {
|
|
505
493
|
return false;
|
|
506
494
|
}
|
|
507
|
-
|
|
508
|
-
|
|
495
|
+
let pos;
|
|
496
|
+
if (hasParentNodeOfType(schema.nodes.body)(selection) || subsection) {
|
|
497
|
+
pos = subsection
|
|
498
|
+
? findPosBeforeFirstSubsection(state.selection.$from) ||
|
|
499
|
+
findPosAfterParentSection(state.selection.$from)
|
|
500
|
+
: findPosAfterParentSection(state.selection.$from);
|
|
509
501
|
}
|
|
510
|
-
|
|
502
|
+
else {
|
|
511
503
|
const body = findBody(state.doc);
|
|
512
504
|
pos = body.pos + body.node.content.size + 1;
|
|
513
505
|
}
|
|
514
|
-
|
|
506
|
+
if (!pos) {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
const section = schema.nodes.section.createAndFill({
|
|
515
510
|
category: subsection ? 'MPSectionCategory:subsection' : '',
|
|
516
511
|
});
|
|
517
|
-
const
|
|
512
|
+
const diff = subsection ? -1 : 0;
|
|
513
|
+
const tr = state.tr.insert(pos + diff, section);
|
|
518
514
|
if (dispatch) {
|
|
519
|
-
const selection = TextSelection.create(tr.doc, pos + 2);
|
|
515
|
+
const selection = TextSelection.create(tr.doc, pos + diff + 2);
|
|
520
516
|
view === null || view === void 0 ? void 0 : view.focus();
|
|
521
517
|
dispatch(tr.setSelection(selection).scrollIntoView());
|
|
522
518
|
}
|
|
@@ -19,6 +19,16 @@ const getSelectedCellsCount = (state) => {
|
|
|
19
19
|
columns: columns > 1 ? `${columns} columns` : `column`,
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
+
const isHeaderCellSelected = (state) => {
|
|
23
|
+
var _a;
|
|
24
|
+
if (state.selection instanceof CellSelection) {
|
|
25
|
+
const anchorNode = state.selection.$anchorCell.node(state.selection.$anchorCell.depth).firstChild;
|
|
26
|
+
const headNode = state.selection.$headCell.node(state.selection.$headCell.depth).firstChild;
|
|
27
|
+
return ((anchorNode === null || anchorNode === void 0 ? void 0 : anchorNode.type) === schema.nodes.table_header ||
|
|
28
|
+
(headNode === null || headNode === void 0 ? void 0 : headNode.type) === schema.nodes.table_header);
|
|
29
|
+
}
|
|
30
|
+
return (((_a = state.doc.nodeAt(state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.table_header);
|
|
31
|
+
};
|
|
22
32
|
const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) => (React.createElement(Dialog, { isOpen: isOpen, category: Category.confirmation, header: "This change can't be tracked", message: "This column action won't be marked as chnage. Do you want to continue?", actions: {
|
|
23
33
|
primary: {
|
|
24
34
|
action: primaryAction,
|
|
@@ -30,19 +40,16 @@ const ColumnChangeWarningDialog = ({ isOpen, primaryAction, secondaryAction }) =
|
|
|
30
40
|
},
|
|
31
41
|
} }));
|
|
32
42
|
export const ContextMenu = ({ view, close, onCancelColumnDialog }) => {
|
|
33
|
-
var _a;
|
|
34
43
|
const runCommand = (command, noTracking) => {
|
|
35
44
|
command(view.state, (tr) => view.dispatch((noTracking && skipTracking(tr)) || tr));
|
|
36
45
|
close();
|
|
37
46
|
};
|
|
38
47
|
const [columnAction, setColumnAction] = useState();
|
|
39
|
-
const isHeaderCellSelected = ((_a = view.state.doc.nodeAt(view.state.selection.from)) === null || _a === void 0 ? void 0 : _a.type) ===
|
|
40
|
-
schema.nodes.table_header;
|
|
41
48
|
const isCellSelectionMerged = mergeCells(view.state);
|
|
42
49
|
const isCellSelectionSplittable = splitCell(view.state);
|
|
43
50
|
const { rows, columns } = getSelectedCellsCount(view.state);
|
|
44
51
|
return (React.createElement(MenuDropdownList, { className: 'table-ctx' },
|
|
45
|
-
React.createElement(ActionButton, { disabled: isHeaderCellSelected, onClick: () => runCommand(addRows('top')) },
|
|
52
|
+
React.createElement(ActionButton, { disabled: isHeaderCellSelected(view.state), onClick: () => runCommand(addRows('top')) },
|
|
46
53
|
React.createElement(PlusIcon, null),
|
|
47
54
|
" Insert ",
|
|
48
55
|
rows,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { isSectionNodeType
|
|
16
|
+
import { isSectionNodeType } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin } from 'prosemirror-state';
|
|
18
18
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
19
|
export default () => {
|
|
@@ -24,7 +24,7 @@ export default () => {
|
|
|
24
24
|
const decorations = [];
|
|
25
25
|
state.doc.descendants((node, pos, parent) => {
|
|
26
26
|
if (parent &&
|
|
27
|
-
|
|
27
|
+
isSectionNodeType(parent.type) &&
|
|
28
28
|
node.type !== section) {
|
|
29
29
|
decorations.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
30
30
|
element: true,
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { isFootnoteNode, isGeneralTableFootnoteNode,
|
|
16
|
+
import { isFootnoteNode, isGeneralTableFootnoteNode, } from '@manuscripts/transform';
|
|
17
17
|
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
18
18
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
19
19
|
const placeholderWidget = (placeholder) => (view, getPos) => {
|
|
@@ -32,9 +32,6 @@ const getParagraphPlaceholderText = (parent) => {
|
|
|
32
32
|
if (!parent || parent.textContent.length) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (parent.type === schema.nodes.body) {
|
|
36
|
-
return 'Paragraph';
|
|
37
|
-
}
|
|
38
35
|
if (isFootnoteNode(parent) || isGeneralTableFootnoteNode(parent)) {
|
|
39
36
|
return 'Type new footnote here';
|
|
40
37
|
}
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.6.9
|
|
1
|
+
export const VERSION = '2.6.9';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.6.9
|
|
1
|
+
export declare const VERSION = "2.6.9";
|
|
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.9
|
|
4
|
+
"version": "2.6.9",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@manuscripts/json-schema": "2.2.11",
|
|
34
34
|
"@manuscripts/library": "1.3.11",
|
|
35
35
|
"@manuscripts/style-guide": "2.0.23",
|
|
36
|
-
"@manuscripts/track-changes-plugin": "1.8.
|
|
37
|
-
"@manuscripts/transform": "3.0.
|
|
36
|
+
"@manuscripts/track-changes-plugin": "1.8.1",
|
|
37
|
+
"@manuscripts/transform": "3.0.14",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|