/** * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ /** * @module list/documentlist/utils/model */ import type { DocumentFragment, Element, Model, Node, Writer, Item } from 'ckeditor5/src/engine'; import { type ArrayOrItem } from 'ckeditor5/src/utils'; /** * The list item ID generator. * * @internal */ export declare class ListItemUid { /** * Returns the next ID. * * @internal */ static next(): string; } /** * An {@link module:engine/model/element~Element} that is known to be a list element. * * @internal */ export interface ListElement extends Element { getAttribute(key: 'listItemId'): string; getAttribute(key: 'listIndent'): number; getAttribute(key: 'listType'): 'numbered' | 'bulleted'; getAttribute(key: string): unknown; } /** * Returns true if the given model node is a list item block. * * @internal */ export declare function isListItemBlock(node: Item | DocumentFragment | null): node is ListElement; /** * Returns an array with all elements that represents the same list item. * * It means that values for `listIndent`, and `listItemId` for all items are equal. * * @internal * @param listItem Starting list item element. * @param options.higherIndent Whether blocks with a higher indent level than the start block should be included * in the result. */ export declare function getAllListItemBlocks(listItem: Node, options?: { higherIndent?: boolean; }): Array; /** * Returns an array with elements that represents the same list item in the specified direction. * * It means that values for `listIndent` and `listItemId` for all items are equal. * * **Note**: For backward search the provided item is not included, but for forward search it is included in the result. * * @internal * @param listItem Starting list item element. * @param options.direction Walking direction. * @param options.higherIndent Whether blocks with a higher indent level than the start block should be included in the result. */ export declare function getListItemBlocks(listItem: Node, options?: { direction?: 'forward' | 'backward'; higherIndent?: boolean; }): Array; /** * Returns a list items nested inside the given list item. * * @internal */ export declare function getNestedListBlocks(listItem: Element): Array; /** * Returns array of all blocks/items of the same list as given block (same indent, same type and properties). * * @internal * @param listItem Starting list item element. */ export declare function getListItems(listItem: Element): Array; /** * Check if the given block is the first in the list item. * * @internal * @param listBlock The list block element. */ export declare function isFirstBlockOfListItem(listBlock: Node): boolean; /** * Check if the given block is the last in the list item. * * @internal */ export declare function isLastBlockOfListItem(listBlock: Element): boolean; /** * Expands the given list of selected blocks to include the leading and tailing blocks of partially selected list items. * * @internal * @param blocks The list of selected blocks. * @param options.withNested Whether should include nested list items. */ export declare function expandListBlocksToCompleteItems(blocks: ArrayOrItem, options?: { withNested?: boolean; }): Array; /** * Expands the given list of selected blocks to include all the items of the lists they're in. * * @internal * @param blocks The list of selected blocks. */ export declare function expandListBlocksToCompleteList(blocks: ArrayOrItem): Array; /** * Splits the list item just before the provided list block. * * @internal * @param listBlock The list block element. * @param writer The model writer. * @returns The array of updated blocks. */ export declare function splitListItemBefore(listBlock: Element, writer: Writer): Array; /** * Merges the list item with the parent list item. * * @internal * @param listBlock The list block element. * @param parentBlock The list block element to merge with. * @param writer The model writer. * @returns The array of updated blocks. */ export declare function mergeListItemBefore(listBlock: Node, parentBlock: Element, writer: Writer): Array; /** * Increases indentation of given list blocks. * * @internal * @param blocks The block or iterable of blocks. * @param writer The model writer. * @param options.expand Whether should expand the list of blocks to include complete list items. * @param options.indentBy The number of levels the indentation should change (could be negative). */ export declare function indentBlocks(blocks: ArrayOrItem, writer: Writer, { expand, indentBy }?: { expand?: boolean; indentBy?: number; }): Array; /** * Decreases indentation of given list of blocks. If the indentation of some blocks matches the indentation * of surrounding blocks, they get merged together. * * @internal * @param blocks The block or iterable of blocks. * @param writer The model writer. */ export declare function outdentBlocksWithMerge(blocks: ArrayOrItem, writer: Writer): Array; /** * Removes all list attributes from the given blocks. * * @internal * @param blocks The block or iterable of blocks. * @param writer The model writer. * @returns Array of altered blocks. */ export declare function removeListAttributes(blocks: ArrayOrItem, writer: Writer): Array; /** * Checks whether the given blocks are related to a single list item. * * @internal * @param blocks The list block elements. */ export declare function isSingleListItem(blocks: Array): boolean; /** * Modifies the indents of list blocks following the given list block so the indentation is valid after * the given block is no longer a list item. * * @internal * @param lastBlock The last list block that has become a non-list element. * @param writer The model writer. * @returns Array of altered blocks. */ export declare function outdentFollowingItems(lastBlock: Element, writer: Writer): Array; /** * Returns the array of given blocks sorted by model indexes (document order). * * @internal */ export declare function sortBlocks(blocks: Iterable): Array; /** * Returns a selected block object. If a selected object is inline or when there is no selected * object, `null` is returned. * * @internal * @param model The instance of editor model. * @returns Selected block object or `null`. */ export declare function getSelectedBlockObject(model: Model): Element | null;