Hi Clifton,
You may remember, some time ago, you helped me create colored link words dynamically in a text. There was a problem if the text included line breaks so I decided to replace line breaks with spaces. I have thought about this and I think that I would prefer to keep the line breaks as these may be important in reported speech, for example.
I use caretPosition to add a marker to the text and I have discovered that this causes all the <br> tags in the innerHTML to disappear. Can this be avoided, please? I have put an example here: https://www.mediacours.com/tb_examples/line_break/ and a zip here: https://www.mediacours.com/tb_examples/line_break.zip
Thanks for you time.
John
UPDATE
I have now found a way round this in the test app by doing this:
let txt = sharedActions.obj2.innerHTML;
txt = tbfunction_pgReplace("<br>", "~", txt, true);
sharedActions.obj2.innerHTML = txt;
tbfunction_caretPosition("myText2", 5, "", " ADDED ", false);
txt = sharedActions.obj2.innerHTML;
txt = tbfunction_pgReplace("~", "<br>", txt, true);
const fct = function()
{
sharedActions.obj2.innerHTML = txt;
}
setTimeout(fct, 100)
So far I have not been able to apply this to my program. I did not realise that ANY use of tbfunction_caretPosition results in the elimination of all occurrences of <br> in the innerHTML. Maybe this is an inevitable part of your system? I imagine you must be using the innerText and/or textContent properties. I'll try again and let you know if I solve the problem.
UPDATE 2
I now have a system that works in my program so, if you have more important things to do, don't worry too much about this. I was wrong about 'ANY use of tbfunction_caretPosition'.
For example: tbfunction_caretPosition("myText2", "home"); and let pos = tbfunction_caretPosition("myText", -1); leave the <br> tags in place but tbfunction_caretPosition("myText2", "end"); does not.
I must now do some more thorough testing to see if my workaround is reliable or not.
John