Automatically adjust height to contents in Ace Cloud 9 editor

前端 未结 8 2002
孤街浪徒
孤街浪徒 2020-12-04 11:28

I\'m trying to add the Ace editor to a page, but I don\'t know how to get the height to be set automatically based on the length of its contents.

Ideally it would wo

8条回答
  •  不知归路
    2020-12-04 11:45

    My method in pure JavaScript (replace editor-container with the right id).

    function adaptEditor() {
        document.getElementById('editor-container').style.height = window.innerHeight + 'px';
        editor.resize();
    }
    window.onresize = function(event) {
        adaptEditor();
    };
    adaptEditor();
    

提交回复
热议问题