Skip to content

Commit d3c6cca

Browse files
committed
Changes toolbar buttons
1 parent 9189741 commit d3c6cca

File tree

12 files changed

+61
-135
lines changed

12 files changed

+61
-135
lines changed

src/editor.ts

Lines changed: 54 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,30 @@ import { DocumentRegistry, DocumentWidget } from '@jupyterlab/docregistry';
1616

1717
import { MainMenu, JupyterLabMenu } from '@jupyterlab/mainmenu';
1818

19-
import { CommandToolbarButton } from '@jupyterlab/apputils';
20-
2119
import { IChangedArgs, PathExt } from '@jupyterlab/coreutils';
2220

21+
import { undoIcon, redoIcon } from '@jupyterlab/ui-components';
22+
2323
import { CommandRegistry } from '@lumino/commands';
2424

2525
import { Signal } from '@lumino/signaling';
2626

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

29-
import { formatPanelIcon, plusIcon } from './icons';
30-
31-
//import { DrawIOToolbarButton } from './toolbar';
29+
import { DrawIOToolbarButton } from './toolbar';
30+
31+
import {
32+
formatPanelIcon,
33+
plusIcon,
34+
zoominIcon,
35+
zoomoutIcon,
36+
deleteIcon,
37+
toFrontIcon,
38+
toBackIcon,
39+
fillColorIcon,
40+
strokeColorIcon,
41+
shadowIcon
42+
} from './icons';
3243

3344
const DIRTY_CLASS = 'jp-mod-dirty';
3445

@@ -206,93 +217,45 @@ export class DrawIODocumentWidget extends DocumentWidget<DrawIOWidget> {
206217

207218
this.toolbar.addItem('ViewDropdown', this._menubar);
208219

209-
/* actions['zoomIn'].iconCls = 'geSprite geSprite-zoomin';
220+
actions['zoomIn'].icon = zoominIcon;
221+
actions['zoomIn'].tooltip = 'Zoom In (Ctrl+(Numpad)/Alt+Mousewheel)';
210222
this.toolbar.addItem('zoomIn', new DrawIOToolbarButton(actions['zoomIn']));
211-
actions['zoomOut'].iconCls = 'geSprite geSprite-zoomout';
212-
this.toolbar.addItem(
213-
'zoomOut',
214-
new DrawIOToolbarButton(actions['zoomOut'])
215-
); */
216-
217-
const button = new CommandToolbarButton({
218-
id: 'drawio:command/zoomIn',
219-
commands: this._commands
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-
);
230-
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-
);
245-
246-
this.toolbar.addItem(
247-
'delete',
248-
new CommandToolbarButton({
249-
id: 'drawio:command/delete',
250-
commands: this._commands
251-
})
252-
);
253-
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({
270-
id: 'drawio:command/fillColor',
271-
commands: this._commands
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',
280-
commands: this._commands
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-
);
223+
224+
actions['zoomOut'].icon = zoomoutIcon;
225+
actions['zoomOut'].tooltip = 'Zoom Out (Ctrl-(Numpad)/Alt+Mousewheel)';
226+
this.toolbar.addItem('zoomOut', new DrawIOToolbarButton(actions['zoomOut']));
227+
228+
actions['undo'].icon = undoIcon;
229+
actions['fillColor'].tooltip = 'Undo (Ctrl+Z)';
230+
this.toolbar.addItem('undo', new DrawIOToolbarButton(actions['undo']));
231+
232+
actions['redo'].icon = redoIcon;
233+
actions['redo'].tooltip = 'Redo (Ctrl+Shift+Z)';
234+
this.toolbar.addItem('redo', new DrawIOToolbarButton(actions['redo']));
235+
236+
actions['delete'].icon = deleteIcon;
237+
actions['delete'].tooltip = 'Delete';
238+
this.toolbar.addItem('delete', new DrawIOToolbarButton(actions['delete']));
239+
240+
actions['toFront'].icon = toFrontIcon;
241+
actions['toFront'].tooltip = 'To Front (Ctrl+Shift+F)';
242+
this.toolbar.addItem('toFront', new DrawIOToolbarButton(actions['toFront']));
243+
244+
actions['toBack'].icon = toBackIcon;
245+
actions['toBack'].tooltip = 'To Back (Ctrl+Shift+B)';
246+
this.toolbar.addItem('toBack', new DrawIOToolbarButton(actions['toBack']));
247+
248+
actions['fillColor'].icon = fillColorIcon;
249+
actions['fillColor'].tooltip = 'Fill Color';
250+
this.toolbar.addItem('fillColor', new DrawIOToolbarButton(actions['fillColor']));
251+
252+
actions['strokeColor'].icon = strokeColorIcon;
253+
actions['strokeColor'].tooltip = 'Fill Stroke Color';
254+
this.toolbar.addItem('strokeColor', new DrawIOToolbarButton(actions['strokeColor']));
255+
256+
actions['shadow'].icon = shadowIcon;
257+
actions['shadow'].tooltip = 'Shadow';
258+
this.toolbar.addItem('shadow', new DrawIOToolbarButton(actions['shadow']));
296259
}
297260

298261
private _commands: CommandRegistry;

src/index.ts

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import { Token } from '@lumino/coreutils';
3939
import {
4040
zoominIcon,
4141
zoomoutIcon,
42-
deleteIcon,
4342
toFrontIcon,
4443
toBackIcon,
4544
fillColorIcon,
@@ -532,7 +531,7 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
532531
{ name: 'cut', label: 'Cut' }, //Ctrl+X
533532
{ name: 'copy', label: 'Copy' }, //Ctrl+C
534533
{ name: 'paste', label: 'Paste' }, //Ctrl+V
535-
//{ name: 'delete', label: 'Delete' },
534+
{ name: 'delete', label: 'Delete' },
536535
{ name: 'duplicate', label: 'Duplicate' }, //Ctrl+D
537536
{ name: 'editData', label: 'Edit Data...' }, //Ctrl+M
538537
{ name: 'editTooltip', label: 'Edit Tooltip...' },
@@ -622,31 +621,6 @@ function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {
622621
}
623622
}
624623
});
625-
app.commands.addCommand('drawio:command/delete', {
626-
label: 'delete',
627-
caption: 'Delete',
628-
icon: deleteIcon,
629-
isEnabled: () => {
630-
if (
631-
tracker.currentWidget !== null &&
632-
tracker.currentWidget === app.shell.currentWidget
633-
) {
634-
const wdg = app.shell.currentWidget as DrawIODocumentWidget;
635-
return wdg.getAction('delete').enabled;
636-
} else {
637-
return false;
638-
}
639-
},
640-
execute: () => {
641-
if (
642-
tracker.currentWidget !== null &&
643-
tracker.currentWidget === app.shell.currentWidget
644-
) {
645-
const wdg = app.shell.currentWidget as DrawIODocumentWidget;
646-
wdg.getAction('delete').funct();
647-
}
648-
}
649-
});
650624

651625
// View MENU
652626
//Not Working:

src/toolbar.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,14 @@ export class DrawIOToolbarButton extends ReactWidget {
1616
}
1717

1818
render(): JSX.Element {
19-
const onClick = (): void => {
20-
this._action.funct();
21-
};
22-
23-
const icon = this._action.iconCls || '';
24-
const label = this._action.iconCls ? '' : this._action.label || '';
25-
const shortcut = this._action.shortcut || '';
26-
const tooltip = label + ' (' + shortcut + ')';
27-
const enabled = this._action.enabled;
28-
2919
return (
3020
<ToolbarButtonComponent
31-
onClick={onClick}
21+
label={this._action.label}
22+
tooltip={this._action.tooltip}
23+
icon={this._action.icon}
24+
enabled={this._action.enabled}
3225
actualOnClick={true}
33-
tooltip={tooltip}
34-
label={label}
35-
iconClass={icon}
36-
enabled={enabled}
26+
onClick={this._action.funct}
3727
/>
3828
);
3929
}

testfiles/This Is A Test.dio

Lines changed: 0 additions & 1 deletion
This file was deleted.

testfiles/cnn.dio

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

testfiles/untitled.dio

Whitespace-only changes.

testfiles/untitled.svg

Whitespace-only changes.

testfiles/untitled1.dio

Lines changed: 0 additions & 1 deletion
This file was deleted.

testfiles/untitled1.svg

Whitespace-only changes.

testfiles/untitled2.dio

Whitespace-only changes.

0 commit comments

Comments
 (0)