3

I'm using Drupal 8,

In source view when I paste some plain text like this:

Hello sir.
<br />
Hello  sir.

And submit node form, without toggling back to rich-text mode, text above is removed.

If I toggle back in rich-text mode before submitting, CKEditor automatically wraps my text in p tag, like this:

<p>Hello sir.<br />
Hello sir.<br />
Hello sir.<br />
Hello sir.</p>

So is it possible to make CKEditor wrap plain text in p without toggling back to rich-text view?

I have tried several things and failed in all of them, I have written custom CKEditor plugin which listens to submit button click and execute this editor.execCommand( 'source' ); but it isn't working, somehow data is submitted before I switch to rich-text mode.

Is there any solution to this?

  • 1
    This sounds like it might be a fairly advanced configuration for CKEditor and something the CKEditor devs themselves would best be able to answer. Maybe raise a ticket here: dev.ckeditor.com ? – JamesWilson Apr 1 '16 at 14:37
2

CKEditor distinguishes Output formatting from Source Code formatting.

You're essentially wanting to do output formatting inside the source code formatting. It seems this is currently not possible.

From the documentation:

Configuring Source Code Format

At the moment the only aspect of the source code view that you can configure is the tab-size CSS property of the source editing area. Use the CKEDITOR.config.sourceAreaTabSize option to set the width of the tab character. Enter an integer to denote the number of spaces that the tab will contain.

http://docs.ckeditor.com/#!/guide/dev_sourcearea

You might play with using the popup source editor instead of the inline editor, I don't know if this would give you any more possibilities to plug into and alter the HTML in source-editing mode or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.