Remove style from pasted HTML in editor

This commit is contained in:
Maikel Linke
2020-02-21 13:57:27 +11:00
parent a3e87d893a
commit 325c427219
2 changed files with 9 additions and 3 deletions

View File

@@ -2,4 +2,10 @@ angular.module("admin.utils").directive "textangularStrip", () ->
restrict: 'CA'
link: (scope, element, attrs) ->
scope.stripFormatting = ($html) ->
return String($html).replace(/<[^>]+>/gm, '')
element = document.createElement("div")
element.innerHTML = String($html)
allTags = element.getElementsByTagName("*")
for child in allTags
child.removeAttribute("style")
child.removeAttribute("class")
return element.innerHTML