@puckeditor/core 0.23.0 → 0.24.0-canary.0575ba70

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 (39) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{Editor-44C53YAG.mjs → Editor-IOB6CBHE.mjs} +7 -7
  3. package/dist/{Render-DQXAYUBI.mjs → Render-KIF7JWS4.mjs} +1 -1
  4. package/dist/{actions-DA1J5F56.d.mts → actions-DzP_zhsF.d.mts} +65 -18
  5. package/dist/{actions-DA1J5F56.d.ts → actions-DzP_zhsF.d.ts} +65 -18
  6. package/dist/{chunk-WF6I3XOL.mjs → chunk-3CZRCHCU.mjs} +4 -4
  7. package/dist/{chunk-GNR2HNTB.mjs → chunk-3OECBDNE.mjs} +8 -8
  8. package/dist/{chunk-NJTGWYYH.mjs → chunk-3USGHYFG.mjs} +1 -1
  9. package/dist/{chunk-4P4VZS4P.mjs → chunk-3YSLTDRT.mjs} +1 -1
  10. package/dist/{chunk-67Y7M4OJ.mjs → chunk-6MVGICFW.mjs} +1 -1
  11. package/dist/{chunk-K2LNXU54.mjs → chunk-MVHLONPE.mjs} +85 -69
  12. package/dist/{chunk-Y2EFNT5P.mjs → chunk-OT7NKYY4.mjs} +2 -2
  13. package/dist/{chunk-55V3NZVF.mjs → chunk-WQ2SNIVF.mjs} +102 -54
  14. package/dist/{chunk-YQWFSBOU.mjs → chunk-XAJK3MOG.mjs} +60 -5
  15. package/dist/{full-7ZJV44EE.mjs → full-G3HMYLKK.mjs} +6 -6
  16. package/dist/{index-DIZKfHDN.d.ts → index-Cv-eVWCd.d.ts} +1 -1
  17. package/dist/{index-n9eR_SWx.d.mts → index-poi3aTIz.d.mts} +1 -1
  18. package/dist/index.css +4 -3
  19. package/dist/index.d.mts +19 -7
  20. package/dist/index.d.ts +19 -7
  21. package/dist/index.js +302 -182
  22. package/dist/index.mjs +11 -9
  23. package/dist/internal.d.mts +2 -2
  24. package/dist/internal.d.ts +2 -2
  25. package/dist/{loaded-JKA25A3T.mjs → loaded-2R7Z7VD4.mjs} +3 -3
  26. package/dist/{loaded-36WRJPBT.mjs → loaded-4W6LSSFR.mjs} +3 -3
  27. package/dist/{loaded-SMPR6KZF.mjs → loaded-O7MEOBEX.mjs} +3 -3
  28. package/dist/no-external.css +4 -3
  29. package/dist/no-external.d.mts +4 -4
  30. package/dist/no-external.d.ts +4 -4
  31. package/dist/no-external.js +302 -182
  32. package/dist/no-external.mjs +11 -9
  33. package/dist/rsc.d.mts +2 -2
  34. package/dist/rsc.d.ts +2 -2
  35. package/dist/rsc.js +59 -5
  36. package/dist/rsc.mjs +2 -2
  37. package/dist/{walk-tree-DbY5zG2K.d.ts → walk-tree-Bu3IHwm_.d.ts} +1 -1
  38. package/dist/{walk-tree-DHP1pWEM.d.mts → walk-tree-iWDqHBcM.d.mts} +1 -1
  39. package/package.json +34 -33
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) The Puck Contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -4,19 +4,19 @@ import {
4
4
  import {
5
5
  EditorInner,
6
6
  LoadedRichTextMenu
7
- } from "./chunk-WF6I3XOL.mjs";
7
+ } from "./chunk-3CZRCHCU.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-3OECBDNE.mjs";
10
+ import "./chunk-6MVGICFW.mjs";
11
+ import "./chunk-3YSLTDRT.mjs";
12
+ import "./chunk-3USGHYFG.mjs";
13
13
  import {
14
14
  useAppStore,
15
15
  useAppStoreApi
16
- } from "./chunk-K2LNXU54.mjs";
16
+ } from "./chunk-MVHLONPE.mjs";
17
17
  import "./chunk-Z2MS6UIF.mjs";
18
18
  import "./chunk-ZRAERXB4.mjs";
19
- import "./chunk-Y2EFNT5P.mjs";
19
+ import "./chunk-OT7NKYY4.mjs";
20
20
  import "./chunk-H65MT2JK.mjs";
21
21
  import {
22
22
  __spreadProps,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-H635BA2V.mjs";
7
7
  import {
8
8
  get_class_name_factory_default
9
- } from "./chunk-Y2EFNT5P.mjs";
9
+ } from "./chunk-OT7NKYY4.mjs";
10
10
  import {
11
11
  init_react_import
12
12
  } from "./chunk-M6W7YEVX.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";
@@ -3,14 +3,14 @@ import {
3
3
  } from "./chunk-H635BA2V.mjs";
4
4
  import {
5
5
  LoadedRichTextMenuInner
6
- } from "./chunk-GNR2HNTB.mjs";
6
+ } from "./chunk-3OECBDNE.mjs";
7
7
  import {
8
8
  useAppStore,
9
9
  useAppStoreApi
10
- } from "./chunk-K2LNXU54.mjs";
10
+ } from "./chunk-MVHLONPE.mjs";
11
11
  import {
12
12
  get_class_name_factory_default
13
- } from "./chunk-Y2EFNT5P.mjs";
13
+ } from "./chunk-OT7NKYY4.mjs";
14
14
  import {
15
15
  __spreadValues,
16
16
  init_react_import
@@ -100,7 +100,7 @@ init_react_import();
100
100
  import { lazy, Suspense } from "react";
101
101
  import { jsx as jsx2 } from "react/jsx-runtime";
102
102
  var LoadedRichTextMenuFull = lazy(
103
- () => import("./full-7ZJV44EE.mjs").then((m) => ({
103
+ () => import("./full-G3HMYLKK.mjs").then((m) => ({
104
104
  default: m.LoadedRichTextMenuFull
105
105
  }))
106
106
  );
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  useAlignOptions
3
- } from "./chunk-67Y7M4OJ.mjs";
3
+ } from "./chunk-6MVGICFW.mjs";
4
4
  import {
5
5
  useHeadingOptions
6
- } from "./chunk-4P4VZS4P.mjs";
6
+ } from "./chunk-3YSLTDRT.mjs";
7
7
  import {
8
8
  useListOptions
9
- } from "./chunk-NJTGWYYH.mjs";
9
+ } from "./chunk-3USGHYFG.mjs";
10
10
  import {
11
11
  Action,
12
12
  AlignCenter,
@@ -29,10 +29,10 @@ import {
29
29
  Underline,
30
30
  useControlContext,
31
31
  useMessage
32
- } from "./chunk-K2LNXU54.mjs";
32
+ } from "./chunk-MVHLONPE.mjs";
33
33
  import {
34
34
  get_class_name_factory_default
35
- } from "./chunk-Y2EFNT5P.mjs";
35
+ } from "./chunk-OT7NKYY4.mjs";
36
36
  import {
37
37
  init_react_import
38
38
  } from "./chunk-M6W7YEVX.mjs";
@@ -204,7 +204,7 @@ function AlignSelectFallback() {
204
204
  // components/RichTextMenu/controls/AlignSelect/index.tsx
205
205
  import { jsx as jsx7 } from "react/jsx-runtime";
206
206
  var AlignSelectLoaded = lazy(
207
- () => import("./loaded-SMPR6KZF.mjs").then((m) => ({
207
+ () => import("./loaded-O7MEOBEX.mjs").then((m) => ({
208
208
  default: m.AlignSelectLoaded
209
209
  }))
210
210
  );
@@ -445,7 +445,7 @@ function HeadingSelectFallback() {
445
445
  // components/RichTextMenu/controls/HeadingSelect/index.tsx
446
446
  import { jsx as jsx19 } from "react/jsx-runtime";
447
447
  var HeadingSelectLoaded = lazy2(
448
- () => import("./loaded-JKA25A3T.mjs").then((m) => ({
448
+ () => import("./loaded-2R7Z7VD4.mjs").then((m) => ({
449
449
  default: m.HeadingSelectLoaded
450
450
  }))
451
451
  );
@@ -477,7 +477,7 @@ function ListSelectFallback() {
477
477
  // components/RichTextMenu/controls/ListSelect/index.tsx
478
478
  import { jsx as jsx21 } from "react/jsx-runtime";
479
479
  var ListSelectLoaded = lazy3(
480
- () => import("./loaded-36WRJPBT.mjs").then((m) => ({
480
+ () => import("./loaded-4W6LSSFR.mjs").then((m) => ({
481
481
  default: m.ListSelectLoaded
482
482
  }))
483
483
  );
@@ -2,7 +2,7 @@ import {
2
2
  List,
3
3
  ListOrdered,
4
4
  useMessage
5
- } from "./chunk-K2LNXU54.mjs";
5
+ } from "./chunk-MVHLONPE.mjs";
6
6
  import {
7
7
  init_react_import
8
8
  } from "./chunk-M6W7YEVX.mjs";
@@ -6,7 +6,7 @@ import {
6
6
  Heading5,
7
7
  Heading6,
8
8
  useMessage
9
- } from "./chunk-K2LNXU54.mjs";
9
+ } from "./chunk-MVHLONPE.mjs";
10
10
  import {
11
11
  init_react_import
12
12
  } from "./chunk-M6W7YEVX.mjs";
@@ -4,7 +4,7 @@ import {
4
4
  AlignLeft,
5
5
  AlignRight,
6
6
  useMessage
7
- } from "./chunk-K2LNXU54.mjs";
7
+ } from "./chunk-MVHLONPE.mjs";
8
8
  import {
9
9
  init_react_import
10
10
  } from "./chunk-M6W7YEVX.mjs";