@@ -274,8 +274,6 @@ export default defineComponent({
274274 } ) => true ,
275275 /** CodeMirror onFocus */
276276 focus : ( value : boolean ) => true ,
277- /** blur */
278- // blur: (value: boolean) => true,
279277 /** State Changed */
280278 change : ( value : EditorState ) => true ,
281279 /** CodeMirror onDestroy */
@@ -349,22 +347,26 @@ export default defineComponent({
349347 */
350348 const diagnosticCount : Ref < number > = ref ( 0 ) ;
351349
352- // Synamic Reconfiguration
353- // @see https://codemirror.net/examples/config/
354-
355- const language = new Compartment ( ) ;
356- const tabSize = new Compartment ( ) ;
357-
358350 /** Get CodeMirror Extension */
359- const extensions : ComputedRef < Extension [ ] > = computed ( ( ) =>
351+ const extensions : ComputedRef < Extension [ ] > = computed ( ( ) => {
352+ // Synamic Reconfiguration
353+ // @see https://codemirror.net/examples/config/
354+ const language = new Compartment ( ) ;
355+ const tabSize = new Compartment ( ) ;
356+
360357 // TODO: Ignore previous prop was not changed.
361- [
358+ return [
362359 // Toggle basic setup
363360 props . basic ? basicSetup : undefined ,
364361 // Toggle minimal setup
365362 props . minimal && ! props . basic ? minimalSetup : undefined ,
366363 // ViewUpdate event listener
367364 EditorView . updateListener . of ( ( update : ViewUpdate ) : void => {
365+ // Emit focus status
366+ context . emit ( 'focus' , view . value . hasFocus ) ;
367+ // Update count
368+ length . value = view . value . state . doc . length ;
369+
368370 if ( update . changes . empty || ! update . docChanged ) {
369371 // Suppress event firing if no change
370372 return ;
@@ -381,7 +383,6 @@ export default defineComponent({
381383 ) . length ;
382384 }
383385 context . emit ( 'update' , update ) ;
384- context . emit ( 'focus' , view . value . hasFocus ) ;
385386 } ) ,
386387 // Toggle light/dark mode.
387388 EditorView . theme ( props . theme , { dark : props . dark } ) ,
@@ -417,8 +418,8 @@ export default defineComponent({
417418 props . placeholder ? placeholder ( props . placeholder ) : undefined ,
418419 // Append Extensions
419420 ...props . extensions ,
420- ] . filter ( ( extension ) : extension is Extension => ! ! extension )
421- ) ;
421+ ] . filter ( ( extension ) : extension is Extension => ! ! extension ) ;
422+ } ) ;
422423
423424 // Extension (mostly props) Changed
424425 watch (
@@ -440,8 +441,6 @@ export default defineComponent({
440441 view . value . state . doc . toJSON ( ) . join ( props . lineSeparator ?? '\n' ) ===
441442 value // don't need to update
442443 ) {
443- // Update count
444- length . value = view . value . state . doc . length ;
445444 // Do not commit CodeMirror's store.
446445 return ;
447446 }
@@ -452,15 +451,10 @@ export default defineComponent({
452451 selection : view . value . state . selection ,
453452 scrollIntoView : true ,
454453 } ) ;
455- // Update count
456- length . value = view . value . state . doc . length ;
457454 } ,
458455 { immediate : true }
459456 ) ;
460457
461- // focus changed
462- watch ( focus , isFocus => context . emit ( 'focus' , isFocus ) ) ;
463-
464458 /** When loaded */
465459 onMounted ( async ( ) => {
466460 /** Initial value */
@@ -485,8 +479,6 @@ export default defineComponent({
485479 dispatch : ( tr : Transaction ) => {
486480 view . value . update ( [ tr ] ) ;
487481
488- context . emit ( 'focus' , view . value . hasFocus ) ;
489-
490482 if ( tr . changes . empty || ! tr . docChanged ) {
491483 // if not change value, no fire emit event
492484 return ;
@@ -677,6 +669,7 @@ export default defineComponent({
677669 length,
678670 json,
679671 diagnosticCount,
672+ dom : view . value . contentDOM ,
680673 lint,
681674 forceReconfigure,
682675 // Bellow is CodeMirror5's function
0 commit comments