2021-12-16 11:10:46 +00:00
|
|
|
import { CSSResult, LitElement, TemplateResult, html } from "lit";
|
|
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
|
|
|
|
|
|
import AKGlobal from "../authentik.css";
|
|
|
|
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")
|
|
|
|
export class Markdown extends LitElement {
|
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:18:43 +00:00
|
|
|
const finalHTML = this.md?.html.replace("<ul>", "<ul class=\"pf-c-list\">");
|
|
|
|
return html`${this.md?.metadata.title ? html`<h2>${this.md.metadata.title}</h2>` : html``}
|
|
|
|
${unsafeHTML(finalHTML)}`;
|
2021-12-16 11:10:46 +00:00
|
|
|
}
|
|
|
|
}
|