@coolon/angular-ui-powerups 16.1.0-alpha.349 → 16.1.0-alpha.351
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.
- package/esm2022/lib/components/text/markdown/markdown.component.mjs +16 -9
- package/esm2022/lib/services/markdown/markdown.service.mjs +19 -3
- package/fesm2022/coolon-angular-ui-powerups.mjs +30 -10
- package/fesm2022/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/components/text/markdown/markdown.component.d.ts +9 -4
- package/lib/services/markdown/markdown.service.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ElementRef, OnInit } from '@angular/core';
|
|
2
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
2
3
|
import { ValueModel } from '@coolon/pectin';
|
|
3
4
|
import { MarkdownService } from '../../../services/markdown/markdown.service';
|
|
4
5
|
import { DisposableComponent } from '../../disposable-component';
|
|
5
6
|
import * as i0 from "@angular/core";
|
|
6
7
|
/**
|
|
7
|
-
* Renders Markdown into the page as HTML
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Renders Markdown into the page as HTML. HTML written into the Markdown is shown as the text it
|
|
9
|
+
* is, apart from `<br>` (`MarkdownService`), and the result is sanitised as Angular sanitises a
|
|
10
|
+
* bound `[innerHTML]`: plain markup and its classes are kept, scripts and event handlers are
|
|
11
|
+
* dropped, and `javascript:` links are made inert. Text a user typed belongs in it only inside a pill, "(({name}))", whose text is escaped
|
|
12
|
+
* (`markdownPillExtension`). The HTML used to go in as Markdown made it, so a name holding "))"
|
|
13
|
+
* could end its pill early and put `<img src=x onerror=…>` into every message that named it.
|
|
10
14
|
*
|
|
11
15
|
* @example
|
|
12
16
|
* <aup-markdown [content]="..."></aup-markdown>
|
|
@@ -23,10 +27,11 @@ export declare class MarkdownComponent extends DisposableComponent implements On
|
|
|
23
27
|
private platform;
|
|
24
28
|
private readonly element;
|
|
25
29
|
private readonly markdownService;
|
|
30
|
+
private readonly sanitizer;
|
|
26
31
|
accessor content$: ValueModel<string>;
|
|
27
32
|
accessor content: string;
|
|
28
33
|
inline: boolean;
|
|
29
|
-
constructor(platform: object, element: ElementRef<HTMLElement>, markdownService: MarkdownService);
|
|
34
|
+
constructor(platform: object, element: ElementRef<HTMLElement>, markdownService: MarkdownService, sanitizer: DomSanitizer);
|
|
30
35
|
private extractInnerContent;
|
|
31
36
|
private renderContent;
|
|
32
37
|
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownComponent, never>;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* Renders Markdown as HTML. HTML written into the Markdown is shown as the text it is, apart from
|
|
4
|
+
* `<br>`, which copy uses to break a line: a name holding "))" ends its pill early, and markup
|
|
5
|
+
* after it, `<img src=x …>`, then reads as typed rather than drawing a broken image.
|
|
6
|
+
* `aup-markdown` sanitises the result as well.
|
|
7
|
+
*/
|
|
2
8
|
export declare class MarkdownService {
|
|
9
|
+
private readonly renderer;
|
|
3
10
|
render(content: string): string;
|
|
4
11
|
renderInline(content: string): string;
|
|
5
12
|
/**
|
|
@@ -7,6 +14,7 @@ export declare class MarkdownService {
|
|
|
7
14
|
* HTML-escaped, and returns the pill's HTML.
|
|
8
15
|
*/
|
|
9
16
|
usePillExtension(renderer?: (escapedText: string) => string): void;
|
|
17
|
+
private static htmlAsText;
|
|
10
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownService, never>;
|
|
11
19
|
static ɵprov: i0.ɵɵInjectableDeclaration<MarkdownService>;
|
|
12
20
|
}
|