/** * Editor Index (Simplified Universal Version) * ------------------------------------------- * - Loads the active file from localStorage * - Parses markers or auto-splits into blocks * - No Ace, overlay, or navigation dependencies * - Works directly with block_editor.js */ (function () { 'use strict'; console.log("[editor_index.js] Loading simplified index module..."); const ACTIVE_FILES_KEY = "sftp_active_files"; // ========================================================================= // LOCALSTORAGE HELPERS // ========================================================================= function getActiveFileContent() { try { const files = JSON.parse(localStorage.getItem(ACTIVE_FILES_KEY) || "[]"); const active = files.find(f => f.active); return { content: active?.content || "", name: active?.name || "Untitled", path: active?.path || "" }; } catch (err) { console.error("[editor_index.js] Failed to load file:", err); return { content: "", name: "Untitled", path: "" }; } } function getLines() { const { content } = getActiveFileContent(); return content.split("\n"); } function getLine(index) { const lines = getLines(); return lines[index] || ""; } function getLineCount() { return getLines().length; } // ========================================================================= // MARKER & LANGUAGE HELPERS // ========================================================================= function parseMarkerName(name) { const cleaned = name.replace(/[\[\]]/g, "").trim(); const parts = cleaned.split("_"); if (parts.length === 1) return { component: parts[0], language: null, number: null, fullName: cleaned }; if (parts.length === 2) return { component: parts[0], language: parts[1], number: null, fullName: cleaned }; const num = parseInt(parts[2]); return { component: parts[0], language: parts[1], number: isNaN(num) ? null : num, fullName: cleaned }; } function findMarkerEnd(startRow, markerName) { const lineCount = getLineCount(); for (let row = startRow + 1; row < lineCount; row++) { const line = getLine(row).trim(); if (line.includes(">")) { const m = line.match(/(?: