Files
emailtemplate.it/public/editor/editor-core.php
2025-12-06 00:24:46 +01:00

87 lines
3.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
$mode = strtolower($_GET['mode'] ?? 'templates');
$id = (int)($_GET['id'] ?? 0);
$ts = time();
?><!doctype html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Editor</title>
<link rel="stylesheet" href="../vendor/grapesjs/grapes.min.css" />
<style>
html,body{height:100%}body{margin:0;background:#f8fafc;color:#0f172a}#gjs{height:100vh}
.gjs-one-bg{background-color:#fff!important}.gjs-two-color{color:#0f172a!important}
.gjs-three-bg{background-color:#f8fafc!important}.gjs-four-color{color:#334155!important}
#badge{position:fixed;right:8px;top:8px;background:#eef2ff;color:#1e3a8a;border:1px solid #c7d2fe;border-radius:999px;padding:4px 10px;font:12px system-ui;z-index:2147483647;opacity:.9}
</style>
</head>
<body>
<div id="badge">lädt …</div>
<div id="gjs"></div>
<div id="blocks"></div>
<script>
window.__editorMode = "<?=htmlspecialchars($mode, ENT_QUOTES)?>";
window.__editorId = <?= $id ?>;
window.BridgeParts = window.BridgeParts || {};
window.BridgeParts.CURRENT_ENTITY_ID = window.BridgeParts.CURRENT_ENTITY_ID || <?= $id ?>;
window.BridgeParts.API_KERNEL_URL = window.BridgeParts.API_KERNEL_URL || '/api.php';
window.BridgeParts.API_BASE = window.BridgeParts.API_BASE || window.BridgeParts.API_KERNEL_URL;
window.BridgeParts.STORAGE_URL_BASE = window.BridgeParts.STORAGE_URL_BASE || window.BridgeParts.API_BASE;
function logToParent(type, detail){ try{ parent.postMessage({source:'editor-core',type:type,detail:String(detail||'')},'*'); }catch(e){} }
window.addEventListener('error', function(e){
var b=document.getElementById('badge');
if(b){ b.textContent='Fehler: '+(e&&e.message?e.message:'unbekannt'); b.style.background='#fee2e2'; b.style.color='#7f1d1d'; b.style.borderColor='#fecaca'; }
logToParent('window-error', e && e.message ? e.message : 'unknown');
});
function loadLocalScript(src, onok){
// Hinzufügen des Cache-Bust-Parameters zur URL
// Die Variable $ts wird durch PHP im HTML-Kontext eingefügt
const url = src + (src.indexOf('?') === -1 ? '?v=' : '&v=') + <?=$ts?>;
var s=document.createElement('script'); s.src=url; s.async=false;
s.onload=function(){ logToParent('script-ok', src); onok&&onok(); };
s.onerror=function(){ var b=document.getElementById('badge'); if(b){ b.textContent='Fehlt: '+src; b.style.background='#fee2e2'; b.style.color='#7f1d1d'; b.style.borderColor='#fecaca'; } logToParent('script-missing', src); };
document.head.appendChild(s);
}
logToParent('boot','start');
// 1) GrapesJS laden
loadLocalScript('../vendor/grapesjs/grapes.min.js', function(){
if(typeof window.grapesjs==='undefined'){
document.getElementById('badge').textContent='grapesjs nicht verfügbar';
logToParent('gjs-missing','window.grapesjs undefined');
return;
}
// 2.A) KRITISCHE HELPER ZUERST LADEN (Category Config)
loadLocalScript('../assets/js/bridge/category-config.js', function() {
// 2.B) Dann die zentrale Log-Funktion
// Diese muss geladen sein, bevor bridge-core.js startet!
loadLocalScript('../assets/js/bridge/general-functions.js', function() {
// 3) Plugin laden (GrapesJS Preset Newsletter)
loadLocalScript('../vendor/grapesjs-preset-newsletter/grapesjs-preset-newsletter.min.js', function(){
// 4) BRIDGE-CORE laden jetzt kann es B.LOG_CONFIG auf false setzen!
loadLocalScript('bridge-core.js', function(){
// 5) Danach config.js (Bibliothek)
// loadLocalScript('config.js');
});
// Heartbeat vom Core (sichtbar im Hauptfenster)
var hb=0, timer=setInterval(function(){ hb++; if(hb>60){clearInterval(timer);return;} logToParent('hb','tick '+hb); }, 200);
});
});
});
});
</script>
</body>
</html>