Skip to content

Commit 56587dd

Browse files
Sync editor upon editor change (#448)
* Sync editor upon editor change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Define `syncEditor` not in commands * Implement `_syncEditor` in JupyterCadPanel * Emit resize event in `trackerPlugin` * Little cleanup --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 049220a commit 56587dd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

python/jupytercad_core/src/factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
22
import {
33
JupyterCadModel,
4-
IJupyterCadTracker,
54
IJCadWorkerRegistry,
6-
IJCadExternalCommandRegistry
5+
IJCadExternalCommandRegistry,
6+
IJupyterCadTracker
77
} from '@jupytercad/schema';
88
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
99
import { CommandRegistry } from '@lumino/commands';

python/jupytercad_core/src/plugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ export const trackerPlugin: JupyterFrontEndPlugin<IJupyterCadTracker> = {
3939
const tracker = new WidgetTracker<JupyterCadWidget>({
4040
namespace: NAME_SPACE
4141
});
42+
tracker.currentChanged.connect(() => {
43+
const currentWidget = tracker.currentWidget;
44+
45+
if (currentWidget) {
46+
const resizeEvent = new Event('resize');
47+
window.dispatchEvent(resizeEvent);
48+
}
49+
});
4250
console.log('jupytercad:core:tracker is activated!');
4351
return tracker;
4452
}

0 commit comments

Comments
 (0)