Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-flat-list

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-flat-list - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

80

./dist/prosemirror-flat-list.js

@@ -281,3 +281,14 @@ // src/commands/dedent-list.ts

}
return tr;
}
function withAutoJoinList(command) {
const commandWithAutoJoinList = (state, dispatch, view) => {
return command(
state,
dispatch && ((tr) => dispatch(autoJoinList(tr))),
view
);
};
return commandWithAutoJoinList;
}

@@ -384,6 +395,3 @@ // src/utils/block-boundary.ts

if (dedentRange(range, tr)) {
if (dispatch) {
autoJoinList(tr);
dispatch(tr);
}
dispatch == null ? void 0 : dispatch(tr);
return true;

@@ -393,3 +401,3 @@ }

};
return dedentListCommand;
return withAutoJoinList(dedentListCommand);
}

@@ -575,6 +583,3 @@ function dedentRange(range, tr, startBoundary, endBoundary) {

if (indentRange(range, tr)) {
if (dispatch) {
autoJoinList(tr);
dispatch(tr);
}
dispatch == null ? void 0 : dispatch(tr);
return true;

@@ -584,3 +589,3 @@ }

};
return indentListCommand;
return withAutoJoinList(indentListCommand);
}

@@ -724,3 +729,3 @@ function indentRange(range, tr, startBoundary, endBoundary) {

import {
chainCommands as chainCommands3,
chainCommands as chainCommands2,
deleteSelection,

@@ -758,3 +763,3 @@ joinTextblockBackward,

// src/commands/split-list.ts
import { chainCommands as chainCommands2 } from "prosemirror-commands";
import { NodeRange as NodeRange5 } from "prosemirror-model";
import { Selection } from "prosemirror-state";

@@ -780,3 +785,7 @@ import { canSplit as canSplit2 } from "prosemirror-transform";

}
const listNode = $from.node(-1);
if ($from.depth < 2) {
return false;
}
const listDepth = $from.depth - 1;
const listNode = $from.node(listDepth);
if (!isListNode(listNode)) {

@@ -786,6 +795,17 @@ return false;

const parent = $from.parent;
const indexInList = $from.index(-1);
const indexInList = $from.index(listDepth);
const parentEmpty = parent.content.size === 0;
if (indexInList === 0) {
if (parentEmpty) {
const $listEnd = state.doc.resolve($from.end(listDepth));
const listParentDepth = listDepth - 1;
const listParent = $from.node(listParentDepth);
const indexInListParent = $from.index(listParentDepth);
const isLastChildInListParent = indexInListParent === listParent.childCount - 1;
const range = isLastChildInListParent ? new NodeRange5($from, $listEnd, listParentDepth) : new NodeRange5($from, $listEnd, listDepth);
const tr = state.tr;
if (range && dedentNodeRange(range, tr)) {
dispatch == null ? void 0 : dispatch(tr);
return true;
}
return false;

@@ -803,3 +823,3 @@ } else {

};
return chainCommands2(protectCollapsed, splitListCommand);
return withAutoJoinList(splitListCommand);
}

@@ -846,4 +866,8 @@ function doSplitList(state, listNode, dispatch) {

// src/commands/keymap.ts
var backspaceCommand = chainCommands3(
var enterCommand = chainCommands2(
protectCollapsed,
createSplitListCommand()
);
var backspaceCommand = chainCommands2(
protectCollapsed,
deleteSelection,

@@ -854,3 +878,3 @@ joinListBackward,

);
var deleteCommand = chainCommands3(
var deleteCommand = chainCommands2(
protectCollapsed,

@@ -862,7 +886,7 @@ deleteSelection,

var listKeymap = {
Enter: createSplitListCommand(),
Enter: enterCommand,
Backspace: backspaceCommand,
Delete: deleteCommand,
"Mod-[": createDedentListCommand(),
"Mod-]": createIndentListCommand(),
Backspace: backspaceCommand,
Delete: deleteCommand
"Mod-]": createIndentListCommand()
};

@@ -880,6 +904,3 @@

if (doMoveList(state.tr, direction, true, !!dispatch)) {
if (dispatch) {
autoJoinList(tr);
dispatch(tr);
}
dispatch == null ? void 0 : dispatch(tr);
return true;

@@ -889,3 +910,3 @@ }

};
return moveList;
return withAutoJoinList(moveList);
}

@@ -975,3 +996,3 @@ function doMoveList(tr, direction, canDedent, dispatch) {

// src/commands/wrap-in-list.ts
import { NodeRange as NodeRange5 } from "prosemirror-model";
import { NodeRange as NodeRange6 } from "prosemirror-model";
import { findWrapping } from "prosemirror-transform";

@@ -1000,3 +1021,3 @@

if (rangeAllowInlineContent(range) && isListNode(range.parent) && range.depth > 0) {
range = new NodeRange5($from, $to, range.depth - 1);
range = new NodeRange6($from, $to, range.depth - 1);
}

@@ -1017,3 +1038,3 @@ const attrs = typeof getAttrs === "function" ? getAttrs(range) : getAttrs;

} else {
const range2 = new NodeRange5(
const range2 = new NodeRange6(
tr.doc.resolve($from.posAtIndex(i, depth) + 1),

@@ -1359,2 +1380,3 @@ tr.doc.resolve($from.posAtIndex(i + 1, depth) - 1),

doSplitList,
enterCommand,
enterWithoutLift,

@@ -1361,0 +1383,0 @@ findListsRange,

@@ -202,2 +202,12 @@ import { Command } from 'prosemirror-state';

/**
* Keybinding for `Enter`. It's chained with following commands:
*
* - {@link protectCollapsed}
* - {@link createSplitListCommand}
*
* @public
*/
export declare const enterCommand: Command;
/**
* This command has the same behavior as the `Enter` keybinding from

@@ -308,7 +318,7 @@ * `prosemirror-commands`, but without the `liftEmptyBlock` command.

*
* - `Enter`: Split current list item or create a new paragraph. See {@link createSplitListCommand}.
* - `Enter`: See {@link enterCommand}.
* - `Backspace`: See {@link backspaceCommand}.
* - `Delete`: See {@link deleteCommand}.
* - `Mod-[`: Decrease indentation. See {@link createDedentListCommand}.
* - `Mod-]`: Increase indentation. See {@link createIndentListCommand}.
* - `Backspace`: See {@link backspaceCommand}.
* - `Delete`: See {@link deleteCommand}.
*

@@ -319,6 +329,6 @@ * @public

Enter: Command;
Backspace: Command;
Delete: Command;
'Mod-[': Command;
'Mod-]': Command;
Backspace: Command;
Delete: Command;
};

@@ -325,0 +335,0 @@

@@ -281,3 +281,14 @@ // src/commands/dedent-list.ts

}
return tr;
}
function withAutoJoinList(command) {
const commandWithAutoJoinList = (state, dispatch, view) => {
return command(
state,
dispatch && ((tr) => dispatch(autoJoinList(tr))),
view
);
};
return commandWithAutoJoinList;
}

@@ -384,6 +395,3 @@ // src/utils/block-boundary.ts

if (dedentRange(range, tr)) {
if (dispatch) {
autoJoinList(tr);
dispatch(tr);
}
dispatch == null ? void 0 : dispatch(tr);
return true;

@@ -393,3 +401,3 @@ }

};
return dedentListCommand;
return withAutoJoinList(dedentListCommand);
}

@@ -575,6 +583,3 @@ function dedentRange(range, tr, startBoundary, endBoundary) {

if (indentRange(range, tr)) {
if (dispatch) {
autoJoinList(tr);
dispatch(tr);
}
dispatch == null ? void 0 : dispatch(tr);
return true;

@@ -584,3 +589,3 @@ }

};
return indentListCommand;
return withAutoJoinList(indentListCommand);
}

@@ -724,3 +729,3 @@ function indentRange(range, tr, startBoundary, endBoundary) {

import {
chainCommands as chainCommands3,
chainCommands as chainCommands2,
deleteSelection,

@@ -758,3 +763,3 @@ joinTextblockBackward,

// src/commands/split-list.ts
import { chainCommands as chainCommands2 } from "prosemirror-commands";
import { NodeRange as NodeRange5 } from "prosemirror-model";
import { Selection } from "prosemirror-state";

@@ -780,3 +785,7 @@ import { canSplit as canSplit2 } from "prosemirror-transform";

}
const listNode = $from.node(-1);
if ($from.depth < 2) {
return false;
}
const listDepth = $from.depth - 1;
const listNode = $from.node(listDepth);
if (!isListNode(listNode)) {

@@ -786,6 +795,17 @@ return false;

const parent = $from.parent;
const indexInList = $from.index(-1);
const indexInList = $from.index(listDepth);
const parentEmpty = parent.content.size === 0;
if (indexInList === 0) {
if (parentEmpty) {
const $listEnd = state.doc.resolve($from.end(listDepth));
const listParentDepth = listDepth - 1;
const listParent = $from.node(listParentDepth);
const indexInListParent = $from.index(listParentDepth);
const isLastChildInListParent = indexInListParent === listParent.childCount - 1;
const range = isLastChildInListParent ? new NodeRange5($from, $listEnd, listParentDepth) : new NodeRange5($from, $listEnd, listDepth);
const tr = state.tr;
if (range && dedentNodeRange(range, tr)) {
dispatch == null ? void 0 : dispatch(tr);
return true;
}
return false;

@@ -803,3 +823,3 @@ } else {

};
return chainCommands2(protectCollapsed, splitListCommand);
return withAutoJoinList(splitListCommand);
}

@@ -846,4 +866,8 @@ function doSplitList(state, listNode, dispatch) {

// src/commands/keymap.ts
var backspaceCommand = chainCommands3(
var enterCommand = chainCommands2(
protectCollapsed,
createSplitListCommand()
);
var backspaceCommand = chainCommands2(
protectCollapsed,
deleteSelection,

@@ -854,3 +878,3 @@ joinListBackward,

);
var deleteCommand = chainCommands3(
var deleteCommand = chainCommands2(
protectCollapsed,

@@ -862,7 +886,7 @@ deleteSelection,

var listKeymap = {
Enter: createSplitListCommand(),
Enter: enterCommand,
Backspace: backspaceCommand,
Delete: deleteCommand,
"Mod-[": createDedentListCommand(),
"Mod-]": createIndentListCommand(),
Backspace: backspaceCommand,
Delete: deleteCommand
"Mod-]": createIndentListCommand()
};

@@ -880,6 +904,3 @@

if (doMoveList(state.tr, direction, true, !!dispatch)) {
if (dispatch) {
autoJoinList(tr);
dispatch(tr);
}
dispatch == null ? void 0 : dispatch(tr);
return true;

@@ -889,3 +910,3 @@ }

};
return moveList;
return withAutoJoinList(moveList);
}

@@ -975,3 +996,3 @@ function doMoveList(tr, direction, canDedent, dispatch) {

// src/commands/wrap-in-list.ts
import { NodeRange as NodeRange5 } from "prosemirror-model";
import { NodeRange as NodeRange6 } from "prosemirror-model";
import { findWrapping } from "prosemirror-transform";

@@ -1000,3 +1021,3 @@

if (rangeAllowInlineContent(range) && isListNode(range.parent) && range.depth > 0) {
range = new NodeRange5($from, $to, range.depth - 1);
range = new NodeRange6($from, $to, range.depth - 1);
}

@@ -1017,3 +1038,3 @@ const attrs = typeof getAttrs === "function" ? getAttrs(range) : getAttrs;

} else {
const range2 = new NodeRange5(
const range2 = new NodeRange6(
tr.doc.resolve($from.posAtIndex(i, depth) + 1),

@@ -1359,2 +1380,3 @@ tr.doc.resolve($from.posAtIndex(i + 1, depth) - 1),

doSplitList,
enterCommand,
enterWithoutLift,

@@ -1361,0 +1383,0 @@ findListsRange,

{
"name": "prosemirror-flat-list",
"type": "module",
"version": "0.1.3",
"version": "0.1.4",
"description": "Powerful list support for ProseMirror",

@@ -6,0 +6,0 @@ "author": "ocavue <ocavue@gmail.com>",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc