Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Model becomes empty after edit for some templates and with 'disableSanitizer = true' #1230

Closed
driver-by opened this issue Jul 15, 2016 · 14 comments
Assignees

Comments

@driver-by
Copy link

For some html, if you edit the text, model becomes empty. But only with 'disableSanitizer = true'.
Here is an example of html:
'\n\n<table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-spacing: 0px; border-collapse: collapse; padding: 0px; font-size: 12px; font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif; "><tr><td>xxx</td></tr></table>'
and plunker (try to edit the field in the first textarea, the second one works fine)

What helps to fix that in the sample template:

  1. Remove one of the first '\n\n' charachters.
  2. Remove entire 'style=".."' attribute in the table

Looks really strange.
I have to disable sanitizer because I work with complex email-templates in text field. And these templates doesn't always work properly with sanitizer.

@JoelParke
Copy link
Collaborator

This is very interesting. I am looking at this with a number of fixes already in the code for the next release and will see if I can figure out why this is happening.

@JoelParke
Copy link
Collaborator

JoelParke commented Jul 15, 2016

This happens in Chrome and Firefox. Also if the html has one blank line at the start, all you need to do is toggle back and forth between the html and wysiwyg view. and MAGIC all the html is gone!
YUCK!

When this happens, the taTextElement still contains the original html that is viewed in the wysiwyg mode and the <input> element following the taHtmlElement is empty where it should contain the same.

NOTE: If I put a <p>a<br></p> after the <table> then the blank line is FINE!
Or even just a <p>a</p> after the <table> is fine!
Something strange is taking place....

I am going to look at this a bit more... But if it isn't clear, I am going to cut the new release and then come back to this later.

@JoelParke
Copy link
Collaborator

This looks difficult to fix. I will punt for today....

@JoelParke JoelParke self-assigned this Jul 20, 2016
@JoelParke
Copy link
Collaborator

I took a long look at this again yesterday.  The code in this whole area is relatively difficult to modify.  It will take some time and perhaps this section of code needs a full redesign which will be difficult. 

One way in which you can see some of the issues, is to simply take your 

<table>....</table> 

example and add a 'a' character before the 'html' in the html view.  When you switch to the WYSIWYG  view your see the expected view, and it you view the underlying html using Chrome's Developer Tools and selected Elements and viewing the <input> element you will see this have become 

<p>a</p>...<table>...</table> 

as expected.  BUT the 'html' view is still

a<table>...</table>

as before.  YUCK

If I can see a good way synchronize this with the <input> element it will get better.  But the fact that it doesn't do that yet is why I believe a redesign of this area of the code is needed.

How big of an issue is this for you at this point.  Have you discovered any good work arounds?

@driver-by
Copy link
Author

driver-by commented Jul 24, 2016

Thanks for your try!
For me that's not a big issue now. I've just removed the '\n\n' from the templates. They generate from the other source with comments at the start, that's the reason of break lines.

But it was really a bad day when I was trying to figure out what the heck is going on :)
So it's really critical for other users, as they could encounter the same problem.

@JoelParke
Copy link
Collaborator

JoelParke commented Jul 27, 2016

I have just about fixed this. I need to spend some time tomorrow making sure that my changes will not break the functionality that folks depend on related to trimming white space.
This will also remove some other strange bugs.

@JoelParke
Copy link
Collaborator

I will finish this tomorrow. The issue is how best to keep the html and the ngModel in sync. And another day of thought makes sense. It now works, but one can get the html out of sync from the model and I would like to stop that.

JoelParke added a commit that referenced this issue Jul 29, 2016
Fix(taBind): Corrected issue around model becomes empty Issue #1230
@JoelParke
Copy link
Collaborator

v1.5.3 fixes this... please check...

@driver-by
Copy link
Author

Really good news, thanks!
I'll definetly check

@driver-by
Copy link
Author

Fix works fine with provided plunkr but still doesn't work for my templates :(
I've modified plunkr and added one bad template with small modifications that fix bad behaviour
click here. There is really strange pattern.

@driver-by
Copy link
Author

Looks like comments make the problem here. Maybe textAngular should clear comments from the model at the start?

@driver-by
Copy link
Author

@JoelParke should I create new issue?

@JoelParke
Copy link
Collaborator

Please test with v1.5.5 which should resolve this. I will close, and please re-open if this is still an issue!

@driver-by
Copy link
Author

It works!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants