@measured/puck-plugin-emotion-cache 0.21.0-canary.af48a401 → 0.21.0-canary.b353d921

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 CHANGED
@@ -1,10 +1,185 @@
1
- import { ReactElement, ReactNode, CSSProperties, ElementType, 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
  }[] = {
@@ -125,7 +322,7 @@ interface SlotField extends BaseField {
125
322
  allow?: string[];
126
323
  disallow?: string[];
127
324
  }
128
- 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 {
129
326
  [key: string]: any;
130
327
  }[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
131
328
  type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
@@ -353,6 +550,7 @@ type UiState = {
353
550
  };
354
551
  field: {
355
552
  focus?: string | null;
553
+ metadata?: Record<string, any>;
356
554
  };
357
555
  };
358
556
  type AppState<UserData extends Data = Data> = {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,185 @@
1
- import { ReactElement, ReactNode, CSSProperties, ElementType, 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
  }[] = {
@@ -125,7 +322,7 @@ interface SlotField extends BaseField {
125
322
  allow?: string[];
126
323
  disallow?: string[];
127
324
  }
128
- 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 {
129
326
  [key: string]: any;
130
327
  }[] ? ValueType : never, UserField> | ObjectField<ValueType, UserField> | ExternalField<ValueType> | ExternalFieldWithAdaptor<ValueType> | CustomField<ValueType> | SlotField;
131
328
  type Fields<ComponentProps extends DefaultComponentProps = DefaultComponentProps, UserField extends {} = {}> = {
@@ -353,6 +550,7 @@ type UiState = {
353
550
  };
354
551
  field: {
355
552
  focus?: string | null;
553
+ metadata?: Record<string, any>;
356
554
  };
357
555
  };
358
556
  type AppState<UserData extends Data = Data> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-emotion-cache",
3
- "version": "0.21.0-canary.af48a401",
3
+ "version": "0.21.0-canary.b353d921",
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,7 @@
24
24
  ],
25
25
  "devDependencies": {
26
26
  "@emotion/react": "^11.13.3",
27
- "@measured/puck": "^0.21.0-canary.af48a401",
27
+ "@measured/puck": "^0.21.0-canary.b353d921",
28
28
  "@types/minimatch": "3.0.5",
29
29
  "@types/react": "^19.0.1",
30
30
  "@types/react-dom": "^19.0.2",