1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<template>
<div v-if="isOpen" class="modal-backdrop" @click.self="close">
<div class="modal-body">
<YueCompiler :text="content" compileronly displayonly />
</div>
</div>
</template>
<script>
import YueCompiler from './YueCompiler.vue'
export default {
components: {
YueCompiler
},
data() {
return {
isOpen: false,
content: ''
}
},
mounted() {
this.handleOpen = (event) => {
this.content = event?.detail || ''
this.isOpen = true
}
this.handleKeydown = (event) => {
if (event.key === 'Escape' && this.isOpen) {
this.close()
}
}
window.addEventListener('yue:open-compiler', this.handleOpen)
window.addEventListener('keydown', this.handleKeydown)
},
beforeUnmount() {
window.removeEventListener('yue:open-compiler', this.handleOpen)
window.removeEventListener('keydown', this.handleKeydown)
},
methods: {
close() {
this.isOpen = false
}
}
}
</script>
<style scoped>
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.6);
display: flex;
align-items: center;
justify-content: center;
z-index: 2000;
}
.modal-body {
position: relative;
width: min(90vw, 1100px);
max-height: 90vh;
overflow: auto;
background: #ffffff;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}
</style>
|