All Projects → sachinrekhi → richtextpy

sachinrekhi / richtextpy

Licence: MIT license
An operational transformation library for rich text documents

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to richtextpy

operational-transform-demo
Implementation/demo of collaborative text editing via operational transforms.
Stars: ✭ 62 (+51.22%)
Mutual labels:  operational-transformation
collaborative-editor
A collaborative editor that supports authorship display, image uploading placeholder and CJK characters composition based on Quill and ShareDB.
Stars: ✭ 78 (+90.24%)
Mutual labels:  operational-transformation
coeditor
Yet Another Pair Programming Package for Atom.
Stars: ✭ 27 (-34.15%)
Mutual labels:  operational-transformation
quill-delta-python
Python port of the Quill-JS Delta library - Has support for HTML Rendering
Stars: ✭ 34 (-17.07%)
Mutual labels:  operational-transformation
bayou
Collaborative document editing, with Quill-based front end
Stars: ✭ 21 (-48.78%)
Mutual labels:  operational-transformation
slate-operational-transform
Slate Operational Transform Demo (used in production at Narration Box)
Stars: ✭ 34 (-17.07%)
Mutual labels:  operational-transformation
Operational-Transformation
A collection of Algorithms to Synchronise changes across multiple clients using Operational Transformation
Stars: ✭ 25 (-39.02%)
Mutual labels:  operational-transformation

richtextpy

An operational transformation library for rich text documents. It enables optimistic conflict-free collaborative editing scenarios (like Google Docs) by providing a rich text document format as well as compose() and transform() methods for managing changes according to the OT algorithm.

This is a Python version of the Javascript Rich Text ottype and can be used in conjunction to support both client-side and server-side operations.

To fully support collaborative editing, you'll also need a rich text editor that produces Delta objects on user changes as well as a server that implements the full OT collaboration protocol. See the references for details on the protocol and some libraries that provide these additional capabilities.

Example

from richtextpy import Delta

delta = Delta([
  {'insert': 'The quick '},
  {'insert': 'brown', 'attributes': {'color': 'brown'}},
  {'insert': ' fox'}
])

# keep the first 10 characters, delete the next 5, and insert a red 'red'
change = Delta().retain(10).delete(5).insert('red', {'color': 'red'})

"""
change is:

[
	{'retain': 10},
	{'delete': 5},
	{'insert': 'red', 'attributes': {'color': 'red'}},
]
"""

composed = delta.compose(change)

"""
composed is:

[
  {'insert': 'The quick '},
  {'insert': 'red', 'attributes': {'color': 'red'}},
  {'insert': ' fox'}
]
"""

Installation

(install from Pypi)

pip install richtextpy

OR

(install from GitHub source download)

python setup.py install

Dependencies

Requires Google's diff-match-patch library for efficient string diffing, which is automatically installed during installation.

Running Tests

(from GitHub source download directory)

python setup.py test

API Reference

Fully implements the original ottypes/rich-text interface. So feel free to use its API reference.

References

License

The MIT License (MIT)

Copyright (c) 2016 Sachin Rekhi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].