Hi,
Sorry if this is a dumb question! I couldn't find an answer to this in the forum but to cut a long story short, when I use pasteHTML to paste a link into the editor from my custom button. I get nested links. Is there any way of stopping this? Thanks in advance. Rich.
I've got masses of code but basically it goes like this;
1) Editor starts of in preview mode with "this is a paragraph"
2) I click my custom button which does;
- if(command=="MyInsertLink")
- {
- var sel = editor1.GetSelection();
- var r = sel.createRange();
- selFromEditor = r.htmlText;
- if(selFromEditor != "")
- {
- document.getElementById("EditorDiv").style.visibility = "hidden";
- document.getElementById("insertLinkBox").style.visibility = "visible";
-
- }
- return true;
- }
3) My code then does some ajax stuff and uses .pasteHTML to paste a link in to the editor to replace the 'current selection'.
If the selection is not already a link, it works.
For example
<h1>This is 9</h1>
<p>This is a paragraph</p>
becomes
<h1>This is 9</h1>
<p>This is a <a title="" href="http://cutesoft.net/files/add-button.gif">paragraph</a></p>
but if I perform the same action again i get
<h1>This is 9</h1>
<p>This is a <a title="" href="http://cutesoft.net/files/add-button.gif"></a><a title="" href="http://cutesoft.net/files/add-button.gif">paragraph</a><a title="" href="http://cutesoft.net/files/add-button.gif"></a></p>
The code for pasting back in is;
- editor1.PasteHTML("\<a href=\""+linkFile+"\" title=\""+document.getElementById("linkTitle").value+"\"\>"+selFromEditor+"\</a\>");