@@ -9,59 +9,58 @@ import SwiftUI
9
9
10
10
extension RichEditorState {
11
11
12
- /// Get a binding for a certain color.
13
- public func binding( for color: RichTextColor ) -> Binding < Color > {
14
- Binding (
15
- get: { Color ( self . color ( for: color) ?? . clear) } ,
16
- set: { self . updateStyleFor ( color, to: . init( $0) ) }
17
- )
18
- }
12
+ /// Get a binding for a certain color.
13
+ public func binding( for color: RichTextColor ) -> Binding < Color > {
14
+ Binding (
15
+ get: { Color ( self . color ( for: color) ?? . clear) } ,
16
+ set: { self . updateStyleFor ( color, to: . init( $0) ) }
17
+ )
18
+ }
19
19
20
- /// Get the value for a certain color.
21
- public func color( for color: RichTextColor ) -> ColorRepresentable ? {
22
- colors [ color]
23
- }
20
+ /// Get the value for a certain color.
21
+ public func color( for color: RichTextColor ) -> ColorRepresentable ? {
22
+ colors [ color]
23
+ }
24
24
25
- /// Set the value for a certain color.
26
- public func setColor(
27
- _ color: RichTextColor ,
28
- to val: ColorRepresentable
29
- ) {
30
- guard self . color ( for: color) != val else { return }
31
- actionPublisher. send ( . setColor( color, val) )
32
- setColorInternal ( color, to: val)
33
- }
25
+ /// Set the value for a certain color.
26
+ public func setColor(
27
+ _ color: RichTextColor ,
28
+ to val: ColorRepresentable
29
+ ) {
30
+ actionPublisher. send ( . setColor( color, val) )
31
+ setColorInternal ( color, to: val)
32
+ }
34
33
35
- public func updateStyleFor(
36
- _ color: RichTextColor , to val: ColorRepresentable
37
- ) {
38
- let value = Color ( val)
39
- switch color {
40
- case . foreground:
41
- updateStyle ( style: . color( value) )
42
- case . background:
43
- updateStyle ( style: . background( value) )
44
- case . strikethrough:
45
- return
46
- case . stroke:
47
- return
48
- case . underline:
49
- return
50
- }
34
+ public func updateStyleFor(
35
+ _ color: RichTextColor , to val: ColorRepresentable
36
+ ) {
37
+ let value = Color ( val)
38
+ switch color {
39
+ case . foreground:
40
+ updateStyle ( style: . color( value) )
41
+ case . background:
42
+ updateStyle ( style: . background( value) )
43
+ case . strikethrough:
44
+ return
45
+ case . stroke:
46
+ return
47
+ case . underline:
48
+ return
51
49
}
50
+ }
52
51
}
53
52
54
53
extension RichEditorState {
55
54
56
- /// Set the value for a certain color, or remove it.
57
- func setColorInternal(
58
- _ color: RichTextColor ,
59
- to val: ColorRepresentable ?
60
- ) {
61
- guard let val else {
62
- colors [ color] = nil
63
- return
64
- }
65
- colors [ color] = val
55
+ /// Set the value for a certain color, or remove it.
56
+ func setColorInternal(
57
+ _ color: RichTextColor ,
58
+ to val: ColorRepresentable ?
59
+ ) {
60
+ guard let val else {
61
+ colors [ color] = nil
62
+ return
66
63
}
64
+ colors [ color] = val
65
+ }
67
66
}
0 commit comments