Creating some predefined html template to be inserted on instance ready of the ckeditor. Place the cursor on the created element but the cursor position moves to the top of the template sometimes. Please suggest.
Related
I am trying to add a table to an existing mshtml document. I have created the html for the table and then added it with
.DomDocument.selection.createRange().pasteHTML(myTableHTML)
This works OK but the caret is left before the table rather than after it. How can I move the caret?
What I am try to achieve is to insert some content in a specific container element designated by a unique id. This would help me insert content at positions other than cursor positions.
editor.model.insertContent(modelFragment); is a function that would insert the new fragment at the cursor position, the second parameter that would be accepted is selectable which I am not sure how to specify to match to that particular div id.
When I was googling for the same, I found a desirable method in ckeditor4, but unfortunately I am looking for an option in ckeditor5.
I have added a custom plugin that inserts the current date at the cursor position in ckeditor when I click on my InsertDate button which is not part of the ckeditor toolbar buttons. Now the question is I have multiple ckeditor in my page, so now I am typing something in the second ckeditor and I just want to insert the current time so I clicked on the insertDate button, but it is inserting the text in the first ckeditor which is not expected.is there any way how to handle this situation.i want to know the recently focused ckeditor so that I can identify the particular ckeditor using the id and can insert the text.
tried using the focusmanager.hasfocus method but as soon as I click on the insertDate button the ckeditor loses the focus.is there any way we can get the reference of the recent focus editor.
$.fn.insertAtCaret = function (myValue) {
myValue = myValue.trim();
CKEDITOR.instances['idofeditor'].insertText(myValue);
};
I use inline CKEditor for editing elements on my page. So when I click into DIV with some class, CKEditor is attached to it and when it loses focus, editor instance is destroyed. I need to insert HTML element into that DIV after CKEditor instance is destroyed - to the last position of cursor before destroying editor instance. So I basicaly need to know index of cursor in edited element's HTML, as it would be taken as a plain text (for this example below it would be 25). I don't want to modify original data.
I have HTML in my DIV like this:
"some <span>text</span> wi|th <b>html</b> tags" (where "|" is cursor position)
I tried to get range and extend it to the start of editable element:
var range = editor.getSelection().getRanges()[ 0 ];
range.collapse( true );
range.setStartAt( editor.editable(), CKEDITOR.POSITION_AFTER_START );
Here range.endOffset is 3 (the same as if I didn't extend range). But even if I sum up offsets of more elements, it wouldn't solve my problem, because it exclude HTML tags.
You won't be able to use ranges if you want to use them after the editor is destroyed, because while being destroyed the editor replaces editable's inner HTML with the data and they are not the same thing.
Instead, you should create a marker for the selection before the editor is destroyed and find this marker in the data.
See this topic for ideas how to achieve that: Retain cursor position after reloading the page in CKEditor.
when I login for the first time on my page I view the information in staggered rows in the table (rich:dataTable). As soon as I step just with the mouse pointer on these areas, the text in the cells goes to occupy its correct position.
I see the text in the header of the columns hidden by filters that are below (the correct position is on top of the filters) and a few rows back off the table but on mouse hover are shown automatically in the correct position of the row in the table.
Can you help me to solve this problem? I use RichFaces 4.3.7 and IE8.
Thanks