Hi Folks,
Firstly - thanks for ckeditor - it is a good tool and helps my project greatly. My question is about shared spaces: What my product needs is an editor with a toolbar in a fixed place and one or more editable areas (spaces) to be dynamically attached to the toolbar. This means, of course, that there will be data in one or more editable area at any given time. However, when saving this data, we need to know which editable area is currently being modified because we want to save the data in that area only. How do we do that? I can get all the data from all the editors by iterating over CKEDITOR.instances and doing a getData() on each editor, but that is not what is required. We need the data from the current editable area. Here is what I've tried:
I've looked at the documentation, which does not cover this use case and have tried a bunch of approaches with little success. So - how does a user know which area is being edited so they can access the data in that area and retrieve it when necessary.
Thanks for all your help,
John
Firstly - thanks for ckeditor - it is a good tool and helps my project greatly. My question is about shared spaces: What my product needs is an editor with a toolbar in a fixed place and one or more editable areas (spaces) to be dynamically attached to the toolbar. This means, of course, that there will be data in one or more editable area at any given time. However, when saving this data, we need to know which editable area is currently being modified because we want to save the data in that area only. How do we do that? I can get all the data from all the editors by iterating over CKEDITOR.instances and doing a getData() on each editor, but that is not what is required. We need the data from the current editable area. Here is what I've tried:
CKEDITOR.currentInstance.name
Get the current instance using the current instance object. This fails because currentInstance does not track the editable area that is in focus. In fact it is often null and when it is populated with an instance it holds that value and does not seem to change it.
editor<N>.focusManager.hasFocus
Get the data from an editor based on its current focus. This fails because this variable does not consistently track the editable area in focus.
var element = CKEDITOR.document.getById("editor<N>");
element.on( 'click', function( ev ) {
var domEvent = ev.data;
alert ("CKEDITOR event" + ev.data);
});
Events - tried that but this does not work. The event is not generated when the cursor is placed in an editable area.
I've looked at the documentation, which does not cover this use case and have tried a bunch of approaches with little success. So - how does a user know which area is being edited so they can access the data in that area and retrieve it when necessary.
Thanks for all your help,
John
Re: Shared spaces: getting data from the current instance
try to use zhe event [key] or [focus]
key
Fired when any keyboard key (or combination) is pressed into the editing area.
http://docs.cksource.com/ckeditor_api/s ... #event:key
CKEDITOR.instances.editor1.on('focus',yourfunction);