File tree Expand file tree Collapse file tree 3 files changed +61
-2
lines changed Expand file tree Collapse file tree 3 files changed +61
-2
lines changed Original file line number Diff line number Diff line change 3
3
import { vue } from ' @codemirror/lang-vue' ;
4
4
import { useDark } from ' @vueuse/core' ;
5
5
6
+ import KeyMapDemo from ' ./components/KeyMapDemo.vue' ;
7
+ import KeyMapDemoSrc from ' ./components/KeyMapDemo.vue?raw' ;
6
8
import LinterAndCrossBindingDemo from ' ./components/LinterAndCrossBindingDemo.vue' ;
7
9
import LinterAndCrossBindingDemoSrc from ' ./components/LinterAndCrossBindingDemo.vue?raw' ;
8
10
import MarkdownDemo from ' ./components/MarkdownDemo.vue' ;
@@ -20,6 +22,7 @@ const markdownDemoSrc = MarkdownDemoSrc.trim();
20
22
const slotDemoSrc = SlotDemoSrc .trim ();
21
23
const readonlyAndDisabledDemoSrc = ReadonlyAndDisabledDemoSrc .trim ();
22
24
const linterAndCrossBindingDemoSrc = LinterAndCrossBindingDemoSrc .trim ();
25
+ const keyMapDemoSrc = KeyMapDemoSrc .trim ();
23
26
</script >
24
27
25
28
<template >
@@ -211,5 +214,37 @@ const linterAndCrossBindingDemoSrc = LinterAndCrossBindingDemoSrc.trim();
211
214
</div >
212
215
</div >
213
216
</section >
217
+ <section class =" mb-5" >
218
+ <h2 >Key Map Demo</h2 >
219
+ <p >
220
+ This is a sample that allows you to define your own keymap. The
221
+ <code >keymap</code >
222
+ prop is an array of objects that define the keymap.
223
+ </p >
224
+ <p >
225
+ The
226
+ <code >run</code >
227
+ function is called when the keymap is matched. If it returns
228
+ <code >true</code >
229
+ , the default behavior of the keymap is not executed.
230
+ </p >
231
+ <div class =" row" >
232
+ <div class =" col-sm" >
233
+ <code-mirror
234
+ v-model =" keyMapDemoSrc"
235
+ :dark =" dark"
236
+ :lang =" vue()"
237
+ basic
238
+ wrap
239
+ readonly
240
+ />
241
+ </div >
242
+ <div class =" col-sm" >
243
+ <h3 >Demo</h3 >
244
+ <p >Press Shift+Ctrl+Enter to see the console log.</p >
245
+ <key-map-demo />
246
+ </div >
247
+ </div >
248
+ </section >
214
249
</div >
215
250
</template >
Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ import { ref } from ' vue' ;
3
+
4
+ import CodeMirror from ' vue-codemirror6' ;
5
+
6
+ const temp = ref (' Press Shift+Ctrl+Enter here to see the console log.' );
7
+ </script >
8
+
9
+ <template >
10
+ <code-mirror
11
+ v-model =" temp"
12
+ tab
13
+ basic
14
+ :keymap =" [
15
+ {
16
+ key: 'Shift-Ctrl-Enter',
17
+ run: () => {
18
+ console.log('Shift+Ctrl+Enter');
19
+ return true;
20
+ },
21
+ },
22
+ ]"
23
+ />
24
+ </template >
Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ defineProps({ dark: Boolean });
38
38
<label class =" form-check-label" for =" disabled" >Disabled</label >
39
39
</div >
40
40
<code-mirror :dark =" dark" basic :readonly =" isReadonly" :disabled =" isDisabled" >
41
- <pre >
42
- 色は匂へど 散りぬるを
41
+ <pre
42
+ > 色は匂へど 散りぬるを
43
43
我が世誰そ 常ならむ
44
44
有為の奥山 今日越えて
45
45
浅き夢見じ 酔ひもせず</pre
You can’t perform that action at this time.
0 commit comments