deneljs 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -2
- package/drizzle/0000_lonely_reptil.sql +27 -0
- package/drizzle/0001_misty_wendigo.sql +74 -0
- package/drizzle/meta/0000_snapshot.json +179 -0
- package/drizzle/meta/0001_snapshot.json +492 -0
- package/drizzle/meta/_journal.json +20 -0
- package/package.json +55 -4
- package/src/admin/auth.ts +851 -0
- package/src/admin/layout.ts +419 -0
- package/src/admin/pages/categories.ts +223 -0
- package/src/admin/pages/dashboard.ts +192 -0
- package/src/admin/pages/media.ts +270 -0
- package/src/admin/pages/posts.ts +804 -0
- package/src/admin/pages/settings.ts +169 -0
- package/src/admin/pages/themes.ts +461 -0
- package/src/admin/pages/users.ts +501 -0
- package/src/admin/routes.ts +455 -0
- package/src/admin/tiptap-bundle.ts +48 -0
- package/src/admin/tiptap-entry.ts +226 -0
- package/src/ai/generator.ts +296 -0
- package/src/ai/index.ts +22 -0
- package/src/ai/schema.ts +13 -0
- package/src/ai/spec.ts +193 -0
- package/src/cli.ts +151 -0
- package/src/db/index.ts +278 -0
- package/src/db/schema.ts +115 -0
- package/src/engine/index.ts +52 -0
- package/src/engine/renderer.ts +533 -0
- package/src/engine/sandbox.ts +108 -0
- package/src/engine/schema.ts +71 -0
- package/src/engine/validator.ts +404 -0
- package/src/routes/admin-api.ts +1035 -0
- package/src/routes/posts.ts +294 -0
- package/src/routes/uploads.ts +119 -0
- package/src/server.ts +672 -0
- package/src/utils/sanitize-html.ts +145 -0
- package/themes/.gitkeep +1 -0
- package/themes/default/assets/style.css +799 -0
- package/themes/default/layouts/base.liquid +31 -0
- package/themes/default/layouts/home.liquid +180 -0
- package/themes/default/layouts/page.liquid +21 -0
- package/themes/default/layouts/post.liquid +55 -0
- package/themes/default/partials/footer.liquid +33 -0
- package/themes/default/partials/navbar.liquid +49 -0
- package/themes/default/theme.json +59 -0
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
import { serializeSafeJson } from "../layout";
|
|
2
|
+
|
|
3
|
+
export interface PostsPageCategory {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
slug: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface PostListItem {
|
|
10
|
+
id: number;
|
|
11
|
+
slug: string;
|
|
12
|
+
title: string;
|
|
13
|
+
excerpt: string;
|
|
14
|
+
category_id: number | null;
|
|
15
|
+
category_name: string | null;
|
|
16
|
+
author_name: string | null;
|
|
17
|
+
status: "draft" | "published";
|
|
18
|
+
updated_at: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface EditablePost {
|
|
22
|
+
id?: number;
|
|
23
|
+
title: string;
|
|
24
|
+
slug: string;
|
|
25
|
+
content: string;
|
|
26
|
+
excerpt: string;
|
|
27
|
+
featured_image: string;
|
|
28
|
+
category_id: number | null;
|
|
29
|
+
meta_title: string;
|
|
30
|
+
meta_description: string;
|
|
31
|
+
status: "draft" | "published";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Render the Posts Manager list page (/admin/posts).
|
|
36
|
+
*/
|
|
37
|
+
export function renderPostsListPage(
|
|
38
|
+
initialPosts: PostListItem[],
|
|
39
|
+
categories: PostsPageCategory[],
|
|
40
|
+
): string {
|
|
41
|
+
const seed = serializeSafeJson({ posts: initialPosts, categories });
|
|
42
|
+
|
|
43
|
+
return `
|
|
44
|
+
<script id="posts-list-seed" type="application/json">${seed}</script>
|
|
45
|
+
<script>
|
|
46
|
+
document.addEventListener("alpine:init", () => {
|
|
47
|
+
Alpine.data("postsListManager", () => ({
|
|
48
|
+
posts: [],
|
|
49
|
+
categories: [],
|
|
50
|
+
q: "",
|
|
51
|
+
statusFilter: "all",
|
|
52
|
+
categoryFilter: "",
|
|
53
|
+
confirmDeleteId: null,
|
|
54
|
+
togglingId: null,
|
|
55
|
+
loading: false,
|
|
56
|
+
|
|
57
|
+
init() {
|
|
58
|
+
const el = document.getElementById("posts-list-seed");
|
|
59
|
+
const seed = el ? JSON.parse(el.textContent || "{}") : {};
|
|
60
|
+
this.posts = Array.isArray(seed.posts) ? seed.posts : [];
|
|
61
|
+
this.categories = Array.isArray(seed.categories) ? seed.categories : [];
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
formatDate(sec) {
|
|
65
|
+
if (!sec) return "—";
|
|
66
|
+
return new Date(sec * 1000).toLocaleDateString(undefined, {
|
|
67
|
+
year: "numeric",
|
|
68
|
+
month: "short",
|
|
69
|
+
day: "numeric",
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
async fetchFiltered() {
|
|
74
|
+
this.loading = true;
|
|
75
|
+
try {
|
|
76
|
+
const params = new URLSearchParams();
|
|
77
|
+
if (this.q.trim()) params.set("q", this.q.trim());
|
|
78
|
+
if (this.statusFilter !== "all") params.set("status", this.statusFilter);
|
|
79
|
+
if (this.categoryFilter) params.set("category_id", this.categoryFilter);
|
|
80
|
+
params.set("t", String(Date.now()));
|
|
81
|
+
const res = await fetch("/api/admin/posts?" + params.toString(), { cache: "no-store" });
|
|
82
|
+
const data = await res.json();
|
|
83
|
+
if (res.ok) {
|
|
84
|
+
this.posts = Array.isArray(data.posts) ? data.posts : [];
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
this.loading = false;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
async toggleStatus(post) {
|
|
92
|
+
this.togglingId = post.id;
|
|
93
|
+
const nextStatus = post.status === "published" ? "draft" : "published";
|
|
94
|
+
try {
|
|
95
|
+
const res = await fetch("/api/admin/posts/" + post.id, {
|
|
96
|
+
method: "PUT",
|
|
97
|
+
headers: { "content-type": "application/json" },
|
|
98
|
+
body: JSON.stringify({ status: nextStatus }),
|
|
99
|
+
});
|
|
100
|
+
const data = await res.json();
|
|
101
|
+
if (!res.ok || !data.success) {
|
|
102
|
+
window.cmsToast("error", (data.errors && data.errors[0]) || "Failed to update status.");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
post.status = nextStatus;
|
|
106
|
+
if (data.post?.updated_at) post.updated_at = data.post.updated_at;
|
|
107
|
+
window.cmsToast("success", nextStatus === "published" ? "Post published." : "Moved to draft.");
|
|
108
|
+
} catch {
|
|
109
|
+
window.cmsToast("error", "Network error while toggling status.");
|
|
110
|
+
} finally {
|
|
111
|
+
this.togglingId = null;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
async deletePost(id) {
|
|
116
|
+
try {
|
|
117
|
+
const res = await fetch("/api/admin/posts/" + id, { method: "DELETE" });
|
|
118
|
+
const data = await res.json();
|
|
119
|
+
if (!res.ok || !data.success) {
|
|
120
|
+
window.cmsToast("error", (data.errors && data.errors[0]) || "Failed to delete post.");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.confirmDeleteId = null;
|
|
124
|
+
this.posts = this.posts.filter((p) => p.id !== id);
|
|
125
|
+
window.cmsToast("success", "Post deleted.");
|
|
126
|
+
} catch {
|
|
127
|
+
window.cmsToast("error", "Network error while deleting post.");
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<div x-data="postsListManager" class="space-y-5">
|
|
135
|
+
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
136
|
+
<div class="flex flex-wrap items-center gap-2.5 flex-1">
|
|
137
|
+
<input
|
|
138
|
+
type="search"
|
|
139
|
+
x-model="q"
|
|
140
|
+
@input.debounce.250ms="fetchFiltered()"
|
|
141
|
+
placeholder="Search posts..."
|
|
142
|
+
class="w-full sm:w-64 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
143
|
+
>
|
|
144
|
+
<select
|
|
145
|
+
x-model="statusFilter"
|
|
146
|
+
@change="fetchFiltered()"
|
|
147
|
+
class="rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
148
|
+
>
|
|
149
|
+
<option value="all">All statuses</option>
|
|
150
|
+
<option value="published">Published</option>
|
|
151
|
+
<option value="draft">Draft</option>
|
|
152
|
+
</select>
|
|
153
|
+
<select
|
|
154
|
+
x-model="categoryFilter"
|
|
155
|
+
@change="fetchFiltered()"
|
|
156
|
+
class="rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
157
|
+
>
|
|
158
|
+
<option value="">All categories</option>
|
|
159
|
+
<template x-for="cat in categories" :key="cat.id">
|
|
160
|
+
<option :value="String(cat.id)" x-text="cat.name"></option>
|
|
161
|
+
</template>
|
|
162
|
+
</select>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<a
|
|
166
|
+
href="/admin/posts/new"
|
|
167
|
+
class="inline-flex items-center gap-1.5 px-4 py-2 rounded-lg bg-slate-900 text-white text-sm font-medium hover:bg-slate-800 transition"
|
|
168
|
+
>
|
|
169
|
+
<i data-lucide="plus" class="w-4 h-4"></i>
|
|
170
|
+
New Post
|
|
171
|
+
</a>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div class="bg-white rounded-xl border border-slate-200 shadow-sm overflow-hidden">
|
|
175
|
+
<div class="overflow-x-auto">
|
|
176
|
+
<table class="w-full text-left border-collapse">
|
|
177
|
+
<thead>
|
|
178
|
+
<tr class="bg-slate-50 border-b border-slate-200 text-[11px] font-semibold uppercase tracking-wider text-slate-500">
|
|
179
|
+
<th class="px-5 py-3">Post</th>
|
|
180
|
+
<th class="px-5 py-3">Category</th>
|
|
181
|
+
<th class="px-5 py-3">Author</th>
|
|
182
|
+
<th class="px-5 py-3">Status</th>
|
|
183
|
+
<th class="px-5 py-3">Updated</th>
|
|
184
|
+
<th class="px-5 py-3 text-right">Actions</th>
|
|
185
|
+
</tr>
|
|
186
|
+
</thead>
|
|
187
|
+
<tbody class="divide-y divide-slate-200">
|
|
188
|
+
<tr x-show="posts.length === 0">
|
|
189
|
+
<td colspan="6" class="px-5 py-10 text-center text-sm text-slate-500">No matching posts found.</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<template x-for="post in posts" :key="post.id">
|
|
192
|
+
<tr class="hover:bg-slate-50/70">
|
|
193
|
+
<td class="px-5 py-3.5">
|
|
194
|
+
<a :href="'/admin/posts/' + post.id + '/edit'" class="text-sm font-semibold text-slate-900 hover:text-blue-600" x-text="post.title"></a>
|
|
195
|
+
<div class="text-xs font-mono text-slate-400" x-text="'/post/' + post.slug"></div>
|
|
196
|
+
</td>
|
|
197
|
+
<td class="px-5 py-3.5 text-xs text-slate-600" x-text="post.category_name || 'Uncategorized'"></td>
|
|
198
|
+
<td class="px-5 py-3.5 text-xs text-slate-600" x-text="post.author_name || '—'"></td>
|
|
199
|
+
<td class="px-5 py-3.5">
|
|
200
|
+
<button
|
|
201
|
+
type="button"
|
|
202
|
+
:disabled="togglingId === post.id"
|
|
203
|
+
@click="toggleStatus(post)"
|
|
204
|
+
title="Click to toggle Published / Draft"
|
|
205
|
+
class="inline-flex px-2.5 py-0.5 rounded-full text-xs font-medium border cursor-pointer transition hover:opacity-80"
|
|
206
|
+
:class="post.status === 'published' ? 'bg-emerald-50 text-emerald-700 border-emerald-200' : 'bg-amber-50 text-amber-700 border-amber-200'"
|
|
207
|
+
x-text="post.status"
|
|
208
|
+
></button>
|
|
209
|
+
</td>
|
|
210
|
+
<td class="px-5 py-3.5 text-xs text-slate-500" x-text="formatDate(post.updated_at)"></td>
|
|
211
|
+
<td class="px-5 py-3.5 text-right whitespace-nowrap">
|
|
212
|
+
<div class="inline-flex items-center gap-2">
|
|
213
|
+
<a x-show="post.status === 'published'" :href="'/post/' + post.slug" target="_blank" rel="noopener" class="text-xs font-medium text-slate-500 hover:text-slate-900">View</a>
|
|
214
|
+
<a :href="'/admin/posts/' + post.id + '/edit'" class="text-xs font-medium text-blue-600 hover:underline">Edit</a>
|
|
215
|
+
<button x-show="confirmDeleteId !== post.id" type="button" @click="confirmDeleteId = post.id" class="text-xs font-medium text-red-600 hover:underline">Delete</button>
|
|
216
|
+
<span x-show="confirmDeleteId === post.id" class="inline-flex items-center gap-1">
|
|
217
|
+
<button type="button" @click="deletePost(post.id)" class="px-2 py-0.5 rounded bg-red-600 text-white text-xs font-medium">Confirm</button>
|
|
218
|
+
<button type="button" @click="confirmDeleteId = null" class="px-2 py-0.5 rounded bg-slate-100 text-slate-600 text-xs font-medium">Cancel</button>
|
|
219
|
+
</span>
|
|
220
|
+
</div>
|
|
221
|
+
</td>
|
|
222
|
+
</tr>
|
|
223
|
+
</template>
|
|
224
|
+
</tbody>
|
|
225
|
+
</table>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Render the Post Create/Edit view (/admin/posts/new & /admin/posts/:id/edit) with Tiptap rich text editor.
|
|
234
|
+
*/
|
|
235
|
+
export function renderPostEditorPage(
|
|
236
|
+
post: EditablePost,
|
|
237
|
+
categories: PostsPageCategory[],
|
|
238
|
+
): string {
|
|
239
|
+
const seed = serializeSafeJson({ post, categories, postId: post.id ?? null });
|
|
240
|
+
const isEdit = Boolean(post.id);
|
|
241
|
+
|
|
242
|
+
return `
|
|
243
|
+
<style>
|
|
244
|
+
.tiptap-prose p.is-editor-empty:first-child::before {
|
|
245
|
+
content: attr(data-placeholder);
|
|
246
|
+
float: left;
|
|
247
|
+
color: #94a3b8;
|
|
248
|
+
pointer-events: none;
|
|
249
|
+
height: 0;
|
|
250
|
+
}
|
|
251
|
+
.tiptap-prose > * + * { margin-top: 0.75em; }
|
|
252
|
+
.tiptap-prose h1 { font-size: 1.65rem; line-height: 1.25; font-weight: 700; color: #0f172a; margin-top: 1.1em; }
|
|
253
|
+
.tiptap-prose h2 { font-size: 1.35rem; line-height: 1.3; font-weight: 700; color: #0f172a; margin-top: 1em; }
|
|
254
|
+
.tiptap-prose h3 { font-size: 1.125rem; line-height: 1.35; font-weight: 600; color: #0f172a; margin-top: 0.9em; }
|
|
255
|
+
.tiptap-prose ul { list-style-type: disc; padding-left: 1.5rem; }
|
|
256
|
+
.tiptap-prose ol { list-style-type: decimal; padding-left: 1.5rem; }
|
|
257
|
+
.tiptap-prose li > p { margin: 0.15em 0; }
|
|
258
|
+
.tiptap-prose blockquote {
|
|
259
|
+
border-left: 3px solid #2563eb;
|
|
260
|
+
padding: 0.4rem 0.9rem;
|
|
261
|
+
background: #f8fafc;
|
|
262
|
+
color: #475569;
|
|
263
|
+
border-radius: 0 0.5rem 0.5rem 0;
|
|
264
|
+
}
|
|
265
|
+
.tiptap-prose code {
|
|
266
|
+
background: #f1f5f9;
|
|
267
|
+
color: #0f172a;
|
|
268
|
+
padding: 0.15rem 0.35rem;
|
|
269
|
+
border-radius: 0.35rem;
|
|
270
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
271
|
+
font-size: 0.85em;
|
|
272
|
+
}
|
|
273
|
+
.tiptap-prose pre {
|
|
274
|
+
background: #0f172a;
|
|
275
|
+
color: #e2e8f0;
|
|
276
|
+
padding: 0.9rem 1rem;
|
|
277
|
+
border-radius: 0.65rem;
|
|
278
|
+
overflow-x: auto;
|
|
279
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
280
|
+
font-size: 0.82rem;
|
|
281
|
+
}
|
|
282
|
+
.tiptap-prose pre code { background: transparent; color: inherit; padding: 0; font-size: inherit; }
|
|
283
|
+
.tiptap-prose hr { border: 0; border-top: 1px solid #e2e8f0; margin: 1.25rem 0; }
|
|
284
|
+
.tiptap-prose a { color: #2563eb; text-decoration: underline; }
|
|
285
|
+
.tiptap-prose img { max-width: 100%; max-height: 380px; border-radius: 0.65rem; border: 1px solid #e2e8f0; object-fit: cover; }
|
|
286
|
+
.tiptap-prose img.ProseMirror-selectednode { outline: 2px solid #2563eb; outline-offset: 2px; }
|
|
287
|
+
</style>
|
|
288
|
+
<script id="post-editor-seed" type="application/json">${seed}</script>
|
|
289
|
+
<script src="/admin/assets/tiptap-editor.js"></script>
|
|
290
|
+
<script>
|
|
291
|
+
document.addEventListener("alpine:init", () => {
|
|
292
|
+
Alpine.data("postEditor", () => ({
|
|
293
|
+
isEdit: ${isEdit ? "true" : "false"},
|
|
294
|
+
postId: null,
|
|
295
|
+
slugEdited: ${isEdit ? "true" : "false"},
|
|
296
|
+
editorTab: "write",
|
|
297
|
+
editorReady: false,
|
|
298
|
+
tiptap: null,
|
|
299
|
+
plainText: "",
|
|
300
|
+
linkOpen: false,
|
|
301
|
+
linkUrl: "",
|
|
302
|
+
toolbarState: {
|
|
303
|
+
bold: false,
|
|
304
|
+
italic: false,
|
|
305
|
+
underline: false,
|
|
306
|
+
strike: false,
|
|
307
|
+
code: false,
|
|
308
|
+
paragraph: true,
|
|
309
|
+
heading1: false,
|
|
310
|
+
heading2: false,
|
|
311
|
+
heading3: false,
|
|
312
|
+
bulletList: false,
|
|
313
|
+
orderedList: false,
|
|
314
|
+
blockquote: false,
|
|
315
|
+
codeBlock: false,
|
|
316
|
+
link: false,
|
|
317
|
+
linkHref: "",
|
|
318
|
+
canUndo: false,
|
|
319
|
+
canRedo: false,
|
|
320
|
+
},
|
|
321
|
+
categories: [],
|
|
322
|
+
form: {
|
|
323
|
+
title: "",
|
|
324
|
+
slug: "",
|
|
325
|
+
content: "",
|
|
326
|
+
excerpt: "",
|
|
327
|
+
featured_image: "",
|
|
328
|
+
category_id: "",
|
|
329
|
+
meta_title: "",
|
|
330
|
+
meta_description: "",
|
|
331
|
+
status: "draft"
|
|
332
|
+
},
|
|
333
|
+
errors: [],
|
|
334
|
+
saving: false,
|
|
335
|
+
|
|
336
|
+
init() {
|
|
337
|
+
const el = document.getElementById("post-editor-seed");
|
|
338
|
+
const seed = el ? JSON.parse(el.textContent || "{}") : {};
|
|
339
|
+
this.categories = Array.isArray(seed.categories) ? seed.categories : [];
|
|
340
|
+
this.postId = seed.postId || null;
|
|
341
|
+
const p = seed.post || {};
|
|
342
|
+
this.form = {
|
|
343
|
+
title: p.title || "",
|
|
344
|
+
slug: p.slug || "",
|
|
345
|
+
content: p.content || "",
|
|
346
|
+
excerpt: p.excerpt || "",
|
|
347
|
+
featured_image: p.featured_image || "",
|
|
348
|
+
category_id: p.category_id ? String(p.category_id) : "",
|
|
349
|
+
meta_title: p.meta_title || "",
|
|
350
|
+
meta_description: p.meta_description || "",
|
|
351
|
+
status: p.status || "draft"
|
|
352
|
+
};
|
|
353
|
+
this.plainText = this.extractPlainText(this.form.content);
|
|
354
|
+
this.$nextTick(() => this.mountTiptap());
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
destroy() {
|
|
358
|
+
if (this.tiptap) {
|
|
359
|
+
this.tiptap.destroy();
|
|
360
|
+
this.tiptap = null;
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
|
|
364
|
+
mountTiptap() {
|
|
365
|
+
if (this.tiptap || !this.$refs.tiptapHost || !window.CmsTiptap) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
this.tiptap = window.CmsTiptap.createEditor({
|
|
369
|
+
element: this.$refs.tiptapHost,
|
|
370
|
+
content: this.form.content || "",
|
|
371
|
+
placeholder: "Write your post content with rich headings, formatting, links, and images...",
|
|
372
|
+
onUpdate: ({ html, text }) => {
|
|
373
|
+
this.form.content = html;
|
|
374
|
+
this.plainText = text;
|
|
375
|
+
},
|
|
376
|
+
onStateChange: (state) => {
|
|
377
|
+
this.toolbarState = state;
|
|
378
|
+
},
|
|
379
|
+
});
|
|
380
|
+
this.plainText = this.tiptap.getText();
|
|
381
|
+
this.editorReady = true;
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
extractPlainText(html) {
|
|
385
|
+
const doc = new DOMParser().parseFromString(String(html || ""), "text/html");
|
|
386
|
+
return (doc.body?.textContent || "").trim();
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
switchTab(nextTab) {
|
|
390
|
+
if (nextTab === this.editorTab) return;
|
|
391
|
+
if (this.editorTab === "write" && this.tiptap) {
|
|
392
|
+
this.form.content = this.tiptap.getHTML();
|
|
393
|
+
this.plainText = this.tiptap.getText();
|
|
394
|
+
} else if (this.editorTab === "html") {
|
|
395
|
+
this.plainText = this.extractPlainText(this.form.content);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
this.editorTab = nextTab;
|
|
399
|
+
|
|
400
|
+
if (nextTab === "write" && this.tiptap) {
|
|
401
|
+
this.tiptap.setContent(this.form.content || "");
|
|
402
|
+
this.plainText = this.tiptap.getText();
|
|
403
|
+
this.$nextTick(() => this.tiptap?.focus());
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
get wordCount() {
|
|
408
|
+
const text = (this.editorTab === "html" ? this.extractPlainText(this.form.content) : this.plainText).trim();
|
|
409
|
+
return text ? text.split(/\\s+/).length : 0;
|
|
410
|
+
},
|
|
411
|
+
|
|
412
|
+
get readingMinutes() {
|
|
413
|
+
return Math.max(1, Math.ceil(this.wordCount / 200));
|
|
414
|
+
},
|
|
415
|
+
|
|
416
|
+
get previewHtml() {
|
|
417
|
+
const raw = this.editorTab === "write" && this.tiptap ? this.tiptap.getHTML() : (this.form.content || "");
|
|
418
|
+
if (!raw.trim()) {
|
|
419
|
+
return "<p class='text-slate-400 italic'>Nothing to preview yet.</p>";
|
|
420
|
+
}
|
|
421
|
+
const doc = new DOMParser().parseFromString(raw, "text/html");
|
|
422
|
+
const blocked = doc.body.querySelectorAll("script,style,iframe,object,embed,svg,math,form");
|
|
423
|
+
blocked.forEach((node) => node.remove());
|
|
424
|
+
const all = doc.body.querySelectorAll("*");
|
|
425
|
+
all.forEach((el) => {
|
|
426
|
+
for (const attr of Array.from(el.attributes)) {
|
|
427
|
+
const name = attr.name.toLowerCase();
|
|
428
|
+
if (name.startsWith("on") || name === "style") {
|
|
429
|
+
el.removeAttribute(attr.name);
|
|
430
|
+
} else if ((name === "href" || name === "src") && /^\\s*(javascript|data|vbscript):/i.test(attr.value)) {
|
|
431
|
+
el.removeAttribute(attr.name);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
return doc.body.innerHTML;
|
|
436
|
+
},
|
|
437
|
+
|
|
438
|
+
slugify(v) {
|
|
439
|
+
return String(v || "").toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
440
|
+
},
|
|
441
|
+
|
|
442
|
+
onTitleInput() {
|
|
443
|
+
if (!this.isEdit && !this.slugEdited) {
|
|
444
|
+
this.form.slug = this.slugify(this.form.title);
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
|
|
448
|
+
toggleLinkBar() {
|
|
449
|
+
this.linkOpen = !this.linkOpen;
|
|
450
|
+
if (this.linkOpen) {
|
|
451
|
+
this.linkUrl = this.toolbarState.linkHref || "https://";
|
|
452
|
+
}
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
applyLink() {
|
|
456
|
+
if (!this.tiptap) return;
|
|
457
|
+
this.tiptap.setLink(this.linkUrl);
|
|
458
|
+
this.linkOpen = false;
|
|
459
|
+
},
|
|
460
|
+
|
|
461
|
+
removeLink() {
|
|
462
|
+
if (!this.tiptap) return;
|
|
463
|
+
this.tiptap.unsetLink();
|
|
464
|
+
this.linkUrl = "";
|
|
465
|
+
this.linkOpen = false;
|
|
466
|
+
},
|
|
467
|
+
|
|
468
|
+
insertImageFromMedia() {
|
|
469
|
+
window.openMediaPicker((url, file) => {
|
|
470
|
+
const alt = (file && (file.alt_text || file.original_name)) || "image";
|
|
471
|
+
if (this.editorTab !== "write") {
|
|
472
|
+
this.switchTab("write");
|
|
473
|
+
}
|
|
474
|
+
if (this.tiptap) {
|
|
475
|
+
this.tiptap.insertImage(url, alt);
|
|
476
|
+
this.form.content = this.tiptap.getHTML();
|
|
477
|
+
} else {
|
|
478
|
+
this.form.content = (this.form.content || "") + '<p><img src="' + url + '" alt="' + alt.replace(/"/g, "") + '"></p>';
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
},
|
|
482
|
+
|
|
483
|
+
pickFeaturedImage() {
|
|
484
|
+
window.openMediaPicker((url) => {
|
|
485
|
+
this.form.featured_image = url;
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
async save() {
|
|
490
|
+
this.saving = true;
|
|
491
|
+
this.errors = [];
|
|
492
|
+
if (this.editorTab === "write" && this.tiptap) {
|
|
493
|
+
this.form.content = this.tiptap.getHTML();
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const payload = {
|
|
497
|
+
title: this.form.title,
|
|
498
|
+
slug: this.form.slug,
|
|
499
|
+
content: this.form.content,
|
|
500
|
+
excerpt: this.form.excerpt,
|
|
501
|
+
featured_image: this.form.featured_image,
|
|
502
|
+
category_id: this.form.category_id ? Number(this.form.category_id) : null,
|
|
503
|
+
meta_title: this.form.meta_title,
|
|
504
|
+
meta_description: this.form.meta_description,
|
|
505
|
+
status: this.form.status
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
const url = this.isEdit ? "/api/admin/posts/" + this.postId : "/api/admin/posts";
|
|
509
|
+
const method = this.isEdit ? "PUT" : "POST";
|
|
510
|
+
|
|
511
|
+
try {
|
|
512
|
+
const res = await fetch(url, {
|
|
513
|
+
method,
|
|
514
|
+
headers: { "content-type": "application/json" },
|
|
515
|
+
body: JSON.stringify(payload)
|
|
516
|
+
});
|
|
517
|
+
const data = await res.json();
|
|
518
|
+
if (!res.ok || !data.success) {
|
|
519
|
+
this.errors = Array.isArray(data.errors) ? data.errors : ["Failed to save post."];
|
|
520
|
+
window.cmsToast("error", this.errors[0]);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
if (data.post && typeof data.post.content === "string") {
|
|
525
|
+
this.form.content = data.post.content;
|
|
526
|
+
}
|
|
527
|
+
window.cmsToast("success", this.isEdit ? "Post updated." : "Post created.");
|
|
528
|
+
if (!this.isEdit && data.post && data.post.id) {
|
|
529
|
+
window.location.href = "/admin/posts/" + data.post.id + "/edit";
|
|
530
|
+
}
|
|
531
|
+
} catch {
|
|
532
|
+
this.errors = ["Network error while saving post."];
|
|
533
|
+
} finally {
|
|
534
|
+
this.saving = false;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}));
|
|
538
|
+
});
|
|
539
|
+
</script>
|
|
540
|
+
|
|
541
|
+
<div x-data="postEditor" class="space-y-5">
|
|
542
|
+
<div class="flex items-center justify-between gap-3">
|
|
543
|
+
<a href="/admin/posts" class="inline-flex items-center gap-1.5 text-sm font-medium text-slate-600 hover:text-slate-900">
|
|
544
|
+
<i data-lucide="arrow-left" class="w-4 h-4"></i>
|
|
545
|
+
Back to Posts
|
|
546
|
+
</a>
|
|
547
|
+
<div class="flex items-center gap-2">
|
|
548
|
+
<a x-show="isEdit && form.status === 'published'" :href="'/post/' + form.slug" target="_blank" rel="noopener" class="px-3 py-2 rounded-lg border border-slate-300 bg-white text-xs font-medium text-slate-700 hover:bg-slate-50">
|
|
549
|
+
View Published Post →
|
|
550
|
+
</a>
|
|
551
|
+
<button
|
|
552
|
+
type="button"
|
|
553
|
+
@click="save()"
|
|
554
|
+
:disabled="saving"
|
|
555
|
+
class="px-4 py-2 rounded-lg bg-blue-600 text-white text-sm font-medium hover:bg-blue-700 disabled:opacity-50 transition"
|
|
556
|
+
x-text="saving ? 'Saving...' : (isEdit ? 'Update Post' : 'Create Post')"
|
|
557
|
+
></button>
|
|
558
|
+
</div>
|
|
559
|
+
</div>
|
|
560
|
+
|
|
561
|
+
<div x-show="errors.length > 0" x-cloak class="rounded-xl bg-red-50 border border-red-200 p-4 text-xs text-red-700 space-y-1">
|
|
562
|
+
<template x-for="(err, idx) in errors" :key="idx">
|
|
563
|
+
<p x-text="err"></p>
|
|
564
|
+
</template>
|
|
565
|
+
</div>
|
|
566
|
+
|
|
567
|
+
<div class="grid grid-cols-1 lg:grid-cols-12 gap-6 items-start">
|
|
568
|
+
<!-- Main Content Column -->
|
|
569
|
+
<div class="lg:col-span-8 space-y-5">
|
|
570
|
+
<div class="bg-white rounded-xl border border-slate-200 shadow-sm p-5 space-y-4">
|
|
571
|
+
<div>
|
|
572
|
+
<label for="editor-title" class="block text-xs font-semibold text-slate-700 mb-1">Title</label>
|
|
573
|
+
<input
|
|
574
|
+
id="editor-title"
|
|
575
|
+
type="text"
|
|
576
|
+
x-model="form.title"
|
|
577
|
+
@input="onTitleInput()"
|
|
578
|
+
placeholder="Post title"
|
|
579
|
+
class="w-full rounded-lg border border-slate-300 px-3.5 py-2.5 text-base font-medium focus:border-blue-500 focus:outline-none"
|
|
580
|
+
>
|
|
581
|
+
</div>
|
|
582
|
+
|
|
583
|
+
<div>
|
|
584
|
+
<label for="editor-slug" class="block text-xs font-semibold text-slate-700 mb-1">Slug</label>
|
|
585
|
+
<input
|
|
586
|
+
id="editor-slug"
|
|
587
|
+
type="text"
|
|
588
|
+
x-model="form.slug"
|
|
589
|
+
@input="slugEdited = true"
|
|
590
|
+
placeholder="post-url-slug"
|
|
591
|
+
class="w-full rounded-lg border border-slate-300 px-3.5 py-2 font-mono text-sm focus:border-blue-500 focus:outline-none"
|
|
592
|
+
>
|
|
593
|
+
</div>
|
|
594
|
+
|
|
595
|
+
<!-- Tiptap Rich Text Editor -->
|
|
596
|
+
<div class="space-y-2">
|
|
597
|
+
<div class="flex flex-wrap items-center justify-between gap-2">
|
|
598
|
+
<div class="flex items-center gap-1.5">
|
|
599
|
+
<button type="button" @click="switchTab('write')" :class="editorTab === 'write' ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-700 hover:bg-slate-200'" class="px-2.5 py-1 rounded-md text-xs font-medium transition">Visual Editor</button>
|
|
600
|
+
<button type="button" @click="switchTab('html')" :class="editorTab === 'html' ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-700 hover:bg-slate-200'" class="px-2.5 py-1 rounded-md text-xs font-medium transition">HTML Source</button>
|
|
601
|
+
<button type="button" @click="switchTab('preview')" :class="editorTab === 'preview' ? 'bg-slate-900 text-white' : 'bg-slate-100 text-slate-700 hover:bg-slate-200'" class="px-2.5 py-1 rounded-md text-xs font-medium transition">Preview</button>
|
|
602
|
+
</div>
|
|
603
|
+
<div class="flex items-center gap-2 text-xs text-slate-500">
|
|
604
|
+
<span class="px-2 py-0.5 rounded bg-blue-50 text-blue-700 font-medium">Tiptap WYSIWYG</span>
|
|
605
|
+
<span x-text="wordCount + ' words · ' + readingMinutes + ' min read'"></span>
|
|
606
|
+
</div>
|
|
607
|
+
</div>
|
|
608
|
+
|
|
609
|
+
<div x-show="editorTab === 'write'" class="rounded-xl border border-slate-300 overflow-hidden bg-white focus-within:border-blue-500 focus-within:ring-2 focus-within:ring-blue-500/15 transition">
|
|
610
|
+
<!-- Formatting Toolbar -->
|
|
611
|
+
<div class="flex flex-wrap items-center gap-1 px-2.5 py-2 bg-slate-50 border-b border-slate-200">
|
|
612
|
+
<button type="button" @click="tiptap?.undo()" :disabled="!toolbarState.canUndo" title="Undo" class="px-2 py-1 rounded text-xs font-medium text-slate-700 hover:bg-slate-200 disabled:opacity-40">
|
|
613
|
+
<i data-lucide="undo-2" class="w-3.5 h-3.5"></i>
|
|
614
|
+
</button>
|
|
615
|
+
<button type="button" @click="tiptap?.redo()" :disabled="!toolbarState.canRedo" title="Redo" class="px-2 py-1 rounded text-xs font-medium text-slate-700 hover:bg-slate-200 disabled:opacity-40">
|
|
616
|
+
<i data-lucide="redo-2" class="w-3.5 h-3.5"></i>
|
|
617
|
+
</button>
|
|
618
|
+
|
|
619
|
+
<span class="w-px h-4 bg-slate-300 mx-1"></span>
|
|
620
|
+
|
|
621
|
+
<button type="button" @click="tiptap?.setParagraph()" :class="toolbarState.paragraph ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Paragraph" class="px-2 py-1 rounded text-xs font-medium">P</button>
|
|
622
|
+
<button type="button" @click="tiptap?.toggleHeading(1)" :class="toolbarState.heading1 ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Heading 1" class="px-2 py-1 rounded text-xs font-bold">H1</button>
|
|
623
|
+
<button type="button" @click="tiptap?.toggleHeading(2)" :class="toolbarState.heading2 ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Heading 2" class="px-2 py-1 rounded text-xs font-bold">H2</button>
|
|
624
|
+
<button type="button" @click="tiptap?.toggleHeading(3)" :class="toolbarState.heading3 ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Heading 3" class="px-2 py-1 rounded text-xs font-bold">H3</button>
|
|
625
|
+
|
|
626
|
+
<span class="w-px h-4 bg-slate-300 mx-1"></span>
|
|
627
|
+
|
|
628
|
+
<button type="button" @click="tiptap?.toggleBold()" :class="toolbarState.bold ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Bold" class="px-2 py-1 rounded text-xs font-bold">B</button>
|
|
629
|
+
<button type="button" @click="tiptap?.toggleItalic()" :class="toolbarState.italic ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Italic" class="px-2 py-1 rounded text-xs italic font-serif">I</button>
|
|
630
|
+
<button type="button" @click="tiptap?.toggleUnderline()" :class="toolbarState.underline ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Underline" class="px-2 py-1 rounded text-xs underline">U</button>
|
|
631
|
+
<button type="button" @click="tiptap?.toggleStrike()" :class="toolbarState.strike ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Strikethrough" class="px-2 py-1 rounded text-xs line-through">S</button>
|
|
632
|
+
<button type="button" @click="tiptap?.toggleCode()" :class="toolbarState.code ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Inline code" class="px-2 py-1 rounded text-xs font-mono"></></button>
|
|
633
|
+
|
|
634
|
+
<span class="w-px h-4 bg-slate-300 mx-1"></span>
|
|
635
|
+
|
|
636
|
+
<button type="button" @click="tiptap?.toggleBulletList()" :class="toolbarState.bulletList ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Bullet list" class="px-2 py-1 rounded text-xs font-medium">
|
|
637
|
+
<i data-lucide="list" class="w-3.5 h-3.5"></i>
|
|
638
|
+
</button>
|
|
639
|
+
<button type="button" @click="tiptap?.toggleOrderedList()" :class="toolbarState.orderedList ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Numbered list" class="px-2 py-1 rounded text-xs font-medium">
|
|
640
|
+
<i data-lucide="list-ordered" class="w-3.5 h-3.5"></i>
|
|
641
|
+
</button>
|
|
642
|
+
<button type="button" @click="tiptap?.toggleBlockquote()" :class="toolbarState.blockquote ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Quote" class="px-2 py-1 rounded text-xs font-medium">
|
|
643
|
+
<i data-lucide="quote" class="w-3.5 h-3.5"></i>
|
|
644
|
+
</button>
|
|
645
|
+
<button type="button" @click="tiptap?.toggleCodeBlock()" :class="toolbarState.codeBlock ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Code block" class="px-2 py-1 rounded text-xs font-mono">{ }</button>
|
|
646
|
+
<button type="button" @click="tiptap?.setHorizontalRule()" title="Divider line" class="px-2 py-1 rounded text-xs font-medium text-slate-700 hover:bg-slate-200">—</button>
|
|
647
|
+
|
|
648
|
+
<span class="w-px h-4 bg-slate-300 mx-1"></span>
|
|
649
|
+
|
|
650
|
+
<button type="button" @click="toggleLinkBar()" :class="toolbarState.link || linkOpen ? 'bg-slate-900 text-white' : 'text-slate-700 hover:bg-slate-200'" title="Insert or edit link" class="inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium">
|
|
651
|
+
<i data-lucide="link" class="w-3.5 h-3.5"></i>
|
|
652
|
+
<span>Link</span>
|
|
653
|
+
</button>
|
|
654
|
+
<button type="button" @click="insertImageFromMedia()" title="Insert image from Media Library" class="inline-flex items-center gap-1 px-2.5 py-1 rounded text-xs font-medium bg-blue-50 text-blue-700 hover:bg-blue-100">
|
|
655
|
+
<i data-lucide="image-plus" class="w-3.5 h-3.5"></i>
|
|
656
|
+
<span>Image</span>
|
|
657
|
+
</button>
|
|
658
|
+
<button type="button" @click="tiptap?.clearFormatting()" title="Clear formatting" class="px-2 py-1 rounded text-xs text-slate-500 hover:bg-slate-200">Clear</button>
|
|
659
|
+
</div>
|
|
660
|
+
|
|
661
|
+
<!-- Inline Link Popover Bar -->
|
|
662
|
+
<div x-show="linkOpen" x-cloak class="flex flex-wrap items-center gap-2 px-3 py-2 bg-blue-50/70 border-b border-blue-200">
|
|
663
|
+
<input
|
|
664
|
+
type="url"
|
|
665
|
+
x-model="linkUrl"
|
|
666
|
+
@keydown.enter.prevent="applyLink()"
|
|
667
|
+
placeholder="https://example.com"
|
|
668
|
+
class="flex-1 min-w-[200px] rounded-md border border-slate-300 bg-white px-2.5 py-1 text-xs focus:border-blue-500 focus:outline-none"
|
|
669
|
+
>
|
|
670
|
+
<button type="button" @click="applyLink()" class="px-2.5 py-1 rounded-md bg-blue-600 text-white text-xs font-medium hover:bg-blue-700">Apply</button>
|
|
671
|
+
<button x-show="toolbarState.link" type="button" @click="removeLink()" class="px-2.5 py-1 rounded-md bg-red-50 border border-red-200 text-red-700 text-xs font-medium hover:bg-red-100">Unlink</button>
|
|
672
|
+
<button type="button" @click="linkOpen = false" class="px-2 py-1 rounded-md text-xs text-slate-600 hover:bg-slate-200">Cancel</button>
|
|
673
|
+
</div>
|
|
674
|
+
|
|
675
|
+
<!-- Tiptap Mount Node -->
|
|
676
|
+
<div x-ref="tiptapHost" class="bg-white cursor-text"></div>
|
|
677
|
+
</div>
|
|
678
|
+
|
|
679
|
+
<!-- HTML Source Mode -->
|
|
680
|
+
<textarea
|
|
681
|
+
x-show="editorTab === 'html'"
|
|
682
|
+
x-cloak
|
|
683
|
+
rows="14"
|
|
684
|
+
x-model="form.content"
|
|
685
|
+
placeholder="<p>Write HTML post content...</p>"
|
|
686
|
+
class="w-full rounded-xl border border-slate-300 px-3.5 py-2.5 text-xs font-mono focus:border-blue-500 focus:outline-none"
|
|
687
|
+
></textarea>
|
|
688
|
+
|
|
689
|
+
<!-- Rendered Preview Mode -->
|
|
690
|
+
<div
|
|
691
|
+
x-show="editorTab === 'preview'"
|
|
692
|
+
x-cloak
|
|
693
|
+
x-html="previewHtml"
|
|
694
|
+
class="tiptap-prose min-h-[320px] rounded-xl border border-slate-200 bg-slate-50/70 p-5 text-sm text-slate-800"
|
|
695
|
+
></div>
|
|
696
|
+
</div>
|
|
697
|
+
|
|
698
|
+
<div>
|
|
699
|
+
<label for="editor-excerpt" class="block text-xs font-semibold text-slate-700 mb-1">Excerpt</label>
|
|
700
|
+
<textarea
|
|
701
|
+
id="editor-excerpt"
|
|
702
|
+
rows="3"
|
|
703
|
+
x-model="form.excerpt"
|
|
704
|
+
placeholder="Short summary for post listings..."
|
|
705
|
+
class="w-full rounded-lg border border-slate-300 px-3.5 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
706
|
+
></textarea>
|
|
707
|
+
</div>
|
|
708
|
+
</div>
|
|
709
|
+
|
|
710
|
+
<!-- SEO Settings -->
|
|
711
|
+
<div class="bg-white rounded-xl border border-slate-200 shadow-sm p-5 space-y-4">
|
|
712
|
+
<h3 class="text-sm font-semibold text-slate-900">SEO Metadata</h3>
|
|
713
|
+
<div>
|
|
714
|
+
<label for="editor-meta-title" class="block text-xs font-medium text-slate-700 mb-1">Meta Title</label>
|
|
715
|
+
<input
|
|
716
|
+
id="editor-meta-title"
|
|
717
|
+
type="text"
|
|
718
|
+
x-model="form.meta_title"
|
|
719
|
+
placeholder="Defaults to post title if blank"
|
|
720
|
+
class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
721
|
+
>
|
|
722
|
+
</div>
|
|
723
|
+
<div>
|
|
724
|
+
<label for="editor-meta-desc" class="block text-xs font-medium text-slate-700 mb-1">Meta Description</label>
|
|
725
|
+
<textarea
|
|
726
|
+
id="editor-meta-desc"
|
|
727
|
+
rows="2"
|
|
728
|
+
x-model="form.meta_description"
|
|
729
|
+
placeholder="Search engine description..."
|
|
730
|
+
class="w-full rounded-lg border border-slate-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
731
|
+
></textarea>
|
|
732
|
+
</div>
|
|
733
|
+
</div>
|
|
734
|
+
</div>
|
|
735
|
+
|
|
736
|
+
<!-- Sidebar Column -->
|
|
737
|
+
<div class="lg:col-span-4 space-y-5">
|
|
738
|
+
<div class="bg-white rounded-xl border border-slate-200 shadow-sm p-5 space-y-4">
|
|
739
|
+
<h3 class="text-sm font-semibold text-slate-900">Publish Settings</h3>
|
|
740
|
+
|
|
741
|
+
<div>
|
|
742
|
+
<label for="editor-status" class="block text-xs font-medium text-slate-700 mb-1">Status</label>
|
|
743
|
+
<select
|
|
744
|
+
id="editor-status"
|
|
745
|
+
x-model="form.status"
|
|
746
|
+
class="w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
747
|
+
>
|
|
748
|
+
<option value="draft">Draft</option>
|
|
749
|
+
<option value="published">Published</option>
|
|
750
|
+
</select>
|
|
751
|
+
</div>
|
|
752
|
+
|
|
753
|
+
<div>
|
|
754
|
+
<label for="editor-category" class="block text-xs font-medium text-slate-700 mb-1">Category</label>
|
|
755
|
+
<select
|
|
756
|
+
id="editor-category"
|
|
757
|
+
x-model="form.category_id"
|
|
758
|
+
class="w-full rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"
|
|
759
|
+
>
|
|
760
|
+
<option value="">Uncategorized</option>
|
|
761
|
+
<template x-for="cat in categories" :key="cat.id">
|
|
762
|
+
<option :value="String(cat.id)" :selected="form.category_id === String(cat.id)" x-text="cat.name"></option>
|
|
763
|
+
</template>
|
|
764
|
+
</select>
|
|
765
|
+
</div>
|
|
766
|
+
</div>
|
|
767
|
+
|
|
768
|
+
<div class="bg-white rounded-xl border border-slate-200 shadow-sm p-5 space-y-3">
|
|
769
|
+
<div class="flex items-center justify-between">
|
|
770
|
+
<h3 class="text-sm font-semibold text-slate-900">Featured Image</h3>
|
|
771
|
+
<button
|
|
772
|
+
type="button"
|
|
773
|
+
x-show="form.featured_image"
|
|
774
|
+
@click="form.featured_image = ''"
|
|
775
|
+
class="text-xs text-red-600 hover:underline"
|
|
776
|
+
>
|
|
777
|
+
Remove
|
|
778
|
+
</button>
|
|
779
|
+
</div>
|
|
780
|
+
|
|
781
|
+
<div x-show="form.featured_image" class="rounded-lg border border-slate-200 overflow-hidden bg-slate-50">
|
|
782
|
+
<img :src="form.featured_image" alt="Featured preview" class="w-full h-40 object-cover">
|
|
783
|
+
</div>
|
|
784
|
+
|
|
785
|
+
<input
|
|
786
|
+
type="text"
|
|
787
|
+
x-model="form.featured_image"
|
|
788
|
+
placeholder="/uploads/image.webp"
|
|
789
|
+
class="w-full rounded-lg border border-slate-300 px-3 py-2 font-mono text-xs focus:border-blue-500 focus:outline-none"
|
|
790
|
+
>
|
|
791
|
+
|
|
792
|
+
<button
|
|
793
|
+
type="button"
|
|
794
|
+
@click="pickFeaturedImage()"
|
|
795
|
+
class="w-full px-3.5 py-2 rounded-lg border border-slate-300 bg-slate-50 text-xs font-medium text-slate-800 hover:bg-slate-100 transition"
|
|
796
|
+
>
|
|
797
|
+
Select Featured Image
|
|
798
|
+
</button>
|
|
799
|
+
</div>
|
|
800
|
+
</div>
|
|
801
|
+
</div>
|
|
802
|
+
</div>
|
|
803
|
+
`;
|
|
804
|
+
}
|