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'; }