Skip to content

Commit

Permalink
Make text view only set image configuration if it's not manually set …
Browse files Browse the repository at this point in the history
…before
  • Loading branch information
danielsaidi committed Oct 8, 2024
1 parent 4d3cb51 commit 7922c5d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
6 changes: 5 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ Reach out if you think that this version changes too much for a minor bump, or i

* Many protocols now use `@preconcurrency @MainActor`.
* All mutable `Image` and `Color` extensions are now computed.
* All standard style and configuration values are now computed.
* All standard style and configuration values are now computed.

### 🐛 Bug Fixes

* `RichTextView` only sets image configuration if it's not manually set before.



Expand Down
4 changes: 3 additions & 1 deletion Sources/RichTextKit/RichTextView+Setup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ extension RichTextView {
_ format: RichTextDataFormat
) {
attributedString = .empty
imageConfiguration = standardImageConfiguration(for: format)
if !imageConfigurationWasSet {
imageConfiguration = standardImageConfiguration(for: format)
}
attributedString = text
setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
}
Expand Down
7 changes: 6 additions & 1 deletion Sources/RichTextKit/RichTextView_AppKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ open class RichTextView: NSTextView, RichTextViewComponent {
public var highlightingStyle: RichTextHighlightingStyle = .standard

/// The image configuration to use by the rich text view.
public var imageConfiguration: RichTextImageConfiguration = .disabled
public var imageConfiguration: RichTextImageConfiguration = .disabled {
didSet { imageConfigurationWasSet = true }
}

/// The image configuration to use by the rich text view.
var imageConfigurationWasSet = false

// MARK: - Overrides

Expand Down
4 changes: 4 additions & 0 deletions Sources/RichTextKit/RichTextView_UIKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ open class RichTextView: UITextView, RichTextViewComponent {
didSet {
#if iOS || os(visionOS)
refreshDropInteraction()
imageConfigurationWasSet = true
#endif
}
}

/// The image configuration to use by the rich text view.
var imageConfigurationWasSet = false

#if iOS || os(visionOS)

/// The image drop interaction to use.
Expand Down

0 comments on commit 7922c5d

Please sign in to comment.