-
Notifications
You must be signed in to change notification settings - Fork 1
feat(notebook-doc): fractional indexing for cell ordering #694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
4e40523
be1b110
18dd1c0
437c929
a3c7b46
f0249bc
fde77d7
2bb846b
3ae8890
df4ddf7
023b57d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ export class JsCell { | |||||||||
| wasm.__wbg_jscell_free(ptr, 0); | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Index in the sorted cell list (for backward compatibility). | ||||||||||
| * @returns {number} | ||||||||||
| */ | ||||||||||
| get index() { | ||||||||||
|
|
@@ -125,6 +126,26 @@ export class JsCell { | |||||||||
| wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Fractional index hex string for ordering (e.g., "80", "7F80"). | ||||||||||
| * @returns {string} | ||||||||||
| */ | ||||||||||
| get position() { | ||||||||||
| let deferred1_0; | ||||||||||
| let deferred1_1; | ||||||||||
| try { | ||||||||||
| const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||||||||||
| wasm.jscell_position(retptr, this.__wbg_ptr); | ||||||||||
| var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); | ||||||||||
| var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); | ||||||||||
| deferred1_0 = r0; | ||||||||||
| deferred1_1 = r1; | ||||||||||
| return getStringFromWasm0(r0, r1); | ||||||||||
| } finally { | ||||||||||
| wasm.__wbindgen_add_to_stack_pointer(16); | ||||||||||
| wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * @returns {string} | ||||||||||
| */ | ||||||||||
|
|
@@ -174,7 +195,9 @@ export class NotebookHandle { | |||||||||
| wasm.__wbg_notebookhandle_free(ptr, 0); | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Add a new cell at the given index. | ||||||||||
| * Add a new cell at the given index (backward-compatible API). | ||||||||||
| * | ||||||||||
| * Internally converts the index to an after_cell_id for fractional indexing. | ||||||||||
| * @param {number} index | ||||||||||
| * @param {string} cell_id | ||||||||||
| * @param {string} cell_type | ||||||||||
|
|
@@ -196,6 +219,48 @@ export class NotebookHandle { | |||||||||
| wasm.__wbindgen_add_to_stack_pointer(16); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Add a new cell after the specified cell (semantic API). | ||||||||||
| * | ||||||||||
| * - `after_cell_id = None` → insert at the beginning | ||||||||||
| * - `after_cell_id = Some(id)` → insert after that cell | ||||||||||
| * | ||||||||||
| * Returns the position string of the new cell. | ||||||||||
| * @param {string} cell_id | ||||||||||
| * @param {string} cell_type | ||||||||||
| * @param {string | null} [after_cell_id] | ||||||||||
| * @returns {string} | ||||||||||
| */ | ||||||||||
| add_cell_after(cell_id, cell_type, after_cell_id) { | ||||||||||
| let deferred5_0; | ||||||||||
| let deferred5_1; | ||||||||||
| try { | ||||||||||
| const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||||||||||
| const ptr0 = passStringToWasm0(cell_id, wasm.__wbindgen_export3, wasm.__wbindgen_export4); | ||||||||||
| const len0 = WASM_VECTOR_LEN; | ||||||||||
| const ptr1 = passStringToWasm0(cell_type, wasm.__wbindgen_export3, wasm.__wbindgen_export4); | ||||||||||
| const len1 = WASM_VECTOR_LEN; | ||||||||||
| var ptr2 = isLikeNone(after_cell_id) ? 0 : passStringToWasm0(after_cell_id, wasm.__wbindgen_export3, wasm.__wbindgen_export4); | ||||||||||
| var len2 = WASM_VECTOR_LEN; | ||||||||||
| wasm.notebookhandle_add_cell_after(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2); | ||||||||||
| var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); | ||||||||||
| var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); | ||||||||||
| var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); | ||||||||||
| var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); | ||||||||||
| var ptr4 = r0; | ||||||||||
| var len4 = r1; | ||||||||||
| if (r3) { | ||||||||||
| ptr4 = 0; len4 = 0; | ||||||||||
| throw takeObject(r2); | ||||||||||
| } | ||||||||||
| deferred5_0 = ptr4; | ||||||||||
| deferred5_1 = len4; | ||||||||||
| return getStringFromWasm0(ptr4, len4); | ||||||||||
| } finally { | ||||||||||
| wasm.__wbindgen_add_to_stack_pointer(16); | ||||||||||
| wasm.__wbindgen_export2(deferred5_0, deferred5_1, 1); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Add a Conda dependency, deduplicating by package name (case-insensitive). | ||||||||||
| * Initializes the Conda section with ["conda-forge"] channels if absent. | ||||||||||
|
|
@@ -494,6 +559,46 @@ export class NotebookHandle { | |||||||||
| wasm.__wbindgen_add_to_stack_pointer(16); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| /** | ||||||||||
| * Move a cell to a new position (after the specified cell). | ||||||||||
| * | ||||||||||
| * - `after_cell_id = None` → move to the beginning | ||||||||||
| * - `after_cell_id = Some(id)` → move after that cell | ||||||||||
|
||||||||||
| * - `after_cell_id = None` → move to the beginning | |
| * - `after_cell_id = Some(id)` → move after that cell | |
| * - `after_cell_id === null` → move to the beginning | |
| * - `after_cell_id` is a cell id string → move after that cell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSDoc here uses Rust
Optionterminology (None/Some(id)), but the actual JS API usesnull(or omitted) vsstring(see the@param {string | null}type). Consider updating the bullets toafter_cell_id = null/after_cell_id = "id"to avoid confusing JS/TS consumers.