How to set context as html code into CKEditor? - ckeditor

I use CKEditor to insert some content in 'wysiwyg' mode. I input Hello, world! in the editor, and the real context inserted into database is <p>Hello, world!</p>.
Now I load the data from database and set it into CKEditor:
String content = loadFromDb();
// --> <p>Hello, world!</p>
CKEditor.instances['test'].setData(content);
But in the CKEditor, it shows:
<p>Hello, world!</p>
in 'wysiwyg' mode. When I click 'source' button, it shows:
<p> <p&rt;Hello, world!</p></p>
How can I set the data as html code, and I can see only Hello, world! in CKEditor on 'wysiwyg' mode?

Did you try simply using the insertHtml command? If you are loading it into a blank editor or not it should do the right thing. There is a function that strips off the tags too, bujt I don't recall that right now...

Related

How to add more html to sweetalert after html to content update?

I saw previously you could edit the html portion of the sweetalert, but now that has been changed to content instead of doing raw html. Is there a way to go back to using html or another way of adding in an input. I saw in another post that it may be better to just use a modal instead.
https://github.com/sweetalert2/sweetalert2/issues/451 here is the guide with the html.
You are using SweetAlert2.
The plain HTML option still exists.
This is used as follows:
swal({
title: 'Title',
html: 'A custom <span style="color: #F8BB86">html<span> message.'
});
Javascript Sweet Alert and html link inside text

CKEditor alters content

When I save my content, it changes things that I don't want to be changed. How can I make it so it would just save my content without changing anything?
Content before saving:
<a anything</a>
After save, the above example becomes:
<a a="" anything=""> </a>
I'm trying to find a config option that would make it so when I save my content, it would save it just as it is - without adding anything of its own.
This <a anything</a> is not a valid HTML and CKEditor works only with a valid HTML. So once you try to load this content into CKEditor it (or the browser) tries to fix it.
Quoting CKEditor basic concepts:
CKEditor is not a tool that will let you input invalid HTML code. CKEditor abides by W3C standards so it will modify code if it is invalid.

CKEditor HTML Autocorrection Issue

I have few lines of HTML in my database. I want to edit the content in CKEditor. But when I open that in editor the HTML gets break down. The HTML gets rearranged.
Below is the HTML which is in database:
<span class="sec_title">
<h1><span>Web</span> Engineering</h1>
<hr>
</span>
And when I open it in CKEditor the HTML looks likes below:
<h1><span class="sec_title"><span>Web</span> Engineering</span></h1>
<hr />
Some one please help me. I tried config.allowedContent = true; but it is also not stopping the CKEditor to do the modifications.
CKEditor works with a valid HTML only and <h1> is not a valid content of <span>. Quoting CKEditor basic concepts:
CKEditor is not a tool that will let you input invalid HTML code. CKEditor abides by W3C standards so it will modify code if it is invalid.

When using CKEditor in inline mode, when can be be sure that the editor is fully ready?

I am using CKEditor with CKEDITOR.disableAutoInline = true.
I then call inlineAll() to inline all contenteditables.
Immediately, after, I am getting data out of the editor:
CKEDITOR.inlineAll();
var editor = ... //get the editor instance
console.log(editor.getData());
The problem is that CKEDITOR changes the markup, and the one I get using getData() is before the change.
This is what the content markup looks like:
<p>testaaatest testbbbtest</p>
<p>test asdf</p>
link
<p>test</p>
link
<p>test</p>
CKEDITOR modifies the markup so that the <a>s are in their own paragraphs:
<p>testaaatest testbbbtest</p>
<p>test asdf</p>
<p>link</p>
<p>test</p>
<p>link</p>
<p>test</p>
The problem is that the markup I receive using getData() is the one before the modification.
What can I do to ensure that CKEditor is ready and the markup from getData() is the most up to date markup?
There's editor.status property and editor#instanceReady event. When the event is fired, the status is changed to 'ready'. Before that editor may return cached editable element's innerHTML instead of processed data.
So if you want to be sure that you get real data, then you need to check status and wait for instance to be ready if it isn't yet.

IPB shoutbox remove texteditor

I am really doubt that it is impossible to disable text editor in shoutbox (mode full or in popup window).
if i remove this (in shoutbox template):
{parse editor="shout_msg" content="" options="array( 'height' => 100 )"}
then editor is disabled, but i can't send any messages(no input fields).
The question is: how to disable any text editors in popup or full mode. ( for example in root mode only one text field and some buttons. but in full mode we have fully CKEditor or something else..). i want keep only one text input field and only..
I got it. just replace Popup template ( shoutbox ) with hookGlobalShoutbox template. and replace all $d with $data will work. (also the javascript is needed to be inserted at the top)
<script type='text/javascript' src='public/js/shoutbox.js'></script>
<script type='text/javascript' src='public/sounds/soundmanager2-nodebug-jsmin.js'></script>
save and go..
but after that any shout edit cannot be done ..

Resources