简体   繁体   English

Ace编辑器未使用容器div调整大小

[英]Ace Editor is not resizing with the container div

I have container div 'myeditor' and I'm adding an ace editor to that div using: 我有容器div'myeditor',我正在使用以下方法向该div添加一个ace编辑器:

var editor = ace.edit('myeditor');
editor.setTheme("ace/theme/terminal");
editor.getSession().setMode("ace/mode/sql");
editor.getSession().setUseWrapMode(true);

Editor looks like this: 编辑器如下所示: 在此处输入图片说明

As shown in the above example it is not taking the full width of the container and the black line is coming on the right. 如以上示例所示,它没有占用容器的整个宽度,黑线在右侧。

Here, the container is resizable. 在这里,容器是可调整大小的。 How can I resize ace editor to fit container whenever the container is resized? 每当调整容器大小时,如何调整ace编辑器的大小以适合容器?

Following is the structure of elements: 以下是元素的结构: 在此处输入图片说明

There is the main div which has a gutter to expand the div horizontally, which expands inner div as well. 有一个主div,该主div具有一个可在水平方向上扩展div的装订线,该沟槽也可以在内部div上扩展。 Inner div is 'myeditor'. 内部div是“ myeditor”。 I am not able to share code as it is an internal project. 我无法共享代码,因为它是一个内部项目。

It looks like you might be referring to the print margin line. 看起来您可能是在指打印边距线。 If that's the case, you can disable it by using editor.setShowPrintMargin(false); 如果是这种情况,可以使用editor.setShowPrintMargin(false);禁用它editor.setShowPrintMargin(false); .

Example: 例:

 var editor = ace.edit('myeditor'); editor.setTheme("ace/theme/terminal"); editor.getSession().setMode("ace/mode/sql"); editor.getSession().setUseWrapMode(true); editor.setShowPrintMargin(false); 
 #myeditor { position: absolute; width: 100%; height: 100%; } 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.4/ace.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.4/theme-terminal.js"></script> <div id="container"> Editor is below. <div id="myeditor"> </div> </div> 

Otherwise, I can't seem to reproduce your issue. 否则,我似乎无法重现您的问题。 If you aren't referring to the print margin line, can you include your HTML? 如果您不参考打印边距行,可以包含HTML吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM