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

171
Visualizações
Render React-Component inside ContentEditable

I use a ContentEditable from react-contenteditable, inside of it I would like to render a button, which opens a menu on click, like this one. It already works, when I render the button normally as a component (not inside the Contendeditable).

Unfortunately, react-contenteditable only allows me to set the html as shown in this example.

I have already tried to use ReactDomServer.renderToStaticMarkup and ReactDomServer.renderToString, but the button is firing the defined onClick function when I click it.

Here is the code I tried: (addSummaryStatementButton is the corresponding button and ContentEditable the corresponding contend-editable.

render = () => {
        const addSummaryStatementButton =
            <AddSummaryStatementButton addSummaryStatement={() => console.log('add summary statement')}/>;
        const staticMarkup = ReactDomServer.renderToStaticMarkup(addSummaryStatementButton);
        const stringMarkup = ReactDomServer.renderToString(addSummaryStatementButton);

        let summary = this.props.summary;
        summary = summary + '<br />' + staticMarkup + '<br />' + stringMarkup;

        return <div className='summary-area'>
            <div className='summary'>
                <ContentEditable
                    html={summary}
                    disabled={false} // use true to disable edition
                    onChange={this.handleChange} // handle innerHTML change
                    spellCheck={false}
                    onBlur={this.props.analyzeSummary}
                />
            </div>
        </div>;

    };

I am very happy for any Ideas!

about 4 years ago · Juan Pablo Isaza
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