Allow hui-timestamp-display in markdown#8215
Closed
spacegaier wants to merge 6 commits intohome-assistant:devfrom
Closed
Allow hui-timestamp-display in markdown#8215spacegaier wants to merge 6 commits intohome-assistant:devfrom
hui-timestamp-display in markdown#8215spacegaier wants to merge 6 commits intohome-assistant:devfrom
Conversation
spacegaier
commented
Jan 23, 2021
| }) | ||
| : (dateObj: Date) => format(dateObj, "mediumTime"); | ||
|
|
||
| export const formatTimeWeekday = toLocaleTimeStringSupportsOptions |
| }) | ||
| : (dateObj: Date) => format(dateObj, "longDate"); | ||
|
|
||
| export const formatDateWeekday = toLocaleDateStringSupportsOptions |
bramkragten
reviewed
Jan 25, 2021
| } 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.
hass should be updated when it changes
bramkragten
reviewed
Jan 25, 2021
| if (!whiteListNormal) { | ||
| whiteListNormal = { | ||
| ...(getDefaultWhiteList() as WhiteList), | ||
| style: [], |
Member
There was a problem hiding this comment.
We can't allow every style, it allows for xss
Member
Author
There was a problem hiding this comment.
Yeah, we might need something like this: https://github.com/leizongmin/js-css-filter
Same author as the xss module we already use, but quite old.
I'll separate the <style> part into a separate future PR.
Member
|
We should not add support for this, this means we can never change these elements again... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
Proposed change
Use case:
I have a markdown card that displays upcoming weather alerts. I show the weather condition plus of course the time period for when they are going to apply. Currently I have this template in the markdown card:
{{ time_start | timestamp_custom("%a %H:%M") }}. That however, means that the date formatting (e.g. the weekdays) are set in the locale of the backend, ignoring the user language of the frontend. So in my case I have a German dashboard with a German alert text (German weather alert integration) but an English weekday.Solution:
This PR now adds the
<hui-timestamp-display>to the allowed list of HA tags in the markdown. I also included<style>which is also supported by the marked JS library we use since we havegfmenabled.Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: