Add a template-backed new-file button to the file list
The file list's "+ New" needs a typed name and seeds only '# <name>',
so every new chapter started from a blank header. Add a second button,
"+ New from template", that takes no name: it picks the first free
untitled-N.md (reusing a gap left by a deleted file), seeds it from a
configurable template, appends it to the manuscript order and selects it.
The template lives in config.json and is edited under Settings > New-file
template..., alongside the existing LanguageTool and Mistral dialogs.
Three placeholders expand at creation time: {{name}} (file stem),
{{marker}} (the configured draft marker, so a template keeps working if
the marker changes) and {{date}} (today's UTC date). Blanking the box
falls back to the built-in default, which seeds the header fields the app
already understands followed by the draft marker.
The date is computed with a local civil-from-days conversion rather than
a date crate, keeping the binary self-contained - ldd still shows only
libc/libgcc/libm.
"+ New" is unchanged; both paths now share insert_new_file. Covered by
13 new tests: placeholder expansion, untitled-N gap reuse, civil date
conversion against known dates, config.json written before this field
still deserializing (Config::load falls back to Default on a parse error,
which would otherwise discard the user's workspace and API keys), and a
round trip proving the seeded header parses back into Title/Slug/POV/goal
via the app's own preprocess::parse.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GBWj9TphFMCoh7VHaSRnvQ
This commit is contained in:
@@ -71,7 +71,9 @@ Terminal=false
|
||||
enclosing repository**. Accept it to have **⟳ Sync** commit and push to that
|
||||
repo; decline to leave the workspace on its own, where **Init git** creates a
|
||||
separate repository in the folder.
|
||||
3. Create files with **+ New**, edit on the right, `Ctrl+S` (or the Save button)
|
||||
3. Create files with **+ New** (type a name first) or **+ New from template**
|
||||
(no name needed — see [New files from a template](#new-files-from-a-template)),
|
||||
edit on the right, `Ctrl+S` (or the Save button)
|
||||
to write to disk. Drag the `⠿` handles to reorder. Use the **Zoom** slider
|
||||
above the editor to scale the editor text (0% = default; **Reset** returns to
|
||||
it), and the **Contrast** slider to brighten dim editor text (0% = theme
|
||||
@@ -137,6 +139,49 @@ A single number (`## Word Count Target: 1800`) sets a point goal; ranges accept
|
||||
`-`, `–`, `to`, and grouped digits (`1,500`). Like the other header lines, the
|
||||
target is stripped from the exported document.
|
||||
|
||||
## New files from a template
|
||||
|
||||
The file list has two create buttons:
|
||||
|
||||
| Button | Name | Contents |
|
||||
|---|---|---|
|
||||
| **+ New** | the name you type beside it | `# <name>` and a blank line |
|
||||
| **+ New from template** | auto-assigned `untitled-N.md` | the configured template |
|
||||
|
||||
**+ New from template** takes no typed name — it picks the first free
|
||||
`untitled-N.md` (reusing a gap if you have deleted one), seeds it from the
|
||||
template, appends it to the manuscript order and selects it. Rename it later with
|
||||
the **Rename** box, or set a `# Title:` header and let the chapter title come
|
||||
from that.
|
||||
|
||||
Edit the template under **Settings ▸ New-file template…**. The built-in default is:
|
||||
|
||||
```
|
||||
# Title: {{name}}
|
||||
# Slug:
|
||||
# POV:
|
||||
# Word Count Target:
|
||||
|
||||
### Rough Draft:
|
||||
|
||||
```
|
||||
|
||||
Three placeholders are expanded when the file is created:
|
||||
|
||||
| Placeholder | Expands to |
|
||||
|---|---|
|
||||
| `{{name}}` | the file stem, e.g. `untitled-3` |
|
||||
| `{{marker}}` | the draft marker set in the top bar (default `### Rough Draft:`) |
|
||||
| `{{date}}` | today's date in UTC, as `YYYY-MM-DD` |
|
||||
|
||||
Anything else in double braces is left alone. Using `{{marker}}` rather than
|
||||
typing the marker literally keeps the template working if you change the marker
|
||||
later. Emptying the box restores the built-in default, and **Reset to default**
|
||||
does the same in one click.
|
||||
|
||||
The template is stored in `~/.config/md-manuscript/config.json`, so it is shared
|
||||
by every workspace on the machine rather than committed with a manuscript.
|
||||
|
||||
## Spelling (offline)
|
||||
|
||||
Spelling is checked **live as you type**, entirely offline — no server, no
|
||||
@@ -286,7 +331,7 @@ only triggers in the header region, never in the prose below the marker.
|
||||
| `<workspace>/*.md` | your manuscript files |
|
||||
| `<workspace>/order.json` | the manual ordering (committed to git) |
|
||||
| `<workspace>/titles.json` | chapter-title overrides (committed to git) |
|
||||
| `~/.config/md-manuscript/config.json` | last workspace, export path, prefs |
|
||||
| `~/.config/md-manuscript/config.json` | last workspace, export path, prefs, new-file template |
|
||||
|
||||
## Markdown supported in ODT export
|
||||
|
||||
|
||||
Reference in New Issue
Block a user