@@ -15,179 +15,179 @@ import SwiftUI
15
15
/// types and views, like ``RichTextAction/Button``.
16
16
public enum RichTextAction : Identifiable , Equatable {
17
17
18
- /// Copy the currently selected text, if any.
19
- case copy
18
+ /// Copy the currently selected text, if any.
19
+ case copy
20
20
21
- /// Dismiss any presented software keyboard.
22
- case dismissKeyboard
21
+ /// Dismiss any presented software keyboard.
22
+ case dismissKeyboard
23
23
24
- /// Paste a single image.
25
- // case pasteImage(RichTextInsertion<ImageRepresentable>)
26
- //
27
- // /// Paste multiple images.
28
- // case pasteImages(RichTextInsertion<[ImageRepresentable]>)
29
- //
30
- // /// Paste plain text.
31
- // case pasteText(RichTextInsertion<String>)
24
+ /// Paste a single image.
25
+ // case pasteImage(RichTextInsertion<ImageRepresentable>)
26
+ //
27
+ // /// Paste multiple images.
28
+ // case pasteImages(RichTextInsertion<[ImageRepresentable]>)
29
+ //
30
+ // /// Paste plain text.
31
+ // case pasteText(RichTextInsertion<String>)
32
32
33
- /// A print command.
34
- case print
33
+ /// A print command.
34
+ case print
35
35
36
- /// Redo the latest undone change.
37
- case redoLatestChange
36
+ /// Redo the latest undone change.
37
+ case redoLatestChange
38
38
39
- /// Select a range.
40
- case selectRange( NSRange )
39
+ /// Select a range.
40
+ case selectRange( NSRange )
41
41
42
- /// Set the text alignment.
43
- case setAlignment( _ alignment: RichTextAlignment )
42
+ /// Set the text alignment.
43
+ case setAlignment( _ alignment: RichTextAlignment )
44
44
45
- /// Set the entire attributed string.
46
- case setAttributedString( NSAttributedString )
45
+ /// Set the entire attributed string.
46
+ case setAttributedString( NSAttributedString )
47
47
48
- // Change background color
49
- case setColor( RichTextColor , ColorRepresentable )
48
+ // Change background color
49
+ case setColor( RichTextColor , ColorRepresentable ? )
50
50
51
- // Highlighted renge
52
- case setHighlightedRange( NSRange ? )
51
+ // Highlighted renge
52
+ case setHighlightedRange( NSRange ? )
53
53
54
- // Change highlighting style
55
- case setHighlightingStyle( RichTextHighlightingStyle )
54
+ // Change highlighting style
55
+ case setHighlightingStyle( RichTextHighlightingStyle )
56
56
57
- /// Set a certain ``RichTextStyle``.
58
- case setStyle( RichTextStyle , Bool )
57
+ /// Set a certain ``RichTextStyle``.
58
+ case setStyle( RichTextStyle , Bool )
59
59
60
- /// Step the font size.
61
- case stepFontSize( points: Int )
60
+ /// Step the font size.
61
+ case stepFontSize( points: Int )
62
62
63
- /// Step the indent level.
64
- case stepIndent( points: CGFloat )
63
+ /// Step the indent level.
64
+ case stepIndent( points: CGFloat )
65
65
66
- /// Step the line spacing.
67
- case stepLineSpacing( points: CGFloat )
66
+ /// Step the line spacing.
67
+ case stepLineSpacing( points: CGFloat )
68
68
69
- /// Step the superscript level.
70
- case stepSuperscript( steps: Int )
69
+ /// Step the superscript level.
70
+ case stepSuperscript( steps: Int )
71
71
72
- /// Toggle a certain style.
73
- case toggleStyle( _ style: RichTextStyle )
72
+ /// Toggle a certain style.
73
+ case toggleStyle( _ style: RichTextStyle )
74
74
75
- /// Undo the latest change.
76
- case undoLatestChange
75
+ /// Undo the latest change.
76
+ case undoLatestChange
77
77
78
- /// Set HeaderStyle.
79
- case setHeaderStyle( _ style: RichTextSpanStyle )
78
+ /// Set HeaderStyle.
79
+ case setHeaderStyle( _ style: RichTextSpanStyle )
80
80
81
- /// Set link
82
- case setLink( String ? = nil )
81
+ /// Set link
82
+ case setLink( String ? = nil )
83
83
}
84
84
85
85
extension RichTextAction {
86
86
87
- public typealias Publisher = PassthroughSubject < Self , Never >
88
-
89
- /// The action's unique identifier.
90
- public var id : String { title }
91
-
92
- /// The action's standard icon.
93
- public var icon : Image {
94
- switch self {
95
- case . copy: . richTextCopy
96
- case . dismissKeyboard: . richTextDismissKeyboard
97
- // case .pasteImage: .richTextDocuments
98
- // case .pasteImages: .richTextDocuments
99
- // case .pasteText: .richTextDocuments
100
- case . print: . richTextPrint
101
- case . redoLatestChange: . richTextRedo
102
- case . selectRange: . richTextSelection
103
- case . setAlignment( let val) : val. icon
104
- case . setAttributedString: . richTextDocument
105
- case . setColor( let color, _) : color. icon
106
- case . setHighlightedRange: . richTextAlignmentCenter
107
- case . setHighlightingStyle: . richTextAlignmentCenter
108
- case . setStyle( let style, _) : style. icon
109
- case . stepFontSize( let val) : . richTextStepFontSize( val)
110
- case . stepIndent( let val) : . richTextStepIndent( val)
111
- case . stepLineSpacing( let val) : . richTextStepLineSpacing( val)
112
- case . stepSuperscript( let val) : . richTextStepSuperscript( val)
113
- case . toggleStyle( let val) : val. icon
114
- case . undoLatestChange: . richTextUndo
115
- case . setHeaderStyle: . richTextIgnoreIt
116
- case . setLink: . richTextLink
117
- }
87
+ public typealias Publisher = PassthroughSubject < Self , Never >
88
+
89
+ /// The action's unique identifier.
90
+ public var id : String { title }
91
+
92
+ /// The action's standard icon.
93
+ public var icon : Image {
94
+ switch self {
95
+ case . copy: . richTextCopy
96
+ case . dismissKeyboard: . richTextDismissKeyboard
97
+ // case .pasteImage: .richTextDocuments
98
+ // case .pasteImages: .richTextDocuments
99
+ // case .pasteText: .richTextDocuments
100
+ case . print: . richTextPrint
101
+ case . redoLatestChange: . richTextRedo
102
+ case . selectRange: . richTextSelection
103
+ case . setAlignment( let val) : val. icon
104
+ case . setAttributedString: . richTextDocument
105
+ case . setColor( let color, _) : color. icon
106
+ case . setHighlightedRange: . richTextAlignmentCenter
107
+ case . setHighlightingStyle: . richTextAlignmentCenter
108
+ case . setStyle( let style, _) : style. icon
109
+ case . stepFontSize( let val) : . richTextStepFontSize( val)
110
+ case . stepIndent( let val) : . richTextStepIndent( val)
111
+ case . stepLineSpacing( let val) : . richTextStepLineSpacing( val)
112
+ case . stepSuperscript( let val) : . richTextStepSuperscript( val)
113
+ case . toggleStyle( let val) : val. icon
114
+ case . undoLatestChange: . richTextUndo
115
+ case . setHeaderStyle: . richTextIgnoreIt
116
+ case . setLink: . richTextLink
118
117
}
119
-
120
- /// The localized label to use for the action.
121
- public var label : some View {
122
- icon. label ( title)
123
- }
124
-
125
- /// The localized title to use in the main menu.
126
- public var menuTitle : String {
127
- menuTitleKey. text
128
- }
129
-
130
- /// The localized title key to use in the main menu.
131
- public var menuTitleKey : RTEL10n {
132
- switch self {
133
- case . stepIndent( let points) : . menuIndent( points)
134
- default : titleKey
135
- }
136
- }
137
-
138
- /// The localized action title.
139
- public var title : String {
140
- titleKey. text
118
+ }
119
+
120
+ /// The localized label to use for the action.
121
+ public var label : some View {
122
+ icon. label ( title)
123
+ }
124
+
125
+ /// The localized title to use in the main menu.
126
+ public var menuTitle : String {
127
+ menuTitleKey. text
128
+ }
129
+
130
+ /// The localized title key to use in the main menu.
131
+ public var menuTitleKey : RTEL10n {
132
+ switch self {
133
+ case . stepIndent( let points) : . menuIndent( points)
134
+ default : titleKey
141
135
}
142
-
143
- /// The localized action title key.
144
- public var titleKey : RTEL10n {
145
- switch self {
146
- case . copy: . actionCopy
147
- case . dismissKeyboard: . actionDismissKeyboard
148
- // case .pasteImage: .pasteImage
149
- // case .pasteImages: .pasteImages
150
- // case .pasteText: .pasteText
151
- case . print: . actionPrint
152
- case . redoLatestChange: . actionRedoLatestChange
153
- case . selectRange: . selectRange
154
- case . setAlignment( let alignment) : alignment. titleKey
155
- case . setAttributedString: . setAttributedString
156
- case . setColor( let color, _) : color. titleKey
157
- case . setHighlightedRange: . highlightedRange
158
- case . setHighlightingStyle: . highlightingStyle
159
- case . setStyle( let style, _) : style. titleKey
160
- case . stepFontSize( let points) : . actionStepFontSize( points)
161
- case . stepIndent( let points) : . actionStepIndent( points)
162
- case . stepLineSpacing( let points) : . actionStepLineSpacing( points)
163
- case . stepSuperscript( let steps) : . actionStepSuperscript( steps)
164
- case . toggleStyle( let style) : style. titleKey
165
- case . undoLatestChange: . actionUndoLatestChange
166
- case . setLink: . link
167
- case . setHeaderStyle: . ignoreIt
168
- }
136
+ }
137
+
138
+ /// The localized action title.
139
+ public var title : String {
140
+ titleKey. text
141
+ }
142
+
143
+ /// The localized action title key.
144
+ public var titleKey : RTEL10n {
145
+ switch self {
146
+ case . copy: . actionCopy
147
+ case . dismissKeyboard: . actionDismissKeyboard
148
+ // case .pasteImage: .pasteImage
149
+ // case .pasteImages: .pasteImages
150
+ // case .pasteText: .pasteText
151
+ case . print: . actionPrint
152
+ case . redoLatestChange: . actionRedoLatestChange
153
+ case . selectRange: . selectRange
154
+ case . setAlignment( let alignment) : alignment. titleKey
155
+ case . setAttributedString: . setAttributedString
156
+ case . setColor( let color, _) : color. titleKey
157
+ case . setHighlightedRange: . highlightedRange
158
+ case . setHighlightingStyle: . highlightingStyle
159
+ case . setStyle( let style, _) : style. titleKey
160
+ case . stepFontSize( let points) : . actionStepFontSize( points)
161
+ case . stepIndent( let points) : . actionStepIndent( points)
162
+ case . stepLineSpacing( let points) : . actionStepLineSpacing( points)
163
+ case . stepSuperscript( let steps) : . actionStepSuperscript( steps)
164
+ case . toggleStyle( let style) : style. titleKey
165
+ case . undoLatestChange: . actionUndoLatestChange
166
+ case . setLink: . link
167
+ case . setHeaderStyle: . ignoreIt
169
168
}
169
+ }
170
170
}
171
171
172
172
// MARK: - Aliases
173
173
174
174
extension RichTextAction {
175
175
176
- /// A name alias for `.redoLatestChange`.
177
- public static var redo : RichTextAction { . redoLatestChange }
176
+ /// A name alias for `.redoLatestChange`.
177
+ public static var redo : RichTextAction { . redoLatestChange }
178
178
179
- /// A name alias for `.undoLatestChange`.
180
- public static var undo : RichTextAction { . undoLatestChange }
179
+ /// A name alias for `.undoLatestChange`.
180
+ public static var undo : RichTextAction { . undoLatestChange }
181
181
}
182
182
183
183
extension CGFloat {
184
184
185
- /// The default rich text indent step size.
186
- public static var defaultRichTextIntentStepSize : CGFloat = 30.0
185
+ /// The default rich text indent step size.
186
+ public static var defaultRichTextIntentStepSize : CGFloat = 30.0
187
187
}
188
188
189
189
extension UInt {
190
190
191
- /// The default rich text indent step size.
192
- public static var defaultRichTextIntentStepSize : UInt = 30
191
+ /// The default rich text indent step size.
192
+ public static var defaultRichTextIntentStepSize : UInt = 30
193
193
}
0 commit comments