From 317f8f8f0651488f226b5280a8f036c7c135c639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 4 Dec 2017 17:54:04 +0100 Subject: Add oembed --- sources/plugins/menu/plugin.js | 59 ++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'sources/plugins/menu') diff --git a/sources/plugins/menu/plugin.js b/sources/plugins/menu/plugin.js index f5de4f9..3596e52 100644 --- a/sources/plugins/menu/plugin.js +++ b/sources/plugins/menu/plugin.js @@ -1,5 +1,5 @@ /** - * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. + * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ @@ -41,10 +41,10 @@ CKEDITOR.plugins.add( 'menu', { }; /** - * Adds one or more items from the specified definition array to the editor context menu. + * Adds one or more items from the specified definition object to the editor context menu. * * @method - * @param {Array} definitions List of definitions for each menu item as if {@link #addMenuItem} is called. + * @param {Object} definitions Object where keys are used as itemName and corresponding values as definition for a {@link #addMenuItem} call. * @member CKEDITOR.editor */ editor.addMenuItems = function( definitions ) { @@ -85,12 +85,15 @@ CKEDITOR.plugins.add( 'menu', { ' class="cke_menubutton cke_menubutton__{name} cke_menubutton_{state} {cls}" href="{href}"' + ' title="{title}"' + ' tabindex="-1"' + - '_cke_focus=1' + + ' _cke_focus=1' + ' hidefocus="true"' + ' role="{role}"' + + ' aria-label="{label}"' + + ' aria-describedby="{id}_description"' + ' aria-haspopup="{hasPopup}"' + ' aria-disabled="{disabled}"' + - ' {ariaChecked}'; + ' {ariaChecked}' + + ' draggable="false"'; // Some browsers don't cancel key events in the keydown but in the // keypress. @@ -99,11 +102,13 @@ CKEDITOR.plugins.add( 'menu', { menuItemSource += ' onkeypress="return false;"'; // With Firefox, we need to force the button to redraw, otherwise it - // will remain in the focus state. - if ( CKEDITOR.env.gecko ) - menuItemSource += ' onblur="this.style.cssText = this.style.cssText;"'; + // will remain in the focus state. Also we some extra help to prevent dragging (http://dev.ckeditor.com/ticket/10373). + if ( CKEDITOR.env.gecko ) { + menuItemSource += ( ' onblur="this.style.cssText = this.style.cssText;"' + + ' ondragstart="return false;"' ); + } - // #188 + // http://dev.ckeditor.com/ticket/188 menuItemSource += ' onmouseover="CKEDITOR.tools.callFunction({hoverFn},{index});"' + ' onmouseout="CKEDITOR.tools.callFunction({moveOutFn},{index});" ' + ( CKEDITOR.env.ie ? 'onclick="return false;" onmouseup' : 'onclick' ) + @@ -111,6 +116,7 @@ CKEDITOR.plugins.add( 'menu', { '>'; menuItemSource += + //'' + '' + '' + '' + @@ -118,16 +124,22 @@ CKEDITOR.plugins.add( 'menu', { '' + '{label}' + '' + + '{shortcutHtml}' + '{arrowHtml}' + '' + - ''; + '{ariaShortcut}'; var menuArrowSource = '' + '{label}' + ''; + var menuShortcutSource = '' + + '{shortcut}' + + ''; + var menuItemTpl = CKEDITOR.addTemplate( 'menuItem', menuItemSource ), - menuArrowTpl = CKEDITOR.addTemplate( 'menuArrow', menuArrowSource ); + menuArrowTpl = CKEDITOR.addTemplate( 'menuArrow', menuArrowSource ), + menuShortcutTpl = CKEDITOR.addTemplate( 'menuShortcut', menuShortcutSource ); /** * @class @@ -246,7 +258,7 @@ CKEDITOR.plugins.add( 'menu', { // Show the submenu. // This timeout is needed to give time for the sub-menu get - // focus when JAWS is running. (#9844) + // focus when JAWS is running. (http://dev.ckeditor.com/ticket/9844) setTimeout( function() { menu.show( element, 2 ); }, 0 ); @@ -262,7 +274,7 @@ CKEDITOR.plugins.add( 'menu', { add: function( item ) { // Later we may sort the items, but Array#sort is not stable in // some browsers, here we're forcing the original sequence with - // 'order' attribute if it hasn't been assigned. (#3868) + // 'order' attribute if it hasn't been assigned. (http://dev.ckeditor.com/ticket/3868) if ( !item.order ) item.order = this.items.length; @@ -330,7 +342,7 @@ CKEDITOR.plugins.add( 'menu', { keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB keys[ ( editor.lang.dir == 'rtl' ? 37 : 39 ) ] = CKEDITOR.env.ie ? 'mouseup' : 'click'; // ARROW-RIGHT/ARROW-LEFT(rtl) keys[ 32 ] = CKEDITOR.env.ie ? 'mouseup' : 'click'; // SPACE - CKEDITOR.env.ie && ( keys[ 13 ] = 'mouseup' ); // Manage ENTER, since onclick is blocked in IE (#8041). + CKEDITOR.env.ie && ( keys[ 13 ] = 'mouseup' ); // Manage ENTER, since onclick is blocked in IE (http://dev.ckeditor.com/ticket/8041). element = this._.element = block.element; @@ -462,7 +474,11 @@ CKEDITOR.plugins.add( 'menu', { render: function( menu, index, output ) { var id = menu.id + String( index ), state = ( typeof this.state == 'undefined' ) ? CKEDITOR.TRISTATE_OFF : this.state, - ariaChecked = ''; + ariaChecked = '', + editor = this.editor, + keystroke, + command, + shortcut; var stateName = state == CKEDITOR.TRISTATE_ON ? 'on' : state == CKEDITOR.TRISTATE_DISABLED ? 'disabled' : 'off'; @@ -478,6 +494,15 @@ CKEDITOR.plugins.add( 'menu', { if ( this.icon && !( /\./ ).test( this.icon ) ) iconName = this.icon; + if ( this.command ) { + command = editor.getCommand( this.command ); + keystroke = editor.getCommandKeystroke( command ); + + if ( keystroke ) { + shortcut = CKEDITOR.tools.keystrokeToString( editor.lang.common.keyboard, keystroke ); + } + } + var params = { id: id, name: this.name, @@ -487,13 +512,15 @@ CKEDITOR.plugins.add( 'menu', { state: stateName, hasPopup: hasSubMenu ? 'true' : 'false', disabled: state == CKEDITOR.TRISTATE_DISABLED, - title: this.label, + title: this.label + ( shortcut ? ' (' + shortcut.display + ')' : '' ), + ariaShortcut: shortcut ? editor.lang.common.keyboardShortcut + ' ' + shortcut.aria : '', href: 'javascript:void(\'' + ( this.label || '' ).replace( "'" + '' ) + '\')', // jshint ignore:line hoverFn: menu._.itemOverFn, moveOutFn: menu._.itemOutFn, clickFn: menu._.itemClickFn, index: index, iconStyle: CKEDITOR.skin.getIconStyle( iconName, ( this.editor.lang.dir == 'rtl' ), iconName == this.icon ? null : this.icon, this.iconOffset ), + shortcutHtml: shortcut ? menuShortcutTpl.output( { shortcut: shortcut.display } ) : '', arrowHtml: hasSubMenu ? menuArrowTpl.output( { label: arrowLabel } ) : '', role: this.role ? this.role : 'menuitem', ariaChecked: ariaChecked -- cgit v1.2.3