@@ -19,6 +19,7 @@ import { map, startWith } from 'rxjs/operators';
19
19
import { GlobalConfigService } from '../../features/config/global-config.service' ;
20
20
import { MatDialog } from '@angular/material/dialog' ;
21
21
import { DialogFullscreenMarkdownComponent } from '../dialog-fullscreen-markdown/dialog-fullscreen-markdown.component' ;
22
+ import { isMarkdownChecklist } from '../../features/markdown-checklist/is-markdown-checklist' ;
22
23
23
24
const HIDE_OVERFLOW_TIMEOUT_DURATION = 300 ;
24
25
@@ -32,6 +33,7 @@ const HIDE_OVERFLOW_TIMEOUT_DURATION = 300;
32
33
export class InlineMarkdownComponent implements OnInit , OnDestroy {
33
34
@Input ( ) isLock : boolean = false ;
34
35
@Input ( ) isShowControls : boolean = false ;
36
+ @Input ( ) isShowChecklistToggle : boolean = false ;
35
37
36
38
@Output ( ) changed : EventEmitter < string > = new EventEmitter ( ) ;
37
39
@Output ( ) focused : EventEmitter < Event > = new EventEmitter ( ) ;
@@ -42,6 +44,7 @@ export class InlineMarkdownComponent implements OnInit, OnDestroy {
42
44
@ViewChild ( 'previewEl' ) previewEl : MarkdownComponent | undefined ;
43
45
44
46
isHideOverflow : boolean = false ;
47
+ isChecklistMode : boolean = false ;
45
48
isShowEdit : boolean = false ;
46
49
modelCopy : string | undefined ;
47
50
@@ -78,6 +81,9 @@ export class InlineMarkdownComponent implements OnInit, OnDestroy {
78
81
this . resizeParsedToFit ( ) ;
79
82
} ) ;
80
83
}
84
+
85
+ this . isChecklistMode =
86
+ this . isChecklistMode && this . isShowChecklistToggle && ! ! v && isMarkdownChecklist ( v ) ;
81
87
}
82
88
83
89
@Input ( ) set isFocus ( val : boolean ) {
@@ -103,6 +109,10 @@ export class InlineMarkdownComponent implements OnInit, OnDestroy {
103
109
}
104
110
}
105
111
112
+ checklistToggle ( ) : void {
113
+ this . isChecklistMode = ! this . isChecklistMode ;
114
+ }
115
+
106
116
keypressHandler ( ev : KeyboardEvent ) : void {
107
117
this . resizeTextareaToFit ( ) ;
108
118
@@ -207,6 +217,18 @@ export class InlineMarkdownComponent implements OnInit, OnDestroy {
207
217
this . blurred . emit ( ev ) ;
208
218
}
209
219
220
+ toggleChecklistMode ( ev : Event ) : void {
221
+ ev . preventDefault ( ) ;
222
+ ev . stopPropagation ( ) ;
223
+ this . isChecklistMode = true ;
224
+ this . _toggleShowEdit ( ) ;
225
+ if ( this . modelCopy && isMarkdownChecklist ( this . modelCopy ) ) {
226
+ this . modelCopy += '\n- [ ] ' ;
227
+ } else {
228
+ this . modelCopy = '- [ ] ' ;
229
+ }
230
+ }
231
+
210
232
private _toggleShowEdit ( ) : void {
211
233
this . isShowEdit = true ;
212
234
this . modelCopy = this . model || '' ;
0 commit comments