Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

nathanfu88/slatediff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slate-diff

Experimental library that compares two Slate Values and returns a list of Slate operations that can be applied with a Change to synchronize the two Values.

Use

This library is not published as an npm module yet. Add with direct url:

yarn add git://github.com/nathanfu88/slatediff.git

Use to compare two Values

const v1 = Value.fromJSON({ document: { nodes: [{ object: 'block', type: 'paragraph', nodes: [{ object: 'text', leaves: [{ text: 'A line of text in a paragraph.'}]}]}]}
const v2 = Value.fromJSON({ document: { nodes: [{ object: 'block', type: 'paragraph', nodes: [{ object: 'text', leaves: [{ text: 'A line of test in a paragraph.'}]}]}]}

const ops = slateDiff(v1, v2)
// [{ type: 'remove_text', path: [0, 0], offset: 12, text: '*', marks: []}, { type: 'insert_text', path: [0, 0], offset: 12, text: 's', marks: []}]

Notes

  • Does not handle marks
  • Has not been extensively tested

About

Diff-ing library for Slate Value objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published