A TipTap-based rich text editor built with Lit components, featuring gutter menu, floating menu, and bubble menu
npm install tiptap-lit-editorA TipTap-based rich text editor built with Lit components, featuring:
- Gutter Menu - Appears on hover with drag handle and add block button
- Floating Menu - Block insertion menu (headings, lists, code blocks)
- Bubble Menu - Text formatting menu (bold, italic, links, images)
- Prompt Dialog - Reusable dialog for URL inputs
``bash`
npm install tiptap-lit-editor
Run the demo locally to try out the editor:
`bash`
npm install
npm run dev
Then open http://localhost:5173 in your browser. The demo showcases:
- Markdown editing with live preview
- Gutter menu for drag-and-drop and block insertion
- Bubble menu for text formatting
- Syntax-highlighted code blocks
- Tables and rich content
`javascript
import { BaseEditor } from 'tiptap-lit-editor';
// The BaseEditor component provides a complete editing experience
// with gutter menu, floating menu, and bubble menu built-in
`
`html`
.markdown="${true}"
@content-changed="${handleContentChange}">
You can also use individual menu components with your own TipTap editor setup:
`javascript`
import {
editorContext,
BubbleMenu,
FloatingMenu,
GutterMenu,
showPrompt
} from 'tiptap-lit-editor';
The package re-exports commonly used TipTap modules:
`javascript`
import {
Editor,
StarterKit,
Markdown,
Image,
Link,
BubbleMenuExtension,
DragHandle,
Table,
TableRow,
TableCell,
TableHeader,
CodeBlockLowlight
} from 'tiptap-lit-editor';
The main editor component with all menus integrated.
Properties:
- content (String) - Initial content (HTML or Markdown)markdown
- (Boolean) - Whether to use Markdown modeeditable
- (Boolean) - Whether the editor is editableextensions
- (Array) - Additional TipTap extensions
Events:
- content-changed - Fired when content changes, with detail.contentselection-changed
- - Fired when selection changes
Text selection menu for formatting.
Block insertion menu accessible from the gutter.
Drag handle and add button that appears in the left gutter.
Helper function to show a prompt dialog. Returns a Promise.
`javascript`
const url = await showPrompt('Enter URL:', 'https://');
if (url) {
// User confirmed
}
Components communicate via Lit Context. If building a custom editor:
`javascript
import { editorContext, ContextProvider } from 'tiptap-lit-editor';
import { ContextProvider } from '@lit/context';
// In your component:
this._provider = new ContextProvider(this, {
context: editorContext,
initialValue: { editor: null, editorElement: null }
});
// After editor creation:
this._provider.setValue({ editor: myEditor, editorElement: myElement });
``
Apache-2.0