npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@univerjs/docs

v1.3.1

Published

Core document model and rich-text operations for Univer Docs.

Readme

@univerjs/docs

npm version license downloads

@univerjs/docs provides the document data model and core rich-text operations for Univer Docs, independent of the UI layer.

Package Overview

| Package | UMD global | CSS | Locales | Facade entry | | --- | --- | :---: | :---: | :---: | | @univerjs/docs | UniverDocs | No | No | Yes |

Installation

pnpm add @univerjs/docs
# or
npm install @univerjs/docs

Keep all @univerjs/* packages on the same version.

Usage

import { UniverDocsPlugin } from '@univerjs/docs';

univer.registerPlugin(UniverDocsPlugin);

Heading collapse in Modern documents

Modern documents (DocumentFlavor.MODERN) support collapsing Heading 1 through Heading 5. The heading stays visible; its section extends to the next heading of the same or a higher level, or the end of its content flow. Each table cell and Modern column has its own heading hierarchy. Expanding a parent preserves the collapse flags of its nested headings. Traditional documents ignore these flags.

IParagraph.headingCollapsed is an optional boolean in the document snapshot. Only true collapses a heading; false or an omitted flag leaves it expanded. Collapsing changes layout visibility without deleting the section's text, tables, images, or other snapshot content. Saving and reopening a Univer snapshot retains the flag. This contract does not establish preservation through Office import or export.

Change collapse state with a command

UniverDocsPlugin registers SetHeadingCollapsedCommand (doc.command.set-heading-collapsed). After registering the plugin and creating the document, execute the registered command through the Facade API or ICommandService; do not call its handler or mutate the model directly. For an existing univerAPI instance:

import { SetHeadingCollapsedCommand } from '@univerjs/docs';

const changed = await univerAPI.executeCommand(SetHeadingCollapsedCommand.id, {
    unitId: documentId,
    paragraphId: headingParagraphId,
    collapsed: true,
});

Pass the document's unit ID, the heading's stable paragraph ID, and the desired boolean state. Use collapsed: false to expand. The command returns false for a no-op or an invalid target, including Traditional or disabled documents, headings hidden by an ancestor, empty sections when collapsing, and targets without edit permission.

Concurrent paragraph formatting preserves inherited style references and imported numbering metadata; a full replacement can still explicitly clear those fields.

Collapse state is shared document state, not a personal view preference. The command uses the rich-text mutation path for undo/redo and collaboration. Undoing a fold preserves later peer character formatting and enclosing field or content-control properties that the fold did not edit. A selection hidden by a collapse moves to the visible heading. Worker layout uses the same flags after edits, undo/redo, and snapshot recovery; visibility changes rebuild the affected layout and retain the published viewport until replacement content is ready. Hidden tables and images are omitted from layout publications, while their source data remains in the snapshot. Rejected edits with empty operations do not advance the Worker mutation queue or force the next real edit to resnapshot the document.

See the editor interaction details for the Canvas control.

Resources