Registry / web-framework / roosterjs-editor-api

roosterjs-editor-api

JSON →
library8.62.0jsnpmunverified

roosterjs-editor-api is a JavaScript/TypeScript package that provided programmatic APIs for interacting with the RoosterJs rich-text editor in its 8.x major version series. This package allowed developers to perform various editor operations such as applying formatting, inserting content, and managing selection directly on an `IEditor` instance. It is now considered deprecated, as the RoosterJs project has transitioned to a new architecture in its 9.x series, primarily utilizing packages prefixed with `roosterjs-content-model-`. The current stable version of this specific package is 8.62.0, with new feature development and ongoing maintenance efforts focused exclusively on the `roosterjs-content-model-api` package. Users are strongly encouraged to migrate to the 9.x content model architecture to benefit from ongoing updates, security fixes, and new features. Its key differentiator was providing a direct API layer for the legacy 8.x editor instances, operating on a DOM-based content model rather than the newer Content Model data structure.

npm install roosterjs-editor-api
INSTALL
IMPORT
SIG · ROOSTERJS-EDITOR-A
R
roosterjs-editor-api
web-frameworkjavascriptv8.62.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

IEditor
import { IEditor } from 'roosterjs-editor-api';
const { IEditor } = require('roosterjs-editor-api');
This interface represents the legacy v8 editor instance. It is replaced by `IEditor` from `roosterjs-content-model-core` in v9+.
toggleBold
import { toggleBold } from 'roosterjs-editor-api';
import toggleBold from 'roosterjs-editor-api';
A named export for a common editor formatting function in v8. In v9+, similar functionality is found within `roosterjs-content-model-api`.
insertNode
import { insertNode } from 'roosterjs-editor-api';
require('roosterjs-editor-api').insertNode;
A named export for content insertion. This package is ESM-first, so CommonJS `require` is generally incorrect.

Demonstrates how to programmatically use API functions (like `toggleBold`, `insertNode`) from the *legacy* `roosterjs-editor-api` package on an assumed RoosterJs v8 editor instance. For new projects, developers should use the `roosterjs-content-model-api` package with a v9+ editor.

import { createEditor } from 'roosterjs'; // Assuming createEditor from the v9 facade for simplicity, v8 had similar setup import { toggleBold, insertNode, IEditor } from 'roosterjs-editor-api'; // Legacy v8 API functions and interface const editorDiv = document.createElement('div'); editorDiv.id = 'editor-container-v8'; document.body.appendChild(editorDiv); // In a real v8 application, an IEditor instance would be created like: // import { Editor } from 'roosterjs-editor-core'; // const editor = new Editor(editorDiv, { initialContent: '<p>Initial content</p>' }); // For this quickstart, we'll use a mock IEditor to demonstrate API calls. // A mock IEditor instance conforming to the legacy roosterjs-editor-api.IEditor const mockEditor: IEditor = { getElement: () => editorDiv, focus: () => { console.log('Mock Editor focused'); editorDiv.focus(); }, addContent: (content: string) => { editorDiv.innerHTML += content; console.log(`Mock Editor received content: ${content}`); }, // ... many other IEditor methods would be present in a real v8 editor instance // We cast to 'any' to avoid implementing the entire large IEditor interface for this demo } as any; console.log('--- RoosterJs Editor API (v8) Quickstart ---'); console.log('Note: This demonstrates legacy v8 API usage. For new projects, use v9+ Content Model APIs.'); // Focus the mock editor mockEditor.focus(); // Use API functions from roosterjs-editor-api on the mock editor instance mockEditor.addContent('This is some '); toggleBold(mockEditor); mockEditor.addContent('bold text'); toggleBold(mockEditor); // Toggle bold off mockEditor.addContent(' and some '); const italicNode = document.createElement('i'); italicNode.textContent = 'italic text.'; insertNode(mockEditor, italicNode); console.log('Final content in mock editor div:', editorDiv.innerHTML); // Clean up for demonstration document.body.removeChild(editorDiv);
Debug
Known issues
breakingThis package is part of the RoosterJs 8.x series and is incompatible with the new 9.x Content Model architecture. Direct migration requires rewriting editor initialization and API calls.
fix
Migrate your editor implementation to use packages prefixed with `roosterjs-content-model-` (e.g., `roosterjs-content-model-core`, `roosterjs-content-model-api`). Refer to the official RoosterJs 9.x upgrade guide on GitHub for detailed migration steps: `https://github.com/microsoft/roosterjs/wiki/RoosterJs-9`.
affects: >=8.0.0 <9.0.0
deprecatedThe entire `roosterjs-editor-api` package is deprecated. No new features, bug fixes, or security updates will be provided for this package. All active development is focused on the `roosterjs-content-model-*` packages.
fix
Immediately plan to upgrade your application to RoosterJs 9.x using the `roosterjs-content-model-api` for editor operations. This will ensure you receive ongoing support and critical updates.
affects: >=8.0.0
gotchaAttempting to mix API calls or plugins from `roosterjs-editor-api` (v8) with a RoosterJs 9.x editor instance (`roosterjs-content-model-core`) will lead to runtime errors, unexpected behavior, or silent failures.
fix
Ensure that your editor instance and all interacting APIs and plugins strictly adhere to either the 8.x (DOM-based) or 9.x (Content Model-based) architecture. Do not combine them. Use `roosterjs-editor-adapter` if you need to bridge some legacy v8 plugins to a v9 editor temporarily.
affects: >=8.0.0
Errors
Common errors & fixes
TypeError: editor.toggleBold is not a function
You are likely attempting to call a legacy v8 API function (like `toggleBold` from `roosterjs-editor-api`) on a RoosterJs 9.x editor instance, which has a different API surface.
fix
Update your code to use the equivalent API from `roosterjs-content-model-api` for your v9 editor. For example, `toggleBold(editor)` would become `editor.toggleContentModel(ContentModelSegmentFormat.Bold);` or a similar content model operation.
Cannot find module 'roosterjs-editor-api' or its corresponding type declarations.
You are using CommonJS `require()` syntax in an ESM project, or the package is not correctly installed/configured for your module resolver.
fix
Use ES module import syntax: `import { someFunction } from 'roosterjs-editor-api';`. Ensure `roosterjs-editor-api` is listed in your `package.json` and properly installed, and your TypeScript `tsconfig.json` has `moduleResolution` set appropriately (e.g., 'Node').
Property 'createEditor' does not exist on type 'typeof import("roosterjs-editor-api")'
You are trying to create an editor instance using this API package. `roosterjs-editor-api` defines operations, not editor creation.
fix
In RoosterJs v8, the editor instance was typically created from `roosterjs` (facade) or `roosterjs-editor-core`. For v9+, use `createEditor` from `roosterjs` or `roosterjs-content-model-core`.
Upgrade
Version history
8.62.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
roosterjs-editor-api — npm install roosterjs-editor-api · libregistry