update : function() {\r
var ed = this.editor, elm, name = document.forms[0].anchorName.value;\r
\r
+ if (!name || !/^[a-z][a-z0-9\-\_:\.]*$/i.test(name)) {\r
+ tinyMCEPopup.alert('advanced_dlg.anchor_invalid');\r
+ return;\r
+ }\r
+\r
tinyMCEPopup.restoreSelection();\r
\r
if (this.action != 'update')\r
ed.selection.collapse(1);\r
\r
elm = ed.dom.getParent(ed.selection.getNode(), 'A');\r
- if (elm)\r
+ if (elm) {\r
+ elm.setAttribute('name', name);\r
elm.name = name;\r
- else\r
- ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, ''));\r
+ } else\r
+ // create with zero-sized nbsp so that in Webkit where anchor is on last line by itself caret cannot be placed after it\r
+ ed.execCommand('mceInsertContent', 0, ed.dom.createHTML('a', {name : name, 'class' : 'mceItemAnchor'}, '\uFEFF'));\r
\r
tinyMCEPopup.close();\r
}\r