@@ -3,7 +3,7 @@ import WordpressPlugin from './main';
3
3
import { CommentStatus , PostStatus } from './wp-api' ;
4
4
import { TranslateKey } from './i18n' ;
5
5
import { WpProfileManageModal } from './wp-profile-manage-modal' ;
6
- import { MathJaxOutputType } from './plugin-settings' ;
6
+ import { CommentConvertMode , MathJaxOutputType } from './plugin-settings' ;
7
7
import { WpProfile } from './wp-profile' ;
8
8
import { setupMarkdownParser } from './utils' ;
9
9
import { AppState } from './app-state' ;
@@ -33,13 +33,25 @@ export class WordpressSettingTab extends PluginSettingTab {
33
33
}
34
34
}
35
35
36
+ const getCommentConvertModeDesc = ( type : CommentConvertMode ) : string => {
37
+ switch ( type ) {
38
+ case CommentConvertMode . Ignore :
39
+ return t ( 'settings_commentConvertModeIgnoreDesc' ) ;
40
+ case CommentConvertMode . HTML :
41
+ return t ( 'settings_commentConvertModeHTMLDesc' ) ;
42
+ default :
43
+ return '' ;
44
+ }
45
+ }
46
+
36
47
const { containerEl } = this ;
37
48
38
49
containerEl . empty ( ) ;
39
50
40
51
containerEl . createEl ( 'h1' , { text : t ( 'settings_title' ) } ) ;
41
52
42
53
let mathJaxOutputTypeDesc = getMathJaxOutputTypeDesc ( this . plugin . settings . mathJaxOutputType ) ;
54
+ let commentConvertModeDesc = getCommentConvertModeDesc ( this . plugin . settings . commentConvertMode ) ;
43
55
44
56
new Setting ( containerEl )
45
57
. setName ( t ( 'settings_profiles' ) )
@@ -147,6 +159,28 @@ export class WordpressSettingTab extends PluginSettingTab {
147
159
cls : 'setting-item-description'
148
160
} ) ;
149
161
162
+ new Setting ( containerEl )
163
+ . setName ( t ( 'settings_commentConvertMode' ) )
164
+ . setDesc ( t ( 'settings_commentConvertModeDesc' ) )
165
+ . addDropdown ( ( dropdown ) => {
166
+ dropdown
167
+ . addOption ( CommentConvertMode . Ignore , t ( 'settings_commentConvertModeIgnore' ) )
168
+ . addOption ( CommentConvertMode . HTML , t ( 'settings_commentConvertModeHTML' ) )
169
+ . setValue ( this . plugin . settings . commentConvertMode )
170
+ . onChange ( async ( value ) => {
171
+ this . plugin . settings . commentConvertMode = value as CommentConvertMode ;
172
+ commentConvertModeDesc = getCommentConvertModeDesc ( this . plugin . settings . commentConvertMode ) ;
173
+ await this . plugin . saveSettings ( ) ;
174
+ this . display ( ) ;
175
+
176
+ setupMarkdownParser ( this . plugin . settings ) ;
177
+ } ) ;
178
+ } ) ;
179
+ containerEl . createEl ( 'p' , {
180
+ text : commentConvertModeDesc ,
181
+ cls : 'setting-item-description'
182
+ } ) ;
183
+
150
184
new Setting ( containerEl )
151
185
. setName ( t ( 'settings_enableHtml' ) )
152
186
. setDesc ( t ( 'settings_enableHtmlDesc' ) )
@@ -157,7 +191,7 @@ export class WordpressSettingTab extends PluginSettingTab {
157
191
this . plugin . settings . enableHtml = value ;
158
192
await this . plugin . saveSettings ( ) ;
159
193
160
- AppState . getInstance ( ) . markdownParser . set ( {
194
+ AppState . markdownParser . set ( {
161
195
html : this . plugin . settings . enableHtml
162
196
} ) ;
163
197
} ) ,
0 commit comments