kityminder-editor
Advanced tools
Comparing version 1.0.55 to 1.0.60
{ | ||
"name": "kityminder-editor", | ||
"version": "1.0.55", | ||
"version": "1.0.60", | ||
"authors": [ | ||
@@ -43,3 +43,3 @@ "fex<fex@baidu.com>" | ||
"codemirror": "~4.8.0", | ||
"marked": "~0.3.3", | ||
"marked": "git://github.com/chjj/marked.git#master", | ||
"kity": "~2.0.0", | ||
@@ -46,0 +46,0 @@ "hotbox": "~1.0.2", |
{ | ||
"name": "kityminder-editor", | ||
"version": "1.0.55", | ||
"version": "1.0.60", | ||
"description": "A powerful mind map editor", | ||
@@ -8,4 +8,4 @@ "main": "kityminder.editor.js", | ||
"init": "npm i -g wr && npm install -g less && npm install -g bower && bower install && npm install", | ||
"dev": "npm run watch-less", | ||
"watch-less": "wr --exec \"lessc --source-map less/editor.less dist/kityminder.editor.css\" less" | ||
"dev": "npm run watch", | ||
"watch": "wr --exec \"lessc --source-map less/editor.less dist/kityminder.editor.css && grunt build\" less ui" | ||
}, | ||
@@ -12,0 +12,0 @@ "repository": { |
@@ -48,2 +48,12 @@ KityMinder Editor | ||
## 初始化配置 | ||
用户可以根据需要,配置 `kityminder-editor`, 具体使用方法如下: | ||
``` | ||
angular.module('kityminderDemo', ['kityminderEditor']) | ||
.config(function (configProvider) { | ||
configProvider.set('imageUpload', 'path/to/image/upload/handler'); | ||
}); | ||
``` | ||
## 数据导入导出 | ||
@@ -50,0 +60,0 @@ 由于 kityminder-editor 是基于 kityminder-core 搭建的,而 kityminder-core 内置了五种常见 |
@@ -154,3 +154,15 @@ /** | ||
minder.refresh(); | ||
} else { | ||
} | ||
else if (clipBoardEvent.clipboardData && clipBoardEvent.clipboardData.items[0].type.indexOf('image') > -1) { | ||
var imageFile = clipBoardEvent.clipboardData.items[0].getAsFile(); | ||
var serverService = angular.element(document.body).injector().get('server'); | ||
return serverService.uploadImage(imageFile).then(function (json) { | ||
var resp = json.data; | ||
if (resp.errno === 0) { | ||
minder.execCommand('image', resp.data.url); | ||
} | ||
}); | ||
} | ||
else { | ||
sNodes.forEach(function(node) { | ||
@@ -157,0 +169,0 @@ minder.Text2Children(node, textData); |
@@ -53,3 +53,3 @@ /** | ||
frame && kity.releaseFrame(frame); | ||
frame = null; | ||
frame = null; | ||
return; | ||
@@ -95,3 +95,3 @@ } | ||
&& (Math.abs(downX - e.originEvent.clientX) > BOUND_CHECK | ||
|| Math.abs(downY - e.originEvent.clientY) > BOUND_CHECK)) { | ||
|| Math.abs(downY - e.originEvent.clientY) > BOUND_CHECK)) { | ||
osx = e.originEvent.clientX; | ||
@@ -98,0 +98,0 @@ osy = e.originEvent.clientY - containerY; |
@@ -64,3 +64,3 @@ /** | ||
minder.on('dblclick', function() { | ||
if (minder.getSelectedNode()) { | ||
if (minder.getSelectedNode() && minder._status !== 'readonly') { | ||
editText(); | ||
@@ -67,0 +67,0 @@ } |
angular.module('kityminderEditor') | ||
.controller('hyperlink.ctrl', function ($scope, $modalInstance, link) { | ||
$scope.R_URL = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/; | ||
var urlRegex = '^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$'; | ||
$scope.R_URL = new RegExp(urlRegex, 'i'); | ||
@@ -6,0 +7,0 @@ $scope.url = link.url || ''; |
angular.module('kityminderEditor') | ||
.controller('image.ctrl', ['$http', '$scope', '$modalInstance', 'image', function($http, $scope, $modalInstance, image) { | ||
.controller('image.ctrl', ['$http', '$scope', '$modalInstance', 'image', 'server', function($http, $scope, $modalInstance, image, server) { | ||
$scope.data = { | ||
@@ -9,3 +8,3 @@ list: [], | ||
title: image.title || '', | ||
R_URL: /^https?\:\/\/(\w+\.)+\w+/ | ||
R_URL: /^https?\:\/\/\w+/ | ||
}; | ||
@@ -55,2 +54,21 @@ | ||
// 自动上传图片,后端需要直接返回图片 URL | ||
$scope.uploadImage = function() { | ||
var fileInput = $('#upload-image'); | ||
if (!fileInput.val()) { | ||
return; | ||
} | ||
if (/^.*\.(jpg|JPG|jpeg|JPEG|gif|GIF|png|PNG)$/.test(fileInput.val())) { | ||
var file = fileInput[0].files[0]; | ||
return server.uploadImage(file).then(function (json) { | ||
var resp = json.data; | ||
if (resp.errno === 0) { | ||
$scope.data.url = resp.data.url; | ||
} | ||
}); | ||
} else { | ||
alert("后缀只能是 jpg、gif 及 png"); | ||
} | ||
}; | ||
$scope.shortCut = function(e) { | ||
@@ -76,4 +94,7 @@ e.stopPropagation(); | ||
var $imageUrl = $('#image-url'); | ||
$imageUrl.focus(); | ||
$imageUrl[0].setSelectionRange(0, $scope.data.url.length); | ||
if ($imageUrl) { | ||
$imageUrl.focus(); | ||
$imageUrl[0].setSelectionRange(0, $scope.data.url.length); | ||
} | ||
} | ||
@@ -89,3 +110,3 @@ | ||
function getImageData(){ | ||
function getImageData() { | ||
var key = $scope.data.searchKeyword2; | ||
@@ -92,0 +113,0 @@ var currentTime = new Date(); |
@@ -46,3 +46,3 @@ angular.module('kityminderEditor') | ||
scope.minder = minder; | ||
scope.config = config.getConfig(); | ||
scope.config = config.get(); | ||
@@ -63,3 +63,3 @@ //scope.minder.setDefaultOptions(scope.config); | ||
scope.config = config.getConfig(); | ||
scope.config = config.get(); | ||
@@ -66,0 +66,0 @@ //scope.minder.setDefaultOptions(config.getConfig()); |
@@ -19,3 +19,3 @@ /** | ||
link: function(scope) { | ||
minder.setDefaultOptions({zoom: config.getConfig('zoom')}); | ||
minder.setDefaultOptions({zoom: config.get('zoom')}); | ||
@@ -22,0 +22,0 @@ scope.isNavOpen = !memory.get('navigator-hidden'); |
angular.module('kityminderEditor') | ||
.filter('lang', ['config', 'lang.zh-cn', function(config, lang) { | ||
return function(text, block) { | ||
var defaultLang = config.getConfig('defaultLang'); | ||
var defaultLang = config.get('defaultLang'); | ||
@@ -6,0 +6,0 @@ if (lang[defaultLang] == undefined) { |
angular.module('kityminderEditor') | ||
.service('config', function() { | ||
.provider('config', function() { | ||
return { | ||
_default: { | ||
this.config = { | ||
// 右侧面板最小宽度 | ||
ctrlPanelMin: 250, | ||
// 右侧面板最小宽度 | ||
ctrlPanelMin: 250, | ||
// 右侧面板宽度 | ||
ctrlPanelWidth: parseInt(window.localStorage.__dev_minder_ctrlPanelWidth) || 250, | ||
// 右侧面板宽度 | ||
ctrlPanelWidth: parseInt(window.localStorage.__dev_minder_ctrlPanelWidth) || 250, | ||
// 分割线宽度 | ||
dividerWidth: 3, | ||
// 分割线宽度 | ||
dividerWidth: 3, | ||
// 默认语言 | ||
defaultLang: 'zh-cn', | ||
// 默认语言 | ||
defaultLang: 'zh-cn', | ||
// 放大缩小比例 | ||
zoom: [10, 20, 30, 50, 80, 100, 120, 150, 200], | ||
// 放大缩小比例 | ||
zoom: [10, 20, 30, 50, 80, 100, 120, 150, 200] | ||
}, | ||
getConfig: function(key) { | ||
return key == undefined ? this._default : (this._default[key] || null); | ||
}, | ||
setConfig: function(obj) { | ||
this._default = obj; | ||
} | ||
// 图片上传接口 | ||
imageUpload: 'server/imageUpload.php' | ||
}; | ||
this.set = function(key, value) { | ||
var supported = Object.keys(this.config); | ||
var configObj = {}; | ||
// 支持全配置 | ||
if (typeof key === 'object') { | ||
configObj = key; | ||
} | ||
else { | ||
configObj[key] = value; | ||
} | ||
for (var i in configObj) { | ||
if (configObj.hasOwnProperty(i) && supported.indexOf(i) !== -1) { | ||
this.config[i] = configObj[i]; | ||
} | ||
else { | ||
console.error('Unsupported config key: ', key, ', please choose in :', supported.join(', ')); | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
this.$get = function () { | ||
var me = this; | ||
return { | ||
get: function (key) { | ||
if (arguments.length === 0) { | ||
return me.config; | ||
} | ||
if (me.config.hasOwnProperty(key)) { | ||
return me.config[key]; | ||
} | ||
console.warn('Missing config key pair for : ', key); | ||
return ''; | ||
} | ||
}; | ||
} | ||
}); |
@@ -335,3 +335,3 @@ angular.module('kityminderEditor') | ||
'insertnote': '插入备注', | ||
'removelink': '移除已有连接', | ||
'removelink': '移除已有链接', | ||
'removeimage': '移除已有图片', | ||
@@ -338,0 +338,0 @@ 'removenote': '移除已有备注', |
@@ -156,5 +156,5 @@ angular.module('kityminderEditor').run(['$templateCache', function($templateCache) { | ||
$templateCache.put('ui/dialog/image/image.tpl.html', | ||
"<div class=\"modal-header\"><h3 class=\"modal-title\">图片</h3></div><div class=\"modal-body\"><tabset><tab heading=\"图片搜索\"><form class=\"form-inline\"><div class=\"form-group\"><label for=\"search-keyword\">关键词:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.searchKeyword2\" id=\"search-keyword\" placeholder=\"请输入搜索的关键词\"></div><button class=\"btn btn-primary\" ng-click=\"searchImage()\">百度一下</button></form><div class=\"search-result\" id=\"search-result\"><ul><li ng-repeat=\"image in list\" id=\"{{ 'img-item' + $index }}\" ng-class=\"{'selected' : isSelected}\" ng-click=\"selectImage($event)\"><img id=\"{{ 'img-' + $index }}\" ng-src=\"{{ image.src || '' }}\" alt=\"{{ image.title }}\" onerror=\"this.parentNode.removeChild(this)\"> <span>{{ image.title }}</span></li></ul></div></tab><tab heading=\"插入图片\" active=\"true\"><form><div class=\"form-group\" ng-class=\"{true: 'has-success', false: 'has-error'}[urlPassed]\"><label for=\"image-url\">链接地址:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.url\" ng-blur=\"urlPassed = data.R_URL.test(data.url)\" ng-focus=\"this.value = data.url\" ng-keydown=\"shortCut($event)\" id=\"image-url\" placeholder=\"必填:以 http(s):// 开头\"></div><div class=\"form-group\" ng-class=\"{'has-success' : titlePassed}\"><label for=\"image-title\">提示文本:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.title\" ng-blur=\"titlePassed = true\" id=\"image-title\" placeholder=\"选填:鼠标在图片上悬停时提示的文本\"></div><div class=\"form-group\"><label for=\"image-preview\">图片预览:</label><img class=\"image-preview\" id=\"image-preview\" ng-src=\"{{ data.url }}\" alt=\"{{ data.title }}\"></div></form></tab></tabset></div><div class=\"modal-footer\"><button class=\"btn btn-primary\" ng-click=\"ok()\">确定</button> <button class=\"btn btn-warning\" ng-click=\"cancel()\">取消</button></div>" | ||
"<div class=\"modal-header\"><h3 class=\"modal-title\">图片</h3></div><div class=\"modal-body\"><tabset><tab heading=\"图片搜索\"><form class=\"form-inline\"><div class=\"form-group\"><label for=\"search-keyword\">关键词:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.searchKeyword2\" id=\"search-keyword\" placeholder=\"请输入搜索的关键词\"></div><button class=\"btn btn-primary\" ng-click=\"searchImage()\">百度一下</button></form><div class=\"search-result\" id=\"search-result\"><ul><li ng-repeat=\"image in list\" id=\"{{ 'img-item' + $index }}\" ng-class=\"{'selected' : isSelected}\" ng-click=\"selectImage($event)\"><img id=\"{{ 'img-' + $index }}\" ng-src=\"{{ image.src || '' }}\" alt=\"{{ image.title }}\" onerror=\"this.parentNode.removeChild(this)\"> <span>{{ image.title }}</span></li></ul></div></tab><tab heading=\"外链图片\"><form><div class=\"form-group\" ng-class=\"{true: 'has-success', false: 'has-error'}[urlPassed]\"><label for=\"image-url\">链接地址:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.url\" ng-blur=\"urlPassed = data.R_URL.test(data.url)\" ng-focus=\"this.value = data.url\" ng-keydown=\"shortCut($event)\" id=\"image-url\" placeholder=\"必填:以 http(s):// 开头\"></div><div class=\"form-group\" ng-class=\"{'has-success' : titlePassed}\"><label for=\"image-title\">提示文本:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.title\" ng-blur=\"titlePassed = true\" id=\"image-title\" placeholder=\"选填:鼠标在图片上悬停时提示的文本\"></div><div class=\"form-group\"><label for=\"image-preview\">图片预览:</label><img class=\"image-preview\" id=\"image-preview\" ng-src=\"{{ data.url }}\" alt=\"{{ data.title }}\"></div></form></tab><tab heading=\"上传图片\" active=\"true\"><form><div class=\"form-group\"><input type=\"file\" name=\"upload-image\" id=\"upload-image\" class=\"upload-image\" accept=\".jpg,.JPG,jpeg,JPEG,.png,.PNG,.gif,.GIF\" onchange=\"angular.element(this).scope().uploadImage()\"><label for=\"upload-image\" class=\"btn btn-primary\"><span>选择文件…</span></label></div><div class=\"form-group\" ng-class=\"{'has-success' : titlePassed}\"><label for=\"image-title\">提示文本:</label><input type=\"text\" class=\"form-control\" ng-model=\"data.title\" ng-blur=\"titlePassed = true\" id=\"image-title\" placeholder=\"选填:鼠标在图片上悬停时提示的文本\"></div><div class=\"form-group\"><label for=\"image-preview\">图片预览:</label><img class=\"image-preview\" id=\"image-preview\" ng-src=\"{{ data.url }}\" title=\"{{ data.title }}\" alt=\"{{ data.title }}\"></div></form></tab></tabset></div><div class=\"modal-footer\"><button class=\"btn btn-primary\" ng-click=\"ok()\">确定</button> <button class=\"btn btn-warning\" ng-click=\"cancel()\">取消</button></div>" | ||
); | ||
}]); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
3999096
160
10394
86
0