# Norg Keyboard Toolbar This package provides a toolbar you can use whenever you need to edit norg files in SwiftUI or UIKit apps. The toolbar provides the following buttons: The heading button creates a new heading, or increases the heading of the current level. See this table for examples. | Starting State | Resulting State | |----------------|-----------------| | * ⏐ | ** ⏐ | | * ⏐ Hello | ** ⏐ Hello | | * Hello ⏐ | * Hello\n* ⏐ | | Hello ⏐ | Hello\n* ⏐ | The task button creates a task on a new line, unless it's at the beginning of a heading or list, in which case it adds the task to the list. | Starting State | Resulting State | |----------------|-----------------| | * ⏐ | * ( ) ⏐ | | * ⏐ Hello | * ( ) ⏐ Hello | | * Hello ⏐ | * Hello\n- ( )⏐ | | Hello ⏐ | Hello\n- ( ) ⏐ | | ~ ⏐ | ~ ( ) ⏐ | The reverse heading buttons add `---` or `===` in a new line. The code button adds a `@code` and `@end` block. ## Usage ### SwiftUI Add the package to your project by including the repo URL with Xcode's package manager, and import it: ```swift import SwiftUI import NorgKeyboardToolbar struct EditorView: View { @State private var draft = "" @State private var selection: TextSelection? var body: some View { TextEditor(text: $draft, selection: $selection) .toolbar { NorgKeyboardToolbar(text: $draft, selection: $selection) } } } ``` `NorgKeyboardToolbar` then places a toolbar above the keyboard (or the bottom of the screen if a hardware keyboard is connected.) with the buttons described above. ### UIKit Add the package to your project by including the repo URL with Xcode's package manager, and import it: ```swift import UIKit import NorgKeyboardToolbar ... let textView = UITextView() textView.installNorgKeyboardAccessory() ``` `installNorgKeyboardAccessory` then attaches a toolbar above the keyboard with the buttons described above. ## Development A `Justfile` is provided to run common tasks: - `just build`, build the code. - `just test`, run tests. - `just coverage`, view coverage information. - `just format`, format and apply lint fixes. - `just lint`, lint the code.