Skip to content

Commit

Permalink
Added schema input class and refactored, changes by @mcqua007
Browse files Browse the repository at this point in the history
  • Loading branch information
JCDriessen committed Jul 16, 2024
1 parent d992416 commit cc8e7a1
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,40 +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 RichTextRendererOptions {
export interface Options {
/** allows for the rich text HTML to be easily styled */
scoped: boolean;
scoped?: boolean | string
/** convert new line character to <br/> */
newLineToBreak: boolean;
classes: {
newLineToBreak?: boolean
classes?: {
/** paragraph classes */
p: string,
p?: string
/** heading1 classes */
h1: string,
h1?: string
/** heading2 classes */
h2: string,
h2?: string
/** heading3 classes */
h3: string,
h3?: string
/** heading4 classes */
h4: string,
h4?: string
/** heading5 classes */
h5: string,
h5?: string
/** heading6 classes */
h6: string,
h6?: string
/** order list classes */
ol: string,
ol?: string
/** unordered list classes */
ul: string,
ul?: string
/** list item classes */
li: string,
li?: string
/** anchor/link classes */
a: string,
a?: string
/** bold/strong classes */
strong: string,
strong?: string
/** italic/em classes */
em: string,
em?: string
}
}

/** Converts Shopify rich text to HTML */
export function convertSchemaToHtml(schema: string, options: RichTextRendererOptions = {}): string;
}
export function convertSchemaToHtml(schema: string | Schema | Schema[], options?: Options | string | boolean): string
}

0 comments on commit cc8e7a1

Please sign in to comment.