HTML source indentation for ckeditor

旧城冷巷雨未停 提交于 2019-12-07 20:40:37

问题


When you add some code to a ckeditor in HTML view and then change to WYSIWYG view and come back, almost all HTML tags have been modified and have loose the indentation. Is there any way to prevent this behaviour? (parameter, plugin, hard code...)

For example:

<div class="former input">
    <span class="big horizontal">
        <label for="test">Hi world</label>
        <input class="medium free" id="test" name="test" type="text" />
    </span>
</div>

Becomes:

<div class="former input">
    <span class="big horizontal"><label for="test">Hi world</label><input class="medium free" id="test" name="test" type="text" /></span></div>

回答1:


Here's a link to a page in the developer's guide:
Output Formatting

It explains how to control the layout of the HTML code that is output by the editor and has an example that sets the formatting for the <p> tag.

Try using the <p> tag example as a template and set the formatting for the <span>, <label> and <input> tags using the same approach.

writer.setRules( 'span',
writer.setRules( 'label',
writer.setRules( 'input',

Be Well,
Joe



来源:https://stackoverflow.com/questions/7512258/html-source-indentation-for-ckeditor

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