Hi,
I’m using RickTextItem and I want to change the content of it but in the same time the cursor should keep it’s position. Here it’s wexactly what I want:
When the user enters a word that begins with “www.something” or “http://something”, this word will be changed in to hyperlink(something). The problem is when I set to the component the bew text cause the cursor is moved at the start.
Here is my code :
isc.DynamicForm.create({
fields:[
{
height:155,
overflow: "hidden",
controlGroups:[],
defaultValue:ajaxDefinition,
change: function(form, item, value) {
var valueReplace = value.replace(/<(a|\/a)[^>]*>/ig,"");
valueReplace = valueReplace
.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim, '<a href="$&" class="my_link" target="_blank">$&</a>')
.replace(/([^\/])(www[\S]+(\b|$))/gim, '$1<a href="http://$2" class="my_link" target="_blank">$2</a>');
console.log(value + "\n" + valueReplace);
if (value != valueReplace) {
item.setValue(valueReplace);
}
},
_constructor:"RichTextItem"
},
{
endRow:false, startRow:false,
title: "Get Content",
name:"btnCancel",
disabled:false,
click: function(form, item){
//form.resetValues();
console.log( form.getValue("editor") );
},
_constructor:"ButtonItem"
},
{
endRow:false, startRow:false,
title: "Set Value",
name:"btnCancel",
disabled:false,
click: function(form, item){
form.getField("editor").setValue("");
},
_constructor:"ButtonItem"
}
],
cellBorder:1,
autoDraw:false
})
An other thing, which is the property that I have to set for making the toolBar to disappear.
Thank you,
Olariu Adrian Mihai.