Add more tests on mindplot/playground and fix.

This commit is contained in:
Matias Arriola 2021-12-13 21:30:37 +00:00 committed by Paulo Veiga
parent e102b61c7d
commit a10b41ee4d
31 changed files with 1846 additions and 2195 deletions

View File

@ -10,8 +10,6 @@
"globals":{ "globals":{
"Class": "readonly", "Class": "readonly",
"$": "readonly", "$": "readonly",
"$assert": "readonly",
"$defined": "readonly",
"$msg": "readonly", "$msg": "readonly",
"_": "readonly" "_": "readonly"
}, },
@ -19,6 +17,7 @@
"rules": { "rules": {
"no-underscore-dangle": "off", "no-underscore-dangle": "off",
"no-plusplus": "off", "no-plusplus": "off",
"class-methods-use-this": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["!cypress/**/*.js"]}] "import/no-extraneous-dependencies": ["error", {"devDependencies": ["!cypress/**/*.js"]}]
}, },
"settings": { "settings": {

View File

@ -33,7 +33,8 @@
"@wisemapping/core-js": "^0.0.1", "@wisemapping/core-js": "^0.0.1",
"@wisemapping/web2d": "^0.0.1", "@wisemapping/web2d": "^0.0.1",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"mootools": "1.4.5" "mootools": "1.4.5",
"underscore": "^1.13.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.14.6", "@babel/core": "^7.14.6",
@ -53,6 +54,8 @@
"eslint-plugin-import": "^2.24.2", "eslint-plugin-import": "^2.24.2",
"eslint-plugin-only-warn": "^1.0.3", "eslint-plugin-only-warn": "^1.0.3",
"html-webpack-plugin": "^5.3.2", "html-webpack-plugin": "^5.3.2",
"less": "^4.1.2",
"less-loader": "^10.2.0",
"nodemon": "^2.0.12", "nodemon": "^2.0.12",
"start-server-and-test": "^1.14.0", "start-server-and-test": "^1.14.0",
"webpack": "^5.44.0", "webpack": "^5.44.0",

View File

@ -17,11 +17,12 @@
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d'; import * as web2d from '@wisemapping/web2d';
import IconGroupRemoveTip from './IconGroupRemoveTip';
import Icon from './Icon'; import Icon from './Icon';
const IconGroup = new Class( class IconGroup {
/** @lends IconGroup */ { /** @lends IconGroup */
/** /**
* @constructs * @constructs
* @param topicId * @param topicId
@ -29,7 +30,7 @@ const IconGroup = new Class(
* @throws will throw an error if topicId is null or undefined * @throws will throw an error if topicId is null or undefined
* @throws will throw an error if iconSize is null or undefined * @throws will throw an error if iconSize is null or undefined
*/ */
initialize(topicId, iconSize) { constructor(topicId, iconSize) {
$assert($defined(topicId), 'topicId can not be null'); $assert($defined(topicId), 'topicId can not be null');
$assert($defined(iconSize), 'iconSize can not be null'); $assert($defined(iconSize), 'iconSize can not be null');
@ -46,33 +47,33 @@ const IconGroup = new Class(
this.seIconSize(iconSize, iconSize); this.seIconSize(iconSize, iconSize);
this._registerListeners(); this._registerListeners();
}, }
/** */ /** */
setPosition(x, y) { setPosition(x, y) {
this._group.setPosition(x, y); this._group.setPosition(x, y);
}, }
/** */ /** */
getPosition() { getPosition() {
return this._group.getPosition(); return this._group.getPosition();
}, }
/** */ /** */
getNativeElement() { getNativeElement() {
return this._group; return this._group;
}, }
/** */ /** */
getSize() { getSize() {
return this._group.getSize(); return this._group.getSize();
}, }
/** */ /** */
seIconSize(width, height) { seIconSize(width, height) {
this._iconSize = { width, height }; this._iconSize = { width, height };
this._resize(this._icons.length); this._resize(this._icons.length);
}, }
/** /**
* @param icon the icon to be added to the icon group * @param icon the icon to be added to the icon group
@ -96,7 +97,7 @@ const IconGroup = new Class(
if (remove) { if (remove) {
this._removeTip.decorate(this._topicId, icon); this._removeTip.decorate(this._topicId, icon);
} }
}, }
_findIconFromModel(iconModel) { _findIconFromModel(iconModel) {
let result = null; let result = null;
@ -114,7 +115,7 @@ const IconGroup = new Class(
} }
return result; return result;
}, }
/** */ /** */
removeIconByModel(featureModel) { removeIconByModel(featureModel) {
@ -122,7 +123,7 @@ const IconGroup = new Class(
const icon = this._findIconFromModel(featureModel); const icon = this._findIconFromModel(featureModel);
this._removeIcon(icon); this._removeIcon(icon);
}, }
_removeIcon(icon) { _removeIcon(icon) {
$assert(icon, 'icon can not be null'); $assert(icon, 'icon can not be null');
@ -138,12 +139,12 @@ const IconGroup = new Class(
this._icons.forEach((elem, i) => { this._icons.forEach((elem, i) => {
me._positionIcon(elem, i); me._positionIcon(elem, i);
}); });
}, }
/** */ /** */
moveToFront() { moveToFront() {
this._group.moveToFront(); this._group.moveToFront();
}, }
_registerListeners() { _registerListeners() {
this._group.addEvent('click', (event) => { this._group.addEvent('click', (event) => {
@ -154,24 +155,24 @@ const IconGroup = new Class(
this._group.addEvent('dblclick', (event) => { this._group.addEvent('dblclick', (event) => {
event.stopPropagation(); event.stopPropagation();
}); });
}, }
_resize(iconsLength) { _resize(iconsLength) {
this._group.setSize(iconsLength * this._iconSize.width, this._iconSize.height); this._group.setSize(iconsLength * this._iconSize.width, this._iconSize.height);
const iconSize = Icon.SIZE + IconGroup.ICON_PADDING * 2; const iconSize = Icon.SIZE + IconGroup.ICON_PADDING * 2;
this._group.setCoordSize(iconsLength * iconSize, iconSize); this._group.setCoordSize(iconsLength * iconSize, iconSize);
}, }
// eslint-disable-next-line class-methods-use-this
_positionIcon(icon, order) { _positionIcon(icon, order) {
const iconSize = Icon.SIZE + IconGroup.ICON_PADDING * 2; const iconSize = Icon.SIZE + IconGroup.ICON_PADDING * 2;
icon.getImage().setPosition( icon.getImage().setPosition(
iconSize * order + IconGroup.ICON_PADDING, iconSize * order + IconGroup.ICON_PADDING,
IconGroup.ICON_PADDING, IconGroup.ICON_PADDING,
); );
}, }
}, }
);
/** /**
* @constant * @constant
@ -180,167 +181,6 @@ const IconGroup = new Class(
*/ */
IconGroup.ICON_PADDING = 5; IconGroup.ICON_PADDING = 5;
IconGroup.RemoveTip = new Class( IconGroup.RemoveTip = IconGroupRemoveTip;
/** @lends IconGroup.RemoveTip */ {
/**
* @classdesc inner class of IconGroup
* @constructs
* @param container
*/
initialize(container) {
$assert(container, 'group can not be null');
this._fadeElem = container;
},
/**
* @param topicId
* @param icon
* @throws will throw an error if icon is null or undefined
*/
show(topicId, icon) {
$assert(icon, 'icon can not be null');
// Nothing to do ...
if (this._activeIcon != icon) {
// If there is an active icon, close it first ...
if (this._activeIcon) {
this.close(0);
}
// Now, let move the position the icon...
const pos = icon.getPosition();
// Register events ...
const widget = this._buildWeb2d();
widget.addEvent('click', () => {
icon.remove();
});
const me = this;
widget.addEvent('mouseover', () => {
me.show(topicId, icon);
});
widget.addEvent('mouseout', () => {
me.hide();
});
widget.setPosition(pos.x + 80, pos.y - 50);
this._fadeElem.append(widget);
// Setup current element ...
this._activeIcon = icon;
this._widget = widget;
} else {
clearTimeout(this._closeTimeoutId);
}
},
/** */
hide() {
this.close(200);
},
/**
* @param delay
*/
close(delay) {
// This is not ok, trying to close the same dialog twice ?
if (this._closeTimeoutId) {
clearTimeout(this._closeTimeoutId);
}
const me = this;
if (this._activeIcon) {
const widget = this._widget;
const close = function () {
me._activeIcon = null;
me._fadeElem.removeChild(widget);
me._widget = null;
me._closeTimeoutId = null;
};
if (!$defined(delay) || delay == 0) {
close();
} else {
this._closeTimeoutId = close.delay(delay);
}
}
},
_buildWeb2d() {
const result = new web2d.Group({
width: 10,
height: 10,
x: 0,
y: 0,
coordSizeWidth: 10,
coordSizeHeight: 10,
});
const outerRect = new web2d.Rect(0, {
x: 0,
y: 0,
width: 10,
height: 10,
stroke: '0',
fillColor: 'black',
});
result.append(outerRect);
outerRect.setCursor('pointer');
const innerRect = new web2d.Rect(0, {
x: 1,
y: 1,
width: 8,
height: 8,
stroke: '1 solid white',
fillColor: 'gray',
});
result.append(innerRect);
const line = new web2d.Line({ stroke: '1 solid white' });
line.setFrom(1, 1);
line.setTo(9, 9);
result.append(line);
const line2 = new web2d.Line({ stroke: '1 solid white' });
line2.setFrom(1, 9);
line2.setTo(9, 1);
result.append(line2);
// Some events ...
result.addEvent('mouseover', () => {
innerRect.setFill('#CC0033');
});
result.addEvent('mouseout', () => {
innerRect.setFill('gray');
});
result.setSize(50, 50);
return result;
},
/**
* @param topicId
* @param icon
*/
decorate(topicId, icon) {
const me = this;
if (!icon.__remove) {
icon.addEvent('mouseover', () => {
me.show(topicId, icon);
});
icon.addEvent('mouseout', () => {
me.hide();
});
icon.__remove = true;
}
},
},
);
export default IconGroup; export default IconGroup;

View File

@ -0,0 +1,165 @@
import * as web2d from '@wisemapping/web2d';
import { $assert, $defined } from '@wisemapping/core-js';
export default class RemoveTip {
/** @lends IconGroup.RemoveTip */
/**
* @classdesc inner class of IconGroup
* @constructs
* @param container
*/
constructor(container) {
$assert(container, 'group can not be null');
this._fadeElem = container;
}
/**
* @param topicId
* @param icon
* @throws will throw an error if icon is null or undefined
*/
show(topicId, icon) {
$assert(icon, 'icon can not be null');
// Nothing to do ...
if (this._activeIcon != icon) {
// If there is an active icon, close it first ...
if (this._activeIcon) {
this.close(0);
}
// Now, let move the position the icon...
const pos = icon.getPosition();
// Register events ...
const widget = this._buildWeb2d();
widget.addEvent('click', () => {
icon.remove();
});
const me = this;
widget.addEvent('mouseover', () => {
me.show(topicId, icon);
});
widget.addEvent('mouseout', () => {
me.hide();
});
widget.setPosition(pos.x + 80, pos.y - 50);
this._fadeElem.append(widget);
// Setup current element ...
this._activeIcon = icon;
this._widget = widget;
} else {
clearTimeout(this._closeTimeoutId);
}
}
/** */
hide() {
this.close(200);
}
/**
* @param delay
*/
close(delay) {
// This is not ok, trying to close the same dialog twice ?
if (this._closeTimeoutId) {
clearTimeout(this._closeTimeoutId);
}
const me = this;
if (this._activeIcon) {
const widget = this._widget;
const close = function close() {
me._activeIcon = null;
me._fadeElem.removeChild(widget);
me._widget = null;
me._closeTimeoutId = null;
};
if (!$defined(delay) || delay == 0) {
close();
} else {
this._closeTimeoutId = close.delay(delay);
}
}
}
// eslint-disable-next-line class-methods-use-this
_buildWeb2d() {
const result = new web2d.Group({
width: 10,
height: 10,
x: 0,
y: 0,
coordSizeWidth: 10,
coordSizeHeight: 10,
});
const outerRect = new web2d.Rect(0, {
x: 0,
y: 0,
width: 10,
height: 10,
stroke: '0',
fillColor: 'black',
});
result.append(outerRect);
outerRect.setCursor('pointer');
const innerRect = new web2d.Rect(0, {
x: 1,
y: 1,
width: 8,
height: 8,
stroke: '1 solid white',
fillColor: 'gray',
});
result.append(innerRect);
const line = new web2d.Line({ stroke: '1 solid white' });
line.setFrom(1, 1);
line.setTo(9, 9);
result.append(line);
const line2 = new web2d.Line({ stroke: '1 solid white' });
line2.setFrom(1, 9);
line2.setTo(9, 1);
result.append(line2);
// Some events ...
result.addEvent('mouseover', () => {
innerRect.setFill('#CC0033');
});
result.addEvent('mouseout', () => {
innerRect.setFill('gray');
});
result.setSize(50, 50);
return result;
}
/**
* @param topicId
* @param icon
*/
decorate(topicId, icon) {
const me = this;
if (!icon.__remove) {
icon.addEvent('mouseover', () => {
me.show(topicId, icon);
});
icon.addEvent('mouseout', () => {
me.hide();
});
icon.__remove = true;
}
}
}

View File

@ -16,10 +16,10 @@
* limitations under the License. * limitations under the License.
*/ */
import { $defined } from '@wisemapping/core-js'; import { $defined } from '@wisemapping/core-js';
import Events from './Events';
import ActionDispatcher from './ActionDispatcher';
import $ from 'jquery'; import $ from 'jquery';
import initHotKeyPluggin from '@libraries/jquery.hotkeys'; import initHotKeyPluggin from '@libraries/jquery.hotkeys';
import Events from './Events';
import ActionDispatcher from './ActionDispatcher';
initHotKeyPluggin($); initHotKeyPluggin($);

View File

@ -1,3 +1,4 @@
/* eslint-disable class-methods-use-this */
/* /*
* Copyright [2015] [wisemapping] * Copyright [2015] [wisemapping]
* *
@ -21,9 +22,8 @@ import ChildrenSorterStrategy from './ChildrenSorterStrategy';
* @class * @class
* @extends mindplot.layout.ChildrenSorterStrategy * @extends mindplot.layout.ChildrenSorterStrategy
*/ */
const AbstractBasicSorter = new Class( class AbstractBasicSorter extends ChildrenSorterStrategy {
/** @lends AbstractBasicSorter */ { /** @lends AbstractBasicSorter */
Extends: ChildrenSorterStrategy,
/** /**
* @param {} treeSet * @param {} treeSet
@ -34,11 +34,11 @@ const AbstractBasicSorter = new Class(
const result = {}; const result = {};
this._computeChildrenHeight(treeSet, node, result); this._computeChildrenHeight(treeSet, node, result);
return result; return result;
}, }
_getVerticalPadding() { _getVerticalPadding() {
return AbstractBasicSorter.INTERNODE_VERTICAL_PADDING; return AbstractBasicSorter.INTERNODE_VERTICAL_PADDING;
}, }
_computeChildrenHeight(treeSet, node, heightCache) { _computeChildrenHeight(treeSet, node, heightCache) {
const height = node.getSize().height + this._getVerticalPadding() * 2; // 2* Top and down padding; const height = node.getSize().height + this._getVerticalPadding() * 2; // 2* Top and down padding;
@ -62,20 +62,19 @@ const AbstractBasicSorter = new Class(
} }
return result; return result;
}, }
_getSortedChildren(treeSet, node) { _getSortedChildren(treeSet, node) {
const result = treeSet.getChildren(node); const result = treeSet.getChildren(node);
result.sort((a, b) => a.getOrder() - b.getOrder()); result.sort((a, b) => a.getOrder() - b.getOrder());
return result; return result;
}, }
_getRelativeDirection(reference, position) { _getRelativeDirection(reference, position) {
const offset = position.x - reference.x; const offset = position.x - reference.x;
return offset >= 0 ? 1 : -1; return offset >= 0 ? 1 : -1;
}, }
}, }
);
/** /**
* @constant * @constant

View File

@ -1,3 +1,4 @@
/* eslint-disable class-methods-use-this */
/* /*
* Copyright [2015] [wisemapping] * Copyright [2015] [wisemapping]
* *
@ -18,15 +19,12 @@
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter'; import AbstractBasicSorter from './AbstractBasicSorter';
const BalancedSorter = new Class( class BalancedSorter extends AbstractBasicSorter {
/** @lends BalancedSorter */ { /** @lends BalancedSorter */
Extends: AbstractBasicSorter,
/** /**
* @constructs * @constructs
* @extends mindplot.layout.AbstractBasicSorter * @extends mindplot.layout.AbstractBasicSorter
*/ */
initialize() { },
/** /**
* @param {} graph * @param {} graph
* @param {} parent * @param {} parent
@ -150,7 +148,7 @@ const BalancedSorter = new Class(
} }
return result; return result;
}, }
/** /**
* @param {} treeSet * @param {} treeSet
@ -181,7 +179,7 @@ const BalancedSorter = new Class(
const newOrder = order > max + 1 ? max + 2 : order; const newOrder = order > max + 1 ? max + 2 : order;
child.setOrder(newOrder); child.setOrder(newOrder);
}, }
/** /**
* @param {} treeSet * @param {} treeSet
@ -198,7 +196,7 @@ const BalancedSorter = new Class(
} }
}); });
node.setOrder(node.getOrder() % 2 == 0 ? 0 : 1); node.setOrder(node.getOrder() % 2 == 0 ? 0 : 1);
}, }
/** /**
* @param {} treeSet * @param {} treeSet
@ -263,7 +261,7 @@ const BalancedSorter = new Class(
result[heights[i].id] = { x: xOffset, y: yOffset }; result[heights[i].id] = { x: xOffset, y: yOffset };
} }
return result; return result;
}, }
/** /**
* @param {} treeSet * @param {} treeSet
@ -286,7 +284,7 @@ const BalancedSorter = new Class(
},Node:${children[i].getId()}`, },Node:${children[i].getId()}`,
); );
} }
}, }
/** /**
* @param {} treeSet * @param {} treeSet
@ -295,24 +293,23 @@ const BalancedSorter = new Class(
*/ */
getChildDirection(treeSet, child) { getChildDirection(treeSet, child) {
return child.getOrder() % 2 == 0 ? 1 : -1; return child.getOrder() % 2 == 0 ? 1 : -1;
}, }
/** /**
* @return {String} the print name of this class * @return {String} the print name of this class
*/ */
toString() { toString() {
return 'Balanced Sorter'; return 'Balanced Sorter';
}, }
_getChildrenForOrder(parent, graph, order) { _getChildrenForOrder(parent, graph, order) {
return this._getSortedChildren(graph, parent).filter((child) => child.getOrder() % 2 == order % 2); return this._getSortedChildren(graph, parent).filter((child) => child.getOrder() % 2 == order % 2);
}, }
_getVerticalPadding() { _getVerticalPadding() {
return BalancedSorter.INTERNODE_VERTICAL_PADDING; return BalancedSorter.INTERNODE_VERTICAL_PADDING;
}, }
}, }
);
/** /**
* @constant * @constant

View File

@ -1,3 +1,4 @@
/* eslint-disable class-methods-use-this */
/* /*
* Copyright [2015] [wisemapping] * Copyright [2015] [wisemapping]
* *
@ -16,54 +17,49 @@
* limitations under the License. * limitations under the License.
*/ */
const ChildrenSorterStrategy = new Class(/** @lends ChildrenSorterStrategy */{ class ChildrenSorterStrategy {/** @lends ChildrenSorterStrategy */
/** /**
* @constructs * @constructs
*/ */
initialize() {
},
/** @abstract */ /** @abstract */
computeChildrenIdByHeights(treeSet, node) { computeChildrenIdByHeights(treeSet, node) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
computeOffsets(treeSet, node) { computeOffsets(treeSet, node) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
insert(treeSet, parent, child, order) { insert(treeSet, parent, child, order) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
detach(treeSet, node) { detach(treeSet, node) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
predict(treeSet, parent, node, position, free) { predict(treeSet, parent, node, position, free) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
verify(treeSet, node) { verify(treeSet, node) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
getChildDirection(treeSet, node) { getChildDirection(treeSet, node) {
throw 'Method must be implemented'; throw new Error('Method must be implemented');
}, }
/** @abstract */ /** @abstract */
toString() { toString() {
throw 'Method must be implemented: print name'; throw new Error('Method must be implemented: print name');
}, }
}
});
export default ChildrenSorterStrategy; export default ChildrenSorterStrategy;

View File

@ -17,20 +17,20 @@
*/ */
import EventBus from './EventBus'; import EventBus from './EventBus';
const EventBusDispatcher = new Class(/** @lends EventBusDispatcher */{ class EventBusDispatcher {/** @lends EventBusDispatcher */
/** /**
* @constructs * @constructs
*/ */
initialize() { constructor() {
this.registerBusEvents(); this.registerBusEvents();
}, }
/** /**
* @param {mindplot.layout.LayoutManager} layoutManager * @param {mindplot.layout.LayoutManager} layoutManager
*/ */
setLayoutManager(layoutManager) { setLayoutManager(layoutManager) {
this._layoutManager = layoutManager; this._layoutManager = layoutManager;
}, }
/** /**
* register bus events * register bus events
@ -44,27 +44,27 @@ const EventBusDispatcher = new Class(/** @lends EventBusDispatcher */{
EventBus.instance.addEvent(EventBus.events.NodeConnectEvent, this._nodeConnectEvent.bind(this)); EventBus.instance.addEvent(EventBus.events.NodeConnectEvent, this._nodeConnectEvent.bind(this));
EventBus.instance.addEvent(EventBus.events.NodeShrinkEvent, this._nodeShrinkEvent.bind(this)); EventBus.instance.addEvent(EventBus.events.NodeShrinkEvent, this._nodeShrinkEvent.bind(this));
EventBus.instance.addEvent(EventBus.events.DoLayout, this._doLayout.bind(this)); EventBus.instance.addEvent(EventBus.events.DoLayout, this._doLayout.bind(this));
}, }
_nodeResizeEvent(args) { _nodeResizeEvent(args) {
this._layoutManager.updateNodeSize(args.node.getId(), args.size); this._layoutManager.updateNodeSize(args.node.getId(), args.size);
}, }
_nodeMoveEvent(args) { _nodeMoveEvent(args) {
this._layoutManager.moveNode(args.node.getId(), args.position); this._layoutManager.moveNode(args.node.getId(), args.position);
}, }
_nodeDisconnectEvent(node) { _nodeDisconnectEvent(node) {
this._layoutManager.disconnectNode(node.getId()); this._layoutManager.disconnectNode(node.getId());
}, }
_nodeConnectEvent(args) { _nodeConnectEvent(args) {
this._layoutManager.connectNode(args.parentNode.getId(), args.childNode.getId(), args.childNode.getOrder()); this._layoutManager.connectNode(args.parentNode.getId(), args.childNode.getId(), args.childNode.getOrder());
}, }
_nodeShrinkEvent(node) { _nodeShrinkEvent(node) {
this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken()); this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken());
}, }
_nodeAdded(node) { _nodeAdded(node) {
// Central topic must not be added twice ... // Central topic must not be added twice ...
@ -72,11 +72,11 @@ const EventBusDispatcher = new Class(/** @lends EventBusDispatcher */{
this._layoutManager.addNode(node.getId(), { width: 10, height: 10 }, node.getPosition()); this._layoutManager.addNode(node.getId(), { width: 10, height: 10 }, node.getPosition());
this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken()); this._layoutManager.updateShrinkState(node.getId(), node.areChildrenShrunken());
} }
}, }
_nodeRemoved(node) { _nodeRemoved(node) {
this._layoutManager.removeNode(node.getId()); this._layoutManager.removeNode(node.getId());
}, }
_doLayout() { _doLayout() {
// (function() { // (function() {
@ -86,13 +86,12 @@ const EventBusDispatcher = new Class(/** @lends EventBusDispatcher */{
// console.log("---------"); // console.log("---------");
// console.log("---------"); // console.log("---------");
// }).delay(0, this); // }).delay(0, this);
}, }
/** @return layout manager */ /** @return layout manager */
getLayoutManager() { getLayoutManager() {
return this._layoutManager; return this._layoutManager;
}, }
}
});
export default EventBusDispatcher; export default EventBusDispatcher;

View File

@ -22,9 +22,7 @@ import AbstractBasicSorter from './AbstractBasicSorter';
* @class * @class
* @extends mindplot.layout.AbstractBasicSorter * @extends mindplot.layout.AbstractBasicSorter
*/ */
const GridSorter = new Class(/** @lends GridSorter */{ class GridSorter extends AbstractBasicSorter {/** @lends GridSorter */
Extends: AbstractBasicSorter,
/** /**
* @param {} treeSet * @param {} treeSet
* @param {} node * @param {} node
@ -59,22 +57,21 @@ const GridSorter = new Class(/** @lends GridSorter */{
const yOffset = zeroHeight + middleHeight + finalHeight; const yOffset = zeroHeight + middleHeight + finalHeight;
const xOffset = node.getSize().width + GridSorter.GRID_HORIZONTAR_SIZE; const xOffset = node.getSize().width + GridSorter.GRID_HORIZONTAR_SIZE;
$assert(!isNaN(xOffset), 'xOffset can not be null'); $assert(!Number.isNaN(xOffset), 'xOffset can not be null');
$assert(!isNaN(yOffset), 'yOffset can not be null'); $assert(!Number.isNaN(yOffset), 'yOffset can not be null');
result[heights[i].id] = { x: xOffset, y: yOffset }; result[heights[i].id] = { x: xOffset, y: yOffset };
} }
return result; return result;
}, }
/** /**
* @return {String} the print name of this class * @return {String} the print name of this class
*/ */
toString() { toString() {
return 'Grid Sorter'; return 'Grid Sorter';
}, }
}
});
/** /**
* @constant * @constant

View File

@ -17,8 +17,8 @@
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
const Node = new Class( class Node {
/** @lends Node */ { /** @lends Node */
/** /**
* @constructs * @constructs
* @param id * @param id
@ -30,7 +30,7 @@ const Node = new Class(
* @throws will throw an error if position is null or undefined * @throws will throw an error if position is null or undefined
* @throws will throw an error if sorter is null or undefined * @throws will throw an error if sorter is null or undefined
*/ */
initialize(id, size, position, sorter) { constructor(id, size, position, sorter) {
$assert(typeof id === 'number' && Number.isFinite(id), 'id can not be null'); $assert(typeof id === 'number' && Number.isFinite(id), 'id can not be null');
$assert(size, 'size can not be null'); $assert(size, 'size can not be null');
$assert(position, 'position can not be null'); $assert(position, 'position can not be null');
@ -43,42 +43,42 @@ const Node = new Class(
this.setSize(size); this.setSize(size);
this.setPosition(position); this.setPosition(position);
this.setShrunken(false); this.setShrunken(false);
}, }
/** */ /** */
getId() { getId() {
return this._id; return this._id;
}, }
/** */ /** */
setFree(value) { setFree(value) {
this._setProperty('free', value); this._setProperty('free', value);
}, }
/** */ /** */
isFree() { isFree() {
return this._getProperty('free'); return this._getProperty('free');
}, }
/** */ /** */
hasFreeChanged() { hasFreeChanged() {
return this._isPropertyChanged('free'); return this._isPropertyChanged('free');
}, }
/** */ /** */
hasFreeDisplacementChanged() { hasFreeDisplacementChanged() {
return this._isPropertyChanged('freeDisplacement'); return this._isPropertyChanged('freeDisplacement');
}, }
/** */ /** */
setShrunken(value) { setShrunken(value) {
this._setProperty('shrink', value); this._setProperty('shrink', value);
}, }
/** */ /** */
areChildrenShrunken() { areChildrenShrunken() {
return this._getProperty('shrink'); return this._getProperty('shrink');
}, }
/** */ /** */
setOrder(order) { setOrder(order) {
@ -87,7 +87,7 @@ const Node = new Class(
`Order can not be null. Value:${order}`, `Order can not be null. Value:${order}`,
); );
this._setProperty('order', order); this._setProperty('order', order);
}, }
/** */ /** */
resetPositionState() { resetPositionState() {
@ -95,7 +95,7 @@ const Node = new Class(
if (prop) { if (prop) {
prop.hasChanged = false; prop.hasChanged = false;
} }
}, }
/** */ /** */
resetOrderState() { resetOrderState() {
@ -103,7 +103,7 @@ const Node = new Class(
if (prop) { if (prop) {
prop.hasChanged = false; prop.hasChanged = false;
} }
}, }
/** */ /** */
resetFreeState() { resetFreeState() {
@ -111,43 +111,43 @@ const Node = new Class(
if (prop) { if (prop) {
prop.hasChanged = false; prop.hasChanged = false;
} }
}, }
/** */ /** */
getOrder() { getOrder() {
return this._getProperty('order'); return this._getProperty('order');
}, }
/** */ /** */
hasOrderChanged() { hasOrderChanged() {
return this._isPropertyChanged('order'); return this._isPropertyChanged('order');
}, }
/** */ /** */
hasPositionChanged() { hasPositionChanged() {
return this._isPropertyChanged('position'); return this._isPropertyChanged('position');
}, }
/** */ /** */
hasSizeChanged() { hasSizeChanged() {
return this._isPropertyChanged('size'); return this._isPropertyChanged('size');
}, }
/** */ /** */
getPosition() { getPosition() {
return this._getProperty('position'); return this._getProperty('position');
}, }
/** */ /** */
setSize(size) { setSize(size) {
$assert($defined(size), 'Size can not be null'); $assert($defined(size), 'Size can not be null');
this._setProperty('size', Object.clone(size)); this._setProperty('size', Object.clone(size));
}, }
/** */ /** */
getSize() { getSize() {
return this._getProperty('size'); return this._getProperty('size');
}, }
/** */ /** */
setFreeDisplacement(displacement) { setFreeDisplacement(displacement) {
@ -161,18 +161,18 @@ const Node = new Class(
}; };
this._setProperty('freeDisplacement', Object.clone(newDisplacement)); this._setProperty('freeDisplacement', Object.clone(newDisplacement));
}, }
/** */ /** */
resetFreeDisplacement() { resetFreeDisplacement() {
this._setProperty('freeDisplacement', { x: 0, y: 0 }); this._setProperty('freeDisplacement', { x: 0, y: 0 });
}, }
/** */ /** */
getFreeDisplacement() { getFreeDisplacement() {
const freeDisplacement = this._getProperty('freeDisplacement'); const freeDisplacement = this._getProperty('freeDisplacement');
return freeDisplacement || { x: 0, y: 0 }; return freeDisplacement || { x: 0, y: 0 };
}, }
/** */ /** */
setPosition(position) { setPosition(position) {
@ -187,7 +187,7 @@ const Node = new Class(
|| Math.abs(currentPos.x - position.x) > 2 || Math.abs(currentPos.x - position.x) > 2
|| Math.abs(currentPos.y - position.y) > 2 || Math.abs(currentPos.y - position.y) > 2
) this._setProperty('position', position); ) this._setProperty('position', position);
}, }
_setProperty(key, value) { _setProperty(key, value) {
let prop = this._properties[key]; let prop = this._properties[key];
@ -206,22 +206,22 @@ const Node = new Class(
prop.hasChanged = true; prop.hasChanged = true;
} }
this._properties[key] = prop; this._properties[key] = prop;
}, }
_getProperty(key) { _getProperty(key) {
const prop = this._properties[key]; const prop = this._properties[key];
return $defined(prop) ? prop.value : null; return $defined(prop) ? prop.value : null;
}, }
_isPropertyChanged(key) { _isPropertyChanged(key) {
const prop = this._properties[key]; const prop = this._properties[key];
return prop ? prop.hasChanged : false; return prop ? prop.hasChanged : false;
}, }
/** */ /** */
getSorter() { getSorter() {
return this._sorter; return this._sorter;
}, }
/** @return {String} returns id, order, position, size and shrink information */ /** @return {String} returns id, order, position, size and shrink information */
toString() { toString() {
@ -242,8 +242,8 @@ const Node = new Class(
this.areChildrenShrunken() this.areChildrenShrunken()
}]` }]`
); );
}, }
}, }
);
export default Node; export default Node;

View File

@ -17,12 +17,12 @@
*/ */
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
const RootedTreeSet = new Class( class RootedTreeSet {
/** @lends RootedTreeSet */ { /** @lends RootedTreeSet */
/** @constructs */ /** @constructs */
initialize() { constructor() {
this._rootNodes = []; this._rootNodes = [];
}, }
/** /**
* @param root * @param root
@ -31,17 +31,17 @@ const RootedTreeSet = new Class(
setRoot(root) { setRoot(root) {
$assert(root, 'root can not be null'); $assert(root, 'root can not be null');
this._rootNodes.push(this._decodate(root)); this._rootNodes.push(this._decodate(root));
}, }
/** getter */ /** getter */
getTreeRoots() { getTreeRoots() {
return this._rootNodes; return this._rootNodes;
}, }
_decodate(node) { _decodate(node) {
node._children = []; node._children = [];
return node; return node;
}, }
/** /**
* @param {mindplot.model.NodeModel} node * @param {mindplot.model.NodeModel} node
@ -57,7 +57,7 @@ const RootedTreeSet = new Class(
); );
$assert(!node._children, 'node already added'); $assert(!node._children, 'node already added');
this._rootNodes.push(this._decodate(node)); this._rootNodes.push(this._decodate(node));
}, }
/** /**
* @param nodeId * @param nodeId
@ -67,7 +67,7 @@ const RootedTreeSet = new Class(
$assert($defined(nodeId), 'nodeId can not be null'); $assert($defined(nodeId), 'nodeId can not be null');
const node = this.find(nodeId); const node = this.find(nodeId);
this._rootNodes.erase(node); this._rootNodes.erase(node);
}, }
/** /**
* @param parentId * @param parentId
@ -90,7 +90,7 @@ const RootedTreeSet = new Class(
parent._children.push(child); parent._children.push(child);
child._parent = parent; child._parent = parent;
this._rootNodes.erase(child); this._rootNodes.erase(child);
}, }
/** /**
* @param nodeId * @param nodeId
@ -105,7 +105,7 @@ const RootedTreeSet = new Class(
node._parent._children.erase(node); node._parent._children.erase(node);
this._rootNodes.push(node); this._rootNodes.push(node);
node._parent = null; node._parent = null;
}, }
/** /**
* @param id * @param id
@ -132,7 +132,7 @@ const RootedTreeSet = new Class(
`node could not be found id:${id}\n,RootedTreeSet${this.dump()}`, `node could not be found id:${id}\n,RootedTreeSet${this.dump()}`,
); );
return result; return result;
}, }
_find(id, parent) { _find(id, parent) {
if (parent.getId() === id) { if (parent.getId() === id) {
@ -148,7 +148,7 @@ const RootedTreeSet = new Class(
} }
return result; return result;
}, }
/** /**
* @param node * @param node
@ -158,7 +158,7 @@ const RootedTreeSet = new Class(
getChildren(node) { getChildren(node) {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return node._children; return node._children;
}, }
/** /**
* @param node * @param node
@ -173,7 +173,7 @@ const RootedTreeSet = new Class(
} }
return node; return node;
}, }
/** /**
* @param node * @param node
@ -182,7 +182,7 @@ const RootedTreeSet = new Class(
getAncestors(node) { getAncestors(node) {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return this._getAncestors(this.getParent(node), []); return this._getAncestors(this.getParent(node), []);
}, }
_getAncestors(node, ancestors) { _getAncestors(node, ancestors) {
const result = ancestors; const result = ancestors;
@ -191,7 +191,7 @@ const RootedTreeSet = new Class(
this._getAncestors(this.getParent(node), result); this._getAncestors(this.getParent(node), result);
} }
return result; return result;
}, }
/** /**
* @param node * @param node
@ -205,7 +205,7 @@ const RootedTreeSet = new Class(
} }
const siblings = node._parent._children.filter((child) => child !== node); const siblings = node._parent._children.filter((child) => child !== node);
return siblings; return siblings;
}, }
/** /**
* @param node * @param node
@ -215,7 +215,7 @@ const RootedTreeSet = new Class(
hasSinglePathToSingleLeaf(node) { hasSinglePathToSingleLeaf(node) {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return this._hasSinglePathToSingleLeaf(node); return this._hasSinglePathToSingleLeaf(node);
}, }
_hasSinglePathToSingleLeaf(node) { _hasSinglePathToSingleLeaf(node) {
const children = this.getChildren(node); const children = this.getChildren(node);
@ -225,14 +225,14 @@ const RootedTreeSet = new Class(
} }
return children.length === 0; return children.length === 0;
}, }
/** /**
* @param node * @param node
* @return {Boolean} whether the node is the start of a subbranch */ * @return {Boolean} whether the node is the start of a subbranch */
isStartOfSubBranch(node) { isStartOfSubBranch(node) {
return this.getSiblings(node).length > 0 && this.getChildren(node).length === 1; return this.getSiblings(node).length > 0 && this.getChildren(node).length === 1;
}, }
/** /**
* @param node * @param node
@ -242,7 +242,7 @@ const RootedTreeSet = new Class(
isLeaf(node) { isLeaf(node) {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return this.getChildren(node).length === 0; return this.getChildren(node).length === 0;
}, }
/** /**
* @param node * @param node
@ -252,7 +252,7 @@ const RootedTreeSet = new Class(
getParent(node) { getParent(node) {
$assert(node, 'node cannot be null'); $assert(node, 'node cannot be null');
return node._parent; return node._parent;
}, }
/** /**
* @return result * @return result
@ -265,7 +265,7 @@ const RootedTreeSet = new Class(
result += this._dump(branch, ''); result += this._dump(branch, '');
} }
return result; return result;
}, }
_dump(node, indent) { _dump(node, indent) {
let result = `${indent + node}\n`; let result = `${indent + node}\n`;
@ -276,7 +276,7 @@ const RootedTreeSet = new Class(
} }
return result; return result;
}, }
/** /**
* @param canvas * @param canvas
@ -287,7 +287,7 @@ const RootedTreeSet = new Class(
const branch = branches[i]; const branch = branches[i];
this._plot(canvas, branch); this._plot(canvas, branch);
} }
}, }
_plot(canvas, node, root) { _plot(canvas, node, root) {
const children = this.getChildren(node); const children = this.getChildren(node);
@ -360,7 +360,7 @@ const RootedTreeSet = new Class(
const child = children[i]; const child = children[i];
this._plot(canvas, child); this._plot(canvas, child);
} }
}, }
/** /**
* @param node * @param node
@ -378,7 +378,7 @@ const RootedTreeSet = new Class(
children.forEach((child) => { children.forEach((child) => {
me.shiftBranchPosition(child, xOffset, yOffset); me.shiftBranchPosition(child, xOffset, yOffset);
}); });
}, }
/** /**
* @param node * @param node
@ -394,7 +394,7 @@ const RootedTreeSet = new Class(
children.forEach((child) => { children.forEach((child) => {
me.shiftBranchPosition(child, xOffset, yOffset); me.shiftBranchPosition(child, xOffset, yOffset);
}); });
}, }
/** /**
* @param node * @param node
@ -419,7 +419,7 @@ const RootedTreeSet = new Class(
} }
return siblings; return siblings;
}, }
/** /**
* @param node * @param node
@ -447,8 +447,7 @@ const RootedTreeSet = new Class(
}, this); }, this);
return rootDescendants; return rootDescendants;
}, }
}, }
);
export default RootedTreeSet; export default RootedTreeSet;

View File

@ -18,15 +18,8 @@
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter'; import AbstractBasicSorter from './AbstractBasicSorter';
class SymmetricSorter extends AbstractBasicSorter {
const SymmetricSorter = new Class( /** @lends SymmetricSorter */
/** @lends SymmetricSorter */ {
Extends: AbstractBasicSorter,
/**
* @constructs
* @extends mindplot.layout.AbstractBasicSorter
*/
initialize() {},
/** /**
* Predict the order and position of a dragged node. * Predict the order and position of a dragged node.
@ -173,7 +166,7 @@ const SymmetricSorter = new Class(
- SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2, - SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
}; };
return [0, position]; return [0, position];
}, }
/** /**
* @param treeSet * @param treeSet
@ -195,7 +188,7 @@ const SymmetricSorter = new Class(
node.setOrder(i + 1); node.setOrder(i + 1);
} }
child.setOrder(order); child.setOrder(order);
}, }
/** /**
* @param treeSet * @param treeSet
@ -213,7 +206,7 @@ const SymmetricSorter = new Class(
child.setOrder(child.getOrder() - 1); child.setOrder(child.getOrder() - 1);
} }
node.setOrder(0); node.setOrder(0);
}, }
/** /**
* @param treeSet * @param treeSet
@ -265,13 +258,13 @@ const SymmetricSorter = new Class(
+ node.getSize().width / 2 + node.getSize().width / 2
+ SymmetricSorter.INTERNODE_HORIZONTAL_PADDING); + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING);
$assert(!isNaN(xOffset), 'xOffset can not be null'); $assert(!Number.isNaN(xOffset), 'xOffset can not be null');
$assert(!isNaN(yOffset), 'yOffset can not be null'); $assert(!Number.isNaN(yOffset), 'yOffset can not be null');
result[heights[i].id] = { x: xOffset, y: yOffset }; result[heights[i].id] = { x: xOffset, y: yOffset };
} }
return result; return result;
}, }
/** /**
* @param treeSet * @param treeSet
@ -285,7 +278,7 @@ const SymmetricSorter = new Class(
for (let i = 0; i < children.length; i++) { for (let i = 0; i < children.length; i++) {
$assert(children[i].getOrder() == i, 'missing order elements'); $assert(children[i].getOrder() == i, 'missing order elements');
} }
}, }
/** /**
* @param treeSet * @param treeSet
@ -308,18 +301,17 @@ const SymmetricSorter = new Class(
result = sorter.getChildDirection(treeSet, parent); result = sorter.getChildDirection(treeSet, parent);
} }
return result; return result;
}, }
/** @return {String} the print name of this class */ /** @return {String} the print name of this class */
toString() { toString() {
return 'Symmetric Sorter'; return 'Symmetric Sorter';
}, }
_getVerticalPadding() { _getVerticalPadding() {
return SymmetricSorter.INTERNODE_VERTICAL_PADDING; return SymmetricSorter.INTERNODE_VERTICAL_PADDING;
}, }
}, }
);
/** /**
* @constant * @constant

View File

@ -19,8 +19,7 @@
// FIXME: this Class should be reimplemented // FIXME: this Class should be reimplemented
import Events from '../Events'; import Events from '../Events';
const FadeEffect = new Class(/** @lends FadeEffect */{ class FadeEffect extends Events {/** @lends FadeEffect */
Extends: Events,
/** /**
* @extends mindplot.Events * @extends mindplot.Events
* @constructs * @constructs
@ -30,7 +29,7 @@ const FadeEffect = new Class(/** @lends FadeEffect */{
initialize(elements, isVisible) { initialize(elements, isVisible) {
this._isVisible = isVisible; this._isVisible = isVisible;
this._element = elements; this._element = elements;
}, }
/** */ /** */
start() { start() {
@ -42,7 +41,7 @@ const FadeEffect = new Class(/** @lends FadeEffect */{
}); });
this._isVisible = !visible; this._isVisible = !visible;
this.fireEvent('complete'); this.fireEvent('complete');
}, }
}); }
export default FadeEffect; export default FadeEffect;

View File

@ -65,7 +65,7 @@ class ColorPalettePanel extends ToolbarPaneItem {
const colorCells = content.find('div[class=palette-colorswatch]'); const colorCells = content.find('div[class=palette-colorswatch]');
const model = this.getModel(); const model = this.getModel();
const me = this; const me = this;
colorCells.each((elem) => { colorCells.each((index, elem) => {
$(elem).on('click', () => { $(elem).on('click', () => {
const color = $(elem).css('background-color'); const color = $(elem).css('background-color');
model.setValue(color); model.setValue(color);

View File

@ -17,30 +17,28 @@
*/ */
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog'; import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
const LinkEditor = new Class(/** @lends LinkEditor */{ class LinkEditor extends BootstrapDialog {/** @lends LinkEditor */
Extends: BootstrapDialog,
/** /**
* @constructs * @constructs
* @param model * @param model
* @throws will throw an error if model is null or undefined * @throws will throw an error if model is null or undefined
* @extends BootstrapDialog * @extends BootstrapDialog
*/ */
initialize(model) { constructor(model) {
$assert(model, 'model can not be null'); $assert(model, 'model can not be null');
this._model = model; super($msg('LINK'), {
this.parent($msg('LINK'), {
cancelButton: true, cancelButton: true,
closeButton: true, closeButton: true,
acceptButton: true, acceptButton: true,
removeButton: typeof model.getValue() !== 'undefined', removeButton: typeof model.getValue() !== 'undefined',
errorMessage: true, errorMessage: true,
onEventData: { model: this._model }, onEventData: { model },
}); });
this._model = model;
this.css({ margin: '150px auto' }); this.css({ margin: '150px auto' });
const panel = this._buildPanel(model); const panel = this._buildPanel(model);
this.setContent(panel); this.setContent(panel);
}, }
_buildPanel(model) { _buildPanel(model) {
const result = $('<div></div>').css('padding-top', '5px'); const result = $('<div></div>').css('padding-top', '5px');
@ -109,7 +107,7 @@ const LinkEditor = new Class(/** @lends LinkEditor */{
result.append(this.form); result.append(this.form);
return result; return result;
}, }
/** /**
* checks whether the input is a valid url * checks whether the input is a valid url
@ -118,7 +116,7 @@ const LinkEditor = new Class(/** @lends LinkEditor */{
checkURL(url) { checkURL(url) {
const regex = /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i; const regex = /^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i;
return (regex.test(url)); return (regex.test(url));
}, }
/** /**
* overrides abstract parent method * overrides abstract parent method
@ -131,7 +129,7 @@ const LinkEditor = new Class(/** @lends LinkEditor */{
if (!this.formSubmitted) { if (!this.formSubmitted) {
event.stopPropagation(); event.stopPropagation();
} }
}, }
/** /**
* overrides parent method * overrides parent method
@ -139,7 +137,7 @@ const LinkEditor = new Class(/** @lends LinkEditor */{
*/ */
onDialogShown() { onDialogShown() {
$(this).find('#inputUrl').focus(); $(this).find('#inputUrl').focus();
}, }
/** /**
* overrides abstract parent method * overrides abstract parent method
@ -148,8 +146,8 @@ const LinkEditor = new Class(/** @lends LinkEditor */{
onRemoveClick(event) { onRemoveClick(event) {
event.data.model.setValue(null); event.data.model.setValue(null);
event.data.dialog.close(); event.data.dialog.close();
}, }
}); }
export default LinkEditor; export default LinkEditor;

View File

@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* /*
* Copyright [2015] [wisemapping] * Copyright [2015] [wisemapping]
* *
@ -15,19 +16,18 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import $ from 'jquery';
import { $assert } from '@wisemapping/core-js';
import TestSuite from './TestSuite'; import TestSuite from './TestSuite';
import LayoutManager from '../../../src/components/layout/LayoutManager'; import LayoutManager from '../../../src/components/layout/LayoutManager';
class BalancedTestSuite extends TestSuite {
const BalancedTestSuite = new Class({ constructor() {
Extends: TestSuite,
initialize() {
$('#balancedTest').css('display', 'block'); $('#balancedTest').css('display', 'block');
super();
this.testBalanced(); this.testBalanced();
this.testBalancedPredict(); this.testBalancedPredict();
this.testBalancedNodeDragPredict(); this.testBalancedNodeDragPredict();
}, }
testBalanced() { testBalanced() {
console.log('testBalanced:'); console.log('testBalanced:');
@ -176,7 +176,7 @@ const BalancedTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testBalancedPredict() { testBalancedPredict() {
console.log('testBalancedPredict:'); console.log('testBalancedPredict:');
@ -335,7 +335,7 @@ const BalancedTestSuite = new Class({
$assert(prediction5a.order == prediction5b.order, 'Both predictions should be the same'); $assert(prediction5a.order == prediction5b.order, 'Both predictions should be the same');
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testBalancedNodeDragPredict() { testBalancedNodeDragPredict() {
console.log('testBalancedNodeDragPredict:'); console.log('testBalancedNodeDragPredict:');
@ -493,7 +493,7 @@ const BalancedTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
}); }
export default BalancedTestSuite; export default BalancedTestSuite;

View File

@ -15,6 +15,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import $ from 'jquery';
import { $assert } from '@wisemapping/core-js';
import TestSuite from './TestSuite'; import TestSuite from './TestSuite';
import LayoutManager from '../../../src/components/layout/LayoutManager'; import LayoutManager from '../../../src/components/layout/LayoutManager';
import OriginalLayout from '../../../src/components/layout/OriginalLayout'; import OriginalLayout from '../../../src/components/layout/OriginalLayout';

View File

@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* /*
* Copyright [2015] [wisemapping] * Copyright [2015] [wisemapping]
* *
@ -15,19 +16,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import $ from 'jquery';
import { $assert } from '@wisemapping/core-js';
import TestSuite from './TestSuite'; import TestSuite from './TestSuite';
import LayoutManager from '../../../src/components/layout/LayoutManager'; import LayoutManager from '../../../src/components/layout/LayoutManager';
const SymmetricTestSuite = new Class({ class SymmetricTestSuite extends TestSuite {
Extends: TestSuite, constructor() {
initialize() {
$('#symmetricTest').css('display', 'block'); $('#symmetricTest').css('display', 'block');
super();
this.testSymmetry(); this.testSymmetry();
this.testSymmetricPredict(); this.testSymmetricPredict();
this.testSymmetricDragPredict(); this.testSymmetricDragPredict();
}, }
testSymmetry() { testSymmetry() {
console.log('testSymmetry:'); console.log('testSymmetry:');
@ -92,7 +94,7 @@ const SymmetricTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testSymmetricPredict() { testSymmetricPredict() {
console.log('testSymmetricPredict:'); console.log('testSymmetricPredict:');
@ -276,7 +278,7 @@ const SymmetricTestSuite = new Class({
$assert(prediction5d.order == 0, 'Prediction order should be 0'); $assert(prediction5d.order == 0, 'Prediction order should be 0');
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testSymmetricDragPredict() { testSymmetricDragPredict() {
console.log('testSymmetricDragPredict:'); console.log('testSymmetricDragPredict:');
@ -345,7 +347,7 @@ const SymmetricTestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
}); }
export default SymmetricTestSuite; export default SymmetricTestSuite;

View File

@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* /*
* Copyright [2015] [wisemapping] * Copyright [2015] [wisemapping]
* *
@ -15,12 +16,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import $ from 'jquery';
import { $assert } from '@wisemapping/core-js';
import LayoutManager from '../../../src/components/layout/LayoutManager'; import LayoutManager from '../../../src/components/layout/LayoutManager';
import ChildrenSorterStrategy from '../../../src/components/layout/ChildrenSorterStrategy';
const TestSuite = new Class({ class TestSuite extends ChildrenSorterStrategy {
Extends: ChildrenSorterStrategy, constructor() {
super();
initialize() {
$('#basicTest').css('display', 'block'); $('#basicTest').css('display', 'block');
// this.testAligned(); // this.testAligned();
this.testBaselineAligned1(); this.testBaselineAligned1();
@ -32,7 +34,7 @@ const TestSuite = new Class({
this.testRemoveNode(); this.testRemoveNode();
this.testSize(); this.testSize();
this.testReconnectSingleNode(); this.testReconnectSingleNode();
}, }
testAligned() { testAligned() {
console.log('testAligned:'); console.log('testAligned:');
@ -79,7 +81,7 @@ const TestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testBaselineAligned1() { testBaselineAligned1() {
console.log('testBaselineAligned1:'); console.log('testBaselineAligned1:');
@ -125,7 +127,7 @@ const TestSuite = new Class({
// manager.plot("testBaselineAligned1", {width:1600,height:800}); // manager.plot("testBaselineAligned1", {width:1600,height:800});
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testBaselineAligned2() { testBaselineAligned2() {
console.log('testBaselineAligned2:'); console.log('testBaselineAligned2:');
@ -143,7 +145,7 @@ const TestSuite = new Class({
manager.plot('testBaselineAligned2', { width: 1600, height: 800 }); manager.plot('testBaselineAligned2', { width: 1600, height: 800 });
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testEvents() { testEvents() {
console.log('testEvents:'); console.log('testEvents:');
@ -181,7 +183,7 @@ const TestSuite = new Class({
$assert(events.length == 0, 'Unnecessary tree updated.'); $assert(events.length == 0, 'Unnecessary tree updated.');
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testEventsComplex() { testEventsComplex() {
console.log('testEventsComplex:'); console.log('testEventsComplex:');
@ -229,7 +231,7 @@ const TestSuite = new Class({
$assert(events.length == 4, 'Only 4 nodes should be repositioned.'); $assert(events.length == 4, 'Only 4 nodes should be repositioned.');
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testDisconnect() { testDisconnect() {
console.log('testDisconnect:'); console.log('testDisconnect:');
@ -290,7 +292,7 @@ const TestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testReconnect() { testReconnect() {
console.log('testReconnect:'); console.log('testReconnect:');
@ -352,7 +354,7 @@ const TestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testRemoveNode() { testRemoveNode() {
console.log('testRemoveNode:'); console.log('testRemoveNode:');
@ -422,7 +424,7 @@ const TestSuite = new Class({
$assert(manager.find(9).getOrder() == 3, 'Node 9 should have order 3'); $assert(manager.find(9).getOrder() == 3, 'Node 9 should have order 3');
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testSize() { testSize() {
console.log('testSize:'); console.log('testSize:');
@ -519,7 +521,7 @@ const TestSuite = new Class({
); );
console.log('OK!\n\n'); console.log('OK!\n\n');
}, }
testReconnectSingleNode() { testReconnectSingleNode() {
console.log('testReconnectSingleNode:'); console.log('testReconnectSingleNode:');
@ -552,7 +554,7 @@ const TestSuite = new Class({
'Node 1 should now be to the left of the root node', 'Node 1 should now be to the left of the root node',
); );
$assert(manager.find(1).getOrder() == 1, 'Node 1 should now have order 0'); $assert(manager.find(1).getOrder() == 1, 'Node 1 should now have order 0');
}, }
_plotPrediction(canvas, prediction) { _plotPrediction(canvas, prediction) {
if (!canvas) { if (!canvas) {
@ -570,10 +572,10 @@ const TestSuite = new Class({
const cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2; const cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2;
const cy = position.y + canvas.height / 2 - TestSuite.NODE_SIZE.height / 2; const cy = position.y + canvas.height / 2 - TestSuite.NODE_SIZE.height / 2;
canvas.rect(cx, cy, TestSuite.NODE_SIZE.width, TestSuite.NODE_SIZE.height); canvas.rect(cx, cy, TestSuite.NODE_SIZE.width, TestSuite.NODE_SIZE.height);
}, }
}); }
(TestSuite.NODE_SIZE = { width: 80, height: 30 }), TestSuite.NODE_SIZE = { width: 80, height: 30 };
(TestSuite.ROOT_NODE_SIZE = { width: 120, height: 40 }); TestSuite.ROOT_NODE_SIZE = { width: 120, height: 40 };
export default TestSuite; export default TestSuite;

View File

@ -4,6 +4,7 @@ import SymmetricTestSuite from './SymmetricTestSuite';
import FreeTestSuite from './FreeTestSuite'; import FreeTestSuite from './FreeTestSuite';
import Raphael from './lib/raphael-min'; import Raphael from './lib/raphael-min';
import { drawGrid } from './lib/raphael-plugins'; import { drawGrid } from './lib/raphael-plugins';
import '../../../src'; // TODO: remove this when removing mootools (hack used to load it as a side effect)
global.Raphael = Raphael; global.Raphael = Raphael;
global.Raphael.fn.drawGrid = drawGrid; global.Raphael.fn.drawGrid = drawGrid;

View File

@ -12,5 +12,6 @@
}, },
"persistenceManager": "mindplot.LocalStorageManager", "persistenceManager": "mindplot.LocalStorageManager",
"mapId": "welcome", "mapId": "welcome",
"container":"mindplot" "container":"mindplot",
"locale": "en"
} }

View File

@ -1,22 +1,14 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>WiseMapping - Editor </title> <title>WiseMapping - Editor </title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
<link rel="stylesheet/less" type="text/css" href="css/editor.less"/>
<script type='text/javascript' src='js/jquery.js'></script>
<script type="text/javascript" language="javascript" src="bootstrap/js/bootstrap.js"></script>
<script src="js/less.js" type="text/javascript"></script>
<link rel="icon" href="favicon.ico" type="image/x-icon"> <link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head> </head>
<body> <body>
<div id='load' class="modal fade"> <div id='load' class="modal fade">
@ -119,4 +111,5 @@
<div id="mindplot" onselectstart="return false;"></div> <div id="mindplot" onselectstart="return false;"></div>
</body> </body>
</html> </html>

View File

@ -1,50 +1,15 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>
<title>WiseMapping - Editor </title> <title>WiseMapping - Editor </title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<!--[if lt IE 9]>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<![endif]-->
<link rel="stylesheet/less" type="text/css" href="css/embedded.less"/>
<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/bootstrap.js'></script>
<script type='text/javascript' src='js/mootools-core.js'></script>
<script type='text/javascript' src='js/core.js'></script>
<script type='text/javascript' src='js/less.js'></script>
<link rel="icon" href="images/favicon.ico" type="image/x-icon"> <link rel="icon" href="images/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<script type="text/javascript">
var mapId = 'welcome';
$(document).on('loadcomplete', function(resource) {
// Options has been defined in by a external ile ?
var queryString = window.location.search;
var confUrl = queryString.replace("?confUrl=", "");
var options = loadDesignerOptions(confUrl);
var designer = buildDesigner(options);
// Load map from XML file persisted on disk...
var persistence = mindplot.PersistenceManager.getInstance();
var mindmap;
try {
mindmap = persistence.load(mapId);
} catch(e) {
// If the map could not be loaded, create a new empty map...
mindmap = mindplot.model.Mindmap.buildEmpty(mapId);
}
designer.loadMap(mindmap);
});
</script>
</head> </head>
<body>
<body>
<div id="header"> <div id="header">
<div id="headerInfo"> <div id="headerInfo">
@ -132,4 +97,5 @@
<div id="mindplot" onselectstart="return false;"></div> <div id="mindplot" onselectstart="return false;"></div>
</body> </body>
</html> </html>

View File

@ -1,187 +1,16 @@
/* import '../css/editor.less';
* Copyright [2015] [wisemapping] import { buildDesigner, loadDesignerOptions, loadExample } from './loader';
* import { PersistenceManager } from '../../../../src';
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import { Mindmap, PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/';
import $ from 'jquery'; const example = async () => {
global.jQuery = $; const mapId = 'welcome';
const options = await loadDesignerOptions();
let designer = null; const designer = buildDesigner(options);
/*
* Disclaimer: this global variable is a temporary workaround to Mootools' Browser class
* We need to avoid browser detection and replace it with feature detection,
* jquery recommends: http://www.modernizr.com/
*/
global.Browser = {
firefox: window.globalStorage,
ie: document.all && !window.opera,
ie6: !window.XMLHttpRequest,
ie7: document.all && window.XMLHttpRequest && !XDomainRequest && !window.opera,
ie8: document.documentMode == 8,
ie11: document.documentMode == 11,
opera: Boolean(window.opera),
chrome: Boolean(window.chrome),
safari: window.getComputedStyle && !window.globalStorage && !window.opera,
Platform: {
mac: navigator.platform.indexOf('Mac') != -1,
},
};
function buildDesigner(options) {
const container = $(`#${options.container}`);
$assert(container, 'container could not be null');
// Register load events ...
designer = new Designer(options, container);
designer.addEvent('loadSuccess', () => {
window.mindmapLoadReady = true;
console.log("Map loadded successfully");
});
const onerrorFn = function onerror(message, url, lineNo) {
// Ignore errors ...
if (message === 'Script error.' && lineNo == 0) {
// http://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-and-firefox
return;
}
// Transform error ...
let errorMsg = message;
if (typeof (message) === 'object' && message.srcElement && message.target) {
if (message.srcElement == '[object HTMLScriptElement]' && message.target == '[object HTMLScriptElement]') {
errorMsg = 'Error loading script';
} else {
errorMsg = `Event Error - target:${message.target} srcElement:${message.srcElement}`;
}
}
errorMsg = errorMsg.toString();
$.ajax({
method: 'post',
url: '/c/restful/logger/editor',
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
data: JSON.stringify({
jsErrorMsg: `Message: '${errorMsg}', line:'${lineNo}', url: :${url}`,
jsStack: window.event.error.stack || window.errorStack,
userAgent: navigator.userAgent,
mapId: options.mapId,
}),
});
// Close loading dialog ...
if (window.waitDialog) {
window.waitDialog.close();
window.waitDialog = null;
}
// Open error dialog only in case of mindmap loading errors. The rest of the error are reported but not display the dialog.
// Remove this in the near future.
if (!window.mindmapLoadReady) {
$notifyModal($msg('UNEXPECTED_ERROR_LOADING'));
}
};
window.onerror = onerrorFn;
// Configure default persistence manager ...
let persistence;
if (options.persistenceManager) {
if (typeof options.persistenceManager === 'string') {
const managerClass = /^mindplot\.(\w+)/.exec(options.persistenceManager);
if (managerClass){
persistence = new mindplot[managerClass[1]]('samples/{id}.xml');
} else {
persistence = eval(`new ${options.persistenceManager}()`);
}
} else {
persistence = options.persistenceManager;
}
} else {
persistence = new LocalStorageManager('samples/{id}.xml');
}
PersistenceManager.init(persistence);
// Register toolbar event ...
if ($('#toolbar')) {
const menu = new Menu(designer, 'toolbar', options.mapId, '');
// If a node has focus, focus can be move to another node using the keys.
designer._cleanScreen = function () {
menu.clear();
};
}
return designer;
}
function loadDesignerOptions(jsonConf) {
// Load map options ...
let result;
if (jsonConf) {
$.ajax({
url: jsonConf,
dataType: 'json',
async: false,
method: 'get',
success(options) {
result = options;
},
});
} else {
// Set workspace screen size as default. In this way, resize issues are solved.
const containerSize = {
height: parseInt(screen.height),
width: parseInt(screen.width),
};
const viewPort = {
height: parseInt(window.innerHeight - 70), // Footer and Header
width: parseInt(window.innerWidth),
};
result = {
readOnly: false,
zoom: 0.85,
saveOnLoad: true,
size: containerSize,
viewPort,
container: 'mindplot',
locale: 'en',
};
}
return result;
}
// Show loading dialog ...
$(() => {
import('../../../../../../libraries/bootstrap').then(() => {
// from viewmode.html ---------
var mapId = 'welcome';
// Set readonly option ...
var options = loadDesignerOptions();
// options.readOnly = true;
var designer = buildDesigner(options);
// Load map from XML file persisted on disk... // Load map from XML file persisted on disk...
const persistence = PersistenceManager.getInstance(); const persistence = PersistenceManager.getInstance();
var mindmap = persistence.load(mapId); const mindmap = persistence.load(mapId);
designer.loadMap(mindmap); designer.loadMap(mindmap);
// from viewmode.html --------- };
});
}); loadExample(example);

View File

@ -0,0 +1,25 @@
import '../css/embedded.less';
import { buildDesigner, loadDesignerOptions, loadExample } from './loader';
import { Mindmap, PersistenceManager } from '../../../../src';
const example = async () => {
const mapId = 'welcome';
// Options has been defined in by a external ile ?
const queryString = window.location.search;
const confUrl = queryString.replace('?confUrl=', '');
const options = await loadDesignerOptions(confUrl);
const designer = buildDesigner(options);
// Load map from XML file persisted on disk...
const persistence = PersistenceManager.getInstance();
let mindmap;
try {
mindmap = persistence.load(mapId);
} catch (e) {
console.error('The map could not be loaded, loading an empty map instead.', e);
mindmap = Mindmap.buildEmpty(mapId);
}
designer.loadMap(mindmap);
};
loadExample(example);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,167 @@
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import { PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/';
import * as mindplot from '../../../../src/';
import $ from 'jquery';
global.jQuery = $;
global.$ = $;
let designer = null;
/*
* Disclaimer: this global variable is a temporary workaround to Mootools' Browser class
* We need to avoid browser detection and replace it with feature detection,
* jquery recommends: http://www.modernizr.com/
*/
global.Browser = {
firefox: window.globalStorage,
ie: document.all && !window.opera,
ie6: !window.XMLHttpRequest,
ie7: document.all && window.XMLHttpRequest && !XDomainRequest && !window.opera,
ie8: document.documentMode == 8,
ie11: document.documentMode == 11,
opera: Boolean(window.opera),
chrome: Boolean(window.chrome),
safari: window.getComputedStyle && !window.globalStorage && !window.opera,
Platform: {
mac: navigator.platform.indexOf('Mac') != -1,
},
};
export function buildDesigner(options) {
const container = $(`#${options.container}`);
$assert(container, 'container could not be null');
// Register load events ...
designer = new Designer(options, container);
designer.addEvent('loadSuccess', () => {
window.mindmapLoadReady = true;
console.log('Map loadded successfully');
});
const onerrorFn = function onerror(message, url, lineNo) {
// Ignore errors ...
if (message === 'Script error.' && lineNo == 0) {
// http://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-and-firefox
return;
}
// Transform error ...
let errorMsg = message;
if (typeof message === 'object' && message.srcElement && message.target) {
if (
message.srcElement == '[object HTMLScriptElement]' &&
message.target == '[object HTMLScriptElement]'
) {
errorMsg = 'Error loading script';
} else {
errorMsg = `Event Error - target:${message.target} srcElement:${message.srcElement}`;
}
}
errorMsg = errorMsg.toString();
// Close loading dialog ...
if (window.waitDialog) {
window.waitDialog.close();
window.waitDialog = null;
}
// Open error dialog only in case of mindmap loading errors. The rest of the error are reported but not display the dialog.
// Remove this in the near future.
if (!window.mindmapLoadReady) {
$notifyModal($msg('UNEXPECTED_ERROR_LOADING'));
}
console.error(errorMsg, 'line:', lineNo, 'url:', url);
};
window.onerror = onerrorFn;
// Configure default persistence manager ...
let persistence;
if (options.persistenceManager) {
if (typeof options.persistenceManager === 'string') {
const managerClass = /^mindplot\.(\w+)/.exec(options.persistenceManager);
if (managerClass) {
persistence = new mindplot[managerClass[1]]('samples/{id}.xml');
} else {
persistence = eval(`new ${options.persistenceManager}()`);
}
} else {
persistence = options.persistenceManager;
}
} else {
persistence = new LocalStorageManager('samples/{id}.xml');
}
PersistenceManager.init(persistence);
// Register toolbar event ...
if ($('#toolbar').length) {
const menu = new Menu(designer, 'toolbar', options.mapId, '');
// If a node has focus, focus can be move to another node using the keys.
designer._cleanScreen = function () {
menu.clear();
};
}
return designer;
}
export async function loadDesignerOptions(jsonConf) {
// Load map options ...
let result;
if (jsonConf) {
result = await $.ajax({
url: jsonConf,
dataType: 'json',
method: 'get',
});
} else {
// Set workspace screen size as default. In this way, resize issues are solved.
const containerSize = {
height: parseInt(screen.height),
width: parseInt(screen.width),
};
const viewPort = {
height: parseInt(window.innerHeight - 70), // Footer and Header
width: parseInt(window.innerWidth),
};
result = {
readOnly: false,
zoom: 0.85,
saveOnLoad: true,
size: containerSize,
viewPort,
container: 'mindplot',
locale: 'en',
};
}
return result;
}
export function loadExample(exampleFn) {
$(() => {
// Hack: load bootstrap first
import('@libraries/bootstrap').then(exampleFn);
});
}

View File

@ -0,0 +1,24 @@
import '../css/embedded.less';
import { buildDesigner, loadDesignerOptions, loadExample } from './loader';
import { Mindmap, PersistenceManager } from '../../../../src';
const example = async () => {
const mapId = 'welcome';
// Set readonly option ...
const options = await loadDesignerOptions();
options.readOnly = true;
const designer = buildDesigner(options);
// Load map from XML file persisted on disk...
const persistence = PersistenceManager.getInstance();
let mindmap;
try {
mindmap = persistence.load(mapId);
} catch (e) {
console.error('The map could not be loaded, loading an empty map instead.', e);
mindmap = Mindmap.buildEmpty(mapId);
}
designer.loadMap(mindmap);
};
loadExample(example);

View File

@ -7,6 +7,8 @@ const CopyPlugin = require('copy-webpack-plugin');
module.exports = { module.exports = {
entry: { entry: {
layout: path.resolve(__dirname, './test/playground/layout/context-loader'), layout: path.resolve(__dirname, './test/playground/layout/context-loader'),
viewmode: path.resolve(__dirname, './test/playground/map-render/js/viewmode'),
embedded: path.resolve(__dirname, './test/playground/map-render/js/embedded'),
editor: path.resolve(__dirname, './test/playground/map-render/js/editor'), editor: path.resolve(__dirname, './test/playground/map-render/js/editor'),
}, },
output: { output: {
@ -35,9 +37,19 @@ module.exports = {
exclude: [ exclude: [
/node_modules/, /node_modules/,
path.resolve(__dirname, '../../libraries/mootools-core-1.4.5'), path.resolve(__dirname, '../../libraries/mootools-core-1.4.5'),
path.resolve(__dirname, '../../libraries/underscore-min'),
/lib\/raphael/ig, /lib\/raphael/ig,
], ],
}, },
{
test: /\.less$/i,
use: [
// compiles Less to CSS
'style-loader',
'css-loader?url=false',
'less-loader',
],
},
], ],
}, },
resolve: { resolve: {
@ -54,13 +66,13 @@ module.exports = {
{ from: 'test/playground/map-render/images/favicon.ico', to: 'favicon.ico' }, { from: 'test/playground/map-render/images/favicon.ico', to: 'favicon.ico' },
{ from: 'test/playground/map-render/images', to: 'images' }, { from: 'test/playground/map-render/images', to: 'images' },
{ from: 'test/playground/map-render/icons', to: 'icons' }, { from: 'test/playground/map-render/icons', to: 'icons' },
{ from: 'test/playground/map-render/css', to: 'css' },
{ from: 'test/playground/map-render/js', to: 'js' }, { from: 'test/playground/map-render/js', to: 'js' },
{ from: 'test/playground/map-render/samples', to: 'samples' }, { from: 'test/playground/map-render/samples', to: 'samples' },
{ from: 'test/playground/map-render/bootstrap', to: 'bootstrap' }, { from: 'test/playground/map-render/bootstrap', to: 'bootstrap' },
{ from: 'test/playground/index.html', to: 'index.html' }, { from: 'test/playground/index.html', to: 'index.html' },
{ from: 'test/playground/map-render/html/container.json', to: 'html/container.json' }, { from: 'test/playground/map-render/html/container.json', to: 'html/container.json' },
{ from: 'test/playground/map-render/html/container.html', to: 'container.html' }, { from: 'test/playground/map-render/html/container.html', to: 'container.html' },
{ from: 'test/playground/map-render/css/widget', to: 'css/widget' },
], ],
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
@ -69,12 +81,12 @@ module.exports = {
template: 'test/playground/layout/index.html', template: 'test/playground/layout/index.html',
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
chunks: ['editor'], chunks: ['viewmode'],
filename: 'viewmode.html', filename: 'viewmode.html',
template: 'test/playground/map-render/html/viewmode.html', template: 'test/playground/map-render/html/viewmode.html',
}), }),
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
chunks: ['editor'], chunks: ['embedded'],
filename: 'embedded.html', filename: 'embedded.html',
template: 'test/playground/map-render/html/embedded.html', template: 'test/playground/map-render/html/embedded.html',
}), }),

View File

@ -4199,6 +4199,13 @@ cookie@0.4.0:
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba"
integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==
copy-anything@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-2.0.3.tgz#842407ba02466b0df844819bbe3baebbe5d45d87"
integrity sha512-GK6QUtisv4fNS+XcI7shX0Gx9ORg7QqIznyfho79JTnX1XhLiyZHfftvGiziqzRiEi/Bjhgpi+D2o7HxJFPnDQ==
dependencies:
is-what "^3.12.0"
copy-concurrently@^1.0.0: copy-concurrently@^1.0.0:
version "1.0.5" version "1.0.5"
resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0" resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0"
@ -5055,7 +5062,7 @@ err-code@^1.0.0:
resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960" resolved "https://registry.yarnpkg.com/err-code/-/err-code-1.1.2.tgz#06e0116d3028f6aef4806849eb0ea6a748ae6960"
integrity sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA= integrity sha1-BuARbTAo9q70gGhJ6w6mp0iuaWA=
errno@^0.1.3: errno@^0.1.1, errno@^0.1.3:
version "0.1.8" version "0.1.8"
resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f" resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.8.tgz#8bb3e9c7d463be4976ff888f76b4809ebc2e811f"
integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A== integrity sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==
@ -6740,7 +6747,7 @@ hyphenate-style-name@^1.0.3:
resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d" resolved "https://registry.yarnpkg.com/hyphenate-style-name/-/hyphenate-style-name-1.0.4.tgz#691879af8e220aea5750e8827db4ef62a54e361d"
integrity sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ== integrity sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==
iconv-lite@0.4.24, iconv-lite@^0.4.24: iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4:
version "0.4.24" version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
@ -6802,6 +6809,11 @@ iltorb@^2.0.1:
prebuild-install "^5.3.3" prebuild-install "^5.3.3"
which-pm-runs "^1.0.0" which-pm-runs "^1.0.0"
image-size@~0.5.0:
version "0.5.5"
resolved "https://registry.yarnpkg.com/image-size/-/image-size-0.5.5.tgz#09dfd4ab9d20e29eb1c3e80b8990378df9e3cb9c"
integrity sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=
immer@^9.0.7: immer@^9.0.7:
version "9.0.7" version "9.0.7"
resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.7.tgz#b6156bd7db55db7abc73fd2fdadf4e579a701075" resolved "https://registry.yarnpkg.com/immer/-/immer-9.0.7.tgz#b6156bd7db55db7abc73fd2fdadf4e579a701075"
@ -7387,6 +7399,11 @@ is-weakref@^1.0.1:
dependencies: dependencies:
call-bind "^1.0.2" call-bind "^1.0.2"
is-what@^3.12.0:
version "3.14.1"
resolved "https://registry.yarnpkg.com/is-what/-/is-what-3.14.1.tgz#e1222f46ddda85dead0fd1c9df131760e77755c1"
integrity sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==
is-windows@^1.0.0, is-windows@^1.0.2: is-windows@^1.0.0, is-windows@^1.0.2:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
@ -7782,6 +7799,30 @@ lerna@^3.16.4:
import-local "^2.0.0" import-local "^2.0.0"
npmlog "^4.1.2" npmlog "^4.1.2"
less-loader@^10.2.0:
version "10.2.0"
resolved "https://registry.yarnpkg.com/less-loader/-/less-loader-10.2.0.tgz#97286d8797dc3dc05b1d16b0ecec5f968bdd4e32"
integrity sha512-AV5KHWvCezW27GT90WATaDnfXBv99llDbtaj4bshq6DvAihMdNjaPDcUMa6EXKLRF+P2opFenJp89BXg91XLYg==
dependencies:
klona "^2.0.4"
less@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/less/-/less-4.1.2.tgz#6099ee584999750c2624b65f80145f8674e4b4b0"
integrity sha512-EoQp/Et7OSOVu0aJknJOtlXZsnr8XE8KwuzTHOLeVSEx8pVWUICc8Q0VYRHgzyjX78nMEyC/oztWFbgyhtNfDA==
dependencies:
copy-anything "^2.0.1"
parse-node-version "^1.0.1"
tslib "^2.3.0"
optionalDependencies:
errno "^0.1.1"
graceful-fs "^4.1.2"
image-size "~0.5.0"
make-dir "^2.1.0"
mime "^1.4.1"
needle "^2.5.2"
source-map "~0.6.0"
levn@^0.3.0, levn@~0.3.0: levn@^0.3.0, levn@~0.3.0:
version "0.3.0" version "0.3.0"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
@ -8374,7 +8415,7 @@ mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.17, mime-types@~2.1.19,
dependencies: dependencies:
mime-db "1.51.0" mime-db "1.51.0"
mime@1.6.0: mime@1.6.0, mime@^1.4.1:
version "1.6.0" version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"
integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==
@ -8652,6 +8693,15 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
needle@^2.5.2:
version "2.9.1"
resolved "https://registry.yarnpkg.com/needle/-/needle-2.9.1.tgz#22d1dffbe3490c2b83e301f7709b6736cd8f2684"
integrity sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==
dependencies:
debug "^3.2.6"
iconv-lite "^0.4.4"
sax "^1.2.4"
negotiator@0.6.2: negotiator@0.6.2:
version "0.6.2" version "0.6.2"
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
@ -9318,6 +9368,11 @@ parse-json@^5.0.0:
json-parse-even-better-errors "^2.3.0" json-parse-even-better-errors "^2.3.0"
lines-and-columns "^1.1.6" lines-and-columns "^1.1.6"
parse-node-version@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parse-node-version/-/parse-node-version-1.0.1.tgz#e2b5dbede00e7fa9bc363607f53327e8b073189b"
integrity sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==
parse-path@^4.0.0: parse-path@^4.0.0:
version "4.0.3" version "4.0.3"
resolved "https://registry.yarnpkg.com/parse-path/-/parse-path-4.0.3.tgz#82d81ec3e071dcc4ab49aa9f2c9c0b8966bb22bf" resolved "https://registry.yarnpkg.com/parse-path/-/parse-path-4.0.3.tgz#82d81ec3e071dcc4ab49aa9f2c9c0b8966bb22bf"
@ -10617,6 +10672,11 @@ sass-loader@^10.1.0:
schema-utils "^3.0.0" schema-utils "^3.0.0"
semver "^7.3.2" semver "^7.3.2"
sax@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
scheduler@^0.20.2: scheduler@^0.20.2:
version "0.20.2" version "0.20.2"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91"
@ -11805,7 +11865,7 @@ tslib@^1.8.1, tslib@^1.9.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
tslib@^2.0.1, tslib@^2.0.3, tslib@^2.2.0: tslib@^2.0.1, tslib@^2.0.3, tslib@^2.2.0, tslib@^2.3.0:
version "2.3.1" version "2.3.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01"
integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==
@ -11933,6 +11993,11 @@ undefsafe@^2.0.5:
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==
underscore@^1.13.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1"
integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==
unicode-canonical-property-names-ecmascript@^2.0.0: unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc" resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"