Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ app.commands.execute('jupyterlab-cell-diff:show-codemirror', {
});
```

#### Command Arguments

The `jupyterlab-cell-diff:show-codemirror` command accepts the following arguments:

| Argument | Type | Required | Description |
| ------------------- | --------- | -------- | ------------------------------------------------------------------------------------ |
| `cellId` | `string` | No | ID of the cell to show diff for. If not provided, uses the active cell |
| `originalSource` | `string` | Yes | Original source code to compare against |
| `newSource` | `string` | Yes | New source code to compare with |
| `showActionButtons` | `boolean` | No | Whether to show action buttons in the diff widget (default: `true`) |
| `notebookPath` | `string` | No | Path to the notebook containing the cell. If not provided, uses the current notebook |
| `openDiff` | `boolean` | No | Whether to open the diff widget automatically (default: `true`) |

## Uninstall

To remove the extension, execute:
Expand Down
10 changes: 9 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ const codeMirrorPlugin: JupyterFrontEndPlugin<void> = {
'Whether to open the diff widget automatically'
)
}
}
},
required: ['originalSource', 'newSource']
}
},
execute: async (args: any = {}) => {
Expand All @@ -118,6 +119,13 @@ const codeMirrorPlugin: JupyterFrontEndPlugin<void> = {
openDiff = true
} = args;

if (!originalSource || !newSource) {
console.error(
trans.__('Missing required arguments: originalSource and newSource')
);
return;
}

const currentNotebook = findNotebook(notebookTracker, notebookPath);
if (!currentNotebook) {
return;
Expand Down