@mixd-id/web-scaffold 0.1.230406166 → 0.1.230406168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -2
- package/src/components/Alert.vue +1 -1
- package/src/components/Modal.vue +34 -17
- package/src/index.js +0 -2
- package/src/utils/helpers.js +19 -0
- package/src/components/Modal2.vue +0 -300
- package/src/components/MonacoEditor.vue +0 -136
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mixd-id/web-scaffold",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.230406168",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite serve",
|
|
7
7
|
"build": "vite build",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
".": "./src/index.js",
|
|
13
13
|
"./themes/default": "./src/themes/default/index.js",
|
|
14
14
|
"./components/Modal.vue": "./src/components/Modal.vue",
|
|
15
|
-
"./components/Modal2.vue": "./src/components/Modal2.vue",
|
|
16
15
|
"./components/Textbox.vue": "./src/components/Textbox.vue",
|
|
17
16
|
"./mixin/component": "./src/mixin/component.js",
|
|
18
17
|
"./mixin/edit-mode": "./src/mixin/edit-mode.js",
|
package/src/components/Alert.vue
CHANGED
package/src/components/Modal.vue
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
appear
|
|
6
6
|
@after-leave="onAfterLeave"
|
|
7
7
|
@after-enter="$emit('show')">
|
|
8
|
-
<div v-if="
|
|
8
|
+
<div v-if="currentState"
|
|
9
|
+
ref="modal"
|
|
10
|
+
:class="computedClass"
|
|
11
|
+
:style="computedStyle"
|
|
9
12
|
:data-state="computedState ? 1 : 0">
|
|
10
13
|
<form v-if="useForm" @submit.prevent="$emit('submit')">
|
|
11
14
|
<div class="modal-head">
|
|
@@ -44,9 +47,9 @@ let modals = []
|
|
|
44
47
|
const registerModal = (modal) => {
|
|
45
48
|
if(modals.includes(modal)) return
|
|
46
49
|
|
|
47
|
-
|
|
50
|
+
modals.forEach((_) => {
|
|
48
51
|
_.isDisabled = 1
|
|
49
|
-
})
|
|
52
|
+
})
|
|
50
53
|
|
|
51
54
|
modals.push(modal)
|
|
52
55
|
}
|
|
@@ -54,8 +57,8 @@ const registerModal = (modal) => {
|
|
|
54
57
|
const unRegisterModal = (modal) => {
|
|
55
58
|
modals = modals.filter((_) => _ !== modal)
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
modals[modals.length - 1].isDisabled = 0
|
|
60
|
+
if(modals.length > 0)
|
|
61
|
+
modals[modals.length - 1].isDisabled = 0
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
export default{
|
|
@@ -77,7 +80,8 @@ export default{
|
|
|
77
80
|
useForm: {
|
|
78
81
|
type: Boolean,
|
|
79
82
|
default: false
|
|
80
|
-
}
|
|
83
|
+
},
|
|
84
|
+
mode: 'v-if', // v-if or v-show
|
|
81
85
|
},
|
|
82
86
|
|
|
83
87
|
methods: {
|
|
@@ -130,9 +134,16 @@ export default{
|
|
|
130
134
|
overlay.classList.add('bW9l')
|
|
131
135
|
}
|
|
132
136
|
|
|
137
|
+
this.$emit('show')
|
|
138
|
+
|
|
133
139
|
registerModal(this)
|
|
134
140
|
}
|
|
135
141
|
else{
|
|
142
|
+
this.$emit('hide')
|
|
143
|
+
|
|
144
|
+
if(this.mode === 'v-show')
|
|
145
|
+
this.$nextTick(() => this.onAfterLeave())
|
|
146
|
+
|
|
136
147
|
unRegisterModal(this)
|
|
137
148
|
}
|
|
138
149
|
}
|
|
@@ -153,7 +164,9 @@ export default{
|
|
|
153
164
|
return [
|
|
154
165
|
this.$style.modal,
|
|
155
166
|
this.$style['modal-' + this.position],
|
|
156
|
-
this.class
|
|
167
|
+
this.class,
|
|
168
|
+
this.mode === 'v-show' ? this.$style['v-show'] : '',
|
|
169
|
+
this.computedState ? this.$style.open : ''
|
|
157
170
|
]
|
|
158
171
|
.join(' ')
|
|
159
172
|
.trim()
|
|
@@ -167,8 +180,13 @@ export default{
|
|
|
167
180
|
},
|
|
168
181
|
|
|
169
182
|
computedState(){
|
|
170
|
-
|
|
171
|
-
}
|
|
183
|
+
return this.state ? Boolean(this.state) : this._state
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
currentState(){
|
|
187
|
+
return this.mode === 'v-show' ? true :
|
|
188
|
+
this.computedState
|
|
189
|
+
},
|
|
172
190
|
|
|
173
191
|
},
|
|
174
192
|
|
|
@@ -186,14 +204,6 @@ export default{
|
|
|
186
204
|
this.setState(to)
|
|
187
205
|
},
|
|
188
206
|
|
|
189
|
-
$route(to, from){
|
|
190
|
-
if(from.path !== to.path && !to.hash){
|
|
191
|
-
let overlay = document.querySelector('.bW9k')
|
|
192
|
-
if(overlay && overlay.classList.contains('bW9l'))
|
|
193
|
-
overlay.classList.remove('bW9l')
|
|
194
|
-
}
|
|
195
|
-
},
|
|
196
|
-
|
|
197
207
|
},
|
|
198
208
|
|
|
199
209
|
mounted() {
|
|
@@ -234,6 +244,13 @@ export default{
|
|
|
234
244
|
@apply rounded-xl overflow-hidden;
|
|
235
245
|
}
|
|
236
246
|
|
|
247
|
+
.modal.v-show{
|
|
248
|
+
transform: scale(0);
|
|
249
|
+
}
|
|
250
|
+
.modal.v-show.open{
|
|
251
|
+
transform: scale(1);
|
|
252
|
+
}
|
|
253
|
+
|
|
237
254
|
.modal form{
|
|
238
255
|
@apply flex-1 min-h-0 flex flex-col relative;
|
|
239
256
|
}
|
package/src/index.js
CHANGED
|
@@ -388,8 +388,6 @@ export default{
|
|
|
388
388
|
app.component('Flex', defineAsyncComponent(() => import("./components/Flex.vue")))
|
|
389
389
|
app.component('Grid', defineAsyncComponent(() => import("./components/Grid.vue")))
|
|
390
390
|
app.component('Modal', defineAsyncComponent(() => import("./components/Modal.vue")))
|
|
391
|
-
app.component('Modal2', defineAsyncComponent(() => import("./components/Modal2.vue")))
|
|
392
|
-
//app.component('MonacoEditor', defineAsyncComponent(() => import("./components/MonacoEditor.vue")))
|
|
393
391
|
app.component('OTPField', defineAsyncComponent(() => import("./components/OTPField.vue")))
|
|
394
392
|
app.component('PageBuilder', defineAsyncComponent(() => import("./components/PageBuilder.vue")))
|
|
395
393
|
app.component('Radio', defineAsyncComponent(() => import("./components/Radio.vue")))
|
package/src/utils/helpers.js
CHANGED
|
@@ -366,6 +366,24 @@ const createComponentInstance = function(component){
|
|
|
366
366
|
return component
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
const deepObjectContainsObject = (outerObject, innerObject) => {
|
|
370
|
+
for (const key in innerObject) {
|
|
371
|
+
if (innerObject.hasOwnProperty(key)) {
|
|
372
|
+
if (typeof innerObject[key] === 'object' && typeof outerObject[key] === 'object') {
|
|
373
|
+
// If both properties are objects, recursively check them
|
|
374
|
+
if (!deepObjectContainsObject(outerObject[key], innerObject[key])) {
|
|
375
|
+
return false; // Nested objects do not match
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
if (outerObject[key] !== innerObject[key]) {
|
|
379
|
+
return false; // Property in innerObject doesn't exist in outerObject or values don't match
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
return true; // All properties and values in innerObject exist in outerObject
|
|
385
|
+
}
|
|
386
|
+
|
|
369
387
|
|
|
370
388
|
module.exports = {
|
|
371
389
|
ceil,
|
|
@@ -389,4 +407,5 @@ module.exports = {
|
|
|
389
407
|
generateStylesheet,
|
|
390
408
|
hexToRgb,
|
|
391
409
|
createComponentInstance,
|
|
410
|
+
deepObjectContainsObject,
|
|
392
411
|
}
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<Teleport to=".bW9k">
|
|
4
|
-
<div :class="computedClass" ref="modal" :style="computedStyle"
|
|
5
|
-
:data-state="!!computedState ? 1 : 0">
|
|
6
|
-
<form v-if="useForm" @submit.prevent="$emit('submit')">
|
|
7
|
-
<div class="modal-head">
|
|
8
|
-
<slot name="head" :context="context"></slot>
|
|
9
|
-
</div>
|
|
10
|
-
<div :class="modalBodyClass">
|
|
11
|
-
<slot :context="context"></slot>
|
|
12
|
-
</div>
|
|
13
|
-
<div class="modal-foot">
|
|
14
|
-
<slot name="foot" :context="context"></slot>
|
|
15
|
-
</div>
|
|
16
|
-
<div v-if="isDisabled" :class="$style.overlay"></div>
|
|
17
|
-
</form>
|
|
18
|
-
<div v-else class="flex-1 min-h-0 flex flex-col relative">
|
|
19
|
-
<div class="modal-head">
|
|
20
|
-
<slot name="head" :context="context"></slot>
|
|
21
|
-
</div>
|
|
22
|
-
<div :class="modalBodyClass">
|
|
23
|
-
<slot :context="context"></slot>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="modal-foot">
|
|
26
|
-
<slot name="foot" :context="context"></slot>
|
|
27
|
-
</div>
|
|
28
|
-
<div v-if="isDisabled" :class="$style.overlay"></div>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</Teleport>
|
|
32
|
-
</div>
|
|
33
|
-
</template>
|
|
34
|
-
|
|
35
|
-
<script>
|
|
36
|
-
|
|
37
|
-
let modals = []
|
|
38
|
-
|
|
39
|
-
const registerModal = (modal) => {
|
|
40
|
-
if(modals.includes(modal)) return
|
|
41
|
-
|
|
42
|
-
modals.forEach((_) => {
|
|
43
|
-
_.isDisabled = 1
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
modals.push(modal)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const unRegisterModal = (modal) => {
|
|
50
|
-
|
|
51
|
-
modals = modals.filter((_) => _ !== modal)
|
|
52
|
-
|
|
53
|
-
if(modals.length > 0)
|
|
54
|
-
modals[modals.length - 1].isDisabled = 0
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export default{
|
|
58
|
-
|
|
59
|
-
emits: [ 'submit', 'dismiss', 'show', 'hide' ],
|
|
60
|
-
|
|
61
|
-
props:{
|
|
62
|
-
bodyClass:{ type: String, default: '' },
|
|
63
|
-
class:{ type: String, default: '' },
|
|
64
|
-
dismissable: undefined,
|
|
65
|
-
height: String,
|
|
66
|
-
position: {
|
|
67
|
-
type: String,
|
|
68
|
-
default: 'bottom'
|
|
69
|
-
},
|
|
70
|
-
state: {
|
|
71
|
-
type: [ Number, Boolean, String ],
|
|
72
|
-
default: true
|
|
73
|
-
},
|
|
74
|
-
transition: { type: String, default: 'slideup' },
|
|
75
|
-
width: String,
|
|
76
|
-
useForm: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
default: false
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
computed:{
|
|
83
|
-
|
|
84
|
-
modalBodyClass(){
|
|
85
|
-
return [
|
|
86
|
-
this.$style.modalBody,
|
|
87
|
-
this.bodyClass
|
|
88
|
-
]
|
|
89
|
-
.join(' ')
|
|
90
|
-
.trim()
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
computedClass(){
|
|
94
|
-
return [
|
|
95
|
-
this.$style.modal,
|
|
96
|
-
this.$style['modal-' + this.position],
|
|
97
|
-
this.class,
|
|
98
|
-
this.computedState ? this.$style.open : ''
|
|
99
|
-
]
|
|
100
|
-
.join(' ')
|
|
101
|
-
.trim()
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
computedStyle(){
|
|
105
|
-
return {
|
|
106
|
-
width: parseInt(this.width) + 'px',
|
|
107
|
-
height: parseInt(this.height) + 'px',
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
computedState(){
|
|
112
|
-
return this.state ? Boolean(this.state) : this._state
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
data(){
|
|
118
|
-
return {
|
|
119
|
-
isDisabled: 0,
|
|
120
|
-
_state: false,
|
|
121
|
-
context: null
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
watch:{
|
|
126
|
-
|
|
127
|
-
computedState(to, from){
|
|
128
|
-
this.setState(to)
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
$route(to, from){
|
|
132
|
-
if(from.path !== to.path && !to.hash){
|
|
133
|
-
let overlay = document.querySelector('.bW9k')
|
|
134
|
-
if(overlay && overlay.classList.contains('bW9l'))
|
|
135
|
-
overlay.classList.remove('bW9l')
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
mounted() {
|
|
142
|
-
document.querySelector('.bW9k').addEventListener('click', this.onDismiss)
|
|
143
|
-
window.addEventListener('keydown', this.onKeyDown)
|
|
144
|
-
|
|
145
|
-
if(this.computedState){
|
|
146
|
-
this.setState(this.computedState)
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
methods: {
|
|
151
|
-
|
|
152
|
-
open(context = {}){
|
|
153
|
-
this.context = context
|
|
154
|
-
this._state = true
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
close(){
|
|
158
|
-
this._state = false
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
onAfterLeave(){
|
|
162
|
-
let overlay = document.querySelector('.bW9k')
|
|
163
|
-
if(overlay){
|
|
164
|
-
|
|
165
|
-
let hasTrueState = false
|
|
166
|
-
|
|
167
|
-
for(let i = 0 ; i < overlay.children.length ; i++){
|
|
168
|
-
if(overlay.children[i].getAttribute('data-state') === '1'){
|
|
169
|
-
hasTrueState = true
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if(!hasTrueState){
|
|
174
|
-
overlay.classList.remove('bW9l')
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
this.$emit('hide')
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
onDismiss(e){
|
|
182
|
-
if(this.computedState && this.dismissable && this.$refs.modal && e.target.classList.contains('bW9k')){
|
|
183
|
-
this.$emit('dismiss')
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
onKeyDown(e){
|
|
188
|
-
if(this.dismissable && this.$refs.modal && e.keyCode === 27){
|
|
189
|
-
this.$emit('dismiss')
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
setState(to){
|
|
194
|
-
if(to){
|
|
195
|
-
let overlay = document.querySelector('.bW9k')
|
|
196
|
-
if(overlay){
|
|
197
|
-
overlay.classList.add('bW9l')
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
this.$emit('show')
|
|
201
|
-
registerModal(this)
|
|
202
|
-
}
|
|
203
|
-
else{
|
|
204
|
-
this.$nextTick(() => {
|
|
205
|
-
this.onAfterLeave()
|
|
206
|
-
unRegisterModal(this)
|
|
207
|
-
})
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
</script>
|
|
215
|
-
|
|
216
|
-
<style>
|
|
217
|
-
|
|
218
|
-
.bW9k{
|
|
219
|
-
@apply fixed z-20 top-0 left-0 bottom-0 right-0 hidden items-center justify-center;
|
|
220
|
-
@apply bg-black/50 backdrop-blur-md;
|
|
221
|
-
}
|
|
222
|
-
.bW9l{
|
|
223
|
-
@apply flex;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
</style>
|
|
227
|
-
|
|
228
|
-
<style module>
|
|
229
|
-
|
|
230
|
-
.modal{
|
|
231
|
-
@apply fixed;
|
|
232
|
-
@apply bg-base-400;
|
|
233
|
-
@apply border-[1px] border-text-50 z-20 flex max-h-[90vh];
|
|
234
|
-
@apply rounded-xl overflow-hidden;
|
|
235
|
-
transform: scale(0);
|
|
236
|
-
}
|
|
237
|
-
.modal.open{
|
|
238
|
-
transform: scale(1);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.modal form{
|
|
242
|
-
@apply flex-1 min-h-0 flex flex-col relative;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.modalBody{
|
|
246
|
-
@apply flex-1 min-h-0 overflow-y-auto flex bg-base-400 dark:bg-base-300;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.overlay{
|
|
250
|
-
@apply absolute z-20 left-0 bottom-0 top-0 right-0 bg-white/50 backdrop-blur-sm;
|
|
251
|
-
}
|
|
252
|
-
html[data-theme='dark'] .overlay{
|
|
253
|
-
@apply bg-black/50;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
@media screen and (max-width: 640px) {
|
|
257
|
-
|
|
258
|
-
.modal {
|
|
259
|
-
max-height: 90vh;
|
|
260
|
-
width: 100vw !important;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.modal-center{
|
|
264
|
-
align-self: center;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.modal-bottom{
|
|
268
|
-
align-self: end;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
@media screen and (min-width: 640px) {
|
|
274
|
-
|
|
275
|
-
.modal {
|
|
276
|
-
max-width: 90vw;
|
|
277
|
-
width: 480px;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
</style>
|
|
283
|
-
|
|
284
|
-
<style>
|
|
285
|
-
|
|
286
|
-
.slideup-enter-active,
|
|
287
|
-
.slideup-leave-active {
|
|
288
|
-
transition: all 300ms cubic-bezier(0.25, 1, 0.5, 1);
|
|
289
|
-
}
|
|
290
|
-
.slideup-enter-active,
|
|
291
|
-
.slideup-leave-active {
|
|
292
|
-
transform: translate3d(0, 0, 0);
|
|
293
|
-
}
|
|
294
|
-
.slideup-enter-from,
|
|
295
|
-
.slideup-leave-to {
|
|
296
|
-
opacity: 0;
|
|
297
|
-
transform: translate3d(0, 10px, 0);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
</style>
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div :class="$style.comp">
|
|
3
|
-
<div class="flex flex-row p-2">
|
|
4
|
-
<code>{{ language }}</code>
|
|
5
|
-
<div class="flex-1"></div>
|
|
6
|
-
<button type="button" class="text-primary" @click="reformat">Beautify</button>
|
|
7
|
-
</div>
|
|
8
|
-
<div ref="editorContainer" :class="$style['monaco-editor-container']"></div>
|
|
9
|
-
</div>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script>
|
|
13
|
-
import * as monaco from 'monaco-editor'
|
|
14
|
-
import editorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'
|
|
15
|
-
import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
|
|
16
|
-
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
|
|
17
|
-
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
|
|
18
|
-
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
|
|
19
|
-
|
|
20
|
-
self.MonacoEnvironment = {
|
|
21
|
-
getWorker(_, label) {
|
|
22
|
-
if (label === 'json') {
|
|
23
|
-
return new jsonWorker()
|
|
24
|
-
}
|
|
25
|
-
if (label === 'css' || label === 'scss' || label === 'less') {
|
|
26
|
-
return new cssWorker()
|
|
27
|
-
}
|
|
28
|
-
if (label === 'html' || label === 'handlebars' || label === 'razor') {
|
|
29
|
-
return new htmlWorker()
|
|
30
|
-
}
|
|
31
|
-
if (label === 'typescript' || label === 'javascript') {
|
|
32
|
-
return new tsWorker()
|
|
33
|
-
}
|
|
34
|
-
return new editorWorker()
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default {
|
|
39
|
-
|
|
40
|
-
props: {
|
|
41
|
-
|
|
42
|
-
language: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: 'json'
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
theme: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: 'vs-dark'
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
lineNumbers: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: "off"
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
modelValue: String
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
methods: {
|
|
62
|
-
|
|
63
|
-
createEditor() {
|
|
64
|
-
this.editor = monaco.editor.create(this.$refs.editorContainer, {
|
|
65
|
-
value: this.modelValue,
|
|
66
|
-
language: this.language,
|
|
67
|
-
lineNumbers: this.lineNumbers,
|
|
68
|
-
minimap: {
|
|
69
|
-
enabled: false
|
|
70
|
-
},
|
|
71
|
-
theme: this.theme
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
this.editor.onDidChangeModelContent(event => {
|
|
75
|
-
const updatedCode = this.editor.getValue();
|
|
76
|
-
this.$emit('update:modelValue', updatedCode)
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
getErrors(){
|
|
81
|
-
const markers = monaco.editor.getModelMarkers({ owner: this.editor.getModel() });
|
|
82
|
-
|
|
83
|
-
let errors = []
|
|
84
|
-
if (markers.length >= 0) {
|
|
85
|
-
markers.forEach(marker => {
|
|
86
|
-
errors.push({
|
|
87
|
-
message: marker.message,
|
|
88
|
-
line: marker.startLineNumber,
|
|
89
|
-
column: marker.startColumn
|
|
90
|
-
})
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return errors.length > 0 ? errors : null
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
reformat(){
|
|
98
|
-
const formatAction = this.editor.getAction('editor.action.formatDocument');
|
|
99
|
-
formatAction.run();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
beforeDestroy() {
|
|
105
|
-
this.editor.dispose();
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
mounted() {
|
|
109
|
-
this.createEditor();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
</script>
|
|
114
|
-
|
|
115
|
-
<style module>
|
|
116
|
-
|
|
117
|
-
.comp{
|
|
118
|
-
@apply flex-1 flex flex-col;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.monaco-editor-container {
|
|
122
|
-
width: 100%;
|
|
123
|
-
height: 300px;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.monaco-editor-container *{
|
|
127
|
-
font-family: Menlo, Monaco, "Courier New", monospace;
|
|
128
|
-
--vscode-editor-background: rgb(var(--base-300));
|
|
129
|
-
--vscode-editorGutter-background: rgb(var(--base-400));
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.monaco-editor-container .margin-view-overlays .line-numbers {
|
|
133
|
-
font-family: 'Menlo', monospace;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
</style>
|