Fix back-button DOM restoration: process OOB swaps on popstate, disable editor font overrides
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m43s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m43s
- Process sx-swap-oob and hx-swap-oob elements in the popstate handler so sidebar, filter, menu, and headers are restored on back navigation - Disable the 62.5% base font-size hack that leaked globally and caused all fonts to shrink when navigating to/from the editor - Cache-bust sx.js to v=20260301d Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1115,6 +1115,7 @@ def render_editor_panel(save_error: str | None = None, is_page: bool = False) ->
|
||||
asset_url_fn = current_app.jinja_env.globals.get("asset_url", lambda p: "")
|
||||
editor_css = asset_url_fn("scripts/editor.css")
|
||||
editor_js = asset_url_fn("scripts/editor.js")
|
||||
sx_editor_js = asset_url_fn("scripts/sx-editor.js")
|
||||
|
||||
upload_image_url = qurl("blog.editor_api.upload_image")
|
||||
upload_media_url = qurl("blog.editor_api.upload_media")
|
||||
@@ -1139,29 +1140,21 @@ def render_editor_panel(save_error: str | None = None, is_page: bool = False) ->
|
||||
)
|
||||
parts.append(form_html)
|
||||
|
||||
# Editor CSS + inline styles
|
||||
# Editor CSS + inline styles + sx editor styles
|
||||
parts.append(sx_call("blog-editor-styles", css_href=editor_css))
|
||||
parts.append(sx_call("sx-editor-styles"))
|
||||
|
||||
# Editor JS + init script
|
||||
init_js = (
|
||||
"console.log('[EDITOR-DEBUG] init script running');\n"
|
||||
"(function() {\n"
|
||||
" console.log('[EDITOR-DEBUG] IIFE entered, mountEditor=', typeof window.mountEditor);\n"
|
||||
" function applyEditorFontSize() {\n"
|
||||
" document.documentElement.style.fontSize = '62.5%';\n"
|
||||
" document.body.style.fontSize = '1.6rem';\n"
|
||||
" }\n"
|
||||
" function restoreDefaultFontSize() {\n"
|
||||
" document.documentElement.style.fontSize = '';\n"
|
||||
" document.body.style.fontSize = '';\n"
|
||||
" }\n"
|
||||
" applyEditorFontSize();\n"
|
||||
" document.body.addEventListener('htmx:beforeSwap', function cleanup(e) {\n"
|
||||
" if (e.detail.target && e.detail.target.id === 'main-panel') {\n"
|
||||
" restoreDefaultFontSize();\n"
|
||||
" document.body.removeEventListener('htmx:beforeSwap', cleanup);\n"
|
||||
" }\n"
|
||||
" });\n"
|
||||
" // Font size overrides disabled — caused global font shrinking\n"
|
||||
" // function applyEditorFontSize() {\n"
|
||||
" // document.documentElement.style.fontSize = '62.5%';\n"
|
||||
" // document.body.style.fontSize = '1.6rem';\n"
|
||||
" // }\n"
|
||||
" // applyEditorFontSize();\n"
|
||||
"\n"
|
||||
" function init() {\n"
|
||||
" var csrfToken = document.querySelector('input[name=\"csrf_token\"]').value;\n"
|
||||
@@ -1259,6 +1252,18 @@ def render_editor_panel(save_error: str | None = None, is_page: bool = False) ->
|
||||
f" snippetsUrl: '{snippets_url}',\n"
|
||||
" });\n"
|
||||
"\n"
|
||||
" if (typeof SxEditor !== 'undefined') {\n"
|
||||
" SxEditor.mount('sx-editor', {\n"
|
||||
" initialSx: window.__SX_INITIAL__ || null,\n"
|
||||
" csrfToken: csrfToken,\n"
|
||||
" uploadUrls: uploadUrls,\n"
|
||||
f" oembedUrl: '{oembed_url}',\n"
|
||||
" onChange: function(sx) {\n"
|
||||
" document.getElementById('sx-content-input').value = sx;\n"
|
||||
" }\n"
|
||||
" });\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" document.addEventListener('keydown', function(e) {\n"
|
||||
" if ((e.ctrlKey || e.metaKey) && e.key === 's') {\n"
|
||||
" e.preventDefault();\n"
|
||||
@@ -1276,7 +1281,10 @@ def render_editor_panel(save_error: str | None = None, is_page: bool = False) ->
|
||||
" }\n"
|
||||
"})();\n"
|
||||
)
|
||||
parts.append(sx_call("blog-editor-scripts", js_src=editor_js, init_js=init_js))
|
||||
parts.append(sx_call("blog-editor-scripts",
|
||||
js_src=editor_js,
|
||||
sx_editor_js_src=sx_editor_js,
|
||||
init_js=init_js))
|
||||
|
||||
return "(<> " + " ".join(parts) + ")" if parts else ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user