Skip to main content

@barocss/model

Version in this checkout: 1.0.3. npm · Source

Document operations, transaction helpers, positions, and selection context.

Purpose

Use the model layer to build document trees and apply structured edits through the editor transaction system.

Install

npm install @barocss/model @barocss/editor-core

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

Public entry points

ImportRole
@barocss/modelPublic JavaScript and TypeScript API

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

Usage

import { node, textNode, mark } from '@barocss/model';

const paragraph = node('paragraph', {}, [
textNode('inline-text', 'A clear heading', [mark('bold')]),
]);
console.log(paragraph.content); // Pass the tree to your document loader.

Peer dependencies

  • @barocss/editor-core: workspace:*.

Integration notes

Tree builders return model data; constructing a node does not insert it into a live document. Apply edits through a transaction or an editor command so history and selection mapping can participate.

Documentation

License

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