@puckeditor/core 0.23.0 → 0.24.0-canary.34794e5d

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.
Files changed (36) hide show
  1. package/dist/{Editor-44C53YAG.mjs → Editor-7HVJABBS.mjs} +6 -6
  2. package/dist/{actions-DA1J5F56.d.mts → actions-DzP_zhsF.d.mts} +65 -18
  3. package/dist/{actions-DA1J5F56.d.ts → actions-DzP_zhsF.d.ts} +65 -18
  4. package/dist/{chunk-NJTGWYYH.mjs → chunk-75VT4L37.mjs} +1 -1
  5. package/dist/{chunk-55V3NZVF.mjs → chunk-A3M7OOIH.mjs} +98 -51
  6. package/dist/{chunk-YQWFSBOU.mjs → chunk-DWQZNG26.mjs} +58 -3
  7. package/dist/{chunk-GNR2HNTB.mjs → chunk-FHGOTDB5.mjs} +7 -7
  8. package/dist/{chunk-WF6I3XOL.mjs → chunk-FVMO3IOJ.mjs} +3 -3
  9. package/dist/{chunk-4P4VZS4P.mjs → chunk-L24AF7CT.mjs} +1 -1
  10. package/dist/{chunk-K2LNXU54.mjs → chunk-OOTCJDR3.mjs} +16 -0
  11. package/dist/{chunk-67Y7M4OJ.mjs → chunk-YBKRDXOL.mjs} +1 -1
  12. package/dist/{full-7ZJV44EE.mjs → full-35XZI7ZG.mjs} +5 -5
  13. package/dist/{index-DIZKfHDN.d.ts → index-Cv-eVWCd.d.ts} +1 -1
  14. package/dist/{index-n9eR_SWx.d.mts → index-poi3aTIz.d.mts} +1 -1
  15. package/dist/index.css +4 -3
  16. package/dist/index.d.mts +8 -6
  17. package/dist/index.d.ts +8 -6
  18. package/dist/index.js +169 -51
  19. package/dist/index.mjs +8 -8
  20. package/dist/internal.d.mts +2 -2
  21. package/dist/internal.d.ts +2 -2
  22. package/dist/{loaded-SMPR6KZF.mjs → loaded-2NYAMF3O.mjs} +2 -2
  23. package/dist/{loaded-JKA25A3T.mjs → loaded-ESP3PLMN.mjs} +2 -2
  24. package/dist/{loaded-36WRJPBT.mjs → loaded-RS7ITDTL.mjs} +2 -2
  25. package/dist/no-external.css +4 -3
  26. package/dist/no-external.d.mts +3 -3
  27. package/dist/no-external.d.ts +3 -3
  28. package/dist/no-external.js +169 -51
  29. package/dist/no-external.mjs +8 -8
  30. package/dist/rsc.d.mts +2 -2
  31. package/dist/rsc.d.ts +2 -2
  32. package/dist/rsc.js +57 -3
  33. package/dist/rsc.mjs +1 -1
  34. package/dist/{walk-tree-DbY5zG2K.d.ts → walk-tree-Bu3IHwm_.d.ts} +1 -1
  35. package/dist/{walk-tree-DHP1pWEM.d.mts → walk-tree-iWDqHBcM.d.mts} +1 -1
  36. package/package.json +1 -1
@@ -4,16 +4,16 @@ import {
4
4
  import {
5
5
  EditorInner,
6
6
  LoadedRichTextMenu
7
- } from "./chunk-WF6I3XOL.mjs";
7
+ } from "./chunk-FVMO3IOJ.mjs";
8
8
  import "./chunk-H635BA2V.mjs";
9
- import "./chunk-GNR2HNTB.mjs";
10
- import "./chunk-67Y7M4OJ.mjs";
11
- import "./chunk-4P4VZS4P.mjs";
12
- import "./chunk-NJTGWYYH.mjs";
9
+ import "./chunk-FHGOTDB5.mjs";
10
+ import "./chunk-YBKRDXOL.mjs";
11
+ import "./chunk-L24AF7CT.mjs";
12
+ import "./chunk-75VT4L37.mjs";
13
13
  import {
14
14
  useAppStore,
15
15
  useAppStoreApi
16
- } from "./chunk-K2LNXU54.mjs";
16
+ } from "./chunk-OOTCJDR3.mjs";
17
17
  import "./chunk-Z2MS6UIF.mjs";
18
18
  import "./chunk-ZRAERXB4.mjs";
19
19
  import "./chunk-Y2EFNT5P.mjs";
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, ElementType, Ref, JSX } from 'react';
1
+ import { ElementType, CSSProperties, Ref, ComponentPropsWithoutRef, ReactElement, ReactNode, JSX } from 'react';
2
2
  import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
3
3
  import { BlockquoteOptions } from '@tiptap/extension-blockquote';
4
4
  import { BoldOptions } from '@tiptap/extension-bold';
@@ -20,6 +20,62 @@ type ItemSelector = {
20
20
  zone?: string;
21
21
  };
22
22
 
23
+ /**
24
+ * Props consumed by Puck internally that are shared between DropZones and slots.
25
+ */
26
+ type DropZoneSharedProps<ComponentType extends ElementType = "div"> = {
27
+ allow?: string[];
28
+ disallow?: string[];
29
+ style?: CSSProperties;
30
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
31
+ className?: string;
32
+ collisionAxis?: DragAxis;
33
+ ref?: Ref<any>;
34
+ as?: ComponentType;
35
+ };
36
+ /**
37
+ * All props consumed by Puck for a DropZone component. `zone` lives here only.
38
+ *
39
+ * On slots `zone` is injected internally, so slots use {@link SlotProps} instead.
40
+ */
41
+ type DropZoneOwnProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & {
42
+ zone: string;
43
+ };
44
+ /**
45
+ * Unsupported additional props that are never forwarded to `as`.
46
+ *
47
+ * Omitted from the public types AND stripped at runtime.
48
+ */
49
+ type NonForwardableProps = {
50
+ children?: unknown;
51
+ dangerouslySetInnerHTML?: unknown;
52
+ };
53
+ /**
54
+ * Keys internally consumed by Puck and never forwarded to `as`.
55
+ */
56
+ type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata";
57
+ /**
58
+ * Additional props forwarded to the element or component provided via `as`,
59
+ * typed against it.
60
+ *
61
+ * Puck-internal/unsupported props are stripped so they don't leak onto the DOM.
62
+ */
63
+ type ForwardedProps<ComponentType extends ElementType> = Omit<ComponentPropsWithoutRef<ComponentType>, ConsumedPropKey | keyof NonForwardableProps>;
64
+ /**
65
+ * Props for a `DropZone` component.
66
+ *
67
+ * Any additional props not consumed by Puck are forwarded to the element or
68
+ * component provided via `as` (defaulting to a `div`), typed against it.
69
+ */
70
+ type DropZoneProps<ComponentType extends ElementType = "div"> = DropZoneOwnProps<ComponentType> & ForwardedProps<ComponentType>;
71
+ /**
72
+ * Props for a `slot` render component.
73
+ *
74
+ * Any additional props not consumed by Puck are forwarded to the element or
75
+ * component provided via `as` (defaulting to a `div`), typed against it.
76
+ */
77
+ type SlotProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & ForwardedProps<ComponentType>;
78
+
23
79
  declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
24
80
  isAlignLeft?: undefined;
25
81
  canAlignLeft?: undefined;
@@ -338,20 +394,11 @@ type FieldProps<F = Field<any>, ValueType = any> = {
338
394
  readOnly?: boolean;
339
395
  };
340
396
 
341
- type DropZoneProps = {
342
- zone: string;
343
- allow?: string[];
344
- disallow?: string[];
345
- style?: CSSProperties;
346
- minEmptyHeight?: CSSProperties["minHeight"] | number;
347
- className?: string;
348
- collisionAxis?: DragAxis;
349
- as?: ElementType;
350
- ref?: Ref<any>;
351
- };
352
-
353
397
  type PuckContext = {
354
- renderDropZone: (props: DropZoneProps) => React.ReactNode;
398
+ /**
399
+ * @deprecated Use {@link https://puckeditor.com/docs/api-reference/fields/slot Slots} instead.
400
+ */
401
+ renderDropZone: <ComponentType extends ElementType = "div">(props: DropZoneProps<ComponentType>) => React.ReactNode;
355
402
  metadata: Metadata;
356
403
  isEditing: boolean;
357
404
  dragRef: ((element: Element | null) => void) | null;
@@ -399,7 +446,7 @@ type ExtractField<UserField extends {
399
446
  type: T;
400
447
  }>;
401
448
 
402
- type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
449
+ type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
403
450
  type PuckComponent<Props> = (props: WithId<WithPuckProps<{
404
451
  [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
405
452
  }>>) => JSX.Element;
@@ -713,12 +760,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
713
760
  }>;
714
761
  type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
715
762
  type: string;
716
- } = Field | G["UserField"]> = Omit<{
763
+ } = Field | G["UserField"]> = {
717
764
  [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
718
765
  children: ReactNode;
719
766
  name: string;
720
- }>;
721
- }, "custom">;
767
+ }> | null;
768
+ };
722
769
 
723
770
  type Direction = "left" | "right" | "up" | "down" | null;
724
771
  type DragAxis = "dynamic" | "y" | "x";
@@ -1,4 +1,4 @@
1
- import { ReactElement, CSSProperties, ReactNode, ElementType, Ref, JSX } from 'react';
1
+ import { ElementType, CSSProperties, Ref, ComponentPropsWithoutRef, ReactElement, ReactNode, JSX } from 'react';
2
2
  import { EditorStateSnapshot, Editor, Extensions } from '@tiptap/react';
3
3
  import { BlockquoteOptions } from '@tiptap/extension-blockquote';
4
4
  import { BoldOptions } from '@tiptap/extension-bold';
@@ -20,6 +20,62 @@ type ItemSelector = {
20
20
  zone?: string;
21
21
  };
22
22
 
23
+ /**
24
+ * Props consumed by Puck internally that are shared between DropZones and slots.
25
+ */
26
+ type DropZoneSharedProps<ComponentType extends ElementType = "div"> = {
27
+ allow?: string[];
28
+ disallow?: string[];
29
+ style?: CSSProperties;
30
+ minEmptyHeight?: CSSProperties["minHeight"] | number;
31
+ className?: string;
32
+ collisionAxis?: DragAxis;
33
+ ref?: Ref<any>;
34
+ as?: ComponentType;
35
+ };
36
+ /**
37
+ * All props consumed by Puck for a DropZone component. `zone` lives here only.
38
+ *
39
+ * On slots `zone` is injected internally, so slots use {@link SlotProps} instead.
40
+ */
41
+ type DropZoneOwnProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & {
42
+ zone: string;
43
+ };
44
+ /**
45
+ * Unsupported additional props that are never forwarded to `as`.
46
+ *
47
+ * Omitted from the public types AND stripped at runtime.
48
+ */
49
+ type NonForwardableProps = {
50
+ children?: unknown;
51
+ dangerouslySetInnerHTML?: unknown;
52
+ };
53
+ /**
54
+ * Keys internally consumed by Puck and never forwarded to `as`.
55
+ */
56
+ type ConsumedPropKey = keyof DropZoneOwnProps | "as" | "content" | "config" | "metadata";
57
+ /**
58
+ * Additional props forwarded to the element or component provided via `as`,
59
+ * typed against it.
60
+ *
61
+ * Puck-internal/unsupported props are stripped so they don't leak onto the DOM.
62
+ */
63
+ type ForwardedProps<ComponentType extends ElementType> = Omit<ComponentPropsWithoutRef<ComponentType>, ConsumedPropKey | keyof NonForwardableProps>;
64
+ /**
65
+ * Props for a `DropZone` component.
66
+ *
67
+ * Any additional props not consumed by Puck are forwarded to the element or
68
+ * component provided via `as` (defaulting to a `div`), typed against it.
69
+ */
70
+ type DropZoneProps<ComponentType extends ElementType = "div"> = DropZoneOwnProps<ComponentType> & ForwardedProps<ComponentType>;
71
+ /**
72
+ * Props for a `slot` render component.
73
+ *
74
+ * Any additional props not consumed by Puck are forwarded to the element or
75
+ * component provided via `as` (defaulting to a `div`), typed against it.
76
+ */
77
+ type SlotProps<ComponentType extends ElementType = "div"> = DropZoneSharedProps<ComponentType> & ForwardedProps<ComponentType>;
78
+
23
79
  declare const defaultEditorState: (ctx: EditorStateSnapshot, readOnly: boolean) => {
24
80
  isAlignLeft?: undefined;
25
81
  canAlignLeft?: undefined;
@@ -338,20 +394,11 @@ type FieldProps<F = Field<any>, ValueType = any> = {
338
394
  readOnly?: boolean;
339
395
  };
340
396
 
341
- type DropZoneProps = {
342
- zone: string;
343
- allow?: string[];
344
- disallow?: string[];
345
- style?: CSSProperties;
346
- minEmptyHeight?: CSSProperties["minHeight"] | number;
347
- className?: string;
348
- collisionAxis?: DragAxis;
349
- as?: ElementType;
350
- ref?: Ref<any>;
351
- };
352
-
353
397
  type PuckContext = {
354
- renderDropZone: (props: DropZoneProps) => React.ReactNode;
398
+ /**
399
+ * @deprecated Use {@link https://puckeditor.com/docs/api-reference/fields/slot Slots} instead.
400
+ */
401
+ renderDropZone: <ComponentType extends ElementType = "div">(props: DropZoneProps<ComponentType>) => React.ReactNode;
355
402
  metadata: Metadata;
356
403
  isEditing: boolean;
357
404
  dragRef: ((element: Element | null) => void) | null;
@@ -399,7 +446,7 @@ type ExtractField<UserField extends {
399
446
  type: T;
400
447
  }>;
401
448
 
402
- type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
449
+ type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
403
450
  type PuckComponent<Props> = (props: WithId<WithPuckProps<{
404
451
  [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
405
452
  }>>) => JSX.Element;
@@ -713,12 +760,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
713
760
  }>;
714
761
  type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
715
762
  type: string;
716
- } = Field | G["UserField"]> = Omit<{
763
+ } = Field | G["UserField"]> = {
717
764
  [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
718
765
  children: ReactNode;
719
766
  name: string;
720
- }>;
721
- }, "custom">;
767
+ }> | null;
768
+ };
722
769
 
723
770
  type Direction = "left" | "right" | "up" | "down" | null;
724
771
  type DragAxis = "dynamic" | "y" | "x";
@@ -2,7 +2,7 @@ import {
2
2
  List,
3
3
  ListOrdered,
4
4
  useMessage
5
- } from "./chunk-K2LNXU54.mjs";
5
+ } from "./chunk-OOTCJDR3.mjs";
6
6
  import {
7
7
  init_react_import
8
8
  } from "./chunk-M6W7YEVX.mjs";