From 9fe142335be19934d61d26bc46568f983c8d4c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 11:03:22 +0800 Subject: [PATCH 01/33] =?UTF-8?q?Add=20=E9=81=97=E6=BC=8F=E7=9A=84=20gem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 66dff8d1..80ac417b 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,5 @@ source 'https://rubygems.org' gem 'github-pages' gem 'sass' +gem 'nokogiri' +gem 'redcarpet' From 54a2c502b70b9d16ab893078e1478037f84260f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 11:04:42 +0800 Subject: [PATCH 02/33] =?UTF-8?q?=E8=87=AA=E5=8A=A8=20package=20=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index bacfab55..789fda37 100644 --- a/package.json +++ b/package.json @@ -20,24 +20,24 @@ "dependencies": { "jquery": "~2.1.4", "simple-hotkeys": "~1.0.3", - "simple-uploader": "~2.0.7", - "simple-module": "~2.0.6" + "simple-module": "~2.0.6", + "simple-uploader": "~2.0.7" }, "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-umd": "2.3.x" } } From 48ed8c3d62f164222a7a4a03e768276a183bceb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 11:04:49 +0800 Subject: [PATCH 03/33] add parallel --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 789fda37..5a9b5302 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "main": "lib/simditor.js", "homepage": "http://simditor.tower.im", "dependencies": { + "grunt-parallel": "^0.5.1", "jquery": "~2.1.4", "simple-hotkeys": "~1.0.3", "simple-module": "~2.0.6", From 50516a0e992fdee1f448f8ceb0339b334d183f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 13:55:23 +0800 Subject: [PATCH 04/33] Upload image callback func to img_path --- src/buttons/image.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index 45e7780c..8a936add 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -187,6 +187,8 @@ class ImageButton extends Button msg = result.msg || @_t('uploadFailed') alert msg img_path = @defaultImage + else if @editor.opts.upload.buildResultPath + img_path = @editor.opts.upload.buildResultPath(result) else img_path = result.file_path From 80f034f20dfdb43a598260c6a6a6380281d70682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 13:55:33 +0800 Subject: [PATCH 05/33] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8D=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=AB=98=E5=BA=A6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buttons/image.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index 8a936add..b3648560 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -282,7 +282,7 @@ class ImageButton extends Button $img.attr src: src, width: width, - height: height, + # height: height, 'data-image-size': width + ',' + height .removeClass('loading') From c419db1ebbe25122c55578b4b20c13991caaefa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 13:55:54 +0800 Subject: [PATCH 06/33] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=EF=BC=8C=E7=82=B9=E5=87=BB=E7=9A=84=E6=A8=A1=E6=9D=BF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buttons/image.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index b3648560..55679481 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -360,10 +360,13 @@ class ImagePopover extends Popover + + +
+ + + +
""" @el.addClass('image-popover') From 703642d6dba6d5020cd6be5081d3f2d9b2c43b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 13:57:30 +0800 Subject: [PATCH 07/33] =?UTF-8?q?size=20=E9=80=89=E9=A1=B9change=E6=97=B6?= =?UTF-8?q?=E5=80=99=E7=9B=B4=E6=8E=A5=E8=BF=9B=E8=A1=8Ccss=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buttons/image.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index 55679481..746875a8 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -397,6 +397,8 @@ class ImagePopover extends Popover @widthEl = @el.find '#image-width' @heightEl = @el.find '#image-height' @altEl = @el.find '#image-alt' + @widthResponse = @el.find '#imageSize-response' + @widthOrigin = @el.find '#imageSize-origin' @srcEl.on 'keydown', (e) => return unless e.which == 13 and !@target.hasClass('uploading') @@ -412,6 +414,10 @@ class ImagePopover extends Popover @_resizeImg $(e.currentTarget) @el.data('popover').refresh() + @el.find('[name="imageSize"]').on 'change', (e) => + @_resizeImg $(e.currentTarget) + @el.data('popover').refresh() + @el.find('.image-size').on 'keyup', (e) => inputEl = $(e.currentTarget) unless e.which == 13 or e.which == 27 or e.which == 9 From 735c93781f4abcf0ccb959d8e600cf7344856c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:03:46 +0800 Subject: [PATCH 08/33] _resizeImg fix --- src/buttons/image.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index 746875a8..d109ad77 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -489,6 +489,7 @@ class ImagePopover extends Popover createInput() _resizeImg: (inputEl, onlySetVal = false) -> + ### 这是旧的 value = inputEl.val() * 1 return unless @target and ($.isNumeric(value) or value < 0) @@ -506,6 +507,22 @@ class ImagePopover extends Popover width: width height: height @editor.trigger 'valuechanged' + ### + + value = inputEl.val() + return unless @target + if 'origin' is value + @target.css + width: 'auto' + @target.attr + width: 'auto' + else + @target.css + width: '100%' + @target.attr + width: '100%' + @editor.trigger 'valuechanged' + return _restoreImg: -> size = @target.data('image-size')?.split(",") || [@width, @height] From 44ae3a71f1ab0e7d4b8ec9f889ef8eb1f6254859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:06:27 +0800 Subject: [PATCH 09/33] _restoreImg --- src/buttons/image.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index d109ad77..67d0a973 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -525,6 +525,7 @@ class ImagePopover extends Popover return _restoreImg: -> + ### 这是旧的 size = @target.data('image-size')?.split(",") || [@width, @height] @target.attr width: size[0] * 1 @@ -533,6 +534,13 @@ class ImagePopover extends Popover @heightEl.val(size[1]) @editor.trigger 'valuechanged' + ### + + @target.attr + width: 'auto' + @target.css + width: 'auto' + @editor.trigger 'valuechanged' _loadImage: (src, callback) -> if /^data:image/.test(src) and not @editor.uploader From 8291cf5424f0ca6e774f28cc3acbeeec58b38932 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:08:10 +0800 Subject: [PATCH 10/33] _loadImage --- src/buttons/image.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index 67d0a973..805c87fa 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -553,11 +553,15 @@ class ImagePopover extends Popover return unless img if @active + ### 这是旧的 @width = img.width @height = img.height @widthEl.val @width @heightEl.val @height + ### + # 下面这行是新的 + @widthResponse.attr('checked', true) if /^data:image/.test(src) blob = @editor.util.dataURLtoBlob src From 6ba103c017146353c816690b57dd14db29f6adbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:11:49 +0800 Subject: [PATCH 11/33] =?UTF-8?q?Show=20=E5=87=BD=E6=95=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/buttons/image.coffee | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/buttons/image.coffee b/src/buttons/image.coffee index 805c87fa..2074bfbe 100644 --- a/src/buttons/image.coffee +++ b/src/buttons/image.coffee @@ -574,6 +574,7 @@ class ImagePopover extends Popover callback(img) if callback + # 旧的 show。会被覆盖。 show: (args...) -> super args... $img = @target @@ -591,5 +592,23 @@ class ImagePopover extends Popover @heightEl.val @height @altEl.val @alt + # 新的的 show。 + show: (args...) -> + super args... + $img = @target + @width = $img.attr('width') || $img.width() + @alt = $img.attr 'alt' + if $img.hasClass 'uploading' + @srcEl.val @_t('uploading') + .prop 'disabled', true + @widthResponse.attr('checked', true) + else + @srcEl.val $img.attr('src') + .prop 'disabled', false + if (''+ @width).endsWith('%') + @widthResponse.attr('checked', true) + else + @widthOrigin.attr('checked', true) + Simditor.Toolbar.addButton ImageButton From 408d1041271497020a48d9288bf3314f4a90e0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:13:22 +0800 Subject: [PATCH 12/33] =?UTF-8?q?src/i18n.coffee=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A4=A7=E5=B0=8F=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E6=A1=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/i18n.coffee b/src/i18n.coffee index 1161903f..f2208d36 100644 --- a/src/i18n.coffee +++ b/src/i18n.coffee @@ -10,10 +10,12 @@ Simditor.i18n = 'image': '插入图片' 'externalImage': '外链图片' 'uploadImage': '上传图片' - 'uploadFailed': '上传失败了' + 'uploadFailed': '图片上传失败了' 'uploadError': '上传出错了' 'imageUrl': '图片地址' 'imageSize': '图片尺寸' + 'imageResponse': '自适应' + 'imageOrigin': '原图大小' 'imageAlt': '图片描述' 'restoreImageSize': '还原图片尺寸' 'uploading': '正在上传' @@ -67,6 +69,8 @@ Simditor.i18n = 'uploadError': 'Error occurs during upload' 'imageUrl': 'Url' 'imageSize': 'Size' + 'imageResponse': 'Response' + 'imageOrigin': 'Origin' 'imageAlt': 'Alt' 'restoreImageSize': 'Restore Origin Size' 'uploading': 'Uploading' From fa86a98c7b7f3d061033afe1ca2a504ffa036035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:13:57 +0800 Subject: [PATCH 13/33] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=9A=84uploa?= =?UTF-8?q?ding=E7=8A=B6=E6=80=81=EF=BC=8C=E4=BB=A5=E5=8F=8A=20label=20?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E8=AE=BE=E7=BD=AEwidth=E8=A1=8C=E5=86=85?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=97=A0=E6=95=88=E7=9A=84=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/editor.scss | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/styles/editor.scss b/styles/editor.scss index f713388e..8e439882 100644 --- a/styles/editor.scss +++ b/styles/editor.scss @@ -55,6 +55,7 @@ $simditor-button-width: 46px; top: 0; left: 0; z-index: 2; + display: none!important; .progress { width: 100%; @@ -111,7 +112,44 @@ $simditor-button-width: 46px; img { cursor: pointer; - + &.uploading { + font-size: 0px; + padding-bottom: 4px; + background: repeating-linear-gradient(to right, #c6e8ef 0%, #3da0dc 50%, #c6e8ef 100%); + @keyframes SimditorImgUploadingAnimate { + 10% { + background: repeating-linear-gradient(to right, #c6e8ef 10%, #3da0dc 60%, #c6e8ef 110%); + } + 20% { + background: repeating-linear-gradient(to right, #c6e8ef 20%, #3da0dc 70%, #c6e8ef 120%); + } + 30% { + background: repeating-linear-gradient(to right, #c6e8ef 30%, #3da0dc 80%, #c6e8ef 130%); + } + 40% { + background: repeating-linear-gradient(to right, #c6e8ef 40%, #3da0dc 90%, #c6e8ef 140%); + } + 50% { + background: repeating-linear-gradient(to right, #c6e8ef 50%, #3da0dc 100%, #c6e8ef 150%); + } + 60% { + background: repeating-linear-gradient(to right, #c6e8ef 60%, #3da0dc 110%, #c6e8ef 160%); + } + 70% { + background: repeating-linear-gradient(to right, #c6e8ef 70%, #3da0dc 120%, #c6e8ef 170%); + } + 80% { + background: repeating-linear-gradient(to right, #c6e8ef 80%, #3da0dc 130%, #c6e8ef 180%); + } + 90% { + background: repeating-linear-gradient(to right, #c6e8ef 90%, #3da0dc 140%, #c6e8ef 190%); + } + 100% { + background: repeating-linear-gradient(to right, #c6e8ef 100%, #3da0dc 150%, #c6e8ef 200%); + } + } + animation: 1s SimditorImgUploadingAnimate ease infinite; + } &.selected { box-shadow: 0 0 0 4px #cccccc; } @@ -465,6 +503,9 @@ $simditor-button-width: 46px; label { display: inline-block; margin: 0 5px 0 0; + &.auto { + width: auto!important; + } } input[type=text] { From 96030c5e4f42d9c2557cd726b2534c3bac0a6441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E5=A5=87=E8=BE=89?= Date: Wed, 31 May 2017 14:15:38 +0800 Subject: [PATCH 14/33] add img setting --- site/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site/index.html b/site/index.html index 4af7ded5..a38d72ae 100644 --- a/site/index.html +++ b/site/index.html @@ -8,7 +8,9 @@