{"library":"roosterjs-editor-api","title":"RoosterJs Editor API (Legacy)","description":"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.","language":"javascript","status":"deprecated","last_verified":"Sun Apr 19","install":{"commands":["npm install roosterjs-editor-api"],"cli":null},"imports":["import { IEditor } from 'roosterjs-editor-api';","import { toggleBold } from 'roosterjs-editor-api';","import { insertNode } from 'roosterjs-editor-api';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { createEditor } from 'roosterjs'; // Assuming createEditor from the v9 facade for simplicity, v8 had similar setup\nimport { toggleBold, insertNode, IEditor } from 'roosterjs-editor-api'; // Legacy v8 API functions and interface\n\nconst editorDiv = document.createElement('div');\neditorDiv.id = 'editor-container-v8';\ndocument.body.appendChild(editorDiv);\n\n// In a real v8 application, an IEditor instance would be created like:\n// import { Editor } from 'roosterjs-editor-core';\n// const editor = new Editor(editorDiv, { initialContent: '<p>Initial content</p>' });\n// For this quickstart, we'll use a mock IEditor to demonstrate API calls.\n\n// A mock IEditor instance conforming to the legacy roosterjs-editor-api.IEditor\nconst mockEditor: IEditor = {\n    getElement: () => editorDiv,\n    focus: () => {\n        console.log('Mock Editor focused');\n        editorDiv.focus();\n    },\n    addContent: (content: string) => {\n        editorDiv.innerHTML += content;\n        console.log(`Mock Editor received content: ${content}`);\n    },\n    // ... many other IEditor methods would be present in a real v8 editor instance\n    // We cast to 'any' to avoid implementing the entire large IEditor interface for this demo\n} as any;\n\nconsole.log('--- RoosterJs Editor API (v8) Quickstart ---');\nconsole.log('Note: This demonstrates legacy v8 API usage. For new projects, use v9+ Content Model APIs.');\n\n// Focus the mock editor\nmockEditor.focus();\n\n// Use API functions from roosterjs-editor-api on the mock editor instance\nmockEditor.addContent('This is some ');\ntoggleBold(mockEditor);\nmockEditor.addContent('bold text');\ntoggleBold(mockEditor); // Toggle bold off\nmockEditor.addContent(' and some ');\n\nconst italicNode = document.createElement('i');\nitalicNode.textContent = 'italic text.';\ninsertNode(mockEditor, italicNode);\n\nconsole.log('Final content in mock editor div:', editorDiv.innerHTML);\n\n// Clean up for demonstration\ndocument.body.removeChild(editorDiv);","lang":"typescript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}