@@ -49,6 +49,7 @@ import {
49
49
unselectEditor ,
50
50
waitForAnnotationEditorLayer ,
51
51
waitForAnnotationModeChanged ,
52
+ waitForPointerUp ,
52
53
waitForSelectedEditor ,
53
54
waitForSerialized ,
54
55
waitForStorageEntries ,
@@ -3392,5 +3393,58 @@ describe("FreeText Editor", () => {
3392
3393
} )
3393
3394
) ;
3394
3395
} ) ;
3396
+
3397
+ it ( "must check that we switch to FreeText in clicking on a FreeText annotation" , async ( ) => {
3398
+ await Promise . all (
3399
+ pages . map ( async ( [ browserName , page ] ) => {
3400
+ await switchToFreeText ( page ) ;
3401
+
3402
+ const rect = await getRect ( page , ".annotationEditorLayer" ) ;
3403
+ const editorSelector = getEditorSelector ( 0 ) ;
3404
+
3405
+ const data = "Hello PDF.js World !!" ;
3406
+ await page . mouse . click (
3407
+ rect . x + rect . width / 2 ,
3408
+ rect . y + rect . height / 2
3409
+ ) ;
3410
+ await page . waitForSelector ( editorSelector , { visible : true } ) ;
3411
+ await page . type ( `${ editorSelector } .internal` , data ) ;
3412
+ await commit ( page ) ;
3413
+ await waitForSerialized ( page , 1 ) ;
3414
+
3415
+ await switchToFreeText ( page , /* disable */ true ) ;
3416
+ await switchToEditor ( "Ink" , page ) ;
3417
+
3418
+ const x = rect . x + 100 ;
3419
+ const y = rect . y + 100 ;
3420
+ const clickHandle = await waitForPointerUp ( page ) ;
3421
+ await page . mouse . move ( x , y ) ;
3422
+ await page . mouse . down ( ) ;
3423
+ await page . mouse . move ( x + 50 , y + 50 ) ;
3424
+ await page . mouse . up ( ) ;
3425
+ await awaitPromise ( clickHandle ) ;
3426
+ await page . keyboard . press ( "Escape" ) ;
3427
+ await page . waitForSelector (
3428
+ ".inkEditor.selectedEditor.draggable.disabled"
3429
+ ) ;
3430
+ await waitForSerialized ( page , 2 ) ;
3431
+
3432
+ const modeChangedHandle = await createPromise ( page , resolve => {
3433
+ window . PDFViewerApplication . eventBus . on (
3434
+ "annotationeditormodechanged" ,
3435
+ resolve ,
3436
+ { once : true }
3437
+ ) ;
3438
+ } ) ;
3439
+ const editorRect = await getRect ( page , editorSelector ) ;
3440
+ await page . mouse . click (
3441
+ editorRect . x + editorRect . width / 2 ,
3442
+ editorRect . y + editorRect . height / 2
3443
+ ) ;
3444
+ await page . waitForSelector ( ".annotationEditorLayer.freetextEditing" ) ;
3445
+ await awaitPromise ( modeChangedHandle ) ;
3446
+ } )
3447
+ ) ;
3448
+ } ) ;
3395
3449
} ) ;
3396
3450
} ) ;
0 commit comments