Skip to main content

@barocss/editor-core

Version in this checkout: 1.0.3. npm · Source

Browse live examples: JavaScript / DOM

Editor sessions, commands, extensions, selection, keybindings, and history.

Purpose

Use this package for an editor without a prescribed UI. For Note, Word, Slides, or Site, start with that product's editor factory instead.

Install

npm install @barocss/editor-core @barocss/schema @barocss/extensions

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

Public entry points

ImportRole
@barocss/editor-corePublic JavaScript and TypeScript API

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

Usage

import { Editor } from '@barocss/editor-core';
import { createSchema, getMinimalSchemaDefinition } from '@barocss/schema';
import { createCoreExtensions } from '@barocss/extensions';

const editor = new Editor({
schema: createSchema('example', getMinimalSchemaDefinition()),
extensions: createCoreExtensions(),
});
editor.loadDocument({ stype: 'document', content: [
{ stype: 'paragraph', content: [{ stype: 'inline-text', text: 'Hello' }] },
]}, 'example-session');
console.log(editor.getRootId());
// Attach your view here. When the session ends:
editor.destroy();

Integration notes

Create one editor per independent editing session. Load a document after construction, attach a view separately, and call destroy when the session ends.

Documentation

License

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