Referencia de API

@univerjs/core

Esta página de API está disponible actualmente en inglés. Las firmas y los identificadores no cambian con el idioma.

Core runtime, data models, command system, dependency injection, and Facade APIs for Univer.

TypeScript
import { Univer } from '@univerjs/core'const univer = new Univer({ undoRedoHistoryLimit: 100 })

Entry Points

  • Facade: @univerjs/core/facade

Additional APIs include:

  • getDrawingOrderIndex() and normalizeDrawingOrderIndex() for stable, absolute drawing-layer positions.
  • setWith() for Lodash-compatible deep assignment with custom container creation.
  • DocumentDataModel.getStatistics(options?) for asynchronous, locale-aware document statistics.

Deep assignment with setWith

setWith(object, path, value, customizer) is exported from @univerjs/core. It follows Lodash setWith semantics and is useful when an integration must control how missing path containers are created.

TypeScript
import { setWith } from '@univerjs/core'const config = {}setWith(config, ['sheets', 'sales', 'enabled'], true, Object)

Document statistics

DocumentDataModel.getStatistics() calculates locale-aware word, character, and paragraph counts for a whole document or selected ranges.

TypeScript
getStatistics(options?: IDocumentStatisticsOptions): Promise<IDocumentStatistics>
OptionPurpose
localeSelect the locale used by Intl.Segmenter.
rangesCount only the supplied text ranges; overlapping ranges are merged.
signalCancel a calculation that is no longer needed.
TypeScript
import { DocumentDataModel, LocaleType } from '@univerjs/core'const model = new DocumentDataModel({ body: { dataStream: 'Hello world.\r\n' } })const statistics = await model.getStatistics({ locale: LocaleType.EN_US })console.log(statistics.words, statistics.charactersWithSpaces, statistics.paragraphs)

The result also includes charactersWithoutSpaces, nonAsianWords, and asianCharactersAndKoreanWords.

IUniverConfig

TypeScript
import type { DependencyOverride, ILocales, LocaleType, LogLevel } from '@univerjs/core'import type { Theme } from '@univerjs/themes'export interface IUniverConfig {  /**   * The theme of the Univer instance, default using the default theme.   */  theme?: Theme  /**   * Whether to use dark mode.   * @default false   */  darkMode?: boolean  /**   * The locale of the Univer instance.   */  locale?: LocaleType  /**   * The region used for locale-dependent formatting.   * It follows `locale` until explicitly configured.   */  region?: LocaleType  /**   * The direction of the Univer instance.   * @default 'ltr'   */  direction?: 'ltr' | 'rtl'  /**   * The locales to be used   */  locales?: ILocales  /**   * The log level of the Univer instance.   */  logLevel?: LogLevel  /**   * Whether to enable logging for command execution.   * @default false   */  logCommandExecution?: boolean  /** Maximum undoable command groups per unit. Default: 50. Set to 0 to disable history. */  undoRedoHistoryLimit?: number  /**   * The override dependencies of the Univer instance.   */  override?: DependencyOverride}

Typed record values

RecordValue and RecordSelection are shared types for typed filter selections. Import them from @univerjs/core; Sheets table record filters use RecordValue[].

TypeScript
import type { RecordSelection, RecordValue } from '@univerjs/core'import { FilterSelectionMode, getRecordValueKey, RecordValueType } from '@univerjs/core'const values: RecordValue[] = [  { type: RecordValueType.Blank },  { type: RecordValueType.String, value: '1' },  { type: RecordValueType.Number, value: 1 },]const selection: RecordSelection = { mode: FilterSelectionMode.Include, values }const keys = values.map(getRecordValueKey)

Keys preserve type distinctions such as number 1 versus string '1', and normalize negative zero to zero. Blank records have no value; numeric and date values must be finite. Invalid records throw rather than producing a key.

Layout units

cssPxToEmu() and emuToCssPx() convert between CSS pixels and drawing EMUs using EMU_PER_CSS_PX (9525). Conversion to EMUs rounds to the nearest integer; conversion back to CSS pixels can return a fraction. These helpers convert units, not zoom or device-pixel ratios.

¿Cómo es esta guía?

© 2026 DreamNum Co., Ltd.