@liquid-js/lyr-extras 22.0.0-alpha.4 → 22.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ import * as i0 from "@angular/core";
5
+ import { ElementRef, TemplateRef } from "@angular/core";
6
+ import { FootnoteDefinition, Node, Parent, Root } from "mdast";
7
+ import { RemarkTemplateDirective } from "ngx-remark";
8
+ /** A unified processor that parses markdown, with its plugins, e.g. `remark().use(remarkGfm)`. */
9
+ export interface NbMarkdownProcessor {
10
+ parse(markdown: string): Node;
11
+ runSync(tree: Node): Node;
12
+ }
13
+ /**
14
+ * What `nb-markdown-renderer` and `nb-markdown-viewer` share: the markdown's syntax tree and the templates that render
15
+ * it. They differ in the processor they parse with and in their styles. Each provides its own `RemarkTemplatesService`,
16
+ * so templates put in it, and the templates' own content, find its templates.
17
+ */
18
+ export declare abstract class NbMarkdownRendering {
19
+ /** The markdown to show. */
20
+ readonly markdown: import("@angular/core").InputSignal<string>;
21
+ /**
22
+ * Gives each block of the document, e.g. a paragraph or a list, the direction of its own text (`dir="auto"`), for
23
+ * text in more than one direction; `false` by default.
24
+ */
25
+ readonly autoDirection: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
26
+ /** The markdown's syntax tree, as its templates render it. */
27
+ readonly tree: import("@angular/core").Signal<Root>;
28
+ protected readonly id: string;
29
+ protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-extras/markdown-renderer").NbMarkdownViewerTexts>;
30
+ protected readonly htmlElements: Set<string>;
31
+ protected readonly blockParents: Set<string>;
32
+ protected readonly element: ElementRef<HTMLElement>;
33
+ /** Whether the app loads highlight.js for code, the same on the server and in the browser. */
34
+ protected readonly highlighting: boolean;
35
+ protected readonly defaultTemplates: import("@angular/core").Signal<readonly RemarkTemplateDirective[]>;
36
+ protected readonly customTemplates: import("@angular/core").Signal<readonly RemarkTemplateDirective[]>;
37
+ protected readonly fallback: import("@angular/core").Signal<TemplateRef<unknown>>;
38
+ constructor();
39
+ /** The processor the markdown is parsed with. */
40
+ protected abstract parser(): NbMarkdownProcessor;
41
+ /** `auto` for a block of the document, with `autoDirection`, which a block in a quote or a list shares. */
42
+ protected direction(parent: Node): "auto" | null;
43
+ protected footnoteId(identifier: string, reference?: boolean): string;
44
+ /** Moves to a footnote in the page, whose address the document's base would otherwise change. */
45
+ protected showFootnote(event: Event, id: string): void;
46
+ static ɵfac: i0.ɵɵFactoryDeclaration<NbMarkdownRendering, never>;
47
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NbMarkdownRendering, never, never, {
48
+ "markdown": {
49
+ "alias": "markdown";
50
+ "required": false;
51
+ "isSignal": true;
52
+ };
53
+ "autoDirection": {
54
+ "alias": "autoDirection";
55
+ "required": false;
56
+ "isSignal": true;
57
+ };
58
+ }, {}, ["customTemplates"], never, true, never>;
59
+ }
60
+ /**
61
+ * Renders markdown with a processor of the app's, and no styles of its own, for an app that styles its content itself:
62
+ *
63
+ * ```html
64
+ * <nb-markdown-renderer [markdown]="text" [processor]="processor" />
65
+ * ```
66
+ *
67
+ * @stacked-example(Renderer, markdown/markdown-renderer.component)
68
+ *
69
+ * It renders as `nb-markdown-viewer` does, with the same templates, which templates of the app's replace the same way,
70
+ * and the same `autoDirection`, footnotes and code highlighting. Unlike the viewer, it doesn't load `remark` or
71
+ * `remark-smartypants` for a default processor, nor the editor's content styles: the processor is the app's, and the
72
+ * content is styled by the app, in the element with class `uf-contents`.
73
+ *
74
+ * ```sh
75
+ * npm install ngx-remark nxt-highlightjs highlight.js
76
+ * ```
77
+ *
78
+ * Import `NbMarkdownRendererComponent` from `@liquid-js/lyr-extras/markdown-renderer`, and give it a processor that
79
+ * parses markdown, e.g. with `unified` and `remark-parse`, which `ngx-remark` uses too:
80
+ *
81
+ * ```ts
82
+ * import { unified } from 'unified';
83
+ * import remarkParse from 'remark-parse';
84
+ * import remarkGfm from 'remark-gfm';
85
+ *
86
+ * readonly processor = unified().use(remarkParse).use(remarkGfm).freeze();
87
+ * ```
88
+ */
89
+ export declare class NbMarkdownRendererComponent extends NbMarkdownRendering {
90
+ /** Parses the markdown, with the plugins the app uses. */
91
+ readonly processor: import("@angular/core").InputSignal<NbMarkdownProcessor>;
92
+ protected parser(): NbMarkdownProcessor;
93
+ static ɵfac: i0.ɵɵFactoryDeclaration<NbMarkdownRendererComponent, never>;
94
+ static ɵcmp: i0.ɵɵComponentDeclaration<NbMarkdownRendererComponent, "nb-markdown-renderer", never, {
95
+ "processor": {
96
+ "alias": "processor";
97
+ "required": true;
98
+ "isSignal": true;
99
+ };
100
+ }, {}, never, never, true, never>;
101
+ }
102
+ /** An inline HTML element of the markdown, e.g. `<kbd>Ctrl</kbd>`, with the markdown between its tags. */
103
+ interface NbMarkdownHtmlElement extends Parent {
104
+ type: 'nbHtmlElement';
105
+ tagName: string;
106
+ }
107
+ /** A link from a footnote back to where the text refers to it, at the end of the footnote. */
108
+ interface NbMarkdownFootnoteBack extends Node {
109
+ type: 'nbFootnoteBack';
110
+ identifier: string;
111
+ }
112
+ /** The footnotes, at the end of the document. */
113
+ interface NbMarkdownFootnotes extends Parent {
114
+ type: 'nbFootnotes';
115
+ children: FootnoteDefinition[];
116
+ }
117
+ declare module 'mdast' {
118
+ interface PhrasingContentMap {
119
+ nbHtmlElement: NbMarkdownHtmlElement;
120
+ nbFootnoteBack: NbMarkdownFootnoteBack;
121
+ }
122
+ interface RootContentMap {
123
+ nbHtmlElement: NbMarkdownHtmlElement;
124
+ nbFootnoteBack: NbMarkdownFootnoteBack;
125
+ nbFootnotes: NbMarkdownFootnotes;
126
+ }
127
+ }
128
+ /**
129
+ * The texts of the markdown viewer. `provideNbTexts({ markdownViewer: { ... } })` changes them, and they're translated
130
+ * with Angular's i18n, as `$localize` messages with ids like `@@nb.markdownViewer.footnotes`.
131
+ */
132
+ interface NbMarkdownViewerTexts {
133
+ /** Names the footnotes at the end of the text. */
134
+ footnotes: string;
135
+ /** Names the link at the end of a footnote back to where the text refers to it. */
136
+ backToText: string;
137
+ }
138
+ declare module '@liquid-js/lyr-core' {
139
+ interface NbTexts {
140
+ markdownViewer: NbMarkdownViewerTexts;
141
+ }
142
+ }
143
+ export type { NbMarkdownFootnoteBack, NbMarkdownFootnotes, NbMarkdownHtmlElement, NbMarkdownViewerTexts };
@@ -1,15 +1,8 @@
1
1
  /**
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
+ import { NbMarkdownFootnoteBack, NbMarkdownFootnotes, NbMarkdownHtmlElement, NbMarkdownProcessor, NbMarkdownProcessor as NbMarkdownProcessor$1, NbMarkdownRendering, NbMarkdownViewerTexts } from "@liquid-js/lyr-extras/markdown-renderer";
4
5
  import * as i0 from "@angular/core";
5
- import { ElementRef, TemplateRef } from "@angular/core";
6
- import { FootnoteDefinition, Node, Parent, Root } from "mdast";
7
- import { RemarkTemplateDirective } from "ngx-remark";
8
- /** A unified processor that parses markdown, with its plugins, e.g. `remark().use(remarkGfm)`. */
9
- export interface NbMarkdownProcessor {
10
- parse(markdown: string): Node;
11
- runSync(tree: Node): Node;
12
- }
13
6
  /**
14
7
  * Shows markdown, in the theme's text styles:
15
8
  *
@@ -63,6 +56,8 @@ export interface NbMarkdownProcessor {
63
56
  * they need `dir="auto"` themselves.
64
57
  *
65
58
  * `processor` replaces the parser, e.g. to add remark plugins, whose new types of nodes need templates of their own.
59
+ * An app with a processor and content styles of its own can use `nb-markdown-renderer` instead, which renders the same
60
+ * way without loading the default processor's packages or these styles.
66
61
  *
67
62
  * ### Code highlighting
68
63
  *
@@ -83,92 +78,17 @@ export interface NbMarkdownProcessor {
83
78
  * Code in other languages, or without one, shows as plain text. The server waits for highlight.js, so a prerendered
84
79
  * page has highlighted code. `nb-markdown-editor` highlights its preview and WYSIWYG code the same way.
85
80
  */
86
- export declare class NbMarkdownViewerComponent {
87
- /** The markdown to show. */
88
- readonly markdown: import("@angular/core").InputSignal<string>;
81
+ export declare class NbMarkdownViewerComponent extends NbMarkdownRendering {
89
82
  /** Parses the markdown, `remark().use(remarkGfm).use(remarkSmartypants, { dashes: 'oldschool' })` by default. */
90
- readonly processor: import("@angular/core").InputSignal<NbMarkdownProcessor | undefined>;
91
- /**
92
- * Gives each block of the document, e.g. a paragraph or a list, the direction of its own text (`dir="auto"`), for
93
- * text in more than one direction; `false` by default.
94
- */
95
- readonly autoDirection: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
96
- /** The markdown's syntax tree, as its templates render it. */
97
- readonly tree: import("@angular/core").Signal<Root>;
98
- protected readonly id: string;
99
- protected readonly texts: import("@angular/core").Signal<import("@liquid-js/lyr-extras/markdown-viewer").NbMarkdownViewerTexts>;
100
- protected readonly htmlElements: Set<string>;
101
- protected readonly blockParents: Set<string>;
102
- protected readonly element: ElementRef<HTMLElement>;
103
- /** Whether the app loads highlight.js for code, the same on the server and in the browser. */
104
- protected readonly highlighting: boolean;
105
- protected readonly defaultTemplates: import("@angular/core").Signal<readonly RemarkTemplateDirective[]>;
106
- protected readonly customTemplates: import("@angular/core").Signal<readonly RemarkTemplateDirective[]>;
107
- protected readonly fallback: import("@angular/core").Signal<TemplateRef<unknown>>;
108
- constructor();
109
- /** `auto` for a block of the document, with `autoDirection`, which a block in a quote or a list shares. */
110
- protected direction(parent: Node): "auto" | null;
111
- protected footnoteId(identifier: string, reference?: boolean): string;
112
- /** Moves to a footnote in the page, whose address the document's base would otherwise change. */
113
- protected showFootnote(event: Event, id: string): void;
83
+ readonly processor: import("@angular/core").InputSignal<NbMarkdownProcessor$1 | undefined>;
84
+ protected parser(): NbMarkdownProcessor$1;
114
85
  static ɵfac: i0.ɵɵFactoryDeclaration<NbMarkdownViewerComponent, never>;
115
86
  static ɵcmp: i0.ɵɵComponentDeclaration<NbMarkdownViewerComponent, "nb-markdown-viewer", never, {
116
- "markdown": {
117
- "alias": "markdown";
118
- "required": false;
119
- "isSignal": true;
120
- };
121
87
  "processor": {
122
88
  "alias": "processor";
123
89
  "required": false;
124
90
  "isSignal": true;
125
91
  };
126
- "autoDirection": {
127
- "alias": "autoDirection";
128
- "required": false;
129
- "isSignal": true;
130
- };
131
- }, {}, ["customTemplates"], never, true, never>;
132
- }
133
- /** An inline HTML element of the markdown, e.g. `<kbd>Ctrl</kbd>`, with the markdown between its tags. */
134
- interface NbMarkdownHtmlElement extends Parent {
135
- type: 'nbHtmlElement';
136
- tagName: string;
137
- }
138
- /** A link from a footnote back to where the text refers to it, at the end of the footnote. */
139
- interface NbMarkdownFootnoteBack extends Node {
140
- type: 'nbFootnoteBack';
141
- identifier: string;
142
- }
143
- /** The footnotes, at the end of the document. */
144
- interface NbMarkdownFootnotes extends Parent {
145
- type: 'nbFootnotes';
146
- children: FootnoteDefinition[];
147
- }
148
- declare module 'mdast' {
149
- interface PhrasingContentMap {
150
- nbHtmlElement: NbMarkdownHtmlElement;
151
- nbFootnoteBack: NbMarkdownFootnoteBack;
152
- }
153
- interface RootContentMap {
154
- nbHtmlElement: NbMarkdownHtmlElement;
155
- nbFootnoteBack: NbMarkdownFootnoteBack;
156
- nbFootnotes: NbMarkdownFootnotes;
157
- }
158
- }
159
- /**
160
- * The texts of the markdown viewer. `provideNbTexts({ markdownViewer: { ... } })` changes them, and they're translated
161
- * with Angular's i18n, as `$localize` messages with ids like `@@nb.markdownViewer.footnotes`.
162
- */
163
- interface NbMarkdownViewerTexts {
164
- /** Names the footnotes at the end of the text. */
165
- footnotes: string;
166
- /** Names the link at the end of a footnote back to where the text refers to it. */
167
- backToText: string;
168
- }
169
- declare module '@liquid-js/lyr-core' {
170
- interface NbTexts {
171
- markdownViewer: NbMarkdownViewerTexts;
172
- }
92
+ }, {}, never, never, true, never>;
173
93
  }
174
- export type { NbMarkdownFootnoteBack, NbMarkdownFootnotes, NbMarkdownHtmlElement, NbMarkdownViewerTexts };
94
+ export type { NbMarkdownFootnoteBack, NbMarkdownFootnotes, NbMarkdownHtmlElement, NbMarkdownProcessor, NbMarkdownViewerTexts };