feat(draw): fold the d2 source into a "view source" disclosure (T-494)
The rendered diagram leads; the d2 source carries through the draw bus and folds into a collapsed ClideCollapserCard beneath the card (D-78 display- only). en+nl catalogs. Also switches the d2 test to a null-aware element. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -720,6 +720,10 @@ class _ConversationTurn extends StatelessWidget {
|
||||
document: doc,
|
||||
label: m.label,
|
||||
description: m.description,
|
||||
source: m.source,
|
||||
sourceLabel: m.source == null
|
||||
? null
|
||||
: ClideSettings.i18n.string(context, 'conversation.draw.viewSource', namespace: 'builtin.claude', placeholder: 'view d2 source'),
|
||||
// A data-lightbox element opens the whole drawing, zoomable (T-318).
|
||||
onLightbox: () => ClideKernel.of(context).dialog.show<Object>(
|
||||
(ctx, dismiss) => ClideLightbox(
|
||||
|
||||
@@ -661,6 +661,7 @@ class ClaudeExtension extends ClideExtension {
|
||||
svg: svg,
|
||||
label: m.data['label'] as String?,
|
||||
description: m.data['description'] as String?,
|
||||
source: m.data['source'] as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,15 @@ final class ImageMessage extends ConversationItem {
|
||||
/// paints (already lowered from the doc's template / primitive source);
|
||||
/// [label] / [description] are the optional card caption.
|
||||
final class DrawingMessage extends ConversationItem {
|
||||
const DrawingMessage({required super.uuid, required super.timestamp, required super.isSidechain, required this.svg, this.label, this.description});
|
||||
const DrawingMessage({
|
||||
required super.uuid,
|
||||
required super.timestamp,
|
||||
required super.isSidechain,
|
||||
required this.svg,
|
||||
this.label,
|
||||
this.description,
|
||||
this.source,
|
||||
});
|
||||
|
||||
/// The SVG document source the renderer paints.
|
||||
final String svg;
|
||||
@@ -204,6 +212,10 @@ final class DrawingMessage extends ConversationItem {
|
||||
/// Optional card-level caption (label + supporting description).
|
||||
final String? label, description;
|
||||
|
||||
/// Optional template source (e.g. the d2 diagram text) — shown in a collapsed
|
||||
/// "view source" disclosure on the card when present (T-494).
|
||||
final String? source;
|
||||
|
||||
@override
|
||||
String toString() => 'DrawingMessage(${label ?? '<svg>'})';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user