Skip to content

Commit

Permalink
Update coordinator documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Feb 15, 2024
1 parent 61c7726 commit 8078c89
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ extension RichTextCoordinator {
func setIsEditing(to newValue: Bool) {
if newValue == textView.isFirstResponder { return }
if newValue {
#if iOS || os(visionOS)
#if iOS || os(visionOS)
textView.becomeFirstResponder()
#else
#else
print("macOS currently doesn't resign first responder.")
#endif
#endif
} else {
#if iOS || os(visionOS)
#if iOS || os(visionOS)
textView.resignFirstResponder()
#else
#else
print("macOS currently doesn't resign first responder.")
#endif
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ extension RichTextCoordinator {
}
guard let attribute = color.attribute else { return }
if let applyRange {
self.textView.setRichTextColor(color, to: val, at: applyRange)
textView.setRichTextColor(color, to: val, at: applyRange)
} else {
self.textView.setRichTextAttribute(attribute, to: val)
textView.setRichTextAttribute(attribute, to: val)
}
}
}
Expand Down
21 changes: 8 additions & 13 deletions Sources/RichTextKit/Coordinator/RichTextCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RichTextKit
//
// Created by Daniel Saidi on 2022-05-22.
// Copyright © 2022-2023 Daniel Saidi. All rights reserved.
// Copyright © 2022-2024 Daniel Saidi. All rights reserved.
//

#if iOS || macOS || os(tvOS) || os(visionOS)
Expand All @@ -13,14 +13,13 @@ import SwiftUI
/**
This coordinator is used to keep a ``RichTextView`` in sync
with a ``RichTextContext``.
This is used by ``RichTextEditor`` to coordinate changes in
its context and the underlying text view.
The coordinator sets itself as the text view's delegate and
updates the context when things change in the text view. It
also subscribes to context observable changes and keeps the
text view in sync with these changes.
You can inherit this class to customize the coordinator for
your own use cases.
The coordinator sets itself as the text view's delegate. It
updates the context when things change in the text view and
syncs to context changes to the text view.
*/
open class RichTextCoordinator: NSObject {

Expand Down Expand Up @@ -171,11 +170,7 @@ extension RichTextCoordinator {
}
}

/**
Sync the rich text context with the text view after the
dispatch queue delay above. The delay will silence some
purple alert warnings about how state is updated.
*/
/// Sync the rich text context with the text view.
func syncContextWithTextViewAfterDelay() {
let styles = textView.richTextStyles

Expand Down

0 comments on commit 8078c89

Please sign in to comment.