From fb9549b1836b5208149a39f51eab5136857d3d3d Mon Sep 17 00:00:00 2001 From: Martin Dell Date: Tue, 19 May 2026 20:19:03 +0100 Subject: [PATCH 1/3] Add Home Assistant dev deploy helper --- README.md | 4 +++ docs/dev-testing.md | 64 ++++++++++++++++++++++++++++++++++++++++ scripts/ha-deploy-dev.sh | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 docs/dev-testing.md create mode 100755 scripts/ha-deploy-dev.sh diff --git a/README.md b/README.md index a96aa92..bd6297e 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,10 @@ Notes are included in normal Home Assistant backups. The integration also provid | `entity_notes.backup_notes` | `/entity_notes_backup.json` | | `entity_notes.restore_notes` | `/entity_notes_backup.json` | +## Development Testing + +For testing unreleased changes on a Home Assistant system, see [Dev Testing In Home Assistant](docs/dev-testing.md). + ## Troubleshooting ### Notes Do Not Appear diff --git a/docs/dev-testing.md b/docs/dev-testing.md new file mode 100644 index 0000000..d5becb4 --- /dev/null +++ b/docs/dev-testing.md @@ -0,0 +1,64 @@ +# Dev Testing In Home Assistant + +This workflow lets you test unreleased changes on a Home Assistant system without manually copying files through VS Code. + +It assumes Home Assistant can reach GitHub from the Terminal add-on. + +## First-Time Setup + +Open the Home Assistant Terminal add-on and run: + +```sh +cd /config +git clone https://github.com/martindell/ha-entity-notes.git ha-entity-notes-dev +chmod +x /config/ha-entity-notes-dev/scripts/ha-deploy-dev.sh +``` + +Deploy `main`: + +```sh +/config/ha-entity-notes-dev/scripts/ha-deploy-dev.sh main +``` + +Restart Home Assistant or reload the Entity Notes integration, then hard-refresh the browser. + +## Normal Test Cycle + +On your development machine, push the branch you want to test: + +```sh +git push origin your-branch-name +``` + +In the Home Assistant Terminal add-on, deploy that branch: + +```sh +/config/ha-entity-notes-dev/scripts/ha-deploy-dev.sh your-branch-name +``` + +Then restart Home Assistant or reload the integration, and hard-refresh the browser. + +## Test Current Branch Again + +If the Home Assistant clone is already on the branch you want, run the script without a branch name: + +```sh +/config/ha-entity-notes-dev/scripts/ha-deploy-dev.sh +``` + +The script fetches from GitHub, fast-forwards the current branch, and replaces `/config/custom_components/entity_notes` with the version from the dev checkout. + +## Optional Paths + +The script defaults to: + +```sh +REPO_DIR=/config/ha-entity-notes-dev +TARGET_PARENT=/config/custom_components +``` + +Override them only if your Home Assistant paths differ: + +```sh +REPO_DIR=/config/my-dev-copy TARGET_PARENT=/config/custom_components ./scripts/ha-deploy-dev.sh main +``` diff --git a/scripts/ha-deploy-dev.sh b/scripts/ha-deploy-dev.sh new file mode 100755 index 0000000..0462b89 --- /dev/null +++ b/scripts/ha-deploy-dev.sh @@ -0,0 +1,52 @@ +#!/bin/sh +set -eu + +REPO_DIR="${REPO_DIR:-/config/ha-entity-notes-dev}" +TARGET_PARENT="${TARGET_PARENT:-/config/custom_components}" +COMPONENT_NAME="entity_notes" +SOURCE_DIR="${REPO_DIR}/custom_components/${COMPONENT_NAME}" +TARGET_DIR="${TARGET_PARENT}/${COMPONENT_NAME}" +BRANCH="${1:-}" + +if [ ! -d "${REPO_DIR}/.git" ]; then + echo "Repository not found at ${REPO_DIR}" + echo "Clone it first with:" + echo " git clone https://github.com/martindell/ha-entity-notes.git ${REPO_DIR}" + exit 1 +fi + +cd "${REPO_DIR}" + +git fetch origin + +if [ -n "${BRANCH}" ]; then + if git rev-parse --verify --quiet "${BRANCH}" >/dev/null; then + git switch "${BRANCH}" + else + git switch --track "origin/${BRANCH}" + fi +fi + +CURRENT_BRANCH="$(git branch --show-current)" +if [ -z "${CURRENT_BRANCH}" ]; then + echo "Cannot deploy from a detached HEAD. Switch to a branch first." + exit 1 +fi + +git pull --ff-only origin "${CURRENT_BRANCH}" + +if [ ! -d "${SOURCE_DIR}" ]; then + echo "Component source not found at ${SOURCE_DIR}" + exit 1 +fi + +mkdir -p "${TARGET_PARENT}" + +TEMP_DIR="${TARGET_PARENT}/${COMPONENT_NAME}.tmp.$$" +rm -rf "${TEMP_DIR}" +cp -R "${SOURCE_DIR}" "${TEMP_DIR}" +rm -rf "${TARGET_DIR}" +mv "${TEMP_DIR}" "${TARGET_DIR}" + +echo "Deployed ${COMPONENT_NAME} from branch ${CURRENT_BRANCH} to ${TARGET_DIR}" +echo "Restart Home Assistant or reload the integration, then hard-refresh your browser." From b5ac4060282b12dc0aef903f50ed4abddb02f165 Mon Sep 17 00:00:00 2001 From: Martin Dell Date: Fri, 22 May 2026 11:41:52 +0100 Subject: [PATCH 2/3] Move frontend strings into translations --- README.md | 21 ++++---- custom_components/entity_notes/__init__.py | 25 ++++++++++ .../entity_notes/entity-notes.js | 49 ++++--------------- .../entity_notes/translations/en.json | 32 ++++++++++++ 4 files changed, 78 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index bd6297e..0e3e33b 100644 --- a/README.md +++ b/README.md @@ -250,22 +250,23 @@ Thanks to [@Bjoern3D](https://github.com/Bjoern3D) for the Markdown toolbar, und ### Adding A Translation -All UI strings live in the `strings` object near the top of `custom_components/entity_notes/entity-notes.js`, organised by language code. The correct language is picked automatically at runtime based on each user's Home Assistant language setting, falling back to English for any missing keys. +All frontend UI strings live in the `frontend` section of the integration translation files under `custom_components/entity_notes/translations/`. The correct language is picked automatically at runtime based on each user's Home Assistant language setting, falling back to English for any missing keys. To add a new language: -1. Open `entity-notes.js` and find the `strings` object inside `window.entityNotes`. -2. Add a new block using the appropriate [BCP 47 language code](https://developers.home-assistant.io/docs/internationalization/core/#supported-languages) (e.g. `fr` for French, `de` for German): +1. Copy `custom_components/entity_notes/translations/en.json` to a new file using the appropriate [BCP 47 language code](https://developers.home-assistant.io/docs/internationalization/core/#supported-languages) (e.g. `fr.json` for French, `de.json` for German). +2. Translate the values in the `frontend`, `config`, and `options` sections: -```js -fr: { - save: 'ENREGISTRER', - delete: 'SUPPRIMER', - // ... all keys from the 'en' block -}, +```json +{ + "frontend": { + "save": "ENREGISTRER", + "delete": "SUPPRIMER" + } +} ``` -3. Translate every key from the `en` block. Any key you omit will automatically fall back to English. +3. Translate every key from the `frontend` section. Any key you omit will automatically fall back to English. 4. Open a pull request. ## Support diff --git a/custom_components/entity_notes/__init__.py b/custom_components/entity_notes/__init__.py index c2bd062..cf62444 100644 --- a/custom_components/entity_notes/__init__.py +++ b/custom_components/entity_notes/__init__.py @@ -800,6 +800,29 @@ class EntityNotesJSView(HomeAssistantView): name = "api:entity_notes_js" requires_auth = False + def _load_frontend_translations(self): + """Load frontend strings from Home Assistant translation files.""" + translations_path = Path(__file__).parent / "translations" + translations = {} + + for translation_file in translations_path.glob("*.json"): + try: + with open(translation_file, 'r') as f: + translation_data = json.load(f) + except Exception as e: + _LOGGER.warning( + "Could not load Entity Notes translation file %s: %s", + translation_file, + e, + ) + continue + + frontend_strings = translation_data.get("frontend") + if isinstance(frontend_strings, dict): + translations[translation_file.stem] = frontend_strings + + return translations + async def get(self, request): """Serve the JavaScript file.""" hass = request.app["hass"] @@ -827,6 +850,7 @@ def read_file(): return f.read() js_content = await hass.async_add_executor_job(read_file) + translations = await hass.async_add_executor_job(self._load_frontend_translations) # Replace configuration placeholders js_content = js_content.replace('{{DEBUG_LOGGING}}', str(debug_logging).lower()) @@ -841,6 +865,7 @@ def read_file(): js_content = js_content.replace('{{HIDE_MARKDOWN_HINTS}}', str(hide_markdown_hints).lower()) js_content = js_content.replace('{{EMPTY_NOTE_PLACEHOLDER}}', json.dumps(empty_note_placeholder)) js_content = js_content.replace('{{HIDE_LAST_MODIFIED}}', str(hide_last_modified).lower()) + js_content = js_content.replace('{{FRONTEND_TRANSLATIONS}}', json.dumps(translations)) return web.Response( text=js_content, diff --git a/custom_components/entity_notes/entity-notes.js b/custom_components/entity_notes/entity-notes.js index 7b7f01b..2164109 100644 --- a/custom_components/entity_notes/entity-notes.js +++ b/custom_components/entity_notes/entity-notes.js @@ -15,38 +15,7 @@ window.entityNotes = { hideMarkdownHints: {{HIDE_MARKDOWN_HINTS}}, emptyNotePlaceholder: {{EMPTY_NOTE_PLACEHOLDER}}, hideLastModified: {{HIDE_LAST_MODIFIED}}, - - strings: { - en: { - save: 'SAVE', - delete: 'DELETE', - preview: 'Preview', - add_note: 'Add a note...', - markdown_hints: 'Notes (# H1, ## H2, **bold**, *italic*, - bullets, 1. numbered, --- divider, `inline code`, > blockquote, ~strikethrough~)', - preview_empty: 'Preview (empty)', - confirm_delete: 'Are you sure you want to delete the note for {type} {item_id}?', - toolbar_toggle_preview: 'Toggle Live Preview', - toolbar_undo: 'Undo (Ctrl+Z)', - toolbar_redo: 'Redo (Ctrl+Y)', - toolbar_heading1: 'Heading 1', - toolbar_heading2: 'Heading 2', - toolbar_bold: 'Bold', - toolbar_italic: 'Italic', - toolbar_bullet_list: 'Bullet list', - toolbar_numbered_list: 'Numbered list', - toolbar_divider: 'Divider', - toolbar_inline_code: 'Inline Code', - toolbar_code_block: 'Code Block', - toolbar_insert_link: 'Insert Link', - toolbar_blockquote: 'Blockquote', - toolbar_strikethrough: 'Strikethrough', - error_loading_note: 'Error loading note.', - prompt_link_text: 'Enter link text:', - prompt_link_url: 'Enter URL:', - }, - // Community translations — add your language here and open a pull request. - // Keys must match the 'en' block above. Missing keys fall back to English. - }, + translations: {{FRONTEND_TRANSLATIONS}}, // Convenience methods for users enableDebug: function() { @@ -74,8 +43,10 @@ function infoLog(message) { function localize(key, replacements) { const ha = document.querySelector('home-assistant'); const lang = ha?.hass?.language || 'en'; - const strings = window.entityNotes.strings[lang] || window.entityNotes.strings['en']; - let str = strings[key] ?? window.entityNotes.strings['en'][key] ?? key; + const languageCode = lang.split('-')[0]; + const translations = window.entityNotes.translations || {}; + const strings = translations[lang] || translations[languageCode] || translations['en'] || {}; + let str = strings[key] ?? translations['en']?.[key] ?? key; if (replacements) { for (const [k, v] of Object.entries(replacements)) { str = str.replace(`{${k}}`, v); @@ -116,7 +87,7 @@ class EntityNotesCard extends HTMLElement { } catch (e) { debugLog('Entity Notes: Error getting user name: ' + e); } - return "User"; + return localize('default_user'); } get accessToken() { @@ -1276,11 +1247,11 @@ class EntityNotesCard extends HTMLElement { debugLog(`Entity Notes: Note saved successfully for ${type}, hasExistingNote: ${this.hasExistingNote}`); } else { console.error(`Entity Notes: Save failed for ${type} - HTTP ${response.status}`); - alert(`Entity Notes: Save failed (HTTP ${response.status}). Your session might have expired. Please reload the page.`); + alert(localize('save_failed', { status: response.status })); } } catch (error) { console.error(`Entity Notes: Error saving note for ${type}:`, error); - alert(`Entity Notes: Connection error during save. Please check your network connection.`); + alert(localize('save_connection_error')); } } @@ -1331,11 +1302,11 @@ class EntityNotesCard extends HTMLElement { debugLog(`Entity Notes: Note deleted successfully for ${type}`); } else { console.error(`Entity Notes: Delete failed for ${type} - HTTP ${response.status}`); - alert(`Entity Notes: Delete failed (HTTP ${response.status}). Your session might have expired. Please reload the page.`); + alert(localize('delete_failed', { status: response.status })); } } catch (error) { console.error(`Entity Notes: Error deleting note for ${type}:`, error); - alert(`Entity Notes: Connection error during delete. Please check your network connection.`); + alert(localize('delete_connection_error')); } } } diff --git a/custom_components/entity_notes/translations/en.json b/custom_components/entity_notes/translations/en.json index 8522735..eba50b4 100644 --- a/custom_components/entity_notes/translations/en.json +++ b/custom_components/entity_notes/translations/en.json @@ -119,5 +119,37 @@ "error": { "invalid_max_length": "Maximum note length must be between 50 and 2000 characters" } + }, + "frontend": { + "save": "SAVE", + "delete": "DELETE", + "preview": "Preview", + "add_note": "Add a note...", + "markdown_hints": "Notes (# H1, ## H2, **bold**, *italic*, - bullets, 1. numbered, --- divider, `inline code`, > blockquote, ~strikethrough~)", + "preview_empty": "Preview (empty)", + "confirm_delete": "Are you sure you want to delete the note for {type} {item_id}?", + "toolbar_toggle_preview": "Toggle Live Preview", + "toolbar_undo": "Undo (Ctrl+Z)", + "toolbar_redo": "Redo (Ctrl+Y)", + "toolbar_heading1": "Heading 1", + "toolbar_heading2": "Heading 2", + "toolbar_bold": "Bold", + "toolbar_italic": "Italic", + "toolbar_bullet_list": "Bullet list", + "toolbar_numbered_list": "Numbered list", + "toolbar_divider": "Divider", + "toolbar_inline_code": "Inline Code", + "toolbar_code_block": "Code Block", + "toolbar_insert_link": "Insert Link", + "toolbar_blockquote": "Blockquote", + "toolbar_strikethrough": "Strikethrough", + "error_loading_note": "Error loading note.", + "prompt_link_text": "Enter link text:", + "prompt_link_url": "Enter URL:", + "default_user": "User", + "save_failed": "Entity Notes: Save failed (HTTP {status}). Your session might have expired. Please reload the page.", + "save_connection_error": "Entity Notes: Connection error during save. Please check your network connection.", + "delete_failed": "Entity Notes: Delete failed (HTTP {status}). Your session might have expired. Please reload the page.", + "delete_connection_error": "Entity Notes: Connection error during delete. Please check your network connection." } } From 13fed8bd962c2701e8b089d29f10f898fceaf595 Mon Sep 17 00:00:00 2001 From: Martin Dell Date: Fri, 22 May 2026 11:53:08 +0100 Subject: [PATCH 3/3] Add option to hide markdown placeholder --- README.md | 1 + custom_components/entity_notes/__init__.py | 6 ++++++ custom_components/entity_notes/config_flow.py | 3 +++ custom_components/entity_notes/const.py | 2 ++ custom_components/entity_notes/entity-notes.js | 12 ++++++++++-- custom_components/entity_notes/translations/en.json | 3 +++ 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e3e33b..ee14f0c 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ Options are grouped into three sections in the integration settings. | Option | Default | Description | | --- | --- | --- | | Hide Markdown toolbar | `false` | Remove formatting controls from the note editor | +| Hide markdown placeholder text | `false` | Hide the long Markdown formatting hint shown in the empty note field | | Hide the Preview button | `false` | Remove the live preview toggle from the editor | | Use compact empty note field until clicked | `false` | Show a simple placeholder first, then reveal formatting controls and Markdown hints when editing starts | | Custom empty note placeholder | blank | Override the simple empty-note placeholder; leave blank to use the translated default | diff --git a/custom_components/entity_notes/__init__.py b/custom_components/entity_notes/__init__.py index cf62444..70c1e15 100644 --- a/custom_components/entity_notes/__init__.py +++ b/custom_components/entity_notes/__init__.py @@ -29,6 +29,7 @@ CONF_ENABLE_DEVICE_NOTES, CONF_SHOW_MARKDOWN_TOOLBAR, CONF_HIDE_MARKDOWN_TOOLBAR, + CONF_HIDE_MARKDOWN_PLACEHOLDER, CONF_CONFIRM_DELETE, CONF_HIDE_PREVIEW_BUTTON, CONF_HIDE_MARKDOWN_HINTS, @@ -46,6 +47,7 @@ DEFAULT_CONFIRM_DELETE, DEFAULT_SHOW_MARKDOWN_TOOLBAR, DEFAULT_HIDE_MARKDOWN_TOOLBAR, + DEFAULT_HIDE_MARKDOWN_PLACEHOLDER, DEFAULT_HIDE_PREVIEW_BUTTON, DEFAULT_HIDE_MARKDOWN_HINTS, DEFAULT_EMPTY_NOTE_PLACEHOLDER, @@ -116,6 +118,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: not options.get(CONF_SHOW_MARKDOWN_TOOLBAR, DEFAULT_SHOW_MARKDOWN_TOOLBAR), ) show_markdown_toolbar = not hide_markdown_toolbar + hide_markdown_placeholder = options.get(CONF_HIDE_MARKDOWN_PLACEHOLDER, DEFAULT_HIDE_MARKDOWN_PLACEHOLDER) confirm_delete = options.get(CONF_CONFIRM_DELETE, DEFAULT_CONFIRM_DELETE) hide_preview_button = options.get(CONF_HIDE_PREVIEW_BUTTON, DEFAULT_HIDE_PREVIEW_BUTTON) hide_markdown_hints = options.get(CONF_HIDE_MARKDOWN_HINTS, DEFAULT_HIDE_MARKDOWN_HINTS) @@ -234,6 +237,7 @@ def _write_migrated(): CONF_ENABLE_DEVICE_NOTES: enable_device_notes, CONF_SHOW_MARKDOWN_TOOLBAR: show_markdown_toolbar, CONF_HIDE_MARKDOWN_TOOLBAR: hide_markdown_toolbar, + CONF_HIDE_MARKDOWN_PLACEHOLDER: hide_markdown_placeholder, CONF_CONFIRM_DELETE: confirm_delete, CONF_HIDE_PREVIEW_BUTTON: hide_preview_button, CONF_HIDE_MARKDOWN_HINTS: hide_markdown_hints, @@ -834,6 +838,7 @@ async def get(self, request): enable_device_notes = hass.data[DOMAIN]["config"].get(CONF_ENABLE_DEVICE_NOTES, True) hide_markdown_toolbar = hass.data[DOMAIN]["config"].get(CONF_HIDE_MARKDOWN_TOOLBAR, DEFAULT_HIDE_MARKDOWN_TOOLBAR) show_markdown_toolbar = not hide_markdown_toolbar + hide_markdown_placeholder = hass.data[DOMAIN]["config"].get(CONF_HIDE_MARKDOWN_PLACEHOLDER, DEFAULT_HIDE_MARKDOWN_PLACEHOLDER) confirm_delete = hass.data[DOMAIN]["config"].get(CONF_CONFIRM_DELETE, True) hide_preview_button = hass.data[DOMAIN]["config"].get(CONF_HIDE_PREVIEW_BUTTON, False) hide_markdown_hints = hass.data[DOMAIN]["config"].get(CONF_HIDE_MARKDOWN_HINTS, False) @@ -861,6 +866,7 @@ def read_file(): js_content = js_content.replace('{{ENABLE_DEVICE_NOTES}}', str(enable_device_notes).lower()) js_content = js_content.replace('{{CONFIRM_DELETE}}', str(confirm_delete).lower()) js_content = js_content.replace('{{SHOW_MARKDOWN_TOOLBAR}}', str(show_markdown_toolbar).lower()) + js_content = js_content.replace('{{HIDE_MARKDOWN_PLACEHOLDER}}', str(hide_markdown_placeholder).lower()) js_content = js_content.replace('{{HIDE_PREVIEW_BUTTON}}', str(hide_preview_button).lower()) js_content = js_content.replace('{{HIDE_MARKDOWN_HINTS}}', str(hide_markdown_hints).lower()) js_content = js_content.replace('{{EMPTY_NOTE_PLACEHOLDER}}', json.dumps(empty_note_placeholder)) diff --git a/custom_components/entity_notes/config_flow.py b/custom_components/entity_notes/config_flow.py index cccaf63..9654605 100644 --- a/custom_components/entity_notes/config_flow.py +++ b/custom_components/entity_notes/config_flow.py @@ -21,6 +21,7 @@ CONF_DELETE_NOTES_WITH_ENTITY, CONF_HIDE_MARKDOWN_TOOLBAR, CONF_SHOW_MARKDOWN_TOOLBAR, + CONF_HIDE_MARKDOWN_PLACEHOLDER, CONF_CONFIRM_DELETE, CONF_HIDE_PREVIEW_BUTTON, CONF_HIDE_MARKDOWN_HINTS, @@ -35,6 +36,7 @@ DEFAULT_DELETE_NOTES_WITH_ENTITY, DEFAULT_HIDE_MARKDOWN_TOOLBAR, DEFAULT_SHOW_MARKDOWN_TOOLBAR, + DEFAULT_HIDE_MARKDOWN_PLACEHOLDER, DEFAULT_CONFIRM_DELETE, DEFAULT_HIDE_PREVIEW_BUTTON, DEFAULT_HIDE_MARKDOWN_HINTS, @@ -52,6 +54,7 @@ SECTION_CONFIG = [ (SECTION_DISPLAY, [ (CONF_HIDE_MARKDOWN_TOOLBAR, DEFAULT_HIDE_MARKDOWN_TOOLBAR, bool), + (CONF_HIDE_MARKDOWN_PLACEHOLDER, DEFAULT_HIDE_MARKDOWN_PLACEHOLDER, bool), (CONF_HIDE_PREVIEW_BUTTON, DEFAULT_HIDE_PREVIEW_BUTTON, bool), (CONF_HIDE_MARKDOWN_HINTS, DEFAULT_HIDE_MARKDOWN_HINTS, bool), (CONF_EMPTY_NOTE_PLACEHOLDER, DEFAULT_EMPTY_NOTE_PLACEHOLDER, vol.All(str, vol.Length(max=120))), diff --git a/custom_components/entity_notes/const.py b/custom_components/entity_notes/const.py index f77211a..71e5623 100644 --- a/custom_components/entity_notes/const.py +++ b/custom_components/entity_notes/const.py @@ -18,6 +18,7 @@ CONF_ENABLE_DEVICE_NOTES = "enable_device_notes" CONF_SHOW_MARKDOWN_TOOLBAR = "show_markdown_toolbar" CONF_HIDE_MARKDOWN_TOOLBAR = "hide_markdown_toolbar" +CONF_HIDE_MARKDOWN_PLACEHOLDER = "hide_markdown_placeholder" CONF_CONFIRM_DELETE = "confirm_delete" CONF_HIDE_PREVIEW_BUTTON = "hide_preview_button" CONF_HIDE_MARKDOWN_HINTS = "hide_markdown_hints" @@ -54,6 +55,7 @@ DEFAULT_ENABLE_DEVICE_NOTES = True DEFAULT_SHOW_MARKDOWN_TOOLBAR = True DEFAULT_HIDE_MARKDOWN_TOOLBAR = False +DEFAULT_HIDE_MARKDOWN_PLACEHOLDER = False DEFAULT_CONFIRM_DELETE = True DEFAULT_HIDE_PREVIEW_BUTTON = False DEFAULT_HIDE_MARKDOWN_HINTS = False diff --git a/custom_components/entity_notes/entity-notes.js b/custom_components/entity_notes/entity-notes.js index 2164109..91d4143 100644 --- a/custom_components/entity_notes/entity-notes.js +++ b/custom_components/entity_notes/entity-notes.js @@ -11,6 +11,7 @@ window.entityNotes = { enableDeviceNotes: {{ENABLE_DEVICE_NOTES}}, confirmDelete: {{CONFIRM_DELETE}}, showMarkdownToolbar: {{SHOW_MARKDOWN_TOOLBAR}}, + hideMarkdownPlaceholder: {{HIDE_MARKDOWN_PLACEHOLDER}}, hidePreviewButton: {{HIDE_PREVIEW_BUTTON}}, hideMarkdownHints: {{HIDE_MARKDOWN_HINTS}}, emptyNotePlaceholder: {{EMPTY_NOTE_PLACEHOLDER}}, @@ -63,6 +64,13 @@ function emptyNotePlaceholder() { return localize('add_note'); } +function markdownPlaceholder() { + if (window.entityNotes.hideMarkdownPlaceholder) { + return emptyNotePlaceholder(); + } + return localize('markdown_hints'); +} + class EntityNotesCard extends HTMLElement { constructor() { super(); @@ -149,7 +157,7 @@ class EntityNotesCard extends HTMLElement { const maxLength = window.entityNotes.maxNoteLength; const previewButtonHtml = window.entityNotes.hidePreviewButton ? '' : ``; - const initialPlaceholder = window.entityNotes.hideMarkdownHints ? emptyNotePlaceholder() : localize('markdown_hints'); + const initialPlaceholder = window.entityNotes.hideMarkdownHints ? emptyNotePlaceholder() : markdownPlaceholder(); this.shadowRoot.innerHTML = `