@mzebley/mark-down-angular 1.2.2 → 1.2.3
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/README.md +29 -24
- package/dist/index.cjs +3 -0
- package/dist/index.js +3 -0
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# mark↓ Angular Adapter
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
_(published as `@mzebley/mark-down-angular`)_
|
|
3
4
|
|
|
4
5
|
Angular bindings for the [mark↓ core runtime](../core/README.md). This package wraps `SnippetClient` with Angular-friendly providers, services, and components so you can render Markdown snippets safely inside your application. For background on the monorepo, see the [root README](../../README.md).
|
|
5
6
|
|
|
@@ -29,14 +30,14 @@ You will also need a manifest generated by the [CLI](../cli/README.md).
|
|
|
29
30
|
Provide a shared `SnippetClient` from your root bootstrap call or feature module:
|
|
30
31
|
|
|
31
32
|
```ts
|
|
32
|
-
import { bootstrapApplication } from
|
|
33
|
-
import { provideSnippetClient } from
|
|
33
|
+
import { bootstrapApplication } from "@angular/platform-browser";
|
|
34
|
+
import { provideSnippetClient } from "@mzebley/mark-down/angular";
|
|
34
35
|
|
|
35
36
|
bootstrapApplication(AppComponent, {
|
|
36
37
|
providers: [
|
|
37
38
|
...provideSnippetClient({
|
|
38
|
-
manifest:
|
|
39
|
-
base:
|
|
39
|
+
manifest: "/assets/content/snippets/manifest.json",
|
|
40
|
+
base: "/assets/content/snippets",
|
|
40
41
|
}),
|
|
41
42
|
],
|
|
42
43
|
});
|
|
@@ -46,12 +47,12 @@ bootstrapApplication(AppComponent, {
|
|
|
46
47
|
|
|
47
48
|
### Angular compatibility
|
|
48
49
|
|
|
49
|
-
| Angular version | Status
|
|
50
|
-
|
|
|
51
|
-
| 17.x
|
|
52
|
-
| 18.x
|
|
53
|
-
| 19.x
|
|
54
|
-
| 20.x
|
|
50
|
+
| Angular version | Status |
|
|
51
|
+
| --------------- | ------------ |
|
|
52
|
+
| 17.x | ✅ Supported |
|
|
53
|
+
| 18.x | ✅ Supported |
|
|
54
|
+
| 19.x | ✅ Supported |
|
|
55
|
+
| 20.x | ✅ Supported |
|
|
55
56
|
|
|
56
57
|
The package declares peer dependency ranges `>=17 <21` so projects running any currently supported Angular major release can install without `--legacy-peer-deps`.
|
|
57
58
|
|
|
@@ -60,11 +61,11 @@ The package declares peer dependency ranges `>=17 <21` so projects running any c
|
|
|
60
61
|
Inject `MarkdownSnippetService` into components or services to access Observables for snippets:
|
|
61
62
|
|
|
62
63
|
```ts
|
|
63
|
-
import { Component, inject } from
|
|
64
|
-
import { MarkdownSnippetService } from
|
|
64
|
+
import { Component, inject } from "@angular/core";
|
|
65
|
+
import { MarkdownSnippetService } from "@mzebley/mark-down/angular";
|
|
65
66
|
|
|
66
67
|
@Component({
|
|
67
|
-
selector:
|
|
68
|
+
selector: "docs-hero",
|
|
68
69
|
template: `
|
|
69
70
|
<ng-container *ngIf="hero$ | async as hero">
|
|
70
71
|
<h1>{{ hero.title }}</h1>
|
|
@@ -74,7 +75,7 @@ import { MarkdownSnippetService } from '@mzebley/mark-down/angular';
|
|
|
74
75
|
})
|
|
75
76
|
export class DocsHeroComponent {
|
|
76
77
|
private readonly snippets = inject(MarkdownSnippetService);
|
|
77
|
-
readonly hero$ = this.snippets.get(
|
|
78
|
+
readonly hero$ = this.snippets.get("getting-started-welcome");
|
|
78
79
|
}
|
|
79
80
|
```
|
|
80
81
|
|
|
@@ -85,7 +86,10 @@ The service mirrors the core client APIs (`get`, `listAll`, `listByType`, `listB
|
|
|
85
86
|
Render snippets declaratively with the bundled standalone component:
|
|
86
87
|
|
|
87
88
|
```html
|
|
88
|
-
<snippet-view
|
|
89
|
+
<snippet-view
|
|
90
|
+
[slug]="'components-button'"
|
|
91
|
+
(loaded)="onSnippetLoaded($event)"
|
|
92
|
+
></snippet-view>
|
|
89
93
|
```
|
|
90
94
|
|
|
91
95
|
Features:
|
|
@@ -100,16 +104,17 @@ Features:
|
|
|
100
104
|
When running in Angular Universal, supply a server-compatible fetch implementation:
|
|
101
105
|
|
|
102
106
|
```ts
|
|
103
|
-
import fetch from
|
|
107
|
+
import fetch from "node-fetch";
|
|
104
108
|
|
|
105
109
|
provideSnippetClient({
|
|
106
|
-
manifest: () => import(
|
|
107
|
-
fetch: (url) =>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
manifest: () => import("../snippets-index.json"),
|
|
111
|
+
fetch: (url) =>
|
|
112
|
+
fetch(url).then((response) => {
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(`Request failed with status ${response.status}`);
|
|
115
|
+
}
|
|
116
|
+
return response;
|
|
117
|
+
}),
|
|
113
118
|
});
|
|
114
119
|
```
|
|
115
120
|
|
package/dist/index.cjs
CHANGED
|
@@ -84,6 +84,9 @@ var SnippetViewComponent = class {
|
|
|
84
84
|
if (!snippet) {
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
|
+
if (typeof window === "undefined") {
|
|
88
|
+
return this.sanitizer.bypassSecurityTrustHtml(snippet.html);
|
|
89
|
+
}
|
|
87
90
|
const sanitized = import_dompurify.default.sanitize(snippet.html);
|
|
88
91
|
return this.sanitizer.bypassSecurityTrustHtml(sanitized);
|
|
89
92
|
})
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,9 @@ var SnippetViewComponent = class {
|
|
|
59
59
|
if (!snippet) {
|
|
60
60
|
return null;
|
|
61
61
|
}
|
|
62
|
+
if (typeof window === "undefined") {
|
|
63
|
+
return this.sanitizer.bypassSecurityTrustHtml(snippet.html);
|
|
64
|
+
}
|
|
62
65
|
const sanitized = DOMPurify.sanitize(snippet.html);
|
|
63
66
|
return this.sanitizer.bypassSecurityTrustHtml(sanitized);
|
|
64
67
|
})
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mzebley/mark-down-angular",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
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": [
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
10
12
|
"exports": {
|
|
11
13
|
".": {
|
|
12
14
|
"types": "./dist/index.d.ts",
|
|
@@ -24,6 +26,9 @@
|
|
|
24
26
|
"@mzebley/mark-down": "^1.2.2",
|
|
25
27
|
"dompurify": "^3.0.9"
|
|
26
28
|
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@angular/platform-browser": ">=17 <21"
|
|
31
|
+
},
|
|
27
32
|
"peerDependencies": {
|
|
28
33
|
"@angular/common": ">=17 <21",
|
|
29
34
|
"@angular/core": ">=17 <21",
|