Hi, i am using rad editor in wysiwyg mode.
I need to insert some text to cursor position.
before paste some text, i need to check some condition like, the given cursor position is center/left/right of the particular elememt.
My code like
i got the range.
But , how to check if the selected text has any text before and after.
I need to implement some text based on the condition like,
I need to insert some text to cursor position.
before paste some text, i need to check some condition like, the given cursor position is center/left/right of the particular elememt.
My code like
var selectedtag = editor.getSelectedElement();
var range = editor.getSelection().getRange();
var selection = editor.getSelection();
if (selectedtag.tagName != "LI" && selectedtag.tagName != "P") {
var sel = editor.getSelection().getText();
var text = selectedtag.innerHTML;
//range.pasteHTML('<
p
>' + sel + '</
p
>');
selectedtag.innerHTML = '<
p
>' + text;
}
else if (selectedtag.tagName == "LI") {
var sel = editor.getSelection().getText();
if (sel == "") {
range.pasteHTML('</
li
><
li
>...</
li
>');
}
else {
range.pasteHTML('</
li
><
li
>' + sel + '</
li
>');
}
}
else if (selectedtag.tagName == "P") {
var sel = editor.getSelection().getText();
if (sel == "") {
range.pasteHTML('</
p
><
p
>');
}
else {
range.pasteHTML('</
p
><
p
>' + sel + '</
p
>');
}
}
else {
var sel = editor.getSelection().getText();
if (sel == "") {
range.pasteHTML('</
p
><
p
>');
}
else {
range.pasteHTML('</
p
><
p
>' + sel + '</
p
><
p
>');
}
}
But , how to check if the selected text has any text before and after.
I need to implement some text based on the condition like,
Te Text to the left is empty (ie selection is at the start of the element): <p> selected text text to the right</p>
3) Text to the right is empty (ie selection is at the end of the element): <p>Text to the left selected text </p>
i need the output like,
<p> selected text</p><p>text to the right</p>
How to check if the selected text /range contains any text before and after the selected text.
This is urgent requirement.
Thanks ,
Uma