Options
All
  • Public
  • Public/Protected
  • All
Menu

Represent a bullet or a numbering list

example

A VList is a logical representation of list items, it contains an item array with node and list type stack. e.g. We have a list like this

<ol>
  <li>item 1</li>
  <li>item 2</li>
  <ul>
    <li>item 2.1</li>
    <li>item 2.2</li>
  <ul>
</ol>

A VList of this list will be like this:

{
  rootList: (OL node),
  items: [{
      node: (LI node with 'item 1'),
      listTypes: [null, OL],
    }, {
      node: (LI node with 'item 2'),
      listTypes: [null, OL],
    }, {
      node: (LI node with 'item 2.1),
      listTypes: [null, OL, UL],
    }, {
      node: (LI node with 'item 2.2'),
      listTypes: [null, OL, UL],
    }
  ]
}

When we want to outdent item 2.1, we just need to remove the last "UL" from listTypes of item 2.1, then the writeBack() function will handle everything related to DOM change

Hierarchy

  • VList

Index

Constructors

constructor

  • new VList(rootList: HTMLUListElement | HTMLOListElement): VList

Properties

Readonly items

items: VListItem[] = []

rootList

rootList: HTMLUListElement | HTMLOListElement

Methods

appendItem

changeListType

  • Change list type of the given range of this list. If some of the items are not real list item yet, this will make them to be list item with given type If all items in the given range are already in the type to change to, this becomes an outdent operation

    Parameters

    Returns void

contains

  • contains(node: Node): boolean

getLastItemNumber

  • getLastItemNumber(): number

getListItemIndex

  • getListItemIndex(input: Node): number
  • Get the index of the List Item in the current List If the root list is: Ordered list, the listIndex start count is going to be the start property of the OL - 1,

    example

    For example if we want to find the index of Item 2 in the list below, the returned index is going to be 6

    • <ol start="5">
      <li>item 1</li>
      <li>item 2</li> <!-- Node to find -->
      <li>item 3</li>
      </ol>
      
      Unordered list, the listIndex start count starts from 0 @example For example if we want to find the index of Item 2 in the list below, the returned index is going to be 2
      <ul>
      <li>item 1</li>
      <li>item 2</li> <!-- Node to find -->
      <li>item 3</li>
      </ul>
      
      @param input List item to find in the root list

    Parameters

    • input: Node

    Returns number

getStart

  • getStart(): number

mergeVList

  • mergeVList(list: VList): void
  • Merge the given VList into current VList.

    • All list items will be removed from the given VList and added into this list.
    • The root node of the given VList will be removed from DOM tree
    • If there are orphan items in the given VList, they will be merged into the last item of this list if any.

    Parameters

    • list: VList

      The vList to merge from

    Returns void

removeMargins

  • removeMargins(): void

setAlignment

setIndentation

setListStyleType

split

  • split(separator: HTMLElement, startNumber: number): void
  • Sets the New List Start Property, that is going to be used to create a new List in the WriteBack function

    Parameters

    • separator: HTMLElement

      The HTML element that indicates when to split the VList

    • startNumber: number

      The start number of the new List

    Returns void

writeBack

  • writeBack(shouldReuseAllAncestorListElements?: boolean, disableListChain?: boolean): void
  • Write the result back into DOM tree After that, this VList becomes unavailable because we set this.rootList to null

    Parameters

    • Optional shouldReuseAllAncestorListElements: boolean

      Optional - defaults to false.

    • Optional disableListChain: boolean

      Whether we want to disable list chain functionality. @default false

    Returns void

Generated using TypeDoc