fix: apply state.xxx pattern and exports to regenerated modules
This commit is contained in:
+35
-35
@@ -1,5 +1,5 @@
|
||||
/* ObsiGate — Auto-extracted module */
|
||||
import { state } from './state.js';
|
||||
import { state } from './state.js';;
|
||||
// ---------------------------------------------------------------------------
|
||||
// Outline/TOC Manager
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -114,7 +114,7 @@ const OutlineManager = {
|
||||
outlineList.appendChild(item);
|
||||
});
|
||||
|
||||
headingsCache = headings;
|
||||
state.headingsCache = headings;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -144,9 +144,9 @@ const OutlineManager = {
|
||||
* Set active heading in outline
|
||||
*/
|
||||
setActiveHeading(headingId) {
|
||||
if (activeHeadingId === headingId) return;
|
||||
if (state.activeHeadingId === headingId) return;
|
||||
|
||||
activeHeadingId = headingId;
|
||||
state.activeHeadingId = headingId;
|
||||
|
||||
const items = document.querySelectorAll(".outline-item");
|
||||
items.forEach((item) => {
|
||||
@@ -178,8 +178,8 @@ const OutlineManager = {
|
||||
destroy() {
|
||||
ScrollSpyManager.destroy();
|
||||
ReadingProgressManager.destroy();
|
||||
headingsCache = [];
|
||||
activeHeadingId = null;
|
||||
state.headingsCache = [];
|
||||
state.activeHeadingId = null;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -309,10 +309,10 @@ const ReadingProgressManager = {
|
||||
// File viewer
|
||||
// ---------------------------------------------------------------------------
|
||||
async function openFile(vaultName, filePath) {
|
||||
currentVault = vaultName;
|
||||
currentPath = filePath;
|
||||
showingSource = false;
|
||||
cachedRawSource = null;
|
||||
state.currentVault = vaultName;
|
||||
state.currentPath = filePath;
|
||||
state.showingSource = false;
|
||||
state.cachedRawSource = null;
|
||||
|
||||
// Highlight active
|
||||
syncActiveFileTreeItem(vaultName, filePath);
|
||||
@@ -435,12 +435,12 @@ function renderFile(data) {
|
||||
copyBtn.addEventListener("click", async () => {
|
||||
try {
|
||||
// Fetch raw content if not already cached
|
||||
if (!cachedRawSource) {
|
||||
if (!state.cachedRawSource) {
|
||||
const rawUrl = `/api/file/${encodeURIComponent(data.vault)}/raw?path=${encodeURIComponent(data.path)}`;
|
||||
const rawData = await api(rawUrl);
|
||||
cachedRawSource = rawData.raw;
|
||||
state.cachedRawSource = rawData.raw;
|
||||
}
|
||||
await navigator.clipboard.writeText(cachedRawSource);
|
||||
await navigator.clipboard.writeText(state.cachedRawSource);
|
||||
copyBtn.lastChild.textContent = "Copié !";
|
||||
setTimeout(() => (copyBtn.lastChild.textContent = "Copier"), 1500);
|
||||
} catch (err) {
|
||||
@@ -541,15 +541,15 @@ function renderFile(data) {
|
||||
const raw = document.getElementById("file-raw-content");
|
||||
if (!rendered || !raw) return;
|
||||
|
||||
showingSource = !showingSource;
|
||||
if (showingSource) {
|
||||
state.showingSource = !state.showingSource;
|
||||
if (state.showingSource) {
|
||||
sourceBtn.classList.add("active");
|
||||
if (!cachedRawSource) {
|
||||
if (!state.cachedRawSource) {
|
||||
const rawUrl = `/api/file/${encodeURIComponent(data.vault)}/raw?path=${encodeURIComponent(data.path)}`;
|
||||
const rawData = await api(rawUrl);
|
||||
cachedRawSource = rawData.raw;
|
||||
state.cachedRawSource = rawData.raw;
|
||||
}
|
||||
raw.textContent = cachedRawSource;
|
||||
raw.textContent = state.cachedRawSource;
|
||||
rendered.style.display = "none";
|
||||
raw.style.display = "block";
|
||||
} else {
|
||||
@@ -725,7 +725,7 @@ function attachTreeItemLongPress(itemEl, getMenuData) {
|
||||
}
|
||||
|
||||
function getVaultIcon(vaultName, size = 16) {
|
||||
const v = allVaults.find((val) => val.name === vaultName);
|
||||
const v = state.allVaults.find((val) => val.name === vaultName);
|
||||
const type = v ? v.type : "VAULT";
|
||||
|
||||
if (type === "DIR") {
|
||||
@@ -948,10 +948,10 @@ function showWelcome() {
|
||||
DashboardConflictsWidget.load();
|
||||
}
|
||||
if (typeof DashboardRecentWidget !== "undefined") {
|
||||
DashboardRecentWidget.load(selectedContextVault);
|
||||
DashboardRecentWidget.load(state.selectedContextVault);
|
||||
}
|
||||
if (typeof DashboardBookmarkWidget !== "undefined") {
|
||||
DashboardBookmarkWidget.load(selectedContextVault);
|
||||
DashboardBookmarkWidget.load(state.selectedContextVault);
|
||||
}
|
||||
if (typeof DashboardSharedWidget !== "undefined") {
|
||||
DashboardSharedWidget.load();
|
||||
@@ -1002,9 +1002,9 @@ async function loadSavedSearches() {
|
||||
// Apply the saved search
|
||||
const input = document.getElementById("search-input");
|
||||
if (input) input.value = s.query;
|
||||
searchCaseSensitive = s.case_sensitive || false;
|
||||
searchWholeWord = s.whole_word || false;
|
||||
searchRegex = s.regex || false;
|
||||
state.searchCaseSensitive = s.case_sensitive || false;
|
||||
state.searchWholeWord = s.whole_word || false;
|
||||
state.searchRegex = s.regex || false;
|
||||
if (typeof _updateToggleUI === "function") _updateToggleUI();
|
||||
if (s.include_paths) {
|
||||
const incl = document.getElementById("search-include-input");
|
||||
@@ -1019,8 +1019,8 @@ async function loadSavedSearches() {
|
||||
AutocompleteDropdown._suppressNext = true;
|
||||
const vault = s.vault || "all";
|
||||
if (input) { input.dispatchEvent(new Event("input")); }
|
||||
clearTimeout(searchTimeout);
|
||||
advancedSearchOffset = 0;
|
||||
clearTimeout(state.searchTimeout);
|
||||
state.advancedSearchOffset = 0;
|
||||
performAdvancedSearch(s.query, vault, null);
|
||||
});
|
||||
});
|
||||
@@ -1059,10 +1059,10 @@ function goHome() {
|
||||
|
||||
document.querySelectorAll(".tree-item.active").forEach((el) => el.classList.remove("active"));
|
||||
|
||||
currentVault = null;
|
||||
currentPath = null;
|
||||
showingSource = false;
|
||||
cachedRawSource = null;
|
||||
state.currentVault = null;
|
||||
state.currentPath = null;
|
||||
state.showingSource = false;
|
||||
state.cachedRawSource = null;
|
||||
|
||||
closeMobileSidebar();
|
||||
showWelcome();
|
||||
@@ -1216,15 +1216,15 @@ const IndexUpdateManager = (() => {
|
||||
// Toast removed: silent auto-indexing — no notification needed
|
||||
|
||||
// Refresh sidebar and tags if affected vault matches current context
|
||||
const affectsCurrentVault = selectedContextVault === "all" || (data.vaults || []).includes(selectedContextVault);
|
||||
const affectsCurrentVault = state.selectedContextVault === "all" || (data.vaults || []).includes(state.selectedContextVault);
|
||||
if (affectsCurrentVault) {
|
||||
try {
|
||||
await Promise.all([refreshSidebarTreePreservingState(), refreshTagsForContext()]);
|
||||
// Refresh current file if it was updated
|
||||
if (currentVault && currentPath) {
|
||||
const changed = (data.changes || []).some((c) => c.vault === currentVault && c.path === currentPath);
|
||||
if (currentVault && state.currentPath) {
|
||||
const changed = (data.changes || []).some((c) => c.vault === currentVault && c.path === state.currentPath);
|
||||
if (changed) {
|
||||
openFile(currentVault, currentPath);
|
||||
openFile(state.currentVault, state.currentPath);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -1233,7 +1233,7 @@ const IndexUpdateManager = (() => {
|
||||
}
|
||||
|
||||
// Refresh recent tab if it is active
|
||||
if (activeSidebarTab === "recent") {
|
||||
if (state.activeSidebarTab === "recent") {
|
||||
const vaultFilter = document.getElementById("recent-vault-filter");
|
||||
loadRecentFiles(vaultFilter ? vaultFilter.value || null : null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user