open-text-editor-latest
v1.0.6
Published
A lightweight, pluggable React contentEditable rich text editor
Maintainers
Readme
Open Text Editor
A lightweight, pluggable React contentEditable rich text editor.
Quick start and full usage are in docs/USAGE.md. Short summary:
Open Text Editor
A lightweight, pluggable React contentEditable rich text editor.
Quick start and full usage are in docs/USAGE.md. Below is a concise summary for using the OpenTextEditor component exported by this package.
Install
npm install open-text-editor-latestPeer dependencies
This package requires React as a peer dependency (supported: ^18 || ^19). Install them if your project doesn't already include React:
npm install react@^18 react-dom@^18
# or for React 19 consumers:
npm install react@^19 react-dom@^19Basic usage
import React, { useRef } from 'react'
import OpenTextEditor from 'open-text-editor-latest'
function App(){
const editorRef = useRef(null)
return (
<OpenTextEditor
ref={editorRef}
initialValue={`<p>Hello from OpenTextEditor</p>`}
onChange={(html) => console.log('content changed', html)}
placeholder="Start typing..."
/>
)
}
export default AppImperative API (via ref)
The editor exposes useful helpers when mounted with ref:
focus()— focus the editorgetHtml()— return current editor HTMLsetHtml(html)— replace editor contentinsertHtml(html)— insert HTML at the current selectionexecCommand(command, value)— run low-leveldocument.execCommandinsertTable(rows, cols)— insert a table programmaticallytableAction(action)— run table actions when a table cell is active
Build and publish
To build the library bundles (ESM/CJS/UMD):
npm run build:libCreate a local package tarball for testing:
npm packPublish to npm (when ready):
npm publish --access publicSee docs/USAGE.md and docs/PUBLISH.md for more details on configuration, plugins and publishing.
Project files of interest:
src/editor/OpentextEditor.jsx— main editor component (default exportOpenTextEditor).src/editor/plugins/— plugin scaffolding and built-in plugin placeholders.build/vite.lib.config.js— library build configuration used bynpm run build:lib.
If you'd like, I can wire the plugin registration API into the editor so built-in plugins are auto-registered.
