{"version":3,"sources":["jsdelivr-header.js","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/getCurrentItem.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/isList.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/getListForItem.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/getCurrentList.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/getItemDepth.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/getItemsAtRange.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/getPreviousItem.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/utils/isSelectionInList.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/changes/decreaseItemDepth.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/changes/increaseItemDepth.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/changes/splitListItem.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/changes/unwrapList.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/changes/wrapInList.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/api.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/options.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/plugin/onBackspace.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/plugin/onEnter.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/plugin/onTab.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/plugin/createPlugin.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/schema/createValidation.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/schema/createSchema.ts","/npm/@gitbook/slate-edit-list@4.1.3/src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,uICCA,SAAS,eACL,EACA,EACA,GAEA,MAAM,SAAE,GAAa,EAErB,IAAK,EAAO,CACR,IAAK,EAAM,UAAU,SACjB,OAAO,KAEX,EAAQ,EAAM,U,CAGlB,MAAM,EAAS,EAAS,UAAU,EA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Ae,EAAK,MAAM,QAAQ,IAAK,EAAK,YAAa,CAC5D,WAAW,IAGf,MAAM,EAAU,EAAO,MAAM,SAAS,cAAc,EAAK,KAAK,MAAM,QASpE,OANA,EAAK,MAAM,OAAO,SAAQ,CAAC,EAAO,IAC9B,EAAO,cAAc,EAAM,IAAK,EAAQ,IAAK,EAAQ,EAAG,CACpD,WAAW,MAIZ,C,CCrEX,SAAS,SACL,EAA2B,IAK3B,MAAM,EAAO,IAAI,QAAQ,GAEzB,OAAA,OAAA,OAAA,GACO,UAAU,GAAK,CAClB,OAAQ,aAAa,GACrB,OAAQ,aAAa,I","file":"/npm/@gitbook/slate-edit-list@4.1.3/dist/cjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@gitbook/slate-edit-list@4.1.3/dist/cjs/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { Block, Value } from '@gitbook/slate';\nimport Options from '../options';\n\n/*\n * Return the current list item, from current selection or from a node.\n */\n\nfunction getCurrentItem(\n    opts: Options,\n    value: Value,\n    block?: Block\n): Block | null {\n    const { document } = value;\n\n    if (!block) {\n        if (!value.selection.startKey) {\n            return null;\n        }\n        block = value.startBlock;\n    }\n\n    const parent = document.getParent(block.key);\n    return parent && parent.type === opts.typeItem ? parent : null;\n}\n\nexport default getCurrentItem;\n","import { Node } from '@gitbook/slate';\n\nimport Options from '../options';\n\n/*\n * True if the node is a list container\n */\n\nfunction isList(opts: Options, node: Node): boolean {\n    return opts.types.includes(node.type);\n}\n\nexport default isList;\n","import { Block, Value } from '@gitbook/slate';\n\nimport Options from '../options';\nimport isList from './isList';\n\n/*\n * Return the parent list block for an item block.\n */\n\nfunction getListForItem(\n    opts: Options,\n    value: Value,\n    item: Block\n): Block | null {\n    const { document } = value;\n    const parent = document.getParent(item.key);\n    return parent && isList(opts, parent) ? parent : null;\n}\n\nexport default getListForItem;\n","import { Block, Value } from '@gitbook/slate';\n\nimport Options from '../options';\nimport getCurrentItem from './getCurrentItem';\nimport getListForItem from './getListForItem';\n\n/*\n * Return the parent list block, from current selection or from a node (paragraph in a list item).\n */\n\nfunction getCurrentList(\n    opts: Options,\n    value: Value,\n    block?: Block\n): Block | null {\n    const item = getCurrentItem(opts, value, block);\n\n    if (!item) {\n        return null;\n    }\n\n    return getListForItem(opts, value, item);\n}\n\nexport default getCurrentList;\n","import { Block, Value } from '@gitbook/slate';\n\nimport Options from '../options';\nimport getCurrentItem from './getCurrentItem';\n\n/*\n * Get depth of current block in a document list\n */\n\nfunction getItemDepth(opts: Options, value: Value, block?: Block): number {\n    const { document, startBlock } = value;\n    block = block || startBlock;\n\n    const currentItem = getCurrentItem(opts, value, block);\n\n    if (!currentItem) {\n        return 0;\n    }\n\n    const list = document.getParent(currentItem.key);\n\n    return 1 + getItemDepth(opts, value, list);\n}\n\nexport default getItemDepth;\n","import { Block, Range, Value } from '@gitbook/slate';\nimport { List } from 'immutable';\n\nimport Options from '../options';\nimport getCurrentItem from './getCurrentItem';\nimport isList from './isList';\n\n/*\n * Return the list of items at the given range. The returned items are\n * the highest list item blocks that cover the range.\n *\n * Returns an empty list if no list of items can cover the range\n */\n\nfunction getItemsAtRange(\n    opts: Options,\n    value: Value,\n    range?: Range\n): List<Block> {\n    range = range || value.selection;\n\n    if (!range.startKey) {\n        return List();\n    }\n\n    const { document } = value;\n\n    const startBlock = document.getClosestBlock(range.startKey);\n    const endBlock = document.getClosestBlock(range.endKey);\n\n    if (startBlock === endBlock) {\n        const item = getCurrentItem(opts, value, startBlock);\n        return item ? List([item]) : List();\n    }\n\n    const ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);\n\n    if (isList(opts, ancestor)) {\n        const startPath = ancestor.getPath(startBlock.key);\n        const endPath = ancestor.getPath(endBlock.key);\n\n        return ancestor.nodes.slice(startPath[0], endPath[0] + 1);\n    } else if (ancestor.type === opts.typeItem) {\n        // The ancestor is the highest list item that covers the range\n        return List([ancestor]);\n    }\n    // No list of items can cover the range\n    return List();\n}\n\nexport default getItemsAtRange;\n","import { Block, Value } from '@gitbook/slate';\n\nimport Options from '../options';\nimport getCurrentItem from './getCurrentItem';\n\n/*\n * Return the previous item, from current selection or from a node.\n */\n\nfunction getPreviousItem(\n    opts: Options,\n    value: Value,\n    block?: Block\n): Block | null {\n    const { document, startBlock } = value;\n    block = block || startBlock;\n\n    const currentItem = getCurrentItem(opts, value, block);\n\n    if (!currentItem) {\n        return null;\n    }\n\n    const previousSibling = document.getPreviousSibling(currentItem.key);\n\n    if (!previousSibling) {\n        return null;\n    } else if (previousSibling.type === opts.typeItem) {\n        return previousSibling;\n    }\n    return null;\n}\n\nexport default getPreviousItem;\n","import { Value } from '@gitbook/slate';\n\nimport Options from '../options';\nimport getItemsAtRange from './getItemsAtRange';\nimport getListForItem from './getListForItem';\n\n/*\n * True if selection is inside a list (and can be unwrapped)\n */\n\nfunction isSelectionInList(\n    opts: Options,\n    value: Value,\n    type?: string\n): boolean {\n    const items = getItemsAtRange(opts, value);\n    return (\n        !items.isEmpty() &&\n        // Check the of the list if needed\n        (!type ||\n            getListForItem(opts, value, items.first()).get('type') === type)\n    );\n}\n\nexport default isSelectionInList;\n","import { Block, Change } from '@gitbook/slate';\n\nimport Options from '../options';\nimport { getCurrentItem, getItemDepth } from '../utils';\n\n/*\n * Decreases the depth of the current item. The following items will\n * be moved as sublist of the decreased item.\n *\n * No-op for root items.\n */\n\nfunction decreaseItemDepth(opts: Options, change: Change): Change {\n    const { value } = change;\n    const { document } = value;\n\n    // Cannot decrease item depth of root items\n    const depth = getItemDepth(opts, value);\n\n    if (depth === 1) {\n        return change;\n    }\n\n    const currentItem = getCurrentItem(opts, value);\n\n    if (!currentItem) {\n        return change;\n    }\n\n    const currentList = document.getParent(currentItem.key);\n    const parentItem = document.getParent(currentList.key);\n    const parentList = document.getParent(parentItem.key);\n    // The items following the item will be moved to a sublist of currentItem\n    const followingItems = currentList.nodes\n        .skipUntil(i => i === currentItem)\n        .rest();\n\n    // True if the currentItem and the followingItems make the whole\n    // currentList, and hence the currentList will be emptied\n    const willEmptyCurrentList =\n        currentList.nodes.size === followingItems.size + 1;\n\n    if (!followingItems.isEmpty()) {\n        // Add them as sublist of currentItem\n        const sublist = Block.create({\n            object: 'block',\n            type: currentList.type,\n            data: currentList.data\n        });\n\n        // Add the sublist\n        change.insertNodeByKey(\n            currentItem.key,\n            currentItem.nodes.size,\n            sublist,\n            {\n                normalize: false\n            }\n        );\n\n        change.moveNodeByKey(\n            currentItem.key,\n            parentList.key,\n            parentList.getChildIndex(parentItem.key) + 1,\n            { normalize: false }\n        );\n\n        // Move the followingItems to the sublist\n        followingItems.forEach((item, index) =>\n            change.moveNodeByKey(\n                item.key,\n                sublist.key,\n                sublist.nodes.size + index,\n                {\n                    normalize: false\n                }\n            )\n        );\n    } else {\n        change.moveNodeByKey(\n            currentItem.key,\n            parentList.key,\n            parentList.getChildIndex(parentItem.key) + 1\n        );\n    }\n\n    // Remove the currentList completely if needed\n    if (willEmptyCurrentList) {\n        change.removeNodeByKey(currentList.key);\n    }\n\n    return change;\n}\n\nexport default decreaseItemDepth;\n","import { Block, Change } from '@gitbook/slate';\n\nimport Options from '../options';\nimport {\n    getCurrentItem,\n    getListForItem,\n    getPreviousItem,\n    isList\n} from '../utils';\n\n/*\n * Increase the depth of the current item by putting it in a sub-list\n * of previous item.\n * For first items in a list, does nothing.\n */\n\nfunction increaseItemDepth(opts: Options, change: Change): Change {\n    const previousItem = getPreviousItem(opts, change.value);\n    const currentItem = getCurrentItem(opts, change.value);\n\n    if (!previousItem) {\n        return change;\n    }\n\n    if (!currentItem) {\n        return change;\n    }\n\n    // Move the item in the sublist of previous item\n    return moveAsSubItem(opts, change, currentItem, previousItem.key);\n}\n\n/*\n * Move the given item to the sublist at the end of destination item,\n * creating a sublist if needed.\n */\n\nfunction moveAsSubItem(\n    opts: Options,\n    change: Change,\n    // The list item to add\n    item: Block,\n    // The key of the destination node\n    destKey: string\n): Change {\n    const destination = change.value.document.getDescendant(destKey);\n    const lastIndex = destination.nodes.size;\n    const lastChild = destination.nodes.last();\n\n    // The potential existing last child list\n    const existingList = isList(opts, lastChild) ? lastChild : null;\n\n    if (existingList) {\n        return change.moveNodeByKey(\n            item.key,\n            existingList.key,\n            existingList.nodes.size // as last item\n        );\n    }\n\n    const currentList = getListForItem(opts, change.value, destination);\n\n    if (!currentList) {\n        throw new Error('Destination is not in a list');\n    }\n\n    const newSublist = Block.create({\n        object: 'block',\n        type: currentList.type,\n        data: currentList.data\n    });\n\n    change.insertNodeByKey(destKey, lastIndex, newSublist, {\n        normalize: false\n    });\n\n    return change.moveNodeByKey(item.key, newSublist.key, 0);\n}\n\nexport default increaseItemDepth;\n","import { Change } from '@gitbook/slate';\n\nimport Options from '../options';\nimport { getCurrentItem } from '../utils';\n\n/*\n * Split a list item at the start of the current range.\n */\n\nfunction splitListItem(opts: Options, change: Change): Change {\n    const { value } = change;\n    const currentItem = getCurrentItem(opts, value);\n\n    if (!currentItem) {\n        return change;\n    }\n\n    const splitOffset = value.startOffset;\n\n    return change.splitDescendantsByKey(\n        currentItem.key,\n        value.startKey,\n        splitOffset\n    );\n}\n\nexport default splitListItem;\n","import { Change } from '@gitbook/slate';\n\nimport Options from '../options';\nimport { getItemsAtRange } from '../utils';\n\n/*\n * Unwrap items at range from their list.\n */\n\nfunction unwrapList(opts: Options, change: Change): Change {\n    const items = getItemsAtRange(opts, change.value);\n\n    if (items.isEmpty()) {\n        return change;\n    }\n\n    // Unwrap the items from their list\n    items.forEach(item =>\n        change.unwrapNodeByKey(item.key, { normalize: false })\n    );\n\n    // Parent of the list of the items\n    const firstItem = items.first();\n    const parent = change.value.document.getParent(firstItem.key);\n\n    let index = parent.getChildIndex(firstItem.key);\n\n    // Unwrap the items' children\n    items.forEach(item => {\n        item.nodes.forEach(node => {\n            change.moveNodeByKey(node.key, parent.key, index, {\n                normalize: false\n            });\n\n            index += 1;\n        });\n    });\n\n    // Finally, remove the now empty items\n    items.forEach(item =>\n        change.removeNodeByKey(item.key, { normalize: false })\n    );\n\n    return change;\n}\n\nexport default unwrapList;\n","import { Block, Change, Data, Value } from '@gitbook/slate';\nimport { List } from 'immutable';\n\nimport Options from '../options';\nimport { isList } from '../utils';\n\n/*\n * Wrap the blocks in the current selection in a new list. Selected\n * lists are merged together.\n */\nfunction wrapInList(\n    opts: Options,\n    change: Change,\n    type?: string,\n    data?: object\n): Change {\n    const selectedBlocks = getHighestSelectedBlocks(change.value);\n    type = type || opts.types[0];\n\n    // Wrap in container\n    change.wrapBlock(\n        {\n            type,\n            data: Data.create(data)\n        },\n        { normalize: false }\n    );\n\n    // Wrap in list items\n    selectedBlocks.forEach(node => {\n        if (isList(opts, node)) {\n            // Merge its items with the created list\n            node.nodes.forEach(({ key }) =>\n                change.unwrapNodeByKey(key, { normalize: false })\n            );\n        } else {\n            change.wrapBlockByKey(node.key, opts.typeItem, {\n                normalize: false\n            });\n        }\n    });\n\n    return change.normalize();\n}\n\n/*\n * Returns the highest list of blocks that cover the current selection\n */\n\nfunction getHighestSelectedBlocks(value: Value): List<Block> {\n    const range = value.selection;\n    const { document } = value;\n\n    const startBlock = document.getClosestBlock(range.startKey);\n    const endBlock = document.getClosestBlock(range.endKey);\n\n    if (startBlock === endBlock) {\n        return List([startBlock]);\n    }\n\n    const ancestor = document.getCommonAncestor(startBlock.key, endBlock.key);\n    const startPath = ancestor.getPath(startBlock.key);\n    const endPath = ancestor.getPath(endBlock.key);\n\n    return ancestor.nodes.slice(startPath[0], endPath[0] + 1);\n}\n\nexport default wrapInList;\n","import {\n    decreaseItemDepth,\n    increaseItemDepth,\n    splitListItem,\n    unwrapList,\n    wrapInList\n} from './changes';\nimport Options, { OptionsFormat } from './options';\nimport {\n    getCurrentItem,\n    getCurrentList,\n    getItemDepth,\n    getItemsAtRange,\n    getPreviousItem,\n    isList,\n    isSelectionInList\n} from './utils';\n\n/*\n * Returns the core of the plugin, limited to the validation and normalization\n * part of `slate-edit-list`, and utils.\n *\n * Import this directly: `import EditListCore from '@gitbook/slate-edit-table/lib/core'`\n * if you don't care about behavior/rendering.\n */\nfunction createAPI(opts: Options): object {\n    return {\n        utils: {\n            getCurrentItem: getCurrentItem.bind(null, opts),\n            getCurrentList: getCurrentList.bind(null, opts),\n            getItemDepth: getItemDepth.bind(null, opts),\n            getItemsAtRange: getItemsAtRange.bind(null, opts),\n            getPreviousItem: getPreviousItem.bind(null, opts),\n            isList: isList.bind(null, opts),\n            isSelectionInList: isSelectionInList.bind(null, opts)\n        },\n\n        changes: {\n            decreaseItemDepth: bindAndScopeChange(opts, decreaseItemDepth),\n            increaseItemDepth: bindAndScopeChange(opts, increaseItemDepth),\n            splitListItem: bindAndScopeChange(opts, splitListItem),\n            unwrapList: bindAndScopeChange(opts, unwrapList),\n            wrapInList: wrapInList.bind(null, opts)\n        }\n    };\n}\n\n/*\n * Bind a change to given options, and scope it to act only inside a list\n */\nfunction bindAndScopeChange(opts: Options, fn: any): any {\n    return (change, ...args) => {\n        const { value } = change;\n\n        if (!isSelectionInList(opts, value)) {\n            return change;\n        }\n\n        return fn(...[opts, change].concat(args));\n    };\n}\n\nexport { createAPI };\n","import { Node } from '@gitbook/slate';\nimport { Record } from 'immutable';\n\nexport interface OptionsFormat {\n    types?: string[];\n    typeItem?: string;\n    typeDefault?: string;\n    canMerge?: (listA: Node, listB: Node) => boolean;\n}\n\n/*\n * The plugin options\n */\n\nclass Options extends Record({\n    types: ['ul_list', 'ol_list'],\n    typeItem: 'list_item',\n    typeDefault: 'paragraph',\n    canMerge: (a: Node, b: Node) => a.type === b.type\n}) {\n    // The possibles types for list containers\n    public types: string[];\n    // The of list items\n    public typeItem: string;\n    // The of default block in items\n    public typeDefault: string;\n    // You can control here the automatic merging of adjacent lists\n    public canMerge: (listA: Node, listB: Node) => boolean;\n}\n\nexport default Options;\n","import { Change } from '@gitbook/slate';\n\nimport { unwrapList } from '../changes';\nimport Options from '../options';\nimport { getCurrentItem } from '../utils';\n\n/*\n * User pressed Delete in an editor\n */\n\nfunction onBackspace(\n    event: any,\n    change: Change,\n    editor: any,\n    opts: Options\n): void | any {\n    const { value } = change;\n    const { startOffset, selection } = value;\n\n    // Only unwrap...\n    // ... with a collapsed selection\n    if (selection.isExpanded) {\n        return undefined;\n    }\n\n    // ... when at the beginning of nodes\n    if (startOffset > 0) {\n        return undefined;\n    }\n\n    // ... in a list\n    const currentItem = getCurrentItem(opts, value);\n\n    if (!currentItem) {\n        return undefined;\n    }\n\n    // ... more precisely at the beginning of the current item\n    if (!selection.isAtStartOf(currentItem)) {\n        return undefined;\n    }\n\n    event.preventDefault();\n    return unwrapList(opts, change);\n}\n\nexport default onBackspace;\n","import { Change } from '@gitbook/slate';\n\nimport { decreaseItemDepth, splitListItem, unwrapList } from '../changes';\nimport Options from '../options';\nimport { getCurrentItem, getItemDepth } from '../utils';\n\n/*\n * User pressed Enter in an editor\n *\n * Enter in a list item should split the list item\n * Enter in an empty list item should remove it\n * Shift+Enter in a list item should make a new line\n */\n\nfunction onEnter(\n    event: any,\n    change: Change,\n    editor: any,\n    opts: Options\n): void | any {\n    // Pressing Shift+Enter\n    // should split block normally\n    if (event.shiftKey) {\n        return undefined;\n    }\n\n    const { value } = change;\n    const currentItem = getCurrentItem(opts, value);\n\n    // Not in a list\n    if (!currentItem) {\n        return undefined;\n    }\n\n    event.preventDefault();\n\n    // If expanded, delete first.\n    if (value.isExpanded) {\n        change.delete();\n    }\n\n    if (currentItem.isEmpty) {\n        // Block is empty, we exit the list\n        if (getItemDepth(opts, value) > 1) {\n            return decreaseItemDepth(opts, change);\n        }\n        // Exit list\n        return unwrapList(opts, change);\n    }\n    // Split list item\n    return splitListItem(opts, change);\n}\n\nexport default onEnter;\n","import { Change } from '@gitbook/slate';\n\nimport { decreaseItemDepth, increaseItemDepth } from '../changes';\nimport Options from '../options';\nimport { getCurrentItem } from '../utils';\n\n/*\n * User pressed Tab in an editor.\n * Tab       -> Increase item depth if inside a list item\n * Shift+Tab -> Decrease item depth if inside a list item\n */\n\nfunction onTab(\n    event: any,\n    change: Change,\n    editor: any,\n    opts: Options\n): void | any {\n    const { value } = change;\n    const { isCollapsed } = value;\n\n    if (!isCollapsed || !getCurrentItem(opts, value)) {\n        return undefined;\n    }\n\n    // Shift+tab reduce depth\n    if (event.shiftKey) {\n        event.preventDefault();\n\n        return decreaseItemDepth(opts, change);\n    }\n\n    // Tab increases depth\n    event.preventDefault();\n\n    return increaseItemDepth(opts, change);\n}\n\nexport default onTab;\n","import { Plugin } from '@gitbook/slate-react';\n\nimport Options from '../options';\nimport onBackspace from './onBackspace';\nimport onEnter from './onEnter';\nimport onTab from './onTab';\n\nconst KEY_ENTER = 'Enter';\nconst KEY_TAB = 'Tab';\nconst KEY_BACKSPACE = 'Backspace';\n\n/*\n * Create the slate-react plugin.\n */\nfunction createPlugin(opts: Options): Plugin {\n    return {\n        onKeyDown: onKeyDown.bind(null, opts)\n    };\n}\n\n/*\n * User is pressing a key in the editor\n */\nfunction onKeyDown(opts: Options, event, change, editor: any): void | any {\n    const args = [event, change, editor, opts];\n\n    switch (event.key) {\n        case KEY_ENTER:\n            return onEnter(...args);\n        case KEY_TAB:\n            return onTab(...args);\n        case KEY_BACKSPACE:\n            return onBackspace(...args);\n        default:\n            return undefined;\n    }\n}\n\nexport default createPlugin;\n","import { Change, Node } from '@gitbook/slate';\n\nimport Options from '../options';\nimport { isList } from '../utils';\n\ntype Normalizer = (change: Change) => any;\n\n/*\n * Create a schema definition with rules to normalize lists\n */\n\nfunction createValidation(opts: Options): (node: Node) => void | Normalizer {\n    return node => joinAdjacentLists(opts, node);\n}\n\n/*\n * A rule that joins adjacent lists of the same type\n */\n\nfunction joinAdjacentLists(opts: Options, node: Node): void | Normalizer {\n    if (node.object !== 'document' && node.object !== 'block') {\n        return undefined;\n    }\n\n    const invalids = node.nodes\n        .map((child, i) => {\n            if (!isList(opts, child)) {\n                return null;\n            }\n            const next = node.nodes.get(i + 1);\n\n            if (!next || !isList(opts, next) || !opts.canMerge(child, next)) {\n                return null;\n            }\n\n            return [child, next];\n        })\n        .filter(Boolean);\n\n    if (invalids.isEmpty()) {\n        return undefined;\n    }\n\n    /*\n     * Join the list pairs\n     */\n    // We join in reverse order, so that multiple lists folds onto the first one\n    return change => {\n        invalids.reverse().forEach(pair => {\n            const [first, second] = pair;\n            const updatedSecond = change.value.document.getDescendant(\n                second.key\n            );\n\n            updatedSecond.nodes.forEach((secondNode, index) => {\n                change.moveNodeByKey(\n                    secondNode.key,\n                    first.key,\n                    first.nodes.size + index,\n                    { normalize: false }\n                );\n            });\n\n            change.removeNodeByKey(second.key, { normalize: false });\n        });\n    };\n}\n\nexport default createValidation;\n","import { Change, Node, Schema } from '@gitbook/slate';\n\nimport Options from '../options';\nimport createValidation from './createValidation';\n\n/*\n * Create a schema definition with rules to normalize lists\n */\n\nfunction createSchema(opts: Options): Schema {\n    const constructedSchema = {\n        validations: [createValidation(opts)],\n        blocks: {\n            [opts.typeItem]: {\n                parent: { types: opts.types },\n                nodes: [{ objects: ['block'] }],\n\n                normalize: normalize({\n                    parent_type_invalid: (change, context) =>\n                        change.unwrapBlockByKey(context.node.key, {\n                            normalize: false\n                        }),\n                    child_object_invalid: (change, context) =>\n                        wrapChildrenInDefaultBlock(opts, change, context.node)\n                })\n            }\n        }\n    };\n\n    // validate all list types, ensure they only have list item children\n    opts.types.forEach(type => {\n        constructedSchema.blocks[type] = {\n            nodes: [{ types: [opts.typeItem] }],\n            normalize: normalize({\n                child_type_invalid: (change, context) =>\n                    change.wrapBlockByKey(context.child.key, opts.typeItem, {\n                        normalize: false\n                    })\n            })\n        };\n    });\n\n    return Schema.create(constructedSchema);\n}\n\n/*\n * Allows to define a normalize function through a keyed collection of functions\n */\nfunction normalize(reasons: { [string]: (Change, context: any) => any }): any {\n    return (change, reason, context) => {\n        const reasonFn = reasons[reason];\n\n        if (reasonFn) {\n            reasonFn(change, context);\n        }\n    };\n}\n\n/*\n * Wraps all child of a node in the default block type.\n * Returns a change, for chaining purposes\n */\nfunction wrapChildrenInDefaultBlock(\n    opts: Options,\n    change: Change,\n    node: Node\n): Change {\n    change.wrapBlockByKey(node.nodes.first().key, opts.typeDefault, {\n        normalize: false\n    });\n\n    const wrapper = change.value.document.getDescendant(node.key).nodes.first();\n\n    // Add in the remaining items\n    node.nodes.rest().forEach((child, index) =>\n        change.moveNodeByKey(child.key, wrapper.key, index + 1, {\n            normalize: false\n        })\n    );\n\n    return change;\n}\n\nexport default createSchema;\n","import { Schema } from '@gitbook/slate';\nimport { Plugin } from '@gitbook/slate-react';\n\nimport { createAPI } from './api';\nimport Options, { OptionsFormat } from './options';\nimport { createPlugin } from './plugin';\nimport { createSchema } from './schema';\n\n/*\n * A Slate plugin to handle keyboard events in lists.\n */\nfunction EditList(\n    optsInput: OptionsFormat = {}\n): {\n    schema: Schema;\n    plugin: Plugin;\n} {\n    const opts = new Options(optsInput);\n\n    return {\n        ...createAPI(opts),\n        schema: createSchema(opts),\n        plugin: createPlugin(opts)\n    };\n}\n\nexport default EditList;\n"]}