EzDevInfo.com

ckeditor interview questions

Top ckeditor frequently asked interview questions

CKEditor Custom Plugins Button

I've written a custom plugin for CKEditor--successful on all fronts, save one currently: I can't, for the life of me, figure out how to customize the image on the button in the toolbar of the editor. As I'm a new user, you'll have to click through to see attached image; the highlighted square in the top left should have a pretty picture (like most of the other toolbar items).

Thanks much for thoughts/advice/help.

Screenshot


Source: (StackOverflow)

How to check CK editor version

There is an existing CK editor folder in my project. How can I find out it's version? Is it documented?


Source: (StackOverflow)

Advertisements

How do I set a value in CKEditor with Javascript?

I am wondering how I can set a value in CKEditor using Javascript?

I have tried the following, but neither of them work...

document.[form name].[textarea name].value=data;
$('#textareaID').val(data);

However, both these work without the editor applied. Is there a way I can do this with the editor?


Source: (StackOverflow)

Remove status bar from CKEditor

The CKEditor website is somewhat lacking; can you tell me how to remove the status bar ('body ul li ...') from CKEditor?

There is a list of HTML at the bottom of the editor - body p ul li - representing how the typed text will be generated and I want to remove this list.


Source: (StackOverflow)

How can you integrate a custom file browser/uploader with CKEditor?

The official documentation is less than clear - what's the correct way to integrate a custom file browser/uploader with CKEditor? (v3 - not FCKEditor)


Source: (StackOverflow)

CKEDITOR - prevent adding image dimensions as a css style

How to prevent CKEDITOR from adding image dimensions as a style?

Instead of this:

<img src="image.jpg" style="height:100px; width:100px;">

I want this

<img src="image.jpg" height="100px" width="100px">

Source: (StackOverflow)

How can i get content of CKEditor using JQuery?

I'm using CKEditor. I am saving the form values with ajax using page methods.

But the content of CKEditor value cannot be saving into the table.

I dont postback the page.

What can i do for that?


Source: (StackOverflow)

CKEditor instance already exists

I am using jquery dialogs to present forms (fetched via AJAX). On some forms I am using a CKEditor for the textareas. The editor displays fine on the first load.

When the user cancels the dialog, I am removing the contents so that they are loaded fresh on a later request. The issue is, once the dialog is reloaded, the CKEditor claims the editor already exists.

uncaught exception: [CKEDITOR.editor] The instance "textarea_name" already exists.

The API includes a method for destroying existing editors, and I have seen people claiming this is a solution:

if (CKEDITOR.instances['textarea_name']) {
CKEDITOR.instances['textarea_name'].destroy();
}
CKEDITOR.replace('textarea_name');

This is not working for me, as I receive a new error instead:

TypeError: Result of expression 'i.contentWindow' [null] is not an object.

This error seems to occur on the "destroy()" rather than the "replace()". Has anyone experienced this and found a different solution?

Is is possible to 're-render' the existing editor, rather than destroying and replacing it?

UPDATED Here is another question dealing with the same problem, but he has provided a downloadable test case.


Source: (StackOverflow)

CKEditor automatically strips classes from div

I am using CKEditor as a back end editor on my website. It is driving me round the bend though as it seems to want to change the code to how it sees fit whenever I press the source button. For example if I hit source and create a <div>...

<div class="myclass">some content</div>

It then for no apparent reason strips the class from the <div>, so when I hit source again it has been changed to...

<div>some content</div>

I presume this irritating behaviour can be turned off in the config.js, but I have been digging and cant find anything in documentation to turn it off.


Source: (StackOverflow)

How to add a custom button to the toolbar that calls a JavaScript function?

I'd like to add a button to the toolbar that calls a JavaScript function like Tada()?

Any ideas on how to add this?


Source: (StackOverflow)

Turn off enclosing

tags in CKEditor 3.0

Is there a possibility to turn off the automatic enclosing of all written content within <p></p> in CKEditor 3.x?

I tried

  CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;

but this just changes the inline linebreaks to <br /> while leaving the enclosing paragraph.

Currently writing "Test" produces this output

<p>
    Test</p>

but I want it to be simply

Test

Is there a configuration property for this or would another inline editor to be better suited for this?


Source: (StackOverflow)

Integrated Markdown WYSIWYG text editor

In looking for a straightforward WYSIWYG editor for Markdown code, I am not finding a comparible UI to that of CkEditor, TinyMCE, ect.

Specifically, the Markdown "WYSIWYG" editors that are often recommended (such as posts like this ) are not pure WYSIWYG editors in the sense that users either still write raw Markdown ( MarkItUp ) or go to the other extreme of having in-line editing without standard controls ( Hallo ).

I need something in-between.

I'm looking for a Markdown editor that looks and functions like a stripped down CkEditor text box, and that accepts and outputs Markdown. There should be a toolbar with a minimum set of formatting options (B, I, U, lists, ect), and the text entry area should show the converted Markdown, not the raw code. There should be a Source button that will allow users to edit the raw Markdown, but even that is optional. Ex:

enter image description here

I get the reason for Markdown/wiki, ect - the security it offers. I don't mind entering raw code like here at SE, but my users are not geeks and do not find this enjoyable. They don't want to see * * * ___ and spaces mixed in with their text. They are used to "Word" style editing, and are most productive in that environment.

So - is there a truly integrated WYSIWYG editor for Markdown? I'm writing in a PHP, so something that I can invoke with a class would be perfect.


Sept 23, 2015 Update

CKEditor now has a Markdown addon that does this exact thing. The addon project is hosted on github.

Screenshots:

markdown WYSIWYG

markdown source


Apr 13, 2015 Update
Someone professing to develop CKEditor says that the appearance of CommonMark is a game changer, and we could possibly see a proper markup interface for CKEditor (read comments for the full story).


Feb 6, 2015 Update

CKEditor now comes with a plugin that outputs (and accepts as input) BBCode.

Demo: http://ckeditor.com/demo#bbcode


Source: (StackOverflow)

Ckeditor update textarea

I am trying to get the ckeditor working. Obviously it doesn't make use of the textarea so on submit the form doesn't submit the text in the editor. Beceause I make use of polymorphic associations etc. I can't make a onsubmit function to get the value of the textarea (when the form is submitted) .

So I found this question: Using jQuery to grab the content from CKEditor's iframe

with some very good answers. The answers posted there keep the textarea up to date. That is very nice and just what I need! Unfortunately I can't get it to work. Does somebody know why (for example) this doesn't work?

I have a textarea (rails but it just translates to a normal textarea):
<%= f.text_area :body, :id => 'ckeditor', :rows => 3 %>

And the following js:

if(CKEDITOR.instances.ckeditor ) {
  CKEDITOR.remove(CKEDITOR.instances.ckeditor);
}
CKEDITOR.replace( 'ckeditor',
{
skin : 'kama',
toolbar :[['Styles', 'Format', '-', 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', 'Link']]});


CKEDITOR.instances["ckeditor"].on("instanceReady", function()
{
//set keyup event
this.document.on("keyup", CK_jQ);

//and paste event
this.document.on("paste", CK_jQ);
}

function CK_jQ()
{
 CKEDITOR.instances.ckeditor.updateElement(); 
}

I get the following "error" in my firebug.
missing ) after argument list [Break on this error] function CK_jQ()\n


Source: (StackOverflow)

How to ajax-submit a form textarea input from CKEditor?

I am using CKEditor, jQuery and jQuery form plugin and I would like to submit contents of the CkEditor form via an Ajax query. Here is my code:

<form id="article-form" name="article-form" method="post" action="/myproject/save">
  <textarea name="bodyText" style="visibility: hidden; display: none;"></textarea>
  <script type="text/javascript">
    CKEDITOR.replace('bodyText');
  </script>

  <a onClick="$("#article-form").ajaxSubmit();">Submit</a>

</form>

Unfortunately, it seems that the Ajax request does not pass the bodyText parameter;

What did I do wrong or how can I achieve what I need?

Thank you.


Source: (StackOverflow)

Get computed font size for DOM element in JS

Is it possible to detect the computed font-size of a DOM element, taking into consideration generic settings made elsewhere (In the body tag for example), inherited values, and so on?

A framework-independent approach would be nice, as I'm working on a script that should work standalone, but that is not a requirement of course.

Background: I'm trying to tweak CKEditor's font selector plugin (source here) so that it always shows the font size of the current cursor position (as opposed to only when within a span that has an explicit font-size set, which is the current behaviour).


Source: (StackOverflow)