From 30c5d88dbd5a317b95c4c0dc8dba11346d1f8211 Mon Sep 17 00:00:00 2001 From: Rajdeep Kwatra Date: Tue, 10 Oct 2023 16:04:18 +1100 Subject: [PATCH] Added helper function to get textRange from provide NSRange in Editor --- Proton/Sources/Swift/Editor/EditorView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Proton/Sources/Swift/Editor/EditorView.swift b/Proton/Sources/Swift/Editor/EditorView.swift index f5ef3470..ece1efbb 100644 --- a/Proton/Sources/Swift/Editor/EditorView.swift +++ b/Proton/Sources/Swift/Editor/EditorView.swift @@ -741,6 +741,13 @@ open class EditorView: UIView { return richTextView.becomeFirstResponder() } + /// Converts given range to `UITextRange`, if valid + /// - Parameter range: Range to convert + /// - Returns: `UITextRange` representation of provided NSRange, if valid. + public func textRange(from range: NSRange) -> UITextRange? { + range.toTextRange(textInput: richTextView) + } + /// 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. public var markedRange: NSRange? {