TLP
TLP

Reputation: 67900

CKEditor excessive formatting of plain text

The problem:

CKEditor is adding tons of <span> tags to plain text, such as the example below.

The code:

The setup is a php page, calling ckeditor and saving entries into a PostgreSQL table. I believe most settings on CKEditor is default. Here's some of the code:

include ('./ckeditor/ckeditor.php') ;
$CKEditor = new CKEditor() ;
$CKEditor->returnOutput = true;
$CKEditor->basePath = '/ckeditor/';
$CKEditor->config['width'] = 560;
$CKEditor->config['height'] = 300;
$CKEditor->textareaAttributes =
                array("cols" => 90, "rows" => 70);
$CKEditor->config['DefaultLanguage'] = "sv" ;
//$CKEditor->config['EnterMode'] = CKEDITOR.ENTER_BR;
$config['toolbar'] = array(
        array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike', '-' ),
        array( 'Image', 'Link', 'Unlink', '-', 'Table', 'NumberedList','BulletedList' )
);
$config['skin'] = 'v2';

Example input/output (in source):

The input:

En hel del av er

Becomes:

En <span data-scayt_word="hel" data-scaytid="2">hel</span> del 
<span data-scayt_word="av" data-scaytid="3">av</span> 
<span data-scayt_word="er" data-scaytid="4">er</span>

Is there a way to avoid this behaviour?

Upvotes: 1

Views: 3544

Answers (3)

user557846
user557846

Reputation:

overkill to to turn the plug-in off if you still want it you can clean the output like so in php:

$output = preg_replace('/<span data-scayt_word="[^"]+" data-scaytid="[0-9]*">([^<]+)<\/span>/','$1',$input);

*credit to balrok for the regX

Upvotes: 2

balrok
balrok

Reputation: 454

I also had this problem, if you want to clean up the html-source you can use this sed command:

cat scaytPolluted.html | sed -r 's/<span data-scayt_word="[^"]+" data-scaytid="[0-9]*">([^<]+)<\/span>/\1/g' > clean.html

Upvotes: 1

atma
atma

Reputation: 875

The easiest way: disable the spellchecker (scayt - spellcheck as you type)

$CKEditor->config['removePlugins'] ='scayt'; // comma separated if many

How to remove unused plugins

If you want to leave SCAYT available, but prevent the feature from being turned on automatically:

$CKEditor->config['scayt_autoStartup'] = false;

But this is strange behavior, how do you retrieves the content from ckeditor instance? Just try to get data from firebug to see the not dirty content:

console.log( CKEDITOR.instances.your_instance_name.getData() );

Upvotes: 5

Related Questions