No quiero que el editor tenga altura, quiero que el editor muestre todo el contenido sin barra de desplazamiento, la altura como la altura del contenido
¿Cómo debo configurar la configuración del editor o el css?
Progreso en: #
@ hh54188 U puede cambiar el tamaño de la altura del editor o pasar la altura como apoyo al editor ace para lograr alturas dinámicas sin barra de desplazamiento
Entonces, si su componente se ve así
<AceEditor
onLoad={onLoad}
height={someInitialHeight}
...
/>
onLoad(editor){
// Your editor options comes here
editor.on('change', (arg, activeEditor) => {
const aceEditor = activeEditor;
const newHeight = aceEditor.getSession().getScreenLength() *
(aceEditor.renderer.lineHeight + aceEditor.renderer.scrollBar.getWidth());
aceEditor.container.style.height = `${newHeight}px`;
aceEditor.resize();
});
}
md5-2967d728d81c1ff90dc28eeb85463c7c
```js
getIntitialHeight(editor=){
if(editor){
let newHeight;
newHeight = editor.getSession()
.getScreenLength() *
(editor.renderer.lineHeight + editor.renderer.scrollBar.getWidth());
newHeight = newHeight > 70 ? newHeight : 70;
return `${newHeight}px`;
}
return someInitialHeight
}
¡Espero que esto responda tu pregunta!
@securingsincity
@ Vijayk93
probé esto y no funciona para mí; el editor mantiene el mismo tamaño
Puede usar el Stylesheet
inherit
o el 100%
:)
Muestra:
<AceEditor height="inherit" />
<AceEditor height="100%" />
El 100% se ajustará al padre, para adaptarse al contenido, use las opciones maxLines y minLInes de ace como se muestra en https://ace.c9.io/demo/autoresize.html
@ Bugaa92 ¿Puedes crear un bolígrafo o un violín para que podamos probar esto?
No establezca ningún height
y use maxLines={Infinity}
para que la altura del editor se ajuste a su contenido y deshabilite el desplazamiento vertical
maxLines = {Infinity}
Esto realmente funcionó para mí
Desafortunadamente, esto no funciona en el modo "Split" https://github.com/securingsincity/react-ace/blob/master/docs/Split.md ... cualquiera tiene ideas sobre cómo lograr lo mismo en Split ¿vista?
Comentario más útil
No establezca ningún
height
y usemaxLines={Infinity}
para que la altura del editor se ajuste a su contenido y deshabilite el desplazamiento vertical