1

When someone pastes content copied from a website or even a word document, textAngular adds additional break <br> tags before and after the content.

I'm using textAngular like this:

<text-angular name="summary" ng-model="summary" ta-paste="trimTags($html)" required>
</text-angular>

What I'd like to do is somehow trim the leading and trailing <br> tags.

The first approach I tried was writing a regex that will trim 2 leading and trailing <br> tags.

/(\<br\s*\/\>)(\<\/?body\>)(\<br\s*\/\>)/g

This works, but the changes are NOT reflected in the text presented. Is there a way to pass this $html being pasted and reflect the changes after modifying it?

Alternatively, I tried the ng-change approach, with no luck since it pastes the actual code, sometimes mixing <br> and <p> tags it adds.

Another problem is that, you could paste something in the middle of the text, which makes detecting changes difficult and time consuming.

Stefan
  • 700
  • 10
  • 22

1 Answers1

1

A silly overlook, if anyone has trouble with this, use the ta-paste and the regex from the question, and after modifying the content simply return it.

$scope.trimTags = function(content){
    //process the content
    return content;
};
Stefan
  • 700
  • 10
  • 22