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);
|
if (name === "SPAN" && !attrs) return inner(node, depth);
|
||||||
var tag = name.toLowerCase();
|
var tag = name.toLowerCase();
|
||||||
if (VOID[name]) return "<" + tag + attrs + " />";
|
|
||||||
var block = BLOCK.test(name);
|
var block = BLOCK.test(name);
|
||||||
|
if (VOID[name]) return "<" + tag + attrs + " />" + (block ? "\n" : "");
|
||||||
var body;
|
var body;
|
||||||
if (/^(P|DIV|LI|PRE)$/.test(name) && isEmptyBlock(node)) {
|
if (/^(P|DIV|LI|PRE)$/.test(name) && isEmptyBlock(node)) {
|
||||||
body = " ";
|
body = " ";
|
||||||
@@ -678,7 +678,9 @@ var XxxEditor = (function () {
|
|||||||
var textWas = inputs.text.value;
|
var textWas = inputs.text.value;
|
||||||
openDialog("Insert link", form, [
|
openDialog("Insert link", form, [
|
||||||
{ text: "Ok", primary: true, action: function () {
|
{ 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;
|
if (/^www\./i.test(href)) href = "http://" + href;
|
||||||
else if (/^[^\s:\/@]+@[^\s:\/@]+\.[^\s:\/@]+$/.test(href)) href = "mailto:" + href;
|
else if (/^[^\s:\/@]+@[^\s:\/@]+\.[^\s:\/@]+$/.test(href)) href = "mailto:" + href;
|
||||||
href = safeUrl(href);
|
href = safeUrl(href);
|
||||||
@@ -689,9 +691,9 @@ var XxxEditor = (function () {
|
|||||||
} else if (link) {
|
} else if (link) {
|
||||||
link.setAttribute("href", href);
|
link.setAttribute("href", href);
|
||||||
setTitle(link, inputs.title.value);
|
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 {
|
} 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();
|
changed();
|
||||||
} },
|
} },
|
||||||
@@ -711,7 +713,7 @@ var XxxEditor = (function () {
|
|||||||
var a = document.createElement("a");
|
var a = document.createElement("a");
|
||||||
a.setAttribute("href", href);
|
a.setAttribute("href", href);
|
||||||
setTitle(a, title);
|
setTitle(a, title);
|
||||||
a.textContent = text || href;
|
a.textContent = text;
|
||||||
range.deleteContents();
|
range.deleteContents();
|
||||||
range.insertNode(a);
|
range.insertNode(a);
|
||||||
var after = document.createRange();
|
var after = document.createRange();
|
||||||
|
|||||||
Reference in New Issue
Block a user