configureAsListElements

How to get configureAsListElements

import configureAsListElements from 'fontoxml-list-flow/src/configureAsListElements.js'

Type: Function

Configure a list-like structure existing of a list container element with children representing list items.

Lists may be nested. The options.list.style property may be used to trigger different numbering or bulleting styles.

Some schemata allow lists to specify the list item numbering with an additional element. Use the options.listItem.labelSelector to mark these elements as labels. These labels will automatically be removed when converting a list to a number of paragraphs.

Automatically creating lists

Set the list.nodeName and use one of the predetermined list styles, like configureAsListElements.NUMBERED_LIST_STYLE to enable the auto create list macro:

  • typing "1." will insert a numbered list.

  • typing "* " will insert a bullet list.

These macros can be undone by pressing the backspace key.

Set the configuredEnableAutoCreateListMacro configuration variable to false to disable the automatic registration of the list macro.

Examples

The configuration of a normal unordered list, <ul>, using <li> and <p> inside list items, could look like this:

configureAsListElements({
  list: {
    selector: 'self::ul',
    nodeName: 'ul',
    style: configureAsListElements.BULLETED_LIST_TYPE
  },
  item: {
    nodeName: 'li'
  },
  paragraph: {
    nodeName: 'p'
  }
});

An example of a list for which the numbering represented with a createLabelQueryWidget is:

configureAsListElements(sxModule, {
  item: {
    nodeName: 'item'
  },
  list: {
    selector: 'self::ul',
    style: createLabelQueryWidget('if (self::item[parent::ul[@type = "openBullet"]]) then "\u25cb" else "\u25cf"')
  },
  paragraph: {
    nodeName: 'para'
  }
});

Arguments

# Name Type Description
1. sxModule Object
2. options Object
  Members

Members

Name Type Description
item Object

Everything configuring the list item

  Members

Members

Name Type Description
[labelSelector] XPathTest

Specify how the optional label element works. Label elements can be used to manually number a list. They should not influence unwrapping lists to convert them to paragraphs.

nodeName String

The nodeName of the items this list contains.

[selector] String

An additional selector for the items in the list. Defaults to self:: <nodeName>.

list Object

Everything configuring the list

  Members

Members

Name Type Description
[attributes] Object

Attributes of the list. This is used for the auto create list macro.

[nodeName] String

The node name of the list. This is used for the auto create list macro.

[priority] Number

The priority of this list configuration.

[selector] String

A selector matching the list which to configure. If this selector is absent, it will be generated from the nodeName and attributes. This can be set as well as the nodename and attributes to further refine when to use the specified styling for the list.

style Widget | Array<String> | Array<Object>

The kind of list to render. Influences the markers (numbered vs bulleted vs empty vs custom). One of the list styles: NUMBERED_LIST_STYLE, EMPTY_LIST_STYLE, BULLETED_LIST_STYLE, or an array defining which types should be used: as a string (infers bulletting) or as objects with a format key (which infers numbering). It can also be a widget. This widget is placed on the item, so it has the context of this item.

[paragraph] Object

Everything configuring the paragraph. If absent, there are no paragraphs in the list items

  Members

Members

Name Type Description
[nodeName] String

The nodeName of the paragraph in the list. If any.

Static properties

Name Type Description
BULLETED_LIST_STYLE Array<String>

Specifies the default style for a bulleted list.

EMPTY_LIST_STYLE Array<String>

Specifies the default style for an unmarked list.

NUMBERED_LIST_STYLE Array<String>

Specifies the default style for a numbered list.