@@ -121,6 +121,7 @@ export default class scripts{
121
121
------------------------------------------------------ */
122
122
@action addNewScript ( ) {
123
123
this . titlePage = { title : 'NEW SCRIPT' , author : 'AUTHOR' , extra : 'EXTRA: this and that' , contact : 'contact info:' } ;
124
+ // First line is always FADE IN:
124
125
this . paragraphs = [ { type : 'para-fadein' , focus : true , innerHTML : 'FADE IN:' , text : 'FADE IN:' , selectionStart : { line :0 , offset :8 } , height : 16 + this . Hdata [ 'para-fadein' ] , key : Math . random ( ) , line : 1 } ] ;
125
126
this . pages = [ [ 0 , 0 ] ] ;
126
127
this . lastSave = Date . now ( ) ;
@@ -258,6 +259,7 @@ export default class scripts{
258
259
// this.selectbox.display='none';
259
260
// }
260
261
262
+
261
263
/* ------------------------------------------------------
262
264
263
265
Handle blur of paragraph, text will be saved, and page will be reCalculated if needed
@@ -274,6 +276,11 @@ export default class scripts{
274
276
const targetLineOffSet = parseInt ( targetOffSet / this . lineCharNum [ targetClassName ] ) ;
275
277
const targetLine = parseInt ( targetText . length / this . lineCharNum [ targetClassName ] ) + 1 ;
276
278
279
+ /* ------------------------------------------------------
280
+ Set focus false
281
+ ------------------------------------------------------ */
282
+ this . paragraphs [ index ] . focus = false ;
283
+
277
284
const paragraphLengthOld = this . paragraphs . length ;
278
285
const paragraphHeightOld = this . paragraphs [ index ] . height ;
279
286
@@ -383,7 +390,6 @@ export default class scripts{
383
390
// show selectbox
384
391
this . selectbox . index = index ;
385
392
this . selectbox . display = 'block' ;
386
- this . paragraphs [ index ] . focus = false ;
387
393
} else {
388
394
389
395
/* ------------------------------------------------------
@@ -396,7 +402,6 @@ export default class scripts{
396
402
newPara . selectionStart = { line :0 , offset :1 }
397
403
}
398
404
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
399
- this . paragraphs [ index ] . focus = false ;
400
405
401
406
// console.log(this.paragraphs[index].type);
402
407
}
@@ -433,7 +438,6 @@ export default class scripts{
433
438
// show selectbox
434
439
this . selectbox . index = index ;
435
440
this . selectbox . display = 'block' ;
436
- this . paragraphs [ index ] . focus = false ;
437
441
}
438
442
439
443
/* ------------------------------------------------------
@@ -446,42 +450,34 @@ export default class scripts{
446
450
case 'para-fadein' :
447
451
newPara = { type : 'para-scene' , focus : true , height : 16 + this . Hdata [ 'para-scene' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
448
452
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
449
- this . paragraphs [ index ] . focus = false ;
450
453
break ;
451
454
case 'para-action' :
452
455
newPara = { type : 'para-action' , focus : true , height : 16 + this . Hdata [ 'para-action' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
453
456
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
454
- this . paragraphs [ index ] . focus = false ;
455
457
break ;
456
458
case 'para-scene' :
457
459
newPara = { type : 'para-action' , focus : true , height : 16 + this . Hdata [ 'para-action' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
458
460
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
459
- this . paragraphs [ index ] . focus = false ;
460
461
break ;
461
462
case 'para-character' :
462
463
newPara = { type : 'para-dialogue' , focus : true , height : 16 + this . Hdata [ 'para-dialogue' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
463
464
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
464
- this . paragraphs [ index ] . focus = false ;
465
465
break ;
466
466
case 'para-parenthetical' :
467
467
newPara = { type : 'para-dialogue' , focus : true , height : 16 + this . Hdata [ 'para-dialogue' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
468
468
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
469
- this . paragraphs [ index ] . focus = false ;
470
469
break ;
471
470
case 'para-dialogue' :
472
471
newPara = { type : 'para-action' , focus : true , height : 16 + this . Hdata [ 'para-action' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
473
472
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
474
- this . paragraphs [ index ] . focus = false ;
475
473
break ;
476
474
case 'para-transition' :
477
475
newPara = { type : 'para-scene' , focus : true , height : 16 + this . Hdata [ 'para-scene' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
478
476
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
479
- this . paragraphs [ index ] . focus = false ;
480
477
break ;
481
478
case 'para-shot' :
482
479
newPara = { type : 'para-action' , focus : true , height : 16 + this . Hdata [ 'para-action' ] , key : Math . random ( ) , line : 1 , selectionStart : { line :0 , offset :0 } , innerHTML : '' , text : '' } ;
483
480
this . paragraphs . splice ( index + 1 , 0 , newPara ) ;
484
- this . paragraphs [ index ] . focus = false ;
485
481
break ;
486
482
}
487
483
}
@@ -515,7 +511,6 @@ export default class scripts{
515
511
if ( util . isSelected ( ) ) {
516
512
util . deleteContent ( ) ;
517
513
} else {
518
- this . paragraphs [ index ] . focus = false ;
519
514
this . paragraphs [ index - 1 ] . focus = true ;
520
515
this . paragraphs [ index - 1 ] . selectionStart = { line : this . paragraphs [ index - 1 ] . line - 1 , offset : this . paragraphs [ index - 1 ] . text . length } ;
521
516
}
@@ -527,7 +522,6 @@ export default class scripts{
527
522
else if ( e . keyCode === 37 && targetOffSet === 0 ) {
528
523
if ( index != 0 ) {
529
524
e . preventDefault ( ) ;
530
- this . paragraphs [ index ] . focus = false ;
531
525
this . paragraphs [ index - 1 ] . focus = true ;
532
526
this . paragraphs [ index - 1 ] . selectionStart = { line : this . paragraphs [ index - 1 ] . line - 1 , offset : this . paragraphs [ index - 1 ] . text . length } ;
533
527
}
@@ -539,7 +533,6 @@ export default class scripts{
539
533
else if ( e . keyCode === 39 && targetOffSet === targetText . length ) {
540
534
if ( index != this . paragraphs . length - 1 ) {
541
535
e . preventDefault ( ) ;
542
- this . paragraphs [ index ] . focus = false ;
543
536
this . paragraphs [ index + 1 ] . focus = true ;
544
537
this . paragraphs [ index + 1 ] . selectionStart = { line : 0 , offset : 0 } ;
545
538
}
@@ -551,7 +544,6 @@ export default class scripts{
551
544
else if ( e . keyCode === 38 && targetLineOffSet === 0 ) {
552
545
if ( index != 0 ) {
553
546
e . preventDefault ( ) ;
554
- this . paragraphs [ index ] . focus = false ;
555
547
this . paragraphs [ index - 1 ] . focus = true ;
556
548
// set cursor of prev paragraph relative to the first line of current paragraph
557
549
this . paragraphs [ index - 1 ] . selectionStart = { line : this . paragraphs [ index - 1 ] . line - 1 , offset : 0 }
@@ -564,7 +556,6 @@ export default class scripts{
564
556
else if ( e . keyCode === 40 && targetLineOffSet === targetLine - 1 ) {
565
557
if ( index != this . paragraphs . length - 1 ) {
566
558
e . preventDefault ( ) ;
567
- this . paragraphs [ index ] . focus = false ;
568
559
this . paragraphs [ index + 1 ] . focus = true ;
569
560
// set cursor of next paragraph relative to the last line of current paragraph
570
561
this . paragraphs [ index + 1 ] . selectionStart = { line : 0 , offset : 0 }
0 commit comments