EditorView
open class EditorView : UIView
extension EditorView: DefaultTextFormattingProviding
A scrollable, multiline text region capable of resizing itself based of the height of the content. Maximum height of EditorView
may be restricted using an absolute value or by using auto-layout constraints. Instantiation of EditorView
is simple and straightforward
and can be used to host simple formatted text or complex layout containing multiple nested EditorView
via use of Attachment
.
-
Undocumented
Declaration
Swift
public var scrollView: UIScrollView { get }
-
Context for the current Editor
Declaration
Swift
public let editorViewContext: EditorViewContext
-
Returns if
attributedText
change is pending.AttributedText
may not have been applied if theEditorView
is not already onwindow
andforceApplyAttributedText
is not set totrue
.Declaration
Swift
public var isAttributedTextPending: Bool { get }
-
Enables asynchronous rendering of attachments.
Note
Since attachments must me rendered on main thread, the rendering only continues when there is no user interaction. By default, rendering starts immediately after the content is set in theEditorView
. However, since attachments must render on main thread only, as soon as there is a user interaction event, like scrolling, is received, the rendering is paused until scrolling stops and then, resumes again.Important
This feature allows for almost instantaneous load of the editor content. However, this is only recommended when there are lots of attachments that may be causing overall load time to be in unacceptable region. Since attachments are rendered one at a time, for simple content, the overall load time mat be more than when synchronous mode, ie default, is used. The perceived performance/TTI will almost always be better with asynchronous rendering.Declaration
Swift
public weak var asyncAttachmentRenderingDelegate: AsyncAttachmentRenderingDelegate?
-
Returns
UITextInput
of current instanceDeclaration
Swift
public var textInput: UITextInput { get }
-
Undocumented
Declaration
Swift
public var textInteractions: [UITextInteraction] { get }
-
Undocumented
Declaration
Swift
public var textViewGestures: [UIGestureRecognizer] { get }
-
Undocumented
Declaration
Swift
public var textDragInteractionEnabled: Bool { get set }
-
Line number provider to be used to show custom line numbers in gutter.
Declaration
Swift
public var lineNumberProvider: LineNumberProvider? { get set }
-
Undocumented
Declaration
Swift
public var isLineNumbersEnabled: Bool { get set }
-
Undocumented
Declaration
Swift
public var lineNumberFormatting: LineNumberFormatting { get set }
-
Undocumented
Declaration
Swift
public override var bounds: CGRect { get set }
-
An object interested in responding to editing and focus related events in the
EditorView
.Declaration
Swift
open weak var delegate: EditorViewDelegate?
-
List formatting provider to be used for rendering lists in the Editor.
Declaration
Swift
public weak var listFormattingProvider: EditorListFormattingProvider?
-
List of commands supported by the editor.
Note
- To support any command, set value to nil. Default behaviour.
- To prevent any command to be executed, set value to be an empty array.
Declaration
Swift
public var registeredCommands: [EditorCommand]?
-
Async Text Resolvers supported by the Editor.
Declaration
Swift
public var asyncTextResolvers: [AsyncTextResolving]
-
Initializes the EditorView
Declaration
Swift
public init(frame: CGRect = .zero, context: EditorViewContext = .shared, allowAutogrowing: Bool = true)
Parameters
frame
Frame to be used for
EditorView
.context
Optional context to be used.
EditorViewContext
is link betweenEditorCommandExecutor
and theEditorView
.EditorCommandExecutor
needs to have same context as theEditorView
to execute a command on it. Unless you need to have restriction around some commands to be restricted in execution on certain specific editors, the default value may be used. -
Input accessory view to be used
Declaration
Swift
open var editorInputAccessoryView: UIView? { get set }
-
Input view to be used
Declaration
Swift
open var editorInputView: UIView? { get set }
-
Undocumented
Declaration
Swift
required public init?(coder aDecoder: NSCoder)
-
List of all the registered
TextProcessors
in theEditorView
. This may be used by nestedEditorView
to inherit all the text processors from the containerEditorView
.Usage example
func execute(on editor: EditorView) { let attachment = PanelAttachment(frame: .zero) let panel = attachment.view panel.editor.registerProcessors(editor.registeredProcessors) editor.insertAttachment(in: editor.selectedRange, attachment: attachment) }
Declaration
Swift
public var registeredProcessors: [TextProcessing] { get }
-
Undocumented
Declaration
Swift
public var selectedTextRange: UITextRange? { get set }
-
Undocumented
Declaration
Swift
public var scrollViewDelegate: UIScrollViewDelegate? { get set }
-
Undocumented
Declaration
Swift
public var panGestureRecognizer: UIGestureRecognizer { get }
-
Undocumented
Declaration
Swift
public var pinchGestureRecognizer: UIPinchGestureRecognizer? { get }
-
Undocumented
Declaration
Swift
public var directionalPressGestureRecognizer: UIGestureRecognizer? { get }
-
Placeholder text for the
EditorView
. The value can contain any attributes which is natively supported in theNSAttributedString
.Declaration
Swift
public var placeholderText: NSAttributedString? { get set }
-
Gets or sets insets for additional scroll area around the content. Default value is UIEdgeInsetsZero.
Declaration
Swift
public var contentInset: UIEdgeInsets { get set }
-
Undocumented
Declaration
Swift
public var verticalScrollIndicatorInsets: UIEdgeInsets { get set }
-
Undocumented
Declaration
Swift
public var keyboardDismissMode: UIScrollView.KeyboardDismissMode { get set }
-
Undocumented
Declaration
Swift
public var isScrollEnabled: Bool { get set }
-
Gets or sets the insets for the text container’s layout area within the editor’s content area
Declaration
Swift
public var textContainerInset: UIEdgeInsets { get set }
-
The types of data converted to tappable URLs in the editor view.
Declaration
Swift
public var dataDetectorTypes: UIDataDetectorTypes { get set }
-
Length of content within the Editor.
Note
An attachment is only counted as a single character. Content length does not include length of content within the Attachment that is hosting anotherEditorView
.Declaration
Swift
public var contentLength: Int { get }
-
Determines if the
EditorView
is editable or not.Note
SettingisEditable
tofalse
before setting theattributedText
will makeEditorView
skip certain layout paths and calculations for attachments containingUIView
s, This is done primarily to improve the rendering performance of theEditorView
in case of text with large number of attachments.Declaration
Swift
public var isEditable: Bool { get set }
-
Determines if the editor is empty.
Declaration
Swift
public var isEmpty: Bool { get }
-
Current line information based the caret position or selected range. If the selected range spans across multiple lines, only the line information of the line containing the start of the range is returned.
Note
This is based on the layout of text in theEditorView
and not on the actual lines based on\n
. The range may contain multiple lines or part of different lines separated by\n
. To get lines based on new line characters, please usecontentLinesInRange(range)
,previousContentLine(location)
andnextContentLine(location)
.Declaration
Swift
public var currentLayoutLine: EditorLine? { get }
-
First line of content based on layout in the Editor. Nil if editor is empty.
Note
This is based on the layout of text in theEditorView
and not on the actual lines based on\n
. The range may contain multiple lines or part of different lines separated by\n
. To get lines based on new line characters, please usecontentLinesInRange(range)
,previousContentLine(location)
andnextContentLine(location)
.Declaration
Swift
public var firstLayoutLine: EditorLine? { get }
-
Last line of content based on layout in the Editor. Nil if editor is empty.
Note
This is based on the layout of text in theEditorView
and not on the actual lines based on\n
. The range may contain multiple lines or part of different lines separated by\n
. To get lines based on new line characters, please usecontentLinesInRange(range)
,previousContentLine(location)
andnextContentLine(location)
.Declaration
Swift
public var lastLayoutLine: EditorLine? { get }
-
Selected text in the editor.
Declaration
Swift
public var selectedText: NSAttributedString { get }
-
Background color for the editor.
Declaration
Swift
public override var backgroundColor: UIColor? { get set }
-
Default font to be used by the Editor. A font may be overridden on whole or part of content in
EditorView
by anEditorCommand
orTextProcessing
conformances.Declaration
Swift
public var font: UIFont { get set }
-
Default paragraph style to be used by the Editor. The style may be overridden on whole or part of content in
EditorView
by anEditorCommand
orTextProcessing
conformances.Declaration
Swift
public var paragraphStyle: NSMutableParagraphStyle { get set }
-
Default text color to be used by the Editor. The color may be overridden on whole or part of content in
EditorView
by anEditorCommand
orTextProcessing
conformances.Declaration
Swift
public var textColor: UIColor { get set }
-
Maximum height that the
EditorView
can expand to. After reaching the maximum specified height, the editor becomes scrollable.Note
If both auto-layout constraints andmaxHeight
are used, the lower of the two height would be used as maximum allowed height.Declaration
Swift
public var maxHeight: EditorHeight { get set }
-
Forces setting attributed text in
EditorView
even if it is not yet in view hierarchy.Note
This may result in misplacedAttachment
s and is recommended to be set totrue
only in unit tests.Declaration
Swift
public var forceApplyAttributedText: Bool
-
Text to be set in the
EditorView
Important
attributedText
is not set for rendering inEditorView
if theEditorView
is not already in aWindow
. Value oftrue
forisAttributedTextPending
confirms that the text has not yet been rendered even though it is set in theEditorView
. Notification of text being set can be observed by subscribing todidSetAttributedText
inEditorViewDelegate
. Alternatively,forceApplyAttributedText
may be set totrue
to always applyattributedText
irrespective ofEditorView
being in aWindow
or not.Declaration
Swift
public var attributedText: NSAttributedString { get set }
-
Undocumented
Declaration
Swift
public var nestedEditors: [EditorView] { get }
-
Undocumented
Declaration
Swift
public var text: String { get }
-
Undocumented
Declaration
Swift
public var selectedRange: NSRange { get set }
-
Undocumented
Declaration
Swift
public var lineFragmentPadding: CGFloat { get }
-
Typing attributes to be used. Automatically resets when the selection changes. To apply an attribute in the current position such that it is applied as text is typed, the attribute must be added to
typingAttributes
collection.Declaration
Swift
public var typingAttributes: [NSAttributedString.Key : Any] { get set }
-
An object interested in observing the changes in bounds of the
Editor
, typically anAttachment
.Declaration
Swift
public var boundsObserver: BoundsObserving? { get set }
-
Gets and sets the content offset.
Declaration
Swift
public var contentOffset: CGPoint { get set }
-
The size of the content view.
Declaration
Swift
public var contentSize: CGSize { get }
-
The attributes to apply to links.
Declaration
Swift
public var linkTextAttributes: [NSAttributedString.Key : Any]! { get set }
-
Range of end of text in the
EditorView
. The range has always has length of 0.Declaration
Swift
public var textEndRange: NSRange { get }
-
Determines if the current Editor is contained in an attachment
Declaration
Swift
public var isContainedInAnAttachment: Bool { get }
-
Name of the content if the Editor is contained within an
Attachment
. This is done by recursive look-up of views in theAttachment
content view i.e. the Editor may be nested in subviews within the contentView of Attachment. The value is nil if the Editor is not contained within anAttachment
.Declaration
Swift
public var contentName: EditorContent.Name? { get }
-
Returns the visible bounds of the
EditorView
within a scrollable container.Note
IfEditorView
has defined aViewportProvider
, theviewport
is calculated per the provider. AViewportProvider
may be needed in cases whereEditorView
is hosted inside anotherUIScrollView
and the viewport needs to be calculated based on the viewport of containerUIScrollView
.Declaration
Swift
open var viewport: CGRect { get }
-
Returns the visible text range. In case of non-scrollable
EditorView
, entire range isvisibleRange
. The range may benil
if it is queried before layout has begunNote
IfEditorView
has defined aViewportProvider
, thevisibleRange
is calculated per theviewport
from provider. AViewportProvider
may be needed in cases whereEditorView
is hosted inside anotherUIScrollView
and the viewport needs to be calculated based on the viewport of containerUIScrollView
.Declaration
Swift
public var visibleRange: NSRange? { get }
-
Attachment containing the current Editor.
Declaration
Swift
public var containerAttachment: Attachment? { get }
-
Nesting level of current Editor within other attachments containing Editors. 0 indicates that the Editor is not contained in an attachment.
Declaration
Swift
public var nestingLevel: Int { get }
-
Returns if the
EditorView
is a root editor i.e. not contained in anyAttachment
Declaration
Swift
public var isRootEditor: Bool { get }
-
Returns the root editor of the current Editor. Returns
self
where the current editor is not contained within anAttachment
.Note
Note:This is different fromparentEditor
which is immediate parent of the current editorDeclaration
Swift
public var rootEditor: EditorView { get }
-
EditorView
containing the currentEditorView
in anAttachment
Declaration
Swift
public var parentEditor: EditorView? { get }
-
Clears the contents in the Editor.
Declaration
Swift
public func clear()
-
The auto-capitalization style for the text object. default is
UITextAutocapitalizationTypeSentences
Declaration
Swift
public var autocapitalizationType: UITextAutocapitalizationType { get set }
-
The autocorrection style for the text object. default is
UITextAutocorrectionTypeDefault
Declaration
Swift
public var autocorrectionType: UITextAutocorrectionType { get set }
-
The spell-checking style for the text object.
Declaration
Swift
public var spellCheckingType: UITextSpellCheckingType { get set }
-
The configuration state for smart quotes.
Declaration
Swift
public var smartQuotesType: UITextSmartQuotesType { get set }
-
The configuration state for smart dashes.
Declaration
Swift
public var smartDashesType: UITextSmartDashesType { get set }
-
The configuration state for the smart insertion and deletion of space characters.
Declaration
Swift
public var smartInsertDeleteType: UITextSmartInsertDeleteType { get set }
-
The keyboard style associated with the text object.
Declaration
Swift
public var keyboardType: UIKeyboardType { get set }
-
The appearance style of the keyboard that is associated with the text object
Declaration
Swift
public var keyboardAppearance: UIKeyboardAppearance { get set }
-
The visible title of the Return key.
Declaration
Swift
public var returnKeyType: UIReturnKeyType { get set }
-
A Boolean value indicating whether the Return key is automatically enabled when the user is entering text. default is
NO
(whenYES
, will automatically disable return key when text widget has zero-length contents, and will automatically enable when text widget has non-zero-length contents)Declaration
Swift
public var enablesReturnKeyAutomatically: Bool { get set }
-
Identifies whether the text object should disable text copying and in some cases hide the text being entered. default is
NO
Declaration
Swift
public var isSecureTextEntry: Bool { get set }
-
The semantic meaning expected by a text input area. The textContentType property is to provide the keyboard with extra information about the semantic intent of the text document. default is
nil
Declaration
Swift
public var textContentType: UITextContentType! { get set }
-
A Boolean value indicating whether the text view allows the user to edit style information.
Declaration
Swift
public var allowsEditingTextAttributes: Bool { get set }
-
A Boolean value indicating whether the receiver is selectable. This property controls the ability of the user to select content and interact with URLs and text attachments. The default value is true.
Declaration
Swift
public var isSelectable: Bool { get set }
-
A text drag delegate object for customizing the drag source behavior of a text view.
Declaration
Swift
public var textDragDelegate: UITextDragDelegate? { get set }
-
The text drop delegate for interacting with a drop activity in the text view.
Declaration
Swift
public var textDropDelegate: UITextDropDelegate? { get set }
-
Subclasses can override it to perform additional actions whenever the window changes.
Important
Overriding implementations must callsuper.didMoveToWindow()
Declaration
Swift
open override func didMoveToWindow()
-
Asks the view to calculate and return the size that best fits the specified size.
Declaration
Swift
override open func sizeThatFits(_ size: CGSize) -> CGSize
Parameters
size
The size for which the view should calculate its best-fitting size.
Return Value
A new size that fits the receiver’s subviews.
-
Asks UIKit to make this object the first responder in its window.
Declaration
Swift
@discardableResult public override func becomeFirstResponder() -> Bool
Return Value
true
if this object is now the first-responder orfalse
if it is not. -
Denotes of the Editor is first responder
Declaration
Swift
public func isFirstResponder() -> Bool
Return Value
true, if is first responder
-
Resets typing attributes back to default text color, font and paragraph style. All other attributes are dropped.
Declaration
Swift
open func resetTypingAttributes()
-
Undocumented
Declaration
Swift
public func attachmentsInRange(_ range: NSRange) -> [AttachmentRange]
-
Converts given range to
UITextRange
, if validDeclaration
Swift
public func textRange(from range: NSRange) -> UITextRange?
Parameters
range
Range to convert
Return Value
UITextRange
representation of provided NSRange, if valid. -
Cancels any pending rendering when async rendering of attachment is schedules.
Note
Asynchronous rendering is opt-in feature scheduled by providingasyncAttachmentRenderingDelegate
toEditorView
Declaration
Swift
public func cancelPendingAsyncRendering()
-
The range of currently marked text in a document. If there is no marked text, the value of the property is
nil
. Marked text is provisionally inserted text that requires user confirmation; it occurs in multistage text input. The current selection, which can be a caret or an extended range, always occurs within the marked text.Declaration
Swift
public var markedRange: NSRange? { get }
-
Undocumented
Declaration
Swift
public func setAttributes(_ attributes: [NSAttributedString.Key : Any], at range: NSRange)
-
Returns the full attributed text contained in the
EditorView
along with the ones in editors nested in contained Attachments.Note
An additional attribute with value ofAttachment.name
is automatically added with keyNSAttributedString.Key.viewOnly
. This can be changed by overriding default implementation ofgetFullTextRangeIdentificationAttributes()
inAttachment
.Declaration
Swift
public func getFullAttributedText(using attachmentContentIdentifier: AttachmentContentIdentifier, in range: NSRange? = nil) -> NSAttributedString
Parameters
attachmentContentIdentifier
Identifier for opening and closing ranges for Attachment Content
Return Value
Full attributed text
-
Sets async text resolution to resolve on next text layout pass.
Note
Changing attributes also causes layout pass to be performed, and this any applicableAsyncTextResolvers
will be executed.Declaration
Swift
public func setNeedsAsyncTextResolution()
-
Invokes async text resolution to resolve on demand.
Declaration
Swift
public func resolveAsyncTextIfNeeded()
-
Returns the range of character at the given point
Declaration
Swift
public func rangeOfCharacter(at point: CGPoint) -> NSRange?
Parameters
point
Point to get range from
Return Value
Character range if available, else nil
-
Gets the lines separated by newline characters from the given range.
Note
Lines returned from this function do not contain terminating newline character in the text content.Declaration
Swift
public func contentLinesInRange(_ range: NSRange) -> [EditorLine]
Parameters
range
Range to get lines from.
Return Value
Array of
EditorLine
from the given content range. -
Gets the previous line of content from the given location. A content line is defined by the presence of a newline character.
Declaration
Swift
public func previousContentLine(from location: Int) -> EditorLine?
Parameters
location
Location to find line from, in reverse direction
Return Value
Content line if a newline character exists before the current location, else nil
-
Gets the next line of content from the given location. A content line is defined by the presence of a newline character.
Declaration
Swift
public func nextContentLine(from location: Int) -> EditorLine?
Parameters
location
Location to find line from, in forward direction
Return Value
Content line if a newline character exists after the current location, else nil
-
Gets the line preceding the given line. Nil if the given line is invalid or is first line
Declaration
Swift
public func layoutLineAfter(_ line: EditorLine) -> EditorLine?
Parameters
line
Reference line
Return Value
EditorLine
after the given line. Nil if the Editor is empty or given line is last line in the Editor. -
Gets the line before the given line. Nil if the given line is invalid or is first line
Declaration
Swift
public func layoutLineBefore(_ line: EditorLine) -> EditorLine?
Parameters
line
Reference line
Return Value
EditorLine
before the given line. Nil if the Editor is empty or given line is first line in the Editor. -
Returns the rectangles for line fragments spanned by the range. Based on the span of the range, multiple rectangles may be returned.
Declaration
Swift
public func rects(for range: NSRange) -> [CGRect]
Parameters
range
Range to be queried.
Return Value
Array of rectangles for the given range.
-
Returns the range of text in the given rect.
Note
This function returns a contiguous glyph range containing all glyphs that would need to be displayed in order to draw all glyphs that fall (even partially) within the bounding rect given. This range might include glyphs which do not fall into the rect at all. At most this will return the glyph range for the whole container. WhenperformingLayout
is set to true, it will not generate glyphs or perform layout in attempting to answer, and thus may not be entirely correct. Bounding rects are always in container coordinates.Declaration
Swift
public func rangeForRect(_ rect: CGRect, performingLayout: Bool = false) -> NSRange?
Parameters
rect
Rect to get range from
performingLayout
If
true
, layout is performed before returning the range. Defaults tofalse
Return Value
Range for the given rect.
nil
if range is queried before layout has begun. -
Returns the caret rectangle for given position in the editor content.
Note
If the location is beyond the bounds of content length, the last valid position is used to get caret rectangle. This function only returns the rectangle denoting the caret positioning. The actual caret is not moved and no new carets are drawn.Declaration
Swift
public func caretRect(for position: Int) -> CGRect
Parameters
position
Location to be queried within the editor content.
Return Value
Rectangle for caret based on the line height and given location.
-
Gets the word from text at given location in editor content
Declaration
Swift
public func word(at location: Int) -> NSAttributedString?
Parameters
location
Location to be queried.
Return Value
Word at the given location. Nil is there’s no content.
-
Gets the full range of attribute at given location.
Declaration
Swift
public func attributeRangeFor(_ attribute: NSAttributedString.Key, at location: Int) -> NSRange?
Parameters
attribute
Attribute to search for
location
Location for the attribute. Location may lie anywhere in the range of attribute.
Return Value
Full range encompassing the given location.
nil
if attribute does not exist. -
Deletes text backwards
Declaration
Swift
public func deleteBackward()
-
Inserts an
Attachment
in theEditorView
.Declaration
Swift
public func insertAttachment(in range: NSRange, attachment: Attachment)
Parameters
range
Range where the
Attachment
should be inserted. If the range contains existing content, the content will be replaced by theAttachment
.attachment
Attachment to be inserted.
-
Sets the focus in the
EditorView
Declaration
Swift
public func setFocus(at range: NSRange? = nil)
-
Makes the
EditorView
lose focus.Declaration
Swift
public func resignFocus()
-
Makes the
EditorView
scroll to given range such that it is visible. No-op if the range is already visible.Declaration
Swift
public func scrollRangeToVisible(_ range: NSRange)
Parameters
range
Range of content to scroll to.
-
Makes the
EditorView
scroll to given range such that it is visible. No-op if the range is already visible.Declaration
Swift
public func scrollRectToVisible(_ rect: CGRect, animated: Bool)
Parameters
range
Range of content to scroll to.
-
Invalidates the display of content at the given range.
Declaration
Swift
public func invalidateDisplay(for range: NSRange)
Parameters
range
Range to invalidate.
-
Invalidates the layout of content at the given range. This will also fore layout of any
Attachment
contained in the given range.Declaration
Swift
public func invalidateLayout(for range: NSRange)
Parameters
range
Range to invalidate.
-
Gets the contents within the
Editor
.Declaration
Swift
public func contents(in range: NSRange? = nil) -> [EditorContent]
Parameters
range
Range to be enumerated to get the contents. If no range is specified, entire content range is enumerated.
-
Transforms
EditorContent
into given type. This function can also be used to encode content into a different type for e.g. encoding the contents to JSON. Encoding is a type of transformation that can also be decoded.Declaration
Swift
public func transformContents<T>(in range: NSRange? = nil, using transformer: T) -> [T.EncodedType] where T : EditorContentEncoding
Parameters
range
Range of
Editor
to transform the contents. By default, entire range is used.transformer
Transformer capable of transforming
EditorContent
to given typeReturn Value
Array of transformed contents based on given transformer.
-
Replaces the given range of content with the attributedString provided.
Declaration
Swift
public func replaceCharacters(in range: NSRange, with attributedString: NSAttributedString)
Parameters
range
Range to replace.
attributedString
Text to replace the range of content with.
-
Replaces the characters in the given range with the string provided.
Attention
The string provided will use the defaultfont
andparagraphStyle
set in theEditorView
. It will not retain any other attributes already applied on the range of text being replaced by thestring
. If you would like add any other attributes, it is best to usereplaceCharacters
with the parameter value of typeNSAttributedString
that may have additional attributes defined, as well as customisedfont
andparagraphStyle
applied.Declaration
Swift
public func replaceCharacters(in range: NSRange, with string: String)
Parameters
range
Range of text to replace. For an empty
EditorView
, you may passNSRange.zero
to insert text at the beginning.string
String to replace the range of text with. The string will use default
font
andparagraphStyle
defined in theEditorView
. -
Appends the given attributed text to the end of content in
EditorView
.Declaration
Swift
public func appendCharacters(_ attributedString: NSAttributedString)
Parameters
attributedString
Text to append.
-
Appends the given attributed text to the end of content in
EditorView
.Declaration
Swift
public func appendCharacters(_ string: String)
Parameters
string
Text to append.
-
Registers the given text processor with the editor.
Declaration
Swift
public func registerProcessor(_ processor: TextProcessing)
Parameters
processor
Text processor to register
-
Unregisters the given text processor from the editor.
Declaration
Swift
public func unregisterProcessor(_ processor: TextProcessing)
Parameters
processor
Text processor to unregister
-
Registers the given text processors with the editor.
Declaration
Swift
public func registerProcessors(_ processors: [TextProcessing])
Parameters
processors
Text processors to register
-
Unregisters the given text processors from the editor.
Declaration
Swift
public func unregisterProcessors(_ processors: [TextProcessing])
Parameters
processors
Text processors to unregister
-
Registers the given commands with the Editor. Only registered commands can be executed if any is added to the Editor.
Declaration
Swift
public func registerCommands(_ commands: [EditorCommand])
Parameters
commands
Commands to register
-
Unregisters the given commands from the Editor. When all commands are unregistered, any command can be executed on the editor.
Declaration
Swift
public func unregisterCommands(_ commands: [EditorCommand])
Parameters
commands
Commands to unregister
-
Registers the given command with the Editor. Only registered commands can be executed if any is added to the Editor.
Declaration
Swift
public func registerCommand(_ command: EditorCommand)
Parameters
commands
Command to register
-
Unregisters the given command from the Editor. When all commands are unregistered, any command can be executed on the editor.
Declaration
Swift
public func unregisterCommand(_ command: EditorCommand)
Parameters
commands
Command to unregister
-
Relayout
EditorView
on demand. This may be required if the size appears incorrect, for e..g. when hosted in an ScrollViewDeclaration
Swift
public func relayout(size: CGSize? = nil)
Parameters
size
Size to use for relayout. When nil, default bounds are used.
-
Undocumented
Declaration
Swift
open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool
-
Determines if the given menu action can be invoked.
Declaration
Swift
open func canPerformMenuAction(_ action: Selector, withSender sender: Any?) -> Bool
Parameters
action
Action to be invoked
sender
Sender of the action
Return Value
true
to invoke default behaviour.false
to conditionally disable/hide menu item. Display of menu item still depends on the context. E.g. Select is not shown in case the editor is empty. -
This method attempt to simulate the
paste
method but with explicitly provided attributed string and insertion range.Declaration
Swift
open func paste(attributedString: NSAttributedString, into range: NSRange) -> Bool
Parameters
attributedString
Attributed string to be inserted
range
Insertion range
Return Value
true
The paste operation was successfulfalse
The paste operation was discarded -
Adds given attributes to the range provided. If the range already contains a value for an attribute being provided, existing value will be overwritten by the new value provided in the attributes.
Declaration
Swift
public func addAttributes(_ attributes: [NSAttributedString.Key : Any], at range: NSRange)
Parameters
attributes
Attributes to be added.
range
Range on which attributes should be applied to.
-
Removes the given attributes from the range provided. If the attribute does not exist in the range, it will be a no-op.
Declaration
Swift
public func removeAttributes(_ attributes: [NSAttributedString.Key], at range: NSRange)
Parameters
attributes
Attributes to remove.
range
Range to remove the attributes from.
-
Adds given attribute to the range provided. If the attribute already exists in the range, it will be overwritten with the new value provided here.
Declaration
Swift
public func addAttribute(_ name: NSAttributedString.Key, value: Any, at range: NSRange)
Parameters
name
Key of the attribute to add.
value
Value of the attribute.
range
Range to which attribute should be added.
-
Removes the attribute from given range. If the attribute does not exist in the range, it is a no-op.
Declaration
Swift
public func removeAttribute(_ name: NSAttributedString.Key, at range: NSRange)
Parameters
name
Key of attribute to be removed.
range
Range from which attribute should be removed.
-
Undocumented
Declaration
Swift
func resolveAsyncText()
-
Determines if the given command can be executed on the current editor. The command is allowed to be executed if
requiresSupportedCommandsRegistration
is false or if the command has been registered with the editor.Declaration
Swift
func isCommandRegistered(_ name: CommandName) -> Bool
Parameters
command
Command to validate
Return Value
true
if the command is registered with the Editor. -
Undocumented
Declaration
Swift
open override var forFirstBaselineLayout: UIView { get }
-
Undocumented
Declaration
Swift
open override var forLastBaselineLayout: UIView { get }