11<script setup lang="ts">
22import { computed , onMounted , onUnmounted , ref , watch } from ' vue'
33import { useStudio } from ' ../../../composables/useStudio'
4+ import { useStudioState } from ' ../../../composables/useStudioState'
45import type { StudioAction } from ' ../../../types'
56import { StudioItemActionId , TreeStatus } from ' ../../../types'
6- import { MEDIA_EXTENSIONS } from ' ../../../utils/file'
7+ import { MEDIA_EXTENSIONS , getFileExtension } from ' ../../../utils/file'
78import type { DropdownMenuItem } from ' @nuxt/ui/runtime/components/DropdownMenu.vue.d.ts'
89import { useI18n } from ' vue-i18n'
910
1011const { context, gitProvider } = useStudio ()
12+ const { preferences, updatePreference } = useStudioState ()
1113const { t } = useI18n ()
1214const fileInputRef = ref <HTMLInputElement >()
1315const toolbarRef = ref <HTMLElement >()
@@ -26,19 +28,38 @@ const item = computed(() => context.activeTree.value.currentItem.value)
2628const extraActions = computed <DropdownMenuItem []>(() => {
2729 const actions: DropdownMenuItem [] = []
2830
29- if (item .value .type === ' file' && item .value .status !== TreeStatus .Created ) {
30- const providerInfo = gitProvider .api .getRepositoryInfo ()
31- const provider = providerInfo .provider
32- const feature = context .currentFeature .value
31+ if (item .value .type === ' file' ) {
32+ const fileExtension = getFileExtension (item .value .fsPath )
33+ const isMarkdown = fileExtension === ' md'
3334
34- if (feature ) {
35+ // Add editor mode switch for markdown files
36+ if (isMarkdown ) {
3537 actions .push ({
36- label: t (` studio.actions.labels.openGitProvider ` , { providerName: gitProvider .name }),
37- icon: provider === ' gitlab' ? ' i-simple-icons:gitlab' : ' i-simple-icons:github' ,
38- to: gitProvider .api .getFileUrl (feature , item .value .fsPath ),
39- target: ' _blank' ,
38+ label: preferences .value .editorMode === ' code'
39+ ? t (' studio.actions.labels.switchToTipTap' )
40+ : t (' studio.actions.labels.switchToCode' ),
41+ icon: preferences .value .editorMode === ' code' ? ' i-lucide-file-pen' : ' i-lucide-file-code' ,
42+ onClick : () => {
43+ updatePreference (' editorMode' , preferences .value .editorMode === ' code' ? ' tiptap' : ' code' )
44+ },
4045 })
4146 }
47+
48+ // Add git provider link for existing files
49+ if (item .value .status !== TreeStatus .Created ) {
50+ const providerInfo = gitProvider .api .getRepositoryInfo ()
51+ const provider = providerInfo .provider
52+ const feature = context .currentFeature .value
53+
54+ if (feature ) {
55+ actions .push ({
56+ label: t (` studio.actions.labels.openGitProvider ` , { providerName: gitProvider .name }),
57+ icon: provider === ' gitlab' ? ' i-simple-icons:gitlab' : ' i-simple-icons:github' ,
58+ to: gitProvider .api .getFileUrl (feature , item .value .fsPath ),
59+ target: ' _blank' ,
60+ })
61+ }
62+ }
4263 }
4364
4465 return actions
0 commit comments