UNPKG

@storyblok/richtext

Version:
183 lines (182 loc) 7.12 kB
import * as _tiptap_extension_paragraph0 from "@tiptap/extension-paragraph"; import * as _tiptap_extension_blockquote0 from "@tiptap/extension-blockquote"; import * as _tiptap_extension_heading0 from "@tiptap/extension-heading"; import * as _tiptap_extension_list0 from "@tiptap/extension-list"; import * as _tiptap_extension_code_block0 from "@tiptap/extension-code-block"; import * as _tiptap_extension_hard_break0 from "@tiptap/extension-hard-break"; import * as _tiptap_extension_horizontal_rule0 from "@tiptap/extension-horizontal-rule"; import * as _tiptap_extension_emoji0 from "@tiptap/extension-emoji"; import * as _tiptap_extension_table0 from "@tiptap/extension-table"; import * as _tiptap_extension_details0 from "@tiptap/extension-details"; import * as _tiptap_extension_bold0 from "@tiptap/extension-bold"; import * as _tiptap_extension_italic0 from "@tiptap/extension-italic"; import * as _tiptap_extension_strike0 from "@tiptap/extension-strike"; import * as _tiptap_extension_underline0 from "@tiptap/extension-underline"; import * as _tiptap_extension_code0 from "@tiptap/extension-code"; import * as _tiptap_extension_superscript0 from "@tiptap/extension-superscript"; import * as _tiptap_extension_subscript0 from "@tiptap/extension-subscript"; import * as _tiptap_extension_highlight0 from "@tiptap/extension-highlight"; import * as _tiptap_extension_link0 from "@tiptap/extension-link"; import { Extension, Mark, Node } from "@tiptap/core"; import * as _tiptap_extension_text_align0 from "@tiptap/extension-text-align"; //#region src/types/index.d.ts /** * Represents text alignment attributes that can be applied to block-level elements. */ interface TextAlignmentAttrs { textAlign?: 'left' | 'center' | 'right' | 'justify'; } /** * Represents common attributes that can be applied to block-level elements. */ interface BlockAttributes extends TextAlignmentAttrs { class?: string; id?: string; [key: string]: any; } interface StoryblokRichTextDocumentNode { type: string; content?: StoryblokRichTextDocumentNode[]; attrs?: BlockAttributes; text?: string; marks?: StoryblokRichTextDocumentNode[]; } /** * Represents the configuration options for optimizing images in rich text content. */ interface StoryblokRichTextImageOptimizationOptions { /** * CSS class to be applied to the image. */ class: string; /** * Width of the image in pixels. */ width: number; /** * Height of the image in pixels. */ height: number; /** * Loading strategy for the image. 'lazy' loads the image when it enters the viewport. 'eager' loads the image immediately. */ loading: 'lazy' | 'eager'; /** * Optional filters that can be applied to the image to adjust its appearance. * * @example * * ```typescript * const filters: Partial<StoryblokRichTextImageOptimizationOptions['filters']> = { * blur: 5, * brightness: 150, * grayscale: true * } * ``` */ filters: Partial<{ blur: number; brightness: number; fill: 'transparent'; format: 'webp' | 'png' | 'jpg'; grayscale: boolean; quality: number; rotate: 0 | 90 | 180 | 270; }>; /** * Defines a set of source set values that tell the browser different image sizes to load based on screen conditions. * The entries can be just the width in pixels or a tuple of width and pixel density. * * @example * * ```typescript * const srcset: (number | [number, number])[] = [ * 320, * [640, 2] * ] * ``` */ srcset: (number | [number, number])[]; /** * A list of sizes that correspond to different viewport widths, instructing the browser on which srcset source to use. * * @example * * ```typescript * const sizes: string[] = [ * '(max-width: 320px) 280px', * '(max-width: 480px) 440px', * '800px' * ] * ``` */ sizes: string[]; } //#endregion //#region src/extensions/marks.d.ts declare const StoryblokLink: Mark<_tiptap_extension_link0.LinkOptions, any>; interface StyledOptions { allowedStyles?: string[]; } //#endregion //#region src/extensions/index.d.ts interface StyleOption { name: string; value: string; } interface HTMLParserOptions { allowCustomAttributes?: boolean; preserveWhitespace?: boolean | 'full'; tiptapExtensions?: Partial<typeof defaultExtensions & Record<string, Extension | Mark | Node>>; styleOptions?: StyleOption[]; } declare const defaultExtensions: { document: Node<any, any>; text: Node<any, any>; paragraph: Node<_tiptap_extension_paragraph0.ParagraphOptions, any>; blockquote: Node<_tiptap_extension_blockquote0.BlockquoteOptions, any>; heading: Node<_tiptap_extension_heading0.HeadingOptions, any>; bulletList: Node<_tiptap_extension_list0.BulletListOptions, any>; orderedList: Node<_tiptap_extension_list0.OrderedListOptions, any>; listItem: Node<_tiptap_extension_list0.ListItemOptions, any>; codeBlock: Node<_tiptap_extension_code_block0.CodeBlockOptions, any>; hardBreak: Node<_tiptap_extension_hard_break0.HardBreakOptions, any>; horizontalRule: Node<_tiptap_extension_horizontal_rule0.HorizontalRuleOptions, any>; image: Node<{ optimizeImages: boolean | Partial<StoryblokRichTextImageOptimizationOptions>; }, any>; emoji: Node<_tiptap_extension_emoji0.EmojiOptions, _tiptap_extension_emoji0.EmojiStorage>; table: Node<_tiptap_extension_table0.TableOptions, any>; tableRow: Node<_tiptap_extension_table0.TableRowOptions, any>; tableCell: Node<_tiptap_extension_table0.TableCellOptions, any>; tableHeader: Node<_tiptap_extension_table0.TableHeaderOptions, any>; blok: Node<{ renderComponent: ((blok: Record<string, unknown>, id?: string) => unknown) | null; }, any>; details: Node<_tiptap_extension_details0.DetailsOptions, any>; detailsContent: Node<_tiptap_extension_details0.DetailsContentOptions, any>; detailsSummary: Node<_tiptap_extension_details0.DetailsSummaryOptions, any>; bold: Mark<_tiptap_extension_bold0.BoldOptions, any>; italic: Mark<_tiptap_extension_italic0.ItalicOptions, any>; strike: Mark<_tiptap_extension_strike0.StrikeOptions, any>; underline: Mark<_tiptap_extension_underline0.UnderlineOptions, any>; code: Mark<_tiptap_extension_code0.CodeOptions, any>; superscript: Mark<_tiptap_extension_superscript0.SuperscriptExtensionOptions, any>; subscript: Mark<_tiptap_extension_subscript0.SubscriptExtensionOptions, any>; highlight: Mark<_tiptap_extension_highlight0.HighlightOptions, any>; textStyle: Mark<any, any>; link: typeof StoryblokLink; anchor: Mark<any, any>; styled: Mark<StyledOptions, any>; reporter: Mark<any, any>; textAlign: Extension<_tiptap_extension_text_align0.TextAlignOptions, any>; }; //#endregion //#region src/markdown-parser.d.ts interface MarkdownParserOptions { tiptapExtensions?: HTMLParserOptions['tiptapExtensions']; } declare function markdownToStoryblokRichtext(md: string, options?: MarkdownParserOptions): StoryblokRichTextDocumentNode; //#endregion export { MarkdownParserOptions, markdownToStoryblokRichtext }; //# sourceMappingURL=markdown-parser.d.cts.map