Changeset 0.25.3 (#163)
This commit is contained in:
@@ -1383,7 +1383,9 @@ const UI = {
|
||||
},
|
||||
closeSettings() {
|
||||
const base = window.__BASE__ || '';
|
||||
window.location.href = base + '/';
|
||||
const returnURL = sessionStorage.getItem('sb_settings_return');
|
||||
sessionStorage.removeItem('sb_settings_return');
|
||||
window.location.href = returnURL || (base + '/');
|
||||
},
|
||||
|
||||
switchSettingsTab(tab) {
|
||||
@@ -1479,15 +1481,27 @@ const UI = {
|
||||
// which only loaded on chat/settings — editor surface was skipped.
|
||||
|
||||
applyAppearance(scale, msgFont) {
|
||||
const z = scale === 100 ? '' : scale / 100;
|
||||
// Zoom content areas — covers both chat and editor surfaces
|
||||
document.querySelectorAll(
|
||||
'.sidebar, .workspace-primary, .workspace-secondary, ' +
|
||||
'.modal-overlay, .admin-panel, ' +
|
||||
'.surface-editor, .surface-notes'
|
||||
).forEach(el => el.style.zoom = z);
|
||||
const splash = document.getElementById('splashGate');
|
||||
if (splash) splash.style.zoom = z;
|
||||
// Use transform:scale() on #surface — the prototype's proven approach.
|
||||
// Transform operates on the visual layer without affecting layout flow
|
||||
// of siblings (banners stay unscaled). Inverse dimensions provide the
|
||||
// right layout space so the scaled visual output fills the viewport:
|
||||
// At 80%: width=125%, height=125% of surface → scale(0.8) → visual 100%
|
||||
// At 150%: width=66.7%, height=66.7% of surface → scale(1.5) → visual 100%
|
||||
const surface = document.getElementById('surface');
|
||||
if (surface) {
|
||||
if (scale === 100) {
|
||||
surface.style.transform = '';
|
||||
surface.style.transformOrigin = '';
|
||||
surface.style.width = '';
|
||||
surface.style.height = '';
|
||||
} else {
|
||||
const z = scale / 100;
|
||||
surface.style.transform = `scale(${z})`;
|
||||
surface.style.transformOrigin = 'top left';
|
||||
surface.style.width = (10000 / scale) + '%';
|
||||
surface.style.height = `calc(var(--surface-h) * ${10000 / scale} / 100)`;
|
||||
}
|
||||
}
|
||||
document.documentElement.style.setProperty('--msg-font', msgFont + 'px');
|
||||
localStorage.setItem('cs-appearance', JSON.stringify({ scale, msgFont }));
|
||||
// Recheck tab overflow after layout settles
|
||||
@@ -1499,6 +1513,9 @@ const UI = {
|
||||
},
|
||||
|
||||
restoreAppearance() {
|
||||
// Clear any stale zoom from previous scaling approaches
|
||||
document.body.style.zoom = '';
|
||||
document.documentElement.style.zoom = '';
|
||||
try {
|
||||
const prefs = JSON.parse(localStorage.getItem('cs-appearance') || '{}');
|
||||
const scale = prefs.scale || 100;
|
||||
|
||||
Reference in New Issue
Block a user