@puckeditor/plugin-heading-analyzer 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.
package/dist/index.d.mts CHANGED
@@ -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;
@@ -397,7 +444,7 @@ type ExtractField<UserField extends {
397
444
  type: T;
398
445
  }>;
399
446
 
400
- type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
447
+ type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
401
448
  type PuckComponent<Props> = (props: WithId<WithPuckProps<{
402
449
  [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
403
450
  }>>) => JSX.Element;
@@ -698,12 +745,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
698
745
  }>;
699
746
  type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
700
747
  type: string;
701
- } = Field | G["UserField"]> = Omit<{
748
+ } = Field | G["UserField"]> = {
702
749
  [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
703
750
  children: ReactNode;
704
751
  name: string;
705
- }>;
706
- }, "custom">;
752
+ }> | null;
753
+ };
707
754
 
708
755
  type DragAxis = "dynamic" | "y" | "x";
709
756
 
package/dist/index.d.ts CHANGED
@@ -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;
@@ -397,7 +444,7 @@ type ExtractField<UserField extends {
397
444
  type: T;
398
445
  }>;
399
446
 
400
- type SlotComponent = (props?: Omit<DropZoneProps, "zone">) => ReactNode;
447
+ type SlotComponent = <ComponentType extends ElementType = "div">(props?: SlotProps<ComponentType>) => ReactNode;
401
448
  type PuckComponent<Props> = (props: WithId<WithPuckProps<{
402
449
  [K in keyof Props]: WithDeepSlots<Props[K], SlotComponent>;
403
450
  }>>) => JSX.Element;
@@ -698,12 +745,12 @@ type Overrides<UserConfig extends Config = Config> = OverridesGeneric<{
698
745
  }>;
699
746
  type FieldRenderFunctions<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>, UserField extends {
700
747
  type: string;
701
- } = Field | G["UserField"]> = Omit<{
748
+ } = Field | G["UserField"]> = {
702
749
  [Type in UserField["type"]]: React.FunctionComponent<FieldProps<ExtractField<UserField, Type>, any> & {
703
750
  children: ReactNode;
704
751
  name: string;
705
- }>;
706
- }, "custom">;
752
+ }> | null;
753
+ };
707
754
 
708
755
  type DragAxis = "dynamic" | "y" | "x";
709
756
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/plugin-heading-analyzer",
3
- "version": "0.23.0",
3
+ "version": "0.24.0-canary.34794e5d",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "devDependencies": {
28
- "@puckeditor/core": "^0.23.0",
28
+ "@puckeditor/core": "^0.24.0-canary.34794e5d",
29
29
  "@types/minimatch": "3.0.5",
30
30
  "@types/react": "^19.0.1",
31
31
  "@types/react-dom": "^19.0.2",