Download src/renderer/js/presentation-config.js from chahuadev/chahuadev-markdown-presenter: direct link, hf CLI and curl.
- Browser
- Download file 82.1 kB
-
https://huggingface.co/datasets/chahuadev/chahuadev-markdown-presenter/resolve/main/src/renderer/js/presentation-config.js
- Command line
-
hf download hf://datasets/chahuadev/chahuadev-markdown-presenter/src/renderer/js/presentation-config.js
-
curl -L -o presentation-config.js https://huggingface.co/datasets/chahuadev/chahuadev-markdown-presenter/resolve/main/src/renderer/js/presentation-config.js
82.1 kB
| // ══════════════════════════════════════════════════════════════════════════════ | |
| // Chahua Video Builder - Presentation Configuration System | |
| // Flexible Configuration Instead of Fixed Templates | |
| // ══════════════════════════════════════════════════════════════════════════════ | |
| // Company: Chahua Development Co., Ltd. | |
| // Version: 2.0.0 | |
| // License: MIT | |
| // ══════════════════════════════════════════════════════════════════════════════ | |
| import { ConfigStorage } from './config-storage.js'; | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // DISPLAY MODE DETECTION (ตรวจสอบโหมดการแสดงผลปัจจุบัน) | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| let currentDisplayMode = 'intro'; // 'intro', 'editor', 'presentation' | |
| /** | |
| * Set current display mode | |
| * @param {string} mode - 'intro' | 'editor' | 'presentation' | |
| */ | |
| export function setDisplayMode(mode) { | |
| const validModes = ['intro', 'editor', 'presentation']; | |
| if (!validModes.includes(mode)) { | |
| console.warn(`[PresentationConfig] Invalid mode: ${mode}, using 'intro'`); | |
| mode = 'intro'; | |
| } | |
| currentDisplayMode = mode; | |
| console.log(`[PresentationConfig] Display mode set to: ${mode}`); | |
| // Trigger event for other systems to respond | |
| window.dispatchEvent(new CustomEvent('displayModeChanged', { | |
| detail: { mode } | |
| })); | |
| } | |
| /** | |
| * Get current display mode | |
| * @returns {string} | |
| */ | |
| export function getDisplayMode() { | |
| return currentDisplayMode; | |
| } | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // Safe Zone Configuration (แยกตามโหมดการแสดงผล 3 ชุด) | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| /** | |
| * INTRO MODE - Safe Zone for intro scene (hard-coded values) | |
| * ใช้สำหรับหน้า Intro เท่านั้น ค่าคงที่ | |
| */ | |
| export const INTRO_SAFE_ZONE_CONFIG = { | |
| margins: { | |
| horizontalRatio: 0.08, // 8% ของความกว้าง (กว้างกว่าโหมดอื่น) | |
| verticalRatio: 0.10, // 10% ของความสูง (สูงกว่าโหมดอื่น) | |
| maxHorizontalRatio: 0.15, | |
| maxVerticalRatio: 0.18, | |
| minHorizontal: 60, // ขั้นต่ำสูงกว่า | |
| minVertical: 60 | |
| }, | |
| border: { | |
| enabled: false, // ไม่แสดงกรอบใน Intro | |
| color: 'rgba(100, 116, 139, 0.3)', | |
| width: 1, | |
| glowColor: 'rgba(100, 116, 139, 0.2)', | |
| glowSize: '2px', | |
| zIndex: 1000 | |
| }, | |
| enforcement: { | |
| enabled: false, // ไม่บังคับใน Intro | |
| snapToEdge: false, | |
| showWarning: false | |
| } | |
| }; | |
| /** | |
| * EDITOR MODE - Safe Zone for edit/drag mode (strict enforcement) | |
| * ใช้สำหรับโหมดแก้ไข/ลาก มีกรอบสีแดงบังคับ | |
| */ | |
| export const EDITOR_SAFE_ZONE_CONFIG = { | |
| margins: { | |
| horizontalRatio: 0.06, // 6% ของความกว้าง | |
| verticalRatio: 0.08, // 8% ของความสูง | |
| maxHorizontalRatio: 0.12, | |
| maxVerticalRatio: 0.15, | |
| minHorizontal: 40, | |
| minVertical: 40 | |
| }, | |
| border: { | |
| enabled: true, // แสดงกรอบสีแดง | |
| color: 'rgba(239, 68, 68, 0.8)', | |
| width: 2, // หนากว่าโหมดอื่น | |
| glowColor: 'rgba(239, 68, 68, 0.5)', | |
| glowSize: '6px', | |
| zIndex: 9999 // อยู่บนสุด | |
| }, | |
| enforcement: { | |
| enabled: true, // บังคับไม่ให้ลากออก | |
| snapToEdge: true, | |
| showWarning: true | |
| } | |
| }; | |
| /** | |
| * PRESENTATION MODE - Safe Zone for presentation (visual guide only) | |
| * ใช้สำหรับโหมดนำเสนอ แสดงกรอบบางๆ เป็นแนวทาง | |
| */ | |
| export const PRESENTATION_SAFE_ZONE_CONFIG = { | |
| margins: { | |
| horizontalRatio: 0.05, // 5% ของความกว้าง (น้อยที่สุด) | |
| verticalRatio: 0.07, // 7% ของความสูง | |
| maxHorizontalRatio: 0.10, | |
| maxVerticalRatio: 0.12, | |
| minHorizontal: 30, | |
| minVertical: 30 | |
| }, | |
| border: { | |
| enabled: false, // ไม่แสดงกรอบในการนำเสนอปกติ | |
| color: 'rgba(100, 116, 139, 0.2)', | |
| width: 1, | |
| glowColor: 'rgba(100, 116, 139, 0.1)', | |
| glowSize: '2px', | |
| zIndex: 100 | |
| }, | |
| enforcement: { | |
| enabled: false, // ไม่บังคับ | |
| snapToEdge: false, | |
| showWarning: false | |
| } | |
| }; | |
| /** | |
| * Get Safe Zone Config based on current display mode | |
| * @returns {Object} Safe Zone configuration for current mode | |
| */ | |
| export function getSafeZoneConfig() { | |
| switch (currentDisplayMode) { | |
| case 'intro': | |
| return { ...INTRO_SAFE_ZONE_CONFIG }; | |
| case 'editor': | |
| return { ...EDITOR_SAFE_ZONE_CONFIG }; | |
| case 'presentation': | |
| return { ...PRESENTATION_SAFE_ZONE_CONFIG }; | |
| default: | |
| console.warn(`[PresentationConfig] Unknown mode: ${currentDisplayMode}, using editor config`); | |
| return { ...EDITOR_SAFE_ZONE_CONFIG }; | |
| } | |
| } | |
| /** | |
| * Legacy export for backward compatibility | |
| * WARNING: This will return config based on current mode | |
| */ | |
| export const SAFE_ZONE_CONFIG = new Proxy({}, { | |
| get(target, prop) { | |
| return getSafeZoneConfig()[prop]; | |
| } | |
| }); | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // Smart Layout Configuration (การจัดเรียงเนื้อหาอัตโนมัติ) | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| export const SMART_LAYOUT_CONFIG = { | |
| fillRatio: 0.92, // ใช้ 92% ของพื้นที่ใช้งาน | |
| stageFallback: { // ขนาดหน้าจอสำรอง | |
| width: 1280, | |
| height: 720 | |
| }, | |
| autoScale: true, // ปรับขนาดเนื้อหาอัตโนมัติ | |
| maintainAspectRatio: true, // รักษาสัดส่วน | |
| centerContent: true // จัดกึ่งกลาง | |
| }; | |
| /** | |
| * Get Smart Layout fill ratio | |
| */ | |
| export function getSmartLayoutFillRatio() { | |
| return SMART_LAYOUT_CONFIG.fillRatio; | |
| } | |
| /** | |
| * Get Smart Layout stage fallback dimensions | |
| */ | |
| export function getSmartLayoutStageFallback() { | |
| return { ...SMART_LAYOUT_CONFIG.stageFallback }; | |
| } | |
| /** | |
| * Update Smart Layout configuration | |
| */ | |
| export function updateSmartLayoutConfig(newConfig) { | |
| Object.assign(SMART_LAYOUT_CONFIG, newConfig); | |
| window.dispatchEvent(new CustomEvent('smartLayoutConfigUpdated', { | |
| detail: SMART_LAYOUT_CONFIG | |
| })); | |
| return SMART_LAYOUT_CONFIG; | |
| } | |
| /** | |
| * Get current Smart Layout configuration | |
| */ | |
| export function getSmartLayoutConfig() { | |
| return { ...SMART_LAYOUT_CONFIG }; | |
| } | |
| /** | |
| * Get Safe Zone margins (คำนวณ margins ตามขนาดหน้าจอและโหมดปัจจุบัน) | |
| * @param {Object} stageRect - ขนาดและตำแหน่งของ stage | |
| * @returns {Object} - { left, right, top, bottom } | |
| */ | |
| export function computeSafeZoneMargins(stageRect = {}) { | |
| const width = stageRect.width || window.innerWidth; | |
| const height = stageRect.height || window.innerHeight; | |
| // ใช้ config ตามโหมดปัจจุบัน | |
| const safeZoneConfig = getSafeZoneConfig(); | |
| const config = safeZoneConfig.margins; | |
| // คำนวณตามสัดส่วน | |
| const horizontalBase = width * config.horizontalRatio; | |
| const verticalBase = height * config.verticalRatio; | |
| // จำกัดค่าให้อยู่ในช่วงที่กำหนด | |
| const left = Math.max( | |
| config.minHorizontal, | |
| Math.min(horizontalBase, width * config.maxHorizontalRatio) | |
| ); | |
| const right = left; | |
| const top = Math.max( | |
| config.minVertical, | |
| Math.min(verticalBase, height * config.maxVerticalRatio) | |
| ); | |
| const bottom = top; | |
| console.log(`[PresentationConfig] Safe Zone margins for ${currentDisplayMode} mode:`, { | |
| width, height, left, right, top, bottom | |
| }); | |
| return { left, right, top, bottom }; | |
| } | |
| /** | |
| * Update Safe Zone configuration | |
| * @param {Object} newConfig - ค่าการตั้งค่าใหม่ | |
| */ | |
| export function updateSafeZoneConfig(newConfig) { | |
| if (newConfig.margins) { | |
| Object.assign(SAFE_ZONE_CONFIG.margins, newConfig.margins); | |
| } | |
| if (newConfig.border) { | |
| Object.assign(SAFE_ZONE_CONFIG.border, newConfig.border); | |
| } | |
| if (newConfig.enforcement) { | |
| Object.assign(SAFE_ZONE_CONFIG.enforcement, newConfig.enforcement); | |
| } | |
| // Dispatch event เพื่อแจ้ง components อื่นๆ | |
| window.dispatchEvent(new CustomEvent('safeZoneConfigUpdated', { | |
| detail: SAFE_ZONE_CONFIG | |
| })); | |
| return SAFE_ZONE_CONFIG; | |
| } | |
| /** | |
| * Reset Safe Zone configuration to defaults for all modes | |
| */ | |
| export function resetSafeZoneConfig() { | |
| // Reset Intro Mode | |
| INTRO_SAFE_ZONE_CONFIG.margins = { | |
| horizontalRatio: 0.08, | |
| verticalRatio: 0.10, | |
| maxHorizontalRatio: 0.15, | |
| maxVerticalRatio: 0.18, | |
| minHorizontal: 60, | |
| minVertical: 60 | |
| }; | |
| INTRO_SAFE_ZONE_CONFIG.border = { | |
| enabled: false, | |
| color: 'rgba(100, 116, 139, 0.3)', | |
| width: 1, | |
| glowColor: 'rgba(100, 116, 139, 0.2)', | |
| glowSize: '2px', | |
| zIndex: 1000 | |
| }; | |
| INTRO_SAFE_ZONE_CONFIG.enforcement = { | |
| enabled: false, | |
| snapToEdge: false, | |
| showWarning: false | |
| }; | |
| // Reset Editor Mode | |
| EDITOR_SAFE_ZONE_CONFIG.margins = { | |
| horizontalRatio: 0.06, | |
| verticalRatio: 0.08, | |
| maxHorizontalRatio: 0.12, | |
| maxVerticalRatio: 0.15, | |
| minHorizontal: 40, | |
| minVertical: 40 | |
| }; | |
| EDITOR_SAFE_ZONE_CONFIG.border = { | |
| enabled: true, | |
| color: 'rgba(239, 68, 68, 0.8)', | |
| width: 2, | |
| glowColor: 'rgba(239, 68, 68, 0.5)', | |
| glowSize: '6px', | |
| zIndex: 9999 | |
| }; | |
| EDITOR_SAFE_ZONE_CONFIG.enforcement = { | |
| enabled: true, | |
| snapToEdge: true, | |
| showWarning: true | |
| }; | |
| // Reset Presentation Mode | |
| PRESENTATION_SAFE_ZONE_CONFIG.margins = { | |
| horizontalRatio: 0.05, | |
| verticalRatio: 0.07, | |
| maxHorizontalRatio: 0.10, | |
| maxVerticalRatio: 0.12, | |
| minHorizontal: 30, | |
| minVertical: 30 | |
| }; | |
| PRESENTATION_SAFE_ZONE_CONFIG.border = { | |
| enabled: false, | |
| color: 'rgba(100, 116, 139, 0.2)', | |
| width: 1, | |
| glowColor: 'rgba(100, 116, 139, 0.1)', | |
| glowSize: '2px', | |
| zIndex: 100 | |
| }; | |
| PRESENTATION_SAFE_ZONE_CONFIG.enforcement = { | |
| enabled: false, | |
| snapToEdge: false, | |
| showWarning: false | |
| }; | |
| window.dispatchEvent(new CustomEvent('safeZoneConfigUpdated', { | |
| detail: getSafeZoneConfig() | |
| })); | |
| return getSafeZoneConfig(); | |
| } | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // Configuration Presets (Default Configuration Examples) | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| export const CONFIG_PRESETS = { | |
| default: { | |
| name: 'Default', | |
| description: 'Standard default settings', | |
| config: { | |
| fonts: { | |
| heading: "'Inter', 'Segoe UI', sans-serif", | |
| body: "'Inter', 'Segoe UI', sans-serif", | |
| code: "'Source Code Pro', 'Consolas', monospace" | |
| }, | |
| fontSizes: { | |
| h1: { min: 1.75, base: 4.5, max: 3 }, // clamp(1.75rem, 4.5vw, 3rem) | |
| h2: { min: 1.5, base: 3.5, max: 2.5 }, | |
| h3: { min: 1.25, base: 2.8, max: 1.9 }, | |
| text: { min: 1.1, base: 1.8, max: 1.6 }, | |
| code: { min: 0.95, base: 1.5, max: 1.3 } | |
| }, | |
| colors: { | |
| primary: '#60a5fa', | |
| secondary: '#a855f7', | |
| background: '#0a1628', | |
| surface: '#132337', | |
| text: '#e2e8f0', | |
| textSecondary: '#94a3b8', | |
| accent: '#06b6d4', | |
| codeBackground: '#1e293b', | |
| codeBorder: '#334155' | |
| }, | |
| background: { | |
| type: 'solid', // 'solid', 'gradient', 'image' | |
| value: '#0a1628', | |
| gradient: null, | |
| image: null, | |
| opacity: 1 | |
| }, | |
| animations: { | |
| enabled: true, | |
| duration: 0.6, | |
| easing: 'cubic-bezier(0.4, 0, 0.2, 1)', | |
| slideTransition: 'fade', // 'fade', 'slide', 'none' | |
| }, | |
| styles: { | |
| borderRadius: '1.25rem', | |
| shadow: '0 20px 40px rgba(0, 0, 0, 0.3)', | |
| lineHeight: { | |
| heading: 1.3, | |
| body: 1.7 | |
| }, | |
| // UI Elements | |
| previewOpacity: 0.68, | |
| overlayBackground: 'rgba(10, 22, 40, 0.85)', | |
| overlayBlur: '8px', | |
| navBorderWidth: '2px', | |
| navBorderOpacity: 0.5, | |
| // Borders & Accents | |
| headingAccentBorderWidth: '4px', | |
| blockquoteBorderWidth: '4px', | |
| imageBorderWidth: '2px', | |
| linkUnderlineWidth: '2px', | |
| tableBorderWidth: '1px', | |
| hrBorderWidth: '2px', | |
| // Effects | |
| backdropGradientColor: 'rgba(59, 130, 246, 0.15)', | |
| backdropGradientSpread: '70%', | |
| backdropBlur: '60px', | |
| // Page Indicator | |
| pageIndicatorTop: '16px', | |
| pageIndicatorRight: '16px', | |
| pageIndicatorFontSize: '0.875rem', // text-sm | |
| pageIndicatorOpacity: 0.7, | |
| pageIndicatorPaddingX: '12px', // px-3 | |
| pageIndicatorPaddingY: '4px', // py-1 | |
| pageIndicatorBgColor: 'rgba(22, 78, 99, 0.5)', // bg-cyan-900/50 | |
| pageIndicatorTextColor: '#a5f3fc' // text-cyan-200 | |
| }, | |
| typography: { | |
| paragraphSpacing: { | |
| before: 0.5, // rem | |
| after: 1 // rem | |
| }, | |
| headingSpacing: { | |
| before: 1.5, // rem | |
| after: 0.75 // rem | |
| }, | |
| indentation: { | |
| firstLine: 0, // rem | |
| hanging: 0, // rem | |
| blockQuote: 1.5 // rem | |
| }, | |
| listIndent: 1.5, // rem | |
| textAlign: 'left' // 'left', 'center', 'right', 'justify' | |
| }, | |
| layout: { | |
| contentPadding: { | |
| small: 40, // px - for small screens | |
| large: 48, // px - for large screens | |
| ultra: 64 // px - for ultra-wide screens | |
| }, | |
| contentAlignment: { | |
| horizontal: 'center', // 'flex-start', 'center', 'flex-end' | |
| vertical: 'center' // 'flex-start', 'center', 'flex-end' | |
| } | |
| }, | |
| smartList: { | |
| twoColumnThreshold: 6, // items threshold for 2-column layout | |
| threeColumnThreshold: 12 // items threshold for 3-column layout | |
| } | |
| } | |
| }, | |
| professional: { | |
| name: 'Professional', | |
| description: 'For business presentations', | |
| config: { | |
| fonts: { | |
| heading: "'Montserrat', 'Arial', sans-serif", | |
| body: "'Lato', 'Helvetica', sans-serif", | |
| code: "'Fira Code', monospace" | |
| }, | |
| fontSizes: { | |
| h1: { min: 2, base: 5, max: 3.5 }, | |
| h2: { min: 1.6, base: 4, max: 2.8 }, | |
| h3: { min: 1.3, base: 3, max: 2.1 }, | |
| text: { min: 1.2, base: 2, max: 1.8 }, | |
| code: { min: 1, base: 1.6, max: 1.4 } | |
| }, | |
| colors: { | |
| primary: '#3b82f6', | |
| secondary: '#8b5cf6', | |
| background: '#0f172a', | |
| surface: '#1e293b', | |
| text: '#f1f5f9', | |
| textSecondary: '#cbd5e1', | |
| accent: '#0ea5e9', | |
| codeBackground: '#1e293b', | |
| codeBorder: '#475569' | |
| }, | |
| background: { | |
| type: 'gradient', | |
| value: null, | |
| gradient: 'linear-gradient(135deg, #0f172a 0%, #1e293b 100%)', | |
| image: null, | |
| opacity: 1 | |
| }, | |
| animations: { | |
| enabled: true, | |
| duration: 0.7, | |
| easing: 'cubic-bezier(0.25, 0.1, 0.25, 1)', | |
| slideTransition: 'slide' | |
| }, | |
| styles: { | |
| borderRadius: '0.75rem', | |
| shadow: '0 25px 50px rgba(0, 0, 0, 0.5)', | |
| lineHeight: { | |
| heading: 1.4, | |
| body: 1.8 | |
| }, | |
| // UI Elements | |
| previewOpacity: 0.68, | |
| overlayBackground: 'rgba(15, 23, 42, 0.9)', | |
| overlayBlur: '10px', | |
| navBorderWidth: '2px', | |
| navBorderOpacity: 0.6, | |
| // Borders & Accents | |
| headingAccentBorderWidth: '4px', | |
| blockquoteBorderWidth: '4px', | |
| imageBorderWidth: '2px', | |
| linkUnderlineWidth: '2px', | |
| tableBorderWidth: '1px', | |
| hrBorderWidth: '2px', | |
| // Effects | |
| backdropGradientColor: 'rgba(59, 130, 246, 0.2)', | |
| backdropGradientSpread: '65%', | |
| backdropBlur: '80px', | |
| // Page Indicator | |
| pageIndicatorTop: '16px', | |
| pageIndicatorRight: '16px', | |
| pageIndicatorFontSize: '0.875rem', | |
| pageIndicatorOpacity: 0.7, | |
| pageIndicatorPaddingX: '12px', | |
| pageIndicatorPaddingY: '4px', | |
| pageIndicatorBgColor: 'rgba(30, 41, 59, 0.6)', | |
| pageIndicatorTextColor: '#cbd5e1' | |
| }, | |
| typography: { | |
| paragraphSpacing: { | |
| before: 0.75, | |
| after: 1.25 | |
| }, | |
| headingSpacing: { | |
| before: 2, | |
| after: 1 | |
| }, | |
| indentation: { | |
| firstLine: 0, | |
| hanging: 0, | |
| blockQuote: 2 | |
| }, | |
| listIndent: 2, | |
| textAlign: 'left' | |
| }, | |
| layout: { | |
| contentPadding: { | |
| small: 48, | |
| large: 56, | |
| ultra: 72 | |
| }, | |
| contentAlignment: { | |
| horizontal: 'flex-start', | |
| vertical: 'flex-start' | |
| } | |
| }, | |
| smartList: { | |
| twoColumnThreshold: 6, | |
| threeColumnThreshold: 12 | |
| } | |
| } | |
| }, | |
| minimal: { | |
| name: 'Minimal', | |
| description: 'Simple and clear design', | |
| config: { | |
| fonts: { | |
| heading: "'Helvetica Neue', 'Arial', sans-serif", | |
| body: "'Helvetica Neue', 'Arial', sans-serif", | |
| code: "'SF Mono', 'Monaco', monospace" | |
| }, | |
| fontSizes: { | |
| h1: { min: 1.5, base: 4, max: 2.5 }, | |
| h2: { min: 1.3, base: 3, max: 2 }, | |
| h3: { min: 1.15, base: 2.5, max: 1.7 }, | |
| text: { min: 1, base: 1.6, max: 1.4 }, | |
| code: { min: 0.9, base: 1.4, max: 1.2 } | |
| }, | |
| colors: { | |
| primary: '#000000', | |
| secondary: '#333333', | |
| background: '#ffffff', | |
| surface: '#f8f9fa', | |
| text: '#000000', | |
| textSecondary: '#666666', | |
| accent: '#0066cc', | |
| codeBackground: '#f5f5f5', | |
| codeBorder: '#e0e0e0' | |
| }, | |
| background: { | |
| type: 'solid', | |
| value: '#ffffff', | |
| gradient: null, | |
| image: null, | |
| opacity: 1 | |
| }, | |
| animations: { | |
| enabled: true, | |
| duration: 0.3, | |
| easing: 'ease-out', | |
| slideTransition: 'fade' | |
| }, | |
| styles: { | |
| borderRadius: '0', | |
| shadow: 'none', | |
| lineHeight: { | |
| heading: 1.2, | |
| body: 1.6 | |
| }, | |
| // UI Elements | |
| previewOpacity: 0.68, | |
| overlayBackground: 'rgba(255, 255, 255, 0.85)', | |
| overlayBlur: '6px', | |
| navBorderWidth: '1px', | |
| navBorderOpacity: 0.3, | |
| // Borders & Accents | |
| headingAccentBorderWidth: '2px', | |
| blockquoteBorderWidth: '3px', | |
| imageBorderWidth: '1px', | |
| linkUnderlineWidth: '1px', | |
| tableBorderWidth: '1px', | |
| hrBorderWidth: '1px', | |
| // Effects | |
| backdropGradientColor: 'rgba(0, 102, 204, 0.05)', | |
| backdropGradientSpread: '50%', | |
| backdropBlur: '20px', | |
| // Page Indicator | |
| pageIndicatorTop: '12px', | |
| pageIndicatorRight: '12px', | |
| pageIndicatorFontSize: '0.75rem', | |
| pageIndicatorOpacity: 0.6, | |
| pageIndicatorPaddingX: '8px', | |
| pageIndicatorPaddingY: '4px', | |
| pageIndicatorBgColor: 'rgba(0, 0, 0, 0.1)', | |
| pageIndicatorTextColor: '#666666' | |
| }, | |
| typography: { | |
| paragraphSpacing: { | |
| before: 0.25, | |
| after: 0.75 | |
| }, | |
| headingSpacing: { | |
| before: 1.25, | |
| after: 0.5 | |
| }, | |
| indentation: { | |
| firstLine: 0, | |
| hanging: 0, | |
| blockQuote: 1 | |
| }, | |
| listIndent: 1.25, | |
| textAlign: 'left' | |
| }, | |
| layout: { | |
| contentPadding: { | |
| small: 32, | |
| large: 40, | |
| ultra: 52 | |
| }, | |
| contentAlignment: { | |
| horizontal: 'center', | |
| vertical: 'center' | |
| } | |
| }, | |
| smartList: { | |
| twoColumnThreshold: 6, | |
| threeColumnThreshold: 12 | |
| } | |
| } | |
| }, | |
| creative: { | |
| name: 'Creative', | |
| description: 'Creative and distinctive style', | |
| config: { | |
| fonts: { | |
| heading: "'Poppins', 'Verdana', sans-serif", | |
| body: "'Inter', sans-serif", | |
| code: "'JetBrains Mono', monospace" | |
| }, | |
| fontSizes: { | |
| h1: { min: 2.2, base: 5.5, max: 4 }, | |
| h2: { min: 1.8, base: 4.5, max: 3 }, | |
| h3: { min: 1.4, base: 3.5, max: 2.3 }, | |
| text: { min: 1.15, base: 2, max: 1.7 }, | |
| code: { min: 1, base: 1.7, max: 1.5 } | |
| }, | |
| colors: { | |
| primary: '#ec4899', | |
| secondary: '#8b5cf6', | |
| background: '#1a0b2e', | |
| surface: '#2d1b4e', | |
| text: '#f0e7ff', | |
| textSecondary: '#c4b5fd', | |
| accent: '#f59e0b', | |
| codeBackground: '#2d1b4e', | |
| codeBorder: '#4c3575' | |
| }, | |
| background: { | |
| type: 'gradient', | |
| value: null, | |
| gradient: 'linear-gradient(135deg, #1a0b2e 0%, #2d1b4e 50%, #4c1d95 100%)', | |
| image: null, | |
| opacity: 1 | |
| }, | |
| animations: { | |
| enabled: true, | |
| duration: 0.8, | |
| easing: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)', | |
| slideTransition: 'slide' | |
| }, | |
| styles: { | |
| borderRadius: '2rem', | |
| shadow: '0 30px 60px rgba(139, 92, 246, 0.4)', | |
| lineHeight: { | |
| heading: 1.35, | |
| body: 1.75 | |
| }, | |
| // UI Elements | |
| previewOpacity: 0.68, | |
| overlayBackground: 'rgba(26, 11, 46, 0.9)', | |
| overlayBlur: '12px', | |
| navBorderWidth: '3px', | |
| navBorderOpacity: 0.7, | |
| // Borders & Accents | |
| headingAccentBorderWidth: '6px', | |
| blockquoteBorderWidth: '5px', | |
| imageBorderWidth: '3px', | |
| linkUnderlineWidth: '3px', | |
| tableBorderWidth: '2px', | |
| hrBorderWidth: '4px', | |
| // Effects | |
| backdropGradientColor: 'rgba(236, 72, 153, 0.25)', | |
| backdropGradientSpread: '75%', | |
| backdropBlur: '100px', | |
| // Page Indicator | |
| pageIndicatorTop: '20px', | |
| pageIndicatorRight: '20px', | |
| pageIndicatorFontSize: '1rem', | |
| pageIndicatorOpacity: 0.8, | |
| pageIndicatorPaddingX: '16px', | |
| pageIndicatorPaddingY: '6px', | |
| pageIndicatorBgColor: 'rgba(139, 92, 246, 0.4)', | |
| pageIndicatorTextColor: '#f0e7ff' | |
| }, | |
| typography: { | |
| paragraphSpacing: { | |
| before: 0.5, | |
| after: 1.5 | |
| }, | |
| headingSpacing: { | |
| before: 2, | |
| after: 1.25 | |
| }, | |
| indentation: { | |
| firstLine: 0, | |
| hanging: 0, | |
| blockQuote: 2 | |
| }, | |
| listIndent: 2, | |
| textAlign: 'left' | |
| }, | |
| layout: { | |
| contentPadding: { | |
| small: 40, | |
| large: 52, | |
| ultra: 68 | |
| }, | |
| contentAlignment: { | |
| horizontal: 'center', | |
| vertical: 'center' | |
| } | |
| }, | |
| smartList: { | |
| twoColumnThreshold: 6, | |
| threeColumnThreshold: 12 | |
| } | |
| } | |
| } | |
| }; | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // Configuration Options (ตัวเลือกที่ใช้ได้) | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| export const FONT_OPTIONS = { | |
| heading: [ | |
| { value: "'Inter', 'Segoe UI', sans-serif", label: 'Inter (Modern)' }, | |
| { value: "'Montserrat', 'Arial', sans-serif", label: 'Montserrat (Professional)' }, | |
| { value: "'Poppins', 'Verdana', sans-serif", label: 'Poppins (Friendly)' }, | |
| { value: "'Playfair Display', 'Georgia', serif", label: 'Playfair Display (Elegant)' }, | |
| { value: "'Space Grotesk', sans-serif", label: 'Space Grotesk (Tech)' }, | |
| { value: "'Helvetica Neue', 'Arial', sans-serif", label: 'Helvetica (Clean)' }, | |
| { value: "'Ubuntu', sans-serif", label: 'Ubuntu (Casual)' }, | |
| { value: "'Orbitron', sans-serif", label: 'Orbitron (Futuristic)' } | |
| ], | |
| body: [ | |
| { value: "'Inter', 'Segoe UI', sans-serif", label: 'Inter' }, | |
| { value: "'Lato', 'Helvetica', sans-serif", label: 'Lato' }, | |
| { value: "'Roboto', sans-serif", label: 'Roboto' }, | |
| { value: "'Open Sans', sans-serif", label: 'Open Sans' }, | |
| { value: "'Helvetica Neue', 'Arial', sans-serif", label: 'Helvetica' }, | |
| { value: "'Ubuntu', sans-serif", label: 'Ubuntu' } | |
| ], | |
| code: [ | |
| { value: "'Source Code Pro', 'Consolas', monospace", label: 'Source Code Pro' }, | |
| { value: "'Fira Code', monospace", label: 'Fira Code' }, | |
| { value: "'JetBrains Mono', monospace", label: 'JetBrains Mono' }, | |
| { value: "'Roboto Mono', monospace", label: 'Roboto Mono' }, | |
| { value: "'SF Mono', 'Monaco', monospace", label: 'SF Mono' }, | |
| { value: "'Courier Prime', 'Courier New', monospace", label: 'Courier' } | |
| ] | |
| }; | |
| export const BACKGROUND_TYPES = [ | |
| { value: 'solid', label: 'สีพื้น' }, | |
| { value: 'gradient', label: 'ไล่สี' }, | |
| { value: 'image', label: 'รูปภาพ' } | |
| ]; | |
| export const TRANSITION_TYPES = [ | |
| { value: 'fade', label: 'Fade (จางเข้า-จางออก)' }, | |
| { value: 'slide', label: 'Slide (เลื่อน)' }, | |
| { value: 'none', label: 'ไม่มีเอฟเฟค' } | |
| ]; | |
| export const TEXT_ALIGN_OPTIONS = [ | |
| { value: 'left', label: 'ชิดซ้าย' }, | |
| { value: 'center', label: 'กึ่งกลาง' }, | |
| { value: 'right', label: 'ชิดขวา' }, | |
| { value: 'justify', label: 'เต็มแนว' } | |
| ]; | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // Configuration Management | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| let currentConfig = { ...CONFIG_PRESETS.default.config }; | |
| /** | |
| * ดึงค่า configuration ปัจจุบัน | |
| */ | |
| export function getCurrentConfig() { | |
| return { ...currentConfig }; | |
| } | |
| /** | |
| * ตั้งค่า configuration ใหม่ | |
| */ | |
| export function setConfig(newConfig, autoSave = true) { | |
| currentConfig = { ...currentConfig, ...newConfig }; | |
| applyConfigToDOM(); | |
| // Auto-save to localStorage | |
| if (autoSave) { | |
| ConfigStorage.autoSave(currentConfig); | |
| } | |
| return currentConfig; | |
| } | |
| /** | |
| * อัปเดตค่าเฉพาะส่วน (รองรับ nested objects) | |
| */ | |
| export function updateConfigPart(part, values, autoSave = true) { | |
| if (!currentConfig[part]) { | |
| currentConfig[part] = values; | |
| } else if (typeof values === 'object' && !Array.isArray(values)) { | |
| // Deep merge for nested objects | |
| currentConfig[part] = deepMerge(currentConfig[part], values); | |
| } else { | |
| currentConfig[part] = values; | |
| } | |
| applyConfigToDOM(); | |
| // Auto-save to localStorage | |
| if (autoSave) { | |
| ConfigStorage.autoSave(currentConfig); | |
| } | |
| return currentConfig; | |
| } | |
| /** | |
| * Deep merge helper function | |
| */ | |
| function deepMerge(target, source) { | |
| const result = { ...target }; | |
| for (const key in source) { | |
| if (source.hasOwnProperty(key)) { | |
| if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) { | |
| result[key] = deepMerge(result[key] || {}, source[key]); | |
| } else { | |
| result[key] = source[key]; | |
| } | |
| } | |
| } | |
| return result; | |
| } | |
| /** | |
| * โหลด preset | |
| */ | |
| export function loadPreset(presetName, autoSave = true) { | |
| const preset = CONFIG_PRESETS[presetName]; | |
| if (!preset) { | |
| console.error(`Preset "${presetName}" not found`); | |
| return null; | |
| } | |
| currentConfig = { ...preset.config }; | |
| applyConfigToDOM(); | |
| // Auto-save to localStorage | |
| if (autoSave) { | |
| ConfigStorage.autoSave(currentConfig); | |
| } | |
| return currentConfig; | |
| } | |
| /** | |
| * รีเซ็ตเป็นค่าเริ่มต้น | |
| */ | |
| export function resetConfig(autoSave = true) { | |
| currentConfig = { ...CONFIG_PRESETS.default.config }; | |
| applyConfigToDOM(); | |
| // Clear saved config และ save default | |
| if (autoSave) { | |
| ConfigStorage.clearLocalStorage(); | |
| ConfigStorage.saveToLocalStorage(currentConfig); | |
| } | |
| return currentConfig; | |
| } | |
| /** | |
| * โหลดการตั้งค่าที่บันทึกไว้จาก localStorage | |
| */ | |
| export function loadSavedConfig() { | |
| const savedConfig = ConfigStorage.loadFromLocalStorage(); | |
| if (savedConfig) { | |
| currentConfig = { ...CONFIG_PRESETS.default.config, ...savedConfig }; | |
| applyConfigToDOM(); | |
| console.log('[PresentationConfig] ✅ Loaded saved config from localStorage'); | |
| return currentConfig; | |
| } | |
| console.log('[PresentationConfig] No saved config found, using default'); | |
| return null; | |
| } | |
| /** | |
| * Export การตั้งค่าปัจจุบันเป็นไฟล์ | |
| */ | |
| export async function exportConfigToFile() { | |
| return ConfigStorage.exportToFile(currentConfig); | |
| } | |
| /** | |
| * Import การตั้งค่าจากไฟล์ | |
| */ | |
| export async function importConfigFromFile() { | |
| try { | |
| const importedConfig = await ConfigStorage.importFromFile(); | |
| if (importedConfig) { | |
| currentConfig = { ...CONFIG_PRESETS.default.config, ...importedConfig }; | |
| applyConfigToDOM(); | |
| ConfigStorage.saveToLocalStorage(currentConfig); | |
| console.log('[PresentationConfig] ✅ Imported config from file'); | |
| return currentConfig; | |
| } | |
| } catch (error) { | |
| console.error('[PresentationConfig] Failed to import config:', error); | |
| } | |
| return null; | |
| } | |
| /** | |
| * ดึงรายชื่อ presets ทั้งหมด | |
| */ | |
| export function getAllPresets() { | |
| return Object.entries(CONFIG_PRESETS).map(([key, preset]) => ({ | |
| id: key, | |
| name: preset.name, | |
| description: preset.description | |
| })); | |
| } | |
| /** | |
| * แปลง font size config เป็น clamp CSS | |
| */ | |
| function generateClampCSS(sizeConfig) { | |
| return `clamp(${sizeConfig.min}rem, ${sizeConfig.base}vw, ${sizeConfig.max}rem)`; | |
| } | |
| /** | |
| * ใส่ค่า configuration ลงใน DOM | |
| */ | |
| export function applyConfigToDOM() { | |
| const root = document.documentElement; | |
| console.log('[PresentationConfig] Applying configuration to DOM...', currentConfig); | |
| // Fonts | |
| root.style.setProperty('--font-heading', currentConfig.fonts.heading); | |
| root.style.setProperty('--font-body', currentConfig.fonts.body); | |
| root.style.setProperty('--font-code', currentConfig.fonts.code); | |
| root.style.setProperty('--font-primary', currentConfig.fonts.body); // Backward compatibility | |
| // Font Sizes | |
| const h1Size = generateClampCSS(currentConfig.fontSizes.h1); | |
| const h2Size = generateClampCSS(currentConfig.fontSizes.h2); | |
| const h3Size = generateClampCSS(currentConfig.fontSizes.h3); | |
| const textSize = generateClampCSS(currentConfig.fontSizes.text); | |
| const codeSize = generateClampCSS(currentConfig.fontSizes.code); | |
| root.style.setProperty('--font-size-h1', h1Size); | |
| root.style.setProperty('--font-size-h2', h2Size); | |
| root.style.setProperty('--font-size-h3', h3Size); | |
| root.style.setProperty('--font-size-text', textSize); | |
| root.style.setProperty('--font-size-code', codeSize); | |
| console.log('[PresentationConfig] Font sizes applied:', { | |
| h1: h1Size, | |
| h2: h2Size, | |
| h3: h3Size, | |
| text: textSize, | |
| code: codeSize | |
| }); | |
| // Colors | |
| root.style.setProperty('--color-primary', currentConfig.colors.primary); | |
| root.style.setProperty('--color-secondary', currentConfig.colors.secondary); | |
| root.style.setProperty('--color-background', currentConfig.colors.background); | |
| root.style.setProperty('--color-surface', currentConfig.colors.surface); | |
| root.style.setProperty('--color-text', currentConfig.colors.text); | |
| root.style.setProperty('--color-text-secondary', currentConfig.colors.textSecondary); | |
| root.style.setProperty('--color-accent', currentConfig.colors.accent); | |
| root.style.setProperty('--color-code-bg', currentConfig.colors.codeBackground); | |
| root.style.setProperty('--color-code-border', currentConfig.colors.codeBorder); | |
| console.log('[PresentationConfig] Colors applied:', currentConfig.colors); | |
| // Background | |
| if (currentConfig.background.type === 'solid') { | |
| document.body.style.background = currentConfig.background.value; | |
| } else if (currentConfig.background.type === 'gradient') { | |
| document.body.style.background = currentConfig.background.gradient; | |
| } else if (currentConfig.background.type === 'image' && currentConfig.background.image) { | |
| document.body.style.background = `url(${currentConfig.background.image})`; | |
| document.body.style.backgroundSize = 'cover'; | |
| document.body.style.backgroundPosition = 'center'; | |
| } | |
| // Animations | |
| root.style.setProperty('--anim-duration', `${currentConfig.animations.duration}s`); | |
| root.style.setProperty('--anim-easing', currentConfig.animations.easing); | |
| // Styles | |
| root.style.setProperty('--border-radius', currentConfig.styles.borderRadius); | |
| root.style.setProperty('--shadow', currentConfig.styles.shadow); | |
| root.style.setProperty('--line-height-heading', currentConfig.styles.lineHeight.heading); | |
| root.style.setProperty('--line-height-body', currentConfig.styles.lineHeight.body); | |
| console.log('[PresentationConfig] Line heights applied:', currentConfig.styles.lineHeight); | |
| // UI Elements Styles | |
| root.style.setProperty('--preview-opacity', currentConfig.styles.previewOpacity); | |
| root.style.setProperty('--overlay-background', currentConfig.styles.overlayBackground); | |
| root.style.setProperty('--overlay-blur', currentConfig.styles.overlayBlur); | |
| root.style.setProperty('--nav-border-width', currentConfig.styles.navBorderWidth); | |
| root.style.setProperty('--nav-border-opacity', currentConfig.styles.navBorderOpacity); | |
| // Borders & Accents | |
| root.style.setProperty('--heading-accent-border-width', currentConfig.styles.headingAccentBorderWidth); | |
| root.style.setProperty('--blockquote-border-width', currentConfig.styles.blockquoteBorderWidth); | |
| root.style.setProperty('--image-border-width', currentConfig.styles.imageBorderWidth); | |
| root.style.setProperty('--link-underline-width', currentConfig.styles.linkUnderlineWidth); | |
| root.style.setProperty('--table-border-width', currentConfig.styles.tableBorderWidth); | |
| root.style.setProperty('--hr-border-width', currentConfig.styles.hrBorderWidth); | |
| // Effects | |
| root.style.setProperty('--backdrop-gradient-color', currentConfig.styles.backdropGradientColor); | |
| root.style.setProperty('--backdrop-gradient-spread', currentConfig.styles.backdropGradientSpread); | |
| root.style.setProperty('--backdrop-blur', currentConfig.styles.backdropBlur); | |
| // Page Indicator | |
| root.style.setProperty('--page-indicator-top', currentConfig.styles.pageIndicatorTop); | |
| root.style.setProperty('--page-indicator-right', currentConfig.styles.pageIndicatorRight); | |
| root.style.setProperty('--page-indicator-font-size', currentConfig.styles.pageIndicatorFontSize); | |
| root.style.setProperty('--page-indicator-opacity', currentConfig.styles.pageIndicatorOpacity); | |
| root.style.setProperty('--page-indicator-padding-x', currentConfig.styles.pageIndicatorPaddingX); | |
| root.style.setProperty('--page-indicator-padding-y', currentConfig.styles.pageIndicatorPaddingY); | |
| root.style.setProperty('--page-indicator-bg-color', currentConfig.styles.pageIndicatorBgColor); | |
| root.style.setProperty('--page-indicator-text-color', currentConfig.styles.pageIndicatorTextColor); | |
| // Typography (NEW) | |
| if (currentConfig.typography) { | |
| console.log('[PresentationConfig] Applying typography:', currentConfig.typography); | |
| root.style.setProperty('--paragraph-spacing-before', `${currentConfig.typography.paragraphSpacing.before}rem`); | |
| root.style.setProperty('--paragraph-spacing-after', `${currentConfig.typography.paragraphSpacing.after}rem`); | |
| root.style.setProperty('--heading-spacing-before', `${currentConfig.typography.headingSpacing.before}rem`); | |
| root.style.setProperty('--heading-spacing-after', `${currentConfig.typography.headingSpacing.after}rem`); | |
| root.style.setProperty('--indent-first-line', `${currentConfig.typography.indentation.firstLine}rem`); | |
| root.style.setProperty('--indent-hanging', `${currentConfig.typography.indentation.hanging || 0}rem`); | |
| root.style.setProperty('--indent-blockquote', `${currentConfig.typography.indentation.blockQuote}rem`); | |
| root.style.setProperty('--list-indent', `${currentConfig.typography.listIndent}rem`); | |
| root.style.setProperty('--text-align', currentConfig.typography.textAlign); | |
| } | |
| // Layout & Content Positioning (NEW) | |
| if (currentConfig.layout) { | |
| console.log('[PresentationConfig] Applying layout:', currentConfig.layout); | |
| root.style.setProperty('--content-padding-small', `${currentConfig.layout.contentPadding.small}px`); | |
| root.style.setProperty('--content-padding-large', `${currentConfig.layout.contentPadding.large}px`); | |
| root.style.setProperty('--content-padding-ultra', `${currentConfig.layout.contentPadding.ultra}px`); | |
| root.style.setProperty('--content-align-horizontal', currentConfig.layout.contentAlignment.horizontal); | |
| root.style.setProperty('--content-align-vertical', currentConfig.layout.contentAlignment.vertical); | |
| } | |
| // Smart List Columns | |
| if (currentConfig.smartList) { | |
| root.style.setProperty('--smart-list-two-column-threshold', currentConfig.smartList.twoColumnThreshold); | |
| root.style.setProperty('--smart-list-three-column-threshold', currentConfig.smartList.threeColumnThreshold); | |
| } | |
| console.log('[PresentationConfig] ✅ Configuration applied successfully'); | |
| return currentConfig; | |
| } | |
| /** | |
| * Export configuration เป็น JSON | |
| */ | |
| export function exportConfig() { | |
| return JSON.stringify(currentConfig, null, 2); | |
| } | |
| /** | |
| * Import configuration จาก JSON | |
| */ | |
| export function importConfig(jsonString) { | |
| try { | |
| const imported = JSON.parse(jsonString); | |
| currentConfig = { ...CONFIG_PRESETS.default.config, ...imported }; | |
| applyConfigToDOM(); | |
| return currentConfig; | |
| } catch (error) { | |
| console.error('Failed to import configuration:', error); | |
| return null; | |
| } | |
| } | |
| /** | |
| * Update typography settings from UI values | |
| * @param {Object} values - Typography values from UI | |
| */ | |
| export function updateTypography(values) { | |
| if (!currentConfig.typography) { | |
| // Use default preset values instead of hardcoding | |
| currentConfig.typography = { ...CONFIG_PRESETS.default.config.typography }; | |
| } | |
| // Deep merge typography values | |
| currentConfig.typography = deepMerge(currentConfig.typography, values); | |
| applyConfigToDOM(); | |
| return currentConfig; | |
| } | |
| /** | |
| * Get current typography settings | |
| */ | |
| export function getTypography() { | |
| return currentConfig.typography || null; | |
| } | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| // UI Integration | |
| // ════════════════════════════════════════════════════════════════════════════ | |
| let uiCallbacks = { | |
| onUpdate: null, | |
| onSave: null, | |
| setStatus: null | |
| }; | |
| /** | |
| * Initialize Presentation UI with DOM elements and callbacks | |
| * @param {Object} domElements - Object containing all DOM element references | |
| * @param {Object} callbacks - Callback functions { onUpdate, onSave, setStatus } | |
| */ | |
| export function initPresentationUI(domElements, callbacks = {}) { | |
| uiCallbacks = { ...uiCallbacks, ...callbacks }; | |
| // Populate font options | |
| if (domElements.fontHeading && FONT_OPTIONS.heading) { | |
| domElements.fontHeading.innerHTML = ''; | |
| FONT_OPTIONS.heading.forEach(opt => { | |
| const option = document.createElement('option'); | |
| option.value = opt.value; | |
| option.textContent = opt.label; | |
| domElements.fontHeading.appendChild(option); | |
| }); | |
| } | |
| if (domElements.fontBody && FONT_OPTIONS.body) { | |
| domElements.fontBody.innerHTML = ''; | |
| FONT_OPTIONS.body.forEach(opt => { | |
| const option = document.createElement('option'); | |
| option.value = opt.value; | |
| option.textContent = opt.label; | |
| domElements.fontBody.appendChild(option); | |
| }); | |
| } | |
| if (domElements.fontCode && FONT_OPTIONS.code) { | |
| domElements.fontCode.innerHTML = ''; | |
| FONT_OPTIONS.code.forEach(opt => { | |
| const option = document.createElement('option'); | |
| option.value = opt.value; | |
| option.textContent = opt.label; | |
| domElements.fontCode.appendChild(option); | |
| }); | |
| } | |
| // Load current config into UI | |
| loadConfigToUI(domElements); | |
| // Setup event listeners | |
| setupPresetListener(domElements); | |
| setupFontListeners(domElements); | |
| setupColorListeners(domElements); | |
| setupAnimationListeners(domElements); | |
| setupFontSizeListeners(domElements); | |
| setupUIStylesListeners(domElements); | |
| setupTypographyListeners(domElements); | |
| setupLayoutListeners(domElements); | |
| setupActionButtons(domElements); | |
| } | |
| /** | |
| * Load current configuration to UI inputs | |
| */ | |
| function loadConfigToUI(domElements) { | |
| // Load fonts | |
| if (domElements.fontHeading) domElements.fontHeading.value = currentConfig.fonts.heading; | |
| if (domElements.fontBody) domElements.fontBody.value = currentConfig.fonts.body; | |
| if (domElements.fontCode) domElements.fontCode.value = currentConfig.fonts.code; | |
| // Load colors | |
| if (domElements.colorPrimary) domElements.colorPrimary.value = currentConfig.colors.primary; | |
| if (domElements.colorAccent) domElements.colorAccent.value = currentConfig.colors.accent; | |
| if (domElements.colorBackground) domElements.colorBackground.value = currentConfig.colors.background; | |
| if (domElements.colorText) domElements.colorText.value = currentConfig.colors.text; | |
| // Load animations | |
| if (domElements.animationTransition) domElements.animationTransition.value = currentConfig.animations.slideTransition; | |
| if (domElements.animationDuration) domElements.animationDuration.value = currentConfig.animations.duration; | |
| // Load font sizes | |
| if (currentConfig.fontSizes) { | |
| if (domElements.fontSizeH1Min) domElements.fontSizeH1Min.value = currentConfig.fontSizes.h1.min; | |
| if (domElements.fontSizeH1Base) domElements.fontSizeH1Base.value = currentConfig.fontSizes.h1.base; | |
| if (domElements.fontSizeH1Max) domElements.fontSizeH1Max.value = currentConfig.fontSizes.h1.max; | |
| if (domElements.fontSizeH2Min) domElements.fontSizeH2Min.value = currentConfig.fontSizes.h2.min; | |
| if (domElements.fontSizeH2Base) domElements.fontSizeH2Base.value = currentConfig.fontSizes.h2.base; | |
| if (domElements.fontSizeH2Max) domElements.fontSizeH2Max.value = currentConfig.fontSizes.h2.max; | |
| if (domElements.fontSizeTextMin) domElements.fontSizeTextMin.value = currentConfig.fontSizes.text.min; | |
| if (domElements.fontSizeTextBase) domElements.fontSizeTextBase.value = currentConfig.fontSizes.text.base; | |
| if (domElements.fontSizeTextMax) domElements.fontSizeTextMax.value = currentConfig.fontSizes.text.max; | |
| } | |
| // Load line height | |
| if (currentConfig.styles && currentConfig.styles.lineHeight) { | |
| if (domElements.lineHeightHeading) domElements.lineHeightHeading.value = currentConfig.styles.lineHeight.heading; | |
| if (domElements.lineHeightBody) domElements.lineHeightBody.value = currentConfig.styles.lineHeight.body; | |
| } | |
| // Load UI & Visual Effects | |
| if (currentConfig.styles) { | |
| if (domElements.previewOpacity) domElements.previewOpacity.value = currentConfig.styles.previewOpacity; | |
| if (domElements.overlayBlur) domElements.overlayBlur.value = parseInt(currentConfig.styles.overlayBlur); | |
| if (domElements.navBorderWidth) domElements.navBorderWidth.value = parseInt(currentConfig.styles.navBorderWidth); | |
| if (domElements.backdropSpread) domElements.backdropSpread.value = parseInt(currentConfig.styles.backdropGradientSpread); | |
| if (domElements.backdropBlur) domElements.backdropBlur.value = parseInt(currentConfig.styles.backdropBlur); | |
| } | |
| // Load Border Widths | |
| if (currentConfig.styles) { | |
| if (domElements.headingBorderWidth) domElements.headingBorderWidth.value = parseInt(currentConfig.styles.headingAccentBorderWidth); | |
| if (domElements.blockquoteBorderWidth) domElements.blockquoteBorderWidth.value = parseInt(currentConfig.styles.blockquoteBorderWidth); | |
| if (domElements.imageBorderWidth) domElements.imageBorderWidth.value = parseInt(currentConfig.styles.imageBorderWidth); | |
| if (domElements.linkUnderlineWidth) domElements.linkUnderlineWidth.value = parseInt(currentConfig.styles.linkUnderlineWidth); | |
| if (domElements.tableBorderWidth) domElements.tableBorderWidth.value = parseInt(currentConfig.styles.tableBorderWidth); | |
| if (domElements.hrBorderWidth) domElements.hrBorderWidth.value = parseInt(currentConfig.styles.hrBorderWidth); | |
| } | |
| // Load typography | |
| if (currentConfig.typography) { | |
| if (domElements.paragraphBefore) domElements.paragraphBefore.value = currentConfig.typography.paragraphSpacing.before; | |
| if (domElements.paragraphAfter) domElements.paragraphAfter.value = currentConfig.typography.paragraphSpacing.after; | |
| if (domElements.headingBefore) domElements.headingBefore.value = currentConfig.typography.headingSpacing.before; | |
| if (domElements.headingAfter) domElements.headingAfter.value = currentConfig.typography.headingSpacing.after; | |
| if (domElements.indentFirst) domElements.indentFirst.value = currentConfig.typography.indentation.firstLine; | |
| if (domElements.indentBlockquote) domElements.indentBlockquote.value = currentConfig.typography.indentation.blockQuote; | |
| if (domElements.listIndent) domElements.listIndent.value = currentConfig.typography.listIndent; | |
| if (domElements.textAlign) domElements.textAlign.value = currentConfig.typography.textAlign; | |
| } | |
| // Load Page Indicator | |
| if (currentConfig.styles) { | |
| if (domElements.pageIndicatorTop) domElements.pageIndicatorTop.value = parseInt(currentConfig.styles.pageIndicatorTop); | |
| if (domElements.pageIndicatorRight) domElements.pageIndicatorRight.value = parseInt(currentConfig.styles.pageIndicatorRight); | |
| if (domElements.pageIndicatorFontSize) domElements.pageIndicatorFontSize.value = parseFloat(currentConfig.styles.pageIndicatorFontSize); | |
| if (domElements.pageIndicatorOpacity) domElements.pageIndicatorOpacity.value = currentConfig.styles.pageIndicatorOpacity; | |
| if (domElements.pageIndicatorPaddingX) domElements.pageIndicatorPaddingX.value = parseInt(currentConfig.styles.pageIndicatorPaddingX); | |
| if (domElements.pageIndicatorPaddingY) domElements.pageIndicatorPaddingY.value = parseInt(currentConfig.styles.pageIndicatorPaddingY); | |
| if (domElements.pageIndicatorBgColor) domElements.pageIndicatorBgColor.value = currentConfig.styles.pageIndicatorBgColor; | |
| if (domElements.pageIndicatorTextColor) domElements.pageIndicatorTextColor.value = currentConfig.styles.pageIndicatorTextColor; | |
| } | |
| // Load Smart List Column Settings | |
| if (currentConfig.smartList) { | |
| if (domElements.smartListTwoColumn) domElements.smartListTwoColumn.value = currentConfig.smartList.twoColumnThreshold; | |
| if (domElements.smartListThreeColumn) domElements.smartListThreeColumn.value = currentConfig.smartList.threeColumnThreshold; | |
| } | |
| // Load Content Layout & Positioning Settings | |
| if (currentConfig.layout) { | |
| if (domElements.contentPaddingSmall) domElements.contentPaddingSmall.value = currentConfig.layout.contentPadding.small; | |
| if (domElements.contentPaddingLarge) domElements.contentPaddingLarge.value = currentConfig.layout.contentPadding.large; | |
| if (domElements.contentPaddingUltra) domElements.contentPaddingUltra.value = currentConfig.layout.contentPadding.ultra; | |
| if (domElements.contentAlignHorizontal) domElements.contentAlignHorizontal.value = currentConfig.layout.contentAlignment.horizontal; | |
| if (domElements.contentAlignVertical) domElements.contentAlignVertical.value = currentConfig.layout.contentAlignment.vertical; | |
| } | |
| } | |
| /** | |
| * Reload UI from current configuration (exported for external use) | |
| */ | |
| export function reloadUI(domElements) { | |
| loadConfigToUI(domElements); | |
| } | |
| /** | |
| * Load configuration from frontmatter object | |
| * @param {Object} frontmatter - Frontmatter key-value pairs | |
| * @param {Object} domElements - DOM element references for updating UI | |
| */ | |
| export function loadConfigFromFrontmatter(frontmatter, domElements) { | |
| // Load preset first if specified | |
| if (frontmatter['presentation.preset']) { | |
| const presetName = frontmatter['presentation.preset']; | |
| loadPreset(presetName); | |
| if (domElements && domElements.presetSelector) { | |
| domElements.presetSelector.value = presetName; | |
| } | |
| } | |
| // Load fonts (overrides preset if specified) | |
| const fontUpdates = {}; | |
| if (frontmatter['presentation.fonts.heading']) { | |
| fontUpdates.heading = frontmatter['presentation.fonts.heading']; | |
| } | |
| if (frontmatter['presentation.fonts.body']) { | |
| fontUpdates.body = frontmatter['presentation.fonts.body']; | |
| } | |
| if (frontmatter['presentation.fonts.code']) { | |
| fontUpdates.code = frontmatter['presentation.fonts.code']; | |
| } | |
| if (Object.keys(fontUpdates).length > 0) { | |
| updateConfigPart('fonts', fontUpdates); | |
| } | |
| // Load colors | |
| const colorUpdates = {}; | |
| if (frontmatter['presentation.colors.primary']) { | |
| colorUpdates.primary = frontmatter['presentation.colors.primary']; | |
| } | |
| if (frontmatter['presentation.colors.accent']) { | |
| colorUpdates.accent = frontmatter['presentation.colors.accent']; | |
| } | |
| if (frontmatter['presentation.colors.background']) { | |
| colorUpdates.background = frontmatter['presentation.colors.background']; | |
| } | |
| if (frontmatter['presentation.colors.text']) { | |
| colorUpdates.text = frontmatter['presentation.colors.text']; | |
| } | |
| if (Object.keys(colorUpdates).length > 0) { | |
| updateConfigPart('colors', colorUpdates); | |
| } | |
| // Load animations | |
| const animationUpdates = {}; | |
| if (frontmatter['presentation.animations.slideTransition']) { | |
| animationUpdates.slideTransition = frontmatter['presentation.animations.slideTransition']; | |
| } | |
| if (frontmatter['presentation.animations.duration'] !== undefined) { | |
| animationUpdates.duration = parseFloat(frontmatter['presentation.animations.duration']); | |
| } | |
| if (Object.keys(animationUpdates).length > 0) { | |
| updateConfigPart('animations', animationUpdates); | |
| } | |
| // Load font sizes | |
| const fontSizeUpdates = {}; | |
| if (frontmatter['presentation.fontSizes.h1.min'] !== undefined) { | |
| if (!fontSizeUpdates.h1) fontSizeUpdates.h1 = {}; | |
| fontSizeUpdates.h1.min = parseFloat(frontmatter['presentation.fontSizes.h1.min']); | |
| } | |
| if (frontmatter['presentation.fontSizes.h1.base'] !== undefined) { | |
| if (!fontSizeUpdates.h1) fontSizeUpdates.h1 = {}; | |
| fontSizeUpdates.h1.base = parseFloat(frontmatter['presentation.fontSizes.h1.base']); | |
| } | |
| if (frontmatter['presentation.fontSizes.h1.max'] !== undefined) { | |
| if (!fontSizeUpdates.h1) fontSizeUpdates.h1 = {}; | |
| fontSizeUpdates.h1.max = parseFloat(frontmatter['presentation.fontSizes.h1.max']); | |
| } | |
| if (frontmatter['presentation.fontSizes.h2.min'] !== undefined) { | |
| if (!fontSizeUpdates.h2) fontSizeUpdates.h2 = {}; | |
| fontSizeUpdates.h2.min = parseFloat(frontmatter['presentation.fontSizes.h2.min']); | |
| } | |
| if (frontmatter['presentation.fontSizes.h2.base'] !== undefined) { | |
| if (!fontSizeUpdates.h2) fontSizeUpdates.h2 = {}; | |
| fontSizeUpdates.h2.base = parseFloat(frontmatter['presentation.fontSizes.h2.base']); | |
| } | |
| if (frontmatter['presentation.fontSizes.h2.max'] !== undefined) { | |
| if (!fontSizeUpdates.h2) fontSizeUpdates.h2 = {}; | |
| fontSizeUpdates.h2.max = parseFloat(frontmatter['presentation.fontSizes.h2.max']); | |
| } | |
| if (frontmatter['presentation.fontSizes.text.min'] !== undefined) { | |
| if (!fontSizeUpdates.text) fontSizeUpdates.text = {}; | |
| fontSizeUpdates.text.min = parseFloat(frontmatter['presentation.fontSizes.text.min']); | |
| } | |
| if (frontmatter['presentation.fontSizes.text.base'] !== undefined) { | |
| if (!fontSizeUpdates.text) fontSizeUpdates.text = {}; | |
| fontSizeUpdates.text.base = parseFloat(frontmatter['presentation.fontSizes.text.base']); | |
| } | |
| if (frontmatter['presentation.fontSizes.text.max'] !== undefined) { | |
| if (!fontSizeUpdates.text) fontSizeUpdates.text = {}; | |
| fontSizeUpdates.text.max = parseFloat(frontmatter['presentation.fontSizes.text.max']); | |
| } | |
| if (Object.keys(fontSizeUpdates).length > 0) { | |
| updateConfigPart('fontSizes', fontSizeUpdates); | |
| } | |
| // Load line height and UI styles | |
| const styleUpdates = {}; | |
| if (frontmatter['presentation.styles.lineHeight.heading'] !== undefined || frontmatter['presentation.styles.lineHeight.body'] !== undefined) { | |
| styleUpdates.lineHeight = {}; | |
| if (frontmatter['presentation.styles.lineHeight.heading'] !== undefined) { | |
| styleUpdates.lineHeight.heading = parseFloat(frontmatter['presentation.styles.lineHeight.heading']); | |
| } | |
| if (frontmatter['presentation.styles.lineHeight.body'] !== undefined) { | |
| styleUpdates.lineHeight.body = parseFloat(frontmatter['presentation.styles.lineHeight.body']); | |
| } | |
| } | |
| // Load UI & Visual Effects | |
| if (frontmatter['presentation.styles.previewOpacity'] !== undefined) { | |
| styleUpdates.previewOpacity = parseFloat(frontmatter['presentation.styles.previewOpacity']); | |
| } | |
| if (frontmatter['presentation.styles.overlayBlur']) { | |
| styleUpdates.overlayBlur = frontmatter['presentation.styles.overlayBlur']; | |
| } | |
| if (frontmatter['presentation.styles.navBorderWidth']) { | |
| styleUpdates.navBorderWidth = frontmatter['presentation.styles.navBorderWidth']; | |
| } | |
| if (frontmatter['presentation.styles.backdropGradientSpread']) { | |
| styleUpdates.backdropGradientSpread = frontmatter['presentation.styles.backdropGradientSpread']; | |
| } | |
| if (frontmatter['presentation.styles.backdropBlur']) { | |
| styleUpdates.backdropBlur = frontmatter['presentation.styles.backdropBlur']; | |
| } | |
| // Load Border Widths | |
| if (frontmatter['presentation.styles.headingAccentBorderWidth']) { | |
| styleUpdates.headingAccentBorderWidth = frontmatter['presentation.styles.headingAccentBorderWidth']; | |
| } | |
| if (frontmatter['presentation.styles.blockquoteBorderWidth']) { | |
| styleUpdates.blockquoteBorderWidth = frontmatter['presentation.styles.blockquoteBorderWidth']; | |
| } | |
| if (frontmatter['presentation.styles.imageBorderWidth']) { | |
| styleUpdates.imageBorderWidth = frontmatter['presentation.styles.imageBorderWidth']; | |
| } | |
| if (frontmatter['presentation.styles.linkUnderlineWidth']) { | |
| styleUpdates.linkUnderlineWidth = frontmatter['presentation.styles.linkUnderlineWidth']; | |
| } | |
| if (frontmatter['presentation.styles.tableBorderWidth']) { | |
| styleUpdates.tableBorderWidth = frontmatter['presentation.styles.tableBorderWidth']; | |
| } | |
| if (frontmatter['presentation.styles.hrBorderWidth']) { | |
| styleUpdates.hrBorderWidth = frontmatter['presentation.styles.hrBorderWidth']; | |
| } | |
| // Load Page Indicator | |
| if (frontmatter['presentation.styles.pageIndicatorTop']) { | |
| styleUpdates.pageIndicatorTop = frontmatter['presentation.styles.pageIndicatorTop']; | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorRight']) { | |
| styleUpdates.pageIndicatorRight = frontmatter['presentation.styles.pageIndicatorRight']; | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorFontSize']) { | |
| styleUpdates.pageIndicatorFontSize = frontmatter['presentation.styles.pageIndicatorFontSize']; | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorOpacity'] !== undefined) { | |
| styleUpdates.pageIndicatorOpacity = parseFloat(frontmatter['presentation.styles.pageIndicatorOpacity']); | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorPaddingX']) { | |
| styleUpdates.pageIndicatorPaddingX = frontmatter['presentation.styles.pageIndicatorPaddingX']; | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorPaddingY']) { | |
| styleUpdates.pageIndicatorPaddingY = frontmatter['presentation.styles.pageIndicatorPaddingY']; | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorBgColor']) { | |
| styleUpdates.pageIndicatorBgColor = frontmatter['presentation.styles.pageIndicatorBgColor']; | |
| } | |
| if (frontmatter['presentation.styles.pageIndicatorTextColor']) { | |
| styleUpdates.pageIndicatorTextColor = frontmatter['presentation.styles.pageIndicatorTextColor']; | |
| } | |
| if (Object.keys(styleUpdates).length > 0) { | |
| updateConfigPart('styles', styleUpdates); | |
| } | |
| // Load typography settings | |
| const typographyUpdates = {}; | |
| if (frontmatter['presentation.typography.paragraphSpacing.before'] !== undefined) { | |
| if (!typographyUpdates.paragraphSpacing) typographyUpdates.paragraphSpacing = {}; | |
| typographyUpdates.paragraphSpacing.before = parseFloat(frontmatter['presentation.typography.paragraphSpacing.before']); | |
| } | |
| if (frontmatter['presentation.typography.paragraphSpacing.after'] !== undefined) { | |
| if (!typographyUpdates.paragraphSpacing) typographyUpdates.paragraphSpacing = {}; | |
| typographyUpdates.paragraphSpacing.after = parseFloat(frontmatter['presentation.typography.paragraphSpacing.after']); | |
| } | |
| if (frontmatter['presentation.typography.headingSpacing.before'] !== undefined) { | |
| if (!typographyUpdates.headingSpacing) typographyUpdates.headingSpacing = {}; | |
| typographyUpdates.headingSpacing.before = parseFloat(frontmatter['presentation.typography.headingSpacing.before']); | |
| } | |
| if (frontmatter['presentation.typography.headingSpacing.after'] !== undefined) { | |
| if (!typographyUpdates.headingSpacing) typographyUpdates.headingSpacing = {}; | |
| typographyUpdates.headingSpacing.after = parseFloat(frontmatter['presentation.typography.headingSpacing.after']); | |
| } | |
| if (frontmatter['presentation.typography.indentation.firstLine'] !== undefined) { | |
| if (!typographyUpdates.indentation) typographyUpdates.indentation = {}; | |
| typographyUpdates.indentation.firstLine = parseFloat(frontmatter['presentation.typography.indentation.firstLine']); | |
| } | |
| if (frontmatter['presentation.typography.indentation.blockQuote'] !== undefined) { | |
| if (!typographyUpdates.indentation) typographyUpdates.indentation = {}; | |
| typographyUpdates.indentation.blockQuote = parseFloat(frontmatter['presentation.typography.indentation.blockQuote']); | |
| } | |
| if (frontmatter['presentation.typography.listIndent'] !== undefined) { | |
| typographyUpdates.listIndent = parseFloat(frontmatter['presentation.typography.listIndent']); | |
| } | |
| if (frontmatter['presentation.typography.textAlign']) { | |
| typographyUpdates.textAlign = frontmatter['presentation.typography.textAlign']; | |
| } | |
| if (Object.keys(typographyUpdates).length > 0) { | |
| updateConfigPart('typography', typographyUpdates); | |
| } | |
| // Load Smart List Column Settings | |
| const smartListUpdates = {}; | |
| if (frontmatter['presentation.smartList.twoColumnThreshold'] !== undefined) { | |
| smartListUpdates.twoColumnThreshold = parseInt(frontmatter['presentation.smartList.twoColumnThreshold']); | |
| } | |
| if (frontmatter['presentation.smartList.threeColumnThreshold'] !== undefined) { | |
| smartListUpdates.threeColumnThreshold = parseInt(frontmatter['presentation.smartList.threeColumnThreshold']); | |
| } | |
| if (Object.keys(smartListUpdates).length > 0) { | |
| updateConfigPart('smartList', smartListUpdates); | |
| } | |
| // Reload UI to reflect changes | |
| if (domElements) { | |
| reloadUI(domElements); | |
| } | |
| return currentConfig; | |
| } | |
| /** | |
| * Sync UI values back to configuration | |
| */ | |
| function syncUIToConfig(domElements) { | |
| console.log('[PresentationConfig] Syncing UI to config...', domElements); | |
| // Update fonts | |
| updateConfigPart('fonts', { | |
| heading: domElements.fontHeading?.value, | |
| body: domElements.fontBody?.value, | |
| code: domElements.fontCode?.value | |
| }); | |
| // Update colors | |
| updateConfigPart('colors', { | |
| primary: domElements.colorPrimary?.value, | |
| accent: domElements.colorAccent?.value, | |
| background: domElements.colorBackground?.value, | |
| text: domElements.colorText?.value | |
| }); | |
| // Update animations | |
| updateConfigPart('animations', { | |
| slideTransition: domElements.animationTransition?.value, | |
| duration: parseFloat(domElements.animationDuration?.value || currentConfig.animations.duration) | |
| }); | |
| // Update font sizes | |
| updateConfigPart('fontSizes', { | |
| h1: { | |
| min: parseFloat(domElements.fontSizeH1Min?.value || currentConfig.fontSizes.h1.min), | |
| base: parseFloat(domElements.fontSizeH1Base?.value || currentConfig.fontSizes.h1.base), | |
| max: parseFloat(domElements.fontSizeH1Max?.value || currentConfig.fontSizes.h1.max) | |
| }, | |
| h2: { | |
| min: parseFloat(domElements.fontSizeH2Min?.value || currentConfig.fontSizes.h2.min), | |
| base: parseFloat(domElements.fontSizeH2Base?.value || currentConfig.fontSizes.h2.base), | |
| max: parseFloat(domElements.fontSizeH2Max?.value || currentConfig.fontSizes.h2.max) | |
| }, | |
| text: { | |
| min: parseFloat(domElements.fontSizeTextMin?.value || currentConfig.fontSizes.text.min), | |
| base: parseFloat(domElements.fontSizeTextBase?.value || currentConfig.fontSizes.text.base), | |
| max: parseFloat(domElements.fontSizeTextMax?.value || currentConfig.fontSizes.text.max) | |
| } | |
| }); | |
| // Update line height and UI styles | |
| const currentStyles = currentConfig.styles || CONFIG_PRESETS.default.config.styles; | |
| updateConfigPart('styles', { | |
| ...currentStyles, | |
| lineHeight: { | |
| heading: parseFloat(domElements.lineHeightHeading?.value || currentStyles.lineHeight.heading), | |
| body: parseFloat(domElements.lineHeightBody?.value || currentStyles.lineHeight.body) | |
| }, | |
| // UI & Visual Effects | |
| previewOpacity: parseFloat(domElements.previewOpacity?.value || currentStyles.previewOpacity), | |
| overlayBlur: `${domElements.overlayBlur?.value || parseInt(currentStyles.overlayBlur)}px`, | |
| navBorderWidth: `${domElements.navBorderWidth?.value || parseInt(currentStyles.navBorderWidth)}px`, | |
| backdropGradientSpread: `${domElements.backdropSpread?.value || parseInt(currentStyles.backdropGradientSpread)}%`, | |
| backdropBlur: `${domElements.backdropBlur?.value || parseInt(currentStyles.backdropBlur)}px`, | |
| // Border Widths | |
| headingAccentBorderWidth: `${domElements.headingBorderWidth?.value || parseInt(currentStyles.headingAccentBorderWidth)}px`, | |
| blockquoteBorderWidth: `${domElements.blockquoteBorderWidth?.value || parseInt(currentStyles.blockquoteBorderWidth)}px`, | |
| imageBorderWidth: `${domElements.imageBorderWidth?.value || parseInt(currentStyles.imageBorderWidth)}px`, | |
| linkUnderlineWidth: `${domElements.linkUnderlineWidth?.value || parseInt(currentStyles.linkUnderlineWidth)}px`, | |
| tableBorderWidth: `${domElements.tableBorderWidth?.value || parseInt(currentStyles.tableBorderWidth)}px`, | |
| hrBorderWidth: `${domElements.hrBorderWidth?.value || parseInt(currentStyles.hrBorderWidth)}px`, | |
| // Page Indicator | |
| pageIndicatorTop: `${domElements.pageIndicatorTop?.value || parseInt(currentStyles.pageIndicatorTop)}px`, | |
| pageIndicatorRight: `${domElements.pageIndicatorRight?.value || parseInt(currentStyles.pageIndicatorRight)}px`, | |
| pageIndicatorFontSize: `${domElements.pageIndicatorFontSize?.value || parseFloat(currentStyles.pageIndicatorFontSize)}rem`, | |
| pageIndicatorOpacity: parseFloat(domElements.pageIndicatorOpacity?.value || currentStyles.pageIndicatorOpacity), | |
| pageIndicatorPaddingX: `${domElements.pageIndicatorPaddingX?.value || parseInt(currentStyles.pageIndicatorPaddingX)}px`, | |
| pageIndicatorPaddingY: `${domElements.pageIndicatorPaddingY?.value || parseInt(currentStyles.pageIndicatorPaddingY)}px`, | |
| pageIndicatorBgColor: domElements.pageIndicatorBgColor?.value || currentStyles.pageIndicatorBgColor, | |
| pageIndicatorTextColor: domElements.pageIndicatorTextColor?.value || currentStyles.pageIndicatorTextColor | |
| }); | |
| // Update typography (use current config as fallback) | |
| const currentTypography = currentConfig.typography || CONFIG_PRESETS.default.config.typography; | |
| updateTypography({ | |
| paragraphSpacing: { | |
| before: parseFloat(domElements.paragraphBefore?.value || currentTypography.paragraphSpacing.before), | |
| after: parseFloat(domElements.paragraphAfter?.value || currentTypography.paragraphSpacing.after) | |
| }, | |
| headingSpacing: { | |
| before: parseFloat(domElements.headingBefore?.value || currentTypography.headingSpacing.before), | |
| after: parseFloat(domElements.headingAfter?.value || currentTypography.headingSpacing.after) | |
| }, | |
| indentation: { | |
| firstLine: parseFloat(domElements.indentFirst?.value || currentTypography.indentation.firstLine), | |
| hanging: currentTypography.indentation.hanging || 0, | |
| blockQuote: parseFloat(domElements.indentBlockquote?.value || currentTypography.indentation.blockQuote) | |
| }, | |
| listIndent: parseFloat(domElements.listIndent?.value || currentTypography.listIndent), | |
| textAlign: domElements.textAlign?.value || currentTypography.textAlign | |
| }); | |
| // Update Smart List Column Settings | |
| const currentSmartList = currentConfig.smartList || CONFIG_PRESETS.default.config.smartList; | |
| updateConfigPart('smartList', { | |
| twoColumnThreshold: parseInt(domElements.smartListTwoColumn?.value || currentSmartList.twoColumnThreshold), | |
| threeColumnThreshold: parseInt(domElements.smartListThreeColumn?.value || currentSmartList.threeColumnThreshold) | |
| }); | |
| // Update Content Layout & Positioning Settings | |
| const currentLayout = currentConfig.layout || CONFIG_PRESETS.default.config.layout; | |
| updateConfigPart('layout', { | |
| contentPadding: { | |
| small: parseInt(domElements.contentPaddingSmall?.value || currentLayout.contentPadding.small), | |
| large: parseInt(domElements.contentPaddingLarge?.value || currentLayout.contentPadding.large), | |
| ultra: parseInt(domElements.contentPaddingUltra?.value || currentLayout.contentPadding.ultra) | |
| }, | |
| contentAlignment: { | |
| horizontal: domElements.contentAlignHorizontal?.value || currentLayout.contentAlignment.horizontal, | |
| vertical: domElements.contentAlignVertical?.value || currentLayout.contentAlignment.vertical | |
| } | |
| }); | |
| console.log('[PresentationConfig] ✅ UI synced to config successfully'); | |
| // Trigger update callback | |
| if (uiCallbacks.onUpdate) { | |
| console.log('[PresentationConfig] Triggering onUpdate callback...'); | |
| uiCallbacks.onUpdate(); | |
| } | |
| } | |
| /** | |
| * Setup preset selector listener | |
| */ | |
| function setupPresetListener(domElements) { | |
| if (domElements.presetSelector) { | |
| domElements.presetSelector.addEventListener('change', (e) => { | |
| loadPreset(e.target.value); | |
| loadConfigToUI(domElements); | |
| if (uiCallbacks.onUpdate) { | |
| uiCallbacks.onUpdate(); | |
| } | |
| if (uiCallbacks.setStatus) { | |
| uiCallbacks.setStatus(`Loaded preset: ${e.target.value}`, 'online'); | |
| } | |
| }); | |
| } | |
| } | |
| /** | |
| * Setup font change listeners | |
| */ | |
| function setupFontListeners(domElements) { | |
| [domElements.fontHeading, domElements.fontBody, domElements.fontCode].forEach(select => { | |
| if (select) { | |
| // Real-time update on change | |
| select.addEventListener('change', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(select); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup color change listeners | |
| */ | |
| function setupColorListeners(domElements) { | |
| [domElements.colorPrimary, domElements.colorAccent, domElements.colorBackground, domElements.colorText].forEach(input => { | |
| if (input) { | |
| // Real-time update on input | |
| input.addEventListener('input', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(input); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup animation change listeners | |
| */ | |
| function setupAnimationListeners(domElements) { | |
| [domElements.animationTransition, domElements.animationDuration].forEach(input => { | |
| if (input) { | |
| // Real-time update on change/input | |
| input.addEventListener('input', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| input.addEventListener('change', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(input); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup font size and line height change listeners | |
| */ | |
| function setupFontSizeListeners(domElements) { | |
| [ | |
| domElements.fontSizeH1Min, domElements.fontSizeH1Base, domElements.fontSizeH1Max, | |
| domElements.fontSizeH2Min, domElements.fontSizeH2Base, domElements.fontSizeH2Max, | |
| domElements.fontSizeTextMin, domElements.fontSizeTextBase, domElements.fontSizeTextMax, | |
| domElements.lineHeightHeading, domElements.lineHeightBody | |
| ].forEach(input => { | |
| if (input) { | |
| // Real-time update on input | |
| input.addEventListener('input', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(input); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup UI styles listeners | |
| */ | |
| function setupUIStylesListeners(domElements) { | |
| [ | |
| domElements.previewOpacity, domElements.overlayBlur, domElements.navBorderWidth, | |
| domElements.backdropSpread, domElements.backdropBlur, | |
| domElements.headingBorderWidth, domElements.blockquoteBorderWidth, | |
| domElements.imageBorderWidth, domElements.linkUnderlineWidth, | |
| domElements.tableBorderWidth, domElements.hrBorderWidth, | |
| domElements.pageIndicatorTop, domElements.pageIndicatorRight, | |
| domElements.pageIndicatorFontSize, domElements.pageIndicatorOpacity, | |
| domElements.pageIndicatorPaddingX, domElements.pageIndicatorPaddingY, | |
| domElements.pageIndicatorBgColor, domElements.pageIndicatorTextColor, | |
| domElements.smartListTwoColumn, domElements.smartListThreeColumn | |
| ].forEach(input => { | |
| if (input) { | |
| // Real-time update on input | |
| input.addEventListener('input', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(input); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup visual feedback system | |
| * Highlights stage elements when hovering over related settings | |
| */ | |
| function setupVisualFeedback(inputElement) { | |
| if (!inputElement || !inputElement.id) return; | |
| const feedbackMap = { | |
| // Font settings -> all text elements | |
| 'fontHeading': { selector: 'h1, h2, h3, h4, h5, h6', type: 'content' }, | |
| 'fontBody': { selector: 'p, li, blockquote', type: 'content' }, | |
| 'fontCode': { selector: 'code, pre', type: 'content' }, | |
| // Font sizes -> specific headings | |
| 'fontSizeH1Min': { selector: 'h1', type: 'content' }, | |
| 'fontSizeH1Base': { selector: 'h1', type: 'content' }, | |
| 'fontSizeH1Max': { selector: 'h1', type: 'content' }, | |
| 'fontSizeH2Min': { selector: 'h2', type: 'content' }, | |
| 'fontSizeH2Base': { selector: 'h2', type: 'content' }, | |
| 'fontSizeH2Max': { selector: 'h2', type: 'content' }, | |
| 'fontSizeTextMin': { selector: 'p, li', type: 'content' }, | |
| 'fontSizeTextBase': { selector: 'p, li', type: 'content' }, | |
| 'fontSizeTextMax': { selector: 'p, li', type: 'content' }, | |
| // Colors -> elements with those colors | |
| 'colorPrimary': { selector: 'h1, a', type: 'content' }, | |
| 'colorAccent': { selector: '.accent, .badge', type: 'content' }, | |
| 'colorBackground': { selector: '#stage', type: 'content' }, | |
| 'colorText': { selector: 'p, li, span', type: 'content' }, | |
| // Line height | |
| 'lineHeightHeading': { selector: 'h1, h2, h3', type: 'content' }, | |
| 'lineHeightBody': { selector: 'p, li', type: 'content' }, | |
| // Border widths | |
| 'headingBorderWidth': { selector: 'h1, h2, h3', type: 'content' }, | |
| 'blockquoteBorderWidth': { selector: 'blockquote', type: 'content' }, | |
| 'imageBorderWidth': { selector: 'img', type: 'content' }, | |
| 'linkUnderlineWidth': { selector: 'a', type: 'content' }, | |
| 'tableBorderWidth': { selector: 'table, td, th', type: 'content' }, | |
| 'hrBorderWidth': { selector: 'hr', type: 'content' }, | |
| // Typography | |
| 'paragraphBefore': { selector: 'p', type: 'content' }, | |
| 'paragraphAfter': { selector: 'p', type: 'content' }, | |
| 'headingBefore': { selector: 'h1, h2, h3', type: 'content' }, | |
| 'headingAfter': { selector: 'h1, h2, h3', type: 'content' }, | |
| 'indentBlockquote': { selector: 'blockquote', type: 'content' }, | |
| 'listIndent': { selector: 'ul, ol, li', type: 'content' }, | |
| 'textAlign': { selector: 'p, h1, h2, h3', type: 'content' }, | |
| // Smart lists | |
| 'smartListTwoColumn': { selector: 'ul, ol', type: 'content' }, | |
| 'smartListThreeColumn': { selector: 'ul, ol', type: 'content' }, | |
| // Content Layout | |
| 'contentPaddingSmall': { selector: '.scene', type: 'content' }, | |
| 'contentPaddingLarge': { selector: '.scene', type: 'content' }, | |
| 'contentPaddingUltra': { selector: '.scene', type: 'content' }, | |
| 'contentAlignHorizontal': { selector: '#slideContainer, .scene', type: 'content' }, | |
| 'contentAlignVertical': { selector: '#slideContainer, .scene', type: 'content' }, | |
| // UI Elements | |
| 'previewOpacity': { selector: '.scene:not(.active)', type: 'ui' }, | |
| 'overlayBlur': { selector: '#pauseOverlay', type: 'ui' }, | |
| 'navBorderWidth': { selector: '.nav-btn', type: 'ui' }, | |
| 'backdropSpread': { selector: '.gradient-backdrop', type: 'ui' }, | |
| 'backdropBlur': { selector: '.gradient-backdrop', type: 'ui' }, | |
| 'pageIndicatorTop': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorRight': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorFontSize': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorOpacity': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorPaddingX': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorPaddingY': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorBgColor': { selector: '#slideCounter', type: 'ui' }, | |
| 'pageIndicatorTextColor': { selector: '#slideCounter', type: 'ui' } | |
| }; | |
| const mapping = feedbackMap[inputElement.id]; | |
| if (!mapping) return; | |
| // Mouse enter - highlight elements | |
| inputElement.addEventListener('mouseenter', () => { | |
| const stage = document.getElementById('stage'); | |
| if (!stage) return; | |
| const elements = stage.querySelectorAll(mapping.selector); | |
| elements.forEach(el => { | |
| // Add highlight class based on type | |
| if (mapping.type === 'content') { | |
| el.style.outline = '2px solid rgba(96, 165, 250, 0.5)'; // Blue for content | |
| el.style.outlineOffset = '4px'; | |
| el.style.transition = 'outline 0.2s ease'; | |
| } else { | |
| el.style.outline = '2px solid rgba(168, 85, 247, 0.5)'; // Purple for UI | |
| el.style.outlineOffset = '4px'; | |
| el.style.transition = 'outline 0.2s ease'; | |
| } | |
| }); | |
| // Add visual feedback to the input itself | |
| const color = mapping.type === 'content' ? 'rgba(96, 165, 250, 0.3)' : 'rgba(168, 85, 247, 0.3)'; | |
| inputElement.style.backgroundColor = color; | |
| inputElement.style.transition = 'background-color 0.2s ease'; | |
| }); | |
| // Mouse leave - remove highlight | |
| inputElement.addEventListener('mouseleave', () => { | |
| const stage = document.getElementById('stage'); | |
| if (!stage) return; | |
| const elements = stage.querySelectorAll(mapping.selector); | |
| elements.forEach(el => { | |
| el.style.outline = ''; | |
| el.style.outlineOffset = ''; | |
| }); | |
| // Remove input highlight | |
| inputElement.style.backgroundColor = ''; | |
| }); | |
| } | |
| /** | |
| * Setup typography change listeners | |
| */ | |
| function setupTypographyListeners(domElements) { | |
| [ | |
| domElements.paragraphBefore, domElements.paragraphAfter, | |
| domElements.headingBefore, domElements.headingAfter, | |
| domElements.indentFirst, domElements.indentBlockquote, | |
| domElements.listIndent, domElements.textAlign | |
| ].forEach(input => { | |
| if (input) { | |
| // Real-time update on input | |
| input.addEventListener('input', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(input); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup layout change listeners | |
| */ | |
| function setupLayoutListeners(domElements) { | |
| [ | |
| domElements.contentPaddingSmall, domElements.contentPaddingLarge, domElements.contentPaddingUltra, | |
| domElements.contentAlignHorizontal, domElements.contentAlignVertical | |
| ].forEach(input => { | |
| if (input) { | |
| // Real-time update on input | |
| input.addEventListener('input', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Real-time update on change (for select elements) | |
| input.addEventListener('change', () => { | |
| syncUIToConfig(domElements); | |
| }); | |
| // Visual feedback on hover | |
| setupVisualFeedback(input); | |
| } | |
| }); | |
| } | |
| /** | |
| * Setup Save and Reset buttons | |
| */ | |
| function setupActionButtons(domElements) { | |
| // Save button | |
| if (domElements.saveSettingsBtn) { | |
| domElements.saveSettingsBtn.addEventListener('click', () => { | |
| if (uiCallbacks.onSave) { | |
| uiCallbacks.onSave(currentConfig, domElements.presetSelector?.value); | |
| } | |
| if (uiCallbacks.setStatus) { | |
| uiCallbacks.setStatus('Settings saved to frontmatter', 'online'); | |
| } | |
| }); | |
| } | |
| // Reset button | |
| if (domElements.resetSettingsBtn) { | |
| domElements.resetSettingsBtn.addEventListener('click', () => { | |
| resetConfig(); | |
| loadConfigToUI(domElements); | |
| if (domElements.presetSelector) { | |
| domElements.presetSelector.value = 'default'; | |
| } | |
| if (uiCallbacks.onUpdate) { | |
| uiCallbacks.onUpdate(); | |
| } | |
| if (uiCallbacks.setStatus) { | |
| uiCallbacks.setStatus('Settings reset to default', 'online'); | |
| } | |
| }); | |
| } | |
| } | |
| // Auto-apply on load | |
| if (typeof window !== 'undefined') { | |
| window.addEventListener('DOMContentLoaded', () => { | |
| applyConfigToDOM(); | |
| }); | |
| } | |