修改文本编辑器
This commit is contained in:
parent
d346e55bd7
commit
68e68e02b1
@ -13,7 +13,7 @@
|
|||||||
<!-- <el-button @click="changePreviewMode">{{previewMode?'预览模式':'源码模式'}}</el-button> -->
|
<!-- <el-button @click="changePreviewMode">{{previewMode?'预览模式':'源码模式'}}</el-button> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content" @keydown="onKeyDown">
|
||||||
<MonacoEditor
|
<MonacoEditor
|
||||||
width="900"
|
width="900"
|
||||||
height="640"
|
height="640"
|
||||||
@ -23,6 +23,7 @@
|
|||||||
original="..."
|
original="..."
|
||||||
:value="content"
|
:value="content"
|
||||||
:options="options"
|
:options="options"
|
||||||
|
@change="change"
|
||||||
></MonacoEditor>
|
></MonacoEditor>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@ -135,9 +136,8 @@
|
|||||||
this.isShowUpdateBtn = true
|
this.isShowUpdateBtn = true
|
||||||
this.newContent = code
|
this.newContent = code
|
||||||
},
|
},
|
||||||
save(code,q) {
|
save() {
|
||||||
if(this.isShowUpdateBtn){
|
if(this.isShowUpdateBtn){
|
||||||
this.newContent = code
|
|
||||||
this.update()
|
this.update()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -161,7 +161,23 @@
|
|||||||
},
|
},
|
||||||
changePreviewMode() {
|
changePreviewMode() {
|
||||||
this.previewMode = !this.previewMode
|
this.previewMode = !this.previewMode
|
||||||
}
|
},
|
||||||
|
onKeyDown(event) {
|
||||||
|
const isMac = navigator.platform.startsWith('Mac');
|
||||||
|
const {key, code, keyCode, ctrlKey, metaKey} = event;
|
||||||
|
const isCmd = isMac && metaKey || !isMac && ctrlKey;
|
||||||
|
if (!isCmd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const isS = key === 's' || code === 'KeyS' || keyCode === 83;
|
||||||
|
if (isS && this.textPreviewVisible) {
|
||||||
|
if(this.newContent !== ''){
|
||||||
|
this.save()
|
||||||
|
}
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user