Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
¿Cómo agregar un rango completo en el contenido del editor?

Tengo estas dos funciones: la primera es para cuando alguien elige una opción del cuadro de selección en la barra de herramientas y la agrega al contenido del editor.

el código está funcionando pero agrega span como este:

<span class="text-tiny">Second Side</span>

Cuando vaya al editor, quiero que sea así:

<span class="text-tiny" id="second_side">Second Side</span>

con identificación en el lapso

El código

 document.addEventListener("DOMContentLoaded", function() { forms.forEach(function(item,index) { var option = document.createElement('option'); option.setAttribute("value",'<span class="text-tiny" id="'+id+item.type+'">'+item.name+'</span> <span></span>'); option.innerHTML = item.name; select.appendChild(option); div.appendChild(select); }); select.addEventListener('change', (e) => { insertHTMLAtCursor(editor,select.value) }); }); function insertHTMLAtCursor(id,value){ // value = <span class="text-tiny" id="second_side">Second Side</span> const viewFragment = id.data.processor.toView(value); const modelFragment = id.data.toModel(viewFragment); id.model.insertContent(modelFragment, id.model.document.selection); }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!