File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed
components/codemirror-pro Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 77<script lang="ts" setup>
88import { CSSProperties } from ' vue' ;
99import { basicSetup , EditorView } from ' codemirror' ;
10- import { EditorState } from ' @codemirror/state' ;
10+ import { EditorState , Extension } from ' @codemirror/state' ;
1111import { oneDark } from ' @codemirror/theme-one-dark' ;
1212import { StreamLanguage } from ' @codemirror/language' ;
1313import { nginx } from ' ./nginx' ;
@@ -27,6 +27,10 @@ const props = defineProps({
2727 type: Boolean ,
2828 default: false ,
2929 },
30+ readonly: {
31+ type: Boolean ,
32+ default: false ,
33+ },
3034 modelValue: {
3135 type: String ,
3236 default: ' ' ,
@@ -119,7 +123,7 @@ const initCodeMirror = () => {
119123 },
120124 });
121125
122- const extensions = [
126+ const extensions: Extension [] = [
123127 defaultTheme ,
124128 oneDark ,
125129 basicSetup ,
@@ -131,6 +135,7 @@ const initCodeMirror = () => {
131135 }),
132136 placeholder (props .placeholder ),
133137 EditorView .editable .of (! props .disabled ),
138+ EditorState .readOnly .of (props .readonly ),
134139 ];
135140
136141 if (props .lineWrapping ) {
Original file line number Diff line number Diff line change 149149 </el-tab-pane >
150150
151151 <el-tab-pane :label =" $t('commons.button.view')" name =" view" >
152- <CodemirrorPro v-model =" rawJson" :height-diff =" 240" :disabled =" true" mode =" json" />
152+ <div class =" mb-2 flex justify-start" >
153+ <el-button type =" primary" @click =" handleCopyRawJson" icon =" DocumentCopy" size =" default" >
154+ {{ $t('commons.button.copy') }}
155+ </el-button >
156+ </div >
157+ <CodemirrorPro v-model =" rawJson" :height-diff =" 240" :readonly =" true" mode =" json" />
153158 </el-tab-pane >
154159 </el-tabs >
155160
165170import { ref } from ' vue' ;
166171import CodemirrorPro from ' @/components/codemirror-pro/index.vue' ;
167172import { routerToFileWithPath } from ' @/utils/router' ;
173+ import { copyText } from ' @/utils/util' ;
168174import i18n from ' @/lang' ;
169175
170176const visible = ref (false );
@@ -263,6 +269,10 @@ const handleJumpToFile = (path: string) => {
263269 }
264270};
265271
272+ const handleCopyRawJson = () => {
273+ copyText (rawJson .value );
274+ };
275+
266276defineExpose ({
267277 acceptParams ,
268278});
Original file line number Diff line number Diff line change 9393 </el-tab-pane >
9494
9595 <el-tab-pane :label =" $t('commons.button.view')" name =" raw" >
96- <CodemirrorPro v-model =" rawJson" :height-diff =" 240" :disabled =" true" mode =" json" />
96+ <div class =" mb-2 flex justify-start" >
97+ <el-button type =" primary" @click =" handleCopyRawJson" icon =" DocumentCopy" size =" default" >
98+ {{ $t('commons.button.copy') }}
99+ </el-button >
100+ </div >
101+ <CodemirrorPro v-model =" rawJson" :height-diff =" 240" :readonly =" true" mode =" json" />
97102 </el-tab-pane >
98103 </el-tabs >
99104
108113<script lang="ts" setup>
109114import { ref , computed } from ' vue' ;
110115import CodemirrorPro from ' @/components/codemirror-pro/index.vue' ;
116+ import { copyText } from ' @/utils/util' ;
111117
112118const visible = ref (false );
113119const activeTab = ref (' overview' );
@@ -173,6 +179,10 @@ const containerList = computed(() => {
173179 }));
174180});
175181
182+ const handleCopyRawJson = () => {
183+ copyText (rawJson .value );
184+ };
185+
176186defineExpose ({
177187 acceptParams ,
178188});
You can’t perform that action at this time.
0 commit comments