EditorTextEncoding

public protocol EditorTextEncoding

Describes an encoder for a content type in Editor. This can be used in conjunction with AnyEditorTextEncoding to register various encoders for each of the supported content types. ### Usage Example ###

 struct ParagraphEncoder: EditorTextEncoding {
     func encode(name: EditorContent.Name, string: NSAttributedString) -> JSON {
         var paragraph = JSON()
         paragraph.type = name.rawValue
         if let style = string.attribute(.paragraphStyle, at: 0, effectiveRange: nil) as? NSParagraphStyle {
             paragraph[style.key] = style.value
         }
         paragraph.contents = contentsFrom(string)
        return paragraph
     }
 }