Clean up images and start first integration

This commit is contained in:
Paulo Gustavo Veiga 2021-12-30 15:59:09 -08:00
parent f774a8a0c9
commit a85d3de71d
32 changed files with 41 additions and 26 deletions

View File

@ -35,6 +35,7 @@ import DragConnector from './DragConnector';
import DragManager from './DragManager'; import DragManager from './DragManager';
import RelationshipPivot from './RelationshipPivot'; import RelationshipPivot from './RelationshipPivot';
import Relationship from './Relationship'; import Relationship from './Relationship';
import SVGExporter from './export/SVGExporter';
import TopicEventDispatcher, { TopicEvent } from './TopicEventDispatcher'; import TopicEventDispatcher, { TopicEvent } from './TopicEventDispatcher';
import TopicFeatureFactory from './TopicFeature'; import TopicFeatureFactory from './TopicFeature';
@ -339,9 +340,9 @@ class Designer extends Events {
} }
/** /**
* @param {Number=} factor * @param {Number=} factor
* zoom out by the given factor, or 1.2, if undefined * zoom out by the given factor, or 1.2, if undefined
*/ */
zoomOut(factor = 1.2) { zoomOut(factor = 1.2) {
const model = this.getModel(); const model = this.getModel();
const scale = model.getZoom() * factor; const scale = model.getZoom() * factor;
@ -353,6 +354,18 @@ class Designer extends Events {
} }
} }
export(formatType) {
const svgElement = this._workspace.getSVGElement();
const mindmap = this._mindmap;
let result = '';
if (formatType === 'svg') {
const exporter = new SVGExporter(mindmap, svgElement);
result = exporter.export();
}
return result;
}
/** /**
* @param {Number=} factor * @param {Number=} factor
* zoom in by the given factor, or 1.2, if undefined * zoom in by the given factor, or 1.2, if undefined

View File

@ -29,8 +29,8 @@ class Workspace {
this._isReadOnly = isReadOnly; this._isReadOnly = isReadOnly;
const divContainer = screenManager.getContainer(); const divContainer = screenManager.getContainer();
this._screenWidth = parseInt(divContainer.css('width'), 10); this._screenWidth = Number.parseInt(divContainer.css('width'), 10);
this._screenHeight = parseInt(divContainer.css('height'), 10); this._screenHeight = Number.parseInt(divContainer.css('height'), 10);
// Initialize web2d workspace. // Initialize web2d workspace.
const workspace = this._createWorkspace(); const workspace = this._createWorkspace();
@ -154,8 +154,8 @@ class Workspace {
return this._eventsEnabled; return this._eventsEnabled;
} }
dumpNativeChart() { getSVGElement() {
return this._workspace.dumpNativeChart(); return this._workspace.getSVGElement();
} }
_registerDragEvents() { _registerDragEvents() {

View File

@ -212,17 +212,17 @@ class Menu extends IMenu {
} }
this._addButton('export', false, false, () => { this._addButton('export', false, false, () => {
BootstrapDialogRequest.active = new BootstrapDialogRequest(`c/maps/${mapId}/exportf`, $msg('EXPORT'), { // BootstrapDialogRequest.active = new BootstrapDialogRequest(`c/maps/${mapId}/exportf`, $msg('EXPORT'), {
cancelButton: true, // cancelButton: true,
closeButton: true, // closeButton: true,
}); // });
const svgContent = designer.export('svg');
console.log(svgContent);
}); });
Menu._registerTooltip('export', $msg('EXPORT')); Menu._registerTooltip('export', $msg('EXPORT'));
const me = this;
this._addButton('print', false, false, () => { this._addButton('print', false, false, () => {
me.save(saveElem, designer, false); this.save(saveElem, designer, false);
const urlPrefix = window.location.href.substring(0, window.location.href.lastIndexOf('c/maps/')); const urlPrefix = window.location.href.substring(0, window.location.href.lastIndexOf('c/maps/'));
window.open(`${urlPrefix}c/maps/${mapId}/print`); window.open(`${urlPrefix}c/maps/${mapId}/print`);
}); });
@ -308,7 +308,7 @@ class Menu extends IMenu {
if (saveElem) { if (saveElem) {
this._addButton('save', false, false, this._addButton('save', false, false,
() => { () => {
me.save(saveElem, designer, true); this.save(saveElem, designer, true);
}); });
Menu._registerTooltip('save', $msg('SAVE'), 'meta+S'); Menu._registerTooltip('save', $msg('SAVE'), 'meta+S');
@ -316,17 +316,17 @@ class Menu extends IMenu {
// To prevent the user from leaving the page with changes ... // To prevent the user from leaving the page with changes ...
// Element.NativeEvents.unload = 1; // Element.NativeEvents.unload = 1;
$(window).bind('unload', () => { $(window).bind('unload', () => {
if (me.isSaveRequired()) { if (this.isSaveRequired()) {
me.save(saveElem, designer, false, true); this.save(saveElem, designer, false, true);
} }
me.unlockMap(designer); this.unlockMap(designer);
}); });
// Autosave on a fixed period of time ... // Autosave on a fixed period of time ...
setInterval( setInterval(
() => { () => {
if (me.isSaveRequired()) { if (this.isSaveRequired()) {
me.save(saveElem, designer, false); this.save(saveElem, designer, false);
} }
}, 30000, }, 30000,
); );
@ -336,7 +336,7 @@ class Menu extends IMenu {
const discardElem = $('#discard'); const discardElem = $('#discard');
if (discardElem) { if (discardElem) {
this._addButton('discard', false, false, () => { this._addButton('discard', false, false, () => {
me.discardChanges(designer); this.discardChanges(designer);
}); });
Menu._registerTooltip('discard', $msg('DISCARD_CHANGES')); Menu._registerTooltip('discard', $msg('DISCARD_CHANGES'));
} }

View File

@ -33,7 +33,10 @@
<img src="images/save.svg" /> <img src="images/save.svg" />
</div> </div>
<div id="discard" class="buttonOn"> <div id="discard" class="buttonOn">
<img src="images/discard.png" /> <img src="images/discard.svg" />
</div>
<div id="export" class="buttonOn">
<img src="images/export.svg" />
</div> </div>
</div> </div>
<div id="edit" class="buttonContainer"> <div id="edit" class="buttonContainer">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 562 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M14.59 8L12 10.59 9.41 8 8 9.41 10.59 12 8 14.59 9.41 16 12 13.41 14.59 16 16 14.59 13.41 12 16 9.41 14.59 8zM12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>

Before

Width:  |  Height:  |  Size: 390 B

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 728 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1002 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 790 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 817 B

View File

@ -197,9 +197,8 @@ class Workspace extends ElementClass {
this.peer.removeChild(element.peer); this.peer.removeChild(element.peer);
} }
dumpNativeChart() { getSVGElement() {
const elem = this._htmlContainer; return this._htmlContainer.firstChild;
return elem.innerHTML;
} }
} }