@prenta/admin 2.16.1 → 2.16.3
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/CHANGELOG.md +12 -0
- package/dist/__tests__/fields/field-renderer-null.render.test.d.ts +2 -0
- package/dist/__tests__/fields/field-renderer-null.render.test.d.ts.map +1 -0
- package/dist/__tests__/fields/field-renderer-null.render.test.js +21 -0
- package/dist/__tests__/fields/field-renderer-null.render.test.js.map +1 -0
- package/dist/__tests__/lib/post-custom-fields.test.d.ts +2 -0
- package/dist/__tests__/lib/post-custom-fields.test.d.ts.map +1 -0
- package/dist/__tests__/lib/post-custom-fields.test.js +158 -0
- package/dist/__tests__/lib/post-custom-fields.test.js.map +1 -0
- package/dist/__tests__/lib/post-editor-custom-fields-api.test.d.ts +2 -0
- package/dist/__tests__/lib/post-editor-custom-fields-api.test.d.ts.map +1 -0
- package/dist/__tests__/lib/post-editor-custom-fields-api.test.js +104 -0
- package/dist/__tests__/lib/post-editor-custom-fields-api.test.js.map +1 -0
- package/dist/__tests__/lib/post-editor-custom-fields-undo.test.d.ts +2 -0
- package/dist/__tests__/lib/post-editor-custom-fields-undo.test.d.ts.map +1 -0
- package/dist/__tests__/lib/post-editor-custom-fields-undo.test.js +128 -0
- package/dist/__tests__/lib/post-editor-custom-fields-undo.test.js.map +1 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.d.ts +2 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.js +157 -0
- package/dist/__tests__/views/editor-top-bar-layout.render.test.js.map +1 -0
- package/dist/__tests__/views/post-tab-custom-fields.render.test.d.ts +2 -0
- package/dist/__tests__/views/post-tab-custom-fields.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/post-tab-custom-fields.render.test.js +164 -0
- package/dist/__tests__/views/post-tab-custom-fields.render.test.js.map +1 -0
- package/dist/components/BreakpointPicker.d.ts.map +1 -1
- package/dist/components/BreakpointPicker.js +2 -2
- package/dist/components/BreakpointPicker.js.map +1 -1
- package/dist/fields/FieldRenderer.d.ts.map +1 -1
- package/dist/fields/FieldRenderer.js +7 -1
- package/dist/fields/FieldRenderer.js.map +1 -1
- package/dist/lib/post-custom-fields.d.ts +28 -0
- package/dist/lib/post-custom-fields.d.ts.map +1 -0
- package/dist/lib/post-custom-fields.js +173 -0
- package/dist/lib/post-custom-fields.js.map +1 -0
- package/dist/lib/post-editor-service.d.ts +29 -0
- package/dist/lib/post-editor-service.d.ts.map +1 -1
- package/dist/lib/post-editor-service.js +53 -0
- package/dist/lib/post-editor-service.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/views/page-editor/EditorTopBar.d.ts.map +1 -1
- package/dist/views/page-editor/EditorTopBar.js +28 -17
- package/dist/views/page-editor/EditorTopBar.js.map +1 -1
- package/dist/views/post-editor/PostRowsField.d.ts +17 -0
- package/dist/views/post-editor/PostRowsField.d.ts.map +1 -0
- package/dist/views/post-editor/PostRowsField.js +29 -0
- package/dist/views/post-editor/PostRowsField.js.map +1 -0
- package/dist/views/post-editor/PostSectionEditor.d.ts.map +1 -1
- package/dist/views/post-editor/PostSectionEditor.js +16 -5
- package/dist/views/post-editor/PostSectionEditor.js.map +1 -1
- package/dist/views/post-editor/PostTab.d.ts +8 -5
- package/dist/views/post-editor/PostTab.d.ts.map +1 -1
- package/dist/views/post-editor/PostTab.js +53 -15
- package/dist/views/post-editor/PostTab.js.map +1 -1
- package/package.json +6 -6
- package/src/__tests__/fields/field-renderer-null.render.test.tsx +34 -0
- package/src/__tests__/lib/post-custom-fields.test.ts +170 -0
- package/src/__tests__/lib/post-editor-custom-fields-api.test.ts +129 -0
- package/src/__tests__/lib/post-editor-custom-fields-undo.test.ts +152 -0
- package/src/__tests__/views/editor-top-bar-layout.render.test.tsx +198 -0
- package/src/__tests__/views/post-tab-custom-fields.render.test.tsx +239 -0
- package/src/components/BreakpointPicker.tsx +7 -6
- package/src/fields/FieldRenderer.tsx +6 -1
- package/src/lib/post-custom-fields.ts +191 -0
- package/src/lib/post-editor-service.ts +71 -0
- package/src/styles/responsive.css +44 -18
- package/src/views/page-editor/EditorTopBar.tsx +109 -65
- package/src/views/post-editor/PostRowsField.tsx +110 -0
- package/src/views/post-editor/PostSectionEditor.tsx +26 -7
- package/src/views/post-editor/PostTab.tsx +72 -6
|
@@ -97,6 +97,19 @@ export interface EditorPost {
|
|
|
97
97
|
seoDescription: string
|
|
98
98
|
publishedAt: string | null
|
|
99
99
|
updatedAt: string | null
|
|
100
|
+
/**
|
|
101
|
+
* Stored values of every `data` key the editor does not manage itself, as
|
|
102
|
+
* loaded. The Post tab reads the post type's own fields (a case study's
|
|
103
|
+
* client name, challenge, key metrics) from here.
|
|
104
|
+
*/
|
|
105
|
+
customFields?: Record<string, unknown>
|
|
106
|
+
/**
|
|
107
|
+
* Custom field values changed since the post was loaded. Only these are
|
|
108
|
+
* written back: the server merges a save onto the stored document, so a key
|
|
109
|
+
* that is not sent keeps its value, and a loaded copy of a key the SEO tab
|
|
110
|
+
* owns is never written back over a newer one.
|
|
111
|
+
*/
|
|
112
|
+
customFieldEdits?: Record<string, unknown>
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
export interface EditorPostTemplate {
|
|
@@ -139,6 +152,57 @@ const REQUIRED_POST_FIELDS = [
|
|
|
139
152
|
'metaDescription',
|
|
140
153
|
] as const
|
|
141
154
|
|
|
155
|
+
/**
|
|
156
|
+
* `data` keys the editor reads into its own `EditorPost` properties. Anything
|
|
157
|
+
* else on the document is a custom field value.
|
|
158
|
+
*/
|
|
159
|
+
const EDITOR_DATA_KEYS: ReadonlySet<string> = new Set(['title', 'slug', ...REQUIRED_POST_FIELDS])
|
|
160
|
+
|
|
161
|
+
function customFieldValues(data: Record<string, unknown>): Record<string, unknown> {
|
|
162
|
+
const out: Record<string, unknown> = {}
|
|
163
|
+
for (const [key, value] of Object.entries(data)) {
|
|
164
|
+
if (!EDITOR_DATA_KEYS.has(key)) out[key] = value
|
|
165
|
+
}
|
|
166
|
+
return out
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The value the Post tab shows for a custom field: the pending edit, else the stored value. */
|
|
170
|
+
export function customFieldValue(post: EditorPost, name: string): unknown {
|
|
171
|
+
const edits = post.customFieldEdits
|
|
172
|
+
if (edits && Object.prototype.hasOwnProperty.call(edits, name)) return edits[name]
|
|
173
|
+
return post.customFields?.[name]
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Re-express a post's custom field values against what the server last
|
|
178
|
+
* stored. Undo and redo restore an older snapshot whose pending edits were
|
|
179
|
+
* taken against an older saved state; since only edits are written, a value
|
|
180
|
+
* the snapshot merely "has" would never reach the server. After this, every
|
|
181
|
+
* custom value that differs from `saved` is a pending edit again.
|
|
182
|
+
*/
|
|
183
|
+
export function rebaseCustomFieldEdits(
|
|
184
|
+
post: EditorPost,
|
|
185
|
+
saved: EditorPost | null,
|
|
186
|
+
/**
|
|
187
|
+
* The fields the Post tab edits. Every other stored key (the SEO tab's
|
|
188
|
+
* focus keyword, canonical, …) keeps its latest saved value: an old
|
|
189
|
+
* snapshot's copy of it must never become a pending edit.
|
|
190
|
+
*/
|
|
191
|
+
fieldNames: readonly string[],
|
|
192
|
+
): EditorPost {
|
|
193
|
+
const stored = saved?.customFields ?? {}
|
|
194
|
+
const edits: Record<string, unknown> = {}
|
|
195
|
+
for (const name of fieldNames) {
|
|
196
|
+
const wanted = customFieldValue(post, name)
|
|
197
|
+
if (JSON.stringify(wanted ?? null) !== JSON.stringify(stored[name] ?? null)) {
|
|
198
|
+
// `null` clears a key the snapshot no longer has; `undefined` would be
|
|
199
|
+
// dropped from the request and leave the stored value in place.
|
|
200
|
+
edits[name] = wanted === undefined ? null : wanted
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { ...post, customFields: stored, customFieldEdits: edits }
|
|
204
|
+
}
|
|
205
|
+
|
|
142
206
|
export function missingPostFields(config: unknown, postType: string): string[] {
|
|
143
207
|
return missingCollectionFields(config, postType, REQUIRED_POST_FIELDS)
|
|
144
208
|
}
|
|
@@ -321,6 +385,8 @@ function rowToEditorPost(postType: string, doc: DocumentApiRow): EditorPost {
|
|
|
321
385
|
seoDescription: dataStr(data, 'metaDescription'),
|
|
322
386
|
publishedAt: doc.publishedAt ?? null,
|
|
323
387
|
updatedAt: doc.updatedAt ?? null,
|
|
388
|
+
customFields: customFieldValues(data),
|
|
389
|
+
customFieldEdits: {},
|
|
324
390
|
}
|
|
325
391
|
}
|
|
326
392
|
|
|
@@ -419,6 +485,9 @@ function stripUnmanagedMarker(section: PageSection): Omit<PageSection, 'unmanage
|
|
|
419
485
|
|
|
420
486
|
function toWriteBody(post: EditorPost, extra?: Record<string, unknown>): string {
|
|
421
487
|
const payload: PostWritePayload & Record<string, unknown> = {
|
|
488
|
+
// Custom field edits go first so they can never replace a key the editor
|
|
489
|
+
// owns.
|
|
490
|
+
...post.customFieldEdits,
|
|
422
491
|
title: post.title,
|
|
423
492
|
slug: post.slug,
|
|
424
493
|
excerpt: post.excerpt,
|
|
@@ -515,5 +584,7 @@ export async function emptyPostFromTemplate(postType: string): Promise<EditorPos
|
|
|
515
584
|
seoDescription: '',
|
|
516
585
|
publishedAt: null,
|
|
517
586
|
updatedAt: null,
|
|
587
|
+
customFields: {},
|
|
588
|
+
customFieldEdits: {},
|
|
518
589
|
}
|
|
519
590
|
}
|
|
@@ -598,25 +598,50 @@
|
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
-
/* ── Editor header
|
|
601
|
+
/* ── Editor header: collapse by the bar's own width, then wrap ─────── */
|
|
602
602
|
/*
|
|
603
|
-
* The
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* actions
|
|
603
|
+
* The bar's room depends on the sidebar and on which review actions are
|
|
604
|
+
* showing, not only on the viewport: a 1280px window with the sidebar open
|
|
605
|
+
* leaves it about 1050px. So the bar is a size container, and below 1360px of
|
|
606
|
+
* its own width the secondary actions (Share, Schedule, Request changes) drop
|
|
607
|
+
* to icons and the canvas-width picker to its two-letter form. Each of those
|
|
608
|
+
* keeps an aria-label and a title.
|
|
609
|
+
*
|
|
610
|
+
* The bar also wraps (classes in EditorTopBar): once the actions no longer fit
|
|
611
|
+
* beside a readable title they take a second line, at any width. The left
|
|
612
|
+
* group sets its own minimum width there, so nothing here may reset it.
|
|
607
613
|
*/
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
614
|
+
.prenta-admin .prenta-editor-header {
|
|
615
|
+
container: editor-header / inline-size;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.prenta-admin .prenta-editor-abbr {
|
|
619
|
+
display: none;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/*
|
|
623
|
+
* The breadcrumb clips its overflow so a long title cannot spill over the
|
|
624
|
+
* status label. That would also clip the focus ring of the back button, which
|
|
625
|
+
* sits flush against the edge, so its ring is drawn inside the box.
|
|
626
|
+
*/
|
|
627
|
+
.prenta-admin .prenta-editor-header nav button:focus-visible {
|
|
628
|
+
outline-offset: -2px;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
@container editor-header (max-width: 1360px) {
|
|
632
|
+
.prenta-admin .prenta-editor-header .prenta-editor-label {
|
|
633
|
+
display: none;
|
|
616
634
|
}
|
|
617
635
|
|
|
618
|
-
.prenta-admin .prenta-editor-header
|
|
619
|
-
|
|
636
|
+
.prenta-admin .prenta-editor-header .prenta-editor-abbr {
|
|
637
|
+
display: inline;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/* An icon-only action is a square, the size of the bar's icon buttons. */
|
|
641
|
+
.prenta-admin .prenta-editor-header .prenta-editor-collapsible {
|
|
642
|
+
width: 34px;
|
|
643
|
+
padding-left: 0;
|
|
644
|
+
padding-right: 0;
|
|
620
645
|
}
|
|
621
646
|
}
|
|
622
647
|
|
|
@@ -671,9 +696,9 @@
|
|
|
671
696
|
|
|
672
697
|
/* ── Mobile (≤460px) ──────────────────────────────────────────────── */
|
|
673
698
|
@media (max-width: 460px) {
|
|
674
|
-
/*
|
|
675
|
-
|
|
676
|
-
.prenta-admin .prenta-editor-header button {
|
|
699
|
+
/* Text actions share each wrapped line rather than leaving a ragged edge.
|
|
700
|
+
Icon buttons (anything with a touch target) keep their own size. */
|
|
701
|
+
.prenta-admin .prenta-editor-header button:not(.prenta-touch-target) {
|
|
677
702
|
flex: 1 1 auto;
|
|
678
703
|
justify-content: center;
|
|
679
704
|
}
|
|
@@ -686,6 +711,7 @@
|
|
|
686
711
|
}
|
|
687
712
|
|
|
688
713
|
.prenta-admin .prenta-editor-header {
|
|
714
|
+
min-height: 0;
|
|
689
715
|
padding-top: 4px;
|
|
690
716
|
padding-bottom: 4px;
|
|
691
717
|
}
|
|
@@ -9,12 +9,14 @@ import {
|
|
|
9
9
|
ExternalLink,
|
|
10
10
|
History,
|
|
11
11
|
Loader2,
|
|
12
|
+
MessageSquareWarning,
|
|
12
13
|
Redo2,
|
|
13
14
|
Settings2,
|
|
14
15
|
Share2,
|
|
15
16
|
TriangleAlert,
|
|
16
17
|
Undo2,
|
|
17
18
|
} from 'lucide-react'
|
|
19
|
+
import { Button } from '../../components/ui/Button.js'
|
|
18
20
|
import { EditorSeoScoreBadge } from '../../components/seo/EditorSeoScoreBadge.js'
|
|
19
21
|
import { BreakpointPicker } from '../../components/BreakpointPicker.js'
|
|
20
22
|
import { RequestChangesDialog } from '../../components/RequestChangesDialog.js'
|
|
@@ -35,6 +37,17 @@ import { type ViewportId } from './viewports.js'
|
|
|
35
37
|
import type { ThemeChromeMode } from '../../lib/theme-chrome.js'
|
|
36
38
|
import { ThemeChromeModeToggle } from './theme-chrome/ThemeChromeModeToggle.js'
|
|
37
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The shared Button stops pointer events while disabled, which also stops the
|
|
42
|
+
* browser showing its title. These actions use the title to say why they are
|
|
43
|
+
* disabled (not ready to publish, no site URL), so they keep the pointer.
|
|
44
|
+
*/
|
|
45
|
+
const DISABLED_WITH_REASON =
|
|
46
|
+
'disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:hover:border-bdr! disabled:hover:text-txt!'
|
|
47
|
+
/** The same for the filled primary action, whose hover is a brightness lift. */
|
|
48
|
+
const DISABLED_PRIMARY_WITH_REASON =
|
|
49
|
+
'disabled:pointer-events-auto! disabled:cursor-not-allowed disabled:hover:brightness-100!'
|
|
50
|
+
|
|
38
51
|
export type SaveState = 'idle' | 'saving' | 'saved' | 'error'
|
|
39
52
|
|
|
40
53
|
interface EditorTopBarProps {
|
|
@@ -219,37 +232,43 @@ export function EditorTopBar({
|
|
|
219
232
|
switch (workflow.primary) {
|
|
220
233
|
case 'submit':
|
|
221
234
|
primaryAction = (
|
|
222
|
-
<
|
|
235
|
+
<Button
|
|
223
236
|
type="button"
|
|
237
|
+
variant="primary"
|
|
224
238
|
onClick={onSubmitForReview}
|
|
239
|
+
className={DISABLED_PRIMARY_WITH_REASON}
|
|
225
240
|
disabled={submitBlocked}
|
|
226
241
|
title={submitTitle}
|
|
227
242
|
aria-disabled={submitBlocked}
|
|
228
|
-
|
|
243
|
+
leftIcon={
|
|
244
|
+
publishing ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : undefined
|
|
245
|
+
}
|
|
229
246
|
>
|
|
230
|
-
{publishing && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}
|
|
231
247
|
{SUBMIT_FOR_REVIEW_LABEL}
|
|
232
|
-
</
|
|
248
|
+
</Button>
|
|
233
249
|
)
|
|
234
250
|
break
|
|
235
251
|
case 'approve':
|
|
236
252
|
primaryAction = (
|
|
237
|
-
<
|
|
253
|
+
<Button
|
|
238
254
|
type="button"
|
|
255
|
+
variant="primary"
|
|
239
256
|
onClick={onApprove}
|
|
257
|
+
className={DISABLED_PRIMARY_WITH_REASON}
|
|
240
258
|
disabled={approveBlocked}
|
|
241
259
|
title={approveTitle}
|
|
242
260
|
aria-disabled={approveBlocked}
|
|
243
|
-
|
|
261
|
+
leftIcon={
|
|
262
|
+
publishing ? <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden /> : undefined
|
|
263
|
+
}
|
|
244
264
|
>
|
|
245
|
-
{publishing && <Loader2 className="h-3.5 w-3.5 animate-spin" aria-hidden />}
|
|
246
265
|
{APPROVE_LABEL}
|
|
247
|
-
</
|
|
266
|
+
</Button>
|
|
248
267
|
)
|
|
249
268
|
break
|
|
250
269
|
case 'waiting':
|
|
251
270
|
primaryAction = (
|
|
252
|
-
<span className="text-muted-foreground text-sm" aria-live="polite">
|
|
271
|
+
<span className="text-muted-foreground text-sm whitespace-nowrap" aria-live="polite">
|
|
253
272
|
{workflow.waitingLabel}
|
|
254
273
|
</span>
|
|
255
274
|
)
|
|
@@ -264,10 +283,18 @@ export function EditorTopBar({
|
|
|
264
283
|
}
|
|
265
284
|
|
|
266
285
|
return (
|
|
267
|
-
|
|
286
|
+
// The bar is a size container (responsive.css): its secondary actions drop
|
|
287
|
+
// their labels by the bar's own width, which the sidebar and the rail
|
|
288
|
+
// change independently of the viewport. When it is still too narrow the
|
|
289
|
+
// actions wrap to a second line: the left group's minimum width is its
|
|
290
|
+
// fixed parts plus a 5rem title, so the title is never squeezed to nothing.
|
|
291
|
+
<header className="prenta-editor-header bg-card border-border flex min-h-14 shrink-0 flex-wrap items-center justify-between gap-x-4 gap-y-2 border-b px-4 py-2">
|
|
268
292
|
{/* Breadcrumb + status */}
|
|
269
|
-
<div className="flex min-w-
|
|
270
|
-
<nav
|
|
293
|
+
<div className="flex min-w-min flex-[1_1_0%] items-center gap-2">
|
|
294
|
+
<nav
|
|
295
|
+
aria-label="Breadcrumb"
|
|
296
|
+
className="flex min-w-[5rem] flex-[0_1_auto] items-center gap-1.5 overflow-hidden text-sm"
|
|
297
|
+
>
|
|
271
298
|
<button
|
|
272
299
|
type="button"
|
|
273
300
|
onClick={onBack}
|
|
@@ -287,7 +314,10 @@ export function EditorTopBar({
|
|
|
287
314
|
{workflow.statusLabel}
|
|
288
315
|
</span>
|
|
289
316
|
{reviewNote ? (
|
|
290
|
-
<span
|
|
317
|
+
<span
|
|
318
|
+
className="text-muted-foreground max-w-[16rem] min-w-0 shrink truncate text-xs"
|
|
319
|
+
title={`${REVIEWER_NOTE_PREFIX} ${reviewNote}`}
|
|
320
|
+
>
|
|
291
321
|
{REVIEWER_NOTE_PREFIX} {reviewNote}
|
|
292
322
|
</span>
|
|
293
323
|
) : null}
|
|
@@ -306,33 +336,37 @@ export function EditorTopBar({
|
|
|
306
336
|
<SaveStatus state={saveState} dirty={dirty} />
|
|
307
337
|
{onUndo && onRedo && (
|
|
308
338
|
<span className="ml-1 inline-flex shrink-0 items-center">
|
|
309
|
-
<
|
|
339
|
+
<Button
|
|
310
340
|
type="button"
|
|
341
|
+
variant="icon"
|
|
342
|
+
size="icon-lg"
|
|
311
343
|
onClick={onUndo}
|
|
312
344
|
disabled={!canUndo}
|
|
313
345
|
aria-label="Undo"
|
|
314
346
|
title="Undo the last edit (Ctrl+Z or ⌘Z). Text fields keep their own undo."
|
|
315
|
-
className="prenta-touch-target
|
|
347
|
+
className="prenta-touch-target"
|
|
316
348
|
>
|
|
317
349
|
<Undo2 className="h-4 w-4" aria-hidden />
|
|
318
|
-
</
|
|
319
|
-
<
|
|
350
|
+
</Button>
|
|
351
|
+
<Button
|
|
320
352
|
type="button"
|
|
353
|
+
variant="icon"
|
|
354
|
+
size="icon-lg"
|
|
321
355
|
onClick={onRedo}
|
|
322
356
|
disabled={!canRedo}
|
|
323
357
|
aria-label="Redo"
|
|
324
358
|
title="Redo (Ctrl+Shift+Z, Ctrl+Y, or ⌘⇧Z)."
|
|
325
|
-
className="prenta-touch-target
|
|
359
|
+
className="prenta-touch-target"
|
|
326
360
|
>
|
|
327
361
|
<Redo2 className="h-4 w-4" aria-hidden />
|
|
328
|
-
</
|
|
362
|
+
</Button>
|
|
329
363
|
</span>
|
|
330
364
|
)}
|
|
331
365
|
{localeControl ? <span className="ml-1 inline-flex shrink-0">{localeControl}</span> : null}
|
|
332
366
|
</div>
|
|
333
367
|
|
|
334
368
|
{/* Right controls */}
|
|
335
|
-
<div className="flex items-center gap-2">
|
|
369
|
+
<div className="ml-auto flex max-w-full shrink-0 flex-wrap items-center justify-end gap-2">
|
|
336
370
|
<div className="hidden items-center gap-1.5 md:flex">
|
|
337
371
|
<BreakpointPicker value={viewport} onChange={onViewport} />
|
|
338
372
|
{zoom !== undefined && onZoom && (
|
|
@@ -343,19 +377,22 @@ export function EditorTopBar({
|
|
|
343
377
|
) : null}
|
|
344
378
|
</div>
|
|
345
379
|
|
|
346
|
-
<
|
|
380
|
+
<Button
|
|
347
381
|
type="button"
|
|
382
|
+
variant="icon"
|
|
383
|
+
size="icon-lg"
|
|
348
384
|
onClick={onOpenSettings}
|
|
349
385
|
aria-label={backLabel === 'Posts' ? 'Post settings' : 'Page settings'}
|
|
350
386
|
title={backLabel === 'Posts' ? 'Post settings' : 'Page settings'}
|
|
351
|
-
className="prenta-touch-target
|
|
387
|
+
className="prenta-touch-target"
|
|
352
388
|
>
|
|
353
389
|
<Settings2 className="h-4 w-4" aria-hidden />
|
|
354
|
-
</
|
|
390
|
+
</Button>
|
|
355
391
|
|
|
356
392
|
{onOpenSeo && (
|
|
357
|
-
<
|
|
393
|
+
<Button
|
|
358
394
|
type="button"
|
|
395
|
+
variant={seoOpen ? 'primary' : 'ghost'}
|
|
359
396
|
onClick={onOpenSeo}
|
|
360
397
|
aria-pressed={seoOpen}
|
|
361
398
|
aria-label={seoScore === undefined ? 'SEO' : `SEO, score ${seoScore} out of 100`}
|
|
@@ -364,40 +401,35 @@ export function EditorTopBar({
|
|
|
364
401
|
? 'SEO — meta tags, social preview, schema, and analysis.'
|
|
365
402
|
: `SEO — score ${seoScore}/100. Meta tags, social preview, schema, and analysis.`
|
|
366
403
|
}
|
|
367
|
-
className=
|
|
368
|
-
seoOpen
|
|
369
|
-
? 'bg-primary text-primary-foreground'
|
|
370
|
-
: 'text-muted-foreground hover:text-foreground hover:bg-accent'
|
|
371
|
-
}`}
|
|
404
|
+
className="px-2!"
|
|
372
405
|
>
|
|
373
406
|
{seoScore !== undefined && (
|
|
374
407
|
<EditorSeoScoreBadge score={seoScore} band={seoScoreBand} inverted={seoOpen} />
|
|
375
408
|
)}
|
|
376
409
|
<span className="hidden sm:inline">SEO</span>
|
|
377
|
-
</
|
|
410
|
+
</Button>
|
|
378
411
|
)}
|
|
379
412
|
|
|
380
413
|
{onHistory && (
|
|
381
|
-
<
|
|
414
|
+
<Button
|
|
382
415
|
type="button"
|
|
416
|
+
variant={historyOpen ? 'primary' : 'icon'}
|
|
417
|
+
size="icon-lg"
|
|
383
418
|
onClick={onHistory}
|
|
384
419
|
aria-pressed={historyOpen}
|
|
385
420
|
aria-label="Version history"
|
|
386
421
|
title={historyOpen ? 'Close version history' : 'Version history'}
|
|
387
|
-
className=
|
|
388
|
-
historyOpen
|
|
389
|
-
? 'bg-primary text-primary-foreground'
|
|
390
|
-
: 'text-muted-foreground hover:text-foreground hover:bg-accent'
|
|
391
|
-
}`}
|
|
422
|
+
className="prenta-touch-target"
|
|
392
423
|
>
|
|
393
424
|
<History className="h-4 w-4" aria-hidden />
|
|
394
|
-
</
|
|
425
|
+
</Button>
|
|
395
426
|
)}
|
|
396
427
|
|
|
397
428
|
{chrome && (
|
|
398
429
|
<>
|
|
399
|
-
<
|
|
430
|
+
<Button
|
|
400
431
|
type="button"
|
|
432
|
+
variant="secondary"
|
|
401
433
|
onClick={() => onViewOnSite?.(chrome.primaryIntent)}
|
|
402
434
|
disabled={!chrome.viewEnabled}
|
|
403
435
|
title={
|
|
@@ -406,22 +438,24 @@ export function EditorTopBar({
|
|
|
406
438
|
? 'Open the published page in a new tab.'
|
|
407
439
|
: 'Open the draft on your site in a new tab.')
|
|
408
440
|
}
|
|
409
|
-
className=
|
|
441
|
+
className={DISABLED_WITH_REASON}
|
|
442
|
+
leftIcon={<ExternalLink className="h-3.5 w-3.5" aria-hidden />}
|
|
410
443
|
>
|
|
411
|
-
<ExternalLink className="h-3.5 w-3.5" aria-hidden />
|
|
412
444
|
{chrome.primaryIntent === 'view-live' ? 'View live' : 'View site'}
|
|
413
|
-
</
|
|
445
|
+
</Button>
|
|
414
446
|
{chrome.showViewLive && (
|
|
415
447
|
<DropdownMenu.Root>
|
|
416
448
|
<DropdownMenu.Trigger asChild>
|
|
417
|
-
<
|
|
449
|
+
<Button
|
|
418
450
|
type="button"
|
|
451
|
+
variant="secondary"
|
|
452
|
+
size="icon-lg"
|
|
419
453
|
disabled={!chrome.viewEnabled}
|
|
420
454
|
aria-label="More view options"
|
|
421
|
-
className="prenta-touch-target
|
|
455
|
+
className="prenta-touch-target"
|
|
422
456
|
>
|
|
423
457
|
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
|
|
424
|
-
</
|
|
458
|
+
</Button>
|
|
425
459
|
</DropdownMenu.Trigger>
|
|
426
460
|
<DropdownMenu.Portal container={adminPortalContainer()}>
|
|
427
461
|
<DropdownMenu.Content
|
|
@@ -440,57 +474,64 @@ export function EditorTopBar({
|
|
|
440
474
|
</DropdownMenu.Root>
|
|
441
475
|
)}
|
|
442
476
|
{chrome.shareVisible && onShare && (
|
|
443
|
-
<
|
|
477
|
+
<Button
|
|
444
478
|
type="button"
|
|
479
|
+
variant="secondary"
|
|
445
480
|
onClick={onShare}
|
|
446
481
|
disabled={!chrome.viewEnabled}
|
|
482
|
+
aria-label="Share"
|
|
447
483
|
title={
|
|
448
484
|
chrome.viewDisabledReason ??
|
|
449
485
|
'Copy a link so someone can view this draft without signing in.'
|
|
450
486
|
}
|
|
451
|
-
className=
|
|
487
|
+
className={`prenta-editor-collapsible prenta-touch-target ${DISABLED_WITH_REASON}`}
|
|
488
|
+
leftIcon={<Share2 className="h-3.5 w-3.5" aria-hidden />}
|
|
452
489
|
>
|
|
453
|
-
<
|
|
454
|
-
|
|
455
|
-
</button>
|
|
490
|
+
<span className="prenta-editor-label">Share</span>
|
|
491
|
+
</Button>
|
|
456
492
|
)}
|
|
457
493
|
</>
|
|
458
494
|
)}
|
|
459
495
|
|
|
460
|
-
<
|
|
496
|
+
<Button
|
|
461
497
|
type="button"
|
|
498
|
+
variant="secondary"
|
|
462
499
|
onClick={onSaveDraft}
|
|
463
500
|
disabled={!canEdit || saveState === 'saving' || (!dirty && saveState !== 'error')}
|
|
464
|
-
className="border-border text-foreground hover:bg-accent rounded-lg border px-3 py-1.5 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
|
465
501
|
>
|
|
466
502
|
{saveState === 'saving' ? 'Saving…' : workflow.saveLabel}
|
|
467
|
-
</
|
|
503
|
+
</Button>
|
|
468
504
|
|
|
469
505
|
{onSchedule && workflow.showSchedule && (
|
|
470
|
-
<
|
|
506
|
+
<Button
|
|
471
507
|
type="button"
|
|
508
|
+
variant="secondary"
|
|
472
509
|
onClick={onSchedule}
|
|
473
510
|
disabled={scheduleBlocked}
|
|
474
511
|
title={scheduleTitle}
|
|
475
512
|
aria-label={scheduledAt ? 'Reschedule publish' : 'Schedule publish'}
|
|
476
|
-
className=
|
|
513
|
+
className={`prenta-editor-collapsible prenta-touch-target ${DISABLED_WITH_REASON}`}
|
|
514
|
+
leftIcon={<Calendar className="h-3.5 w-3.5" aria-hidden />}
|
|
477
515
|
>
|
|
478
|
-
<
|
|
479
|
-
|
|
480
|
-
</button>
|
|
516
|
+
<span className="prenta-editor-label">{scheduledAt ? 'Reschedule' : 'Schedule'}</span>
|
|
517
|
+
</Button>
|
|
481
518
|
)}
|
|
482
519
|
|
|
483
520
|
{primaryAction}
|
|
484
521
|
|
|
485
522
|
{workflow.showRequestChanges && (
|
|
486
|
-
<
|
|
523
|
+
<Button
|
|
487
524
|
type="button"
|
|
525
|
+
variant="secondary"
|
|
488
526
|
onClick={() => setRequestChangesOpen(true)}
|
|
489
527
|
disabled={requestChangesBlocked}
|
|
490
|
-
|
|
528
|
+
aria-label={REQUEST_CHANGES_LABEL}
|
|
529
|
+
title={REQUEST_CHANGES_LABEL}
|
|
530
|
+
className="prenta-editor-collapsible prenta-touch-target"
|
|
531
|
+
leftIcon={<MessageSquareWarning className="h-3.5 w-3.5" aria-hidden />}
|
|
491
532
|
>
|
|
492
|
-
{REQUEST_CHANGES_LABEL}
|
|
493
|
-
</
|
|
533
|
+
<span className="prenta-editor-label">{REQUEST_CHANGES_LABEL}</span>
|
|
534
|
+
</Button>
|
|
494
535
|
)}
|
|
495
536
|
|
|
496
537
|
<RequestChangesDialog
|
|
@@ -507,7 +548,7 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
507
548
|
if (state === 'saving') {
|
|
508
549
|
return (
|
|
509
550
|
<span
|
|
510
|
-
className="text-muted-foreground ml-2 inline-flex items-center gap-1 text-xs"
|
|
551
|
+
className="text-muted-foreground ml-2 inline-flex min-w-0 shrink items-center gap-1 overflow-hidden text-xs whitespace-nowrap"
|
|
511
552
|
aria-live="polite"
|
|
512
553
|
>
|
|
513
554
|
<Loader2 className="h-3 w-3 animate-spin" aria-hidden />
|
|
@@ -518,7 +559,7 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
518
559
|
if (state === 'error') {
|
|
519
560
|
return (
|
|
520
561
|
<span
|
|
521
|
-
className="text-destructive ml-2 inline-flex items-center gap-1 text-xs"
|
|
562
|
+
className="text-destructive ml-2 inline-flex min-w-0 shrink items-center gap-1 overflow-hidden text-xs whitespace-nowrap"
|
|
522
563
|
aria-live="polite"
|
|
523
564
|
>
|
|
524
565
|
<TriangleAlert className="h-3 w-3" aria-hidden />
|
|
@@ -528,7 +569,10 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
528
569
|
}
|
|
529
570
|
if (dirty) {
|
|
530
571
|
return (
|
|
531
|
-
<span
|
|
572
|
+
<span
|
|
573
|
+
className="text-muted-foreground ml-2 min-w-0 shrink truncate text-xs"
|
|
574
|
+
aria-live="polite"
|
|
575
|
+
>
|
|
532
576
|
Unsaved changes
|
|
533
577
|
</span>
|
|
534
578
|
)
|
|
@@ -536,7 +580,7 @@ function SaveStatus({ state, dirty }: { state: SaveState; dirty: boolean }) {
|
|
|
536
580
|
if (state === 'saved') {
|
|
537
581
|
return (
|
|
538
582
|
<span
|
|
539
|
-
className="text-muted-foreground ml-2 inline-flex items-center gap-1 text-xs"
|
|
583
|
+
className="text-muted-foreground ml-2 inline-flex min-w-0 shrink items-center gap-1 overflow-hidden text-xs whitespace-nowrap"
|
|
540
584
|
aria-live="polite"
|
|
541
585
|
>
|
|
542
586
|
<Check className="h-3 w-3" aria-hidden />
|