0
I have a character counter that works well for text without special conditions, for example a text without bold none works very well, however ,if I put bold in the text, the counter does not recognize the <b>
, and so the substitution does not work, because the starting point and end point are incorrect. How can I count the characters that are hidden, such as characters that make text bold?
$j2(document).on("change", ".abre", function(evt){
var selection = document.getSelection('#m_summernote_1');
//conta inicio da palavra selecionada
var start5 = selection.anchorOffset;
//conta final da palavra selecionada
var finish5 = selection.focusOffset;
//texto que irá substituir a palavra seleciona
var textot = $j2("#valor option:selected").val();
//texto completo do textarea
var textoc = $j2('#m_summernote_1').val();
//aqui eu limpo o texto original , apagando a partir do ponto incicial start5 e finish5
var delText = textoc.substr(0,start5)+''+textoc.substr(finish5);
// aqui coloco o texto que irá substituir a palavra selecionada
var addText = textoc.substr(0,start5)+textot+delText.substr(start5);
//aqui eu substituo o texto do textarea
$("#m_summernote_1").summernote("code", addText);
});
var textoc = $j2('#m_summernote_1').text();
– vik
opa, the change of val by text in this case has not changed at all, because the text it is picking full. what seems to have some incompatibility would be at this point: var Selection = Document.getSelection('#m_summernote_1'); //start account of the selected word var start5 = Selection.anchorOffset; //end account of the selected word var finish5 = Selection.focusOffset; maybe anchorOffSet and focusOffSet don’t recognize the text with the special characters, for example they don’t count the initial <b> of a text.
– Michel Carnelós Rodrigues