Skip to content

Commit c3498e1

Browse files
committed
Add new paragraph value function to the context
1 parent d2e2a5b commit c3498e1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ As a result, all parts of the library that handled individual value types have b
2323
* `NSParagraphStyle.KeyPath` has a new `defaultPickerValues` property.
2424
* `NSParagraphStyle.KeyPath` has a new `defaultStepperInterval` property.
2525
* `NSTextAlignment` has a new `defaultIcon` image-building property.
26-
* `RichTextContext` has a new `paragraphStyleValueBinding` property.
26+
* `RichTextContext` has a new `paragraphStyleValue(for:)` function.
27+
* `RichTextContext` has a new `paragraphStyleValueBinding(for:)` function.
2728
* `RichTextViewComponent` has a new, keypath-based `richTextParagraphStyleValue(_:)`.
2829
* `RichTextViewComponent` has a new, keypath-based `setRichTextParagraphStyleValue(_:_:)`.
2930
* `RichTextViewComponent` has a new, keypath-based `stepRichTextParagraphStyleValue(_:_:)`.

Sources/RichTextKit/RichTextContext.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,16 @@ public class RichTextContext: ObservableObject {
8686
@Published public internal(set) var styles = [RichTextStyle: Bool]()
8787

8888

89-
// MARK: - Bindings
89+
// MARK: - Paragraph
90+
91+
/// A paragraph style value for a certain value type.
92+
public func paragraphStyleValue<ValueType>(
93+
for keyPath: KeyPath<NSParagraphStyle, ValueType>
94+
) -> ValueType {
95+
paragraphStyle[keyPath: keyPath]
96+
}
9097

91-
/// This binding lets you bind to paragraph style values.
98+
/// A binding that binds to paragraph style values.
9299
public func paragraphStyleValueBinding<ValueType>(
93100
for keyPath: WritableKeyPath<NSMutableParagraphStyle, ValueType>
94101
) -> Binding<ValueType> {

0 commit comments

Comments
 (0)