Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,210 additions
and
2 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or http://ckeditor.com/license | ||
*/ | ||
|
||
( function() { | ||
'use strict'; | ||
|
||
CKEDITOR.plugins.add( 'embed', { | ||
icons: 'embed', // %REMOVE_LINE_CORE% | ||
hidpi: true, // %REMOVE_LINE_CORE% | ||
requires: 'embedbase', | ||
|
||
init: function( editor ) { | ||
var widgetDefinition = CKEDITOR.plugins.embedBase.createWidgetBaseDefinition( editor ); | ||
|
||
// Extend the base definition with additional properties. | ||
CKEDITOR.tools.extend( widgetDefinition, { | ||
// Use a dialog exposed by the embedbase plugin. | ||
dialog: 'embedBase', | ||
button: editor.lang.embedbase.button, | ||
allowedContent: 'div[!data-oembed-url]', | ||
requiredContent: 'div[data-oembed-url]', | ||
providerUrl: new CKEDITOR.template( | ||
editor.config.embed_provider || | ||
'//ckeditor.iframe.ly/api/oembed?url={url}&callback={callback}' | ||
), | ||
|
||
upcast: function( el, data ) { | ||
if ( el.name == 'div' && el.attributes[ 'data-oembed-url' ] ) { | ||
data.url = el.attributes[ 'data-oembed-url' ]; | ||
|
||
return true; | ||
} | ||
}, | ||
|
||
downcast: function( el ) { | ||
el.attributes[ 'data-oembed-url' ] = this.data.url; | ||
} | ||
}, true ); | ||
|
||
// Register the definition as 'embed' widget. | ||
editor.widgets.add( 'embed', widgetDefinition ); | ||
|
||
// Do not filter contents of the div[data-oembed-url] at all. | ||
editor.filter.addElementCallback( function( el ) { | ||
if ( 'data-oembed-url' in el.attributes ) { | ||
return CKEDITOR.FILTER_SKIP_TREE; | ||
} | ||
} ); | ||
} | ||
} ); | ||
|
||
} )(); | ||
|
||
/** | ||
* A template for URL to the provider endpoint. This URL will be queried for each resource to be embedded. | ||
* By default CKEditor uses [Iframely](https://iframely.com/) service. | ||
* | ||
* The template might use the following parameters: | ||
* | ||
* * `url` - The URL of requested media, e.g. `https://twitter.com/ckeditor/status/401373919157821441`. | ||
* * `callback` - A name of globally available callback, used for JSONP requests. | ||
* | ||
* You can read more about content providers in {@link CKEDITOR.plugins.embedBase.baseDefinition#providerUrl}. | ||
* | ||
* @since 4.5.0 | ||
* @cfg {String} [embed_provider=//ckeditor.iframe.ly/api/oembed?url={url}&callback={callback}] | ||
* @member CKEDITOR.config | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or http://ckeditor.com/license | ||
*/ | ||
|
||
/* global alert */ | ||
|
||
CKEDITOR.dialog.add( 'embedBase', function( editor ) { | ||
'use strict'; | ||
|
||
var lang = editor.lang.embedbase; | ||
|
||
return { | ||
title: lang.title, | ||
minWidth: 350, | ||
minHeight: 50, | ||
|
||
onLoad: function() { | ||
var that = this, | ||
okButton = that.getButton( 'ok' ); | ||
|
||
this.on( 'ok', function( evt ) { | ||
// We're going to hide it manually, after remote response is fetched. | ||
evt.data.hide = false; | ||
|
||
// Disable the OK button for the time of loading, so user can't trigger multiple inserts. | ||
okButton.disable(); | ||
|
||
// We don't want the widget system to finalize widget insertion (it happens with priority 20). | ||
evt.stop(); | ||
|
||
var url = that.getValueOf( 'info', 'url' ); | ||
|
||
that.widget.loadContent( url, { | ||
noNotifications: true, | ||
|
||
callback: function() { | ||
if ( !that.widget.isReady() ) { | ||
editor.widgets.finalizeCreation( that.widget.wrapper.getParent( true ) ); | ||
} | ||
|
||
editor.fire( 'saveSnapshot' ); | ||
|
||
okButton.enable(); | ||
that.hide(); | ||
}, | ||
|
||
errorCallback: function( messageTypeOrMessage ) { | ||
that.getContentElement( 'info', 'url' ).select(); | ||
|
||
// We need to enable the OK button so user can fix the URL. | ||
okButton.enable(); | ||
|
||
alert( that.widget.getErrorMessage( messageTypeOrMessage, url, 'Given' ) ); | ||
} | ||
} ); | ||
}, null, null, 15 ); | ||
}, | ||
|
||
contents: [ | ||
{ | ||
id: 'info', | ||
|
||
elements: [ | ||
{ | ||
type: 'text', | ||
id: 'url', | ||
label: lang.url, | ||
|
||
setup: function( widget ) { | ||
this.setValue( widget.data.url ); | ||
}, | ||
|
||
validate: function() { | ||
if ( !this.getDialog().widget.isUrlValid( this.getValue() ) ) { | ||
return lang.unsupportedUrlGiven; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
For licensing, see LICENSE.md or http://ckeditor.com/license | ||
*/ | ||
CKEDITOR.plugins.setLang( 'embedbase', 'en', { | ||
pathName: 'media object', | ||
title: 'Media Embed', | ||
url: 'URL', | ||
button: 'Insert Media Embed', | ||
unsupportedUrlGiven: 'The given URL is not supported.', | ||
unsupportedUrl: 'The URL {url} is not supported by Media Embed.', | ||
fetchingFailedGiven: 'Failed to fetch content for the given URL.', | ||
fetchingFailed: 'Failed to fetch content for {url}.', | ||
fetchingOne: 'Fetching oEmbed response...', | ||
fetchingMany: 'Fetching oEmbed responses, {current} of {max} done...' | ||
} ); |
Oops, something went wrong.