AsyncTextResolving
public protocol AsyncTextResolving
An object capable of resolving text asynchronously to another representation. New representation may contain change in attributes or the string itself.
-
Name of the Resolver. This name must be applied to the range of text that requires async resolution with attribute key:
.asyncTextResolver
Declaration
Swift
var name: String { get }
-
Resolves the string to a different representation
Important
As part of resolution,.asyncTextResolver
is removed from original range. If the content in original range has changed in the time it took for resolution, it is responsibility of consumer to cleanup dangling attribute, if any.Declaration
Swift
func resolve(using editor: EditorView, range: NSRange, string: NSAttributedString, completion: @escaping (AsyncTextResolvingResult) -> Void)
Parameters
editor
Editor containing the attributed string
range
Range of attributesString containing
.asyncTextResolver
attributestring
Substring of attributesString containing
.asyncTextResolver
attributecompletion
Transformed result to be applied.
.apply
will replace therange
inEditor
with providedattributedString
. ..discard
discards the operation.