Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Lost empty <br> when edit again #113

Closed
cesarve77 opened this issue Jan 27, 2016 · 10 comments
Closed

Lost empty <br> when edit again #113

cesarve77 opened this issue Jan 27, 2016 · 10 comments

Comments

@cesarve77
Copy link

Hi, if I insert <br> at the end of a paragraph and I save everything it's ok. but when i click in edit again I lost then.

thanks and sorry for my english

@anthonyjb
Copy link
Member

Hi @cesarve77 this is the expected behaviour currently, that is CT strips/trims white space from editable elements unless it's a <pre> preformatted tag. <br> and &nbsp; are considered white-space by the HTMLString parser.

But your point is a good one as I'm not sure this is the correct behaviour, and in any case it should be consistent and either allow them or strip them on saving out.

I'll open this up to feedback from others and have a think about what the correct behaviour should be, but I suspect that <br> tags and &nbsp; should be retained as you've stated.

Thanks for highlighting this and your English is far better than my attempt at any language other than English!

@bfintal
Copy link
Contributor

bfintal commented Jan 30, 2016

I'm unsure about this. At one hand I like everything being trimmed and clean, it kind of forces things to be neat. On the other hand, it feels that linebreaks should be allowed.

@anthonyjb
Copy link
Member

If no one else has a strong opinion on this ATM I'm going to initially ensure that save trims out line breaks so the behaviour is consistent as I believe this is a simpler option for now and wont risk breaking anything. But once that's in place I'll leave the issue open as an enhancement on the basis that I agree long term this behaviour might need to be changed.

@anthonyjb
Copy link
Member

OK the behaviour now is consistent and white space (includeing <br> elements) is trimmed from the output of all text elements except PreText.

In future we may revise this behaviour if there is a strong enough argument made that it should be switch to preserver white space, or perhaps as an enhancement we might consider allowing the behaviour to be configured as a setting.

@anthonyjb anthonyjb mentioned this issue May 18, 2016
@hassanakram
Copy link

I think it should be available as a setting. Some applications include a lot of editing on daily basis. E.g add few line breaks, remove few line breaks. I am currently working on such application and it requires this feature.
Currently even if we add blank space anywhere in the document, it is instantly trimmed on pressing save and nothing gets saved.
Thanks

@anthonyjb
Copy link
Member

@hassanakram I'm inclined to agree, there's an example of the changes we might need to make to support this behaviour on this SO post http://stackoverflow.com/questions/36883079/how-to-preserve-multiple-br-when-no-content-before-or-after-with-contenttools/36954440#36954440

So we'd have a setting of something like ContentEdit.TRIM_WHITESPACE which by default is true but that could be set to false to provide this behaviour.

@hassanakram
Copy link

Hi @anthonyjb, Yes sounds great!
I tried the code given in this SO post last night, looks like we might need to improve that code, because it does not save white spaces correctly. We always need to add some characters after the white spaces in order to save them. May be some function hooked with save button trims the white spaces.
Can I help you creating this functionality in a PR ? May be you can guide me a bit.

@anthonyjb
Copy link
Member

It's possible the solution there is no longer valid with the current version of CT as it was a valid solution when posting so will check that again later this evening and update the solution if it's not working - it's a bit of a mess of a solution but (if working) it could form the basis of what we're attempting to do.

It would be great to get some help on a PR @hassanakram - thank you 👍 - The changes would need making to the ContentEdit library (https://github.com/GetmeUK/ContentEdit) for this change. The only thing that might be a pain for you is the changes need to be made in CoffeeScript, but if you're used to CoffeeScript (or happy to spend an hour learning it) then that wont be an issue.

@anthonyjb
Copy link
Member

I've posted an enhancement issue for this here on CE: GetmeUK/ContentEdit#10

@hassanakram
Copy link

Ok sure. CoffeeScript won't be a problem, I am already used to it. I will try to look into this later tonight.

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

No branches or pull requests

4 participants