-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Allow hui-timestamp-display in markdown
#8215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5096451
42f13a1
fde70a7
2079998
fee5966
74e283c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,3 +17,12 @@ export const formatTimeWithSeconds = toLocaleTimeStringSupportsOptions | |
| second: "2-digit", | ||
| }) | ||
| : (dateObj: Date) => format(dateObj, "mediumTime"); | ||
|
|
||
| export const formatTimeWeekday = toLocaleTimeStringSupportsOptions | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied from PR #8182. |
||
| ? (dateObj: Date, locales: string) => | ||
| dateObj.toLocaleTimeString(locales, { | ||
| weekday: "long", | ||
| hour: "numeric", | ||
| minute: "2-digit", | ||
| }) | ||
| : (dateObj: Date) => format(dateObj, "dddd, HH:mm"); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| import { customElement, property, UpdatingElement } from "lit-element"; | ||
| import { fireEvent } from "../common/dom/fire_event"; | ||
| import { renderMarkdown } from "../resources/render-markdown"; | ||
| import type { HomeAssistant } from "../types"; | ||
| import { HuiTimestampDisplay } from "../panels/lovelace/components/hui-timestamp-display"; | ||
|
|
||
| @customElement("ha-markdown-element") | ||
| class HaMarkdownElement extends UpdatingElement { | ||
| @property({ attribute: false }) public hass?: HomeAssistant; | ||
|
|
||
| @property() public content?; | ||
|
|
||
| @property({ type: Boolean }) public allowSvg = false; | ||
|
|
@@ -55,6 +59,8 @@ class HaMarkdownElement extends UpdatingElement { | |
| // Fire a resize event when images loaded to notify content resized | ||
| } else if (node instanceof HTMLImageElement) { | ||
| node.addEventListener("load", this._resize); | ||
| } else if (node instanceof HuiTimestampDisplay) { | ||
| node.hass = this.hass; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,10 @@ const renderMarkdown = ( | |
| if (!whiteListNormal) { | ||
| whiteListNormal = { | ||
| ...(getDefaultWhiteList() as WhiteList), | ||
| style: [], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't allow every style, it allows for xss
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we might need something like this: https://github.com/leizongmin/js-css-filter Same author as the I'll separate the <style> part into a separate future PR. |
||
| "ha-icon": ["icon"], | ||
| "ha-svg-icon": ["path"], | ||
| "hui-timestamp-display": ["ts", "format"], | ||
| }; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from PR #8182.