mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add prismic-dom types for version 2.1 (#34228)
* Add prismic-dom new asHtml types * improve indentation
This commit is contained in:
parent
f1be41efc5
commit
f7fa09cecb
51
types/prismic-dom/index.d.ts
vendored
51
types/prismic-dom/index.d.ts
vendored
@ -1,12 +1,50 @@
|
||||
// Type definitions for prismic-dom 2.0
|
||||
// Type definitions for prismic-dom 2.1
|
||||
// Project: https://github.com/prismicio/prismic-dom#readme
|
||||
// Definitions by: Nick Whyte <https://github.com/nickw444>
|
||||
// Siggy Bilstein <https://github.com/sbilstein>
|
||||
// Douglas Nomizo <https://github.com/douglasnomizo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
type ElementType =
|
||||
| "heading1"
|
||||
| "heading2"
|
||||
| "heading3"
|
||||
| "heading4"
|
||||
| "heading5"
|
||||
| "heading6"
|
||||
| "paragraph"
|
||||
| "preformatted"
|
||||
| "strong"
|
||||
| "em"
|
||||
| "list-item"
|
||||
| "o-list-item"
|
||||
| "group-list-item"
|
||||
| "group-o-list-item"
|
||||
| "image"
|
||||
| "embed"
|
||||
| "hyperlink"
|
||||
| "label"
|
||||
| "span";
|
||||
|
||||
type Elements = {[key in ElementType]: string};
|
||||
|
||||
type HTMLSerializer<T> = (
|
||||
type: ElementType,
|
||||
element: any,
|
||||
text: string | null,
|
||||
children: T[],
|
||||
index: number,
|
||||
) => T;
|
||||
|
||||
interface RichText {
|
||||
asHtml(richText: any, linkResolver?: (doc: any) => string): string;
|
||||
asText(richText: any, joinString?: string): string;
|
||||
asHtml(
|
||||
richText: any,
|
||||
linkResolver?: (doc: any) => string,
|
||||
serializer?: HTMLSerializer<string>,
|
||||
): string;
|
||||
asText(richText: any, joinString?: string): string;
|
||||
Elements: Elements;
|
||||
}
|
||||
|
||||
interface Link {
|
||||
@ -15,6 +53,11 @@ interface Link {
|
||||
|
||||
export const RichText: RichText;
|
||||
export const Link: Link;
|
||||
export const HTMLSerializer: HTMLSerializer<string>;
|
||||
|
||||
declare const _default: {
|
||||
RichText: RichText;
|
||||
Link: Link
|
||||
};
|
||||
|
||||
declare const _default: { RichText: RichText, Link: Link };
|
||||
export default _default;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import prismicDom = require("prismic-dom");
|
||||
|
||||
const rendered: string = prismicDom.RichText.asHtml({});
|
||||
const string = '';
|
||||
const rendered: string = prismicDom.RichText.asHtml({}, () => string, () => string);
|
||||
const link: string = prismicDom.Link.url({}, ({}) => string);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user