Socket
Socket
Sign inDemoInstall

@remirror/extension-list

Package Overview
Dependencies
225
Maintainers
2
Versions
246
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.16 to 3.0.0-beta.0

dist/_tsup-dts-rollup.d.cts

285

dist/remirror-extension-list.d.ts

@@ -1,257 +0,28 @@

import { PlainExtension, KeyBindings, CreateExtensionPlugin, NodeExtension, ApplySchemaAttributes, NodeSpecOverride, NodeExtensionSpec, NodeViewMethod, CommandFunction, Static, KeyBindingProps, NodeType as NodeType$1, AnyExtension } from '@remirror/core';
import { InputRule } from '@remirror/pm/inputrules';
import { NodeType, ResolvedPos } from '@remirror/pm/model';
import { Transaction } from '@remirror/pm/state';
/**
* Provides some shared thing used by both `listItem` and `taskListItem`
*/
declare class ListItemSharedExtension extends PlainExtension {
get name(): "listItemShared";
createKeymap(): KeyBindings;
createPlugin(): CreateExtensionPlugin;
}
declare global {
namespace Remirror {
interface AllExtensions {
listItemShared: ListItemSharedExtension;
}
}
}
/**
* Creates the node for a list item.
*/
declare class ListItemExtension extends NodeExtension<ListItemOptions> {
get name(): "listItem";
createTags(): "listItemNode"[];
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
createNodeViews(): NodeViewMethod | Record<string, never>;
createKeymap(): KeyBindings;
createExtensions(): ListItemSharedExtension[];
/**
* Toggles the current list item.
*
* @param closed - the `closed` attribute. If it's a boolean value, then it
* will be set as an attribute. If it's undefined, then the `closed` attribuate
* will be toggled.
*/
toggleListItemClosed(closed?: boolean | undefined): CommandFunction;
/**
* Lift the content inside a list item around the selection out of list
*/
liftListItemOutOfList(listItemType?: NodeType | undefined): CommandFunction;
}
interface ListItemOptions {
/**
* Set this to true to support toggling.
*/
enableCollapsible?: Static<boolean>;
}
declare global {
namespace Remirror {
interface AllExtensions {
listItem: ListItemExtension;
}
}
}
/**
* Create the node for a bullet list.
*/
declare class BulletListExtension extends NodeExtension<BulletListOptions> {
get name(): "bulletList";
createTags(): ("listContainer" | "block")[];
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
createNodeViews(): NodeViewMethod | Record<string, never>;
createExtensions(): ListItemExtension[];
/**
* Toggle the bullet list for the current selection.
*/
toggleBulletList(): CommandFunction;
listShortcut(props: KeyBindingProps): boolean;
createInputRules(): InputRule[];
}
interface BulletListOptions {
/**
* Set this to true to add a spine.
*/
enableSpine?: Static<boolean>;
}
declare global {
namespace Remirror {
interface AllExtensions {
bulletList: BulletListExtension;
}
}
}
/**
* A helper function to dedent selected list items.
*
* @beta
*/
declare function dedentList(tr: Transaction): boolean;
/**
* A helper function to indent selected list items.
*
* @beta
*/
declare function indentList(tr: Transaction): boolean;
/**
* Toggles a list.
*
* @remarks
*
* When the provided list wrapper is inactive (e.g. ul) then wrap the list with
* this type. When it is active then remove the selected line from the list.
*
* @param listType - the list node type
* @param itemType - the list item node type
*/
declare function toggleList(listType: NodeType$1, itemType: NodeType$1): CommandFunction;
/**
* Create a command to sink the list item around the selection down into an
* inner list. Use this function if you get multiple list item nodes in your
* schema.
*
* @deprecated use `indentList` instead.
*/
declare function sharedSinkListItem(allExtensions: AnyExtension[]): CommandFunction;
/**
* Create a command to lift the list item around the selection up intoa wrapping
* list. Use this function if you get multiple list item nodes in your schema.
*
* @deprecated use `dedentList` instead.
*/
declare function sharedLiftListItem(allExtensions: AnyExtension[]): CommandFunction;
/**
* Wraps existed list items to a new type of list, which only containes these list items.
*
* @remarks
*
* @example
*
* Here is some pseudo-code to show the purpose of this function:
*
* before:
*
* ```html
* <ul>
* <li>item A</li>
* <li>item B<!-- cursor_start --></li>
* <li>item C<!-- cursor_end --></li>
* <li>item D</li>
* </ul>
* ```
*
* after:
*
* ```html
* <ul>
* <li>item A</li>
* </ul>
* <ol>
* <li>item B<!-- cursor_start --></li>
* <li>item C<!-- cursor_end --></li>
* </ol>
* <ul>
* <li>item D</li>
* </ul>
* ```
*
* @alpha
*/
declare function wrapSelectedItems({ listType, itemType, tr, }: {
listType: NodeType$1;
itemType: NodeType$1;
tr: Transaction;
}): boolean;
/**
* Creates the list for the ordered list.
*/
declare class OrderedListExtension extends NodeExtension {
get name(): "orderedList";
createTags(): ("listContainer" | "block")[];
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
/**
* Automatically add the `ListItemExtension` which is required here.
*/
createExtensions(): ListItemExtension[];
/**
* Toggle the ordered list for the current selection.
*/
toggleOrderedList(): CommandFunction;
listShortcut(props: KeyBindingProps): boolean;
createInputRules(): InputRule[];
}
declare global {
namespace Remirror {
interface AllExtensions {
orderedList: OrderedListExtension;
}
}
}
/**
* Creates the node for a task list item.
*/
declare class TaskListItemExtension extends NodeExtension {
get name(): "taskListItem";
createTags(): "listItemNode"[];
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
createNodeViews(): NodeViewMethod | Record<string, never>;
createKeymap(): KeyBindings;
createExtensions(): ListItemSharedExtension[];
/**
* Toggles the current checkbox state and transform a normal list item into a
* checkbox list item when necessary.
*
* @param checked - the `checked` attribute. If it's a boolean value, then it
* will be set as an attribute. If it's undefined, then the `checked` attribuate
* will be toggled.
*
* @param selection - a resolved position within the task list item you want to
* toggle. It it's not passed, the lower bound of the current selection's will
* be used.
*/
toggleCheckboxChecked(props?: {
checked?: boolean;
$pos?: ResolvedPos;
} | boolean): CommandFunction;
createInputRules(): InputRule[];
}
declare global {
namespace Remirror {
interface AllExtensions {
taskListItem: TaskListItemExtension;
}
}
}
/**
* Create the node for a task list.
*/
declare class TaskListExtension extends NodeExtension {
get name(): "taskList";
createTags(): ("listContainer" | "block")[];
createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec;
createExtensions(): TaskListItemExtension[];
/**
* Toggle the task list for the current selection.
*/
toggleTaskList(): CommandFunction;
listShortcut(props: KeyBindingProps): boolean;
}
declare global {
namespace Remirror {
interface AllExtensions {
taskList: TaskListExtension;
}
}
}
export { BulletListExtension, ListItemExtension, ListItemSharedExtension, OrderedListExtension, TaskListExtension, TaskListItemExtension, dedentList, indentList, sharedLiftListItem, sharedSinkListItem, toggleList, wrapSelectedItems };
export { BulletListExtension } from './_tsup-dts-rollup';
export { BulletListOptions } from './_tsup-dts-rollup';
export { dedentList } from './_tsup-dts-rollup';
export { indentList } from './_tsup-dts-rollup';
export { sharedLiftListItem } from './_tsup-dts-rollup';
export { sharedSinkListItem } from './_tsup-dts-rollup';
export { toggleList } from './_tsup-dts-rollup';
export { wrapSelectedItems } from './_tsup-dts-rollup';
export { ListItemExtension } from './_tsup-dts-rollup';
export { ListItemSharedExtension } from './_tsup-dts-rollup';
export { OrderedListExtension } from './_tsup-dts-rollup';
export { TaskListExtension } from './_tsup-dts-rollup';
export { TaskListItemExtension } from './_tsup-dts-rollup';
export { dedentListCommand } from './_tsup-dts-rollup';
export { indentListCommand } from './_tsup-dts-rollup';
export { splitListItem } from './_tsup-dts-rollup';
export { maybeJoinList } from './_tsup-dts-rollup';
export { liftListItemOutOfList } from './_tsup-dts-rollup';
export { calculateItemRange } from './_tsup-dts-rollup';
export { listBackspace } from './_tsup-dts-rollup';
export { ListItemOptions } from './_tsup-dts-rollup';
export { ListItemAttributes } from './_tsup-dts-rollup';
export { createCustomMarkListItemNodeView } from './_tsup-dts-rollup';
export { isList } from './_tsup-dts-rollup';
export { isListItem } from './_tsup-dts-rollup';
export { isListNode } from './_tsup-dts-rollup';
export { isListItemNode } from './_tsup-dts-rollup';
export { TaskListItemAttributes } from './_tsup-dts-rollup';

@@ -1,24 +0,19 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i = decorators.length - 1, decorator; i >= 0; i--)
if (decorator = decorators[i])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result)
__defProp(target, key, result);
return result;
};
// packages/remirror__extension-list/src/bullet-list-extension.ts
import {
assertGet,
command as command2,
extension as extension2,
ExtensionPriority as ExtensionPriority2,
ExtensionTag as ExtensionTag4,
keyBinding,
NamedShortcut,
NodeExtension as NodeExtension2
} from "@remirror/core";
var _initClass, _ListItemExtension, _dec, _dec2, _dec3, _initProto, _initClass2, _BulletListExtension, _dec4, _dec5, _dec6, _initProto2, _initClass3, _OrderedListExtension, _dec7, _dec8, _dec9, _initProto3, _dec10, _initProto4, _dec11, _dec12, _initProto5;
function createAddInitializerMethod(e, t) { return function (r) { assertNotFinished(t, "addInitializer"), assertCallable(r, "An initializer"), e.push(r); }; }
function assertInstanceIfPrivate(e, t) { if (!e(t)) throw new TypeError("Attempted to access private element on non-instance"); }
function memberDec(e, t, r, a, n, i, s, o, c, l, u) { var f; switch (i) { case 1: f = "accessor"; break; case 2: f = "method"; break; case 3: f = "getter"; break; case 4: f = "setter"; break; default: f = "field"; } var d, p, h = { kind: f, name: o ? "#" + r : r, static: s, private: o, metadata: u }, v = { v: !1 }; if (0 !== i && (h.addInitializer = createAddInitializerMethod(n, v)), o || 0 !== i && 2 !== i) { if (2 === i) d = function (e) { return assertInstanceIfPrivate(l, e), a.value; };else { var y = 0 === i || 1 === i; (y || 3 === i) && (d = o ? function (e) { return assertInstanceIfPrivate(l, e), a.get.call(e); } : function (e) { return a.get.call(e); }), (y || 4 === i) && (p = o ? function (e, t) { assertInstanceIfPrivate(l, e), a.set.call(e, t); } : function (e, t) { a.set.call(e, t); }); } } else d = function (e) { return e[r]; }, 0 === i && (p = function (e, t) { e[r] = t; }); var m = o ? l.bind() : function (e) { return r in e; }; h.access = d && p ? { get: d, set: p, has: m } : d ? { get: d, has: m } : { set: p, has: m }; try { return e.call(t, c, h); } finally { v.v = !0; } }
function assertNotFinished(e, t) { if (e.v) throw new Error("attempted to call " + t + " after decoration was finished"); }
function assertCallable(e, t) { if ("function" != typeof e) throw new TypeError(t + " must be a function"); }
function assertValidReturnValue(e, t) { var r = typeof t; if (1 === e) { if ("object" !== r || null === t) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0"); void 0 !== t.get && assertCallable(t.get, "accessor.get"), void 0 !== t.set && assertCallable(t.set, "accessor.set"), void 0 !== t.init && assertCallable(t.init, "accessor.init"); } else if ("function" !== r) { var a; throw a = 0 === e ? "field" : 5 === e ? "class" : "method", new TypeError(a + " decorators must return a function or void 0"); } }
function curryThis1(e) { return function () { return e(this); }; }
function curryThis2(e) { return function (t) { e(this, t); }; }
function applyMemberDec(e, t, r, a, n, i, s, o, c, l, u) { var f, d, p, h, v, y, m = r[0]; a || Array.isArray(m) || (m = [m]), o ? f = 0 === i || 1 === i ? { get: curryThis1(r[3]), set: curryThis2(r[4]) } : 3 === i ? { get: r[3] } : 4 === i ? { set: r[3] } : { value: r[3] } : 0 !== i && (f = Object.getOwnPropertyDescriptor(t, n)), 1 === i ? p = { get: f.get, set: f.set } : 2 === i ? p = f.value : 3 === i ? p = f.get : 4 === i && (p = f.set); for (var g = a ? 2 : 1, b = m.length - 1; b >= 0; b -= g) { var I; if (void 0 !== (h = memberDec(m[b], a ? m[b - 1] : void 0, n, f, c, i, s, o, p, l, u))) assertValidReturnValue(i, h), 0 === i ? I = h : 1 === i ? (I = h.init, v = h.get || p.get, y = h.set || p.set, p = { get: v, set: y }) : p = h, void 0 !== I && (void 0 === d ? d = I : "function" == typeof d ? d = [d, I] : d.push(I)); } if (0 === i || 1 === i) { if (void 0 === d) d = function (e, t) { return t; };else if ("function" != typeof d) { var w = d; d = function (e, t) { for (var r = t, a = w.length - 1; a >= 0; a--) r = w[a].call(e, r); return r; }; } else { var M = d; d = function (e, t) { return M.call(e, t); }; } e.push(d); } 0 !== i && (1 === i ? (f.get = p.get, f.set = p.set) : 2 === i ? f.value = p : 3 === i ? f.get = p : 4 === i && (f.set = p), o ? 1 === i ? (e.push(function (e, t) { return p.get.call(e, t); }), e.push(function (e, t) { return p.set.call(e, t); })) : 2 === i ? e.push(p) : e.push(function (e, t) { return p.call(e, t); }) : Object.defineProperty(t, n, f)); }
function applyMemberDecs(e, t, r, a) { for (var n, i, s, o = [], c = new Map(), l = new Map(), u = 0; u < t.length; u++) { var f = t[u]; if (Array.isArray(f)) { var d, p, h = f[1], v = f[2], y = f.length > 3, m = 16 & h, g = !!(8 & h), b = r; if (h &= 7, g ? (d = e, 0 !== h && (p = i = i || []), y && !s && (s = function (t) { return _checkInRHS(t) === e; }), b = s) : (d = e.prototype, 0 !== h && (p = n = n || [])), 0 !== h && !y) { var I = g ? l : c, w = I.get(v) || 0; if (!0 === w || 3 === w && 4 !== h || 4 === w && 3 !== h) throw new Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + v); I.set(v, !(!w && h > 2) || h); } applyMemberDec(o, d, f, m, v, h, g, y, p, b, a); } } return pushInitializers(o, n), pushInitializers(o, i), o; }
function pushInitializers(e, t) { t && e.push(function (e) { for (var r = 0; r < t.length; r++) t[r].call(e); return e; }); }
function applyClassDecs(e, t, r, a) { if (t.length) { for (var n = [], i = e, s = e.name, o = r ? 2 : 1, c = t.length - 1; c >= 0; c -= o) { var l = { v: !1 }; try { var u = t[c].call(r ? t[c - 1] : void 0, i, { kind: "class", name: s, addInitializer: createAddInitializerMethod(n, l), metadata: a }); } finally { l.v = !0; } void 0 !== u && (assertValidReturnValue(5, u), i = u); } return [defineMetadata(i, a), function () { for (var e = 0; e < n.length; e++) n[e].call(i); }]; } }
function defineMetadata(e, t) { return Object.defineProperty(e, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: t }); }
function _applyDecs(e, t, r, a, n, i) { if (arguments.length >= 6) var s = i[Symbol.metadata || Symbol.for("Symbol.metadata")]; var o = Object.create(void 0 === s ? null : s), c = applyMemberDecs(e, t, n, o); return r.length || defineMetadata(e, o), { e: c, get c() { return applyClassDecs(e, r, a, o); } }; }
function _checkInRHS(e) { if (Object(e) !== e) throw TypeError("right-hand side of 'in' should be an object, got " + (null !== e ? typeof e : "null")); return e; }
// src/bullet-list-extension.ts
import { assertGet, command as command2, extension as extension2, ExtensionPriority as ExtensionPriority2, ExtensionTag as ExtensionTag4, keyBinding, NamedShortcut, NodeExtension as NodeExtension2 } from "@remirror/core";
import { ExtensionListMessages as Messages } from "@remirror/messages";

@@ -29,10 +24,4 @@ import { InputRule, wrappingInputRule } from "@remirror/pm/inputrules";

// packages/remirror__extension-list/src/list-commands.ts
import {
chainableEditorState,
ExtensionTag as ExtensionTag2,
findParentNode,
getNodeType,
isNodeSelection
} from "@remirror/core";
// src/list-commands.ts
import { chainableEditorState, ExtensionTag as ExtensionTag2, findParentNode, getNodeType, isNodeSelection } from "@remirror/core";
import { joinBackward } from "@remirror/pm/commands";

@@ -44,11 +33,9 @@ import { Fragment, Slice } from "@remirror/pm/model";

// packages/remirror__extension-list/src/list-utils.ts
// src/list-utils.ts
import { ExtensionTag } from "@remirror/core";
function isList(type) {
var _a;
return !!((_a = type.spec.group) == null ? void 0 : _a.includes(ExtensionTag.ListContainerNode));
return !!type.spec.group?.includes(ExtensionTag.ListContainerNode);
}
function isListItem(type) {
var _a;
return !!((_a = type.spec.group) == null ? void 0 : _a.includes(ExtensionTag.ListItemNode));
return !!type.spec.group?.includes(ExtensionTag.ListItemNode);
}

@@ -62,8 +49,14 @@ function isListNode(node) {

// packages/remirror__extension-list/src/list-commands.ts
// src/list-commands.ts
function toggleList(listType, itemType) {
return (props) => {
const { dispatch, tr } = props;
return props => {
const {
dispatch,
tr
} = props;
const state = chainableEditorState(tr, props.state);
const { $from, $to } = tr.selection;
const {
$from,
$to
} = tr.selection;
const range = $from.blockRange($to);

@@ -74,10 +67,10 @@ if (!range) {

const parentList = findParentNode({
predicate: (node) => isList(node.type),
predicate: node => isList(node.type),
selection: tr.selection
});
if (
// the selection range is right inside the list
parentList && range.depth - parentList.depth <= 1 && // the selectron range is the first child of the list
range.startIndex === 0
) {
// the selection range is right inside the list
parentList && range.depth - parentList.depth <= 1 &&
// the selectron range is the first child of the list
range.startIndex === 0) {
if (parentList.node.type === listType) {

@@ -88,7 +81,7 @@ return liftListItemOutOfList(itemType)(props);

if (listType.validContent(parentList.node.content)) {
dispatch == null ? void 0 : dispatch(tr.setNodeMarkup(parentList.pos, listType));
dispatch?.(tr.setNodeMarkup(parentList.pos, listType));
return true;
}
if (deepChangeListType(tr, parentList, listType, itemType)) {
dispatch == null ? void 0 : dispatch(tr.scrollIntoView());
dispatch?.(tr.scrollIntoView());
return true;

@@ -103,13 +96,20 @@ }

function splitListItem(listItemTypeOrName, ignoreAttrs = ["checked"]) {
return function({ tr, dispatch, state }) {
var _a, _b;
return function ({
tr,
dispatch,
state
}) {
const listItemType = getNodeType(listItemTypeOrName, state.schema);
const { $from, $to } = tr.selection;
const {
$from,
$to
} = tr.selection;
if (
// Don't apply to node selection where the selected node is a block (inline nodes might be okay)
// eslint-disable-next-line unicorn/consistent-destructuring
isNodeSelection(tr.selection) && tr.selection.node.isBlock || // List items can only exists at a depth of 2 or greater
$from.depth < 2 || // Don't apply to a selection which spans multiple nodes.
!$from.sameParent($to)
) {
// Don't apply to node selection where the selected node is a block (inline nodes might be okay)
// eslint-disable-next-line unicorn/consistent-destructuring
isNodeSelection(tr.selection) && tr.selection.node.isBlock ||
// List items can only exists at a depth of 2 or greater
$from.depth < 2 ||
// Don't apply to a selection which spans multiple nodes.
!$from.sameParent($to)) {
return false;

@@ -131,15 +131,7 @@ }

}
const content = ((_a = listItemType.contentMatch.defaultType) == null ? void 0 : _a.createAndFill()) || void 0;
const content = listItemType.contentMatch.defaultType?.createAndFill() || void 0;
wrap = wrap.append(Fragment.from(listItemType.createAndFill(null, content) || void 0));
const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;
tr.replace(
$from.before(keepItem ? void 0 : -1),
$from.after(-depthAfter),
new Slice(wrap, keepItem ? 3 : 2, 2)
);
tr.setSelection(
tr.selection.constructor.near(
tr.doc.resolve($from.pos + (keepItem ? 3 : 2))
)
);
tr.replace($from.before(keepItem ? void 0 : -1), $from.after(-depthAfter), new Slice(wrap, keepItem ? 3 : 2, 2));
tr.setSelection(tr.selection.constructor.near(tr.doc.resolve($from.pos + (keepItem ? 3 : 2))));
dispatch(tr.scrollIntoView());

@@ -152,3 +144,3 @@ }

const newListItemStartPos = $from.after(-1);
const content = ((_b = listItemType.contentMatch.defaultType) == null ? void 0 : _b.createAndFill()) || void 0;
const content = listItemType.contentMatch.defaultType?.createAndFill() || void 0;
const newListItem = listItemType.createAndFill(null, content);

@@ -164,12 +156,18 @@ if (newListItem) {

}
const listItemAttributes = Object.fromEntries(
Object.entries(grandParent.attrs).filter(([attr]) => !ignoreAttrs.includes(attr))
);
const listItemAttributes = Object.fromEntries(Object.entries(grandParent.attrs).filter(([attr]) => !ignoreAttrs.includes(attr)));
const contentType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
const contentAttributes = { ...$from.node().attrs };
const contentAttributes = {
...$from.node().attrs
};
tr.delete($from.pos, $to.pos);
const types = contentType ? [
{ type: listItemType, attrs: listItemAttributes },
{ type: contentType, attrs: contentAttributes }
] : [{ type: listItemType, attrs: listItemAttributes }];
const types = contentType ? [{
type: listItemType,
attrs: listItemAttributes
}, {
type: contentType,
attrs: contentAttributes
}] : [{
type: listItemType,
attrs: listItemAttributes
}];
if (!canSplit(tr.doc, $from.pos, 2)) {

@@ -185,8 +183,11 @@ return false;

function getAllListItemNames(allExtensions) {
return allExtensions.filter((extension4) => extension4.tags.includes(ExtensionTag2.ListItemNode)).map((extension4) => extension4.name);
return allExtensions.filter(extension4 => extension4.tags.includes(ExtensionTag2.ListItemNode)).map(extension4 => extension4.name);
}
function getOrderedListItemTypes(listItemNames, state) {
const { $from, $to } = state.selection;
const {
$from,
$to
} = state.selection;
const sharedDepth = $from.sharedDepth($to.pos);
const listItemTypes = /* @__PURE__ */ new Map();
const listItemTypes = /* @__PURE__ */new Map();
for (let depth = sharedDepth; depth >= 0; depth--) {

@@ -202,3 +203,6 @@ const type = $from.node(depth).type;

const listItemNames = getAllListItemNames(allExtensions);
return ({ dispatch, state }) => {
return ({
dispatch,
state
}) => {
const listItemTypes = getOrderedListItemTypes(listItemNames, state);

@@ -215,3 +219,6 @@ for (const type of listItemTypes.values()) {

const listItemNames = getAllListItemNames(allExtensions);
return ({ dispatch, state }) => {
return ({
dispatch,
state
}) => {
const listItemTypes = getOrderedListItemTypes(listItemNames, state);

@@ -260,6 +267,5 @@ for (const type of listItemTypes.values()) {

}) {
var _a;
const oldList = range.parent;
const slice = tr.doc.slice(range.start, range.end);
if (oldList.type === listType && ((_a = slice.content.firstChild) == null ? void 0 : _a.type) === itemType) {
if (oldList.type === listType && slice.content.firstChild?.type === itemType) {
return false;

@@ -290,12 +296,15 @@ }

const atStart = range.startIndex === 0;
const { from, to } = tr.selection;
if (!wrapItems({ listType, itemType, tr, range })) {
const {
from,
to
} = tr.selection;
if (!wrapItems({
listType,
itemType,
tr,
range
})) {
return false;
}
tr.setSelection(
TextSelection.between(
tr.doc.resolve(atStart ? from : from + 2),
tr.doc.resolve(atStart ? to : to + 2)
)
);
tr.setSelection(TextSelection.between(tr.doc.resolve(atStart ? from : from + 2), tr.doc.resolve(atStart ? to : to + 2)));
tr.scrollIntoView();

@@ -305,3 +314,4 @@ return true;

function liftOutOfList(state, dispatch, range) {
const tr = state.tr, list = range.parent;
const tr = state.tr,
list = range.parent;
const originMappingLength = tr.mapping.maps.length;

@@ -312,3 +322,4 @@ for (let pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {

}
const $start = tr.doc.resolve(range.start), item = $start.nodeAfter;
const $start = tr.doc.resolve(range.start),
item = $start.nodeAfter;
if (!item) {

@@ -320,28 +331,12 @@ return false;

}
const atStart = range.startIndex === 0, atEnd = range.endIndex === list.childCount;
const parent = $start.node(-1), indexBefore = $start.index(-1);
if (!parent.canReplace(
indexBefore + (atStart ? 0 : 1),
indexBefore + 1,
item.content.append(atEnd ? Fragment.empty : Fragment.from(list))
)) {
const atStart = range.startIndex === 0,
atEnd = range.endIndex === list.childCount;
const parent = $start.node(-1),
indexBefore = $start.index(-1);
if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? Fragment.empty : Fragment.from(list)))) {
return false;
}
const start = $start.pos, end = start + item.nodeSize;
tr.step(
new ReplaceAroundStep(
start - (atStart ? 1 : 0),
end + (atEnd ? 1 : 0),
start + 1,
end - 1,
new Slice(
(atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(
atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))
),
atStart ? 0 : 1,
atEnd ? 0 : 1
),
atStart ? 0 : 1
)
);
const start = $start.pos,
end = start + item.nodeSize;
tr.step(new ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new Slice((atStart ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));
dispatch(tr.scrollIntoView());

@@ -385,4 +380,7 @@ return true;

function liftListItemOutOfList(itemType) {
return (props) => {
const { dispatch, tr } = props;
return props => {
const {
dispatch,
tr
} = props;
const state = chainableEditorState(tr, props.state);

@@ -401,11 +399,14 @@ const range = getItemRange(itemType, tr.selection);

function getItemRange(itemType, selection) {
const { $from, $to } = selection;
const range = $from.blockRange($to, (node) => {
var _a;
return ((_a = node.firstChild) == null ? void 0 : _a.type) === itemType;
});
const {
$from,
$to
} = selection;
const range = $from.blockRange($to, node => node.firstChild?.type === itemType);
return range;
}
function calculateItemRange(selection) {
const { $from, $to } = selection;
const {
$from,
$to
} = selection;
return $from.blockRange($to, isListNode);

@@ -424,15 +425,15 @@ }

const previousList = root.maybeChild(rootIndex - 1);
const previousListItem = previousList == null ? void 0 : previousList.lastChild;
const previousListItem = previousList?.lastChild;
if (
// current node must be the first node in its parent list item;
itemIndex !== 0 || // current list item must be the first list item in its parent list;
listIndex !== 0
) {
// current node must be the first node in its parent list item;
itemIndex !== 0 ||
// current list item must be the first list item in its parent list;
listIndex !== 0) {
return false;
}
if (
// there is a list before current list;
previousList && isListNode(previousList) && // we can find the list item type for previousList;
previousListItem && isListItemNode(previousListItem)
) {
// there is a list before current list;
previousList && isListNode(previousList) &&
// we can find the list item type for previousList;
previousListItem && isListItemNode(previousListItem)) {
return wrapSelectedItems({

@@ -457,3 +458,5 @@ listType: previousList.type,

}
function listBackspace({ view }) {
function listBackspace({
view
}) {
if (!view) {

@@ -499,16 +502,8 @@ return false;

// packages/remirror__extension-list/src/list-item-extension.ts
import {
command,
extension,
ExtensionPriority,
ExtensionTag as ExtensionTag3,
isBoolean,
isNodeSelection as isNodeSelection2,
NodeExtension
} from "@remirror/core";
// src/list-item-extension.ts
import { command, extension, ExtensionPriority, ExtensionTag as ExtensionTag3, isBoolean, isNodeSelection as isNodeSelection2, NodeExtension } from "@remirror/core";
import { NodeSelection } from "@remirror/pm/state";
import { ExtensionListTheme as ExtensionListTheme2 } from "@remirror/theme";
// packages/remirror__extension-list/src/list-item-node-view.ts
// src/list-item-node-view.ts
import { ExtensionListTheme } from "@remirror/theme";

@@ -530,3 +525,3 @@ function createCustomMarkListItemNodeView({

dom.append(contentDOM);
const update = (newNode) => {
const update = newNode => {
if (newNode.type !== node.type) {

@@ -541,9 +536,13 @@ return false;

update(node);
return { dom, contentDOM, update };
return {
dom,
contentDOM,
update
};
}
// packages/remirror__extension-list/src/list-item-shared-extension.ts
// src/list-item-shared-extension.ts
import { environment, PlainExtension } from "@remirror/core";
// packages/remirror__extension-list/src/list-command-dedent.ts
// src/list-command-dedent.ts
import { Fragment as Fragment2, NodeRange as NodeRange2, Slice as Slice2 } from "@remirror/pm/model";

@@ -557,3 +556,6 @@ import { liftTarget, ReplaceAroundStep as ReplaceAroundStep2 } from "@remirror/pm/transform";

}
return { parentItem, parentList };
return {
parentItem,
parentList
};
}

@@ -566,18 +568,4 @@ function indentSiblingsOfItems(tr, range) {

if (endOfRange < endOfSelectedList) {
tr.step(
new ReplaceAroundStep2(
endOfRange - 1,
endOfSelectedList,
endOfRange,
endOfSelectedList,
new Slice2(Fragment2.from(lastSelectedItem.type.create(null, selectedList.copy())), 1, 0),
1,
true
)
);
return new NodeRange2(
tr.doc.resolve(range.$from.pos),
tr.doc.resolve(endOfSelectedList),
range.depth
);
tr.step(new ReplaceAroundStep2(endOfRange - 1, endOfSelectedList, endOfRange, endOfSelectedList, new Slice2(Fragment2.from(lastSelectedItem.type.create(null, selectedList.copy())), 1, 0), 1, true));
return new NodeRange2(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfSelectedList), range.depth);
}

@@ -592,17 +580,3 @@ return range;

if (endOfSelectedList + 1 < endOfParentListItem) {
tr.step(
new ReplaceAroundStep2(
endOfSelectedList - 1,
endOfParentListItem,
endOfSelectedList + 1,
endOfParentListItem,
new Slice2(
Fragment2.from(selectedList.type.create(null, lastSelectedItem.type.create(null))),
2,
0
),
0,
true
)
);
tr.step(new ReplaceAroundStep2(endOfSelectedList - 1, endOfParentListItem, endOfSelectedList + 1, endOfParentListItem, new Slice2(Fragment2.from(selectedList.type.create(null, lastSelectedItem.type.create(null))), 2, 0), 0, true));
return new NodeRange2(tr.selection.$from, tr.selection.$to, range.depth);

@@ -632,3 +606,6 @@ }

}
const { parentItem, parentList } = findParentItemResult;
const {
parentItem,
parentList
} = findParentItemResult;
range = indentSiblingsOfItems(tr, range);

@@ -648,5 +625,8 @@ range = indentSiblingsOfList(tr, range);

}
var dedentListCommand = ({ tr, dispatch }) => {
var dedentListCommand = ({
tr,
dispatch
}) => {
if (dedentList(tr)) {
dispatch == null ? void 0 : dispatch(tr.scrollIntoView());
dispatch?.(tr.scrollIntoView());
return true;

@@ -657,3 +637,3 @@ }

// packages/remirror__extension-list/src/list-command-indent.ts
// src/list-command-indent.ts
import { Fragment as Fragment3 } from "@remirror/pm/model";

@@ -717,6 +697,12 @@ import { TextSelection as TextSelection2 } from "@remirror/pm/state";

}
return { selectedSlice, unselectedSlice };
return {
selectedSlice,
unselectedSlice
};
}
function indentList(tr) {
const { $from, $to } = tr.selection;
const {
$from,
$to
} = tr.selection;
const range = calculateItemRange(tr.selection);

@@ -734,4 +720,11 @@ if (!range) {

}
const { previousItem, previousList, previousItemStart } = findPreviousItemResult;
const { selectedSlice, unselectedSlice } = sliceSelectedItems(tr.doc, $to, range);
const {
previousItem,
previousList,
previousItemStart
} = findPreviousItemResult;
const {
selectedSlice,
unselectedSlice
} = sliceSelectedItems(tr.doc, $to, range);
const newPreviousItemContent = previousItem.content.append(Fragment3.fromArray([selectedList.copy(selectedSlice.content)])).append(unselectedSlice ? unselectedSlice.content : Fragment3.empty);

@@ -743,10 +736,11 @@ tr.deleteRange(range.start, range.end);

tr.replaceRangeWith(previousItemStart - 1, previousItemEnd + 1, newPreviousItem);
tr.setSelection(
previousList === selectedList ? TextSelection2.between(tr.doc.resolve($from.pos), tr.doc.resolve($to.pos)) : TextSelection2.between(tr.doc.resolve($from.pos - 2), tr.doc.resolve($to.pos - 2))
);
tr.setSelection(previousList === selectedList ? TextSelection2.between(tr.doc.resolve($from.pos), tr.doc.resolve($to.pos)) : TextSelection2.between(tr.doc.resolve($from.pos - 2), tr.doc.resolve($to.pos - 2)));
return true;
}
var indentListCommand = ({ tr, dispatch }) => {
var indentListCommand = ({
tr,
dispatch
}) => {
if (indentList(tr)) {
dispatch == null ? void 0 : dispatch(tr.scrollIntoView());
dispatch?.(tr.scrollIntoView());
return true;

@@ -757,3 +751,3 @@ }

// packages/remirror__extension-list/src/list-item-shared-extension.ts
// src/list-item-shared-extension.ts
var ListItemSharedExtension = class extends PlainExtension {

@@ -775,3 +769,6 @@ get name() {

};
return { ...pcKeymap, ...macKeymap };
return {
...pcKeymap,
...macKeymap
};
}

@@ -791,4 +788,19 @@ return pcKeymap;

// packages/remirror__extension-list/src/list-item-extension.ts
var ListItemExtension = class extends NodeExtension {
// src/list-item-extension.ts
var ListItemExtension = ((_dec = extension({
defaultOptions: {
enableCollapsible: false
},
staticKeys: ["enableCollapsible"]
}), _dec2 = command(), _dec3 = command(), class ListItemExtension extends NodeExtension {
static {
({
e: [_initProto],
c: [_ListItemExtension, _initClass]
} = _applyDecs(this, [[_dec2, 2, "toggleListItemClosed"], [_dec3, 2, "liftListItemOutOfList"]], [_dec]));
}
constructor(...args) {
super(...args);
_initProto(this);
}
get name() {

@@ -808,15 +820,16 @@ return "listItem";

...extra.defaults(),
closed: { default: false },
nested: { default: false }
closed: {
default: false
},
nested: {
default: false
}
},
parseDOM: [
{
tag: "li",
getAttrs: extra.parse,
priority: ExtensionPriority.Lowest
// Make sure this rule has lower priority then `TaskListItemExtension`'s
},
...override.parseDOM ?? []
],
toDOM: (node) => {
parseDOM: [{
tag: "li",
getAttrs: extra.parse,
priority: ExtensionPriority.Lowest
// Make sure this rule has lower priority then `TaskListItemExtension`'s
}, ...(override.parseDOM ?? [])],
toDOM: node => {
const attrs = extra.dom(node);

@@ -862,9 +875,21 @@ return ["li", attrs, 0];

toggleListItemClosed(closed) {
return ({ state: { tr, selection }, dispatch }) => {
return ({
state: {
tr,
selection
},
dispatch
}) => {
if (!isNodeSelection2(selection) || selection.node.type.name !== this.name) {
return false;
}
const { node, from } = selection;
const {
node,
from
} = selection;
closed = isBoolean(closed) ? closed : !node.attrs.closed;
dispatch == null ? void 0 : dispatch(tr.setNodeMarkup(from, void 0, { ...node.attrs, closed }));
dispatch?.(tr.setNodeMarkup(from, void 0, {
...node.attrs,
closed
}));
return true;

@@ -876,15 +901,6 @@ };

}
};
__decorateClass([
command()
], ListItemExtension.prototype, "toggleListItemClosed", 1);
__decorateClass([
command()
], ListItemExtension.prototype, "liftListItemOutOfList", 1);
ListItemExtension = __decorateClass([
extension({
defaultOptions: { enableCollapsible: false },
staticKeys: ["enableCollapsible"]
})
], ListItemExtension);
static {
_initClass();
}
}), _ListItemExtension);
function updateNodeViewDOM(node, dom) {

@@ -897,4 +913,27 @@ node.attrs.closed ? dom.classList.add(ExtensionListTheme2.COLLAPSIBLE_LIST_ITEM_CLOSED) : dom.classList.remove(ExtensionListTheme2.COLLAPSIBLE_LIST_ITEM_CLOSED);

// packages/remirror__extension-list/src/bullet-list-extension.ts
var BulletListExtension = class extends NodeExtension2 {
// src/bullet-list-extension.ts
var BulletListExtension = ((_dec4 = extension2({
defaultOptions: {
enableSpine: false
},
staticKeys: ["enableSpine"]
}), _dec5 = command2({
icon: "listUnordered",
label: ({
t
}) => t(Messages.BULLET_LIST_LABEL)
}), _dec6 = keyBinding({
shortcut: NamedShortcut.BulletList,
command: "toggleBulletList"
}), class BulletListExtension extends NodeExtension2 {
static {
({
e: [_initProto2],
c: [_BulletListExtension, _initClass2]
} = _applyDecs(this, [[_dec5, 2, "toggleBulletList"], [_dec6, 2, "listShortcut"]], [_dec4]));
}
constructor(...args) {
super(...args);
_initProto2(this);
}
get name() {

@@ -911,4 +950,7 @@ return "bulletList";

attrs: extra.defaults(),
parseDOM: [{ tag: "ul", getAttrs: extra.parse }, ...override.parseDOM ?? []],
toDOM: (node) => ["ul", extra.dom(node), 0]
parseDOM: [{
tag: "ul",
getAttrs: extra.parse
}, ...(override.parseDOM ?? [])],
toDOM: node => ["ul", extra.dom(node), 0]
};

@@ -921,3 +963,2 @@ }

return (_, view, getPos) => {
var _a;
const dom = document.createElement("div");

@@ -928,3 +969,3 @@ dom.style.position = "relative";

const parentListItemNode = $pos.node($pos.depth - 1);
const isFirstLevel = ((_a = parentListItemNode == null ? void 0 : parentListItemNode.type) == null ? void 0 : _a.name) !== "listItem";
const isFirstLevel = parentListItemNode?.type?.name !== "listItem";
if (!isFirstLevel) {

@@ -934,3 +975,3 @@ const spine = document.createElement("div");

spine.classList.add(ExtensionListTheme3.LIST_SPINE);
spine.addEventListener("click", (event) => {
spine.addEventListener("click", event => {
const pos2 = getPos();

@@ -957,8 +998,6 @@ const $pos2 = view.state.doc.resolve(pos2 + 1);

createExtensions() {
return [
new ListItemExtension({
priority: ExtensionPriority2.Low,
enableCollapsible: this.options.enableSpine
})
];
return [new ListItemExtension({
priority: ExtensionPriority2.Low,
enableCollapsible: this.options.enableSpine
})];
}

@@ -973,49 +1012,44 @@ toggleBulletList() {

const regexp = /^\s*([*+-])\s$/;
return [
wrappingInputRule(regexp, this.type),
new InputRule(regexp, (state, _match, start, end) => {
const tr = state.tr;
tr.deleteRange(start, end);
const canUpdate = wrapSelectedItems({
listType: this.type,
itemType: assertGet(this.store.schema.nodes, "listItem"),
tr
});
if (!canUpdate) {
return null;
}
return tr;
})
];
return [wrappingInputRule(regexp, this.type), new InputRule(regexp, (state, _match, start, end) => {
const tr = state.tr;
tr.deleteRange(start, end);
const canUpdate = wrapSelectedItems({
listType: this.type,
itemType: assertGet(this.store.schema.nodes, "listItem"),
tr
});
if (!canUpdate) {
return null;
}
return tr;
})];
}
};
__decorateClass([
command2({ icon: "listUnordered", label: ({ t }) => t(Messages.BULLET_LIST_LABEL) })
], BulletListExtension.prototype, "toggleBulletList", 1);
__decorateClass([
keyBinding({ shortcut: NamedShortcut.BulletList, command: "toggleBulletList" })
], BulletListExtension.prototype, "listShortcut", 1);
BulletListExtension = __decorateClass([
extension2({
defaultOptions: { enableSpine: false },
staticKeys: ["enableSpine"]
})
], BulletListExtension);
static {
_initClass2();
}
}), _BulletListExtension);
// packages/remirror__extension-list/src/ordered-list-extension.ts
import {
assertGet as assertGet2,
command as command3,
extension as extension3,
ExtensionPriority as ExtensionPriority3,
ExtensionTag as ExtensionTag5,
findParentNodeOfType,
isElementDomNode,
keyBinding as keyBinding2,
NamedShortcut as NamedShortcut2,
NodeExtension as NodeExtension3
} from "@remirror/core";
// src/ordered-list-extension.ts
import { assertGet as assertGet2, command as command3, extension as extension3, ExtensionPriority as ExtensionPriority3, ExtensionTag as ExtensionTag5, findParentNodeOfType, isElementDomNode, keyBinding as keyBinding2, NamedShortcut as NamedShortcut2, NodeExtension as NodeExtension3 } from "@remirror/core";
import { ExtensionListMessages as Messages2 } from "@remirror/messages";
import { InputRule as InputRule2, wrappingInputRule as wrappingInputRule2 } from "@remirror/pm/inputrules";
var OrderedListExtension = class extends NodeExtension3 {
var OrderedListExtension = ((_dec7 = extension3({}), _dec8 = command3({
icon: "listOrdered",
label: ({
t
}) => t(Messages2.ORDERED_LIST_LABEL)
}), _dec9 = keyBinding2({
shortcut: NamedShortcut2.OrderedList,
command: "toggleOrderedList"
}), class OrderedListExtension extends NodeExtension3 {
static {
({
e: [_initProto3],
c: [_OrderedListExtension, _initClass3]
} = _applyDecs(this, [[_dec8, 2, "toggleOrderedList"], [_dec9, 2, "listShortcut"]], [_dec7]));
}
constructor(...args) {
super(...args);
_initProto3(this);
}
get name() {

@@ -1037,20 +1071,20 @@ return "orderedList";

},
parseDOM: [
{
tag: "ol",
getAttrs: (node) => {
if (!isElementDomNode(node)) {
return {};
}
return {
...extra.parse(node),
order: +(node.getAttribute("start") ?? 1)
};
parseDOM: [{
tag: "ol",
getAttrs: node => {
if (!isElementDomNode(node)) {
return {};
}
},
...override.parseDOM ?? []
],
toDOM: (node) => {
return {
...extra.parse(node),
order: +(node.getAttribute("start") ?? 1)
};
}
}, ...(override.parseDOM ?? [])],
toDOM: node => {
const extraAttributes = extra.dom(node);
return node.attrs.order === 1 ? ["ol", extraAttributes, 0] : ["ol", { ...extraAttributes, start: node.attrs.order }, 0];
return node.attrs.order === 1 ? ["ol", extraAttributes, 0] : ["ol", {
...extraAttributes,
start: node.attrs.order
}, 0];
}

@@ -1063,3 +1097,5 @@ };

createExtensions() {
return [new ListItemExtension({ priority: ExtensionPriority3.Low })];
return [new ListItemExtension({
priority: ExtensionPriority3.Low
})];
}

@@ -1074,68 +1110,51 @@ toggleOrderedList() {

const regexp = /^(\d+)\.\s$/;
return [
wrappingInputRule2(
regexp,
this.type,
(match) => ({ order: +assertGet2(match, 1) }),
(match, node) => node.childCount + node.attrs.order === +assertGet2(match, 1)
),
new InputRule2(regexp, (state, match, start, end) => {
const tr = state.tr;
tr.deleteRange(start, end);
const canUpdate = wrapSelectedItems({
listType: this.type,
itemType: assertGet2(this.store.schema.nodes, "listItem"),
tr
return [wrappingInputRule2(regexp, this.type, match => ({
order: +assertGet2(match, 1)
}), (match, node) => node.childCount + node.attrs.order === +assertGet2(match, 1)), new InputRule2(regexp, (state, match, start, end) => {
const tr = state.tr;
tr.deleteRange(start, end);
const canUpdate = wrapSelectedItems({
listType: this.type,
itemType: assertGet2(this.store.schema.nodes, "listItem"),
tr
});
if (!canUpdate) {
return null;
}
const order = +assertGet2(match, 1);
if (order !== 1) {
const found = findParentNodeOfType({
selection: tr.selection,
types: this.type
});
if (!canUpdate) {
return null;
if (found) {
tr.setNodeMarkup(found.pos, void 0, {
order
});
}
const order = +assertGet2(match, 1);
if (order !== 1) {
const found = findParentNodeOfType({ selection: tr.selection, types: this.type });
if (found) {
tr.setNodeMarkup(found.pos, void 0, { order });
}
}
return tr;
})
];
}
return tr;
})];
}
};
__decorateClass([
command3({ icon: "listOrdered", label: ({ t }) => t(Messages2.ORDERED_LIST_LABEL) })
], OrderedListExtension.prototype, "toggleOrderedList", 1);
__decorateClass([
keyBinding2({ shortcut: NamedShortcut2.OrderedList, command: "toggleOrderedList" })
], OrderedListExtension.prototype, "listShortcut", 1);
OrderedListExtension = __decorateClass([
extension3({})
], OrderedListExtension);
static {
_initClass3();
}
}), _OrderedListExtension);
// packages/remirror__extension-list/src/task-list-extension.ts
import {
assertGet as assertGet4,
command as command5,
ExtensionPriority as ExtensionPriority5,
ExtensionTag as ExtensionTag7,
keyBinding as keyBinding3,
NamedShortcut as NamedShortcut3,
NodeExtension as NodeExtension5
} from "@remirror/core";
// src/task-list-extension.ts
import { assertGet as assertGet4, command as command5, ExtensionPriority as ExtensionPriority5, ExtensionTag as ExtensionTag7, keyBinding as keyBinding3, NamedShortcut as NamedShortcut3, NodeExtension as NodeExtension5 } from "@remirror/core";
import { ExtensionListMessages as Messages3 } from "@remirror/messages";
// packages/remirror__extension-list/src/task-list-item-extension.ts
import {
assertGet as assertGet3,
command as command4,
ExtensionPriority as ExtensionPriority4,
ExtensionTag as ExtensionTag6,
findParentNodeOfType as findParentNodeOfType2,
getMatchString,
isElementDomNode as isElementDomNode2,
NodeExtension as NodeExtension4
} from "@remirror/core";
// src/task-list-item-extension.ts
import { assertGet as assertGet3, command as command4, ExtensionPriority as ExtensionPriority4, ExtensionTag as ExtensionTag6, findParentNodeOfType as findParentNodeOfType2, getMatchString, isElementDomNode as isElementDomNode2, NodeExtension as NodeExtension4 } from "@remirror/core";
import { InputRule as InputRule3, wrappingInputRule as wrappingInputRule3 } from "@remirror/pm/inputrules";
import { ExtensionListTheme as ExtensionListTheme4 } from "@remirror/theme";
var TaskListItemExtension = class extends NodeExtension4 {
var TaskListItemExtension = (_dec10 = command4(), class _Class extends NodeExtension4 {
static {
[_initProto4] = _applyDecs(this, [[_dec10, 2, "toggleCheckboxChecked"]], []).e;
}
constructor(...args) {
super(...args);
_initProto4(this);
}
get name() {

@@ -1155,33 +1174,26 @@ return "taskListItem";

...extra.defaults(),
checked: { default: false }
checked: {
default: false
}
},
parseDOM: [
{
tag: "li[data-task-list-item]",
getAttrs: (node) => {
let checked = false;
if (isElementDomNode2(node) && node.getAttribute("data-checked") !== null) {
checked = true;
}
return {
checked,
...extra.parse(node)
};
},
// Make sure it has higher priority then ListItemExtension's parseDOM by default
priority: ExtensionPriority4.Medium
parseDOM: [{
tag: "li[data-task-list-item]",
getAttrs: node => {
let checked = false;
if (isElementDomNode2(node) && node.getAttribute("data-checked") !== null) {
checked = true;
}
return {
checked,
...extra.parse(node)
};
},
...override.parseDOM ?? []
],
toDOM: (node) => {
return [
"li",
{
...extra.dom(node),
"data-task-list-item": "",
"data-checked": node.attrs.checked ? "" : void 0
},
0
];
}
// Make sure it has higher priority then ListItemExtension's parseDOM by default
priority: ExtensionPriority4.Medium
}, ...(override.parseDOM ?? [])],
toDOM: node => ["li", {
...extra.dom(node),
"data-task-list-item": "",
"data-checked": node.attrs.checked ? "" : void 0
}, 0]
};

@@ -1195,3 +1207,3 @@ }

mark.contentEditable = "false";
mark.addEventListener("click", (e) => {
mark.addEventListener("click", e => {
if (!view.editable) {

@@ -1204,3 +1216,5 @@ e.preventDefault();

const $pos = view.state.doc.resolve(pos + 1);
this.store.commands.toggleCheckboxChecked({ $pos });
this.store.commands.toggleCheckboxChecked({
$pos
});
});

@@ -1233,3 +1247,6 @@ mark.checked = node.attrs.checked;

}
return ({ tr, dispatch }) => {
return ({
tr,
dispatch
}) => {
const found = findParentNodeOfType2({

@@ -1242,5 +1259,11 @@ selection: $pos ?? tr.selection.$from,

}
const { node, pos } = found;
const attrs = { ...node.attrs, checked: checked ?? !node.attrs.checked };
dispatch == null ? void 0 : dispatch(tr.setNodeMarkup(pos, void 0, attrs));
const {
node,
pos
} = found;
const attrs = {
...node.attrs,
checked: checked ?? !node.attrs.checked
};
dispatch?.(tr.setNodeMarkup(pos, void 0, attrs));
return true;

@@ -1251,32 +1274,31 @@ };

const regexp = /^\s*(\[( ?|x|X)]\s)$/;
return [
wrappingInputRule3(regexp, this.type, (match) => {
return { checked: ["x", "X"].includes(getMatchString(match, 2)) };
}),
new InputRule3(regexp, (state, match, start, end) => {
const tr = state.tr;
tr.deleteRange(start, end);
const canUpdate = wrapSelectedItems({
listType: assertGet3(this.store.schema.nodes, "taskList"),
itemType: this.type,
tr
return [wrappingInputRule3(regexp, this.type, match => ({
checked: ["x", "X"].includes(getMatchString(match, 2))
})), new InputRule3(regexp, (state, match, start, end) => {
const tr = state.tr;
tr.deleteRange(start, end);
const canUpdate = wrapSelectedItems({
listType: assertGet3(this.store.schema.nodes, "taskList"),
itemType: this.type,
tr
});
if (!canUpdate) {
return null;
}
const checked = ["x", "X"].includes(getMatchString(match, 2));
if (checked) {
const found = findParentNodeOfType2({
selection: tr.selection,
types: this.type
});
if (!canUpdate) {
return null;
if (found) {
tr.setNodeMarkup(found.pos, void 0, {
checked
});
}
const checked = ["x", "X"].includes(getMatchString(match, 2));
if (checked) {
const found = findParentNodeOfType2({ selection: tr.selection, types: this.type });
if (found) {
tr.setNodeMarkup(found.pos, void 0, { checked });
}
}
return tr;
})
];
}
return tr;
})];
}
};
__decorateClass([
command4()
], TaskListItemExtension.prototype, "toggleCheckboxChecked", 1);
});
function updateNodeViewDOM2(node, dom) {

@@ -1290,4 +1312,19 @@ node.attrs.checked ? dom.setAttribute("data-checked", "") : dom.removeAttribute("data-checked");

// packages/remirror__extension-list/src/task-list-extension.ts
var TaskListExtension = class extends NodeExtension5 {
// src/task-list-extension.ts
var TaskListExtension = (_dec11 = command5({
icon: "checkboxMultipleLine",
label: ({
t
}) => t(Messages3.TASK_LIST_LABEL)
}), _dec12 = keyBinding3({
shortcut: NamedShortcut3.TaskList,
command: "toggleTaskList"
}), class _Class2 extends NodeExtension5 {
static {
[_initProto5] = _applyDecs(this, [[_dec11, 2, "toggleTaskList"], [_dec12, 2, "listShortcut"]], []).e;
}
constructor(...args) {
super(...args);
_initProto5(this);
}
get name() {

@@ -1304,12 +1341,12 @@ return "taskList";

attrs: extra.defaults(),
parseDOM: [
{
tag: "ul[data-task-list]",
getAttrs: extra.parse,
// Make sure it has higher priority then BulletListExtension's parseDOM by default
priority: ExtensionPriority5.Medium
},
...override.parseDOM ?? []
],
toDOM: (node) => ["ul", { ...extra.dom(node), "data-task-list": "" }, 0]
parseDOM: [{
tag: "ul[data-task-list]",
getAttrs: extra.parse,
// Make sure it has higher priority then BulletListExtension's parseDOM by default
priority: ExtensionPriority5.Medium
}, ...(override.parseDOM ?? [])],
toDOM: node => ["ul", {
...extra.dom(node),
"data-task-list": ""
}, 0]
};

@@ -1326,22 +1363,3 @@ }

}
};
__decorateClass([
command5({ icon: "checkboxMultipleLine", label: ({ t }) => t(Messages3.TASK_LIST_LABEL) })
], TaskListExtension.prototype, "toggleTaskList", 1);
__decorateClass([
keyBinding3({ shortcut: NamedShortcut3.TaskList, command: "toggleTaskList" })
], TaskListExtension.prototype, "listShortcut", 1);
export {
BulletListExtension,
ListItemExtension,
ListItemSharedExtension,
OrderedListExtension,
TaskListExtension,
TaskListItemExtension,
dedentList,
indentList,
sharedLiftListItem,
sharedSinkListItem,
toggleList,
wrapSelectedItems
};
});
export { BulletListExtension, ListItemExtension, ListItemSharedExtension, OrderedListExtension, TaskListExtension, TaskListItemExtension, dedentList, indentList, sharedLiftListItem, sharedSinkListItem, toggleList, wrapSelectedItems };
{
"name": "@remirror/extension-list",
"version": "2.0.16",
"version": "3.0.0-beta.0",
"description": "The list extensions.",

@@ -40,17 +40,24 @@ "keywords": [

"dependencies": {
"@babel/runtime": "^7.21.0",
"@remirror/core": "^2.0.13",
"@remirror/extension-events": "^2.1.14",
"@remirror/messages": "^2.0.3",
"@remirror/theme": "^2.0.7"
"@babel/runtime": "^7.22.3",
"@remirror/core": "3.0.0-beta.0",
"@remirror/extension-events": "3.0.0-beta.0",
"@remirror/messages": "3.0.0-beta.0",
"@remirror/theme": "3.0.0-beta.0"
},
"devDependencies": {
"@remirror/pm": "^2.0.5"
"@remirror/cli": "1.0.1",
"@remirror/pm": "3.0.0-beta.0"
},
"peerDependencies": {
"@remirror/pm": "^2.0.5"
"@remirror/pm": "^3.0.0-beta.0"
},
"publishConfig": {
"access": "public"
},
"@remirror": {
"sizeLimit": "10 KB"
},
"scripts": {
"build": "remirror-cli build"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc