@manuscripts/body-editor 2.2.4 → 2.2.6
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 +23 -1
- package/dist/cjs/keys/misc.js +1 -1
- package/dist/cjs/lib/paste.js +14 -1
- package/dist/cjs/plugins/selected-suggestion.js +3 -1
- package/dist/cjs/versions.js +1 -1
- package/dist/cjs/views/block_view.js +3 -3
- package/dist/es/commands.js +21 -0
- package/dist/es/keys/misc.js +2 -2
- package/dist/es/lib/paste.js +14 -1
- package/dist/es/plugins/selected-suggestion.js +3 -1
- package/dist/es/versions.js +1 -1
- package/dist/es/views/block_view.js +3 -3
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/versions.d.ts +1 -1
- package/package.json +2 -2
- package/styles/AdvancedEditor.css +3 -1
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.insertTableFootnote = 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.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = 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.insertGeneralFootnote = exports.undoFootnoteDelete = exports.createBlock = exports.createSelection = exports.canInsert = exports.blockActive = exports.isNodeSelection = exports.markActive = void 0;
|
|
18
|
+
exports.autoComplete = exports.mergeCellsWithSpace = exports.addColumns = exports.addRows = exports.insertTableFootnote = 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.insertInlineFootnote = exports.insertFootnote = exports.createFootnote = 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.insertGeneralFootnote = exports.undoFootnoteDelete = 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");
|
|
@@ -36,6 +36,28 @@ const comments_2 = require("./plugins/comments");
|
|
|
36
36
|
const editor_props_1 = require("./plugins/editor-props");
|
|
37
37
|
const footnotes_2 = require("./plugins/footnotes");
|
|
38
38
|
const autocompletion_1 = require("./plugins/section_title/autocompletion");
|
|
39
|
+
const addToStart = (state, dispatch) => {
|
|
40
|
+
const { selection } = state;
|
|
41
|
+
if (!dispatch ||
|
|
42
|
+
!(selection instanceof prosemirror_state_1.TextSelection) ||
|
|
43
|
+
selection.$from.node().type !== transform_1.schema.nodes.paragraph) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const { $anchor: { parentOffset: startOffset }, $head: { parentOffset: endOffset }, $from, $to, } = selection;
|
|
47
|
+
const parentSize = $from.node().content.size;
|
|
48
|
+
if ((startOffset === 0 && endOffset === 0) ||
|
|
49
|
+
startOffset === parentSize ||
|
|
50
|
+
endOffset === parentSize) {
|
|
51
|
+
const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
|
|
52
|
+
.pos - (startOffset === 0 ? 1 : 0);
|
|
53
|
+
const tr = state.tr.insert(side, $from.node().type.createAndFill());
|
|
54
|
+
tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, side + 1));
|
|
55
|
+
dispatch(tr.scrollIntoView());
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
};
|
|
60
|
+
exports.addToStart = addToStart;
|
|
39
61
|
const markActive = (type) => (state) => {
|
|
40
62
|
const { from, $from, to, empty } = state.selection;
|
|
41
63
|
return empty
|
package/dist/cjs/keys/misc.js
CHANGED
|
@@ -39,7 +39,7 @@ const customKeymap = {
|
|
|
39
39
|
'Mod-Alt-=': (0, prosemirror_commands_1.toggleMark)(transform_1.schema.marks.superscript),
|
|
40
40
|
'Mod-Alt--': (0, prosemirror_commands_1.toggleMark)(transform_1.schema.marks.subscript),
|
|
41
41
|
'Ctrl->': (0, prosemirror_commands_1.wrapIn)(transform_1.schema.nodes.blockquote),
|
|
42
|
-
Enter: (0, prosemirror_commands_1.chainCommands)(commands_1.autoComplete, prosemirror_commands_1.newlineInCode, prosemirror_commands_1.createParagraphNear, prosemirror_commands_1.liftEmptyBlock, prosemirror_commands_1.splitBlock),
|
|
42
|
+
Enter: (0, prosemirror_commands_1.chainCommands)(commands_1.autoComplete, commands_1.addToStart, prosemirror_commands_1.newlineInCode, prosemirror_commands_1.createParagraphNear, prosemirror_commands_1.liftEmptyBlock, prosemirror_commands_1.splitBlock),
|
|
43
43
|
'Shift-Mod-Enter': (0, commands_1.insertSection)(true),
|
|
44
44
|
'Mod-Enter': (0, prosemirror_commands_1.chainCommands)(prosemirror_commands_1.exitCode, (0, commands_1.insertSection)()),
|
|
45
45
|
'Shift-Enter': (0, prosemirror_commands_1.chainCommands)(prosemirror_commands_1.exitCode, commands_1.insertBreak),
|
package/dist/cjs/lib/paste.js
CHANGED
|
@@ -53,7 +53,9 @@ const handlePaste = (view, event, slice) => {
|
|
|
53
53
|
if (event.type !== 'paste') {
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
-
const { state: { tr }, dispatch, } = view;
|
|
56
|
+
const { state: { tr, selection }, dispatch, } = view;
|
|
57
|
+
tr.setMeta('uiEvent', 'paste');
|
|
58
|
+
tr.setMeta('paste', true);
|
|
57
59
|
const parent = (0, prosemirror_utils_1.findParentNode)((node) => node.type === transform_1.schema.nodes.section)(tr.selection);
|
|
58
60
|
if (((_a = slice.content.firstChild) === null || _a === void 0 ? void 0 : _a.type) === transform_1.schema.nodes.section && parent) {
|
|
59
61
|
const $pos = tr.doc.resolve(parent.start);
|
|
@@ -62,6 +64,17 @@ const handlePaste = (view, event, slice) => {
|
|
|
62
64
|
dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, insertPos)).scrollIntoView());
|
|
63
65
|
return true;
|
|
64
66
|
}
|
|
67
|
+
if (selection instanceof prosemirror_state_1.TextSelection &&
|
|
68
|
+
selection.$anchor.parentOffset === 0 &&
|
|
69
|
+
selection.$head.parentOffset === 0 &&
|
|
70
|
+
selection.$from.node().type === transform_1.schema.nodes.paragraph) {
|
|
71
|
+
const { $from, $to } = selection;
|
|
72
|
+
const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
|
|
73
|
+
.pos - 1;
|
|
74
|
+
tr.insert(side, slice.content);
|
|
75
|
+
dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, side + 1)).scrollIntoView());
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
65
78
|
return false;
|
|
66
79
|
};
|
|
67
80
|
exports.handlePaste = handlePaste;
|
|
@@ -43,10 +43,12 @@ const buildPluginState = (state) => {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const getEffectiveSelection = ($pos) => {
|
|
46
|
+
var _a;
|
|
46
47
|
let current;
|
|
47
48
|
for (let depth = $pos.depth; depth > 0; depth--) {
|
|
48
49
|
const node = $pos.node(depth);
|
|
49
|
-
if (node.attrs.dataTracked
|
|
50
|
+
if (node.attrs.dataTracked &&
|
|
51
|
+
!((_a = node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.find((c) => c.operation === 'reference'))) {
|
|
50
52
|
current = {
|
|
51
53
|
node,
|
|
52
54
|
from: $pos.before(depth),
|
package/dist/cjs/versions.js
CHANGED
|
@@ -49,12 +49,12 @@ class BlockView extends base_node_view_1.BaseNodeView {
|
|
|
49
49
|
this.contentDOM.classList.toggle('empty-node', !this.node.childCount);
|
|
50
50
|
};
|
|
51
51
|
this.updateAttributes = () => {
|
|
52
|
-
var _a;
|
|
53
52
|
if (!this.contentDOM) {
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
const dataTracked = (this.node.attrs.dataTracked || []).filter((attr) => attr.operation !== 'reference');
|
|
56
|
+
if (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) {
|
|
57
|
+
const lastChange = dataTracked[dataTracked.length - 1];
|
|
58
58
|
this.dom.setAttribute('data-track-status', lastChange.status);
|
|
59
59
|
this.dom.setAttribute('data-track-op', lastChange.operation);
|
|
60
60
|
}
|
package/dist/es/commands.js
CHANGED
|
@@ -33,6 +33,27 @@ import { setCommentSelection } from './plugins/comments';
|
|
|
33
33
|
import { getEditorProps } from './plugins/editor-props';
|
|
34
34
|
import { footnotesKey } from './plugins/footnotes';
|
|
35
35
|
import { checkForCompletion } from './plugins/section_title/autocompletion';
|
|
36
|
+
export const addToStart = (state, dispatch) => {
|
|
37
|
+
const { selection } = state;
|
|
38
|
+
if (!dispatch ||
|
|
39
|
+
!(selection instanceof TextSelection) ||
|
|
40
|
+
selection.$from.node().type !== schema.nodes.paragraph) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const { $anchor: { parentOffset: startOffset }, $head: { parentOffset: endOffset }, $from, $to, } = selection;
|
|
44
|
+
const parentSize = $from.node().content.size;
|
|
45
|
+
if ((startOffset === 0 && endOffset === 0) ||
|
|
46
|
+
startOffset === parentSize ||
|
|
47
|
+
endOffset === parentSize) {
|
|
48
|
+
const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
|
|
49
|
+
.pos - (startOffset === 0 ? 1 : 0);
|
|
50
|
+
const tr = state.tr.insert(side, $from.node().type.createAndFill());
|
|
51
|
+
tr.setSelection(TextSelection.create(tr.doc, side + 1));
|
|
52
|
+
dispatch(tr.scrollIntoView());
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
36
57
|
export const markActive = (type) => (state) => {
|
|
37
58
|
const { from, $from, to, empty } = state.selection;
|
|
38
59
|
return empty
|
package/dist/es/keys/misc.js
CHANGED
|
@@ -18,7 +18,7 @@ import { chainCommands, createParagraphNear, exitCode, joinDown, joinUp, lift, l
|
|
|
18
18
|
import { redo, undo } from 'prosemirror-history';
|
|
19
19
|
import { undoInputRule } from 'prosemirror-inputrules';
|
|
20
20
|
import { goToNextCell } from 'prosemirror-tables';
|
|
21
|
-
import { autoComplete, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
|
|
21
|
+
import { autoComplete, addToStart, ignoreAtomBlockNodeBackward, ignoreAtomBlockNodeForward, ignoreMetaNodeBackspaceCommand, insertBlock, insertBreak, insertCrossReference, insertInlineCitation, insertInlineEquation, insertSection, selectAllIsolating, } from '../commands';
|
|
22
22
|
const customKeymap = {
|
|
23
23
|
Backspace: chainCommands(undoInputRule, ignoreAtomBlockNodeBackward, ignoreMetaNodeBackspaceCommand),
|
|
24
24
|
Delete: ignoreAtomBlockNodeForward,
|
|
@@ -37,7 +37,7 @@ const customKeymap = {
|
|
|
37
37
|
'Mod-Alt-=': toggleMark(schema.marks.superscript),
|
|
38
38
|
'Mod-Alt--': toggleMark(schema.marks.subscript),
|
|
39
39
|
'Ctrl->': wrapIn(schema.nodes.blockquote),
|
|
40
|
-
Enter: chainCommands(autoComplete, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),
|
|
40
|
+
Enter: chainCommands(autoComplete, addToStart, newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),
|
|
41
41
|
'Shift-Mod-Enter': insertSection(true),
|
|
42
42
|
'Mod-Enter': chainCommands(exitCode, insertSection()),
|
|
43
43
|
'Shift-Enter': chainCommands(exitCode, insertBreak),
|
package/dist/es/lib/paste.js
CHANGED
|
@@ -49,7 +49,9 @@ export const handlePaste = (view, event, slice) => {
|
|
|
49
49
|
if (event.type !== 'paste') {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
52
|
-
const { state: { tr }, dispatch, } = view;
|
|
52
|
+
const { state: { tr, selection }, dispatch, } = view;
|
|
53
|
+
tr.setMeta('uiEvent', 'paste');
|
|
54
|
+
tr.setMeta('paste', true);
|
|
53
55
|
const parent = findParentNode((node) => node.type === schema.nodes.section)(tr.selection);
|
|
54
56
|
if (((_a = slice.content.firstChild) === null || _a === void 0 ? void 0 : _a.type) === schema.nodes.section && parent) {
|
|
55
57
|
const $pos = tr.doc.resolve(parent.start);
|
|
@@ -58,5 +60,16 @@ export const handlePaste = (view, event, slice) => {
|
|
|
58
60
|
dispatch(tr.setSelection(TextSelection.create(tr.doc, insertPos)).scrollIntoView());
|
|
59
61
|
return true;
|
|
60
62
|
}
|
|
63
|
+
if (selection instanceof TextSelection &&
|
|
64
|
+
selection.$anchor.parentOffset === 0 &&
|
|
65
|
+
selection.$head.parentOffset === 0 &&
|
|
66
|
+
selection.$from.node().type === schema.nodes.paragraph) {
|
|
67
|
+
const { $from, $to } = selection;
|
|
68
|
+
const side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to)
|
|
69
|
+
.pos - 1;
|
|
70
|
+
tr.insert(side, slice.content);
|
|
71
|
+
dispatch(tr.setSelection(TextSelection.create(tr.doc, side + 1)).scrollIntoView());
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
61
74
|
return false;
|
|
62
75
|
};
|
|
@@ -40,10 +40,12 @@ const buildPluginState = (state) => {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
const getEffectiveSelection = ($pos) => {
|
|
43
|
+
var _a;
|
|
43
44
|
let current;
|
|
44
45
|
for (let depth = $pos.depth; depth > 0; depth--) {
|
|
45
46
|
const node = $pos.node(depth);
|
|
46
|
-
if (node.attrs.dataTracked
|
|
47
|
+
if (node.attrs.dataTracked &&
|
|
48
|
+
!((_a = node.attrs.dataTracked) === null || _a === void 0 ? void 0 : _a.find((c) => c.operation === 'reference'))) {
|
|
47
49
|
current = {
|
|
48
50
|
node,
|
|
49
51
|
from: $pos.before(depth),
|
package/dist/es/versions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '2.2.
|
|
1
|
+
export const VERSION = '2.2.6';
|
|
2
2
|
export const MATHJAX_VERSION = '3.2.2';
|
|
@@ -47,12 +47,12 @@ export default class BlockView extends BaseNodeView {
|
|
|
47
47
|
this.contentDOM.classList.toggle('empty-node', !this.node.childCount);
|
|
48
48
|
};
|
|
49
49
|
this.updateAttributes = () => {
|
|
50
|
-
var _a;
|
|
51
50
|
if (!this.contentDOM) {
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const dataTracked = (this.node.attrs.dataTracked || []).filter((attr) => attr.operation !== 'reference');
|
|
54
|
+
if (dataTracked === null || dataTracked === void 0 ? void 0 : dataTracked.length) {
|
|
55
|
+
const lastChange = dataTracked[dataTracked.length - 1];
|
|
56
56
|
this.dom.setAttribute('data-track-status', lastChange.status);
|
|
57
57
|
this.dom.setAttribute('data-track-op', lastChange.operation);
|
|
58
58
|
}
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { EditorView } from 'prosemirror-view';
|
|
|
21
21
|
import { FileAttachment } from './lib/files';
|
|
22
22
|
import { EditorAction } from './types';
|
|
23
23
|
export type Dispatch = (tr: ManuscriptTransaction) => void;
|
|
24
|
+
export declare const addToStart: (state: ManuscriptEditorState, dispatch?: Dispatch) => boolean;
|
|
24
25
|
export declare const markActive: (type: ManuscriptMarkType) => (state: ManuscriptEditorState) => boolean;
|
|
25
26
|
export declare const isNodeSelection: (selection: Selection) => selection is NodeSelection;
|
|
26
27
|
export declare const blockActive: (type: ManuscriptNodeType) => (state: ManuscriptEditorState) => boolean;
|
package/dist/types/versions.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.2.
|
|
1
|
+
export declare const VERSION = "2.2.6";
|
|
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.2.
|
|
4
|
+
"version": "2.2.6",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
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.7.
|
|
36
|
+
"@manuscripts/track-changes-plugin": "1.7.23",
|
|
37
37
|
"@manuscripts/transform": "2.6.0",
|
|
38
38
|
"@popperjs/core": "^2.11.8",
|
|
39
39
|
"astrocite-eutils": "^0.16.4",
|
|
@@ -512,7 +512,9 @@ span.accepted .selected-suggestion,
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
.ProseMirror .inserted.pending,
|
|
515
|
-
.ProseMirror [data-track-op='insert'][data-track-status='pending'] .block
|
|
515
|
+
.ProseMirror [data-track-op='insert'][data-track-status='pending'] .block,
|
|
516
|
+
.ProseMirror [data-track-op='node_split'][data-track-status='pending'] .block,
|
|
517
|
+
.ProseMirror [data-track-op='wrap_with_node'][data-track-status='pending'] .block {
|
|
516
518
|
background: var(--inserted-pending-bg-color);
|
|
517
519
|
color: var(--inserted-pending-color);
|
|
518
520
|
text-decoration: underline;
|