diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 2390eae57ad..a4ebb6bb2c2 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -936,7 +936,7 @@ class core_plugin_manager { 'equation', 'fontcolor', 'html', 'image', 'indent', 'italic', 'link', 'managefiles', 'media', 'noautolink', 'orderedlist', 'rtl', 'strike', 'subscript', 'superscript', 'table', 'title', - 'underline', 'undo', 'unlink', 'unorderedlist' + 'underline', 'undo', 'unorderedlist' ), 'assignment' => array( diff --git a/lib/editor/atto/plugins/link/lang/en/atto_link.php b/lib/editor/atto/plugins/link/lang/en/atto_link.php index cff9e2f862c..f138de839e0 100644 --- a/lib/editor/atto/plugins/link/lang/en/atto_link.php +++ b/lib/editor/atto/plugins/link/lang/en/atto_link.php @@ -27,3 +27,4 @@ $string['createlink'] = 'Create link'; $string['enterurl'] = 'Enter a URL'; $string['openinnewwindow'] = 'Open in new window'; $string['pluginname'] = 'Link'; +$string['unlink'] = 'Unlink'; diff --git a/lib/editor/atto/plugins/link/lib.php b/lib/editor/atto/plugins/link/lib.php index 6b5f19dd741..fa9496ac2c8 100644 --- a/lib/editor/atto/plugins/link/lib.php +++ b/lib/editor/atto/plugins/link/lib.php @@ -32,6 +32,7 @@ function atto_link_strings_for_js() { global $PAGE; $PAGE->requires->strings_for_js(array('createlink', + 'unlink', 'enterurl', 'browserepositories', 'openinnewwindow'), diff --git a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js index 077e2363021..2304d4b124c 100644 --- a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js +++ b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-debug.js @@ -77,11 +77,22 @@ Y.namespace('M.atto_link').Button = Y.Base.create('button', Y.M.editor_atto.Edit _content: null, initializer: function() { + // Add the link button first. this.addButton({ icon: 'e/insert_edit_link', callback: this._displayDialogue, tags: 'a' }); + + // And then the unlink button. + this.addBasicButton({ + exec: 'unlink', + icon: 'e/remove_link', + title: 'unlink', + + // Watch the following tags and add/remove highlighting as appropriate: + tags: 'a' + }); }, /** diff --git a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js index 2b145903e6b..91e757380e3 100644 --- a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js +++ b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button-min.js @@ -1 +1 @@ -YUI.add("moodle-atto_link-button",function(e,t){var n="atto_link",r={NEWWINDOW:"atto_link_openinnewwindow"},i='
';e.namespace("M.atto_link").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.addButton({icon:"e/insert_edit_link",callback:this._displayDialogue,tags:"a"})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1||this._currentSelection.collapsed)return;var e=this.getDialogue({headerContent:M.util.get_string("createlink",n),focusAfterHide:!0});e.set("bodyContent",this._getDialogueContent()),this._resolveAnchors(),e.show()},_resolveAnchors:function(){var t=this.get("host").getSelectionParentNode(),n,r,i,s;if(!t)return;n=this._findSelectedAnchors(e.one(t)),n.length>0&&(r=n[0],this._currentSelection=this.get("host").getSelectionFromNode(r),i=r.getAttribute("href"),s=r.getAttribute("target"),i!==""&&this._content.one(".url").setAttribute("value",i),s==="_blank"?this._content.one(".newwindow").setAttribute("checked","checked"):this._content.one(".newwindow").removeAttribute("checked"))},_filepickerCallback:function(e){this.getDialogue().set("focusAfterHide",null).hide(),e.url!==""&&(this.get("host").setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},_setLink:function(t){var n,r,i,s,o,u=this.get("host");t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=this._content.one(".url"),o=n.get("value");if(o!==""){this.editor.focus(),u.setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,o),i=u.getSelectionParentNode();if(!i)return;s=this._findSelectedAnchors(e.one(i)),e.Array.each(s,function(e){r=this._content.one(".newwindow"),r.get("checked")?e.setAttribute("target","_blank"):e.removeAttribute("target")},this),this.markUpdated()}},_findSelectedAnchors:function(e){var t=e.get("tagName"),n,r;return t&&t.toLowerCase()==="a"?[e]:(r=[],e.all("a").each(function(e){!n&&this.get("host").selectionContainsNode(e)&&r.push(e)}),r.length>0?r:(n=e.ancestor("a"),n?[n]:[]))},_getDialogueContent:function(){var t=this.get("host").canShowFilepicker("link"),s=e.Handlebars.compile(i);return this._content=e.Node.create(s({showFilepicker:t,component:n,CSS:r})),this._content.one(".submit").on("click",this._setLink,this),t&&this._content.one(".openlinkbrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("link",this._filepickerCallback,this)},this),this._content}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); +YUI.add("moodle-atto_link-button",function(e,t){var n="atto_link",r={NEWWINDOW:"atto_link_openinnewwindow"},i='';e.namespace("M.atto_link").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.addButton({icon:"e/insert_edit_link",callback:this._displayDialogue,tags:"a"}),this.addBasicButton({exec:"unlink",icon:"e/remove_link",title:"unlink",tags:"a"})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1||this._currentSelection.collapsed)return;var e=this.getDialogue({headerContent:M.util.get_string("createlink",n),focusAfterHide:!0});e.set("bodyContent",this._getDialogueContent()),this._resolveAnchors(),e.show()},_resolveAnchors:function(){var t=this.get("host").getSelectionParentNode(),n,r,i,s;if(!t)return;n=this._findSelectedAnchors(e.one(t)),n.length>0&&(r=n[0],this._currentSelection=this.get("host").getSelectionFromNode(r),i=r.getAttribute("href"),s=r.getAttribute("target"),i!==""&&this._content.one(".url").setAttribute("value",i),s==="_blank"?this._content.one(".newwindow").setAttribute("checked","checked"):this._content.one(".newwindow").removeAttribute("checked"))},_filepickerCallback:function(e){this.getDialogue().set("focusAfterHide",null).hide(),e.url!==""&&(this.get("host").setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},_setLink:function(t){var n,r,i,s,o,u=this.get("host");t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=this._content.one(".url"),o=n.get("value");if(o!==""){this.editor.focus(),u.setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,o),i=u.getSelectionParentNode();if(!i)return;s=this._findSelectedAnchors(e.one(i)),e.Array.each(s,function(e){r=this._content.one(".newwindow"),r.get("checked")?e.setAttribute("target","_blank"):e.removeAttribute("target")},this),this.markUpdated()}},_findSelectedAnchors:function(e){var t=e.get("tagName"),n,r;return t&&t.toLowerCase()==="a"?[e]:(r=[],e.all("a").each(function(e){!n&&this.get("host").selectionContainsNode(e)&&r.push(e)}),r.length>0?r:(n=e.ancestor("a"),n?[n]:[]))},_getDialogueContent:function(){var t=this.get("host").canShowFilepicker("link"),s=e.Handlebars.compile(i);return this._content=e.Node.create(s({showFilepicker:t,component:n,CSS:r})),this._content.one(".submit").on("click",this._setLink,this),t&&this._content.one(".openlinkbrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("link",this._filepickerCallback,this)},this),this._content}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]}); diff --git a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js index 077e2363021..2304d4b124c 100644 --- a/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js +++ b/lib/editor/atto/plugins/link/yui/build/moodle-atto_link-button/moodle-atto_link-button.js @@ -77,11 +77,22 @@ Y.namespace('M.atto_link').Button = Y.Base.create('button', Y.M.editor_atto.Edit _content: null, initializer: function() { + // Add the link button first. this.addButton({ icon: 'e/insert_edit_link', callback: this._displayDialogue, tags: 'a' }); + + // And then the unlink button. + this.addBasicButton({ + exec: 'unlink', + icon: 'e/remove_link', + title: 'unlink', + + // Watch the following tags and add/remove highlighting as appropriate: + tags: 'a' + }); }, /** diff --git a/lib/editor/atto/plugins/link/yui/src/button/js/button.js b/lib/editor/atto/plugins/link/yui/src/button/js/button.js index efd47b92204..31d8ee82392 100644 --- a/lib/editor/atto/plugins/link/yui/src/button/js/button.js +++ b/lib/editor/atto/plugins/link/yui/src/button/js/button.js @@ -75,11 +75,22 @@ Y.namespace('M.atto_link').Button = Y.Base.create('button', Y.M.editor_atto.Edit _content: null, initializer: function() { + // Add the link button first. this.addButton({ icon: 'e/insert_edit_link', callback: this._displayDialogue, tags: 'a' }); + + // And then the unlink button. + this.addBasicButton({ + exec: 'unlink', + icon: 'e/remove_link', + title: 'unlink', + + // Watch the following tags and add/remove highlighting as appropriate: + tags: 'a' + }); }, /** diff --git a/lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php b/lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php deleted file mode 100644 index bbf03b7a181..00000000000 --- a/lib/editor/atto/plugins/unlink/lang/en/atto_unlink.php +++ /dev/null @@ -1,25 +0,0 @@ -. - -/** - * Strings for component 'atto_unlink', language 'en'. - * - * @package atto_unlink - * @copyright 2013 Damyon Wiese