Skip to content

Commit

Permalink
Merge pull request #30 from JCDriessen/main
Browse files Browse the repository at this point in the history
Added type definitions for use of this package in Typescript
  • Loading branch information
mcqua007 committed Jul 23, 2024
2 parents 8e45b69 + cc8e7a1 commit 0a6058d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
declare module '@thebeyondgroup/shopify-rich-text-renderer' {

/** Shopify rich text schema */
export interface Schema {
type: string
children?: Schema[]
level?: number
listType?: 'ordered' | 'unordered'
url?: string
title?: string
target?: string
bold?: boolean
italic?: boolean
value?: string
}

/** Optional options for rendering Shopify rich text to HTML */
export interface Options {
/** allows for the rich text HTML to be easily styled */
scoped?: boolean | string
/** convert new line character to <br/> */
newLineToBreak?: boolean
classes?: {
/** paragraph classes */
p?: string
/** heading1 classes */
h1?: string
/** heading2 classes */
h2?: string
/** heading3 classes */
h3?: string
/** heading4 classes */
h4?: string
/** heading5 classes */
h5?: string
/** heading6 classes */
h6?: string
/** order list classes */
ol?: string
/** unordered list classes */
ul?: string
/** list item classes */
li?: string
/** anchor/link classes */
a?: string
/** bold/strong classes */
strong?: string
/** italic/em classes */
em?: string
}
}

/** Converts Shopify rich text to HTML */
export function convertSchemaToHtml(schema: string | Schema | Schema[], options?: Options | string | boolean): string
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"license": "MIT",
"private": false,
"type": "module",
"typings": "index.d.ts",
"scripts": {
"build": "npx rollup -c",
"docs": "npx jsdoc2md ./src/index.js > docs.md",
Expand Down

0 comments on commit 0a6058d

Please sign in to comment.