@prismicio/editor-fields 0.4.10 → 0.4.14

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 (70) hide show
  1. package/dist/DocumentEditor.d.ts +4 -7
  2. package/dist/EditorConfig.d.ts +15 -5
  3. package/dist/GroupEditor.d.ts +1 -1
  4. package/dist/Selection.d.ts +25 -3
  5. package/dist/UID.d.ts +5 -0
  6. package/dist/constants/images.d.ts +8 -0
  7. package/dist/fields/EmbedField/EmbedFooter.d.ts +2 -2
  8. package/dist/fields/GeoPointField/geoPointFieldUtils.d.ts +1 -1
  9. package/dist/fields/ImageField/Components/EmptyCardContent.d.ts +2 -2
  10. package/dist/fields/ImageField/Components/ImageFieldCard.d.ts +4 -4
  11. package/dist/fields/ImageField/CropperDialog/CropperDialog.d.ts +1 -1
  12. package/dist/fields/ImageField/CropperDialog/croppedImage.d.ts +2 -2
  13. package/dist/fields/ImageField/MediaPicker/MediaLibrary/MediaLibrary.d.ts +5 -5
  14. package/dist/fields/ImageField/MediaPicker/MediaLibrary/mediaLibraryData.d.ts +28 -6
  15. package/dist/fields/ImageField/MediaPicker/MediaPicker.d.ts +5 -4
  16. package/dist/fields/ImageField/MediaPicker/UnsplashLibrary/unsplashData.d.ts +14 -3
  17. package/dist/fields/ImageField/MediaPicker/externalImage.d.ts +3 -2
  18. package/dist/fields/ImageField/MediaPicker/mediaPickerData.d.ts +10 -12
  19. package/dist/fields/ImageField/imageFieldUtils.d.ts +1 -1
  20. package/dist/fields/ImageField/useImageField.d.ts +2 -2
  21. package/dist/fields/LinkField/Documents/DocumentsModal.d.ts +6 -0
  22. package/dist/fields/LinkField/Documents/Filters.d.ts +1 -1
  23. package/dist/fields/LinkField/Documents/documentsData.d.ts +10 -0
  24. package/dist/fields/LinkField/Documents/useFilters.d.ts +5 -3
  25. package/dist/fields/LinkField/LinkFieldActions.d.ts +1 -1
  26. package/dist/fields/LinkField/index.d.ts +1 -0
  27. package/dist/fields/LinkField/useLinkField.d.ts +48 -4
  28. package/dist/fields/NumberField.d.ts +1 -1
  29. package/dist/fields/RichTextField/BubbleMenu/BubbleMenu.d.ts +1 -0
  30. package/dist/fields/RichTextField/BubbleMenu/Link/DocumentDescriptionCard.d.ts +7 -0
  31. package/dist/fields/RichTextField/BubbleMenu/Link/LinkItems.d.ts +2 -1
  32. package/dist/fields/RichTextField/BubbleMenu/Link/LinkPopover.d.ts +10 -2
  33. package/dist/fields/RichTextField/BubbleMenu/Link/SetDocumentLinkModal.d.ts +8 -0
  34. package/dist/fields/RichTextField/BubbleMenu/Link/SetMediaLinkModal.d.ts +8 -0
  35. package/dist/fields/RichTextField/BubbleMenu/Link/{SetLinkModal.d.ts → SetWebLinkModal.d.ts} +2 -2
  36. package/dist/fields/RichTextField/coreExtensions/ListItem.d.ts +99 -8
  37. package/dist/fields/RichTextField/coreExtensions/Placeholder.d.ts +1 -1
  38. package/dist/fields/RichTextField/coreExtensions/index.d.ts +3 -2
  39. package/dist/fields/RichTextField/extensions/Bold/Bold.d.ts +2 -2
  40. package/dist/fields/RichTextField/extensions/Bold/BoldModel.d.ts +23 -0
  41. package/dist/fields/RichTextField/extensions/Embed/EmbedView.d.ts +1 -1
  42. package/dist/fields/RichTextField/extensions/Embed/useEmbedView.d.ts +21 -2
  43. package/dist/fields/RichTextField/extensions/Heading/Heading.d.ts +3 -4
  44. package/dist/fields/RichTextField/extensions/Image/ImageView.d.ts +1 -1
  45. package/dist/fields/RichTextField/extensions/Image/useImageView.d.ts +2 -2
  46. package/dist/fields/RichTextField/extensions/Italic/Italic.d.ts +2 -2
  47. package/dist/fields/RichTextField/extensions/Italic/ItalicModel.d.ts +23 -0
  48. package/dist/fields/RichTextField/extensions/Link/Link.d.ts +35 -0
  49. package/dist/fields/RichTextField/extensions/Link/LinkModel.d.ts +58 -0
  50. package/dist/fields/RichTextField/extensions/extensions.d.ts +2 -2
  51. package/dist/fields/RichTextField/models/EditorExtension.d.ts +18 -30
  52. package/dist/fields/RichTextField/models/MenuItems.d.ts +2 -2
  53. package/dist/fields/RichTextField/models/RichTextConfig.d.ts +49 -3
  54. package/dist/fields/RichTextField/models/Span.d.ts +88 -4
  55. package/dist/fields/RichTextField/useEditor.d.ts +6 -1
  56. package/dist/fields/UIDField/UIDField.d.ts +3 -3
  57. package/dist/fields/utils.d.ts +2 -2
  58. package/dist/index.d.ts +3 -1
  59. package/dist/index.es.js +33142 -32807
  60. package/dist/slices/CompositeSliceEditor.d.ts +4 -4
  61. package/dist/slices/LegacySliceEditor.d.ts +4 -4
  62. package/dist/slices/SharedSliceEditor.d.ts +4 -2
  63. package/dist/slices/defaults.d.ts +23 -0
  64. package/dist/slices/utils.d.ts +34 -0
  65. package/dist/zones/NonRepeatableZoneEditor.d.ts +4 -5
  66. package/dist/zones/SliceZoneEditor.d.ts +0 -1
  67. package/dist/zones/StaticZone.d.ts +2 -2
  68. package/package.json +6 -7
  69. package/dist/fields/RichTextField/extensions/Link.d.ts +0 -2
  70. package/dist/fields/UIDField/uidUtils.d.ts +0 -1
@@ -1,10 +1,11 @@
1
1
  import type { EmbedBlock, ImageBlock, RichTextContent, TextBlock } from "@prismicio/types-internal/lib/content";
2
2
  import type { RichTextNodeType } from "@prismicio/types-internal/lib/customtypes";
3
- import type { Mark, Node } from "@tiptap/core";
4
- import type { NonEmptyArray } from "fp-ts/NonEmptyArray";
5
- import type { ReadonlyNonEmptyArray } from "fp-ts/ReadonlyNonEmptyArray";
6
- import type { Mark as ProsemirrorMark, Node as ProsemirrorNode, Schema } from "prosemirror-model";
3
+ import type { Node } from "@tiptap/core";
4
+ import type { Node as ProsemirrorNode, Schema } from "prosemirror-model";
5
+ import type { BoldExtension } from "../extensions/Bold/BoldModel";
7
6
  import type { Level } from "../extensions/Heading/Heading";
7
+ import type { ItalicExtension } from "../extensions/Italic/ItalicModel";
8
+ import type { LinkExtension } from "../extensions/Link/LinkModel";
8
9
  export declare enum ExtensionType {
9
10
  Document = "document",
10
11
  Mark = "mark",
@@ -15,9 +16,9 @@ export declare enum NodeType {
15
16
  Embed = "embed",
16
17
  Image = "image"
17
18
  }
18
- export declare type Extension = WidgetExtension | DocumentExtension;
19
- export declare type WidgetExtension = MarkExtension<unknown> | NodeExtension;
20
- export declare type ExtensionPlaceholder = string | ((nodeAttrs: ProsemirrorNode["attrs"]) => string | undefined) | undefined;
19
+ export type Extension = WidgetExtension | DocumentExtension;
20
+ export type WidgetExtension = MarkExtension | NodeExtension;
21
+ export type ExtensionPlaceholder = string | ((nodeAttrs: ProsemirrorNode["attrs"]) => string | undefined) | undefined;
21
22
  export declare class DocumentExtension {
22
23
  readonly name: string;
23
24
  readonly component: (multiLines: boolean) => Node;
@@ -31,23 +32,10 @@ export declare class DocumentExtension {
31
32
  toPrismic(elmt: ProsemirrorNode): RichTextContent | undefined;
32
33
  });
33
34
  }
34
- export declare class MarkExtension<P> {
35
- readonly richTextNodeTypes: NonEmptyArray<RichTextNodeType>;
36
- readonly name: string;
37
- readonly component: Mark;
38
- readonly converter: {
39
- fromPrismic(schema: Schema): (elmt: P) => ProsemirrorMark | undefined;
40
- toPrismic(elmt: ProsemirrorMark): P | undefined;
41
- };
42
- extType: ExtensionType.Mark;
43
- constructor(richTextNodeTypes: NonEmptyArray<RichTextNodeType>, name: string, component: Mark, converter: {
44
- fromPrismic(schema: Schema): (elmt: P) => ProsemirrorMark | undefined;
45
- toPrismic(elmt: ProsemirrorMark): P | undefined;
46
- });
47
- }
48
- export declare type NodeExtension = TextExtension | EmbedExtension | ImageExtension;
35
+ export type MarkExtension = LinkExtension | BoldExtension | ItalicExtension;
36
+ export type NodeExtension = TextExtension | EmbedExtension | ImageExtension;
49
37
  export declare class TextExtension {
50
- readonly richTextNodeTypes: ReadonlyNonEmptyArray<RichTextNodeType>;
38
+ readonly richTextNodeTypes: RichTextNodeType[];
51
39
  readonly name: string;
52
40
  readonly component: Node;
53
41
  readonly converter: {
@@ -58,14 +46,14 @@ export declare class TextExtension {
58
46
  readonly lockedFormat: boolean;
59
47
  extType: ExtensionType.Node;
60
48
  nodeType: NodeType.Text;
61
- constructor(richTextNodeTypes: ReadonlyNonEmptyArray<RichTextNodeType>, name: string, component: Node, converter: {
49
+ constructor(richTextNodeTypes: RichTextNodeType[], name: string, component: Node, converter: {
62
50
  fromPrismic(schema: Schema): (elmt: TextBlock) => ProsemirrorNode | undefined;
63
51
  toPrismic(elmt: ProsemirrorNode): TextBlock | readonly TextBlock[] | undefined;
64
52
  }, placeholder?: ExtensionPlaceholder, lockedFormat?: boolean);
65
53
  }
66
54
  export declare function isTextExtension(extension: WidgetExtension): extension is TextExtension;
67
55
  export declare class EmbedExtension {
68
- readonly richTextNodeTypes: NonEmptyArray<RichTextNodeType>;
56
+ readonly richTextNodeTypes: RichTextNodeType[];
69
57
  readonly name: string;
70
58
  readonly component: Node;
71
59
  readonly converter: {
@@ -74,13 +62,13 @@ export declare class EmbedExtension {
74
62
  };
75
63
  extType: ExtensionType;
76
64
  nodeType: NodeType.Embed;
77
- constructor(richTextNodeTypes: NonEmptyArray<RichTextNodeType>, name: string, component: Node, converter: {
65
+ constructor(richTextNodeTypes: RichTextNodeType[], name: string, component: Node, converter: {
78
66
  fromPrismic(schema: Schema): (elmt: EmbedBlock) => ProsemirrorNode | undefined;
79
67
  toPrismic(elmt: ProsemirrorNode): EmbedBlock | undefined;
80
68
  });
81
69
  }
82
70
  export declare class ImageExtension {
83
- readonly richTextNodeTypes: NonEmptyArray<RichTextNodeType>;
71
+ readonly richTextNodeTypes: RichTextNodeType[];
84
72
  readonly name: string;
85
73
  readonly component: Node;
86
74
  readonly converter: {
@@ -89,20 +77,20 @@ export declare class ImageExtension {
89
77
  };
90
78
  extType: ExtensionType.Node;
91
79
  nodeType: NodeType.Image;
92
- constructor(richTextNodeTypes: NonEmptyArray<RichTextNodeType>, name: string, component: Node, converter: {
80
+ constructor(richTextNodeTypes: RichTextNodeType[], name: string, component: Node, converter: {
93
81
  fromPrismic(schema: Schema): (elmt: ImageBlock) => ProsemirrorNode | undefined;
94
82
  toPrismic(elmt: ProsemirrorNode): ImageBlock | undefined;
95
83
  });
96
84
  }
97
85
  export declare class HeadingTextExtension extends TextExtension {
98
86
  readonly levels: readonly Level[];
99
- constructor(richTextNodeTypes: ReadonlyNonEmptyArray<RichTextNodeType>, Component: Node, levels: readonly Level[], Converter: {
87
+ constructor(richTextNodeTypes: RichTextNodeType[], Component: Node, levels: readonly Level[], Converter: {
100
88
  fromPrismic(schema: Schema): (elmt: TextBlock) => ProsemirrorNode | undefined;
101
89
  toPrismic(elmt: ProsemirrorNode): TextBlock | undefined;
102
90
  }, placeholder?: ExtensionPlaceholder);
103
91
  }
104
92
  export declare class ListExtension extends TextExtension {
105
- constructor(richTextNodeTypes: NonEmptyArray<RichTextNodeType>, name: string, Component: Node, Converter: {
93
+ constructor(richTextNodeTypes: RichTextNodeType[], name: string, Component: Node, Converter: {
106
94
  fromPrismic(schema: Schema): (elmt: TextBlock) => ProsemirrorNode | undefined;
107
95
  toPrismic(elmt: ProsemirrorNode): readonly TextBlock[];
108
96
  });
@@ -1,7 +1,7 @@
1
1
  import type { IconName } from "@prismicio/editor-ui";
2
2
  import { RichTextNodeType } from "@prismicio/types-internal/lib/customtypes";
3
3
  import type { ChainedCommands, Editor, Range } from "@tiptap/core";
4
- export declare type MenuItem = Readonly<{
4
+ export type MenuItem = Readonly<{
5
5
  nodeType: RichTextNodeType;
6
6
  icon: IconName;
7
7
  isActive: (editor: Editor) => boolean;
@@ -13,7 +13,7 @@ export declare type MenuItem = Readonly<{
13
13
  shortText?: undefined;
14
14
  text?: undefined;
15
15
  })>;
16
- declare type RunCommandsOptions = Readonly<{
16
+ type RunCommandsOptions = Readonly<{
17
17
  can?: boolean;
18
18
  deleteRange?: Range;
19
19
  }>;
@@ -12,11 +12,57 @@ export declare function composeExtensions(config?: RichTextConfig): {
12
12
  text: string;
13
13
  } & {
14
14
  spans?: ({
15
- data?: unknown;
16
- } & {
15
+ data: ({
16
+ __TYPE__: "ImageLink";
17
+ } & {
18
+ id: string;
19
+ url: string;
20
+ height: string;
21
+ width: string;
22
+ size: string;
23
+ name: string;
24
+ kind: string;
25
+ } & {
26
+ date?: string | null | undefined;
27
+ }) | ({
28
+ id: string;
29
+ url: string;
30
+ name: string;
31
+ kind: string;
32
+ size: string;
33
+ } & {
34
+ date?: string | null | undefined;
35
+ } & {
36
+ __TYPE__: "FileLink";
37
+ } & {
38
+ size?: string | undefined;
39
+ }) | ({
40
+ __TYPE__: "DocumentLink";
41
+ } & {
42
+ id: string;
43
+ }) | ({
44
+ __TYPE__: "ExternalLink";
45
+ } & {
46
+ url: string;
47
+ } & {
48
+ kind?: "web" | undefined;
49
+ target?: string | null | undefined;
50
+ preview?: {
51
+ title?: string | undefined;
52
+ } | null | undefined;
53
+ });
17
54
  start: number;
18
55
  end: number;
19
- type: "label" | "em" | "embed" | "strong" | "image" | "paragraph" | "list-item" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
56
+ type: "hyperlink";
57
+ } | {
58
+ data: string;
59
+ start: number;
60
+ end: number;
61
+ type: "label";
62
+ } | {
63
+ start: number;
64
+ end: number;
65
+ type: "em" | "strong" | "list-item";
20
66
  })[] | undefined;
21
67
  };
22
68
  } & {
@@ -1,11 +1,95 @@
1
1
  import type { Span } from "@prismicio/types-internal/lib/content";
2
2
  export declare const SpanUtils: {
3
- groupBy<K extends unknown>(spans: readonly Span[], f: (span: Span) => K): Map<K, readonly ({
4
- data?: unknown;
5
- } & {
3
+ groupBy<K extends number | "label" | "em" | "strong" | "list-item" | "hyperlink">(spans: readonly Span[], f: (span: Span) => K): Map<K, readonly ({
4
+ data: ({
5
+ __TYPE__: "ImageLink";
6
+ } & {
7
+ id: string;
8
+ url: string;
9
+ height: string;
10
+ width: string;
11
+ size: string;
12
+ name: string;
13
+ kind: string;
14
+ } & {
15
+ date?: string | null | undefined;
16
+ }) | ({
17
+ id: string;
18
+ url: string;
19
+ name: string;
20
+ kind: string;
21
+ size: string;
22
+ } & {
23
+ date?: string | null | undefined;
24
+ } & {
25
+ __TYPE__: "FileLink";
26
+ } & {
27
+ size?: string | undefined;
28
+ }) | ({
29
+ __TYPE__: "DocumentLink";
30
+ } & {
31
+ id: string;
32
+ }) | ({
33
+ __TYPE__: "ExternalLink";
34
+ } & {
35
+ url: string;
36
+ } & {
37
+ kind?: "web" | undefined;
38
+ target?: string | null | undefined;
39
+ preview?: {
40
+ title?: string | undefined;
41
+ } | null | undefined;
42
+ }) | ({
43
+ __TYPE__: "ImageLink";
44
+ } & {
45
+ id: string;
46
+ url: string;
47
+ height: string;
48
+ width: string;
49
+ size: string;
50
+ name: string;
51
+ kind: string;
52
+ } & {
53
+ date?: string | null | undefined;
54
+ }) | ({
55
+ id: string;
56
+ url: string;
57
+ name: string;
58
+ kind: string;
59
+ size: string;
60
+ } & {
61
+ date?: string | null | undefined;
62
+ } & {
63
+ __TYPE__: "FileLink";
64
+ } & {
65
+ size?: string | undefined;
66
+ }) | ({
67
+ __TYPE__: "DocumentLink";
68
+ } & {
69
+ id: string;
70
+ }) | ({
71
+ __TYPE__: "ExternalLink";
72
+ } & {
73
+ url: string;
74
+ } & {
75
+ kind?: "web" | undefined;
76
+ target?: string | null | undefined;
77
+ preview?: {
78
+ title?: string | undefined;
79
+ } | null | undefined;
80
+ });
6
81
  start: number;
7
82
  end: number;
8
- type: "label" | "em" | "embed" | "strong" | "image" | "paragraph" | "list-item" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
83
+ type: "hyperlink";
84
+ } | {
85
+ data: string;
86
+ start: number;
87
+ end: number;
88
+ type: "label";
89
+ } | {
90
+ start: number;
91
+ end: number;
92
+ type: "em" | "strong" | "list-item";
9
93
  })[]>;
10
94
  sort(spans: readonly Span[]): readonly Span[];
11
95
  mergeOverlap(spans: readonly Span[]): readonly Span[];
@@ -1,4 +1,9 @@
1
1
  import type { EditorOptions } from "@tiptap/core";
2
2
  import { Editor } from "@tiptap/react";
3
- import { DependencyList } from "react";
3
+ import { type DependencyList } from "react";
4
4
  export declare function useEditor(options?: Partial<EditorOptions>, deps?: DependencyList): Editor | undefined;
5
+ /**
6
+ * setTimeout is required to combat tiptap flushsync issue
7
+ * https://github.com/ueberdosis/tiptap/issues/3764
8
+ */
9
+ export declare function handleEditorFlushSyncError(callback: VoidFunction): number;
@@ -1,10 +1,10 @@
1
1
  import type { UIDContent } from "@prismicio/types-internal/lib/content";
2
2
  import type { UID as UIDType } from "@prismicio/types-internal/lib/customtypes";
3
- declare type Props = Readonly<{
3
+ interface UIDFieldProps {
4
4
  id: string;
5
5
  content?: UIDContent;
6
6
  field: UIDType;
7
7
  onContentChange: (content?: UIDContent) => void;
8
- }>;
9
- export declare const UIDField: ({ id, field, content, onContentChange }: Props) => JSX.Element;
8
+ }
9
+ export declare function UIDField(props: UIDFieldProps): JSX.Element;
10
10
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { BooleanField, GeoPoint, NestableWidget, Separator, UID } from "@prismicio/types-internal/lib/customtypes";
2
- declare type Widgets = NestableWidget | UID;
3
- declare type Field = Exclude<Widgets, Separator | GeoPoint>;
2
+ type Widgets = NestableWidget | UID;
3
+ type Field = Exclude<Widgets, Separator | GeoPoint>;
4
4
  export declare function getFieldLabel(field: Widgets): string;
5
5
  export declare const DEFAULT_PLACEHOLDER = "...";
6
6
  export declare function getFieldPlaceholder(field: Exclude<Field, BooleanField>): string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export { DocumentEditor } from "./DocumentEditor";
2
2
  export { type EditorConfig, suppressConfigErrors, throwConfigError } from "./EditorConfig";
3
- export type { Selection } from "./Selection";
3
+ export { getSelectionDOMId, type Selection, type SelectionArea, SelectionContext, useSelection } from "./Selection";
4
+ export { defaultImageContentWidget } from "./slices/defaults";
4
5
  export { SharedSliceEditor } from "./slices/SharedSliceEditor";
6
+ export { UIDContext } from "./UID";