This commit is contained in:
seb
2026-10-07 13:36:16 +02:00
parent 7045fe5e69
commit 8f46e59f08
19 changed files with 299 additions and 66 deletions

View File

@@ -62,18 +62,24 @@ export default class VfsEditorPanel extends PureComponent {
handleMentionInChat = (file, lineInfo = null) => {
if (!file) return;
if (this.props.onMentionReference) {
this.props.onMentionReference({
fileName: file.name,
path: file.name,
startLine: lineInfo?.startLine || null,
endLine: lineInfo?.endLine || null,
selectedText: lineInfo?.selectedText || '',
isImage: file.isImage || false,
});
return;
}
if (this.props.onInsertToChat) {
const isImg = file.isImage;
let tag = '';
if (lineInfo?.startLine) {
const lineRef =
lineInfo.startLine === lineInfo.endLine
? `L${lineInfo.startLine}`
: `L${lineInfo.startLine}-L${lineInfo.endLine}`;
tag = `[${file.name}#${lineRef}](${file.name}#${lineRef})`;
} else {
tag = isImg ? `![${file.name}](${file.name})` : `[${file.name}](${file.name})`;
}
const tag = lineInfo?.startLine
? `[${file.name}#${lineInfo.startLine === lineInfo.endLine ? `L${lineInfo.startLine}` : `L${lineInfo.startLine}-L${lineInfo.endLine}`}](${file.name}#${lineInfo.startLine === lineInfo.endLine ? `L${lineInfo.startLine}` : `L${lineInfo.startLine}-L${lineInfo.endLine}`})`
: isImg
? `![${file.name}](${file.name})`
: `[${file.name}](${file.name})`;
this.props.onInsertToChat(tag);
}
};

View File

@@ -466,11 +466,9 @@ export default class VfsFileExplorer extends PureComponent {
render() {
const {
loading,
onRefresh,
onOpenNewDialog,
searchQuery,
onSearchChange,
files,
} = this.props;
const { menuAnchor, menuFile, isDraggingOver } = this.state;

View File

@@ -125,7 +125,7 @@ export default class VfsFilePreview extends PureComponent {
}
render() {
const { fileName, file, onClose, onDownload, onMentionInChat } = this.props;
const { fileName, file, onClose, onMentionInChat } = this.props;
const vfsUrl = `/api/vfs/${encodeURIComponent(fileName).replace(/%2F/g, '/')}?raw=1`;
return (

View File

@@ -56,7 +56,7 @@ export default class VfsNewFileDialog extends PureComponent {
handleSubmit = (e) => {
e?.preventDefault();
const clean = this.state.filename.trim().replace(/^[\/\\]+/, '');
const clean = this.state.filename.trim().replace(/^[/\\]+/, '');
if (!clean) {
this.setState({ error: 'Bitte gib einen Dateinamen ein.' });
return;

View File

@@ -152,7 +152,6 @@ export default class VfsTextEditor extends PureComponent {
loadingContent,
onSave,
onClose,
onDownload,
onMentionInChat,
} = this.props;
@@ -316,7 +315,7 @@ export default class VfsTextEditor extends PureComponent {
autoCorrect="off"
autoCapitalize="off"
wrap={this.state.wrapLines ? 'soft' : 'off'}
sx={(theme) => ({
sx={{
flexGrow: 1,
height: '100%',
p: 1.5,
@@ -337,7 +336,7 @@ export default class VfsTextEditor extends PureComponent {
'&:focus': {
outline: 'none',
},
})}
}}
/>
</>
)}

View File

@@ -85,7 +85,7 @@ export function getVfsCategory(filePath, mime = '') {
* @returns {{ dir: string, base: string }}
*/
export function splitVfsPath(path) {
const clean = String(path || '').replace(/^[\/\\]+/, '');
const clean = String(path || '').replace(/^[/\\]+/, '');
const lastSlash = clean.lastIndexOf('/');
if (lastSlash === -1) {
return { dir: '', base: clean };