import * as _angular_core from '@angular/core'; import { Type, InputSignal, TemplateRef, InjectionToken, Signal, OutputEmitterRef } from '@angular/core'; import { SourceReference } from '@siemens/element-ng/source-chip'; import * as mdast from 'mdast'; import { Node, Parent, RootContent, FootnoteDefinition, Root, Definition } from 'mdast'; import { Plugin, Transformer, Preset, PluggableList, Processor } from 'unified'; import * as _siemens_element_ng_markdown from '@siemens/element-ng/markdown'; import { StatusType } from '@siemens/element-ng/common'; import { TranslatableString } from '@siemens/element-translate-ng/translate-types'; import * as _angular_platform_browser from '@angular/platform-browser'; /** * Copyright (c) Siemens 2016 - 2026 * SPDX-License-Identifier: MIT */ /** Interface an extension component must implement */ interface SiMarkdownExtensionComponent { /** Node to be rendered */ node: InputSignal; /** The parent node */ parent: InputSignal; /** Options passed to the component */ options: InputSignal; } /** Interface a code highlighter component must implement */ interface SiMarkdownHighlighterComponent { /** The code to be highlighted */ code: InputSignal; /** The language */ language: InputSignal; /** Function the highlighter can call to updated the displayed language */ updateLanguage: InputSignal<(lang?: string) => void>; /** Options passed to the component */ options: InputSignal; } /** A combination of a component and options passed to it during run-time */ interface ComponentWithOptions { /** The component used to render the node */ component: Type; /** Options passed to the component */ options?: any; } /** Type handler for a named type. This can be an AST node type, a code type, a directive name */ interface TypeHandler extends ComponentWithOptions { /** Type name */ type: string; } /** AST node created by `remark-directive`. */ interface DirectiveNode extends Parent { type: 'containerDirective' | 'leafDirective' | 'textDirective'; /** The directive name without its leading colons. */ name: string; /** Attributes declared on the directive. */ attributes: Record; } type SiMarkdownHighlighter = ComponentWithOptions; type UnifiedPlugin = Plugin | Transformer | Preset | PluggableList; type UnifiedPluginOptions = ((meta: SiMarkdownMetadata) => any) | any; /** Combination of unified plugin with options */ interface PluginWithOptions { /** The plugin */ plugin: UnifiedPlugin; /** Options passed during plugin registration */ options?: UnifiedPluginOptions; } /** An extension to the si-markdown component */ interface SiMarkdownExtension { /** `unified` plugins to install */ plugins?: PluginWithOptions[]; /** Type handlers to install */ types?: TypeHandler[]; /** Special code type handlers to install */ codeTypes?: TypeHandler[]; /** Directives */ directives?: TypeHandler[]; } /** Citation metadata associated with a markdown response. */ interface SiMarkdownCitation extends SourceReference { /** Identifier referenced by bracket notation, such as `[source-1]`. */ identifier?: string; /** Zero-based, end-exclusive source range of the citation reference in the markdown source. */ position?: { startIndex: number; endIndex: number; }; } /** Options passed to makeProcessor() */ interface SiMarkdownMetadata { citations?: SiMarkdownCitation[]; } /** Inline node that references an item in the source citation array. */ interface Citation extends Node { type: 'citation'; citationIndex: number; /** Text replaced by a position-based citation. */ text?: string; } /** Container for one or more adjacent citation nodes. */ interface Citations extends Node { type: 'citations'; children: Citation[]; } /** Extra node for collecting all footnotes */ interface Footnotes extends Parent { type: 'footnotes'; children: FootnoteDefinition[]; } type ExtendedRootContent = RootContent | Footnotes | Citations | DirectiveNode; /** Extended root with references */ type SiMarkdownRoot = Omit & { children: ExtendedRootContent[]; references?: { footnoteDefinitions?: Map; definitions?: Map; }; }; /** * Copyright (c) Siemens 2016 - 2026 * SPDX-License-Identifier: MIT */ /** * Options for the markdown renderer. This holds all configuration and allows installing * extensions. A number of extensions are already ready to use and shipped with Element. * * @example * ```ts * import { siMarkdownMathKaTeX } from '@siemens/element-ng/markdown/extensions/math'; * import remarkGemoji from 'remark-gemoji'; * * protected markdownOptions = new SiMarkdownOptions() * .installExtension(siMarkdownMathKaTeX()) * .installUnifiedPlugin(remarkGemoji); * ``` * * ```html * * ``` */ declare class SiMarkdownOptions { private readonly plugins; private types; private codeTypes; private directives; private highlighter?; constructor(); /** * Installs a plugin into the `unified` chain * @param plugin - The `unified` plugin * @param options - Options for the plugin * @returns self for chaining */ installUnifiedPlugin(plugin: UnifiedPlugin, options?: UnifiedPluginOptions): SiMarkdownOptions; /** * Registers a component used to render a named Markdown directive. * @param directive - The directive with name and handling component * @returns self for chaining */ registerDirective(directives: TypeHandler | TypeHandler[]): SiMarkdownOptions; /** * Installs a extension which can contain plugins, type handlers * @param extension - The extension definition * @returns self for chaining */ installExtension(extension: SiMarkdownExtension): SiMarkdownOptions; /** * Sets the code highlighter * @param highlighter - The highlighter */ setCodeHighlighter(highlighter?: SiMarkdownHighlighter): SiMarkdownOptions; /** * Creates the `unified` processor with all plugins and options * @returns `unified` processor */ makeProcessor(meta: SiMarkdownMetadata): Processor; /** * @returns All type handlers */ getTypeHandlers(): TypeHandler[]; /** * @returns All code type handlers */ getCodeTypeHandlers(): Map; /** * @returns The highlighter */ getHighlighter(): SiMarkdownHighlighter | undefined; } declare const makeSiMarkdownOptions: () => SiMarkdownOptions; /** Directive used to mark a template as a node type for rendering. */ declare class SiMarkdownTemplateDirective { readonly template: TemplateRef; /** @defaultValue '#dummy' */ readonly nodeType: _angular_core.InputSignal; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵdir: _angular_core.ɵɵDirectiveDeclaration; } /** * Copyright (c) Siemens 2016 - 2026 * SPDX-License-Identifier: MIT */ /** * Token to pass the si-markdown component w/o circular dependencies. */ declare const SI_MARKDOWN_CONTROL: InjectionToken; /** * Interface of si-markdown exposed to children. */ interface SiMarkdownControl { templates: Signal>>; meta: Signal; debug: Signal; extensionEvent: OutputEmitterRef<{ name: string; data: any; }>; } /** * Component to display markdown text * * This component is built using concepts from [ngx-remark](https://github.com/ericleib/ngx-remark), * namely using Angular templates to render the AST produced by `remark`. * * Unlike `ngx-remark`, it features a configuration based approach of extensibility so that multiple * instances of the component can be used with the same configuration, e.g. inside a chat component * w/o repeating templates. * * @experimental */ declare class SiMarkdownComponent implements SiMarkdownControl { private static idCounter; /** * The markdown text to transform and display * @defaultValue '' */ readonly markdown: _angular_core.InputSignal; /** * Options to control rendering. Can be shared across multiple instances. */ readonly options: _angular_core.InputSignal; /** Citation metadata used to create citations. */ readonly citations: _angular_core.InputSignal; /** * Debug mode. When true, unknown node types will be displayed along with the node * as JSON. * @defaultValue false */ readonly debug: _angular_core.InputSignalWithTransform; /** Emitted by extension components. */ readonly extensionEvent: _angular_core.OutputEmitterRef<{ name: string; data: any; }>; protected baseId: string; protected readonly parsed: _angular_core.Signal; protected readonly templateQuery: _angular_core.Signal; protected readonly customTemplateQuery: _angular_core.Signal; /** @internal */ readonly templates: _angular_core.Signal>>; /** Gives access to metadata in extension components */ readonly meta: _angular_core.Signal; private readonly actualOptions; protected readonly config: _angular_core.Signal<{ processor: Processor; typeHandlers: _siemens_element_ng_markdown.TypeHandler[]; codeTypeHandlers: Map; }>; private parseMarkdown; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } /** * Renders a fragment of markdown based on the children of a single node in the AST. */ declare class SiMarkdownFragmentComponent { protected readonly control: _siemens_element_ng_markdown.SiMarkdownControl; /** The node for which to render all children */ readonly node: _angular_core.InputSignal; /** all the children of the node */ readonly children: _angular_core.Signal; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } type CalloutType = 'success' | 'info' | 'warning' | 'danger' | 'caution' | 'critical' | 'note' | 'tip'; interface Callout { label?: TranslatableString; severity: StatusType; icon?: string; color?: string; } declare class SiMarkdownCalloutComponent implements SiMarkdownExtensionComponent { private readonly statusIcons; readonly node: _angular_core.InputSignal; readonly parent: _angular_core.InputSignal; readonly options: _angular_core.InputSignal; readonly icons: Record<"elementLightOn", string>; readonly callouts: Record; protected readonly config: _angular_core.Signal<{ callout: Callout; heading: string | undefined; }>; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } /** * Copyright (c) Siemens 2016 - 2026 * SPDX-License-Identifier: MIT */ /** Installs component rendering for directives parsed by `remark-directive`. */ declare const siMarkdownDirective: (directives: ReadonlyMap) => SiMarkdownExtension; declare class SiMarkdownInlineHtmlComponent implements SiMarkdownExtensionComponent { private readonly sanitizer; readonly node: _angular_core.InputSignal; readonly parent: _angular_core.InputSignal; readonly options: _angular_core.InputSignal; private readonly html; protected readonly sanitized: _angular_core.Signal<_angular_platform_browser.SafeHtml | null>; static ɵfac: _angular_core.ɵɵFactoryDeclaration; static ɵcmp: _angular_core.ɵɵComponentDeclaration; } /** * Copyright (c) Siemens 2016 - 2026 * SPDX-License-Identifier: MIT */ /** Options for `computedAsync()` */ interface ComputedAsyncOptions { /** Params function, params will be passed to the `computation` function. This is tracked. */ params: () => R; /** Computation function. This is `untracked()`, params from the `params` function are passed */ computation: (params: R) => Promise; /** Initial value of the `computedAsync` signal. */ initial: T; } /** * Computed value, but async. This exists because the `resource()` API is not suitable. During * loading, the value changes to `undefined`. The proposed solution of resource snapshots and * a `withPreviousValue()` function that uses `resourceFromSnapshots()` isn't suitable either * because it's experimental. * * @param options - the options * @returns readonly signal */ declare const computedAsync: (options: ComputedAsyncOptions) => Signal; /** * A readonly throttled version of a signal. Emits at most every `interval` milliseconds * @param source - the source signal * @param interval - the interval * @param immediatelyEmitFirstChange - immediately emit the first change * @returns A readonly signal */ declare const throttledSignal: (source: Signal, interval: number, immediatelyEmitFirstChange?: boolean) => Signal; export { SI_MARKDOWN_CONTROL, SiMarkdownCalloutComponent, SiMarkdownComponent, SiMarkdownFragmentComponent, SiMarkdownInlineHtmlComponent, SiMarkdownOptions, SiMarkdownTemplateDirective, computedAsync, makeSiMarkdownOptions, siMarkdownDirective, throttledSignal }; export type { Citation, Citations, ComponentWithOptions, ComputedAsyncOptions, DirectiveNode, ExtendedRootContent, Footnotes, PluginWithOptions, SiMarkdownCitation, SiMarkdownControl, SiMarkdownExtension, SiMarkdownExtensionComponent, SiMarkdownHighlighter, SiMarkdownHighlighterComponent, SiMarkdownMetadata, SiMarkdownRoot, TypeHandler, UnifiedPlugin, UnifiedPluginOptions };