Skip to content

Commit 7922c5d

Browse files
committed
Make text view only set image configuration if it's not manually set before
1 parent 4d3cb51 commit 7922c5d

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

RELEASE_NOTES.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ Reach out if you think that this version changes too much for a minor bump, or i
2727

2828
* Many protocols now use `@preconcurrency @MainActor`.
2929
* All mutable `Image` and `Color` extensions are now computed.
30-
* All standard style and configuration values are now computed.
30+
* All standard style and configuration values are now computed.
31+
32+
### 🐛 Bug Fixes
33+
34+
* `RichTextView` only sets image configuration if it's not manually set before.
3135

3236

3337

Sources/RichTextKit/RichTextView+Setup.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ extension RichTextView {
1616
_ format: RichTextDataFormat
1717
) {
1818
attributedString = .empty
19-
imageConfiguration = standardImageConfiguration(for: format)
19+
if !imageConfigurationWasSet {
20+
imageConfiguration = standardImageConfiguration(for: format)
21+
}
2022
attributedString = text
2123
setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
2224
}

Sources/RichTextKit/RichTextView_AppKit.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ open class RichTextView: NSTextView, RichTextViewComponent {
3939
public var highlightingStyle: RichTextHighlightingStyle = .standard
4040

4141
/// The image configuration to use by the rich text view.
42-
public var imageConfiguration: RichTextImageConfiguration = .disabled
42+
public var imageConfiguration: RichTextImageConfiguration = .disabled {
43+
didSet { imageConfigurationWasSet = true }
44+
}
45+
46+
/// The image configuration to use by the rich text view.
47+
var imageConfigurationWasSet = false
4348

4449
// MARK: - Overrides
4550

Sources/RichTextKit/RichTextView_UIKit.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,14 @@ open class RichTextView: UITextView, RichTextViewComponent {
9898
didSet {
9999
#if iOS || os(visionOS)
100100
refreshDropInteraction()
101+
imageConfigurationWasSet = true
101102
#endif
102103
}
103104
}
104105

106+
/// The image configuration to use by the rich text view.
107+
var imageConfigurationWasSet = false
108+
105109
#if iOS || os(visionOS)
106110

107111
/// The image drop interaction to use.

0 commit comments

Comments
 (0)