@measured/puck-plugin-heading-analyzer 0.21.0-canary.ec77dd9f → 0.21.0-canary.ece26d91
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 +206 -6
- package/dist/index.d.ts +206 -6
- package/dist/index.js +26 -15
- package/dist/index.mjs +26 -15
- package/package.json +2 -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[];
|
|
@@ -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 {} = {}> = {
|
|
@@ -146,9 +343,10 @@ type DropZoneProps = {
|
|
|
146
343
|
allow?: string[];
|
|
147
344
|
disallow?: string[];
|
|
148
345
|
style?: CSSProperties;
|
|
149
|
-
minEmptyHeight?: number;
|
|
346
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
150
347
|
className?: string;
|
|
151
348
|
collisionAxis?: DragAxis;
|
|
349
|
+
as?: ElementType;
|
|
152
350
|
};
|
|
153
351
|
|
|
154
352
|
type PuckContext = {
|
|
@@ -237,6 +435,7 @@ UserField extends BaseField = {}> = {
|
|
|
237
435
|
permissions: Partial<Permissions>;
|
|
238
436
|
appState: AppState;
|
|
239
437
|
lastData: DataShape | null;
|
|
438
|
+
parent: ComponentData | null;
|
|
240
439
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
241
440
|
metadata?: ComponentMetadata;
|
|
242
441
|
} & ComponentConfigExtensions;
|
|
@@ -351,6 +550,7 @@ type UiState = {
|
|
|
351
550
|
};
|
|
352
551
|
field: {
|
|
353
552
|
focus?: string | null;
|
|
553
|
+
metadata?: Record<string, any>;
|
|
354
554
|
};
|
|
355
555
|
};
|
|
356
556
|
type AppState<UserData extends Data = Data> = {
|
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[];
|
|
@@ -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 {} = {}> = {
|
|
@@ -146,9 +343,10 @@ type DropZoneProps = {
|
|
|
146
343
|
allow?: string[];
|
|
147
344
|
disallow?: string[];
|
|
148
345
|
style?: CSSProperties;
|
|
149
|
-
minEmptyHeight?: number;
|
|
346
|
+
minEmptyHeight?: CSSProperties["minHeight"] | number;
|
|
150
347
|
className?: string;
|
|
151
348
|
collisionAxis?: DragAxis;
|
|
349
|
+
as?: ElementType;
|
|
152
350
|
};
|
|
153
351
|
|
|
154
352
|
type PuckContext = {
|
|
@@ -237,6 +435,7 @@ UserField extends BaseField = {}> = {
|
|
|
237
435
|
permissions: Partial<Permissions>;
|
|
238
436
|
appState: AppState;
|
|
239
437
|
lastData: DataShape | null;
|
|
438
|
+
parent: ComponentData | null;
|
|
240
439
|
}) => Promise<Partial<Permissions>> | Partial<Permissions>;
|
|
241
440
|
metadata?: ComponentMetadata;
|
|
242
441
|
} & ComponentConfigExtensions;
|
|
@@ -351,6 +550,7 @@ type UiState = {
|
|
|
351
550
|
};
|
|
352
551
|
field: {
|
|
353
552
|
focus?: string | null;
|
|
553
|
+
metadata?: Record<string, any>;
|
|
354
554
|
};
|
|
355
555
|
};
|
|
356
556
|
type AppState<UserData extends Data = Data> = {
|
package/dist/index.js
CHANGED
|
@@ -1006,7 +1006,9 @@ var replaceAction = (state, action, appStore) => {
|
|
|
1006
1006
|
});
|
|
1007
1007
|
});
|
|
1008
1008
|
});
|
|
1009
|
-
const stateWithDeepSlotsRemoved = __spreadValues({}, state)
|
|
1009
|
+
const stateWithDeepSlotsRemoved = __spreadProps(__spreadValues({}, state), {
|
|
1010
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
|
1011
|
+
});
|
|
1010
1012
|
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
1011
1013
|
const id = zoneCompound.split(":")[0];
|
|
1012
1014
|
if (id === originalId) {
|
|
@@ -1518,9 +1520,9 @@ function debounce(func, timeout = 300) {
|
|
|
1518
1520
|
var tidyState = (state) => {
|
|
1519
1521
|
return __spreadProps(__spreadValues({}, state), {
|
|
1520
1522
|
ui: __spreadProps(__spreadValues({}, state.ui), {
|
|
1521
|
-
field: {
|
|
1523
|
+
field: __spreadProps(__spreadValues({}, state.ui.field), {
|
|
1522
1524
|
focus: null
|
|
1523
|
-
}
|
|
1525
|
+
})
|
|
1524
1526
|
})
|
|
1525
1527
|
});
|
|
1526
1528
|
};
|
|
@@ -2090,26 +2092,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2090
2092
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
2091
2093
|
const { state, permissions, config } = get();
|
|
2092
2094
|
const { cache: cache2, globalPermissions } = permissions;
|
|
2093
|
-
const
|
|
2094
|
-
var _a, _b
|
|
2095
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
2096
|
+
var _a, _b;
|
|
2095
2097
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
2098
|
+
const itemCache = cache2[item2.props.id];
|
|
2099
|
+
const nodes = appState.indexes.nodes;
|
|
2100
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
2101
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
2102
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
2096
2103
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
2097
2104
|
if (!componentConfig) {
|
|
2098
2105
|
return;
|
|
2099
2106
|
}
|
|
2100
2107
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
2101
2108
|
if (componentConfig.resolvePermissions) {
|
|
2102
|
-
const changed = getChanged(item2,
|
|
2103
|
-
|
|
2109
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
2110
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
2111
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
2112
|
+
if (propsChanged || parentChanged || force2) {
|
|
2104
2113
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
2105
2114
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
2106
2115
|
item2,
|
|
2107
2116
|
{
|
|
2108
2117
|
changed,
|
|
2109
|
-
lastPermissions: (
|
|
2118
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
2110
2119
|
permissions: initialPermissions,
|
|
2111
2120
|
appState: makeStatePublic(appState),
|
|
2112
|
-
lastData: (
|
|
2121
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2122
|
+
parent: parentData
|
|
2113
2123
|
}
|
|
2114
2124
|
);
|
|
2115
2125
|
const latest = get().permissions;
|
|
@@ -2117,6 +2127,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2117
2127
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2118
2128
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2119
2129
|
[item2.props.id]: {
|
|
2130
|
+
lastParentId: parentId,
|
|
2120
2131
|
lastData: item2,
|
|
2121
2132
|
lastPermissions: resolvedPermissions
|
|
2122
2133
|
}
|
|
@@ -2130,9 +2141,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2130
2141
|
}
|
|
2131
2142
|
}
|
|
2132
2143
|
});
|
|
2133
|
-
const
|
|
2144
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2134
2145
|
const { state: appState } = get();
|
|
2135
|
-
|
|
2146
|
+
resolvePermissionsForItem(
|
|
2136
2147
|
// Shim the root data in by conforming to component data shape
|
|
2137
2148
|
{
|
|
2138
2149
|
type: "root",
|
|
@@ -2143,16 +2154,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2143
2154
|
};
|
|
2144
2155
|
const { item, type, root } = params;
|
|
2145
2156
|
if (item) {
|
|
2146
|
-
yield
|
|
2157
|
+
yield resolvePermissionsForItem(item, force);
|
|
2147
2158
|
} else if (type) {
|
|
2148
2159
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2149
|
-
yield
|
|
2160
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2150
2161
|
}));
|
|
2151
2162
|
} else if (root) {
|
|
2152
|
-
|
|
2163
|
+
resolvePermissionsForRoot(force);
|
|
2153
2164
|
} else {
|
|
2154
2165
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2155
|
-
yield
|
|
2166
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2156
2167
|
}));
|
|
2157
2168
|
}
|
|
2158
2169
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -994,7 +994,9 @@ var replaceAction = (state, action, appStore) => {
|
|
|
994
994
|
});
|
|
995
995
|
});
|
|
996
996
|
});
|
|
997
|
-
const stateWithDeepSlotsRemoved = __spreadValues({}, state)
|
|
997
|
+
const stateWithDeepSlotsRemoved = __spreadProps(__spreadValues({}, state), {
|
|
998
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
|
999
|
+
});
|
|
998
1000
|
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
999
1001
|
const id = zoneCompound.split(":")[0];
|
|
1000
1002
|
if (id === originalId) {
|
|
@@ -1506,9 +1508,9 @@ function debounce(func, timeout = 300) {
|
|
|
1506
1508
|
var tidyState = (state) => {
|
|
1507
1509
|
return __spreadProps(__spreadValues({}, state), {
|
|
1508
1510
|
ui: __spreadProps(__spreadValues({}, state.ui), {
|
|
1509
|
-
field: {
|
|
1511
|
+
field: __spreadProps(__spreadValues({}, state.ui.field), {
|
|
1510
1512
|
focus: null
|
|
1511
|
-
}
|
|
1513
|
+
})
|
|
1512
1514
|
})
|
|
1513
1515
|
});
|
|
1514
1516
|
};
|
|
@@ -2078,26 +2080,34 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2078
2080
|
const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
|
|
2079
2081
|
const { state, permissions, config } = get();
|
|
2080
2082
|
const { cache: cache2, globalPermissions } = permissions;
|
|
2081
|
-
const
|
|
2082
|
-
var _a, _b
|
|
2083
|
+
const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
|
|
2084
|
+
var _a, _b;
|
|
2083
2085
|
const { config: config2, state: appState, setComponentLoading } = get();
|
|
2086
|
+
const itemCache = cache2[item2.props.id];
|
|
2087
|
+
const nodes = appState.indexes.nodes;
|
|
2088
|
+
const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
|
|
2089
|
+
const parentNode = parentId ? nodes[parentId] : null;
|
|
2090
|
+
const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
|
|
2084
2091
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
|
2085
2092
|
if (!componentConfig) {
|
|
2086
2093
|
return;
|
|
2087
2094
|
}
|
|
2088
2095
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
|
|
2089
2096
|
if (componentConfig.resolvePermissions) {
|
|
2090
|
-
const changed = getChanged(item2,
|
|
2091
|
-
|
|
2097
|
+
const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
|
|
2098
|
+
const propsChanged = Object.values(changed).some((el) => el === true);
|
|
2099
|
+
const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
|
|
2100
|
+
if (propsChanged || parentChanged || force2) {
|
|
2092
2101
|
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
|
2093
2102
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
|
2094
2103
|
item2,
|
|
2095
2104
|
{
|
|
2096
2105
|
changed,
|
|
2097
|
-
lastPermissions: (
|
|
2106
|
+
lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
|
|
2098
2107
|
permissions: initialPermissions,
|
|
2099
2108
|
appState: makeStatePublic(appState),
|
|
2100
|
-
lastData: (
|
|
2109
|
+
lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
|
|
2110
|
+
parent: parentData
|
|
2101
2111
|
}
|
|
2102
2112
|
);
|
|
2103
2113
|
const latest = get().permissions;
|
|
@@ -2105,6 +2115,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2105
2115
|
permissions: __spreadProps(__spreadValues({}, latest), {
|
|
2106
2116
|
cache: __spreadProps(__spreadValues({}, latest.cache), {
|
|
2107
2117
|
[item2.props.id]: {
|
|
2118
|
+
lastParentId: parentId,
|
|
2108
2119
|
lastData: item2,
|
|
2109
2120
|
lastPermissions: resolvedPermissions
|
|
2110
2121
|
}
|
|
@@ -2118,9 +2129,9 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2118
2129
|
}
|
|
2119
2130
|
}
|
|
2120
2131
|
});
|
|
2121
|
-
const
|
|
2132
|
+
const resolvePermissionsForRoot = (force2 = false) => {
|
|
2122
2133
|
const { state: appState } = get();
|
|
2123
|
-
|
|
2134
|
+
resolvePermissionsForItem(
|
|
2124
2135
|
// Shim the root data in by conforming to component data shape
|
|
2125
2136
|
{
|
|
2126
2137
|
type: "root",
|
|
@@ -2131,16 +2142,16 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2131
2142
|
};
|
|
2132
2143
|
const { item, type, root } = params;
|
|
2133
2144
|
if (item) {
|
|
2134
|
-
yield
|
|
2145
|
+
yield resolvePermissionsForItem(item, force);
|
|
2135
2146
|
} else if (type) {
|
|
2136
2147
|
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
|
|
2137
|
-
yield
|
|
2148
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2138
2149
|
}));
|
|
2139
2150
|
} else if (root) {
|
|
2140
|
-
|
|
2151
|
+
resolvePermissionsForRoot(force);
|
|
2141
2152
|
} else {
|
|
2142
2153
|
flattenData(state, config).map((item2) => __async(null, null, function* () {
|
|
2143
|
-
yield
|
|
2154
|
+
yield resolvePermissionsForItem(item2, force);
|
|
2144
2155
|
}));
|
|
2145
2156
|
}
|
|
2146
2157
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
|
3
|
-
"version": "0.21.0-canary.
|
|
3
|
+
"version": "0.21.0-canary.ece26d91",
|
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
5
5
|
"repository": "measuredco/puck",
|
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@measured/puck": "^0.21.0-canary.
|
|
28
|
+
"@measured/puck": "^0.21.0-canary.ece26d91",
|
|
29
29
|
"@types/minimatch": "3.0.5",
|
|
30
30
|
"@types/react": "^19.0.1",
|
|
31
31
|
"@types/react-dom": "^19.0.2",
|