Skip to content

Commit 9ad0a30

Browse files
committed
Makes drawio collaborative sharing the mxCells as string, and makes ICommandPalette an optional dependency (see #98)
1 parent b61a811 commit 9ad0a30

File tree

7 files changed

+447
-514
lines changed

7 files changed

+447
-514
lines changed

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,25 @@
4646
"watch:src": "tsc -w"
4747
},
4848
"dependencies": {
49-
"@jupyterlab/application": "^3.1.0-alpha.8",
50-
"@jupyterlab/apputils": "^3.1.0-alpha.8",
51-
"@jupyterlab/coreutils": "^5.1.0-alpha.8",
52-
"@jupyterlab/docregistry": "^3.1.0-alpha.8",
53-
"@jupyterlab/filebrowser": "^3.1.0-alpha.8",
54-
"@jupyterlab/launcher": "^3.1.0-alpha.8",
55-
"@jupyterlab/mainmenu": "^3.1.0-alpha.8",
56-
"@jupyterlab/observables": "^4.1.0-alpha.8",
57-
"@jupyterlab/services": "^6.1.0-alpha.8",
58-
"@jupyterlab/shared-models": "^3.1.0-alpha.8",
59-
"@jupyterlab/ui-components": "^3.1.0-alpha.8",
49+
"@jupyterlab/application": "^3.1.0-alpha.13",
50+
"@jupyterlab/apputils": "^3.1.0-alpha.13",
51+
"@jupyterlab/coreutils": "^5.1.0-alpha.13",
52+
"@jupyterlab/docregistry": "^3.1.0-alpha.13",
53+
"@jupyterlab/filebrowser": "^3.1.0-alpha.13",
54+
"@jupyterlab/launcher": "^3.1.0-alpha.13",
55+
"@jupyterlab/mainmenu": "^3.1.0-alpha.13",
56+
"@jupyterlab/observables": "^4.1.0-alpha.13",
57+
"@jupyterlab/services": "^6.1.0-alpha.13",
58+
"@jupyterlab/shared-models": "^3.1.0-alpha.13",
59+
"@jupyterlab/ui-components": "^3.1.0-alpha.13",
6060
"@lumino/commands": "^1.12.0",
6161
"@lumino/coreutils": "^1.5.3",
6262
"@lumino/signaling": "^1.4.3",
6363
"@lumino/widgets": "^1.19.0",
6464
"fast-xml-parser": "^3.19.0",
6565
"react": "^17.0.1",
6666
"react-dom": "^17.0.1",
67-
"yjs": "^13.5.3"
67+
"yjs": "^13.5.6"
6868
},
6969
"devDependencies": {
7070
"@jupyterlab/builder": "^3.1.0-alpha.8",

src/index.ts

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function activate(
7878
browserFactory: IFileBrowserFactory,
7979
restorer: ILayoutRestorer | null,
8080
menu: IMainMenu,
81-
palette: ICommandPalette,
81+
palette: ICommandPalette | null,
8282
launcher: ILauncher | null
8383
): IDrawioTracker {
8484
const { commands } = app;
@@ -158,19 +158,26 @@ function activate(
158158
tracker.currentWidget === app.shell.currentWidget,
159159
execute: () => {
160160
const wdg = app.shell.currentWidget as DrawIODocumentWidget;
161-
const name = wdg.context.path.split('/').pop().split('.')[0] + ".svg";
162-
let path = wdg.context.path.split('/').slice(0, -1).join();
163-
161+
const name =
162+
wdg.context.path
163+
.split('/')
164+
.pop()
165+
.split('.')[0] + '.svg';
166+
const path = wdg.context.path
167+
.split('/')
168+
.slice(0, -1)
169+
.join();
170+
164171
commands
165172
.execute('docmanager:new-untitled', {
166173
name,
167174
path,
168175
type: 'file',
169176
ext: '.svg'
170177
})
171-
.then( model => {
172-
model.name = name
173-
model.path = path ? path + "/" + name : name;
178+
.then(model => {
179+
model.name = name;
180+
model.path = path ? path + '/' + name : name;
174181
model.content = wdg.getSVG();
175182
model.format = 'text';
176183
app.serviceManager.contents.save(model.path, model);
@@ -211,13 +218,13 @@ function addMenus(
211218
tracker: IDrawioTracker
212219
): void {
213220
const diagram = new JupyterLabMenu({ commands });
214-
diagram.menu.title.label = 'Diagram';
221+
diagram.title.label = 'Diagram';
215222

216223
// FILE MENU
217224
// Add new text file creation to the file menu.
218225
menu.fileMenu.newMenu.addGroup([{ command: 'drawio:create-new' }], 40);
219226
const fileMenu = new JupyterLabMenu({ commands });
220-
fileMenu.menu.title.label = 'File';
227+
fileMenu.title.label = 'File';
221228
fileMenu.addGroup([{ command: 'drawio:create-new' }], 0);
222229
fileMenu.addGroup(
223230
[
@@ -236,7 +243,7 @@ function addMenus(
236243
} as any);
237244

238245
const editMenu = new JupyterLabMenu({ commands });
239-
editMenu.menu.title.label = 'Edit';
246+
editMenu.title.label = 'Edit';
240247
editMenu.addGroup(
241248
[{ command: 'drawio:command/undo' }, { command: 'drawio:command/redo' }],
242249
0
@@ -280,7 +287,7 @@ function addMenus(
280287

281288
// View MENU
282289
const viewMenu = new JupyterLabMenu({ commands });
283-
viewMenu.menu.title.label = 'View';
290+
viewMenu.title.label = 'View';
284291
viewMenu.addGroup(
285292
[
286293
{ command: 'drawio:command/formatPanel' },
@@ -325,7 +332,7 @@ function addMenus(
325332

326333
// Arrange MENU
327334
const arrangeMenu = new JupyterLabMenu({ commands });
328-
arrangeMenu.menu.title.label = 'Arrange';
335+
arrangeMenu.title.label = 'Arrange';
329336
arrangeMenu.addGroup(
330337
[
331338
{ command: 'drawio:command/toFront' },
@@ -335,22 +342,22 @@ function addMenus(
335342
);
336343

337344
const direction = new JupyterLabMenu({ commands });
338-
direction.menu.title.label = 'Direction';
345+
direction.title.label = 'Direction';
339346
direction.addGroup(
340347
[{ command: 'drawio:command/flipH' }, { command: 'drawio:command/flipV' }],
341348
0
342349
);
343350
direction.addGroup([{ command: 'drawio:command/rotation' }], 1);
344351
arrangeMenu.addGroup(
345352
[
346-
{ type: 'submenu', submenu: direction.menu },
353+
{ type: 'submenu', submenu: direction },
347354
{ command: 'drawio:command/turn' }
348355
],
349356
1
350357
);
351358

352359
const align = new JupyterLabMenu({ commands });
353-
align.menu.title.label = 'Diagram Align';
360+
align.title.label = 'Diagram Align';
354361
align.addGroup(
355362
[
356363
{ command: 'drawio:command/alignCellsLeft' },
@@ -369,7 +376,7 @@ function addMenus(
369376
);
370377

371378
const distribute = new JupyterLabMenu({ commands });
372-
distribute.menu.title.label = 'Distribute';
379+
distribute.title.label = 'Distribute';
373380
distribute.addGroup(
374381
[
375382
{ command: 'drawio:command/horizontal' },
@@ -379,14 +386,14 @@ function addMenus(
379386
);
380387
arrangeMenu.addGroup(
381388
[
382-
{ type: 'submenu', submenu: align.menu },
383-
{ type: 'submenu', submenu: distribute.menu }
389+
{ type: 'submenu', submenu: align },
390+
{ type: 'submenu', submenu: distribute }
384391
],
385392
2
386393
);
387394

388395
const navigation = new JupyterLabMenu({ commands });
389-
navigation.menu.title.label = 'Navigation';
396+
navigation.title.label = 'Navigation';
390397
navigation.addGroup([{ command: 'drawio:command/home' }], 0);
391398
navigation.addGroup(
392399
[
@@ -405,7 +412,7 @@ function addMenus(
405412
navigation.addGroup([{ command: 'drawio:command/collapsible' }], 3);
406413

407414
const insert = new JupyterLabMenu({ commands });
408-
insert.menu.title.label = 'Insert';
415+
insert.title.label = 'Insert';
409416
insert.addGroup(
410417
[
411418
{ command: 'drawio:command/insertLink' },
@@ -415,7 +422,7 @@ function addMenus(
415422
);
416423

417424
const layout = new JupyterLabMenu({ commands });
418-
layout.menu.title.label = 'Layout';
425+
layout.title.label = 'Layout';
419426
layout.addGroup(
420427
[
421428
{ command: 'drawio:command/horizontalFlow' },
@@ -440,9 +447,9 @@ function addMenus(
440447
);
441448
arrangeMenu.addGroup(
442449
[
443-
{ type: 'submenu', submenu: navigation.menu },
444-
{ type: 'submenu', submenu: insert.menu },
445-
{ type: 'submenu', submenu: layout.menu }
450+
{ type: 'submenu', submenu: navigation },
451+
{ type: 'submenu', submenu: insert },
452+
{ type: 'submenu', submenu: layout }
446453
],
447454
3
448455
);
@@ -466,7 +473,7 @@ function addMenus(
466473

467474
// Extras MENU
468475
const extrasMenu = new JupyterLabMenu({ commands });
469-
extrasMenu.menu.title.label = 'Extras';
476+
extrasMenu.title.label = 'Extras';
470477
extrasMenu.addGroup(
471478
[
472479
{ command: 'drawio:command/copyConnect' },
@@ -478,16 +485,16 @@ function addMenus(
478485

479486
diagram.addGroup(
480487
[
481-
{ type: 'submenu', submenu: fileMenu.menu },
482-
{ type: 'submenu', submenu: editMenu.menu },
483-
{ type: 'submenu', submenu: viewMenu.menu },
484-
{ type: 'submenu', submenu: arrangeMenu.menu },
485-
{ type: 'submenu', submenu: extrasMenu.menu },
488+
{ type: 'submenu', submenu: fileMenu },
489+
{ type: 'submenu', submenu: editMenu },
490+
{ type: 'submenu', submenu: viewMenu },
491+
{ type: 'submenu', submenu: arrangeMenu },
492+
{ type: 'submenu', submenu: extrasMenu },
486493
{ command: 'drawio:command/about' }
487494
],
488495
0
489496
);
490-
menu.addMenu(diagram.menu, { rank: 60 });
497+
menu.addMenu(diagram, { rank: 60 });
491498
}
492499

493500
function addCommands(app: JupyterFrontEnd, tracker: IDrawioTracker): void {

0 commit comments

Comments
 (0)