Skip to content

A library for Quill delta format to HTML DOM translation and back.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

mundo-68/quill-core-rs

Repository files navigation

Quill-core-rs

A Rust re-implementation of the well known Quill HTML editor.

The functionality provided by this package is:

  • Translate a Delta document to a HTML DOM
  • Edit the Delta document using operational transform commands
  • Translate the current DOM state back to a Delta document
  • Provide a set of formats that translate Delta operations to HTML DOM

Documentation:

Todo

  • clean up code and simplify
  • automate wasm-pack tests (only run per crate now)
  • see missing formats below

Usage

fn main() {
    DocumentRoot::set_log_level(Level::Debug);
    register_all();
    //Assuming there is a <div id="some_id"></div> 
    let mut doc = DocumentRoot::new("some_id");
    doc.open();
    //fetch some delta document
    doc.apply_dela(delta);
}

fn register_all() -> Result<()> {
    let register = Registry::get_mut_ref()?;
    register.register_block(NAME_OL_BLOCK, Arc::new(ListBlock::new_ol()));
    register.register_block(NAME_UL_BLOCK, Arc::new(ListBlock::new_ul()));
    register.register_block(NAME_HEADER, Arc::new(HeaderBlock::new()));
    register.register_block(NAME_CODE, Arc::new(CodeBlock::new()));
    register.register_block(NAME_P_BLOCK, Arc::new(Pblock::new()));
    register.register_text(NAME_LINK, Arc::new(LinkFormat::new()));
    register.register_text(NAME_IMAGE, Arc::new(ImageFormat::new()));
    register.register_text(NAME_SOFT_BREAK, Arc::new(SoftBreak::new()));
    register.register_text(NAME_TEXT, Arc::new(TextFormat::new()));
    Ok(())
}

Supported formats

Line formatting operations

Line nodes are horizontally aligned elements.

Font related:

  • Background Color
  • Bold
  • Font Color
  • Font
  • Inline Code
  • Italic
  • Link
  • Size
  • Strikethrough
  • Superscript/Subscript
  • Underline

Other:

  • Inline image <img>
    • emoji
  • link <a>

Block formatting operations

Block nodes are used for vertical formatting.

  • paragraphs <P>
  • Headings <Hx>
    • automatic header numbering
  • Lists
    • ordered
    • bullet
    • list headers with automatic numbering
  • Code
  • Tables
    • table headers with automatic numbering
  • Nicely formatted alert / warn / error blocks
  • [ ]Blockquote - blockquote
  • Header - header
  • Indent - indent
  • List - list
  • Text Alignment - align
  • Text Direction - direction
  • Code Block - code-block
  • Image - image
    • automated image footer and numbering

Block Embeds

  • Formula - formula (Retex)
  • Video - video

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

WASM testing

For WASM testing use:

wasm-pack test --headless --chrome --test document
wasm-pack test --headless --firefox

To run the other rust tests use:

cargo test

About

A library for Quill delta format to HTML DOM translation and back.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published