mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-19 07:16:39 +00:00
Add hint helpers to fields that support markdown (#25528)
* Add hint helpers to fields that support markdown * reduce duplication
This commit is contained in:
parent
07e5f53469
commit
f0beef22d2
14
src/common/translations/markdown_support.ts
Normal file
14
src/common/translations/markdown_support.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { html } from "lit";
|
||||||
|
import type { LocalizeFunc } from "./localize";
|
||||||
|
|
||||||
|
const MARKDOWN_SUPPORT_URL = "https://commonmark.org/help/";
|
||||||
|
|
||||||
|
export const supportsMarkdownHelper = (localize: LocalizeFunc) =>
|
||||||
|
localize("ui.common.supports_markdown", {
|
||||||
|
markdown_help_link: html`<a
|
||||||
|
href=${MARKDOWN_SUPPORT_URL}
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
>${localize("ui.common.markdown")}</a
|
||||||
|
>`,
|
||||||
|
});
|
@ -23,6 +23,7 @@ import type {
|
|||||||
EntityRegistryUpdate,
|
EntityRegistryUpdate,
|
||||||
SaveDialogParams,
|
SaveDialogParams,
|
||||||
} from "./show-dialog-automation-save";
|
} from "./show-dialog-automation-save";
|
||||||
|
import { supportsMarkdownHelper } from "../../../../common/translations/markdown_support";
|
||||||
|
|
||||||
@customElement("ha-dialog-automation-save")
|
@customElement("ha-dialog-automation-save")
|
||||||
class DialogAutomationSave extends LitElement implements HassDialog {
|
class DialogAutomationSave extends LitElement implements HassDialog {
|
||||||
@ -156,6 +157,7 @@ class DialogAutomationSave extends LitElement implements HassDialog {
|
|||||||
name="description"
|
name="description"
|
||||||
autogrow
|
autogrow
|
||||||
.value=${this._newDescription}
|
.value=${this._newDescription}
|
||||||
|
.helper=${supportsMarkdownHelper(this.hass.localize)}
|
||||||
@input=${this._valueChanged}
|
@input=${this._valueChanged}
|
||||||
></ha-textarea>`
|
></ha-textarea>`
|
||||||
: nothing}
|
: nothing}
|
||||||
|
@ -25,6 +25,7 @@ import { showConfirmationDialog } from "../../dialogs/generic/show-dialog-box";
|
|||||||
import { haStyleDialog } from "../../resources/styles";
|
import { haStyleDialog } from "../../resources/styles";
|
||||||
import type { HomeAssistant } from "../../types";
|
import type { HomeAssistant } from "../../types";
|
||||||
import type { TodoItemEditDialogParams } from "./show-dialog-todo-item-editor";
|
import type { TodoItemEditDialogParams } from "./show-dialog-todo-item-editor";
|
||||||
|
import { supportsMarkdownHelper } from "../../common/translations/markdown_support";
|
||||||
|
|
||||||
@customElement("dialog-todo-item-editor")
|
@customElement("dialog-todo-item-editor")
|
||||||
class DialogTodoItemEditor extends LitElement {
|
class DialogTodoItemEditor extends LitElement {
|
||||||
@ -146,6 +147,7 @@ class DialogTodoItemEditor extends LitElement {
|
|||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.components.todo.item.description"
|
"ui.components.todo.item.description"
|
||||||
)}
|
)}
|
||||||
|
.helper=${supportsMarkdownHelper(this.hass.localize)}
|
||||||
.value=${this._description}
|
.value=${this._description}
|
||||||
@input=${this._handleDescriptionChanged}
|
@input=${this._handleDescriptionChanged}
|
||||||
autogrow
|
autogrow
|
||||||
|
@ -374,7 +374,9 @@
|
|||||||
"copy": "Copy",
|
"copy": "Copy",
|
||||||
"show": "Show",
|
"show": "Show",
|
||||||
"replace": "Replace",
|
"replace": "Replace",
|
||||||
"append": "Append"
|
"append": "Append",
|
||||||
|
"supports_markdown": "Supports {markdown_help_link}",
|
||||||
|
"markdown": "Markdown"
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
"selectors": {
|
"selectors": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user