From 30feff9c99a1c8086d96b4fa676831f16ca6b73e Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 20 Feb 2016 21:36:25 +0000 Subject: [PATCH] TinyMCE, inline link dialog: - Fix passing values to the (old) modal on open when non-linked text is selected and Advanced is clicked before pasting an URL. - When the user has selected text partially including a link and opens the editing dialog, auto-select the link only. Helps when a linked word is selected by double-clicking. - Remove all placeholders on saving. - Do not add undo level on inserting link placeholder. - Remove the placeholder when canceling from the modal. See #33301. Built from https://develop.svn.wordpress.org/trunk@36602 git-svn-id: http://core.svn.wordpress.org/trunk@36569 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/wplink/plugin.js | 94 ++++++++++++------ .../js/tinymce/plugins/wplink/plugin.min.js | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 164866 -> 165007 bytes wp-includes/js/wplink.js | 20 +++- wp-includes/js/wplink.min.js | 2 +- wp-includes/version.php | 2 +- 6 files changed, 84 insertions(+), 36 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.js b/wp-includes/js/tinymce/plugins/wplink/plugin.js index b1769a51c7..4ffd5dc109 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.js @@ -41,7 +41,7 @@ if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) { // If the beginning + ending are shorter that 40 chars, show more of the ending if ( index + url.length - lastIndex < 40 ) { - lastIndex = -( 40 - ( index + 1 ) ); + lastIndex = -( 40 - ( index + 1 ) ); } url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex ); @@ -74,26 +74,49 @@ var $ = window.jQuery; function getSelectedLink() { - var href, - selectedNode = editor.selection.getNode(), - selectedText = editor.selection.getContent(), - link = editor.dom.getParent( selectedNode, 'a[href]' ); + var href, html + node = editor.selection.getNode(); + link = editor.dom.getParent( node, 'a[href]' ); - if ( ! link && selectedText.indexOf( '' ) !== -1 ) { - href = selectedText.match( /href="([^">]+)"/ ); + if ( ! link ) { + html = editor.selection.getContent({ format: 'raw' }); - if ( href && href[1] ) { - link = editor.$( 'a[href="' + href[1] + '"]', selectedNode )[0]; - } + if ( html && html.indexOf( '' ) !== -1 ) { + href = html.match( /href="([^">]+)"/ ); - if ( link ) { - editor.selection.select( link ); - editor.nodeChanged(); + if ( href && href[1] ) { + link = editor.$( 'a[href="' + href[1] + '"]', node )[0]; + } + + if ( link ) { + editor.selection.select( link ); + editor.nodeChanged(); + } } } return link; } + + function removePlaceholders() { + editor.$( 'a' ).each( function( i, element ) { + var $element = editor.$( element ); + + if ( $element.attr( 'href' ) === '_wp_link_placeholder' ) { + editor.dom.remove( element, true ); + } else if ( $element.attr( 'data-wp-link-edit' ) ) { + $element.attr( 'data-wp-link-edit', null ); + } + }); + } + + function removePlaceholderStrings( content, dataAttr ) { + if ( dataAttr ) { + content = content.replace( / data-wp-link-edit="true"/g, '' ); + } + + return content.replace( /]*?href="_wp_link_placeholder"[^>]*>([\s\S]+)<\/a>/g, '$1' ); + } editor.on( 'preinit', function() { if ( editor.wp && editor.wp._createToolbar ) { @@ -126,9 +149,12 @@ var link = getSelectedLink(); if ( link ) { - editor.dom.setAttribs( link, { 'data-wp-edit': true } ); + editor.dom.setAttribs( link, { 'data-wp-link-edit': true } ); } else { + removePlaceholders(); + editor.execCommand( 'mceInsertLink', false, { href: '_wp_link_placeholder' } ); + editor.selection.select( editor.$( 'a[href="_wp_link_placeholder"]' )[0] ); editor.nodeChanged(); } } ); @@ -150,7 +176,7 @@ } if ( a ) { - editor.dom.setAttribs( a, { href: href, 'data-wp-edit': null } ); + editor.dom.setAttribs( a, { href: href, 'data-wp-link-edit': null } ); } a = false; @@ -160,16 +186,8 @@ } ); editor.addCommand( 'wp_link_cancel', function() { - if ( a ) { - if ( editor.$( a ).attr( 'href' ) === '_wp_link_placeholder' ) { - editor.dom.remove( a, true ); - } else { - editor.dom.setAttribs( a, { 'data-wp-edit': null } ); - } - } - + removePlaceholders(); a = false; - editor.nodeChanged(); editor.focus(); } ); @@ -218,6 +236,18 @@ } } } ); + + // Remove any remaining placeholders on saving. + editor.on( 'savecontent', function( event ) { + event.content = removePlaceholderStrings( event.content, true ); + }); + + // Prevent adding undo levels on inserting link placeholder. + editor.on( 'BeforeAddUndo', function( event ) { + if ( event.level.content ) { + event.level.content = removePlaceholderStrings( event.level.content ); + } + }); editor.addButton( 'wp_link_preview', { type: 'WPLinkPreview', @@ -235,7 +265,7 @@ inputInstance = this; - if ( $ ) { + if ( $ && $.ui && $.ui.autocomplete ) { $( input ) .on( 'keydown', function() { $( input ).removeAttr( 'aria-activedescendant' ); @@ -311,13 +341,12 @@ editor.on( 'wptoolbar', function( event ) { var anchor = editor.dom.getParent( event.element, 'a' ), - $anchor, - href, edit; + $anchor, href, edit; if ( anchor ) { $anchor = editor.$( anchor ); href = $anchor.attr( 'href' ); - edit = $anchor.attr( 'data-wp-edit' ); + edit = $anchor.attr( 'data-wp-link-edit' ); if ( href === '_wp_link_placeholder' || edit ) { inputInstance.setURL( edit ? href : '' ); @@ -348,8 +377,13 @@ tooltip: 'Advanced', icon: 'dashicon dashicons-admin-generic', onclick: function() { - editor.execCommand( 'wp_link_apply' ); - window.wpLink && window.wpLink.open( editor.id ); + if ( typeof window.wpLink !== 'undefined' ) { + if ( inputInstance.getEl().firstChild.value ) { + editor.execCommand( 'wp_link_apply' ); + } + + window.wpLink.open( editor.id ); + } } } ); diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js index 9468c37e75..28b00dcb8c 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}}),a.PluginManager.add("wplink",function(b){function c(){var a,c=b.selection.getNode(),d=b.selection.getContent(),e=b.dom.getParent(c,"a[href]");return e||-1===d.indexOf("")||(a=d.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',c)[0]),e&&(b.selection.select(e),b.nodeChanged())),e}var d,e,f,g,h,i=window.jQuery;b.on("preinit",function(){b.wp&&b.wp._createToolbar&&(e=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0),f=b.wp._createToolbar(["wp_link_input","wp_link_apply","wp_link_advanced"],!0),f.on("show",function(){var a=f.find("toolbar")[0];a&&a.focus(!0),d=c()}),f.on("hide",function(){f.scrolling||b.execCommand("wp_link_cancel")}))}),b.addCommand("WP_Link",function(){var a=c();a?b.dom.setAttribs(a,{"data-wp-edit":!0}):(b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),b.nodeChanged())}),b.addCommand("wp_link_apply",function(){if(!f.scrolling){var c=a.trim(h.getEl().firstChild.value);if(c&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)&&(c="http://"+c),!c)return void b.dom.remove(d,!0);d&&b.dom.setAttribs(d,{href:c,"data-wp-edit":null}),d=!1,b.nodeChanged(),b.focus()}}),b.addCommand("wp_link_cancel",function(){d&&("_wp_link_placeholder"===b.$(d).attr("href")?b.dom.remove(d,!0):b.dom.setAttribs(d,{"data-wp-edit":null})),d=!1,b.nodeChanged(),b.focus()}),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.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){g=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e=this.getEl().firstChild;h=this,i&&(i(e).on("keydown",function(){i(e).removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return d===a.term?void b(c):/^https?:/.test(a.term)||-1!==a.term.indexOf(".")?b():(i.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:i("#_ajax_linking_nonce").val()},function(a){c=a,b(a)},"json"),void(d=a.term))},focus:function(a,b){i(e).attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID)},select:function(a,b){return i(e).val(b.item.permalink),!1},open:function(){i(e).attr("aria-expanded","true"),f.blockHide=!0},close:function(){i(e).attr("aria-expanded","false"),f.blockHide=!1},minLength:2,position:{my:"left top+5"}}).autocomplete("instance")._renderItem=function(a,b){return i('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},i(e).attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":i(e).autocomplete("widget").attr("id")}).on("focus",function(){i(e).autocomplete("search")}).autocomplete("widget").addClass("mce-wp-autocomplete").attr("role","listbox")),a.$(e).on("keydown",function(a){13===a.keyCode&&b.execCommand("wp_link_apply")})}}),b.on("wptoolbar",function(a){var c,d,i,j=b.dom.getParent(a.element,"a");j&&(c=b.$(j),d=c.attr("href"),i=c.attr("data-wp-edit"),"_wp_link_placeholder"===d||i?(h.setURL(i?d:""),a.element=j,a.toolbar=f):d&&!c.find("img").length&&(g.setURL(d),a.element=j,a.toolbar=e))}),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(){b.execCommand("wp_link_apply"),window.wpLink&&window.wpLink.open(b.id)}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"})})}(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}}),a.PluginManager.add("wplink",function(b){function c(){var a,c;return node=b.selection.getNode(),link=b.dom.getParent(node,"a[href]"),link||(c=b.selection.getContent({format:"raw"}),c&&-1!==c.indexOf("")&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(link=b.$('a[href="'+a[1]+'"]',node)[0]),link&&(b.selection.select(link),b.nodeChanged()))),link}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-wp-link-edit")&&d.attr("data-wp-link-edit",null)})}function e(a,b){return b&&(a=a.replace(/ data-wp-link-edit="true"/g,"")),a.replace(/]*?href="_wp_link_placeholder"[^>]*>([\s\S]+)<\/a>/g,"$1")}var f,g,h,i,j,k=window.jQuery;b.on("preinit",function(){b.wp&&b.wp._createToolbar&&(g=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0),h=b.wp._createToolbar(["wp_link_input","wp_link_apply","wp_link_advanced"],!0),h.on("show",function(){var a=h.find("toolbar")[0];a&&a.focus(!0),f=c()}),h.on("hide",function(){h.scrolling||b.execCommand("wp_link_cancel")}))}),b.addCommand("WP_Link",function(){var a=c();a?b.dom.setAttribs(a,{"data-wp-link-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),b.selection.select(b.$('a[href="_wp_link_placeholder"]')[0]),b.nodeChanged())}),b.addCommand("wp_link_apply",function(){if(!h.scrolling){var c=a.trim(j.getEl().firstChild.value);if(c&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)&&(c="http://"+c),!c)return void b.dom.remove(f,!0);f&&b.dom.setAttribs(f,{href:c,"data-wp-link-edit":null}),f=!1,b.nodeChanged(),b.focus()}}),b.addCommand("wp_link_cancel",function(){d(),f=!1,b.nodeChanged(),b.focus()}),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.level.content&&(a.level.content=e(a.level.content))}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){i=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e=this.getEl().firstChild;j=this,k&&k.ui&&k.ui.autocomplete&&(k(e).on("keydown",function(){k(e).removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return d===a.term?void b(c):/^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){c=a,b(a)},"json"),void(d=a.term))},focus:function(a,b){k(e).attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID)},select:function(a,b){return k(e).val(b.item.permalink),!1},open:function(){k(e).attr("aria-expanded","true"),h.blockHide=!0},close:function(){k(e).attr("aria-expanded","false"),h.blockHide=!1},minLength:2,position:{my:"left top+5"}}).autocomplete("instance")._renderItem=function(a,b){return k('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},k(e).attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":k(e).autocomplete("widget").attr("id")}).on("focus",function(){k(e).autocomplete("search")}).autocomplete("widget").addClass("mce-wp-autocomplete").attr("role","listbox")),a.$(e).on("keydown",function(a){13===a.keyCode&&b.execCommand("wp_link_apply")})}}),b.on("wptoolbar",function(a){var c,d,e,f=b.dom.getParent(a.element,"a");f&&(c=b.$(f),d=c.attr("href"),e=c.attr("data-wp-link-edit"),"_wp_link_placeholder"===d||e?(j.setURL(e?d:""),a.element=f,a.toolbar=h):d&&!c.find("img").length&&(i.setURL(d),a.element=f,a.toolbar=g))}),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(){"undefined"!=typeof window.wpLink&&(j.getEl().firstChild.value&&b.execCommand("wp_link_apply"),window.wpLink.open(b.id))}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"})})}(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 59a6f000bf4694a7fee7c3f5813b4ee7feea3411..f1ff3f77a9fca3b6757fd575f542d8e8ed778bed 100644 GIT binary patch delta 6431 zcmV+)8Q|uEhzgI13V?(Gv;urM{SD;Aq^$b^0lUsm z)x_HTVv}>LP^m)Q40+=jS8j9+R2j)r{lGejJ8+Di$2M6{!^{u+)LmJ-&f0BNo*ExeA}QYBM+IhbS>n2RP^ zl!sQ#bGaB@?*9HWhKVO+rRG9W3Xj_EzESDXB3VFLWRtoPl%js#%Q|8G1fZ?^;-q%z(7mFWPxD%%Dwj^u^DOxoCOiflu@`7iWEWFy z3B@tAHA6us+h|vsCp~<`ImSF*BH`s9uYW5R$5(^rN+R)CIWn%Zjix`{)-+d5Z?E-P zFTH4C3fG2ZmtHhGf7%c4o2v4twGMyU&|%dOs(cUz-q{P6?kmaX6C%RY%dJaJkTOj% zulC5lbmY5EKfo_LO|3bppiUdlkT9^qa0CqJ4YuA};$(~o`kcC3@THft>DBA$hy^&Y zZu}?KfBi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W)CW8(pxS5fx@3Gw3? zh|SpA)ftDz>n8(EP4WM_gbn*~?1l)0o~gHH$GkheT+W&O-GxG36yS_jk@%?RcoLuKPfy^L)pg{{cEtUYYa2HERxv~oYV-KoK}#% zhE>_uLRYq7M-o5O+DWQL7Y@2rp1Z2B)m6rnv;%=11q;N)Lvu6R-X0?gp^s7m%Xjg$! z?Nm9_KZz&aIy?O8uUFznnfBNJL$#D;bF~y}o~mQNLxB_VJ?lu>i4`fk)Yy6zd@)+s lKahK!%Fns{l!Lxs#5d|b>W6jBkLQ3I`!8f5z3xwv2LJ}NS{eWV diff --git a/wp-includes/js/wplink.js b/wp-includes/js/wplink.js index b5a84aecb7..eba50fc70d 100644 --- a/wp-includes/js/wplink.js +++ b/wp-includes/js/wplink.js @@ -219,14 +219,20 @@ var wpLink; }, mceRefresh: function() { - var text, + var text, url, selectedNode = editor.selection.getNode(), linkNode = editor.dom.getParent( selectedNode, 'a[href]' ), onlyText = this.hasSelectedText( linkNode ); if ( linkNode ) { text = linkNode.innerText || linkNode.textContent; - inputs.url.val( editor.dom.getAttrib( linkNode, 'href' ) ); + url = editor.dom.getAttrib( linkNode, 'href' ); + + if ( url === '_wp_link_placeholder' ) { + url = ''; + } + + inputs.url.val( url ); inputs.openInNewTab.prop( 'checked', '_blank' === editor.dom.getAttrib( linkNode, 'target' ) ); inputs.submit.val( wpLinkL10n.update ); } else { @@ -244,6 +250,8 @@ var wpLink; }, close: function() { + var linkNode; + $( document.body ).removeClass( 'modal-open' ); if ( ! wpLink.isMCE() ) { @@ -254,6 +262,12 @@ var wpLink; wpLink.range.select(); } } else { + linkNode = editor.dom.getParent( editor.selection.getNode(), 'a[href]' ); + + if ( linkNode && editor.dom.getAttrib( linkNode, 'href' ) === '_wp_link_placeholder' ) { + editor.dom.remove( linkNode, true ); + } + editor.focus(); } @@ -352,7 +366,6 @@ var wpLink; var attrs = wpLink.getAttrs(), link, text; - wpLink.close(); editor.focus(); if ( tinymce.isIE ) { @@ -388,6 +401,7 @@ var wpLink; } } + wpLink.close(); editor.nodeChanged(); }, diff --git a/wp-includes/js/wplink.min.js b/wp-includes/js/wplink.min.js index cb209184d4..eab9b90119 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,g,h={},i={},j="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){h.wrap=a("#wp-link-wrap"),h.dialog=a("#wp-link"),h.backdrop=a("#wp-link-backdrop"),h.submit=a("#wp-link-submit"),h.close=a("#wp-link-close"),h.text=a("#wp-link-text"),h.url=a("#wp-link-url"),h.nonce=a("#_ajax_linking_nonce"),h.openInNewTab=a("#wp-link-target"),h.search=a("#wp-link-search"),i.search=new e(a("#search-results")),i.recent=new e(a("#most-recent-results")),i.elements=h.dialog.find(".query-results"),h.queryNotice=a("#query-notice-message"),h.queryNoticeTextDefault=h.queryNotice.find(".query-notice-default"),h.queryNoticeTextHint=h.queryNotice.find(".query-notice-hint"),h.dialog.keydown(wpLink.keydown),h.dialog.keyup(wpLink.keyup),h.submit.click(function(a){a.preventDefault(),wpLink.update()}),h.close.add(h.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),i.elements.on("river-select",wpLink.updateFields),h.search.on("focus.wplink",function(){h.queryNoticeTextDefault.hide(),h.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){h.queryNoticeTextDefault.show(),h.queryNoticeTextHint.addClass("screen-reader-text").hide()}),h.search.on("keyup input",function(){var a=this;window.clearTimeout(d),d=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)}),h.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),h.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(h.url.val());b&&g!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(h.url.val("http://"+b),g=b)},open:function(b){var d,e=a(document.body);e.addClass("modal-open"),wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e.append(h.backdrop,h.wrap),d=tinymce.get(wpActiveEditor),c=d&&!d.isHidden()?d:null,c&&tinymce.isIE&&(c.windowManager.bookmark=c.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),h.wrap.show(),h.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",h.wrap))},isMCE:function(){return c&&!c.isHidden()},refresh:function(){var a="";i.search.refresh(),i.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(h.wrap.hasClass("has-text-field")||h.wrap.addClass("has-text-field"),document.selection?a=document.selection.createRange().text||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(a=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),h.text.val(a),wpLink.setDefaultValues()),j?h.url.focus().blur():h.url.focus()[0].select(),i.recent.ul.children().length||i.recent.ajax(),g=h.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b=c.selection.getContent();if(/]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b=c.selection.getNode(),d=c.dom.getParent(b,"a[href]"),e=this.hasSelectedText(d);d?(a=d.innerText||d.textContent,h.url.val(c.dom.getAttrib(d,"href")),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(d,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),e?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?c.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(h.url.val()),target:h.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,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.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,g=b||i.value.substring(d,e),c=c+g+"",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return wpLink.close(),c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),h.wrap.hasClass("has-text-field")&&(d=h.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),void c.nodeChanged()):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},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)?h.url.val("mailto:"+a):a&&d.test(a)?h.url.val(a.replace(/&|�?38;/gi,"&")):h.url.val(""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>2){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(a){var b,c;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(c=a.target.id,"wp-link-submit"!==c||a.shiftKey?"wp-link-close"===c&&a.shiftKey&&(h.submit.focus(),a.preventDefault()):(h.close.focus(),a.preventDefault())),(38===a.keyCode||40===a.keyCode)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(b=38===a.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[b](),wpLink.keyInterval=setInterval(wpLink[b],wpLink.keySensitivity),a.preventDefault())},keyup:function(a){(38===a.keyCode||40===a.keyCode)&&(clearInterval(wpLink.keyInterval),a.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'
  • ':"
  • ",d+='',d+='',d+=this.title?this.title:wpLinkL10n.noTitle,d+=''+this.info+"
  • ",e=!e}):g&&(d+='
  • '+wpLinkL10n.noMatchesFound+"
  • "),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c]+>[^<]+<\/a>$/.test(b)||-1===b.indexOf("href=")))return!1;if(a){var d,e=a.childNodes;if(0===e.length)return!1;for(d=e.length-1;d>=0;d--)if(3!=e[d].nodeType)return!1}return!0},mceRefresh:function(){var a,b,d=c.selection.getNode(),e=c.dom.getParent(d,"a[href]"),f=this.hasSelectedText(e);e?(a=e.innerText||e.textContent,b=c.dom.getAttrib(e,"href"),"_wp_link_placeholder"===b&&(b=""),h.url.val(b),h.openInNewTab.prop("checked","_blank"===c.dom.getAttrib(e,"target")),h.submit.val(wpLinkL10n.update)):(a=c.selection.getContent({format:"text"}),this.setDefaultValues()),f?(h.text.val(a||""),h.wrap.addClass("has-text-field")):(h.text.val(""),h.wrap.removeClass("has-text-field"))},close:function(){var b;a(document.body).removeClass("modal-open"),wpLink.isMCE()?(b=c.dom.getParent(c.selection.getNode(),"a[href]"),b&&"_wp_link_placeholder"===c.dom.getAttrib(b,"href")&&c.dom.remove(b,!0),c.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),h.backdrop.hide(),h.wrap.hide(),g=!1,a(document).trigger("wplink-close",h.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(h.url.val()),target:h.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,f,g,i=wpLink.textarea;i&&(a=wpLink.getAttrs(),b=h.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,g=b||i.value.substring(d,e),c=c+g+"",f=d+c.length,d!==e||g||(f-=4),i.value=i.value.substring(0,d)+c+i.value.substring(e,i.value.length),i.selectionStart=i.selectionEnd=f),wpLink.close(),i.focus()))},mceUpdate:function(){var a,d,e=wpLink.getAttrs();return c.focus(),tinymce.isIE&&c.selection.moveToBookmark(c.windowManager.bookmark),e.href?(a=b(),h.wrap.hasClass("has-text-field")&&(d=h.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(),void c.nodeChanged()):void c.execCommand("unlink")},updateFields:function(a,b){h.url.val(b.children(".item-permalink").val())},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)?h.url.val("mailto:"+a):a&&d.test(a)?h.url.val(a.replace(/&|�?38;/gi,"&")):h.url.val(""),h.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>2){if(i.recent.hide(),i.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").addClass("is-active"),i.search.change(d),i.search.ajax(function(){b.removeClass("is-active")})}else i.search.hide(),i.recent.show()},next:function(){i.search.next(),i.recent.next()},prev:function(){i.search.prev(),i.recent.prev()},keydown:function(a){var b,c;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(c=a.target.id,"wp-link-submit"!==c||a.shiftKey?"wp-link-close"===c&&a.shiftKey&&(h.submit.focus(),a.preventDefault()):(h.close.focus(),a.preventDefault())),(38===a.keyCode||40===a.keyCode)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(b=38===a.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[b](),wpLink.keyInterval=setInterval(wpLink[b],wpLink.keySensitivity),a.preventDefault())},keyup:function(a){(38===a.keyCode||40===a.keyCode)&&(clearInterval(wpLink.keyInterval),a.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a},toggleInternalLinking:function(a){var b=h.wrap.hasClass("search-panel-visible");h.wrap.toggleClass("search-panel-visible",!b),setUserSetting("wplink",b?"0":"1"),h[b?"url":"search"].focus(),a.preventDefault()}},e=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(e.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),0>e?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new f(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'
  • ':"
  • ",d+='',d+='',d+=this.title?this.title:wpLinkL10n.noTitle,d+=''+this.info+"
  • ",e=!e}):g&&(d+='
  • '+wpLinkL10n.noMatchesFound+"
  • "),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c