Skip to content

Commit 548b1c0

Browse files
Added flexible support
1 parent 4c16430 commit 548b1c0

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

Package.resolved

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ let package = Package(
2222
from: "1.0.0"
2323
),
2424
.package(
25-
name: "AttributedText",
26-
url: "https://github.com/gonzalezreal/AttributedText",
25+
name: "FlexibleAttributedText",
26+
url: "https://github.com/wilmaplus/FlexibleAttributedText",
2727
from: "1.0.0"
2828
),
2929
.package(
@@ -43,7 +43,7 @@ let package = Package(
4343
name: "MarkdownUI",
4444
dependencies: [
4545
.product(name: "CommonMark", package: "SwiftCommonMark"),
46-
"AttributedText",
46+
"FlexibleAttributedText",
4747
"NetworkImage",
4848
.product(name: "CombineSchedulers", package: "combine-schedulers"),
4949
]

Sources/MarkdownUI/Markdown.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import AttributedText
1+
import FlexibleAttributedText
22
import Combine
33
import CombineSchedulers
44
@_exported import CommonMark
@@ -227,7 +227,7 @@ public struct Markdown: View {
227227
}
228228

229229
public var body: some View {
230-
AttributedText(self.viewState.attributedString, onOpenLink: openMarkdownLink?.handler)
230+
FlexibleAttributedText(self.viewState.attributedString, onOpenLink: openMarkdownLink?.handler, flexibleWidth: style.measurements.flexibleWidth)
231231
.onReceive(self.viewStatePublisher) { viewState in
232232
self.viewState = viewState
233233
}

Sources/MarkdownUI/Style/Measurements.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ extension MarkdownStyle {
2626

2727
/// The distance between the bottom of a heading and the top of the next block, relative to the base font size.
2828
public var headingSpacing: CGFloat
29+
30+
public var flexibleWidth: Bool
2931

3032
/// Creates a `Measurements` instance.
3133
/// - Parameters:
@@ -39,14 +41,16 @@ extension MarkdownStyle {
3941
/// - headingScales: The scale that the `Markdown` view applies to each heading level.
4042
/// - headingSpacing: The distance between the bottom of a heading and the top of the next block,
4143
/// relative to the base font size. The default is `0.67`.
44+
/// - flexibleWidth: Flexible width does not take full width of available space
4245
public init(
4346
codeFontScale: CGFloat = 0.94,
4447
headIndentStep: CGFloat = 1.97,
4548
tailIndentStep: CGFloat = -1,
4649
paragraphSpacing: CGFloat = 1,
4750
listMarkerSpacing: CGFloat = 0.47,
4851
headingScales: HeadingScales = .default,
49-
headingSpacing: CGFloat = 0.67
52+
headingSpacing: CGFloat = 0.67,
53+
flexibleWidth: Bool = false
5054
) {
5155
self.codeFontScale = codeFontScale
5256
self.headIndentStep = headIndentStep
@@ -55,6 +59,7 @@ extension MarkdownStyle {
5559
self.listMarkerSpacing = listMarkerSpacing
5660
self.headingScales = headingScales
5761
self.headingSpacing = headingSpacing
62+
self.flexibleWidth = flexibleWidth
5863
}
5964
}
6065
}

0 commit comments

Comments
 (0)