From 3bb0e0ce9fd73f32b3593b642c6e92b151204077 Mon Sep 17 00:00:00 2001 From: julmis Date: Sat, 29 Jan 2005 20:03:07 +0000 Subject: [PATCH] Adding nolink feature which uses tag. --- lib/editor/htmlarea.php | 30 +++++++++++++++++++++++++++--- lib/editor/lang/en.php | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/editor/htmlarea.php b/lib/editor/htmlarea.php index 243115a594..1bbab7cc9b 100644 --- a/lib/editor/htmlarea.php +++ b/lib/editor/htmlarea.php @@ -144,7 +144,8 @@ HTMLArea.Config = function () { "lefttoright", "righttoleft", "separator", "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator", "forecolor", "hilitecolor", "separator", - "inserthorizontalrule", "createanchor", "createlink", "unlink", "insertimage", "inserttable", + "inserthorizontalrule", "createanchor", "createlink", "unlink", "nolink", "separator", + "insertimage", "inserttable", "insertsmile", "insertchar", aspellpath) && !empty($CFG->editorspelling)) { echo '"separator","spellcheck",'; @@ -213,6 +214,7 @@ HTMLArea.Config = function () { createanchor: [ "Create anchor", "ed_anchor.gif", false, function(e) {e.execCommand("createanchor", true);} ], createlink: [ "Insert Web Link", "ed_link.gif", false, function(e) {e.execCommand("createlink", true);} ], unlink: [ "Remove Link", "ed_unlink.gif", false, function(e) {e.execCommand("unlink");} ], + nolink: [ "No link", "ed_nolink.gif", false, function(e) {e.execCommand("nolink");} ], insertimage: [ "Insert/Modify Image", "ed_image.gif", false, function(e) {e.execCommand("insertimage");} ], inserttable: [ "Insert Table", "insert_table.gif", false, function(e) {e.execCommand("inserttable");} ], htmlmode: [ "Toggle HTML Source", "ed_html.gif", true, function(e) {e.execCommand("htmlmode");} ], @@ -665,6 +667,8 @@ HTMLArea.prototype.generate = function () { html += '\n'; // See bug #2222 html += (editor._textArea.value != null && editor._textArea.value != '') ? editor._textArea.value : '

 

'; + html = html.replace(//gi, ''). + replace(/<\/nolink>/gi, ''); html += "\n"; html += ""; } else { @@ -1381,7 +1385,7 @@ HTMLArea.prototype._createLink = function(link) { var rng = this._createRange(sel); var len = HTMLArea.is_ie ? rng.text.toString().length : sel.toString().length; if(len < 1) { - alert("You must select text first!"); + alert(""); return false; } } @@ -1619,7 +1623,7 @@ HTMLArea.prototype._createanchor = function () { var rng = this._createRange(sel); var len = HTMLArea.is_ie ? rng.text.toString().length : sel.toString().length; if(len < 1) { - alert("You must select text first!"); + alert(""); return false; } this._popupDialog("createanchor.php", function(objAn) { @@ -1633,6 +1637,25 @@ HTMLArea.prototype._createanchor = function () { },null); }; +HTMLArea.prototype._nolinktag = function () { + + var editor = this; + var sel = this._getSelection(); + var rng = this._createRange(sel); + var len = HTMLArea.is_ie ? rng.text.toString().length : sel.toString().length; + + if (len < 1) { + alert(""); + return false; + } + var str = ''; + str += HTMLArea.is_ie ? rng.text : sel; + str += ''; + editor.insertHTML(str); + this.focusEditor(); + +}; + /// Moodle hack's ends // // Category: EVENT HANDLERS @@ -1682,6 +1705,7 @@ HTMLArea.prototype.execCommand = function(cmdID, UI, param) { this._createLink(); break; case "unlink": this._removelink(); break; + case "nolink": this._nolinktag(); break; case "popupeditor": // this object will be passed to the newly opened window HTMLArea._object = this; diff --git a/lib/editor/lang/en.php b/lib/editor/lang/en.php index 6624b909c1..4ebb996350 100644 --- a/lib/editor/lang/en.php +++ b/lib/editor/lang/en.php @@ -50,6 +50,7 @@ HTMLArea.I18N = { inserthorizontalrule: "", createlink: "", unlink: "", + nolink: "", insertimage: "", inserttable: "", htmlmode: "", -- 2.39.5