@@ -150,12 +150,6 @@ open class EditorView: UIView {
150
150
}
151
151
}
152
152
153
-
154
- // Holds `attributedText` until Editor move to a window
155
- // Setting attributed text without Editor being fully ready
156
- // causes issues with cached bounds that shows up when rotating the device.
157
- private var pendingAttributedText : NSAttributedString ?
158
-
159
153
var editorContextDelegate : EditorViewDelegate ? {
160
154
get { editorViewContext. delegate }
161
155
}
@@ -172,12 +166,6 @@ open class EditorView: UIView {
172
166
/// Context for the current Editor
173
167
public let editorViewContext : EditorViewContext
174
168
175
- /// Returns if `attributedText` change is pending. `AttributedText` may not have been applied if the `EditorView` is not already on
176
- /// `window` and `forceApplyAttributedText` is not set to `true`.
177
- public var isAttributedTextPending : Bool {
178
- pendingAttributedText != nil
179
- }
180
-
181
169
/// Enables asynchronous rendering of attachments.
182
170
/// - Note:
183
171
/// Since attachments must me rendered on main thread, the rendering only continues when there is no user interaction. By default, rendering starts
@@ -419,7 +407,6 @@ open class EditorView: UIView {
419
407
/// An attachment is only counted as a single character. Content length does not include
420
408
/// length of content within the Attachment that is hosting another `EditorView`.
421
409
public var contentLength : Int {
422
- guard pendingAttributedText == nil else { return attributedText. length }
423
410
return richTextView. contentLength
424
411
}
425
412
@@ -539,35 +526,20 @@ open class EditorView: UIView {
539
526
}
540
527
}
541
528
542
- /// Forces setting attributed text in `EditorView` even if it is not
543
- /// yet in view hierarchy.
544
- /// - Note: This may result in misplaced `Attachment`s and is recommended to be set to `true` only in unit tests.
545
- public var forceApplyAttributedText = false
546
-
547
529
/// Text to be set in the `EditorView`
548
- /// - Important: `attributedText` is not set for rendering in `EditorView` if the `EditorView` is not already in a `Window`. Value of `true`
549
- /// for `isAttributedTextPending` confirms that the text has not yet been rendered even though it is set in the `EditorView`.
550
- /// Notification of text being set can be observed by subscribing to `didSetAttributedText` in `EditorViewDelegate`.
551
- /// Alternatively, `forceApplyAttributedText` may be set to `true` to always apply `attributedText` irrespective of `EditorView` being
552
- /// in a `Window` or not.
553
530
public var attributedText : NSAttributedString {
554
531
get {
555
- pendingAttributedText ?? richTextView. attributedText
532
+ richTextView. attributedText
556
533
}
557
534
set {
558
- if forceApplyAttributedText == false && window == nil {
559
- pendingAttributedText = newValue
560
- return
561
- }
562
535
isSettingAttributedText = true
563
536
attachmentRenderingScheduler. cancel ( )
564
537
renderedViewport = nil
565
538
// Clear text before setting new value to avoid issues with formatting/layout when
566
539
// editor is hosted in a scrollable container and content is set multiple times.
567
540
richTextView. attributedText = NSAttributedString ( )
568
541
569
- let isDeferred = pendingAttributedText != nil
570
- pendingAttributedText = nil
542
+ let isDeferred = false
571
543
572
544
AggregateEditorViewDelegate . editor ( self , willSetAttributedText: newValue, isDeferred: isDeferred)
573
545
@@ -872,9 +844,6 @@ open class EditorView: UIView {
872
844
/// - IMPORTANT: Overriding implementations must call `super.didMoveToWindow()`
873
845
open override func didMoveToWindow( ) {
874
846
super. didMoveToWindow ( )
875
- if let pendingAttributedText {
876
- attributedText = pendingAttributedText
877
- }
878
847
let isReady = window != nil
879
848
AggregateEditorViewDelegate . editor ( self , isReady: isReady)
880
849
}
0 commit comments