@standhigher/puck-page-builder 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/chunk-72MFV6J7.js +15 -0
- package/dist/chunk-G2LNCKYO.js +107 -0
- package/dist/chunk-RGB53WE6.js +180 -0
- package/dist/extensions.d.ts +148 -0
- package/dist/extensions.js +10 -0
- package/dist/index.d.ts +182 -0
- package/dist/index.js +911 -0
- package/dist/renderer.d.ts +12 -0
- package/dist/renderer.js +6 -0
- package/dist/schema.d.ts +59 -0
- package/dist/schema.js +10 -0
- package/package.json +68 -0
- package/src/styles.css +91 -0
- package/src/ui/builder/tokens.css +23 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { ExtensionRegistry } from './extensions.js';
|
|
4
|
+
export { BlockDefinition, DataSourceDefinition, EditorAction, EditorActionPosition, ExtensionActionContext, ExtensionRegistryError, ExtensionRegistryErrorCode, ExtensionRegistryOptions, ExtensionTarget, FieldConfig, FieldDefinition, FieldProps, LifecycleHooks, PageBuilderExtension, RendererDefinition, TemplateDefinition, UISlotContribution, UISlotName, ValidationIssue, createExtensionRegistry } from './extensions.js';
|
|
5
|
+
import { PageDocument, BlockNode, JsonValue } from './schema.js';
|
|
6
|
+
export { DataBinding, PageDocumentIssue, PageDocumentMigration, PageSettings, RenderTarget, createPageDocument, migratePageDocument, validatePageDocument } from './schema.js';
|
|
7
|
+
import { Data } from '@puckeditor/core';
|
|
8
|
+
export { WebRenderer, WebRendererProps } from './renderer.js';
|
|
9
|
+
|
|
10
|
+
type BlockView = "blocks" | "outline";
|
|
11
|
+
type Device = "desktop" | "tablet" | "mobile" | "full";
|
|
12
|
+
type Zoom = "auto" | "50" | "70" | "100";
|
|
13
|
+
type SaveState = "clean" | "dirty" | "saving" | "saved" | "failed" | "conflict";
|
|
14
|
+
type PreviewMode = "editor" | "mock-preview" | "live-preview";
|
|
15
|
+
type PublishState = "draft" | "publishing" | "published" | "publish-failed";
|
|
16
|
+
type DemoBlock = {
|
|
17
|
+
id: string;
|
|
18
|
+
type: "Hero" | "TrackingForm" | "Text";
|
|
19
|
+
label: string;
|
|
20
|
+
description: string;
|
|
21
|
+
title: string;
|
|
22
|
+
body: string;
|
|
23
|
+
};
|
|
24
|
+
type EditorState = {
|
|
25
|
+
blocks: DemoBlock[];
|
|
26
|
+
selectedBlockId: string | null;
|
|
27
|
+
blockView: BlockView;
|
|
28
|
+
device: Device;
|
|
29
|
+
zoom: Zoom;
|
|
30
|
+
saveState: SaveState;
|
|
31
|
+
previewMode: PreviewMode;
|
|
32
|
+
publishState: PublishState;
|
|
33
|
+
editorLocale: string;
|
|
34
|
+
pageLocale: string;
|
|
35
|
+
isPickerOpen: boolean;
|
|
36
|
+
isLeftRailOpen: boolean;
|
|
37
|
+
isRightPanelOpen: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type EditorShellProps = {
|
|
41
|
+
initialState?: Partial<EditorState>;
|
|
42
|
+
iframe?: boolean;
|
|
43
|
+
};
|
|
44
|
+
declare function EditorShell({ initialState, iframe }: EditorShellProps): react.JSX.Element;
|
|
45
|
+
|
|
46
|
+
type EditorLoadState = "loading" | "ready" | "empty" | "error" | "disabled" | "success";
|
|
47
|
+
type EditorActionState = {
|
|
48
|
+
canUndo: boolean;
|
|
49
|
+
canRedo: boolean;
|
|
50
|
+
canAdd: boolean;
|
|
51
|
+
canEdit: boolean;
|
|
52
|
+
canDelete: boolean;
|
|
53
|
+
canDuplicate: boolean;
|
|
54
|
+
canReorder: boolean;
|
|
55
|
+
};
|
|
56
|
+
type EditorContextValue = {
|
|
57
|
+
document: PageDocument;
|
|
58
|
+
selectedBlockId: string | null;
|
|
59
|
+
selectedBlock: BlockNode | null;
|
|
60
|
+
canvasSelectionRequest: string | null;
|
|
61
|
+
device: Device;
|
|
62
|
+
loadState: EditorLoadState;
|
|
63
|
+
isDirty: boolean;
|
|
64
|
+
actionState: EditorActionState;
|
|
65
|
+
/** Request a canvas selection. The inspector changes only after Puck confirms it. */
|
|
66
|
+
requestCanvasSelection(id: string): void;
|
|
67
|
+
/** Called from the canvas/Puck selection event. */
|
|
68
|
+
confirmCanvasSelection(id: string | null): void;
|
|
69
|
+
/** Applies an edit that originated in the canvas engine. */
|
|
70
|
+
updateFromCanvas(document: PageDocument): void;
|
|
71
|
+
setDevice(device: Device): void;
|
|
72
|
+
addBlock(type: string, beforeId?: string): string | null;
|
|
73
|
+
duplicateBlock(id: string): void;
|
|
74
|
+
deleteBlock(id: string): void;
|
|
75
|
+
moveBlock(id: string, direction: -1 | 1): void;
|
|
76
|
+
reorderBlock(id: string, beforeId: string): void;
|
|
77
|
+
updateBlockProps(id: string, props: Record<string, JsonValue>): void;
|
|
78
|
+
undo(): void;
|
|
79
|
+
redo(): void;
|
|
80
|
+
markSaved(): void;
|
|
81
|
+
};
|
|
82
|
+
declare function EditorProvider({ initialDocument, registry, loadState, leaveWarning, onDocumentChange, children }: {
|
|
83
|
+
initialDocument: PageDocument;
|
|
84
|
+
registry?: ExtensionRegistry;
|
|
85
|
+
loadState?: EditorLoadState;
|
|
86
|
+
leaveWarning?: string;
|
|
87
|
+
onDocumentChange?: (document: PageDocument) => void;
|
|
88
|
+
children: ReactNode;
|
|
89
|
+
}): react.JSX.Element;
|
|
90
|
+
declare function useEditorContext(): EditorContextValue;
|
|
91
|
+
|
|
92
|
+
type PageDocumentEditorShellProps = {
|
|
93
|
+
initialDocument: PageDocument;
|
|
94
|
+
iframe?: boolean;
|
|
95
|
+
registry?: ExtensionRegistry;
|
|
96
|
+
/** Presentation states are explicit so host applications can provide a consistent Admin experience. */
|
|
97
|
+
loadState?: EditorLoadState;
|
|
98
|
+
adminLocale?: string;
|
|
99
|
+
onDocumentChange?: (document: PageDocument) => void;
|
|
100
|
+
/** Persist the current draft. The shell marks the document clean only after this resolves. */
|
|
101
|
+
onSave?: (document: PageDocument) => Promise<void> | void;
|
|
102
|
+
/** Publish the current document. Hosts should persist it atomically with publication. */
|
|
103
|
+
onPublish?: (document: PageDocument) => Promise<void> | void;
|
|
104
|
+
};
|
|
105
|
+
declare function PageDocumentEditorShell(props: PageDocumentEditorShellProps): react.JSX.Element;
|
|
106
|
+
|
|
107
|
+
type AdminLocale = "zh-CN" | "en";
|
|
108
|
+
declare const messages: {
|
|
109
|
+
readonly "zh-CN": {
|
|
110
|
+
readonly blocks: "区块";
|
|
111
|
+
readonly outline: "结构";
|
|
112
|
+
readonly properties: "属性";
|
|
113
|
+
readonly addBlock: "添加区块";
|
|
114
|
+
readonly undo: "撤销";
|
|
115
|
+
readonly redo: "恢复";
|
|
116
|
+
readonly duplicate: "复制";
|
|
117
|
+
readonly remove: "删除";
|
|
118
|
+
readonly moveUp: "上移";
|
|
119
|
+
readonly moveDown: "下移";
|
|
120
|
+
readonly loading: "正在加载编辑器…";
|
|
121
|
+
readonly empty: "页面还没有区块";
|
|
122
|
+
readonly error: "编辑器无法加载";
|
|
123
|
+
readonly disabled: "编辑器当前不可编辑";
|
|
124
|
+
readonly success: "操作已完成";
|
|
125
|
+
readonly unsaved: "未保存变更";
|
|
126
|
+
readonly saved: "所有更改已保留在当前会话中";
|
|
127
|
+
readonly save: "保存草稿";
|
|
128
|
+
readonly saving: "正在保存…";
|
|
129
|
+
readonly publish: "发布";
|
|
130
|
+
readonly publishing: "正在发布…";
|
|
131
|
+
readonly saveFailed: "保存草稿失败";
|
|
132
|
+
readonly publishFailed: "发布失败";
|
|
133
|
+
readonly published: "已发布";
|
|
134
|
+
readonly leaveWarning: "你有未保存的更改。确定要离开吗?";
|
|
135
|
+
readonly selectBlock: "选择一个区块以编辑。";
|
|
136
|
+
readonly desktop: "桌面";
|
|
137
|
+
readonly tablet: "平板";
|
|
138
|
+
readonly mobile: "手机";
|
|
139
|
+
};
|
|
140
|
+
readonly en: {
|
|
141
|
+
readonly blocks: "Blocks";
|
|
142
|
+
readonly outline: "Outline";
|
|
143
|
+
readonly properties: "Properties";
|
|
144
|
+
readonly addBlock: "Add block";
|
|
145
|
+
readonly undo: "Undo";
|
|
146
|
+
readonly redo: "Redo";
|
|
147
|
+
readonly duplicate: "Duplicate";
|
|
148
|
+
readonly remove: "Delete";
|
|
149
|
+
readonly moveUp: "Move up";
|
|
150
|
+
readonly moveDown: "Move down";
|
|
151
|
+
readonly loading: "Loading editor…";
|
|
152
|
+
readonly empty: "This page has no blocks";
|
|
153
|
+
readonly error: "The editor could not load";
|
|
154
|
+
readonly disabled: "The editor is currently read-only";
|
|
155
|
+
readonly success: "Action completed";
|
|
156
|
+
readonly unsaved: "Unsaved changes";
|
|
157
|
+
readonly saved: "Changes are kept in this session";
|
|
158
|
+
readonly save: "Save draft";
|
|
159
|
+
readonly saving: "Saving…";
|
|
160
|
+
readonly publish: "Publish";
|
|
161
|
+
readonly publishing: "Publishing…";
|
|
162
|
+
readonly saveFailed: "Could not save draft";
|
|
163
|
+
readonly publishFailed: "Could not publish";
|
|
164
|
+
readonly published: "Published";
|
|
165
|
+
readonly leaveWarning: "You have unsaved changes. Are you sure you want to leave?";
|
|
166
|
+
readonly selectBlock: "Select a block to edit it.";
|
|
167
|
+
readonly desktop: "Desktop";
|
|
168
|
+
readonly tablet: "Tablet";
|
|
169
|
+
readonly mobile: "Mobile";
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
type AdminMessageKey = keyof typeof messages["zh-CN"];
|
|
173
|
+
/** Minimal, dependency-free Admin copy catalog. Product locale remains PageDocument.settings.locale. */
|
|
174
|
+
declare function createAdminI18n(locale?: string): {
|
|
175
|
+
locale: AdminLocale;
|
|
176
|
+
t: (key: AdminMessageKey) => "Desktop" | "Tablet" | "Mobile" | "未保存变更" | "Outline" | "区块" | "结构" | "撤销" | "恢复" | "属性" | "添加区块" | "复制" | "删除" | "上移" | "下移" | "正在加载编辑器…" | "页面还没有区块" | "编辑器无法加载" | "编辑器当前不可编辑" | "操作已完成" | "所有更改已保留在当前会话中" | "保存草稿" | "正在保存…" | "发布" | "正在发布…" | "保存草稿失败" | "发布失败" | "已发布" | "你有未保存的更改。确定要离开吗?" | "选择一个区块以编辑。" | "桌面" | "平板" | "手机" | "Blocks" | "Properties" | "Add block" | "Undo" | "Redo" | "Duplicate" | "Delete" | "Move up" | "Move down" | "Loading editor…" | "This page has no blocks" | "The editor could not load" | "The editor is currently read-only" | "Action completed" | "Unsaved changes" | "Changes are kept in this session" | "Save draft" | "Saving…" | "Publish" | "Publishing…" | "Could not save draft" | "Could not publish" | "Published" | "You have unsaved changes. Are you sure you want to leave?" | "Select a block to edit it.";
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
declare function toEngineData(document: PageDocument, registry?: ExtensionRegistry): Data;
|
|
180
|
+
declare function fromEngineData(data: Data, base: PageDocument, registry?: ExtensionRegistry): PageDocument;
|
|
181
|
+
|
|
182
|
+
export { type AdminLocale, type AdminMessageKey, BlockNode, type DemoBlock, type Device, type EditorActionState, type EditorLoadState, EditorProvider, EditorShell, type EditorShellProps, type EditorState, ExtensionRegistry, JsonValue, PageDocument, PageDocumentEditorShell, type PageDocumentEditorShellProps, type PreviewMode, type PublishState, type SaveState, type Zoom, createAdminI18n, fromEngineData, toEngineData, useEditorContext };
|