@foliokit/cms-markdown 0.0.0 → 1.0.0
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.
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { Component } from '@angular/core';
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
|
2
|
+
import { MarkdownComponent as NgxMarkdownComponent } from 'ngx-markdown';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
|
-
export class
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export class MarkdownComponent {
|
|
5
|
+
content = input.required(...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
6
|
+
embeddedMedia = input({}, ...(ngDevMode ? [{ debugName: "embeddedMedia" }] : /* istanbul ignore next */ []));
|
|
7
|
+
processedContent = computed(() => {
|
|
8
|
+
const raw = this.content();
|
|
9
|
+
const media = this.embeddedMedia();
|
|
10
|
+
if (!media || Object.keys(media).length === 0)
|
|
11
|
+
return raw;
|
|
12
|
+
// Replace  where token is a key in embeddedMedia with the resolved URL
|
|
13
|
+
return raw.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, (_match, alt, token) => {
|
|
14
|
+
const entry = media[token];
|
|
15
|
+
if (!entry)
|
|
16
|
+
return _match;
|
|
17
|
+
return ``;
|
|
18
|
+
});
|
|
19
|
+
}, ...(ngDevMode ? [{ debugName: "processedContent" }] : /* istanbul ignore next */ []));
|
|
20
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: MarkdownComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
21
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: MarkdownComponent, isStandalone: true, selector: "folio-markdown", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: true, transformFunction: null }, embeddedMedia: { classPropertyName: "embeddedMedia", publicName: "embeddedMedia", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `<markdown class="prose prose-neutral dark:prose-invert max-w-none" [data]="processedContent()"></markdown>`, isInline: true, styles: [":host{display:block}:host ::ng-deep img{max-width:100%;height:auto;border-radius:.5rem}\n"], dependencies: [{ kind: "component", type: NgxMarkdownComponent, selector: "markdown, [markdown]", inputs: ["data", "src", "disableSanitizer", "inline", "clipboard", "clipboardButtonComponent", "clipboardButtonTemplate", "emoji", "katex", "katexOptions", "mermaid", "mermaidOptions", "lineHighlight", "line", "lineOffset", "lineNumbers", "start", "commandLine", "filterOutput", "host", "prompt", "output", "user"], outputs: ["error", "load", "ready"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
6
22
|
}
|
|
7
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: MarkdownComponent, decorators: [{
|
|
8
24
|
type: Component,
|
|
9
|
-
args: [{ selector: '
|
|
10
|
-
}] });
|
|
25
|
+
args: [{ selector: 'folio-markdown', changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, imports: [NgxMarkdownComponent], template: `<markdown class="prose prose-neutral dark:prose-invert max-w-none" [data]="processedContent()"></markdown>`, styles: [":host{display:block}:host ::ng-deep img{max-width:100%;height:auto;border-radius:.5rem}\n"] }]
|
|
26
|
+
}], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: true }] }], embeddedMedia: [{ type: i0.Input, args: [{ isSignal: true, alias: "embeddedMedia", required: false }] }] } });
|
|
11
27
|
//# sourceMappingURL=cms-markdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-markdown.js","sourceRoot":"","sources":["../../../../../../libs/cms-markdown/src/lib/cms-markdown/cms-markdown.ts"
|
|
1
|
+
{"version":3,"file":"cms-markdown.js","sourceRoot":"","sources":["../../../../../../libs/cms-markdown/src/lib/cms-markdown/cms-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,iBAAiB,IAAI,oBAAoB,EAAE,MAAM,cAAc,CAAC;;AAczE,MAAM,OAAO,iBAAiB;IACnB,OAAO,GAAG,KAAK,CAAC,QAAQ,6EAAU,CAAC;IACnC,aAAa,GAAG,KAAK,CAAqC,EAAE,oFAAC,CAAC;IAE9D,gBAAgB,GAAG,QAAQ,CAAC,GAAG,EAAE;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC;QAE1D,oFAAoF;QACpF,OAAO,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;YACrE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YAC3B,IAAI,CAAC,KAAK;gBAAE,OAAO,MAAM,CAAC;YAC1B,OAAO,KAAK,GAAG,KAAK,KAAK,CAAC,WAAW,GAAG,CAAC;QAC3C,CAAC,CAAC,CAAC;IACL,CAAC,uFAAC,CAAC;uGAfQ,iBAAiB;2FAAjB,iBAAiB,mWANlB,4GAA4G,mKAD5G,oBAAoB;;2FAOnB,iBAAiB;kBAX7B,SAAS;+BACE,gBAAgB,mBACT,uBAAuB,CAAC,MAAM,cACnC,IAAI,WACP,CAAC,oBAAoB,CAAC,YACrB,4GAA4G","sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';\nimport { MarkdownComponent as NgxMarkdownComponent } from 'ngx-markdown';\nimport type { EmbeddedMediaEntry } from '@foliokit/cms-core';\n\n@Component({\n selector: 'folio-markdown',\n changeDetection: ChangeDetectionStrategy.OnPush,\n standalone: true,\n imports: [NgxMarkdownComponent],\n template: `<markdown class=\"prose prose-neutral dark:prose-invert max-w-none\" [data]=\"processedContent()\"></markdown>`,\n styles: [`\n :host { display: block; }\n :host ::ng-deep img { max-width: 100%; height: auto; border-radius: 0.5rem; }\n `],\n})\nexport class MarkdownComponent {\n readonly content = input.required<string>();\n readonly embeddedMedia = input<Record<string, EmbeddedMediaEntry>>({});\n\n readonly processedContent = computed(() => {\n const raw = this.content();\n const media = this.embeddedMedia();\n if (!media || Object.keys(media).length === 0) return raw;\n\n // Replace  where token is a key in embeddedMedia with the resolved URL\n return raw.replace(/!\\[([^\\]]*)\\]\\(([^)]+)\\)/g, (_match, alt, token) => {\n const entry = media[token];\n if (!entry) return _match;\n return ``;\n });\n });\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import type { EmbeddedMediaEntry } from '@foliokit/cms-core';
|
|
1
2
|
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export declare class MarkdownComponent {
|
|
4
|
+
readonly content: import("@angular/core").InputSignal<string>;
|
|
5
|
+
readonly embeddedMedia: import("@angular/core").InputSignal<Record<string, EmbeddedMediaEntry>>;
|
|
6
|
+
readonly processedContent: import("@angular/core").Signal<string>;
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MarkdownComponent, never>;
|
|
8
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MarkdownComponent, "folio-markdown", never, { "content": { "alias": "content"; "required": true; "isSignal": true; }; "embeddedMedia": { "alias": "embeddedMedia"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
5
9
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foliokit/cms-markdown",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Markdown rendering component with embedded media token resolution for FolioKit CMS",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"cms",
|
|
8
|
+
"foliokit",
|
|
9
|
+
"markdown",
|
|
10
|
+
"ngx-markdown"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/dougwilliamson/foliokit"
|
|
16
|
+
},
|
|
4
17
|
"publishConfig": {
|
|
5
18
|
"access": "public"
|
|
6
19
|
},
|
|
7
20
|
"peerDependencies": {
|
|
8
|
-
"@angular/common": "^21.
|
|
9
|
-
"@angular/core": "^21.
|
|
21
|
+
"@angular/common": "^21.2.4",
|
|
22
|
+
"@angular/core": "^21.2.4",
|
|
23
|
+
"@foliokit/cms-core": "^1.0.0",
|
|
24
|
+
"ngx-markdown": "^21.1.0"
|
|
10
25
|
},
|
|
11
26
|
"sideEffects": false,
|
|
12
27
|
"module": "esm2022/foliokit-cms-markdown.js",
|