quill-delta
raw JSON → 1.0.3 verified Fri May 01 auth: no python
Python port of the quill.js delta library for representing rich text documents and supporting operational transformation (OT). Version 1.0.3, stable release with no major recent updates.
pip install quill-delta Common errors
error ImportError: No module named quill.delta ↓
cause Incorrect import path using dot instead of underscore.
fix
Use: from quill_delta import Delta
error AttributeError: 'list' object has no attribute 'ops' ↓
cause Creating Delta with a plain list of ops without using the Delta constructor correctly.
fix
Use Delta(ops=[...]) or build via methods: Delta().insert('a').delete(1)
Warnings
gotcha Delta ops are mutable lists; modifying in-place can break OT assumptions. ↓
fix Always use Delta methods (insert, delete, retain) to build operations.
deprecated The 'compose' method is deprecated in favor of __add__ for composing deltas. ↓
fix Use delta1 + delta2 instead of delta1.compose(delta2).
Imports
- Delta wrong
from quill.delta import Deltacorrectfrom quill_delta import Delta
Quickstart
from quill_delta import Delta
delta = Delta()
delta.retain(5)
delta.insert('Hello')
delta.delete(2)
print(delta.ops)
# Output: [{'retain': 5}, {'insert': 'Hello'}, {'delete': 2}]