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

155
Views
How to retain the proper formatting on partially copying the tags

I have added a custom event listener to copy/cut of Rich text (HTML) from an element (say elementId). Now when I copy partial ordered list tags, it converts them to unordered list items. This happens due to partial copying the list. Is there any way to solve this ?

document.getElementById(config.editorEl).addEventListener('copy', function(event) {
    const range = window.getSelection().getRangeAt(0);
    const content = range.cloneContents();
    const div = document.createElement('div');
    div.appendChild(content);
    $(div)
    .find('.remove_this_class')
    .contents()
    .unwrap();
    event.clipboardData.setData('text/html', div.innerHTML);
    event.preventDefault();
    });

Summary: when I copy partial ordered list tags, custom copy handler converts them to unordered list items. How to retain the same ? I see many RTFs have this working.

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!