diff --git a/README.md b/README.md index 8f2a673..1704e48 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/src/plugin.ts b/src/plugin.ts index c0c9eb4..ed48514 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -105,7 +105,8 @@ const codeMirrorPlugin: JupyterFrontEndPlugin = { 'Whether to open the diff widget automatically' ) } - } + }, + required: ['originalSource', 'newSource'] } }, execute: async (args: any = {}) => { @@ -118,6 +119,13 @@ const codeMirrorPlugin: JupyterFrontEndPlugin = { openDiff = true } = args; + if (!originalSource || !newSource) { + console.error( + trans.__('Missing required arguments: originalSource and newSource') + ); + return; + } + const currentNotebook = findNotebook(notebookTracker, notebookPath); if (!currentNotebook) { return;