jQuery UI Resizable in CKEditor

喜你入骨 提交于 2019-12-08 04:41:15

问题


I am trying to get a within a CKEditor instance working with jQuery UI Resizable.

I use the following code to setup 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.

Does anyone know why the div won't resize?


回答1:


I don't understand why jQuery UI Resizable. CKEditor already has own resizing API:

  • editor.resize() for resizing on-demand
  • config.resize_enabled, config.resize_maxHeight, config.resize_maxWidth and so on - to control resizing process

Perhaps you should better rethink your goal. Anyway, if you really want to use jQuery UI, consider this HTML:

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

And the following 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. If the performance is crucial (old browsers), consider using the stop event instead.

Have fun!



来源:https://stackoverflow.com/questions/12487190/jquery-ui-resizable-in-ckeditor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!