CKEditor inline editor on elements within an iframe

梦想的初衷 提交于 2019-12-10 16:12:12

问题


In an application I have content editable elements within an iframe and want to apply inline CKEditor to those elements. It works except when I scroll the iframe the CKEditor toolbars do not scroll with it. Is there a special flag or some way to get the toolbars to scroll with the iframe contents rather than with the parent window? Also I want to avoid adding the CKEditor script into the iframe.


回答1:


You can achieve this by wrapping the iframe with a container element that is the same size as the iframe and has relative positioning.

<div id="iframe-wrapper">
    <iframe>
        <body>
            <div contenteditable></div>
        </body>
    </iframe>
</div>

Then you move the position of each ckeditor panel into that container element and the absolute positioning values will work.

var el = $('iframe').contents().find('[contenteditable]');
el.ckeditor();
el.ckeditorGet().on('instanceReady', function(){
    $('body > .cke_float').appendTo('#iframe-wrapper');
});


来源:https://stackoverflow.com/questions/19416016/ckeditor-inline-editor-on-elements-within-an-iframe

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