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
@barocss/office-word/criterion-confirmationExact native criterion context; Node consumers run pnpm build:criterion before use

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.

Customization boundary​

createWordEditor(options) accepts these composition options:

OptionBehavior
extensionsAppend extension instances after the default product kit
kitReplace the default product extension kit, including when set to an empty array
schemaReplace the default product schema; it is not merged automatically
keybindingsRegister additional bindings without clearing the existing registry

Keep the product's schema, commands, and renderers compatible. An arbitrary schema accepted by the factory does not make every product control work with that schema. A custom extension does not automatically add a toolbar or inspector control.

The author option supplies the identity used by document features such as comments. It is not authentication. The factory adds Word keybindings before caller keybindings. Keep pagination and measurement in the host; changing a renderer can change page geometry.

See extension boundaries and product customization before replacing a kit or adding a node type.

Documentation​

License​

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