-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add documentation to all exports
- Loading branch information
1 parent
3a083ca
commit ba15a01
Showing
10 changed files
with
226 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
import * as React from "react"; | ||
|
||
/** | ||
* Props for `<PrismicToolbar>`. | ||
*/ | ||
export type PrismicToolbarProps = { | ||
/** The name of the Prismic repository. For example, `"my-repo"` if the repository URL is `my-repo.prismic.io`. */ | ||
repositoryName: string; | ||
|
||
/** | ||
* The type of toolbar needed for the repository. Defaults to `"new"`. | ||
* | ||
* @see To check which version you need, view the Prismic Toolbar documentation {@link https://prismic.io/docs/technologies/previews-and-the-prismic-toolbar-reactjs} | ||
*/ | ||
type?: "new" | "legacy"; | ||
}; | ||
|
||
/** | ||
* React component that injects the Prismic Toolbar to the app. This component can be placed anywhere in the React tree. | ||
*/ | ||
export const PrismicToolbar = ({ | ||
repositoryName, | ||
type = "new", | ||
}: PrismicToolbarProps): JSX.Element => { | ||
return ( | ||
<script | ||
src={`https://static.cdn.prismic.io/prismic.js?repositoryName=${repositoryName}${ | ||
type == "new" ? "&type=new" : "" | ||
}`} | ||
defer={true} | ||
/> | ||
); | ||
}: PrismicToolbarProps): null => { | ||
React.useEffect(() => { | ||
const script = document.createElement("script"); | ||
script.src = `https://static.cdn.prismic.io/prismic.js?repositoryName=${repositoryName}${ | ||
type == "new" ? "&type=new" : "" | ||
}`; | ||
script.defer = true; | ||
document.body.appendChild(script); | ||
}, [repositoryName, type]); | ||
|
||
return null; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,16 @@ | ||
import { | ||
RichTextFunctionSerializer, | ||
RichTextMapSerializer, | ||
} from "@prismicio/richtext"; | ||
import React from "react"; | ||
|
||
export type JSXFunctionSerializer = RichTextFunctionSerializer<JSX.Element>; | ||
export type JSXMapSerializer = RichTextMapSerializer<JSX.Element>; | ||
import * as prismicR from "@prismicio/richtext"; | ||
|
||
/** | ||
* Serializes a node from a rich text or title field with a function to HTML | ||
* A function mapping Rich Text block types to React Components. It is used to render Rich Text or Title fields. | ||
* | ||
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript} | ||
*/ | ||
export type ComponentFunctionSerializer = | ||
RichTextFunctionSerializer<React.ReactNode>; | ||
export type JSXFunctionSerializer = | ||
prismicR.RichTextFunctionSerializer<JSX.Element>; | ||
|
||
/** | ||
* Serializes a node from a rich text or title field with a map to HTML | ||
* A map of Rich Text block types to React Components. It is used to render Rich Text or Title fields. | ||
* | ||
* @see Templating rich text and title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript} | ||
* @see Templating Rich Text and Title fields from Prismic {@link https://prismic.io/docs/technologies/templating-rich-text-and-title-fields-javascript} | ||
*/ | ||
export type ComponentMapSerializer = RichTextMapSerializer<React.ReactNode>; | ||
export type JSXMapSerializer = prismicR.RichTextMapSerializer<JSX.Element>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters