Fix duplicate headers on HTMX nav, editor content loading, and double mount
- Nest admin header inside post-header-child (layouts.py/helpers.py) so full-page DOM matches OOB swap structure, eliminating duplicate headers - Clear post-header-child on post layout OOB to remove stale admin rows - Read SX initial content from #sx-content-input instead of window.__SX_INITIAL__ to avoid escaping issues through SX pipeline - Fix client-side SX parser RE_STRING to handle escaped newlines - Clear root element in SxEditor.mount() to prevent double content on HTMX re-mount - Remove unused ~blog-editor-sx-initial component Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2249,7 +2249,9 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
root.className = (root.className || "") + " sx-editor";
|
||||
// Clear any previous mount
|
||||
root.innerHTML = "";
|
||||
root.className = (root.className || "").replace(/\bsx-editor\b/g, "").trim() + " sx-editor";
|
||||
|
||||
var container = el("div", { className: "sx-blocks-container" });
|
||||
root.appendChild(container);
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
var RE_WS = /\s+/y;
|
||||
var RE_COMMENT = /;[^\n]*/y;
|
||||
var RE_STRING = /"(?:[^"\\]|\\.)*"/y;
|
||||
var RE_STRING = /"(?:[^"\\]|\\[\s\S])*"/y;
|
||||
var RE_NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y;
|
||||
var RE_KEYWORD = /:[a-zA-Z_][a-zA-Z0-9_>:\-]*/y;
|
||||
var RE_SYMBOL = /[a-zA-Z_~*+\-><=/!?&][a-zA-Z0-9_~*+\-><=/!?.:&]*/y;
|
||||
|
||||
@@ -254,7 +254,7 @@ def search_desktop_sx(ctx: dict) -> str:
|
||||
)
|
||||
|
||||
|
||||
def post_header_sx(ctx: dict, *, oob: bool = False) -> str:
|
||||
def post_header_sx(ctx: dict, *, oob: bool = False, child: str = "") -> str:
|
||||
"""Build the post-level header row as sx call string."""
|
||||
post = ctx.get("post") or {}
|
||||
slug = post.get("slug", "")
|
||||
@@ -273,6 +273,7 @@ def post_header_sx(ctx: dict, *, oob: bool = False) -> str:
|
||||
link_label_content=SxExpr(label_sx),
|
||||
nav=SxExpr(nav_sx) if nav_sx else None,
|
||||
child_id="post-header-child",
|
||||
child=SxExpr(child) if child else None,
|
||||
oob=oob, external=True,
|
||||
)
|
||||
|
||||
|
||||
@@ -104,16 +104,18 @@ def _post_full(ctx: dict, **kw: Any) -> str:
|
||||
|
||||
def _post_oob(ctx: dict, **kw: Any) -> str:
|
||||
post_hdr = post_header_sx(ctx, oob=True)
|
||||
return post_hdr
|
||||
# Also replace #post-header-child (empty — clears any nested admin rows)
|
||||
child_oob = oob_header_sx("post-header-child", "", "")
|
||||
return "(<> " + post_hdr + " " + child_oob + ")"
|
||||
|
||||
|
||||
def _post_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
slug = ctx.get("post", {}).get("slug", "")
|
||||
selected = kw.get("selected", "")
|
||||
root_hdr = root_header_sx(ctx)
|
||||
post_hdr = post_header_sx(ctx)
|
||||
admin_hdr = post_admin_header_sx(ctx, slug, selected=selected)
|
||||
return "(<> " + root_hdr + " " + post_hdr + " " + admin_hdr + ")"
|
||||
post_hdr = post_header_sx(ctx, child=admin_hdr)
|
||||
return "(<> " + root_hdr + " " + post_hdr + ")"
|
||||
|
||||
|
||||
def _post_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
|
||||
Reference in New Issue
Block a user