Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/app/view/codeeditor/codeeditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ interface CodeEditorProps {
text: string;
readonly: boolean;
language?: string;
fileName?: string;
onChange?: (text: string) => void;
onMount?: (monacoPtr: MonacoTypes.editor.IStandaloneCodeEditor, monaco: Monaco) => () => void;
}

export function CodeEditor({ blockId, text, language, readonly, onChange, onMount }: CodeEditorProps) {
export function CodeEditor({ blockId, text, language, fileName, readonly, onChange, onMount }: CodeEditorProps) {
const divRef = useRef<HTMLDivElement>(null);
const unmountRef = useRef<() => void>(null);
const minimapEnabled = useOverrideConfigAtom(blockId, "editor:minimapenabled") ?? false;
const stickyScrollEnabled = useOverrideConfigAtom(blockId, "editor:stickyscrollenabled") ?? false;
const wordWrap = useOverrideConfigAtom(blockId, "editor:wordwrap") ?? false;
const fontSize = boundNumber(useOverrideConfigAtom(blockId, "editor:fontsize"), 6, 64);
const theme = "wave-theme-dark";
const editorPath = useRef(crypto.randomUUID()).current;
const editorPath = useRef(fileName ?? crypto.randomUUID()).current;

React.useEffect(() => {
return () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/view/preview/preview-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function CodeEditPreview({ model }: SpecializedViewProps) {
const fileContent = useAtomValue(model.fileContent);
const setNewFileContent = useSetAtom(model.newFileContent);
const fileInfo = useAtomValue(model.statFile);
const fileName = fileInfo?.path || fileInfo?.name;

function codeEditKeyDownHandler(e: WaveKeyboardEvent): boolean {
if (checkKeyPressed(e, "Cmd:e")) {
Expand Down Expand Up @@ -65,6 +66,7 @@ function CodeEditPreview({ model }: SpecializedViewProps) {
<CodeEditor
blockId={model.blockId}
text={fileContent}
fileName={fileName}
readonly={fileInfo.readonly}
onChange={(text) => setNewFileContent(text)}
onMount={onMount}
Expand Down