From 3402f5764f794a60f85a152a13c4eacaa2a719f6 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Sun, 14 Jun 2026 17:07:38 +0200 Subject: Extract from Norganizer --- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc8cec4 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +# Norg Keyboard Toolbar + +This package provides a toolbar you can use whenever you need to edit norg +files. 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 + +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. + +## 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. -- cgit