2022-09-14 22:05:21 +00:00
|
|
|
import { AKElement } from "@goauthentik/elements/Base";
|
|
|
|
|
|
|
|
import { CSSResult, TemplateResult, html } from "lit";
|
2021-12-16 11:10:46 +00:00
|
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
|
|
|
2022-09-14 22:05:21 +00:00
|
|
|
import AKGlobal from "@goauthentik/common/styles/authentik.css";
|
2021-12-16 11:10:46 +00:00
|
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
|
|
import PFList from "@patternfly/patternfly/components/List/list.css";
|
|
|
|
|
2021-12-16 11:18:43 +00:00
|
|
|
export interface MarkdownDocument {
|
|
|
|
html: string;
|
|
|
|
metadata: { [key: string]: string };
|
|
|
|
filename: string;
|
|
|
|
}
|
|
|
|
|
2021-12-16 11:10:46 +00:00
|
|
|
@customElement("ak-markdown")
|
2022-09-14 22:05:21 +00:00
|
|
|
export class Markdown extends AKElement {
|
2021-12-16 11:18:43 +00:00
|
|
|
@property({ attribute: false })
|
|
|
|
md?: MarkdownDocument;
|
2021-12-16 11:10:46 +00:00
|
|
|
|
|
|
|
static get styles(): CSSResult[] {
|
|
|
|
return [PFList, PFContent, AKGlobal];
|
|
|
|
}
|
|
|
|
|
|
|
|
render(): TemplateResult {
|
|
|
|
if (!this.md) {
|
|
|
|
return html``;
|
|
|
|
}
|
2021-12-16 11:26:14 +00:00
|
|
|
const finalHTML = this.md?.html.replace("<ul>", "<ul class='pf-c-list'>");
|
2021-12-16 11:18:43 +00:00
|
|
|
return html`${this.md?.metadata.title ? html`<h2>${this.md.metadata.title}</h2>` : html``}
|
|
|
|
${unsafeHTML(finalHTML)}`;
|
2021-12-16 11:10:46 +00:00
|
|
|
}
|
|
|
|
}
|