import React from "react"; import { MarkdownProps } from "../../cmem/markdown/Markdown"; import { ReduceToTextFuncType } from "./reduceToText"; interface MarkdownWithCutOffProps extends Omit { cutOff: NonNullable; } export interface TruncateMarkdownDisplayType { ( /** * Markdown element with mandatory `cutOff` property. */ input: React.ReactElement, /** * Options given to the internal used `reduceToText` function. */ reduceToTextOptions?: Pick[1]>, "decodeHtmlEntities" | "decodeHtmlEntitiesOptions">, /** * Maximum number of rounds to iterate over text length of the rendered Markdown display. */ maxRounds?: number): React.ReactElement; } /** * The internal `truncateMarkdown` function cuts off the raw Markdown content. * Because of the Markdown syntax, the rendered Markdown content can be much shorter (e.g., Markdown link syntax is * longer than the rendered link text). * * This method iterates over a series of Markdown displays, updating the internally used `cutOff` value to create a * Markdown result whose text length is closer to the initial `cutOff` value. * * As a fast path, if the Markdown rendered without any `cutOff` is already shorter than or equal to the initial * `cutOff`, the untruncated element is returned without iteration. * * Otherwise, the algorithm: * * * calculates a factor from the given `cutOff` and the text length of the returned Markdown element * * uses this factor to adjust the `cutOff` value applied in the next iteration * * loops over the iterations and tracks the result whose rendered text length is closest to the initial `cutOff` * * The loop will stop when: * * * the text length of the Markdown result does not change over one iteration step * * the adjusted `cutOff` value does not change over one iteration step (no further progress possible) * * the text length of the Markdown result is exactly the given initial `cutOff` * * the maximum number of iteration rounds is reached (defaults to `5`) * * The returned element is the iteration whose rendered text length is closest in absolute distance to the initial * `cutOff`. This may be slightly over or under the initial `cutOff` value. */ export declare const truncateMarkdownDisplay: TruncateMarkdownDisplayType; export {};