|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| import { ConfigStorage } from './config-storage.js';
|
|
|
|
|
|
|
|
|
|
|
| let currentDisplayMode = 'intro';
|
|
|
| |
| |
| |
|
|
| 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}`);
|
|
|
|
|
| window.dispatchEvent(new CustomEvent('displayModeChanged', {
|
| detail: { mode }
|
| }));
|
| }
|
|
|
| |
| |
| |
|
|
| export function getDisplayMode() {
|
| return currentDisplayMode;
|
| }
|
|
|
|
|
|
|
|
|
|
|
| |
| |
| |
|
|
| export const INTRO_SAFE_ZONE_CONFIG = {
|
| margins: {
|
| horizontalRatio: 0.08,
|
| verticalRatio: 0.10,
|
| maxHorizontalRatio: 0.15,
|
| maxVerticalRatio: 0.18,
|
| minHorizontal: 60,
|
| minVertical: 60
|
| },
|
| border: {
|
| enabled: false,
|
| color: 'rgba(100, 116, 139, 0.3)',
|
| width: 1,
|
| glowColor: 'rgba(100, 116, 139, 0.2)',
|
| glowSize: '2px',
|
| zIndex: 1000
|
| },
|
| enforcement: {
|
| enabled: false,
|
| snapToEdge: false,
|
| showWarning: false
|
| }
|
| };
|
|
|
| |
| |
| |
|
|
| export const EDITOR_SAFE_ZONE_CONFIG = {
|
| margins: {
|
| horizontalRatio: 0.06,
|
| verticalRatio: 0.08,
|
| 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
|
| }
|
| };
|
|
|
| |
| |
| |
|
|
| export const PRESENTATION_SAFE_ZONE_CONFIG = {
|
| margins: {
|
| horizontalRatio: 0.05,
|
| verticalRatio: 0.07,
|
| 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
|
| }
|
| };
|
|
|
| |
| |
| |
|
|
| 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 };
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| export const SAFE_ZONE_CONFIG = new Proxy({}, {
|
| get(target, prop) {
|
| return getSafeZoneConfig()[prop];
|
| }
|
| });
|
|
|
|
|
|
|
|
|
|
|
| export const SMART_LAYOUT_CONFIG = {
|
| fillRatio: 0.92,
|
| stageFallback: {
|
| width: 1280,
|
| height: 720
|
| },
|
| autoScale: true,
|
| maintainAspectRatio: true,
|
| centerContent: true
|
| };
|
|
|
| |
| |
|
|
| export function getSmartLayoutFillRatio() {
|
| return SMART_LAYOUT_CONFIG.fillRatio;
|
| }
|
|
|
| |
| |
|
|
| export function getSmartLayoutStageFallback() {
|
| return { ...SMART_LAYOUT_CONFIG.stageFallback };
|
| }
|
|
|
| |
| |
|
|
| export function updateSmartLayoutConfig(newConfig) {
|
| Object.assign(SMART_LAYOUT_CONFIG, newConfig);
|
|
|
| window.dispatchEvent(new CustomEvent('smartLayoutConfigUpdated', {
|
| detail: SMART_LAYOUT_CONFIG
|
| }));
|
|
|
| return SMART_LAYOUT_CONFIG;
|
| }
|
|
|
| |
| |
|
|
| export function getSmartLayoutConfig() {
|
| return { ...SMART_LAYOUT_CONFIG };
|
| }
|
|
|
| |
| |
| |
| |
|
|
| export function computeSafeZoneMargins(stageRect = {}) {
|
| const width = stageRect.width || window.innerWidth;
|
| const height = stageRect.height || window.innerHeight;
|
|
|
|
|
| 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 };
|
| }
|
|
|
| |
| |
| |
|
|
| 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);
|
| }
|
|
|
|
|
| window.dispatchEvent(new CustomEvent('safeZoneConfigUpdated', {
|
| detail: SAFE_ZONE_CONFIG
|
| }));
|
|
|
| return SAFE_ZONE_CONFIG;
|
| }
|
|
|
| |
| |
|
|
| export function resetSafeZoneConfig() {
|
|
|
| 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
|
| };
|
|
|
|
|
| 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
|
| };
|
|
|
|
|
| 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();
|
| }
|
|
|
|
|
|
|
|
|
|
|
| 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 },
|
| 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',
|
| 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',
|
| },
|
| styles: {
|
| borderRadius: '1.25rem',
|
| shadow: '0 20px 40px rgba(0, 0, 0, 0.3)',
|
| lineHeight: {
|
| heading: 1.3,
|
| body: 1.7
|
| },
|
|
|
| previewOpacity: 0.68,
|
| overlayBackground: 'rgba(10, 22, 40, 0.85)',
|
| overlayBlur: '8px',
|
| navBorderWidth: '2px',
|
| navBorderOpacity: 0.5,
|
|
|
| headingAccentBorderWidth: '4px',
|
| blockquoteBorderWidth: '4px',
|
| imageBorderWidth: '2px',
|
| linkUnderlineWidth: '2px',
|
| tableBorderWidth: '1px',
|
| hrBorderWidth: '2px',
|
|
|
| backdropGradientColor: 'rgba(59, 130, 246, 0.15)',
|
| backdropGradientSpread: '70%',
|
| backdropBlur: '60px',
|
|
|
| pageIndicatorTop: '16px',
|
| pageIndicatorRight: '16px',
|
| pageIndicatorFontSize: '0.875rem',
|
| pageIndicatorOpacity: 0.7,
|
| pageIndicatorPaddingX: '12px',
|
| pageIndicatorPaddingY: '4px',
|
| pageIndicatorBgColor: 'rgba(22, 78, 99, 0.5)',
|
| pageIndicatorTextColor: '#a5f3fc'
|
| },
|
| typography: {
|
| paragraphSpacing: {
|
| before: 0.5,
|
| after: 1
|
| },
|
| headingSpacing: {
|
| before: 1.5,
|
| after: 0.75
|
| },
|
| indentation: {
|
| firstLine: 0,
|
| hanging: 0,
|
| blockQuote: 1.5
|
| },
|
| listIndent: 1.5,
|
| textAlign: 'left'
|
| },
|
| layout: {
|
| contentPadding: {
|
| small: 40,
|
| large: 48,
|
| ultra: 64
|
| },
|
| contentAlignment: {
|
| horizontal: 'center',
|
| vertical: 'center'
|
| }
|
| },
|
| smartList: {
|
| twoColumnThreshold: 6,
|
| threeColumnThreshold: 12
|
| }
|
| }
|
| },
|
|
|
| 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
|
| },
|
|
|
| previewOpacity: 0.68,
|
| overlayBackground: 'rgba(15, 23, 42, 0.9)',
|
| overlayBlur: '10px',
|
| navBorderWidth: '2px',
|
| navBorderOpacity: 0.6,
|
|
|
| headingAccentBorderWidth: '4px',
|
| blockquoteBorderWidth: '4px',
|
| imageBorderWidth: '2px',
|
| linkUnderlineWidth: '2px',
|
| tableBorderWidth: '1px',
|
| hrBorderWidth: '2px',
|
|
|
| backdropGradientColor: 'rgba(59, 130, 246, 0.2)',
|
| backdropGradientSpread: '65%',
|
| backdropBlur: '80px',
|
|
|
| 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
|
| },
|
|
|
| previewOpacity: 0.68,
|
| overlayBackground: 'rgba(255, 255, 255, 0.85)',
|
| overlayBlur: '6px',
|
| navBorderWidth: '1px',
|
| navBorderOpacity: 0.3,
|
|
|
| headingAccentBorderWidth: '2px',
|
| blockquoteBorderWidth: '3px',
|
| imageBorderWidth: '1px',
|
| linkUnderlineWidth: '1px',
|
| tableBorderWidth: '1px',
|
| hrBorderWidth: '1px',
|
|
|
| backdropGradientColor: 'rgba(0, 102, 204, 0.05)',
|
| backdropGradientSpread: '50%',
|
| backdropBlur: '20px',
|
|
|
| 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
|
| },
|
|
|
| previewOpacity: 0.68,
|
| overlayBackground: 'rgba(26, 11, 46, 0.9)',
|
| overlayBlur: '12px',
|
| navBorderWidth: '3px',
|
| navBorderOpacity: 0.7,
|
|
|
| headingAccentBorderWidth: '6px',
|
| blockquoteBorderWidth: '5px',
|
| imageBorderWidth: '3px',
|
| linkUnderlineWidth: '3px',
|
| tableBorderWidth: '2px',
|
| hrBorderWidth: '4px',
|
|
|
| backdropGradientColor: 'rgba(236, 72, 153, 0.25)',
|
| backdropGradientSpread: '75%',
|
| backdropBlur: '100px',
|
|
|
| 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
|
| }
|
| }
|
| }
|
| };
|
|
|
|
|
|
|
|
|
|
|
| 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: 'เต็มแนว' }
|
| ];
|
|
|
|
|
|
|
|
|
|
|
| let currentConfig = { ...CONFIG_PRESETS.default.config };
|
|
|
| |
| |
|
|
| export function getCurrentConfig() {
|
| return { ...currentConfig };
|
| }
|
|
|
| |
| |
|
|
| export function setConfig(newConfig, autoSave = true) {
|
| currentConfig = { ...currentConfig, ...newConfig };
|
| applyConfigToDOM();
|
|
|
|
|
| if (autoSave) {
|
| ConfigStorage.autoSave(currentConfig);
|
| }
|
|
|
| return currentConfig;
|
| }
|
|
|
| |
| |
|
|
| export function updateConfigPart(part, values, autoSave = true) {
|
| if (!currentConfig[part]) {
|
| currentConfig[part] = values;
|
| } else if (typeof values === 'object' && !Array.isArray(values)) {
|
|
|
| currentConfig[part] = deepMerge(currentConfig[part], values);
|
| } else {
|
| currentConfig[part] = values;
|
| }
|
| applyConfigToDOM();
|
|
|
|
|
| if (autoSave) {
|
| ConfigStorage.autoSave(currentConfig);
|
| }
|
|
|
| return currentConfig;
|
| }
|
|
|
| |
| |
|
|
| 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;
|
| }
|
|
|
| |
| |
|
|
| 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();
|
|
|
|
|
| if (autoSave) {
|
| ConfigStorage.autoSave(currentConfig);
|
| }
|
|
|
| return currentConfig;
|
| }
|
|
|
| |
| |
|
|
| export function resetConfig(autoSave = true) {
|
| currentConfig = { ...CONFIG_PRESETS.default.config };
|
| applyConfigToDOM();
|
|
|
|
|
| if (autoSave) {
|
| ConfigStorage.clearLocalStorage();
|
| ConfigStorage.saveToLocalStorage(currentConfig);
|
| }
|
|
|
| return currentConfig;
|
| }
|
|
|
| |
| |
|
|
| 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 async function exportConfigToFile() {
|
| return ConfigStorage.exportToFile(currentConfig);
|
| }
|
|
|
| |
| |
|
|
| 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;
|
| }
|
|
|
| |
| |
|
|
| export function getAllPresets() {
|
| return Object.entries(CONFIG_PRESETS).map(([key, preset]) => ({
|
| id: key,
|
| name: preset.name,
|
| description: preset.description
|
| }));
|
| }
|
|
|
| |
| |
|
|
| function generateClampCSS(sizeConfig) {
|
| return `clamp(${sizeConfig.min}rem, ${sizeConfig.base}vw, ${sizeConfig.max}rem)`;
|
| }
|
|
|
| |
| |
|
|
| export function applyConfigToDOM() {
|
| const root = document.documentElement;
|
|
|
| console.log('[PresentationConfig] Applying configuration to DOM...', currentConfig);
|
|
|
|
|
| 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);
|
|
|
|
|
| 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
|
| });
|
|
|
|
|
| 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);
|
|
|
|
|
| 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';
|
| }
|
|
|
|
|
| root.style.setProperty('--anim-duration', `${currentConfig.animations.duration}s`);
|
| root.style.setProperty('--anim-easing', currentConfig.animations.easing);
|
|
|
|
|
| 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);
|
|
|
|
|
| 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);
|
|
|
|
|
| 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);
|
|
|
|
|
| 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);
|
|
|
|
|
| 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);
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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 function exportConfig() {
|
| return JSON.stringify(currentConfig, null, 2);
|
| }
|
|
|
| |
| |
|
|
| 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;
|
| }
|
| }
|
|
|
| |
| |
| |
|
|
| export function updateTypography(values) {
|
| if (!currentConfig.typography) {
|
|
|
| currentConfig.typography = { ...CONFIG_PRESETS.default.config.typography };
|
| }
|
|
|
|
|
| currentConfig.typography = deepMerge(currentConfig.typography, values);
|
| applyConfigToDOM();
|
| return currentConfig;
|
| }
|
|
|
| |
| |
|
|
| export function getTypography() {
|
| return currentConfig.typography || null;
|
| }
|
|
|
|
|
|
|
|
|
|
|
| let uiCallbacks = {
|
| onUpdate: null,
|
| onSave: null,
|
| setStatus: null
|
| };
|
|
|
| |
| |
| |
| |
|
|
| export function initPresentationUI(domElements, callbacks = {}) {
|
| uiCallbacks = { ...uiCallbacks, ...callbacks };
|
|
|
|
|
| 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);
|
| });
|
| }
|
|
|
|
|
| loadConfigToUI(domElements);
|
|
|
|
|
| setupPresetListener(domElements);
|
| setupFontListeners(domElements);
|
| setupColorListeners(domElements);
|
| setupAnimationListeners(domElements);
|
| setupFontSizeListeners(domElements);
|
| setupUIStylesListeners(domElements);
|
| setupTypographyListeners(domElements);
|
| setupLayoutListeners(domElements);
|
| setupActionButtons(domElements);
|
| }
|
|
|
| |
| |
|
|
| function loadConfigToUI(domElements) {
|
|
|
| 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;
|
|
|
|
|
| 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;
|
|
|
|
|
| if (domElements.animationTransition) domElements.animationTransition.value = currentConfig.animations.slideTransition;
|
| if (domElements.animationDuration) domElements.animationDuration.value = currentConfig.animations.duration;
|
|
|
|
|
| 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;
|
| }
|
|
|
|
|
| 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;
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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;
|
| }
|
|
|
|
|
| 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;
|
| }
|
|
|
|
|
| if (currentConfig.smartList) {
|
| if (domElements.smartListTwoColumn) domElements.smartListTwoColumn.value = currentConfig.smartList.twoColumnThreshold;
|
| if (domElements.smartListThreeColumn) domElements.smartListThreeColumn.value = currentConfig.smartList.threeColumnThreshold;
|
| }
|
|
|
|
|
| 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;
|
| }
|
| }
|
|
|
| |
| |
|
|
| export function reloadUI(domElements) {
|
| loadConfigToUI(domElements);
|
| }
|
|
|
| |
| |
| |
| |
|
|
| export function loadConfigFromFrontmatter(frontmatter, domElements) {
|
|
|
| if (frontmatter['presentation.preset']) {
|
| const presetName = frontmatter['presentation.preset'];
|
| loadPreset(presetName);
|
| if (domElements && domElements.presetSelector) {
|
| domElements.presetSelector.value = presetName;
|
| }
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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']);
|
| }
|
| }
|
|
|
|
|
| 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'];
|
| }
|
|
|
|
|
| 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'];
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| 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);
|
| }
|
|
|
|
|
| if (domElements) {
|
| reloadUI(domElements);
|
| }
|
|
|
| return currentConfig;
|
| }
|
|
|
| |
| |
|
|
| function syncUIToConfig(domElements) {
|
| console.log('[PresentationConfig] Syncing UI to config...', domElements);
|
|
|
|
|
| updateConfigPart('fonts', {
|
| heading: domElements.fontHeading?.value,
|
| body: domElements.fontBody?.value,
|
| code: domElements.fontCode?.value
|
| });
|
|
|
|
|
| updateConfigPart('colors', {
|
| primary: domElements.colorPrimary?.value,
|
| accent: domElements.colorAccent?.value,
|
| background: domElements.colorBackground?.value,
|
| text: domElements.colorText?.value
|
| });
|
|
|
|
|
| updateConfigPart('animations', {
|
| slideTransition: domElements.animationTransition?.value,
|
| duration: parseFloat(domElements.animationDuration?.value || currentConfig.animations.duration)
|
| });
|
|
|
|
|
| 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)
|
| }
|
| });
|
|
|
|
|
| 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)
|
| },
|
|
|
| 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`,
|
|
|
| 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`,
|
|
|
| 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
|
| });
|
|
|
|
|
| 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
|
| });
|
|
|
|
|
| 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)
|
| });
|
|
|
|
|
| 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');
|
|
|
|
|
| if (uiCallbacks.onUpdate) {
|
| console.log('[PresentationConfig] Triggering onUpdate callback...');
|
| uiCallbacks.onUpdate();
|
| }
|
| }
|
|
|
| |
| |
|
|
| 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');
|
| }
|
| });
|
| }
|
| }
|
|
|
| |
| |
|
|
| function setupFontListeners(domElements) {
|
| [domElements.fontHeading, domElements.fontBody, domElements.fontCode].forEach(select => {
|
| if (select) {
|
|
|
| select.addEventListener('change', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(select);
|
| }
|
| });
|
| }
|
|
|
| |
| |
|
|
| function setupColorListeners(domElements) {
|
| [domElements.colorPrimary, domElements.colorAccent, domElements.colorBackground, domElements.colorText].forEach(input => {
|
| if (input) {
|
|
|
| input.addEventListener('input', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(input);
|
| }
|
| });
|
| }
|
|
|
| |
| |
|
|
| function setupAnimationListeners(domElements) {
|
| [domElements.animationTransition, domElements.animationDuration].forEach(input => {
|
| if (input) {
|
|
|
| input.addEventListener('input', () => {
|
| syncUIToConfig(domElements);
|
| });
|
| input.addEventListener('change', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(input);
|
| }
|
| });
|
| }
|
|
|
| |
| |
|
|
| 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) {
|
|
|
| input.addEventListener('input', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(input);
|
| }
|
| });
|
| }
|
|
|
| |
| |
|
|
| 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) {
|
|
|
| input.addEventListener('input', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(input);
|
| }
|
| });
|
| }
|
|
|
| |
| |
| |
|
|
| function setupVisualFeedback(inputElement) {
|
| if (!inputElement || !inputElement.id) return;
|
|
|
| const feedbackMap = {
|
|
|
| 'fontHeading': { selector: 'h1, h2, h3, h4, h5, h6', type: 'content' },
|
| 'fontBody': { selector: 'p, li, blockquote', type: 'content' },
|
| 'fontCode': { selector: 'code, pre', type: 'content' },
|
|
|
|
|
| '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' },
|
|
|
|
|
| 'colorPrimary': { selector: 'h1, a', type: 'content' },
|
| 'colorAccent': { selector: '.accent, .badge', type: 'content' },
|
| 'colorBackground': { selector: '#stage', type: 'content' },
|
| 'colorText': { selector: 'p, li, span', type: 'content' },
|
|
|
|
|
| 'lineHeightHeading': { selector: 'h1, h2, h3', type: 'content' },
|
| 'lineHeightBody': { selector: 'p, li', type: 'content' },
|
|
|
|
|
| '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' },
|
|
|
|
|
| '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' },
|
|
|
|
|
| 'smartListTwoColumn': { selector: 'ul, ol', type: 'content' },
|
| 'smartListThreeColumn': { selector: 'ul, ol', type: 'content' },
|
|
|
|
|
| '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' },
|
|
|
|
|
| '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;
|
|
|
|
|
| inputElement.addEventListener('mouseenter', () => {
|
| const stage = document.getElementById('stage');
|
| if (!stage) return;
|
|
|
| const elements = stage.querySelectorAll(mapping.selector);
|
| elements.forEach(el => {
|
|
|
| if (mapping.type === 'content') {
|
| el.style.outline = '2px solid rgba(96, 165, 250, 0.5)';
|
| el.style.outlineOffset = '4px';
|
| el.style.transition = 'outline 0.2s ease';
|
| } else {
|
| el.style.outline = '2px solid rgba(168, 85, 247, 0.5)';
|
| el.style.outlineOffset = '4px';
|
| el.style.transition = 'outline 0.2s ease';
|
| }
|
| });
|
|
|
|
|
| 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';
|
| });
|
|
|
|
|
| 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 = '';
|
| });
|
|
|
|
|
| inputElement.style.backgroundColor = '';
|
| });
|
| }
|
|
|
| |
| |
|
|
| function setupTypographyListeners(domElements) {
|
| [
|
| domElements.paragraphBefore, domElements.paragraphAfter,
|
| domElements.headingBefore, domElements.headingAfter,
|
| domElements.indentFirst, domElements.indentBlockquote,
|
| domElements.listIndent, domElements.textAlign
|
| ].forEach(input => {
|
| if (input) {
|
|
|
| input.addEventListener('input', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(input);
|
| }
|
| });
|
| }
|
|
|
| |
| |
|
|
| function setupLayoutListeners(domElements) {
|
| [
|
| domElements.contentPaddingSmall, domElements.contentPaddingLarge, domElements.contentPaddingUltra,
|
| domElements.contentAlignHorizontal, domElements.contentAlignVertical
|
| ].forEach(input => {
|
| if (input) {
|
|
|
| input.addEventListener('input', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| input.addEventListener('change', () => {
|
| syncUIToConfig(domElements);
|
| });
|
|
|
|
|
| setupVisualFeedback(input);
|
| }
|
| });
|
| }
|
|
|
| |
| |
|
|
| function setupActionButtons(domElements) {
|
|
|
| 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');
|
| }
|
| });
|
| }
|
|
|
|
|
| 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');
|
| }
|
| });
|
| }
|
| }
|
|
|
|
|
| if (typeof window !== 'undefined') {
|
| window.addEventListener('DOMContentLoaded', () => {
|
| applyConfigToDOM();
|
| });
|
| }
|
|
|
|
|