UPDATE: Dynamic arrays!

This commit is contained in:
Nicolás Hatcher
2025-03-23 01:51:17 +01:00
parent c554d929f4
commit 6f577575c7
28 changed files with 1714 additions and 641 deletions

View File

@@ -201,6 +201,18 @@ defined_name_list_types = r"""
getDefinedNameList(): DefinedName[];
"""
cell_structure = r"""
* @returns {any}
*/
getCellArrayStructure(sheet: number, row: number, column: number): any;
"""
cell_structure_types = r"""
* @returns {CellArrayStructure}
*/
getCellArrayStructure(sheet: number, row: number, column: number): CellArrayStructure;
"""
def fix_types(text):
text = text.replace(get_tokens_str, get_tokens_str_types)
text = text.replace(update_style_str, update_style_str_types)
@@ -215,6 +227,7 @@ def fix_types(text):
text = text.replace(clipboard, clipboard_types)
text = text.replace(paste_from_clipboard, paste_from_clipboard_types)
text = text.replace(defined_name_list, defined_name_list_types)
text = text.replace(cell_structure, cell_structure_types)
with open("types.ts") as f:
types_str = f.read()
header_types = "{}\n\n{}".format(header, types_str)

View File

@@ -672,4 +672,18 @@ impl Model {
.delete_defined_name(name, scope)
.map_err(|e| to_js_error(e.to_string()))
}
#[wasm_bindgen(js_name = "getCellArrayStructure")]
pub fn get_cell_array_structure(
&self,
sheet: u32,
row: i32,
column: i32,
) -> Result<JsValue, JsError> {
let cell_structure = self
.model
.get_cell_array_structure(sheet, row, column)
.map_err(|e| to_js_error(e.to_string()))?;
serde_wasm_bindgen::to_value(&cell_structure).map_err(JsError::from)
}
}

View File

@@ -109,6 +109,11 @@ export interface MarkedToken {
end: number;
}
export type CellArrayStructure =
| "SingleCell"
| { DynamicChild: [number, number, number, number] }
| { DynamicMother: [number, number] };
export interface WorksheetProperties {
name: string;
color: string;
@@ -216,7 +221,7 @@ export interface SelectedView {
// };
// type ClipboardData = Record<string, Record <string, ClipboardCell>>;
type ClipboardData = Map<number, Map <number, ClipboardCell>>;
type ClipboardData = Map<number, Map<number, ClipboardCell>>;
export interface ClipboardCell {
text: string;
@@ -233,4 +238,4 @@ export interface DefinedName {
name: string;
scope?: number;
formula: string;
}
}