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/panel/plugin.js | 71 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 63 insertions(+), 8 deletions(-) (limited to 'sources/plugins/panel') diff --git a/sources/plugins/panel/plugin.js b/sources/plugins/panel/plugin.js index 44129a9..816ccc4 100644 --- a/sources/plugins/panel/plugin.js +++ b/sources/plugins/panel/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 */ @@ -99,7 +99,7 @@ parentDiv = iframe.getParent(), doc = iframe.getFrameDocument(); - // Make it scrollable on iOS. (#8308) + // Make it scrollable on iOS. (http://dev.ckeditor.com/ticket/8308) CKEDITOR.env.iOS && parentDiv.setStyles( { 'overflow': 'scroll', '-webkit-overflow-scrolling': 'touch' @@ -121,7 +121,7 @@ // Register the CKEDITOR global. win.$.CKEDITOR = CKEDITOR; - // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (#4534). + // Arrow keys for scrolling is only preventable with 'keypress' event in Opera (http://dev.ckeditor.com/ticket/4534). doc.on( 'keydown', function( evt ) { var keystroke = evt.data.getKeystroke(), dir = this.document.getById( this.id ).getAttribute( 'dir' ); @@ -219,7 +219,7 @@ current = this._.currentBlock; // ARIA role works better in IE on the body element, while on the iframe - // for FF. (#8864) + // for FF. (http://dev.ckeditor.com/ticket/8864) var holder = !this.forceIFrame || CKEDITOR.env.ie ? this._.holder : this.document.getById( this.id + '_frame' ); if ( current ) @@ -300,13 +300,68 @@ var links = this.element.getElementsByTag( 'a' ); var item = links.getItem( this._.focusIndex = index ); - // Safari need focus on the iframe window first(#3389), but we need + // Safari need focus on the iframe window first(http://dev.ckeditor.com/ticket/3389), but we need // lock the blur to avoid hiding the panel. if ( CKEDITOR.env.webkit ) item.getDocument().getWindow().focus(); item.focus(); this.onMark && this.onMark( item ); + }, + + /** + * Marks the first visible item or the one whose `aria-selected` attribute is set to `true`. + * The latter has priority over the former. + * + * @private + * @param beforeMark function to be executed just before marking. + * Used in cases when any preparatory cleanup (like unmarking all items) would simultaneously + * destroy the information that is needed to determine the focused item. + */ + markFirstDisplayed: function( beforeMark ) { + var notDisplayed = function( element ) { + return element.type == CKEDITOR.NODE_ELEMENT && element.getStyle( 'display' ) == 'none'; + }, + links = this._.getItems(), + item, focused; + + for ( var i = links.count() - 1; i >= 0; i-- ) { + item = links.getItem( i ); + + if ( !item.getAscendant( notDisplayed ) ) { + focused = item; + this._.focusIndex = i; + } + + if ( item.getAttribute( 'aria-selected' ) == 'true' ) { + focused = item; + this._.focusIndex = i; + break; + } + } + + if ( !focused ) { + return; + } + + if ( beforeMark ) { + beforeMark(); + } + + if ( CKEDITOR.env.webkit ) + focused.getDocument().getWindow().focus(); + focused.focus(); + + this.onMark && this.onMark( focused ); + }, + + /** + * Returns a `CKEDITOR.dom.nodeList` of block items. + * + * @returns {*|CKEDITOR.dom.nodeList} + */ + getItems: function() { + return this.element.getElementsByTag( 'a' ); } }, @@ -340,7 +395,7 @@ } } - // If no link was found, cycle and restart from the top. (#11125) + // If no link was found, cycle and restart from the top. (http://dev.ckeditor.com/ticket/11125) if ( !link && !noCycle ) { this._.focusIndex = -1; return this.onKeyDown( keystroke, 1 ); @@ -364,11 +419,11 @@ } // Make sure link is null when the loop ends and nothing was - // found (#11125). + // found (http://dev.ckeditor.com/ticket/11125). link = null; } - // If no link was found, cycle and restart from the bottom. (#11125) + // If no link was found, cycle and restart from the bottom. (http://dev.ckeditor.com/ticket/11125) if ( !link && !noCycle ) { this._.focusIndex = links.count(); return this.onKeyDown( keystroke, 1 ); -- cgit v1.2.3