How to Rid of Large Spacing in CKEditor?

蹲街弑〆低调 提交于 2019-12-03 15:39:53

问题


I installed CKEditor, i found it causes large space between lines even though i'm just pressing enter once to move to the next! I have to press "Shift" for every enter to have the breakline! Any idea on how to make it work without pressing Shift?

Line 2 caused by pressing Shift + enter. Line 3 caused by just pressing Enter.

I'm using PHP


回答1:


You can set in your config.js to use a <br> instead of <p> while hitting the ENTER key:

config.enterMode = CKEDITOR.ENTER_BR;

The available flags are

CKEDITOR.ENTER_P (1) – new <p> paragraphs are created;
CKEDITOR.ENTER_BR (2) – lines are broken with <br> elements;
CKEDITOR.ENTER_DIV (3) – new <div> blocks are created.

Look on the docs for enterMode for further details


Expanding on Josepth Silber answer (that he know deleted.. He suggested using config.autoParagraph = false; ), IIRC (the Manual is not really clear on what create wrapping blocks around inline contents means), the autoParagraph config adds a <p></p> pair around each inline content inside the body. So, even if you hit Enter on an empty line, it will generate <p></p> (or <p>&nbsp;</p>, if so configured). The manual suggest leaving that option as it is, though (so set to true);




回答2:


I found it easier to hardcode this. Open the file sites/all/libraries/ckeditor/ckeditor.js in Notepad++ Go to line 22 or search for shiftEnterMode

Change following:

enterMode:1,forceEnterMode:false,shiftEnterMode:2,

into:

enterMode:2,forceEnterMode:false,shiftEnterMode:1,

done!



来源:https://stackoverflow.com/questions/8098867/how-to-rid-of-large-spacing-in-ckeditor

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