custom_components/bahmcloud_store/panel/panel.js aktualisiert
This commit is contained in:
@@ -169,7 +169,7 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
`bcs/readme?repo_id=${encodeURIComponent(repoId)}`
|
`bcs/readme?repo_id=${encodeURIComponent(repoId)}`
|
||||||
);
|
);
|
||||||
|
|
||||||
if (resp?.ok && typeof resp.readme === "string") {
|
if (resp?.ok && typeof resp.readme === "string" && resp.readme.trim()) {
|
||||||
this._readmeText = resp.readme;
|
this._readmeText = resp.readme;
|
||||||
} else {
|
} else {
|
||||||
this._readmeText = null;
|
this._readmeText = null;
|
||||||
@@ -294,14 +294,14 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select{
|
input, select, textarea{
|
||||||
padding:10px 12px; border-radius:12px;
|
padding:10px 12px; border-radius:12px;
|
||||||
border:1px solid var(--divider-color);
|
border:1px solid var(--divider-color);
|
||||||
background:var(--card-background-color);
|
background:var(--card-background-color);
|
||||||
color:var(--primary-text-color);
|
color:var(--primary-text-color);
|
||||||
outline:none;
|
outline:none;
|
||||||
}
|
}
|
||||||
input:focus, select:focus{
|
input:focus, select:focus, textarea:focus{
|
||||||
border-color:var(--bcs-accent);
|
border-color:var(--bcs-accent);
|
||||||
box-shadow:0 0 0 2px color-mix(in srgb, var(--bcs-accent) 20%, transparent);
|
box-shadow:0 0 0 2px color-mix(in srgb, var(--bcs-accent) 20%, transparent);
|
||||||
}
|
}
|
||||||
@@ -341,18 +341,15 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
opacity: .55;
|
opacity: .55;
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
.fab-label{
|
|
||||||
position: fixed;
|
|
||||||
right: 84px;
|
|
||||||
bottom: 18px;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mdwrap ha-markdown{
|
/* README fallback pre */
|
||||||
display: block;
|
pre.readme{
|
||||||
}
|
white-space: pre-wrap;
|
||||||
.mdwrap{
|
word-break: break-word;
|
||||||
padding-top: 6px;
|
margin: 0;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||||
|
font-size: 12.5px;
|
||||||
|
line-height: 1.5;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -394,6 +391,29 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
this._update();
|
this._update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ✅ CRITICAL FIX: prevent HA global shortcuts (Assist/Command Palette) from
|
||||||
|
// stealing keystrokes while typing in inputs inside this panel.
|
||||||
|
const stopIfFormField = (e) => {
|
||||||
|
const t = e.composedPath ? e.composedPath()[0] : e.target;
|
||||||
|
if (!t) return;
|
||||||
|
|
||||||
|
const tag = (t.tagName || "").toLowerCase();
|
||||||
|
const isEditable =
|
||||||
|
tag === "input" ||
|
||||||
|
tag === "textarea" ||
|
||||||
|
tag === "select" ||
|
||||||
|
t.isContentEditable;
|
||||||
|
|
||||||
|
if (isEditable) {
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Use capture phase so we intercept before HA handlers.
|
||||||
|
root.addEventListener("keydown", stopIfFormField, true);
|
||||||
|
root.addEventListener("keyup", stopIfFormField, true);
|
||||||
|
root.addEventListener("keypress", stopIfFormField, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_update() {
|
_update() {
|
||||||
@@ -406,14 +426,12 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
const v = this._data?.version ? String(this._data.version) : null;
|
const v = this._data?.version ? String(this._data.version) : null;
|
||||||
subtitle.textContent = v ? `BCS ${v}` : "BCS — loading…";
|
subtitle.textContent = v ? `BCS ${v}` : "BCS — loading…";
|
||||||
|
|
||||||
// Tabs active state (detail is not a tab)
|
|
||||||
for (const tab of root.querySelectorAll(".tab")) {
|
for (const tab of root.querySelectorAll(".tab")) {
|
||||||
tab.classList.toggle("active", tab.getAttribute("data-view") === this._view);
|
tab.classList.toggle("active", tab.getAttribute("data-view") === this._view);
|
||||||
}
|
}
|
||||||
|
|
||||||
err.textContent = this._error ? `Error: ${this._error}` : "";
|
err.textContent = this._error ? `Error: ${this._error}` : "";
|
||||||
|
|
||||||
// FABs only on detail view
|
|
||||||
fabs.innerHTML = this._view === "detail" ? this._renderFabs() : "";
|
fabs.innerHTML = this._view === "detail" ? this._renderFabs() : "";
|
||||||
this._wireFabs();
|
this._wireFabs();
|
||||||
|
|
||||||
@@ -560,8 +578,10 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
? `<div class="card">Loading README…</div>`
|
? `<div class="card">Loading README…</div>`
|
||||||
: this._readmeText
|
: this._readmeText
|
||||||
? `
|
? `
|
||||||
<div class="card mdwrap">
|
<div class="card">
|
||||||
<ha-markdown id="readmeMd"></ha-markdown>
|
<div><strong>README</strong></div>
|
||||||
|
<div class="muted small" style="margin-top:6px;">Rendered Markdown (fallback to raw text if needed).</div>
|
||||||
|
<div id="readmeContainer" style="margin-top:12px;"></div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
: `
|
: `
|
||||||
@@ -608,15 +628,34 @@ class BahmcloudStorePanel extends HTMLElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_wireDetail() {
|
_wireDetail() {
|
||||||
// Render markdown into ha-markdown after DOM exists
|
// Render README into container:
|
||||||
|
// 1) Try ha-markdown (if available)
|
||||||
|
// 2) Fallback: raw markdown in <pre>
|
||||||
const root = this.shadowRoot;
|
const root = this.shadowRoot;
|
||||||
const mdEl = root.getElementById("readmeMd");
|
const container = root.getElementById("readmeContainer");
|
||||||
if (mdEl && this._readmeText) {
|
if (!container) return;
|
||||||
try {
|
|
||||||
mdEl.hass = this._hass;
|
container.innerHTML = "";
|
||||||
} catch (_) {}
|
|
||||||
mdEl.content = this._readmeText;
|
if (!this._readmeText) return;
|
||||||
|
|
||||||
|
// Try HA markdown element (best effort)
|
||||||
|
try {
|
||||||
|
const el = document.createElement("ha-markdown");
|
||||||
|
// some HA builds need hass set before content
|
||||||
|
try { el.hass = this._hass; } catch (_) {}
|
||||||
|
el.content = this._readmeText;
|
||||||
|
container.appendChild(el);
|
||||||
|
return;
|
||||||
|
} catch (_) {
|
||||||
|
// fall through
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback: raw text
|
||||||
|
const pre = document.createElement("pre");
|
||||||
|
pre.className = "readme";
|
||||||
|
pre.textContent = this._readmeText;
|
||||||
|
container.appendChild(pre);
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderFabs() {
|
_renderFabs() {
|
||||||
|
|||||||
Reference in New Issue
Block a user