0

Editor WYSIWYG genera dentro de un div contenteditable = true

<script>
const editor = document.getElementById('editor');
    
$('#bold').bind('click', function () {
    document.execCommand('bold', false, null);
});
$('#italic').bind('click', function () {
    document.execCommand('italic',  false, null);
});
</script>

Importante SOLO SUCEDE EN CHROME

En ocasiones añade codigo "style="" al escribir manualmente cualquier texto, posterior seleccionarlo y aplicar los efectos de los botones bolt o italic

<button type="button" id="bold" class="editor-button" title="Bold"><i>format_bold</i></button>
<button type="button" id="italic" class="editor-button" title="Italic"><i>format_italic</i></button>
<div id="editor" contenteditable="true"><b style="">prueba escrita a mano</b></div>

Al ver el codigo del div "editor" añade styles automaticamente al cargar distintos

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.