@prismicio/editor-fields 0.3.0 → 0.4.1

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.
@@ -1,16 +1,16 @@
1
1
  import type { Document } from "@prismicio/types-internal/lib/content";
2
- import { type CustomType, type SharedSlice } from "@prismicio/types-internal/lib/customtypes";
2
+ import type { StaticCustomType } from "@prismicio/types-internal/lib/customtypes";
3
3
  import { type FC } from "react";
4
- import { DocumentEditorConfig } from "./DocumentEditorConfig";
5
- declare type SharedSlices = Readonly<Record<string, SharedSlice>>;
4
+ import { EditorConfig } from "./EditorConfig";
5
+ import type { Selection } from "./Selection";
6
6
  declare type DocumentEditorProps = Readonly<{
7
+ config: EditorConfig;
8
+ readOnly?: boolean;
9
+ customType: StaticCustomType;
10
+ sectionName: string;
11
+ selection?: Selection;
7
12
  content: Document;
8
- customType: CustomType;
9
13
  onContentChange: (content: Document) => void;
10
- readOnly?: boolean;
11
- sectionName: string | undefined;
12
- sharedSlices: SharedSlices;
13
- config?: DocumentEditorConfig;
14
14
  }>;
15
15
  export declare const DocumentEditor: FC<DocumentEditorProps>;
16
16
  export {};
@@ -0,0 +1,10 @@
1
+ export interface EditorConfig {
2
+ embeds: {
3
+ url: string;
4
+ };
5
+ unsplash: {
6
+ url: string;
7
+ };
8
+ }
9
+ export declare const EditorConfigContext: import("react").Context<EditorConfig | undefined>;
10
+ export declare function useEditorConfig(): EditorConfig;
@@ -1,9 +1,11 @@
1
1
  import { type Document } from "@prismicio/types-internal/lib/content";
2
2
  import type { StaticSection } from "@prismicio/types-internal/lib/customtypes";
3
3
  import { type FC } from "react";
4
+ import type { Selection } from "./Selection";
4
5
  declare type SectionEditorProps = Readonly<{
5
6
  id: string;
6
7
  readOnly: boolean;
8
+ selection?: Selection;
7
9
  section: StaticSection;
8
10
  content: Document;
9
11
  onContentChange: (content: Document) => void;
@@ -0,0 +1,5 @@
1
+ export interface Selection {
2
+ id: string;
3
+ key: string;
4
+ offset?: number;
5
+ }
@@ -0,0 +1,10 @@
1
+ import type { ColorContent } from "@prismicio/types-internal/lib/content";
2
+ import type { Color as ColorT } from "@prismicio/types-internal/lib/customtypes";
3
+ declare type Props = Readonly<{
4
+ id: string;
5
+ field: ColorT;
6
+ content?: ColorContent;
7
+ onContentChange: (content?: ColorContent) => void;
8
+ }>;
9
+ export declare const ColorField: ({ id, field, content, onContentChange }: Props) => JSX.Element;
10
+ export {};
@@ -0,0 +1 @@
1
+ export { ColorField } from "./ColorField";
@@ -1,11 +1,11 @@
1
1
  import type { DateContent } from "@prismicio/types-internal/lib/content";
2
2
  import type { Date as DateT } from "@prismicio/types-internal/lib/customtypes";
3
3
  declare type Props = Readonly<{
4
- content?: DateContent;
5
- field: DateT;
6
4
  id: string;
7
- onContentChange: (content?: DateContent) => void;
8
5
  readOnly: boolean;
6
+ field: DateT;
7
+ content?: DateContent;
8
+ onContentChange: (content?: DateContent) => void;
9
9
  }>;
10
- export declare const DateField: ({ content, field, id, onContentChange, readOnly }: Props) => JSX.Element;
10
+ export declare const DateField: ({ id, readOnly, field, content, onContentChange }: Props) => JSX.Element;
11
11
  export {};
@@ -0,0 +1,11 @@
1
+ import type { EmbedContent } from "@prismicio/types-internal/lib/content";
2
+ import type { Embed as EmbedT } from "@prismicio/types-internal/lib/customtypes";
3
+ declare type Props = Readonly<{
4
+ id: string;
5
+ readOnly: boolean;
6
+ field: EmbedT;
7
+ content?: EmbedContent;
8
+ onContentChange: (content?: EmbedContent) => void;
9
+ }>;
10
+ export declare const EmbedField: ({ id, readOnly, field, content, onContentChange }: Props) => JSX.Element;
11
+ export {};
@@ -0,0 +1 @@
1
+ export { EmbedField } from "./EmbedField";
@@ -0,0 +1 @@
1
+ export declare const MediaLibrary: () => JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { FC, ReactNode } from "react";
2
+ import type { ExternalImage } from "./externalImage";
3
+ interface MediaPickerProps {
4
+ trigger: ReactNode;
5
+ onMediaSelected: (media: ExternalImage) => void;
6
+ }
7
+ export declare const MediaPicker: FC<MediaPickerProps>;
8
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { ExternalImage } from "./externalImage";
2
+ interface Props {
3
+ onMediaSelected: (media: ExternalImage) => void;
4
+ }
5
+ export declare const UnsplashLibrary: (props: Props) => JSX.Element;
6
+ export {};
@@ -1,8 +1 @@
1
- import { FC, ReactNode } from "react";
2
- import type { ExternalImage } from "./externalImage";
3
- interface MediaPickerProps {
4
- trigger: ReactNode;
5
- onMediaSelected?: (media: ExternalImage) => void;
6
- }
7
- export declare const MediaPicker: FC<MediaPickerProps>;
8
- export {};
1
+ export { MediaPicker } from "./MediaPicker";
@@ -4,7 +4,7 @@ declare const _default: {
4
4
  component: import("@tiptap/core").Node<import("@tiptap/extension-list-item").ListItemOptions, any>;
5
5
  converter: {
6
6
  fromPrismic(schema: Schema<any, any>): (list: {
7
- type: "em" | "embed" | "strong" | "image" | "paragraph" | "list-item" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
7
+ type: "em" | "embed" | "strong" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl";
8
8
  content: {
9
9
  text: string;
10
10
  } & {
@@ -13,7 +13,7 @@ declare const _default: {
13
13
  } & {
14
14
  start: number;
15
15
  end: number;
16
- type: "label" | "em" | "embed" | "strong" | "image" | "paragraph" | "list-item" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
16
+ type: "label" | "em" | "embed" | "strong" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl";
17
17
  })[] | undefined;
18
18
  };
19
19
  } & {
@@ -21,7 +21,7 @@ declare const _default: {
21
21
  direction?: string | undefined;
22
22
  }) => ProsemirrorNode | undefined;
23
23
  toPrismic(node: ProsemirrorNode, nodeType: "list-item" | "o-list-item"): readonly ({
24
- type: "em" | "embed" | "strong" | "image" | "paragraph" | "list-item" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
24
+ type: "em" | "embed" | "strong" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl";
25
25
  content: {
26
26
  text: string;
27
27
  } & {
@@ -30,7 +30,7 @@ declare const _default: {
30
30
  } & {
31
31
  start: number;
32
32
  end: number;
33
- type: "label" | "em" | "embed" | "strong" | "image" | "paragraph" | "list-item" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
33
+ type: "label" | "em" | "embed" | "strong" | "image" | "paragraph" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "list-item" | "o-list-item" | "rtl";
34
34
  })[] | undefined;
35
35
  };
36
36
  } & {
@@ -0,0 +1,11 @@
1
+ import type { TimestampContent } from "@prismicio/types-internal/lib/content";
2
+ import type { Timestamp } from "@prismicio/types-internal/lib/customtypes";
3
+ declare type Props = Readonly<{
4
+ id: string;
5
+ readOnly: boolean;
6
+ field: Timestamp;
7
+ content?: TimestampContent;
8
+ onContentChange: (content?: TimestampContent) => void;
9
+ }>;
10
+ export declare const TimestampField: ({ id, readOnly, field, content, onContentChange }: Props) => JSX.Element;
11
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { UIDContent } from "@prismicio/types-internal/lib/content";
2
+ import type { UID as UIDType } from "@prismicio/types-internal/lib/customtypes";
3
+ declare type Props = Readonly<{
4
+ id: string;
5
+ content?: UIDContent;
6
+ field: UIDType;
7
+ onContentChange: (content?: UIDContent) => void;
8
+ }>;
9
+ export declare const UIDField: ({ id, field, content, onContentChange }: Props) => JSX.Element;
10
+ export {};
@@ -0,0 +1 @@
1
+ export { UIDField } from "./UIDField";
@@ -0,0 +1 @@
1
+ export declare const slugifyUID: (input: string) => string;
@@ -1,6 +1,7 @@
1
- import type { BooleanField, NestableWidget, Separator } from "@prismicio/types-internal/lib/customtypes";
2
- declare type Field = Exclude<NestableWidget, Separator>;
3
- export declare function getFieldLabel(field: NestableWidget): string;
1
+ import type { BooleanField, NestableWidget, Separator, UID } from "@prismicio/types-internal/lib/customtypes";
2
+ declare type Widgets = NestableWidget | UID;
3
+ declare type Field = Exclude<Widgets, Separator>;
4
+ export declare function getFieldLabel(field: Widgets): string;
4
5
  export declare function getFieldPlaceholder(field: Exclude<Field, BooleanField>): string;
5
6
  export declare function getFieldPlaceholder(field: BooleanField, value: boolean): string;
6
7
  export {};
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { DocumentEditor } from "./DocumentEditor";
2
- export type { DocumentEditorConfig } from "./DocumentEditorConfig";
2
+ export type { EditorConfig } from "./EditorConfig";
3
+ export type { Selection } from "./Selection";
3
4
  export { SharedSliceEditor } from "./slices/SharedSliceEditor";