@mzebley/mark-down-angular 1.2.0 → 1.2.2
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/package.json +3 -2
- package/src/index.ts +0 -4
- package/src/snippet-view.component.ts +0 -61
- package/src/snippet.service.ts +0 -1
- package/src/token.ts +0 -14
- package/tsconfig.json +0 -16
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mzebley/mark-down-angular",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "mark↓ Angular Adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"files": ["dist"],
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"build": "tsup src/index.ts --dts --format esm,cjs"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@mzebley/mark-down": "
|
|
24
|
+
"@mzebley/mark-down": "^1.2.2",
|
|
24
25
|
"dompurify": "^3.0.9"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
package/src/index.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { CommonModule } from "@angular/common";
|
|
2
|
-
import {
|
|
3
|
-
ChangeDetectionStrategy,
|
|
4
|
-
Component,
|
|
5
|
-
EventEmitter,
|
|
6
|
-
Input,
|
|
7
|
-
OnChanges,
|
|
8
|
-
Output,
|
|
9
|
-
inject
|
|
10
|
-
} from "@angular/core";
|
|
11
|
-
import { DomSanitizer, SafeHtml } from "@angular/platform-browser";
|
|
12
|
-
import { BehaviorSubject, Observable, of } from "rxjs";
|
|
13
|
-
import { catchError, map, shareReplay, switchMap, tap } from "rxjs/operators";
|
|
14
|
-
import type { Snippet } from "@mzebley/mark-down";
|
|
15
|
-
import { SnippetService } from "./snippet.service";
|
|
16
|
-
import DOMPurify from "dompurify";
|
|
17
|
-
|
|
18
|
-
@Component({
|
|
19
|
-
selector: "snippet-view",
|
|
20
|
-
standalone: true,
|
|
21
|
-
imports: [CommonModule],
|
|
22
|
-
template: `
|
|
23
|
-
<ng-container *ngIf="content$ | async as html; else loading">
|
|
24
|
-
<div class="mark-down-snippet" [innerHTML]="html"></div>
|
|
25
|
-
</ng-container>
|
|
26
|
-
<ng-template #loading>
|
|
27
|
-
<div class="mark-down-snippet--loading">Loading snippet…</div>
|
|
28
|
-
</ng-template>
|
|
29
|
-
`,
|
|
30
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
31
|
-
})
|
|
32
|
-
export class SnippetViewComponent implements OnChanges {
|
|
33
|
-
private readonly slug$ = new BehaviorSubject<string | null>(null);
|
|
34
|
-
private readonly sanitizer = inject(DomSanitizer);
|
|
35
|
-
private readonly snippets = inject(SnippetService);
|
|
36
|
-
|
|
37
|
-
@Input() slug?: string;
|
|
38
|
-
@Output() readonly loaded = new EventEmitter<Snippet | undefined>();
|
|
39
|
-
|
|
40
|
-
private readonly snippet$: Observable<Snippet | null> = this.slug$.pipe(
|
|
41
|
-
switchMap((slug) =>
|
|
42
|
-
slug ? this.snippets.get(slug).pipe(catchError(() => of(null))) : of(null)
|
|
43
|
-
),
|
|
44
|
-
tap((snippet) => this.loaded.emit(snippet ?? undefined)),
|
|
45
|
-
shareReplay({ bufferSize: 1, refCount: true })
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
readonly content$: Observable<SafeHtml | null> = this.snippet$.pipe(
|
|
49
|
-
map((snippet) => {
|
|
50
|
-
if (!snippet) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const sanitized = DOMPurify.sanitize(snippet.html);
|
|
54
|
-
return this.sanitizer.bypassSecurityTrustHtml(sanitized);
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
ngOnChanges(): void {
|
|
59
|
-
this.slug$.next(this.slug ?? null);
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/snippet.service.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MarkdownSnippetService as SnippetService } from "@mzebley/mark-down/angular";
|
package/src/token.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Provider } from "@angular/core";
|
|
2
|
-
import {
|
|
3
|
-
SNIPPET_CLIENT,
|
|
4
|
-
SNIPPET_CLIENT_OPTIONS,
|
|
5
|
-
provideSnippetClient,
|
|
6
|
-
type SnippetClientOptions
|
|
7
|
-
} from "@mzebley/mark-down/angular";
|
|
8
|
-
|
|
9
|
-
export const MARK_DOWN_CLIENT = SNIPPET_CLIENT;
|
|
10
|
-
export const MARK_DOWN_OPTIONS = SNIPPET_CLIENT_OPTIONS;
|
|
11
|
-
|
|
12
|
-
export function provideMarkDown(options: SnippetClientOptions): Provider[] {
|
|
13
|
-
return provideSnippetClient(options);
|
|
14
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"experimentalDecorators": true,
|
|
6
|
-
"emitDecoratorMetadata": true,
|
|
7
|
-
"baseUrl": ".",
|
|
8
|
-
"paths": {
|
|
9
|
-
"@mzebley/mark-down": ["../core/src/index.ts"],
|
|
10
|
-
"@mzebley/mark-down/angular": ["../core/src/angular/index.ts"],
|
|
11
|
-
"@mzebley/mark-down/browser": ["../core/src/browser.ts"],
|
|
12
|
-
"@mzebley/mark-down/slug": ["../core/src/slug.ts"]
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
"include": ["src/**/*"]
|
|
16
|
-
}
|