payload-canvas 0.2.0 → 0.3.0-next.1
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/README.md +14 -22
- package/dist/admin/BuilderTab.js +1 -1
- package/dist/admin/diff/LayoutDiff.js +3 -3
- package/dist/admin/diff/layoutDiff.scss +48 -48
- package/dist/admin/editor/DragLayer.js +1 -1
- package/dist/admin/editor/InlineToolbar.js +1 -1
- package/dist/admin/editor/Inspector.js +1 -1
- package/dist/admin/editor/Outline.js +1 -1
- package/dist/admin/editor/Overlay.js +1 -1
- package/dist/admin/editor/assistant/AssistantPanel.js +1 -1
- package/dist/admin/editor/assistant/ConnectAgents.js +1 -1
- package/dist/admin/editor/assistant/assistant.scss +65 -65
- package/dist/admin/editor/dnd/dnd.scss +2 -2
- package/dist/admin/editor/editor.scss +134 -134
- package/dist/admin/editor/empty/EmptyStart.js +3 -3
- package/dist/admin/editor/empty/empty.scss +3 -3
- package/dist/admin/editor/fields/ArrayField.js +2 -2
- package/dist/admin/editor/fields/access.d.ts +1 -1
- package/dist/admin/editor/fields/fields.scss +33 -33
- package/dist/admin/editor/generate/GenerateImage.js +1 -1
- package/dist/admin/editor/generate/generate.scss +48 -48
- package/dist/admin/editor/icons.js +1 -1
- package/dist/admin/editor/insert/InsertHandle.js +1 -1
- package/dist/admin/editor/layout/FrameResize.js +1 -1
- package/dist/admin/editor/layout/LeftPanel.js +1 -1
- package/dist/admin/editor/layout/layout.scss +4 -4
- package/dist/admin/editor/live/PresenceUI.js +1 -1
- package/dist/admin/editor/live/presence.scss +1 -1
- package/dist/admin/editor/locale/LocaleField.d.ts +1 -1
- package/dist/admin/editor/locale/LocaleField.js +1 -1
- package/dist/admin/editor/locale/locale.scss +12 -12
- package/dist/admin/editor/media/ImageEditor.js +1 -1
- package/dist/admin/editor/media/media.scss +23 -23
- package/dist/admin/editor/menu/Menu.js +1 -1
- package/dist/admin/editor/menu/menu.scss +16 -16
- package/dist/admin/editor/motion/MotionPanel.js +1 -1
- package/dist/admin/editor/motion/model.d.ts +2 -2
- package/dist/admin/editor/motion/motion.scss +2 -2
- package/dist/admin/editor/regions/RegionOverlay.js +1 -1
- package/dist/admin/editor/regions/RegionPane.js +1 -1
- package/dist/admin/editor/renderField.js +1 -1
- package/dist/admin/editor/styles/ColorPicker.js +1 -1
- package/dist/admin/editor/styles/VariantBar.js +1 -1
- package/dist/admin/editor/styles/controls.js +1 -1
- package/dist/admin/editor/styles/sections.js +1 -1
- package/dist/admin/editor/styles/styles.scss +93 -93
- package/dist/admin/editor/templates/Bindable.d.ts +1 -1
- package/dist/admin/editor/templates/Bindable.js +1 -1
- package/dist/admin/editor/templates/SamplePicker.js +1 -1
- package/dist/admin/editor/templates/templates.scss +90 -90
- package/dist/admin/editor/tooltip/tooltip.scss +4 -4
- package/dist/admin/editor/topbar/DocumentActions.js +1 -1
- package/dist/admin/editor/topbar/DocumentTitle.js +1 -1
- package/dist/admin/editor/topbar/screens/DrawerRouter.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/ScreenDrawer.js +1 -1
- package/dist/admin/editor/topbar/screens/drawerRouterSupport.d.ts +1 -1
- package/dist/admin/editor/topbar/screens/screens.scss +20 -20
- package/dist/admin/editor/topbar/settingsDrawer.js +3 -3
- package/dist/admin/editor/topbar/settingsDrawer.scss +7 -7
- package/dist/admin/editor/topbar/topbar.scss +47 -47
- package/dist/admin/editor/ui/Select.js +1 -1
- package/dist/admin/editor/ui/controls.scss +26 -26
- package/dist/admin/screen/BuilderScreen.js +1 -1
- package/dist/ai/adapters/anthropic.d.ts +2 -2
- package/dist/ai/images/service.js +1 -1
- package/dist/ai/loop.d.ts +5 -5
- package/dist/blocks/defaults.d.ts +9 -9
- package/dist/core/bindings.d.ts +1 -1
- package/dist/core/fieldAccess.js +1 -1
- package/dist/core/fieldHooks.d.ts +1 -1
- package/dist/core/motion.d.ts +7 -7
- package/dist/live/draftAccess.js +1 -1
- package/dist/live/session.d.ts +1 -1
- package/dist/live/storage.js +2 -4
- package/dist/mcp/shared.d.ts +31 -31
- package/dist/plugin/index.js +4 -4
- package/dist/plugin/templates.js +5 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/react/canvas/BuilderCanvas.js +1 -1
- package/dist/react/canvas/inline/rich/editor.js +6 -1
- package/dist/react/canvas/thumbnail/ThumbnailCanvas.js +1 -1
- package/dist/react/motion/style.js +1 -1
- package/dist/react/render/PayloadRoot.js +1 -1
- package/dist/react/render/RenderLayout.js +1 -1
- package/dist/react/render/resolve.js +2 -0
- package/dist/react/server.d.ts +3 -1
- package/dist/react/server.js +5 -2
- package/dist/react/theme/ThemeStyle.js +1 -1
- package/dist/theme/admin/ColorField.d.ts +2 -2
- package/dist/theme/admin/ColorField.js +2 -2
- package/dist/theme/admin/FontField.d.ts +2 -2
- package/dist/theme/admin/FontField.js +2 -2
- package/dist/theme/admin/SaveSignal.js +2 -2
- package/dist/theme/admin/fields.scss +48 -48
- package/package.json +28 -23
package/dist/core/motion.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Block } from './types.js';
|
|
2
|
-
export declare const ENTER_PRESETS: readonly [
|
|
3
|
-
export declare const HOVER_PRESETS: readonly [
|
|
4
|
-
export declare const PRESS_PRESETS: readonly [
|
|
5
|
-
export declare const SCROLL_PRESETS: readonly [
|
|
6
|
-
export declare const LOOP_PRESETS: readonly [
|
|
7
|
-
export declare const MOTION_EASINGS: readonly [
|
|
8
|
-
export declare const ENTER_TRIGGERS: readonly [
|
|
2
|
+
export declare const ENTER_PRESETS: readonly ["fade", "fade-up", "fade-down", "fade-left", "fade-right", "zoom-in", "zoom-out", "blur-in", "wipe-up", "wipe-down", "wipe-left", "wipe-right"];
|
|
3
|
+
export declare const HOVER_PRESETS: readonly ["lift", "grow", "tilt"];
|
|
4
|
+
export declare const PRESS_PRESETS: readonly ["shrink"];
|
|
5
|
+
export declare const SCROLL_PRESETS: readonly ["parallax", "fade", "zoom"];
|
|
6
|
+
export declare const LOOP_PRESETS: readonly ["float", "pulse"];
|
|
7
|
+
export declare const MOTION_EASINGS: readonly ["ease-out", "ease-in-out", "linear", "spring", "bouncy"];
|
|
8
|
+
export declare const ENTER_TRIGGERS: readonly ["view", "load"];
|
|
9
9
|
export type EnterPreset = (typeof ENTER_PRESETS)[number];
|
|
10
10
|
export type HoverPreset = (typeof HOVER_PRESETS)[number];
|
|
11
11
|
export type PressPreset = (typeof PRESS_PRESETS)[number];
|
package/dist/live/draftAccess.js
CHANGED
|
@@ -106,7 +106,7 @@ export async function liveReadProblem(req, target) {
|
|
|
106
106
|
if (!config)
|
|
107
107
|
return DRAFT_NOT_READABLE_MESSAGE;
|
|
108
108
|
// Without `access.read` (never after Payload's sanitizing), executeAccess allows signed-in users.
|
|
109
|
-
const result = await executeAccess({ id: target.id,
|
|
109
|
+
const result = await executeAccess({ id: target.id, slug: target.collection, disableErrors: true, req }, config.access?.read);
|
|
110
110
|
if (!result)
|
|
111
111
|
return DRAFT_NOT_READABLE_MESSAGE;
|
|
112
112
|
// As in Payload: anything but a Where that is not false allows.
|
package/dist/live/session.d.ts
CHANGED
|
@@ -247,7 +247,7 @@ export declare function channelKey(collection: string, id: string | number): str
|
|
|
247
247
|
* Payload's blue accent (about 200°), so collaborator colors stay away from 180–265°. Each is
|
|
248
248
|
* dark enough for white text (contrast 4.5:1 or more) and visible on light and dark canvases.
|
|
249
249
|
*/
|
|
250
|
-
export declare const COLLABORATOR_COLORS: readonly [
|
|
250
|
+
export declare const COLLABORATOR_COLORS: readonly ["#dc2626", "#c2410c", "#a16207", "#4d7c0f", "#15803d", "#9333ea", "#a21caf", "#be185d", "#57534e", "#3f3f46"];
|
|
251
251
|
/** A stable color per user id (FNV-1a hash). */
|
|
252
252
|
export declare function collaboratorColor(userId: string): string;
|
|
253
253
|
/** Display name of a person: `name`, then the local part of `email`, then "Someone". */
|
package/dist/live/storage.js
CHANGED
|
@@ -88,7 +88,7 @@ export async function canReadBlocksValue(req, args) {
|
|
|
88
88
|
if (field.hidden)
|
|
89
89
|
return false;
|
|
90
90
|
if (field.access?.read) {
|
|
91
|
-
const ok = await field.access.read({ req, id: args.id, data: doc, doc, siblingData: sibling, blockData });
|
|
91
|
+
const ok = await field.access.read({ collection: config, req, id: args.id, data: doc, doc, siblingData: sibling, blockData });
|
|
92
92
|
if (!ok)
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
@@ -135,9 +135,7 @@ export async function canReadBlocksValue(req, args) {
|
|
|
135
135
|
}
|
|
136
136
|
if (f.type === 'blocks') {
|
|
137
137
|
const blocks = new Map();
|
|
138
|
-
for (const
|
|
139
|
-
blocks.set(b.slug, b);
|
|
140
|
-
for (const ref of f.blockReferences ?? []) {
|
|
138
|
+
for (const ref of [...(f.blocks ?? []), ...(f.blockReferences ?? [])]) {
|
|
141
139
|
const block = typeof ref === 'string' ? references.get(ref) : ref;
|
|
142
140
|
if (block)
|
|
143
141
|
blocks.set(block.slug, block);
|
package/dist/mcp/shared.d.ts
CHANGED
|
@@ -42,48 +42,48 @@ export declare function sectionInsertOps(layout: Layout, section: SectionDefinit
|
|
|
42
42
|
}): Operation[] | string;
|
|
43
43
|
/** A block type as plain data for AI models: props, slots, where it may go, description and example. */
|
|
44
44
|
export declare function describeBlock(def: BlockDefinition): {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
props: {
|
|
50
|
-
name: string;
|
|
51
|
-
type: string;
|
|
52
|
-
required?: boolean | undefined;
|
|
53
|
-
hasMany?: boolean | undefined;
|
|
54
|
-
options?: string[] | undefined;
|
|
55
|
-
relationTo?: string | string[] | undefined;
|
|
56
|
-
}[];
|
|
45
|
+
example?: Omit<Partial<Block>, "id"> | undefined;
|
|
46
|
+
defaultClassName?: string | undefined;
|
|
47
|
+
className?: string | undefined;
|
|
48
|
+
onlyInside?: string[] | undefined;
|
|
57
49
|
slots: {
|
|
58
50
|
[k: string]: {
|
|
59
|
-
label?: string | undefined;
|
|
60
|
-
accepts: string | string[];
|
|
61
|
-
minBlocks?: number | undefined;
|
|
62
51
|
maxBlocks?: number | undefined;
|
|
52
|
+
minBlocks?: number | undefined;
|
|
53
|
+
accepts: string | string[];
|
|
54
|
+
label?: string | undefined;
|
|
63
55
|
};
|
|
64
56
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
props: {
|
|
58
|
+
relationTo?: string | string[] | undefined;
|
|
59
|
+
options?: string[] | undefined;
|
|
60
|
+
hasMany?: boolean | undefined;
|
|
61
|
+
required?: boolean | undefined;
|
|
62
|
+
name: string;
|
|
63
|
+
type: string;
|
|
64
|
+
}[];
|
|
65
|
+
description?: string | undefined;
|
|
66
|
+
category?: string | undefined;
|
|
70
67
|
type: string;
|
|
71
68
|
label: string;
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
} | {
|
|
70
|
+
example?: Omit<Partial<Block>, "id"> | undefined;
|
|
71
|
+
defaultClassName?: string | undefined;
|
|
72
|
+
className?: string | undefined;
|
|
73
|
+
onlyInside?: string[] | undefined;
|
|
74
|
+
slots: string;
|
|
74
75
|
props: {
|
|
76
|
+
relationTo?: string | string[] | undefined;
|
|
77
|
+
options?: string[] | undefined;
|
|
78
|
+
hasMany?: boolean | undefined;
|
|
79
|
+
required?: boolean | undefined;
|
|
75
80
|
name: string;
|
|
76
81
|
type: string;
|
|
77
|
-
required?: boolean | undefined;
|
|
78
|
-
hasMany?: boolean | undefined;
|
|
79
|
-
options?: string[] | undefined;
|
|
80
|
-
relationTo?: string | string[] | undefined;
|
|
81
82
|
}[];
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
example?: Omit<Partial<Block>, "id"> | undefined;
|
|
83
|
+
description?: string | undefined;
|
|
84
|
+
category?: string | undefined;
|
|
85
|
+
type: string;
|
|
86
|
+
label: string;
|
|
87
87
|
};
|
|
88
88
|
/** One line per block (indented by depth), with the start of its text, for a short section summary. */
|
|
89
89
|
export declare function outline(blocks: Block[], depth?: number): string[];
|
package/dist/plugin/index.js
CHANGED
|
@@ -99,10 +99,10 @@ export function websiteBuilder(options) {
|
|
|
99
99
|
throw new Error(`[websiteBuilder] A global named "${theme.slug}" already exists. Remove it (the plugin adds the theme global), set \`theme.slug\` to another name, or set \`theme: false\`.`);
|
|
100
100
|
}
|
|
101
101
|
/** The theme's font families for the Styles panel. Empty without a theme or when the read fails. */
|
|
102
|
-
const themeFamilies = async (
|
|
102
|
+
const themeFamilies = async (req) => {
|
|
103
103
|
if (!theme)
|
|
104
104
|
return {};
|
|
105
|
-
const doc = await payload.findGlobal({ slug: theme.slug, depth: 0 }).catch(() => null);
|
|
105
|
+
const doc = await req.payload.findGlobal({ slug: theme.slug, depth: 0, req, overrideAccess: false }).catch(() => null);
|
|
106
106
|
return themeFontFamilies(doc);
|
|
107
107
|
};
|
|
108
108
|
// Templates: a collection of layouts for the template-enabled collections.
|
|
@@ -395,7 +395,7 @@ export function websiteBuilder(options) {
|
|
|
395
395
|
return Response.json({ error: 'Unauthorized' }, { status: 401 });
|
|
396
396
|
const tokens = await getStyleTokens(css);
|
|
397
397
|
const custom = await Promise.resolve(options.css.fontFamilies?.(req.payload)).catch(() => undefined);
|
|
398
|
-
const families = { ...(await themeFamilies(req
|
|
398
|
+
const families = { ...(await themeFamilies(req)), ...custom };
|
|
399
399
|
const fonts = applyFontFamilies(tokens.fonts, families);
|
|
400
400
|
// Not cached by the browser: the fonts follow the theme global.
|
|
401
401
|
return Response.json({ ...tokens, fonts }, { headers: { 'Cache-Control': 'private, no-cache' } });
|
|
@@ -569,7 +569,7 @@ function addPayloadBlocksBuilder(collection, args, storage) {
|
|
|
569
569
|
name: builderConfigFieldName(field),
|
|
570
570
|
type: 'json',
|
|
571
571
|
virtual: true,
|
|
572
|
-
admin: { hidden: true,
|
|
572
|
+
admin: { hidden: true, custom: { builder: clientConfig } },
|
|
573
573
|
};
|
|
574
574
|
const skip = [builderConfigFieldName(field), ...(richText ? [richText.name] : []), ...ownFields];
|
|
575
575
|
return {
|
package/dist/plugin/templates.js
CHANGED
|
@@ -167,6 +167,8 @@ export const keepOneDefault = async ({ collection, context, doc, req }) => {
|
|
|
167
167
|
draft: false,
|
|
168
168
|
depth: 0,
|
|
169
169
|
pagination: false,
|
|
170
|
+
// This hook maintains the collection-wide default after the user's publish passed access.
|
|
171
|
+
overrideAccess: true,
|
|
170
172
|
req,
|
|
171
173
|
});
|
|
172
174
|
for (const other of others.docs) {
|
|
@@ -174,7 +176,7 @@ export const keepOneDefault = async ({ collection, context, doc, req }) => {
|
|
|
174
176
|
if (!isPublished(other))
|
|
175
177
|
continue;
|
|
176
178
|
const id = other.id;
|
|
177
|
-
const latest = (await req.payload.findByID({ collection: slug, id, draft: true, depth: 0, req }));
|
|
179
|
+
const latest = (await req.payload.findByID({ collection: slug, id, draft: true, depth: 0, overrideAccess: true, req }));
|
|
178
180
|
const { id: _id, ...published } = other;
|
|
179
181
|
// Localized templates: the reads above hold one locale's view; save the stored layouts.
|
|
180
182
|
published[TEMPLATE_LAYOUT_FIELD] = await storedTemplateLayout(req.payload, slug, id, false);
|
|
@@ -187,6 +189,7 @@ export const keepOneDefault = async ({ collection, context, doc, req }) => {
|
|
|
187
189
|
data: { ...published, [TEMPLATE_DEFAULT_FIELD]: false, _status: 'published' },
|
|
188
190
|
draft: false,
|
|
189
191
|
depth: 0,
|
|
192
|
+
overrideAccess: true,
|
|
190
193
|
req,
|
|
191
194
|
context: { [DEFAULT_CONTEXT]: true, [KEEP_LAYOUT]: true, [STORED_LAYOUT]: true },
|
|
192
195
|
});
|
|
@@ -200,6 +203,7 @@ export const keepOneDefault = async ({ collection, context, doc, req }) => {
|
|
|
200
203
|
data: { ...draft, [TEMPLATE_DEFAULT_FIELD]: false },
|
|
201
204
|
draft: true,
|
|
202
205
|
depth: 0,
|
|
206
|
+
overrideAccess: true,
|
|
203
207
|
req,
|
|
204
208
|
context: { [DEFAULT_CONTEXT]: true, [STORED_LAYOUT]: true },
|
|
205
209
|
});
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Block, BlockDefinition, CanvasMeasurement, Layout, Point, Rect, RegionConfig, TemplateContext } from '../core/types.js';
|
|
2
2
|
export * from './motion.js';
|
|
3
|
-
export declare const CHANNEL:
|
|
3
|
+
export declare const CHANNEL: "payload-builder";
|
|
4
4
|
/** What the iframe needs besides the layout. Sent by the admin before the first layout. */
|
|
5
5
|
export type CanvasInit = {
|
|
6
6
|
blocks: BlockDefinition[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// Runs inside the canvas iframe. It renders the layout it gets from the admin editor and reports
|
|
4
4
|
// block and slot rectangles, the pointer and editor shortcuts back. It holds no selection or drop logic.
|
|
5
5
|
import { collectClasses, createId, findBlock, joinListItem, TEXT_LIST_ITEM_BLOCK, } from '../../core/index.js';
|
|
@@ -38,7 +38,12 @@ export function registerCommands(editor) {
|
|
|
38
38
|
export function loadValue(editor, value) {
|
|
39
39
|
if (isRichValue(value)) {
|
|
40
40
|
try {
|
|
41
|
-
|
|
41
|
+
// Lexical 0.52 reports parse errors through onError and can return a partial state.
|
|
42
|
+
let parsed = false;
|
|
43
|
+
const state = editor.parseEditorState(value, () => { parsed = true; });
|
|
44
|
+
if (!parsed)
|
|
45
|
+
return false;
|
|
46
|
+
editor.setEditorState(state);
|
|
42
47
|
}
|
|
43
48
|
catch {
|
|
44
49
|
return false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
// The canvas page in thumbnail mode (`?mode=thumbnail`): a hidden iframe the editor's library
|
|
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).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { EASING_CURVES, enterFrom, enterTiming, LIST_ITEMS_PROP, MOTION_ATTR, MOTION_ITEM_ATTR, MOTION_READY_ATTR, MOTION_REVEAL_ATTR, staggersChildren, } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* The animation that hides a block until the runtime takes it over. When it ends (the runtime
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Fragment, useLayoutEffect, useRef, useState, version } from 'react';
|
|
4
4
|
const HOST_STYLE = { display: 'contents' };
|
|
5
5
|
const EMPTY_STYLE = { minHeight: 48, padding: 8, border: '1px dashed currentColor', fontSize: 12, opacity: 0.6 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, memo } from 'react';
|
|
3
3
|
import { blocksHaveMotion, COLLECTION_LIST_BLOCK, motionAttributes, staggersChildren, LIST_ITEM_SLOT, LIST_ITEMS_PROP, resolveBlockBindings, } from '../../core/index.js';
|
|
4
4
|
import { defaultBlocks, isLinkField, withBuilderCssClass } from '../../blocks/index.js';
|
|
@@ -145,6 +145,8 @@ export async function loadLayoutData(layout, blocks, payload, options) {
|
|
|
145
145
|
pagination: false,
|
|
146
146
|
// Join fields (for example media's "Used in") are not needed to render; skip their subqueries.
|
|
147
147
|
joins: false,
|
|
148
|
+
overrideAccess: false,
|
|
149
|
+
user: options?.user,
|
|
148
150
|
...locale,
|
|
149
151
|
});
|
|
150
152
|
return new Map(result.docs.map((doc) => [doc.id, doc]));
|
package/dist/react/server.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type LoadTemplateArgs = RenderLocale & {
|
|
|
24
24
|
templatesSlug?: string;
|
|
25
25
|
/** Draft mode: use the latest template drafts. Otherwise only published templates. */
|
|
26
26
|
draft?: boolean;
|
|
27
|
+
/** The signed-in user when reading template drafts. */
|
|
28
|
+
user?: unknown;
|
|
27
29
|
};
|
|
28
30
|
/**
|
|
29
31
|
* The template a document renders through: the document's own template (its `template` field),
|
|
@@ -36,7 +38,7 @@ export type LoadTemplateArgs = RenderLocale & {
|
|
|
36
38
|
* template cannot show fields the visitor may not read (for example an author's email):
|
|
37
39
|
*
|
|
38
40
|
* const post = await payload.find({ collection: 'posts', where, depth: 1, draft, overrideAccess: false, user })
|
|
39
|
-
* const found = await loadTemplate(payload, { collection: 'posts', doc: post, draft })
|
|
41
|
+
* const found = await loadTemplate(payload, { collection: 'posts', doc: post, draft, user })
|
|
40
42
|
* const context = { collection: 'posts', doc: post }
|
|
41
43
|
* const layout = await loadLayoutData(found.layout, blocks, payload, { draft, context, resolveLink, user })
|
|
42
44
|
* <RenderLayout layout={layout} context={context} blocks={blocks} resolveLink={resolveLink} />
|
package/dist/react/server.js
CHANGED
|
@@ -41,7 +41,7 @@ const DEFAULT_CANDIDATES = 5;
|
|
|
41
41
|
* template cannot show fields the visitor may not read (for example an author's email):
|
|
42
42
|
*
|
|
43
43
|
* const post = await payload.find({ collection: 'posts', where, depth: 1, draft, overrideAccess: false, user })
|
|
44
|
-
* const found = await loadTemplate(payload, { collection: 'posts', doc: post, draft })
|
|
44
|
+
* const found = await loadTemplate(payload, { collection: 'posts', doc: post, draft, user })
|
|
45
45
|
* const context = { collection: 'posts', doc: post }
|
|
46
46
|
* const layout = await loadLayoutData(found.layout, blocks, payload, { draft, context, resolveLink, user })
|
|
47
47
|
* <RenderLayout layout={layout} context={context} blocks={blocks} resolveLink={resolveLink} />
|
|
@@ -58,7 +58,7 @@ export async function loadTemplate(payload, args) {
|
|
|
58
58
|
const ownId = isRecord(own) ? own.id : own;
|
|
59
59
|
if (typeof ownId === 'string' || typeof ownId === 'number') {
|
|
60
60
|
try {
|
|
61
|
-
const template = (await payload.findByID({ collection: slug, id: ownId, depth: 0, draft, ...locale }));
|
|
61
|
+
const template = (await payload.findByID({ collection: slug, id: ownId, depth: 0, draft, overrideAccess: !draft, user: args.user, ...locale }));
|
|
62
62
|
const found = usable(template, collection, draft);
|
|
63
63
|
if (found)
|
|
64
64
|
return found;
|
|
@@ -80,6 +80,9 @@ export async function loadTemplate(payload, args) {
|
|
|
80
80
|
depth: 0,
|
|
81
81
|
limit: DEFAULT_CANDIDATES,
|
|
82
82
|
draft,
|
|
83
|
+
// Published templates are server-rendered layout data; drafts use the visitor's access.
|
|
84
|
+
overrideAccess: !draft,
|
|
85
|
+
user: args.user,
|
|
83
86
|
...locale,
|
|
84
87
|
});
|
|
85
88
|
for (const candidate of result.docs) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// Server-only: the theme global as CSS variables and Google Fonts links, for the `<head>`.
|
|
3
3
|
import { themeConfigOf, themeOutput } from '../../theme/index.js';
|
|
4
4
|
import { cache } from 'react';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextFieldClientProps } from 'payload';
|
|
2
2
|
import './fields.scss';
|
|
3
3
|
/** A hex color: a swatch that opens a picker with presets, and a hex input. Empty means "not set". */
|
|
4
|
-
export declare
|
|
4
|
+
export declare function ThemeColorField({ path, field, readOnly }: TextFieldClientProps): import("react").JSX.Element;
|
|
@@ -21,7 +21,7 @@ function normalizeHex(input) {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
/** A hex color: a swatch that opens a picker with presets, and a hex input. Empty means "not set". */
|
|
24
|
-
export
|
|
24
|
+
export function ThemeColorField({ path, field, readOnly }) {
|
|
25
25
|
const { value, setValue, disabled } = useField({ path });
|
|
26
26
|
const locked = Boolean(readOnly || disabled);
|
|
27
27
|
// The hex input's text while the user types. `null`: show the stored value.
|
|
@@ -46,4 +46,4 @@ export const ThemeColorField = function ThemeColorField({ path, field, readOnly
|
|
|
46
46
|
if (e.key === 'Escape')
|
|
47
47
|
setDraft(null);
|
|
48
48
|
} })] }) }));
|
|
49
|
-
}
|
|
49
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TextFieldClientProps } from 'payload';
|
|
2
2
|
import './fields.scss';
|
|
3
3
|
/** A Google Font family: a searchable list that previews each font in its own typeface. */
|
|
4
|
-
export declare
|
|
4
|
+
export declare function ThemeFontField({ path, field, readOnly }: TextFieldClientProps): import("react").JSX.Element;
|
|
@@ -23,7 +23,7 @@ function loadPreview(family) {
|
|
|
23
23
|
document.head.appendChild(link);
|
|
24
24
|
}
|
|
25
25
|
/** A Google Font family: a searchable list that previews each font in its own typeface. */
|
|
26
|
-
export
|
|
26
|
+
export function ThemeFontField({ path, field, readOnly }) {
|
|
27
27
|
const { value, setValue, disabled } = useField({ path });
|
|
28
28
|
const locked = Boolean(readOnly || disabled);
|
|
29
29
|
const [query, setQuery] = useState('');
|
|
@@ -57,4 +57,4 @@ export const ThemeFontField = function ThemeFontField({ path, field, readOnly })
|
|
|
57
57
|
setValue(next ?? '');
|
|
58
58
|
setQuery('');
|
|
59
59
|
}, onInputValueChange: setQuery, children: [_jsxs("div", { className: "theme-font__row", children: [_jsx(Combobox.Input, { className: "theme-font__input", placeholder: "Search Google Fonts\u2026", "aria-label": `${labelText(field, path)} font` }), value && !locked ? (_jsx("button", { type: "button", className: "theme-font__clear", onClick: () => setValue(''), children: "Clear" })) : null] }), _jsx(Combobox.Portal, { children: _jsx(Combobox.Positioner, { sideOffset: 4, className: "theme-popover", children: _jsxs(Combobox.Popup, { className: "theme-font__popup", children: [_jsx(Combobox.List, { ref: listRef, className: "theme-font__list", children: fonts.map((font, index) => (_jsx(Combobox.Item, { value: font, index: index, className: "theme-font__option", "data-font": font, style: { fontFamily: `"${font}", sans-serif` }, children: font }, font))) }), _jsx(Combobox.Empty, { className: "theme-font__empty", children: "No fonts found" })] }) }) })] }), _jsx("div", { className: "theme-font__preview", style: value ? { fontFamily: `"${value}", sans-serif` } : undefined, children: value ? `${value}: The quick brown fox jumps over the lazy dog` : 'Not set: the font from your CSS.' })] }));
|
|
60
|
-
}
|
|
60
|
+
}
|
|
@@ -7,8 +7,8 @@ import { THEME_CHANNEL } from '../config.js';
|
|
|
7
7
|
* so every open builder canvas (any tab of this site) reloads the theme at once.
|
|
8
8
|
*/
|
|
9
9
|
export function ThemeSaveSignal() {
|
|
10
|
-
const {
|
|
11
|
-
const updatedAt = typeof
|
|
10
|
+
const { data } = useDocumentInfo();
|
|
11
|
+
const updatedAt = typeof data?.updatedAt === 'string' ? data.updatedAt : null;
|
|
12
12
|
const first = useRef(updatedAt);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (!updatedAt || updatedAt === first.current || typeof BroadcastChannel === 'undefined')
|
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
// Theme fields in Payload's admin. Payload CSS variables only, no Tailwind.
|
|
2
2
|
@layer payload-default {
|
|
3
3
|
.theme-field {
|
|
4
|
-
margin-bottom: var(--spacing-field, calc(var(--
|
|
4
|
+
margin-bottom: var(--spacing-field, calc(var(--spacer-3) * 1.5));
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
// Shared look of the text inputs, close to Payload's own inputs.
|
|
8
8
|
%theme-input {
|
|
9
|
-
height: calc(var(--
|
|
10
|
-
padding: 0 calc(var(--
|
|
11
|
-
border: 1px solid var(--
|
|
12
|
-
border-radius: var(--
|
|
13
|
-
background: var(--
|
|
14
|
-
color: var(--
|
|
9
|
+
height: calc(var(--spacer-3) * 2);
|
|
10
|
+
padding: 0 calc(var(--spacer-3) * 0.5);
|
|
11
|
+
border: 1px solid var(--color-border);
|
|
12
|
+
border-radius: var(--radius-medium, var(--radius-medium));
|
|
13
|
+
background: var(--color-bg);
|
|
14
|
+
color: var(--color-text);
|
|
15
15
|
font: inherit;
|
|
16
|
-
font-size: var(--
|
|
16
|
+
font-size: var(--text-body-medium-font-size, 13px);
|
|
17
17
|
box-sizing: border-box;
|
|
18
18
|
outline: none;
|
|
19
19
|
|
|
20
20
|
&:hover {
|
|
21
|
-
border-color: var(--
|
|
21
|
+
border-color: var(--color-border);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
&:focus {
|
|
25
|
-
border-color: var(--
|
|
25
|
+
border-color: var(--color-text-tertiary);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
&:disabled {
|
|
29
|
-
background: var(--
|
|
30
|
-
color: var(--
|
|
29
|
+
background: var(--color-bg-secondary);
|
|
30
|
+
color: var(--color-text-secondary);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
%theme-quiet-button {
|
|
35
35
|
flex-shrink: 0;
|
|
36
|
-
padding: calc(var(--
|
|
36
|
+
padding: calc(var(--spacer-3) * 0.25) calc(var(--spacer-3) * 0.5);
|
|
37
37
|
border: none;
|
|
38
|
-
border-radius: var(--
|
|
38
|
+
border-radius: var(--radius-medium, var(--radius-medium));
|
|
39
39
|
background: none;
|
|
40
|
-
color: var(--
|
|
40
|
+
color: var(--color-text-secondary);
|
|
41
41
|
font: inherit;
|
|
42
|
-
font-size: var(--
|
|
42
|
+
font-size: var(--text-body-small-font-size, 12px);
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
|
|
45
45
|
&:hover {
|
|
46
|
-
background: var(--
|
|
47
|
-
color: var(--
|
|
46
|
+
background: var(--color-bg-hover);
|
|
47
|
+
color: var(--color-text);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
%theme-popup {
|
|
57
|
-
border: 1px solid var(--
|
|
58
|
-
border-radius: var(--
|
|
59
|
-
background: var(--
|
|
57
|
+
border: 1px solid var(--color-border);
|
|
58
|
+
border-radius: var(--radius-large, var(--radius-medium));
|
|
59
|
+
background: var(--color-bg);
|
|
60
60
|
box-shadow: 0 6px 20px rgb(0 0 0 / 14%);
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -66,24 +66,24 @@
|
|
|
66
66
|
&__controls {
|
|
67
67
|
display: flex;
|
|
68
68
|
align-items: center;
|
|
69
|
-
gap: calc(var(--
|
|
69
|
+
gap: calc(var(--spacer-3) * 0.5);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
&__swatch {
|
|
73
73
|
flex-shrink: 0;
|
|
74
|
-
width: calc(var(--
|
|
75
|
-
height: calc(var(--
|
|
74
|
+
width: calc(var(--spacer-3) * 2);
|
|
75
|
+
height: calc(var(--spacer-3) * 2);
|
|
76
76
|
padding: 0;
|
|
77
|
-
border: 1px solid var(--
|
|
78
|
-
border-radius: var(--
|
|
77
|
+
border: 1px solid var(--color-border);
|
|
78
|
+
border-radius: var(--radius-medium, var(--radius-medium));
|
|
79
79
|
cursor: pointer;
|
|
80
80
|
|
|
81
81
|
&:hover {
|
|
82
|
-
box-shadow: 0 0 0 2px var(--
|
|
82
|
+
box-shadow: 0 0 0 2px var(--color-border);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
&:focus-visible {
|
|
86
|
-
outline: 2px solid var(--
|
|
86
|
+
outline: 2px solid var(--color-text-secondary);
|
|
87
87
|
outline-offset: 2px;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -92,24 +92,24 @@
|
|
|
92
92
|
background: linear-gradient(
|
|
93
93
|
to top right,
|
|
94
94
|
transparent calc(50% - 1px),
|
|
95
|
-
var(--
|
|
96
|
-
var(--
|
|
95
|
+
var(--color-bg-danger) calc(50% - 1px),
|
|
96
|
+
var(--color-bg-danger) calc(50% + 1px),
|
|
97
97
|
transparent calc(50% + 1px)
|
|
98
98
|
),
|
|
99
|
-
var(--
|
|
99
|
+
var(--color-bg);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
&__hex {
|
|
104
104
|
@extend %theme-input;
|
|
105
|
-
width: calc(var(--
|
|
106
|
-
font-family: var(--
|
|
105
|
+
width: calc(var(--spacer-3) * 6);
|
|
106
|
+
font-family: var(--text-mono-family, monospace);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
&__popup {
|
|
110
110
|
@extend %theme-popup;
|
|
111
111
|
width: 224px;
|
|
112
|
-
padding: calc(var(--
|
|
112
|
+
padding: calc(var(--spacer-3) * 0.5);
|
|
113
113
|
|
|
114
114
|
.react-colorful {
|
|
115
115
|
width: 100%;
|
|
@@ -135,20 +135,20 @@
|
|
|
135
135
|
display: grid;
|
|
136
136
|
grid-template-columns: repeat(6, 1fr);
|
|
137
137
|
gap: 4px;
|
|
138
|
-
margin: calc(var(--
|
|
138
|
+
margin: calc(var(--spacer-3) * 0.5) 0;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
&__preset {
|
|
142
142
|
width: 100%;
|
|
143
143
|
aspect-ratio: 1;
|
|
144
144
|
padding: 0;
|
|
145
|
-
border: 1px solid var(--
|
|
145
|
+
border: 1px solid var(--color-border);
|
|
146
146
|
border-radius: 4px;
|
|
147
147
|
cursor: pointer;
|
|
148
148
|
|
|
149
149
|
&:hover,
|
|
150
150
|
&:focus-visible {
|
|
151
|
-
border-color: var(--
|
|
151
|
+
border-color: var(--color-text-secondary);
|
|
152
152
|
outline: none;
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
&__row {
|
|
166
166
|
display: flex;
|
|
167
167
|
align-items: center;
|
|
168
|
-
gap: calc(var(--
|
|
168
|
+
gap: calc(var(--spacer-3) * 0.5);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
&__input {
|
|
@@ -194,12 +194,12 @@
|
|
|
194
194
|
&__option {
|
|
195
195
|
display: block;
|
|
196
196
|
padding: 6px 10px;
|
|
197
|
-
color: var(--
|
|
197
|
+
color: var(--color-text);
|
|
198
198
|
font-size: 15px;
|
|
199
199
|
cursor: pointer;
|
|
200
200
|
|
|
201
201
|
&[data-highlighted] {
|
|
202
|
-
background: var(--
|
|
202
|
+
background: var(--color-bg-hover);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
&[data-selected] {
|
|
@@ -209,13 +209,13 @@
|
|
|
209
209
|
|
|
210
210
|
&__empty:not(:empty) {
|
|
211
211
|
padding: 8px 10px;
|
|
212
|
-
color: var(--
|
|
213
|
-
font-size: var(--
|
|
212
|
+
color: var(--color-text-secondary);
|
|
213
|
+
font-size: var(--text-body-small-font-size, 12px);
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
&__preview {
|
|
217
|
-
margin-top: calc(var(--
|
|
218
|
-
color: var(--
|
|
217
|
+
margin-top: calc(var(--spacer-3) * 0.5);
|
|
218
|
+
color: var(--color-text);
|
|
219
219
|
font-size: 16px;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
&__controls {
|
|
227
227
|
display: flex;
|
|
228
228
|
align-items: center;
|
|
229
|
-
gap: calc(var(--
|
|
229
|
+
gap: calc(var(--spacer-3) * 0.5);
|
|
230
230
|
max-width: 480px;
|
|
231
231
|
}
|
|
232
232
|
|
|
@@ -234,13 +234,13 @@
|
|
|
234
234
|
|
|
235
235
|
&__number {
|
|
236
236
|
@extend %theme-input;
|
|
237
|
-
width: calc(var(--
|
|
237
|
+
width: calc(var(--spacer-3) * 3.5);
|
|
238
238
|
text-align: right;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
&__unit {
|
|
242
|
-
color: var(--
|
|
243
|
-
font-size: var(--
|
|
242
|
+
color: var(--color-text-secondary);
|
|
243
|
+
font-size: var(--text-body-small-font-size, 12px);
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
&__reset {
|