Hi Team,
We are developing an Intuition platform, having Auto complete functionality in the editor. Here we are handling the editor data as expressions,
In the editor there will be any number of variables, operators, text and comments can use by the user. Each line is separated in <p> and inside that all the nodes are formatted.
For Example:
Variables and Operators placed in <a> tags
Comments and default text in <span> tags
We are having typing and Editing functionality, if the typing text is matching in the variable or operator text then we have to place the string in <a> tag.
When the user can edit the expression anywhere in the editor. If they edit the variable text,
For example:
Consider "Alpha0" is a variable which is formatted to <a href="#" style="color: #a50;">Alpha0</a>, the user edited the text to "Alha0", after the editing the node formatting to <Span style=" color: black;">Alha0</span>
The color format change is working when typing and editing in Chrome. In IE 10 is not supporting in all the cases.
If I try to update in the middle of the expression the caret position is jumping to first node. The below code is using for getting the caret position
var selection = editor.getSelection();
var selectedElement = selection.focusNode;
var range;
if (selectedElement.nodeName != 'P'
&& selectedElement.nodeName != 'DIV') {
range = editor.getSelection().getRangeAt(0).endOffset;
} else if ((selectedElement.nodeName == 'P' || selectedElement.nodeName == 'A')) {
var index = editor.getSelection().getRangeAt(0).endOffset;
if (index != 0) {
selectedElement = selectedElement.childNodes[index - 1];
range = selectedElement.textContent.length;
} else if (selectedElement.childNodes.length > 0) {
selectedElement = selectedElement.childNodes[index];
range = index;
}
}
If the text is editing in the middle of <a> tag it should change to <span> tag based on the validation, in that case editor's caret position getting as "0". So it jumping to the first node. Please help us with this issue.
Thanks in Advance.
We are developing an Intuition platform, having Auto complete functionality in the editor. Here we are handling the editor data as expressions,
In the editor there will be any number of variables, operators, text and comments can use by the user. Each line is separated in <p> and inside that all the nodes are formatted.
For Example:
Variables and Operators placed in <a> tags
Comments and default text in <span> tags
We are having typing and Editing functionality, if the typing text is matching in the variable or operator text then we have to place the string in <a> tag.
When the user can edit the expression anywhere in the editor. If they edit the variable text,
For example:
Consider "Alpha0" is a variable which is formatted to <a href="#" style="color: #a50;">Alpha0</a>, the user edited the text to "Alha0", after the editing the node formatting to <Span style=" color: black;">Alha0</span>
The color format change is working when typing and editing in Chrome. In IE 10 is not supporting in all the cases.
If I try to update in the middle of the expression the caret position is jumping to first node. The below code is using for getting the caret position
var selection = editor.getSelection();
var selectedElement = selection.focusNode;
var range;
if (selectedElement.nodeName != 'P'
&& selectedElement.nodeName != 'DIV') {
range = editor.getSelection().getRangeAt(0).endOffset;
} else if ((selectedElement.nodeName == 'P' || selectedElement.nodeName == 'A')) {
var index = editor.getSelection().getRangeAt(0).endOffset;
if (index != 0) {
selectedElement = selectedElement.childNodes[index - 1];
range = selectedElement.textContent.length;
} else if (selectedElement.childNodes.length > 0) {
selectedElement = selectedElement.childNodes[index];
range = index;
}
}
If the text is editing in the middle of <a> tag it should change to <span> tag based on the validation, in that case editor's caret position getting as "0". So it jumping to the first node. Please help us with this issue.
Thanks in Advance.