payload-canvas 0.6.2 → 0.6.4
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 -21
- package/README.md +7 -5
- package/dist/admin/aiKeyField.scss +58 -58
- package/dist/admin/diff/layoutDiff.scss +181 -181
- package/dist/admin/editor/assistant/assistant.scss +944 -944
- package/dist/admin/editor/classes/manager.scss +262 -262
- package/dist/admin/editor/comments/comments.scss +539 -539
- package/dist/admin/editor/dnd/dnd.scss +261 -261
- package/dist/admin/editor/editor.scss +2629 -2629
- package/dist/admin/editor/empty/empty.scss +92 -92
- package/dist/admin/editor/fields/fields.scss +778 -778
- package/dist/admin/editor/generate/generate.scss +276 -276
- package/dist/admin/editor/layout/layout.scss +240 -240
- package/dist/admin/editor/live/presence.scss +24 -24
- package/dist/admin/editor/locale/locale.scss +154 -154
- package/dist/admin/editor/media/media.scss +233 -233
- package/dist/admin/editor/menu/menu.scss +132 -132
- package/dist/admin/editor/motion/motion.scss +84 -84
- package/dist/admin/editor/sections/components.scss +238 -238
- package/dist/admin/editor/sections/variants.scss +90 -90
- package/dist/admin/editor/styles/ClassCss.js +3 -3
- package/dist/admin/editor/styles/classes.scss +381 -381
- package/dist/admin/editor/styles/styles.scss +1123 -1123
- package/dist/admin/editor/styles/tokens.js +2 -1
- package/dist/admin/editor/templates/templates.scss +654 -654
- package/dist/admin/editor/tooltip/tooltip.scss +39 -39
- package/dist/admin/editor/topbar/DocumentActions.js +1 -1
- package/dist/admin/editor/topbar/contentMode.scss +26 -26
- package/dist/admin/editor/topbar/screens/screens.scss +134 -134
- package/dist/admin/editor/topbar/settingsDrawer.scss +32 -32
- package/dist/admin/editor/topbar/topbar.scss +645 -645
- package/dist/admin/editor/ui/controls.scss +320 -320
- package/dist/admin/forms/submissions.scss +197 -197
- package/dist/admin/layoutField.scss +69 -69
- package/dist/admin/templateConditions.scss +24 -24
- package/dist/ai/prompt.js +40 -40
- package/dist/blocks/client/marquee.js +14 -14
- package/dist/blocks/defaults.js +17 -1
- package/dist/blocks/payload.js +13 -3
- package/dist/core/responseError.d.ts +5 -0
- package/dist/core/responseError.js +8 -0
- package/dist/css/index.d.ts +6 -0
- package/dist/css/index.js +40 -1
- package/dist/css/shared.js +2 -2
- package/dist/live/session.js +18 -0
- package/dist/live/storage.d.ts +5 -0
- package/dist/live/storage.js +20 -0
- package/dist/mcp/shared.js +16 -16
- package/dist/plugin/index.d.ts +14 -1
- package/dist/plugin/index.js +46 -8
- package/dist/react/canvas/BuilderCanvas.js +4 -3
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +2 -1
- package/dist/react/components/AutoplayVideo.d.ts +3 -1
- package/dist/react/components/AutoplayVideo.js +4 -3
- package/dist/react/components/Video.d.ts +1 -0
- package/dist/react/components/Video.js +13 -2
- package/dist/react/components/videoPlayback.d.ts +13 -0
- package/dist/react/components/videoPlayback.js +10 -0
- package/dist/theme/admin/fields.scss +363 -363
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
4
4
|
// uses to picture ready-made and saved sections. It renders one section at a time with the app's
|
|
5
5
|
// components, CSS and theme, and sends back a picture (see capture.ts).
|
|
6
6
|
import { collectClasses } from '../../../core/index.js';
|
|
7
|
+
import { responseErrorMessage } from '../../../core/responseError.js';
|
|
7
8
|
import { createCanvasCompiler } from '../../../css/browser.js';
|
|
8
9
|
import { compileClassSheet } from '../../../css/classes.js';
|
|
9
10
|
import { withoutClassNames } from '../../../classes/shared.js';
|
|
@@ -96,7 +97,7 @@ export function ThumbnailCanvas({ blocks, components, plugins, resolveLink, serv
|
|
|
96
97
|
const state = { cancelled: false, busy: false };
|
|
97
98
|
const input = fetch(init.cssEndpoint, { credentials: 'include' }).then(async (res) => {
|
|
98
99
|
if (!res.ok)
|
|
99
|
-
throw new Error(`Canvas CSS: ${
|
|
100
|
+
throw new Error(`Canvas CSS: ${await responseErrorMessage(res)}`);
|
|
100
101
|
return (await res.json());
|
|
101
102
|
});
|
|
102
103
|
const compiler = input.then((value) => createCanvasCompiler(value, pluginsRef.current));
|
|
@@ -4,6 +4,8 @@ export type AutoplayVideoProps = {
|
|
|
4
4
|
attributes: Record<string, string | number>;
|
|
5
5
|
className?: string;
|
|
6
6
|
src: string;
|
|
7
|
+
/** A smaller copy for phones (`PHONE_MEDIA`). */
|
|
8
|
+
phoneSrc?: string;
|
|
7
9
|
poster?: string;
|
|
8
10
|
loop: boolean;
|
|
9
11
|
muted: boolean;
|
|
@@ -17,4 +19,4 @@ export type AutoplayVideoProps = {
|
|
|
17
19
|
* shows the poster and stays paused. A change of that setting plays or pauses it. A browser that
|
|
18
20
|
* refuses to play (an unmuted video) keeps the poster too.
|
|
19
21
|
*/
|
|
20
|
-
export declare function AutoplayVideo({ attributes, className, src, poster, loop, muted, controls, preload, style }: AutoplayVideoProps): import("react").JSX.Element;
|
|
22
|
+
export declare function AutoplayVideo({ attributes, className, src, phoneSrc, poster, loop, muted, controls, preload, style }: AutoplayVideoProps): import("react").JSX.Element;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
import { useCanvasMode } from '../render/canvasMode.js';
|
|
5
|
-
import { REDUCED_MOTION, startsPlaying } from './videoPlayback.js';
|
|
5
|
+
import { REDUCED_MOTION, startsPlaying, videoSources } from './videoPlayback.js';
|
|
6
6
|
/**
|
|
7
7
|
* An autoplaying `<video>` that starts from script after mount, not with the `autoplay` attribute,
|
|
8
8
|
* so it can ask first: it plays only when the visitor does not ask for less motion. Otherwise it
|
|
9
9
|
* shows the poster and stays paused. A change of that setting plays or pauses it. A browser that
|
|
10
10
|
* refuses to play (an unmuted video) keeps the poster too.
|
|
11
11
|
*/
|
|
12
|
-
export function AutoplayVideo({ attributes, className, src, poster, loop, muted, controls, preload, style }) {
|
|
12
|
+
export function AutoplayVideo({ attributes, className, src, phoneSrc, poster, loop, muted, controls, preload, style }) {
|
|
13
13
|
const ref = useRef(null);
|
|
14
14
|
const canvas = useCanvasMode() !== 'site';
|
|
15
15
|
useEffect(() => {
|
|
@@ -30,5 +30,6 @@ export function AutoplayVideo({ attributes, className, src, poster, loop, muted,
|
|
|
30
30
|
query.addEventListener('change', sync);
|
|
31
31
|
return () => query.removeEventListener('change', sync);
|
|
32
32
|
}, [canvas, muted]);
|
|
33
|
-
|
|
33
|
+
const sources = videoSources(src, phoneSrc);
|
|
34
|
+
return (_jsx("video", { ref: ref, ...attributes, className: className, src: sources.length ? undefined : src, poster: poster, loop: loop, muted: muted, controls: controls, playsInline: true, preload: preload, style: style, children: sources.map((source) => (_jsx("source", { media: source.media, src: source.src }, source.src))) }));
|
|
34
35
|
}
|
|
@@ -10,5 +10,6 @@ import type { BlockComponentProps } from '../render/types.js';
|
|
|
10
10
|
* - `priority` (Load first): `preload="auto"`, and the poster preloads with high fetch priority.
|
|
11
11
|
* - The poster's focal point sets `object-position`, with the image block's rule (`focalStyle`).
|
|
12
12
|
* - `decorative`: `aria-hidden="true"`, no controls, no tab stop. For a background video.
|
|
13
|
+
* - A phone video (`phoneVideo` or `phoneUrl`, a file): screens up to 767 px wide load it instead.
|
|
13
14
|
*/
|
|
14
15
|
export declare function Video({ props, className, attributes, mode, canvasMode }: BlockComponentProps): import("react").JSX.Element | null;
|
|
@@ -4,7 +4,7 @@ import { focalStyle, isDoc } from './Image.js';
|
|
|
4
4
|
// The script that starts an autoplaying video loads only on pages that render one.
|
|
5
5
|
import { AutoplayVideo } from './lazy.js';
|
|
6
6
|
import { PlaceholderBox } from './placeholder.js';
|
|
7
|
-
import { decorativeAttributes, videoPreload, videoSettingsOf } from './videoPlayback.js';
|
|
7
|
+
import { decorativeAttributes, videoPreload, videoSettingsOf, videoSources } from './videoPlayback.js';
|
|
8
8
|
import { isPlayableVideoUrl, parseVideoUrl } from './videoUrl.js';
|
|
9
9
|
/** Classes that already give the element a height. Without one, an embed gets a 16:9 ratio. */
|
|
10
10
|
const SIZE_CLASS = /(^|\s|:)(aspect-|h-|size-|min-h-)/;
|
|
@@ -39,6 +39,7 @@ function InvalidUrl({ attributes, className }) {
|
|
|
39
39
|
* - `priority` (Load first): `preload="auto"`, and the poster preloads with high fetch priority.
|
|
40
40
|
* - The poster's focal point sets `object-position`, with the image block's rule (`focalStyle`).
|
|
41
41
|
* - `decorative`: `aria-hidden="true"`, no controls, no tab stop. For a background video.
|
|
42
|
+
* - A phone video (`phoneVideo` or `phoneUrl`, a file): screens up to 767 px wide load it instead.
|
|
42
43
|
*/
|
|
43
44
|
export function Video({ props, className, attributes, mode, canvasMode }) {
|
|
44
45
|
const canvas = mode === 'canvas' || canvasMode !== undefined;
|
|
@@ -51,6 +52,8 @@ export function Video({ props, className, attributes, mode, canvasMode }) {
|
|
|
51
52
|
// A missing source means the default ("upload"), unless only a URL is set.
|
|
52
53
|
const fromUrl = props.source === 'url' || (props.source == null && props.video == null && typeof props.url === 'string');
|
|
53
54
|
let src = null;
|
|
55
|
+
// A smaller copy for phones: a video file link, or an upload. A YouTube or Vimeo link does not count.
|
|
56
|
+
let phoneSrc;
|
|
54
57
|
if (fromUrl) {
|
|
55
58
|
const url = typeof props.url === 'string' ? props.url : '';
|
|
56
59
|
// A URL that cannot play: nothing on the site, a message on the canvas.
|
|
@@ -67,9 +70,15 @@ export function Video({ props, className, attributes, mode, canvasMode }) {
|
|
|
67
70
|
return (_jsx("iframe", { ...attributes, ...hidden, className: className, src: embed.embedUrl, title: embed.kind === 'youtube' ? 'YouTube video' : 'Vimeo video', allow: "accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share", allowFullScreen: true, loading: settings.priority ? 'eager' : 'lazy', referrerPolicy: "strict-origin-when-cross-origin", style: style }));
|
|
68
71
|
}
|
|
69
72
|
src = embed?.src ?? null;
|
|
73
|
+
const phoneUrl = typeof props.phoneUrl === 'string' ? props.phoneUrl.trim() : '';
|
|
74
|
+
const phone = phoneUrl && isPlayableVideoUrl(phoneUrl) ? parseVideoUrl(phoneUrl, options) : null;
|
|
75
|
+
if (phone?.kind === 'file')
|
|
76
|
+
phoneSrc = phone.src;
|
|
70
77
|
}
|
|
71
78
|
else if (isDoc(props.video)) {
|
|
72
79
|
src = props.video.url;
|
|
80
|
+
if (isDoc(props.phoneVideo) && typeof props.phoneVideo.url === 'string')
|
|
81
|
+
phoneSrc = props.phoneVideo.url;
|
|
73
82
|
}
|
|
74
83
|
if (!src) {
|
|
75
84
|
if (mode !== 'canvas')
|
|
@@ -83,6 +92,7 @@ export function Video({ props, className, attributes, mode, canvasMode }) {
|
|
|
83
92
|
attributes: { ...attributes, ...hidden },
|
|
84
93
|
className,
|
|
85
94
|
src,
|
|
95
|
+
phoneSrc,
|
|
86
96
|
poster,
|
|
87
97
|
loop: options.loop,
|
|
88
98
|
muted: options.muted,
|
|
@@ -92,5 +102,6 @@ export function Video({ props, className, attributes, mode, canvasMode }) {
|
|
|
92
102
|
};
|
|
93
103
|
if (options.autoplay)
|
|
94
104
|
return _jsx(AutoplayVideo, { ...video });
|
|
95
|
-
|
|
105
|
+
const sources = videoSources(src, phoneSrc);
|
|
106
|
+
return (_jsx("video", { ...video.attributes, className: className, src: sources.length ? undefined : src, poster: poster, loop: video.loop, muted: video.muted, controls: video.controls, playsInline: true, preload: video.preload, style: video.style, children: sources.map((source) => (_jsx("source", { media: source.media, src: source.src }, source.src))) }));
|
|
96
107
|
}
|
|
@@ -23,6 +23,19 @@ export declare function startsPlaying(args: {
|
|
|
23
23
|
}): boolean;
|
|
24
24
|
/** The `preload` attribute: the whole video for a video that loads first, else only its metadata. */
|
|
25
25
|
export declare function videoPreload(priority: boolean): 'auto' | 'metadata';
|
|
26
|
+
/** Screens up to 767 px wide (below Tailwind's `md`) load the phone video, when the block has one. */
|
|
27
|
+
export declare const PHONE_MEDIA = "(max-width: 767px)";
|
|
28
|
+
/** One `<source>` of a video. */
|
|
29
|
+
export type VideoSource = {
|
|
30
|
+
src: string;
|
|
31
|
+
media?: string;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The `<source>` list of a video with a phone copy: the phone copy first, for narrow screens, then
|
|
35
|
+
* the main file. Without a phone copy the list is empty and the `<video>` keeps its `src`.
|
|
36
|
+
* The browser picks a source once, when the video loads; a later resize does not switch it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function videoSources(src: string, phoneSrc?: string): VideoSource[];
|
|
26
39
|
/** The attributes that take a decorative video out of the accessibility tree and the tab order. */
|
|
27
40
|
export declare function decorativeAttributes(decorative: boolean): {
|
|
28
41
|
'aria-hidden'?: 'true';
|
|
@@ -27,6 +27,16 @@ export function startsPlaying(args) {
|
|
|
27
27
|
export function videoPreload(priority) {
|
|
28
28
|
return priority ? 'auto' : 'metadata';
|
|
29
29
|
}
|
|
30
|
+
/** Screens up to 767 px wide (below Tailwind's `md`) load the phone video, when the block has one. */
|
|
31
|
+
export const PHONE_MEDIA = '(max-width: 767px)';
|
|
32
|
+
/**
|
|
33
|
+
* The `<source>` list of a video with a phone copy: the phone copy first, for narrow screens, then
|
|
34
|
+
* the main file. Without a phone copy the list is empty and the `<video>` keeps its `src`.
|
|
35
|
+
* The browser picks a source once, when the video loads; a later resize does not switch it.
|
|
36
|
+
*/
|
|
37
|
+
export function videoSources(src, phoneSrc) {
|
|
38
|
+
return phoneSrc ? [{ src: phoneSrc, media: PHONE_MEDIA }, { src }] : [];
|
|
39
|
+
}
|
|
30
40
|
/** The attributes that take a decorative video out of the accessibility tree and the tab order. */
|
|
31
41
|
export function decorativeAttributes(decorative) {
|
|
32
42
|
return decorative ? { 'aria-hidden': 'true', tabIndex: -1 } : {};
|