Skip to content

Commit 621f752

Browse files
committed
add switch from ellipis in toolbar
1 parent 7d7044c commit 621f752

File tree

4 files changed

+37
-23
lines changed

4 files changed

+37
-23
lines changed

src/app/src/components/AppFooter.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,6 @@ function closeStudio() {
9595
</UDropdownMenu>
9696

9797
<div class="flex items-center">
98-
<UTooltip
99-
:text="preferences.editorMode === 'code' ? $t('studio.tooltips.switchToTipTap') : $t('studio.tooltips.switchToCode')"
100-
:delay-duration="0"
101-
>
102-
<UButton
103-
:icon="preferences.editorMode === 'code' ? 'i-lucide-whole-word' : 'i-lucide-code'"
104-
variant="ghost"
105-
color="neutral"
106-
@click="updatePreference('editorMode', preferences.editorMode === 'code' ? 'tiptap' : 'code')"
107-
/>
108-
</UTooltip>
10998
<UTooltip
11099
:text="syncTooltipText"
111100
:delay-duration="0"

src/app/src/components/shared/item/ItemActionsToolbar.vue

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<script setup lang="ts">
22
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
33
import { useStudio } from '../../../composables/useStudio'
4+
import { useStudioState } from '../../../composables/useStudioState'
45
import type { StudioAction } from '../../../types'
56
import { StudioItemActionId, TreeStatus } from '../../../types'
6-
import { MEDIA_EXTENSIONS } from '../../../utils/file'
7+
import { MEDIA_EXTENSIONS, getFileExtension } from '../../../utils/file'
78
import type { DropdownMenuItem } from '@nuxt/ui/runtime/components/DropdownMenu.vue.d.ts'
89
import { useI18n } from 'vue-i18n'
910
1011
const { context, gitProvider } = useStudio()
12+
const { preferences, updatePreference } = useStudioState()
1113
const { t } = useI18n()
1214
const fileInputRef = ref<HTMLInputElement>()
1315
const toolbarRef = ref<HTMLElement>()
@@ -26,19 +28,38 @@ const item = computed(() => context.activeTree.value.currentItem.value)
2628
const 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

src/app/src/locales/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@
128128
"duplicateItem": "Duplicate",
129129
"revertItem": "Revert changes",
130130
"publishBranch": "Publish branch",
131-
"openGitProvider": "Open on {providerName}"
131+
"openGitProvider": "Open on {providerName}",
132+
"switchToTipTap": "Use visual editor",
133+
"switchToCode": "Use code editor"
132134
},
133135
"tooltips": {
134136
"createDocument": "Create a new file",

src/app/src/locales/fr.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@
128128
"duplicateItem": "Dupliquer",
129129
"revertItem": "Annuler les changements",
130130
"publishBranch": "Publier la branche",
131-
"openGitProvider": "Ouvrir sur {providerName}"
131+
"openGitProvider": "Ouvrir sur {providerName}",
132+
"switchToTipTap": "Utiliser l'éditeur visuel",
133+
"switchToCode": "Utiliser l'éditeur de code"
132134
},
133135
"tooltips": {
134136
"createDocument": "Créer un nouveau fichier",

0 commit comments

Comments
 (0)