Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

153
Visualizações
Draft.js conversion without browser

I'm in the middle of migrating some saved editor text/data from another rich text editor (Quill) to using Draft.js. The data exist in files in a format digestible by the current text editor, and I would like to transform these files to Draft.js format.

All of the rich text editors have some sort of data-to-html and html-to-data conversion functions, which come in handy here.

My plan was to convert the current editor text/data to html using a converter of the current editor, and then convert the resulting html to the format supported by Draft.js using some converter from the Draft.js package.

However, it seems (I could be wrong) that all of the Draft.js converters require the browser in some form or another, so I'm unable to this as a backend/server-side application only. Is there a tool that I'm missing and/or is there another type of solution to this?

TL;DR:

editor_data --(phase 1)--> html --(phase 2)--> Draft.js_data
phase 2 seems to require browser, I would like to not involve browser
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

convert data from quill to markdown and then convert markdown back to draftjs accepted format, below code is an example of export and can be executed using node, follow the same logic for import

quill --> markdown --> draftjs

https://github.com/sstur/draft-js-utils

const {
    convertFromRaw
  } = require('draft-js');
const {stateToMarkdown} = require('draft-js-export-markdown'); 
const {draftToMarkdown} = require('markdown-draft-js');
  
  const converter = () => {
      const sampleMarkup =
      {"blocks":[{"key":"dsf1t","text":"👍👎🏾 this isn't trueeeeeeeeeeeeeeeee","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[{"offset":0,"length":1,"key":0},{"offset":1,"length":2,"key":1}],"data":{}}],"entityMap":{"0":{"type":"emoji","mutability":"IMMUTABLE","data":{"emojiUnicode":"👍"}},"1":{"type":"emoji","mutability":"IMMUTABLE","data":{"emojiUnicode":"👎🏾"}}}} ;
  
      const blocksFromHTML = convertFromRaw(sampleMarkup);
    //   const state = ContentState.createFromBlockArray(blocksFromHTML);
  
      console.log('state: ', stateToMarkdown(blocksFromHTML));
      console.log('state: ', draftToMarkdown(sampleMarkup));
  }
  
  converter();

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda