@@ -56,6 +56,10 @@ class SignatureManager {
5656
5757 #errorBar;
5858
59+ #errorDescription;
60+
61+ #errorTitle;
62+
5963 #extractedSignatureData = null ;
6064
6165 #imagePath = null ;
@@ -123,6 +127,8 @@ class SignatureManager {
123127 addButton,
124128 errorCloseButton,
125129 errorBar,
130+ errorTitle,
131+ errorDescription,
126132 saveCheckbox,
127133 saveContainer,
128134 } ,
@@ -142,6 +148,8 @@ class SignatureManager {
142148 this . #drawPlaceholder = drawPlaceholder ;
143149 this . #drawThickness = drawThickness ;
144150 this . #errorBar = errorBar ;
151+ this . #errorTitle = errorTitle ;
152+ this . #errorDescription = errorDescription ;
145153 this . #imageSVG = imageSVG ;
146154 this . #imagePlaceholder = imagePlaceholder ;
147155 this . #imagePicker = imagePicker ;
@@ -161,6 +169,12 @@ class SignatureManager {
161169
162170 SignatureManager . #l10nDescription ||= Object . freeze ( {
163171 signature : "pdfjs-editor-add-signature-description-default-when-drawing" ,
172+ errorUploadTitle : "pdfjs-editor-add-signature-image-upload-error-title" ,
173+ errorUploadDescription :
174+ "pdfjs-editor-add-signature-image-upload-error-description" ,
175+ errorNoDataTitle : "pdfjs-editor-add-signature-image-no-data-error-title" ,
176+ errorNoDataDescription :
177+ "pdfjs-editor-add-signature-image-no-data-error-description" ,
164178 } ) ;
165179
166180 dialog . addEventListener ( "close" , this . #close. bind ( this ) ) ;
@@ -506,6 +520,18 @@ class SignatureManager {
506520 ) ;
507521 }
508522
523+ #showError( type ) {
524+ this . #errorTitle. setAttribute (
525+ "data-l10n-id" ,
526+ SignatureManager . #l10nDescription[ `error${ type } Title` ]
527+ ) ;
528+ this . #errorDescription. setAttribute (
529+ "data-l10n-id" ,
530+ SignatureManager . #l10nDescription[ `error${ type } Description` ]
531+ ) ;
532+ this . #errorBar. hidden = false ;
533+ }
534+
509535 #initImageTab( reset ) {
510536 if ( reset ) {
511537 this . #resetTab( "image" ) ;
@@ -539,7 +565,7 @@ class SignatureManager {
539565 async ( ) => {
540566 const file = this . #imagePicker. files ?. [ 0 ] ;
541567 if ( ! file || ! SupportedImageMimeTypes . includes ( file . type ) ) {
542- this . #errorBar . hidden = false ;
568+ this . #showError ( "Upload" ) ;
543569 this . #dialog. classList . toggle ( "waiting" , false ) ;
544570 return ;
545571 }
@@ -601,18 +627,19 @@ class SignatureManager {
601627 console . error ( "SignatureManager.#extractSignature." , e ) ;
602628 }
603629 if ( ! data ) {
604- this . #errorBar . hidden = false ;
630+ this . #showError ( "Upload" ) ;
605631 this . #dialog. classList . toggle ( "waiting" , false ) ;
606632 return ;
607633 }
608634
609- const { outline } = ( this . #extractedSignatureData =
635+ const lineData = ( this . #extractedSignatureData =
610636 this . #currentEditor. getFromImage ( data . bitmap ) ) ;
611-
612- if ( ! outline ) {
637+ if ( ! lineData ) {
638+ this . #showError ( "NoData" ) ;
613639 this . #dialog. classList . toggle ( "waiting" , false ) ;
614640 return ;
615641 }
642+ const { outline } = lineData ;
616643
617644 this . #imagePlaceholder. hidden = true ;
618645 this . #disableButtons( true ) ;
0 commit comments