diff --git a/publish/editor.js b/publish/editor.js index 6e81fa2..272fc45 100644 --- a/publish/editor.js +++ b/publish/editor.js @@ -315,8 +315,8 @@ var XxxEditor = (function () { }); if (name === "SPAN" && !attrs) return inner(node, depth); var tag = name.toLowerCase(); - if (VOID[name]) return "<" + tag + attrs + " />"; var block = BLOCK.test(name); + if (VOID[name]) return "<" + tag + attrs + " />" + (block ? "\n" : ""); var body; if (/^(P|DIV|LI|PRE)$/.test(name) && isEmptyBlock(node)) { body = " "; @@ -678,7 +678,9 @@ var XxxEditor = (function () { var textWas = inputs.text.value; openDialog("Insert link", form, [ { text: "Ok", primary: true, action: function () { - var href = inputs.href.value.trim(); + // Without text, the link shows the address as it was typed + var typed = inputs.href.value.trim(); + var href = typed; if (/^www\./i.test(href)) href = "http://" + href; else if (/^[^\s:\/@]+@[^\s:\/@]+\.[^\s:\/@]+$/.test(href)) href = "mailto:" + href; href = safeUrl(href); @@ -689,9 +691,9 @@ var XxxEditor = (function () { } else if (link) { link.setAttribute("href", href); setTitle(link, inputs.title.value); - if (inputs.text.value !== textWas) link.textContent = inputs.text.value || href; + if (inputs.text.value !== textWas) link.textContent = inputs.text.value || typed; } else { - insertLink(href, inputs.title.value, inputs.text.value, inputs.text.value !== textWas); + insertLink(href, inputs.title.value, inputs.text.value || typed, inputs.text.value !== textWas); } changed(); } }, @@ -711,7 +713,7 @@ var XxxEditor = (function () { var a = document.createElement("a"); a.setAttribute("href", href); setTitle(a, title); - a.textContent = text || href; + a.textContent = text; range.deleteContents(); range.insertNode(a); var after = document.createRange();