{#if profileEvent}
-
{JSON.stringify(profileEvent, null, 2)}
+
{JSON.stringify(profileEvent, null, 2)}
{:else}
Loading profile event...
{/if}
@@ -688,18 +710,23 @@
}
.json-content {
+ background: #1e1e1e !important; /* VS Code dark background, same as code blocks */
+ border: 1px solid #3e3e3e;
+ border-radius: 0.25rem;
+ padding: 1rem;
margin: 0;
- font-family: 'Courier New', monospace;
- font-size: 0.875rem;
- line-height: 1.5;
- color: var(--fog-text, #1f2937);
- white-space: pre-wrap;
- word-break: break-word;
- overflow-wrap: break-word;
+ overflow-x: auto;
}
- :global(.dark) .json-content {
- color: var(--fog-dark-text, #f9fafb);
+ .json-content code {
+ display: block;
+ overflow-x: auto;
+ padding: 0;
+ background: transparent !important;
+ color: #d4d4d4; /* VS Code text color */
+ font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Droid Sans Mono', 'Source Code Pro', monospace;
+ font-size: 0.875rem;
+ line-height: 1.5;
}
@media (max-width: 640px) {
@@ -721,6 +748,10 @@
}
.json-content {
+ padding: 0.75rem;
+ }
+
+ .json-content code {
font-size: 0.75rem;
}
}
diff --git a/src/lib/components/write/AdvancedEditor.svelte b/src/lib/components/write/AdvancedEditor.svelte
index 25eff88..8b292ed 100644
--- a/src/lib/components/write/AdvancedEditor.svelte
+++ b/src/lib/components/write/AdvancedEditor.svelte
@@ -19,6 +19,9 @@
import MediaViewer from '../content/MediaViewer.svelte';
import type { NostrEvent } from '../../types/nostr.js';
import Icon from '../ui/Icon.svelte';
+ // @ts-ignore - highlight.js default export works at runtime
+ import hljs from 'highlight.js';
+ import 'highlight.js/styles/vs2015.css';
interface Props {
value: string;
@@ -46,6 +49,22 @@
let previewContent = $state
('');
let previewEvent = $state(null);
let eventJson = $state('{}');
+ let jsonPreviewRef: HTMLElement | null = $state(null);
+
+ // Highlight JSON when it changes
+ $effect(() => {
+ if (jsonPreviewRef && eventJson && jsonPreviewRef instanceof HTMLElement) {
+ try {
+ const highlighted = hljs.highlight(eventJson, { language: 'json' }).value;
+ jsonPreviewRef.innerHTML = highlighted;
+ jsonPreviewRef.className = 'hljs language-json';
+ } catch (err) {
+ // Fallback to plain text if highlighting fails
+ jsonPreviewRef.textContent = eventJson;
+ jsonPreviewRef.className = 'language-json';
+ }
+ }
+ });
// Media viewer state for preview
let mediaViewerOpen = $state(false);
@@ -1121,7 +1140,7 @@