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

243
Views
Paste rich text as plain text without HTML markup formatting in Trix editor

I am using Rich Text (Trix editor) with Rails and I want to be able to convert everything that user pastes to sanitized plain text instead of having formatted elements. Based on Trix documentation I am using this code to convert pasted elements to string.

const element = document.querySelector("trix-editor")
  element.addEventListener("trix-paste", function(e) {
    element.editor.getDocument().toString()
    console.log(element.editor.getDocument().toString())
  })

In console, it shows correct plain text, but in the editor, all the elements are still formatted.

How can I replace text in the editor to this sanitized text?

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!