@coolon/angular-ui-powerups 16.1.0-alpha.348 → 16.1.0-alpha.350
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 -6
- package/esm2022/lib/services/markdown/markdown.service.mjs +5 -1
- package/esm2022/lib/services/markdown/pill-plugin.mjs +50 -11
- package/fesm2022/coolon-angular-ui-powerups.mjs +65 -15
- package/fesm2022/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/components/text/markdown/markdown.component.d.ts +9 -1
- package/lib/services/markdown/markdown.service.d.ts +5 -1
- package/lib/services/markdown/pill-plugin.d.ts +17 -1
- package/package.json +2 -2
|
@@ -1,9 +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
|
/**
|
|
8
|
+
* Renders Markdown into the page as HTML, sanitised as Angular sanitises a bound `[innerHTML]`:
|
|
9
|
+
* plain markup and its classes are kept, scripts and event handlers are dropped, and `javascript:`
|
|
10
|
+
* links are made inert. Text a user typed belongs in it only inside a pill, "(({name}))", whose text is escaped
|
|
11
|
+
* (`markdownPillExtension`). The HTML used to go in as Markdown made it, so a name holding "))"
|
|
12
|
+
* could end its pill early and put `<img src=x onerror=…>` into every message that named it.
|
|
13
|
+
*
|
|
7
14
|
* @example
|
|
8
15
|
* <aup-markdown [content]="..."></aup-markdown>
|
|
9
16
|
* <aup-markdown [content$]="stringValueModel$"></aup-markdown>
|
|
@@ -19,10 +26,11 @@ export declare class MarkdownComponent extends DisposableComponent implements On
|
|
|
19
26
|
private platform;
|
|
20
27
|
private readonly element;
|
|
21
28
|
private readonly markdownService;
|
|
29
|
+
private readonly sanitizer;
|
|
22
30
|
accessor content$: ValueModel<string>;
|
|
23
31
|
accessor content: string;
|
|
24
32
|
inline: boolean;
|
|
25
|
-
constructor(platform: object, element: ElementRef<HTMLElement>, markdownService: MarkdownService);
|
|
33
|
+
constructor(platform: object, element: ElementRef<HTMLElement>, markdownService: MarkdownService, sanitizer: DomSanitizer);
|
|
26
34
|
private extractInnerContent;
|
|
27
35
|
private renderContent;
|
|
28
36
|
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownComponent, never>;
|
|
@@ -2,7 +2,11 @@ import * as i0 from "@angular/core";
|
|
|
2
2
|
export declare class MarkdownService {
|
|
3
3
|
render(content: string): string;
|
|
4
4
|
renderInline(content: string): string;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Draws "((text))" as a pill (`markdownPillExtension`). [renderer] is given the pill's text
|
|
7
|
+
* HTML-escaped, and returns the pill's HTML.
|
|
8
|
+
*/
|
|
9
|
+
usePillExtension(renderer?: (escapedText: string) => string): void;
|
|
6
10
|
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownService, never>;
|
|
7
11
|
static ɵprov: i0.ɵɵInjectableDeclaration<MarkdownService>;
|
|
8
12
|
}
|
|
@@ -2,7 +2,23 @@ import { marked } from 'marked';
|
|
|
2
2
|
import RendererThis = marked.RendererThis;
|
|
3
3
|
import TokenizerThis = marked.TokenizerThis;
|
|
4
4
|
import Tokens = marked.Tokens;
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Draws "((text))" in Markdown as a pill, with [renderPill]'s HTML.
|
|
7
|
+
*
|
|
8
|
+
* A pill's text may hold brackets of its own, as a file named "WDK_972P_APP (1).otap" or a group
|
|
9
|
+
* named "Loading dock (theirs)" does: brackets that pair up stay inside the pill, and it ends at the
|
|
10
|
+
* first "))" outside them. So "((Loading dock (theirs)))" is one pill of "Loading dock (theirs)",
|
|
11
|
+
* and "(see ((Night)))" a pill of "Night" inside a parenthetical. A ")" with no "(" to pair with
|
|
12
|
+
* ends the pill early when another ")" follows it: "((Lobby :)))" is a pill of "Lobby :". A "(" with
|
|
13
|
+
* no ")" to pair with leaves the brackets unpaired to the end, and the pill then ends at the first
|
|
14
|
+
* "))": "((Bay (north))" is a pill of "Bay (north". The pill used to end at the first "))" whatever
|
|
15
|
+
* came before, so a name ending in a bracket lost it.
|
|
16
|
+
*
|
|
17
|
+
* [renderPill] is given the text HTML-escaped, as Markdown escapes the text around it. The text is
|
|
18
|
+
* often a name a user typed, and the pill's HTML goes into the page as it is, so a name such as
|
|
19
|
+
* `<img src=x onerror=…>` would otherwise run in every message that names it.
|
|
20
|
+
*/
|
|
21
|
+
export declare const markdownPillExtension: (renderPill: (escapedText: string) => string) => {
|
|
6
22
|
name: string;
|
|
7
23
|
level: string;
|
|
8
24
|
start: (src: string) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coolon/angular-ui-powerups",
|
|
3
|
-
"version": "16.1.0-alpha.
|
|
3
|
+
"version": "16.1.0-alpha.350",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/animations": "^16.2.9",
|
|
6
6
|
"@angular/common": "^16.2.9",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@angular/platform-browser-dynamic": "^16.2.9",
|
|
13
13
|
"@angular/material-moment-adapter": "^16.2.10",
|
|
14
14
|
"@angular/router": "^16.2.9",
|
|
15
|
-
"@coolon/pectin": "^5.0.0-alpha.
|
|
15
|
+
"@coolon/pectin": "^5.0.0-alpha.153",
|
|
16
16
|
"fast-typescript-memoize": "^1.1.1",
|
|
17
17
|
"lodash-es": "^4.17.21",
|
|
18
18
|
"marked": "4.0.10",
|