Commit f7529961 authored by techird's avatar techird

1.4.1

parent 518eec4e
/*! /*!
* ==================================================== * ====================================================
* kityminder - v1.4.0 - 2015-04-23 * kityminder - v1.4.1 - 2015-04-23
* https://github.com/fex-team/kityminder-core * https://github.com/fex-team/kityminder-core
* GitHub: https://github.com/fex-team/kityminder-core.git * GitHub: https://github.com/fex-team/kityminder-core.git
* Copyright (c) 2015 Baidu FEX; Licensed MIT * Copyright (c) 2015 Baidu FEX; Licensed MIT
...@@ -48,8 +48,8 @@ var _p = { ...@@ -48,8 +48,8 @@ var _p = {
*/ */
_p[0] = { _p[0] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var connect = _p.r(9); var connect = _p.r(10);
var connectMarker = new kity.Marker().pipe(function() { var connectMarker = new kity.Marker().pipe(function() {
var r = 7; var r = 7;
var dot = new kity.Circle(r - 1); var dot = new kity.Circle(r - 1);
...@@ -88,8 +88,8 @@ _p[0] = { ...@@ -88,8 +88,8 @@ _p[0] = {
*/ */
_p[1] = { _p[1] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var connect = _p.r(9); var connect = _p.r(10);
connect.register("bezier", function(node, parent, connection) { connect.register("bezier", function(node, parent, connection) {
// 连线起点和终点 // 连线起点和终点
var po = parent.getLayoutVertexOut(), pi = node.getLayoutVertexIn(); var po = parent.getLayoutVertexOut(), pi = node.getLayoutVertexIn();
...@@ -125,8 +125,8 @@ _p[1] = { ...@@ -125,8 +125,8 @@ _p[1] = {
*/ */
_p[2] = { _p[2] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var connect = _p.r(9); var connect = _p.r(10);
connect.register("fish-bone-master", function(node, parent, connection) { connect.register("fish-bone-master", function(node, parent, connection) {
var pout = parent.getLayoutVertexOut(), pin = node.getLayoutVertexIn(); var pout = parent.getLayoutVertexOut(), pin = node.getLayoutVertexIn();
var abs = Math.abs; var abs = Math.abs;
...@@ -152,8 +152,8 @@ _p[2] = { ...@@ -152,8 +152,8 @@ _p[2] = {
*/ */
_p[3] = { _p[3] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var connect = _p.r(9); var connect = _p.r(10);
connect.register("l", function(node, parent, connection) { connect.register("l", function(node, parent, connection) {
var po = parent.getLayoutVertexOut(); var po = parent.getLayoutVertexOut();
var pi = node.getLayoutVertexIn(); var pi = node.getLayoutVertexIn();
...@@ -183,8 +183,8 @@ _p[3] = { ...@@ -183,8 +183,8 @@ _p[3] = {
*/ */
_p[4] = { _p[4] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var connect = _p.r(9); var connect = _p.r(10);
connect.register("poly", function(node, parent, connection, width) { connect.register("poly", function(node, parent, connection, width) {
// 连线起点和终点 // 连线起点和终点
var po = parent.getLayoutVertexOut(), pi = node.getLayoutVertexIn(); var po = parent.getLayoutVertexOut(), pi = node.getLayoutVertexIn();
...@@ -240,8 +240,8 @@ _p[4] = { ...@@ -240,8 +240,8 @@ _p[4] = {
*/ */
_p[5] = { _p[5] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var connect = _p.r(9); var connect = _p.r(10);
connect.register("under", function(node, parent, connection, width, color) { connect.register("under", function(node, parent, connection, width, color) {
var box = node.getLayoutBox(), pBox = parent.getLayoutBox(); var box = node.getLayoutBox(), pBox = parent.getLayoutBox();
var start, end, vector; var start, end, vector;
...@@ -271,6 +271,39 @@ _p[5] = { ...@@ -271,6 +271,39 @@ _p[5] = {
} }
}; };
//src/core/_boxv.js
/**
* @fileOverview
*
* 调试工具:为 kity.Box 提供一个可视化的渲染
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
_p[6] = {
value: function(require, exports, module) {
var kity = _p.r(16);
var Minder = _p.r(18);
if (location.href.indexOf("boxv") != -1) {
var vrect;
Object.defineProperty(kity.Box.prototype, "visualization", {
get: function() {
if (!vrect) return null;
return vrect.setBox(this);
}
});
Minder.registerInitHook(function() {
this.on("paperrender", function() {
vrect = new kity.Rect();
vrect.fill("rgba(200, 200, 200, .5)");
vrect.stroke("orange");
this.getRenderContainer().addShape(vrect);
});
});
}
}
};
//src/core/animate.js //src/core/animate.js
/** /**
* @fileOverview * @fileOverview
...@@ -280,9 +313,9 @@ _p[5] = { ...@@ -280,9 +313,9 @@ _p[5] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[6] = { _p[7] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var Minder = _p.r(17); var Minder = _p.r(18);
var animateDefaultOptions = { var animateDefaultOptions = {
enableAnimation: true, enableAnimation: true,
layoutAnimationDuration: 300, layoutAnimationDuration: 300,
...@@ -315,13 +348,13 @@ _p[6] = { ...@@ -315,13 +348,13 @@ _p[6] = {
}; };
//src/core/command.js //src/core/command.js
_p[7] = { _p[8] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var MinderEvent = _p.r(11); var MinderEvent = _p.r(12);
var COMMAND_STATE_NORMAL = 0; var COMMAND_STATE_NORMAL = 0;
var COMMAND_STATE_DISABLED = -1; var COMMAND_STATE_DISABLED = -1;
var COMMAND_STATE_ACTIVED = 1; var COMMAND_STATE_ACTIVED = 1;
...@@ -430,17 +463,13 @@ _p[7] = { ...@@ -430,17 +463,13 @@ _p[7] = {
if (!cmd || !~this.queryCommandState(name)) { if (!cmd || !~this.queryCommandState(name)) {
return false; return false;
} }
if (!this._hasEnterExecCommand && cmd.isNeedUndo()) { if (!this._hasEnterExecCommand) {
this._hasEnterExecCommand = true; this._hasEnterExecCommand = true;
stoped = this._fire(new MinderEvent("beforeExecCommand", eventParams, true)); stoped = this._fire(new MinderEvent("beforeExecCommand", eventParams, true));
if (!stoped) { if (!stoped) {
//保存场景
this._fire(new MinderEvent("saveScene"));
this._fire(new MinderEvent("preExecCommand", eventParams, false)); this._fire(new MinderEvent("preExecCommand", eventParams, false));
result = cmd.execute.apply(cmd, [ me ].concat(cmdArgs)); result = cmd.execute.apply(cmd, [ me ].concat(cmdArgs));
this._fire(new MinderEvent("execCommand", eventParams, false)); this._fire(new MinderEvent("execCommand", eventParams, false));
//保存场景
this._fire(new MinderEvent("saveScene"));
if (cmd.isContentChanged()) { if (cmd.isContentChanged()) {
this._firePharse(new MinderEvent("contentchange")); this._firePharse(new MinderEvent("contentchange"));
} }
...@@ -461,9 +490,9 @@ _p[7] = { ...@@ -461,9 +490,9 @@ _p[7] = {
}; };
//src/core/compatibility.js //src/core/compatibility.js
_p[8] = { _p[9] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var utils = _p.r(30); var utils = _p.r(32);
function compatibility(json) { function compatibility(json) {
var version = json.version || (json.root ? "1.4.0" : "1.1.3"); var version = json.version || (json.root ? "1.4.0" : "1.1.3");
switch (version) { switch (version) {
...@@ -547,13 +576,13 @@ _p[8] = { ...@@ -547,13 +576,13 @@ _p[8] = {
}; };
//src/core/connect.js //src/core/connect.js
_p[9] = { _p[10] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Module = _p.r(18); var Module = _p.r(19);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
// 连线提供方 // 连线提供方
var _connectProviders = {}; var _connectProviders = {};
function register(name, provider) { function register(name, provider) {
...@@ -649,15 +678,15 @@ _p[9] = { ...@@ -649,15 +678,15 @@ _p[9] = {
}; };
//src/core/data.js //src/core/data.js
_p[10] = { _p[11] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var MinderEvent = _p.r(11); var MinderEvent = _p.r(12);
var compatibility = _p.r(8); var compatibility = _p.r(9);
var Promise = _p.r(22); var Promise = _p.r(24);
var protocols = {}; var protocols = {};
function registerProtocol(name, protocol) { function registerProtocol(name, protocol) {
protocols[name] = protocol; protocols[name] = protocol;
...@@ -693,11 +722,9 @@ _p[10] = { ...@@ -693,11 +722,9 @@ _p[10] = {
var exported = {}; var exported = {};
exported.data = node.getData(); exported.data = node.getData();
var childNodes = node.getChildren(); var childNodes = node.getChildren();
if (childNodes.length) { exported.children = [];
exported.children = []; for (var i = 0; i < childNodes.length; i++) {
for (var i = 0; i < childNodes.length; i++) { exported.children.push(exportNode(childNodes[i]));
exported.children.push(exportNode(childNodes[i]));
}
} }
return exported; return exported;
} }
...@@ -707,7 +734,7 @@ _p[10] = { ...@@ -707,7 +734,7 @@ _p[10] = {
json.template = this.getTemplate(); json.template = this.getTemplate();
json.theme = this.getTheme(); json.theme = this.getTheme();
json.version = Minder.version; json.version = Minder.version;
return json; return JSON.parse(JSON.stringify(json));
}, },
/** /**
* @method importJson() * @method importJson()
...@@ -769,7 +796,7 @@ _p[10] = { ...@@ -769,7 +796,7 @@ _p[10] = {
* *
* @param {string} protocol 指定的数据协议(默认内置五种数据协议 `json`、`text`、`markdown`、`svg` 和 `png`) * @param {string} protocol 指定的数据协议(默认内置五种数据协议 `json`、`text`、`markdown`、`svg` 和 `png`)
*/ */
exportData: function(protocolName) { exportData: function(protocolName, option) {
var json, protocol; var json, protocol;
json = this.exportJson(); json = this.exportJson();
// 指定了协议进行导出,需要检测协议是否支持 // 指定了协议进行导出,需要检测协议是否支持
...@@ -785,7 +812,7 @@ _p[10] = { ...@@ -785,7 +812,7 @@ _p[10] = {
protocolName: protocolName, protocolName: protocolName,
protocol: protocol protocol: protocol
})); }));
return Promise.resolve(protocol.encode(json, this)); return Promise.resolve(protocol.encode(json, this, option));
}, },
/** /**
* @method importData() * @method importData()
...@@ -797,7 +824,7 @@ _p[10] = { ...@@ -797,7 +824,7 @@ _p[10] = {
* @param {string} protocol 指定的用于解析数据的数据协议(默认内置三种数据协议 `json`、`text` 和 `markdown` 的支持) * @param {string} protocol 指定的用于解析数据的数据协议(默认内置三种数据协议 `json`、`text` 和 `markdown` 的支持)
* @param {any} data 要导入的数据 * @param {any} data 要导入的数据
*/ */
importData: function(protocolName, data) { importData: function(protocolName, data, option) {
var json, protocol; var json, protocol;
var minder = this; var minder = this;
// 指定了协议进行导入,需要检测协议是否支持 // 指定了协议进行导入,需要检测协议是否支持
...@@ -814,7 +841,7 @@ _p[10] = { ...@@ -814,7 +841,7 @@ _p[10] = {
}; };
// 导入前抛事件 // 导入前抛事件
this._fire(new MinderEvent("beforeimport", params)); this._fire(new MinderEvent("beforeimport", params));
return Promise.resolve(protocol.decode(data, this)).then(function(json) { return Promise.resolve(protocol.decode(data, this, option)).then(function(json) {
minder.importJson(json); minder.importJson(json);
return json; return json;
}); });
...@@ -824,11 +851,11 @@ _p[10] = { ...@@ -824,11 +851,11 @@ _p[10] = {
}; };
//src/core/event.js //src/core/event.js
_p[11] = { _p[12] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
/** /**
* @class MinderEvent * @class MinderEvent
* @description 表示一个脑图中发生的事件 * @description 表示一个脑图中发生的事件
...@@ -1056,10 +1083,10 @@ _p[11] = { ...@@ -1056,10 +1083,10 @@ _p[11] = {
}; };
//src/core/focus.js //src/core/focus.js
_p[12] = { _p[13] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Minder = _p.r(17); var Minder = _p.r(18);
Minder.registerInitHook(function() { Minder.registerInitHook(function() {
this.on("beforemousedown", function(e) { this.on("beforemousedown", function(e) {
this.focus(); this.focus();
...@@ -1097,7 +1124,7 @@ _p[12] = { ...@@ -1097,7 +1124,7 @@ _p[12] = {
}; };
//src/core/keymap.js //src/core/keymap.js
_p[13] = { _p[14] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var keymap = { var keymap = {
Backspace: 8, Backspace: 8,
...@@ -1208,11 +1235,11 @@ _p[13] = { ...@@ -1208,11 +1235,11 @@ _p[13] = {
}; };
//src/core/keyreceiver.js //src/core/keyreceiver.js
_p[14] = { _p[15] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
function listen(element, type, handler) { function listen(element, type, handler) {
type.split(" ").forEach(function(name) { type.split(" ").forEach(function(name) {
element.addEventListener(name, handler, false); element.addEventListener(name, handler, false);
...@@ -1278,21 +1305,21 @@ _p[14] = { ...@@ -1278,21 +1305,21 @@ _p[14] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[15] = { _p[16] = {
value: function(require, exports, module) { value: function(require, exports, module) {
module.exports = window.kity; module.exports = window.kity;
} }
}; };
//src/core/layout.js //src/core/layout.js
_p[16] = { _p[17] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var MinderEvent = _p.r(11); var MinderEvent = _p.r(12);
var Command = _p.r(7); var Command = _p.r(8);
var _layouts = {}; var _layouts = {};
var _defaultLayout; var _defaultLayout;
function register(name, layout) { function register(name, layout) {
...@@ -1318,7 +1345,7 @@ _p[16] = { ...@@ -1318,7 +1345,7 @@ _p[16] = {
* children[i].setLayoutTransform(new kity.Matrix().translate(x, y)); * children[i].setLayoutTransform(new kity.Matrix().translate(x, y));
* } * }
*/ */
doLayout: function(node) { doLayout: function(parent, children) {
throw new Error("Not Implement: Layout.doLayout()"); throw new Error("Not Implement: Layout.doLayout()");
}, },
/** /**
...@@ -1483,9 +1510,6 @@ _p[16] = { ...@@ -1483,9 +1510,6 @@ _p[16] = {
getOrderHint: function(refer) { getOrderHint: function(refer) {
return this.parent.getLayoutInstance().getOrderHint(this); return this.parent.getLayoutInstance().getOrderHint(this);
}, },
getExpandPosition: function() {
return this.getLayoutInstance().getExpandPosition();
},
/** /**
* 获取当前节点相对于父节点的布局变换 * 获取当前节点相对于父节点的布局变换
*/ */
...@@ -1502,7 +1526,7 @@ _p[16] = { ...@@ -1502,7 +1526,7 @@ _p[16] = {
var matrix = this.getLayoutTransform(); var matrix = this.getLayoutTransform();
var offset = this.getLayoutOffset(); var offset = this.getLayoutOffset();
if (offset) { if (offset) {
matrix.translate(offset.x, offset.y); matrix = matrix.clone().translate(offset.x, offset.y);
} }
return pMatrix.merge(matrix); return pMatrix.merge(matrix);
}, },
...@@ -1584,15 +1608,10 @@ _p[16] = { ...@@ -1584,15 +1608,10 @@ _p[16] = {
}, },
setLayoutOffset: function(p) { setLayoutOffset: function(p) {
if (!this.parent) return this; if (!this.parent) return this;
if (p && !this.hasLayoutOffset()) {
var m = this.getLayoutTransform().m;
p = p.offset(m.e, m.f);
this.setLayoutTransform(null);
}
this.setData("layout_" + this.parent.getLayout() + "_offset", p ? { this.setData("layout_" + this.parent.getLayout() + "_offset", p ? {
x: p.x, x: p.x,
y: p.y y: p.y
} : null); } : undefined);
return this; return this;
}, },
hasLayoutOffset: function() { hasLayoutOffset: function() {
...@@ -1633,7 +1652,7 @@ _p[16] = { ...@@ -1633,7 +1652,7 @@ _p[16] = {
var childrenInFlow = node.getChildren().filter(function(child) { var childrenInFlow = node.getChildren().filter(function(child) {
return !child.hasLayoutOffset(); return !child.hasLayoutOffset();
}); });
layout.doLayout(node, childrenInFlow, round); layout.doLayout(node, node.getChildren(), round);
} }
// 第一轮布局 // 第一轮布局
layoutNode(this.getRoot(), 1); layoutNode(this.getRoot(), 1);
...@@ -1671,7 +1690,7 @@ _p[16] = { ...@@ -1671,7 +1690,7 @@ _p[16] = {
}); });
} }
function apply(node, pMatrix) { function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(pMatrix); var matrix = node.getLayoutTransform().merge(pMatrix.clone());
var lastMatrix = node.getGlobalLayoutTransform() || new kity.Matrix(); var lastMatrix = node.getGlobalLayoutTransform() || new kity.Matrix();
var offset = node.getLayoutOffset(); var offset = node.getLayoutOffset();
matrix.translate(offset.x, offset.y); matrix.translate(offset.x, offset.y);
...@@ -1724,10 +1743,10 @@ _p[16] = { ...@@ -1724,10 +1743,10 @@ _p[16] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[17] = { _p[18] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var _initHooks = []; var _initHooks = [];
var Minder = kity.createClass("Minder", { var Minder = kity.createClass("Minder", {
constructor: function(options) { constructor: function(options) {
...@@ -1743,7 +1762,7 @@ _p[17] = { ...@@ -1743,7 +1762,7 @@ _p[17] = {
this.fire("ready"); this.fire("ready");
} }
}); });
Minder.version = "1.4.0"; Minder.version = "1.4.1";
Minder.registerInitHook = function(hook) { Minder.registerInitHook = function(hook) {
_initHooks.push(hook); _initHooks.push(hook);
}; };
...@@ -1752,11 +1771,11 @@ _p[17] = { ...@@ -1752,11 +1771,11 @@ _p[17] = {
}; };
//src/core/module.js //src/core/module.js
_p[18] = { _p[19] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
/* 已注册的模块 */ /* 已注册的模块 */
var _modules = {}; var _modules = {};
exports.register = function(name, module) { exports.register = function(name, module) {
...@@ -1852,11 +1871,11 @@ _p[18] = { ...@@ -1852,11 +1871,11 @@ _p[18] = {
}; };
//src/core/node.js //src/core/node.js
_p[19] = { _p[20] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
/** /**
* @class MinderNode * @class MinderNode
* *
...@@ -1915,6 +1934,15 @@ _p[19] = { ...@@ -1915,6 +1934,15 @@ _p[19] = {
getParent: function() { getParent: function() {
return this.parent; return this.parent;
}, },
getSiblings: function() {
var children = this.parent.children;
var siblings = [];
var self = this;
children.forEach(function(child) {
if (child != self) siblings.push(child);
});
return siblings;
},
/** /**
* 获得节点的深度 * 获得节点的深度
*/ */
...@@ -1959,7 +1987,15 @@ _p[19] = { ...@@ -1959,7 +1987,15 @@ _p[19] = {
return key ? this.data[key] : this.data; return key ? this.data[key] : this.data;
}, },
setData: function(key, value) { setData: function(key, value) {
this.data[key] = value; if (typeof key == "object") {
var data = key;
for (key in data) if (data.hasOwnProperty(key)) {
this.data[key] = data[key];
}
} else {
this.data[key] = value;
}
return this;
}, },
/** /**
* 设置节点的文本数据 * 设置节点的文本数据
...@@ -2107,6 +2143,26 @@ _p[19] = { ...@@ -2107,6 +2143,26 @@ _p[19] = {
this._root = root; this._root = root;
root.minder = this; root.minder = this;
}, },
getAllNode: function() {
var nodes = [];
this.getRoot().traverse(function(node) {
nodes.push(node);
});
return nodes;
},
getNodeById: function(id) {
return this.getNodesById([ id ])[0];
},
getNodesById: function(ids) {
var nodes = this.getAllNode();
var result = [];
nodes.forEach(function(node) {
if (ids.indexOf(node.getData("id")) != -1) {
result.push(node);
}
});
return result;
},
createNode: function(textOrData, parent, index) { createNode: function(textOrData, parent, index) {
var node = new MinderNode(textOrData); var node = new MinderNode(textOrData);
this.fire("nodecreate", { this.fire("nodecreate", {
...@@ -2169,11 +2225,11 @@ _p[19] = { ...@@ -2169,11 +2225,11 @@ _p[19] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[20] = { _p[21] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
Minder.registerInitHook(function(options) { Minder.registerInitHook(function(options) {
this._defaultOptions = {}; this._defaultOptions = {};
}); });
...@@ -2205,11 +2261,11 @@ _p[20] = { ...@@ -2205,11 +2261,11 @@ _p[20] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[21] = { _p[22] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
Minder.registerInitHook(function() { Minder.registerInitHook(function() {
this._initPaper(); this._initPaper();
}); });
...@@ -2264,8 +2320,116 @@ _p[21] = { ...@@ -2264,8 +2320,116 @@ _p[21] = {
} }
}; };
//src/core/patch.js
/**
* @fileOverview
*
* 打补丁
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
_p[23] = {
value: function(require, exports, module) {
var kity = _p.r(16);
var Minder = _p.r(18);
function insertNode(minder, info, parent, index) {
parent = minder.createNode(info.data, parent, index);
info.children.forEach(function(childInfo, index) {
insertNode(minder, childInfo, parent, index);
});
return parent;
}
function applyPatch(minder, patch) {
// patch.op - 操作,包括 remove, add, replace
// patch.path - 路径,如 '/root/children/1/data'
// patch.value - 数据,如 { text: "思路" }
var path = patch.path.split("/");
path.shift();
var changed = path.shift();
var node;
if (changed == "root") {
var dataIndex = path.indexOf("data");
if (dataIndex > -1) {
changed = "data";
var dataPath = path.splice(dataIndex + 1);
patch.dataPath = dataPath;
} else {
changed = "node";
}
node = minder.getRoot();
var segment, index;
while (segment = path.shift()) {
if (segment == "children") continue;
if (typeof index != "undefined") node = node.getChild(index);
index = +segment;
}
patch.index = index;
patch.node = node;
}
var express = patch.express = [ changed, patch.op ].join(".");
switch (express) {
case "theme.replace":
minder.useTheme(patch.value);
break;
case "template.replace":
minder.useTemplate(patch.value);
break;
case "node.add":
insertNode(minder, patch.value, patch.node, patch.index).renderTree();
minder.layout();
break;
case "node.remove":
minder.removeNode(patch.node.getChild(patch.index));
minder.layout();
break;
case "data.add":
case "data.replace":
case "data.remove":
var data = patch.node.data;
var field;
path = patch.dataPath.slice();
while (data && path.length > 1) {
field = path.shift();
if (field in data) {
data = data[field];
} else if (patch.op != "remove") {
data = data[field] = {};
}
}
if (data) {
field = path.shift();
data[field] = patch.value;
}
if (field == "expandState") {
node.renderTree();
} else {
node.render();
}
minder.layout();
}
minder.fire("patch", {
patch: patch
});
}
kity.extendClass(Minder, {
applyPatches: function(patches) {
for (var i = 0; i < patches.length; i++) {
applyPatch(this, patches[i]);
}
this.fire("contentchange");
return this;
}
});
}
};
//src/core/promise.js //src/core/promise.js
_p[22] = { _p[24] = {
value: function(require, exports, module) { value: function(require, exports, module) {
/*! /*!
** Thenable -- Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable ** Thenable -- Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
...@@ -2454,10 +2618,10 @@ _p[22] = { ...@@ -2454,10 +2618,10 @@ _p[22] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[23] = { _p[25] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Minder = _p.r(17); var Minder = _p.r(18);
Minder.registerInitHook(function(options) { Minder.registerInitHook(function(options) {
if (options.readOnly) { if (options.readOnly) {
this.setDisabled(); this.setDisabled();
...@@ -2504,11 +2668,11 @@ _p[23] = { ...@@ -2504,11 +2668,11 @@ _p[23] = {
}; };
//src/core/render.js //src/core/render.js
_p[24] = { _p[26] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Renderer = kity.createClass("Renderer", { var Renderer = kity.createClass("Renderer", {
constructor: function(node) { constructor: function(node) {
this.node = node; this.node = node;
...@@ -2716,12 +2880,12 @@ _p[24] = { ...@@ -2716,12 +2880,12 @@ _p[24] = {
}; };
//src/core/select.js //src/core/select.js
_p[25] = { _p[27] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
Minder.registerInitHook(function() { Minder.registerInitHook(function() {
this._initSelection(); this._initSelection();
}); });
...@@ -2791,6 +2955,11 @@ _p[25] = { ...@@ -2791,6 +2955,11 @@ _p[25] = {
this.renderChangedSelection(lastSelect); this.renderChangedSelection(lastSelect);
return this; return this;
}, },
selectById: function(ids, isSingleSelect) {
ids = utils.isArray(ids) ? ids : [ ids ];
var nodes = this.getNodesById(ids);
return this.select(nodes, isSingleSelect);
},
//当前选区中的节点在给定的节点范围内的保留选中状态, //当前选区中的节点在给定的节点范围内的保留选中状态,
//没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果 //没在给定范围的取消选中,给定范围中的但没在当前选中范围的也做选中效果
toggleSelect: function(node) { toggleSelect: function(node) {
...@@ -2849,13 +3018,13 @@ _p[25] = { ...@@ -2849,13 +3018,13 @@ _p[25] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[26] = { _p[28] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var keymap = _p.r(13); var keymap = _p.r(14);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderEvent = _p.r(11); var MinderEvent = _p.r(12);
/** /**
* 计算包含 meta 键的 keycode * 计算包含 meta 键的 keycode
* *
...@@ -2979,10 +3148,10 @@ _p[26] = { ...@@ -2979,10 +3148,10 @@ _p[26] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[27] = { _p[29] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Minder = _p.r(17); var Minder = _p.r(18);
var sf = ~window.location.href.indexOf("status"); var sf = ~window.location.href.indexOf("status");
var tf = ~window.location.href.indexOf("trace"); var tf = ~window.location.href.indexOf("trace");
Minder.registerInitHook(function() { Minder.registerInitHook(function() {
...@@ -3027,14 +3196,14 @@ _p[27] = { ...@@ -3027,14 +3196,14 @@ _p[27] = {
}; };
//src/core/template.js //src/core/template.js
_p[28] = { _p[30] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var Command = _p.r(7); var Command = _p.r(8);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Module = _p.r(18); var Module = _p.r(19);
var _templates = {}; var _templates = {};
function register(name, supports) { function register(name, supports) {
_templates[name] = supports; _templates[name] = supports;
...@@ -3109,14 +3278,14 @@ _p[28] = { ...@@ -3109,14 +3278,14 @@ _p[28] = {
}; };
//src/core/theme.js //src/core/theme.js
_p[29] = { _p[31] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Module = _p.r(18); var Module = _p.r(19);
var Command = _p.r(7); var Command = _p.r(8);
var cssLikeValueMatcher = { var cssLikeValueMatcher = {
left: function(value) { left: function(value) {
return 3 in value && value[3] || 1 in value && value[1] || value[0]; return 3 in value && value[3] || 1 in value && value[1] || value[0];
...@@ -3165,6 +3334,7 @@ _p[29] = { ...@@ -3165,6 +3334,7 @@ _p[29] = {
return true; return true;
}, },
setTheme: function(name) { setTheme: function(name) {
if (name && !_themes[name]) throw new Error("Theme " + name + " not exists!");
var lastTheme = this._theme; var lastTheme = this._theme;
this._theme = name || null; this._theme = name || null;
var container = this.getRenderTarget(); var container = this.getRenderTarget();
...@@ -3261,9 +3431,9 @@ _p[29] = { ...@@ -3261,9 +3431,9 @@ _p[29] = {
}; };
//src/core/utils.js //src/core/utils.js
_p[30] = { _p[32] = {
value: function(require, exports) { value: function(require, exports) {
var kity = _p.r(15); var kity = _p.r(16);
var uuidMap = {}; var uuidMap = {};
exports.extend = kity.Utils.extend.bind(kity.Utils); exports.extend = kity.Utils.extend.bind(kity.Utils);
exports.each = kity.Utils.each.bind(kity.Utils); exports.each = kity.Utils.each.bind(kity.Utils);
...@@ -3320,9 +3490,9 @@ _p[30] = { ...@@ -3320,9 +3490,9 @@ _p[30] = {
}; };
//src/expose-kityminder.js //src/expose-kityminder.js
_p[31] = { _p[33] = {
value: function(require, exports, module) { value: function(require, exports, module) {
module.exports = window.kityminder = _p.r(32); module.exports = window.kityminder = _p.r(34);
} }
}; };
...@@ -3335,40 +3505,40 @@ _p[31] = { ...@@ -3335,40 +3505,40 @@ _p[31] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[32] = { _p[34] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kityminder = { var kityminder = {
version: _p.r(17).version version: _p.r(18).version
}; };
// 核心导出,大写的部分导出类,小写的部分简单 require 一下 // 核心导出,大写的部分导出类,小写的部分简单 require 一下
// 这里顺序是有讲究的,调整前先弄清楚依赖关系。 // 这里顺序是有讲究的,调整前先弄清楚依赖关系。
_p.r(30); _p.r(32);
kityminder.Minder = _p.r(17); kityminder.Minder = _p.r(18);
kityminder.Command = _p.r(7); kityminder.Command = _p.r(8);
kityminder.Node = _p.r(19); kityminder.Node = _p.r(20);
_p.r(20);
_p.r(6);
kityminder.Event = _p.r(11);
kityminder.data = _p.r(10);
_p.r(8);
kityminder.KeyMap = _p.r(13);
_p.r(26);
_p.r(27);
_p.r(21); _p.r(21);
_p.r(7);
kityminder.Event = _p.r(12);
kityminder.data = _p.r(11);
_p.r(9);
kityminder.KeyMap = _p.r(14);
_p.r(28);
_p.r(29);
_p.r(22);
_p.r(27);
_p.r(13);
_p.r(15);
kityminder.Module = _p.r(19);
_p.r(25); _p.r(25);
_p.r(12); kityminder.Render = _p.r(26);
_p.r(14); kityminder.Connect = _p.r(10);
kityminder.Module = _p.r(18); kityminder.Layout = _p.r(17);
kityminder.Theme = _p.r(31);
kityminder.Template = _p.r(30);
kityminder.Promise = _p.r(24);
_p.r(6);
_p.r(23); _p.r(23);
kityminder.Render = _p.r(24);
kityminder.Connect = _p.r(9);
kityminder.Layout = _p.r(16);
kityminder.Theme = _p.r(29);
kityminder.Template = _p.r(28);
kityminder.Promise = _p.r(22);
// 模块依赖 // 模块依赖
_p.r(38);
_p.r(39);
_p.r(40); _p.r(40);
_p.r(41); _p.r(41);
_p.r(42); _p.r(42);
...@@ -3390,40 +3560,42 @@ _p[32] = { ...@@ -3390,40 +3560,42 @@ _p[32] = {
_p.r(58); _p.r(58);
_p.r(59); _p.r(59);
_p.r(60); _p.r(60);
_p.r(64);
_p.r(61); _p.r(61);
_p.r(63); _p.r(65);
_p.r(62); _p.r(62);
_p.r(37); _p.r(64);
_p.r(33); _p.r(63);
_p.r(34); _p.r(39);
_p.r(35); _p.r(35);
_p.r(36); _p.r(36);
_p.r(70); _p.r(37);
_p.r(73); _p.r(38);
_p.r(72);
_p.r(71); _p.r(71);
_p.r(74);
_p.r(73); _p.r(73);
_p.r(72);
_p.r(74);
_p.r(75);
_p.r(0); _p.r(0);
_p.r(1); _p.r(1);
_p.r(2); _p.r(2);
_p.r(3); _p.r(3);
_p.r(4); _p.r(4);
_p.r(5); _p.r(5);
_p.r(65);
_p.r(69);
_p.r(66); _p.r(66);
_p.r(68); _p.r(70);
_p.r(67); _p.r(67);
_p.r(69);
_p.r(68);
module.exports = kityminder; module.exports = kityminder;
} }
}; };
//src/layout/btree.js //src/layout/btree.js
_p[33] = { _p[35] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Layout = _p.r(16); var Layout = _p.r(17);
[ "left", "right", "top", "bottom" ].forEach(registerLayoutForDirection); [ "left", "right", "top", "bottom" ].forEach(registerLayoutForDirection);
function registerLayoutForDirection(name) { function registerLayoutForDirection(name) {
var axis = name == "left" || name == "right" ? "x" : "y"; var axis = name == "left" || name == "right" ? "x" : "y";
...@@ -3517,7 +3689,7 @@ _p[33] = { ...@@ -3517,7 +3689,7 @@ _p[33] = {
this.align(children, oppsite[name]); this.align(children, oppsite[name]);
this.stack(children, oppsite[axis]); this.stack(children, oppsite[axis]);
var bbox = this.getBranchBox(children); var bbox = this.getBranchBox(children);
var xAdjust, yAdjust; var xAdjust = 0, yAdjust = 0;
if (axis == "x") { if (axis == "x") {
xAdjust = pbox[name]; xAdjust = pbox[name];
xAdjust += dir * parent.getStyle("margin-" + name); xAdjust += dir * parent.getStyle("margin-" + name);
...@@ -3544,10 +3716,10 @@ _p[33] = { ...@@ -3544,10 +3716,10 @@ _p[33] = {
}; };
//src/layout/filetree.js //src/layout/filetree.js
_p[34] = { _p[36] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Layout = _p.r(16); var Layout = _p.r(17);
[ -1, 1 ].forEach(registerLayoutForDir); [ -1, 1 ].forEach(registerLayoutForDir);
function registerLayoutForDir(dir) { function registerLayoutForDir(dir) {
var name = "filetree-" + (dir > 0 ? "down" : "up"); var name = "filetree-" + (dir > 0 ? "down" : "up");
...@@ -3626,10 +3798,10 @@ _p[34] = { ...@@ -3626,10 +3798,10 @@ _p[34] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[35] = { _p[37] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Layout = _p.r(16); var Layout = _p.r(17);
Layout.register("fish-bone-master", kity.createClass("FishBoneMasterLayout", { Layout.register("fish-bone-master", kity.createClass("FishBoneMasterLayout", {
base: Layout, base: Layout,
doLayout: function(parent, children, round) { doLayout: function(parent, children, round) {
...@@ -3680,10 +3852,10 @@ _p[35] = { ...@@ -3680,10 +3852,10 @@ _p[35] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[36] = { _p[38] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Layout = _p.r(16); var Layout = _p.r(17);
Layout.register("fish-bone-slave", kity.createClass("FishBoneSlaveLayout", { Layout.register("fish-bone-slave", kity.createClass("FishBoneSlaveLayout", {
base: Layout, base: Layout,
doLayout: function(parent, children, round) { doLayout: function(parent, children, round) {
...@@ -3733,11 +3905,11 @@ _p[36] = { ...@@ -3733,11 +3905,11 @@ _p[36] = {
}; };
//src/layout/mind.js //src/layout/mind.js
_p[37] = { _p[39] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Layout = _p.r(16); var Layout = _p.r(17);
var Minder = _p.r(17); var Minder = _p.r(18);
Layout.register("mind", kity.createClass({ Layout.register("mind", kity.createClass({
base: Layout, base: Layout,
doLayout: function(node, children) { doLayout: function(node, children) {
...@@ -3789,12 +3961,12 @@ _p[37] = { ...@@ -3789,12 +3961,12 @@ _p[37] = {
}; };
//src/module/arrange.js //src/module/arrange.js
_p[38] = { _p[40] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
kity.extendClass(MinderNode, { kity.extendClass(MinderNode, {
arrange: function(index) { arrange: function(index) {
var parent = this.parent; var parent = this.parent;
...@@ -3927,15 +4099,15 @@ _p[38] = { ...@@ -3927,15 +4099,15 @@ _p[38] = {
}; };
//src/module/basestyle.js //src/module/basestyle.js
_p[39] = { _p[41] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var TextRenderer = _p.r(57); var TextRenderer = _p.r(58);
Module.register("basestylemodule", function() { Module.register("basestylemodule", function() {
var km = this; var km = this;
function getNodeDataOrStyle(node, name) { function getNodeDataOrStyle(node, name) {
...@@ -4042,13 +4214,13 @@ _p[39] = { ...@@ -4042,13 +4214,13 @@ _p[39] = {
}; };
//src/module/clipboard.js //src/module/clipboard.js
_p[40] = { _p[42] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
Module.register("ClipboardModule", function() { Module.register("ClipboardModule", function() {
var km = this, _clipboardNodes = [], _selectedNodes = []; var km = this, _clipboardNodes = [], _selectedNodes = [];
function appendChildNode(parent, child) { function appendChildNode(parent, child) {
...@@ -4066,7 +4238,7 @@ _p[40] = { ...@@ -4066,7 +4238,7 @@ _p[40] = {
function sendToClipboard(nodes) { function sendToClipboard(nodes) {
if (!nodes.length) return; if (!nodes.length) return;
nodes.sort(function(a, b) { nodes.sort(function(a, b) {
return b.getIndex() - a.getIndex(); return a.getIndex() - b.getIndex();
}); });
_clipboardNodes = nodes.map(function(node) { _clipboardNodes = nodes.map(function(node) {
return node.clone(); return node.clone();
...@@ -4151,13 +4323,13 @@ _p[40] = { ...@@ -4151,13 +4323,13 @@ _p[40] = {
}; };
//src/module/dragtree.js //src/module/dragtree.js
_p[41] = { _p[43] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
// 矩形的变形动画定义 // 矩形的变形动画定义
var MoveToParentCommand = kity.createClass("MoveToParentCommand", { var MoveToParentCommand = kity.createClass("MoveToParentCommand", {
base: Command, base: Command,
...@@ -4475,15 +4647,15 @@ _p[41] = { ...@@ -4475,15 +4647,15 @@ _p[41] = {
}; };
//src/module/expand.js //src/module/expand.js
_p[42] = { _p[44] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var keymap = _p.r(13); var keymap = _p.r(14);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("Expand", function() { Module.register("Expand", function() {
var minder = this; var minder = this;
var EXPAND_STATE_DATA = "expandState", STATE_EXPAND = "expand", STATE_COLLAPSE = "collapse"; var EXPAND_STATE_DATA = "expandState", STATE_EXPAND = "expand", STATE_COLLAPSE = "collapse";
...@@ -4544,7 +4716,8 @@ _p[42] = { ...@@ -4544,7 +4716,8 @@ _p[42] = {
km.layout(100); km.layout(100);
}, },
queryState: function(km) { queryState: function(km) {
return km.getSelectedNode() ? 0 : -1; var node = km.getSelectedNode();
return node && !node.isRoot() && !node.isExpanded() ? 0 : -1;
} }
}); });
/** /**
...@@ -4565,6 +4738,27 @@ _p[42] = { ...@@ -4565,6 +4738,27 @@ _p[42] = {
}, },
enableReadOnly: true enableReadOnly: true
}); });
/**
* @command Collapse
* @description 收起当前节点的子树
* @state
* 0: 当前有选中的节点
* -1: 当前没有选中的节点
*/
var CollapseCommand = kity.createClass("CollapseCommand", {
base: Command,
execute: function(km) {
var node = km.getSelectedNode();
if (!node) return;
node.collapse();
node.renderTree();
km.layout();
},
queryState: function(km) {
var node = km.getSelectedNode();
return node && !node.isRoot() && node.isExpanded() ? 0 : -1;
}
});
var Expander = kity.createClass("Expander", { var Expander = kity.createClass("Expander", {
base: kity.Group, base: kity.Group,
constructor: function(node) { constructor: function(node) {
...@@ -4632,7 +4826,8 @@ _p[42] = { ...@@ -4632,7 +4826,8 @@ _p[42] = {
return { return {
commands: { commands: {
expand: ExpandCommand, expand: ExpandCommand,
expandtolevel: ExpandToLevelCommand expandtolevel: ExpandToLevelCommand,
collapse: CollapseCommand
}, },
events: { events: {
layoutapply: function(e) { layoutapply: function(e) {
...@@ -4717,15 +4912,15 @@ _p[42] = { ...@@ -4717,15 +4912,15 @@ _p[42] = {
}; };
//src/module/font.js //src/module/font.js
_p[43] = { _p[45] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var TextRenderer = _p.r(57); var TextRenderer = _p.r(58);
function getNodeDataOrStyle(node, name) { function getNodeDataOrStyle(node, name) {
return node.getData(name) || node.getStyle(name); return node.getData(name) || node.getStyle(name);
} }
...@@ -4863,336 +5058,16 @@ _p[43] = { ...@@ -4863,336 +5058,16 @@ _p[43] = {
} }
}; };
//src/module/history.js
_p[44] = {
value: function(require, exports, module) {
var kity = _p.r(15);
var utils = _p.r(30);
var Minder = _p.r(17);
var MinderNode = _p.r(19);
var Command = _p.r(7);
var Module = _p.r(18);
function compareObject(source, target) {
var tmp;
if (isEmptyObject(source) !== isEmptyObject(target)) {
return false;
}
if (getObjectLength(source) != getObjectLength(target)) {
return false;
}
for (var p in source) {
if (source.hasOwnProperty(p)) {
tmp = source[p];
if (target[p] === undefined) {
return false;
}
if (utils.isObject(tmp) || utils.isArray(tmp)) {
if (utils.isObject(target[p]) !== utils.isObject(tmp)) {
return false;
}
if (utils.isArray(tmp) !== utils.isArray(target[p])) {
return false;
}
if (compareObject(tmp, target[p]) === false) {
return false;
}
} else {
if (tmp != target[p]) {
return false;
}
}
}
}
return true;
}
function getObjectLength(obj) {
if (utils.isArray(obj) || utils.isString(obj)) return obj.length;
var count = 0;
for (var key in obj) if (obj.hasOwnProperty(key)) count++;
return count;
}
function isEmptyObject(obj) {
if (obj === null || obj === undefined) return true;
if (utils.isArray(obj) || utils.isString(obj)) return obj.length === 0;
for (var key in obj) if (obj.hasOwnProperty(key)) return false;
return true;
}
function getValueByIndex(data, index) {
var initIndex = 0, result = 0;
data.forEach(function(arr, i) {
if (initIndex + arr.length >= index) {
if (index - initIndex == arr.length) {
if (arr.length == 1 && arr[0].width === 0) {
initIndex++;
return;
}
result = {
x: arr[arr.length - 1].x + arr[arr.length - 1].width,
y: arr[arr.length - 1].y
};
} else {
result = arr[index - initIndex];
}
return false;
} else {
initIndex += arr.length + (arr.length == 1 && arr[0].width === 0 ? 0 : 1);
}
});
return result;
}
function getNodeIndex(node, ignoreTextNode) {
var preNode = node, i = 0;
while (preNode = preNode.previousSibling) {
if (ignoreTextNode && preNode.nodeType == 3) {
if (preNode.nodeType != preNode.nextSibling.nodeType) {
i++;
}
continue;
}
i++;
}
return i;
}
var km = this;
var Scene = kity.createClass("Scene", {
constructor: function(root, inputStatus) {
this.data = root.clone();
this.inputStatus = inputStatus;
},
getData: function() {
return this.data;
},
cloneData: function() {
return this.getData().clone();
},
equals: function(scene) {
return this.getData().compareTo(scene.getData());
},
isInputStatus: function() {
return this.inputStatus;
},
setInputStatus: function(status) {
this.inputStatus = status;
}
});
var HistoryManager = kity.createClass("HistoryManager", {
constructor: function(km) {
this.list = [];
this.index = 0;
this.hasUndo = false;
this.hasRedo = false;
this.km = km;
},
undo: function() {
if (this.hasUndo) {
var currentScene = this.list[this.index];
//如果是输入文字时的保存,直接回复当前场景
if (currentScene && currentScene.isInputStatus()) {
this.saveScene();
this.restore(--this.index);
currentScene.setInputStatus(false);
return;
}
if (this.list.length == 1) {
this.restore(0);
return;
}
if (!this.list[this.index - 1] && this.list.length == 1) {
this.reset();
return;
}
while (this.list[this.index].equals(this.list[this.index - 1])) {
this.index--;
if (this.index === 0) {
return this.restore(0);
}
}
this.restore(--this.index);
}
},
redo: function() {
if (this.hasRedo) {
while (this.list[this.index].equals(this.list[this.index + 1])) {
this.index++;
if (this.index == this.list.length - 1) {
return this.restore(this.index);
}
}
this.restore(++this.index);
}
},
partialRenewal: function(target) {
var selectedNodes = [];
function compareNode(source, target) {
if (source.getText() != target.getText()) {
return false;
}
if (compareObject(source.getData(), target.getData()) === false) {
return false;
}
return true;
}
function appendChildNode(parent, child) {
if (child.isSelected()) {
selectedNodes.push(child);
}
km.appendNode(child, parent);
child.render();
var children = child.children.slice();
for (var i = 0, ci; ci = children[i++]; ) {
appendChildNode(child, ci);
}
}
function traverseNode(srcNode, tagNode) {
if (compareNode(srcNode, tagNode) === false) {
srcNode.setValue(tagNode);
}
//todo,这里有性能问题,变成全部render了
srcNode.render();
if (srcNode.isSelected()) {
selectedNodes.push(srcNode);
}
for (var i = 0, j = 0, si, tj; si = srcNode.children[i], tj = tagNode.children[j],
si || tj; i++, j++) {
if (si && !tj) {
i--;
km.removeNode(si);
} else if (!si && tj) {
j--;
appendChildNode(srcNode, tj);
} else {
traverseNode(si, tj);
}
}
}
var km = this.km;
traverseNode(km.getRoot(), target);
km.layout(200);
km.select(selectedNodes, true);
selectedNodes = [];
},
restore: function(index) {
index = index === undefined ? this.index : index;
var scene = this.list[index];
this.partialRenewal(scene.cloneData());
this.update();
this.km.fire("restoreScene");
this.km.fire("contentChange");
},
getScene: function(inputStatus) {
return new Scene(this.km.getRoot(), inputStatus);
},
saveScene: function(inputStatus) {
var currentScene = this.getScene(inputStatus);
var lastScene = this.list[this.index];
if (lastScene && lastScene.equals(currentScene)) {
if (inputStatus) {
lastScene.setInputStatus(true);
this.update();
}
return;
}
this.list = this.list.slice(0, this.index + 1);
this.list.push(currentScene);
//如果大于最大数量了,就把最前的剔除
if (this.list.length > this.km.getOption("maxUndoCount")) {
this.list.shift();
}
this.index = this.list.length - 1;
//跟新undo/redo状态
this.update();
},
update: function() {
this.hasRedo = !!this.list[this.index + 1];
this.hasUndo = !!this.list[this.index - 1];
var currentScene = this.list[this.index];
if (currentScene && currentScene.isInputStatus()) {
this.hasUndo = true;
}
},
reset: function() {
this.list = [];
this.index = 0;
this.hasUndo = false;
this.hasRedo = false;
}
});
Module.register("HistoryModule", function() {
//为km实例添加history管理
this.historyManager = new HistoryManager(this);
return {
defaultOptions: {
maxUndoCount: 20,
maxInputCount: 20
},
commands: {
/**
* @command Undo
* @description 回退上一步操作
* @state
* 0: 当前有可回退的内容
* -1: 当前没有可回退的内容
*/
undo: kity.createClass("UndoCommand", {
base: Command,
execute: function(km) {
km.historyManager.undo();
},
queryState: function(km) {
return km.historyManager.hasUndo ? 0 : -1;
},
isNeedUndo: function() {
return false;
}
}),
/**
* @command Redo
* @description 重做下一步已回退的操作
* @state
* 0: 当前有可重做的内容
* -1: 当前没有可重做的内容
*/
redo: kity.createClass("RedoCommand", {
base: Command,
execute: function(km) {
km.historyManager.redo();
},
queryState: function(km) {
return km.historyManager.hasRedo ? 0 : -1;
},
isNeedUndo: function() {
return false;
}
})
},
commandShortcutKeys: {
undo: "ctrl+z",
//undo
redo: "ctrl+y"
},
events: {
saveScene: function(e) {
this.historyManager.saveScene(e.inputStatus);
},
"import": function() {
this.historyManager.reset();
}
}
};
});
}
};
//src/module/hyperlink.js //src/module/hyperlink.js
_p[45] = { _p[46] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
// jscs:disable maximumLineLength // jscs:disable maximumLineLength
var linkShapePath = "M16.614,10.224h-1.278c-1.668,0-3.07-1.07-3.599-2.556h4.877c0.707,0,1.278-0.571,1.278-1.278V3.834 c0-0.707-0.571-1.278-1.278-1.278h-4.877C12.266,1.071,13.668,0,15.336,0h1.278c2.116,0,3.834,1.716,3.834,3.834V6.39 C20.448,8.508,18.73,10.224,16.614,10.224z M5.112,5.112c0-0.707,0.573-1.278,1.278-1.278h7.668c0.707,0,1.278,0.571,1.278,1.278 S14.765,6.39,14.058,6.39H6.39C5.685,6.39,5.112,5.819,5.112,5.112z M2.556,3.834V6.39c0,0.707,0.573,1.278,1.278,1.278h4.877 c-0.528,1.486-1.932,2.556-3.599,2.556H3.834C1.716,10.224,0,8.508,0,6.39V3.834C0,1.716,1.716,0,3.834,0h1.278 c1.667,0,3.071,1.071,3.599,2.556H3.834C3.129,2.556,2.556,3.127,2.556,3.834z"; var linkShapePath = "M16.614,10.224h-1.278c-1.668,0-3.07-1.07-3.599-2.556h4.877c0.707,0,1.278-0.571,1.278-1.278V3.834 c0-0.707-0.571-1.278-1.278-1.278h-4.877C12.266,1.071,13.668,0,15.336,0h1.278c2.116,0,3.834,1.716,3.834,3.834V6.39 C20.448,8.508,18.73,10.224,16.614,10.224z M5.112,5.112c0-0.707,0.573-1.278,1.278-1.278h7.668c0.707,0,1.278,0.571,1.278,1.278 S14.765,6.39,14.058,6.39H6.39C5.685,6.39,5.112,5.819,5.112,5.112z M2.556,3.834V6.39c0,0.707,0.573,1.278,1.278,1.278h4.877 c-0.528,1.486-1.932,2.556-3.599,2.556H3.834C1.716,10.224,0,8.508,0,6.39V3.834C0,1.716,1.716,0,3.834,0h1.278 c1.667,0,3.071,1.071,3.599,2.556H3.834C3.129,2.556,2.556,3.127,2.556,3.834z";
Module.register("hyperlink", { Module.register("hyperlink", {
...@@ -5288,15 +5163,15 @@ _p[45] = { ...@@ -5288,15 +5163,15 @@ _p[45] = {
}; };
//src/module/image.js //src/module/image.js
_p[46] = { _p[47] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("image", function() { Module.register("image", function() {
function loadImageSize(url, callback) { function loadImageSize(url, callback) {
var img = document.createElement("img"); var img = document.createElement("img");
...@@ -5410,16 +5285,16 @@ _p[46] = { ...@@ -5410,16 +5285,16 @@ _p[46] = {
}; };
//src/module/keynav.js //src/module/keynav.js
_p[47] = { _p[48] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var keymap = _p.r(13); var keymap = _p.r(14);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("KeyboardModule", function() { Module.register("KeyboardModule", function() {
var min = Math.min, max = Math.max, abs = Math.abs, sqrt = Math.sqrt, exp = Math.exp; var min = Math.min, max = Math.max, abs = Math.abs, sqrt = Math.sqrt, exp = Math.exp;
function buildPositionNetwork(root) { function buildPositionNetwork(root) {
...@@ -5435,8 +5310,7 @@ _p[47] = { ...@@ -5435,8 +5310,7 @@ _p[47] = {
bottom: p.y + p.height, bottom: p.y + p.height,
width: p.width, width: p.width,
height: p.height, height: p.height,
node: node, node: node
text: node.getText()
}); });
} }
}); });
...@@ -5455,10 +5329,17 @@ _p[47] = { ...@@ -5455,10 +5329,17 @@ _p[47] = {
xDist = xMax - xMin - box1.width - box2.width; xDist = xMax - xMin - box1.width - box2.width;
yDist = yMax - yMin - box1.height - box2.height; yDist = yMax - yMin - box1.height - box2.height;
if (xDist < 0) dist = yDist; else if (yDist < 0) dist = xDist; else dist = sqrt(xDist * xDist + yDist * yDist); if (xDist < 0) dist = yDist; else if (yDist < 0) dist = xDist; else dist = sqrt(xDist * xDist + yDist * yDist);
return { var node1 = box1.node;
cx: dist, var node2 = box2.node;
cy: dist // sibling
}; if (node1.parent == node2.parent) {
dist /= 10;
}
// parent
if (node2.parent == node1) {
dist /= 5;
}
return dist;
} }
function findClosestPointsFor(pointIndexes, iFind) { function findClosestPointsFor(pointIndexes, iFind) {
var find = pointIndexes[iFind]; var find = pointIndexes[iFind];
...@@ -5470,36 +5351,36 @@ _p[47] = { ...@@ -5470,36 +5351,36 @@ _p[47] = {
dist = getCoefedDistance(current, find); dist = getCoefedDistance(current, find);
// left check // left check
if (current.right < find.left) { if (current.right < find.left) {
if (!most.left || dist.cx < most.left.dist) { if (!most.left || dist < most.left.dist) {
most.left = { most.left = {
dist: dist.cx, dist: dist,
node: current.node node: current.node
}; };
} }
} }
// right check // right check
if (current.left > find.right) { if (current.left > find.right) {
if (!most.right || dist.cx < most.right.dist) { if (!most.right || dist < most.right.dist) {
most.right = { most.right = {
dist: dist.cx, dist: dist,
node: current.node node: current.node
}; };
} }
} }
// top check // top check
if (current.bottom < find.top) { if (current.bottom < find.top) {
if (!most.top || dist.cy < most.top.dist) { if (!most.top || dist < most.top.dist) {
most.top = { most.top = {
dist: dist.cy, dist: dist,
node: current.node node: current.node
}; };
} }
} }
// bottom check // bottom check
if (current.top > find.bottom) { if (current.top > find.bottom) {
if (!most.down || dist.cy < most.down.dist) { if (!most.down || dist < most.down.dist) {
most.down = { most.down = {
dist: dist.cy, dist: dist,
node: current.node node: current.node
}; };
} }
...@@ -5540,6 +5421,7 @@ _p[47] = { ...@@ -5540,6 +5421,7 @@ _p[47] = {
[ "left", "right", "up", "down" ].forEach(function(key) { [ "left", "right", "up", "down" ].forEach(function(key) {
if (e.isShortcutKey(key)) { if (e.isShortcutKey(key)) {
navigateTo(minder, key == "up" ? "top" : key); navigateTo(minder, key == "up" ? "top" : key);
e.preventDefault();
} }
}); });
} }
...@@ -5558,11 +5440,11 @@ _p[47] = { ...@@ -5558,11 +5440,11 @@ _p[47] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[48] = { _p[49] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
/** /**
* @command Layout * @command Layout
* @description 设置选中节点的布局 * @description 设置选中节点的布局
...@@ -5633,15 +5515,15 @@ _p[48] = { ...@@ -5633,15 +5515,15 @@ _p[48] = {
}; };
//src/module/node.js //src/module/node.js
_p[49] = { _p[50] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
/** /**
* @command AppendChildNode * @command AppendChildNode
* @description 添加子节点到选中的节点中 * @description 添加子节点到选中的节点中
...@@ -5657,10 +5539,14 @@ _p[49] = { ...@@ -5657,10 +5539,14 @@ _p[49] = {
if (!parent) { if (!parent) {
return null; return null;
} }
parent.expand();
var node = km.createNode(text, parent); var node = km.createNode(text, parent);
km.select(node, true); km.select(node, true);
node.render(); if (parent.isExpanded()) {
node.render();
} else {
parent.expand();
parent.renderTree();
}
km.layout(600); km.layout(600);
}, },
queryState: function(km) { queryState: function(km) {
...@@ -5721,7 +5607,7 @@ _p[49] = { ...@@ -5721,7 +5607,7 @@ _p[49] = {
}, },
queryState: function(km) { queryState: function(km) {
var selectedNode = km.getSelectedNode(); var selectedNode = km.getSelectedNode();
return selectedNode ? 0 : -1; return selectedNode && !selectedNode.isRoot() ? 0 : -1;
} }
}); });
var AppendParentCommand = kity.createClass("AppendParentCommand", { var AppendParentCommand = kity.createClass("AppendParentCommand", {
...@@ -5742,7 +5628,7 @@ _p[49] = { ...@@ -5742,7 +5628,7 @@ _p[49] = {
}, },
queryState: function(km) { queryState: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if (!nodes.length) return; if (!nodes.length) return -1;
var parent = nodes[0].parent; var parent = nodes[0].parent;
if (!parent) return -1; if (!parent) return -1;
for (var i = 1; i < nodes.length; i++) { for (var i = 1; i < nodes.length; i++) {
...@@ -5779,15 +5665,15 @@ _p[49] = { ...@@ -5779,15 +5665,15 @@ _p[49] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[50] = { _p[51] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("NoteModule", function() { Module.register("NoteModule", function() {
var NOTE_PATH = "M9,9H3V8h6L9,9L9,9z M9,7H3V6h6V7z M9,5H3V4h6V5z M8.5,11H2V2h8v7.5 M9,12l2-2V1H1v11"; var NOTE_PATH = "M9,9H3V8h6L9,9L9,9z M9,7H3V6h6V7z M9,5H3V4h6V5z M8.5,11H2V2h8v7.5 M9,12l2-2V1H1v11";
/** /**
...@@ -5877,15 +5763,15 @@ _p[50] = { ...@@ -5877,15 +5763,15 @@ _p[50] = {
}; };
//src/module/outline.js //src/module/outline.js
_p[51] = { _p[52] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
var OutlineRenderer = kity.createClass("OutlineRenderer", { var OutlineRenderer = kity.createClass("OutlineRenderer", {
base: Renderer, base: Renderer,
create: function(node) { create: function(node) {
...@@ -5973,15 +5859,15 @@ _p[51] = { ...@@ -5973,15 +5859,15 @@ _p[51] = {
}; };
//src/module/priority.js //src/module/priority.js
_p[52] = { _p[53] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("PriorityModule", function() { Module.register("PriorityModule", function() {
var minder = this; var minder = this;
// Designed by Akikonata // Designed by Akikonata
...@@ -6099,15 +5985,15 @@ _p[52] = { ...@@ -6099,15 +5985,15 @@ _p[52] = {
}; };
//src/module/progress.js //src/module/progress.js
_p[53] = { _p[54] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("ProgressModule", function() { Module.register("ProgressModule", function() {
var minder = this; var minder = this;
var PROGRESS_DATA = "progress"; var PROGRESS_DATA = "progress";
...@@ -6224,15 +6110,15 @@ _p[53] = { ...@@ -6224,15 +6110,15 @@ _p[53] = {
}; };
//src/module/resource.js //src/module/resource.js
_p[54] = { _p[55] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("Resource", function() { Module.register("Resource", function() {
/** /**
* 自动使用的颜色序列 * 自动使用的颜色序列
...@@ -6452,15 +6338,15 @@ _p[54] = { ...@@ -6452,15 +6338,15 @@ _p[54] = {
}; };
//src/module/select.js //src/module/select.js
_p[55] = { _p[56] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("Select", function() { Module.register("Select", function() {
var minder = this; var minder = this;
var rc = minder.getRenderContainer(); var rc = minder.getRenderContainer();
...@@ -6557,7 +6443,7 @@ _p[55] = { ...@@ -6557,7 +6443,7 @@ _p[55] = {
this.removeAllSelectedNodes(); this.removeAllSelectedNodes();
marqueeActivator.selectStart(e); marqueeActivator.selectStart(e);
this.setStatus("normal"); this.setStatus("normal");
} else if (e.originEvent.shiftKey) { } else if (e.isShortcutKey("Ctrl")) {
this.toggleSelect(downNode); this.toggleSelect(downNode);
} else if (!downNode.isSelected()) { } else if (!downNode.isSelected()) {
this.select(downNode, true); this.select(downNode, true);
...@@ -6597,15 +6483,15 @@ _p[55] = { ...@@ -6597,15 +6483,15 @@ _p[55] = {
}; };
//src/module/style.js //src/module/style.js
_p[56] = { _p[57] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("StyleModule", function() { Module.register("StyleModule", function() {
var styleNames = [ "font-size", "font-family", "font-weight", "font-style", "background", "color" ]; var styleNames = [ "font-size", "font-family", "font-weight", "font-style", "background", "color" ];
var styleClipBoard = null; var styleClipBoard = null;
...@@ -6702,15 +6588,15 @@ _p[56] = { ...@@ -6702,15 +6588,15 @@ _p[56] = {
}; };
//src/module/text.js //src/module/text.js
_p[57] = { _p[58] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
var FONT_ADJUST = { var FONT_ADJUST = {
"微软雅黑,Microsoft YaHei": -.15, "微软雅黑,Microsoft YaHei": -.15,
"arial black,avant garde": -.17, "arial black,avant garde": -.17,
...@@ -6828,15 +6714,15 @@ _p[57] = { ...@@ -6828,15 +6714,15 @@ _p[57] = {
}; };
//src/module/view.js //src/module/view.js
_p[58] = { _p[59] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
var ViewDragger = kity.createClass("ViewDragger", { var ViewDragger = kity.createClass("ViewDragger", {
constructor: function(minder) { constructor: function(minder) {
this._minder = minder; this._minder = minder;
...@@ -7124,15 +7010,15 @@ _p[58] = { ...@@ -7124,15 +7010,15 @@ _p[58] = {
}; };
//src/module/zoom.js //src/module/zoom.js
_p[59] = { _p[60] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var utils = _p.r(30); var utils = _p.r(32);
var Minder = _p.r(17); var Minder = _p.r(18);
var MinderNode = _p.r(19); var MinderNode = _p.r(20);
var Command = _p.r(7); var Command = _p.r(8);
var Module = _p.r(18); var Module = _p.r(19);
var Renderer = _p.r(24); var Renderer = _p.r(26);
Module.register("Zoom", function() { Module.register("Zoom", function() {
var me = this; var me = this;
var timeline; var timeline;
...@@ -7306,9 +7192,9 @@ _p[59] = { ...@@ -7306,9 +7192,9 @@ _p[59] = {
}; };
//src/protocol/json.js //src/protocol/json.js
_p[60] = { _p[61] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var data = _p.r(10); var data = _p.r(11);
data.registerProtocol("json", module.exports = { data.registerProtocol("json", module.exports = {
fileDescription: "KityMinder 格式", fileDescription: "KityMinder 格式",
fileExtension: ".km", fileExtension: ".km",
...@@ -7325,9 +7211,9 @@ _p[60] = { ...@@ -7325,9 +7211,9 @@ _p[60] = {
}; };
//src/protocol/markdown.js //src/protocol/markdown.js
_p[61] = { _p[62] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var data = _p.r(10); var data = _p.r(11);
var LINE_ENDING_SPLITER = /\r\n|\r|\n/; var LINE_ENDING_SPLITER = /\r\n|\r|\n/;
var EMPTY_LINE = ""; var EMPTY_LINE = "";
var NOTE_MARK_START = "<!--Note-->"; var NOTE_MARK_START = "<!--Note-->";
...@@ -7456,11 +7342,11 @@ _p[61] = { ...@@ -7456,11 +7342,11 @@ _p[61] = {
}; };
//src/protocol/png.js //src/protocol/png.js
_p[62] = { _p[63] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var data = _p.r(10); var data = _p.r(11);
var Promise = _p.r(22); var Promise = _p.r(24);
var DomURL = window.URL || window.webkitURL || window; var DomURL = window.URL || window.webkitURL || window;
function loadImage(url, callback) { function loadImage(url, callback) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
...@@ -7570,9 +7456,9 @@ _p[62] = { ...@@ -7570,9 +7456,9 @@ _p[62] = {
}; };
//src/protocol/svg.js //src/protocol/svg.js
_p[63] = { _p[64] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var data = _p.r(10); var data = _p.r(11);
data.registerProtocol("svg", module.exports = { data.registerProtocol("svg", module.exports = {
fileDescription: "SVG 矢量图", fileDescription: "SVG 矢量图",
fileExtension: ".svg", fileExtension: ".svg",
...@@ -7604,9 +7490,9 @@ _p[63] = { ...@@ -7604,9 +7490,9 @@ _p[63] = {
}; };
//src/protocol/text.js //src/protocol/text.js
_p[64] = { _p[65] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var data = _p.r(10); var data = _p.r(11);
var LINE_ENDING = "\r", LINE_ENDING_SPLITER = /\r\n|\r|\n/, TAB_CHAR = " "; var LINE_ENDING = "\r", LINE_ENDING_SPLITER = /\r\n|\r|\n/, TAB_CHAR = " ";
function repeat(s, n) { function repeat(s, n) {
var result = ""; var result = "";
...@@ -7690,9 +7576,9 @@ _p[64] = { ...@@ -7690,9 +7576,9 @@ _p[64] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[65] = { _p[66] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var template = _p.r(28); var template = _p.r(30);
template.register("default", { template.register("default", {
getLayout: function(node) { getLayout: function(node) {
if (node.getData("layout")) return node.getData("layout"); if (node.getData("layout")) return node.getData("layout");
...@@ -7724,9 +7610,9 @@ _p[65] = { ...@@ -7724,9 +7610,9 @@ _p[65] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[66] = { _p[67] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var template = _p.r(28); var template = _p.r(30);
template.register("filetree", { template.register("filetree", {
getLayout: function(node) { getLayout: function(node) {
if (node.getData("layout")) return node.getData("layout"); if (node.getData("layout")) return node.getData("layout");
...@@ -7752,9 +7638,9 @@ _p[66] = { ...@@ -7752,9 +7638,9 @@ _p[66] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[67] = { _p[68] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var template = _p.r(28); var template = _p.r(30);
template.register("fish-bone", { template.register("fish-bone", {
getLayout: function(node) { getLayout: function(node) {
if (node.getData("layout")) return node.getData("layout"); if (node.getData("layout")) return node.getData("layout");
...@@ -7794,9 +7680,9 @@ _p[67] = { ...@@ -7794,9 +7680,9 @@ _p[67] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[68] = { _p[69] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var template = _p.r(28); var template = _p.r(30);
template.register("right", { template.register("right", {
getLayout: function(node) { getLayout: function(node) {
return node.getData("layout") || "right"; return node.getData("layout") || "right";
...@@ -7818,9 +7704,9 @@ _p[68] = { ...@@ -7818,9 +7704,9 @@ _p[68] = {
* @author: techird * @author: techird
* @copyright: Baidu FEX, 2014 * @copyright: Baidu FEX, 2014
*/ */
_p[69] = { _p[70] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var template = _p.r(28); var template = _p.r(30);
template.register("structure", { template.register("structure", {
getLayout: function(node) { getLayout: function(node) {
return node.getData("layout") || "bottom"; return node.getData("layout") || "bottom";
...@@ -7833,9 +7719,9 @@ _p[69] = { ...@@ -7833,9 +7719,9 @@ _p[69] = {
}; };
//src/theme/default.js //src/theme/default.js
_p[70] = { _p[71] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var theme = _p.r(29); var theme = _p.r(31);
[ "classic", "classic-compact" ].forEach(function(name) { [ "classic", "classic-compact" ].forEach(function(name) {
var compact = name == "classic-compact"; var compact = name == "classic-compact";
/* jscs:disable maximumLineLength */ /* jscs:disable maximumLineLength */
...@@ -7892,9 +7778,9 @@ _p[70] = { ...@@ -7892,9 +7778,9 @@ _p[70] = {
}; };
//src/theme/fish.js //src/theme/fish.js
_p[71] = { _p[72] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var theme = _p.r(29); var theme = _p.r(31);
theme.register("fish", { theme.register("fish", {
background: "#3A4144 url(ui/theme/default/images/grid.png) repeat", background: "#3A4144 url(ui/theme/default/images/grid.png) repeat",
"root-color": "#430", "root-color": "#430",
...@@ -7943,10 +7829,10 @@ _p[71] = { ...@@ -7943,10 +7829,10 @@ _p[71] = {
}; };
//src/theme/fresh.js //src/theme/fresh.js
_p[72] = { _p[73] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var kity = _p.r(15); var kity = _p.r(16);
var theme = _p.r(29); var theme = _p.r(31);
function hsl(h, s, l) { function hsl(h, s, l) {
return kity.Color.createHSL(h, s, l); return kity.Color.createHSL(h, s, l);
} }
...@@ -8012,9 +7898,9 @@ _p[72] = { ...@@ -8012,9 +7898,9 @@ _p[72] = {
}; };
//src/theme/snow.js //src/theme/snow.js
_p[73] = { _p[74] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var theme = _p.r(29); var theme = _p.r(31);
[ "snow", "snow-compact" ].forEach(function(name) { [ "snow", "snow-compact" ].forEach(function(name) {
var compact = name == "snow-compact"; var compact = name == "snow-compact";
/* jscs:disable maximumLineLength */ /* jscs:disable maximumLineLength */
...@@ -8067,9 +7953,9 @@ _p[73] = { ...@@ -8067,9 +7953,9 @@ _p[73] = {
}; };
//src/theme/wire.js //src/theme/wire.js
_p[74] = { _p[75] = {
value: function(require, exports, module) { value: function(require, exports, module) {
var theme = _p.r(29); var theme = _p.r(31);
theme.register("wire", { theme.register("wire", {
background: "black", background: "black",
color: "#999", color: "#999",
...@@ -8097,7 +7983,7 @@ _p[74] = { ...@@ -8097,7 +7983,7 @@ _p[74] = {
}; };
var moduleMapping = { var moduleMapping = {
"expose-kityminder": 31 "expose-kityminder": 33
}; };
function use(name) { function use(name) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "kityminder", "name": "kityminder",
"title": "kityminder", "title": "kityminder",
"description": "KityMinder Core Implement", "description": "KityMinder Core Implement",
"version": "1.4.0", "version": "1.4.1",
"homepage": "https://github.com/fex-team/kityminder-core", "homepage": "https://github.com/fex-team/kityminder-core",
"author": { "author": {
"name": "Baidu FEX", "name": "Baidu FEX",
......
...@@ -30,7 +30,7 @@ define(function(require, exports, module) { ...@@ -30,7 +30,7 @@ define(function(require, exports, module) {
} }
}); });
Minder.version = '1.4.0'; Minder.version = '1.4.1';
Minder.registerInitHook = function(hook) { Minder.registerInitHook = function(hook) {
_initHooks.push(hook); _initHooks.push(hook);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment