Skip to content

Commit 17e13d8

Browse files
authored
fix: minor improvements (#24)
1 parent 2fc68b0 commit 17e13d8

File tree

8 files changed

+2457
-16
lines changed

8 files changed

+2457
-16
lines changed

src/app/src/components/content/ContentEditorCode.vue

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
2-
import { onMounted, ref, shallowRef, watch } from 'vue'
3-
import { type DatabasePageItem, type DraftItem, DraftStatus } from '../../types'
2+
import { computed, onMounted, ref, shallowRef, watch } from 'vue'
3+
import { ContentFileExtension, type DatabasePageItem, type DraftItem, DraftStatus } from '../../types'
44
import type { PropType } from 'vue'
55
import { generateContentFromDocument, generateDocumentFromContent, pickReservedKeysFromDocument } from '../../utils/content'
66
import { setupMonaco, setupSuggestion, type Editor } from '../../utils/monaco'
@@ -35,6 +35,20 @@ watch(() => props.draftItem.status, (newStatus) => {
3535
}
3636
})
3737
38+
const language = computed(() => {
39+
switch (document.value?.extension) {
40+
case ContentFileExtension.Markdown:
41+
return 'mdc';
42+
case ContentFileExtension.YAML:
43+
case ContentFileExtension.YML:
44+
return 'yaml';
45+
case ContentFileExtension.JSON:
46+
return 'javascript';
47+
default:
48+
return 'text'
49+
}
50+
})
51+
3852
// Trigger on document changes
3953
watch(() => document.value?.id, async () => {
4054
if (document.value?.body) {
@@ -48,7 +62,7 @@ onMounted(async () => {
4862
4963
// create a Monaco editor instance
5064
editor.value = monaco.createEditor(editorRef.value, {
51-
// theme: ui.colorMode.value === 'light' ? 'vs' : 'vs-dark',
65+
theme: ui.colorMode.value === 'light' ? 'vitesse-light' : 'vitesse-dark',
5266
lineNumbers: 'off',
5367
readOnly: props.readOnly,
5468
scrollbar: props.readOnly
@@ -89,14 +103,14 @@ onMounted(async () => {
89103
})
90104
91105
// create and attach a model to the editor
92-
editor.value.setModel(monaco.editor.createModel(content.value, 'mdc'))
106+
editor.value.setModel(monaco.editor.createModel(content.value, language.value))
93107
94108
// Set the theme based on the color mode
95-
// watch(ui.colorMode, () => {
96-
// editor.value?.updateOptions({
97-
// theme: ui.colorMode.value === 'light' ? 'vs' : 'vs-dark',
98-
// })
99-
// })
109+
watch(ui.colorMode, () => {
110+
editor.value?.updateOptions({
111+
theme: ui.colorMode.value === 'light' ? 'vitesse-light' : 'vitesse-dark',
112+
})
113+
})
100114
})
101115
102116
function setContent(document: DatabasePageItem) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const imageSrc = computed(() => {
3434
if (props.item.preview) {
3535
return props.item.preview
3636
}
37-
return 'https://placehold.co/1920x1080/f9fafc/f9fafc'
37+
return ''
3838
})
3939
4040
// ring-(--ui-success) ring-(--ui-info) ring-(--ui-warning) ring-(--ui-error) ring-(--ui-neutral)
@@ -53,12 +53,14 @@ const statusRingColor = computed(() => props.item.status ? `ring-(--ui-${COLOR_U
5353
>
5454
<div class="bg-default bg-[linear-gradient(45deg,#e6e9ea_25%,transparent_0),linear-gradient(-45deg,#e6e9ea_25%,transparent_0),linear-gradient(45deg,transparent_75%,#e6e9ea_0),linear-gradient(-45deg,transparent_75%,#e6e9ea_0)] bg-size-[24px_24px] bg-position-[0_0,0_12px,12px_-12px,-12px_0]">
5555
<Image
56+
v-if="imageSrc"
5657
:src="imageSrc"
5758
width="426"
5859
height="240"
5960
alt="Card placeholder"
6061
class="z-[-1] rounded-t-lg aspect-video object-cover"
6162
/>
63+
<div v-else class="z-[-1] aspect-video bg-muted" />
6264
<div
6365
v-if="itemExtensionIcon"
6466
class="absolute inset-0 flex items-center justify-center"

src/app/src/composables/useDraftDocuments.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export const useDraftDocuments = createSharedComposable((host: StudioHost, git:
5757
list.value.push(item)
5858

5959
await hooks.callHook('studio:draft:document:updated')
60+
// Rerender host app
61+
host.app.requestRerender()
6062

6163
return item
6264
}

src/app/src/utils/monaco/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { createSingletonPromise } from '@vueuse/core'
22
import type { editor as Editor } from 'modern-monaco/editor-core'
3+
import themeLight from './theme-light'
4+
import themeDark from './theme-dark'
35

46
export { setupSuggestion } from './mdc-compilation'
57
export type { editor as Editor } from 'modern-monaco/editor-core'
@@ -20,6 +22,8 @@ export const setupMonaco = createSingletonPromise(async () => {
2022
}
2123

2224
const monaco: Monaco = await init()
25+
monaco.editor.defineTheme('vitesse-light', themeLight)
26+
monaco.editor.defineTheme('vitesse-dark', themeDark)
2327

2428
return {
2529
monaco,

0 commit comments

Comments
 (0)