diff --git a/bower.json b/bower.json index 602446e0..4d496482 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "simditor", - "version": "2.3.16", + "version": "2.3.17", "homepage": "http://simditor.tower.im/", "authors": [ "farthinker " diff --git a/lib/simditor.js b/lib/simditor.js index 6a5a931d..cb00cdac 100644 --- a/lib/simditor.js +++ b/lib/simditor.js @@ -1,8 +1,3 @@ -/*! -* Simditor v2.3.16 -* http://simditor.tower.im/ -* 2018-06-14 -*/ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module unless amdModuleId is set @@ -2354,6 +2349,7 @@ Clipboard = (function(superClass) { pasteContent = $('
').append(_this._pasteBin.contents()); pasteContent.find('style').remove(); pasteContent.find('table colgroup').remove(); + _this._cleanPasteFontSize(pasteContent); _this.editor.formatter.format(pasteContent); _this.editor.formatter.decorate(pasteContent); _this.editor.formatter.beautify(pasteContent.children()); @@ -2493,6 +2489,22 @@ Clipboard = (function(superClass) { return this.editor.inputManager.throttledValueChanged(); }; + Clipboard.prototype._cleanPasteFontSize = function(node) { + var $node, sizeMap; + $node = $(node); + if (!($node.length > 0)) { + return; + } + sizeMap = ['1.5em', '1.25em', '0.75em', '0.5em']; + return $node.find('[style*="font-size"]').map(function(i, el) { + var $el; + $el = $(el); + if ($.inArray($el.css('font-size'), sizeMap) < 0) { + return $el.css('font-size', ''); + } + }); + }; + return Clipboard; })(SimpleModule); diff --git a/package.json b/package.json index e3383583..56b6f93a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "simditor", - "version": "2.3.16", + "version": "2.3.17", "description": "A simple online editor", "keywords": "editor simditor", "repository": { diff --git a/site/assets/scripts/simditor.js b/site/assets/scripts/simditor.js index 2497c379..cb00cdac 100644 --- a/site/assets/scripts/simditor.js +++ b/site/assets/scripts/simditor.js @@ -2349,6 +2349,7 @@ Clipboard = (function(superClass) { pasteContent = $('
').append(_this._pasteBin.contents()); pasteContent.find('style').remove(); pasteContent.find('table colgroup').remove(); + _this._cleanPasteFontSize(pasteContent); _this.editor.formatter.format(pasteContent); _this.editor.formatter.decorate(pasteContent); _this.editor.formatter.beautify(pasteContent.children()); @@ -2488,6 +2489,22 @@ Clipboard = (function(superClass) { return this.editor.inputManager.throttledValueChanged(); }; + Clipboard.prototype._cleanPasteFontSize = function(node) { + var $node, sizeMap; + $node = $(node); + if (!($node.length > 0)) { + return; + } + sizeMap = ['1.5em', '1.25em', '0.75em', '0.5em']; + return $node.find('[style*="font-size"]').map(function(i, el) { + var $el; + $el = $(el); + if ($.inArray($el.css('font-size'), sizeMap) < 0) { + return $el.css('font-size', ''); + } + }); + }; + return Clipboard; })(SimpleModule); diff --git a/src/clipboard.coffee b/src/clipboard.coffee index 2a4d7865..0444ce24 100644 --- a/src/clipboard.coffee +++ b/src/clipboard.coffee @@ -94,9 +94,11 @@ class Clipboard extends SimpleModule pasteContent = $('
').append(@_pasteBin.contents()) pasteContent.find('style').remove() # clear style tag pasteContent.find('table colgroup').remove() # clear table cols width + @_cleanPasteFontSize pasteContent @editor.formatter.format pasteContent @editor.formatter.decorate pasteContent @editor.formatter.beautify pasteContent.children() + pasteContent = pasteContent.contents() @_pasteBin.remove() @@ -209,3 +211,20 @@ class Clipboard extends SimpleModule @editor.selection.setRangeAtEndOf(pasteContent.last()) @editor.inputManager.throttledValueChanged() + + _cleanPasteFontSize: (node) -> + $node = $(node) + return unless $node.length > 0 + + sizeMap = [ + '1.5em' + '1.25em' + '0.75em' + '0.5em' + ] + + $node.find('[style*="font-size"]') + .map (i, el) -> + $el = $(el) + if $.inArray($el.css('font-size'), sizeMap) < 0 + $el.css('font-size', '') diff --git a/styles/simditor.css b/styles/simditor.css index 218df4af..08f3048d 100644 --- a/styles/simditor.css +++ b/styles/simditor.css @@ -1,7 +1,7 @@ /*! -* Simditor v2.3.16 +* Simditor v2.3.17 * http://simditor.tower.im/ -* 2018-06-14 +* 2018-07-23 */ @font-face { font-family: 'Simditor';