groove-dev 0.26.14 → 0.26.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" type="image/png" href="/favicon.png" />
7
7
  <title>Groove GUI</title>
8
- <script type="module" crossorigin src="/assets/index-D5zShz2P.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CBlL5EFb.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/vendor-C0HXlhrU.js">
10
10
  <link rel="modulepreload" crossorigin href="/assets/reactflow-BQPfi37R.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/codemirror-BBL3i_JW.js">
@@ -5,11 +5,16 @@ import { FileTree } from '../components/editor/file-tree';
5
5
  import { EditorTabs } from '../components/editor/editor-tabs';
6
6
  import { CodeEditor } from '../components/editor/code-editor';
7
7
  import { MediaViewer, isMediaFile } from '../components/editor/media-viewer';
8
- import { Code2, AlertTriangle, RefreshCw, X } from 'lucide-react';
8
+ import { Code2, AlertTriangle, RefreshCw, X, Eye, FileCode } from 'lucide-react';
9
9
  import { Button } from '../components/ui/button';
10
10
  import { api } from '../lib/api';
11
11
  import { cn } from '../lib/cn';
12
12
 
13
+ function isHtmlFile(path) {
14
+ const ext = path?.split('.').pop()?.toLowerCase();
15
+ return ext === 'html' || ext === 'htm';
16
+ }
17
+
13
18
  export default function EditorView() {
14
19
  const activeFile = useGrooveStore((s) => s.editorActiveFile);
15
20
  const files = useGrooveStore((s) => s.editorFiles);
@@ -20,14 +25,20 @@ export default function EditorView() {
20
25
  const dismissFileChange = useGrooveStore((s) => s.dismissFileChange);
21
26
 
22
27
  const [rootDir, setRootDir] = useState('');
28
+ const [previewMode, setPreviewMode] = useState(false);
29
+ const [previewKey, setPreviewKey] = useState(0);
23
30
 
24
31
  // Fetch root dir
25
32
  useEffect(() => {
26
33
  api.get('/files/root').then((d) => setRootDir(d.root || '')).catch(() => {});
27
34
  }, []);
28
35
 
36
+ // Reset preview mode when switching files
37
+ useEffect(() => { setPreviewMode(false); }, [activeFile]);
38
+
29
39
  const file = activeFile ? files[activeFile] : null;
30
40
  const isMedia = activeFile && isMediaFile(activeFile);
41
+ const isHtml = activeFile && isHtmlFile(activeFile);
31
42
  const hasExternalChange = activeFile && changedFiles[activeFile];
32
43
 
33
44
  return (
@@ -70,7 +81,52 @@ export default function EditorView() {
70
81
 
71
82
  {activeFile && isMedia && <MediaViewer path={activeFile} />}
72
83
 
73
- {activeFile && !isMedia && file && (
84
+ {activeFile && !isMedia && isHtml && (
85
+ <>
86
+ {/* Code / Preview toggle for HTML files */}
87
+ <div className="absolute top-0 right-4 z-10 flex items-center gap-0.5 mt-2 bg-surface-2 border border-border-subtle rounded-md p-0.5">
88
+ <button
89
+ onClick={() => setPreviewMode(false)}
90
+ className={cn(
91
+ 'flex items-center gap-1.5 px-2.5 py-1 text-xs font-sans rounded cursor-pointer transition-colors',
92
+ !previewMode ? 'bg-surface-4 text-text-0 font-medium' : 'text-text-3 hover:text-text-1',
93
+ )}
94
+ >
95
+ <FileCode size={12} /> Code
96
+ </button>
97
+ <button
98
+ onClick={() => { setPreviewMode(true); setPreviewKey((k) => k + 1); }}
99
+ className={cn(
100
+ 'flex items-center gap-1.5 px-2.5 py-1 text-xs font-sans rounded cursor-pointer transition-colors',
101
+ previewMode ? 'bg-surface-4 text-text-0 font-medium' : 'text-text-3 hover:text-text-1',
102
+ )}
103
+ >
104
+ <Eye size={12} /> Preview
105
+ </button>
106
+ </div>
107
+
108
+ {previewMode ? (
109
+ <iframe
110
+ key={previewKey}
111
+ src={`/api/files/raw?path=${encodeURIComponent(activeFile)}`}
112
+ className="w-full h-full border-0"
113
+ sandbox="allow-scripts allow-same-origin"
114
+ title="HTML Preview"
115
+ />
116
+ ) : (
117
+ file && (
118
+ <CodeEditor
119
+ content={file.content}
120
+ language={file.language}
121
+ onChange={(content) => updateFileContent(activeFile, content)}
122
+ onSave={() => saveFile(activeFile)}
123
+ />
124
+ )
125
+ )}
126
+ </>
127
+ )}
128
+
129
+ {activeFile && !isMedia && !isHtml && file && (
74
130
  <CodeEditor
75
131
  content={file.content}
76
132
  language={file.language}