@@ -4,33 +4,51 @@ import {buildForInput} from '../wysiwyg-tinymce/config';
44
55export class PageComment extends Component {
66
7+ protected commentId : string ;
8+ protected commentLocalId : string ;
9+ protected commentContentRef : string ;
10+ protected deletedText : string ;
11+ protected updatedText : string ;
12+
13+ protected wysiwygEditor : any = null ;
14+ protected wysiwygLanguage : string ;
15+ protected wysiwygTextDirection : string ;
16+
17+ protected container : HTMLElement ;
18+ protected contentContainer : HTMLElement ;
19+ protected form : HTMLFormElement ;
20+ protected formCancel : HTMLElement ;
21+ protected editButton : HTMLElement ;
22+ protected deleteButton : HTMLElement ;
23+ protected replyButton : HTMLElement ;
24+ protected input : HTMLInputElement ;
25+
726 setup ( ) {
827 // Options
928 this . commentId = this . $opts . commentId ;
1029 this . commentLocalId = this . $opts . commentLocalId ;
11- this . commentParentId = this . $opts . commentParentId ;
30+ this . commentContentRef = this . $opts . commentContentRef ;
1231 this . deletedText = this . $opts . deletedText ;
1332 this . updatedText = this . $opts . updatedText ;
1433
1534 // Editor reference and text options
16- this . wysiwygEditor = null ;
1735 this . wysiwygLanguage = this . $opts . wysiwygLanguage ;
1836 this . wysiwygTextDirection = this . $opts . wysiwygTextDirection ;
1937
2038 // Element references
2139 this . container = this . $el ;
2240 this . contentContainer = this . $refs . contentContainer ;
23- this . form = this . $refs . form ;
41+ this . form = this . $refs . form as HTMLFormElement ;
2442 this . formCancel = this . $refs . formCancel ;
2543 this . editButton = this . $refs . editButton ;
2644 this . deleteButton = this . $refs . deleteButton ;
2745 this . replyButton = this . $refs . replyButton ;
28- this . input = this . $refs . input ;
46+ this . input = this . $refs . input as HTMLInputElement ;
2947
3048 this . setupListeners ( ) ;
3149 }
3250
33- setupListeners ( ) {
51+ protected setupListeners ( ) : void {
3452 if ( this . replyButton ) {
3553 this . replyButton . addEventListener ( 'click' , ( ) => this . $emit ( 'reply' , {
3654 id : this . commentLocalId ,
@@ -49,12 +67,12 @@ export class PageComment extends Component {
4967 }
5068 }
5169
52- toggleEditMode ( show ) {
70+ protected toggleEditMode ( show : boolean ) : void {
5371 this . contentContainer . toggleAttribute ( 'hidden' , show ) ;
5472 this . form . toggleAttribute ( 'hidden' , ! show ) ;
5573 }
5674
57- startEdit ( ) {
75+ protected startEdit ( ) : void {
5876 this . toggleEditMode ( true ) ;
5977
6078 if ( this . wysiwygEditor ) {
@@ -67,29 +85,30 @@ export class PageComment extends Component {
6785 containerElement : this . input ,
6886 darkMode : document . documentElement . classList . contains ( 'dark-mode' ) ,
6987 textDirection : this . wysiwygTextDirection ,
88+ drawioUrl : '' ,
89+ pageId : 0 ,
7090 translations : { } ,
71- translationMap : window . editor_translations ,
91+ translationMap : ( window as Record < string , Object > ) . editor_translations ,
7292 } ) ;
7393
74- window . tinymce . init ( config ) . then ( editors => {
94+ ( window as { tinymce : { init : ( Object ) => Promise < any > } } ) . tinymce . init ( config ) . then ( editors => {
7595 this . wysiwygEditor = editors [ 0 ] ;
7696 setTimeout ( ( ) => this . wysiwygEditor . focus ( ) , 50 ) ;
7797 } ) ;
7898 }
7999
80- async update ( event ) {
100+ protected async update ( event : Event ) : Promise < void > {
81101 event . preventDefault ( ) ;
82102 const loading = this . showLoading ( ) ;
83103 this . form . toggleAttribute ( 'hidden' , true ) ;
84104
85105 const reqData = {
86106 html : this . wysiwygEditor . getContent ( ) ,
87- parent_id : this . parentId || null ,
88107 } ;
89108
90109 try {
91110 const resp = await window . $http . put ( `/comment/${ this . commentId } ` , reqData ) ;
92- const newComment = htmlToDom ( resp . data ) ;
111+ const newComment = htmlToDom ( resp . data as string ) ;
93112 this . container . replaceWith ( newComment ) ;
94113 window . $events . success ( this . updatedText ) ;
95114 } catch ( err ) {
@@ -100,7 +119,7 @@ export class PageComment extends Component {
100119 }
101120 }
102121
103- async delete ( ) {
122+ protected async delete ( ) : Promise < void > {
104123 this . showLoading ( ) ;
105124
106125 await window . $http . delete ( `/comment/${ this . commentId } ` ) ;
@@ -109,7 +128,7 @@ export class PageComment extends Component {
109128 window . $events . success ( this . deletedText ) ;
110129 }
111130
112- showLoading ( ) {
131+ protected showLoading ( ) : HTMLElement {
113132 const loading = getLoading ( ) ;
114133 loading . classList . add ( 'px-l' ) ;
115134 this . container . append ( loading ) ;
0 commit comments