问题
I have written a plugin that adds bootstrap grid into the editor.However it seems that CKEditor deletes the whole wrapping col div when there is no content inside it.
Plugin on github: https://github.com/radko26/CKEditor_layoutmanagerPlugin/tree/master/layoutmanager
This is what is default inside the dom.When i delete the 'content', the editor removes the wrapping div-layout-column .
<div class="container-fluid layout-container">
<div class="row layout-row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 layout-column">
<p>content</p>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 layout-column">
<p>content</p>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6 layout-column">
<p>content</p>
</div>
</div>
I read through this documentation and althought the div element is not stripped on default, i added
config.protectedSource.push(/<div[^>]><\/div>/g);
CKEDITOR.dtd.$removeEmpty['div'] = false;
inside the config.js.
http://docs.ckeditor.com/#!/api/CKEDITOR.dtd
I have thought about a workaround: to listen for editor change when layout-column will be with no data,(i must think more about that part), and insert blank space to prevent the editor from removing it, but i was wondering if any event is fired when the editor removes the div or is there easier way to solve my problem.
I tried the solutions suggested but none of them seems to solve the problem.
来源:https://stackoverflow.com/questions/29322028/why-ckeditor-ignores-empty-div-or-is-it-something-else