mirror of
https://github.com/olehomelchenko/astrolabe.git
synced 2025-12-21 21:22:25 +00:00
refactor: pass snippetManager to PanelResizer and update visualization on resize
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
export class PanelResizer {
|
export class PanelResizer {
|
||||||
constructor() {
|
constructor(snippetManager) {
|
||||||
|
this.snippetManager = snippetManager;
|
||||||
this.handleDragStart = this.handleDragStart.bind(this);
|
this.handleDragStart = this.handleDragStart.bind(this);
|
||||||
this.handleDrag = this.handleDrag.bind(this);
|
this.handleDrag = this.handleDrag.bind(this);
|
||||||
this.handleDragEnd = this.handleDragEnd.bind(this);
|
this.handleDragEnd = this.handleDragEnd.bind(this);
|
||||||
@@ -104,6 +105,13 @@ export class PanelResizer {
|
|||||||
if (window.editor) {
|
if (window.editor) {
|
||||||
window.editor.layout();
|
window.editor.layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update visualization after resize is complete
|
||||||
|
if (this.snippetManager && typeof this.snippetManager.updateVisualization === 'function') {
|
||||||
|
// Get the current editor value and update visualization
|
||||||
|
const editorValue = this.snippetManager.editor.getValue();
|
||||||
|
this.snippetManager.updateVisualization(editorValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
normalizePanelWidths() {
|
normalizePanelWidths() {
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export class SnippetManager {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Invalid JSON:', e);
|
console.error('Invalid JSON:', e);
|
||||||
}
|
}
|
||||||
}, 300);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load first snippet if available
|
// Load first snippet if available
|
||||||
@@ -135,6 +135,8 @@ export class SnippetManager {
|
|||||||
async updateVisualization(spec) {
|
async updateVisualization(spec) {
|
||||||
try {
|
try {
|
||||||
const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
|
const parsedSpec = typeof spec === 'string' ? JSON.parse(spec) : spec;
|
||||||
|
parsedSpec.width = parsedSpec.width? parsedSpec.width : 'container';
|
||||||
|
parsedSpec.height = parsedSpec.height? parsedSpec.height : 'container';
|
||||||
await vegaEmbed('#vis', parsedSpec, {
|
await vegaEmbed('#vis', parsedSpec, {
|
||||||
actions: true, // This adds the export/view source buttons
|
actions: true, // This adds the export/view source buttons
|
||||||
theme: 'light'
|
theme: 'light'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ require(['vs/editor/editor.main'], async function () {
|
|||||||
formatOnType: true
|
formatOnType: true
|
||||||
});
|
});
|
||||||
|
|
||||||
const resizer = new PanelResizer();
|
const resizer = new PanelResizer(snippetManager);
|
||||||
window.editor = editor;
|
window.editor = editor;
|
||||||
|
|
||||||
snippetManager.setEditor(editor);
|
snippetManager.setEditor(editor);
|
||||||
|
|||||||
Reference in New Issue
Block a user