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
attributedTextchange is pending.AttributedTextmay not have been applied if theEditorViewis not already onwindowandforceApplyAttributedTextis 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
UITextInputof 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
frameFrame to be used for
EditorView.contextOptional context to be used.
EditorViewContextis link betweenEditorCommandExecutorand theEditorView.EditorCommandExecutorneeds to have same context as theEditorViewto 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
TextProcessorsin theEditorView. This may be used by nestedEditorViewto 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
EditorViewis editable or not.Note
SettingisEditabletofalsebefore setting theattributedTextwill makeEditorViewskip certain layout paths and calculations for attachments containingUIViews, This is done primarily to improve the rendering performance of theEditorViewin 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 theEditorViewand 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 theEditorViewand 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 theEditorViewand 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
EditorViewby anEditorCommandorTextProcessingconformances.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
EditorViewby anEditorCommandorTextProcessingconformances.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
EditorViewby anEditorCommandorTextProcessingconformances.Declaration
Swift
public var textColor: UIColor { get set } -
Maximum height that the
EditorViewcan expand to. After reaching the maximum specified height, the editor becomes scrollable.Note
If both auto-layout constraints andmaxHeightare 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
EditorVieweven if it is not yet in view hierarchy.Note
This may result in misplacedAttachments and is recommended to be set totrueonly in unit tests.Declaration
Swift
public var forceApplyAttributedText: Bool -
Text to be set in the
EditorViewImportant
attributedTextis not set for rendering inEditorViewif theEditorViewis not already in aWindow. Value oftrueforisAttributedTextPendingconfirms 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 todidSetAttributedTextinEditorViewDelegate. Alternatively,forceApplyAttributedTextmay be set totrueto always applyattributedTextirrespective ofEditorViewbeing in aWindowor 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
typingAttributescollection.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 theAttachmentcontent 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
EditorViewwithin a scrollable container.Note
IfEditorViewhas defined aViewportProvider, theviewportis calculated per the provider. AViewportProvidermay be needed in cases whereEditorViewis hosted inside anotherUIScrollViewand 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 benilif it is queried before layout has begunNote
IfEditorViewhas defined aViewportProvider, thevisibleRangeis calculated per theviewportfrom provider. AViewportProvidermay be needed in cases whereEditorViewis hosted inside anotherUIScrollViewand 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
EditorViewis a root editor i.e. not contained in anyAttachmentDeclaration
Swift
public var isRootEditor: Bool { get } -
Returns the root editor of the current Editor. Returns
selfwhere the current editor is not contained within anAttachment.Note
Note:This is different fromparentEditorwhich is immediate parent of the current editorDeclaration
Swift
public var rootEditor: EditorView { get } -
EditorViewcontaining the currentEditorViewin anAttachmentDeclaration
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
UITextAutocapitalizationTypeSentencesDeclaration
Swift
public var autocapitalizationType: UITextAutocapitalizationType { get set } -
The autocorrection style for the text object. default is
UITextAutocorrectionTypeDefaultDeclaration
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
NODeclaration
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
nilDeclaration
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) -> CGSizeParameters
sizeThe 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() -> BoolReturn Value
trueif this object is now the first-responder orfalseif it is not. -
Denotes of the Editor is first responder
Declaration
Swift
public func isFirstResponder() -> BoolReturn 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
rangeRange to convert
Return Value
UITextRangerepresentation 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 providingasyncAttachmentRenderingDelegatetoEditorViewDeclaration
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
EditorViewalong with the ones in editors nested in contained Attachments.Note
An additional attribute with value ofAttachment.nameis 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) -> NSAttributedStringParameters
attachmentContentIdentifierIdentifier 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 applicableAsyncTextResolverswill 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
pointPoint 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
rangeRange to get lines from.
Return Value
Array of
EditorLinefrom 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
locationLocation 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
locationLocation 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
lineReference line
Return Value
EditorLineafter 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
lineReference line
Return Value
EditorLinebefore 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
rangeRange 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. WhenperformingLayoutis 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
rectRect to get range from
performingLayoutIf
true, layout is performed before returning the range. Defaults tofalseReturn Value
Range for the given rect.
nilif 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) -> CGRectParameters
positionLocation 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
locationLocation 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
attributeAttribute to search for
locationLocation for the attribute. Location may lie anywhere in the range of attribute.
Return Value
Full range encompassing the given location.
nilif attribute does not exist. -
Deletes text backwards
Declaration
Swift
public func deleteBackward() -
Inserts an
Attachmentin theEditorView.Declaration
Swift
public func insertAttachment(in range: NSRange, attachment: Attachment)Parameters
rangeRange where the
Attachmentshould be inserted. If the range contains existing content, the content will be replaced by theAttachment.attachmentAttachment to be inserted.
-
Sets the focus in the
EditorViewDeclaration
Swift
public func setFocus(at range: NSRange? = nil) -
Makes the
EditorViewlose focus.Declaration
Swift
public func resignFocus() -
Makes the
EditorViewscroll to given range such that it is visible. No-op if the range is already visible.Declaration
Swift
public func scrollRangeToVisible(_ range: NSRange)Parameters
rangeRange of content to scroll to.
-
Makes the
EditorViewscroll 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
rangeRange of content to scroll to.
-
Invalidates the display of content at the given range.
Declaration
Swift
public func invalidateDisplay(for range: NSRange)Parameters
rangeRange to invalidate.
-
Invalidates the layout of content at the given range. This will also fore layout of any
Attachmentcontained in the given range.Declaration
Swift
public func invalidateLayout(for range: NSRange)Parameters
rangeRange to invalidate.
-
Gets the contents within the
Editor.Declaration
Swift
public func contents(in range: NSRange? = nil) -> [EditorContent]Parameters
rangeRange to be enumerated to get the contents. If no range is specified, entire content range is enumerated.
-
Transforms
EditorContentinto 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 : EditorContentEncodingParameters
rangeRange of
Editorto transform the contents. By default, entire range is used.transformerTransformer capable of transforming
EditorContentto 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
rangeRange to replace.
attributedStringText 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 defaultfontandparagraphStyleset 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 usereplaceCharacterswith the parameter value of typeNSAttributedStringthat may have additional attributes defined, as well as customisedfontandparagraphStyleapplied.Declaration
Swift
public func replaceCharacters(in range: NSRange, with string: String)Parameters
rangeRange of text to replace. For an empty
EditorView, you may passNSRange.zeroto insert text at the beginning.stringString to replace the range of text with. The string will use default
fontandparagraphStyledefined in theEditorView. -
Appends the given attributed text to the end of content in
EditorView.Declaration
Swift
public func appendCharacters(_ attributedString: NSAttributedString)Parameters
attributedStringText to append.
-
Appends the given attributed text to the end of content in
EditorView.Declaration
Swift
public func appendCharacters(_ string: String)Parameters
stringText to append.
-
Registers the given text processor with the editor.
Declaration
Swift
public func registerProcessor(_ processor: TextProcessing)Parameters
processorText processor to register
-
Unregisters the given text processor from the editor.
Declaration
Swift
public func unregisterProcessor(_ processor: TextProcessing)Parameters
processorText processor to unregister
-
Registers the given text processors with the editor.
Declaration
Swift
public func registerProcessors(_ processors: [TextProcessing])Parameters
processorsText processors to register
-
Unregisters the given text processors from the editor.
Declaration
Swift
public func unregisterProcessors(_ processors: [TextProcessing])Parameters
processorsText 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
commandsCommands 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
commandsCommands 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
commandsCommand 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
commandsCommand to unregister
-
Relayout
EditorViewon 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
sizeSize 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?) -> BoolParameters
actionAction to be invoked
senderSender of the action
Return Value
trueto invoke default behaviour.falseto 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
pastemethod but with explicitly provided attributed string and insertion range.Declaration
Swift
open func paste(attributedString: NSAttributedString, into range: NSRange) -> BoolParameters
attributedStringAttributed string to be inserted
rangeInsertion range
Return Value
trueThe paste operation was successfulfalseThe 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
attributesAttributes to be added.
rangeRange 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
attributesAttributes to remove.
rangeRange 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
nameKey of the attribute to add.
valueValue of the attribute.
rangeRange 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
nameKey of attribute to be removed.
rangeRange 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
requiresSupportedCommandsRegistrationis false or if the command has been registered with the editor.Declaration
Swift
func isCommandRegistered(_ name: CommandName) -> BoolParameters
commandCommand to validate
Return Value
trueif 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 }
View on GitHub
EditorView Class Reference