Put a line break after a rule, and show a link as it was typed.
This commit is contained in:
+7
-5
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user