diff --git a/app/assets/javascripts/app/lib/app_post/utils.js.coffee b/app/assets/javascripts/app/lib/app_post/utils.js.coffee
index 945ece4dd..cbf3c12ca 100644
--- a/app/assets/javascripts/app/lib/app_post/utils.js.coffee
+++ b/app/assets/javascripts/app/lib/app_post/utils.js.coffee
@@ -82,12 +82,12 @@ class App.Utils
@htmlRemoveTags: (html) ->
# remove tags, keep content
- html.find('div, span, p, li, ul, ol, a, b, u, i, strong, blockquote, h1, h2, h3, h4, h5, h6').replaceWith( ->
+ html.find('div, span, p, li, ul, ol, a, b, u, i, form, strong, blockquote, textarea, h1, h2, h3, h4, h5, h6').replaceWith( ->
$(@).contents()
)
# remove tags & content
- html.find('div, span, p, li, ul, ol, a, b, u, i, strong, blockquote, h1, h2, h3, h4, h5, h6, br, hr, img').remove()
+ html.find('div, span, p, li, ul, ol, a, b, u, i, form, strong, blockquote, textarea, h1, h2, h3, h4, h5, h6, br, hr, img, input').remove()
html
@@ -98,12 +98,12 @@ class App.Utils
@_removeAttributes( html )
# remove tags, keep content
- html.find('li, ul, ol, a, b, u, i, strong, blockquote, h1, h2, h3, h4, h5, h6').replaceWith( ->
+ html.find('li, ul, ol, a, b, u, i, strong, form, blockquote, textarea, h1, h2, h3, h4, h5, h6').replaceWith( ->
$(@).contents()
)
# remove tags & content
- html.find('li, ul, ol, a, b, u, i, strong, blockquote, h1, h2, h3, h4, h5, h6, hr, img').remove()
+ html.find('li, ul, ol, a, b, u, i, strong, form, blockquote, textarea, h1, h2, h3, h4, h5, h6, hr, img, input').remove()
html
@@ -113,9 +113,6 @@ class App.Utils
# remove style and class
@_removeAttributes( html )
- # remove tags & content
- html.find('hr, img').remove()
-
# remove tags, keep content
html.find('a').replaceWith( ->
$(@).contents()
@@ -126,7 +123,7 @@ class App.Utils
replacementTag = 'div';
# Replace all a tags with the type of replacementTag
- html.find('h1, h2, h3, h4, h5, h6').each( ->
+ html.find('h1, h2, h3, h4, h5, h6, textarea').each( ->
outer = this.outerHTML;
# Replace opening tag
@@ -139,6 +136,10 @@ class App.Utils
$(@).replaceWith(newTag);
)
+
+ # remove tags & content
+ html.find('hr, img, form, input').remove()
+
html
@_removeAttributes: (html) ->
diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js
index 8c9d89dc3..f47e1ac43 100644
--- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js
+++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js
@@ -48,6 +48,7 @@
this._defaults = defaults;
this._name = pluginName;
+ this._setTimeOutReformat = false;
// take placeholder from markup
if ( !this.options.placeholder && this.$element.data('placeholder') ) {
@@ -92,11 +93,22 @@
})
this.$element.on('keyup', function (e) {
- console.log('KU')
+ console.log('KU', e.ctrlKey)
+ // do not remove tags on space, enter or backspace key, it's needed for FF
if ( _this.options.mode === 'textonly' ) {
- console.log('REMOVE TAGS')
if ( !_this.options.multiline ) {
- App.Utils.htmlRemoveTags(_this.$element)
+
+ // do tricky this for FF
+ if ( e.keyCode !== 32 && e.keyCode !== 13 && e.keyCode !== 8 ) {
+
+ // start request to remove tags
+ _this.htmlRemoveTags()
+ }
+ else {
+
+ // clear request to delete tags, in FF we need
anytime at the end
+ _this.htmlRemoveTagsClearClearTimeout()
+ }
}
else {
App.Utils.htmlRemoveRichtext(_this.$element)
@@ -112,9 +124,8 @@
this.$element.on('paste', function (e) {
console.log('paste')
if ( _this.options.mode === 'textonly' ) {
- console.log('REMOVE TAGS')
if ( !_this.options.multiline ) {
- App.Utils.htmlRemoveTags(_this.$element)
+ _this.htmlRemoveTags()
}
else {
App.Utils.htmlRemoveRichtext(_this.$element)
@@ -175,8 +186,25 @@
}
})
}
+ }
+ // check if rich text key is pressed
+ Plugin.prototype.htmlRemoveTags = function() {
+ // clear old clear request
+ this.htmlRemoveTagsClearClearTimeout()
+
+ // set new clear request
+ this._setTimeOutReformat = setTimeout($.proxy(function(){
+ App.Utils.htmlRemoveTags(this.$element)
+ }, this), 100)
+ console.log('htmlRemoveTagsClearSetTimeout', this._setTimeOutReformat)
+ }
+ Plugin.prototype.htmlRemoveTagsClearClearTimeout = function() {
+ if (this._setTimeOutReformat) {
+ console.log('htmlRemoveTagsClearClearTimeout', this._setTimeOutReformat)
+ clearTimeout(this._setTimeOutReformat)
+ }
}
// check if rich text key is pressed
diff --git a/public/assets/tests/html-utils.js b/public/assets/tests/html-utils.js
index 3e9a92f71..fe7884b58 100644
--- a/public/assets/tests/html-utils.js
+++ b/public/assets/tests/html-utils.js
@@ -165,7 +165,6 @@ test( "htmlRemoveTags", function() {
var source = "