35 // If nothing's left (maybe the URL was just a fragment), use the whole URL. |
35 // If nothing's left (maybe the URL was just a fragment), use the whole URL. |
36 if ( url === '' ) { |
36 if ( url === '' ) { |
37 url = this.url; |
37 url = this.url; |
38 } |
38 } |
39 |
39 |
40 // If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with ... |
40 // If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with '...'. |
41 if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) { |
41 if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) { |
42 // If the beginning + ending are shorter that 40 chars, show more of the ending |
42 // If the beginning + ending are shorter that 40 chars, show more of the ending. |
43 if ( index + url.length - lastIndex < 40 ) { |
43 if ( index + url.length - lastIndex < 40 ) { |
44 lastIndex = -( 40 - ( index + 1 ) ); |
44 lastIndex = -( 40 - ( index + 1 ) ); |
45 } |
45 } |
46 |
46 |
47 url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex ); |
47 url = url.slice( 0, index + 1 ) + '\u2026' + url.slice( lastIndex ); |
295 editor.execCommand( 'unlink' ); |
295 editor.execCommand( 'unlink' ); |
296 editToolbar.tempHide = false; |
296 editToolbar.tempHide = false; |
297 editor.execCommand( 'wp_link_cancel' ); |
297 editor.execCommand( 'wp_link_cancel' ); |
298 } ); |
298 } ); |
299 |
299 |
300 // WP default shortcuts |
300 // WP default shortcuts. |
301 editor.addShortcut( 'access+a', '', 'WP_Link' ); |
301 editor.addShortcut( 'access+a', '', 'WP_Link' ); |
302 editor.addShortcut( 'access+s', '', 'wp_unlink' ); |
302 editor.addShortcut( 'access+s', '', 'wp_unlink' ); |
303 // The "de-facto standard" shortcut, see #27305 |
303 // The "de-facto standard" shortcut, see #27305. |
304 editor.addShortcut( 'meta+k', '', 'WP_Link' ); |
304 editor.addShortcut( 'meta+k', '', 'WP_Link' ); |
305 |
305 |
306 editor.addButton( 'link', { |
306 editor.addButton( 'link', { |
307 icon: 'link', |
307 icon: 'link', |
308 tooltip: 'Insert/edit link', |
308 tooltip: 'Insert/edit link', |
563 editor.execCommand( 'wp_link_cancel' ); |
563 editor.execCommand( 'wp_link_cancel' ); |
564 } |
564 } |
565 } ); |
565 } ); |
566 |
566 |
567 editor.addButton( 'wp_link_edit', { |
567 editor.addButton( 'wp_link_edit', { |
568 tooltip: 'Edit|button', // '|button' is not displayed, only used for context |
568 tooltip: 'Edit|button', // '|button' is not displayed, only used for context. |
569 icon: 'dashicon dashicons-edit', |
569 icon: 'dashicon dashicons-edit', |
570 cmd: 'WP_Link' |
570 cmd: 'WP_Link' |
571 } ); |
571 } ); |
572 |
572 |
573 editor.addButton( 'wp_link_remove', { |
573 editor.addButton( 'wp_link_remove', { |