private string IgnoreVoidElementsInHTML(string inputString)
{
inputString = inputString.Replace("<meta http-equiv=\"Content-Type\" content=\"application/xhtml+xml; charset=utf-8\">", "");
inputString = inputString.Replace("<br>", "<br/>");
inputString = inputString.Replace("\n\n", "\n");
inputString = inputString.Replace("\r", "");
inputString = inputString.Replace("<title></title>", "");
inputString = inputString.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE html PUBLIC" +
" \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">", "");
return inputString;
}
|
There is even a bigger problem. I believe it started after updating to 19.2.0.46. Please check against 19.2.0.39.
I just hit enter key between First and Second. When I take the plain text using RichTextEditor.Text property, I get 3 new line characters \n. See above screenshot.
It is a serious issue for us. Your earlier suggestion to replace double \n with single \n in this thread will not work. We have a very urgent release and it is important that this gets fixed.
Many times I notice that both <p></p> and <br> are inserted when hitting Enter key. To reproduce this, hit Enter keys twice between First and Second and then hit a backspace key. You will get the below in HtmlText property.
I guess, you are replacing <br> with one \n. And </p> with two \n. Which is causing an issue of multiple \n characters when only one \n is required.
Please do resolve this asap.
Regards,
Gautam Jain
Here is another example of above issue:
Although I hit only one enter key. There are three \n added. Causing a lot of issues. This can be reproduced when using backspace to delete the previous line and then hitting enter again to create new line.
Queries |
Answer |
I just hit enter key between First and Second. When I take the plain text using RichTextEditor.Text property, I get 3 new line characters. See above screenshot. |
We suspect that the issue is not raised due to latest version 19.2.0.46. it happens at certain operation.
We have tried to reproduce the issue with given details. However, we could see that the 2 new lines are added not 3 when entering in between the words.
We have shared the sample for your reference. Kindly modify the sample or else provide us the exact operation that causes the issue.
|
It is a serious issue for us. Your earlier suggestion to replace double with single in this thread will not work. We have a very urgent release and it is important that this gets fixed. |
As we said in previous update, RichTextEditor relies on Web-view with java-script content editable div. Content editable div returns 2 new lines when enters. This is the behavior of content editable div and RTE also does the same. So, we request you to replace the string at sample level
inputString = inputString.Replace("\n\n", "\n"); |
Many times I notice that both <p></p> and <br> are inserted when hitting Enter key. To reproduce this, hit Enter keys twice between First and Second and then hit a backspace key. You will get the below in HtmlText property. |
We could reproduce the issue “<p></p> and <br> tags are appended when hitting enter and back space”. We have forwarded this query to our dependent web team. We will provide the validation details on 12th 2021. |
Thanks a lot Prakash.
The first and third issue you had mentioned above are related.
You will be able to see three \n only when hitting backspace to remove new lines and then again hitting Enter key when adding new lines.
So when you try the above, you will see <p></p> and <br> both in the HtmlText property. At the same time you will see three \n in the Text property.
Your second suggestion to replace \n\n with \n works fine. But the above is creating a lot of issues as we cannot replace \n\n\n as they may contain actual new lines.
Thanks for your fantastic service. Hats off! Hope to get this resolved. We are stuck.
Regards,
Gautam Jain
Thanks Prakash, but the answers are not satisfactory.
Query |
Details |
The issue doesn’t appear when simply pressing enter key. This issue occurs when enters back space to remove the new line and enter the key
|
Yes, the issue with ‘/n/n/n’ doesn’t occur for simple enter key. It occurs when doing + backspace + enter
|
The former result is <p> <br> </p>The later result is <p> </p>
|
Sorry for the inconvenience.
We did not construct the HTML text in RichTextEditor. RichTextEditor is a wrapper of content editable div element. Content editable div element is an Html element. We get the HTML text from content editable div element and returned the same in RichTextEditor.
As mentioned in the previous update, this is a default behavior of HTML and RTE does the same.
You can the behavior of HTML in the below W3Schools by doing backspace +enter https://www.w3schools.com/code/tryit.asp?filename=GSAZCR6WF02B
|