kopia lustrzana https://github.com/deathbeds/ipydrawio
commit
d5bdda058d
Plik diff jest za duży
Load Diff
14
package.json
14
package.json
|
@ -30,13 +30,13 @@
|
||||||
"watch": "tsc -w"
|
"watch": "tsc -w"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jupyterlab/application": "^0.16.2",
|
"@jupyterlab/application": "^0.17.2",
|
||||||
"@jupyterlab/apputils": "^0.16.2",
|
"@jupyterlab/apputils": "^0.17.2",
|
||||||
"@jupyterlab/coreutils": "^1.1.2",
|
"@jupyterlab/coreutils": "^2.0.2",
|
||||||
"@jupyterlab/docregistry": "^0.16.2",
|
"@jupyterlab/docregistry": "^0.17.2",
|
||||||
"@jupyterlab/filebrowser": "^0.16.2",
|
"@jupyterlab/filebrowser": "^0.17.3",
|
||||||
"@jupyterlab/launcher": "^0.16.2",
|
"@jupyterlab/launcher": "^0.17.2",
|
||||||
"@jupyterlab/mainmenu": "^0.5.2"
|
"@jupyterlab/mainmenu": "^0.6.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"rimraf": "^2.6.1",
|
"rimraf": "^2.6.1",
|
||||||
|
|
|
@ -31,9 +31,13 @@ w.mxLoadResources = false;
|
||||||
import * as mx from './mxgraph/javascript/examples/grapheditor/www/modulated.js';
|
import * as mx from './mxgraph/javascript/examples/grapheditor/www/modulated.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ABCWidgetFactory, DocumentRegistry
|
ABCWidgetFactory, DocumentRegistry, DocumentWidget,
|
||||||
} from '@jupyterlab/docregistry';
|
} from '@jupyterlab/docregistry';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Toolbar
|
||||||
|
} from '@jupyterlab/apputils';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IChangedArgs, PathExt
|
IChangedArgs, PathExt
|
||||||
} from '@jupyterlab/coreutils';
|
} from '@jupyterlab/coreutils';
|
||||||
|
@ -61,17 +65,17 @@ import {
|
||||||
const DIRTY_CLASS = 'jp-mod-dirty';
|
const DIRTY_CLASS = 'jp-mod-dirty';
|
||||||
|
|
||||||
export
|
export
|
||||||
class DrawioWidget extends Widget implements DocumentRegistry.IReadyWidget {
|
class DrawioWidget extends DocumentWidget<Widget> {
|
||||||
|
|
||||||
constructor(context: DocumentRegistry.Context) {
|
constructor(options: DocumentWidget.IOptions<Widget>) {
|
||||||
super();
|
super({ ...options });
|
||||||
this.context = context;
|
this.context = options['context'];
|
||||||
|
|
||||||
this._onTitleChanged();
|
this._onTitleChanged();
|
||||||
context.pathChanged.connect(this._onTitleChanged, this);
|
this.context.pathChanged.connect(this._onTitleChanged, this);
|
||||||
|
|
||||||
this.context.ready.then(() => { this._onContextReady(); });
|
this.context.ready.then(() => { this._onContextReady(); });
|
||||||
this.context.ready.then(() => { this._handleDirtyState(); });
|
this.context.ready.then(() => { this._handleDirtyStateNew(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onAfterShow(msg: Message): void {
|
protected onAfterShow(msg: Message): void {
|
||||||
|
@ -90,7 +94,7 @@ class DrawioWidget extends Widget implements DocumentRegistry.IReadyWidget {
|
||||||
this._onContentChanged();
|
this._onContentChanged();
|
||||||
|
|
||||||
contextModel.contentChanged.connect(this._onContentChanged, this);
|
contextModel.contentChanged.connect(this._onContentChanged, this);
|
||||||
contextModel.stateChanged.connect(this._onModelStateChanged, this);
|
contextModel.stateChanged.connect(this._onModelStateChangedNew, this);
|
||||||
|
|
||||||
this._editor.sidebarContainer.style.width = '208px';
|
this._editor.sidebarContainer.style.width = '208px';
|
||||||
var footer = document.getElementsByClassName('geFooterContainer');
|
var footer = document.getElementsByClassName('geFooterContainer');
|
||||||
|
@ -166,13 +170,13 @@ class DrawioWidget extends Widget implements DocumentRegistry.IReadyWidget {
|
||||||
this.context.model.fromString(xml);
|
this.context.model.fromString(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onModelStateChanged(sender: DocumentRegistry.IModel, args: IChangedArgs<any>): void {
|
private _onModelStateChangedNew(sender: DocumentRegistry.IModel, args: IChangedArgs<any>): void {
|
||||||
if (args.name === 'dirty') {
|
if (args.name === 'dirty') {
|
||||||
this._handleDirtyState();
|
this._handleDirtyStateNew();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleDirtyState() : void {
|
private _handleDirtyStateNew() : void {
|
||||||
if (this.context.model.dirty) {
|
if (this.context.model.dirty) {
|
||||||
this.title.className += ` ${DIRTY_CLASS}`;
|
this.title.className += ` ${DIRTY_CLASS}`;
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,6 +191,9 @@ class DrawioWidget extends Widget implements DocumentRegistry.IReadyWidget {
|
||||||
return this._ready.promise;
|
return this._ready.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public content: Widget;
|
||||||
|
public toolbar: Toolbar;
|
||||||
|
public revealed: Promise<void>;
|
||||||
readonly context: DocumentRegistry.Context;
|
readonly context: DocumentRegistry.Context;
|
||||||
private _editor : any;
|
private _editor : any;
|
||||||
private _ready = new PromiseDelegate<void>();
|
private _ready = new PromiseDelegate<void>();
|
||||||
|
@ -197,10 +204,14 @@ class DrawioWidget extends Widget implements DocumentRegistry.IReadyWidget {
|
||||||
*/
|
*/
|
||||||
export
|
export
|
||||||
class DrawioFactory extends ABCWidgetFactory<DrawioWidget, DocumentRegistry.IModel> {
|
class DrawioFactory extends ABCWidgetFactory<DrawioWidget, DocumentRegistry.IModel> {
|
||||||
/**
|
/**
|
||||||
* Create a new widget given a context.
|
* Create a new widget given a context.
|
||||||
*/
|
*/
|
||||||
protected createNewWidget(context: DocumentRegistry.Context): DrawioWidget {
|
constructor(options: DocumentRegistry.IWidgetFactoryOptions){
|
||||||
return new DrawioWidget(context);
|
super(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected createNewWidget(context: DocumentRegistry.Context): DrawioWidget {
|
||||||
|
return new DrawioWidget({context, content: new Widget()});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,6 +136,7 @@ function activate(app: JupyterLab,
|
||||||
// Add a command for creating a new diagram file.
|
// Add a command for creating a new diagram file.
|
||||||
commands.addCommand('drawio:create-new', {
|
commands.addCommand('drawio:create-new', {
|
||||||
label: 'Diagram',
|
label: 'Diagram',
|
||||||
|
iconClass: 'jp-MaterialIcon jp-ImageIcon',
|
||||||
caption: 'Create a new diagram file',
|
caption: 'Create a new diagram file',
|
||||||
execute: () => {
|
execute: () => {
|
||||||
let cwd = browserFactory.defaultBrowser.model.path;
|
let cwd = browserFactory.defaultBrowser.model.path;
|
||||||
|
@ -156,10 +157,7 @@ function activate(app: JupyterLab,
|
||||||
// Add a launcher item if the launcher is available.
|
// Add a launcher item if the launcher is available.
|
||||||
if (launcher) {
|
if (launcher) {
|
||||||
launcher.add({
|
launcher.add({
|
||||||
displayName: 'Diagram',
|
command: 'drawio:create-new',
|
||||||
name: 'diagram',
|
|
||||||
iconClass: 'jp-MaterialIcon jp-ImageIcon',
|
|
||||||
callback: createNewDIO,
|
|
||||||
rank: 1,
|
rank: 1,
|
||||||
category: 'Other'
|
category: 'Other'
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "ES5",
|
"target": "ES2015",
|
||||||
"outDir": "./lib",
|
"outDir": "./lib",
|
||||||
"lib": ["ES5", "ES2015.Promise", "DOM", "ES2015.Collection"],
|
"lib": ["ES2015", "ES2015.Promise", "DOM", "ES2015.Collection"],
|
||||||
"types": []
|
"types": []
|
||||||
},
|
},
|
||||||
"include": ["src/*"]
|
"include": ["src/*"]
|
||||||
|
|
Ładowanie…
Reference in New Issue