diff --git a/www/pad/links.js b/www/pad/links.js index 68c59d5b3..2904c480d 100644 --- a/www/pad/links.js +++ b/www/pad/links.js @@ -18,14 +18,20 @@ define([ e.preventDefault(); e.stopPropagation(); - if (href[0] === '#') { - var anchor = $inner.find(href); - if (!anchor.length) { return; } - anchor[0].scrollIntoView(); - return; - } - var open = function () { + if (href[0] === '#') { + try { + $inner.find('.cke_anchor[data-cke-realelement]').each(function (j, el) { + var i = editor.restoreRealElement($(el)); + var node = i.$; + if (node.id === href.slice(1)) { + el.scrollIntoView(); + } + }); + } catch (err) {} + return; + } + var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(href); window.open(bounceHref); }; @@ -39,7 +45,10 @@ define([ var l = (rect.left - rect0.left)+'px'; var t = rect.bottom + $iframe.scrollTop() +'px'; - var a = h('a', { href: href}, href); + var text = href; + Messages.pad_goToAnchor = "Go to anchor"; // XXX + if (text[0] === '#') { text = Messages.pad_goToAnchor; } + var a = h('a', { href: href}, text); var link = h('div.cp-link-clicked.non-realtime', { contenteditable: false, style: 'top:'+t+';left:'+l