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
}
}
See also
EditorContentEncoder
-
Undocumented
Declaration
Swift
associatedtype EncodedType -
Encodes the given attributed string to
EncodedTypeDeclaration
Swift
func encode(name: EditorContent.Name, string: NSAttributedString) -> EncodedTypeParameters
nameName of the content to encode
stringAttributed string to encode
View on GitHub
EditorTextEncoding Protocol Reference