@@ -23,13 +23,16 @@ it's recommended that you take a backup of your notes more often using the
23
23
const lightMetaColor = '#4d4d4d' ;
24
24
const metaThemeColor = document . querySelector ( 'meta[name=theme-color]' ) ;
25
25
const { notepad, state, setState, removeState, get } = selector ( ) ;
26
+ const optimalLineLengthPadding = '15px 15vw 40px' ;
26
27
27
28
const editorConfig = {
28
29
defaultFontSize : 18 ,
29
30
defaultLineHeight : 26 ,
30
31
defaultFontWeight : 'normal' ,
31
32
defaultShowWordCountPill : 'Yes' ,
32
- defaultWriteDirection : 'ltr'
33
+ defaultWriteDirection : 'ltr' ,
34
+ defaultOptimalLineLength : 'No' ,
35
+ defaultOptimalLineLengthPadding : '15px 15px 40px'
33
36
} ;
34
37
35
38
const themeConfig = {
@@ -87,6 +90,20 @@ it's recommended that you take a backup of your notes more often using the
87
90
resetWriteDirection ( editorConfig . defaultWriteDirection ) ;
88
91
}
89
92
93
+ if ( state . userChosenOptimalLineLengthSelected ) {
94
+ const textArea = document . getElementById ( 'note' ) ;
95
+
96
+ if ( state . userChosenOptimalLineLengthSelected === 'Yes' ) {
97
+ textArea . style . padding = optimalLineLengthPadding ;
98
+ } else {
99
+ textArea . style . padding = editorConfig . defaultOptimalLineLengthPadding ;
100
+ }
101
+
102
+ notepad . optimalLineLength . val ( state . userChosenOptimalLineLengthSelected ) ;
103
+ } else {
104
+ resetOptimalLineLength ( editorConfig . defaultOptimalLineLengthPadding , editorConfig . defaultOptimalLineLength ) ;
105
+ }
106
+
90
107
if ( state . mode && state . mode === 'dark' ) {
91
108
enableDarkMode ( lightmodeText , darkMetaColor , metaThemeColor ) ;
92
109
} else {
@@ -165,6 +182,20 @@ it's recommended that you take a backup of your notes more often using the
165
182
setState ( 'userChosenWordCountPillSelected' , showWordCountPillSelected ) ;
166
183
} ) ;
167
184
185
+ notepad . optimalLineLength . on ( 'change' , function ( e ) {
186
+ const optimalLineLengthSelected = this . value ;
187
+
188
+ const textArea = document . getElementById ( 'note' ) ;
189
+
190
+ if ( optimalLineLengthSelected === 'Yes' ) {
191
+ textArea . style . padding = optimalLineLengthPadding ;
192
+ } else {
193
+ textArea . style . padding = editorConfig . defaultOptimalLineLengthPadding ;
194
+ }
195
+
196
+ setState ( 'userChosenOptimalLineLengthSelected' , optimalLineLengthSelected ) ;
197
+ } )
198
+
168
199
notepad . resetPreferences . click ( function ( ) {
169
200
if ( selector ( ) . state . userChosenFontSize ) {
170
201
removeState ( 'userChosenFontSize' ) ;
@@ -190,6 +221,11 @@ it's recommended that you take a backup of your notes more often using the
190
221
removeState ( 'userChosenWriteDirection' ) ;
191
222
resetWriteDirection ( editorConfig . defaultWriteDirection ) ;
192
223
}
224
+
225
+ if ( selector ( ) . state . userChosenOptimalLineLengthSelected ) {
226
+ removeState ( 'userChosenOptimalLineLengthSelected' ) ;
227
+ resetOptimalLineLength ( editorConfig . defaultOptimalLineLengthPadding , editorConfig . defaultOptimalLineLength ) ;
228
+ }
193
229
} ) ;
194
230
195
231
// This changes the application's theme when
0 commit comments