canopycms 0.0.68-int.113 → 0.0.68-int.114
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/dist/ai/generate.d.ts +4 -4
- package/dist/ai/generate.js +75 -14
- package/dist/ai/types.d.ts +12 -0
- package/dist/api/branch.js +13 -13
- package/dist/auth/cache.d.ts +1 -1
- package/dist/auth/cache.js +1 -1
- package/dist/auth/file-based-auth-cache.d.ts +8 -0
- package/dist/auth/file-based-auth-cache.js +11 -0
- package/dist/authorization/branch.d.ts +1 -1
- package/dist/authorization/branch.js +2 -1
- package/dist/cli/cli.js +160 -28
- package/dist/cli/generate-ai-content.js +156 -24
- package/dist/content-reader.js +2 -1
- package/dist/context.js +2 -1
- package/dist/editor/BranchManager.js +13 -17
- package/dist/editor/CommentsPanel.js +7 -6
- package/dist/editor/Editor.js +152 -30
- package/dist/editor/EditorAuthGate.js +2 -2
- package/dist/editor/EditorPanes.d.ts +10 -0
- package/dist/editor/EditorPanes.js +32 -8
- package/dist/editor/FormRenderer.d.ts +10 -0
- package/dist/editor/FormRenderer.js +92 -73
- package/dist/editor/PreviewFrame.d.ts +3 -1
- package/dist/editor/PreviewFrame.js +72 -9
- package/dist/editor/admin/SystemHealthPanel.js +27 -24
- package/dist/editor/branch-status.d.ts +16 -0
- package/dist/editor/branch-status.js +28 -0
- package/dist/editor/comments/BranchComments.js +1 -1
- package/dist/editor/comments/EntryComments.d.ts +3 -0
- package/dist/editor/comments/EntryComments.js +3 -3
- package/dist/editor/comments/FieldWrapper.d.ts +3 -0
- package/dist/editor/comments/FieldWrapper.js +2 -2
- package/dist/editor/comments/InlineCommentThread.js +2 -1
- package/dist/editor/comments/ThreadCarousel.js +2 -2
- package/dist/editor/components/ConfirmDeleteModal.js +1 -1
- package/dist/editor/components/EditorCrashScreen.js +1 -1
- package/dist/editor/components/EditorHeader.d.ts +2 -0
- package/dist/editor/components/EditorHeader.js +15 -36
- package/dist/editor/components/EditorSidebar.d.ts +5 -6
- package/dist/editor/components/EditorSidebar.js +2 -2
- package/dist/editor/components/EntryCreateModal.js +1 -1
- package/dist/editor/components/NoEditPermissionNotice.d.ts +3 -2
- package/dist/editor/components/NoEditPermissionNotice.js +3 -2
- package/dist/editor/components/ReadOnlyDraftNotice.d.ts +11 -0
- package/dist/editor/components/ReadOnlyDraftNotice.js +12 -0
- package/dist/editor/components/RenameEntryModal.js +1 -1
- package/dist/editor/components/StagedChangesDrawer.js +3 -3
- package/dist/editor/components/UndoToastMessage.d.ts +14 -0
- package/dist/editor/components/UndoToastMessage.js +9 -0
- package/dist/editor/components/UserBadge.js +9 -5
- package/dist/editor/copy.d.ts +14 -0
- package/dist/editor/copy.js +14 -0
- package/dist/editor/fields/BlockField.d.ts +5 -0
- package/dist/editor/fields/BlockField.js +38 -32
- package/dist/editor/fields/CodeField.d.ts +2 -0
- package/dist/editor/fields/CodeField.js +5 -2
- package/dist/editor/fields/DateTimeField.d.ts +2 -0
- package/dist/editor/fields/DateTimeField.js +5 -2
- package/dist/editor/fields/FieldCrashFallback.d.ts +3 -3
- package/dist/editor/fields/FieldCrashFallback.js +4 -4
- package/dist/editor/fields/FieldLabel.d.ts +24 -0
- package/dist/editor/fields/FieldLabel.js +9 -0
- package/dist/editor/fields/ImageField.d.ts +4 -0
- package/dist/editor/fields/ImageField.js +17 -8
- package/dist/editor/fields/InlineGroupField.js +4 -3
- package/dist/editor/fields/MarkdownField.d.ts +6 -0
- package/dist/editor/fields/MarkdownField.js +41 -11
- package/dist/editor/fields/MdxImageDialog.js +1 -1
- package/dist/editor/fields/NumberField.d.ts +2 -0
- package/dist/editor/fields/NumberField.js +4 -2
- package/dist/editor/fields/NumberListField.d.ts +2 -0
- package/dist/editor/fields/NumberListField.js +4 -2
- package/dist/editor/fields/ObjectField.d.ts +1 -0
- package/dist/editor/fields/ObjectField.js +5 -4
- package/dist/editor/fields/ReferenceField.d.ts +2 -0
- package/dist/editor/fields/ReferenceField.js +9 -3
- package/dist/editor/fields/SelectField.d.ts +2 -0
- package/dist/editor/fields/SelectField.js +8 -2
- package/dist/editor/fields/StringListField.d.ts +2 -0
- package/dist/editor/fields/StringListField.js +5 -2
- package/dist/editor/fields/TextField.d.ts +2 -0
- package/dist/editor/fields/TextField.js +5 -2
- package/dist/editor/fields/ToggleField.d.ts +2 -0
- package/dist/editor/fields/ToggleField.js +6 -3
- package/dist/editor/fields/entry-link/InsertEntryLink.js +1 -1
- package/dist/editor/fields/list-item-keys.d.ts +8 -0
- package/dist/editor/fields/list-item-keys.js +50 -0
- package/dist/editor/group-manager/GroupCard.js +1 -1
- package/dist/editor/group-manager/GroupForm.js +1 -1
- package/dist/editor/group-manager/InternalGroupsTab.js +1 -1
- package/dist/editor/group-manager/MemberList.js +1 -1
- package/dist/editor/group-manager/hooks/useGroupState.d.ts +1 -0
- package/dist/editor/group-manager/hooks/useGroupState.js +1 -1
- package/dist/editor/group-manager/index.js +26 -2
- package/dist/editor/hooks/useBranchActions.js +2 -2
- package/dist/editor/hooks/useBranchManager.js +36 -22
- package/dist/editor/hooks/useDraftManager.d.ts +8 -0
- package/dist/editor/hooks/useDraftManager.js +27 -5
- package/dist/editor/hooks/useEditorLayout.d.ts +45 -3
- package/dist/editor/hooks/useEditorLayout.js +97 -7
- package/dist/editor/hooks/useUserMetadata.js +12 -1
- package/dist/editor/media/AssetCard.js +1 -1
- package/dist/editor/media/CropStep.js +6 -1
- package/dist/editor/media/MediaLibraryBody.js +3 -3
- package/dist/editor/permission-manager/PermissionEditor.js +3 -3
- package/dist/editor/permission-manager/index.js +1 -1
- package/dist/editor/preview-bridge.js +2 -2
- package/dist/editor/schema-editor/CollectionEditor.js +1 -1
- package/dist/editor/schema-editor/EntryTypeEditor.js +1 -1
- package/dist/editor/theme.d.ts +1 -1
- package/dist/editor/theme.js +11 -11
- package/dist/editor/undo-removal.d.ts +44 -0
- package/dist/editor/undo-removal.js +129 -0
- package/dist/editor/user-display.d.ts +4 -0
- package/dist/editor/user-display.js +5 -0
- package/dist/editor/utils/confirm-modal.d.ts +8 -0
- package/dist/editor/utils/confirm-modal.js +12 -0
- package/dist/entry-link-resolver.d.ts +11 -1
- package/dist/entry-link-resolver.js +65 -5
- package/dist/git-manager.d.ts +6 -6
- package/dist/git-manager.js +16 -15
- package/dist/github-service.d.ts +25 -1
- package/dist/github-service.js +65 -6
- package/dist/http/handler.js +2 -1
- package/dist/static/seo.d.ts +5 -5
- package/dist/static/seo.js +5 -5
- package/dist/system-users.d.ts +12 -0
- package/dist/system-users.js +12 -0
- package/dist/types.d.ts +9 -1
- package/dist/utils/error.js +4 -3
- package/dist/utils/escape-text.d.ts +7 -0
- package/dist/utils/escape-text.js +27 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/branch-policy.d.ts +124 -0
- package/dist/worker/branch-policy.js +243 -0
- package/dist/worker/bundle-header.d.ts +117 -0
- package/dist/worker/bundle-header.js +253 -0
- package/dist/worker/cms-worker.d.ts +68 -17
- package/dist/worker/cms-worker.js +116 -33
- package/dist/worker/gateway-egress.d.ts +43 -0
- package/dist/worker/gateway-egress.js +209 -0
- package/dist/worker/gateway-instance.d.ts +42 -0
- package/dist/worker/gateway-instance.js +129 -0
- package/dist/worker/git-process.d.ts +81 -0
- package/dist/worker/git-process.js +234 -0
- package/dist/worker/git-sync.d.ts +8 -7
- package/dist/worker/git-sync.js +184 -74
- package/dist/worker/github-gateway-http.d.ts +62 -0
- package/dist/worker/github-gateway-http.js +977 -0
- package/dist/worker/github-gateway-wire.d.ts +589 -0
- package/dist/worker/github-gateway-wire.js +484 -0
- package/dist/worker/github-gateway.d.ts +152 -58
- package/dist/worker/github-gateway.js +485 -129
- package/dist/worker/github-mirror-upkeep.d.ts +75 -0
- package/dist/worker/github-mirror-upkeep.js +266 -0
- package/dist/worker/github-mirror.d.ts +271 -71
- package/dist/worker/github-mirror.js +755 -238
- package/dist/worker/github-transfer.d.ts +56 -0
- package/dist/worker/github-transfer.js +444 -0
- package/dist/worker/self-checks.d.ts +107 -0
- package/dist/worker/self-checks.js +358 -0
- package/dist/worker/shared-repo-git.d.ts +20 -7
- package/dist/worker/shared-repo-git.js +51 -22
- package/dist/worker/stale-mirror.d.ts +82 -0
- package/dist/worker/stale-mirror.js +130 -0
- package/dist/worker/task-runner.d.ts +2 -0
- package/dist/worker/task-runner.js +49 -20
- package/dist/worker/worker-context.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef, useState } from 'react';
|
|
4
|
-
import { Alert, Button,
|
|
4
|
+
import { Alert, Button, Paper, Stack, Text } from '@mantine/core';
|
|
5
5
|
import { IconAlertCircle, IconInfoCircle } from '@tabler/icons-react';
|
|
6
6
|
import { MarkdownField } from './fields/MarkdownField.js';
|
|
7
7
|
import { useSiteMdxAllow } from './context/index.js';
|
|
@@ -19,13 +19,16 @@ import { ReferenceField } from './fields/ReferenceField.js';
|
|
|
19
19
|
import { CodeField } from './fields/CodeField.js';
|
|
20
20
|
import { ImageField } from './fields/ImageField.js';
|
|
21
21
|
import { ObjectField } from './fields/ObjectField.js';
|
|
22
|
-
import {
|
|
22
|
+
import { groupDescriptionProps } from './fields/FieldDescription.js';
|
|
23
|
+
import { FieldLabel } from './fields/FieldLabel.js';
|
|
24
|
+
import { EDITOR_ACTIONS } from './copy.js';
|
|
23
25
|
import { InlineGroupField } from './fields/InlineGroupField.js';
|
|
24
26
|
import { formatCanopyPath, normalizeCanopyPath } from './canopy-path.js';
|
|
25
27
|
import { FieldWrapper } from './comments/FieldWrapper.js';
|
|
26
28
|
import { EntryComments } from './comments/EntryComments.js';
|
|
27
29
|
import { EditorErrorBoundary } from './components/EditorErrorBoundary.js';
|
|
28
30
|
import { FieldCrashFallback } from './fields/FieldCrashFallback.js';
|
|
31
|
+
import { useListItemKeys } from './fields/list-item-keys.js';
|
|
29
32
|
/**
|
|
30
33
|
* Card heading for an object-list item: the value of its `itemTitleField` when that is a
|
|
31
34
|
* non-blank string or a number, otherwise `fallback`.
|
|
@@ -38,12 +41,48 @@ const listItemTitle = (item, itemTitleField, fallback) => {
|
|
|
38
41
|
return raw.trim();
|
|
39
42
|
return fallback;
|
|
40
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* How an Undo toast names a removed object-list item: by its title field or first non-empty
|
|
46
|
+
* text field, since a positional "#2" title passes to the next item once this one is gone.
|
|
47
|
+
*/
|
|
48
|
+
const removedItemLabel = (item, objectField, listLabel, index) => {
|
|
49
|
+
const named = listItemTitle(item, objectField.itemTitleField, '');
|
|
50
|
+
const text = named ||
|
|
51
|
+
objectField.fields
|
|
52
|
+
.filter((f) => f.type === 'string')
|
|
53
|
+
.map((f) => item?.[f.name])
|
|
54
|
+
.find((v) => typeof v === 'string' && v.trim() !== '')
|
|
55
|
+
?.trim();
|
|
56
|
+
if (!text)
|
|
57
|
+
return `item ${index + 1} from ${listLabel}`;
|
|
58
|
+
return `"${text.length > 60 ? `${text.slice(0, 59)}…` : text}" from ${listLabel}`;
|
|
59
|
+
};
|
|
41
60
|
const normalizeOptions = (options) => {
|
|
42
61
|
if (!options)
|
|
43
62
|
return [];
|
|
44
63
|
return options.map((opt) => (typeof opt === 'string' ? { label: opt, value: opt } : opt));
|
|
45
64
|
};
|
|
46
65
|
const fieldKey = (path) => formatCanopyPath(path);
|
|
66
|
+
const noop = () => { };
|
|
67
|
+
const FENCE_STYLE = { border: 0, padding: 0, margin: 0, minWidth: 0 };
|
|
68
|
+
const READ_ONLY_FORM_CLASS = 'canopy-read-only-form';
|
|
69
|
+
/** Read-only inputs look disabled but stay focusable, so a reviewer can select and copy them. */
|
|
70
|
+
const ReadOnlyFormStyles = () => (_jsx("style", { children: `
|
|
71
|
+
.${READ_ONLY_FORM_CLASS} .mantine-Input-input:is([readonly], :has(input[readonly])) {
|
|
72
|
+
background-color: var(--input-disabled-bg);
|
|
73
|
+
}
|
|
74
|
+
.${READ_ONLY_FORM_CLASS} .canopy-mdx-content {
|
|
75
|
+
background-color: var(--mantine-color-gray-1);
|
|
76
|
+
}
|
|
77
|
+
.${READ_ONLY_FORM_CLASS} .mantine-Switch-label {
|
|
78
|
+
color: var(--mantine-color-text);
|
|
79
|
+
}
|
|
80
|
+
` }));
|
|
81
|
+
/**
|
|
82
|
+
* Disables a custom renderer's native controls on a read-only form, whether or not it honours
|
|
83
|
+
* `readOnly`. It wraps the control, never its `FieldWrapper`, so review comments stay open.
|
|
84
|
+
*/
|
|
85
|
+
const ReadOnlyFence = ({ readOnly, children, }) => (_jsx("fieldset", { disabled: readOnly, role: "presentation", style: FENCE_STYLE, children: children }));
|
|
47
86
|
/** Builds the control inside the field's boundary: a custom renderer is called, not mounted. */
|
|
48
87
|
const FieldControl = ({ build }) => _jsx(_Fragment, { children: build() });
|
|
49
88
|
/**
|
|
@@ -64,54 +103,12 @@ const FieldBoundary = ({ canopyPath, resetKey, update, build, fallback }) => {
|
|
|
64
103
|
setGeneration(liveGeneration.current);
|
|
65
104
|
}, fallback: fallback, children: _jsx(FieldControl, { build: () => build(guardedUpdate) }) }));
|
|
66
105
|
};
|
|
67
|
-
export const FormRenderer = ({ fields, value, onChange, customRenderers, branch = 'main', comments = [], currentEntryPath, currentUserId, canResolve = false, focusedFieldPath, highlightThreadId, onAddComment, onResolveThread, conflictNotice = false, fieldErrors, format, }) => {
|
|
106
|
+
export const FormRenderer = ({ fields, value, onChange, customRenderers, branch = 'main', comments = [], currentEntryPath, currentUserId, canResolve = false, focusedFieldPath, highlightThreadId, onAddComment, onResolveThread, conflictNotice = false, fieldErrors, format, readOnly = false, onRemoved, onGetUserMetadata, }) => {
|
|
107
|
+
const emit = readOnly ? noop : onChange;
|
|
68
108
|
const boundaryResetKey = `${branch}\n${currentEntryPath ?? ''}`;
|
|
69
109
|
const siteMdxAllow = useSiteMdxAllow();
|
|
70
110
|
const bodyName = format === 'md' || format === 'mdx' ? findBodyFieldName(fields) : undefined;
|
|
71
|
-
|
|
72
|
-
// append remounts no item and a removal never hands a crashed item's boundary to the next one.
|
|
73
|
-
// A list whose length is unchanged (an edited item, the saved copy of the same items) keeps
|
|
74
|
-
// keys by position.
|
|
75
|
-
const listItemKeys = useRef(new WeakMap());
|
|
76
|
-
const lastListKeys = useRef(new Map());
|
|
77
|
-
const nextListItemKey = useRef(0);
|
|
78
|
-
const keysForList = (items, listPath) => {
|
|
79
|
-
const previous = lastListKeys.current.get(listPath);
|
|
80
|
-
const occurrences = new Map();
|
|
81
|
-
for (const item of items) {
|
|
82
|
-
if (typeof item === 'object' && item !== null) {
|
|
83
|
-
occurrences.set(item, (occurrences.get(item) ?? 0) + 1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Only an object listed once has an identity; a repeated one is keyed by position.
|
|
87
|
-
const single = (item) => typeof item === 'object' && item !== null && occurrences.get(item) === 1;
|
|
88
|
-
const claimed = new Set();
|
|
89
|
-
const keys = items.map((item) => {
|
|
90
|
-
const own = single(item) ? listItemKeys.current.get(item) : undefined;
|
|
91
|
-
// Two objects can hold one key, an edited copy having inherited its original's.
|
|
92
|
-
if (own === undefined || claimed.has(own))
|
|
93
|
-
return undefined;
|
|
94
|
-
claimed.add(own);
|
|
95
|
-
return own;
|
|
96
|
-
});
|
|
97
|
-
// The rest inherit their position's key, never one an object present here holds.
|
|
98
|
-
const resolved = keys.map((key, idx) => {
|
|
99
|
-
if (key !== undefined)
|
|
100
|
-
return key;
|
|
101
|
-
let next = previous?.length === items.length ? previous[idx] : undefined;
|
|
102
|
-
if (next === undefined || claimed.has(next)) {
|
|
103
|
-
nextListItemKey.current += 1;
|
|
104
|
-
next = `item-${nextListItemKey.current}`;
|
|
105
|
-
}
|
|
106
|
-
claimed.add(next);
|
|
107
|
-
const item = items[idx];
|
|
108
|
-
if (single(item))
|
|
109
|
-
listItemKeys.current.set(item, next);
|
|
110
|
-
return next;
|
|
111
|
-
});
|
|
112
|
-
lastListKeys.current.set(listPath, resolved);
|
|
113
|
-
return resolved;
|
|
114
|
-
};
|
|
111
|
+
const keysForList = useListItemKeys();
|
|
115
112
|
// Wraps the rendered control in an error boundary, and with an inline validation message
|
|
116
113
|
// when this field has an active error (keyed by canonical canopy path, so errors land on
|
|
117
114
|
// nested object/block fields too). Passed down to BlockField/ObjectField so nested fields
|
|
@@ -119,7 +116,7 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
119
116
|
const renderField = (field, currentValue, update, path) => {
|
|
120
117
|
const canopyPath = normalizeCanopyPath(path);
|
|
121
118
|
const error = fieldErrors?.[canopyPath];
|
|
122
|
-
return (_jsxs(Stack, { gap: 4, children: [_jsx(FieldBoundary, { canopyPath: canopyPath, resetKey: boundaryResetKey, update: update, build: (guardedUpdate) => renderFieldControl(field, currentValue, guardedUpdate, path), fallback: (caught) => (_jsx(FieldCrashFallback, { label: field.label ?? field.name, fieldType: field.type, value: currentValue, onChange: update, caught: caught, dataCanopyField: canopyPath })) }), error && (_jsx(Text, { size: "xs", c: "red", "data-testid": `field-error-${fieldKey(path)}`, children: error }))] }, fieldKey(path)));
|
|
119
|
+
return (_jsxs(Stack, { gap: 4, children: [_jsx(FieldBoundary, { canopyPath: canopyPath, resetKey: boundaryResetKey, update: update, build: (guardedUpdate) => renderFieldControl(field, currentValue, guardedUpdate, path), fallback: (caught) => (_jsx(FieldCrashFallback, { label: field.label ?? field.name, fieldType: field.type, value: currentValue, onChange: readOnly ? undefined : update, caught: caught, dataCanopyField: canopyPath })) }), error && (_jsx(Text, { size: "xs", c: "red", "data-testid": `field-error-${fieldKey(path)}`, children: error }))] }, fieldKey(path)));
|
|
123
120
|
};
|
|
124
121
|
const renderFieldControl = (field, currentValue, update, path) => {
|
|
125
122
|
const fieldId = `field-${fieldKey(path).replace(/[^a-zA-Z0-9_-]/g, '-')}`;
|
|
@@ -131,47 +128,48 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
131
128
|
: [];
|
|
132
129
|
const custom = customRenderers?.[field.type];
|
|
133
130
|
if (custom) {
|
|
134
|
-
const renderedField = (_jsx(
|
|
131
|
+
const renderedField = (_jsx(ReadOnlyFence, { readOnly: readOnly, children: custom({
|
|
135
132
|
field,
|
|
136
133
|
value: currentValue,
|
|
137
|
-
onChange: update,
|
|
134
|
+
onChange: readOnly ? noop : update,
|
|
138
135
|
path,
|
|
139
136
|
id: fieldId,
|
|
137
|
+
readOnly,
|
|
140
138
|
}) }, fieldKey(path)));
|
|
141
139
|
if (currentEntryPath && currentUserId && onAddComment && onResolveThread) {
|
|
142
|
-
return (_jsx(FieldWrapper, { canopyPath: canopyPath, entryPath: currentEntryPath, threads: fieldThreads, autoFocus: focusedFieldPath === canopyPath, currentUserId: currentUserId, canResolve: canResolve, onAddComment: onAddComment, onResolveThread: onResolveThread, highlightThreadId: highlightThreadId, children: renderedField }, fieldKey(path)));
|
|
140
|
+
return (_jsx(FieldWrapper, { canopyPath: canopyPath, entryPath: currentEntryPath, threads: fieldThreads, autoFocus: focusedFieldPath === canopyPath, currentUserId: currentUserId, canResolve: canResolve, onAddComment: onAddComment, onResolveThread: onResolveThread, highlightThreadId: highlightThreadId, onGetUserMetadata: onGetUserMetadata, children: renderedField }, fieldKey(path)));
|
|
143
141
|
}
|
|
144
142
|
return renderedField;
|
|
145
143
|
}
|
|
146
144
|
const label = field.label ?? field.name;
|
|
147
145
|
const wrapWithComments = (renderedField) => {
|
|
148
146
|
if (currentEntryPath && currentUserId && onAddComment && onResolveThread) {
|
|
149
|
-
return (_jsx(FieldWrapper, { canopyPath: canopyPath, entryPath: currentEntryPath, threads: fieldThreads, autoFocus: focusedFieldPath === canopyPath, currentUserId: currentUserId, canResolve: canResolve, onAddComment: onAddComment, onResolveThread: onResolveThread, highlightThreadId: highlightThreadId, children: renderedField }));
|
|
147
|
+
return (_jsx(FieldWrapper, { canopyPath: canopyPath, entryPath: currentEntryPath, threads: fieldThreads, autoFocus: focusedFieldPath === canopyPath, currentUserId: currentUserId, canResolve: canResolve, onAddComment: onAddComment, onResolveThread: onResolveThread, highlightThreadId: highlightThreadId, onGetUserMetadata: onGetUserMetadata, children: renderedField }));
|
|
150
148
|
}
|
|
151
149
|
return renderedField;
|
|
152
150
|
};
|
|
153
151
|
switch (field.type) {
|
|
154
152
|
case 'string':
|
|
155
153
|
if (field.list) {
|
|
156
|
-
return wrapWithComments(_jsx(StringListField, { id: fieldId, label: label, description: field.description, value: Array.isArray(currentValue) ? currentValue : [], onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
154
|
+
return wrapWithComments(_jsx(StringListField, { id: fieldId, label: label, description: field.description, value: Array.isArray(currentValue) ? currentValue : [], onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
157
155
|
}
|
|
158
|
-
return wrapWithComments(_jsx(TextField, { id: fieldId, label: label, description: field.description, value: currentValue ?? '', onChange: update, dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
156
|
+
return wrapWithComments(_jsx(TextField, { id: fieldId, label: label, description: field.description, value: currentValue ?? '', onChange: update, dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
159
157
|
case 'boolean':
|
|
160
|
-
return wrapWithComments(_jsx(ToggleField, { id: fieldId, label: label, description: field.description, value: Boolean(currentValue), onChange: (v) => update(Boolean(v)), dataCanopyField: normalizeCanopyPath(path), testId: `field-toggle-${field.name}
|
|
158
|
+
return wrapWithComments(_jsx(ToggleField, { id: fieldId, label: label, description: field.description, value: Boolean(currentValue), onChange: (v) => update(Boolean(v)), dataCanopyField: normalizeCanopyPath(path), testId: `field-toggle-${field.name}`, readOnly: readOnly }, fieldKey(path)));
|
|
161
159
|
case 'number':
|
|
162
160
|
if (field.list) {
|
|
163
161
|
return wrapWithComments(_jsx(NumberListField, { id: fieldId, label: label, description: field.description, value: Array.isArray(currentValue)
|
|
164
162
|
? currentValue.filter((v) => typeof v === 'number')
|
|
165
|
-
: [], onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
163
|
+
: [], onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
166
164
|
}
|
|
167
|
-
return wrapWithComments(_jsx(NumberField, { id: fieldId, label: label, description: field.description, value: typeof currentValue === 'number' ? currentValue : undefined, onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
165
|
+
return wrapWithComments(_jsx(NumberField, { id: fieldId, label: label, description: field.description, value: typeof currentValue === 'number' ? currentValue : undefined, onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
168
166
|
case 'datetime':
|
|
169
|
-
return wrapWithComments(_jsx(DateTimeField, { id: fieldId, label: label, description: field.description, value: typeof currentValue === 'string' ? currentValue : '', onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
167
|
+
return wrapWithComments(_jsx(DateTimeField, { id: fieldId, label: label, description: field.description, value: typeof currentValue === 'string' ? currentValue : '', onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
170
168
|
case 'markdown':
|
|
171
169
|
case 'mdx': {
|
|
172
170
|
const isBody = path.length === 1 && path[0] === bodyName;
|
|
173
171
|
const policy = markdownPolicyOf(field, siteMdxAllow, isBody ? format : undefined);
|
|
174
|
-
return wrapWithComments(_jsx(MarkdownField, { id: fieldId, label: label, description: field.description, value: currentValue ?? '', onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), htmlTags: policy?.dialect === 'mdx' ? policy.allow.htmlTags : undefined }, fieldKey(path)));
|
|
172
|
+
return wrapWithComments(_jsx(MarkdownField, { id: fieldId, label: label, description: field.description, value: currentValue ?? '', onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), htmlTags: policy?.dialect === 'mdx' ? policy.allow.htmlTags : undefined, readOnly: readOnly }, fieldKey(path)));
|
|
175
173
|
}
|
|
176
174
|
case 'select': {
|
|
177
175
|
const selectField = field;
|
|
@@ -181,7 +179,7 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
181
179
|
? Array.isArray(currentValue)
|
|
182
180
|
? currentValue
|
|
183
181
|
: []
|
|
184
|
-
: (currentValue ?? ''), multiple: isMulti, onChange: (next) => update(next), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
182
|
+
: (currentValue ?? ''), multiple: isMulti, onChange: (next) => update(next), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
185
183
|
}
|
|
186
184
|
case 'reference': {
|
|
187
185
|
const referenceField = field;
|
|
@@ -196,7 +194,7 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
196
194
|
? Array.isArray(currentValue)
|
|
197
195
|
? currentValue
|
|
198
196
|
: []
|
|
199
|
-
: (currentValue ?? ''), multiple: isMulti, onChange: (next) => update(next), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
197
|
+
: (currentValue ?? ''), multiple: isMulti, onChange: (next) => update(next), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
200
198
|
}
|
|
201
199
|
case 'image': {
|
|
202
200
|
const imageField = field;
|
|
@@ -204,11 +202,18 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
204
202
|
src: fieldErrors?.[`${canopyPath}.src`],
|
|
205
203
|
alt: fieldErrors?.[`${canopyPath}.alt`],
|
|
206
204
|
crop: fieldErrors?.[`${canopyPath}.crop`],
|
|
207
|
-
} }, fieldKey(path)));
|
|
205
|
+
}, readOnly: readOnly, onRemoved: (removed) => onRemoved?.({ kind: 'value', path, value: removed, label: `the image from ${label}` }) }, fieldKey(path)));
|
|
208
206
|
}
|
|
209
207
|
case 'block': {
|
|
210
208
|
const blockField = field;
|
|
211
|
-
return wrapWithComments(_jsx(BlockField, { label: label, description: field.description, templates: blockField.templates, value: (Array.isArray(currentValue) ? currentValue : []), onChange: (next) => update(next), renderField: renderField, path: path, dataCanopyField: normalizeCanopyPath(path)
|
|
209
|
+
return wrapWithComments(_jsx(BlockField, { label: label, required: field.required, description: field.description, templates: blockField.templates, value: (Array.isArray(currentValue) ? currentValue : []), onChange: (next) => update(next), renderField: renderField, path: path, dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly, onRemoved: (index, block) => onRemoved?.({
|
|
210
|
+
kind: 'list-item',
|
|
211
|
+
listPath: path,
|
|
212
|
+
index,
|
|
213
|
+
item: block,
|
|
214
|
+
label: `"${blockField.templates.find((t) => t.name === block.template)?.label ??
|
|
215
|
+
block.template}" from ${label}`,
|
|
216
|
+
}) }, fieldKey(path)));
|
|
212
217
|
}
|
|
213
218
|
case 'object': {
|
|
214
219
|
const objectField = field;
|
|
@@ -217,14 +222,26 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
217
222
|
? currentValue
|
|
218
223
|
: [];
|
|
219
224
|
const itemKeys = keysForList(items, fieldKey(path));
|
|
220
|
-
return wrapWithComments(_jsx(Paper, { withBorder: true,
|
|
225
|
+
return wrapWithComments(_jsx(Paper, { withBorder: true, p: "md", shadow: "xs", ...groupDescriptionProps(fieldId, field.description), role: "group", "aria-label": label, "data-removal-focus": true, tabIndex: -1, children: _jsxs(Stack, { gap: "sm", children: [_jsx(FieldLabel, { label: label, required: field.required, description: field.description, descriptionBaseId: fieldId, actions: !readOnly && (_jsx(Button, { variant: "light", onClick: () => update([...items, {}]), children: "Add item" })) }), _jsxs(Stack, { gap: "sm", children: [items.map((item, idx) => {
|
|
221
226
|
const itemTitle = listItemTitle(item, objectField.itemTitleField, `${label} #${idx + 1}`);
|
|
222
|
-
return (_jsx(Paper, { role: "group", "aria-label": itemTitle, withBorder: true,
|
|
227
|
+
return (_jsx(Paper, { role: "group", "aria-label": itemTitle, withBorder: true, p: "sm", shadow: "xs", children: _jsxs(Stack, { gap: "xs", children: [_jsx(FieldLabel, { label: itemTitle, actions: !readOnly && (_jsx(Button, { variant: "subtle", color: "red", onClick: (event) => {
|
|
228
|
+
// The row goes, so focus moves to its list, not the page.
|
|
229
|
+
const list = event.currentTarget.closest('[data-removal-focus]');
|
|
230
|
+
update(items.filter((_, i) => i !== idx));
|
|
231
|
+
list?.focus();
|
|
232
|
+
onRemoved?.({
|
|
233
|
+
kind: 'list-item',
|
|
234
|
+
listPath: path,
|
|
235
|
+
index: idx,
|
|
236
|
+
item,
|
|
237
|
+
label: removedItemLabel(item, objectField, label, idx),
|
|
238
|
+
});
|
|
239
|
+
}, children: EDITOR_ACTIONS.remove })) }), _jsx(ObjectField, { fields: objectField.fields, value: item, onChange: (next) => {
|
|
223
240
|
const nextItems = [...items];
|
|
224
241
|
nextItems[idx] = next;
|
|
225
242
|
update(nextItems);
|
|
226
243
|
}, renderField: renderField, path: [...path, idx], dataCanopyField: normalizeCanopyPath([...path, idx]) })] }) }, itemKeys[idx]));
|
|
227
|
-
}), items.length === 0 && (_jsx(Text, { size: "xs", c: "dimmed", children:
|
|
244
|
+
}), items.length === 0 && (_jsx(Text, { size: "xs", c: "dimmed", children: readOnly ? 'No items.' : 'No items yet. Add one to get started.' }))] })] }) }, fieldKey(path)));
|
|
228
245
|
}
|
|
229
246
|
// Unlike the list branch above (each item has its own Remove button), a
|
|
230
247
|
// non-list object has no other way back to `undefined`: a required child
|
|
@@ -235,23 +252,25 @@ export const FormRenderer = ({ fields, value, onChange, customRenderers, branch
|
|
|
235
252
|
// already has a value, and labeled "Clear" rather than "Remove" so it
|
|
236
253
|
// doesn't read as deleting the field from the schema.
|
|
237
254
|
const hasValue = currentValue !== undefined && currentValue !== null;
|
|
238
|
-
const canClear = objectField.required !== true && hasValue;
|
|
239
|
-
return wrapWithComments(_jsx(ObjectField, { label: label, description: field.description, fields: objectField.fields, value: currentValue, onChange: (next) => update(next), onRemove: canClear ? () => update(undefined) : undefined, renderField: renderField, path: path, dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
255
|
+
const canClear = !readOnly && objectField.required !== true && hasValue;
|
|
256
|
+
return wrapWithComments(_jsx(ObjectField, { label: label, required: objectField.required, description: field.description, fields: objectField.fields, value: currentValue, onChange: (next) => update(next), onRemove: canClear ? () => update(undefined) : undefined, renderField: renderField, path: path, dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
240
257
|
}
|
|
241
258
|
case 'code':
|
|
242
|
-
return wrapWithComments(_jsx(CodeField, { id: fieldId, label: label, description: field.description, value: typeof currentValue === 'string' ? currentValue : '', onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path) }, fieldKey(path)));
|
|
259
|
+
return wrapWithComments(_jsx(CodeField, { id: fieldId, label: label, description: field.description, value: typeof currentValue === 'string' ? currentValue : '', onChange: (v) => update(v), dataCanopyField: normalizeCanopyPath(path), readOnly: readOnly }, fieldKey(path)));
|
|
243
260
|
default:
|
|
244
261
|
return (_jsxs(Text, { size: "xs", c: "dimmed", children: ["Unsupported field: ", field.type] }, fieldKey(path)));
|
|
245
262
|
}
|
|
246
263
|
};
|
|
247
|
-
return (_jsxs(Stack, { gap: "md", "data-form-renderer": true, children: [currentEntryPath && currentUserId && onAddComment && onResolveThread && (_jsx(EntryComments, { comments: comments, entryPath: currentEntryPath, currentUserId: currentUserId, canResolve: canResolve, onAddComment: onAddComment, onResolveThread: onResolveThread, highlightThreadId: highlightThreadId })), conflictNotice && (_jsx(Alert, { icon: _jsx(IconInfoCircle, { size: 16 }), color: "orange", variant: "light", title: "Page updated since your draft started", "data-testid": "conflict-alert", children:
|
|
264
|
+
return (_jsxs(Stack, { gap: "md", "data-form-renderer": true, className: readOnly ? READ_ONLY_FORM_CLASS : undefined, children: [readOnly && _jsx(ReadOnlyFormStyles, {}), currentEntryPath && currentUserId && onAddComment && onResolveThread && (_jsx(EntryComments, { comments: comments, entryPath: currentEntryPath, currentUserId: currentUserId, canResolve: canResolve, onAddComment: onAddComment, onResolveThread: onResolveThread, highlightThreadId: highlightThreadId, onGetUserMetadata: onGetUserMetadata })), conflictNotice && (_jsx(Alert, { icon: _jsx(IconInfoCircle, { size: 16 }), color: "orange", variant: "light", title: "Page updated since your draft started", "data-testid": "conflict-alert", children: readOnly
|
|
265
|
+
? 'Someone else has recently changed this page.'
|
|
266
|
+
: 'Someone else has recently changed this page. You can keep editing — a reviewer will reconcile your changes when you submit.' })), fieldErrors && Object.keys(fieldErrors).length > 0 && (_jsx(Alert, { icon: _jsx(IconAlertCircle, { size: 16 }), color: "red", variant: "light", title: "Fix these issues before saving", "data-testid": "validation-alert", children: _jsx(Stack, { gap: 2, children: Object.entries(fieldErrors).map(([path, message]) => (_jsxs(Text, { size: "xs", children: [path, ": ", message] }, path))) }) })), fields.map((field) => {
|
|
248
267
|
// Inline groups are transparent to the value — render them directly with parent value/onChange
|
|
249
268
|
if (field.type === 'group') {
|
|
250
269
|
const groupField = field;
|
|
251
|
-
return (_jsx("div", { children: _jsx(InlineGroupField, { label: groupField.label, description: groupField.description, fields: groupField.fields, value: value, onChange:
|
|
270
|
+
return (_jsx("div", { children: _jsx(InlineGroupField, { label: groupField.label, description: groupField.description, fields: groupField.fields, value: value, onChange: emit, renderField: renderField, path: [] }) }, `group-${groupField.name}`));
|
|
252
271
|
}
|
|
253
272
|
const val = value[field.name];
|
|
254
273
|
const path = [field.name];
|
|
255
|
-
return (_jsx("div", { children: renderField(field, val, (next) =>
|
|
274
|
+
return (_jsx("div", { children: renderField(field, val, (next) => emit({ ...value, [field.name]: next }), path) }, fieldKey(path)));
|
|
256
275
|
})] }));
|
|
257
276
|
};
|
|
@@ -6,7 +6,9 @@ export interface PreviewMarks {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Lightweight iframe wrapper to keep the preview in sync with form state.
|
|
9
|
-
* It posts the latest draft data to the iframe after load and when data changes.
|
|
9
|
+
* It posts the latest draft data to the iframe after load and when data changes. A progress bar
|
|
10
|
+
* runs until the preview's ready message arrives; when none does, a "Live updates off" chip offers
|
|
11
|
+
* to reload the preview.
|
|
10
12
|
*/
|
|
11
13
|
export declare const PreviewFrame: ({ src, path, data, isLoading, className, style, highlightEnabled, onPreviewError, onMarks, assetBase, }: {
|
|
12
14
|
src: string;
|
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { CANOPY_PREVIEW_ERROR, CANOPY_PREVIEW_HIGHLIGHT, CANOPY_PREVIEW_MARKS, CANOPY_PREVIEW_MESSAGE, CANOPY_PREVIEW_READY, isOpaqueOrigin, MARK_REPORT_LIMITS, resolveMessageOrigin, } from './preview-bridge.js';
|
|
5
|
+
/**
|
|
6
|
+
* How long after the iframe's `load` the preview has to send its ready message before the frame
|
|
7
|
+
* says live updates are off. Ready can also arrive before `load`, which waits for images too.
|
|
8
|
+
*/
|
|
9
|
+
const READY_TIMEOUT_MS = 5000;
|
|
10
|
+
const LIVE_UPDATES_OFF_HELP = "The preview didn't connect, so your edits won't show in it until it reconnects. Retry reloads the preview; your edits are kept.";
|
|
11
|
+
const visuallyHidden = {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
width: 1,
|
|
14
|
+
height: 1,
|
|
15
|
+
padding: 0,
|
|
16
|
+
margin: -1,
|
|
17
|
+
overflow: 'hidden',
|
|
18
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
19
|
+
whiteSpace: 'nowrap',
|
|
20
|
+
border: 0,
|
|
21
|
+
};
|
|
5
22
|
const isMarkPaths = (paths) => Array.isArray(paths) &&
|
|
6
23
|
paths.length <= MARK_REPORT_LIMITS.paths &&
|
|
7
24
|
paths.every((path) => typeof path === 'string' && path.length <= MARK_REPORT_LIMITS.pathLength);
|
|
@@ -15,7 +32,9 @@ const sendDraftUpdate = (iframe, message, targetOrigin) => {
|
|
|
15
32
|
};
|
|
16
33
|
/**
|
|
17
34
|
* Lightweight iframe wrapper to keep the preview in sync with form state.
|
|
18
|
-
* It posts the latest draft data to the iframe after load and when data changes.
|
|
35
|
+
* It posts the latest draft data to the iframe after load and when data changes. A progress bar
|
|
36
|
+
* runs until the preview's ready message arrives; when none does, a "Live updates off" chip offers
|
|
37
|
+
* to reload the preview.
|
|
19
38
|
*/
|
|
20
39
|
export const PreviewFrame = ({ src, path, data, isLoading, className, style, highlightEnabled, onPreviewError, onMarks, assetBase, }) => {
|
|
21
40
|
const iframeRef = useRef(null);
|
|
@@ -23,14 +42,35 @@ export const PreviewFrame = ({ src, path, data, isLoading, className, style, hig
|
|
|
23
42
|
// and inbound messages must come from it. An iframe that navigates cross-origin
|
|
24
43
|
// silently stops participating in the bridge.
|
|
25
44
|
const previewOrigin = resolveMessageOrigin(src);
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
// Only the ready message clears the progress bar: `onLoad` can post the draft before the
|
|
46
|
+
// preview's listener exists, so only the re-post that ready triggers is sure to land.
|
|
47
|
+
const [handshake, setHandshake] = useState('waiting');
|
|
48
|
+
const [loaded, setLoaded] = useState(false);
|
|
49
|
+
// Retry and a new src each mount a fresh iframe rather than navigating the old one, so a late
|
|
50
|
+
// ready from the page it replaces fails the source check, and a late load has no handler.
|
|
51
|
+
const [retries, setRetries] = useState(0);
|
|
52
|
+
// A new src is a new page, with a handshake of its own.
|
|
29
53
|
const [prevSrc, setPrevSrc] = useState(src);
|
|
30
54
|
if (src !== prevSrc) {
|
|
31
55
|
setPrevSrc(src);
|
|
32
|
-
|
|
56
|
+
setHandshake('waiting');
|
|
57
|
+
setLoaded(false);
|
|
33
58
|
}
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!loaded || handshake !== 'waiting')
|
|
61
|
+
return;
|
|
62
|
+
// Functional, so a ready batched into the same render as this callback still wins.
|
|
63
|
+
const timer = setTimeout(() => setHandshake((current) => (current === 'waiting' ? 'missing' : current)), READY_TIMEOUT_MS);
|
|
64
|
+
return () => clearTimeout(timer);
|
|
65
|
+
}, [loaded, handshake]);
|
|
66
|
+
const retry = () => {
|
|
67
|
+
setHandshake('waiting');
|
|
68
|
+
setLoaded(false);
|
|
69
|
+
setRetries((count) => count + 1);
|
|
70
|
+
};
|
|
71
|
+
const hasDraft = data !== undefined;
|
|
72
|
+
const syncPending = hasDraft && handshake === 'waiting';
|
|
73
|
+
const liveUpdatesOff = hasDraft && handshake === 'missing';
|
|
34
74
|
// Inject the progress bar keyframe animation once per page.
|
|
35
75
|
useEffect(() => {
|
|
36
76
|
const styleId = 'canopycms-preview-sync-style';
|
|
@@ -97,7 +137,7 @@ export const PreviewFrame = ({ src, path, data, isLoading, className, style, hig
|
|
|
97
137
|
if (type === CANOPY_PREVIEW_READY) {
|
|
98
138
|
postRef.current();
|
|
99
139
|
postHighlightRef.current();
|
|
100
|
-
|
|
140
|
+
setHandshake('ready');
|
|
101
141
|
}
|
|
102
142
|
else if (type === CANOPY_PREVIEW_ERROR) {
|
|
103
143
|
const msg = event.data;
|
|
@@ -120,7 +160,7 @@ export const PreviewFrame = ({ src, path, data, isLoading, className, style, hig
|
|
|
120
160
|
window.addEventListener('message', handleMessage);
|
|
121
161
|
return () => window.removeEventListener('message', handleMessage);
|
|
122
162
|
}, [previewOrigin]);
|
|
123
|
-
return (_jsxs("div", { className: className, style: { position: 'relative', overflow: 'hidden', ...style }, children: [syncPending && (_jsx("div", { style: {
|
|
163
|
+
return (_jsxs("div", { className: className, style: { position: 'relative', overflow: 'hidden', ...style }, children: [syncPending && (_jsx("div", { role: "progressbar", "aria-label": "Connecting to the preview", style: {
|
|
124
164
|
position: 'absolute',
|
|
125
165
|
top: 0,
|
|
126
166
|
left: 0,
|
|
@@ -137,7 +177,29 @@ export const PreviewFrame = ({ src, path, data, isLoading, className, style, hig
|
|
|
137
177
|
background: 'var(--mantine-color-blue-filled, #228be6)',
|
|
138
178
|
borderRadius: '0 2px 2px 0',
|
|
139
179
|
animation: 'canopy-preview-sync 1.5s ease-in-out infinite',
|
|
140
|
-
} }) })), _jsx("
|
|
180
|
+
} }) })), _jsx("div", { role: "status", style: { position: 'absolute', top: 8, right: 8, zIndex: 1 }, children: liveUpdatesOff && (_jsxs("div", { style: {
|
|
181
|
+
display: 'flex',
|
|
182
|
+
alignItems: 'center',
|
|
183
|
+
gap: 6,
|
|
184
|
+
padding: '2px 4px 2px 10px',
|
|
185
|
+
borderRadius: 999,
|
|
186
|
+
border: '1px solid var(--mantine-color-gray-4, #ced4da)',
|
|
187
|
+
background: 'var(--mantine-color-white, #fff)',
|
|
188
|
+
boxShadow: 'var(--mantine-shadow-xs, 0 1px 3px rgba(0, 0, 0, 0.1))',
|
|
189
|
+
color: 'var(--mantine-color-gray-7, #495057)',
|
|
190
|
+
fontFamily: 'var(--mantine-font-family, inherit)',
|
|
191
|
+
fontSize: 12,
|
|
192
|
+
lineHeight: '20px',
|
|
193
|
+
}, children: [_jsx("span", { title: LIVE_UPDATES_OFF_HELP, children: "Live updates off" }), _jsx("span", { style: visuallyHidden, children: LIVE_UPDATES_OFF_HELP }), _jsx("button", { type: "button", onClick: retry, title: "Reload the preview", style: {
|
|
194
|
+
border: 'none',
|
|
195
|
+
borderRadius: 999,
|
|
196
|
+
padding: '0 8px',
|
|
197
|
+
background: 'transparent',
|
|
198
|
+
color: 'var(--mantine-color-blue-filled, #228be6)',
|
|
199
|
+
font: 'inherit',
|
|
200
|
+
fontWeight: 600,
|
|
201
|
+
cursor: 'pointer',
|
|
202
|
+
}, children: "Retry" })] })) }), _jsx("iframe", { ref: iframeRef, src: src, title: "Live preview", style: {
|
|
141
203
|
display: 'block',
|
|
142
204
|
position: 'absolute',
|
|
143
205
|
inset: 0,
|
|
@@ -147,5 +209,6 @@ export const PreviewFrame = ({ src, path, data, isLoading, className, style, hig
|
|
|
147
209
|
}, onLoad: () => {
|
|
148
210
|
post();
|
|
149
211
|
postHighlight();
|
|
150
|
-
|
|
212
|
+
setLoaded(true);
|
|
213
|
+
} }, `${retries}:${src}`)] }));
|
|
151
214
|
};
|