Skip to content

Commit 9189741

Browse files
committed
Test CommandToolbarButton
1 parent 555ed17 commit 9189741

File tree

2 files changed

+77
-47
lines changed

2 files changed

+77
-47
lines changed

src/editor.ts

Lines changed: 73 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import { Signal } from '@lumino/signaling';
2626

2727
import { DrawIOWidget } from './widget';
2828

29-
import {
30-
formatPanelIcon,
31-
plusIcon
32-
} from './icons';
29+
import { formatPanelIcon, plusIcon } from './icons';
3330

3431
//import { DrawIOToolbarButton } from './toolbar';
3532

@@ -216,51 +213,86 @@ export class DrawIODocumentWidget extends DocumentWidget<DrawIOWidget> {
216213
'zoomOut',
217214
new DrawIOToolbarButton(actions['zoomOut'])
218215
); */
219-
actions['delete'].addListener('stateChanged', () => this.toolbar.update());
220-
this.toolbar.addItem('zoomIn', new CommandToolbarButton({
216+
217+
const button = new CommandToolbarButton({
221218
id: 'drawio:command/zoomIn',
222219
commands: this._commands
223-
}));
224-
this.toolbar.addItem('zoomOut', new CommandToolbarButton({
225-
id: 'drawio:command/zoomOut',
226-
commands: this._commands
227-
}));
228-
229-
this.toolbar.addItem('undo', new CommandToolbarButton({
230-
id: 'drawio:command/undo',
231-
commands: this._commands
232-
}));
233-
this.toolbar.addItem('redo', new CommandToolbarButton({
234-
id: 'drawio:command/redo',
235-
commands: this._commands
236-
}));
220+
});
221+
actions['zoomIn'].addListener('stateChanged', () => button.update());
222+
this.toolbar.addItem('zoomIn', button);
223+
this.toolbar.addItem(
224+
'zoomOut',
225+
new CommandToolbarButton({
226+
id: 'drawio:command/zoomOut',
227+
commands: this._commands
228+
})
229+
);
237230

238-
this.toolbar.addItem('delete', new CommandToolbarButton({
239-
id: 'drawio:command/delete',
240-
commands: this._commands
241-
}));
231+
this.toolbar.addItem(
232+
'undo',
233+
new CommandToolbarButton({
234+
id: 'drawio:command/undo',
235+
commands: this._commands
236+
})
237+
);
238+
this.toolbar.addItem(
239+
'redo',
240+
new CommandToolbarButton({
241+
id: 'drawio:command/redo',
242+
commands: this._commands
243+
})
244+
);
242245

243-
this.toolbar.addItem('toFront', new CommandToolbarButton({
244-
id: 'drawio:command/toFront',
245-
commands: this._commands
246-
}));
247-
this.toolbar.addItem('toBack', new CommandToolbarButton({
248-
id: 'drawio:command/toBack',
249-
commands: this._commands
250-
}));
246+
this.toolbar.addItem(
247+
'delete',
248+
new CommandToolbarButton({
249+
id: 'drawio:command/delete',
250+
commands: this._commands
251+
})
252+
);
251253

252-
this.toolbar.addItem('fillColor', new CommandToolbarButton({
254+
this.toolbar.addItem(
255+
'toFront',
256+
new CommandToolbarButton({
257+
id: 'drawio:command/toFront',
258+
commands: this._commands
259+
})
260+
);
261+
this.toolbar.addItem(
262+
'toBack',
263+
new CommandToolbarButton({
264+
id: 'drawio:command/toBack',
265+
commands: this._commands
266+
})
267+
);
268+
269+
const buttonFillColor = new CommandToolbarButton({
253270
id: 'drawio:command/fillColor',
254271
commands: this._commands
255-
}));
256-
this.toolbar.addItem('strokeColor', new CommandToolbarButton({
257-
id: 'drawio:command/strokeColor',
258-
commands: this._commands
259-
}));
260-
this.toolbar.addItem('shadow', new CommandToolbarButton({
261-
id: 'drawio:command/shadow',
272+
});
273+
console.debug(actions['fillColor']);
274+
actions['fillColor'].addListener('stateChanged', () =>
275+
buttonFillColor.update()
276+
);
277+
this.toolbar.addItem('fillColor', buttonFillColor);
278+
/* this.toolbar.addItem('fillColor', new CommandToolbarButton({
279+
id: 'drawio:command/fillColor',
262280
commands: this._commands
263-
}));
281+
})); */
282+
this.toolbar.addItem(
283+
'strokeColor',
284+
new CommandToolbarButton({
285+
id: 'drawio:command/strokeColor',
286+
commands: this._commands
287+
})
288+
);
289+
this.toolbar.addItem(
290+
'shadow',
291+
new CommandToolbarButton({
292+
id: 'drawio:command/shadow',
293+
commands: this._commands
294+
})
295+
);
264296
}
265297

266298
private _commands: CommandRegistry;

src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@ import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
3030

3131
import { ILauncher } from '@jupyterlab/launcher';
3232

33-
import {
34-
undoIcon,
35-
redoIcon,
36-
} from '@jupyterlab/ui-components';
33+
import { undoIcon, redoIcon } from '@jupyterlab/ui-components';
3734

3835
import { CommandRegistry } from '@lumino/commands';
3936

4037
import { Token } from '@lumino/coreutils';
4138

42-
import {
39+
import {
4340
zoominIcon,
4441
zoomoutIcon,
4542
deleteIcon,
@@ -672,7 +669,7 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
672669
{ name: 'guides', label: 'Guides' },
673670
{ name: 'connectionArrows', label: 'Connection Arrows' }, //Alt+Shift+A
674671
{ name: 'connectionPoints', label: 'Connection Points' }, //Alt+Shift+P
675-
{ name: 'resetView', label: 'Reset View' }, //Ctrl+H
672+
{ name: 'resetView', label: 'Reset View' } //Ctrl+H
676673
//{ name: 'zoomIn', label: 'Zoom In' }, //Ctrl+(Numpad)/Alt+Mousewheel
677674
//{ name: 'zoomOut', label: 'Zoom Out' } //Ctrl-(Numpad)/Alt+Mousewheel
678675
];
@@ -1276,6 +1273,7 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
12761273
tracker.currentWidget === app.shell.currentWidget
12771274
) {
12781275
const wdg = app.shell.currentWidget as DrawIODocumentWidget;
1276+
console.debug('fill Color:', wdg.getAction('fillColor').enabled);
12791277
return wdg.getAction('fillColor').enabled;
12801278
} else {
12811279
return false;

0 commit comments

Comments
 (0)