@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 CmsMarkdown {
4
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.6", ngImport: i0, type: CmsMarkdown, deps: [], target: i0.ɵɵFactoryTarget.Component });
5
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.6", type: CmsMarkdown, isStandalone: true, selector: "lib-cms-markdown", ngImport: i0, template: "<p>CmsMarkdown works!</p>\n", styles: [""] });
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 ![alt](token) 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 `![${alt}](${entry.downloadUrl})`;
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.1.6", ngImport: i0, type: CmsMarkdown, decorators: [{
23
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: MarkdownComponent, decorators: [{
8
24
  type: Component,
9
- args: [{ selector: 'lib-cms-markdown', imports: [], template: "<p>CmsMarkdown works!</p>\n" }]
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","../../../../../../libs/cms-markdown/src/lib/cms-markdown/cms-markdown.html"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;AAQ1C,MAAM,OAAO,WAAW;uGAAX,WAAW;2FAAX,WAAW,4ECRxB,6BACA;;2FDOa,WAAW;kBANvB,SAAS;+BACE,kBAAkB,WACnB,EAAE","sourcesContent":["import { Component } from '@angular/core';\n\n@Component({\n selector: 'lib-cms-markdown',\n imports: [],\n templateUrl: './cms-markdown.html',\n styleUrl: './cms-markdown.scss',\n})\nexport class CmsMarkdown {}\n","<p>CmsMarkdown works!</p>\n"]}
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 ![alt](token) 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 `![${alt}](${entry.downloadUrl})`;\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 CmsMarkdown {
3
- static ɵfac: i0.ɵɵFactoryDeclaration<CmsMarkdown, never>;
4
- static ɵcmp: i0.ɵɵComponentDeclaration<CmsMarkdown, "lib-cms-markdown", never, {}, {}, never, never, true, never>;
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": "0.0.0",
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.1.0",
9
- "@angular/core": "^21.1.0"
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",