From 32ac4bf58a5b5b54948b17c12efe501bbc40c0ec Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 27 Feb 2016 21:33:26 +0000 Subject: [PATCH] TinyMCE, inline link: - Fix in IE (again). Remove setting/getting placeholders, pass the link node instead. - In the inline dialog: when the selected text looks like URL or email, pre-fill the URL field with it (same as in the modal). - Fix setting the name of the main button in the modal: Add Link or Update. - In the modal when clicking Update remove the link if the URL field is empty. That matches the inline dialog behaviour. Otherwise the modal remains open, nothing happens when clicking the Update button there. See #33301. Built from https://develop.svn.wordpress.org/trunk@36747 git-svn-id: http://core.svn.wordpress.org/trunk@36714 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/wplink/plugin.js | 38 +++----- .../js/tinymce/plugins/wplink/plugin.min.js | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 165761 -> 165755 bytes wp-includes/js/wplink.js | 90 ++++++++++-------- wp-includes/js/wplink.min.js | 2 +- wp-includes/version.php | 2 +- 6 files changed, 68 insertions(+), 66 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.js b/wp-includes/js/tinymce/plugins/wplink/plugin.js index 9a91dc3b71..c47b4c384f 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.js @@ -78,6 +78,7 @@ }, reset: function() { var urlInput = this.getEl().firstChild; + urlInput.value = ''; urlInput.nextSibling.value = ''; } @@ -88,6 +89,7 @@ var editToolbar; var previewInstance; var inputInstance; + var linkNode; var $ = window.jQuery; function getSelectedLink() { @@ -107,7 +109,6 @@ if ( link ) { editor.selection.select( link ); - editor.nodeChanged(); } } } @@ -152,9 +153,14 @@ editToolbar.on( 'show', function() { if ( ! tinymce.$( document.body ).hasClass( 'modal-open' ) ) { window.setTimeout( function() { - var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0]; + var element = editToolbar.$el.find( 'input.ui-autocomplete-input' )[0], + selection = linkNode && ( linkNode.textContent || linkNode.innerText ); if ( element ) { + if ( ! element.value && selection && typeof window.wpLink !== 'undefined' ) { + element.value = window.wpLink.getUrlFromSelection( selection ); + } + element.focus(); element.select(); } @@ -171,8 +177,6 @@ } ); editor.addCommand( 'WP_Link', function() { - var link = getSelectedLink(); - if ( tinymce.Env.ie && tinymce.Env.ie < 10 ) { if ( typeof window.wpLink !== 'undefined' ) { window.wpLink.open( editor.id ); @@ -181,18 +185,16 @@ return; } + linkNode = getSelectedLink(); editToolbar.tempHide = false; - if ( link ) { - editor.dom.setAttribs( link, { 'data-wplink-edit': true } ); + if ( linkNode ) { + editor.dom.setAttribs( linkNode, { 'data-wplink-edit': true } ); } else { removePlaceholders(); editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); - if ( tinymce.Env.ie ) { - editor.windowManager.wplinkBookmark = editor.selection.getBookmark(); - } - + linkNode = editor.$( 'a[href="_wp_link_placeholder"]' )[0]; editor.nodeChanged(); } } ); @@ -202,19 +204,13 @@ return; } - var href, text, - linkNode = getSelectedLink(); + var href, text; if ( linkNode ) { href = inputInstance.getURL(); text = inputInstance.getLinkText(); editor.focus(); - if ( tinymce.isIE ) { - editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark ); - editor.windowManager.wplinkBookmark = null; - } - if ( ! href ) { editor.dom.remove( linkNode, true ); return; @@ -240,12 +236,6 @@ inputInstance.reset(); removePlaceholders(); editor.focus(); - - if ( tinymce.isIE ) { - editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark ); - editor.windowManager.wplinkBookmark = null; - } - editToolbar.tempHide = false; } } ); @@ -456,7 +446,7 @@ text = inputInstance.getLinkText() || null; editor.focus(); // Needed for IE - window.wpLink.open( editor.id, url, text ); + window.wpLink.open( editor.id, url, text, linkNode ); editToolbar.tempHide = true; inputInstance.reset(); diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js index e4253580fe..1e78a57d56 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js @@ -1 +1 @@ -!function(a){a.ui.WPLinkPreview=a.ui.Control.extend({url:"#",renderHtml:function(){return'"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),-1!==(c=b.indexOf("?"))&&(b=b.slice(0,c)),-1!==(c=b.indexOf("#"))&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&-1!==(c=b.indexOf("/"))&&-1!==(d=b.lastIndexOf("/"))&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}}),a.ui.WPLinkInput=a.ui.Control.extend({renderHtml:function(){return''},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){return a.trim(this.getEl().firstChild.value)},getLinkText:function(){var b=this.getEl().firstChild.nextSibling.value;return a.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){var a=this.getEl().firstChild;a.value="",a.nextSibling.value=""}}),a.PluginManager.add("wplink",function(b){function c(){var a,c,d=b.selection.getNode(),e=b.dom.getParent(d,"a[href]");return e||(c=b.selection.getContent({format:"raw"}),c&&-1!==c.indexOf("")&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&(b.selection.select(e),b.nodeChanged()))),e}function d(){b.$("a").each(function(a,c){var d=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}function e(a,b){return b&&(a=a.replace(/ data-wplink-edit="true"/g,"")),a.replace(/]*?href="_wp_link_placeholder"[^>]*>([\s\S]+)<\/a>/g,"$1")}var f,g,h,i,j=window.jQuery;return b.on("preinit",function(){b.wp&&b.wp._createToolbar&&(f=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0),g=b.wp._createToolbar(["wp_link_input","wp_link_apply","wp_link_advanced"],!0),g.on("show",function(){a.$(document.body).hasClass("modal-open")||window.setTimeout(function(){var a=g.$el.find("input.ui-autocomplete-input")[0];a&&(a.focus(),a.select())})}),g.on("hide",function(){g.scrolling||b.execCommand("wp_link_cancel")}))}),b.addCommand("WP_Link",function(){var e=c();return a.Env.ie&&a.Env.ie<10?void("undefined"!=typeof window.wpLink&&window.wpLink.open(b.id)):(g.tempHide=!1,void(e?b.dom.setAttribs(e,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),a.Env.ie&&(b.windowManager.wplinkBookmark=b.selection.getBookmark()),b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!g.scrolling){var d,e,f=c();if(f){if(d=i.getURL(),e=i.getLinkText(),b.focus(),a.isIE&&(b.selection.moveToBookmark(b.windowManager.wplinkBookmark),b.windowManager.wplinkBookmark=null),!d)return void b.dom.remove(f,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(d)||(d="http://"+d),b.dom.setAttribs(f,{href:d,"data-wplink-edit":null}),a.trim(f.innerHTML)||b.$(f).text(e||d)}i.reset(),b.nodeChanged()}}),b.addCommand("wp_link_cancel",function(){g.tempHide||(i.reset(),d(),b.focus(),a.isIE&&(b.selection.moveToBookmark(b.windowManager.wplinkBookmark),b.windowManager.wplinkBookmark=null),g.tempHide=!1)}),b.addShortcut("access+a","","WP_Link"),b.addShortcut("meta+k","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.on("savecontent",function(a){a.content=e(a.content,!0)}),b.on("BeforeAddUndo",function(a){a.lastLevel&&a.lastLevel.content&&a.level.content&&a.lastLevel.content===e(a.level.content)&&a.preventDefault()}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){h=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e,f=this.getEl(),h=f.firstChild;i=this,j&&j.ui&&j.ui.autocomplete&&(c=j(h),c.on("keydown",function(){c.removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return e===a.term?void b(d):/^https?:/.test(a.term)||-1!==a.term.indexOf(".")?b():(j.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:j("#_ajax_linking_nonce").val()},function(a){d=a,b(a)},"json"),void(e=a.term))},focus:function(a,b){c.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID)},select:function(a,b){return c.val(b.item.permalink),j(f.firstChild.nextSibling).val(b.item.title),!1},open:function(){c.attr("aria-expanded","true"),g.blockHide=!0},close:function(){c.attr("aria-expanded","false"),g.blockHide=!1},minLength:2,position:{my:"left top+2"}}).autocomplete("instance")._renderItem=function(a,b){return j('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},c.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":c.autocomplete("widget").attr("id")}).on("focus",function(){c.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox")),a.$(h).on("keydown",function(a){13===a.keyCode&&(b.execCommand("wp_link_apply"),a.preventDefault())})}}),b.on("wptoolbar",function(c){var d,e,j,k=b.dom.getParent(c.element,"a");return a.$(document.body).hasClass("modal-open")?void(g.tempHide=!0):(g.tempHide=!1,void(k&&(d=b.$(k),e=d.attr("href"),j=d.attr("data-wplink-edit"),"_wp_link_placeholder"===e||j?(j&&!i.getURL()&&i.setURL(e),c.element=k,c.toolbar=g):e&&!d.find("img").length&&(h.setURL(e),c.element=k,c.toolbar=f))))}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",cmd:"unlink"}),b.addButton("wp_link_advanced",{tooltip:"Advanced",icon:"dashicon dashicons-admin-generic",onclick:function(){if("undefined"!=typeof window.wpLink){var a=i.getURL()||null,c=i.getLinkText()||null;b.focus(),window.wpLink.open(b.id,a,c),g.tempHide=!0,i.reset()}}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){g.tempHide=!1,b.execCommand("wp_link_cancel")}}})}(window.tinymce); \ No newline at end of file +!function(a){a.ui.WPLinkPreview=a.ui.Control.extend({url:"#",renderHtml:function(){return'"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),-1!==(c=b.indexOf("?"))&&(b=b.slice(0,c)),-1!==(c=b.indexOf("#"))&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&-1!==(c=b.indexOf("/"))&&-1!==(d=b.lastIndexOf("/"))&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}}),a.ui.WPLinkInput=a.ui.Control.extend({renderHtml:function(){return''},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){return a.trim(this.getEl().firstChild.value)},getLinkText:function(){var b=this.getEl().firstChild.nextSibling.value;return a.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){var a=this.getEl().firstChild;a.value="",a.nextSibling.value=""}}),a.PluginManager.add("wplink",function(b){function c(){var a,c,d=b.selection.getNode(),e=b.dom.getParent(d,"a[href]");return e||(c=b.selection.getContent({format:"raw"}),c&&-1!==c.indexOf("")&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&b.selection.select(e))),e}function d(){b.$("a").each(function(a,c){var d=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}function e(a,b){return b&&(a=a.replace(/ data-wplink-edit="true"/g,"")),a.replace(/]*?href="_wp_link_placeholder"[^>]*>([\s\S]+)<\/a>/g,"$1")}var f,g,h,i,j,k=window.jQuery;return b.on("preinit",function(){b.wp&&b.wp._createToolbar&&(f=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0),g=b.wp._createToolbar(["wp_link_input","wp_link_apply","wp_link_advanced"],!0),g.on("show",function(){a.$(document.body).hasClass("modal-open")||window.setTimeout(function(){var a=g.$el.find("input.ui-autocomplete-input")[0],b=j&&(j.textContent||j.innerText);a&&(!a.value&&b&&"undefined"!=typeof window.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),a.focus(),a.select())})}),g.on("hide",function(){g.scrolling||b.execCommand("wp_link_cancel")}))}),b.addCommand("WP_Link",function(){return a.Env.ie&&a.Env.ie<10?void("undefined"!=typeof window.wpLink&&window.wpLink.open(b.id)):(j=c(),g.tempHide=!1,void(j?b.dom.setAttribs(j,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),j=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!g.scrolling){var c,d;if(j){if(c=i.getURL(),d=i.getLinkText(),b.focus(),!c)return void b.dom.remove(j,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)||(c="http://"+c),b.dom.setAttribs(j,{href:c,"data-wplink-edit":null}),a.trim(j.innerHTML)||b.$(j).text(d||c)}i.reset(),b.nodeChanged()}}),b.addCommand("wp_link_cancel",function(){g.tempHide||(i.reset(),d(),b.focus(),g.tempHide=!1)}),b.addShortcut("access+a","","WP_Link"),b.addShortcut("meta+k","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.on("savecontent",function(a){a.content=e(a.content,!0)}),b.on("BeforeAddUndo",function(a){a.lastLevel&&a.lastLevel.content&&a.level.content&&a.lastLevel.content===e(a.level.content)&&a.preventDefault()}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){h=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e,f=this.getEl(),h=f.firstChild;i=this,k&&k.ui&&k.ui.autocomplete&&(c=k(h),c.on("keydown",function(){c.removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return e===a.term?void b(d):/^https?:/.test(a.term)||-1!==a.term.indexOf(".")?b():(k.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:k("#_ajax_linking_nonce").val()},function(a){d=a,b(a)},"json"),void(e=a.term))},focus:function(a,b){c.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID)},select:function(a,b){return c.val(b.item.permalink),k(f.firstChild.nextSibling).val(b.item.title),!1},open:function(){c.attr("aria-expanded","true"),g.blockHide=!0},close:function(){c.attr("aria-expanded","false"),g.blockHide=!1},minLength:2,position:{my:"left top+2"}}).autocomplete("instance")._renderItem=function(a,b){return k('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},c.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":c.autocomplete("widget").attr("id")}).on("focus",function(){c.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox")),a.$(h).on("keydown",function(a){13===a.keyCode&&(b.execCommand("wp_link_apply"),a.preventDefault())})}}),b.on("wptoolbar",function(c){var d,e,j,k=b.dom.getParent(c.element,"a");return a.$(document.body).hasClass("modal-open")?void(g.tempHide=!0):(g.tempHide=!1,void(k&&(d=b.$(k),e=d.attr("href"),j=d.attr("data-wplink-edit"),"_wp_link_placeholder"===e||j?(j&&!i.getURL()&&i.setURL(e),c.element=k,c.toolbar=g):e&&!d.find("img").length&&(h.setURL(e),c.element=k,c.toolbar=f))))}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove",icon:"dashicon dashicons-no",cmd:"unlink"}),b.addButton("wp_link_advanced",{tooltip:"Advanced",icon:"dashicon dashicons-admin-generic",onclick:function(){if("undefined"!=typeof window.wpLink){var a=i.getURL()||null,c=i.getLinkText()||null;b.focus(),window.wpLink.open(b.id,a,c,j),g.tempHide=!0,i.reset()}}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){g.tempHide=!1,b.execCommand("wp_link_cancel")}}})}(window.tinymce); \ No newline at end of file diff --git a/wp-includes/js/tinymce/wp-tinymce.js.gz b/wp-includes/js/tinymce/wp-tinymce.js.gz index 46cd1051ac6000dc5fd6b45f09f06b7cf1f88b1d..28f5b30d401732575867d9b47027c348c0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wBpec>(e}GQM7F6frV%hZy zL+rIYF^=99x^bC?!v^G+8dVY)CCe~f!pvI2_JA#wa?OoPM7TdT0J@+U5b}U1KY4-L zpjt^0w2qC_yW7mmJK7_H)WWfK(8`|<++et_rySgt_=uYO0m;Fh^~g~-DH2WtgGmP(!n08X}6jsO4v diff --git a/wp-includes/js/wplink.js b/wp-includes/js/wplink.js index 447e723e42..7a0e61a096 100644 --- a/wp-includes/js/wplink.js +++ b/wp-includes/js/wplink.js @@ -2,12 +2,12 @@ var wpLink; ( function( $ ) { - var editor, correctedURL, + var editor, correctedURL, linkNode, inputs = {}, isTouch = ( 'ontouchend' in document ); function getLink() { - return editor.dom.getParent( editor.selection.getNode(), 'a' ); + return linkNode || editor.dom.getParent( editor.selection.getNode(), 'a[href]' ); } wpLink = { @@ -125,11 +125,12 @@ var wpLink; } }, - open: function( editorId, url, text ) { + open: function( editorId, url, text, node ) { var ed, $body = $( document.body ); $body.addClass( 'modal-open' ); + linkNode = node; wpLink.range = null; @@ -258,20 +259,20 @@ var wpLink; url = url || editor.dom.getAttrib( linkNode, 'href' ); - if ( url === '_wp_link_placeholder' ) { - url = ''; + if ( url !== '_wp_link_placeholder' ) { + inputs.url.val( url ); + inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) ); + inputs.submit.val( wpLinkL10n.update ); + } else { + this.setDefaultValues( linkText ); } - - inputs.url.val( url ); - inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) ); - inputs.submit.val( wpLinkL10n.update ); } else { - text = editor.selection.getContent({ format: 'text' }) || text; - this.setDefaultValues(); + linkText = editor.selection.getContent({ format: 'text' }) || text || ''; + this.setDefaultValues( linkText ); } if ( onlyText ) { - inputs.text.val( linkText || '' ); + inputs.text.val( linkText ); inputs.wrap.addClass( 'has-text-field' ); } else { inputs.text.val( '' ); @@ -279,22 +280,24 @@ var wpLink; } }, - close: function() { + close: function( reset ) { $( document.body ).removeClass( 'modal-open' ); - if ( ! wpLink.isMCE() ) { - wpLink.textarea.focus(); + if ( reset !== 'noReset' ) { + if ( ! wpLink.isMCE() ) { + wpLink.textarea.focus(); - if ( wpLink.range ) { - wpLink.range.moveToBookmark( wpLink.range.getBookmark() ); - wpLink.range.select(); - } - } else { - if ( editor.plugins.wplink ) { - editor.plugins.wplink.close(); - } + if ( wpLink.range ) { + wpLink.range.moveToBookmark( wpLink.range.getBookmark() ); + wpLink.range.select(); + } + } else { + if ( editor.plugins.wplink ) { + editor.plugins.wplink.close(); + } - editor.focus(); + editor.focus(); + } } inputs.backdrop.hide(); @@ -394,13 +397,14 @@ var wpLink; editor.focus(); - if ( tinymce.isIE ) { + if ( tinymce.isIE && editor.windowManager.wplinkBookmark ) { editor.selection.moveToBookmark( editor.windowManager.wplinkBookmark ); editor.windowManager.wplinkBookmark = null; } if ( ! attrs.href ) { editor.execCommand( 'unlink' ); + wpLink.close(); return; } @@ -428,7 +432,8 @@ var wpLink; } } - wpLink.close(); + wpLink.close( 'noReset' ); + editor.focus(); editor.nodeChanged(); }, @@ -455,30 +460,37 @@ var wpLink; } }, - setDefaultValues: function() { - var selection, + getUrlFromSelection: function( selection ) { + var url, emailRegexp = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i, urlRegexp = /^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i; - if ( this.isMCE() ) { - selection = editor.selection.getContent(); - } else if ( document.selection && wpLink.range ) { - selection = wpLink.range.text; - } else if ( typeof this.textarea.selectionStart !== 'undefined' ) { - selection = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ); + if ( ! selection ) { + if ( this.isMCE() ) { + selection = editor.selection.getContent({ format: 'text' }); + } else if ( document.selection && wpLink.range ) { + selection = wpLink.range.text; + } else if ( typeof this.textarea.selectionStart !== 'undefined' ) { + selection = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ); + } } + selection = tinymce.trim( selection ); + if ( selection && emailRegexp.test( selection ) ) { // Selection is email address - inputs.url.val( 'mailto:' + selection ); + return 'mailto:' + selection; } else if ( selection && urlRegexp.test( selection ) ) { // Selection is URL - inputs.url.val( selection.replace( /&|�?38;/gi, '&' ) ); - } else { - // Set URL to default. - inputs.url.val( '' ); + return selection.replace( /&|�?38;/gi, '&' ); } + return ''; + }, + + setDefaultValues: function( selection ) { + inputs.url.val( this.getUrlFromSelection( selection ) ); + // Update save prompt. inputs.submit.val( wpLinkL10n.save ); } diff --git a/wp-includes/js/wplink.min.js b/wp-includes/js/wplink.min.js index 43400c08a4..d388ca3f94 100644 --- a/wp-includes/js/wplink.min.js +++ b/wp-includes/js/wplink.min.js @@ -1 +1 @@ -var wpLink;!function(a){function b(){return c.dom.getParent(c.selection.getNode(),"a")}var c,d,e={},f="ontouchend"in document;wpLink={textarea:"",init:function(){e.wrap=a("#wp-link-wrap"),e.dialog=a("#wp-link"),e.backdrop=a("#wp-link-backdrop"),e.submit=a("#wp-link-submit"),e.close=a("#wp-link-close"),e.text=a("#wp-link-text"),e.url=a("#wp-link-url"),e.openInNewTab=a("#wp-link-target"),a.ui&&a.ui.autocomplete&&wpLink.setAutocomplete(),e.dialog.on("keydown",wpLink.keydown),e.submit.on("click",function(a){a.preventDefault(),wpLink.update()}),e.close.add(e.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),e.url.on("paste",function(){setTimeout(wpLink.correctURL,0)})},setAutocomplete:function(){var b,c,d=e.url;d.on("keydown",function(){d.removeAttr("aria-activedescendant")}).autocomplete({source:function(d,e){return c===d.term?void e(b):/^https?:/.test(d.term)||-1!==d.term.indexOf(".")?e():(a.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:d.term,_ajax_linking_nonce:a("#_ajax_linking_nonce").val()},function(a){b=a,e(a)},"json"),void(c=d.term))},focus:function(a,b){d.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID)},select:function(a,b){return d.val(b.item.permalink),e.wrap.hasClass("has-text-field")&&""===tinymce.trim(e.text.val())&&e.text.val(b.item.title),!1},open:function(){d.attr("aria-expanded","true")},close:function(){d.attr("aria-expanded","false")},minLength:2,position:{my:"left top+2"}}).autocomplete("instance")._renderItem=function(b,c){return a('
  • ').append(''+c.title+' '+c.info+"").appendTo(b)},d.attr({"aria-owns":d.autocomplete("widget").attr("id")}).on("focus",function(){d.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox")},correctURL:function(){var b=a.trim(e.url.val());b&&d!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(e.url.val("http://"+b),d=b)},open:function(b,d,f){var g,h=a(document.body);h.addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(h.append(e.backdrop,e.wrap),g=tinymce.get(wpActiveEditor),c=g&&!g.isHidden()?g:null,c&&tinymce.isIE&&!c.windowManager.wplinkBookmark&&(c.windowManager.wplinkBookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),e.wrap.show(),e.backdrop.show(),wpLink.refresh(d,f),a(document).trigger("wplink-open",e.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(a,b){var c="";wpLink.isMCE()?wpLink.mceRefresh(a,b):(e.wrap.hasClass("has-text-field")||e.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),e.text.val(b),wpLink.setDefaultValues()),f?e.url.focus().blur():window.setTimeout(function(){e.url.focus()[0].select()}),d=e.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,d,e,f=c.selection.getContent();if(/]+>[^<]+<\/a>$/.test(f)||-1===f.indexOf("href=")))return!1;if(a){if(d=a.childNodes,0===d.length)return!1;for(e=d.length-1;e>=0;e--)if(b=d[e],3!=b.nodeType&&!tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(a,d){var f,g=b(),h=this.hasSelectedText(g);g?(f=g.innerText||g.textContent,tinymce.trim(f)||(f=d||""),a=a||c.dom.getAttrib(g,"href"),"_wp_link_placeholder"===a&&(a=""),e.url.val(a),e.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(g,"target")),e.submit.val(wpLinkL10n.update)):(d=c.selection.getContent({format:"text"})||d,this.setDefaultValues()),h?(e.text.val(f||""),e.wrap.addClass("has-text-field")):(e.text.val(""),e.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?(c.plugins.wplink&&c.plugins.wplink.close(),c.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),e.backdrop.hide(),e.wrap.hide(),d=!1,a(document).trigger("wplink-close",e.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(e.url.val()),target:e.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,f,g,h,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=e.text.val(),a.href&&(c=wpLink.buildHtml(a),document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,f=i.selectionEnd,h=b||i.value.substring(d,f),c=c+h+"",g=d+c.length,d!==f||h||(g-=4),i.value=i.value.substring(0,d)+c+i.value.substring(f,i.value.length),i.selectionStart=i.selectionEnd=g),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,f=wpLink.getAttrs();return c.focus(),tinymce.isIE&&(c.selection.moveToBookmark(c.windowManager.wplinkBookmark),c.windowManager.wplinkBookmark=null),f.href?(a=b(),e.wrap.hasClass("has-text-field")&&(d=e.text.val()||f.href),a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,f)):d?c.selection.setNode(c.dom.create("a",f,c.dom.encode(d))):c.execCommand("mceInsertLink",!1,f),wpLink.close(),void c.nodeChanged()):void c.execCommand("unlink")},keydown:function(a){var b;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(b=a.target.id,"wp-link-submit"!==b||a.shiftKey?"wp-link-close"===b&&a.shiftKey&&(e.submit.focus(),a.preventDefault()):(e.close.focus(),a.preventDefault()))},setDefaultValues:function(){var a,b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?a=c.selection.getContent():document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),a&&b.test(a)?e.url.val("mailto:"+a):a&&d.test(a)?e.url.val(a.replace(/&|�?38;/gi,"&")):e.url.val(""),e.submit.val(wpLinkL10n.save)}},a(document).ready(wpLink.init)}(jQuery); \ No newline at end of file +var wpLink;!function(a){function b(){return e||c.dom.getParent(c.selection.getNode(),"a[href]")}var c,d,e,f={},g="ontouchend"in document;wpLink={textarea:"",init:function(){f.wrap=a("#wp-link-wrap"),f.dialog=a("#wp-link"),f.backdrop=a("#wp-link-backdrop"),f.submit=a("#wp-link-submit"),f.close=a("#wp-link-close"),f.text=a("#wp-link-text"),f.url=a("#wp-link-url"),f.openInNewTab=a("#wp-link-target"),a.ui&&a.ui.autocomplete&&wpLink.setAutocomplete(),f.dialog.on("keydown",wpLink.keydown),f.submit.on("click",function(a){a.preventDefault(),wpLink.update()}),f.close.add(f.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),f.url.on("paste",function(){setTimeout(wpLink.correctURL,0)})},setAutocomplete:function(){var b,c,d=f.url;d.on("keydown",function(){d.removeAttr("aria-activedescendant")}).autocomplete({source:function(d,e){return c===d.term?void e(b):/^https?:/.test(d.term)||-1!==d.term.indexOf(".")?e():(a.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:d.term,_ajax_linking_nonce:a("#_ajax_linking_nonce").val()},function(a){b=a,e(a)},"json"),void(c=d.term))},focus:function(a,b){d.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID)},select:function(a,b){return d.val(b.item.permalink),f.wrap.hasClass("has-text-field")&&""===tinymce.trim(f.text.val())&&f.text.val(b.item.title),!1},open:function(){d.attr("aria-expanded","true")},close:function(){d.attr("aria-expanded","false")},minLength:2,position:{my:"left top+2"}}).autocomplete("instance")._renderItem=function(b,c){return a('
  • ').append(''+c.title+' '+c.info+"").appendTo(b)},d.attr({"aria-owns":d.autocomplete("widget").attr("id")}).on("focus",function(){d.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox")},correctURL:function(){var b=a.trim(f.url.val());b&&d!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(f.url.val("http://"+b),d=b)},open:function(b,d,g,h){var i,j=a(document.body);j.addClass("modal-open"),e=h,wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(j.append(f.backdrop,f.wrap),i=tinymce.get(wpActiveEditor),c=i&&!i.isHidden()?i:null,c&&tinymce.isIE&&!c.windowManager.wplinkBookmark&&(c.windowManager.wplinkBookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),f.wrap.show(),f.backdrop.show(),wpLink.refresh(d,g),a(document).trigger("wplink-open",f.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(a,b){var c="";wpLink.isMCE()?wpLink.mceRefresh(a,b):(f.wrap.hasClass("has-text-field")||f.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),f.text.val(b),wpLink.setDefaultValues()),g?f.url.focus().blur():window.setTimeout(function(){f.url.focus()[0].select()}),d=f.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,d,e,f=c.selection.getContent();if(/]+>[^<]+<\/a>$/.test(f)||-1===f.indexOf("href=")))return!1;if(a){if(d=a.childNodes,0===d.length)return!1;for(e=d.length-1;e>=0;e--)if(b=d[e],3!=b.nodeType&&!tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(a,d){var e,g=b(),h=this.hasSelectedText(g);g?(e=g.innerText||g.textContent,tinymce.trim(e)||(e=d||""),a=a||c.dom.getAttrib(g,"href"),"_wp_link_placeholder"!==a?(f.url.val(a),f.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(g,"target")),f.submit.val(wpLinkL10n.update)):this.setDefaultValues(e)):(e=c.selection.getContent({format:"text"})||d||"",this.setDefaultValues(e)),h?(f.text.val(e),f.wrap.addClass("has-text-field")):(f.text.val(""),f.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),"noReset"!==b&&(wpLink.isMCE()?(c.plugins.wplink&&c.plugins.wplink.close(),c.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),f.backdrop.hide(),f.wrap.hide(),d=!1,a(document).trigger("wplink-close",f.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(f.url.val()),target:f.openInNewTab.prop("checked")?"_blank":""}},buildHtml:function(a){var b='"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,g,h,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=f.text.val(),a.href&&(c=wpLink.buildHtml(a),document.selection&&wpLink.range?(i.focus(),wpLink.range.text=c+(b||wpLink.range.text)+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof i.selectionStart&&(d=i.selectionStart,e=i.selectionEnd,h=b||i.value.substring(d,e),c=c+h+"",g=d+c.length,d!==e||h||(g-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=g),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return c.focus(),tinymce.isIE&&c.windowManager.wplinkBookmark&&(c.selection.moveToBookmark(c.windowManager.wplinkBookmark),c.windowManager.wplinkBookmark=null),e.href?(a=b(),f.wrap.hasClass("has-text-field")&&(d=f.text.val()||e.href),a?(d&&("innerText"in a?a.innerText=d:a.textContent=d),c.dom.setAttribs(a,e)):d?c.selection.setNode(c.dom.create("a",e,c.dom.encode(d))):c.execCommand("mceInsertLink",!1,e),wpLink.close("noReset"),c.focus(),void c.nodeChanged()):(c.execCommand("unlink"),void wpLink.close())},keydown:function(a){var b;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(b=a.target.id,"wp-link-submit"!==b||a.shiftKey?"wp-link-close"===b&&a.shiftKey&&(f.submit.focus(),a.preventDefault()):(f.close.focus(),a.preventDefault()))},getUrlFromSelection:function(a){var b=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,d=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;return a||(this.isMCE()?a=c.selection.getContent({format:"text"}):document.selection&&wpLink.range?a=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),a=tinymce.trim(a),a&&b.test(a)?"mailto:"+a:a&&d.test(a)?a.replace(/&|�?38;/gi,"&"):""},setDefaultValues:function(a){f.url.val(this.getUrlFromSelection(a)),f.submit.val(wpLinkL10n.save)}},a(document).ready(wpLink.init)}(jQuery); \ No newline at end of file diff --git a/wp-includes/version.php b/wp-includes/version.php index 2563b9cf49..5196de123b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-beta1-36746'; +$wp_version = '4.5-beta1-36747'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.