How to keep the html source in CKEditor untouched?
|
09 Aug 10
I have just noticed you probably can use createfakeelement to achieve these. I haven't use this function before. Let me digest it a little bit and I will write something on it. |
|
02 Aug 10
I don't think that can be easily done. CKEditor (or bascially web WYSIWYG editors) use HTML contentEditable feature provided by web broswers to implement the WYSIWYG page editing functionalities, which understands the HTML input and converts it into DOM element trees before allowing user to edit on the page. During editing, it is the DOM element tree being edited instead of the HTML source and the DOM tree is converted into HTML source code again during submission. As line breaks and tabs in HTML source are ingored during DOM tree parsing, that cannot easily be preserved. If you insist to achieve what you want, one possible way that I can think of is converting all line breaks and tabs into HTML comments, which is preserved by DOM element tree. And during source editing/submission, convert back the HTML comments into tab/line breaks. But in order to achieve this, some customization into the core of CKEditor is needed. A rough guess is you may want to edit htmlparser and htmlwriter. |
|
02 Aug 10
Thank you for your quick answer! In addition I won't use the source view of CKEditor instead I'm using Codemirror for viewing the html source. Thus I have an own switching mechanism which also converts the PHP tags because CKEditor makes html entities out of them but they need to be shown as they are in Codemirror. Maybe it is possible to build in your suggestion into my switching mechanism without changing something in the core? I'll have a try... I have also noticed those two plugins you mentioned, thank you very much for your help! |
|
05 Aug 10
Okay, I can live with reformatting of the source. Because I'm not very experienced with the CKEditor, could you tell me how to write an plugin which displays an placeholder (fake element as far as I know) for entered JSP tags? Thank you! Cheers, MS |
|
18 Aug 10
Thanks for your help! Concerning to fake elements an example can easily be found in the folder of CKEditor in _source > plugins > link. This is the placeholder displayed for anchors. Concerning the reformatting I can settle for it so it doesn't matter.
Cheers, MS |
Please login to post answer.
I have a few problems with CKEditor.
It is very important for my users that a html source that is entered stays as entered and should not be "reformatted" by CKEditor. Means when a user enters (or pastes) a html source which consists of one single line (because of not producing to much spaces) it should also remain in one line. But when a user decides to write his html source with line breaks and indents and so on it also should stay the same.
Of course I have tried stuff like protectedSource and dataProcessor.writer.setRules but this is not the solution for my problem.
Help is very appreciated!
Thanks,
MS