fix: preview affichait du JSON brut au lieu du texte des pages FlowDeck
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

Ajout de _extractPreview(): parse le JSON Notion blocks, extrait le
texte des champs .content ou .text de chaque block. Fallback sur le
raw content si le format n'est pas blocks/markdown.

Avant: {"blocks":[{"type":"text","content":"Hello"}]}
Après: Hello
This commit is contained in:
2026-07-11 10:34:04 -04:00
parent 51cad3ee16
commit d97f79f737
+22 -1
View File
@@ -504,11 +504,32 @@ document.addEventListener('alpine:init', function() {
fetch('/api/local-workspace/page-content/' + node.id)
.then(function(r) { return r.json(); })
.then(function(d) {
self.previewContent = (d.content || '').substring(0, 500);
self.previewContent = self._extractPreview(d.content || '', d.format);
})
.catch(function() { self.previewContent = '(preview not available)'; });
}
},
_extractPreview(content, format) {
if (!content) return '(empty)';
// Try to extract text from Notion block JSON
if (format === 'blocks' || format === 'markdown') {
try {
var blocks = typeof content === 'string' ? JSON.parse(content) : content;
if (blocks && blocks.blocks && Array.isArray(blocks.blocks)) {
var lines = [];
for (var i=0; i<blocks.blocks.length && lines.length<20; i++) {
var b = blocks.blocks[i];
if (b.content) lines.push(b.content);
else if (b.text) lines.push(b.text);
else if (typeof b === 'string') lines.push(b);
}
return lines.join('\n').substring(0, 500) || '(empty)';
}
} catch(e) {}
}
// Fallback: raw text
return String(content).substring(0, 500);
},
hidePreview() {
this.previewVisible = false;
},