API 参考

FDocumentListItem

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。

Facade object for a single docs list item.

Access

Access through:

Example

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Ship API')item?.setGlyphType(univerAPI.Enum.ListGlyphType.UPPER_LETTER, {  mode: univerAPI.Enum.DocsListSelectionMode.Level,})item?.demote()

Setup

Register @univerjs-pro/docs-list or a preset that includes it. In plugin mode, import @univerjs-pro/docs-list/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/docs-list

FDocumentListItem.continueNumbering

Continues numbering from the previous same-level ordered list segment.

TypeScript
continueNumbering(): boolean

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Start a new list segment that continues numbering from the previous segment.const item = fDocument.findListItemByText('New Segment')item?.continueNumbering()

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.demote

Demotes this item, level, or whole list by one nesting level.

mode: Item only changes this item's nesting level. It works for both ordered and unordered list items. Demoting an item that is already at the maximum nesting level is a no-op, so it may succeed without a visible change.

TypeScript
demote(options?: IDocsListOperationOptions): boolean

Parameters

  • options — Optional. Default: {}. Scope options. Defaults to mode: 'list' in command behavior.

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Demote the whole list.const item = fDocument.findListItemByText('Todo')item?.demote({ mode: univerAPI.Enum.DocsListSelectionMode.List })// Demote the current level.const item2 = fDocument.findListItemByText('Subtask 1')item2?.demote({ mode: univerAPI.Enum.DocsListSelectionMode.Level })// Demote just the item.const item3 = fDocument.findListItemByText('Subtask 1')item3?.demote({ mode: univerAPI.Enum.DocsListSelectionMode.Item })

Types: IDocsListOperationOptions

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.describe

Returns an agent-friendly description of this list item.

TypeScript
describe(): IDocsListItemInfo | null

Returns

The list item info, or null if the paragraph is no longer a list item.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Ship API')console.log(item?.describe())

Types: IDocsListItemInfo

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.getParagraphStartIndex

Returns the paragraph start index that identifies this list item.

TypeScript
getParagraphStartIndex(): number

Returns

The paragraph start index.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Ship API')console.log(item?.getParagraphStartIndex())

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.getSegmentId

Get the segment id of this list item. The main body list item have an empty string segment id. The header and footer list item have a non-empty string segment id.

TypeScript
getSegmentId(): string

Returns

The segment id.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Ship API')console.log(item?.getSegmentId())

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.getText

Returns plain text in this list item.

TypeScript
getText(): string

Returns

The list item text.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Ship API')console.log(item?.getText())

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.isOrdered

Returns whether this list item is rendered as an ordered marker.

This is the recommended guard before calling ordered-list-only APIs such as setPrefixSuffix() or setStartNumber().

TypeScript
isOrdered(): boolean

Returns

true when this item uses an ordered marker.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Step 1')if (item?.isOrdered()) {  item.setPrefixSuffix('Step ', ':')}

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.isUnordered

Returns whether this list item is rendered as an unordered bullet marker.

This is the recommended guard before calling bullet-list-oriented APIs such as setGlyphSymbol().

TypeScript
isUnordered(): boolean

Returns

true when this item exists and uses an unordered marker.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()const item = fDocument.findListItemByText('Todo')if (item?.isUnordered()) {  item.setGlyphSymbol('')}

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.promote

Promotes this item, level, or whole list by one nesting level.

mode: Item only changes this item's nesting level. It works for both ordered and unordered list items. Promoting an item that is already at the top level is a no-op, so it may succeed without a visible change.

TypeScript
promote(options?: IDocsListOperationOptions): boolean

Parameters

  • options — Optional. Default: {}. Scope options. Defaults to mode: 'list' in command behavior.

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Promote the whole list.const item = fDocument.findListItemByText('Todo')item?.promote({ mode: univerAPI.Enum.DocsListSelectionMode.List })// Promote the current level.const item2 = fDocument.findListItemByText('Subtask 1')item2?.promote({ mode: univerAPI.Enum.DocsListSelectionMode.Level })// Promote just the item.const item3 = fDocument.findListItemByText('Subtask 1')item3?.promote({ mode: univerAPI.Enum.DocsListSelectionMode.Item })

Types: IDocsListOperationOptions

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.select

Selects this item, its current level, or its whole list.

TypeScript
select(mode?: DocsListSelectionMode): boolean

Parameters

  • mode — Optional. Default: DocsListSelectionMode.Item. Selection scope. Defaults to item.

Returns

Whether the selection command succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Select just the item.const item = fDocument.findListItemByText('Ship API')item?.select()// Select the whole list.const item2 = fDocument.findListItemByText('Todo')item2?.select(univerAPI.Enum.DocsListSelectionMode.List)// Select the current level.const item3 = fDocument.findListItemByText('Subtask 1')item3?.select(univerAPI.Enum.DocsListSelectionMode.Level)

Types: DocsListSelectionMode

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.setGlyphSymbol

Changes the bullet symbol for this item, level, or whole list.

TypeScript
setGlyphSymbol(symbol: string, options?: IDocsListOperationOptions): boolean

Parameters

  • symbol — Required. The bullet symbol to apply.
  • options — Optional. Default: {}. Scope options. Defaults to mode: 'list' in command behavior.

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Change bullet symbol for the whole list.const item = fDocument.findListItemByText('Todo')item?.setGlyphSymbol('', { mode: univerAPI.Enum.DocsListSelectionMode.List })// Change bullet symbol for the current level.const item2 = fDocument.findListItemByText('Subtask 1')item2?.setGlyphSymbol('', { mode: univerAPI.Enum.DocsListSelectionMode.Level })// Change bullet symbol for just the item.const item3 = fDocument.findListItemByText('Subtask 1')item3?.setGlyphSymbol('', { mode: univerAPI.Enum.DocsListSelectionMode.Item })

Types: IDocsListOperationOptions

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.setGlyphType

Changes the list marker glyph type for this item, level, or whole list.

glyphType controls the marker value style, such as decimal numbers, upper-case letters, lower-case letters, or Roman numerals. It does not change marker punctuation or wrapping; use setPrefixSuffix() to change formats such as 1., (1), or Step 1:.

For unordered bullet lists, setting an ordered glyph type such as DECIMAL removes the bullet symbol and renders the marker as an ordered value. For ordered lists, setting the same glyph type as the current level may succeed without a visible change. For example, the default first level of PresetListType.ORDER_LIST is already DECIMAL.

TypeScript
setGlyphType(glyphType: ListGlyphType, options?: IDocsListOperationOptions): boolean

Parameters

  • glyphType — Required. The marker glyph type to apply.
  • options — Optional. Default: {}. Scope options. Defaults to mode: 'list' in command behavior.

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Change glyph type for the whole list.const item = fDocument.findListItemByText('Todo')item?.setGlyphType(univerAPI.Enum.ListGlyphType.UPPER_LETTER, {  mode: univerAPI.Enum.DocsListSelectionMode.List,})// Change glyph type for the current level.const item2 = fDocument.findListItemByText('Subtask 1')item2?.setGlyphType(univerAPI.Enum.ListGlyphType.LOWER_ROMAN, {  mode: univerAPI.Enum.DocsListSelectionMode.Level,})// Change glyph type for just the item.const item3 = fDocument.findListItemByText('Subtask 1')item3?.setGlyphType(univerAPI.Enum.ListGlyphType.UPPER_LETTER, {  mode: univerAPI.Enum.DocsListSelectionMode.Item,})

Types: ListGlyphType · IDocsListOperationOptions

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.setPrefixSuffix

Sets ordered-list prefix and suffix for this item, level, or whole list.

This changes the ordered marker format around the number placeholder. For example, prefix: '(' and suffix: ')' renders markers like (1), while prefix: 'Step ' and suffix: ':' renders markers like Step 1:.

In mode: Item, the item receives a custom list definition, but it keeps the same listId so ordered-list numbering stays continuous with the surrounding list. Because ordered marker rendering also depends on that shared numbering context, prefix/suffix changes may appear to affect adjacent items in the same continuous list. Use mode: Level or mode: List when formatting ordered-list markers for a stable visual result. No-op for unordered bullet lists.

TypeScript
setPrefixSuffix(prefix: string, suffix: string, options?: IDocsListOperationOptions): boolean

Parameters

  • prefix — Required. Prefix before the number token.
  • suffix — Required. Suffix after the number token.
  • options — Optional. Default: {}. Scope options. Defaults to mode: 'list' in command behavior.

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Set prefix/suffix for the whole list.const item = fDocument.findListItemByText('Todo')if (item?.isOrdered()) {  item.setPrefixSuffix('(', ')', { mode: univerAPI.Enum.DocsListSelectionMode.List })}// Set prefix/suffix for the current level.const item2 = fDocument.findListItemByText('Subtask 1')if (item2?.isOrdered()) {  item2.setPrefixSuffix('<', '>', { mode: univerAPI.Enum.DocsListSelectionMode.Level })}// Set prefix/suffix for just the item.const item3 = fDocument.findListItemByText('Subtask 1')if (item3?.isOrdered()) {  item3.setPrefixSuffix('[', ']', { mode: univerAPI.Enum.DocsListSelectionMode.Item })}

Types: IDocsListOperationOptions

Package: @univerjs-pro/docs-list · Type definitions

FDocumentListItem.setStartNumber

Starts ordered-list numbering from the provided number at this item.

This only applies to ordered list items. Calling it on an unordered bullet list is a no-op. The current implementation restarts numbering from this item and may affect following continuous ordered-list items, regardless of mode.

TypeScript
setStartNumber(startNumber: number, options?: IDocsListStartNumberOptions): boolean

Parameters

  • startNumber — Required. The visible number to start from.
  • options — Optional. Default: {}. Scope and restart options.

Returns

Whether the mutation succeeded.

Examples

TypeScript
const fDocument = univerAPI.getActiveDocument()// Start numbering from 5 for the whole list.const item = fDocument.findListItemByText('Todo')if (item?.isOrdered()) {  item.setStartNumber(5, { mode: univerAPI.Enum.DocsListSelectionMode.List })}// Start numbering from 3 for the current level.const item2 = fDocument.findListItemByText('Subtask 1')if (item2?.isOrdered()) {  item2.setStartNumber(3, { mode: univerAPI.Enum.DocsListSelectionMode.Level })}// Start numbering from 10 for just the item.const item3 = fDocument.findListItemByText('Subtask 1')if (item3?.isOrdered()) {  item3.setStartNumber(10, { mode: univerAPI.Enum.DocsListSelectionMode.Item })}

Types: IDocsListStartNumberOptions

Package: @univerjs-pro/docs-list · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.