From 988f99f58bc222330d517b116f0625d79f0d1abc Mon Sep 17 00:00:00 2001 From: Joakim Date: Wed, 17 Sep 2025 17:08:35 +0200 Subject: [PATCH] fix: Hide control panel from regular visitors - Move control panel initialization from start() to startEditor() - Ensure UI only appears after successful gate activation - Regular visitors now see zero indication of insertr presence - Maintains 'invisible CMS' principle for end users User Experience: - Before gate: Website appears completely normal - After gate: Control panel slides in for authenticated editors - Gates remain the only trigger mechanism for editors --- lib/src/index.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/src/index.js b/lib/src/index.js index 484ac65..b094202 100644 --- a/lib/src/index.js +++ b/lib/src/index.js @@ -78,21 +78,24 @@ window.Insertr = { document.head.appendChild(link); }, - // Start the system - initializes auth gates and UI + // Start the system - only creates invisible editor gates start() { if (this.auth) { - this.auth.init(); // Sets up editor gates + this.auth.init(); // Sets up invisible editor gates only } - if (this.controlPanel) { + // Note: Control panel is NOT created here - only after gate activation + // Note: Editor is NOT started here - only when authentication succeeds + }, + + // Start the full editor system (called when gate is activated) + startEditor() { + // Initialize control panel UI (first time only) + if (this.controlPanel && !this.controlPanel.isInitialized) { this.controlPanel.init(); // Creates unified control panel UI } - // Note: Editor is NOT started here, only when authentication succeeds - }, - - // Start the full editor system (called when trigger is activated) - startEditor() { + // Start editor functionality if (this.editor && !this.editor.isActive) { this.editor.start(); } @@ -139,7 +142,8 @@ function autoInitialize() { if (insertrScript) { config.siteId = insertrScript.getAttribute('data-site-id'); // No fallback - let ApiClient handle missing values config.apiEndpoint = insertrScript.getAttribute('data-api-endpoint') || '/api/content'; - config.mockAuth = insertrScript.getAttribute('data-mock-auth') === 'true'; + config.authProvider = insertrScript.getAttribute('data-auth-provider') || 'mock'; + config.mockAuth = config.authProvider === 'mock'; // Set mockAuth based on provider config.debug = insertrScript.getAttribute('data-debug') === 'true'; }