Files
emailtemplate.it/public/editor/editor-core.php
2026-01-15 02:36:36 +01:00

122 lines
5.7 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);
$assetVersion = defined('ASSET_VERSION') ? ASSET_VERSION : time();
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
$appBaseUrl = rtrim($GLOBALS['app_base_url'] ?? ($scheme . '://' . $host), '/');
$fontDir = __DIR__ . '/../assets/fonts';
$fontBase = $appBaseUrl . '/assets/fonts';
$customFontName = 'Kids Handwriting';
$customFontFiles = [
'woff2' => 'KidsHandwriting-Regular.woff2',
'woff' => 'KidsHandwriting-Regular.woff',
'ttf' => 'KidsHandwriting-Regular.ttf',
];
$fontSources = [];
foreach ($customFontFiles as $format => $file) {
if (is_file($fontDir . '/' . $file)) {
$fontSources[] = "url('" . htmlspecialchars($fontBase . '/' . $file, ENT_QUOTES) . "') format('{$format}')";
}
}
$fontFaceCss = '';
if ($fontSources) {
$fontFaceCss = "@font-face{font-family:'{$customFontName}';font-style:normal;font-weight:400;src:" . implode(',', $fontSources) . ";}";
}
?><!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;overflow:auto;}#gjs{min-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}
<?= $fontFaceCss ?>
</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;
window.BridgeParts.DISABLE_PLACEHOLDERS = true;
window.BridgeParts.RTE_FONTS = window.BridgeParts.RTE_FONTS || [
{ label: 'Kids Handwriting', value: "'Kids Handwriting', 'Comic Sans MS', cursive" },
{ label: 'Arial', value: 'Arial, sans-serif' },
{ label: 'Calibri', value: 'Calibri, sans-serif' },
{ label: 'Cambria', value: 'Cambria, serif' },
{ label: 'Georgia', value: 'Georgia, serif' },
{ label: 'Tahoma', value: 'Tahoma, sans-serif' },
{ label: 'Times New Roman', value: 'Times New Roman, serif' },
{ label: 'Trebuchet MS', value: 'Trebuchet MS, sans-serif' },
{ label: 'Verdana', value: 'Verdana, sans-serif' },
];
window.BridgeParts.RTE_FONT_FACE_CSS = window.BridgeParts.RTE_FONT_FACE_CSS || <?= json_encode($fontFaceCss) ?>;
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=') + <?= json_encode($assetVersion) ?>;
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>