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

78
Views
Leer texto formateado draft.js desde el portapapeles

Cuando hago clic en el botón, el texto del portapapeles se pega sin estilo, pero mantiene el estilo actual en línea, pero eso no es lo que necesito.

Mi código

 async function getClipboardContents() { try { const textFromClipboard = await navigator.clipboard.readText(); const newContentState = Modifier.replaceText( editorState.getCurrentContent(), editorState.getSelection(), textFromClipboard, editorState.getCurrentInlineStyle(), ); const newPushState = Draft.EditorState.push(editorState, newContentState, 'change-block-data'); handleOnChange(newPushState); } catch (err) { console.error('error', err); } }

¿Qué hay que hacer para que el texto se inserte con formato?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El formato de texto se pierde después de usar clipboard.readText() . Debería usar clipboard.read() en su lugar. Devolverá una matriz de ClipBoardItem .

Puede leer su formato inicial de este objeto de esa manera:

 const [clipboardItem] = await navigator.clipboard.read(); const blob = await clipboardItem.getType('text/html'); // Here's your formmated text const formattedText = await new Response(blob).text();
about 4 years ago · Juan Pablo Isaza Report
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!