1
- import { App , PluginSettingTab , Setting } from 'obsidian' ;
2
- import ReadItLaterPlugin from './main' ;
3
-
4
1
export interface ReadItLaterSettings {
5
2
inboxDir : string ;
6
3
assetsDir : string ;
7
4
openNewNote : boolean ;
5
+ youtubeNoteTitle : string ;
8
6
youtubeNote : string ;
7
+ twitterNoteTitle : string ;
9
8
twitterNote : string ;
9
+ parseableArticleNoteTitle : string ;
10
10
parsableArticleNote : string ;
11
+ notParseableArticleNoteTitle : string ;
11
12
notParsableArticleNote : string ;
13
+ textSnippetNoteTitle : string ;
12
14
textSnippetNote : string ;
13
15
downloadImages : boolean ;
14
16
}
@@ -17,153 +19,15 @@ export const DEFAULT_SETTINGS: ReadItLaterSettings = {
17
19
inboxDir : 'ReadItLater Inbox' ,
18
20
assetsDir : 'ReadItLater Inbox/assets' ,
19
21
openNewNote : false ,
22
+ youtubeNoteTitle : 'Youtube - %title%' ,
20
23
youtubeNote : `[[ReadItLater]] [[Youtube]]\n\n# [%videoTitle%](%videoURL%)\n\n%videoPlayer%` ,
24
+ twitterNoteTitle : 'Tweet from %tweetAuthorName% (%date%)' ,
21
25
twitterNote : `[[ReadItLater]] [[Tweet]]\n\n# [%tweetAuthorName%](%tweetURL%)\n\n%tweetContent%` ,
26
+ parseableArticleNoteTitle : '%title%' ,
22
27
parsableArticleNote : `[[ReadItLater]] [[Article]]\n\n# [%articleTitle%](%articleURL%)\n\n%articleContent%` ,
28
+ notParseableArticleNoteTitle : 'Article %date%' ,
23
29
notParsableArticleNote : `[[ReadItLater]] [[Article]]\n\n[%articleURL%](%articleURL%)` ,
30
+ textSnippetNoteTitle : 'Notice %date%' ,
24
31
textSnippetNote : `[[ReadItLater]] [[Textsnippet]]\n\n%content%` ,
25
32
downloadImages : true ,
26
- } ;
27
-
28
- export class ReadItLaterSettingsTab extends PluginSettingTab {
29
- plugin : ReadItLaterPlugin ;
30
-
31
- constructor ( app : App , plugin : ReadItLaterPlugin ) {
32
- super ( app , plugin ) ;
33
- this . plugin = plugin ;
34
- }
35
-
36
- display ( ) : void {
37
- const { containerEl } = this ;
38
-
39
- containerEl . empty ( ) ;
40
-
41
- containerEl . createEl ( 'h2' , { text : 'Settings for the ReadItLater plugin.' } ) ;
42
-
43
- new Setting ( containerEl )
44
- . setName ( 'Inbox dir' )
45
- . setDesc (
46
- 'Enter valid folder name. For nested folders use this format: Folder A/Folder B. If no folder is enetred, new note will be created in vault root.' ,
47
- )
48
- . addText ( ( text ) =>
49
- text
50
- . setPlaceholder ( 'Defaults to root' )
51
- . setValue ( this . plugin . settings . inboxDir || DEFAULT_SETTINGS . inboxDir )
52
- . onChange ( async ( value ) => {
53
- this . plugin . settings . inboxDir = value ;
54
- await this . plugin . saveSettings ( ) ;
55
- } ) ,
56
- ) ;
57
-
58
- new Setting ( containerEl )
59
- . setName ( 'Open new note' )
60
- . setDesc ( 'If enabled, new note will open in current workspace' )
61
- . addToggle ( ( toggle ) =>
62
- toggle
63
- . setValue ( this . plugin . settings . openNewNote || DEFAULT_SETTINGS . openNewNote )
64
- . onChange ( async ( value ) => {
65
- this . plugin . settings . openNewNote = value ;
66
- await this . plugin . saveSettings ( ) ;
67
- } ) ,
68
- ) ;
69
-
70
- new Setting ( containerEl )
71
- . setName ( 'Download images' )
72
- . setDesc ( 'If this is true, the used images are downloaded to the defined folder' )
73
- . addToggle ( ( toggle ) =>
74
- toggle
75
- . setValue ( this . plugin . settings . downloadImages || DEFAULT_SETTINGS . downloadImages )
76
- . onChange ( async ( value ) => {
77
- this . plugin . settings . downloadImages = value ;
78
- assetDirSetting . setDisabled ( ! value ) ;
79
- await this . plugin . saveSettings ( ) ;
80
- } ) ,
81
- ) ;
82
-
83
- const assetDirSetting = new Setting ( containerEl )
84
- . setName ( 'Assets dir' )
85
- . setDesc (
86
- 'Enter valid folder name. For nested folders use this format: Folder A/Folder B. If no folder is enetred, new note will be created in vault root.' ,
87
- )
88
- . addText ( ( text ) =>
89
- text
90
- . setPlaceholder ( 'Defaults to root' )
91
- . setValue ( this . plugin . settings . assetsDir || DEFAULT_SETTINGS . inboxDir + '/assets' )
92
- . setDisabled ( ! this . plugin . settings . downloadImages )
93
- . onChange ( async ( value ) => {
94
- this . plugin . settings . assetsDir = value ;
95
- await this . plugin . saveSettings ( ) ;
96
- } ) ,
97
- ) ;
98
-
99
- new Setting ( containerEl )
100
- . setName ( 'Youtube note template' )
101
- . setDesc ( 'Available variables: %videoTitle%, %videoURL%, %videoId%, %videoPlayer%' )
102
- . addTextArea ( ( textarea ) => {
103
- textarea
104
- . setValue ( this . plugin . settings . youtubeNote || DEFAULT_SETTINGS . youtubeNote )
105
- . onChange ( async ( value ) => {
106
- this . plugin . settings . youtubeNote = value ;
107
- await this . plugin . saveSettings ( ) ;
108
- } ) ;
109
- textarea . inputEl . rows = 10 ;
110
- textarea . inputEl . cols = 25 ;
111
- } ) ;
112
-
113
- new Setting ( containerEl )
114
- . setName ( 'Twitter note template' )
115
- . setDesc ( 'Available variables: %tweetAuthorName%, %tweetURL%, %tweetContent%' )
116
- . addTextArea ( ( textarea ) => {
117
- textarea
118
- . setValue ( this . plugin . settings . twitterNote || DEFAULT_SETTINGS . twitterNote )
119
- . onChange ( async ( value ) => {
120
- this . plugin . settings . twitterNote = value ;
121
- await this . plugin . saveSettings ( ) ;
122
- } ) ;
123
- textarea . inputEl . rows = 10 ;
124
- textarea . inputEl . cols = 25 ;
125
- } ) ;
126
-
127
- new Setting ( containerEl )
128
- . setName ( 'Parsable article note template' )
129
- . setDesc ( 'Available variables: %articleTitle%, %articleURL%, %articleContent%' )
130
- . addTextArea ( ( textarea ) => {
131
- textarea
132
- . setValue ( this . plugin . settings . parsableArticleNote || DEFAULT_SETTINGS . parsableArticleNote )
133
- . onChange ( async ( value ) => {
134
- this . plugin . settings . parsableArticleNote = value ;
135
- await this . plugin . saveSettings ( ) ;
136
- } ) ;
137
- textarea . inputEl . rows = 10 ;
138
- textarea . inputEl . cols = 25 ;
139
- } ) ;
140
-
141
- new Setting ( containerEl )
142
- . setName ( 'Not parsable article note template' )
143
- . setDesc ( 'Available variables: %articleURL%' )
144
- . addTextArea ( ( textarea ) => {
145
- textarea
146
- . setValue ( this . plugin . settings . notParsableArticleNote || DEFAULT_SETTINGS . notParsableArticleNote )
147
- . onChange ( async ( value ) => {
148
- this . plugin . settings . notParsableArticleNote = value ;
149
- await this . plugin . saveSettings ( ) ;
150
- } ) ;
151
- textarea . inputEl . rows = 10 ;
152
- textarea . inputEl . cols = 25 ;
153
- } ) ;
154
-
155
- new Setting ( containerEl )
156
- . setName ( 'Text snippet note template' )
157
- . setDesc ( 'Available variables: %content%' )
158
- . addTextArea ( ( textarea ) => {
159
- textarea
160
- . setValue ( this . plugin . settings . textSnippetNote || DEFAULT_SETTINGS . textSnippetNote )
161
- . onChange ( async ( value ) => {
162
- this . plugin . settings . textSnippetNote = value ;
163
- await this . plugin . saveSettings ( ) ;
164
- } ) ;
165
- textarea . inputEl . rows = 10 ;
166
- textarea . inputEl . cols = 25 ;
167
- } ) ;
168
- }
169
- }
33
+ } ;
0 commit comments