|
@@ -10,22 +10,10 @@ final class GrammarCheckerViewModel: ObservableObject {
|
|
|
|
|
|
|
|
var characterCount: Int { text.count }
|
|
var characterCount: Int { text.count }
|
|
|
|
|
|
|
|
- var wordCount: Int {
|
|
|
|
|
- let components = text
|
|
|
|
|
- .trimmingCharacters(in: .whitespacesAndNewlines)
|
|
|
|
|
- .components(separatedBy: .whitespacesAndNewlines)
|
|
|
|
|
- .filter { !$0.isEmpty }
|
|
|
|
|
- return components.count
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
var characterCountLabel: String {
|
|
var characterCountLabel: String {
|
|
|
"\(characterCount)/\(Self.maxCharacters)"
|
|
"\(characterCount)/\(Self.maxCharacters)"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var wordCountLabel: String {
|
|
|
|
|
- "\(wordCount)/\(Self.maxCharacters) Words"
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
func pasteText() {
|
|
func pasteText() {
|
|
|
guard let clipboard = NSPasteboard.general.string(forType: .string) else { return }
|
|
guard let clipboard = NSPasteboard.general.string(forType: .string) else { return }
|
|
|
text = String(clipboard.prefix(Self.maxCharacters))
|
|
text = String(clipboard.prefix(Self.maxCharacters))
|