Add file empty tips for the file editor component
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"tab_settings": "Einstellungen",
|
||||
"tab_about": "Über",
|
||||
"tab_file_editor": "Editor",
|
||||
"file_empty_tips": "Bitte wählen Sie eine Datei zum Bearbeiten aus",
|
||||
"continue_inputting_prompt": "Bitte weitermachen",
|
||||
"copy_btn": "Kopieren",
|
||||
"insert_btn": "Einfügen",
|
||||
@@ -97,4 +98,4 @@
|
||||
"file_editor_forgot_save_tips_title": "Möchten Sie die Änderungen an {{fileName}} speichern?",
|
||||
"file_editor_forgot_save_tips_content": "Ihre Änderungen gehen verloren, wenn Sie sie nicht speichern."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"tab_settings": "Settings",
|
||||
"tab_about": "About",
|
||||
"tab_file_editor": "Editor",
|
||||
"file_empty_tips": "Please select a file to edit",
|
||||
"continue_inputting_prompt": "Please continue",
|
||||
"copy_btn": "Copy",
|
||||
"insert_btn": "Insert",
|
||||
@@ -97,4 +98,4 @@
|
||||
"file_editor_forgot_save_tips_title": "Do you want to save changes to {{fileName}}?",
|
||||
"file_editor_forgot_save_tips_content": "Your changes will be lost if you don't save them."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"tab_settings": "設定",
|
||||
"tab_about": "情報",
|
||||
"tab_file_editor": "エディター",
|
||||
"file_empty_tips": "編集するファイルを選択してください",
|
||||
"continue_inputting_prompt": "続けてください",
|
||||
"copy_btn": "コピー",
|
||||
"insert_btn": "挿入",
|
||||
@@ -97,4 +98,4 @@
|
||||
"file_editor_forgot_save_tips_title": "変更を{{fileName}}に保存しますか?",
|
||||
"file_editor_forgot_save_tips_content": "保存しない場合、変更は失われます。"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"tab_settings": "设置",
|
||||
"tab_about": "关于",
|
||||
"tab_file_editor": "编辑器",
|
||||
"file_empty_tips": "请选择要编辑的文件",
|
||||
"continue_inputting_prompt": "请继续",
|
||||
"copy_btn": "复制",
|
||||
"insert_btn": "插入",
|
||||
@@ -97,4 +98,4 @@
|
||||
"file_editor_forgot_save_tips_title": "你想要保存对{{fileName}}的更改吗?",
|
||||
"file_editor_forgot_save_tips_content": "如果你不保存,你的改动将会丢失."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"tab_settings": "設定",
|
||||
"tab_about": "關於",
|
||||
"tab_file_editor": "編輯器",
|
||||
"file_empty_tips": "請選擇要編輯的檔案",
|
||||
"continue_inputting_prompt": "請繼續",
|
||||
"copy_btn": "複製",
|
||||
"insert_btn": "插入",
|
||||
@@ -97,4 +98,4 @@
|
||||
"file_editor_forgot_save_tips_title": "你想要保存對{{fileName}}的更改嗎?",
|
||||
"file_editor_forgot_save_tips_content": "如果你不保存,你的改動將會丟失."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,3 +6,17 @@ export const FileEditorWrapper = styled.div`
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
`
|
||||
|
||||
export const EmptyEditorWrapper = styled.div`
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
background-color: var(--panel-view-background);
|
||||
color: var(--foreground);
|
||||
user-select: text;
|
||||
text-align: center;
|
||||
`
|
||||
|
||||
@@ -10,7 +10,7 @@ import { PanelTab } from '../../../../components/panel-tab'
|
||||
import type { FileEditorItem } from '../../../../store/zustand/file-editor/file-editor-item'
|
||||
import { useElementSizeRealTime } from '../../../../hooks/use-element-size-real-time.hook'
|
||||
import { saveFileContent } from '../../../../networks/editor'
|
||||
import { FileEditorWrapper } from './file-editor.styles'
|
||||
import { EmptyEditorWrapper, FileEditorWrapper } from './file-editor.styles'
|
||||
import { FileEditorTabLabel } from './components/file-editor-tab-label'
|
||||
import { FileContentEditor } from './components/file-content-editor'
|
||||
|
||||
@@ -38,6 +38,7 @@ export const FileEditor: FC<FileEditorProps> = memo((props) => {
|
||||
updateFileEditorItem,
|
||||
removeFileEditorItem,
|
||||
} = useFileEditorStore()
|
||||
console.log('fileEditorItems', fileEditorItems)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const { mutate: saveFileToRemote, isLoading: saveFileLoading } = useMutation({
|
||||
mutationFn: (params: SaveFileContentReqParams) => saveFileContent(params),
|
||||
@@ -75,7 +76,7 @@ export const FileEditor: FC<FileEditorProps> = memo((props) => {
|
||||
fileName,
|
||||
dirPath,
|
||||
}
|
||||
|
||||
// If user open the same name file, we need to show parent path
|
||||
if (fileName) {
|
||||
const count = fileNameMap.get(fileName) || 0
|
||||
fileNameMap.set(fileName, count + 1)
|
||||
@@ -149,8 +150,8 @@ export const FileEditor: FC<FileEditorProps> = memo((props) => {
|
||||
|
||||
return <FileEditorWrapper ref={fileEditorRef}>
|
||||
{isLoading && <LoadingView absolute></LoadingView>}
|
||||
|
||||
<PanelTab
|
||||
{fileTabItems.length
|
||||
? (<PanelTab
|
||||
items={fileTabItems}
|
||||
activeId={activeFileFullPath}
|
||||
onChange={(id) => {
|
||||
@@ -167,7 +168,8 @@ export const FileEditor: FC<FileEditorProps> = memo((props) => {
|
||||
tabItemStyles={{
|
||||
padding: 0,
|
||||
}}
|
||||
/>
|
||||
/>)
|
||||
: <EmptyEditorWrapper>{t('chat_page.file_empty_tips')}</EmptyEditorWrapper>}
|
||||
</FileEditorWrapper>
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user