11<script setup lang="ts">
22import { useSnippets } from ' @/composables'
3- import { i18n , ipc } from ' @/electron'
3+ import { i18n , ipc , store } from ' @/electron'
44import { useDark } from ' @vueuse/core'
55import CodeMirror from ' codemirror'
66import { Minus , Plus } from ' lucide-vue-next'
@@ -14,6 +14,8 @@ import 'codemirror/addon/runmode/runmode'
1414import ' codemirror/theme/neo.css'
1515import ' codemirror/theme/oceanic-next.css'
1616
17+ const isDev = import .meta .env .DEV
18+
1719const { selectedSnippetContent } = useSnippets ()
1820const isDark = useDark ()
1921const { scaleToShow, onZoom } = useMarkdown ()
@@ -58,7 +60,7 @@ async function renderMarkdown() {
5860 if (selectedSnippetContent .value ?.value ) {
5961 const markdownHtml = await marked .parse (selectedSnippetContent .value .value )
6062
61- const sanitizedHtml = sanitizeHtml (markdownHtml , {
63+ let sanitizedHtml = sanitizeHtml (markdownHtml , {
6264 allowedTags: sanitizeHtml .defaults .allowedTags .concat ([' img' , ' del' ]),
6365 allowedAttributes: {
6466 ' *' : [
@@ -81,6 +83,13 @@ async function renderMarkdown() {
8183 allowedSchemes: [' http' , ' https' , ' masscode' ],
8284 })
8385
86+ const re = / src="\.\/ / g
87+ const path = store .preferences .get (' storagePath' )
88+
89+ sanitizedHtml = isDev
90+ ? sanitizedHtml .replace (re , ` src="file://${path }/ ` )
91+ : sanitizedHtml .replace (re , ` src="${path }/ ` )
92+
8493 renderedContent .value = sanitizedHtml
8594 }
8695 else {
@@ -167,35 +176,33 @@ watch(isDark, (value) => {
167176 </script >
168177
169178<template >
170- <div >
171- <EditorHeaderTool v-if =" isShowHeaderTool" >
172- <div class =" flex w-full justify-end gap-2 px-2" >
173- <UiActionButton
174- :tooltip =" i18n.t('button.zoomOut')"
175- @click =" onZoom('out')"
176- >
177- <Minus class =" h-3 w-3" />
178- </UiActionButton >
179- <div class =" tabular-nums select-none" >
180- {{ scaleToShow }}
181- </div >
182- <UiActionButton
183- :tooltip =" i18n.t('button.zoomIn')"
184- @click =" onZoom('in')"
185- >
186- <Plus class =" h-3 w-3" />
187- </UiActionButton >
188- </div >
189- </EditorHeaderTool >
190- <PerfectScrollbar :options =" { minScrollbarLength: 20 }" >
191- <div
192- ref =" markdownRef"
193- class =" markdown-content"
179+ <EditorHeaderTool v-if =" isShowHeaderTool" >
180+ <div class =" flex w-full justify-end gap-2 px-2" >
181+ <UiActionButton
182+ :tooltip =" i18n.t('button.zoomOut')"
183+ @click =" onZoom('out')"
194184 >
195- <div v-html =" renderedContent" />
185+ <Minus class =" h-3 w-3" />
186+ </UiActionButton >
187+ <div class =" tabular-nums select-none" >
188+ {{ scaleToShow }}
196189 </div >
197- </PerfectScrollbar >
198- </div >
190+ <UiActionButton
191+ :tooltip =" i18n.t('button.zoomIn')"
192+ @click =" onZoom('in')"
193+ >
194+ <Plus class =" h-3 w-3" />
195+ </UiActionButton >
196+ </div >
197+ </EditorHeaderTool >
198+ <PerfectScrollbar :options =" { minScrollbarLength: 20 }" >
199+ <div
200+ ref =" markdownRef"
201+ class =" markdown-content"
202+ >
203+ <div v-html =" renderedContent" />
204+ </div >
205+ </PerfectScrollbar >
199206</template >
200207
201208<style >
0 commit comments