简体   繁体   English

在CKEditor中可调整大小的jQuery UI

[英]jQuery UI Resizable in CKEditor

I am trying to get a within a CKEditor instance working with jQuery UI Resizable. 我试图在使用jQuery UI Resizable的CKEditor实例中获取一个。

I use the following code to setup jQuery UI Resizable: 我使用以下代码来设置jQuery UI Resizable:

var ckinstance = CKEDITOR.instances.ckeditor-1;
ckinstance.on("instanceReady", function() {
    $(ckinstance.document.$).find(".gallery").resizable();
});

This seems to half work. 这似乎完成了一半。 If I inspect the HTML within the CKEditor instance the div has all the jQuery UI Resizable tags for handles etc but the div doesn't seem to be able to resize. 如果我检查CKEditor实例中的HTML,则div具有用于句柄等的所有jQuery UI Resizable标签,但是div似乎无法调整大小。

Does anyone know why the div won't resize? 有谁知道为什么div不会调整大小?

I don't understand why jQuery UI Resizable. 我不明白为什么jQuery UI Resizable。 CKEditor already has own resizing API: CKEditor已经拥有自己的大小调整API:

Perhaps you should better rethink your goal. 也许您应该更好地重新考虑您的目标。 Anyway, if you really want to use jQuery UI, consider this HTML: 无论如何,如果您确实要使用jQuery UI,请考虑以下HTML:

<div id="resizable" style="overflow: hidden;">
    <textarea id="editor1">
        Initial content
    </textarea>
</div>

And the following JavaScript: 以及以下JavaScript:

(function( $ ) {
    var editor = CKEDITOR.replace( 'editor1', {
        width: '100%',
        resize_enabled: false       // Disable native CKEditor resize.
    });

    $( "#resizable" ).resizable({
        resize: function( event, ui ) {
            editor.resize( '100%', ui.size.height - 2 );        // Play with this.
        }
    });
})( jQuery );

Editor will be automatically adjusted to your #resizable container. 编辑器将自动调整为您的#resizable容器。 If the performance is crucial (old browsers), consider using the stop event instead. 如果性能至关重要(旧的浏览器),请考虑使用stop事件

Have fun! 玩得开心!

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

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