Files
emailtemplate.it/public/assets/js/bridge/category-config.js
2025-12-10 21:40:26 +01:00

63 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* /assets/js/bridge/category-config.js (FINALE KORREKTUR DER BLAUPASE) */
(function(B) {
    if (!B) return;
// NEU: Map, die Ressourcentyp ('kind') zu API-Basis-URL zuordnet. Wird von library-api.js gelesen.
B.RESOURCE_API_BASES = B.RESOURCE_API_BASES || {};
const API_BASE_DEFAULT = (B.API_BASE || '/api/editor');
    // DEFINITION DER ZIEL-KATEGORIEN
    B.CATEGORY_CONFIG = {
        // --- 1. BIBLIOTHEK (mysnips) ---
        mysnips: {
            // ... (Bleibt unverändert, da es kein API-Async-Laden nutzt)
            ord: 20, 
            open: false,
            label: '📚 Bibliothek',
            files: ['blocks-standard.js'],
registration_mode: 'sync',
        },
placeholders: {
ord: 5,
open: true,
label: '🔖 Placeholder',
files: ['blocks-placeholder.js'],
registration_mode: 'sync',
},
        // --- 2. BAUSTEINE (bausteine) ---
        bausteine: {
            // ... (Bleibt unverändert, da es kein API-Async-Laden nutzt)
            ord: 10,
            open: true,
            label: '🧱 Bausteine',
            files: ['blocks-custom.js'],
            registration_mode: 'sync',
        },
        // --- 3. API Custom-Blocks (Standard-API) ----
        custom: {
            ord: 1,
            label: 'Custom',
            open: true,
            files: ['library-api.js','blocks-api.js'],
            registration_mode: 'async',
// NEU: API-Konfiguration für diese Kategorie
api_config: {
base_url: '/api/editor', // Nutzt die Standard-API
resources: ['sections', 'blocks', 'snippets'] // Ressourcen, die von dort geladen werden
}
}
    };
// --- Initialisierung der zentralen RESOURCE_API_BASES Map ---
// Diese Logik stellt sicher, dass library-api.js weiß, welchen Endpunkt es für welchen "kind" nutzen muss.
Object.values(B.CATEGORY_CONFIG).forEach(config => {
if (config.api_config && Array.isArray(config.api_config.resources)) {
const baseUrl = config.api_config.base_url || API_BASE_DEFAULT;
config.api_config.resources.forEach(resourceKind => {
B.RESOURCE_API_BASES[resourceKind] = baseUrl;
});
}
});
    
})(window.BridgeParts || (window.BridgeParts = {}));