File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Sources/SwiftUI-Utils/View/HTMLText Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ extension EnvironmentValues {
6
6
@Entry var htmlKerning : CGFloat = 0
7
7
@Entry var htmlFont : HTMLFont = . system
8
8
@Entry var htmlLineSpacing : CGFloat ?
9
+ @Entry var htmlLineBreakMode : NSLineBreakMode = . byTruncatingTail
9
10
}
10
11
11
12
extension View {
@@ -29,4 +30,8 @@ extension View {
29
30
public func htmlLineSpacing( _ spacing: CGFloat ? ) -> some View {
30
31
environment ( \. htmlLineSpacing, spacing)
31
32
}
33
+
34
+ public func htmlLineBreakMode( _ mode: NSLineBreakMode ) -> some View {
35
+ environment ( \. htmlLineBreakMode, mode)
36
+ }
32
37
}
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public struct HTMLText: UIViewRepresentable {
23
23
@Environment ( \. htmlKerning) var kerning
24
24
@Environment ( \. htmlFont) var font
25
25
@Environment ( \. htmlLineSpacing) var lineSpacing
26
+ @Environment ( \. htmlLineBreakMode) var lineBreakMode
26
27
27
28
let html : String
28
29
@@ -38,7 +39,7 @@ public struct HTMLText: UIViewRepresentable {
38
39
view. backgroundColor = . clear
39
40
view. setContentCompressionResistancePriority ( . defaultLow, for: . horizontal)
40
41
view. textContainer. lineFragmentPadding = . zero
41
- view. textContainer. lineBreakMode = . byTruncatingTail
42
+ view. textContainer. lineBreakMode = lineBreakMode
42
43
view. textContainer. maximumNumberOfLines = lineLimit ?? 0
43
44
view. textContainerInset = . zero
44
45
view. accessibilityTraits = . staticText
You can’t perform that action at this time.
0 commit comments