Key
public extension NSAttributedString.Key
-
Applying this attribute makes the range of text act as a single block/unit. The content can still be deleted and selected but cursor cannot be moved into textBlock range using taps or mouse/keys (macOS Catalyst). Selection and delete on part of the range works atomically on the entire range.
Note
In successive ranges, if thetextblock
is provided with a value type with same value e.g.true
, the behaviour will be combined for the ranges as one text block i.e. it will work as single textblock even though the attribute was added separately. However, if the value provided is different in successive ranges, these will work independent of each other even if one range immediately follows the other.Declaration
Swift
static let textBlock: NSAttributedString.Key
-
Identifies block based attributes. A block acts as a container for other content types. For e.g. a Paragraph is a block content that contains Text as inline content. A block content may contain multiple inline contents of different types. This is utilized only when using
editor.contents(in:)
orNSAttributedString.enumerateContents(in:)
. Both these utility functions allow breaking content in the editor into sub-parts that can be used to encode content.Declaration
Swift
static let blockContentType: NSAttributedString.Key
-
Identifies inline content attributes. An inline acts as a content in another content types. For e.g. an emoji is an inline content that may be contained in a Paragraph along side another inline content of Text. This is utilized only when using using
NSAttributedString.enumerateInlineContents(in:)
. This utility functions allow breaking content in a block based content string into sub-parts that can then be used to encode content.Declaration
Swift
static let inlineContentType: NSAttributedString.Key
-
Additional style attribute for background color. Using this attribute in addition to
backgroundColor
attribute allows applying shadow and corner radius to the background.Note
This attribute only takes effect with.backgroundColor
. In absence of.backgroundColor
, this attribute has no effect.Declaration
Swift
static let backgroundStyle: NSAttributedString.Key
-
Attribute denoting the range as a list item. This attribute enables use of
ListTextProcessor
to indent/outdent list using tab/shift-tab (macOS) as well as create a new list item on hitting enter key.Declaration
Swift
static let listItem: NSAttributedString.Key
-
When applied to a new line char alongside
listItem
attribute, skips the rendering of list marker on subsequent line.Declaration
Swift
static let skipNextListMarker: NSAttributedString.Key
-
Array of
NSAttributedString.Key
that must be locked in the applied range.Note
This can be used to prevent atttributes from bleeding into the following text as content is typed in the editor. By default, any attribute from preceeding range is automatically carried forward via typing attributes in theEditorView
. One or more attributes may be marked as locked to prevent the bleeding.- Example: To prevent
.backgroundStyle
attribute, following may be used:let backgroundStyle = BackgroundStyle(color: .green)
editor.addAttributes([
.backgroundStyle: backgroundStyle,
.lockedAttributes: [NSAttributedString.Key.backgroundStyle]
], at: editor.selectedRange)
Declaration
Swift
static let lockedAttributes: NSAttributedString.Key
- Example: To prevent
-
Undocumented
Declaration
Swift
static let asyncTextResolver: NSAttributedString.Key