SiMarkdownComponent documentation¶
import { SiMarkdownComponent } from '@siemens/element-ng/markdown'; Component to display markdown text
This component is built using concepts from 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.
Input Properties¶
| Name | Type | Default | Description |
|---|---|---|---|
| citations ¶ | SiMarkdownCitation[] | undefined | Citation metadata used to create citations. | |
| debug ¶ | boolean | false | Debug mode. When true, unknown node types will be displayed along with the node as JSON. Implements SiMarkdownControl |
| markdown ¶ | string | '' | The markdown text to transform and display |
| options ¶ | SiMarkdownOptions | undefined | Options to control rendering. Can be shared across multiple instances. |
Output Properties¶
| Name | Type | Description |
|---|---|---|
| extensionEvent ¶ | { name: string; data: any; } | Emitted by extension components. Implements SiMarkdownControl |
Attributes and Methods¶
| Name | Type | Default | Description |
|---|---|---|---|
| (readonly)meta ¶ | Signal<SiMarkdownMetadata> | computed<SiMarkdownMetadata>(() => ({ citations: this.citations() })) | Gives access to metadata in extension components Implements SiMarkdownControl |
Types Documentation¶
Citation metadata associated with a markdown response. Optional source description. description ? : Identifier referenced by bracket notation, such as identifier ? : Source name displayed to the user. name : Zero-based, end-exclusive source range of the citation reference in the markdown source. Optional source quote. Takes precedence over description. quote ? : Source URL. url : import type { SiMarkdownCitation } from '@siemens/element-ng/markdown';
string Inherited from SourceReference ¶ [source-1].string ¶ string Inherited from SourceReference ¶ string Inherited from SourceReference ¶ string Inherited from SourceReference ¶
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: getCodeTypeHandlers Returns: All code type handlers getHighlighter Returns: The highlighter getTypeHandlers Returns: All type handlers installExtension Installs a extension which can contain plugins, type handlers Returns: self for chaining • The extension definition installUnifiedPlugin Installs a plugin into the Returns: self for chaining makeProcessor Creates the Returns: registerDirective Registers a component used to render a named Markdown directive. Returns: self for chaining directives : setCodeHighlighter Sets the code highlighter • The highlighterimport { SiMarkdownOptions } from '@siemens/element-ng/markdown';import { siMarkdownMathKaTeX } from '@siemens/element-ng/markdown/extensions/math';
import remarkGemoji from 'remark-gemoji';
protected markdownOptions = new SiMarkdownOptions()
.installExtension(siMarkdownMathKaTeX())
.installUnifiedPlugin(remarkGemoji);
<si-markdown [markdown]="markdownText()" [options]="markdownOptions" />
() => SiMarkdownOptions ¶
() => Map<string, TypeHandler> ¶ () => SiMarkdownHighlighter | undefined ¶ () => TypeHandler[] ¶ (extension: SiMarkdownExtension) => SiMarkdownOptions ¶
(plugin: UnifiedPlugin, options?: any) => SiMarkdownOptions ¶ unified chain(meta: SiMarkdownMetadata) => Processor<Root, Root, SiMarkdownRoot, undefined, undefined> ¶ unified processor with all plugins and optionsunified processor(directives: TypeHandler | TypeHandler[]) => SiMarkdownOptions ¶
TypeHandler | TypeHandler[] ¶ (highlighter?: SiMarkdownHighlighter) => SiMarkdownOptions ¶
Interface of si-markdown exposed to children.import type { SiMarkdownControl } from '@siemens/element-ng/markdown';
Options passed to makeProcessor() citations ? : import type { SiMarkdownMetadata } from '@siemens/element-ng/markdown';
SiMarkdownCitation[] ¶
import type { UnifiedPlugin } from '@siemens/element-ng/markdown';
Type handler for a named type. This can be an AST node type, a code type, a directive name The component used to render the node component : Options passed to the component options ? : Type nameimport type { TypeHandler } from '@siemens/element-ng/markdown';
Type<SiMarkdownExtensionComponent> Inherited from ComponentWithOptions<SiMarkdownExtensionComponent> ¶ any Inherited from ComponentWithOptions<SiMarkdownExtensionComponent> ¶
An extension to the si-markdown component Special code type handlers to install codeTypes ? : Directives directives ? : plugins ? : Type handlers to install types ? : import type { SiMarkdownExtension } from '@siemens/element-ng/markdown';
TypeHandler[] ¶ TypeHandler[] ¶ unified plugins to installPluginWithOptions[] ¶ TypeHandler[] ¶
import type { SiMarkdownHighlighter } from '@siemens/element-ng/markdown';
Extended root with references SiMarkdownRoot
Omit<Root, 'children'> & { children: ExtendedRootContent[]; references?: { footnoteDefinitions?: Map<string, FootnoteDefinition>; definitions?: Map<string, Definition>; }; } ¶ import type { SiMarkdownRoot } from '@siemens/element-ng/markdown';
Definition of a single sourceimport type { SourceReference } from '@siemens/element-ng/source-chip';
Interface an extension component must implement Node to be rendered node : Options passed to the component options : The parent node parent : import type { SiMarkdownExtensionComponent } from '@siemens/element-ng/markdown';
InputSignal<Node> ¶ InputSignal<any> ¶ InputSignal<Parent> ¶
Interface a code highlighter component must implement The code to be highlighted code : The language Options passed to the component options : Function the highlighter can call to updated the displayed language updateLanguage : import type { SiMarkdownHighlighterComponent } from '@siemens/element-ng/markdown';
InputSignal<string> ¶ InputSignal<any> ¶ InputSignal<(lang?: string) => void> ¶
import type { ExtendedRootContent } from '@siemens/element-ng/markdown';
Extra node for collecting all footnotes List of children. children : Info from the ecosystem. Position of a node in a source document. Nodes that are generated (not in the original source document) must not have a position. Node type.import type { Footnotes } from '@siemens/element-ng/markdown';
FootnoteDefinition[] Inherited from Parent ¶
Container for one or more adjacent citation nodes. Info from the ecosystem. Position of a node in a source document. Nodes that are generated (not in the original source document) must not have a position. Node type.import type { Citations } from '@siemens/element-ng/markdown';
AST node created by Attributes declared on the directive. attributes : List of children. children : Info from the ecosystem. The directive name without its leading colons. Position of a node in a source document. Nodes that are generated (not in the original source document) must not have a position. Node type. type : import type { DirectiveNode } from '@siemens/element-ng/markdown';remark-directive.
Record<string, string | undefined> ¶ RootContent[] Inherited from Parent ¶ "containerDirective" | "leafDirective" | "textDirective" Inherited from Node ¶
Inline node that references an item in the source citation array. Info from the ecosystem. Position of a node in a source document. Nodes that are generated (not in the original source document) must not have a position. Text replaced by a position-based citation. Node type.import type { Citation } from '@siemens/element-ng/markdown';
Except where otherwise noted, content on this site is licensed under MIT License.