Skip to content

Commit fae2661

Browse files
committed
Refine code editor config
1 parent 9bdc489 commit fae2661

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

client/src/components/Markdown/Editor/CellCode.vue

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div ref="editor" class="editor" />
2+
<div ref="editor" class="w-100" />
33
</template>
44

55
<script setup>
@@ -34,12 +34,16 @@ async function buildEditor() {
3434
const themeUrl = await import(`ace-builds/src-noconflict/theme-${props.theme}?url`);
3535
ace.config.setModuleUrl(modePath, modeUrl);
3636
ace.config.setModuleUrl(themePath, themeUrl);
37-
ace.edit(editor.value, {
38-
value: props.modelValue,
39-
theme: themePath,
37+
const aceEditor = ace.edit(editor.value, {
38+
highlightActiveLine: false,
39+
highlightGutterLine: false,
40+
maxLines: 30,
41+
minLines: 1,
4042
mode: modePath,
4143
showPrintMargin: false,
44+
theme: themePath,
4245
useWorker: false,
46+
value: props.modelValue,
4347
});
4448
4549
/*/ Update modelValue when editor content changes
@@ -49,6 +53,15 @@ async function buildEditor() {
4953
const newValue = aceEditor.getValue();
5054
emit('update:modelValue', newValue);
5155
});*/
56+
57+
aceEditor.on("focus", () => {
58+
aceEditor.setOption("highlightActiveLine", true);
59+
aceEditor.setOption("highlightGutterLine", true);
60+
});
61+
aceEditor.on("blur", () => {
62+
aceEditor.setOption("highlightActiveLine", false);
63+
aceEditor.setOption("highlightGutterLine", false);
64+
});
5265
}
5366
5467
// Initialize the Ace editor
@@ -66,11 +79,3 @@ onMounted(() => {
6679
}
6780
);*/
6881
</script>
69-
70-
<style>
71-
.editor {
72-
width: 100%;
73-
height: 300px;
74-
border: 1px solid #ddd;
75-
}
76-
</style>

0 commit comments

Comments
 (0)