UPDATE: Adds autofill_columns (#74)

This commit is contained in:
Nicolás Hatcher Andrés
2024-06-02 18:43:43 +02:00
committed by GitHub
parent 72c7c94f3d
commit 864a37f1e6
6 changed files with 574 additions and 1 deletions

View File

@@ -63,15 +63,69 @@ style_types = r"""
getCellStyle(sheet: number, row: number, column: number): CellStyle;
""".strip()
view = r"""
* @returns {any}
*/
getSelectedView(): any;
""".strip()
view_types = r"""
* @returns {CellStyle}
*/
getSelectedView(): SelectedView;
""".strip()
autofill_rows = r"""
/**
* @param {any} source_area
* @param {number} to_row
*/
autoFillRows(source_area: any, to_row: number): void;
}
"""
autofill_rows_types = r"""
/**
* @param {Area} source_area
* @param {number} to_row
*/
autoFillRows(source_area: Area, to_row: number): void;
}
"""
autofill_columns = r"""
/**
* @param {any} source_area
* @param {number} to_column
*/
autoFillColumns(source_area: any, to_column: number): void;
}
"""
autofill_columns_types = r"""
/**
* @param {Area} source_area
* @param {number} to_column
*/
autoFillColumns(source_area: Area, to_column: number): void;
}
"""
def fix_types(text):
text = text.replace(get_tokens_str, get_tokens_str_types)
text = text.replace(update_style_str, update_style_str_types)
text = text.replace(properties, properties_types)
text = text.replace(style, style_types)
text = text.replace(view, view_types)
text = text.replace(autofill_rows, autofill_rows_types)
text = text.replace(autofill_columns, autofill_columns_types)
with open("types.ts") as f:
types_str = f.read()
header_types = "{}\n\n{}".format(header, types_str)
text = text.replace(header, header_types)
if text.find("any") != -1:
print("There are 'unfixed' types. Please check.")
exit(1)
return text

View File

@@ -363,4 +363,17 @@ impl Model {
.auto_fill_rows(&area, to_row)
.map_err(to_js_error)
}
#[wasm_bindgen(js_name = "autoFillColumns")]
pub fn auto_fill_columns(
&mut self,
source_area: JsValue,
to_column: i32,
) -> Result<(), JsError> {
let area: Area =
serde_wasm_bindgen::from_value(source_area).map_err(|e| to_js_error(e.to_string()))?;
self.model
.auto_fill_columns(&area, to_column)
.map_err(to_js_error)
}
}