[#12578] Fix @ issue by using innerHTML tag #12586
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #12578
Outline of Solution
I have identified that the backend database stores special characters as HTML-encoded entities, which is sent back to the UI.
My solution is to fix the issue in the UI by decoding the HTML characters and showing them in the UI.
I found two ways to do this. Both have advantages and disadvantages, but both approaches work flawlessly as far as I have tested them.
The first approach was to use the innerHtml tag, which automatically decodes text, but for this, ngModel should be removed since ngModelChange works with ngModel; it also has to be removed and replaced with input event so that event binding to the variable works.
The second approach its to use approach mentioned here https://www.npmjs.com/package/decode-html-entities.
The second approach is to create another textarea that does the decoding and gets its value to be shown in the UI.
The code for the above approach is simple, but it requires the creation of another texture
transform(value: any, args: any[]): any {
if (!value) return;
let txt = document.createElement("textarea");
txt.innerHTML = value;
return txt.value;
}
I went with the first approach rather than creating a new textarea box.