mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-12 11:56:34 +00:00
Enable ha-icons in markdown card (#3458)
* Allow ha-icon in markdown * Please the linter * Remove allowSvg * Remove lasts allow-svgs
This commit is contained in:
parent
f3729759b7
commit
dc2ee2e63f
@ -106,7 +106,6 @@ class HaAuthFlow extends litLocalizeLiteMixin(LitElement) {
|
|||||||
? html`
|
? html`
|
||||||
<ha-markdown
|
<ha-markdown
|
||||||
.content=${this._computeStepDescription(step)}
|
.content=${this._computeStepDescription(step)}
|
||||||
allow-svg
|
|
||||||
></ha-markdown>
|
></ha-markdown>
|
||||||
`
|
`
|
||||||
: html``}
|
: html``}
|
||||||
|
@ -3,11 +3,7 @@ import { EventsMixin } from "../mixins/events-mixin";
|
|||||||
|
|
||||||
let loaded = null;
|
let loaded = null;
|
||||||
|
|
||||||
/**
|
const tagWhiteList = ["svg", "path", "ha-icon"];
|
||||||
* White list allowed svg tag.
|
|
||||||
* Only put in the tag used in QR code, can be extend in future.
|
|
||||||
*/
|
|
||||||
const svgWhiteList = ["svg", "path"];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @appliesMixin EventsMixin
|
* @appliesMixin EventsMixin
|
||||||
@ -16,12 +12,8 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
|
|||||||
static get properties() {
|
static get properties() {
|
||||||
return {
|
return {
|
||||||
content: {
|
content: {
|
||||||
type: String,
|
|
||||||
observer: "_render",
|
observer: "_render",
|
||||||
},
|
type: String,
|
||||||
allowSvg: {
|
|
||||||
type: Boolean,
|
|
||||||
value: false,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -51,7 +43,9 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_render() {
|
_render() {
|
||||||
if (this._scriptLoaded === 0 || this._renderScheduled) return;
|
if (this._scriptLoaded === 0 || this._renderScheduled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._renderScheduled = true;
|
this._renderScheduled = true;
|
||||||
|
|
||||||
@ -62,14 +56,13 @@ class HaMarkdown extends EventsMixin(PolymerElement) {
|
|||||||
if (this._scriptLoaded === 1) {
|
if (this._scriptLoaded === 1) {
|
||||||
this.innerHTML = this.filterXSS(
|
this.innerHTML = this.filterXSS(
|
||||||
this.marked(this.content, {
|
this.marked(this.content, {
|
||||||
|
breaks: true,
|
||||||
gfm: true,
|
gfm: true,
|
||||||
tables: true,
|
tables: true,
|
||||||
breaks: true,
|
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
onIgnoreTag: this.allowSvg
|
onIgnoreTag: (tag, html) =>
|
||||||
? (tag, html) => (svgWhiteList.indexOf(tag) >= 0 ? html : null)
|
tagWhiteList.indexOf(tag) >= 0 ? html : null,
|
||||||
: null,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this._resize();
|
this._resize();
|
||||||
|
@ -37,7 +37,7 @@ class StepFlowAbort extends LitElement {
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
${description
|
${description
|
||||||
? html`
|
? html`
|
||||||
<ha-markdown .content=${description} allow-svg></ha-markdown>
|
<ha-markdown .content=${description}></ha-markdown>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</div>
|
</div>
|
||||||
|
@ -56,7 +56,7 @@ class StepFlowCreateEntry extends LitElement {
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
${description
|
${description
|
||||||
? html`
|
? html`
|
||||||
<ha-markdown .content=${description} allow-svg></ha-markdown>
|
<ha-markdown .content=${description}></ha-markdown>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
<p>Created config for ${step.title}.</p>
|
<p>Created config for ${step.title}.</p>
|
||||||
|
@ -51,7 +51,7 @@ class StepFlowExternal extends LitElement {
|
|||||||
</p>
|
</p>
|
||||||
${description
|
${description
|
||||||
? html`
|
? html`
|
||||||
<ha-markdown .content=${description} allow-svg></ha-markdown>
|
<ha-markdown .content=${description}></ha-markdown>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
<div class="open-button">
|
<div class="open-button">
|
||||||
|
@ -79,7 +79,7 @@ class StepFlowForm extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
${description
|
${description
|
||||||
? html`
|
? html`
|
||||||
<ha-markdown .content=${description} allow-svg></ha-markdown>
|
<ha-markdown .content=${description}></ha-markdown>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
<ha-form
|
<ha-form
|
||||||
|
@ -91,7 +91,6 @@ class HaMfaModuleSetupFlow extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
>
|
>
|
||||||
<ha-markdown
|
<ha-markdown
|
||||||
content="[[_computeStepDescription(localize, _step)]]"
|
content="[[_computeStepDescription(localize, _step)]]"
|
||||||
allow-svg
|
|
||||||
></ha-markdown>
|
></ha-markdown>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user