@measured/puck-plugin-emotion-cache 0.21.0-canary.e9d5c0ea → 0.21.0-canary.eb8ea5ce
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/index.d.mts +214 -23
- package/dist/index.d.ts +214 -23
- package/dist/index.js +7 -7
- package/dist/index.mjs +4 -4
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,185 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
|
|
1
|
+
import { ReactElement, CSSProperties, ReactNode, ElementType, JSX } from 'react';
|
|
2
|
+
import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
|
|
3
|
+
import { BlockquoteOptions } from '@tiptap/extension-blockquote';
|
|
4
|
+
import { BoldOptions } from '@tiptap/extension-bold';
|
|
5
|
+
import { CodeOptions } from '@tiptap/extension-code';
|
|
6
|
+
import { CodeBlockOptions } from '@tiptap/extension-code-block';
|
|
7
|
+
import { HardBreakOptions } from '@tiptap/extension-hard-break';
|
|
8
|
+
import { HeadingOptions } from '@tiptap/extension-heading';
|
|
9
|
+
import { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule';
|
|
10
|
+
import { ItalicOptions } from '@tiptap/extension-italic';
|
|
11
|
+
import { LinkOptions } from '@tiptap/extension-link';
|
|
12
|
+
import { BulletListOptions, ListItemOptions, ListKeymapOptions, OrderedListOptions } from '@tiptap/extension-list';
|
|
13
|
+
import { ParagraphOptions } from '@tiptap/extension-paragraph';
|
|
14
|
+
import { StrikeOptions } from '@tiptap/extension-strike';
|
|
15
|
+
import { TextAlignOptions } from '@tiptap/extension-text-align';
|
|
16
|
+
import { UnderlineOptions } from '@tiptap/extension-underline';
|
|
2
17
|
|
|
3
18
|
type ItemSelector = {
|
|
4
19
|
index: number;
|
|
5
20
|
zone?: string;
|
|
6
21
|
};
|
|
7
22
|
|
|
23
|
+
declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
|
|
24
|
+
isAlignLeft?: undefined;
|
|
25
|
+
canAlignLeft?: undefined;
|
|
26
|
+
isAlignCenter?: undefined;
|
|
27
|
+
canAlignCenter?: undefined;
|
|
28
|
+
isAlignRight?: undefined;
|
|
29
|
+
canAlignRight?: undefined;
|
|
30
|
+
isAlignJustify?: undefined;
|
|
31
|
+
canAlignJustify?: undefined;
|
|
32
|
+
isBold?: undefined;
|
|
33
|
+
canBold?: undefined;
|
|
34
|
+
isItalic?: undefined;
|
|
35
|
+
canItalic?: undefined;
|
|
36
|
+
isUnderline?: undefined;
|
|
37
|
+
canUnderline?: undefined;
|
|
38
|
+
isStrike?: undefined;
|
|
39
|
+
canStrike?: undefined;
|
|
40
|
+
isInlineCode?: undefined;
|
|
41
|
+
canInlineCode?: undefined;
|
|
42
|
+
isBulletList?: undefined;
|
|
43
|
+
canBulletList?: undefined;
|
|
44
|
+
isOrderedList?: undefined;
|
|
45
|
+
canOrderedList?: undefined;
|
|
46
|
+
isCodeBlock?: undefined;
|
|
47
|
+
canCodeBlock?: undefined;
|
|
48
|
+
isBlockquote?: undefined;
|
|
49
|
+
canBlockquote?: undefined;
|
|
50
|
+
canHorizontalRule?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
isAlignLeft: boolean;
|
|
53
|
+
canAlignLeft: boolean;
|
|
54
|
+
isAlignCenter: boolean;
|
|
55
|
+
canAlignCenter: boolean;
|
|
56
|
+
isAlignRight: boolean;
|
|
57
|
+
canAlignRight: boolean;
|
|
58
|
+
isAlignJustify: boolean;
|
|
59
|
+
canAlignJustify: boolean;
|
|
60
|
+
isBold: boolean;
|
|
61
|
+
canBold: boolean;
|
|
62
|
+
isItalic: boolean;
|
|
63
|
+
canItalic: boolean;
|
|
64
|
+
isUnderline: boolean;
|
|
65
|
+
canUnderline: boolean;
|
|
66
|
+
isStrike: boolean;
|
|
67
|
+
canStrike: boolean;
|
|
68
|
+
isInlineCode: boolean;
|
|
69
|
+
canInlineCode: boolean;
|
|
70
|
+
isBulletList: boolean;
|
|
71
|
+
canBulletList: boolean;
|
|
72
|
+
isOrderedList: boolean;
|
|
73
|
+
canOrderedList: boolean;
|
|
74
|
+
isCodeBlock: boolean;
|
|
75
|
+
canCodeBlock: boolean;
|
|
76
|
+
isBlockquote: boolean;
|
|
77
|
+
canBlockquote: boolean;
|
|
78
|
+
canHorizontalRule: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type RichTextSelector = (ctx: EditorStateSnapshot, readOnly: boolean) => Partial<Record<string, boolean>>;
|
|
82
|
+
type DefaultEditorState = ReturnType<typeof defaultEditorState>;
|
|
83
|
+
type EditorState<Selector extends RichTextSelector = RichTextSelector> = DefaultEditorState & ReturnType<Selector> & Record<string, boolean | undefined>;
|
|
84
|
+
|
|
85
|
+
interface PuckRichTextOptions {
|
|
86
|
+
/**
|
|
87
|
+
* If set to false, the blockquote extension will not be registered
|
|
88
|
+
* @example blockquote: false
|
|
89
|
+
*/
|
|
90
|
+
blockquote: Partial<BlockquoteOptions> | false;
|
|
91
|
+
/**
|
|
92
|
+
* If set to false, the bold extension will not be registered
|
|
93
|
+
* @example bold: false
|
|
94
|
+
*/
|
|
95
|
+
bold: Partial<BoldOptions> | false;
|
|
96
|
+
/**
|
|
97
|
+
* If set to false, the bulletList extension will not be registered
|
|
98
|
+
* @example bulletList: false
|
|
99
|
+
*/
|
|
100
|
+
bulletList: Partial<BulletListOptions> | false;
|
|
101
|
+
/**
|
|
102
|
+
* If set to false, the code extension will not be registered
|
|
103
|
+
* @example code: false
|
|
104
|
+
*/
|
|
105
|
+
code: Partial<CodeOptions> | false;
|
|
106
|
+
/**
|
|
107
|
+
* If set to false, the codeBlock extension will not be registered
|
|
108
|
+
* @example codeBlock: false
|
|
109
|
+
*/
|
|
110
|
+
codeBlock: Partial<CodeBlockOptions> | false;
|
|
111
|
+
/**
|
|
112
|
+
* If set to false, the document extension will not be registered
|
|
113
|
+
* @example document: false
|
|
114
|
+
*/
|
|
115
|
+
document: false;
|
|
116
|
+
/**
|
|
117
|
+
* If set to false, the hardBreak extension will not be registered
|
|
118
|
+
* @example hardBreak: false
|
|
119
|
+
*/
|
|
120
|
+
hardBreak: Partial<HardBreakOptions> | false;
|
|
121
|
+
/**
|
|
122
|
+
* If set to false, the heading extension will not be registered
|
|
123
|
+
* @example heading: false
|
|
124
|
+
*/
|
|
125
|
+
heading: Partial<HeadingOptions> | false;
|
|
126
|
+
/**
|
|
127
|
+
* If set to false, the horizontalRule extension will not be registered
|
|
128
|
+
* @example horizontalRule: false
|
|
129
|
+
*/
|
|
130
|
+
horizontalRule: Partial<HorizontalRuleOptions> | false;
|
|
131
|
+
/**
|
|
132
|
+
* If set to false, the italic extension will not be registered
|
|
133
|
+
* @example italic: false
|
|
134
|
+
*/
|
|
135
|
+
italic: Partial<ItalicOptions> | false;
|
|
136
|
+
/**
|
|
137
|
+
* If set to false, the listItem extension will not be registered
|
|
138
|
+
* @example listItem: false
|
|
139
|
+
*/
|
|
140
|
+
listItem: Partial<ListItemOptions> | false;
|
|
141
|
+
/**
|
|
142
|
+
* If set to false, the listItemKeymap extension will not be registered
|
|
143
|
+
* @example listKeymap: false
|
|
144
|
+
*/
|
|
145
|
+
listKeymap: Partial<ListKeymapOptions> | false;
|
|
146
|
+
/**
|
|
147
|
+
* If set to false, the link extension will not be registered
|
|
148
|
+
* @example link: false
|
|
149
|
+
*/
|
|
150
|
+
link: Partial<LinkOptions> | false;
|
|
151
|
+
/**
|
|
152
|
+
* If set to false, the orderedList extension will not be registered
|
|
153
|
+
* @example orderedList: false
|
|
154
|
+
*/
|
|
155
|
+
orderedList: Partial<OrderedListOptions> | false;
|
|
156
|
+
/**
|
|
157
|
+
* If set to false, the paragraph extension will not be registered
|
|
158
|
+
* @example paragraph: false
|
|
159
|
+
*/
|
|
160
|
+
paragraph: Partial<ParagraphOptions> | false;
|
|
161
|
+
/**
|
|
162
|
+
* If set to false, the strike extension will not be registered
|
|
163
|
+
* @example strike: false
|
|
164
|
+
*/
|
|
165
|
+
strike: Partial<StrikeOptions> | false;
|
|
166
|
+
/**
|
|
167
|
+
* If set to false, the text extension will not be registered
|
|
168
|
+
* @example text: false
|
|
169
|
+
*/
|
|
170
|
+
text: false;
|
|
171
|
+
/**
|
|
172
|
+
* If set to false, the textAlign extension will not be registered
|
|
173
|
+
* @example text: false
|
|
174
|
+
*/
|
|
175
|
+
textAlign: Partial<TextAlignOptions> | false;
|
|
176
|
+
/**
|
|
177
|
+
* If set to false, the underline extension will not be registered
|
|
178
|
+
* @example underline: false
|
|
179
|
+
*/
|
|
180
|
+
underline: Partial<UnderlineOptions> | false;
|
|
181
|
+
}
|
|
182
|
+
|
|
8
183
|
type FieldOption = {
|
|
9
184
|
label: string;
|
|
10
185
|
value: string | number | boolean | undefined | null | object;
|
|
@@ -41,6 +216,28 @@ interface RadioField extends BaseField {
|
|
|
41
216
|
type: "radio";
|
|
42
217
|
options: FieldOptions;
|
|
43
218
|
}
|
|
219
|
+
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
220
|
+
type: "richtext";
|
|
221
|
+
contentEditable?: boolean;
|
|
222
|
+
initialHeight?: CSSProperties["height"];
|
|
223
|
+
options?: Partial<PuckRichTextOptions>;
|
|
224
|
+
renderMenu?: (props: {
|
|
225
|
+
children: ReactNode;
|
|
226
|
+
editor: Editor | null;
|
|
227
|
+
editorState: EditorState<UserSelector> | null;
|
|
228
|
+
readOnly: boolean;
|
|
229
|
+
}) => ReactNode;
|
|
230
|
+
renderInlineMenu?: (props: {
|
|
231
|
+
children: ReactNode;
|
|
232
|
+
editor: Editor | null;
|
|
233
|
+
editorState: EditorState<UserSelector> | null;
|
|
234
|
+
readOnly: boolean;
|
|
235
|
+
}) => ReactNode;
|
|
236
|
+
tiptap?: {
|
|
237
|
+
selector?: UserSelector;
|
|
238
|
+
extensions?: Extensions;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
44
241
|
interface ArrayField<Props extends {
|
|
45
242
|
[key: string]: any;
|
|
46
243
|
}[] = {
|
|
@@ -53,7 +250,7 @@ interface ArrayField<Props extends {
|
|
|
53
250
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
251
|
};
|
|
55
252
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
253
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
254
|
max?: number;
|
|
58
255
|
min?: number;
|
|
59
256
|
}
|
|
@@ -80,7 +277,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
277
|
placeholder?: string;
|
|
81
278
|
adaptor: Adaptor<any, any, Props>;
|
|
82
279
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
280
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
281
|
};
|
|
85
282
|
type CacheOpts = {
|
|
86
283
|
enabled?: boolean;
|
|
@@ -97,7 +294,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
294
|
}) => Promise<any[] | null>;
|
|
98
295
|
mapProp?: (value: any) => Props;
|
|
99
296
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
297
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
298
|
showSearch?: boolean;
|
|
102
299
|
renderFooter?: (props: {
|
|
103
300
|
items: any[];
|
|
@@ -118,13 +315,14 @@ interface CustomField<Value extends any> extends BaseField {
|
|
|
118
315
|
type: "custom";
|
|
119
316
|
render: CustomFieldRender<Value>;
|
|
120
317
|
contentEditable?: boolean;
|
|
318
|
+
key?: string;
|
|
121
319
|
}
|
|
122
320
|
interface SlotField extends BaseField {
|
|
123
321
|
type: "slot";
|
|
124
322
|
allow?: string[];
|
|
125
323
|
disallow?: string[];
|
|
126
324
|
}
|
|
127
|
-
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
325
|
+
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
128
326
|
[key: string]: any;
|
|
129
327
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
130
328
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -145,9 +343,10 @@ type DropZoneProps = {
|
|
|
145
343
|
allow?: string[];
|
|
146
344
|
disallow?: string[];
|
|
147
345
|
style?: CSSProperties;
|
|
148
|
-
minEmptyHeight?: number;
|
|
346
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
149
347
|
className?: string;
|
|
150
348
|
collisionAxis?: DragAxis;
|
|
349
|
+
as?: ElementType;
|
|
151
350
|
};
|
|
152
351
|
|
|
153
352
|
type PuckContext = {
|
|
@@ -236,6 +435,7 @@ UserField extends BaseField = {}> = {
|
|
|
236
435
|
permissions: Partial<Permissions>;
|
|
237
436
|
appState: AppState;
|
|
238
437
|
lastData: DataShape | null;
|
|
438
|
+
parent: ComponentData | null;
|
|
239
439
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
240
440
|
metadata?: ComponentMetadata;
|
|
241
441
|
} & ComponentConfigExtensions;
|
|
@@ -320,7 +520,6 @@ interface FieldMetadata extends Metadata {
|
|
|
320
520
|
type ItemWithId = {
|
|
321
521
|
_arrayId: string;
|
|
322
522
|
_originalIndex: number;
|
|
323
|
-
_currentIndex: number;
|
|
324
523
|
};
|
|
325
524
|
type ArrayState = {
|
|
326
525
|
items: ItemWithId[];
|
|
@@ -331,7 +530,6 @@ type UiState = {
|
|
|
331
530
|
rightSideBarVisible: boolean;
|
|
332
531
|
leftSideBarWidth?: number | null;
|
|
333
532
|
rightSideBarWidth?: number | null;
|
|
334
|
-
mobilePanelExpanded?: boolean;
|
|
335
533
|
itemSelector: ItemSelector | null;
|
|
336
534
|
arrayState: Record<string, ArrayState | undefined>;
|
|
337
535
|
previewMode: "interactive" | "edit";
|
|
@@ -344,7 +542,7 @@ type UiState = {
|
|
|
344
542
|
isDragging: boolean;
|
|
345
543
|
viewports: {
|
|
346
544
|
current: {
|
|
347
|
-
width: number
|
|
545
|
+
width: number;
|
|
348
546
|
height: number | "auto";
|
|
349
547
|
};
|
|
350
548
|
controlsVisible: boolean;
|
|
@@ -352,9 +550,7 @@ type UiState = {
|
|
|
352
550
|
};
|
|
353
551
|
field: {
|
|
354
552
|
focus?: string | null;
|
|
355
|
-
|
|
356
|
-
plugin: {
|
|
357
|
-
current: string | null;
|
|
553
|
+
metadata?: Record<string, any>;
|
|
358
554
|
};
|
|
359
555
|
};
|
|
360
556
|
type AppState<UserData extends Data = Data> = {
|
|
@@ -399,11 +595,6 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
|
|
|
399
595
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
400
596
|
never
|
|
401
597
|
] ? False : True;
|
|
402
|
-
type RenderFunc<Props extends {
|
|
403
|
-
[key: string]: any;
|
|
404
|
-
} = {
|
|
405
|
-
children: ReactNode;
|
|
406
|
-
}> = (props: Props) => ReactElement;
|
|
407
598
|
|
|
408
599
|
type MapFnParams<ThisField = Field> = {
|
|
409
600
|
value: any;
|
|
@@ -427,6 +618,11 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
427
618
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
428
619
|
}>;
|
|
429
620
|
|
|
621
|
+
type RenderFunc<Props extends {
|
|
622
|
+
[key: string]: any;
|
|
623
|
+
} = {
|
|
624
|
+
children: ReactNode;
|
|
625
|
+
}> = (props: Props) => ReactElement;
|
|
430
626
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
431
627
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
432
628
|
type OverridesGeneric<Shape extends {
|
|
@@ -497,7 +693,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
497
693
|
|
|
498
694
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
499
695
|
type Viewport = {
|
|
500
|
-
width: number
|
|
696
|
+
width: number;
|
|
501
697
|
height?: number | "auto";
|
|
502
698
|
label?: string;
|
|
503
699
|
icon?: iconTypes | ReactNode;
|
|
@@ -511,13 +707,8 @@ type Permissions = {
|
|
|
511
707
|
insert: boolean;
|
|
512
708
|
} & Record<string, boolean>;
|
|
513
709
|
type Plugin<UserConfig extends Config = Config> = {
|
|
514
|
-
name?: string;
|
|
515
|
-
label?: string;
|
|
516
|
-
icon?: ReactNode;
|
|
517
|
-
render?: () => ReactElement;
|
|
518
710
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
519
711
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
520
|
-
mobilePanelHeight?: "toggle" | "min-content";
|
|
521
712
|
};
|
|
522
713
|
type Slot<Props extends {
|
|
523
714
|
[key: string]: DefaultComponentProps;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,185 @@
|
|
|
1
|
-
import { ReactElement, CSSProperties, ReactNode, JSX } from 'react';
|
|
1
|
+
import { ReactElement, CSSProperties, ReactNode, ElementType, JSX } from 'react';
|
|
2
|
+
import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
|
|
3
|
+
import { BlockquoteOptions } from '@tiptap/extension-blockquote';
|
|
4
|
+
import { BoldOptions } from '@tiptap/extension-bold';
|
|
5
|
+
import { CodeOptions } from '@tiptap/extension-code';
|
|
6
|
+
import { CodeBlockOptions } from '@tiptap/extension-code-block';
|
|
7
|
+
import { HardBreakOptions } from '@tiptap/extension-hard-break';
|
|
8
|
+
import { HeadingOptions } from '@tiptap/extension-heading';
|
|
9
|
+
import { HorizontalRuleOptions } from '@tiptap/extension-horizontal-rule';
|
|
10
|
+
import { ItalicOptions } from '@tiptap/extension-italic';
|
|
11
|
+
import { LinkOptions } from '@tiptap/extension-link';
|
|
12
|
+
import { BulletListOptions, ListItemOptions, ListKeymapOptions, OrderedListOptions } from '@tiptap/extension-list';
|
|
13
|
+
import { ParagraphOptions } from '@tiptap/extension-paragraph';
|
|
14
|
+
import { StrikeOptions } from '@tiptap/extension-strike';
|
|
15
|
+
import { TextAlignOptions } from '@tiptap/extension-text-align';
|
|
16
|
+
import { UnderlineOptions } from '@tiptap/extension-underline';
|
|
2
17
|
|
|
3
18
|
type ItemSelector = {
|
|
4
19
|
index: number;
|
|
5
20
|
zone?: string;
|
|
6
21
|
};
|
|
7
22
|
|
|
23
|
+
declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
|
|
24
|
+
isAlignLeft?: undefined;
|
|
25
|
+
canAlignLeft?: undefined;
|
|
26
|
+
isAlignCenter?: undefined;
|
|
27
|
+
canAlignCenter?: undefined;
|
|
28
|
+
isAlignRight?: undefined;
|
|
29
|
+
canAlignRight?: undefined;
|
|
30
|
+
isAlignJustify?: undefined;
|
|
31
|
+
canAlignJustify?: undefined;
|
|
32
|
+
isBold?: undefined;
|
|
33
|
+
canBold?: undefined;
|
|
34
|
+
isItalic?: undefined;
|
|
35
|
+
canItalic?: undefined;
|
|
36
|
+
isUnderline?: undefined;
|
|
37
|
+
canUnderline?: undefined;
|
|
38
|
+
isStrike?: undefined;
|
|
39
|
+
canStrike?: undefined;
|
|
40
|
+
isInlineCode?: undefined;
|
|
41
|
+
canInlineCode?: undefined;
|
|
42
|
+
isBulletList?: undefined;
|
|
43
|
+
canBulletList?: undefined;
|
|
44
|
+
isOrderedList?: undefined;
|
|
45
|
+
canOrderedList?: undefined;
|
|
46
|
+
isCodeBlock?: undefined;
|
|
47
|
+
canCodeBlock?: undefined;
|
|
48
|
+
isBlockquote?: undefined;
|
|
49
|
+
canBlockquote?: undefined;
|
|
50
|
+
canHorizontalRule?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
isAlignLeft: boolean;
|
|
53
|
+
canAlignLeft: boolean;
|
|
54
|
+
isAlignCenter: boolean;
|
|
55
|
+
canAlignCenter: boolean;
|
|
56
|
+
isAlignRight: boolean;
|
|
57
|
+
canAlignRight: boolean;
|
|
58
|
+
isAlignJustify: boolean;
|
|
59
|
+
canAlignJustify: boolean;
|
|
60
|
+
isBold: boolean;
|
|
61
|
+
canBold: boolean;
|
|
62
|
+
isItalic: boolean;
|
|
63
|
+
canItalic: boolean;
|
|
64
|
+
isUnderline: boolean;
|
|
65
|
+
canUnderline: boolean;
|
|
66
|
+
isStrike: boolean;
|
|
67
|
+
canStrike: boolean;
|
|
68
|
+
isInlineCode: boolean;
|
|
69
|
+
canInlineCode: boolean;
|
|
70
|
+
isBulletList: boolean;
|
|
71
|
+
canBulletList: boolean;
|
|
72
|
+
isOrderedList: boolean;
|
|
73
|
+
canOrderedList: boolean;
|
|
74
|
+
isCodeBlock: boolean;
|
|
75
|
+
canCodeBlock: boolean;
|
|
76
|
+
isBlockquote: boolean;
|
|
77
|
+
canBlockquote: boolean;
|
|
78
|
+
canHorizontalRule: boolean;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
type RichTextSelector = (ctx: EditorStateSnapshot, readOnly: boolean) => Partial<Record<string, boolean>>;
|
|
82
|
+
type DefaultEditorState = ReturnType<typeof defaultEditorState>;
|
|
83
|
+
type EditorState<Selector extends RichTextSelector = RichTextSelector> = DefaultEditorState & ReturnType<Selector> & Record<string, boolean | undefined>;
|
|
84
|
+
|
|
85
|
+
interface PuckRichTextOptions {
|
|
86
|
+
/**
|
|
87
|
+
* If set to false, the blockquote extension will not be registered
|
|
88
|
+
* @example blockquote: false
|
|
89
|
+
*/
|
|
90
|
+
blockquote: Partial<BlockquoteOptions> | false;
|
|
91
|
+
/**
|
|
92
|
+
* If set to false, the bold extension will not be registered
|
|
93
|
+
* @example bold: false
|
|
94
|
+
*/
|
|
95
|
+
bold: Partial<BoldOptions> | false;
|
|
96
|
+
/**
|
|
97
|
+
* If set to false, the bulletList extension will not be registered
|
|
98
|
+
* @example bulletList: false
|
|
99
|
+
*/
|
|
100
|
+
bulletList: Partial<BulletListOptions> | false;
|
|
101
|
+
/**
|
|
102
|
+
* If set to false, the code extension will not be registered
|
|
103
|
+
* @example code: false
|
|
104
|
+
*/
|
|
105
|
+
code: Partial<CodeOptions> | false;
|
|
106
|
+
/**
|
|
107
|
+
* If set to false, the codeBlock extension will not be registered
|
|
108
|
+
* @example codeBlock: false
|
|
109
|
+
*/
|
|
110
|
+
codeBlock: Partial<CodeBlockOptions> | false;
|
|
111
|
+
/**
|
|
112
|
+
* If set to false, the document extension will not be registered
|
|
113
|
+
* @example document: false
|
|
114
|
+
*/
|
|
115
|
+
document: false;
|
|
116
|
+
/**
|
|
117
|
+
* If set to false, the hardBreak extension will not be registered
|
|
118
|
+
* @example hardBreak: false
|
|
119
|
+
*/
|
|
120
|
+
hardBreak: Partial<HardBreakOptions> | false;
|
|
121
|
+
/**
|
|
122
|
+
* If set to false, the heading extension will not be registered
|
|
123
|
+
* @example heading: false
|
|
124
|
+
*/
|
|
125
|
+
heading: Partial<HeadingOptions> | false;
|
|
126
|
+
/**
|
|
127
|
+
* If set to false, the horizontalRule extension will not be registered
|
|
128
|
+
* @example horizontalRule: false
|
|
129
|
+
*/
|
|
130
|
+
horizontalRule: Partial<HorizontalRuleOptions> | false;
|
|
131
|
+
/**
|
|
132
|
+
* If set to false, the italic extension will not be registered
|
|
133
|
+
* @example italic: false
|
|
134
|
+
*/
|
|
135
|
+
italic: Partial<ItalicOptions> | false;
|
|
136
|
+
/**
|
|
137
|
+
* If set to false, the listItem extension will not be registered
|
|
138
|
+
* @example listItem: false
|
|
139
|
+
*/
|
|
140
|
+
listItem: Partial<ListItemOptions> | false;
|
|
141
|
+
/**
|
|
142
|
+
* If set to false, the listItemKeymap extension will not be registered
|
|
143
|
+
* @example listKeymap: false
|
|
144
|
+
*/
|
|
145
|
+
listKeymap: Partial<ListKeymapOptions> | false;
|
|
146
|
+
/**
|
|
147
|
+
* If set to false, the link extension will not be registered
|
|
148
|
+
* @example link: false
|
|
149
|
+
*/
|
|
150
|
+
link: Partial<LinkOptions> | false;
|
|
151
|
+
/**
|
|
152
|
+
* If set to false, the orderedList extension will not be registered
|
|
153
|
+
* @example orderedList: false
|
|
154
|
+
*/
|
|
155
|
+
orderedList: Partial<OrderedListOptions> | false;
|
|
156
|
+
/**
|
|
157
|
+
* If set to false, the paragraph extension will not be registered
|
|
158
|
+
* @example paragraph: false
|
|
159
|
+
*/
|
|
160
|
+
paragraph: Partial<ParagraphOptions> | false;
|
|
161
|
+
/**
|
|
162
|
+
* If set to false, the strike extension will not be registered
|
|
163
|
+
* @example strike: false
|
|
164
|
+
*/
|
|
165
|
+
strike: Partial<StrikeOptions> | false;
|
|
166
|
+
/**
|
|
167
|
+
* If set to false, the text extension will not be registered
|
|
168
|
+
* @example text: false
|
|
169
|
+
*/
|
|
170
|
+
text: false;
|
|
171
|
+
/**
|
|
172
|
+
* If set to false, the textAlign extension will not be registered
|
|
173
|
+
* @example text: false
|
|
174
|
+
*/
|
|
175
|
+
textAlign: Partial<TextAlignOptions> | false;
|
|
176
|
+
/**
|
|
177
|
+
* If set to false, the underline extension will not be registered
|
|
178
|
+
* @example underline: false
|
|
179
|
+
*/
|
|
180
|
+
underline: Partial<UnderlineOptions> | false;
|
|
181
|
+
}
|
|
182
|
+
|
|
8
183
|
type FieldOption = {
|
|
9
184
|
label: string;
|
|
10
185
|
value: string | number | boolean | undefined | null | object;
|
|
@@ -41,6 +216,28 @@ interface RadioField extends BaseField {
|
|
|
41
216
|
type: "radio";
|
|
42
217
|
options: FieldOptions;
|
|
43
218
|
}
|
|
219
|
+
interface RichtextField<UserSelector extends RichTextSelector = RichTextSelector> extends BaseField {
|
|
220
|
+
type: "richtext";
|
|
221
|
+
contentEditable?: boolean;
|
|
222
|
+
initialHeight?: CSSProperties["height"];
|
|
223
|
+
options?: Partial<PuckRichTextOptions>;
|
|
224
|
+
renderMenu?: (props: {
|
|
225
|
+
children: ReactNode;
|
|
226
|
+
editor: Editor | null;
|
|
227
|
+
editorState: EditorState<UserSelector> | null;
|
|
228
|
+
readOnly: boolean;
|
|
229
|
+
}) => ReactNode;
|
|
230
|
+
renderInlineMenu?: (props: {
|
|
231
|
+
children: ReactNode;
|
|
232
|
+
editor: Editor | null;
|
|
233
|
+
editorState: EditorState<UserSelector> | null;
|
|
234
|
+
readOnly: boolean;
|
|
235
|
+
}) => ReactNode;
|
|
236
|
+
tiptap?: {
|
|
237
|
+
selector?: UserSelector;
|
|
238
|
+
extensions?: Extensions;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
44
241
|
interface ArrayField<Props extends {
|
|
45
242
|
[key: string]: any;
|
|
46
243
|
}[] = {
|
|
@@ -53,7 +250,7 @@ interface ArrayField<Props extends {
|
|
|
53
250
|
} ? Field<Props[0][SubPropName], UserField> | UserField : Field<Props[0][SubPropName], UserField>;
|
|
54
251
|
};
|
|
55
252
|
defaultItemProps?: Props[0] | ((index: number) => Props[0]);
|
|
56
|
-
getItemSummary?: (item: Props[0], index?: number) =>
|
|
253
|
+
getItemSummary?: (item: Props[0], index?: number) => ReactNode;
|
|
57
254
|
max?: number;
|
|
58
255
|
min?: number;
|
|
59
256
|
}
|
|
@@ -80,7 +277,7 @@ type ExternalFieldWithAdaptor<Props extends any = {
|
|
|
80
277
|
placeholder?: string;
|
|
81
278
|
adaptor: Adaptor<any, any, Props>;
|
|
82
279
|
adaptorParams?: object;
|
|
83
|
-
getItemSummary: (item: NotUndefined<Props>, index?: number) =>
|
|
280
|
+
getItemSummary: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
84
281
|
};
|
|
85
282
|
type CacheOpts = {
|
|
86
283
|
enabled?: boolean;
|
|
@@ -97,7 +294,7 @@ interface ExternalField<Props extends any = {
|
|
|
97
294
|
}) => Promise<any[] | null>;
|
|
98
295
|
mapProp?: (value: any) => Props;
|
|
99
296
|
mapRow?: (value: any) => Record<string, string | number | ReactElement>;
|
|
100
|
-
getItemSummary?: (item: NotUndefined<Props>, index?: number) =>
|
|
297
|
+
getItemSummary?: (item: NotUndefined<Props>, index?: number) => ReactNode;
|
|
101
298
|
showSearch?: boolean;
|
|
102
299
|
renderFooter?: (props: {
|
|
103
300
|
items: any[];
|
|
@@ -118,13 +315,14 @@ interface CustomField<Value extends any> extends BaseField {
|
|
|
118
315
|
type: "custom";
|
|
119
316
|
render: CustomFieldRender<Value>;
|
|
120
317
|
contentEditable?: boolean;
|
|
318
|
+
key?: string;
|
|
121
319
|
}
|
|
122
320
|
interface SlotField extends BaseField {
|
|
123
321
|
type: "slot";
|
|
124
322
|
allow?: string[];
|
|
125
323
|
disallow?: string[];
|
|
126
324
|
}
|
|
127
|
-
type Field<ValueType = any, UserField extends {} = {}> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
325
|
+
type Field<ValueType = any, UserField extends {} = {}> = TextField | RichtextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<ValueType extends {
|
|
128
326
|
[key: string]: any;
|
|
129
327
|
}[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
|
|
130
328
|
type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
|
|
@@ -145,9 +343,10 @@ type DropZoneProps = {
|
|
|
145
343
|
allow?: string[];
|
|
146
344
|
disallow?: string[];
|
|
147
345
|
style?: CSSProperties;
|
|
148
|
-
minEmptyHeight?: number;
|
|
346
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
149
347
|
className?: string;
|
|
150
348
|
collisionAxis?: DragAxis;
|
|
349
|
+
as?: ElementType;
|
|
151
350
|
};
|
|
152
351
|
|
|
153
352
|
type PuckContext = {
|
|
@@ -236,6 +435,7 @@ UserField extends BaseField = {}> = {
|
|
|
236
435
|
permissions: Partial<Permissions>;
|
|
237
436
|
appState: AppState;
|
|
238
437
|
lastData: DataShape | null;
|
|
438
|
+
parent: ComponentData | null;
|
|
239
439
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
240
440
|
metadata?: ComponentMetadata;
|
|
241
441
|
} & ComponentConfigExtensions;
|
|
@@ -320,7 +520,6 @@ interface FieldMetadata extends Metadata {
|
|
|
320
520
|
type ItemWithId = {
|
|
321
521
|
_arrayId: string;
|
|
322
522
|
_originalIndex: number;
|
|
323
|
-
_currentIndex: number;
|
|
324
523
|
};
|
|
325
524
|
type ArrayState = {
|
|
326
525
|
items: ItemWithId[];
|
|
@@ -331,7 +530,6 @@ type UiState = {
|
|
|
331
530
|
rightSideBarVisible: boolean;
|
|
332
531
|
leftSideBarWidth?: number | null;
|
|
333
532
|
rightSideBarWidth?: number | null;
|
|
334
|
-
mobilePanelExpanded?: boolean;
|
|
335
533
|
itemSelector: ItemSelector | null;
|
|
336
534
|
arrayState: Record<string, ArrayState | undefined>;
|
|
337
535
|
previewMode: "interactive" | "edit";
|
|
@@ -344,7 +542,7 @@ type UiState = {
|
|
|
344
542
|
isDragging: boolean;
|
|
345
543
|
viewports: {
|
|
346
544
|
current: {
|
|
347
|
-
width: number
|
|
545
|
+
width: number;
|
|
348
546
|
height: number | "auto";
|
|
349
547
|
};
|
|
350
548
|
controlsVisible: boolean;
|
|
@@ -352,9 +550,7 @@ type UiState = {
|
|
|
352
550
|
};
|
|
353
551
|
field: {
|
|
354
552
|
focus?: string | null;
|
|
355
|
-
|
|
356
|
-
plugin: {
|
|
357
|
-
current: string | null;
|
|
553
|
+
metadata?: Record<string, any>;
|
|
358
554
|
};
|
|
359
555
|
};
|
|
360
556
|
type AppState<UserData extends Data = Data> = {
|
|
@@ -399,11 +595,6 @@ type LeftOrExactRight<Union, Left, Right> = (Left & Union extends Right ? Exact<
|
|
|
399
595
|
type AssertHasValue<T, True = T, False = never> = [keyof T] extends [
|
|
400
596
|
never
|
|
401
597
|
] ? False : True;
|
|
402
|
-
type RenderFunc<Props extends {
|
|
403
|
-
[key: string]: any;
|
|
404
|
-
} = {
|
|
405
|
-
children: ReactNode;
|
|
406
|
-
}> = (props: Props) => ReactElement;
|
|
407
598
|
|
|
408
599
|
type MapFnParams<ThisField = Field> = {
|
|
409
600
|
value: any;
|
|
@@ -427,6 +618,11 @@ G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends
|
|
|
427
618
|
[Type in UserField["type"]]: FieldTransformFn<ExtractField<UserField, Type>>;
|
|
428
619
|
}>;
|
|
429
620
|
|
|
621
|
+
type RenderFunc<Props extends {
|
|
622
|
+
[key: string]: any;
|
|
623
|
+
} = {
|
|
624
|
+
children: ReactNode;
|
|
625
|
+
}> = (props: Props) => ReactElement;
|
|
430
626
|
declare const overrideKeys: readonly ["header", "headerActions", "fields", "fieldLabel", "drawer", "drawerItem", "componentOverlay", "outline", "puck", "preview"];
|
|
431
627
|
type OverrideKey = (typeof overrideKeys)[number];
|
|
432
628
|
type OverridesGeneric<Shape extends {
|
|
@@ -497,7 +693,7 @@ type DragAxis = "dynamic" | "y" | "x";
|
|
|
497
693
|
|
|
498
694
|
type iconTypes = "Smartphone" | "Monitor" | "Tablet";
|
|
499
695
|
type Viewport = {
|
|
500
|
-
width: number
|
|
696
|
+
width: number;
|
|
501
697
|
height?: number | "auto";
|
|
502
698
|
label?: string;
|
|
503
699
|
icon?: iconTypes | ReactNode;
|
|
@@ -511,13 +707,8 @@ type Permissions = {
|
|
|
511
707
|
insert: boolean;
|
|
512
708
|
} & Record<string, boolean>;
|
|
513
709
|
type Plugin<UserConfig extends Config = Config> = {
|
|
514
|
-
name?: string;
|
|
515
|
-
label?: string;
|
|
516
|
-
icon?: ReactNode;
|
|
517
|
-
render?: () => ReactElement;
|
|
518
710
|
overrides?: Partial<Overrides<UserConfig>>;
|
|
519
711
|
fieldTransforms?: FieldTransforms<UserConfig>;
|
|
520
|
-
mobilePanelHeight?: "toggle" | "min-content";
|
|
521
712
|
};
|
|
522
713
|
type Slot<Props extends {
|
|
523
714
|
[key: string]: DefaultComponentProps;
|
package/dist/index.js
CHANGED
|
@@ -28,11 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// index.tsx
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
33
|
-
default: () =>
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default
|
|
34
34
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
36
|
|
|
37
37
|
// ../tsup-config/react-import.js
|
|
38
38
|
var import_react = __toESM(require("react"));
|
|
@@ -63,7 +63,7 @@ function createStyleElement(options) {
|
|
|
63
63
|
tag.setAttribute("data-s", "");
|
|
64
64
|
return tag;
|
|
65
65
|
}
|
|
66
|
-
var StyleSheet = /* @__PURE__ */ function() {
|
|
66
|
+
var StyleSheet = /* @__PURE__ */ (function() {
|
|
67
67
|
function StyleSheet2(options) {
|
|
68
68
|
var _this = this;
|
|
69
69
|
this._insertTag = function(tag) {
|
|
@@ -121,7 +121,7 @@ var StyleSheet = /* @__PURE__ */ function() {
|
|
|
121
121
|
this.ctr = 0;
|
|
122
122
|
};
|
|
123
123
|
return StyleSheet2;
|
|
124
|
-
}();
|
|
124
|
+
})();
|
|
125
125
|
|
|
126
126
|
// ../../node_modules/stylis/src/Enum.js
|
|
127
127
|
var MS = "-ms-";
|
|
@@ -924,4 +924,4 @@ var createEmotionCachePlugin = (key) => {
|
|
|
924
924
|
}
|
|
925
925
|
};
|
|
926
926
|
};
|
|
927
|
-
var
|
|
927
|
+
var index_default = createEmotionCachePlugin;
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ function createStyleElement(options) {
|
|
|
27
27
|
tag.setAttribute("data-s", "");
|
|
28
28
|
return tag;
|
|
29
29
|
}
|
|
30
|
-
var StyleSheet = /* @__PURE__ */ function() {
|
|
30
|
+
var StyleSheet = /* @__PURE__ */ (function() {
|
|
31
31
|
function StyleSheet2(options) {
|
|
32
32
|
var _this = this;
|
|
33
33
|
this._insertTag = function(tag) {
|
|
@@ -85,7 +85,7 @@ var StyleSheet = /* @__PURE__ */ function() {
|
|
|
85
85
|
this.ctr = 0;
|
|
86
86
|
};
|
|
87
87
|
return StyleSheet2;
|
|
88
|
-
}();
|
|
88
|
+
})();
|
|
89
89
|
|
|
90
90
|
// ../../node_modules/stylis/src/Enum.js
|
|
91
91
|
var MS = "-ms-";
|
|
@@ -888,7 +888,7 @@ var createEmotionCachePlugin = (key) => {
|
|
|
888
888
|
}
|
|
889
889
|
};
|
|
890
890
|
};
|
|
891
|
-
var
|
|
891
|
+
var index_default = createEmotionCachePlugin;
|
|
892
892
|
export {
|
|
893
|
-
|
|
893
|
+
index_default as default
|
|
894
894
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck-plugin-emotion-cache",
|
|
3
|
-
"version": "0.21.0-canary.
|
|
3
|
+
"version": "0.21.0-canary.eb8ea5ce",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@emotion/react": "^11.13.3",
|
|
27
|
-
"@measured/puck": "^0.21.0-canary.
|
|
27
|
+
"@measured/puck": "^0.21.0-canary.eb8ea5ce",
|
|
28
|
+
"@types/minimatch": "3.0.5",
|
|
28
29
|
"@types/react": "^19.0.1",
|
|
29
30
|
"@types/react-dom": "^19.0.2",
|
|
30
31
|
"eslint": "^7.32.0",
|