@@ -21,7 +21,7 @@ const baseOptions = {
21
21
automaticLayout : true ,
22
22
} ;
23
23
24
- function getEditorconfig ( input ) {
24
+ function getEditorconfig ( input : HTMLInputElement ) {
25
25
try {
26
26
return JSON . parse ( input . getAttribute ( 'data-editorconfig' ) ) ;
27
27
} catch {
@@ -58,7 +58,7 @@ function exportEditor(editor) {
58
58
if ( ! window . codeEditors . includes ( editor ) ) window . codeEditors . push ( editor ) ;
59
59
}
60
60
61
- export async function createMonaco ( textarea , filename , editorOpts ) {
61
+ export async function createMonaco ( textarea : HTMLTextAreaElement , filename : string , editorOpts : Record < string , any > ) {
62
62
const monaco = await import ( /* webpackChunkName: "monaco" */ 'monaco-editor' ) ;
63
63
64
64
initLanguages ( monaco ) ;
@@ -72,7 +72,7 @@ export async function createMonaco(textarea, filename, editorOpts) {
72
72
// https://github.com/microsoft/monaco-editor/issues/2427
73
73
// also, monaco can only parse 6-digit hex colors, so we convert the colors to that format
74
74
const styles = window . getComputedStyle ( document . documentElement ) ;
75
- const getColor = ( name ) => tinycolor ( styles . getPropertyValue ( name ) . trim ( ) ) . toString ( 'hex6' ) ;
75
+ const getColor = ( name : string ) => tinycolor ( styles . getPropertyValue ( name ) . trim ( ) ) . toString ( 'hex6' ) ;
76
76
77
77
monaco . editor . defineTheme ( 'gitea' , {
78
78
base : isDarkTheme ( ) ? 'vs-dark' : 'vs' ,
@@ -127,13 +127,13 @@ export async function createMonaco(textarea, filename, editorOpts) {
127
127
return { monaco, editor} ;
128
128
}
129
129
130
- function getFileBasedOptions ( filename , lineWrapExts ) {
130
+ function getFileBasedOptions ( filename : string , lineWrapExts : string [ ] ) {
131
131
return {
132
132
wordWrap : ( lineWrapExts || [ ] ) . includes ( extname ( filename ) ) ? 'on' : 'off' ,
133
133
} ;
134
134
}
135
135
136
- function togglePreviewDisplay ( previewable ) {
136
+ function togglePreviewDisplay ( previewable : boolean ) {
137
137
const previewTab = document . querySelector ( 'a[data-tab="preview"]' ) ;
138
138
if ( ! previewTab ) return ;
139
139
@@ -152,7 +152,7 @@ function togglePreviewDisplay(previewable) {
152
152
}
153
153
}
154
154
155
- export async function createCodeEditor ( textarea , filenameInput ) {
155
+ export async function createCodeEditor ( textarea : HTMLTextAreaElement , filenameInput : HTMLInputElement ) {
156
156
const filename = basename ( filenameInput . value ) ;
157
157
const previewableExts = new Set ( ( textarea . getAttribute ( 'data-previewable-extensions' ) || '' ) . split ( ',' ) ) ;
158
158
const lineWrapExts = ( textarea . getAttribute ( 'data-line-wrap-extensions' ) || '' ) . split ( ',' ) ;
@@ -177,10 +177,10 @@ export async function createCodeEditor(textarea, filenameInput) {
177
177
return editor ;
178
178
}
179
179
180
- function getEditorConfigOptions ( ec ) {
180
+ function getEditorConfigOptions ( ec : Record < string , any > ) : Record < string , any > {
181
181
if ( ! isObject ( ec ) ) return { } ;
182
182
183
- const opts = { } ;
183
+ const opts : Record < string , any > = { } ;
184
184
opts . detectIndentation = ! ( 'indent_style' in ec ) || ! ( 'indent_size' in ec ) ;
185
185
if ( 'indent_size' in ec ) opts . indentSize = Number ( ec . indent_size ) ;
186
186
if ( 'tab_width' in ec ) opts . tabSize = Number ( ec . tab_width ) || opts . indentSize ;
0 commit comments