Added keyboard shortcuts for post editing.

This commit is contained in:
Leon Mika 2026-02-24 22:21:26 +11:00
parent 4f7058bf36
commit 44d35c6ccb
13 changed files with 215 additions and 28 deletions

View file

@ -1,5 +1,9 @@
{{ $isPublished := ne .post.State 1 }}
<main class="flex-grow-1 position-relative">
<form action="/sites/{{.site.ID}}/posts" method="post" class="container-fluid post-form p-2">
<form action="/sites/{{.site.ID}}/posts" method="post" class="container-fluid post-form p-2"
data-controller="postedit"
data-action="keydown.meta+s->postedit#save keydown.meta+enter->postedit#publish"
data-postedit-save-action-value="{{ if $isPublished }}Update{{ else }}Save Draft{{ end }}">
<input type="hidden" name="guid" value="{{ .post.GUID }}">
<div class="mb-2">
<input type="text" name="title" class="form-control" placeholder="Title" value="{{ .post.Title }}">
@ -8,7 +12,12 @@
<textarea name="body" class="form-control" rows="3">{{.post.Body}}</textarea>
</div>
<div>
<input type="submit" class="btn btn-primary mt-2" value="Publish">
{{ if $isPublished }}
<input type="submit" name="action" class="btn btn-primary mt-2" value="Update">
{{ else }}
<input type="submit" name="action" class="btn btn-primary mt-2" value="Publish">
<input type="submit" name="action" class="btn btn-secondary mt-2" value="Save Draft">
{{ end }}
</div>
</form>
</main>