0

我有以下代码:

app.directive('ckEditor', [function () {
    return {
        require: '?ngModel',
        link: function ($scope, elm, attr, ngModel) {

            var ck = null;
            var config = attr.ckSize;

            ck = CKEDITOR.replace(elm[0]);
            if (config == 'narrow') {
                ck.resize(700, 357);
            } else {
                ck.resize(900, 357);
            }

我正在尝试调整 ckEditor 实例的大小,但它给了我一条错误消息:

TypeError: Cannot call method 'setSize' of undefined
    at CKEDITOR.editor.resize (http://127.0.0.1:81/Scripts/ckeditor/ckeditor.js:294:23)

有人可以就如何更改该编辑器大小的实例给我建议吗?

4

1 回答 1

1

这是从这里创建实例代码:

function createEditor()
{
    if ( editor )
        return;

    var html = document.getElementById( 'editorcontents' ).innerHTML;

    // Create a new editor inside the <div id="editor">, setting its value to html
    var config = {};
    editor = CKEDITOR.appendTo( 'editor', config, html );
}

确保代码中存在 id='editorcontents' 的 div:

<div id='editorcontents'></div>

帮助页面的底部有width你尝试过的属性:

ck.width = 700;
ck.height = 357;
于 2013-10-30T18:46:59.390 回答