Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9fe1423
Add 遗漏的 gem
shenqihui May 31, 2017
54a2c50
自动 package 排序
shenqihui May 31, 2017
48ed8c3
add parallel
shenqihui May 31, 2017
50516a0
Upload image callback func to img_path
shenqihui May 31, 2017
80f034f
图片不设置高度。
shenqihui May 31, 2017
c419db1
增加模板,点击的模板。
shenqihui May 31, 2017
703642d
size 选项change时候直接进行css修改。
shenqihui May 31, 2017
735c937
_resizeImg fix
shenqihui May 31, 2017
44ae3a7
_restoreImg
shenqihui May 31, 2017
8291cf5
_loadImage
shenqihui May 31, 2017
6ba103c
Show 函数修改。
shenqihui May 31, 2017
408d104
src/i18n.coffee 增加图片大小的设置文案。
shenqihui May 31, 2017
fa86a98
上传图的uploading状态,以及 label 强制设置width行内样式无效的样式。
shenqihui May 31, 2017
96030c5
add img setting
shenqihui May 31, 2017
66a7b8a
yarn lock
shenqihui May 31, 2017
6da0d60
强制 bug fix ,暂时不管他。
shenqihui May 31, 2017
054ff17
Add page-demo config
shenqihui May 31, 2017
018e525
Img setting
shenqihui May 31, 2017
8913269
Accept
shenqihui May 31, 2017
3c1279d
Fix package
shenqihui May 31, 2017
dfbda36
Accept
shenqihui May 31, 2017
c85c7e4
site/assets/scripts/page-demo.js add
shenqihui May 31, 2017
8d85d9c
Accept fix
shenqihui May 31, 2017
8aac2eb
Upload config
shenqihui May 31, 2017
7deb46b
simpleHotkeys simpleUploader
shenqihui May 31, 2017
5d7c056
Params settings
shenqihui May 31, 2017
f0740f5
Package
shenqihui May 31, 2017
2e144de
Fix package
shenqihui May 31, 2017
290357b
Remove width
shenqihui May 31, 2017
99efaf4
Width
shenqihui May 31, 2017
e83e66c
修复图片选中,响应式的问题。
shenqihui Aug 22, 2017
3d066bf
simditor 2.3.6-next1
shenqihui Aug 22, 2017
6da8fc9
simditor 2.3.6-next2 选择器问题。
shenqihui Aug 22, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ source 'https://rubygems.org'

gem 'github-pages'
gem 'sass'
gem 'nokogiri'
gem 'redcarpet'
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = (grunt) ->
amd: ['jquery', 'simple-module', 'simple-hotkeys', 'simple-uploader']
cjs: ['jquery', 'simple-module', 'simple-hotkeys', 'simple-uploader']
global:
items: ['jQuery', 'SimpleModule', 'simple.hotkeys', 'simple.uploader']
items: ['jQuery', 'SimpleModule', 'simpleHotkeys', 'simpleUploader']
prefix: ''

copy:
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simditor",
"version": "2.3.6",
"version": "2.3.6-next2",
"homepage": "http://simditor.tower.im/",
"authors": [
"farthinker <[email protected]>"
Expand Down
145 changes: 109 additions & 36 deletions lib/simditor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Simditor v2.3.6
* Simditor v2.3.6-next2
* http://simditor.tower.im/
* 2015-12-21
* 2017-08-22
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
Expand All @@ -15,7 +15,7 @@
// like Node.
module.exports = factory(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader"));
} else {
root['Simditor'] = factory(jQuery,SimpleModule,simple.hotkeys,simple.uploader);
root['Simditor'] = factory(root["jQuery"],root["SimpleModule"],root["simpleHotkeys"],root["simpleUploader"]);
}
}(this, function ($, SimpleModule, simpleHotkeys, simpleUploader) {

Expand Down Expand Up @@ -2670,10 +2670,12 @@ Simditor.i18n = {
'image': '插入图片',
'externalImage': '外链图片',
'uploadImage': '上传图片',
'uploadFailed': '上传失败了',
'uploadFailed': '图片上传失败了',
'uploadError': '上传出错了',
'imageUrl': '图片地址',
'imageSize': '图片尺寸',
'imageResponse': '自适应',
'imageOrigin': '原图大小',
'imageAlt': '图片描述',
'restoreImageSize': '还原图片尺寸',
'uploading': '正在上传',
Expand Down Expand Up @@ -2727,6 +2729,8 @@ Simditor.i18n = {
'uploadError': 'Error occurs during upload',
'imageUrl': 'Url',
'imageSize': 'Size',
'imageResponse': 'Response',
'imageOrigin': 'Origin',
'imageAlt': 'Alt',
'restoreImageSize': 'Restore Origin Size',
'uploading': 'Uploading',
Expand Down Expand Up @@ -4336,7 +4340,7 @@ ImageButton = (function(superClass) {
type: 'file',
title: _this._t('uploadImage'),
multiple: true,
accept: 'image/*'
accept: 'image/gif,image/jpeg,image/jpg,image/png'
}).appendTo($uploadItem);
};
})(this);
Expand Down Expand Up @@ -4438,6 +4442,8 @@ ImageButton = (function(superClass) {
msg = result.msg || _this._t('uploadFailed');
alert(msg);
img_path = _this.defaultImage;
} else if (_this.editor.opts.upload.buildResultPath) {
img_path = _this.editor.opts.upload.buildResultPath(result);
} else {
img_path = result.file_path;
}
Expand Down Expand Up @@ -4544,8 +4550,6 @@ ImageButton = (function(superClass) {
height = img.height;
$img.attr({
src: src,
width: width,
height: height,
'data-image-size': width + ',' + height
}).removeClass('loading');
if ($img.hasClass('uploading')) {
Expand Down Expand Up @@ -4621,13 +4625,16 @@ ImagePopover = (function(superClass) {
};

ImagePopover.prototype.render = function() {
var tpl;
tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('imageUrl')) + "</label>\n <input class=\"image-src\" type=\"text\" tabindex=\"1\" />\n <a class=\"btn-upload\" href=\"javascript:;\"\n title=\"" + (this._t('uploadImage')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-upload\"></span>\n </a>\n </div>\n <div class='settings-field'>\n <label>" + (this._t('imageAlt')) + "</label>\n <input class=\"image-alt\" id=\"image-alt\" type=\"text\" tabindex=\"1\" />\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <input class=\"image-size\" id=\"image-width\" type=\"text\" tabindex=\"2\" />\n <span class=\"times\">×</span>\n <input class=\"image-size\" id=\"image-height\" type=\"text\" tabindex=\"3\" />\n <a class=\"btn-restore\" href=\"javascript:;\"\n title=\"" + (this._t('restoreImageSize')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-undo\"></span>\n </a>\n </div>\n</div>";
var random, tpl;
random = '' + Math.random();
tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('imageUrl')) + "</label>\n <input class=\"image-src\" type=\"text\" tabindex=\"1\" />\n <a class=\"btn-upload\" href=\"javascript:;\"\n title=\"" + (this._t('uploadImage')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-upload\"></span>\n </a>\n </div>\n <!--\n <div class='settings-field'>\n <label>" + (this._t('imageAlt')) + "</label>\n <input class=\"image-alt\" id=\"image-alt\" type=\"text\" tabindex=\"1\" />\n </div>\n -->\n <!--\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <input class=\"image-size\" id=\"image-width\" type=\"text\" tabindex=\"2\" />\n <span class=\"times\">×</span>\n <input class=\"image-size\" id=\"image-height\" type=\"text\" tabindex=\"3\" />\n <a class=\"btn-restore\" href=\"javascript:;\"\n title=\"" + (this._t('restoreImageSize')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-undo\"></span>\n </a>\n </div>\n -->\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <label class=\"auto\">\n <input type=\"radio\" id=\"imageSize-response\" value=\"response\" name=\"imageSize_" + random + "\">\n <span>" + (this._t('imageResponse')) + "</span>\n </label>\n <label class=\"auto\">\n <input type=\"radio\" id=\"imageSize-origin\" value=\"origin\" name=\"imageSize_" + random + "\">\n <span>" + (this._t('imageOrigin')) + "</span>\n </label>\n </div>\n</div>";
this.el.addClass('image-popover').append(tpl);
this.srcEl = this.el.find('.image-src');
this.widthEl = this.el.find('#image-width');
this.heightEl = this.el.find('#image-height');
this.altEl = this.el.find('#image-alt');
this.widthResponse = this.el.find('#imageSize-response');
this.widthOrigin = this.el.find('#imageSize-origin');
this.srcEl.on('keydown', (function(_this) {
return function(e) {
var range;
Expand All @@ -4651,6 +4658,12 @@ ImagePopover = (function(superClass) {
return _this.el.data('popover').refresh();
};
})(this));
this.el.find('[name^=imageSize]').on('change', (function(_this) {
return function(e) {
_this._resizeImg($(e.currentTarget));
return _this.el.data('popover').refresh();
};
})(this));
this.el.find('.image-size').on('keyup', (function(_this) {
return function(e) {
var inputEl;
Expand Down Expand Up @@ -4732,7 +4745,7 @@ ImagePopover = (function(superClass) {
type: 'file',
title: _this._t('uploadImage'),
multiple: true,
accept: 'image/*'
accept: 'image/gif,image/jpeg,image/jpg,image/png'
}).appendTo($uploadBtn);
};
})(this);
Expand All @@ -4752,41 +4765,70 @@ ImagePopover = (function(superClass) {
};

ImagePopover.prototype._resizeImg = function(inputEl, onlySetVal) {
var height, value, width;
var value;
if (onlySetVal == null) {
onlySetVal = false;
}
value = inputEl.val() * 1;
if (!(this.target && ($.isNumeric(value) || value < 0))) {

/* 这是旧的
value = inputEl.val() * 1
return unless @target and ($.isNumeric(value) or value < 0)

if inputEl.is @widthEl
width = value
height = @height * value / @width
@heightEl.val height
else
height = value
width = @width * value / @height
@widthEl.val width

unless onlySetVal
@target.attr
width: width
height: height
@editor.trigger 'valuechanged'
*/
value = inputEl.val();
if (!this.target) {
return;
}
if (inputEl.is(this.widthEl)) {
width = value;
height = this.height * value / this.width;
this.heightEl.val(height);
if ('origin' === value) {
this.target.css({
width: 'auto'
});
this.target.attr({
width: 'auto'
});
} else {
height = value;
width = this.width * value / this.height;
this.widthEl.val(width);
}
if (!onlySetVal) {
this.target.css({
width: '100%'
});
this.target.attr({
width: width,
height: height
width: '100%'
});
return this.editor.trigger('valuechanged');
}
this.editor.trigger('valuechanged');
};

ImagePopover.prototype._restoreImg = function() {
var ref, size;
size = ((ref = this.target.data('image-size')) != null ? ref.split(",") : void 0) || [this.width, this.height];
this.target.attr({
width: size[0] * 1,

/* 这是旧的
size = @target.data('image-size')?.split(",") || [@width, @height]
@target.attr
width: size[0] * 1
height: size[1] * 1
@widthEl.val(size[0])
@heightEl.val(size[1])

@editor.trigger 'valuechanged'
*/
this.target.attr({
width: 'auto'
});
this.target.css({
width: 'auto'
});
this.widthEl.val(size[0]);
this.heightEl.val(size[1]);
return this.editor.trigger('valuechanged');
};

Expand All @@ -4802,15 +4844,23 @@ ImagePopover = (function(superClass) {
}
return this.button.loadImage(this.target, src, (function(_this) {
return function(img) {
var blob;
var blob, ref;
if (!img) {
return;
}
if (_this.active) {
_this.width = img.width;
_this.height = img.height;
_this.widthEl.val(_this.width);
_this.heightEl.val(_this.height);

/* 这是旧的
@width = img.width
@height = img.height

@widthEl.val @width
@heightEl.val @height
*/
_this.widthResponse.attr('checked', true);
if ((ref = _this.widthResponse[0]) != null) {
ref.checked = true;
}
}
if (/^data:image/.test(src)) {
blob = _this.editor.util.dataURLtoBlob(src);
Expand Down Expand Up @@ -4847,6 +4897,29 @@ ImagePopover = (function(superClass) {
}
};

ImagePopover.prototype.show = function() {
var $img, args, ref, ref1, ref2;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
ImagePopover.__super__.show.apply(this, args);
$img = this.target;
this.width = $img.attr('width') || $img.width();
this.alt = $img.attr('alt');
if ($img.hasClass('uploading')) {
this.srcEl.val(this._t('uploading')).prop('disabled', true);
this.widthResponse.attr('checked', true);
return (ref = this.widthResponse[0]) != null ? ref.checked = true : void 0;
} else {
this.srcEl.val($img.attr('src')).prop('disabled', false);
if (('' + this.width).endsWith('%')) {
this.widthResponse.attr('checked', true);
return (ref1 = this.widthResponse[0]) != null ? ref1.checked = true : void 0;
} else {
this.widthOrigin.attr('checked', true);
return (ref2 = this.widthOrigin[0]) != null ? ref2.checked = true : void 0;
}
}
};

return ImagePopover;

})(Popover);
Expand Down
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simditor",
"version": "2.3.6",
"version": "2.3.6-next2",
"description": "A simple online editor",
"keywords": "editor simditor",
"repository": {
Expand All @@ -19,25 +19,26 @@
"homepage": "http://simditor.tower.im",
"dependencies": {
"jquery": "~2.1.4",
"simple-hotkeys": "~1.0.3",
"simple-uploader": "~2.0.7",
"simple-module": "~2.0.6"
"simple-hotkeys": "github:pchange/simple-hotkeys#0ae78e4e3d326af65052bb2de009b6d61b450b51",
"simple-module": "~2.0.6",
"simple-uploader": "github:pchange/simple-uploader#e6e2bf82e376158703953c36dac81bb6cc02ab95"
},
"devDependencies": {
"express": "~3.3.4",
"grunt": "0.x",
"grunt-contrib-sass": "0.x",
"grunt-contrib-watch": "0.x",
"grunt-banner": "0.3.x",
"grunt-contrib-clean": "0.x",
"grunt-contrib-coffee": "0.x",
"grunt-contrib-copy": "0.x",
"grunt-contrib-uglify": "0.x",
"grunt-contrib-compress": "0.x",
"grunt-contrib-clean": "0.x",
"grunt-contrib-copy": "0.x",
"grunt-contrib-jasmine": "0.x",
"grunt-jekyll": "0.x",
"grunt-umd": "2.3.x",
"grunt-express": "1.4.0",
"grunt-banner": "0.3.x",
"grunt-contrib-sass": "0.x",
"grunt-contrib-uglify": "0.x",
"grunt-contrib-watch": "0.x",
"grunt-curl": "2.1.x",
"express": "~3.3.4"
"grunt-express": "1.4.0",
"grunt-jekyll": "0.x",
"grunt-parallel": "^0.5.1",
"grunt-umd": "2.3.x"
}
}
21 changes: 21 additions & 0 deletions site/assets/_coffee/page-demo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ $ ->
pasteImage: true
defaultImage: 'assets/images/image.png'
upload: if location.search == '?upload' then {url: '/upload'} else false
upload: {
url: if 'https:' is location.protocol then 'https://up.qbox.me/' else 'http://up.qiniu.com'
connectionCount: 3
leaveConfirm: '还在上传图片,确定要离开吗?'
buildResultPath: () ->
console.log 'buildResultPath result', retust
return ''
params: () ->
console.log 'params'
request = new XMLHttpRequest()
request.open('GET', 'https://api.github.com', false)
request.send(null)
window.r1 = request;

if request.status is 200
console.log(request.responseText)
console.log 'params sync request'
return {
a: request.responseText,
}
}

$preview = $('#preview')
if $preview.length > 0
Expand Down
10 changes: 5 additions & 5 deletions site/assets/scripts/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define('simple-hotkeys', ["jquery","simple-module"], function ($, SimpleModule) {
return (root['hotkeys'] = factory($, SimpleModule));
return (root['simpleHotkeys'] = factory($, SimpleModule));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
Expand All @@ -11,11 +11,11 @@
module.exports = factory(require("jquery"),require("simple-module"));
} else {
root.simple = root.simple || {};
root.simple['hotkeys'] = factory(jQuery,SimpleModule);
root['simpleHotkeys'] = factory(root["jQuery"],root["SimpleModule"]);
}
}(this, function ($, SimpleModule) {

var Hotkeys, hotkeys,
var Hotkeys, simpleHotkeys,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

Expand Down Expand Up @@ -231,11 +231,11 @@ Hotkeys = (function(superClass) {

})(SimpleModule);

hotkeys = function(opts) {
simpleHotkeys = function(opts) {
return new Hotkeys(opts);
};

return hotkeys;
return simpleHotkeys;

}));

Loading