@manuscripts/body-editor 1.9.23-LEAN-3579.0 → 1.10.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/commands.js +26 -0
- package/dist/cjs/keys/list.js +1 -2
- package/dist/es/commands.js +27 -1
- package/dist/es/keys/list.js +2 -3
- package/package.json +3 -3
package/dist/cjs/commands.js
CHANGED
|
@@ -427,12 +427,38 @@ const findListsAtSameLevel = (doc, list) => {
|
|
|
427
427
|
});
|
|
428
428
|
return lists;
|
|
429
429
|
};
|
|
430
|
+
function toggleOffList(state, dispatch) {
|
|
431
|
+
const { selection: { $from }, tr, } = state;
|
|
432
|
+
const rootList = findRootList($from);
|
|
433
|
+
if (rootList) {
|
|
434
|
+
state.doc.nodesBetween(rootList.pos, rootList.pos + rootList.node.nodeSize, (node, pos) => {
|
|
435
|
+
const $fromPos = tr.doc.resolve(tr.mapping.map(pos));
|
|
436
|
+
const $toPos = tr.doc.resolve(tr.mapping.map(pos + node.nodeSize - 1));
|
|
437
|
+
const nodeRange = $fromPos.blockRange($toPos);
|
|
438
|
+
if (!nodeRange) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const targetLiftDepth = (0, prosemirror_transform_1.liftTarget)(nodeRange);
|
|
442
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
443
|
+
tr.lift(nodeRange, targetLiftDepth);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
dispatch((0, track_changes_plugin_1.skipTracking)(tr));
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
430
453
|
const insertList = (type, style) => (state, dispatch) => {
|
|
431
454
|
const list = findSelectedList(state.selection);
|
|
432
455
|
if (list) {
|
|
433
456
|
if (!dispatch) {
|
|
434
457
|
return true;
|
|
435
458
|
}
|
|
459
|
+
if (list.node.attrs.listStyleType === style) {
|
|
460
|
+
return toggleOffList(state, dispatch);
|
|
461
|
+
}
|
|
436
462
|
const nodes = findListsAtSameLevel(state.doc, list);
|
|
437
463
|
const tr = state.tr;
|
|
438
464
|
for (const { node, pos } of nodes) {
|
package/dist/cjs/keys/list.js
CHANGED
|
@@ -19,7 +19,6 @@ exports.skipCommandTracking = void 0;
|
|
|
19
19
|
const track_changes_plugin_1 = require("@manuscripts/track-changes-plugin");
|
|
20
20
|
const transform_1 = require("@manuscripts/transform");
|
|
21
21
|
const prosemirror_commands_1 = require("prosemirror-commands");
|
|
22
|
-
const prosemirror_inputrules_1 = require("prosemirror-inputrules");
|
|
23
22
|
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
|
24
23
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
25
24
|
const skipCommandTracking = (command) => (state, dispatch) => {
|
|
@@ -65,6 +64,6 @@ const listKeymap = {
|
|
|
65
64
|
'Mod-Alt-k': (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.wrapInList)(transform_1.schema.nodes.bullet_list)),
|
|
66
65
|
'Shift-Tab': (0, exports.skipCommandTracking)(liftToOuterList(transform_1.schema.nodes.list_item)),
|
|
67
66
|
Tab: (0, exports.skipCommandTracking)((0, prosemirror_schema_list_1.sinkListItem)(transform_1.schema.nodes.list_item)),
|
|
68
|
-
Backspace: (0, exports.skipCommandTracking)(
|
|
67
|
+
Backspace: (0, exports.skipCommandTracking)(listItemBackward),
|
|
69
68
|
};
|
|
70
69
|
exports.default = listKeymap;
|
package/dist/es/commands.js
CHANGED
|
@@ -19,7 +19,7 @@ import { buildComment, generateID, isElementNodeType, isFootnoteNode, isInBiblio
|
|
|
19
19
|
import { NodeRange } from 'prosemirror-model';
|
|
20
20
|
import { wrapInList } from 'prosemirror-schema-list';
|
|
21
21
|
import { NodeSelection, TextSelection, } from 'prosemirror-state';
|
|
22
|
-
import { findWrapping } from 'prosemirror-transform';
|
|
22
|
+
import { findWrapping, liftTarget } from 'prosemirror-transform';
|
|
23
23
|
import { findChildrenByType, findParentNodeOfType, } from 'prosemirror-utils';
|
|
24
24
|
import { skipCommandTracking } from './keys/list';
|
|
25
25
|
import { isNodeOfType, nearestAncestor } from './lib/helpers';
|
|
@@ -405,12 +405,38 @@ const findListsAtSameLevel = (doc, list) => {
|
|
|
405
405
|
});
|
|
406
406
|
return lists;
|
|
407
407
|
};
|
|
408
|
+
function toggleOffList(state, dispatch) {
|
|
409
|
+
const { selection: { $from }, tr, } = state;
|
|
410
|
+
const rootList = findRootList($from);
|
|
411
|
+
if (rootList) {
|
|
412
|
+
state.doc.nodesBetween(rootList.pos, rootList.pos + rootList.node.nodeSize, (node, pos) => {
|
|
413
|
+
const $fromPos = tr.doc.resolve(tr.mapping.map(pos));
|
|
414
|
+
const $toPos = tr.doc.resolve(tr.mapping.map(pos + node.nodeSize - 1));
|
|
415
|
+
const nodeRange = $fromPos.blockRange($toPos);
|
|
416
|
+
if (!nodeRange) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const targetLiftDepth = liftTarget(nodeRange);
|
|
420
|
+
if (targetLiftDepth || targetLiftDepth === 0) {
|
|
421
|
+
tr.lift(nodeRange, targetLiftDepth);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
dispatch(skipTracking(tr));
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
408
431
|
export const insertList = (type, style) => (state, dispatch) => {
|
|
409
432
|
const list = findSelectedList(state.selection);
|
|
410
433
|
if (list) {
|
|
411
434
|
if (!dispatch) {
|
|
412
435
|
return true;
|
|
413
436
|
}
|
|
437
|
+
if (list.node.attrs.listStyleType === style) {
|
|
438
|
+
return toggleOffList(state, dispatch);
|
|
439
|
+
}
|
|
414
440
|
const nodes = findListsAtSameLevel(state.doc, list);
|
|
415
441
|
const tr = state.tr;
|
|
416
442
|
for (const { node, pos } of nodes) {
|
package/dist/es/keys/list.js
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { skipTracking } from '@manuscripts/track-changes-plugin';
|
|
17
17
|
import { schema } from '@manuscripts/transform';
|
|
18
|
-
import {
|
|
19
|
-
import { undoInputRule } from 'prosemirror-inputrules';
|
|
18
|
+
import { joinBackward } from 'prosemirror-commands';
|
|
20
19
|
import { liftListItem, sinkListItem, splitListItem, wrapInList, } from 'prosemirror-schema-list';
|
|
21
20
|
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
22
21
|
export const skipCommandTracking = (command) => (state, dispatch) => {
|
|
@@ -61,6 +60,6 @@ const listKeymap = {
|
|
|
61
60
|
'Mod-Alt-k': skipCommandTracking(wrapInList(schema.nodes.bullet_list)),
|
|
62
61
|
'Shift-Tab': skipCommandTracking(liftToOuterList(schema.nodes.list_item)),
|
|
63
62
|
Tab: skipCommandTracking(sinkListItem(schema.nodes.list_item)),
|
|
64
|
-
Backspace: skipCommandTracking(
|
|
63
|
+
Backspace: skipCommandTracking(listItemBackward),
|
|
65
64
|
};
|
|
66
65
|
export default listKeymap;
|
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": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"repository": "github:Atypon-OpenSource/manuscripts-body-editor",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/cjs",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@iarna/word-count": "^1.1.2",
|
|
31
31
|
"@manuscripts/json-schema": "^2.2.7",
|
|
32
32
|
"@manuscripts/library": "^1.3.6",
|
|
33
|
-
"@manuscripts/style-guide": "1.12.
|
|
33
|
+
"@manuscripts/style-guide": "1.12.7",
|
|
34
34
|
"@manuscripts/track-changes-plugin": "1.7.11",
|
|
35
|
-
"@manuscripts/transform": "2.3.
|
|
35
|
+
"@manuscripts/transform": "2.3.3",
|
|
36
36
|
"astrocite-eutils": "^0.16.4",
|
|
37
37
|
"mathjax-full": "^3.2.2",
|
|
38
38
|
"codemirror": "^5.58.1",
|