Skip to main content

@barocss/office-word

Version in this checkout: 0.1.2. npm · Source

Word-processing schema, editor kit, pagination, formatting, and document UI components.

Purpose

Use the root entry for document behavior and the /ui entry for React controls. The complete application assembly is in apps/word.

Install

npm install @barocss/office-word react react-dom

The published package provides ES modules and TypeScript declarations. Use a bundler that supports package exports.

Public entry points

ImportRole
@barocss/office-wordPublic JavaScript and TypeScript API
@barocss/office-word/uiReact UI components
@barocss/office-word/ui.cssStylesheet
@barocss/office-word/workspaceWorkspace file codec

Import only these public paths. Source paths such as @barocss/office-word/src/... are not part of the published API.

Usage

import { createWordEditor, getWordSchemaDefinition } from '@barocss/office-word';

const editor = createWordEditor();
console.log(getWordSchemaDefinition().topNode);
console.log(editor.getRootId());
// Keep this editor for the host's view, layout, and controls.
// When the host closes the document:
editor.destroy();

Peer dependencies

  • react: >=18.
  • react-dom: >=18.

Styles

Load @barocss/office-ui/tokens.css once in the host. Load @barocss/office-text/text.css for shared document content. This package also exposes @barocss/office-word/ui.css.

Office React controls use Tailwind 4 utility classes. Configure the host to scan the installed package dist files; npm packages do not include the repository's src directories. See the Office styling guide for a Vite setup and CSS source paths.

Host integration

Register registerWordRenderers in the registry passed to EditorViewDOM. The host also coordinates measurement and pagination. Ribbon, Ruler, DrawingOverlay, OutlinePane, and dialogs are available from /ui. See the Word host for the full composition; the example above intentionally creates only the editor session.

Integration notes

createWordEditor creates a session, not a ready-mounted word processor. A host must connect the DOM view, page measurement/layout, selection overlays, storage, and UI. Importing the package does not provide a cloud document service.

Documentation

License

MIT. The published archive includes the license in dist/LICENSE.