1
1
<script setup lang="ts">
2
- import { onBeforeUnmount , onMounted , reactive , ref , shallowRef , watch } from ' vue' ;
2
+ import { computed , onBeforeUnmount , onMounted , reactive , ref , shallowRef , watch } from ' vue' ;
3
3
import type { editor } from ' monaco-editor' ;
4
4
import { themeNames , themes } from ' @/lib/monaco/themes' ;
5
5
import type * as monacoEditor from ' monaco-editor/esm/vs/editor/editor.api' ;
@@ -18,6 +18,7 @@ import type { AtUri } from '@atproto/syntax';
18
18
import { useLocalStorage , watchImmediate } from ' @vueuse/core' ;
19
19
import { lookupMime } from ' @/lib/mime' ;
20
20
import MonacoEditor from ' @/components/MonacoEditor.vue' ;
21
+ import MarkdownRenderer from ' @/components/MarkdownRenderer.vue' ;
21
22
22
23
const MONACO_EDITOR_OPTIONS: editor .IStandaloneEditorConstructionOptions = {
23
24
automaticLayout: true ,
@@ -28,6 +29,7 @@ const MONACO_EDITOR_OPTIONS: editor.IStandaloneEditorConstructionOptions = {
28
29
};
29
30
30
31
const editorRef = shallowRef <editor .IStandaloneCodeEditor >();
32
+ const editorValue = ref (' ' );
31
33
const submitted = ref (false );
32
34
33
35
function onBeforeMonacoMount() {
@@ -43,6 +45,13 @@ function onBeforeMonacoMount() {
43
45
44
46
function onMonacoMount(editor : editor .IStandaloneCodeEditor ) {
45
47
editorRef .value = editor ;
48
+
49
+ editorRef .value .onDidChangeModelContent (event => {
50
+ const value = editorRef .value ! .getValue ();
51
+ if (value !== editorValue .value ) {
52
+ editorValue .value = value ;
53
+ }
54
+ });
46
55
}
47
56
48
57
// your action
@@ -108,6 +117,8 @@ watch(activeFile, activeFile => {
108
117
);
109
118
});
110
119
120
+ const isMarkdownFile = computed (() => ! activeFile .value || ((lookupMime (activeFile .value ) ?? ' text/mdx' ) === ' text/mdx' ));
121
+
111
122
</script >
112
123
113
124
<template >
@@ -123,15 +134,6 @@ watch(activeFile, activeFile => {
123
134
</template >
124
135
<template #content >
125
136
<div class =" flex" >
126
- <div class =" errors" v-if =" submitErrors.length" >
127
- Errors:
128
- <ul >
129
- <li v-for =" error, idx in submitErrors" :key =" idx" >
130
- {{ String(error) }}
131
- </li >
132
- </ul >
133
- </div >
134
-
135
137
<div class =" inputs" >
136
138
<VaInput
137
139
v-model =" activeFile"
@@ -169,6 +171,22 @@ watch(activeFile, activeFile => {
169
171
/> -->
170
172
</div >
171
173
</template >
174
+ <template #right v-if =" isMarkdownFile " >
175
+ <div style =" min-width : 25vw ;" >
176
+ <div style =" padding : var (--va-grid-gutter-base ); max-height : calc (100vh - 69.6px ); overflow : auto ;" >
177
+ <div class =" errors" v-if =" submitErrors.length" >
178
+ Errors:
179
+ <ul >
180
+ <li v-for =" error, idx in submitErrors" :key =" idx" >
181
+ {{ String(error) }}
182
+ </li >
183
+ </ul >
184
+ </div >
185
+
186
+ <MarkdownRenderer :markdown =" editorValue" ></MarkdownRenderer >
187
+ </div >
188
+ </div >
189
+ </template >
172
190
</VaLayout >
173
191
</template >
174
192
0 commit comments