directly update edited content

This commit is contained in:
Julien Calixte
2023-08-26 18:37:21 +02:00
parent ccb486a0b6
commit 80888696c9
4 changed files with 43 additions and 21 deletions

View File

@@ -13,14 +13,18 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
return file?.path ?? ''
})
const { render, getRawContent: getRawContentFromFile } = useMarkdown(
toValue(sha)
)
const {
render,
renderFromUTF8,
getRawContent: getRawContentFromFile
} = useMarkdown(toValue(sha))
const { getCachedNote, saveCacheNote } = prepareNoteCache(toValue(sha))
const fromCache = ref(false)
const content = ref('')
const rawContent = ref('')
const content = computed(() =>
rawContent.value ? renderFromUTF8(rawContent.value) : ''
)
const getCachedFileContent = async (): Promise<string | null> => {
const cachedNote = await getCachedNote()
@@ -72,7 +76,6 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
}
rawContent.value = getRawContentFromFile(fileContent)
content.value = render(fileContent)
})
}
@@ -83,6 +86,7 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
getRawContent,
getContent,
getCachedFileContent,
fromCache
fromCache,
saveCacheNote
}
}