diff --git a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js index 6af6477e770..9b5fe59fb22 100644 --- a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js +++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-debug.js @@ -1485,17 +1485,9 @@ EditorClean.prototype = { // Scrub the paste content. content = this._cleanPasteHTML(content); - // Save the current selection. - // Using saveSelection as it produces a more consistent experience. - var selection = window.rangy.saveSelection(); - // Insert the content. this.insertContentAtFocusPoint(content); - // Restore the selection, and collapse to end. - window.rangy.restoreSelection(selection); - window.rangy.getSelection().collapseToEnd(); - // Update the text area. this.updateOriginal(); return false; @@ -2826,7 +2818,12 @@ EditorSelection.prototype = { } if (range) { range.deleteContents(); - range.insertNode(node.getDOMNode()); + range.collapse(false); + var currentnode = node.getDOMNode(), + last = currentnode.lastChild || currentnode; + range.insertNode(currentnode); + range.collapseAfter(last); + selection.setSingleRange(range); } return node; } diff --git a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js index 4dd78d5c6e4..860a3a94770 100644 --- a/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js +++ b/lib/editor/atto/yui/build/moodle-editor_atto-editor/moodle-editor_atto-editor-min.js @@ -1,5 +1,5 @@ YUI.add("moodle-editor_atto-editor",function(u,t){var o,r,n,l,s,a={CONTENT:"editor_atto_content",CONTENTWRAPPER:"editor_atto_content_wrap",TOOLBAR:"editor_atto_toolbar",WRAPPER:"editor_atto",HIGHLIGHT:"highlight"},c=window.rangy;function e(){e.superclass.constructor.apply(this,arguments)}function i(){}function h(){}function d(){}function g(){g.superclass.constructor.apply(this,arguments),this._submitEvents={},this._queue=[],this._throttle=null}function p(){}function f(){}function m(){}function v(){}function b(){}function _(){}function y(){}function S(){}u.extend(e,u.Base,{BLOCK_TAGS:["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","noscript","ol","output","p","pre","section","table","tfoot","ul","video"],PLACEHOLDER_CLASS:"atto-tmp-class",ALL_NODES_SELECTOR:"[style],font[face]",FONT_FAMILY:"fontFamily",_wrapper:null,editor:null,textarea:null,textareaLabel:null,plugins:null,coreDirection:null,_eventHandles:null,initializer:function(){var t,e,i;this.textarea=u.one(document.getElementById(this.get("elementid"))),this.textarea&&(e=this.textarea.getAttribute("class"),this._eventHandles=[],this._wrapper=u.Node.create('
'),t=u.Handlebars.compile(''),this.editor=u.Node.create(t({elementid:this.get("elementid"),CSS:a})),this.textareaLabel=u.one('[for="'+this.get("elementid")+'"]'),this.textareaLabel&&(this.textareaLabel.generateID(),this.editor.setAttribute("aria-labelledby",this.textareaLabel.get("id"))),this.coreDirection=u.one("body").hasClass("dir-rtl")?"rtl":"ltr",this.setupToolbar(),(i=u.Node.create('')).appendChild(this.editor),this._wrapper.appendChild(i),this.editor.setStyle("minHeight",20*this.textarea.getAttribute("rows")+8+"px"),0===u.UA.ie&&this.editor.setStyle("height",20*this.textarea.getAttribute("rows")+8+"px"),this.disableCssStyling(),document.queryCommandSupported("DefaultParagraphSeparator")&&document.execCommand("DefaultParagraphSeparator",!1,"p"),this.textarea.get("parentNode").insert(this._wrapper,this.textarea).setAttribute("class","editor_atto_wrap"),this.textarea.hide(),u.mix(u.Node.DOM_EVENTS,{"form:editorUpdated":!0}),this.textarea.on("form:editorUpdated",function(){this.updateEditorState()},this),this.updateFromTextArea(),this.publishEvents(),this.setupSelectionWatchers(),this.setupAutomaticPolling(),this.setupPlugins(),this.setupAutosave(),this.setupNotifications())},focus:function(){return this.editor.focus(),this},publishEvents:function(){return this.publish("change",{broadcast:!0,preventable:!0}),this.publish("pluginsloaded",{fireOnce:!0}),this.publish("atto:selectionchanged",{prefix:"atto"}),this},setupAutomaticPolling:function(){return this._registerEventHandle(this.editor.on(["keyup","cut"],this.updateOriginal,this)),this._registerEventHandle(this.editor.on("paste",this.pasteCleanup,this)),this._registerEventHandle(this.editor.on("drop",this.updateOriginalDelayed,this)),this},updateOriginalDelayed:function(){return u.soon(u.bind(this.updateOriginal,this)),this},setupPlugins:function(){var t,e,i,n,s,a;for(e in this.plugins={},t=this.get("plugins"))if((i=t[e]).plugins)for(n in i.plugins)s=i.plugins[n],a=u.mix({name:s.name,group:i.group,editor:this.editor,toolbar:this.toolbar,host:this},s),"undefined"!=typeof u.M["atto_"+s.name]&&(this.plugins[s.name]=new u.M["atto_"+s.name].Button(a));return this.fire("pluginsloaded"),this},enablePlugins:function(t){this._setPluginState(!0,t)},disablePlugins:function(t){this._setPluginState(!1,t)},_setPluginState:function(t,e){var i="disableButtons";t&&(i="enableButtons"),e?this.plugins[e][i]():u.Object.each(this.plugins,function(t){t[i]()},this)},updateEditorState:function(){var t=this.textarea.hasAttribute("readonly"),e=u.one("#"+this.get("elementid")+"editable");this._setPluginState(!t),e&&e.setAttribute("contenteditable",!t)},_registerEventHandle:function(t){this._eventHandles.push(t)}},{NS:"editor_atto",ATTRS:{elementid:{value:null,writeOnce:!0},contextid:{value:null,writeOnce:!0},plugins:{value:{},writeOnce:!0}}}),u.augment(e,u.EventTarget),u.namespace("M.editor_atto").Editor=e,u.namespace("M.editor_atto.Editor").init=function(t){return new u.M.editor_atto.Editor(t)},o="info",r="warning",i.ATTRS={},i.prototype={messageOverlay:null,hideTimer:null,setupNotifications:function(){var t=new Image,e=new Image;return t.src=M.util.image_url("i/warning","moodle"),e.src=M.util.image_url("i/info","moodle"),this},showMessage:function(t,e,i){var n,s,a="";return null===this.messageOverlay&&(this.messageOverlay=u.Node.create(''),this.messageOverlay.hide(!0),this.textarea.get("parentNode").append(this.messageOverlay),this.messageOverlay.on("click",function(){this.messageOverlay.hide(!0)},this)),null!==this.hideTimer&&this.hideTimer.cancel(),e===r?a='","
','
','
","
','
','