@manuscripts/body-editor 2.5.2 → 2.5.3-LEAN-3978.0
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/configs/ManuscriptsEditor.js +2 -0
- package/dist/cjs/lib/copy.js +29 -0
- package/dist/cjs/lib/paste.js +11 -0
- package/dist/cjs/lib/table.js +20 -0
- package/dist/cjs/versions.js +1 -1
- package/dist/es/configs/ManuscriptsEditor.js +2 -0
- package/dist/es/lib/copy.js +25 -0
- package/dist/es/lib/paste.js +11 -0
- package/dist/es/lib/table.js +16 -0
- package/dist/es/versions.js +1 -1
- package/dist/types/lib/copy.d.ts +3 -0
- package/dist/types/lib/table.d.ts +2 -0
- package/dist/types/versions.d.ts +1 -1
- package/package.json +3 -3
|
@@ -24,6 +24,7 @@ const transform_1 = require("@manuscripts/transform");
|
|
|
24
24
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
25
25
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
26
26
|
const clipboard_1 = require("../clipboard");
|
|
27
|
+
const copy_1 = require("../lib/copy");
|
|
27
28
|
const helpers_1 = require("../lib/helpers");
|
|
28
29
|
const paste_1 = require("../lib/paste");
|
|
29
30
|
const editor_plugins_1 = __importDefault(require("./editor-plugins"));
|
|
@@ -51,6 +52,7 @@ const createEditorView = (props, root, state, dispatch) => {
|
|
|
51
52
|
handlePaste: paste_1.handlePaste,
|
|
52
53
|
clipboardParser: clipboard_1.clipboardParser,
|
|
53
54
|
handleScrollToSelection: helpers_1.handleScrollToBibliographyItem,
|
|
55
|
+
transformCopied: copy_1.transformCopied,
|
|
54
56
|
handleClickOn: (view, pos, node, nodePos, event) => {
|
|
55
57
|
if ((event === null || event === void 0 ? void 0 : event.target) &&
|
|
56
58
|
event.target.classList.contains('table-context-menu-button')) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformCopied = void 0;
|
|
4
|
+
const transform_1 = require("@manuscripts/transform");
|
|
5
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
6
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
7
|
+
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
8
|
+
const transformCopied = (slice, view) => {
|
|
9
|
+
var _a;
|
|
10
|
+
const { state } = view;
|
|
11
|
+
if ((!view.props.handleKeyDown || !state.selection.empty) &&
|
|
12
|
+
((_a = slice.content.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.table) {
|
|
13
|
+
let tableStart = null;
|
|
14
|
+
let tableNode = null;
|
|
15
|
+
const tableElement = (0, prosemirror_utils_1.findParentNodeOfType)(transform_1.schema.nodes.table_element)(state.selection);
|
|
16
|
+
if (tableElement) {
|
|
17
|
+
tableStart = tableElement.pos;
|
|
18
|
+
tableNode = tableElement.node;
|
|
19
|
+
if (tableNode && tableStart) {
|
|
20
|
+
view.dispatch(state.tr.setSelection(prosemirror_state_1.TextSelection.create(state.doc, tableStart, tableStart + tableNode.nodeSize)));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (tableNode) {
|
|
24
|
+
return new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from(tableNode), 0, 0);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return slice;
|
|
28
|
+
};
|
|
29
|
+
exports.transformCopied = transformCopied;
|
package/dist/cjs/lib/paste.js
CHANGED
|
@@ -20,6 +20,7 @@ const transform_1 = require("@manuscripts/transform");
|
|
|
20
20
|
const prosemirror_model_1 = require("prosemirror-model");
|
|
21
21
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
22
22
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
23
|
+
const table_1 = require("./table");
|
|
23
24
|
const removeFirstParagraphIfEmpty = (slice) => {
|
|
24
25
|
const firstChild = slice.content.firstChild;
|
|
25
26
|
if (firstChild &&
|
|
@@ -57,6 +58,16 @@ const handlePaste = (view, event, slice) => {
|
|
|
57
58
|
tr.setMeta('uiEvent', 'paste');
|
|
58
59
|
tr.setMeta('paste', true);
|
|
59
60
|
const parent = (0, prosemirror_utils_1.findParentNode)((node) => node.type === transform_1.schema.nodes.section)(tr.selection);
|
|
61
|
+
if (slice.content.firstChild &&
|
|
62
|
+
(slice.content.firstChild.type == transform_1.schema.nodes.table_row ||
|
|
63
|
+
slice.content.firstChild.type == transform_1.schema.nodes.table_cell)) {
|
|
64
|
+
const newTable = (0, table_1.createTableFromSlice)(slice, view.state.schema);
|
|
65
|
+
if (newTable) {
|
|
66
|
+
const tr = view.state.tr.insert(view.state.selection.$anchor.pos, newTable);
|
|
67
|
+
view.dispatch(tr);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
60
71
|
if (((_a = slice.content.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.section && parent) {
|
|
61
72
|
const $pos = tr.doc.resolve(parent.start);
|
|
62
73
|
const insertPos = $pos.after($pos.depth);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTableFromSlice = void 0;
|
|
4
|
+
const prosemirror_model_1 = require("prosemirror-model");
|
|
5
|
+
const createTableFromSlice = (slice, schema) => {
|
|
6
|
+
const rows = [];
|
|
7
|
+
slice.content.forEach((node) => {
|
|
8
|
+
if (node.type === schema.nodes.table_row) {
|
|
9
|
+
rows.push(node);
|
|
10
|
+
}
|
|
11
|
+
else if (node.type === schema.nodes.table_cell) {
|
|
12
|
+
rows.push(schema.nodes.table_row.create(null, prosemirror_model_1.Fragment.from(node)));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
if (rows.length > 0) {
|
|
16
|
+
return schema.nodes.table.create(null, rows);
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
exports.createTableFromSlice = createTableFromSlice;
|
package/dist/cjs/versions.js
CHANGED
|
@@ -18,6 +18,7 @@ import { schema } from '@manuscripts/transform';
|
|
|
18
18
|
import { EditorState } from 'prosemirror-state';
|
|
19
19
|
import { EditorView } from 'prosemirror-view';
|
|
20
20
|
import { clipboardParser } from '../clipboard';
|
|
21
|
+
import { transformCopied } from '../lib/copy';
|
|
21
22
|
import { handleScrollToBibliographyItem } from '../lib/helpers';
|
|
22
23
|
import { handlePaste, transformPasted } from '../lib/paste';
|
|
23
24
|
import plugins from './editor-plugins';
|
|
@@ -44,6 +45,7 @@ export const createEditorView = (props, root, state, dispatch) => {
|
|
|
44
45
|
handlePaste,
|
|
45
46
|
clipboardParser,
|
|
46
47
|
handleScrollToSelection: handleScrollToBibliographyItem,
|
|
48
|
+
transformCopied,
|
|
47
49
|
handleClickOn: (view, pos, node, nodePos, event) => {
|
|
48
50
|
if ((event === null || event === void 0 ? void 0 : event.target) &&
|
|
49
51
|
event.target.classList.contains('table-context-menu-button')) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { schema } from '@manuscripts/transform';
|
|
2
|
+
import { Fragment, Slice } from 'prosemirror-model';
|
|
3
|
+
import { TextSelection } from 'prosemirror-state';
|
|
4
|
+
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
5
|
+
export const transformCopied = (slice, view) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const { state } = view;
|
|
8
|
+
if ((!view.props.handleKeyDown || !state.selection.empty) &&
|
|
9
|
+
((_a = slice.content.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.table) {
|
|
10
|
+
let tableStart = null;
|
|
11
|
+
let tableNode = null;
|
|
12
|
+
const tableElement = findParentNodeOfType(schema.nodes.table_element)(state.selection);
|
|
13
|
+
if (tableElement) {
|
|
14
|
+
tableStart = tableElement.pos;
|
|
15
|
+
tableNode = tableElement.node;
|
|
16
|
+
if (tableNode && tableStart) {
|
|
17
|
+
view.dispatch(state.tr.setSelection(TextSelection.create(state.doc, tableStart, tableStart + tableNode.nodeSize)));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (tableNode) {
|
|
21
|
+
return new Slice(Fragment.from(tableNode), 0, 0);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return slice;
|
|
25
|
+
};
|
package/dist/es/lib/paste.js
CHANGED
|
@@ -17,6 +17,7 @@ import { schema, } from '@manuscripts/transform';
|
|
|
17
17
|
import { Fragment } from 'prosemirror-model';
|
|
18
18
|
import { TextSelection } from 'prosemirror-state';
|
|
19
19
|
import { findParentNode } from 'prosemirror-utils';
|
|
20
|
+
import { createTableFromSlice } from './table';
|
|
20
21
|
const removeFirstParagraphIfEmpty = (slice) => {
|
|
21
22
|
const firstChild = slice.content.firstChild;
|
|
22
23
|
if (firstChild &&
|
|
@@ -53,6 +54,16 @@ export const handlePaste = (view, event, slice) => {
|
|
|
53
54
|
tr.setMeta('uiEvent', 'paste');
|
|
54
55
|
tr.setMeta('paste', true);
|
|
55
56
|
const parent = findParentNode((node) => node.type === schema.nodes.section)(tr.selection);
|
|
57
|
+
if (slice.content.firstChild &&
|
|
58
|
+
(slice.content.firstChild.type == schema.nodes.table_row ||
|
|
59
|
+
slice.content.firstChild.type == schema.nodes.table_cell)) {
|
|
60
|
+
const newTable = createTableFromSlice(slice, view.state.schema);
|
|
61
|
+
if (newTable) {
|
|
62
|
+
const tr = view.state.tr.insert(view.state.selection.$anchor.pos, newTable);
|
|
63
|
+
view.dispatch(tr);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
56
67
|
if (((_a = slice.content.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.section && parent) {
|
|
57
68
|
const $pos = tr.doc.resolve(parent.start);
|
|
58
69
|
const insertPos = $pos.after($pos.depth);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Fragment } from 'prosemirror-model';
|
|
2
|
+
export const createTableFromSlice = (slice, schema) => {
|
|
3
|
+
const rows = [];
|
|
4
|
+
slice.content.forEach((node) => {
|
|
5
|
+
if (node.type === schema.nodes.table_row) {
|
|
6
|
+
rows.push(node);
|
|
7
|
+
}
|
|
8
|
+
else if (node.type === schema.nodes.table_cell) {
|
|
9
|
+
rows.push(schema.nodes.table_row.create(null, Fragment.from(node)));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (rows.length > 0) {
|
|
13
|
+
return schema.nodes.table.create(null, rows);
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.5.
|
|
1
|
+
export const VERSION = '2.5.3-LEAN-3978.0';
|
|
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.5.
|
|
1
|
+
export declare const VERSION = "2.5.3-LEAN-3978.0";
|
|
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.5.
|
|
4
|
+
"version": "2.5.3-LEAN-3978.0",
|
|
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.21",
|
|
36
|
-
"@manuscripts/track-changes-plugin": "1.8.0",
|
|
37
|
-
"@manuscripts/transform": "3.0.
|
|
36
|
+
"@manuscripts/track-changes-plugin": "1.8.1-LEAN-3978.0",
|
|
37
|
+
"@manuscripts/transform": "3.0.10-LEAN-3978.1",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
40
40
|
"codemirror": "^5.58.1",
|