@yorkie-js/prosemirror
v0.7.3-alpha
Published
ProseMirror binding for Yorkie collaborative editing
Readme
Yorkie ProseMirror
Yorkie ProseMirror is a library that provides ProseMirror bindings for building collaborative rich-text editors with Yorkie.
Features
- Two-way sync between ProseMirror and Yorkie Tree CRDT
- Mark support (bold, italic, code, link) via Yorkie wrapper elements
- Bidirectional position mapping between ProseMirror positions and Yorkie indices
- Cursor and presence sharing across clients
- Block-level and character-level diffing for efficient upstream sync
Installation
npm install @yorkie-js/prosemirrorPeer Dependencies
This package requires the following peer dependencies:
npm install prosemirror-model prosemirror-state prosemirror-viewUsage
Quick Start with YorkieProseMirrorBinding
import { YorkieProseMirrorBinding } from '@yorkie-js/prosemirror';
const binding = new YorkieProseMirrorBinding(view, doc, 'tree', {
markMapping: { strong: 'strong', em: 'em', code: 'code', link: 'link' },
cursors: {
enabled: true,
overlayElement: document.getElementById('cursor-overlay'),
},
});
binding.initialize();
// When done:
binding.destroy();Lower-Level Utilities
You can also use the individual sync functions directly:
import {
syncToYorkie,
syncToPMIncremental,
syncToPM,
diffDocs,
buildPositionMap,
pmPosToYorkieIdx,
yorkieIdxToPmPos,
pmToYorkie,
yorkieToJSON,
defaultMarkMapping,
invertMapping,
} from '@yorkie-js/prosemirror';Contributing
See CONTRIBUTING for details on submitting patches and the contribution workflow.
Contributors ✨
Thanks goes to these incredible people:
