diff --git a/lib/simditor.js b/lib/simditor.js index a61d7e65..056090fb 100644 --- a/lib/simditor.js +++ b/lib/simditor.js @@ -2211,7 +2211,8 @@ Clipboard = (function(superClass) { Clipboard.pluginName = 'Clipboard'; Clipboard.prototype.opts = { - pasteImage: false + pasteImage: false, + cleanPaste: false }; Clipboard.prototype._init = function() { @@ -2302,7 +2303,7 @@ Clipboard = (function(superClass) { _this.editor.selection.reset(); _this.editor.selection.range(); _this._pasteInBlockEl = _this.editor.selection.blockNodes().last(); - _this._pastePlainText = _this._pasteInBlockEl.is('pre, table'); + _this._pastePlainText = _this.opts.cleanPaste || _this._pasteInBlockEl.is('pre, table'); if (_this._pastePlainText) { pasteContent = _this.editor.formatter.clearHtml(_this._pasteBin.html(), true); } else { diff --git a/site/_data/configs.yml b/site/_data/configs.yml index 60de5ad2..87dc0ca6 100644 --- a/site/_data/configs.yml +++ b/site/_data/configs.yml @@ -120,6 +120,12 @@ description: | Support uploading by pasting images from the clipboard. Work together with `upload` and only supported by Firefox and Chrome. +- name: "cleanPaste" + type: "Boolean" + default: "false" + description: | + Remove all styles in paste content automatically. + - name: "imageButton" type: "Array/String" default: "['upload', 'external']" diff --git a/site/assets/scripts/simditor.js b/site/assets/scripts/simditor.js index f29c9dcf..0e066624 100644 --- a/site/assets/scripts/simditor.js +++ b/site/assets/scripts/simditor.js @@ -2206,7 +2206,8 @@ Clipboard = (function(superClass) { Clipboard.pluginName = 'Clipboard'; Clipboard.prototype.opts = { - pasteImage: false + pasteImage: false, + cleanPaste: false }; Clipboard.prototype._init = function() { @@ -2297,7 +2298,7 @@ Clipboard = (function(superClass) { _this.editor.selection.reset(); _this.editor.selection.range(); _this._pasteInBlockEl = _this.editor.selection.blockNodes().last(); - _this._pastePlainText = _this._pasteInBlockEl.is('pre, table'); + _this._pastePlainText = _this.opts.cleanPaste || _this._pasteInBlockEl.is('pre, table'); if (_this._pastePlainText) { pasteContent = _this.editor.formatter.clearHtml(_this._pasteBin.html(), true); } else { diff --git a/site/docs/doc-config.md b/site/docs/doc-config.md index 093487e8..167914da 100644 --- a/site/docs/doc-config.md +++ b/site/docs/doc-config.md @@ -8,7 +8,7 @@ root: ../ #Options You can customize Simditor by passing optional options when initializing Simditor. -Here are all the optional options and their default values: +Here are some optional options and their default values: ```coffee editor = new Simditor @@ -23,6 +23,7 @@ editor = new Simditor toolbarFloatOffset: 0 toolbarHidden: false pasteImage: false + cleanPaste: false ``` diff --git a/src/clipboard.coffee b/src/clipboard.coffee index 525969b5..3a78e88f 100644 --- a/src/clipboard.coffee +++ b/src/clipboard.coffee @@ -5,6 +5,7 @@ class Clipboard extends SimpleModule opts: pasteImage: false + cleanPaste: false _init: -> @editor = @_module @@ -84,7 +85,7 @@ class Clipboard extends SimpleModule @editor.selection.range() @_pasteInBlockEl = @editor.selection.blockNodes().last() - @_pastePlainText = @_pasteInBlockEl.is 'pre, table' + @_pastePlainText = @opts.cleanPaste || @_pasteInBlockEl.is('pre, table') if @_pastePlainText pasteContent = @editor.formatter.clearHtml @_pasteBin.html(), true