Crates.io | quill-delta-rs |
lib.rs | quill-delta-rs |
version | 1.1.1 |
source | src |
created_at | 2024-04-04 19:56:04.510446 |
updated_at | 2024-04-17 11:09:26.402135 |
description | Implementation of Quill editor Delta format in Rust |
homepage | https://github.com/amantoux/quill-delta-rs |
repository | https://github.com/amantoux/quill-delta-rs |
max_upload_size | |
id | 1196682 |
size | 90,635 |
Implementation of Quill editor Delta format in Rust. Refer to official documentation for more details.
use quill_delta_rs::{
attributes::{attributes, AttributesMap},
delta::Delta
};
fn main() {
let mut doc = Delta::new();
doc.insert("Hello world\n", Some(attributes!("h" => "1")));
let mut change = Delta::new();
change
.retain(6, None)
.delete(6)
.insert("Earth\n", None);
let result = doc.compose(&change);
println!("Original document:\n{}\n", doc);
println!("Change:\n{}\n", change);
println!("Updated document:\n{}\n", result);
// Prints:
//
// Original document:
// ins(Hello world⏎) + {h: 1}}
//
//
// Change:
// ret(6)
// ins(Earth⏎)
// del(6)
//
//
// Updated document:
// ins(Hello ) + {h: 1}}
// ins(Earth⏎)
}
Please file feature requests and bugs at the issue tracker.