Autosave box HTML, fix editor selection, make /shrines a canvas page
Test and deploy / test (push) Successful in 1m56s
Test and deploy / deploy (push) Successful in 48s

The HTML editor's selection was invisible: CodeMirror's focused-selection
rule outranked ours and painted #233, and the opaque active line covered
the selection layer. Match its selector and make the active line
translucent.

Unsaved HTML now saves on leaving a box (selecting another, clicking
empty canvas, Done, closing the panel) instead of asking to discard.

/shrines is no longer a hard-coded route but an ordinary canvas page,
with links placed by hand as Link boxes; the backend no longer reserves
the slug. The Shrine starter layout is gone, and the admin Pages tab
gains a "New shrine" form that makes a blank page under shrines/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-15 12:27:06 +01:00
co-authored by Claude Opus 5.5
parent e54aaac181
commit ca3cd4db30
11 changed files with 83 additions and 110 deletions
+8 -5
View File
@@ -2,8 +2,9 @@
/**
* Create a canvas page: its address, title, a starting layout from
* pageStarters.js, and whether only admins may see it. On success it opens
* the new page and emits `created`. Used on the admin panel's Pages tab, on /shrines, and on the
* 404 an admin sees at an address that has no page yet.
* the new page and emits `created`. Used on the admin panel's Pages tab
* (twice: any page, and a shrine under /shrines/) and on the 404 an admin sees
* at an address that has no page yet.
*/
import { ref } from "vue";
import { useRouter } from "vue-router";
@@ -15,9 +16,11 @@ import { STARTERS } from "./pageStarters";
const props = defineProps({
// Pre-filled address, e.g. the path of the 404 being looked at.
slug: { type: String, default: "" },
// Fixed leading part of the address, e.g. "shrines/" on /shrines.
// Fixed leading part of the address, e.g. "shrines/" for a new shrine.
prefix: { type: String, default: "" },
starter: { type: String, default: "blank" },
placeholder: { type: String, default: "address, e.g. shrines/evangelion" },
submitLabel: { type: String, default: "Create page" },
});
const emit = defineEmits(["created"]);
@@ -64,7 +67,7 @@ async function submit() {
<form class="page-form flex flex-col gap-1" @submit.prevent="submit">
<label class="flex items-center gap-1">
<span class="text-muted">/{{ prefix }}</span>
<input v-model="slug" type="text" placeholder="address, e.g. evangelion" required class="flex-1" />
<input v-model="slug" type="text" :placeholder="placeholder" required class="flex-1" />
</label>
<input v-model="title" type="text" placeholder="Title (required)" />
<select v-model="starter">
@@ -74,7 +77,7 @@ async function submit() {
<input v-model="adminOnly" type="checkbox" />
Only admins can see this page
</label>
<Button type="submit" :disabled="busy">{{ busy ? "Creating…" : "Create page" }}</Button>
<Button type="submit" :disabled="busy">{{ busy ? "Creating…" : submitLabel }}</Button>
<p v-if="error" class="text-tertiary">{{ error }}</p>
</form>
</template>
-55
View File
@@ -4,62 +4,8 @@
* stores/boxes.js — without `page`, which the store adds. Everything is an
* ordinary box afterwards: move it, edit it, delete it.
*/
import { galleryHtml, imageHtml } from "@/views/home3/templates";
const escape = (s) =>
s.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
const html = (title, body, geom, extra = {}) => ({ kind: "html", title, html: body, ...geom, ...extra });
function shrine(title) {
const t = escape(title);
return [
html(
"Heading",
`<style>
body { display: grid; place-items: center; text-align: center; }
h1 { margin: 0; font-size: 4.5rem; line-height: 1; }
p { margin: .3rem 0 0; color: var(--color-tertiary); }
</style>
<div>
<h1>${t}</h1>
<p>a shrine</p>
</div>`,
{ x: 300, y: 20, w: 800, h: 160 },
{ framed: false },
),
html(
"Main image",
imageHtml("/img/memes/epic.jpeg"),
{ x: 300, y: 200, w: 380, h: 380 },
{ framed: false },
),
html(
"About",
`<h3>Why ${t}</h3>
<p>What it is, and why it gets a shrine.</p>
<h3>Favourite moments</h3>
<ul>
<li>…</li>
</ul>`,
{ x: 700, y: 200, w: 400, h: 380 },
),
html(
"Gallery",
galleryHtml(["/img/memes/fire-woman.gif", "/img/memes/mix.gif", "/img/memes/lol.jpg"]),
{ x: 300, y: 600, w: 800, h: 320 },
),
html(
"Quote",
`<style>
body { display: grid; place-items: center; text-align: center; font-style: italic; }
</style>
<blockquote>“A line worth remembering.”</blockquote>`,
{ x: 300, y: 940, w: 800, h: 120 },
),
].map((box, i) => ({ z: i + 1, ...box }));
}
function notes() {
const note = (text, x, y) =>
html(
@@ -82,6 +28,5 @@ function notes() {
export const STARTERS = [
{ id: "blank", label: "Blank", boxes: () => [] },
{ id: "shrine", label: "Shrine", boxes: shrine },
{ id: "notes", label: "Notes board (admin-only notes)", boxes: notes },
];