💄 (fonts) add fonts
This commit is contained in:
@@ -12,33 +12,39 @@ export const useImages = (sha: string) => {
|
||||
() => store.files.find((file) => file.sha === sha)?.path
|
||||
)
|
||||
|
||||
watch(currentFilePath, (filePath) => {
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
|
||||
const images = document.querySelectorAll(`.note-${sha} img`)
|
||||
|
||||
images.forEach(async (image) => {
|
||||
const src = image.getAttribute('src')
|
||||
if (!src || src.startsWith(SRC_PREFIX)) {
|
||||
watch(
|
||||
currentFilePath,
|
||||
(filePath) => {
|
||||
if (!filePath) {
|
||||
return
|
||||
}
|
||||
|
||||
const imageFilePath = resolvePath(
|
||||
filePath,
|
||||
image.getAttribute('src') ?? ''
|
||||
)
|
||||
const images = document.querySelectorAll(`.note-${sha} img`)
|
||||
|
||||
const imageFile = store.files.find((file) => file.path === imageFilePath)
|
||||
images.forEach(async (image) => {
|
||||
const src = image.getAttribute('src')
|
||||
if (!src || src.startsWith(SRC_PREFIX)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!imageFile?.sha) {
|
||||
return
|
||||
}
|
||||
const { getCachedFileContent } = useFile(imageFile.sha, false)
|
||||
const imageFilePath = resolvePath(
|
||||
filePath,
|
||||
image.getAttribute('src') ?? ''
|
||||
)
|
||||
|
||||
const fileContent = await getCachedFileContent()
|
||||
image.setAttribute('src', `${SRC_PREFIX} ${fileContent}`)
|
||||
})
|
||||
})
|
||||
const imageFile = store.files.find(
|
||||
(file) => file.path === imageFilePath
|
||||
)
|
||||
|
||||
if (!imageFile?.sha) {
|
||||
return
|
||||
}
|
||||
const { getCachedFileContent } = useFile(imageFile.sha, false)
|
||||
|
||||
const fileContent = await getCachedFileContent()
|
||||
image.setAttribute('src', `${SRC_PREFIX} ${fileContent}`)
|
||||
})
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user