New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@prezly/slate-lists

Package Overview
Dependencies
Maintainers
11
Versions
303
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prezly/slate-lists - npm Package Compare versions

Comparing version

to
0.78.1

20

build/esm/jsx.js
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { createEditor, Element } from 'slate';

@@ -39,7 +36,5 @@ import { createEditor as createEditorFactory, createHyperscript } from 'slate-hyperscript';

},
isDefaultTextNode(node) {
return Element.isElementType(node, PARAGRAPH_TYPE);
},
isListNode(node, type) {

@@ -49,14 +44,10 @@ if (type) {

}
return Element.isElementType(node, ORDERED_LIST_TYPE) || Element.isElementType(node, UNORDERED_LIST_TYPE);
},
isListItemNode(node) {
return Element.isElementType(node, LIST_ITEM_TYPE);
},
isListItemTextNode(node) {
return Element.isElementType(node, LIST_ITEM_TEXT_TYPE);
},
createDefaultTextNode() {

@@ -72,3 +63,2 @@ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

},
createListNode() {

@@ -85,3 +75,2 @@ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ListType.UNORDERED;

},
createListItemNode() {

@@ -97,3 +86,2 @@ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

},
createListItemTextNode() {

@@ -109,3 +97,2 @@ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

}
};

@@ -144,3 +131,2 @@ export var jsx = createHyperscript({

});
function withVoidElements(editor) {

@@ -151,10 +137,7 @@ var types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : VOID_ELEMENTS;

} = editor;
editor.isVoid = function (node) {
return types.some(type => Element.isElementType(node, type)) || isVoid(node);
};
return editor;
}
function withInlineElements(editor) {

@@ -165,12 +148,9 @@ var types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INLINE_ELEMENTS;

} = editor;
editor.isInline = function (node) {
return types.some(type => Element.isElementType(node, type)) || isInline(node);
};
return editor;
}
export function noop() {
return null;
}

3

build/esm/lib/canDeleteBackward.js

@@ -8,10 +8,7 @@ import { getListItemsInRange } from "./getListItemsInRange.js";

*/
export function canDeleteBackward(editor) {
var listItemsInSelection = getListItemsInRange(editor, editor.selection);
if (listItemsInSelection.length === 0) {
return true;
}
var [[, listItemPath]] = listItemsInSelection;

@@ -18,0 +15,0 @@ var isInNestedList = getParentListItem(editor, listItemPath) !== null;

import { Editor, Path, Point, Range } from 'slate';
/**

@@ -8,7 +7,5 @@ * Returns all "list-items" in a given Range.

var at = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : editor.selection;
if (!at) {
return [];
}
var start = getLocationStart(at);

@@ -27,3 +24,2 @@ var listItems = Editor.nodes(editor, {

var rangeStartsAfter = Path.isAfter(start, path);
if (rangeIsDescendant) {

@@ -43,7 +39,5 @@ // There's just one case where we want to include a "list-item" that is

}
return !rangeStartsAfter;
});
}
function getLocationStart(location) {

@@ -53,8 +47,6 @@ if (Range.isRange(location)) {

}
if (Point.isPoint(location)) {
return location.path;
}
return location;
}

5

build/esm/lib/getListsInRange.js

@@ -6,3 +6,2 @@ import { getListItemsInRange } from "./getListItemsInRange.js";

*/
export function getListsInRange(editor, at) {

@@ -13,5 +12,5 @@ var listItemsInRange = getListItemsInRange(editor, at);

return getParentList(editor, listItemPath);
}).filter(list => list !== null); // TypeScript complains about `null`s even though we filter for them, hence the typecast.
}).filter(list => list !== null);
// TypeScript complains about `null`s even though we filter for them, hence the typecast.
return lists;
}

@@ -6,16 +6,13 @@ import { Element } from 'slate';

*/
export function getListType(editor, node) {
var isElement = Element.isElement(node);
if (isElement && editor.isListNode(node, ListType.ORDERED)) {
return ListType.ORDERED;
}
if (isElement && editor.isListNode(node, ListType.UNORDERED)) {
return ListType.UNORDERED;
} // This should never happen.
}
// This should never happen.
return ListType.UNORDERED;
}
import { Node, Element } from 'slate';
import { NESTED_LIST_PATH_INDEX } from "../constants.js";
/**

@@ -10,9 +9,6 @@ * Returns "list" node nested in "list-item" at a given path.

var nestedListPath = [...path, NESTED_LIST_PATH_INDEX];
if (!Node.has(editor, nestedListPath)) {
return null;
}
var nestedList = Node.get(editor, nestedListPath);
if (Element.isElement(nestedList) && editor.isListNode(nestedList)) {

@@ -22,4 +18,3 @@ // Sanity check.

}
return null;
}
import { Node, Path } from 'slate';
export function getNextSibling(editor, path) {
var nextSiblingPath;
try {

@@ -11,8 +10,6 @@ nextSiblingPath = Path.next(path);

}
if (Node.has(editor, nextSiblingPath)) {
return [Node.get(editor, nextSiblingPath), nextSiblingPath];
}
return null;
}
import { Editor } from 'slate';
/**

@@ -4,0 +3,0 @@ * Returns parent "list" node of "list-item" at a given path.

import { Editor } from 'slate';
/**

@@ -4,0 +3,0 @@ * Returns parent "list-item" node of "list-item" at a given path.

import { Node, Path } from 'slate';
export function getPrevSibling(editor, path) {
var previousSiblingPath;
try {

@@ -11,8 +10,6 @@ previousSiblingPath = Path.previous(path);

}
if (Node.has(editor, previousSiblingPath)) {
return [Node.get(editor, previousSiblingPath), previousSiblingPath];
}
return null;
}

@@ -7,3 +7,2 @@ import { Range } from 'slate';

*/
export function isCursorAtStartOfListItem(editor) {

@@ -13,9 +12,6 @@ if (!editor.selection || Range.isExpanded(editor.selection)) {

}
var listItemsInSelection = getListItemsInRange(editor, editor.selection);
if (listItemsInSelection.length !== 1) {
return false;
}
var [[, listItemPath]] = listItemsInSelection;

@@ -22,0 +18,0 @@ var {

@@ -7,3 +7,2 @@ import { Range } from 'slate';

*/
export function isCursorInEmptyListItem(editor) {

@@ -13,11 +12,8 @@ if (!editor.selection || Range.isExpanded(editor.selection)) {

}
var listItemsInSelection = getListItemsInRange(editor, editor.selection);
if (listItemsInSelection.length !== 1) {
return false;
}
var [[listItemNode]] = listItemsInSelection;
return !isListItemContainingText(editor, listItemNode);
}
import { Editor } from 'slate';
export function isInList(editor) {
var location = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : editor.selection;
if (!location) {
return false;
}
for (var [currentNode] of Editor.levels(editor, {

@@ -16,4 +14,3 @@ at: location

}
return false;
}
import { Editor, Element } from 'slate';
/**

@@ -12,4 +11,3 @@ * Returns true if given "list-item" node contains a non-empty "list-item-text" node.

}
return false;
}
import { Path } from 'slate';
/**

@@ -27,3 +28,2 @@ * Will return a minimal subset of the given nodes that includes the rest of the given nodes as descendants.

*/
export function pickSubtreesRoots(entries) {

@@ -30,0 +30,0 @@ return entries.filter(_ref => {

import { canDeleteBackward, getListItemsInRange, getListsInRange, getListType, getNestedList, getParentList, getParentListItem, isCursorAtStartOfListItem, isCursorInEmptyListItem, isInList, isListItemContainingText } from "./lib/index.js";
import { decreaseDepth, decreaseListItemDepth, increaseDepth, increaseListItemDepth, mergeListWithPreviousSiblingList, moveListItemsToAnotherList, moveListToListItem, setListType, splitListItem, unwrapList, wrapInList } from "./transformations/index.js";
// Workaround name collision
export var ListsEditor = {

@@ -8,3 +9,2 @@ isListsEditor(editor) {

},
canDeleteBackward,

@@ -11,0 +11,0 @@ decreaseDepth,

import { Element, Node, Text, Transforms } from 'slate';
/**

@@ -10,3 +9,2 @@ * All children of a "list" have to be "list-items". It can happen (e.g. during pasting) that

var [node, path] = _ref;
if (!editor.isListNode(node)) {

@@ -16,3 +14,2 @@ // This function does not know how to normalize other nodes.

}
var normalized = false;

@@ -22,3 +19,2 @@ var children = Array.from(Node.children(editor, path));

var [childNode, childPath] = _ref2;
if (normalized) {

@@ -28,5 +24,5 @@ // Make sure at most 1 normalization operation is done at a time.

}
if (Text.isText(childNode)) {
// This can happen during pasting
// When pasting from MS Word there may be weird text nodes with some whitespace

@@ -46,7 +42,5 @@ // characters. They're not expected to be deserialized so we remove them.

}
normalized = true;
return;
}
Transforms.wrapNodes(editor, editor.createListItemNode({

@@ -62,7 +56,5 @@ children: [editor.createListItemTextNode({

}
if (!Element.isElement(childNode)) {
return;
}
if (editor.isListItemTextNode(childNode)) {

@@ -75,3 +67,2 @@ Transforms.wrapNodes(editor, editor.createListItemNode(), {

}
if (editor.isListNode(childNode)) {

@@ -85,3 +76,2 @@ // Wrap it into a list item so that `normalizeOrphanNestedList` can take care of it.

}
if (!editor.isListItemNode(childNode)) {

@@ -88,0 +78,0 @@ Transforms.setNodes(editor, editor.createListItemTextNode(), {

import { Node, Text, Transforms } from 'slate';
/**

@@ -8,3 +7,2 @@ * A "list-item" can have a single "list-item-text" and optionally an extra "list" as a child.

var [node, path] = _ref;
if (!editor.isListItemNode(node)) {

@@ -14,8 +12,5 @@ // This function does not know how to normalize other nodes.

}
var children = Array.from(Node.children(editor, path));
for (var childIndex = 0; childIndex < children.length; ++childIndex) {
var [childNode, childPath] = children[childIndex];
if (Text.isText(childNode) || editor.isInline(childNode)) {

@@ -28,6 +23,4 @@ var listItemText = editor.createListItemTextNode({

});
if (childIndex > 0) {
var [previousChildNode] = children[childIndex - 1];
if (editor.isListItemTextNode(previousChildNode)) {

@@ -39,6 +32,4 @@ Transforms.mergeNodes(editor, {

}
return true;
}
if (editor.isListItemNode(childNode)) {

@@ -50,3 +41,2 @@ Transforms.liftNodes(editor, {

}
if (editor.isListItemTextNode(childNode) && childIndex !== 0) {

@@ -58,3 +48,2 @@ Transforms.wrapNodes(editor, editor.createListItemNode(), {

}
if (!editor.isListItemTextNode(childNode) && !editor.isListNode(childNode)) {

@@ -67,4 +56,3 @@ Transforms.setNodes(editor, editor.createListItemTextNode(), {

}
return false;
}
import { Editor, Element, Node, Transforms } from 'slate';
/**

@@ -8,3 +7,2 @@ * A "list-item-text" can have only inline nodes in it.

var [node, path] = _ref;
if (!editor.isListItemTextNode(node)) {

@@ -14,3 +12,2 @@ // This function does not know how to normalize other nodes.

}
for (var [childNode, childPath] of Node.children(editor, path)) {

@@ -24,4 +21,3 @@ if (Element.isElement(childNode) && !Editor.isInline(editor, childNode)) {

}
return false;
}
import { Editor, Transforms } from 'slate';
import { getParentList } from "../lib/index.js";
/**

@@ -14,3 +13,2 @@ * If "list-item" somehow (e.g. by deleting everything around it) ends up

var [node, path] = _ref;
if (!editor.isListItemNode(node)) {

@@ -20,5 +18,3 @@ // This function does not know how to normalize other nodes.

}
var parentList = getParentList(editor, path);
if (parentList) {

@@ -28,3 +24,2 @@ // If there is a parent "list", then the fix does not apply.

}
Editor.withoutNormalizing(editor, () => {

@@ -31,0 +26,0 @@ Transforms.unwrapNodes(editor, {

import { Transforms } from 'slate';
import { getParentListItem } from "../lib/index.js";
/**

@@ -14,3 +13,2 @@ * If "list-item-text" somehow (e.g. by deleting everything around it) ends up

var [node, path] = _ref;
if (!editor.isListItemTextNode(node)) {

@@ -20,5 +18,3 @@ // This function does not know how to normalize other nodes.

}
var parentListItem = getParentListItem(editor, path);
if (parentListItem) {

@@ -28,3 +24,2 @@ // If there is a parent "list-item", then the fix does not apply.

}
Transforms.setNodes(editor, editor.createDefaultTextNode(), {

@@ -31,0 +26,0 @@ at: path

import { Node, Transforms } from 'slate';
import { getNestedList, getPrevSibling } from "../lib/index.js";
import { moveListItemsToAnotherList, moveListToListItem } from "../transformations/index.js";
/**

@@ -11,3 +10,2 @@ * If there is a nested "list" inside a "list-item" without a "list-item-text"

var [node, path] = _ref;
if (!editor.isListItemNode(node)) {

@@ -17,12 +15,8 @@ // This function does not know how to normalize other nodes.

}
var children = Array.from(Node.children(editor, path));
if (children.length !== 1) {
return false;
}
var [list] = children;
var [listNode, listPath] = list;
if (!editor.isListNode(listNode)) {

@@ -32,9 +26,6 @@ // If the first child is not a "list", then this fix does not apply.

}
var previousListItem = getPrevSibling(editor, path);
if (previousListItem) {
var [, previousListItemPath] = previousListItem;
var previousListItemNestedList = getNestedList(editor, previousListItemPath);
if (previousListItemNestedList) {

@@ -50,5 +41,4 @@ moveListItemsToAnotherList(editor, {

});
} // Remove now empty "list-item".
}
// Remove now empty "list-item".
Transforms.removeNodes(editor, {

@@ -66,4 +56,3 @@ at: path

}
return true;
}
import { getNextSibling } from "../lib/index.js";
import { mergeListWithPreviousSiblingList } from "../transformations/index.js";
/**

@@ -10,15 +9,11 @@ * If there are 2 "lists" of the same type next to each other, merge them together.

var normalized = mergeListWithPreviousSiblingList(editor, entry);
if (normalized) {
return true;
}
var [, path] = entry;
var nextSibling = getNextSibling(editor, path);
if (!nextSibling) {
return false;
}
return mergeListWithPreviousSiblingList(editor, nextSibling);
}

@@ -7,6 +7,7 @@ import { isHotkey } from 'is-hotkey';

export function onKeyDown(editor, event) {
var listItemsInSelection = getListItemsInRange(editor, editor.selection); // Since we're overriding the default Tab key behavior
var listItemsInSelection = getListItemsInRange(editor, editor.selection);
// Since we're overriding the default Tab key behavior
// we need to bring back the possibility to blur the editor
// with keyboard.
if (isHotkey('esc', event.nativeEvent)) {

@@ -16,3 +17,2 @@ event.preventDefault();

}
if (isHotkey('tab', event.nativeEvent)) {

@@ -22,3 +22,2 @@ event.preventDefault();

}
if (isHotkey('shift+tab', event.nativeEvent)) {

@@ -28,3 +27,2 @@ event.preventDefault();

}
if (isHotkey('backspace', event.nativeEvent) && !canDeleteBackward(editor)) {

@@ -34,3 +32,2 @@ event.preventDefault();

}
if (isHotkey('enter', event.nativeEvent)) {

@@ -44,8 +41,8 @@ if (isCursorInEmptyListItem(editor)) {

}
} // Slate does not always trigger normalization when one would expect it to.
}
// Slate does not always trigger normalization when one would expect it to.
// So we want to force it after we perform lists operations, as it fixes
// many unexpected behaviors.
// https://github.com/ianstormtaylor/slate/issues/3758
Editor.normalize(editor, {

@@ -52,0 +49,0 @@ force: true

@@ -8,13 +8,11 @@ import { Editor } from 'slate';

*/
export function decreaseDepth(editor) {
var at = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : editor.selection;
if (!at) {
return;
}
var listItems = getListItemsInRange(editor, at);
var listItems = getListItemsInRange(editor, at); // When calling `decreaseListItemDepth` the paths and references to "list-items"
// When calling `decreaseListItemDepth` the paths and references to "list-items"
// can change, so we need a way of marking the "list-items" scheduled for transformation.
var refs = pickSubtreesRoots(listItems).map(_ref => {

@@ -28,5 +26,4 @@ var [_, path] = _ref;

}
ref.unref();
});
}

@@ -8,6 +8,4 @@ import { Editor, Node, Path, Transforms } from 'slate';

*/
export function decreaseListItemDepth(editor, listItemPath) {
var parentList = getParentList(editor, listItemPath);
if (!parentList) {

@@ -17,3 +15,2 @@ // It should never happen.

}
var [parentListNode, parentListPath] = parentList;

@@ -33,3 +30,2 @@ var parentListItem = getParentListItem(editor, listItemPath);

});
if (parentListItem) {

@@ -41,5 +37,6 @@ // Move the "list-item" to the grandparent "list".

to: Path.next(parentListItemPath)
}); // We've moved the "list-item" and all its subsequent sibling "list-items" out of this list.
});
// We've moved the "list-item" and all its subsequent sibling "list-items" out of this list.
// So in case there are no more "list-items" left, we should remove the list.
if (previousSiblings.length === 0) {

@@ -54,3 +51,2 @@ Transforms.removeNodes(editor, {

var listItemNestedListPath = [...listItemPath, NESTED_LIST_PATH_INDEX];
if (Node.has(editor, listItemNestedListPath)) {

@@ -69,3 +65,2 @@ Transforms.setNodes(editor, editor.createListNode(getListType(editor, parentListNode), {

}
if (Node.has(editor, listItemTextPath)) {

@@ -72,0 +67,0 @@ Transforms.setNodes(editor, editor.createDefaultTextNode(), {

@@ -10,3 +10,2 @@ import { Editor } from 'slate';

*/
export function increaseDepth(editor) {

@@ -16,3 +15,2 @@ if (!editor.selection) {

}
var listItems = getListItemsInRange(editor, editor.selection);

@@ -23,5 +21,6 @@ var indentableListItems = listItems.filter(_ref => {

return previousListItem !== null;
}); // When calling `increaseListItemDepth` the paths and references to list items
});
// When calling `increaseListItemDepth` the paths and references to list items
// can change, so we need a way of marking the list items scheduled for transformation.
var refs = pickSubtreesRoots(indentableListItems).map(_ref2 => {

@@ -38,3 +37,2 @@ var [_, path] = _ref2;

}
ref.unref();

@@ -41,0 +39,0 @@ });

import { Editor, Element, Node, Path, Transforms } from 'slate';
import { NESTED_LIST_PATH_INDEX } from "../constants.js";
import { getListType, getPrevSibling } from "../lib/index.js";
/**

@@ -10,3 +9,2 @@ * Increases nesting depth of "list-item" at a given Path.

var previousListItem = getPrevSibling(editor, listItemPath);
if (!previousListItem) {

@@ -17,5 +15,3 @@ // The existence of previous "list-item" is necessary and sufficient for the operation to be possible.

}
var [previousListItemNode, previousListItemPath] = previousListItem;
if (!editor.isListItemNode(previousListItemNode)) {

@@ -25,3 +21,2 @@ // Sanity check.

}
var previousListItemChildListPath = [...previousListItemPath, NESTED_LIST_PATH_INDEX];

@@ -42,5 +37,3 @@ var previousListItemHasChildList = Node.has(editor, previousListItemChildListPath);

}
var previousListItemChildList = Node.get(editor, previousListItemChildListPath);
if (Element.isElement(previousListItemChildList) && editor.isListNode(previousListItemChildList)) {

@@ -47,0 +40,0 @@ var index = previousListItemHasChildList ? previousListItemChildList.children.length : 0;

@@ -5,3 +5,2 @@ import { Transforms } from 'slate';

var [node, path] = _ref;
if (!editor.isListNode(node)) {

@@ -11,5 +10,3 @@ // This function does not know how to normalize other nodes.

}
var previousSibling = getPrevSibling(editor, path);
if (!previousSibling) {

@@ -19,12 +16,8 @@ // Nothing to merge with.

}
var [previousSiblingNode] = previousSibling;
if (!editor.isListNode(previousSiblingNode)) {
return false;
}
var isNestedList = Boolean(getParentListItem(editor, path));
var isPreviousSiblingSameListType = getListType(editor, previousSiblingNode) === getListType(editor, node);
if (!isPreviousSiblingSameListType && !isNestedList) {

@@ -35,3 +28,2 @@ // If previous sibling "list" is of a different type, then this fix does not apply

}
Transforms.mergeNodes(editor, {

@@ -38,0 +30,0 @@ at: path

import { Element, Transforms } from 'slate';
/**

@@ -9,3 +8,2 @@ * Moves all "list-items" from one "list" to the end of another "list".

var [targetListNode, targetListPath] = parameters.to;
if (Element.isElement(sourceListNode) && Element.isElement(targetListNode) && editor.isListNode(sourceListNode) && editor.isListNode(targetListNode)) {

@@ -12,0 +10,0 @@ // Sanity check.

import { Transforms } from 'slate';
import { NESTED_LIST_PATH_INDEX } from "../constants.js";
/**

@@ -10,3 +9,2 @@ * Nests (moves) given "list" in a given "list-item".

var [targetListNode, targetListPath] = parameters.to;
if (!editor.isListNode(sourceListNode) || !editor.isListItemNode(targetListNode)) {

@@ -16,3 +14,2 @@ // Sanity check.

}
Transforms.moveNodes(editor, {

@@ -19,0 +16,0 @@ at: sourceListPath,

import { Editor, Node, Transforms } from 'slate';
import { getListsInRange } from "../lib/index.js";
/**

@@ -11,3 +10,2 @@ * Sets "type" of all "list" nodes in the current selection.

}
var lists = getListsInRange(editor, editor.selection);

@@ -21,3 +19,2 @@ var refs = lists.map(_ref => {

var node = path ? Node.get(editor, path) : null;
if (node && path) {

@@ -28,5 +25,4 @@ Transforms.setNodes(editor, editor.createListNode(listType, node), {

}
ref.unref();
});
}
import { Editor, Node, Path, Range, Transforms } from 'slate';
import { NESTED_LIST_PATH_INDEX, TEXT_PATH_INDEX } from "../constants.js";
import { getCursorPositionInNode, getListItemsInRange } from "../lib/index.js";
/**

@@ -14,3 +13,2 @@ * Collapses the current selection (by removing everything in it) and if the cursor

}
if (Range.isExpanded(editor.selection)) {

@@ -20,5 +18,3 @@ // Remove everything in selection (this will collapse the selection).

}
var listItemsInSelection = getListItemsInRange(editor, editor.selection);
if (listItemsInSelection.length !== 1) {

@@ -28,5 +24,5 @@ // Selection is collapsed, so there should be either 0 or 1 "list-item" in selection.

return;
} // Selection is collapsed, `editor.selection.anchor` is equal to `editor.selection.focus`.
}
// Selection is collapsed, `editor.selection.anchor` is equal to `editor.selection.focus`.
var cursorPoint = editor.selection.anchor;

@@ -39,3 +35,2 @@ var [[listItemNode, listItemPath]] = listItemsInSelection;

} = getCursorPositionInNode(editor, cursorPoint, listItemTextPath);
if (isStart) {

@@ -50,3 +45,2 @@ var newListItem = editor.createListItemNode({

}
var newListItemPath = Path.next(listItemPath);

@@ -61,16 +55,17 @@ var newListItemTextPath = Path.next(listItemTextPath);

});
Transforms.insertNodes(editor, _newListItem, {
at: newListItemPath
}); // Move the cursor to the new "list-item".
});
// Move the cursor to the new "list-item".
Transforms.select(editor, newListItemPath);
} else {
// Split current "list-item-text" element into 2.
Transforms.splitNodes(editor); // The current "list-item-text" has a parent "list-item", the new one needs its own.
Transforms.splitNodes(editor);
// The current "list-item-text" has a parent "list-item", the new one needs its own.
Transforms.wrapNodes(editor, editor.createListItemNode(), {
at: newListItemTextPath
}); // Move the new "list-item" up to be a sibling of the original "list-item".
});
// Move the new "list-item" up to be a sibling of the original "list-item".
Transforms.moveNodes(editor, {

@@ -80,5 +75,5 @@ at: newListItemTextPath,

});
} // If there was a "list" in the "list-item" move it to the new "list-item".
}
// If there was a "list" in the "list-item" move it to the new "list-item".
if (hasNestedList) {

@@ -85,0 +80,0 @@ Transforms.moveNodes(editor, {

@@ -8,11 +8,8 @@ import { Editor } from 'slate';

*/
export function unwrapList(editor) {
Editor.withoutNormalizing(editor, () => {
var iterations = 0;
while (getListItemsInRange(editor, editor.selection).length > 0) {
iterations++;
decreaseDepth(editor);
if (iterations > 1000) {

@@ -19,0 +16,0 @@ throw new Error('Too many iterations. Most likely there is a bug causing an infinite loop.');

import { Editor, Element, Transforms } from 'slate';
/**

@@ -13,3 +12,2 @@ * All nodes matching `isConvertibleToListTextNode()` in the current selection

}
var nonListEntries = Array.from(Editor.nodes(editor, {

@@ -27,3 +25,2 @@ at: editor.selection,

var path = ref.current;
if (path) {

@@ -42,5 +39,4 @@ Editor.withoutNormalizing(editor, () => {

}
ref.unref();
});
}
export var ListType;
(function (ListType) {

@@ -4,0 +3,0 @@ ListType["ORDERED"] = "ol";

@@ -6,3 +6,2 @@ function wrapInFragment(nodes) {

}
function wrapInList(nodes, nodeName) {

@@ -13,3 +12,2 @@ var listElement = document.createElement(nodeName);

}
function wrapInLi(nodes) {

@@ -20,2 +18,3 @@ var listItemElement = document.createElement('li');

}
/**

@@ -26,25 +25,18 @@ * Activates `Range.prototype.cloneContents` override that ensures in the cloned contents:

*/
export function patchRangeCloneContents() {
var originalCloneContents = Range.prototype.cloneContents;
Range.prototype.cloneContents = function cloneContents() {
var contents = originalCloneContents.apply(this);
if (this.commonAncestorContainer.nodeName === 'OL' || this.commonAncestorContainer.nodeName === 'UL') {
return wrapInFragment([wrapInList([...contents.childNodes], this.commonAncestorContainer.nodeName)]);
}
if (this.commonAncestorContainer.nodeName === 'LI' && this.commonAncestorContainer.parentElement && (this.commonAncestorContainer.parentElement.nodeName === 'OL' || this.commonAncestorContainer.parentElement.nodeName === 'UL')) {
return wrapInFragment([wrapInList([wrapInLi([...contents.childNodes])], this.commonAncestorContainer.parentElement.nodeName)]);
}
return contents;
};
/**
* Brings back the original `Range.prototype.cloneContents`.
*/
return function undo() {

@@ -51,0 +43,0 @@ Range.prototype.cloneContents = originalCloneContents;

import { patchRangeCloneContents } from "./patchRangeCloneContents.js";
export function withRangeCloneContentsPatched(callback) {
var undo = patchRangeCloneContents();
try {

@@ -6,0 +5,0 @@ callback();

import { normalizeListChildren, normalizeListItemChildren, normalizeListItemTextChildren, normalizeOrphanListItem, normalizeOrphanListItemText, normalizeOrphanNestedList, normalizeSiblingLists } from "./normalizations/index.js";
var LIST_NORMALIZERS = [normalizeListChildren, normalizeListItemChildren, normalizeListItemTextChildren, normalizeOrphanListItem, normalizeOrphanListItemText, normalizeOrphanNestedList, normalizeSiblingLists];
/**
* Enables normalizations that enforce schema constraints and recover from unsupported cases.
*/
export function withLists(schema) {

@@ -23,3 +23,2 @@ return function (editor) {

}
function withNormalizations(editor, normalizers) {

@@ -29,7 +28,5 @@ var {

} = editor;
editor.normalizeNode = entry => {
for (var normalize of normalizers) {
var changed = normalize(editor, entry);
if (changed) {

@@ -39,7 +36,5 @@ return;

}
normalizeNode(entry);
};
return editor;
}

@@ -7,3 +7,2 @@ /* eslint-disable no-param-reassign */

*/
export function withListsReact(editor) {

@@ -13,3 +12,2 @@ var {

} = editor;
editor.setFragmentData = data => {

@@ -20,4 +18,3 @@ withRangeCloneContentsPatched(function () {

};
return editor;
}
import { canDeleteBackward, getListItemsInRange, getListsInRange, getListType, getNestedList, getParentList, getParentListItem, isCursorAtStartOfListItem, isCursorInEmptyListItem, isInList, isListItemContainingText } from './lib';
import { decreaseDepth, decreaseListItemDepth, increaseDepth, increaseListItemDepth, mergeListWithPreviousSiblingList, moveListItemsToAnotherList, moveListToListItem, setListType, splitListItem, unwrapList, wrapInList } from './transformations';
import type { ListsEditor as Type } from './types';
export declare type ListsEditor = Type;
export type ListsEditor = Type;
export declare const ListsEditor: {

@@ -6,0 +6,0 @@ isListsEditor<T extends import("slate").BaseEditor>(editor: T): editor is T & Type;

{
"name": "@prezly/slate-lists",
"version": "0.78.0",
"version": "0.78.1",
"description": "The best Slate lists extension out there",

@@ -55,5 +55,6 @@ "license": "MIT",

"@types/is-hotkey": "^0.1.7",
"@types/node": "^18.13.0",
"@types/uuid": "^8.3.0"
},
"gitHead": "83d9b3901a899dadaffc370b7216bf7ad7218a00"
"gitHead": "477d1e56f9be6d6d8f93220bccf1f6e3ffe65dba"
}