Skip to content

Commit

Permalink
Merge branch 'release/1.3.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
techird committed Nov 20, 2014
2 parents 87c12e9 + deaef9d commit 85c8d1d
Show file tree
Hide file tree
Showing 18 changed files with 435 additions and 178 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

# KityMinder 更新日志

## v1.3.5

### 功能更新

1. 支持 Markdown 格式导入和导出

### 问题修复

1. 修复备注在分享页面不能查看的问题
2. 修复字体颜色修改不能撤销的问题

## v1.3.4

### 功能更新
Expand Down Expand Up @@ -142,7 +153,7 @@
7. 可指定放大缩小的百分比


## 问题修复
### 问题修复

1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题
2. 优化了拖拽节点操作体验
Expand Down
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = function(grunt) {
// Metadata.
pkg: grunt.file.readJSON('package.json'),

clean: ['dist', 'native-support/upload', 'native-support/src/tmp'],
clean: ['dist', 'native-support/upload/', 'native-support/src/tmp/'],

concat: concatConfigs,

Expand Down
3 changes: 3 additions & 0 deletions import.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
{ path: 'src/protocol/freemind.js', pack: 'edit' },
{ path: 'src/protocol/mindmanager.js', pack: 'edit' },
{ path: 'src/protocol/plain.js', pack: 'edit|share|m-share' },
{ path: 'src/protocol/markdown.js', pack: 'edit|share|m-share' },
{ path: 'src/protocol/json.js', pack: 'edit|share|m-share' },
{ path: 'src/protocol/png.js', pack: 'edit|share|m-share' },
{ path: 'src/protocol/svg.js', pack: 'edit|share|m-share' },
Expand All @@ -138,6 +139,7 @@
{ path: 'ui/eve.js', pack: 'edit|share|m-share' },
{ path: 'ui/memory.js', pack: 'edit|share|m-share' },
{ path: 'ui/fuix.js', pack: 'edit|share|m-share' },
{ path: 'ui/axss.js', pack: 'edit|share|m-share' },
{ path: 'ui/fiox.js', pack: 'edit' },

/* UI 组件 */
Expand Down Expand Up @@ -211,6 +213,7 @@
{ path: 'ui/ribbon/idea/link.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/image.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/note.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/notepreview.js', pack: 'edit|share' },
{ path: 'ui/ribbon/idea/priority.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/progress.js', pack: 'edit' },
{ path: 'ui/ribbon/idea/resource.js', pack: 'edit' },
Expand Down
2 changes: 2 additions & 0 deletions lang/zh-cn/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ KityMinder.LANG['zh-cn'] = {
},
'theme': {
'classic': '脑图经典',
'classic-compact': '紧凑经典',
'snow': '温柔冷光',
'snow-compact': '紧凑冷光',
'fish': '鱼骨图',
'wire': '线框',
'fresh-red': '清新红',
Expand Down
2 changes: 1 addition & 1 deletion lib/kity
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "kityminder",
"title": "kityminder",
"description": "Kity Minder",
"version": "1.3.4",
"version": "1.3.5",
"homepage": "https://github.com/fex-team/kityminder",
"author": {
"name": "f-cube @ FEX",
Expand Down
2 changes: 1 addition & 1 deletion src/core/kityminder.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var KityMinder = window.KM = window.KityMinder = function() {
instanceId = 0,
uuidMap = {};
return {
version: '1.3.4',
version: '1.3.5',
uuid: function(name) {
name = name || 'unknown';
uuidMap[name] = uuidMap[name] || 0;
Expand Down
3 changes: 2 additions & 1 deletion src/module/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ KityMinder.registerModule('Expand', function() {
if (node.getLevel() == level) node.collapse();
});
km.refresh(100);
}
},
enableReadOnly: true
});

var Expander = kity.createClass('Expander', {
Expand Down
8 changes: 3 additions & 5 deletions src/module/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ KityMinder.registerModule("fontmodule", function() {
var fontFamily = getNodeDataOrStyle(node, 'font-family');
var fontSize = getNodeDataOrStyle(node, 'font-size');
var fontHash = [fontFamily, fontSize].join('/');

if (foreColor.toString() != node.getTmpData('fore-color')) {
textGroup.fill(foreColor);
node.setTmpData('fore-color', foreColor.toString());
}

textGroup.fill(foreColor);
node.setTmpData('fore-color', foreColor.toString());

textGroup.eachItem(function(index,item){
item.setFont({
Expand Down
168 changes: 168 additions & 0 deletions src/protocol/markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* @fileOverview
*
* Markdown 格式导入导出支持
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/

KityMinder.registerProtocol('markdown', function() {
var LINE_ENDING_SPLITER = /\r\n|\r|\n/;
var EMPTY_LINE = '';
var NOTE_MARK_START = '<!--Note-->';
var NOTE_MARK_CLOSE = '<!--/Note-->';

function encode(json) {

return _build(json, 1).join('\n');
}

function _build(node, level) {
var lines = [];

level = level || 1;

var sharps = _generateHeaderSharp(level);
lines.push(sharps + ' ' + node.data.text);
lines.push(EMPTY_LINE);

var note = node.data.note;
if (note) {
var hasSharp = /^#/.test(note);
if (hasSharp) {
lines.push(NOTE_MARK_START);
note = note.replace(/^#+/gm, function($0) {
return sharps + $0;
});
}
lines.push(note);
if (hasSharp) {
lines.push(NOTE_MARK_CLOSE);
}
lines.push(EMPTY_LINE);
}

if (node.children) node.children.forEach(function(child) {
lines = lines.concat(_build(child, level + 1));
});

return lines;
}

function _generateHeaderSharp(level) {
var sharps = '';
while(level--) sharps += '#';
return sharps;
}

function decode(markdown) {

var json,
parentMap = {},
lines, line, lineInfo, level, node, parent, noteProgress, codeBlock;

// 一级标题转换 `{title}\n===` => `# {title}`
markdown = markdown.replace(/^(.+)\n={3,}/, function($0, $1) {
return '# ' + $1;
});

lines = markdown.split(LINE_ENDING_SPLITER);

// 按行分析
for (var i = 0; i < lines.length; i++) {
line = lines[i];

lineInfo = _resolveLine(line);

// 备注标记处理
if (lineInfo.noteClose) {
noteProgress = false;
continue;
} else if (lineInfo.noteStart) {
noteProgress = true;
continue;
}

// 代码块处理
codeBlock = lineInfo.codeBlock ? !codeBlock : codeBlock;

// 备注条件:备注标签中,非标题定义,或标题越位
if (noteProgress || codeBlock || !lineInfo.level || lineInfo.level > level + 1) {
if (node) _pushNote(node, line);
continue;
}

// 标题处理
level = lineInfo.level;
node = _initNode(lineInfo.content, parentMap[level - 1]);
parentMap[level] = node;
}

_cleanUp(parentMap[1]);
return parentMap[1];
}

function _initNode(text, parent) {
var node = {
data: {
text: text,
note: ''
}
};
if (parent) {
if (parent.children) parent.children.push(node);
else parent.children = [node];
}
return node;
}

function _pushNote(node, line) {
node.data.note += line + '\n';
}

function _isEmpty(line) {
return !/\S/.test(line);
}

function _resolveLine(line) {
var match = /^(#+)?\s*(.*)$/.exec(line);
return {
level: match[1] && match[1].length || null,
content: match[2],
noteStart: line == NOTE_MARK_START,
noteClose: line == NOTE_MARK_CLOSE,
codeBlock: /^\s*```/.test(line)
};
}

function _cleanUp(node) {
if (!/\S/.test(node.data.note)) {
node.data.note = null;
delete node.data.note;
} else {
var notes = node.data.note.split('\n');
while(notes.length && !/\S/.test(notes[0])) notes.shift();
while(notes.length && !/\S/.test(notes[notes.length - 1])) notes.pop();
node.data.note = notes.join('\n');
}
if (node.children) node.children.forEach(_cleanUp);
}

return {
fileDescription: 'Markdown/GFM 格式',
fileExtension: '.md',
mineType: 'text/markdown',
dataType: 'text',

encode: function(json) {
return encode(json);
},

decode: function(markdown) {
return decode(markdown);
},

recognizePriority: -1
};
});
Loading

0 comments on commit 85c8d1d

Please sign in to comment.