Ckeditor no html tag

CKEditor, отображающий HTML-теги в редакторе

Я использую CKEditor и сохраняю содержимое в базе данных MySQL. При попытке изменить содержимое снова в редакторе я получаю HTML-теги, отображаемые в виде текста, например:

Как я могу снова отобразить его в редакторе?

Я занимаюсь htmlentities и html_entity_decode и настройками CKEditor более часа, но безрезультатно.

 $config = array(); $config['enterMode'] = 2; $config['shiftEnterMode'] = 1; //$config['basicEntities'] = FALSE; //$config['entities'] = FALSE; //$config['entities_greek'] = FALSE; //$config['entities_latin'] = FALSE; //$config['htmlDecodeOutput'] = TRUE; $ck_editor->editor("sec1_content", $default_value, $config); 

Solutions Collecting From Web of «CKEditor, отображающий HTML-теги в редакторе»

Кажется, что func set_value() функции CodeIgniter как- set_value() действует как htmlspecialchars() . Поэтому, если вы получаете в CKEditor, это обходное решение может вам помочь. + Изменить

$ck_editor->editor("sec1_content", set_value('sec1_content', html_entity_decode($default_value)), $config); 
$ck_editor->editor("sec1_content", html_entity_decode(set_value('sec1_content', $default_value)), $config); 

PoloRM
Поместите html_entity_decode вокруг set_value. Причина этого заключается, очевидно, в том, что метод set_value может не использовать параметр $ default_value, а вместо этого возвращать опубликованные данные.

Для людей, которые могут иметь такую ​​же проблему с CodeIgniter / CKEditor:

Способ решения этой проблемы и использование метода CodeIgniter set_value () заключается в следующем:

$ck_editor->editor("sec1_content", set_value('sec1_content', html_entity_decode($default_value)), $config); 
$ck_editor->editor("sec1_content", html_entity_decode(set_value('sec1_content', $default_value)), $config); 

Поместите html_entity_decode вокруг set_value. Причина этого заключается, очевидно, в том, что метод set_value может не использовать параметр $ default_value, а вместо этого возвращать опубликованные данные.

Спасибо, Корамба, за то, что заставил меня осознать мою ошибку.

  • Создать URL-адрес с параметрами из массива
  • Невозможно убить скрипт PHP
  • Схват атрибута href элемента A
  • Сохранить изображение с url с curl PHP
  • PHP формат даты mysql
  • Fetch Api не может получить сеанс с сервера PHP
  • как вы обнаруживаете, пришел ли ваш посетитель сайта из результатов поиска Google?
  • Передавать функции классу
  • Мне действительно нужно сделать mysql_close ()
  • Doctrine Inheritance – Single_Table inheritade from Join table
  • Проблема с сеткой Magento
  • Безопасный способ отправки почты через PHP многим пользователям
  • Проверка того, что два файла идентичны с использованием чистого PHP?
  • Проверьте, существует ли изображение на удаленном URL-адресе
  • Как отредактировать implode, чтобы он присоединил значения к двум строкам?

Источник

CKEditor 4.3.4 strips HTML5 Tags like figure, section..

im a little bit confused. I found a lot of topics with discusions about HTML5 Tags are supported by newer versions of the CKEditor and i also found some indications for HTML5 Tags in the .js files but at the moment i only find ways where people edit their dtd.js files and compile their own version.

Читайте также:  Как редактировать файл html

I use CKEditor 4.3.4 (revision 40ccd20) from the downloadpage in a testproject but the Editor strips html 5 tags.

For example i put some html5 tags in the sourcemode:

 
testheader
testcaption

Result after switching to wysiwyg and back:

Do i have to activate this functionality or use it in other way?
Maybe someone can give me an explicit answer about the point that HTML 5 Tags work in newer Versions of CKEditor out of the box, yes or no 😉

That the Allowed Content

That the Allowed Content Filter stepping in. You can use for example config.extraAllowedContent to allow these tags.

That the Allowed Content

thx for your fast reply. So i have to explicit list every single html5 element in the extraAllowedContent section?

extraAllowedContent: ‘section; article; header;’ .

Yes, it’d be something like:

Yes, it’d be something like:

extraAllowedContent: 'section article header nav aside. '

And if you want to allow some attributes for them:

extraAllowedContent: 'section article header nav aside[*]' // or more precisely: extraAllowedContent: 'section article header nav aside[lang,foo]'

Thx, i tried this and this

Thx, i tried this and this worked for my tested tags.

Im wondering that i actually cant find an adjusted config with adjusted extraAllowedContent Rules for html5 tags right now and i think im not the only one who tries to embed html5 support in his CKEditor 😉 .

BTW:

BTW:
1.) Tags containing an hyphen like extraAllowedContent: ‘test-tag’ wont work / still getting stripped. Are tags with hyphen underlaying some kind of reserved keywords or something else?

2.) Is it possible to allow tags with wildcards, for example allow every tag that starts with «test»? (testtag, testing. )

Personally I think that most

Personally I think that most of the people that want that kind of features just end up disabling ACF to avoid wasting the time with all those problems.

String format of ACF does not

String format of ACF does not allow incorrect (in HTML POV) characters in elements, attributes, classes and styles names. Or I should even say that it does not allow unusual characters, because HTML has very complicated characters sets in its grammar. To workaround this you can use the object format which doesn’t have to be parsed so it’s move forgivable. As for wildcards — that’s not possible yet. In CKEditor 4.4 we introduced (will introduce as for the time I’m writing this) wildcards in attributes, classes and styles names, but not in element names, because for defining HTML purposes they are not necessary.

Читайте также:  Java 8 support date

However, I should warn you that CKEditor is not «some XML editor». This is primarily an HTML editor and you would have to do more than just setting ACF, to make it work well with custom tags. For examaple — you should also extend CKEDITOR.dtd object. I cannot also guarantee that all CKEditor features will handle those custom tags, although I know that many people use them.

Источник

CKEditor 4.3.4 strips HTML5 Tags like figure, section..

im a little bit confused. I found a lot of topics with discusions about HTML5 Tags are supported by newer versions of the CKEditor and i also found some indications for HTML5 Tags in the .js files but at the moment i only find ways where people edit their dtd.js files and compile their own version.

I use CKEditor 4.3.4 (revision 40ccd20) from the downloadpage in a testproject but the Editor strips html 5 tags.

For example i put some html5 tags in the sourcemode:

 
testheader
testcaption

Result after switching to wysiwyg and back:

Do i have to activate this functionality or use it in other way?
Maybe someone can give me an explicit answer about the point that HTML 5 Tags work in newer Versions of CKEditor out of the box, yes or no 😉

That the Allowed Content

That the Allowed Content Filter stepping in. You can use for example config.extraAllowedContent to allow these tags.

That the Allowed Content

thx for your fast reply. So i have to explicit list every single html5 element in the extraAllowedContent section?

extraAllowedContent: ‘section; article; header;’ .

Yes, it’d be something like:

Yes, it’d be something like:

extraAllowedContent: 'section article header nav aside. '

And if you want to allow some attributes for them:

extraAllowedContent: 'section article header nav aside[*]' // or more precisely: extraAllowedContent: 'section article header nav aside[lang,foo]'

Thx, i tried this and this

Thx, i tried this and this worked for my tested tags.

Im wondering that i actually cant find an adjusted config with adjusted extraAllowedContent Rules for html5 tags right now and i think im not the only one who tries to embed html5 support in his CKEditor 😉 .

BTW:

BTW:
1.) Tags containing an hyphen like extraAllowedContent: ‘test-tag’ wont work / still getting stripped. Are tags with hyphen underlaying some kind of reserved keywords or something else?

2.) Is it possible to allow tags with wildcards, for example allow every tag that starts with «test»? (testtag, testing. )

Personally I think that most

Personally I think that most of the people that want that kind of features just end up disabling ACF to avoid wasting the time with all those problems.

String format of ACF does not

String format of ACF does not allow incorrect (in HTML POV) characters in elements, attributes, classes and styles names. Or I should even say that it does not allow unusual characters, because HTML has very complicated characters sets in its grammar. To workaround this you can use the object format which doesn’t have to be parsed so it’s move forgivable. As for wildcards — that’s not possible yet. In CKEditor 4.4 we introduced (will introduce as for the time I’m writing this) wildcards in attributes, classes and styles names, but not in element names, because for defining HTML purposes they are not necessary.

Читайте также:  Цвета на c sharp

However, I should warn you that CKEditor is not «some XML editor». This is primarily an HTML editor and you would have to do more than just setting ACF, to make it work well with custom tags. For examaple — you should also extend CKEDITOR.dtd object. I cannot also guarantee that all CKEditor features will handle those custom tags, although I know that many people use them.

Источник

Getting non-html text from CKeditor

When the form is submitted, you can serverside access hidden_snippet along with the rest of the fields in the form.

Solution 2

CKEDITOR.instances.editor1.document.getBody().getText(); 

It works fine for me. You can test it on http://ckeditor.com/demo. It’s not ideal (text in table cells is joined together without spaces), but may be enough for your needs.

EDIT (20 Dec 2017): The CKEditor 4 demo was moved to https://ckeditor.com/ckeditor-4/ and uses different editor names, so the new code to execute is:

CKEDITOR.instances.ckdemo.document.getBody().getText(); 

It’s also important that it will work in the «Article editor» and in the «Inline editor» you need to get text of a different element:

CKEDITOR.instances.editor1.editable().getText(); 

Solution 3

i personally use this method to compact the code and remove also double spaces and line feeds:

 var TextGrab = CKEDITOR.instances['editor1'].getData(); TextGrab = $(TextGrab).text(); // html to text TextGrab = TextGrab.replace(/\r?\n|\r/gm," "); // remove line breaks TextGrab = TextGrab.replace(/\s\s+/g, " ").trim(); // remove double spaces 

Solution 4

function getPlainText( strSrc ) < var resultStr = ""; // Ignore the 

tag if it is in very start of the text if(strSrc.indexOf('

') == 0) resultStr = strSrc.substring(3); else resultStr = strSrc; // Replace

with two newlines resultStr = resultStr.replace(/

/gi, "\r\n\r\n"); // Replace
with one newline resultStr = resultStr.replace(/
/gi, "\r\n"); resultStr = resultStr.replace(/
/gi, "\r\n"); //-+-+-+-+-+-+-+-+-+-+-+ // Strip off other HTML tags. //-+-+-+-+-+-+-+-+-+-+-+ return resultStr.replace( /<[^<|>]+?>/gi,'' ); >

var plain_text = getPlainText(FCKeditorAPI.GetInstance("FCKeditor1").GetXHTML()); 

I created this fiddle for testing: http://jsfiddle.net/4etVv/3/

Solution 5

Assuming that editor is your CKEditor instance ( CKEditor.instances.editor1 from above example or if you are using events then event.editor ). You can use following code to get plain text content.

Apparently CKEditor adds a «voice label» element to the actual editable content. Hence getChild(0) .

Источник

Оцените статью