Skip to content

Commit

Permalink
Sync editor upon editor change (#448)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
arjxn-py and pre-commit-ci[bot] authored Oct 11, 2024
1 parent 049220a commit 56587dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/jupytercad_core/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ConsolePanel, IConsoleTracker } from '@jupyterlab/console';
import {
JupyterCadModel,
IJupyterCadTracker,
IJCadWorkerRegistry,
IJCadExternalCommandRegistry
IJCadExternalCommandRegistry,
IJupyterCadTracker
} from '@jupytercad/schema';
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry';
import { CommandRegistry } from '@lumino/commands';
Expand Down
8 changes: 8 additions & 0 deletions python/jupytercad_core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ export const trackerPlugin: JupyterFrontEndPlugin<IJupyterCadTracker> = {
const tracker = new WidgetTracker<JupyterCadWidget>({
namespace: NAME_SPACE
});
tracker.currentChanged.connect(() => {
const currentWidget = tracker.currentWidget;

if (currentWidget) {
const resizeEvent = new Event('resize');
window.dispatchEvent(resizeEvent);
}
});
console.log('jupytercad:core:tracker is activated!');
return tracker;
}
Expand Down

0 comments on commit 56587dd

Please sign in to comment.