Keep empty region previews blank

This commit is contained in:
2026-09-14 00:22:39 +01:00
parent 1e317997c4
commit 67c1e29154
13 changed files with 22 additions and 15 deletions
+2
View File
@@ -11,6 +11,8 @@ All notable changes to this project will be documented in this file.
- Fixed cached API and RSS images not being served by the player after being downloaded. - Fixed cached API and RSS images not being served by the player after being downloaded.
- Fixed blank time/date regions displaying the default clock format on the player. - Fixed blank time/date regions displaying the default clock format on the player.
- Fixed the time/date placeholder popup omitting text and math transform help. - Fixed the time/date placeholder popup omitting text and math transform help.
- Fixed empty region previews displaying type labels instead of remaining blank.
- Fixed empty weather regions displaying the default weather summary.
## 2.13.2 - 2026-09-11 ## 2.13.2 - 2026-09-11
+2 -1
View File
@@ -69,6 +69,8 @@ function substituteWeatherVariables(html, value) {
} }
function renderWeatherRegion(region, regionContent) { function renderWeatherRegion(region, regionContent) {
var value = String(regionContent && regionContent.value || '');
if (!value.trim()) return '';
var location = getWeatherLocation(regionContent && regionContent.weather_location_id); var location = getWeatherLocation(regionContent && regionContent.weather_location_id);
var snapshot = location && location.responseJson && typeof location.responseJson === 'object' ? location.responseJson : null; var snapshot = location && location.responseJson && typeof location.responseJson === 'object' ? location.responseJson : null;
var width = Math.max(1, Math.round(Number(region && region.pixelWidth) || 1)); var width = Math.max(1, Math.round(Number(region && region.pixelWidth) || 1));
@@ -77,7 +79,6 @@ function renderWeatherRegion(region, regionContent) {
var style = 'width:' + width + 'px;height:' + height + 'px;transform:scale(' + scale + ');transform-origin:top left;overflow:hidden;'; var style = 'width:' + width + 'px;height:' + height + 'px;transform:scale(' + scale + ');transform-origin:top left;overflow:hidden;';
if (!location || !snapshot) return '<div class="template-region weather" style="' + region.baseStyle + '"><div style="' + style + '"></div></div>'; if (!location || !snapshot) return '<div class="template-region weather" style="' + region.baseStyle + '"><div style="' + style + '"></div></div>';
var current = snapshot.current || {}; var current = snapshot.current || {};
var value = String(regionContent && regionContent.value || '');
if (value) { if (value) {
var weatherData = withWeatherUnits(snapshot, location); var weatherData = withWeatherUnits(snapshot, location);
var fontSize = Math.max(8, Number(regionContent && regionContent.font_size || region && (region.font_size || region.fontSize) || 32) || 32); var fontSize = Math.max(8, Number(regionContent && regionContent.font_size || region && (region.font_size || region.fontSize) || 32) || 32);
+1 -1
View File
@@ -44,7 +44,7 @@
function renderPreview(region, value) { function renderPreview(region, value) {
var html = normalizePreviewValue(value !== undefined ? value : region).trim(); var html = normalizePreviewValue(value !== undefined ? value : region).trim();
if (!html) { if (!html) {
return '<div class="slide-preview-placeholder">HTML</div>'; return '';
} }
if (/^<!doctype\b/i.test(html) || /^<html\b/i.test(html)) { if (/^<!doctype\b/i.test(html) || /^<html\b/i.test(html)) {
return '<iframe class="slide-preview-html-frame" sandbox="" allowtransparency="true" scrolling="no" srcdoc="' + escapeHtml(buildHtmlDocument(html)) + '" title="HTML preview" loading="eager" style="width:100%;height:100%;border:0;display:block;background:transparent;overflow:hidden;"></iframe>'; return '<iframe class="slide-preview-html-frame" sandbox="" allowtransparency="true" scrolling="no" srcdoc="' + escapeHtml(buildHtmlDocument(html)) + '" title="HTML preview" loading="eager" style="width:100%;height:100%;border:0;display:block;background:transparent;overflow:hidden;"></iframe>';
+1 -1
View File
@@ -21,7 +21,7 @@
var content = value && typeof value === 'object' && value.value !== undefined ? value : null; var content = value && typeof value === 'object' && value.value !== undefined ? value : null;
var src = String(content ? content.value : value || '').trim(); var src = String(content ? content.value : value || '').trim();
if (!src) { if (!src) {
return '<div class="slide-preview-placeholder">Image</div>'; return '';
} }
return '<img class="slide-preview-image" src="' + escapeHtml(src) + '" alt="" style="width:100%;height:100%;object-fit:contain;display:block;" />'; return '<img class="slide-preview-image" src="' + escapeHtml(src) + '" alt="" style="width:100%;height:100%;object-fit:contain;display:block;" />';
} }
+1 -1
View File
@@ -880,7 +880,7 @@
src = svgSrc || buildStyledQrSvgMarkup(value); src = svgSrc || buildStyledQrSvgMarkup(value);
} }
if (!src) { if (!src) {
return '<div class="slide-preview-placeholder">QR Code</div>'; return '';
} }
if (/^data:image\//i.test(src)) { if (/^data:image\//i.test(src)) {
return '<img class="slide-preview-qr-code" src="' + escapeHtml(src) + '" alt="QR code preview" style="' + imageStyle + '" />'; return '<img class="slide-preview-qr-code" src="' + escapeHtml(src) + '" alt="QR code preview" style="' + imageStyle + '" />';
+2 -2
View File
@@ -158,7 +158,7 @@
function getPreviewFallback(item) { function getPreviewFallback(item) {
if (!item || typeof item !== 'object') { if (!item || typeof item !== 'object') {
return '<div class="slide-preview-placeholder">RSS item</div>'; return '';
} }
var title = String(item.title || '').trim(); var title = String(item.title || '').trim();
@@ -171,7 +171,7 @@
summary.push('<p>' + sanitizePreviewHtml(description) + '</p>'); summary.push('<p>' + sanitizePreviewHtml(description) + '</p>');
} }
if (!summary.length) { if (!summary.length) {
return '<div class="slide-preview-placeholder">RSS item</div>'; return '';
} }
return summary.join(''); return summary.join('');
} }
+4 -1
View File
@@ -11,7 +11,10 @@
function renderPreview(value, disableAudio) { function renderPreview(value, disableAudio) {
var content = value && typeof value === 'object' && value.value !== undefined ? value : null; var content = value && typeof value === 'object' && value.value !== undefined ? value : null;
var src = String(content ? content.value : value || '').trim(); var src = String(content ? content.value : value || '').trim();
var label = src ? 'RTMP' : 'RTMP stream'; if (!src) {
return '';
}
var label = 'RTMP';
if (disableAudio) { if (disableAudio) {
label += ' (muted)'; label += ' (muted)';
} }
+1 -1
View File
@@ -29,7 +29,7 @@
var rawValue = value && typeof value === 'object' && value.value !== undefined ? value.value : value; var rawValue = value && typeof value === 'object' && value.value !== undefined ? value.value : value;
var raw = String(rawValue || ''); var raw = String(rawValue || '');
if (!raw) { if (!raw) {
return '<div class="slide-preview-placeholder">Empty text</div>'; return '';
} }
var style = styleOrContext && styleOrContext.style ? styleOrContext.style : styleOrContext || {}; var style = styleOrContext && styleOrContext.style ? styleOrContext.style : styleOrContext || {};
+1 -1
View File
@@ -26,7 +26,7 @@
var content = value && typeof value === 'object' && value.value !== undefined ? value : null; var content = value && typeof value === 'object' && value.value !== undefined ? value : null;
var src = String(content ? content.value : value || '').trim(); var src = String(content ? content.value : value || '').trim();
if (!src) { if (!src) {
return '<div class="slide-preview-placeholder">Video</div>'; return '';
} }
return '<video class="slide-preview-video" src="' + escapeHtml(src) + '" autoplay loop muted playsinline preload="metadata" style="width:100%;height:100%;object-fit:contain;display:block;"></video>'; return '<video class="slide-preview-video" src="' + escapeHtml(src) + '" autoplay loop muted playsinline preload="metadata" style="width:100%;height:100%;object-fit:contain;display:block;"></video>';
} }
+3 -2
View File
@@ -148,10 +148,11 @@
function renderPreview(region, content, context) { function renderPreview(region, content, context) {
var locations = context && context.weatherLocations ? context.weatherLocations : []; var locations = context && context.weatherLocations ? context.weatherLocations : [];
var value = String(content && content.value || '');
if (!value.trim()) return '';
var location = getLocationById(content && content.weather_location_id, locations); var location = getLocationById(content && content.weather_location_id, locations);
var snapshot = getSnapshot(location); var snapshot = getSnapshot(location);
var value = String(content && content.value || ''); if (!location || !snapshot) return '';
if (!location || !snapshot) return '<div class="template-region weather"><div class="slide-preview-placeholder">Select a weather location with cached data</div></div>';
var weatherData = withWeatherUnits(snapshot, location); var weatherData = withWeatherUnits(snapshot, location);
if (value) { if (value) {
var fontSize = Math.max(8, Number(content && content.font_size || region && (region.font_size || region.fontSize) || 32) || 32); var fontSize = Math.max(8, Number(content && content.font_size || region && (region.font_size || region.fontSize) || 32) || 32);
+1 -1
View File
@@ -37,7 +37,7 @@
function renderPreview(region, value) { function renderPreview(region, value) {
var src = normalizePreviewValue(value !== undefined ? value : region).trim(); var src = normalizePreviewValue(value !== undefined ? value : region).trim();
if (!src) { if (!src) {
return '<div class="slide-preview-placeholder">Webpage</div>'; return '';
} }
return '<iframe class="slide-preview-webpage-frame" src="' + escapeHtml(src) + '" title="Webpage preview" loading="eager" referrerpolicy="no-referrer" scrolling="no" style="width:100%;height:100%;border:0;display:block;background:#fff;overflow:hidden;"></iframe>'; return '<iframe class="slide-preview-webpage-frame" src="' + escapeHtml(src) + '" title="Webpage preview" loading="eager" referrerpolicy="no-referrer" scrolling="no" style="width:100%;height:100%;border:0;display:block;background:#fff;overflow:hidden;"></iframe>';
} }
@@ -187,7 +187,7 @@ export function createSlideFormPreviewHelpers(options) {
} }
var raw = String(rawValue || ''); var raw = String(rawValue || '');
if (!raw) { if (!raw) {
return '<div class="slide-preview-placeholder">Empty text</div>'; return '';
} }
return sanitizePreviewHtml(raw); return sanitizePreviewHtml(raw);
} }
@@ -323,7 +323,7 @@ export function createSlideFormRegionHelpers(options) {
} }
if (!item || typeof item !== 'object') { if (!item || typeof item !== 'object') {
return '<div class="slide-preview-placeholder">RSS item</div>'; return '';
} }
var title = String(item.title || '').trim(); var title = String(item.title || '').trim();
@@ -336,7 +336,7 @@ export function createSlideFormRegionHelpers(options) {
summary.push('<p>' + sanitizePreviewHtml(description) + '</p>'); summary.push('<p>' + sanitizePreviewHtml(description) + '</p>');
} }
if (!summary.length) { if (!summary.length) {
return '<div class="slide-preview-placeholder">RSS item</div>'; return '';
} }
return summary.join(''); return summary.join('');
} }