Remove mootools as dependency.

This commit is contained in:
Paulo Veiga 2021-12-14 17:06:09 +00:00
parent 25b86f3cff
commit 75a153d1d5
47 changed files with 255 additions and 1107 deletions

View File

@ -1,802 +0,0 @@
/*
---
MooTools: the javascript framework
web build:
- http://mootools.net/core/b28139f033891d55fabb70ffafd6813b
packager build:
- packager build Core/Core Core/Array Core/Class Core/Class.Extras
copyrights:
- [MooTools](http://mootools.net)
licenses:
- [MIT License](http://mootools.net/license.txt)
...
*/
(function () {
this.MooTools = { version: '1.4.5', build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0' };
var o = (this.typeOf = function (i) {
if (i == null) {
return 'null';
}
if (i.$family != null) {
return i.$family();
}
if (i.nodeName) {
if (i.nodeType == 1) {
return 'element';
}
if (i.nodeType == 3) {
return /\S/.test(i.nodeValue) ? 'textnode' : 'whitespace';
}
} else {
if (typeof i.length == 'number') {
if (i.callee) {
return 'arguments';
}
if ('item' in i) {
return 'collection';
}
}
}
return typeof i;
});
var j = (this.instanceOf = function (t, i) {
if (t == null) {
return false;
}
var s = t.$constructor || t.constructor;
while (s) {
if (s === i) {
return true;
}
s = s.parent;
}
if (!t.hasOwnProperty) {
return false;
}
return t instanceof i;
});
var f = this.Function;
var p = true;
for (var k in { toString: 1 }) {
p = null;
}
if (p) {
p = [
'hasOwnProperty',
'valueOf',
'isPrototypeOf',
'propertyIsEnumerable',
'toLocaleString',
'toString',
'constructor',
];
}
f.prototype.overloadSetter = function (s) {
var i = this;
return function (u, t) {
if (u == null) {
return this;
}
if (s || typeof u != 'string') {
for (var v in u) {
i.call(this, v, u[v]);
}
if (p) {
for (var w = p.length; w--; ) {
v = p[w];
if (u.hasOwnProperty(v)) {
i.call(this, v, u[v]);
}
}
}
} else {
i.call(this, u, t);
}
return this;
};
};
f.prototype.overloadGetter = function (s) {
var i = this;
return function (u) {
var v, t;
if (typeof u != 'string') {
v = u;
} else {
if (arguments.length > 1) {
v = arguments;
} else {
if (s) {
v = [u];
}
}
}
if (v) {
t = {};
for (var w = 0; w < v.length; w++) {
t[v[w]] = i.call(this, v[w]);
}
} else {
t = i.call(this, u);
}
return t;
};
};
f.prototype.extend = function (i, s) {
this[i] = s;
}.overloadSetter();
f.prototype.implement = function (i, s) {
this.prototype[i] = s;
}.overloadSetter();
var n = Array.prototype.slice;
f.from = function (i) {
return o(i) == 'function'
? i
: function () {
return i;
};
};
Array.from = function (i) {
if (i == null) {
return [];
}
return a.isEnumerable(i) && typeof i != 'string' ? (o(i) == 'array' ? i : n.call(i)) : [i];
};
Number.from = function (s) {
var i = parseFloat(s);
return isFinite(i) ? i : null;
};
String.from = function (i) {
return i + '';
};
f.implement({
hide: function () {
this.$hidden = true;
return this;
},
protect: function () {
this.$protected = true;
return this;
},
});
var a = (this.Type = function (u, t) {
if (u) {
var s = u.toLowerCase();
var i = function (v) {
return o(v) == s;
};
a['is' + u] = i;
if (t != null) {
t.prototype.$family = function () {
return s;
}.hide();
}
}
if (t == null) {
return null;
}
t.extend(this);
t.$constructor = a;
t.prototype.$constructor = t;
return t;
});
var e = Object.prototype.toString;
a.isEnumerable = function (i) {
return i != null && typeof i.length == 'number' && e.call(i) != '[object Function]';
};
var q = {};
var r = function (i) {
var s = o(i.prototype);
return q[s] || (q[s] = []);
};
var b = function (t, x) {
if (x && x.$hidden) {
return;
}
var s = r(this);
for (var u = 0; u < s.length; u++) {
var w = s[u];
if (o(w) == 'type') {
b.call(w, t, x);
} else {
w.call(this, t, x);
}
}
var v = this.prototype[t];
if (v == null || !v.$protected) {
this.prototype[t] = x;
}
if (this[t] == null && o(x) == 'function') {
m.call(this, t, function (i) {
return x.apply(i, n.call(arguments, 1));
});
}
};
var m = function (i, t) {
if (t && t.$hidden) {
return;
}
var s = this[i];
if (s == null || !s.$protected) {
this[i] = t;
}
};
a.implement({
implement: b.overloadSetter(),
extend: m.overloadSetter(),
alias: function (i, s) {
b.call(this, i, this.prototype[s]);
}.overloadSetter(),
mirror: function (i) {
r(this).push(i);
return this;
},
});
new a('Type', a);
var d = function (s, x, v) {
var u = x != Object,
B = x.prototype;
if (u) {
x = new a(s, x);
}
for (var y = 0, w = v.length; y < w; y++) {
var C = v[y],
A = x[C],
z = B[C];
if (A) {
A.protect();
}
if (u && z) {
x.implement(C, z.protect());
}
}
if (u) {
var t = B.propertyIsEnumerable(v[0]);
x.forEachMethod = function (G) {
if (!t) {
for (var F = 0, D = v.length; F < D; F++) {
G.call(B, B[v[F]], v[F]);
}
}
for (var E in B) {
G.call(B, B[E], E);
}
};
}
return d;
};
d('String', String, [
'charAt',
'charCodeAt',
'concat',
'indexOf',
'lastIndexOf',
'match',
'quote',
'replace',
'search',
'slice',
'split',
'substr',
'substring',
'trim',
'toLowerCase',
'toUpperCase',
])('Array', Array, [
'pop',
'push',
'reverse',
'shift',
'sort',
'splice',
'unshift',
'concat',
'join',
'slice',
'indexOf',
'lastIndexOf',
'filter',
'forEach',
'every',
'map',
'some',
'reduce',
'reduceRight',
])('Number', Number, ['toExponential', 'toFixed', 'toLocaleString', 'toPrecision'])(
'Function',
f,
['apply', 'call', 'bind']
)('RegExp', RegExp, ['exec', 'test'])('Object', Object, [
'create',
'defineProperty',
'defineProperties',
'keys',
'getPrototypeOf',
'getOwnPropertyDescriptor',
'getOwnPropertyNames',
'preventExtensions',
'isExtensible',
'seal',
'isSealed',
'freeze',
'isFrozen',
])('Date', Date, ['now']);
Object.extend = m.overloadSetter();
Date.extend('now', function () {
return +new Date();
});
new a('Boolean', Boolean);
Number.prototype.$family = function () {
return isFinite(this) ? 'number' : 'null';
}.hide();
Number.extend('random', function (s, i) {
return Math.floor(Math.random() * (i - s + 1) + s);
});
var g = Object.prototype.hasOwnProperty;
Object.extend('forEach', function (i, t, u) {
for (var s in i) {
if (g.call(i, s)) {
t.call(u, i[s], s, i);
}
}
});
Object.each = Object.forEach;
Array.implement({
forEach: function (u, v) {
for (var t = 0, s = this.length; t < s; t++) {
if (t in this) {
u.call(v, this[t], t, this);
}
}
},
each: function (i, s) {
Array.forEach(this, i, s);
return this;
},
});
var l = function (i) {
switch (o(i)) {
case 'array':
return i.clone();
case 'object':
return Object.clone(i);
default:
return i;
}
};
Array.implement('clone', function () {
var s = this.length,
t = new Array(s);
while (s--) {
t[s] = l(this[s]);
}
return t;
});
var h = function (s, i, t) {
switch (o(t)) {
case 'object':
if (o(s[i]) == 'object') {
Object.merge(s[i], t);
} else {
s[i] = Object.clone(t);
}
break;
case 'array':
s[i] = t.clone();
break;
default:
s[i] = t;
}
return s;
};
Object.extend({
merge: function (z, u, t) {
if (o(u) == 'string') {
return h(z, u, t);
}
for (var y = 1, s = arguments.length; y < s; y++) {
var w = arguments[y];
for (var x in w) {
h(z, x, w[x]);
}
}
return z;
},
clone: function (i) {
var t = {};
for (var s in i) {
t[s] = l(i[s]);
}
return t;
},
append: function (w) {
for (var v = 1, t = arguments.length; v < t; v++) {
var s = arguments[v] || {};
for (var u in s) {
w[u] = s[u];
}
}
return w;
},
});
['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function (i) {
new a(i);
});
var c = Date.now();
String.extend('uniqueID', function () {
return (c++).toString(36);
});
})();
Array.implement({
every: function (c, d) {
for (var b = 0, a = this.length >>> 0; b < a; b++) {
if (b in this && !c.call(d, this[b], b, this)) {
return false;
}
}
return true;
},
filter: function (d, f) {
var c = [];
for (var e, b = 0, a = this.length >>> 0; b < a; b++) {
if (b in this) {
e = this[b];
if (d.call(f, e, b, this)) {
c.push(e);
}
}
}
return c;
},
indexOf: function (c, d) {
var b = this.length >>> 0;
for (var a = d < 0 ? Math.max(0, b + d) : d || 0; a < b; a++) {
if (this[a] === c) {
return a;
}
}
return -1;
},
map: function (c, e) {
var d = this.length >>> 0,
b = Array(d);
for (var a = 0; a < d; a++) {
if (a in this) {
b[a] = c.call(e, this[a], a, this);
}
}
return b;
},
some: function (c, d) {
for (var b = 0, a = this.length >>> 0; b < a; b++) {
if (b in this && c.call(d, this[b], b, this)) {
return true;
}
}
return false;
},
clean: function () {
return this.filter(function (a) {
return a != null;
});
},
invoke: function (a) {
var b = Array.slice(arguments, 1);
return this.map(function (c) {
return c[a].apply(c, b);
});
},
associate: function (c) {
var d = {},
b = Math.min(this.length, c.length);
for (var a = 0; a < b; a++) {
d[c[a]] = this[a];
}
return d;
},
link: function (c) {
var a = {};
for (var e = 0, b = this.length; e < b; e++) {
for (var d in c) {
if (c[d](this[e])) {
a[d] = this[e];
delete c[d];
break;
}
}
}
return a;
},
contains: function (a, b) {
return this.indexOf(a, b) != -1;
},
append: function (a) {
this.push.apply(this, a);
return this;
},
getLast: function () {
return this.length ? this[this.length - 1] : null;
},
getRandom: function () {
return this.length ? this[Number.random(0, this.length - 1)] : null;
},
include: function (a) {
if (!this.contains(a)) {
this.push(a);
}
return this;
},
combine: function (c) {
for (var b = 0, a = c.length; b < a; b++) {
this.include(c[b]);
}
return this;
},
erase: function (b) {
for (var a = this.length; a--; ) {
if (this[a] === b) {
this.splice(a, 1);
}
}
return this;
},
empty: function () {
this.length = 0;
return this;
},
flatten: function () {
var d = [];
for (var b = 0, a = this.length; b < a; b++) {
var c = typeOf(this[b]);
if (c == 'null') {
continue;
}
d = d.concat(
c == 'array' || c == 'collection' || c == 'arguments' || instanceOf(this[b], Array)
? Array.flatten(this[b])
: this[b]
);
}
return d;
},
pick: function () {
for (var b = 0, a = this.length; b < a; b++) {
if (this[b] != null) {
return this[b];
}
}
return null;
},
rgbToHex: function (d) {
if (this.length < 3) {
return null;
}
if (this.length == 4 && this[3] == 0 && !d) {
return 'transparent';
}
var b = [];
for (var a = 0; a < 3; a++) {
var c = (this[a] - 0).toString(16);
b.push(c.length == 1 ? '0' + c : c);
}
return d ? b : '#' + b.join('');
},
});
String.implement({
test: function (a, b) {
return (typeOf(a) == 'regexp' ? a : new RegExp('' + a, b)).test(this);
},
contains: function (a, b) {
return b ? (b + this + b).indexOf(b + a + b) > -1 : String(this).indexOf(a) > -1;
},
trim: function () {
return String(this).replace(/^\s+|\s+$/g, '');
},
clean: function () {
return String(this).replace(/\s+/g, ' ').trim();
},
camelCase: function () {
return String(this).replace(/-\D/g, function (a) {
return a.charAt(1).toUpperCase();
});
},
hyphenate: function () {
return String(this).replace(/[A-Z]/g, function (a) {
return '-' + a.charAt(0).toLowerCase();
});
},
capitalize: function () {
return String(this).replace(/\b[a-z]/g, function (a) {
return a.toUpperCase();
});
},
escapeRegExp: function () {
return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
},
rgbToHex: function (b) {
var a = String(this).match(/\d{1,3}/g);
return a ? a.rgbToHex(b) : null;
},
substitute: function (a, b) {
return String(this).replace(b || /\\?\{([^{}]+)\}/g, function (d, c) {
if (d.charAt(0) == '\\') {
return d.slice(1);
}
return a[c] != null ? a[c] : '';
});
},
});
Function.implement({
bind: function (e) {
var a = this,
b = arguments.length > 1 ? Array.slice(arguments, 1) : null,
d = function () {};
var c = function () {
var g = e,
h = arguments.length;
if (this instanceof c) {
d.prototype = a.prototype;
g = new d();
}
var f =
!b && !h
? a.call(g)
: a.apply(g, b && h ? b.concat(Array.slice(arguments)) : b || arguments);
return g == e ? f : g;
};
return c;
},
pass: function (b, c) {
var a = this;
if (b != null) {
b = Array.from(b);
}
return function () {
return a.apply(c, b || arguments);
};
},
delay: function (b, c, a) {
return setTimeout(this.pass(a == null ? [] : a, c), b);
},
});
Number.alias('each', 'times');
(function (b) {
var a = {};
b.each(function (c) {
if (!Number[c]) {
a[c] = function () {
return Math[c].apply(null, [this].concat(Array.from(arguments)));
};
}
});
Number.implement(a);
})([
'abs',
'acos',
'asin',
'atan',
'atan2',
'ceil',
'cos',
'exp',
'floor',
'log',
'max',
'min',
'pow',
'sin',
'sqrt',
'tan',
]);
(function () {
var a = (this.Class = new Type('Class', function (h) {
if (instanceOf(h, Function)) {
h = { initialize: h };
}
var g = function () {
e(this);
if (g.$prototyping) {
return this;
}
this.$caller = null;
var i = this.initialize ? this.initialize.apply(this, arguments) : this;
this.$caller = this.caller = null;
return i;
}
.extend(this)
.implement(h);
g.$constructor = a;
g.prototype.$constructor = g;
g.prototype.parent = c;
return g;
}));
var c = function () {
if (!this.$caller) {
throw new Error('The method "parent" cannot be called.');
}
var g = this.$caller.$name,
h = this.$caller.$owner.parent,
i = h ? h.prototype[g] : null;
if (!i) {
throw new Error('The method "' + g + '" has no parent.');
}
return i.apply(this, arguments);
};
var e = function (g) {
for (var h in g) {
var j = g[h];
switch (typeOf(j)) {
case 'object':
var i = function () {};
i.prototype = j;
g[h] = e(new i());
break;
case 'array':
g[h] = j.clone();
break;
}
}
return g;
};
var b = function (g, h, j) {
if (j.$origin) {
j = j.$origin;
}
var i = function () {
if (j.$protected && this.$caller == null) {
throw new Error('The method "' + h + '" cannot be called.');
}
var l = this.caller,
m = this.$caller;
this.caller = m;
this.$caller = i;
var k = j.apply(this, arguments);
this.$caller = m;
this.caller = l;
return k;
}.extend({ $owner: g, $origin: j, $name: h });
return i;
};
var f = function (h, i, g) {
if (a.Mutators.hasOwnProperty(h)) {
i = a.Mutators[h].call(this, i);
if (i == null) {
return this;
}
}
if (typeOf(i) == 'function') {
if (i.$hidden) {
return this;
}
this.prototype[h] = g ? i : b(this, h, i);
} else {
Object.merge(this.prototype, h, i);
}
return this;
};
var d = function (g) {
g.$prototyping = true;
var h = new g();
delete g.$prototyping;
return h;
};
a.implement('implement', f.overloadSetter());
a.Mutators = {
Extends: function (g) {
this.parent = g;
this.prototype = d(g);
},
Implements: function (g) {
Array.from(g).each(function (j) {
var h = new j();
for (var i in h) {
f.call(this, i, h[i], true);
}
}, this);
},
};
})();

View File

@ -8,12 +8,6 @@
"airbnb-base", "airbnb-base",
"plugin:cypress/recommended" "plugin:cypress/recommended"
], ],
"globals":{
"Class": "readonly",
"$": "readonly",
"$msg": "readonly",
"_": "readonly"
},
"plugins": ["only-warn"], "plugins": ["only-warn"],
"rules": { "rules": {
"no-underscore-dangle": "off", "no-underscore-dangle": "off",

View File

@ -34,8 +34,7 @@
"@wisemapping/core-js": "^0.0.1", "@wisemapping/core-js": "^0.0.1",
"@wisemapping/web2d": "^0.0.1", "@wisemapping/web2d": "^0.0.1",
"jest": "^27.4.3", "jest": "^27.4.3",
"jquery": "^3.6.0", "jquery": "^3.6.0"
"mootools": "1.4.5"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.14.6", "@babel/core": "^7.14.6",

View File

@ -16,6 +16,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { $assert, $defined } from "@wisemapping/core-js"; import { $assert, $defined } from "@wisemapping/core-js";
import EventBus from "./layout/EventBus";
class CommandContext { class CommandContext {
constructor(designer) { constructor(designer) {
@ -31,7 +32,7 @@ class CommandContext {
} }
const designerTopics = this._designer.getModel().getTopics(); const designerTopics = this._designer.getModel().getTopics();
const result = designerTopics.filter((topic) => topicsIds.contains(topic.getId())); const result = designerTopics.filter((topic) => topicsIds.includes(topic.getId()));
if (result.length !== topicsIds.length) { if (result.length !== topicsIds.length) {
const ids = designerTopics.map((topic) => topic.getId()); const ids = designerTopics.map((topic) => topic.getId());
@ -98,7 +99,7 @@ class CommandContext {
} }
const designerRel = this._designer.getModel().getRelationships(); const designerRel = this._designer.getModel().getRelationships();
return designerRel.filter((rel) => relIds.contains(rel.getId())); return designerRel.filter((rel) => relIds.includes(rel.getId()));
} }
/** */ /** */

View File

@ -78,10 +78,10 @@ class ControlPoint {
this._createControlPoint(); this._createControlPoint();
this._endPoint = []; this._endPoint = [];
this._orignalCtrlPoint = []; this._orignalCtrlPoint = [];
this._orignalCtrlPoint[0] = this._controls[0].clone(); this._orignalCtrlPoint[0] = { ...this._controls[0] };
this._orignalCtrlPoint[1] = this._controls[1].clone(); this._orignalCtrlPoint[1] = { ...this._controls[1] };
this._endPoint[0] = this._line.getLine().getFrom().clone(); this._endPoint[0] = { ...this._line.getLine().getFrom() };
this._endPoint[1] = this._line.getLine().getTo().clone(); this._endPoint[1] = { ...this._line.getLine().getTo() };
} }
redraw() { redraw() {

View File

@ -240,7 +240,7 @@ class DesignerKeyboard extends Keyboard {
$(document).on('keypress', (event) => { $(document).on('keypress', (event) => {
let keyCode; let keyCode;
// Firefox doesn't skip special keys for keypress event... // Firefox doesn't skip special keys for keypress event...
if (event.key && excludes.contains(event.key.toLowerCase())) { if (event.key && excludes.includes(event.key.toLowerCase())) {
return; return;
} }
// Sometimes Firefox doesn't contain keyCode value // Sometimes Firefox doesn't contain keyCode value

View File

@ -81,8 +81,8 @@ class DesignerModel extends Events {
* @return {Array.<mindplot.Relationship, mindplot.Topic>} all topics and relationships * @return {Array.<mindplot.Relationship, mindplot.Topic>} all topics and relationships
*/ */
getEntities() { getEntities() {
const result = [].append(this._topics); let result = [].concat(this._topics);
result.append(this._relationships); result = result.concat(this._relationships);
return result; return result;
} }
@ -92,7 +92,7 @@ class DesignerModel extends Events {
*/ */
removeTopic(topic) { removeTopic(topic) {
$assert(topic, 'topic can not be null'); $assert(topic, 'topic can not be null');
this._topics.erase(topic); this._topics = this._topics.filter((t) => t !== topic);
} }
/** /**
@ -101,7 +101,7 @@ class DesignerModel extends Events {
*/ */
removeRelationship(rel) { removeRelationship(rel) {
$assert(rel, 'rel can not be null'); $assert(rel, 'rel can not be null');
this._relationships.erase(rel); this._relationships = this._relationships.filter((r) => r !== rel);
} }
/** /**

View File

@ -59,8 +59,8 @@ class DragConnector {
// - Nodes that are collapsed // - Nodes that are collapsed
// - It's not part of the branch dragged itself // - It's not part of the branch dragged itself
topics = topics.filter((topic) => { topics = topics.filter((topic) => {
let result = draggedNode != topic; let result = draggedNode !== topic;
result = result && topic != draggedNode; result = result && topic !== draggedNode;
result = result && !topic.areChildrenShrunken() && !topic.isCollapsed(); result = result && !topic.areChildrenShrunken() && !topic.isCollapsed();
result = result && !draggedNode.isChildTopic(topic); result = result && !draggedNode.isChildTopic(topic);
return result; return result;

View File

@ -25,16 +25,24 @@ class Events {
return string.replace(/^on([A-Z])/, (full, first) => first.toLowerCase()); return string.replace(/^on([A-Z])/, (full, first) => first.toLowerCase());
} }
addEvent(type, fn, internal) { addEvent(typeName, fn, internal) {
type = Events._removeOn(type); const type = Events._removeOn(typeName);
this.$events[type] = (this.$events[type] || []).include(fn); // Add function had not been added yet
if (internal) fn.internal = true; const funByType = this.$events[type] ? this.$events[type] : [];
if (!funByType.includes(fn)) {
funByType.push(fn);
this.$events[type] = funByType;
}
// Mark reference ...
// eslint-disable-next-line no-param-reassign
fn.internal = Boolean(internal);
return this; return this;
} }
fireEvent(type, args, delay) { fireEvent(typeName, args, delay) {
type = Events._removeOn(type); const type = Events._removeOn(typeName);
const events = this.$events[type]; const events = this.$events[type];
if (!events) return this; if (!events) return this;
@ -42,16 +50,15 @@ class Events {
events.forEach(((fn) => { events.forEach(((fn) => {
if (delay) { if (delay) {
fn.delay(delay, this, args); fn.delay(delay, this, args);
} } else {
else {
fn.apply(this, args); fn.apply(this, args);
} }
}).bind(this)); }));
return this; return this;
} }
removeEvent(type, fn) { removeEvent(typeName, fn) {
type = Events._removeOn(type); const type = Events._removeOn(typeName);
const events = this.$events[type]; const events = this.$events[type];
if (events && !fn.internal) { if (events && !fn.internal) {
const index = events.indexOf(fn); const index = events.indexOf(fn);

View File

@ -15,6 +15,7 @@
* 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.
*/ */
// eslint-disable-next-line max-classes-per-file
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 IconGroupRemoveTip from './IconGroupRemoveTip';
@ -22,14 +23,6 @@ import IconGroupRemoveTip from './IconGroupRemoveTip';
import Icon from './Icon'; import Icon from './Icon';
class IconGroup { class IconGroup {
/** @lends IconGroup */
/**
* @constructs
* @param topicId
* @param iconSize
* @throws will throw an error if topicId is null or undefined
* @throws will throw an error if iconSize is null or undefined
*/
constructor(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');
@ -43,7 +36,7 @@ class IconGroup {
coordSizeWidth: 0, coordSizeWidth: 0,
coordSizeHeight: 100, coordSizeHeight: 100,
}); });
this._removeTip = new IconGroup.RemoveTip(this._group, topicId); this._removeTip = new IconGroupRemoveTip(this._group, topicId);
this.seIconSize(iconSize, iconSize); this.seIconSize(iconSize, iconSize);
this._registerListeners(); this._registerListeners();
@ -111,7 +104,7 @@ class IconGroup {
}); });
if (result == null) { if (result == null) {
throw new Error(`Icon can no be found:${iconModel.getId()}, Icons:${this._icons}`); throw new Error(`Icon can no be found:${iconModel.getId()} Icons:${this._icons}`);
} }
return result; return result;
@ -131,7 +124,7 @@ class IconGroup {
this._removeTip.close(0); this._removeTip.close(0);
this._group.removeChild(icon.getImage()); this._group.removeChild(icon.getImage());
this._icons.erase(icon); this._icons = this._icons.filter((i) => i !== icon);
this._resize(this._icons.length); this._resize(this._icons.length);
const me = this; const me = this;
@ -164,7 +157,6 @@ class IconGroup {
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(
@ -181,6 +173,4 @@ class IconGroup {
*/ */
IconGroup.ICON_PADDING = 5; IconGroup.ICON_PADDING = 5;
IconGroup.RemoveTip = IconGroupRemoveTip;
export default IconGroup; export default IconGroup;

View File

@ -22,7 +22,7 @@ export default class RemoveTip {
$assert(icon, 'icon can not be null'); $assert(icon, 'icon can not be null');
// Nothing to do ... // Nothing to do ...
if (this._activeIcon != icon) { if (this._activeIcon !== icon) {
// If there is an active icon, close it first ... // If there is an active icon, close it first ...
if (this._activeIcon) { if (this._activeIcon) {
this.close(0); this.close(0);
@ -82,10 +82,10 @@ export default class RemoveTip {
me._closeTimeoutId = null; me._closeTimeoutId = null;
}; };
if (!$defined(delay) || delay == 0) { if (!$defined(delay) || delay === 0) {
close(); close();
} else { } else {
this._closeTimeoutId = close.delay(delay); this._closeTimeoutId = $(close).delay(delay);
} }
} }
} }

View File

@ -1,10 +1,14 @@
class Options { class Options {
setOptions() { setOptions(...args) {
const options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments)); this.options = { ...this.options, ...args };
const { options } = this;
if (this.addEvent) { if (this.addEvent) {
for (const option in options) { for (const option in options) {
if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; if (typeof (options[option]) != 'function' || !(/^on[A-Z]/).test(option) ){
continue;
}
this.addEvent(option, options[option]); this.addEvent(option, options[option]);
delete options[option]; delete options[option];
} }

View File

@ -65,11 +65,11 @@ class Relationship extends ConnectionLine {
// Position the line ... // Position the line ...
if ($defined(model.getSrcCtrlPoint())) { if ($defined(model.getSrcCtrlPoint())) {
const srcPoint = model.getSrcCtrlPoint().clone(); const srcPoint = { ...model.getSrcCtrlPoint() };
this.setSrcControlPoint(srcPoint); this.setSrcControlPoint(srcPoint);
} }
if ($defined(model.getDestCtrlPoint())) { if ($defined(model.getDestCtrlPoint())) {
const destPoint = model.getDestCtrlPoint().clone(); const destPoint = { ...model.getDestCtrlPoint() };
this.setDestControlPoint(destPoint); this.setDestControlPoint(destPoint);
} }
} }

View File

@ -355,7 +355,7 @@ class Topic extends NodeGraph {
/** */ /** */
deleteRelationship(relationship) { deleteRelationship(relationship) {
this._relationships.erase(relationship); this._relationships = this._relationships.filter((r) => r !== relationship);
} }
/** */ /** */
@ -1186,7 +1186,7 @@ class Topic extends NodeGraph {
/** */ /** */
removeChild(child) { removeChild(child) {
const children = this.getChildren(); const children = this.getChildren();
children.erase(child); this._children = children.filter((c) => c !== child);
} }
/** */ /** */

View File

@ -75,7 +75,7 @@ class AddTopicCommand extends Command {
// Delete disconnected the nodes. Create a copy of the topics ... // Delete disconnected the nodes. Create a copy of the topics ...
const clonedModel = []; const clonedModel = [];
this._models.forEach((model) => { this._models.forEach((model) => {
clonedModel.push(model.clone()); clonedModel.push({ ...model });
}); });
// Finally, remove the nodes ... // Finally, remove the nodes ...

View File

@ -53,14 +53,14 @@ class DeleteCommand extends Command {
// Delete relationships // Delete relationships
const relationships = this._collectInDepthRelationships(topic); const relationships = this._collectInDepthRelationships(topic);
this._deletedRelModel.append(relationships.map((rel) => rel.getModel().clone())); this._deletedRelModel.append(relationships.map((rel) => ({ ...rel.getModel() })));
relationships.forEach((relationship) => { relationships.forEach((relationship) => {
commandContext.deleteRelationship(relationship); commandContext.deleteRelationship(relationship);
}); });
// Store information for undo ... // Store information for undo ...
const clonedModel = model.clone(); const clonedModel = { ...model };
this._deletedTopicModels.push(clonedModel); this._deletedTopicModels.push(clonedModel);
const outTopic = topic.getOutgoingConnectedTopic(); const outTopic = topic.getOutgoingConnectedTopic();
let outTopicId = null; let outTopicId = null;
@ -77,9 +77,9 @@ class DeleteCommand extends Command {
const rels = commandContext.findRelationships(this._relIds); const rels = commandContext.findRelationships(this._relIds);
if (rels.length > 0) { if (rels.length > 0) {
rels.forEach(((rel) => { rels.forEach(((rel) => {
this._deletedRelModel.push(rel.getModel().clone()); this._deletedRelModel.push({ ...rel.getModel() });
commandContext.deleteRelationship(rel); commandContext.deleteRelationship(rel);
}).bind(this)); }));
} }
} }
@ -102,7 +102,7 @@ class DeleteCommand extends Command {
const parentTopics = commandContext.findTopics(parentId); const parentTopics = commandContext.findTopics(parentId);
commandContext.connect(topics[0], parentTopics[0]); commandContext.connect(topics[0], parentTopics[0]);
} }
}).bind(this)); }));
// Add rebuild relationships ... // Add rebuild relationships ...
this._deletedRelModel.forEach((model) => { this._deletedRelModel.forEach((model) => {
@ -135,7 +135,7 @@ class DeleteCommand extends Command {
let parent = topic.getParent(); let parent = topic.getParent();
let found = false; let found = false;
while (parent != null && !found) { while (parent != null && !found) {
found = topicIds.contains(parent.getId()); found = topicIds.includes(parent.getId());
if (found) { if (found) {
break; break;
} }
@ -152,12 +152,10 @@ class DeleteCommand extends Command {
_collectInDepthRelationships(topic) { _collectInDepthRelationships(topic) {
let result = []; let result = [];
result.append(topic.getRelationships()); result = result.concat(topic.getRelationships());
const children = topic.getChildren(); const children = topic.getChildren();
const rels = children.map(function (topic) { const rels = children.map(((t) => this._collectInDepthRelationships(t)));
return this._collectInDepthRelationships(topic);
}, this);
result.append(rels.flatten()); result.append(rels.flatten());
if (result.length > 0) { if (result.length > 0) {

View File

@ -37,17 +37,17 @@ class MoveControlPointCommand extends Command {
super(); super();
this._ctrlPointControler = ctrlPointController; this._ctrlPointControler = ctrlPointController;
this._line = ctrlPointController._line; this._line = ctrlPointController._line;
this._controlPoint = this._ctrlPointControler.getControlPoint(point).clone(); this._controlPoint = { ...this._ctrlPointControler.getControlPoint(point) };
this._oldControlPoint = this._ctrlPointControler.getOriginalCtrlPoint(point).clone(); this._oldControlPoint = { ...this._ctrlPointControler.getOriginalCtrlPoint(point) };
this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point).clone(); this._originalEndPoint = this._ctrlPointControler.getOriginalEndPoint(point);
switch (point) { switch (point) {
case 0: case 0:
this._wasCustom = this._line.getLine().isSrcControlPointCustom(); this._wasCustom = this._line.getLine().isSrcControlPointCustom();
this._endPoint = this._line.getLine().getFrom().clone(); this._endPoint = { ...this._line.getLine().getFrom() };
break; break;
case 1: case 1:
this._wasCustom = this._line.getLine().isDestControlPointCustom(); this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._endPoint = this._line.getLine().getTo().clone(); this._endPoint = { ...this._line.getLine().getTo() };
break; break;
default: default:
break; break;
@ -62,17 +62,17 @@ class MoveControlPointCommand extends Command {
const model = this._line.getModel(); const model = this._line.getModel();
switch (this._point) { switch (this._point) {
case 0: case 0:
model.setSrcCtrlPoint(this._controlPoint.clone()); model.setSrcCtrlPoint({ ...this._controlPoint });
this._line.setFrom(this._endPoint.x, this._endPoint.y); this._line.setFrom(this._endPoint.x, this._endPoint.y);
this._line.setIsSrcControlPointCustom(true); this._line.setIsSrcControlPointCustom(true);
this._line.setSrcControlPoint(this._controlPoint.clone()); this._line.setSrcControlPoint({ ...this._controlPoint });
break; break;
case 1: case 1:
model.setDestCtrlPoint(this._controlPoint.clone()); model.setDestCtrlPoint({ ...this._controlPoint });
this._wasCustom = this._line.getLine().isDestControlPointCustom(); this._wasCustom = this._line.getLine().isDestControlPointCustom();
this._line.setTo(this._endPoint.x, this._endPoint.y); this._line.setTo(this._endPoint.x, this._endPoint.y);
this._line.setIsDestControlPointCustom(true); this._line.setIsDestControlPointCustom(true);
this._line.setDestControlPoint(this._controlPoint.clone()); this._line.setDestControlPoint({ ...this._controlPoint });
break; break;
default: default:
break; break;
@ -95,16 +95,16 @@ class MoveControlPointCommand extends Command {
case 0: case 0:
if ($defined(this._oldControlPoint)) { if ($defined(this._oldControlPoint)) {
line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y); line.setFrom(this._originalEndPoint.x, this._originalEndPoint.y);
model.setSrcCtrlPoint(this._oldControlPoint.clone()); model.setSrcCtrlPoint({ ...this._oldControlPoint });
line.setSrcControlPoint(this._oldControlPoint.clone()); line.setSrcControlPoint({ ...this._oldControlPoint });
line.setIsSrcControlPointCustom(this._wasCustom); line.setIsSrcControlPointCustom(this._wasCustom);
} }
break; break;
case 1: case 1:
if ($defined(this._oldControlPoint)) { if ($defined(this._oldControlPoint)) {
line.setTo(this._originalEndPoint.x, this._originalEndPoint.y); line.setTo(this._originalEndPoint.x, this._originalEndPoint.y);
model.setDestCtrlPoint(this._oldControlPoint.clone()); model.setDestCtrlPoint({ ...this._oldControlPoint });
line.setDestControlPoint(this._oldControlPoint.clone()); line.setDestControlPoint({ ...this._oldControlPoint });
line.setIsDestControlPointCustom(this._wasCustom); line.setIsDestControlPointCustom(this._wasCustom);
} }
break; break;

View File

@ -23,13 +23,6 @@ import ChildrenSorterStrategy from './ChildrenSorterStrategy';
* @extends mindplot.layout.ChildrenSorterStrategy * @extends mindplot.layout.ChildrenSorterStrategy
*/ */
class AbstractBasicSorter extends ChildrenSorterStrategy { class AbstractBasicSorter extends ChildrenSorterStrategy {
/** @lends AbstractBasicSorter */
/**
* @param {} treeSet
* @param {} node
* @return the height of a node and its children if existing and not shrunken
*/
computeChildrenIdByHeights(treeSet, node) { computeChildrenIdByHeights(treeSet, node) {
const result = {}; const result = {};
this._computeChildrenHeight(treeSet, node, result); this._computeChildrenHeight(treeSet, node, result);

View File

@ -20,19 +20,6 @@ import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter'; import AbstractBasicSorter from './AbstractBasicSorter';
class BalancedSorter extends AbstractBasicSorter { class BalancedSorter extends AbstractBasicSorter {
/** @lends BalancedSorter */
/**
* @constructs
* @extends mindplot.layout.AbstractBasicSorter
*/
/**
* @param {} graph
* @param {} parent
* @param {} node
* @param {} position
* @param {Boolean} free
* @return an array with order and position
*/
predict(graph, parent, node, position, free) { predict(graph, parent, node, position, free) {
// If its a free node... // If its a free node...
if (free) { if (free) {
@ -42,8 +29,8 @@ class BalancedSorter extends AbstractBasicSorter {
); );
$assert($defined(node), 'node cannot be null for predict in free positioning'); $assert($defined(node), 'node cannot be null for predict in free positioning');
var rootNode = graph.getRootNode(parent); const rootNode = graph.getRootNode(parent);
var direction = this._getRelativeDirection( const direction = this._getRelativeDirection(
rootNode.getPosition(), rootNode.getPosition(),
node.getPosition(), node.getPosition(),
); );
@ -65,7 +52,7 @@ class BalancedSorter extends AbstractBasicSorter {
return [0, { x: xPos, y: position.y }]; return [0, { x: xPos, y: position.y }];
} }
var rootNode = graph.getRootNode(parent); const rootNode = graph.getRootNode(parent);
// If it is a dragged node... // If it is a dragged node...
if (node) { if (node) {
@ -86,9 +73,10 @@ class BalancedSorter extends AbstractBasicSorter {
} }
} }
let right; let left;
if (!position) { if (!position) {
var right = this._getChildrenForOrder(parent, graph, 0); right = this._getChildrenForOrder(parent, graph, 0);
var left = this._getChildrenForOrder(parent, graph, 1); left = this._getChildrenForOrder(parent, graph, 1);
} }
// Filter nodes on one side.. // Filter nodes on one side..
const order = position const order = position
@ -101,7 +89,7 @@ class BalancedSorter extends AbstractBasicSorter {
var direction = order % 2 == 0 ? 1 : -1; var direction = order % 2 == 0 ? 1 : -1;
// Exclude the dragged node (if set) // Exclude the dragged node (if set)
const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child != node); const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child !== node);
// No children? // No children?
if (children.length == 0) { if (children.length == 0) {
@ -120,7 +108,7 @@ class BalancedSorter extends AbstractBasicSorter {
// Try to fit within ... // Try to fit within ...
let result = null; let result = null;
const last = children.getLast(); const last = children[children.length - 1];
position = position || { x: last.getPosition().x, y: last.getPosition().y + 1 }; position = position || { x: last.getPosition().x, y: last.getPosition().y + 1 };
children.forEach((child, index) => { children.forEach((child, index) => {
const cpos = child.getPosition(); const cpos = child.getPosition();
@ -303,7 +291,7 @@ class BalancedSorter extends AbstractBasicSorter {
} }
_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() {

View File

@ -16,7 +16,6 @@
* 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.
*/ */
class ChildrenSorterStrategy {/** @lends ChildrenSorterStrategy */ class ChildrenSorterStrategy {/** @lends ChildrenSorterStrategy */
/** /**
* @constructs * @constructs

View File

@ -17,10 +17,7 @@
*/ */
import EventBus from './EventBus'; import EventBus from './EventBus';
class EventBusDispatcher {/** @lends EventBusDispatcher */ class EventBusDispatcher {
/**
* @constructs
*/
constructor() { constructor() {
this.registerBusEvents(); this.registerBusEvents();
} }

View File

@ -22,12 +22,7 @@ import AbstractBasicSorter from './AbstractBasicSorter';
* @class * @class
* @extends mindplot.layout.AbstractBasicSorter * @extends mindplot.layout.AbstractBasicSorter
*/ */
class GridSorter extends AbstractBasicSorter {/** @lends GridSorter */ class GridSorter extends AbstractBasicSorter {
/**
* @param {} treeSet
* @param {} node
* @return offsets
*/
computeOffsets(treeSet, node) { computeOffsets(treeSet, node) {
$assert(treeSet, 'treeSet can no be null.'); $assert(treeSet, 'treeSet can no be null.');
$assert(node, 'node can no be null.'); $assert(node, 'node can no be null.');

View File

@ -18,18 +18,6 @@
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
class Node { class Node {
/** @lends Node */
/**
* @constructs
* @param id
* @param size
* @param position
* @param sorter
* @throws will throw an error if id is not a finite number or is null or undefined
* @throws will throw an error if size 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
*/
constructor(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');
@ -141,7 +129,7 @@ class Node {
/** */ /** */
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', { ...size });
} }
/** */ /** */
@ -245,5 +233,4 @@ class Node {
} }
} }
export default Node; export default Node;

View File

@ -77,7 +77,7 @@ class OriginalLayout {
/** */ /** */
layout() { layout() {
const roots = this._treeSet.getTreeRoots(); const roots = this._treeSet.getTreeRoots();
roots.each(((node) => { roots.forEach(((node) => {
// Calculate all node heights ... // Calculate all node heights ...
const sorter = node.getSorter(); const sorter = node.getSorter();
@ -109,7 +109,7 @@ class OriginalLayout {
const parentPosition = node.getPosition(); const parentPosition = node.getPosition();
const me = this; const me = this;
children.each((child) => { children.forEach((child) => {
const offset = offsetById[child.getId()]; const offset = offsetById[child.getId()];
const childFreeDisplacement = child.getFreeDisplacement(); const childFreeDisplacement = child.getFreeDisplacement();
@ -143,7 +143,7 @@ class OriginalLayout {
} }
// Continue reordering the children nodes ... // Continue reordering the children nodes ...
children.each(((child) => { children.forEach(((child) => {
this._layoutChildren(child, heightById); this._layoutChildren(child, heightById);
})); }));
} }
@ -198,7 +198,7 @@ class OriginalLayout {
if (node.isFree()) { if (node.isFree()) {
this._shiftBranches(node, heightById); this._shiftBranches(node, heightById);
} }
children.each(((child) => { children.forEach(((child) => {
this._fixOverlapping(child, heightById); this._fixOverlapping(child, heightById);
})); }));
} }
@ -211,27 +211,25 @@ class OriginalLayout {
node.getFreeDisplacement().y, node.getFreeDisplacement().y,
); );
siblingsToShift.each(((sibling) => { siblingsToShift.forEach(((sibling) => {
const overlappingOccurs = shiftedBranches.some(((shiftedBranch) =>{ const overlappingOccurs = shiftedBranches.some(((shiftedBranch) => OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById)));
return OriginalLayout._branchesOverlap(shiftedBranch, sibling, heightById);
}).bind(this));
if (!sibling.isFree() || overlappingOccurs) { if (!sibling.isFree() || overlappingOccurs) {
const sAmount = node.getFreeDisplacement().y; const sAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(sibling, 0, sAmount); this._treeSet.shiftBranchPosition(sibling, 0, sAmount);
shiftedBranches.push(sibling); shiftedBranches.push(sibling);
} }
}).bind(this)); }));
const branchesToShift = this._treeSet const branchesToShift = this._treeSet
.getBranchesInVerticalDirection(node, node.getFreeDisplacement().y) .getBranchesInVerticalDirection(node, node.getFreeDisplacement().y)
.filter((branch) => !shiftedBranches.contains(branch)); .filter((branch) => !shiftedBranches.includes(branch));
branchesToShift.each(((branch) =>{ branchesToShift.forEach(((branch) => {
const bAmount = node.getFreeDisplacement().y; const bAmount = node.getFreeDisplacement().y;
this._treeSet.shiftBranchPosition(branch, 0, bAmount); this._treeSet.shiftBranchPosition(branch, 0, bAmount);
shiftedBranches.push(branch); shiftedBranches.push(branch);
}).bind(this)); }));
} }
static _branchesOverlap(branchA, branchB, heightById) { static _branchesOverlap(branchA, branchB, heightById) {

View File

@ -18,8 +18,6 @@
import { $assert, $defined } from '@wisemapping/core-js'; import { $assert, $defined } from '@wisemapping/core-js';
class RootedTreeSet { class RootedTreeSet {
/** @lends RootedTreeSet */
/** @constructs */
constructor() { constructor() {
this._rootNodes = []; this._rootNodes = [];
} }
@ -53,7 +51,7 @@ class RootedTreeSet {
$assert(node, 'node can not be null'); $assert(node, 'node can not be null');
$assert( $assert(
!this.find(node.getId(), false), !this.find(node.getId(), false),
`node already exits with this id. Id:${node.getId()}`, `node already exits with this id. Id:${node.getId()}: ${this.dump()}`,
); );
$assert(!node._children, 'node already added'); $assert(!node._children, 'node already added');
this._rootNodes.push(this._decodate(node)); this._rootNodes.push(this._decodate(node));
@ -66,7 +64,7 @@ class RootedTreeSet {
remove(nodeId) { remove(nodeId) {
$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 = this._rootNodes.filter((n) => n !== node);
} }
/** /**
@ -89,7 +87,7 @@ class RootedTreeSet {
parent._children.push(child); parent._children.push(child);
child._parent = parent; child._parent = parent;
this._rootNodes.erase(child); this._rootNodes = this._rootNodes.filter((c) => c !== child);
} }
/** /**
@ -102,7 +100,7 @@ class RootedTreeSet {
const node = this.find(nodeId); const node = this.find(nodeId);
$assert(node._parent, 'Node is not connected'); $assert(node._parent, 'Node is not connected');
node._parent._children.erase(node); node._parent._children = node._parent._children.filter((n)=> node !== n);
this._rootNodes.push(node); this._rootNodes.push(node);
node._parent = null; node._parent = null;
} }
@ -301,7 +299,7 @@ class RootedTreeSet {
`${node.getId()}[${order}]`, `${node.getId()}[${order}]`,
); );
text.attr('fill', '#FFF'); text.attr('fill', '#FFF');
const fillColor = this._rootNodes.contains(node) const fillColor = this._rootNodes.includes(node)
? '#000' ? '#000'
: node.isFree() : node.isFree()
? '#abc' ? '#abc'
@ -321,11 +319,11 @@ class RootedTreeSet {
node.getOrder() node.getOrder()
}, position:(${ }, position:(${
rectPosition.x rectPosition.x
},${ }, ${
rectPosition.y rectPosition.y
}), size:${ }), size:${
rectSize.width rectSize.width
}x${ },${
rectSize.height rectSize.height
}, freeDisplacement:(${ }, freeDisplacement:(${
node.getFreeDisplacement().x node.getFreeDisplacement().x

View File

@ -19,8 +19,6 @@ import { $assert, $defined } from '@wisemapping/core-js';
import AbstractBasicSorter from './AbstractBasicSorter'; import AbstractBasicSorter from './AbstractBasicSorter';
class SymmetricSorter extends AbstractBasicSorter { class SymmetricSorter extends AbstractBasicSorter {
/** @lends SymmetricSorter */
/** /**
* Predict the order and position of a dragged node. * Predict the order and position of a dragged node.
* *
@ -37,10 +35,8 @@ class SymmetricSorter extends AbstractBasicSorter {
// If its a free node... // If its a free node...
if (free) { if (free) {
$assert( $assert($defined(position),
$defined(position), 'position cannot be null for predict in free positioning');
'position cannot be null for predict in free positioning',
);
$assert($defined(node), 'node cannot be null for predict in free positioning'); $assert($defined(node), 'node cannot be null for predict in free positioning');
const direction = this._getRelativeDirection( const direction = this._getRelativeDirection(
@ -71,14 +67,14 @@ class SymmetricSorter extends AbstractBasicSorter {
parent.getPosition(), parent.getPosition(),
); );
var position = { const result = {
x: x:
parent.getPosition().x parent.getPosition().x
+ parentDirection + parentDirection
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING), * (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y, y: parent.getPosition().y,
}; };
return [graph.getChildren(parent).length, position]; return [graph.getChildren(parent).length, result];
} }
// If it is a dragged node... // If it is a dragged node...
@ -91,44 +87,42 @@ class SymmetricSorter extends AbstractBasicSorter {
const siblings = graph.getSiblings(node); const siblings = graph.getSiblings(node);
// node has no siblings and its trying to reconnect to its own parent // node has no siblings and its trying to reconnect to its own parent
const sameParent = parent == graph.getParent(node); const sameParent = parent === graph.getParent(node);
if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) { if (siblings.length == 0 && nodeDirection == positionDirection && sameParent) {
return [node.getOrder(), node.getPosition()]; return [node.getOrder(), node.getPosition()];
} }
const parentChildren = graph.getChildren(parent); const parentChildren = graph.getChildren(parent);
if (parentChildren.length === 0) {
if (parentChildren.length == 0) {
// Fit as a child of the parent node... // Fit as a child of the parent node...
var position = { const result = {
x: x: parent.getPosition().x + positionDirection * (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
parent.getPosition().x
+ positionDirection
* (parent.getSize().width + SymmetricSorter.INTERNODE_HORIZONTAL_PADDING),
y: parent.getPosition().y, y: parent.getPosition().y,
}; };
return [0, position];
return [0, result];
} }
// Try to fit within ... // Try to fit within ...
const result = null; const last = parentChildren[parentChildren.length - 1];
const last = parentChildren.getLast();
for (let i = 0; i < parentChildren.length; i++) { for (let i = 0; i < parentChildren.length; i++) {
const parentChild = parentChildren[i]; const parentChild = parentChildren[i];
const nodeAfter = i + 1 == parentChild.length ? null : parentChildren[i + 1]; const nodeAfter = i + 1 === parentChild.length ? null : parentChildren[i + 1];
// Fit at the bottom // Fit at the bottom
if (!nodeAfter && position.y > parentChild.getPosition().y) { if (!nodeAfter && position.y > parentChild.getPosition().y) {
var order = graph.getParent(node) && graph.getParent(node).getId() == parent.getId() const order = graph.getParent(node) && graph.getParent(node).getId() === parent.getId()
? last.getOrder() ? last.getOrder()
: last.getOrder() + 1; : last.getOrder() + 1;
var position = {
const result = {
x: parentChild.getPosition().x, x: parentChild.getPosition().x,
y: y:
parentChild.getPosition().y parentChild.getPosition().y
+ parentChild.getSize().height + parentChild.getSize().height
+ SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2, + SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
}; };
return [order, position]; return [order, result];
} }
// Fit after this node // Fit after this node
@ -138,34 +132,36 @@ class SymmetricSorter extends AbstractBasicSorter {
&& position.y < nodeAfter.getPosition().y && position.y < nodeAfter.getPosition().y
) { ) {
if ( if (
nodeAfter.getId() == node.getId() nodeAfter.getId() === node.getId()
|| parentChild.getId() == node.getId() || parentChild.getId() === node.getId()
) { ) {
return [node.getOrder(), node.getPosition()]; return [node.getOrder(), node.getPosition()];
} }
var order = position.y > node.getPosition().y const orderResult = position.y > node.getPosition().y
? nodeAfter.getOrder() - 1 ? nodeAfter.getOrder() - 1
: parentChild.getOrder() + 1; : parentChild.getOrder() + 1;
var position = {
const positionResult = {
x: parentChild.getPosition().x, x: parentChild.getPosition().x,
y: y:
parentChild.getPosition().y parentChild.getPosition().y
+ (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2, + (nodeAfter.getPosition().y - parentChild.getPosition().y) / 2,
}; };
return [order, position];
return [orderResult, positionResult];
} }
} }
// Position wasn't below any node, so it must be fitted above the first // Position wasn't below any node, so it must be fitted above the first
const first = parentChildren[0]; const first = parentChildren[0];
var position = { const resultPosition = {
x: first.getPosition().x, x: first.getPosition().x,
y: y:
first.getPosition().y first.getPosition().y
- first.getSize().height - first.getSize().height
- SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2, - SymmetricSorter.INTERNODE_VERTICAL_PADDING * 2,
}; };
return [0, position]; return [0, resultPosition];
} }
/** /**
@ -227,16 +223,13 @@ class SymmetricSorter extends AbstractBasicSorter {
// Compute heights ... // Compute heights ...
const heights = children const heights = children
.map(function (child) { .map(((child) => ({
return {
id: child.getId(), id: child.getId(),
order: child.getOrder(), order: child.getOrder(),
position: child.getPosition(), position: child.getPosition(),
width: child.getSize().width, width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child), height: this._computeChildrenHeight(treeSet, child),
}; })).bind(this)).reverse();
}, this)
.reverse();
// Compute the center of the branch ... // Compute the center of the branch ...
let totalHeight = 0; let totalHeight = 0;

View File

@ -15,7 +15,7 @@
* 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 { $assert, $defined } from "@wisemapping/core-js"; import { $assert, $defined } from '@wisemapping/core-js';
import $ from 'jquery'; import $ from 'jquery';
class FeatureModel { class FeatureModel {
@ -33,18 +33,24 @@ class FeatureModel {
this._attributes = {}; this._attributes = {};
// Create type method ... // Create type method ...
this[`is${$.camelCase(type)}Model`] = () => true; this[`is${FeatureModel.camelize(type)}Model`] = () => true;
} }
/** */ /** */
getAttributes() { getAttributes() {
return Object.clone(this._attributes); return { ...this._attributes };
}
static camelize(str) {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) => (index === 0 ? word.toLowerCase() : word.toUpperCase())).replace(/\s+/g, '');
} }
/** */ /** */
setAttributes(attributes) { setAttributes(attributes) {
for (const key in attributes) { for (const attr in attributes) {
this[`set${key.capitalize()}`](attributes[key]); const funName = `set${FeatureModel.camelize(attr)}`;
const value = attributes[attr];
this[funName](value);
} }
} }

View File

@ -39,14 +39,14 @@ class LinkModel extends FeatureModel {
const fixedUrl = LinkModel._fixUrl(url); const fixedUrl = LinkModel._fixUrl(url);
this.setAttribute('url', fixedUrl); this.setAttribute('url', fixedUrl);
const type = fixedUrl.contains('mailto:') ? 'mail' : 'url'; const type = fixedUrl.includes('mailto:') ? 'mail' : 'url';
this.setAttribute('urlType', type); this.setAttribute('urlType', type);
} }
// url format is already checked in LinkEditor.checkUrl // url format is already checked in LinkEditor.checkUrl
static _fixUrl(url) { static _fixUrl(url) {
let result = url; let result = url;
if (!result.contains('http://') && !result.contains('https://') && !result.contains('mailto://')) { if (!result.includes('http://') && !result.includes('https://') && !result.includes('mailto://')) {
result = `http://${result}`; result = `http://${result}`;
} }
return result; return result;

View File

@ -86,7 +86,7 @@ class Mindmap extends IMindmap {
*/ */
removeBranch(nodeModel) { removeBranch(nodeModel) {
$assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects'); $assert(nodeModel && nodeModel.isNodeModel(), 'Remove node must be invoked with model objects');
return this._branches.erase(nodeModel); this._branches = this._branches.filter((b) => b !== nodeModel);
} }
/** */ /** */
@ -151,7 +151,7 @@ class Mindmap extends IMindmap {
* @param relationship * @param relationship
*/ */
deleteRelationship(relationship) { deleteRelationship(relationship) {
this._relationships.erase(relationship); this._relationships = this._branches.filter((r) => r !== relationship);
} }
/** /**

View File

@ -169,7 +169,7 @@ class NodeModel extends INodeModel {
*/ */
removeChild(child) { removeChild(child) {
$assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.'); $assert(child && child.isNodeModel(), 'Only NodeModel can be appended to Mindmap object.');
this._children.erase(child); this._children = this._children.filter((c) => c !== child);
child._parent = null; child._parent = null;
} }

View File

@ -61,11 +61,15 @@ class FloatingTip extends Events {
return this; return this;
} }
setOptions() { setOptions(...args) {
const options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments)); this.options = { ...this.options, ...args };
const { options } = this;
if (this.addEvent) { if (this.addEvent) {
for (const option in options) { for (const option in options) {
if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; if (typeof (options[option]) != 'function' || !(/^on[A-Z]/).test(option)) {
continue;
}
this.addEvent(option, options[option]); this.addEvent(option, options[option]);
delete options[option]; delete options[option];
} }

View File

@ -15,12 +15,12 @@
* 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 { $assert } from "@wisemapping/core-js"; import { $assert } from '@wisemapping/core-js';
import PersistenceManager from '../PersistenceManager'; import PersistenceManager from '../PersistenceManager';
import { $notify } from './ToolbarNotifier'; import { $notify } from './ToolbarNotifier';
import $notifyModal from './ModalDialogNotifier';
class IMenu { class IMenu {
constructor(designer, containerId, mapId) { constructor(designer, containerId, mapId) {
$assert(designer, 'designer can not be null'); $assert(designer, 'designer can not be null');
$assert(containerId, 'containerId can not be null'); $assert(containerId, 'containerId can not be null');
@ -97,7 +97,7 @@ class IMenu {
$notifyModal(error.message); $notifyModal(error.message);
} }
} }
} },
}, sync); }, sync);
} }

View File

@ -148,7 +148,6 @@ class LinkEditor extends BootstrapDialog {
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

@ -14,9 +14,9 @@
* 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 { $assert } from '@wisemapping/core-js';
class ModalDialogNotifier { class ModalDialogNotifier {
// FIXME: replace by alert()
show(message, title) { show(message, title) {
$assert(message, 'message can not be null'); $assert(message, 'message can not be null');
@ -42,11 +42,10 @@ class ModalDialogNotifier {
modalDialog.find('.alert-content').append(h4 + p); modalDialog.find('.alert-content').append(h4 + p);
modalDialog.modal(); modalDialog.modal();
}, }
}); }
const dialogNotifier = new ModalDialogNotifier(); const dialogNotifier = new ModalDialogNotifier();
const $notifyModal = dialogNotifier.show.bind(dialogNotifier); const $notifyModal = dialogNotifier.show.bind(dialogNotifier);
export { $notifyModal }; export default { $notifyModal };
export default ModalDialogNotifier;

View File

@ -15,6 +15,7 @@
* 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 { $assert } from '@wisemapping/core-js';
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog'; import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
class NoteEditor extends BootstrapDialog { class NoteEditor extends BootstrapDialog {

View File

@ -1,6 +1,4 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import '@libraries/mootools-core-1.4.5';
import Mindmap from './components/model/Mindmap'; import Mindmap from './components/model/Mindmap';
import PersistenceManager from './components/PersistenceManager'; import PersistenceManager from './components/PersistenceManager';
import Designer from './components/Designer'; import Designer from './components/Designer';

View File

@ -20,6 +20,7 @@ import $ from 'jquery';
import { $assert } from '@wisemapping/core-js'; 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 { class BalancedTestSuite extends TestSuite {
constructor() { constructor() {
$('#balancedTest').css('display', 'block'); $('#balancedTest').css('display', 'block');

View File

@ -501,13 +501,13 @@ class FreeTestSuite extends TestSuite {
_assertBranchCollision(treeSet, node, heightById) { _assertBranchCollision(treeSet, node, heightById) {
const children = treeSet.getChildren(node); const children = treeSet.getChildren(node);
const childOfRootNode = treeSet._rootNodes.contains(node); const childOfRootNode = treeSet._rootNodes.includes(node);
children.forEach((child) => { children.forEach((child) => {
const height = heightById[child.getId()]; const height = heightById[child.getId()];
let siblings = treeSet.getSiblings(child); let siblings = treeSet.getSiblings(child);
if (childOfRootNode) { if (childOfRootNode) {
siblings = siblings.filter((sibling) => child.getOrder() % 2 == sibling.getOrder() % 2); siblings = siblings.filter((sibling) => child.getOrder() % 2 === sibling.getOrder() % 2);
} }
siblings.forEach((sibling) => { siblings.forEach((sibling) => {

View File

@ -91,7 +91,7 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0); manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 0); manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 0);
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(3, 5, 0); manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(3, 5, 0);
manager.addNode(6, { width: 140, height: 130 }, position).connectNode(3, 6, 1); manager.addNode(6, { width: 140, height: 130 } , position).connectNode(3, 6, 1);
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(6, 7, 0); manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(6, 7, 0);
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(7, 8, 0); manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(7, 8, 0);
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(7, 9, 1); manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(7, 9, 1);
@ -105,10 +105,10 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(17, TestSuite.NODE_SIZE, position).connectNode(7, 17, 9); manager.addNode(17, TestSuite.NODE_SIZE, position).connectNode(7, 17, 9);
manager.addNode(29, TestSuite.NODE_SIZE, position).connectNode(6, 29, 1); manager.addNode(29, TestSuite.NODE_SIZE, position).connectNode(6, 29, 1);
manager.addNode(30, TestSuite.NODE_SIZE, position).connectNode(6, 30, 2); manager.addNode(30, TestSuite.NODE_SIZE, position).connectNode(6, 30, 2);
manager.addNode(31, { width: 100, height: 50 }, position).connectNode(6, 31, 3); manager.addNode(31, { width: 100, height: 50 } , position).connectNode(6, 31, 3);
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 1); manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 1);
manager.addNode(18, { width: 80, height: 70 }, position).connectNode(4, 18, 0); manager.addNode(18, { width: 80, height: 70 } , position).connectNode(4, 18, 0);
manager.addNode(19, TestSuite.NODE_SIZE, position).connectNode(18, 19, 0); manager.addNode(19, TestSuite.NODE_SIZE, position).connectNode(18, 19, 0);
manager.addNode(20, TestSuite.NODE_SIZE, position).connectNode(19, 20, 0); manager.addNode(20, TestSuite.NODE_SIZE, position).connectNode(19, 20, 0);
manager.addNode(21, TestSuite.NODE_SIZE, position).connectNode(20, 21, 0); manager.addNode(21, TestSuite.NODE_SIZE, position).connectNode(20, 21, 0);
@ -117,11 +117,11 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(22, TestSuite.NODE_SIZE, position).connectNode(2, 22, 0); manager.addNode(22, TestSuite.NODE_SIZE, position).connectNode(2, 22, 0);
manager.addNode(24, TestSuite.NODE_SIZE, position).connectNode(22, 24, 0); manager.addNode(24, TestSuite.NODE_SIZE, position).connectNode(22, 24, 0);
manager.addNode(23, { width: 80, height: 50 }, position).connectNode(2, 23, 1); manager.addNode(23, { width: 80, height: 50 } , position).connectNode(2, 23, 1);
manager.addNode(25, { width: 80, height: 40 }, position).connectNode(23, 25, 0); manager.addNode(25, { width: 80, height: 40 } , position).connectNode(23, 25, 0);
manager.addNode(26, { width: 80, height: 80 }, position).connectNode(25, 26, 0); manager.addNode(26, { width: 80, height: 80 } , position).connectNode(25, 26, 0);
manager.addNode(27, TestSuite.NODE_SIZE, position).connectNode(26, 27, 0); manager.addNode(27, TestSuite.NODE_SIZE, position).connectNode(26, 27, 0);
manager.addNode(28, { width: 80, height: 80 }, position).connectNode(27, 28, 0); manager.addNode(28, { width: 80, height: 80 } , position).connectNode(27, 28, 0);
// manager.layout(); // manager.layout();
// manager.plot("testBaselineAligned1", {width:1600,height:800}); // manager.plot("testBaselineAligned1", {width:1600,height:800});
@ -135,7 +135,7 @@ class TestSuite extends ChildrenSorterStrategy {
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE); const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0); manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
manager.addNode(2, { width: 130, height: 200 }, position).connectNode(1, 2, 0); manager.addNode(2, { width: 130, height: 200 } , position).connectNode(1, 2, 0);
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(2, 3, 0); manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(2, 4, 1); manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(2, 4, 1);
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(2, 5, 2); manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(2, 5, 2);
@ -164,9 +164,9 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addEvent('change', (event) => { manager.addEvent('change', (event) => {
console.log( console.log(
`\tUpdated nodes: {id:${event.getId() `\tUpdated nodes: {id:${event.getId()
}, order: ${event.getOrder() } order: ${event.getOrder()
},position: {${event.getPosition().x }position: {${event.getPosition().x
},${event.getPosition().y }${event.getPosition().y
}}`, }}`,
); );
events.push(event); events.push(event);
@ -206,9 +206,9 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addEvent('change', (event) => { manager.addEvent('change', (event) => {
console.log( console.log(
`\tUpdated nodes: {id:${event.getId() `\tUpdated nodes: {id:${event.getId()
}, order: ${event.getOrder() } order: ${event.getOrder()
},position: {${event.getPosition().x }position: {${event.getPosition().x
},${event.getPosition().y }${event.getPosition().y
}}`, }}`,
); );
events.push(event); events.push(event);
@ -256,12 +256,12 @@ class TestSuite extends ChildrenSorterStrategy {
const events = []; const events = [];
manager.addEvent('change', (event) => { manager.addEvent('change', (event) => {
const pos = event.getPosition(); const pos = event.getPosition();
const posStr = pos ? `,position: {${pos.x},${pos.y}` : ''; const posStr = pos ? `,position: {${pos.x}${pos.y}` : '';
const node = manager.find(event.getId()); const node = manager.find(event.getId());
console.log( console.log(
`\tUpdated nodes: {id:${event.getId() `\tUpdated nodes: {id:${event.getId()
}, order: ${event.getOrder() } order: ${event.getOrder()
},${posStr }${posStr
}}`, }}`,
); );
events.push(event); events.push(event);
@ -385,7 +385,7 @@ class TestSuite extends ChildrenSorterStrategy {
const events = []; const events = [];
manager.addEvent('change', (event) => { manager.addEvent('change', (event) => {
const pos = event.getPosition(); const pos = event.getPosition();
const posStr = pos ? `,position: {${pos.x},${event.getPosition().y}` : ''; const posStr = pos ? `,position: {${pos.x}${event.getPosition().y}` : '';
events.push(event); events.push(event);
}); });
manager.layout(true); manager.layout(true);
@ -431,17 +431,17 @@ class TestSuite extends ChildrenSorterStrategy {
const position = { x: 0, y: 0 }; const position = { x: 0, y: 0 };
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE); const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, { width: 60, height: 60 }, position); manager.addNode(1, { width: 60, height: 60 } ,position);
manager.addNode(2, TestSuite.NODE_SIZE, position); manager.addNode(2, TestSuite.NODE_SIZE, position);
manager.addNode(3, { width: 260, height: 30 }, position); manager.addNode(3, { width: 260, height: 30 } ,position);
manager.addNode(4, TestSuite.NODE_SIZE, position); manager.addNode(4, TestSuite.NODE_SIZE, position);
manager.addNode(5, TestSuite.NODE_SIZE, position); manager.addNode(5, TestSuite.NODE_SIZE, position);
manager.addNode(7, { width: 80, height: 80 }, position); manager.addNode(7, { width: 80, height: 80 } ,position);
manager.addNode(8, TestSuite.NODE_SIZE, position); manager.addNode(8, TestSuite.NODE_SIZE, position);
manager.addNode(9, { width: 30, height: 30 }, position); manager.addNode(9, { width: 30, height: 30 } ,position);
manager.addNode(10, TestSuite.NODE_SIZE, position); manager.addNode(10, TestSuite.NODE_SIZE, position);
manager.addNode(11, TestSuite.NODE_SIZE, position); manager.addNode(11, TestSuite.NODE_SIZE, position);
manager.addNode(12, { width: 100, height: 70 }, position); manager.addNode(12, { width: 100, height: 70 } ,position);
manager.addNode(13, TestSuite.NODE_SIZE, position); manager.addNode(13, TestSuite.NODE_SIZE, position);
manager.addNode(14, TestSuite.NODE_SIZE, position); manager.addNode(14, TestSuite.NODE_SIZE, position);
manager.addNode(15, TestSuite.NODE_SIZE, position); manager.addNode(15, TestSuite.NODE_SIZE, position);
@ -565,8 +565,8 @@ class TestSuite extends ChildrenSorterStrategy {
const { order } = prediction; const { order } = prediction;
console.log( console.log(
`\t\tprediction {order:${order `\t\tprediction {order:${order
}, position: (${position.x } position: (${position.x
},${position.y }${position.y
})}`, })}`,
); );
const cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2; const cx = position.x + canvas.width / 2 - TestSuite.NODE_SIZE.width / 2;

View File

@ -11,7 +11,6 @@
<![endif]--> <![endif]-->
<link rel="stylesheet/less" type="text/css" href="css/editor.less"/> <link rel="stylesheet/less" type="text/css" href="css/editor.less"/>
<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/core.js'></script>
<script type='text/javascript' src='js/less.js'></script> <script type='text/javascript' src='js/less.js'></script>

View File

@ -18,6 +18,7 @@
import { $assert } from '@wisemapping/core-js'; import { $assert } from '@wisemapping/core-js';
import { PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/'; import { PersistenceManager, Designer, LocalStorageManager, Menu } from '../../../../src/';
import * as mindplot from '../../../../src/'; import * as mindplot from '../../../../src/';
import $notifyModal from '../../../../src/components/widget/ModalDialogNotifier';
import $ from 'jquery'; import $ from 'jquery';
global.jQuery = $; global.jQuery = $;

View File

@ -33,7 +33,7 @@ describe('Free Test Suite', () => {
function branchCollision(treeSet, node, heightById) { function branchCollision(treeSet, node, heightById) {
const children = treeSet.getChildren(node); const children = treeSet.getChildren(node);
const childOfRootNode = treeSet._rootNodes.contains(node); const childOfRootNode = treeSet._rootNodes.includes(node);
children.forEach(((child) => { children.forEach(((child) => {
let siblings = treeSet.getSiblings(child); let siblings = treeSet.getSiblings(child);

View File

@ -18,7 +18,6 @@ module.exports = {
test: /.(js$)/, test: /.(js$)/,
exclude: [ exclude: [
/node_modules/, /node_modules/,
path.resolve(__dirname, '../../libraries/mootools-core-1.4.5'),
], ],
}, },
], ],

View File

@ -36,7 +36,6 @@ module.exports = {
test: /.js$/, test: /.js$/,
exclude: [ exclude: [
/node_modules/, /node_modules/,
path.resolve(__dirname, '../../libraries/mootools-core-1.4.5'),
/lib\/raphael/ig, /lib\/raphael/ig,
], ],
}, },

View File

@ -13,6 +13,7 @@
"rules": { "rules": {
"no-underscore-dangle": "off", "no-underscore-dangle": "off",
"no-restricted-syntax": "off", "no-restricted-syntax": "off",
"no-underscore-dangle": "off",
"no-plusplus": "off", "no-plusplus": "off",
"max-len": [1,250], "max-len": [1,250],
"import/no-extraneous-dependencies": ["warn", { "import/no-extraneous-dependencies": ["warn", {

View File

@ -3,7 +3,7 @@ const BASE_URL = 'http://localhost:8080';
context('Playground', () => { context('Playground', () => {
it('every test page should match its snapshot', () => { it('every test page should match its snapshot', () => {
cy.visit(BASE_URL); cy.visit(BASE_URL);
cy.get('a').each(($el) => { cy.get('a').forEach(($el) => {
const url = `${BASE_URL}${$el.attr('href')}`; const url = `${BASE_URL}${$el.attr('href')}`;
cy.visit(url); cy.visit(url);
cy.matchImageSnapshot($el.text()); cy.matchImageSnapshot($el.text());

View File

@ -74,12 +74,14 @@ class ElementPeer {
removeChild(elementPeer) { removeChild(elementPeer) {
// Store parent and child relationship. // Store parent and child relationship.
elementPeer.setParent(null); elementPeer.setParent(null);
const children = this.getChildren(); let children = this.getChildren();
// Remove from children array ... // Remove from children array ...
const oldLength = children.length; const oldLength = children.length;
children.erase(elementPeer); children = children.filter((c) => c !== elementPeer);
this.setChildren(children);
$assert( $assert(
children.length < oldLength, children.length < oldLength,
`element could not be removed:${elementPeer}`, `element could not be removed:${elementPeer}`,