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

242
Views
Cómo inyectar un nuevo elemento en SlateJS Editor DOM

¿Cómo inyectar un nuevo componente/elemento de reacción en SlateJS Editor DOM?

Quiero inyectar un nuevo elemento dentro del DOM del editor SlateJS, no arriba o abajo.

La mayoría de los ejemplos de SlateJS transformarían nodos, pero no permite la inyección directa en el DOM de SlateJS. Eso está dentro del contexto del editor.

P.EJ

 SlateJS Typing INJECTED REACT COMPONENT SlateJS Typing SlateJS Typing <div slatejs editor> <div child div> // Want to insert a react component here <div child div> </div>

En este momento, puede agregar un nuevo componente de reacción arriba o debajo del editor SlateJS, pero no dentro.

 <Slate editor={editor} value={value} onChange={value => setValue(value)}> // <Tags /> Added component on top of SlateJS Editor <Editable placeholder="Enter some rich text…" spellCheck autoFocus onKeyDown={event => { switch (event.key) { case '/': { event.preventDefault() console.log('/ Command') // How to DOM inject into the current SlateJS component? ReactDOM.render(<Tags />, ...) } } }} /> // <Tags /> Added component UNDER SlateJS Editor </Slate>,

Mi solución actual es intentar inyectar a través de ReactDOM, pero tengo problemas para obtener el componente SlateJS real, ya que no puedo configurar la ID, lo que dificulta la consulta de documento.

¿Cómo podría inyectar un nuevo componente de reacción dentro del dom SlateJS?

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

0

Al final, inyecté el componente React en el div H1 en Elements. Aunque, este método tiene errores.

Es decir, mantenga todo igual en el ejemplo de texto enriquecido excepto los elementos, modificados a continuación.

Línea de ejemplo de texto enriquecido

 const Element = ({ attributes, children, element }) => { const style = { textAlign: element.align } switch (element.type) { case 'heading-one': return ( <h1 style={style} {...attributes}> {children} // Just inserted the react component in the h1 div // Easiest way, but causes a bunch of slate errors when trying // to click the react component line <REACT_COMPONENT /> </h1> ) default: return ( <p style={style} {...attributes}> {children} </p> ) } }
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!