Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 1.31 KB

README.md

File metadata and controls

29 lines (23 loc) · 1.31 KB

Maxle5.ProseMirror

Nuget Build

Maxle5.ProseMirror is a library used for converting ProseMirror content to/from JSON and HTML

Examples

1. Convert HTML to ProseMirror object:

  const string html = "<h1>Heading</h1><p>Some more <b>TEXT</b></p>";
  var obj = ProseMirrorConvert.DeserializeObjectFromHtml(html);

2. Convert JSON to ProseMirror object:

  const string json = "{\"type\":\"doc\",\"content\":[{\"type\":\"heading\",\"attrs\":{\"level\":1,\"textAlign\":\"left\"},\"content\":[{\"text\":\"Heading\",\"type\":\"text\"}]},{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":\"left\"},\"content\":[{\"text\":\"Some more \",\"type\":\"text\"},{\"text\":\"TEXT\",\"type\":\"text\",\"marks\":[{\"type\":\"bold\"}]}]}]}";
  var obj = ProseMirrorConvert.DeserializeObjectFromHtml(html);

3. Convert ProseMirror object to JSON:

  var json = ProseMirrorConvert.SerializeToJson(obj);

4. Convert ProseMirror object to HTML:

var html = ProseMirrorConvert.SerializeToHtml(obj);