Skip to content

Commit d3c6476

Browse files
authored
fix(editor): can't edit .md source files (#189)
1 parent 4f45910 commit d3c6476

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/hooks/useUtil.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ export const useUtil = () => {
3434
}
3535
}
3636

37-
export function useFetchText() {
37+
export function useFetchText(raw?: boolean) {
3838
const { proxyLink } = useLink()
3939
const fetchContent = async () => {
40-
return fetchText(proxyLink(objStore.obj, true))
40+
let fileurl = proxyLink(objStore.obj, true)
41+
if (raw) {
42+
const separator = fileurl.includes("?") ? "&" : "?"
43+
fileurl = `${fileurl}${separator}raw=true`
44+
}
45+
return fetchText(fileurl)
4146
}
4247
return createResource("", fetchContent)
4348
}

src/pages/home/previews/text-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function Editor(props: { data?: string | ArrayBuffer; contentType?: string }) {
7070

7171
// TODO add encoding select
7272
const TextEditor = () => {
73-
const [content] = useFetchText()
73+
const [content] = useFetchText(true)
7474
return (
7575
<MaybeLoading loading={content.loading}>
7676
<Editor data={content()?.content} contentType={content()?.contentType} />

0 commit comments

Comments
 (0)