@perkyzz/emvb 1.0.0 → 1.2.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.
Files changed (142) hide show
  1. package/README.md +9 -0
  2. package/THIRD_PARTY_NOTICES.md +1 -0
  3. package/package.json +10 -9
  4. package/src/admin/agents-api.ts +5 -1
  5. package/src/admin/bulk-api.ts +67 -0
  6. package/src/admin/content-api.ts +39 -6
  7. package/src/admin/copy-rich-text.ts +119 -0
  8. package/src/admin/dialog-tab-wrap.ts +78 -0
  9. package/src/admin/editor/A11yCopilot.tsx +2 -0
  10. package/src/admin/editor/Editor.tsx +24 -7
  11. package/src/admin/editor/ScheduleDialog.tsx +167 -0
  12. package/src/admin/editor/Timeline.tsx +6 -2
  13. package/src/admin/editor/TopBar.tsx +60 -8
  14. package/src/admin/editor/canvas/CanvasFrame.tsx +7 -2
  15. package/src/admin/editor/canvas/DeviceBar.tsx +22 -9
  16. package/src/admin/editor/canvas/canvas-scale.ts +3 -3
  17. package/src/admin/editor/canvas/use-canvas-session.ts +2 -2
  18. package/src/admin/editor/dnd/new-element.ts +68 -0
  19. package/src/admin/editor/editor-chrome.tsx +16 -5
  20. package/src/admin/editor/editor-commands.ts +10 -4
  21. package/src/admin/editor/editor-css.ts +2 -1
  22. package/src/admin/editor/element-chrome.ts +22 -0
  23. package/src/admin/editor/panels/ElementPanel.tsx +34 -17
  24. package/src/admin/editor/panels/SettingsPanel.tsx +2 -2
  25. package/src/admin/editor/panels/settings/DraftTextField.tsx +33 -1
  26. package/src/admin/editor/panels/settings/EffectsControls.tsx +79 -1
  27. package/src/admin/editor/panels/settings/FieldBindControl.tsx +6 -1
  28. package/src/admin/editor/panels/settings/FieldControl.tsx +10 -1
  29. package/src/admin/editor/panels/settings/IconControls.tsx +11 -0
  30. package/src/admin/editor/panels/settings/IconPicker.tsx +4 -1
  31. package/src/admin/editor/panels/settings/ItemList.tsx +36 -2
  32. package/src/admin/editor/panels/settings/LengthRow.tsx +36 -3
  33. package/src/admin/editor/panels/settings/LoopItemBindControl.tsx +18 -0
  34. package/src/admin/editor/panels/settings/StyleRow.tsx +7 -0
  35. package/src/admin/editor/panels/settings/advanced-rules.ts +3 -0
  36. package/src/admin/editor/panels/settings/length-units.ts +15 -3
  37. package/src/admin/editor/panels/settings/style-sections.ts +1 -0
  38. package/src/admin/editor/panels/style-target.ts +17 -4
  39. package/src/admin/editor/section-templates.ts +26 -4
  40. package/src/admin/editor/store.ts +15 -3
  41. package/src/admin/editor/useEditorCommands.ts +7 -5
  42. package/src/admin/editor/useEditorData.ts +4 -0
  43. package/src/admin/editor/useNodeActions.ts +4 -2
  44. package/src/admin/editor/useSave.ts +47 -3
  45. package/src/admin/export-api.ts +238 -0
  46. package/src/admin/index.tsx +6 -1
  47. package/src/admin/menus-api.ts +113 -0
  48. package/src/admin/pages/ExportDialog.tsx +395 -0
  49. package/src/admin/pages/ImportElementorDialog.tsx +25 -1
  50. package/src/admin/pages/PageList.tsx +67 -2
  51. package/src/admin/pages/ThemePartList.tsx +37 -1
  52. package/src/admin/pages/bulk.tsx +303 -0
  53. package/src/admin/search.ts +20 -0
  54. package/src/admin/theme-api.ts +4 -0
  55. package/src/admin/ui.ts +11 -2
  56. package/src/admin/widgets/CanvasField.tsx +8 -0
  57. package/src/admin/widgets/ConvertToRichText.tsx +136 -0
  58. package/src/admin/widgets/ExportEntryHtml.tsx +92 -0
  59. package/src/admin/widgets/convert-body.ts +73 -2
  60. package/src/astro/EmVBPage.astro +3 -0
  61. package/src/astro/render.ts +47 -22
  62. package/src/astro/request-data.ts +3 -0
  63. package/src/astro/resolve-theme.ts +88 -51
  64. package/src/astro/tabs/runtime.ts +16 -6
  65. package/src/astro/visitor.ts +23 -4
  66. package/src/astro/widgets/EmVBAlertsRuntime.astro +8 -0
  67. package/src/astro/widgets/EmVBCarouselRuntime.astro +8 -0
  68. package/src/astro/widgets/EmVBLightboxRuntime.astro +8 -0
  69. package/src/astro/widgets/EmVBWidgetRuntimes.astro +19 -0
  70. package/src/astro/widgets/alerts.ts +37 -0
  71. package/src/astro/widgets/carousel.ts +167 -0
  72. package/src/astro/widgets/index.ts +1 -0
  73. package/src/astro/widgets/lightbox.ts +123 -0
  74. package/src/constants.ts +1 -1
  75. package/src/core/a11y/audit.ts +103 -3
  76. package/src/core/arrange.ts +57 -1
  77. package/src/core/bounded-array.ts +16 -13
  78. package/src/core/contract.ts +26 -3
  79. package/src/core/css/generate.ts +83 -21
  80. package/src/core/css/scope.ts +10 -2
  81. package/src/core/css/trace.ts +33 -8
  82. package/src/core/design/classes.ts +25 -5
  83. package/src/core/design/devices.ts +78 -2
  84. package/src/core/design/variables.ts +14 -1
  85. package/src/core/elements/icon-svg.ts +135 -0
  86. package/src/core/elements/index.ts +33 -127
  87. package/src/core/elements/widgets.ts +907 -0
  88. package/src/core/export/runtimes.generated.ts +12 -0
  89. package/src/core/export/site.ts +579 -0
  90. package/src/core/export/zip.ts +95 -0
  91. package/src/core/extensions/schema.ts +2 -1
  92. package/src/core/geo-trust.ts +18 -0
  93. package/src/core/history/diff.ts +25 -0
  94. package/src/core/icons/social.generated.ts +29 -0
  95. package/src/core/image-edit/schema.ts +2 -1
  96. package/src/core/import/elementor/atomic.ts +22 -9
  97. package/src/core/import/elementor/context.ts +18 -0
  98. package/src/core/import/elementor/index.ts +72 -11
  99. package/src/core/import/elementor/style.ts +21 -1
  100. package/src/core/import/elementor/widgets.ts +394 -133
  101. package/src/core/index.ts +14 -0
  102. package/src/core/issue-cap.ts +19 -0
  103. package/src/core/json-schema.ts +8 -1
  104. package/src/core/limits.ts +6 -0
  105. package/src/core/loop-collections.ts +33 -0
  106. package/src/core/perf/meter.ts +37 -19
  107. package/src/core/portable-text-export.ts +243 -0
  108. package/src/core/proposals.ts +8 -2
  109. package/src/core/public-attributes.ts +30 -0
  110. package/src/core/render/index.ts +115 -13
  111. package/src/core/render/tabs.ts +18 -11
  112. package/src/core/render/vnode.ts +44 -6
  113. package/src/core/sanitize/css.ts +26 -0
  114. package/src/core/sanitize/svg-upload.ts +276 -23
  115. package/src/core/sanitize/svg.ts +3 -3
  116. package/src/core/schema/descriptors.ts +4 -0
  117. package/src/core/schema/design.ts +8 -7
  118. package/src/core/schema/layout.ts +406 -18
  119. package/src/core/schema/style.ts +49 -1
  120. package/src/core/search-text.ts +70 -0
  121. package/src/core/shadowing-ids.ts +41 -0
  122. package/src/core/theme/conditions.ts +2 -1
  123. package/src/core/theme/float.ts +1 -0
  124. package/src/core/theme/parse-doc.ts +10 -5
  125. package/src/core/theme/popup-rules.ts +16 -0
  126. package/src/core/theme/triggers.ts +3 -2
  127. package/src/core/validate.ts +3 -2
  128. package/src/index.ts +23 -2
  129. package/src/mcp/ports.ts +18 -7
  130. package/src/mcp/proposals.ts +36 -11
  131. package/src/mcp/read.ts +2 -3
  132. package/src/mcp/tools.ts +1 -1
  133. package/src/server/agent-settings.ts +12 -1
  134. package/src/server/hooks.ts +41 -6
  135. package/src/server/icon-routes.ts +52 -12
  136. package/src/server/mcp-routes.ts +11 -5
  137. package/src/server/plugin.ts +27 -2
  138. package/src/server/presence.ts +5 -1
  139. package/src/server/proposals.ts +16 -4
  140. package/src/server/requests.ts +60 -11
  141. package/src/server/site-origin.ts +13 -0
  142. package/src/server/targets.ts +26 -0
@@ -0,0 +1,167 @@
1
+ import { Button, Dialog, Loader } from "@cloudflare/kumo";
2
+ import * as React from "react";
3
+ import { BUTTON, FIELD, SOLID_PRIMARY, UI_CSS } from "../ui.ts";
4
+ import { DialogCloseButton } from "./DialogCloseButton.tsx";
5
+ import { useEditedNoun } from "./edited-noun.ts";
6
+ import { useMediaQuery } from "./useMediaQuery.ts";
7
+
8
+ /** W-1027: a date and time as people read it here: "14 Nov 2026, 09:00". */
9
+ export const scheduleLabel = (iso: string) =>
10
+ new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format(
11
+ new Date(iso),
12
+ );
13
+
14
+ const pad = (n: number) => String(n).padStart(2, "0");
15
+
16
+ /** The visitor's time zone name, such as America/Toronto. */
17
+ const timeZone = () => new Intl.DateTimeFormat().resolvedOptions().timeZone;
18
+
19
+ const systemNow = () => new Date();
20
+
21
+ /** A local time as a datetime-local input's value. */
22
+ export function localInputValue(date: Date): string {
23
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`;
24
+ }
25
+
26
+ /** Tomorrow at 9:00, local time: the first suggestion. */
27
+ function tomorrowMorning(now: Date): Date {
28
+ const next = new Date(now);
29
+ next.setDate(next.getDate() + 1);
30
+ next.setHours(9, 0, 0, 0);
31
+ return next;
32
+ }
33
+
34
+ /**
35
+ * W-1027: Schedule publish. EmDash publishes the saved draft at the chosen time; until then the
36
+ * page stays as it is (a draft, or its published version). Unsaved edits are saved first. When
37
+ * a time is set, the dialog shows it and can change or cancel it.
38
+ */
39
+ export function ScheduleDialog({
40
+ open,
41
+ onOpenChange,
42
+ scheduledAt,
43
+ onSchedule,
44
+ now = systemNow,
45
+ }: {
46
+ open: boolean;
47
+ onOpenChange: (open: boolean) => void;
48
+ scheduledAt: string | null;
49
+ /** Schedules at a time, or with null cancels; resolves to an error message or null. */
50
+ onSchedule: (at: Date | null) => Promise<string | null>;
51
+ /** Test seam. */
52
+ now?: () => Date;
53
+ }) {
54
+ const noun = useEditedNoun();
55
+ const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
56
+ const id = React.useId();
57
+ const [value, setValue] = React.useState("");
58
+ const [error, setError] = React.useState<string | null>(null);
59
+ const [busy, setBusy] = React.useState<"schedule" | "cancel" | null>(null);
60
+ const [wasOpen, setWasOpen] = React.useState(false);
61
+ if (open !== wasOpen) {
62
+ setWasOpen(open);
63
+ if (open) {
64
+ setValue(localInputValue(scheduledAt ? new Date(scheduledAt) : tomorrowMorning(now())));
65
+ setError(null);
66
+ setBusy(null);
67
+ }
68
+ }
69
+ const zone = timeZone();
70
+
71
+ const run = async (kind: "schedule" | "cancel") => {
72
+ if (busy) return;
73
+ let at: Date | null = null;
74
+ if (kind === "schedule") {
75
+ at = value ? new Date(value) : null;
76
+ if (!at || Number.isNaN(at.getTime())) {
77
+ setError("Choose a date and a time.");
78
+ return;
79
+ }
80
+ if (at.getTime() <= now().getTime() + 60_000) {
81
+ setError("Choose a time at least a minute from now.");
82
+ return;
83
+ }
84
+ }
85
+ setBusy(kind);
86
+ setError(null);
87
+ const failure = await onSchedule(at);
88
+ setBusy(null);
89
+ if (failure) setError(failure);
90
+ else onOpenChange(false);
91
+ };
92
+
93
+ return (
94
+ <Dialog.Root
95
+ open={open}
96
+ onOpenChange={(next) => {
97
+ if (!next && busy) return;
98
+ onOpenChange(next);
99
+ }}
100
+ >
101
+ <Dialog size="base" className="p-6">
102
+ <style>{UI_CSS}</style>
103
+ <form
104
+ data-emvb-dialog="schedule"
105
+ className="emvb-dialog"
106
+ onSubmit={(event) => {
107
+ event.preventDefault();
108
+ void run("schedule");
109
+ }}
110
+ >
111
+ <Dialog.Title>Schedule publishing</Dialog.Title>
112
+ <Dialog.Description>
113
+ {scheduledAt
114
+ ? `This ${noun} publishes on ${scheduleLabel(scheduledAt)}. Change the time or cancel it.`
115
+ : `Choose when this ${noun} goes live. Your saved changes publish then; until then visitors see what is live now.`}
116
+ </Dialog.Description>
117
+ <label className="emvb-field-label" htmlFor={id}>
118
+ Publish on
119
+ </label>
120
+ <input
121
+ id={id}
122
+ type="datetime-local"
123
+ className={FIELD}
124
+ value={value}
125
+ min={localInputValue(now())}
126
+ aria-describedby={`${id}-zone${error ? ` ${id}-error` : ""}`}
127
+ aria-invalid={error ? true : undefined}
128
+ onChange={(event) => setValue(event.currentTarget.value)}
129
+ />
130
+ <p className="emvb-helper" id={`${id}-zone`}>
131
+ Time zone: {zone}.
132
+ </p>
133
+ {error && (
134
+ <p className="emvb-inline-error" role="alert" id={`${id}-error`}>
135
+ {error}
136
+ </p>
137
+ )}
138
+ <div className="emvb-dialog-actions">
139
+ <DialogCloseButton>Close</DialogCloseButton>
140
+ {scheduledAt && (
141
+ <Button
142
+ variant="secondary"
143
+ className={BUTTON}
144
+ aria-disabled={busy !== null}
145
+ aria-busy={busy === "cancel"}
146
+ onClick={() => void run("cancel")}
147
+ >
148
+ Cancel schedule
149
+ </Button>
150
+ )}
151
+ <Button
152
+ type="submit"
153
+ variant="primary"
154
+ className={BUTTON}
155
+ style={SOLID_PRIMARY}
156
+ aria-disabled={busy !== null}
157
+ aria-busy={busy === "schedule"}
158
+ icon={busy === "schedule" && !reducedMotion ? <Loader size={14} /> : undefined}
159
+ >
160
+ {scheduledAt ? "Change schedule" : "Schedule"}
161
+ </Button>
162
+ </div>
163
+ </form>
164
+ </Dialog>
165
+ </Dialog.Root>
166
+ );
167
+ }
@@ -418,6 +418,7 @@ export function TimelineDialog({
418
418
  <span className="emvb-timeline-kind">{KIND_LABELS[change.kind]}</span>{" "}
419
419
  {change.label || ELEMENT_NAMES[change.type] || change.type}
420
420
  {change.kind === "changed" &&
421
+ !change.page &&
421
422
  ` · ${change.edits} element${change.edits === 1 ? "" : "s"}`}
422
423
  {(change.kind === "changed" || change.kind === "removed") && (
423
424
  <button
@@ -433,10 +434,13 @@ export function TimelineDialog({
433
434
  }
434
435
  setError(null);
435
436
  refocusAfterRestore.current = true;
436
- onApply(result.layout, "Section restored");
437
+ onApply(
438
+ result.layout,
439
+ change.page ? "Page styles restored" : "Section restored",
440
+ );
437
441
  }}
438
442
  >
439
- Restore this section
443
+ {change.page ? "Restore page styles" : "Restore this section"}
440
444
  </button>
441
445
  )}
442
446
  </li>
@@ -2,6 +2,7 @@ import { Button, DropdownMenu, Loader } from "@cloudflare/kumo";
2
2
  import * as React from "react";
3
3
  import {
4
4
  ArrowSquareOutIcon,
5
+ CalendarBlankIcon,
5
6
  CaretDownIcon,
6
7
  CheckIcon,
7
8
  EyeIcon,
@@ -11,6 +12,7 @@ import {
11
12
  FloppyDiskIcon,
12
13
  KeyboardIcon,
13
14
  LaptopIcon,
15
+ MonitorIcon,
14
16
  PaintBrushIcon,
15
17
  SignOutIcon,
16
18
  UploadSimpleIcon,
@@ -18,19 +20,29 @@ import {
18
20
  } from "@phosphor-icons/react";
19
21
  import { BUTTON, SOLID_PRIMARY } from "../ui.ts";
20
22
  import { statusLabel } from "../entry-status.ts";
23
+ import { scheduleLabel } from "./ScheduleDialog.tsx";
21
24
  import type { SaveStatus } from "./useSave.ts";
22
- import type { Device } from "../../core/index.ts";
25
+ import { WIDE_MIN_PX, type EditorDevice } from "../../core/index.ts";
23
26
  import { useMediaQuery } from "./useMediaQuery.ts";
24
27
 
25
28
  /** Preview sizes (W-158): the canvas device widths, in a window of that size. */
26
29
  const PREVIEW_SIZES = [
30
+ { device: "wide", label: "Wide screen (2560 px)", icon: MonitorIcon },
27
31
  { device: "desktop", label: "Desktop", icon: DesktopIcon },
28
32
  { device: "laptop", label: "Laptop (1200 px)", icon: LaptopIcon },
29
33
  { device: "tablet", label: "Tablet (768 px)", icon: DeviceTabletIcon },
30
34
  { device: "mobile", label: "Mobile (390 px)", icon: DeviceMobileIcon },
31
35
  ] as const;
32
36
 
33
- export type TopBarPage = { title: string; status: string };
37
+ export type TopBarPage = {
38
+ title: string;
39
+ status: string;
40
+ /** W-1027: when EmDash publishes the saved draft by itself. */
41
+ scheduledAt?: string | null;
42
+ };
43
+
44
+ const wideScreenFits = () =>
45
+ typeof window !== "undefined" && (window.screen?.availWidth ?? 0) >= WIDE_MIN_PX;
34
46
 
35
47
  function SaveStatusText({
36
48
  status,
@@ -82,6 +94,7 @@ export function TopBar({
82
94
  stylesUnpublished = false,
83
95
  canRevert = false,
84
96
  onRevert,
97
+ onSchedule,
85
98
  tools,
86
99
  onApply,
87
100
  }: {
@@ -93,7 +106,7 @@ export function TopBar({
93
106
  onShortcuts: () => void;
94
107
  onSiteStyles?: () => void;
95
108
  /** Opens the preview; with no device, at the device shown on the canvas (W-158). */
96
- onPreview: (device?: Device) => void;
109
+ onPreview: (device?: EditorDevice) => void;
97
110
  onSave: () => void;
98
111
  onPublish: () => void;
99
112
  /** Site styles have unpublished changes (W-153): the Publish button carries a dot. */
@@ -102,6 +115,8 @@ export function TopBar({
102
115
  canRevert?: boolean;
103
116
  /** Shown once the entry has a published version; asks before discarding. */
104
117
  onRevert?: () => void;
118
+ /** W-1027: opens Schedule publishing. */
119
+ onSchedule?: () => void;
105
120
  /** Extra tools beside Site styles: the page weight and accessibility meters, … (W-310). */
106
121
  tools?: React.ReactNode;
107
122
  /** Field mode (W-900): one Apply button replaces Preview, Revert, Save draft and Publish. */
@@ -143,6 +158,12 @@ export function TopBar({
143
158
  <span className="emvb-status-dot" aria-hidden="true" />
144
159
  {statusLabel(page.status)}
145
160
  </span>
161
+ {page.scheduledAt && (
162
+ <span className="emvb-status" data-emvb-scheduled="">
163
+ <CalendarBlankIcon size={12} aria-hidden="true" />
164
+ Publishes {scheduleLabel(page.scheduledAt)}
165
+ </span>
166
+ )}
146
167
  </>
147
168
  )}
148
169
  </div>
@@ -253,11 +274,26 @@ export function TopBar({
253
274
  />
254
275
  </DropdownMenu.Trigger>
255
276
  <DropdownMenu.Content data-emvb-preview-sizes="">
256
- {PREVIEW_SIZES.map(({ device, label, icon }) => (
257
- <DropdownMenu.Item key={device} icon={icon} onClick={() => onPreview(device)}>
258
- {label}
259
- </DropdownMenu.Item>
260
- ))}
277
+ {PREVIEW_SIZES.map(({ device, label, icon }) => {
278
+ // W-959: a window can't be wider than the screen, so Wide screen's media
279
+ // queries only apply on a screen at least 2400 px wide.
280
+ const tooNarrow = device === "wide" && !wideScreenFits();
281
+ return (
282
+ <DropdownMenu.Item
283
+ key={device}
284
+ icon={icon}
285
+ disabled={tooNarrow}
286
+ title={
287
+ tooNarrow
288
+ ? `Needs a screen at least ${WIDE_MIN_PX} px wide; the canvas shows Wide screen at any size`
289
+ : undefined
290
+ }
291
+ onClick={() => onPreview(device)}
292
+ >
293
+ {label}
294
+ </DropdownMenu.Item>
295
+ );
296
+ })}
261
297
  </DropdownMenu.Content>
262
298
  </DropdownMenu>
263
299
  </div>
@@ -301,6 +337,22 @@ export function TopBar({
301
337
  Save draft
302
338
  {dirty && <span className="emvb-unsaved-dot" aria-hidden="true" />}
303
339
  </Button>
340
+ {onSchedule && (
341
+ <Button
342
+ variant="secondary"
343
+ shape="square"
344
+ className="emvb-icon-btn"
345
+ // Named without "Publish", so the Publish button keeps a name of its own.
346
+ aria-label={page?.scheduledAt ? "Change schedule" : "Schedule"}
347
+ title={page?.scheduledAt ? "Change scheduled publishing" : "Schedule publishing"}
348
+ aria-disabled={busy !== null}
349
+ onClick={() => {
350
+ if (busy === null) onSchedule();
351
+ }}
352
+ >
353
+ <CalendarBlankIcon size={16} aria-hidden="true" />
354
+ </Button>
355
+ )}
304
356
  <Button
305
357
  variant="primary"
306
358
  className={`${BUTTON} emvb-publish-button`}
@@ -1,5 +1,10 @@
1
1
  import { createPortal } from "react-dom";
2
- import { isMultilineText, type Layout, type Device, type VNode } from "../../../core/index.ts";
2
+ import {
3
+ isMultilineText,
4
+ type Layout,
5
+ type EditorDevice,
6
+ type VNode,
7
+ } from "../../../core/index.ts";
3
8
  import type { PasteRefusal } from "../useClipboardActions.ts";
4
9
  import { CanvasTextEdit } from "./CanvasTextEdit.tsx";
5
10
  import { useFrameFocusRing } from "./frame-focus-ring.ts";
@@ -112,7 +117,7 @@ export function CanvasFrame({
112
117
  /** The style state chosen in the Style tab, shown on the selected element (W-089). */
113
118
  statePreview?: StatePreview | null;
114
119
  /** The previewed device (W-096): its page width, scaled to the stage (W-158, D-046). */
115
- device?: Device;
120
+ device?: EditorDevice;
116
121
  /** Fit to the stage or show at 100% (W-158). */
117
122
  zoom?: CanvasZoom;
118
123
  /** Told the on-screen scale whenever it changes, for the zoom readout (W-158). */
@@ -5,18 +5,21 @@ import {
5
5
  DeviceTabletIcon,
6
6
  type Icon,
7
7
  LaptopIcon,
8
+ MonitorIcon,
8
9
  } from "@phosphor-icons/react";
9
10
  import * as React from "react";
10
- import { DEVICES, type Device } from "../../../core/index.ts";
11
+ import { EDITOR_DEVICES, type EditorDevice } from "../../../core/index.ts";
11
12
 
12
- const LABELS: Record<Device, string> = {
13
+ const LABELS: Record<EditorDevice, string> = {
14
+ wide: "Wide screen",
13
15
  desktop: "Desktop",
14
16
  laptop: "Laptop",
15
17
  tablet: "Tablet",
16
18
  mobile: "Mobile",
17
19
  };
18
20
 
19
- const ICONS: Record<Device, Icon> = {
21
+ const ICONS: Record<EditorDevice, Icon> = {
22
+ wide: MonitorIcon,
20
23
  desktop: DesktopIcon,
21
24
  laptop: LaptopIcon,
22
25
  tablet: DeviceTabletIcon,
@@ -24,7 +27,7 @@ const ICONS: Record<Device, Icon> = {
24
27
  };
25
28
 
26
29
  /** The device's icon (decorative) and its name, which stays the tab's accessible name (W-127). */
27
- function DeviceLabel({ device }: { device: Device }) {
30
+ function DeviceLabel({ device }: { device: EditorDevice }) {
28
31
  const DeviceIcon = ICONS[device];
29
32
  return (
30
33
  <span className="emvb-device-label">
@@ -34,25 +37,28 @@ function DeviceLabel({ device }: { device: Device }) {
34
37
  );
35
38
  }
36
39
 
37
- /** Desktop, tablet or mobile. Desktop edits `style`; the others edit overrides (W-096). */
40
+ /** Wide screen (W-959), desktop, laptop, tablet or mobile. Desktop edits `style`; the others edit overrides (W-096). */
38
41
  export function DeviceBar({
39
42
  device,
40
43
  hidden,
41
44
  canHide,
42
45
  hideLabel,
46
+ inherited = false,
43
47
  onDevice,
44
48
  onToggleHidden,
45
49
  zoom = "fit",
46
50
  scale = 1,
47
51
  onZoom,
48
52
  }: {
49
- device: Device;
53
+ device: EditorDevice;
50
54
  /** Whether the selected element is hidden on `device`. */
51
55
  hidden: boolean;
52
56
  canHide: boolean;
53
57
  /** From the hide-on-device command, so the checkbox wording has one source. */
54
58
  hideLabel: string;
55
- onDevice: (device: Device) => void;
59
+ /** W-959: Wide screen's hide still follows Desktop (no choice of its own yet). */
60
+ inherited?: boolean;
61
+ onDevice: (device: EditorDevice) => void;
56
62
  onToggleHidden: () => void;
57
63
  /** Fit or 100% (W-158), with the current on-screen scale for the readout. */
58
64
  zoom?: "fit" | "actual";
@@ -70,19 +76,26 @@ export function DeviceBar({
70
76
  variant="segmented"
71
77
  size="sm"
72
78
  className="emvb-device-tabs"
73
- tabs={DEVICES.map((item) => ({
79
+ tabs={EDITOR_DEVICES.map((item) => ({
74
80
  value: item,
75
81
  label: <DeviceLabel device={item} />,
76
82
  }))}
77
83
  value={device}
78
84
  onValueChange={(next) => {
79
- if ((DEVICES as readonly string[]).includes(next)) onDevice(next as Device);
85
+ if ((EDITOR_DEVICES as readonly string[]).includes(next))
86
+ onDevice(next as EditorDevice);
80
87
  }}
81
88
  />
82
89
  </div>
83
90
  <label className="emvb-device-hide">
84
91
  <input type="checkbox" checked={hidden} disabled={!canHide} onChange={onToggleHidden} />
85
92
  {hideLabel}
93
+ {inherited && (
94
+ <span className="emvb-helper" data-emvb-hide-inherited="">
95
+ {" "}
96
+ (follows Desktop)
97
+ </span>
98
+ )}
86
99
  </label>
87
100
  {onZoom && (
88
101
  <Button
@@ -1,4 +1,4 @@
1
- import { DEVICE_PREVIEW_PX, type Device } from "../../../core/index.ts";
1
+ import { DEVICE_PREVIEW_PX, WIDE_PREVIEW_PX, type EditorDevice } from "../../../core/index.ts";
2
2
 
3
3
  /** Fit scales the canvas down to the stage; Actual shows it at 100% and scrolls (W-158). */
4
4
  export type CanvasZoom = "fit" | "actual";
@@ -9,11 +9,11 @@ export type CanvasZoom = "fit" | "actual";
9
9
  * the stage width, never up; Actual keeps 100% and the stage scrolls sideways.
10
10
  */
11
11
  export function canvasScale(
12
- device: Device,
12
+ device: EditorDevice,
13
13
  stageWidth: number,
14
14
  zoom: CanvasZoom,
15
15
  ): { width: number; scale: number } {
16
- const base = DEVICE_PREVIEW_PX[device];
16
+ const base = device === "wide" ? WIDE_PREVIEW_PX : DEVICE_PREVIEW_PX[device];
17
17
  const width = device === "desktop" ? Math.max(base, Math.floor(stageWidth)) : base;
18
18
  if (zoom === "actual" || stageWidth <= 0) return { width, scale: 1 };
19
19
  return { width, scale: Math.min(1, stageWidth / width) };
@@ -4,7 +4,7 @@ import {
4
4
  isPlainTextNode,
5
5
  plainTextOf,
6
6
  type Layout,
7
- type Device,
7
+ type EditorDevice,
8
8
  type VNode,
9
9
  } from "../../../core/index.ts";
10
10
  import type { PasteRefusal, ClipboardActions } from "../useClipboardActions.ts";
@@ -65,7 +65,7 @@ export function useCanvasSession({
65
65
  layout: Layout | null;
66
66
  selection: CanvasSelection;
67
67
  statePreview: StatePreview | null;
68
- device: Device;
68
+ device: EditorDevice;
69
69
  zoom: CanvasZoom;
70
70
  onScale?: (scale: number) => void;
71
71
  refusal: PasteRefusal | null;
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  defaultElement,
3
+ updateNode,
3
4
  ELEMENTS,
4
5
  isExtensionType,
5
6
  newNodeId,
@@ -8,6 +9,7 @@ import {
8
9
  type LayoutNode,
9
10
  } from "../../../core/index.ts";
10
11
  import type { ThemePartType } from "../../../core/theme/part-types.ts";
12
+ import { indexLayout } from "../../../core/tree-ops.ts";
11
13
  import { isSharedPart } from "../panels/settings/heading-warning.ts";
12
14
 
13
15
  const hasH1 = (node: LayoutNode): boolean =>
@@ -31,6 +33,26 @@ export function withPageHeadingLevel(
31
33
  return { ...node, props: { ...node.props, level: 1 } };
32
34
  }
33
35
 
36
+ /**
37
+ * W-968: a new Post title inside a Loop (or in a loop item part) is an H2. Its default H1 gave a
38
+ * grid of cards one H1 per post. Run on the layout right after the insert; a title whose level was
39
+ * already changed, or one moved in later, is left alone.
40
+ */
41
+ export function withLoopPostTitleLevel(
42
+ layout: Layout,
43
+ id: string,
44
+ partType?: ThemePartType,
45
+ ): Layout {
46
+ const index = indexLayout(layout);
47
+ const node = index.byId.get(id);
48
+ if (node?.type !== "post-title" || (node.props as { level?: number }).level !== 1) return layout;
49
+ let inLoop = partType === "loop_item";
50
+ for (let at = index.parentOf.get(id); !inLoop && at; at = index.parentOf.get(at))
51
+ inLoop = index.byId.get(at)?.type === "loop";
52
+ if (!inLoop) return layout;
53
+ return updateNode(layout, id, (n) => ({ ...n, props: { ...n.props, level: 2 } }) as LayoutNode);
54
+ }
55
+
34
56
  const textNode = (text: string, random?: () => number): LayoutNode => ({
35
57
  ...defaultElement("text", newNodeId(random)),
36
58
  props: { text },
@@ -61,6 +83,40 @@ export function newTabPanel(n: number, random?: () => number): LayoutNode {
61
83
  };
62
84
  }
63
85
 
86
+ /** W-1024: the networks new Social links cycle through, and an example profile for each. */
87
+ const STARTER_NETWORKS = [
88
+ ["facebook", "https://facebook.com/"],
89
+ ["instagram", "https://instagram.com/"],
90
+ ["linkedin", "https://linkedin.com/"],
91
+ ["youtube", "https://youtube.com/"],
92
+ ["x", "https://x.com/"],
93
+ ] as const;
94
+
95
+ /** W-1024: a Social link for a new Social icons element or its Add link. */
96
+ export function newSocialLink(n: number, random?: () => number): LayoutNode {
97
+ const [network, href] =
98
+ STARTER_NETWORKS[(n - 1) % STARTER_NETWORKS.length] ?? STARTER_NETWORKS[0];
99
+ return { id: newNodeId(random), type: "social-link", props: { network, href, newTab: true } };
100
+ }
101
+
102
+ /** W-1018: a Carousel slide holding a heading and a Text, for a new Carousel or its Add slide. */
103
+ export function newCarouselSlide(n: number, random?: () => number): LayoutNode {
104
+ return {
105
+ id: newNodeId(random),
106
+ type: "carousel-slide",
107
+ props: {},
108
+ children: [
109
+ { id: newNodeId(random), type: "heading", props: { text: `Slide ${n}`, level: 3 } },
110
+ textNode(`What slide ${n} says. Replace this text or add elements here.`, random),
111
+ ],
112
+ };
113
+ }
114
+
115
+ /** W-1019: an empty Gallery image for a Gallery's Add picture; its panel picks the picture. */
116
+ export function newGalleryImage(random?: () => number): LayoutNode {
117
+ return { id: newNodeId(random), type: "gallery-image", props: { src: "", alt: "Image" } };
118
+ }
119
+
64
120
  /**
65
121
  * Default node for a new element from the Add panel. Only new inserts get starter children;
66
122
  * saved Accordions and Tabs with no items keep working as they are (W-130).
@@ -118,6 +174,18 @@ export function newElement(
118
174
  ],
119
175
  };
120
176
  }
177
+ if (type === "carousel") {
178
+ return {
179
+ ...defaultElement("carousel", newNodeId(random)),
180
+ children: [1, 2, 3].map((n) => newCarouselSlide(n, random)),
181
+ };
182
+ }
183
+ if (type === "social-icons") {
184
+ return {
185
+ ...defaultElement("social-icons", newNodeId(random)),
186
+ children: [1, 2, 3].map((n) => newSocialLink(n, random)),
187
+ };
188
+ }
121
189
  if (type === "accordion") {
122
190
  const accordion = defaultElement("accordion", newNodeId(random));
123
191
  return {
@@ -4,11 +4,11 @@ import type { SavedSectionActions } from "./useSavedSections.ts";
4
4
  import * as React from "react";
5
5
  import {
6
6
  findNode,
7
- toggleHidden,
7
+ toggleHiddenOn,
8
8
  type A11yReport,
9
9
  type ElementType,
10
10
  type LayoutNode,
11
- type Device,
11
+ type EditorDevice,
12
12
  type ThemeDynamicData,
13
13
  } from "../../core/index.ts";
14
14
  import type { Fetcher } from "../api.ts";
@@ -18,6 +18,7 @@ import { saveEditedCopy } from "../media-api.ts";
18
18
  import { A11yDialog } from "./A11yCopilot.tsx";
19
19
  import { CommandPalette } from "./CommandPalette.tsx";
20
20
  import { ConflictDialog, DeleteSubtreeDialog, LeaveDialog, RevertDialog } from "./dialogs.tsx";
21
+ import { ScheduleDialog } from "./ScheduleDialog.tsx";
21
22
  import type { EditorCommand } from "./editor-commands.ts";
22
23
  import { paletteItems } from "./palette-items.ts";
23
24
  import { PerfMeterDialog } from "./PerfMeter.tsx";
@@ -47,6 +48,7 @@ export const initialState = (entry: EditorEntry, design: LoadedDesign): EditorSt
47
48
  float: entry.float,
48
49
  },
49
50
  status: entry.status,
51
+ scheduledAt: entry.scheduledAt ?? null,
50
52
  rev: entry.rev,
51
53
  design: design.design,
52
54
  designRevision: design.revision,
@@ -69,6 +71,7 @@ const CLOSED = {
69
71
  a11y: false,
70
72
  leave: false,
71
73
  revert: false,
74
+ schedule: false,
72
75
  imageEditor: false,
73
76
  };
74
77
 
@@ -167,19 +170,21 @@ async function revertToPublished({
167
170
  /** Hide or show the selected element on the current device (W-096). */
168
171
  export function hideSelectedOnDevice(
169
172
  state: EditorState,
170
- device: Device,
173
+ device: EditorDevice,
171
174
  dispatch: React.Dispatch<EditorAction>,
172
175
  ): void {
173
176
  const id = state.selectedId;
174
177
  const node = state.page.layout && id ? findNode(state.page.layout, id) : undefined;
175
178
  if (!node) return;
176
- const hiddenOn = toggleHidden(node.hiddenOn, device);
177
179
  dispatch({
178
180
  type: "update-node",
179
181
  id: node.id,
180
182
  update: (current) => {
181
- const next = { ...current, hiddenOn };
183
+ // W-959: Wide screen's hide sits in `style.wide.hidden`; the rest in `hiddenOn`.
184
+ const { hiddenOn, style } = toggleHiddenOn(current, device);
185
+ const next = { ...current, hiddenOn, style };
182
186
  if (!hiddenOn) delete next.hiddenOn;
187
+ if (!style) delete next.style;
183
188
  return next;
184
189
  },
185
190
  });
@@ -357,6 +362,12 @@ export function EditorDialogs({
357
362
  onReload={() => void reloadEntry({ fetcher, collection, state, dispatch, saver })}
358
363
  onOverwrite={() => void saver.overwrite()}
359
364
  />
365
+ <ScheduleDialog
366
+ open={chrome.flags.schedule}
367
+ onOpenChange={chrome.setOpen("schedule")}
368
+ scheduledAt={state.scheduledAt ?? null}
369
+ onSchedule={saver.schedule}
370
+ />
360
371
  <RevertDialog
361
372
  open={chrome.flags.revert}
362
373
  onOpenChange={chrome.setOpen("revert")}