@prismicio/editor-fields 0.4.10 → 0.4.11
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/fields/ImageField/MediaPicker/MediaLibrary/MediaLibrary.d.ts +2 -3
- package/dist/fields/ImageField/MediaPicker/mediaPickerData.d.ts +8 -10
- package/dist/fields/RichTextField/BubbleMenu/BubbleMenu.d.ts +1 -0
- package/dist/fields/RichTextField/BubbleMenu/Link/DocumentDescriptionCard.d.ts +7 -0
- package/dist/fields/RichTextField/BubbleMenu/Link/LinkItems.d.ts +2 -1
- package/dist/fields/RichTextField/BubbleMenu/Link/LinkPopover.d.ts +9 -2
- package/dist/fields/RichTextField/BubbleMenu/Link/SetDocumentLinkModal.d.ts +8 -0
- package/dist/fields/RichTextField/BubbleMenu/Link/{SetLinkModal.d.ts → SetWebLinkModal.d.ts} +2 -2
- package/dist/fields/RichTextField/coreExtensions/ListItem.d.ts +101 -10
- package/dist/fields/RichTextField/extensions/Bold/Bold.d.ts +2 -2
- package/dist/fields/RichTextField/extensions/Bold/BoldModel.d.ts +23 -0
- package/dist/fields/RichTextField/extensions/Embed/useEmbedView.d.ts +1 -1
- package/dist/fields/RichTextField/extensions/Italic/Italic.d.ts +2 -2
- package/dist/fields/RichTextField/extensions/Italic/ItalicModel.d.ts +23 -0
- package/dist/fields/RichTextField/extensions/Link/Link.d.ts +29 -0
- package/dist/fields/RichTextField/extensions/Link/LinkModel.d.ts +58 -0
- package/dist/fields/RichTextField/extensions/extensions.d.ts +2 -2
- package/dist/fields/RichTextField/models/EditorExtension.d.ts +7 -17
- package/dist/fields/RichTextField/models/RichTextConfig.d.ts +50 -4
- package/dist/fields/RichTextField/models/Span.d.ts +88 -4
- package/dist/index.es.js +22282 -22402
- package/package.json +4 -5
- package/dist/fields/RichTextField/extensions/Link.d.ts +0 -2
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { ExternalImage } from "../externalImage";
|
|
2
2
|
import type { UploadFile } from "../mediaPickerData";
|
|
3
3
|
interface MediaLibraryProps {
|
|
4
|
+
isUploading: boolean;
|
|
4
5
|
uploadingFiles: UploadFile[];
|
|
5
6
|
onFilesSelected: (uploadingFiles: File[]) => void;
|
|
6
|
-
onSuccessFiles: () => void;
|
|
7
|
-
onFailedFiles: (failedFiles: UploadFile[]) => void;
|
|
8
|
-
onTryAgain: (failedFile: UploadFile) => void;
|
|
9
7
|
onMediaSelected: (media: ExternalImage) => void;
|
|
8
|
+
onRetry: () => void;
|
|
10
9
|
}
|
|
11
10
|
export declare function MediaLibrary(props: MediaLibraryProps): JSX.Element;
|
|
12
11
|
export {};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { MediaLibraryImage } from "./MediaLibrary/mediaLibraryData";
|
|
2
|
-
export declare type UploadFile =
|
|
3
|
-
interface
|
|
2
|
+
export declare type UploadFile = NewUploadFile | UploadedFile;
|
|
3
|
+
interface NewUploadFile {
|
|
4
4
|
id: string;
|
|
5
5
|
file: File;
|
|
6
|
-
status: "
|
|
7
|
-
response?: MediaLibraryImage;
|
|
6
|
+
status: "idle" | "uploading" | "error";
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
interface UploadedFile {
|
|
10
9
|
id: string;
|
|
11
10
|
file: File;
|
|
12
11
|
status: "success";
|
|
13
12
|
response: MediaLibraryImage;
|
|
14
13
|
}
|
|
15
|
-
export declare function useMediaLibraryUpload(): {
|
|
16
|
-
onFilesSelected: (selectedFiles: File[]) => void;
|
|
14
|
+
export declare function useMediaLibraryUpload(open: boolean): {
|
|
17
15
|
uploadingFiles: UploadFile[];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
isUploading: boolean;
|
|
17
|
+
onFilesSelected: (files: File[]) => void;
|
|
18
|
+
onRetry: () => void;
|
|
21
19
|
};
|
|
22
20
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Editor } from "@tiptap/core";
|
|
2
2
|
import type { MutableRefObject } from "react";
|
|
3
|
+
import type { Modal } from "../BubbleMenu";
|
|
3
4
|
interface LinkItemsProps {
|
|
4
5
|
editor: Editor;
|
|
5
|
-
|
|
6
|
+
setModal: (modal: Modal) => void;
|
|
6
7
|
bubbleMenuContainerRef?: MutableRefObject<null>;
|
|
7
8
|
}
|
|
8
9
|
export declare function LinkItems(props: LinkItemsProps): JSX.Element;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { Editor } from "@tiptap/core";
|
|
2
2
|
interface LinkPopoverProps {
|
|
3
3
|
editor: Editor;
|
|
4
|
-
|
|
4
|
+
onEditWebLink: () => void;
|
|
5
|
+
onEditDocumentLink: () => void;
|
|
5
6
|
}
|
|
6
|
-
export declare function LinkPopover(props: LinkPopoverProps): JSX.Element;
|
|
7
|
+
export declare function LinkPopover(props: LinkPopoverProps): JSX.Element | null;
|
|
8
|
+
interface DocumentLinkPopoverProps {
|
|
9
|
+
editor: Editor;
|
|
10
|
+
onEditDocumentLink: () => void;
|
|
11
|
+
docId: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function DocumentLinkPopover(props: DocumentLinkPopoverProps): JSX.Element;
|
|
7
14
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/core";
|
|
2
|
+
interface SetDocumentLinkModalProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
setOpen: (open: boolean) => void;
|
|
5
|
+
editor: Editor;
|
|
6
|
+
}
|
|
7
|
+
export declare function SetDocumentLinkModal(props: SetDocumentLinkModalProps): JSX.Element;
|
|
8
|
+
export {};
|
package/dist/fields/RichTextField/BubbleMenu/Link/{SetLinkModal.d.ts → SetWebLinkModal.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Editor } from "@tiptap/core";
|
|
2
|
-
interface
|
|
2
|
+
interface SetWebLinkModalProps {
|
|
3
3
|
open: boolean;
|
|
4
4
|
setOpen: (open: boolean) => void;
|
|
5
5
|
editor: Editor;
|
|
6
6
|
}
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function SetWebLinkModal(props: SetWebLinkModalProps): JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -1,19 +1,64 @@
|
|
|
1
|
-
import type { ReadonlyNonEmptyArray } from "fp-ts/ReadonlyNonEmptyArray";
|
|
2
1
|
import type { Node as ProsemirrorNode, Schema } from "prosemirror-model";
|
|
3
2
|
declare const _default: {
|
|
4
3
|
component: import("@tiptap/core").Node<import("@tiptap/extension-list-item").ListItemOptions, any>;
|
|
5
4
|
converter: {
|
|
6
5
|
fromPrismic(schema: Schema<any, any>): (list: {
|
|
7
|
-
type: "em" | "embed" | "strong" | "image" | "
|
|
6
|
+
type: "em" | "embed" | "strong" | "image" | "list-item" | "paragraph" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
|
|
8
7
|
content: {
|
|
9
8
|
text: string;
|
|
10
9
|
} & {
|
|
11
10
|
spans?: ({
|
|
12
|
-
data
|
|
13
|
-
|
|
11
|
+
data: ({
|
|
12
|
+
__TYPE__: "ImageLink";
|
|
13
|
+
} & {
|
|
14
|
+
id: string;
|
|
15
|
+
url: string;
|
|
16
|
+
height: string;
|
|
17
|
+
width: string;
|
|
18
|
+
size: string;
|
|
19
|
+
name: string;
|
|
20
|
+
kind: string;
|
|
21
|
+
} & {
|
|
22
|
+
date?: string | null | undefined;
|
|
23
|
+
}) | ({
|
|
24
|
+
id: string;
|
|
25
|
+
url: string;
|
|
26
|
+
name: string;
|
|
27
|
+
kind: string;
|
|
28
|
+
size: string;
|
|
29
|
+
} & {
|
|
30
|
+
date?: string | null | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
__TYPE__: "FileLink";
|
|
33
|
+
} & {
|
|
34
|
+
size?: string | undefined;
|
|
35
|
+
}) | ({
|
|
36
|
+
__TYPE__: "DocumentLink";
|
|
37
|
+
} & {
|
|
38
|
+
id: string;
|
|
39
|
+
}) | ({
|
|
40
|
+
__TYPE__: "ExternalLink";
|
|
41
|
+
} & {
|
|
42
|
+
url: string;
|
|
43
|
+
} & {
|
|
44
|
+
kind?: "web" | undefined;
|
|
45
|
+
target?: string | null | undefined;
|
|
46
|
+
preview?: {
|
|
47
|
+
title?: string | undefined;
|
|
48
|
+
} | null | undefined;
|
|
49
|
+
});
|
|
14
50
|
start: number;
|
|
15
51
|
end: number;
|
|
16
|
-
type: "
|
|
52
|
+
type: "hyperlink";
|
|
53
|
+
} | {
|
|
54
|
+
data: string;
|
|
55
|
+
start: number;
|
|
56
|
+
end: number;
|
|
57
|
+
type: "label";
|
|
58
|
+
} | {
|
|
59
|
+
start: number;
|
|
60
|
+
end: number;
|
|
61
|
+
type: "em" | "strong" | "list-item";
|
|
17
62
|
})[] | undefined;
|
|
18
63
|
};
|
|
19
64
|
} & {
|
|
@@ -21,16 +66,62 @@ declare const _default: {
|
|
|
21
66
|
direction?: string | undefined;
|
|
22
67
|
}) => ProsemirrorNode | undefined;
|
|
23
68
|
toPrismic(node: ProsemirrorNode, nodeType: "list-item" | "o-list-item"): readonly ({
|
|
24
|
-
type: "em" | "embed" | "strong" | "image" | "
|
|
69
|
+
type: "em" | "embed" | "strong" | "image" | "list-item" | "paragraph" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
|
|
25
70
|
content: {
|
|
26
71
|
text: string;
|
|
27
72
|
} & {
|
|
28
73
|
spans?: ({
|
|
29
|
-
data
|
|
30
|
-
|
|
74
|
+
data: ({
|
|
75
|
+
__TYPE__: "ImageLink";
|
|
76
|
+
} & {
|
|
77
|
+
id: string;
|
|
78
|
+
url: string;
|
|
79
|
+
height: string;
|
|
80
|
+
width: string;
|
|
81
|
+
size: string;
|
|
82
|
+
name: string;
|
|
83
|
+
kind: string;
|
|
84
|
+
} & {
|
|
85
|
+
date?: string | null | undefined;
|
|
86
|
+
}) | ({
|
|
87
|
+
id: string;
|
|
88
|
+
url: string;
|
|
89
|
+
name: string;
|
|
90
|
+
kind: string;
|
|
91
|
+
size: string;
|
|
92
|
+
} & {
|
|
93
|
+
date?: string | null | undefined;
|
|
94
|
+
} & {
|
|
95
|
+
__TYPE__: "FileLink";
|
|
96
|
+
} & {
|
|
97
|
+
size?: string | undefined;
|
|
98
|
+
}) | ({
|
|
99
|
+
__TYPE__: "DocumentLink";
|
|
100
|
+
} & {
|
|
101
|
+
id: string;
|
|
102
|
+
}) | ({
|
|
103
|
+
__TYPE__: "ExternalLink";
|
|
104
|
+
} & {
|
|
105
|
+
url: string;
|
|
106
|
+
} & {
|
|
107
|
+
kind?: "web" | undefined;
|
|
108
|
+
target?: string | null | undefined;
|
|
109
|
+
preview?: {
|
|
110
|
+
title?: string | undefined;
|
|
111
|
+
} | null | undefined;
|
|
112
|
+
});
|
|
113
|
+
start: number;
|
|
114
|
+
end: number;
|
|
115
|
+
type: "hyperlink";
|
|
116
|
+
} | {
|
|
117
|
+
data: string;
|
|
118
|
+
start: number;
|
|
119
|
+
end: number;
|
|
120
|
+
type: "label";
|
|
121
|
+
} | {
|
|
31
122
|
start: number;
|
|
32
123
|
end: number;
|
|
33
|
-
type: "
|
|
124
|
+
type: "em" | "strong" | "list-item";
|
|
34
125
|
})[] | undefined;
|
|
35
126
|
};
|
|
36
127
|
} & {
|
|
@@ -41,4 +132,4 @@ declare const _default: {
|
|
|
41
132
|
placeholder: string;
|
|
42
133
|
};
|
|
43
134
|
export default _default;
|
|
44
|
-
export declare function mergeLists(
|
|
135
|
+
export declare function mergeLists(previousNode: ProsemirrorNode, newNode: ProsemirrorNode): ProsemirrorNode | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const EditorBold:
|
|
1
|
+
import { BoldExtension } from "./BoldModel";
|
|
2
|
+
declare const EditorBold: BoldExtension;
|
|
3
3
|
export default EditorBold;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Mark } from "@tiptap/core";
|
|
2
|
+
import type { Mark as ProsemirrorMark, Schema } from "prosemirror-model";
|
|
3
|
+
import { ExtensionType } from "../../models";
|
|
4
|
+
export declare class BoldExtension {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly component: Mark;
|
|
7
|
+
readonly converter: {
|
|
8
|
+
fromPrismic(schema: Schema): (elmt: BoldElement) => ProsemirrorMark | undefined;
|
|
9
|
+
toPrismic(elmt: ProsemirrorMark): undefined;
|
|
10
|
+
};
|
|
11
|
+
extType: ExtensionType.Mark;
|
|
12
|
+
richTextNodeTypes: "strong";
|
|
13
|
+
constructor(name: string, component: Mark, converter: {
|
|
14
|
+
fromPrismic(schema: Schema): (elmt: BoldElement) => ProsemirrorMark | undefined;
|
|
15
|
+
toPrismic(elmt: ProsemirrorMark): undefined;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
interface BoldElement {
|
|
19
|
+
type: "strong" | "em" | "list-item";
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -6,7 +6,7 @@ export declare function useEmbedView(props: EmbedViewProps, inputRef: RefObject<
|
|
|
6
6
|
containerRef: RefObject<HTMLDivElement>;
|
|
7
7
|
onKeyDown: (event: KeyboardEvent<Element>) => void;
|
|
8
8
|
url: string;
|
|
9
|
-
urlChanged: (
|
|
9
|
+
urlChanged: (newUrl: string) => void;
|
|
10
10
|
onContentChange: (content?: EmbedContent) => void;
|
|
11
11
|
debouncedUrl: string;
|
|
12
12
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const EditorItalic:
|
|
1
|
+
import { ItalicExtension } from "./ItalicModel";
|
|
2
|
+
declare const EditorItalic: ItalicExtension;
|
|
3
3
|
export default EditorItalic;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Mark } from "@tiptap/core";
|
|
2
|
+
import type { Mark as ProsemirrorMark, Schema } from "prosemirror-model";
|
|
3
|
+
import { ExtensionType } from "../../models";
|
|
4
|
+
export declare class ItalicExtension {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly component: Mark;
|
|
7
|
+
readonly converter: {
|
|
8
|
+
fromPrismic(schema: Schema): (elmt: ItalicElement) => ProsemirrorMark | undefined;
|
|
9
|
+
toPrismic(elmt: ProsemirrorMark): undefined;
|
|
10
|
+
};
|
|
11
|
+
extType: ExtensionType.Mark;
|
|
12
|
+
richTextNodeTypes: "em";
|
|
13
|
+
constructor(name: string, component: Mark, converter: {
|
|
14
|
+
fromPrismic(schema: Schema): (elmt: ItalicElement) => ProsemirrorMark | undefined;
|
|
15
|
+
toPrismic(elmt: ProsemirrorMark): undefined;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
interface ItalicElement {
|
|
19
|
+
type: "strong" | "em" | "list-item";
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LinkExtension } from "./LinkModel";
|
|
2
|
+
export interface LinkProtocolOptions {
|
|
3
|
+
scheme: string;
|
|
4
|
+
optionalSlashes?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface LinkOptions {
|
|
7
|
+
autolink: boolean;
|
|
8
|
+
protocols: (LinkProtocolOptions | string)[];
|
|
9
|
+
openOnClick: boolean;
|
|
10
|
+
linkOnPaste: boolean;
|
|
11
|
+
/** These are the values passed into the HTML through the Tiptap extension. */
|
|
12
|
+
htmlAttributes: Record<string, any>;
|
|
13
|
+
validate?: (url: string) => boolean;
|
|
14
|
+
}
|
|
15
|
+
declare module "@tiptap/core" {
|
|
16
|
+
interface Commands<ReturnType> {
|
|
17
|
+
Link: {
|
|
18
|
+
setWebLink: (attributes: {
|
|
19
|
+
href: string;
|
|
20
|
+
target?: string | null;
|
|
21
|
+
}) => ReturnType;
|
|
22
|
+
setDocumentLink: (attributes: {
|
|
23
|
+
id: string;
|
|
24
|
+
}) => ReturnType;
|
|
25
|
+
unsetLink: () => ReturnType;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export declare const Link: LinkExtension;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Mark } from "@tiptap/core";
|
|
2
|
+
import type { Mark as ProsemirrorMark, Schema } from "prosemirror-model";
|
|
3
|
+
import { ExtensionType } from "../../models";
|
|
4
|
+
export declare class LinkExtension {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly component: Mark;
|
|
7
|
+
readonly converter: {
|
|
8
|
+
fromPrismic(schema: Schema): (elmt: LinkElement) => ProsemirrorMark | undefined;
|
|
9
|
+
toPrismic(elmt: ProsemirrorMark): LinkElementData;
|
|
10
|
+
};
|
|
11
|
+
extType: ExtensionType.Mark;
|
|
12
|
+
richTextNodeTypes: "hyperlink";
|
|
13
|
+
constructor(name: string, component: Mark, converter: {
|
|
14
|
+
fromPrismic(schema: Schema): (elmt: LinkElement) => ProsemirrorMark | undefined;
|
|
15
|
+
toPrismic(elmt: ProsemirrorMark): LinkElementData;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export interface LinkElement {
|
|
19
|
+
type: "hyperlink";
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
data: LinkElementData;
|
|
23
|
+
}
|
|
24
|
+
export declare type LinkElementData = ImageLinkData | FileLinkData | DocumentLinkData | ExternalLinkData;
|
|
25
|
+
interface ImageLinkData {
|
|
26
|
+
__TYPE__: "ImageLink";
|
|
27
|
+
id: string;
|
|
28
|
+
url: string;
|
|
29
|
+
height: string;
|
|
30
|
+
width: string;
|
|
31
|
+
size: string;
|
|
32
|
+
name: string;
|
|
33
|
+
kind: string;
|
|
34
|
+
date?: string | null | undefined;
|
|
35
|
+
}
|
|
36
|
+
interface FileLinkData {
|
|
37
|
+
__TYPE__: "FileLink";
|
|
38
|
+
id: string;
|
|
39
|
+
url: string;
|
|
40
|
+
name: string;
|
|
41
|
+
kind: string;
|
|
42
|
+
size: string;
|
|
43
|
+
date?: string | null | undefined;
|
|
44
|
+
}
|
|
45
|
+
interface DocumentLinkData {
|
|
46
|
+
__TYPE__: "DocumentLink";
|
|
47
|
+
id: string;
|
|
48
|
+
}
|
|
49
|
+
interface ExternalLinkData {
|
|
50
|
+
__TYPE__: "ExternalLink";
|
|
51
|
+
url: string;
|
|
52
|
+
kind?: "web";
|
|
53
|
+
target?: string | null | undefined;
|
|
54
|
+
preview?: {
|
|
55
|
+
title?: string;
|
|
56
|
+
} | null | undefined;
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -7,10 +7,10 @@ import { default as Embed } from "./Embed/EmbedExtension";
|
|
|
7
7
|
import { default as Heading } from "./Heading/Heading";
|
|
8
8
|
import { default as Image } from "./Image/ImageExtension";
|
|
9
9
|
import { default as Italic } from "./Italic/Italic";
|
|
10
|
-
import { Link } from "./Link";
|
|
10
|
+
import { Link } from "./Link/Link";
|
|
11
11
|
import { default as OrderedList } from "./OrderedList/OrderedList";
|
|
12
12
|
import { default as Paragraph } from "./Paragraph/Paragraph";
|
|
13
13
|
export declare const DefaultTextExtension: import("../models").TextExtension;
|
|
14
|
-
export declare const MarkExtensions: import("
|
|
14
|
+
export declare const MarkExtensions: (import("./Bold/BoldModel").BoldExtension | import("./Italic/ItalicModel").ItalicExtension | import("./Link/LinkModel").LinkExtension)[];
|
|
15
15
|
export declare function getAllExtensions(nodeTypes?: Set<RichTextNodeType>): WidgetExtension[];
|
|
16
16
|
export { Bold, BulletList, CodeBlock, Embed, Heading, Image, Italic, Link, OrderedList, Paragraph };
|
|
@@ -1,10 +1,13 @@
|
|
|
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 {
|
|
3
|
+
import type { Node } from "@tiptap/core";
|
|
4
4
|
import type { NonEmptyArray } from "fp-ts/NonEmptyArray";
|
|
5
5
|
import type { ReadonlyNonEmptyArray } from "fp-ts/ReadonlyNonEmptyArray";
|
|
6
|
-
import type {
|
|
6
|
+
import type { Node as ProsemirrorNode, Schema } from "prosemirror-model";
|
|
7
|
+
import type { BoldExtension } from "../extensions/Bold/BoldModel";
|
|
7
8
|
import type { Level } from "../extensions/Heading/Heading";
|
|
9
|
+
import type { ItalicExtension } from "../extensions/Italic/ItalicModel";
|
|
10
|
+
import type { LinkExtension } from "../extensions/Link/LinkModel";
|
|
8
11
|
export declare enum ExtensionType {
|
|
9
12
|
Document = "document",
|
|
10
13
|
Mark = "mark",
|
|
@@ -16,7 +19,7 @@ export declare enum NodeType {
|
|
|
16
19
|
Image = "image"
|
|
17
20
|
}
|
|
18
21
|
export declare type Extension = WidgetExtension | DocumentExtension;
|
|
19
|
-
export declare type WidgetExtension = MarkExtension
|
|
22
|
+
export declare type WidgetExtension = MarkExtension | NodeExtension;
|
|
20
23
|
export declare type ExtensionPlaceholder = string | ((nodeAttrs: ProsemirrorNode["attrs"]) => string | undefined) | undefined;
|
|
21
24
|
export declare class DocumentExtension {
|
|
22
25
|
readonly name: string;
|
|
@@ -31,20 +34,7 @@ export declare class DocumentExtension {
|
|
|
31
34
|
toPrismic(elmt: ProsemirrorNode): RichTextContent | undefined;
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
|
-
export declare
|
|
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
|
-
}
|
|
37
|
+
export declare type MarkExtension = LinkExtension | BoldExtension | ItalicExtension;
|
|
48
38
|
export declare type NodeExtension = TextExtension | EmbedExtension | ImageExtension;
|
|
49
39
|
export declare class TextExtension {
|
|
50
40
|
readonly richTextNodeTypes: ReadonlyNonEmptyArray<RichTextNodeType>;
|
|
@@ -7,16 +7,62 @@ export declare function composeExtensions(config?: RichTextConfig): {
|
|
|
7
7
|
} | {
|
|
8
8
|
extensions: WidgetExtension[];
|
|
9
9
|
defaultTextConverter: (schema: Schema<any, any>) => (block: {
|
|
10
|
-
type: "em" | "embed" | "strong" | "image" | "
|
|
10
|
+
type: "em" | "embed" | "strong" | "image" | "list-item" | "paragraph" | "o-list-item" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "preformatted" | "hyperlink" | "rtl";
|
|
11
11
|
content: {
|
|
12
12
|
text: string;
|
|
13
13
|
} & {
|
|
14
14
|
spans?: ({
|
|
15
|
-
data
|
|
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: "
|
|
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
|
|
4
|
-
data
|
|
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: "
|
|
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[];
|