@@ -77,7 +77,7 @@ const CopyCode = {
7777 <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
7878 </svg>
7979 </div>
80- `
80+ ` ,
8181} ;
8282
8383// Dropdown
@@ -159,14 +159,14 @@ const Dropdown = {
159159 <slot></slot>
160160 </div>
161161 </transition>
162- </div>`
162+ </div>` ,
163163} ;
164164
165165// CodeEditor
166166const CodeEditor = {
167167 components : {
168- ' copy-code' : CopyCode ,
169- ' dropdown' : Dropdown
168+ " copy-code" : CopyCode ,
169+ dropdown : Dropdown ,
170170 } ,
171171 props : {
172172 modelValue : {
@@ -266,31 +266,31 @@ const CodeEditor = {
266266 highlight : {
267267 //vue2
268268 bind ( el , binding ) {
269- el . textContent = binding . value
270- hljs . highlightElement ( el )
269+ el . textContent = binding . value ;
270+ hljs . highlightElement ( el ) ;
271271 } ,
272272 componentUpdated ( el , binding ) {
273- el . textContent = binding . value
274- hljs . highlightElement ( el )
273+ el . textContent = binding . value ;
274+ hljs . highlightElement ( el ) ;
275275 } ,
276276 //vue3
277277 created ( el , binding ) {
278- el . textContent = binding . value
279- hljs . highlightElement ( el )
278+ el . textContent = binding . value ;
279+ hljs . highlightElement ( el ) ;
280280 } ,
281281 updated ( el , binding ) {
282- el . textContent = binding . value
283- hljs . highlightElement ( el )
284- }
285- }
282+ el . textContent = binding . value ;
283+ hljs . highlightElement ( el ) ;
284+ } ,
285+ } ,
286286 } ,
287287 data ( ) {
288288 return {
289289 containerWidth : 0 ,
290290 staticValue : this . value ,
291291 top : 0 ,
292292 left : 0 ,
293- languageClass : ' hljs language-' + this . languages [ 0 ] [ 0 ] ,
293+ languageClass : " hljs language-" + this . languages [ 0 ] [ 0 ] ,
294294 mark :
295295 this . languages [ 0 ] [ 1 ] === undefined
296296 ? this . languages [ 0 ] [ 0 ]
@@ -302,14 +302,16 @@ const CodeEditor = {
302302 } ,
303303 watch : {
304304 value ( value ) {
305- this . staticValue = value
306- }
305+ this . staticValue = value ;
306+ } ,
307307 } ,
308308 computed : {
309309 contentValue ( ) {
310- return this . read_only ?
311- this . value : this . modelValue === undefined ?
312- this . staticValue + '\n' : this . modelValue + '\n'
310+ return this . read_only
311+ ? this . value
312+ : this . modelValue === undefined
313+ ? this . staticValue + "\n"
314+ : this . modelValue + "\n" ;
313315 } ,
314316 canScroll ( ) {
315317 return this . height == "auto" ? false : true ;
@@ -327,7 +329,7 @@ const CodeEditor = {
327329 methods : {
328330 changeLang ( lang ) {
329331 this . mark = lang [ 1 ] === undefined ? lang [ 0 ] : lang [ 1 ] ;
330- this . languageClass = ' language-' + lang [ 0 ] ;
332+ this . languageClass = " language-" + lang [ 0 ] ;
331333 } ,
332334 calcContainerWidth ( event ) {
333335 // calculating the textarea's width while typing for syncing the width between textarea and highlight area
@@ -342,27 +344,27 @@ const CodeEditor = {
342344 } ,
343345 resize ( ) {
344346 // listen to the change of the textarea's width to resize the highlight area
345- const resize = new ResizeObserver ( entries => {
347+ const resize = new ResizeObserver ( ( entries ) => {
346348 for ( let entry of entries ) {
347349 const obj = entry . contentRect ;
348- this . containerWidth = obj . width + 40 // 40 is the padding
350+ this . containerWidth = obj . width + 40 ; // 40 is the padding
349351 }
350352 } ) ;
351353 // only the textarea is rendered the listener will run
352354 if ( this . $refs . textarea ) {
353355 resize . observe ( this . $refs . textarea ) ;
354356 }
355- }
357+ } ,
356358 } ,
357359 mounted ( ) {
358360 this . $nextTick ( function ( ) {
359361 this . content =
360362 this . modelValue === undefined ? this . staticValue : this . modelValue ;
361363 } ) ;
362- this . resize ( )
364+ this . resize ( ) ;
363365 } ,
364366 updated ( ) {
365- this . $emit ( ' input' , this . staticValue )
367+ this . $emit ( " input" , this . staticValue ) ;
366368 this . $nextTick ( function ( ) {
367369 this . content =
368370 this . modelValue === undefined ? this . staticValue : this . modelValue ;
@@ -433,7 +435,7 @@ const CodeEditor = {
433435 ref="textarea"
434436 :autofocus="autofocus"
435437 @input="calcContainerWidth"
436- @keydown.tab.prevent="tab"
438+ @keydown.tab.prevent.stop ="tab"
437439 v-on:scroll="scroll"
438440 v-model="staticValue"
439441 :style="{ fontSize: font_size }"
@@ -444,7 +446,7 @@ const CodeEditor = {
444446 "
445447 ref="textarea"
446448 :autofocus="autofocus"
447- @keydown.tab.prevent="tab"
449+ @keydown.tab.prevent.stop ="tab"
448450 v-on:scroll="scroll"
449451 :value="modelValue"
450452 @input="
@@ -464,5 +466,5 @@ const CodeEditor = {
464466 </pre>
465467 </div>
466468 </div>
467- `
468- }
469+ ` ,
470+ } ;
0 commit comments